############################################################
###                 Technologies : other                 ###
############################################################

# ── Orbital Power Stations				: unlocks advanced reactor for starfortresses
# ── Stellar Energy Tower				: unique power plant; requires killed Stellarite Devourer / Leviathans DLC
# ── Quantum Computation Node			: unique science laboratory; requires 'greeted' Infinity Machine / Leviathans DLC
# ── Reprocessing Plant					: unique building for managing resources; requires killed Scrapper Bot / Distant Stars DLC
# ── Zro Distilleries					: unlocks building for zro production
# ── Dark Matter Drawing Facilities		: unlocks building for dark matter production
# ┬─ Planetary Core Mining				: unlocks special mining building for ecumenopolis
# └─ Impr. Planetary Core Mining		: unlocks andvanced version of the Mantle Mining Facility
# ── Colossal Creature Cloning 			: unlocks Dragon Hatchery building
# ── Precursor Armaments				: unlocks special aux slot component
# ── Bio-Horror Armies					: bio-ascension armies
# ── Psionic Avatar Armies				: psi-ascension armies

# ┬─ Neutronium-Infused Mandibles		: unlocks tier 4 mandibles
# ├─ Adamantine Mandibles				: unlocks tier 5 mandibles
# └─ Cybernetically-Enhanced Mandibles	: unlocks cybernetic mandibles
#     └─ Bionic Mandibles				: unlocks andvanced cybernetic mandibles

############################################################
##                 Orbital Power Station                  ##
############################################################

esc_tech_orbital_powerplant = {
	area = physics
	category = { industry }
	tier = 4
	cost = @tier4cost3
	weight = @tier4weight3
	prerequisites = { "tech_starbase_4" "tech_zero_point_power" }

	modifier = {
		starbase_constructions_energy_produces_mult = 0.10
	}

	weight_modifier = {
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
	}
}

############################################################
##                Stellar Enengy Tower                    ##
############################################################

esc_tech_stellar_energy_tower = {
	area = physics
	category = { field_manipulation }
	tier = 4
	cost = @tier4cost2
	weight = @tier4weight2
	ai_update_type = all
	prerequisites = { }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_stellarite_tech_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOT = { has_country_flag = ESC_COUNTRY_FLAG_killed_stellarite_devourer }
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			NOT = { has_country_flag = ESC_COUNTRY_FLAG_killed_stellarite_devourer }
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}
}

############################################################
##               Quantum Computation Node                 ##
############################################################

esc_tech_quantum_node = {
	area = physics
	category = { computing }
	tier = 4
	cost = @tier4cost2
	weight = @tier4weight2
	prerequisites = {  }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_technosphere_tech_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOT = { has_country_flag = technosphere_studied }
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_quantum_node }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			NOT = { has_country_flag = technosphere_studied }
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_quantum_node }
			}
		}
	}
}

############################################################
##                    Reprocessing Plant                  ##
############################################################

esc_tech_reprocessing_plant = {
	area = engineering
	category = { materials }
	tier = 4
	cost = @tier4cost2
	weight = @tier4weight2
	prerequisites = {  }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_scrapper_tech_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOT = { has_country_flag = scrapper_killed }
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			NOT = { has_country_flag = scrapper_killed }
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}
}

############################################################
##                    Zro Distilleries                    ##
############################################################

esc_tech_zro_distilleries = {
	area = engineering
	category = { materials }
	tier = 3
	cost = @tier3cost3
	weight = @tier3weight3
	prerequisites = { "esc_tech_grand_research_initiative" }
	is_rare = yes

	potential = {
		ESC_TRIGGER_may_research_psionic_weapons_basic = yes
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_psionic_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOT = {
				has_technology = esc_tech_psionic_weapons
			}
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_zro_distilleries }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			NOT = {
				has_technology = esc_tech_psionic_weapons
			}
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_zro_distilleries }
			}
		}
	}
}

############################################################
##              Dark Matter Drawing Facilities            ##
############################################################

