# See traditions/README.txt for format.
# Updated Perk list for the Expanded Stellaris Ascension Perks Mod.
# Includes all perks in the mod, as well as in the vanilla game. Mods are re-ordered to appear in a sensible order in the i-game perk list.

#######################
### ASCENSION PATHS ###
#######################

### Biological Ascension ###

ap_esap_bio_bonus = {
	possible = {
		custom_tooltip = {
			fail_text = "requires_ap_engineered_evolution"
			has_ascension_perk = ap_engineered_evolution
		}
	}
	modifier = {
		planet_jobs_food_upkeep_mult = -0.05
		logistic_growth_mult = 0.05
		bonus_pop_growth_mult = 0.10
	}
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_bio_bonus
			has_authority = "auth_machine_intelligence"
		}
	}

	ai_weight = {
		factor = 15
	}
}

### Cybernetic Ascension ###

ap_esap_cyber_bonus = {
	possible = {
		OR = {
			has_ascension_perk = ap_the_flesh_is_weak
			has_origin = origin_cybernetic_creed
			has_origin = origin_synthetic_fertility
			has_origin = origin_unplugged
			owner_main_species = { is_robotic = yes }
		}
	}
	modifier = {
		country_unity_produces_mult = 0.10
		pop_government_ethic_attraction = 0.50
	}

	potential = {
		NOR = {
			has_ascension_perk = ap_esap_cyber_bonus
			is_machine_empire = yes
		}
	}
	
	ai_weight = {
		factor = 15
	}
}

### Psionic Ascension ###

ap_esap_psi_bonus = {
	on_enabled = { 
		custom_tooltip = ap_esap_psi_bonus_tooltip
		hidden_effect = {
			every_country = {
				limit = {
					is_at_war_with = root
					NOR = {
						has_modifier = mod_esap_psi_1
						is_gestalt = yes
					}
				}
				add_modifier = {
					modifier = "mod_esap_psi_1"
					days = -1
				}				
			}
			if = {
				limit = {
					Not = { has_global_flag = flag_esap_psi_1_picked }
				}
				set_global_flag = flag_esap_psi_1_picked
			}
		}
	}

	modifier = {
		ship_fire_rate_mult = 0.05
		army_morale_damage_mult = 0.33
	}

	possible = {
		if = {
			limit = { has_origin = origin_shroudwalker_apprentice }
			custom_tooltip = {
				fail_text = "requires_technology_psionic_theory"
				has_technology = tech_psionic_theory
			}
		}
		else = {
			custom_tooltip = {
				fail_text = "requires_ap_mind_over_matter"
				has_ascension_perk = ap_mind_over_matter
			}
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_psi_bonus
			has_authority = "auth_machine_intelligence"
		}
	}
	
	ai_weight = {
		factor = 15
		modifier = {
			factor = 0
			esap_AI_no_passive_aggressive_perks = yes
		}	
	}
}

#########################
### COMBINATION PATHS ###
#########################

### Tier 1 ###

ap_esap_ct1_war = {
	on_enabled = {
		custom_tooltip = ap_esap_ct1_war_tooltip
		hidden_effect = {
			every_owned_leader = {
				owner = {
					country_event = {
						id = esap_combination_t1.1
						scopes = { 
							from = prev
						}
					}
				}
			}
			every_pool_leader = {
				owner = {
					country_event = {
						id = esap_combination_t1.1
						scopes = { 
							from = prev
						}
					}
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct1_war_req_1"
			max_naval_capacity > 99
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct1_war_req_2"
			NOT = {
				has_ascension_perk = ap_esap_ct3_not_war
			}
		}
	}

	modifier = {
		ship_weapon_range_mult = 0.05
		ship_experience_gain_mult = 0.50
		army_experience_gain_mult = 0.50
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct1_war
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct1_expansion = {
	on_enabled = {
		if = {
			limit = {
				NOT = { has_technology = tech_wormhole_stabilization }
			}
			add_tech_progress = { 
				tech = tech_wormhole_stabilization
				progress = 0.66
			}
		}
		custom_tooltip = ap_esap_ct1_expansion_tooltip
	} 	# Cornucopia handled on_action - on_colonized

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct1_expansion_req_1"
			# Old trigger - caused the perk to be picked early WHILE a third colonization process was ongoing.
			# num_owned_planets > 2
			count_owned_planet = {
				count >= 3 
				limit = { is_under_colonization = no }
			}
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct1_expansion_req_2"
			NOT = {
				has_ascension_perk = ap_esap_ct3_not_expansion
			}
		}
	}

	# Delegated to POLICY EFFECTS - Settler Policies
	# modifier = {
	# 	planet_colony_development_speed_mult = 0.50
	# }
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct1_expansion
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct1_diplomacy = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct1_diplomacy_tooltip
	}

	possible = {
		if = {
			limit = {
				is_ai = no
			}
			custom_tooltip = {
				fail_text = "ap_esap_ct1_diplomacy_req_1"
				diplomacy_weight >= 9000
			}
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct1_diplomacy_req_2"
			NOT = {
				has_ascension_perk = ap_esap_ct3_not_diplomacy
			}
		}
	}

	modifier = {
		envoys_add = 3
	}

	# Increases diplomatic weight for each delegate's level, buffed for AI for fun situations.
	triggered_modifier = {
		potential = {
			is_ai = no
		}
		diplo_weight_delegate_mult = 0.10
	}

	triggered_modifier = {
		potential = {
			is_ai = yes
		}
		diplo_weight_delegate_mult = 0.20
	}
	
	potential = {
		NOT = { has_ascension_perk = ap_esap_ct1_diplomacy }
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct1_finance = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct1_finance_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct1_finance_req_1"
			has_resource = { 
				type = energy 
				amount > 2499
			}
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct1_finance_req_2"
			NOT = {
				has_ascension_perk = ap_esap_ct3_not_finance
			}
		}
	}

	modifier = {
		# description = ap_esap_ct1_finance_tooltip
		country_trade_produces_mult = 0.10
		country_trade_attractiveness = 0.10
		ship_military_trade_upkeep_mult = -0.10 	# Brand New Modifier with loc
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct1_finance
		}
	}
	
	ai_weight = {
		factor = 9
		modifier = {
			factor = 2
			is_megacorp = yes
		}
	}
}

