# Ascension Perks Broadened - Eye of the Storm (ap_eye_of_the_storm)
# Used by events/apb_eye_of_the_storm_events.txt. Scope: system the storm just left.

# Storm-Washed modifier and a research lump for every colony in this system whose owner has the perk.
# MODIFIER = the apb_eots_washed_<type> static modifier.
apb_eots_wash_colonies = {
	every_system_planet = {
		limit = {
			is_colony = yes
			exists = owner
			owner = {
				has_ascension_perk = ap_eye_of_the_storm
			}
		}
		remove_modifier = $MODIFIER$
		add_modifier = {
			modifier = $MODIFIER$
			days = 3600
		}
		# 0.05 of each research type per pop (pop_amount), e.g. a colony of 3,000 pops gives 150 of each
		owner = {
			add_resource = {
				physics_research = 0.05
				society_research = 0.05
				engineering_research = 0.05
				mult = prev.trigger:pop_amount
			}
		}
	}
}

# Storm-Washed for the storm type that just left (FROM = the storm), plus a second roll on the
# vanilla deposit effect for that type at 50%. The vanilla effect itself rolls 20% per eligible planet
# in the system (colonies and colonisable planets, not artificial), so the extra chance is about 10%
# per planet. Nexus storms have no vanilla deposit effect.
apb_eots_storm_gifts = {
	if = {
		limit = { from = { is_storm_type = electric_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_electric }
		random_list = {
			50 = { }
			50 = { electric_storm_apply_deposits = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = particle_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_particle }
		random_list = {
			50 = { }
			50 = { particle_storm_apply_deposits = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = gravity_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_gravity }
		random_list = {
			50 = { }
			50 = { gravity_storm_apply_deposits = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = magnetic_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_magnetic }
		random_list = {
			50 = { }
			50 = { magnetic_storm_apply_deposit = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = solar_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_solar }
		random_list = {
			50 = { }
			50 = { solar_storm_apply_deposits = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = celestial_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_celestial }
		random_list = {
			50 = { }
			50 = { celestial_storm_apply_deposits = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = shroud_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_shroud }
		random_list = {
			50 = { }
			50 = { shroud_storm_apply_deposits = yes }
		}
	}
	else_if = {
		limit = { from = { is_storm_type = nexus_storm } }
		apb_eots_wash_colonies = { MODIFIER = apb_eots_washed_nexus }
	}
}
