namespace = esap_general

#Sets flag that the mod is in use
event = {
	id = esap_general.1
	hide_window = yes
	is_triggered_only = yes
	fire_only_once = yes
	immediate = { set_global_flag = esap_mod_in_use }
}

#Remove planet modifiers from a planet when ownerless or occupation is transfered.
carrier_event = {
	id = esap_general.2
	hide_window = yes
	is_triggered_only = yes
	immediate = {	
		### Natural Ascension
		if = {
			limit = { has_modifier = mod_esap_garden }
			remove_modifier = "mod_esap_garden"
		}	

		### Industrial Ascension ###
		if = {
			limit = { has_modifier = mod_esap_industry }
			remove_modifier = "mod_esap_industry"
		}	

		### Combination Paths ###
		if = {
			limit = { has_modifier = mod_esap_ct2_expansion_diplomacy }
			remove_modifier = "mod_esap_ct2_expansion_diplomacy"
		}	
		if = {
			limit = { has_modifier = mod_esap_ct1_infrastructure }
			remove_modifier = "mod_esap_ct1_infrastructure"
		}	

		### Ethics Ascension Perks ###
		if = {
			limit = { has_modifier = mod_esap_egalitarian_1 }
			remove_modifier = "mod_esap_egalitarian_1"
		}	

	}
}

#No event esap_general.3 (one in est, but not needed here, but want to have the same numbering for the later one, so number 3 skipped.

#A war have begun, triggers other events.
country_event = {
	id = esap_general.4
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		country_event = {
			id =esap_general.7
			days = 1
		}
	}
}

#A war have ended (triggered if one side won), triggers other events.
country_event = {
	id = esap_general.5
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		fromfrom = {
			every_war_participant = {
				country_event = {
					id = esap_general.7
					days = 1
				}
			}
		}
	}
}

#A war have ended (triggered on white peace), triggers other events.
country_event = {
	id = esap_general.6
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		fromfromfromfrom = {
			every_war_participant = {
				country_event = {
					id = esap_general.7
					days = 1
				}
			}
		}
	}
}

#Updates war modifiers
country_event = {
	id = esap_general.7
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		country_event = {
			id = esap_ascension_paths.2
		}
	}
}