ap_esap_ct1_infrastructure = {
	on_enabled = {
		custom_tooltip = ap_esap_ct1_infrastructure_tooltip
		hidden_effect = {
			every_owned_colony = {
				if = {
					limit = { 
						num_free_districts = { 
							type = any
							value < 1
						} 
					}
					add_modifier = {
						modifier = "mod_esap_ct1_infrastructure"
						days = -1
					}
				}
			}
		}
		if = {
			limit = {
				mid_game_years_passed < 1
			}
			custom_tooltip = ap_esap_ct1_infrastructure_tooltip_midgame
		}
		if = {
			limit = {
				end_game_years_passed < 1
			}
			custom_tooltip = ap_esap_ct1_infrastructure_tooltip_endgame
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct1_infrastructure_req_1"
			capital_scope = {
				num_buildings = { 
					type = any
					value > 9 
				}
			}
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct1_infrastructure_req_2"
			NOT = {
				has_ascension_perk = ap_esap_ct3_not_infrastructure
			}
		}
	}

	modifier = {
		planet_building_capacity_add = 0
		planet_non_artificial_max_districts_add = 2
	}

	triggered_modifier = {
		potential = {
			mid_game_years_passed > 0
			end_game_years_passed < 1
		}
		planet_building_capacity_add = 1
	}

	triggered_modifier = {
		potential = {
			end_game_years_passed > 0
		}
		planet_building_capacity_add = 2
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct1_infrastructure
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

### Tier 2 ###

ap_esap_ct2_war_expansion = {
	on_enabled = {
		custom_tooltip = ap_esap_ct2_war_expansion_tooltip
		hidden_effect = {
			if = {
				limit = {
					NOT = { has_global_flag = flag_esap_ct2_war_expansion_picked }
				}
				set_global_flag = flag_esap_ct2_war_expansion_picked
			}

		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct2_war_expansion_req_1"
			has_ascension_perk = ap_esap_ct1_war
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct2_war_expansion_req_2"
			has_ascension_perk = ap_esap_ct1_expansion
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct2_war_expansion
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct2_expansion_diplomacy = {
	on_enabled = {
		custom_tooltip = ap_esap_ct2_expansion_diplomacy_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct2_expansion_diplomacy_req_1"
			has_ascension_perk = ap_esap_ct1_expansion
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct2_expansion_diplomacy_req_2"
			has_ascension_perk = ap_esap_ct1_diplomacy
		}
	}

	modifier = {
		empire_size_penalty_mult = -0.20
		empire_size_pops_mult = -0.25
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct2_expansion_diplomacy
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct2_diplomacy_finance = {
	on_enabled = {
		custom_tooltip = ap_esap_ct2_diplomacy_finance_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct2_diplomacy_finance_req_1"
			has_ascension_perk = ap_esap_ct1_diplomacy
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct2_diplomacy_finance_req_2"
			has_ascension_perk = ap_esap_ct1_finance
		}
	}

	modifier = {
		planet_jobs_trade_produces_mult = 0.10
		planet_civilians_unity_produces_add = 1
		planet_civilians_consumer_goods_upkeep_add = 0.25
		planet_traders_unity_produces_add = 1
		commercial_pact_mult = 0.50
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct2_diplomacy_finance
		}
	}
	
	ai_weight = {
		factor = 9
		modifier = {
			factor = 2
			is_megacorp = yes
		}		
	}
}

ap_esap_ct2_finance_infrastructure = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct2_finance_infrastructure_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct2_finance_infrastructure_req_1"
			has_ascension_perk = ap_esap_ct1_finance
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct2_finance_infrastructure_req_2"
			has_ascension_perk = ap_esap_ct1_infrastructure
		}
	}

	modifier = {
		planet_jobs_trade_produces_mult = 0.10
		planet_buildings_exotic_gases_upkeep_mult = -0.50
		planet_buildings_rare_crystals_upkeep_mult = -0.50
		planet_buildings_volatile_motes_upkeep_mult = -0.50
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct2_finance_infrastructure
		}
	}
	
	ai_weight = {
		factor = 9
		modifier = {
			factor = 2
			is_megacorp = yes
		}
	}
}