esc_tech_dark_matter_facilities = {
	area = physics
	category = { field_manipulation }
	tier = 4
	cost = @tier4cost3
	weight = @tier4weight3
	prerequisites = { "tech_mine_dark_matter" "esc_tech_grand_research_initiative" }
	is_rare = yes

	potential = {
		NOR = {
			has_global_flag = ESC_GLOBAL_FLAG_chronospatial_weapons_forbidden
			has_global_flag = ESC_GLOBAL_FLAG_enigmatic_weapons_forbidden
			has_global_flag = ESC_GLOBAL_FLAG_gravitic_weapons_forbidden
		}
	}

	weight_modifier = {
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_dark_matter_facilities }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier #strategic resource
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_dark_matter_facilities }
			}
		}
	}
}

############################################################
##                 Planetary Core Mining                  ##
############################################################

esc_tech_magmaminer_1 = {
	area = engineering
	category = { industry }
	tier = 5
	cost = @tier5cost2
	weight = @tier5weight2
	prerequisites = { "tech_mega_engineering" "esc_tech_advanced_materials" }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_mantle_mining_facility_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 1.25
			OR = {
				has_trait_in_council = { TRAIT = leader_trait_curator }
				has_trait_in_council = { TRAIT = leader_trait_maniacal }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_2 }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_3 }
			}
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_magmaminer_1 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.25
			OR = {
				has_trait_in_council = { TRAIT = leader_trait_curator }
				has_trait_in_council = { TRAIT = leader_trait_maniacal }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_2 }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_3 }
			}
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_magmaminer_1 }
			}
		}
	}
}

############################################################
##             Improved Planetary Core Mining             ##
############################################################

esc_tech_magmaminer_2 = {
	area = engineering
	category = { industry }
	tier = 5
	cost = @tier5cost3
	weight = @tier5weight3
	prerequisites = { "esc_tech_magmaminer_1" }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_mantle_mining_facility_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 1.25
			OR = {
				has_trait_in_council = { TRAIT = leader_trait_curator }
				has_trait_in_council = { TRAIT = leader_trait_maniacal }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_2 }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_3 }
			}
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_magmaminer_2 }
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.25
			OR = {
				has_trait_in_council = { TRAIT = leader_trait_curator }
				has_trait_in_council = { TRAIT = leader_trait_maniacal }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_2 }
				has_trait_in_council = { TRAIT = leader_trait_maniacal_3 }
			}
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
		modifier = {
			factor = @federation_perk_factor
			has_federation = yes
			federation = {
				has_federation_perk = rare_tech_boost
				any_member = { has_technology = esc_tech_magmaminer_2 }
			}
		}
	}
}

############################################################
##              Colossal Creature Cloning                 ##
############################################################

esc_tech_dragon_hatchery = {
	area = society
	category = { biology }
	tier = 5
	cost = @tier5cost3
	weight = @ESC_TECH_tier6_weight1
	is_rare = yes
	prerequisites = { "tech_cloning" "tech_gene_tailoring" }

	potential = {
		#NOT = { has_global_flag = ESC_GLOBAL_FLAG_ether_dragon_tech_forbidden }
		NOT = { has_valid_civic = civic_machine_terminator }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOT = { has_country_flag = ESC_COUNTRY_FLAG_killed_ether_drake }
		}
		modifier = {
			factor = 0
			AND = {
				OR = {
					is_machine_empire = no
					has_valid_civic = civic_machine_servitor
					has_valid_civic = civic_machine_assimilator
				}
				NAND = {
					has_technology = tech_cloning
					has_technology = tech_gene_tailoring
				}
			}
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			NOT = { has_country_flag = ESC_COUNTRY_FLAG_killed_ether_drake }
		}
		modifier = {
			factor = 0
			AND = {
				OR = {
					is_machine_empire = no
					has_valid_civic = civic_machine_servitor
					has_valid_civic = civic_machine_assimilator
				}
				NAND = {
					has_technology = tech_cloning
					has_technology = tech_gene_tailoring
				}
			}
		}
	}
}

############################################################
##                   Precursor Armaments                  ##
############################################################