ap_esap_ct2_infrastructure_war = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct2_infrastructure_war_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct2_infrastructure_war_req_1"
			has_ascension_perk = ap_esap_ct1_infrastructure
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct2_infrastructure_war_req_2"
			has_ascension_perk = ap_esap_ct1_war
		}
	}

	modifier = {
		country_starbase_capacity_mult = 0.50
		shipclass_starbase_hull_mult = 0.10
		ship_military_trade_upkeep_mult = -0.10
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct2_infrastructure_war
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

### Tier 3 ###

ap_esap_ct3_not_war = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct3_not_war_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_war_req_1"
			has_ascension_perk = ap_esap_ct2_expansion_diplomacy
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_war_req_2"
			has_ascension_perk = ap_esap_ct2_finance_infrastructure
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_war_req_3"
			NOT = {
				has_ascension_perk = ap_esap_ct1_war
			}
		}
	}

	modifier = {
		logistic_growth_mult = 0.05
		bonus_pop_growth_mult = 0.05
		planet_jobs_produces_mult = 0.05
		country_starbase_influence_cost_mult = -0.10
		# all_technology_research_speed = 0.025	
		# ships_upkeep_mult = 0.25
		# armies_upkeep_mult = 0.25
		# country_naval_cap_mult = -0.25
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct3_not_war
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct3_not_expansion = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct3_not_expansion_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_expansion_req_1"
			has_ascension_perk = ap_esap_ct2_diplomacy_finance
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_expansion_req_2"
			has_ascension_perk = ap_esap_ct2_infrastructure_war
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_expansion_req_3"
			NOT = {
				has_ascension_perk = ap_esap_ct1_expansion
			}
		}
	}

	modifier = {
		country_unity_produces_mult = 0.10
		planet_jobs_specialist_produces_mult = 0.10
		planet_stability_add = 2.5
		# empire_size_penalty_mult = 0.50
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct3_not_expansion
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct3_not_diplomacy = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct3_not_diplomacy_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_diplomacy_req_1"
			has_ascension_perk = ap_esap_ct2_finance_infrastructure
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_diplomacy_req_2"
			has_ascension_perk = ap_esap_ct2_war_expansion
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_diplomacy_req_3"
			NOT = {
				has_ascension_perk = ap_esap_ct1_diplomacy
			}
		}
	}

	modifier = {
		description = ap_esap_ct3_not_diplomacy_tooltip
		planet_army_build_speed_mult = 0.50
		starbase_shipyard_build_speed_mult = 0.50
		country_naval_cap_mult = 0.20
		command_limit_mult = 0.20
		country_border_friction_mult = 1.0
		#	Opinion -50
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct3_not_diplomacy
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct3_not_finance = {
	on_enabled = {
		#custom_tooltip = ap_esap_ct3_not_finance_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_finance_req_1"
			has_ascension_perk = ap_esap_ct2_infrastructure_war
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_finance_req_2"
			has_ascension_perk = ap_esap_ct2_expansion_diplomacy
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_finance_req_3"
			NOT = {
				has_ascension_perk = ap_esap_ct1_finance
			}
		}
	}

	modifier = {
		pop_government_ethic_attraction = 1.0
		refugee_attraction = 0.50
		edicts_upkeep_mult = -0.20
		edicts_cost_mult = -0.20
		country_unity_produces_mult = 0.10
		pop_amenities_usage_mult = 0.10
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct3_not_finance
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_ct3_not_infrastructure = {
	on_enabled = {
		custom_tooltip = ap_esap_ct3_not_infrastructure_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_infrastructure_req_1"
			has_ascension_perk = ap_esap_ct2_war_expansion
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_infrastructure_req_2"
			has_ascension_perk = ap_esap_ct2_diplomacy_finance
		}
		custom_tooltip = {
			fail_text = "ap_esap_ct3_not_infrastructure_req_3"
			NOT = {
				has_ascension_perk = ap_esap_ct1_infrastructure
			}
		}
	}

	modifier = {
		ships_upkeep_mult = -0.05
		ship_speed_mult = 0.05
		ship_fire_rate_mult = 0.05
		planet_jobs_upkeep_mult = -0.05
		country_claim_influence_cost_mult = -0.10
		country_war_exhaustion_mult = -0.25
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_ct3_not_infrastructure
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

###############################
### TECHNOLOGICAL ASCENDACY ###
###############################

ap_esap_technological_ascendancy_bonus_1 = {
	on_enabled = {
		custom_tooltip = ap_esap_technological_ascendancy_bonus_1_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_technological_ascendancy_bonus_1_req_1"
			has_ascension_perk = ap_technological_ascendancy
		}
		custom_tooltip = {
			fail_text = "ap_esap_technological_ascendancy_bonus_1_req_2"
			num_rare_techs > 9
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_technological_ascendancy_bonus_1
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

ap_esap_technological_ascendancy_bonus_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_technological_ascendancy_bonus_2_tooltip
		hidden_effect = {
			country_event = {
				id = esap_technological_ascendancy.1
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_technological_ascendancy_bonus_2_req_1"
			has_ascension_perk = ap_technological_ascendancy
		}
		custom_tooltip = {
			fail_text = "ap_esap_technological_ascendancy_bonus_2_req_2"
			OR = {
				has_technology = tech_repeatable_improved_tile_mineral_output
				has_technology = tech_repeatable_improved_military_station_damage
				has_technology = tech_repeatable_improved_military_station_health
				has_technology = tech_repeatable_improved_armor_output
				has_technology = tech_repeatable_weapon_type_explosive_damage
				has_technology = tech_repeatable_weapon_type_explosive_fire_rate
				has_technology = tech_repeatable_weapon_type_kinetic_damage
				has_technology = tech_repeatable_weapon_type_kinetic_fire_rate
				has_technology = tech_repeatable_weapon_type_strike_craft_fire_damage
				has_technology = tech_repeatable_weapon_type_strike_craft_fire_rate
				has_technology = tech_repeatable_reduced_building_time
				
				has_technology = tech_repeatable_improved_tile_energy_output
				has_technology = tech_repeatable_improved_shield_output
				has_technology = tech_repeatable_weapon_type_energy_damage
				has_technology = tech_repeatable_weapon_type_energy_fire_rate
				has_technology = tech_repeatable_reduced_building_cost
				
				has_technology = tech_repeatable_improved_tile_food_output
				has_technology = tech_repeatable_improved_core_system_cap
				has_technology = tech_repeatable_improved_army_damage
				has_technology = tech_repeatable_improved_army_health
				has_technology = tech_repeatable_improved_leader_life_span
				has_technology = tech_repeatable_naval_cap
				has_technology = tech_repeatable_command_limit
				has_technology = tech_repeatable_improved_starbase_capacity
			}
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_technological_ascendancy_bonus_2
		}
	}
	
	ai_weight = {
		factor = 9
	}
}

#########################
### NATURAL ASCENDACY ###
#########################

ap_esap_nature = {
	on_enabled = {
		custom_tooltip = ap_esap_nature_tooltip
		hidden_effect = {
			every_owned_colony = {
				carrier_event = {
					id = esap_nature_ascendancy.1
				}			
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
		# custom_tooltip = {
		# 	fail_text = "ap_esap_nature_req_1"
		# 	NOT = {
		# 		has_ascension_perk = ap_esap_mining	
		# 	}
		# }
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_nature
		}
	}

	modifier = {
		category_new_worlds_research_speed_mult = 0.05
		resolution_category_ecology_vote_strength_mult = 0
		add_attunement_the_composer_of_strands = @ascension_perk_attunement1
	}

	triggered_modifier = {
		potential = { 
			is_diplomatic = yes
		}
		resolution_category_ecology_vote_strength_mult = 0.25
	}
	
	ai_weight = {
		factor = 5
	}
}

ap_esap_garden = {
	on_enabled = {
		custom_tooltip = ap_esap_garden_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
		# custom_tooltip = {
		# 	fail_text = "ap_esap_garden_req_1"
		# 	Not = {
		# 		has_ascension_perk = ap_esap_mining	
		# 	}
		# }
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_garden
		}
	}

	modifier = {
		planet_farmers_unity_produces_add = 0.25
		resolution_category_ecology_vote_strength_mult = 0
		add_attunement_the_composer_of_strands = @ascension_perk_attunement1
	}

	triggered_modifier = {
		potential = { 
			is_diplomatic = yes
		}
		resolution_category_ecology_vote_strength_mult = 0.25
	}
	
	ai_weight = {
		factor = 5
	}
}

############################
### INDUSTRIAL ASCENDACY ###
############################

ap_esap_mining = {
	on_enabled = {
		custom_tooltip = ap_esap_mining_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
		# custom_tooltip = {			
		# 	fail_text = "ap_esap_mining_req_1"
		# 	Not = { has_ascension_perk = ap_esap_nature }
		# }
		custom_tooltip = {
			fail_text = "ap_esap_mining_req_2"
			has_technology = tech_mining_3
		}
	}

	modifier = {
		planet_miners_unity_produces_add = 0.25
		resolution_category_industry_vote_strength_mult = 0
		add_attunement_the_instrument_of_desire = @ascension_perk_attunement1
	}	

	triggered_modifier = {
		potential = { 
			is_diplomatic = yes
		}
		resolution_category_industry_vote_strength_mult = 0.25
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_mining
		}
	}
	
	ai_weight = {
		factor = 5
	}
}

ap_esap_industry = {
	on_enabled = {
		if = {
			limit = { is_regular_empire = yes }
			custom_tooltip = ap_esap_industry_tooltip
		}
		if = {
			limit = { is_hive_empire = yes }
			custom_tooltip = ap_esap_industry_hive_tooltip
		}
		if = {
			limit = { 
				is_machine_empire = yes }
			custom_tooltip = ap_esap_industry_machines_tooltip
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_3"
			num_ascension_perks > 2
		}
		# custom_tooltip = {
		# 	fail_text = "ap_esap_industry_req_1"
		# 	has_ascension_perk = ap_esap_mining
		# }
		custom_tooltip = {
			fail_text = "ap_esap_industry_req_2"
			has_technology = tech_alloys_2
		}
	}

	modifier = {
		resolution_category_industry_vote_strength_mult = 0
		add_attunement_the_instrument_of_desire = @ascension_perk_attunement1
	}

	triggered_modifier = {
		potential = { 
			is_diplomatic = yes
		}
		resolution_category_industry_vote_strength_mult = 0.25
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_industry
		}
	}
	
	ai_weight = {
		factor = 5
	}
}

###################
### ETHIC PERKS ###
###################

### Base Ethic ###
ap_esap_authoritarian_1 = {
	on_enabled = {
		#custom_tooltip = ap_esap_authoritarian_1_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
	}

	modifier = {
		pop_cat_ruler_political_power = 2.0
		planet_jobs_ruler_produces_mult = 0.25
		diplo_weight_mult = 0.05
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_authoritarian_1
		}
		OR = {
			has_ethic = ethic_authoritarian
			has_ethic = ethic_fanatic_authoritarian
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

ap_esap_egalitarian_1 = {
	on_enabled = {
		custom_tooltip = ap_esap_egalitarian_1_tooltip
		hidden_effect = {
			every_owned_colony = {
				if = {
					limit = { happiness_planet < 70 }
					add_modifier = {
						modifier = "mod_esap_egalitarian_1"
						days = -1
					}
				}
			}
		}
	}

	modifier = {
		pop_factions_produces_mult = 0.25
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_egalitarian_1
		}
		OR = {
			has_ethic = ethic_egalitarian
			has_ethic = ethic_fanatic_egalitarian
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

ap_esap_xenophile_1 = {
	# on_enabled = {
	# 	custom_tooltip = ap_esap_xenophile_1_tooltip
	# }

	modifier = {
		envoy_improve_relations_mult = 0.50
		country_trust_growth = 0.25
		country_trust_cap_add = 50
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
	}

	potential = {
		NOT = {
			has_ascension_perk = ap_esap_xenophile_1
		}
		OR = {
			has_ethic = ethic_xenophile
			has_ethic = ethic_fanatic_xenophile
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

ap_esap_militarist_1 = {
	on_enabled = {
		custom_tooltip = ap_esap_militarist_1_tooltip
		hidden_effect = {
			every_owned_ship = {
				ship_event = {
					id = esap_ethics.3
				}
			}
		}
	}

	modifier = {
		shipsize_corvette_build_speed_mult = 0.20
		shipsize_destroyer_build_speed_mult = 0.20
		shipsize_cruiser_build_speed_mult = 0.20
		ship_corvette_cost_mult = 0.05 
		ship_destroyer_cost_mult = 0.05
		ship_cruiser_cost_mult = 0.05
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
		custom_tooltip = {
			fail_text = "ap_esap_militarist_1_req_1"
			has_technology = tech_battleships
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_militarist_1
		}
		OR = {
			has_ethic = ethic_militarist
			has_ethic = ethic_fanatic_militarist
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

ap_esap_pacifist_1 = {
	on_enabled = {
		custom_tooltip = ap_esap_pacifist_1_tooltip
	}

	modifier = {
		diplo_weight_mult = 0.25
		country_base_influence_produces_add = 1
		defensive_war_influence_gain_add = 2
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
		is_galactic_community_formed = yes
	}

	potential = {
		NOT = {
			has_ascension_perk = ap_esap_pacifist_1
		}
		OR = {
			has_ethic = ethic_pacifist
			has_ethic = ethic_fanatic_pacifist
		}
	}
	
	ai_weight = {
		factor = 10
		modifier = {
			factor = 2
			is_pacifist = yes
		}
	}
}

ap_esap_materialist_1 = {
	on_enabled = {
		custom_tooltip = ap_esap_materialist_1_tooltip
		hidden_effect = {
			every_owned_ship = {
				ship_event = {
					id = esap_ethics.6
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
	}

	potential = {
		NOT = {
			has_ascension_perk = ap_esap_materialist_1
		}
		OR = {
			has_ethic = ethic_materialist
			has_ethic = ethic_fanatic_materialist
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

### Fanatic Ethic ###

ap_esap_authoritarian_2 = {
	# on_enabled = {
	# 	custom_tooltip = ap_esap_authoritarian_2_tooltip
	# }

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}

	modifier = {
		description = ap_esap_authoritarian_2_modifier_desc
		planet_jobs_worker_minerals_produces_mult = 0.10
		planet_jobs_worker_food_produces_mult = 0.10
		planet_jobs_ruler_unity_produces_mult = 0.05
		planet_jobs_specialist_alloys_produces_mult = 0.05
		planet_jobs_specialist_consumer_goods_produces_mult = 0.05 
		planet_jobs_specialist_society_research_produces_mult = 0.025
		planet_jobs_specialist_engineering_research_produces_mult = 0.025
		planet_jobs_specialist_physics_research_produces_mult = 0.025
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_authoritarian_2
		}
		has_ethic = ethic_fanatic_authoritarian
	}
	
	ai_weight = {
		factor = 15
	}
}

ap_esap_egalitarian_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_egalitarian_2_tooltip
		hidden_effect = {
			every_owned_leader = {
				owner = {
					country_event = {
						id = esap_ethics.2
						scopes = { 
							from = prev
						}
					}
				}
			}
			every_pool_leader = {
				owner = {
					country_event = {
						id = esap_ethics.2
						scopes = { 
							from = prev
						}
					}
				}
			}
		}
	}

	modifier = {
		refugee_attraction = 0.25
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_egalitarian_2
		}
		has_ethic = ethic_fanatic_egalitarian
		
	}
	
	ai_weight = {
		factor = 0
	}
}

ap_esap_xenophobe_2 = {
	# on_enabled = {
	# 	custom_tooltip = ap_esap_xenophobe_2_tooltip
	# }

	modifier = {
		# TODO: This needs a buff or interesting effect
		l_slot_weapon_damage_mult = 0.10
		terraforming_cost_mult = -0.15
		terraform_speed_mult = 1.00
		refugee_attraction = -1.00
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_xenophobe_2
		}
		has_ethic = ethic_fanatic_xenophobe
	}
	
	ai_weight = {
		factor = 15
	}
}

ap_esap_xenophile_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_xenophile_2_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}

	modifier = { 
		# TODO: This needs a buff or interesting effect
		federation_naval_cap_contribution_mult = 2.50
	}
	
	potential = {
		always = no #Should involve federations. But will have to wait until I got the expansion and can work with it.
		NOT = {
			has_ascension_perk = ap_esap_xenophile_2
		}
		has_ethic = ethic_fanatic_xenophile
	}
	
	ai_weight = {
		factor = 15
	}
}

ap_esap_militarist_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_militarist_2_tooltip
		hidden_effect = {
			if = {
				limit = { is_at_war = yes }
				set_variable = {
					which = var_esap_militarist_2_years_of_peace
					value = 0
				}
			}
			else = {
				set_variable = {
					which = var_esap_militarist_2_years_of_peace
					value = 5
				}
				add_modifier = {
					modifier = "mod_esap_militarist_2_5"
					days = -1
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}

	modifier = {
		# TODO: This needs a buff or interesting effect
		pop_happiness = 0.10
		country_alloys_produces_mult = 0.05
		country_unity_produces_mult = 0.20
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_militarist_2
		}
		has_ethic = ethic_fanatic_militarist
	}
	
	ai_weight = {
		factor = 15
	}
}

ap_esap_pacifist_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_pacifist_2_tooltip
		hidden_effect = {
			set_variable = {
				which = var_esap_pacifism_2_years_of_peace
				value = 0
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}

	modifier = {
		ship_home_territory_fire_rate_mult = 0.10
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_pacifist_2
		}
		has_ethic = ethic_fanatic_pacifist
	}
	
	ai_weight = {
		factor = 15
		modifier = {
			factor = 2
			is_pacifist = yes
		}
	}
}

ap_esap_spiritualist_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_spiritualist_2_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}

	# modifier = {
	# }
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_spiritualist_2
		}
		has_ethic = ethic_fanatic_spiritualist
	}
	
	ai_weight = {
		factor = 15
	}
}

ap_esap_materialist_2 = {
	on_enabled = {
		custom_tooltip = ap_esap_materialist_2_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}

	# modifier = {
	# }
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_materialist_2
		}
		has_ethic = ethic_fanatic_materialist
	}
	
	ai_weight = {
		factor = 15
	}
}

#######################
### HIVE MIND PERKS ###
#######################

ap_esap_hive_swarm = {
	on_enabled = {
		custom_tooltip = ap_esap_hive_swarm_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_1"
			num_ascension_perks > 0
		}
	}

	modifier = {
		weapon_type_strike_craft_weapon_fire_rate_mult = 0.25
		shipsize_corvette_build_speed_mult = 0.50
		shipsize_corvette_experience_gain_mult = 0.50
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_hive_swarm
		}
		has_authority = auth_hive_mind
	}
	
	ai_weight = {
		factor = 10
	}
}

ap_esap_hive_devouring = {
	on_enabled = {
		custom_tooltip = ap_esap_hive_devouring_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_3"
			num_ascension_perks > 2
		}
	}

	modifier = {
		ship_hull_mult = 0.1
		ship_weapon_range_mult = 0.05
		ship_shield_regen_add_perc = 0.005
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_hive_devouring
		}
		has_authority = auth_hive_mind 
		has_valid_civic = civic_hive_devouring_swarm
	}
	
	ai_weight = {
		factor = 0
	}
}

# Disabled until I get Lithoids and can copy terravore decision.
ap_esap_hive_terravores = {
	on_enabled = {
		custom_tooltip = ap_esap_hive_terravores_tooltip
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_2"
			num_ascension_perks > 1
		}
	}
	
	potential = {
		always = no 
		NOT = {
			has_ascension_perk = ap_esap_hive_terravores
		}
		has_authority = auth_hive_mind
	}
	
	ai_weight = {
		factor = 0
	}
}

###############################
### GENERIC ASCENSION PERKS ###
###############################

ap_esap_one_purpose = {
	modifier = {
		country_unity_produces_mult = 0.10
	}

	triggered_modifier = {
		potential = {
			is_wilderness_empire = no
		}
		pop_amenities_usage_no_happiness_mult = -0.15
		add_attunement_the_cradle_of_souls = @ascension_perk_attunement1
	}

	triggered_modifier = {
		potential = {
			is_wilderness_empire = yes
		}
		planetary_ascension_cost_mult = -0.10
	}

	possible = {
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_one_purpose
		}
		is_gestalt = yes
	}
	
	ai_weight = {
		factor = 10	
	}
}

ap_esap_smallworld = {
	on_enabled = {
		custom_tooltip = ap_esap_smallworld_tooltip
		hidden_effect = {
			every_owned_colony = {
				carrier_event = {
					id = esap_generic.1
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_ascension_perks_3"
			num_ascension_perks > 2
		}
	}
	
	potential = {
		NOT = {
			has_ascension_perk = ap_esap_smallworld
		}
	}
	
	ai_weight = {
		factor = 0
	}
}

###################################
### GOVERMENTAL ASCENSION PERKS ###
###################################

#Executive Vigor for gestalt consciousness
ap_esap_gov_GC_1 = {	
	modifier = {
		# country_government_civic_points_add = 1
		country_edict_fund_add = 100
		council_agenda_progress_speed = 0.15
	}

	potential = {
		is_gestalt = yes
		NOT = {
			has_ascension_perk = ap_executive_vigor
			has_ascension_perk = ap_esap_gov_GC_1
		}
	}
	# Unique Ascension Perks
	# Merged effect for ESAP
	on_enabled = {
		# if = {
		# 	limit = { has_global_flag = has_uap_mod }
		# 	custom_tooltip = "ap_executive_vigor_tooltip"
		# 	hidden_effect = {
		# 		country_event = { id = UniqueAscensionPerksEvents.421 }
		# 	}
		# }

		# ESAP Merger Stack
		custom_tooltip = "ap_esap_gov_GC_1_tooltip"
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_1_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_1_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_1_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_1_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_1_4" days = -1 }
			}
			country_event = {
				id = esap_gov.2
			}
		}	
	}
	
	ai_weight = {
		factor = 30 #it's better than average
	}
}