esc_tech_precursor_armaments = {
	area = physics
	category = { field_manipulation }
	tier = 7
	cost = @ESC_TECH_tier7_cost1
	weight = 0 # can only be found in FE debris if playing with ESC overwrites
	ai_update_type = all
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_auxiliary_forbidden }
	}
}

############################################################
##                    Bio-Horror Armies                   ##
############################################################

esc_tech_bio_horror_army = {
	area = society
	category = { biology }
	tier = 5
	cost = @tier5cost1
	weight = @tier5weight1
	prerequisites = { "esc_tech_biological_weapons" "tech_morphogenetic_field_mastery" }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_biological_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_biological_weapons_advanced = no
		}
		modifier = {
			factor = 2
			is_hive_empire = yes
			is_lithoid_empire = no
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_biological_weapons_advanced = no
		}
		modifier = {
			factor = 2
			is_hive_empire = yes
			is_lithoid_empire = no
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}
}

############################################################
##                 Psionic Avatar Armies                  ##
############################################################

esc_tech_psi_avatar_army = {
	area = society
	category = { psionics }
	tier = 5
	cost = @tier5cost1
	weight = @tier5weight1
	prerequisites = { "esc_tech_psionic_weapons" }
	is_rare = yes

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_psionic_weapons_forbidden }
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_psionic_weapons_advanced = no
		}
		modifier = {
			factor = 2
			is_hive_empire = yes
			is_lithoid_empire = no
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_psionic_weapons_advanced = no
		}
		modifier = {
			factor = 2
			is_hive_empire = yes
			is_lithoid_empire = no
		}
		modifier = {
			factor = @ESC_TECH_Technology_Ascendancy_weight_modifier
			has_ascension_perk = ap_technological_ascendancy
		}
	}
}

############################################################
##              Neutronium-Infused Mandibles              ##
############################################################

esc_tech_mandibles_4 = {
	area = engineering
	cost = @tier4cost3
	weight = @tier4weight3
	tier = 4
	category = { materials }
	ai_update_type = military
	prerequisites = { tech_mandibles_3 esc_tech_new_age_warfare }

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_adv_vanilla_creature_weapons_forbidden }
		country_uses_bio_ships = yes
	}

	weight_modifier = {
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}
}

############################################################
##                  Adamantine Mandibles                  ##
############################################################

esc_tech_mandibles_5 = {
	area = engineering
	cost = @tier5cost2
	weight = @tier5weight2
	tier = 5
	category = { materials }
	ai_update_type = military
	prerequisites = { esc_tech_mandibles_4 }

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_adv_vanilla_creature_weapons_forbidden }
		country_uses_bio_ships = yes
	}

	weight_modifier = {
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}
}

############################################################
##            Cybernetically-Enhanced Mandibles           ##
############################################################

esc_tech_mandibles_cyber_1 = {
	area = engineering
	cost = @tier5cost2
	weight = @tier5weight2
	tier = 5
	category = { materials }
	ai_update_type = military
	prerequisites = { esc_tech_mandibles_4 }

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_adv_vanilla_creature_weapons_forbidden }
		country_uses_bio_ships = yes
	}

	weight_modifier = {
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_cybernetic_amoeba = no
		}
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 0
			ESC_TRIGGER_may_research_cybernetic_amoeba = no
		}
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}
}

############################################################
##                    Bionic Mandibles                    ##
############################################################

esc_tech_mandibles_cyber_2 = {
	area = engineering
	cost = @ESC_TECH_tier6_cost1
	weight = @ESC_TECH_tier6_weight1
	tier = 6
	category = { materials }
	ai_update_type = military
	prerequisites = { esc_tech_mandibles_cyber_1 }

	potential = {
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_adv_vanilla_creature_weapons_forbidden }
		country_uses_bio_ships = yes
	}

	weight_modifier = {
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}

	ai_weight = {
		factor = @ESC_AI_tech_weight_multiplier
		modifier = {
			factor = 1.25
			has_ethic = ethic_militarist
		}
		modifier = {
			factor = 1.5
			has_ethic = ethic_fanatic_militarist
		}
	}
}