#Transcendent Learning for gestalt consciousness
ap_esap_gov_GC_2 = {
	modifier = {
		country_scientist_cap_add = 2
		leaders_upkeep_mult = -0.25
		# Added modifiers on_enabled instead
		#species_leader_exp_gain = 0.50
	}
	on_enabled = {
		# Worthy Ascension Perks
		# if = {
		# 	limit = { has_global_flag = has_mute_ap_mod }
		# 	custom_tooltip = "worthy_transcendent_learning_effect"
		# 	hidden_effect = {
		# 		country_event = { id = worthyperks.02 }
		# 	}
		# }

		# ESAP Merger Stack
		custom_tooltip = "ap_esap_gov_GC_2_tooltip"
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_2_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_2_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_2_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_2_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_2_4" days = -1 }
			}
			country_event = {
				id = esap_gov.2
			}
		}
		# Unique Ascension Perks
		# if = {
		# 	limit = { has_global_flag = has_uap_mod }
		# 	custom_tooltip = "ap_transcendent_learning_tooltip"
		# 	hidden_effect = {
		# 		country_event = { id = UniqueAscensionPerksEvents.31 }
		# 	}
		# }
	}

	potential = {
		is_gestalt = yes
		NOT = {
			has_ascension_perk = ap_transcendent_learning
			has_ascension_perk = ap_esap_gov_GC_2
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

#Imperial Prerrogative for mega-corporations
ap_esap_gov_3_corp = {	
	modifier = {
		empire_size_colonies_mult = 0
		pop_cat_ruler_bonus_workforce_mult = 0
		country_official_cap_add = 2
	}	

	triggered_modifier = {
		potential = { is_nomadic = no }
		empire_size_colonies_mult = -0.25
	}

	triggered_modifier = {
		potential = { is_nomadic = yes }
		pop_cat_ruler_bonus_workforce_mult = 0.15
	}

	potential = {
		NOT = {
			is_gestalt = yes
			has_ascension_perk = ap_imperial_prerogative
			has_ascension_perk = ap_esap_gov_3_corp
		}
		is_megacorp = yes
	}

	ai_weight = {
		factor = 15
		modifier = {
			factor = 0
			num_owned_planets < 5
		}
		modifier = {
			factor = 0.1
			num_owned_planets < 7
		}
		modifier = {
			factor = 2
			num_owned_planets > 20
		}
		modifier = {
			factor = 5
			num_owned_planets > 40
		}
	}

	on_enabled = {
		run_ai_strategic_data = yes
		# ESAP Merger Stack
		custom_tooltip = "ap_esap_gov_3_corp_tooltip"
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_3_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_3_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_3_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_3_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_3_4" days = -1 }
			}
			country_event = {
				id = esap_gov.1
			}
		}
	}
}

#Imperial Prerrogative for gestalt consciousness
ap_esap_gov_GC_3 = {	
	modifier = {
		empire_size_colonies_mult = 0
		pop_cat_ruler_bonus_workforce_mult = 0
		country_official_cap_add = 2
	}	

	triggered_modifier = {
		potential = { is_nomadic = no }
		empire_size_colonies_mult = -0.25
	}

	triggered_modifier = {
		potential = { is_nomadic = yes }
		pop_cat_ruler_bonus_workforce_mult = 0.15
	}

	potential = {
		is_gestalt = yes
		NOR = {
			has_ascension_perk = ap_imperial_prerogative
			has_ascension_perk = ap_esap_gov_GC_3
			has_authority = auth_corporate
		}
	}

	ai_weight = {
		factor = 15
		modifier = {
			factor = 0
			num_owned_planets < 5
		}
		modifier = {
			factor = 0.1
			num_owned_planets < 7
		}
		modifier = {
			factor = 2
			num_owned_planets > 20
		}
		modifier = {
			factor = 5
			num_owned_planets > 40
		}
	}

	on_enabled = {
		run_ai_strategic_data = yes
		# ESAP Merger Stack
		custom_tooltip = "ap_esap_gov_GC_3_tooltip"
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_3_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_3_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_3_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_3_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_3_4" days = -1 }
			}
			country_event = {
				id = esap_gov.2
			}
		}	
	}
}

#The Beautiful Bureaucracy
ap_esap_gov_4 = {	
	on_enabled = {
		custom_tooltip = ap_esap_gov_4_tooltip
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_4_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_4_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_4_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_4_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_4_4" days = -1 }
			}
			country_event = {
				id = esap_gov.1
			}
		}	
	}

	modifier = {
		pop_category_specialists_unity_produces_add = 1
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_gov_4_global_req"
			has_technology = tech_global_production_strategy
		}
	}

	potential = {
		NOT = {
			is_gestalt = yes
			has_ascension_perk = ap_esap_gov_4
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

#The Great Echo
ap_esap_gov_hive_4 = {
	on_enabled = {
		custom_tooltip = ap_esap_gov_hive_4_tooltip
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_hive_4_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_hive_4_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_hive_4_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_hive_4_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_hive_4_4" days = -1 }
			}
			country_event = {
				id = esap_gov.2
			}
		}	
	}

	modifier = {
		planet_maintenance_drones_unity_produces_add = 1.5
		# pop_category_specialists_unity_produces_add = 1
		# pop_category_workers_unity_produces_add = 1
		# pop_category_complex_drones_unity_produces_add = 1
		# pop_category_simple_drones_unity_produces_add = 1
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_gov_4_global_req"
			has_technology = tech_global_production_strategy
		}
	}

	potential = {
		is_hive_empire = yes
		NOT = {
			has_ascension_perk = ap_esap_gov_hive_4
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

#The Great Echo (Machine)
ap_esap_gov_machines_4 = {
	on_enabled = {
		custom_tooltip = ap_esap_gov_machines_4_tooltip
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_machines_4_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_machines_4_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_machines_4_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_machines_4_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_machines_4_4" days = -1 }
			}
			country_event = {
				id = esap_gov.2
			}
		}	
	}

	modifier = {
		planet_maintenance_drones_unity_produces_add = 1.5		
		# pop_category_specialists_unity_produces_add = 1
		# pop_category_workers_unity_produces_add = 1
		# pop_category_complex_drones_unity_produces_add = 1
		# pop_category_simple_drones_unity_produces_add = 1
	}

	possible = {
		custom_tooltip = {
			fail_text = "ap_esap_gov_4_global_req"
			has_technology = tech_global_production_strategy
		}
	}

	potential = {
		is_machine_empire = yes
		NOT = {
			has_ascension_perk = ap_esap_gov_machines_4
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

#Ascendancy of the State
ap_esap_gov_5 = {	
	on_enabled = {
		custom_tooltip = ap_esap_gov_5_tooltip
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_5_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_5_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_5_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_5_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_5_4" days = -1 }
			}
			country_event = {
				id = esap_gov.1
			}
		}	
	}

	modifier = {
		country_government_civic_points_add = 1
		country_official_cap_add = 2
		official_initial_skill = 2
		category_statecraft_research_speed_mult = 0.10
	}

	possible = {
		has_ascension_perk = ap_transcendent_learning
		has_ascension_perk = ap_executive_vigor
		if = { 
			limit = { NOT = { has_authority = auth_corporate } }
			has_ascension_perk = ap_imperial_prerogative
		}
		if = {
			limit = { has_authority = auth_corporate }
			has_ascension_perk = ap_esap_gov_3_corp
		}
		has_ascension_perk = ap_esap_gov_4
	}

	potential = {
		NOR = {
			is_gestalt = yes
			has_ascension_perk = ap_esap_gov_5
		}
	}
	
	ai_weight = {
		factor = 10
	}
}

#The Ascendant Mind
ap_esap_gov_GC_5 = {	
	on_enabled = {
		custom_tooltip = ap_esap_gov_GC_5_tooltip
		hidden_effect = {
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 0 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_5_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 1 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_5_1" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 2 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_5_2" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 3 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_5_3" days = -1 }
			}
			if = {
				limit = {
					check_variable = { which = var_esap_goverment_GC_perk_count value = 4 }
				}
				add_modifier = { modifier = "mod_esap_gov_GC_5_4" days = -1 }
			}
			country_event = {
				id = esap_gov.2
			}
		}	
	}

	modifier = {
		country_government_civic_points_add = 1
		country_official_cap_add = 2
		official_initial_skill = 2
		category_statecraft_research_speed_mult = 0.10
		restored_regulatory_node_bonus_skill = 2
	}

	possible = {
		has_ascension_perk = ap_esap_gov_GC_1
		has_ascension_perk = ap_esap_gov_GC_2
		has_ascension_perk = ap_esap_gov_GC_3
		if = { 
			limit = { is_hive_empire = yes }
			has_ascension_perk = ap_esap_gov_hive_4
		}
		if = {
			limit = { is_machine_empire = yes }
			has_ascension_perk = ap_esap_gov_machines_4
		}
	}

	potential = {
		is_gestalt = yes
		NOT = {
			has_ascension_perk = ap_esap_gov_GC_5
		}
	}
	
	ai_weight = {
		factor = 10
	}
}
