
#########################
# Initiate Storm events #
#########################

situation_event = {
	id = cstorms.2000
	title = cstorms.2000.name
	desc = {
		trigger = {
			text = cstorms.2000.desc_common_1
			success_text = {
				text = cstorms.2000.desc_tech
				owner = {
					OR = {
						has_technology = tech_basic_science_lab_3
						has_technology = tech_mine_dark_matter
						has_technology = tech_hyper_drive_3
					}
				}
			}
			success_text = {
				text = cstorms.2000.desc_common_2
				owner = { NOT = { has_country_flag = triggered_gather_storm } }
			}
		}
	}
	picture = GFX_evt_cosmic_storms_preparation
	show_sound = event_laboratory_sound
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = situation_locked
	}

	option = {
		name = cstorms.2000.a
		hidden_effect = {
			set_situation_flag = approach_supercharge_selected
		}
		set_situation_approach = approach_situation_initiate_storm_supercharge
		custom_tooltip = cstorms.2000.a.tt
	}

	option = {
		name = cstorms.2000.b
		allow = {
			custom_tooltip = {
				fail_text = cstorms.2000.b.tt.allow
				owner = {
					OR = {
						AND = {
							has_technology = tech_basic_science_lab_3
							can_obtain_volatile_motes = yes
						}
						has_technology = tech_mine_dark_matter
						AND = {
							has_technology = tech_hyper_drive_3
							can_obtain_rare_crystals = yes
						}
					}
				}
			}
		}
		hidden_effect = {
			set_situation_flag = approach_overfeed_selected
		}
		set_situation_approach = approach_situation_initiate_storm_overfeed
		if = {
			limit = {
				owner = {
					OR = {
						AND = {
							has_technology = tech_basic_science_lab_3
							can_obtain_volatile_motes = yes
						}
						has_technology = tech_mine_dark_matter
						AND = {
							has_technology = tech_hyper_drive_3
							can_obtain_rare_crystals = yes
						}
					}
				}
			}
			custom_tooltip = cstorms.2000.b.tt
		}
	}

	option = {
		name = cstorms.2000.c
		default_hide_option = yes
		abort_situation = this
	}

	after = {
		hidden_effect = {
			remove_situation_flag = situation_locked
			set_situation_locked = no
			owner = {
				if = {
					limit = { NOT = { has_country_flag = triggered_gather_storm } }
					set_country_flag = triggered_gather_storm
				}
			}
		}
	}
}

situation_event = {
	id = cstorms.2010
	title = cstorms.2010.name
	desc = {
		trigger = {
			owner = {
				NOR = {
					has_technology = tech_power_plant_4
					has_technology = tech_mining_3
				}
			}
		}
		text = cstorms.2010.desc_irradiate_only
	}
	desc = {
		trigger = {
			owner = {
				OR = {
					has_technology = tech_power_plant_4
					has_technology = tech_mining_3
				}
			}
		}
		text = cstorms.2010.desc_others
	}
	picture = GFX_evt_cosmic_storms_calibration
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = situation_locked
	}

	option = {
		name = cstorms.2010.a
		hidden_effect = {
			set_situation_flag = approach_irradiate_selected
		}
		set_situation_approach = approach_situation_initiate_storm_irradiate
		custom_tooltip = cstorms.2010.a.tt
	}

	option = {
		name = cstorms.2010.b
		allow = {
			owner = { has_technology = tech_power_plant_4 }
		}
		hidden_effect = {
			set_situation_flag = approach_sever_selected
		}
		set_situation_approach = approach_situation_initiate_storm_sever
		custom_tooltip = cstorms.2010.b.tt
	}

	option = {
		name = cstorms.2010.c
		allow = {
			owner = { has_technology = tech_mining_3 }
		}
		hidden_effect = {
			set_situation_flag = approach_magnetize_selected
		}
		set_situation_approach = approach_situation_initiate_storm_magnetize
		custom_tooltip = cstorms.2010.c.tt
	}

	option = {
		name = cstorms.2010.d
		abort_situation = this
	}

	after = {
		hidden_effect = {
			remove_situation_flag = situation_locked
			set_situation_locked = no
		}
	}
}

situation_event = {
	id = cstorms.2015
	title = cstorms.2015.name
	desc = {
		trigger = {
			check_variable = {
				which = count_techs
				value = 1
			}
		}
		text = cstorms.2015.desc_one_tech_only
	}
	desc = {
		trigger = {
			check_variable = {
				which = count_techs
				value > 1
			}
		}
		text = cstorms.2015.desc_others
	}
	picture = GFX_evt_cosmic_storms_calibration
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target
	situation = this

	immediate = {
		set_situation_locked = yes
		set_situation_flag = situation_locked
		set_variable = {
			which = count_techs
			value = 0
		}
		if = {
			limit = {
				owner = {
					has_technology = tech_basic_science_lab_3
					can_obtain_volatile_motes = yes
				}
			}
			change_variable = {
				which = count_techs
				value = 1
			}
		}
		if = {
			limit = {
				owner = { has_technology = tech_mine_dark_matter }
			}
			change_variable = {
				which = count_techs
				value = 1
			}
		}
		if = {
			limit = {
				owner = {
					has_technology = tech_hyper_drive_3
					can_obtain_rare_crystals = yes
				}
			}
			change_variable = {
				which = count_techs
				value = 1
			}
		}
	}

	option = {
		name = cstorms.2015.a
		allow = {
			owner = {
				has_technology = tech_basic_science_lab_3
				can_obtain_volatile_motes = yes
			}
		}
		hidden_effect = {
			set_situation_flag = approach_agitate_selected
		}
		set_situation_approach = approach_situation_initiate_storm_agitate
		custom_tooltip = cstorms.2015.a.tt
	}

	option = {
		name = cstorms.2015.b
		allow = {
			owner = { has_technology = tech_mine_dark_matter }
		}
		hidden_effect = {
			set_situation_flag = approach_destabilize_selected
		}
		set_situation_approach = approach_situation_initiate_storm_destabilize
		custom_tooltip = cstorms.2015.b.tt
	}

	option = {
		name = cstorms.2015.c
		allow = {
			owner = {
				has_technology = tech_hyper_drive_3
				can_obtain_rare_crystals = yes
			}
		}
		hidden_effect = {
			set_situation_flag = approach_scramble_selected
		}
		set_situation_approach = approach_situation_initiate_storm_scramble
		custom_tooltip = cstorms.2015.c.tt
	}

	option = {
		name = cstorms.2015.d
		abort_situation = this
	}

	after = {
		hidden_effect = {
			remove_situation_flag = situation_locked
			set_situation_locked = no
		}
	}
}

# Spawn Solar Storm
# from = fleet
situation_event = {
	id = cstorms.2020
	title = cstorms.2020.name
	desc = cstorms.2020.desc
	picture = GFX_evt_cosmic_storms_solar_storm
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target

	option = {
		name = cstorms.storm_gathered.a
		spawn_random_storm = {
			type = solar_storm
			immediate = yes
			cosmic_storm_start_position = target.solar_system
		}
	}
	after = { destroy_situation = this }
}

# Spawn Electric Storm
situation_event = {
	id = cstorms.2025
	title = cstorms.2025.name
	desc = cstorms.2025.desc
	picture = GFX_evt_cosmic_storms_electric_storm
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target

	option = {
		name = cstorms.storm_gathered.a
		spawn_random_storm = {
			type = electric_storm
			immediate = yes
			cosmic_storm_start_position = target.solar_system
		}
	}
	after = { destroy_situation = this }
}

# Spawn Magnetic Storm
situation_event = {
	id = cstorms.2030
	title = cstorms.2030.name
	desc = cstorms.2030.desc
	picture = GFX_evt_cosmic_storms_magnetic_storm
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target

	option = {
		name = cstorms.storm_gathered.a
		spawn_random_storm = {
			type = magnetic_storm
			immediate = yes
			cosmic_storm_start_position = target.solar_system
		}
	}
	after = { destroy_situation = this }
}

# Spawn Particles Storm
situation_event = {
	id = cstorms.2035
	title = cstorms.2035.name
	desc = cstorms.2035.desc
	picture = GFX_evt_cosmic_storms_particle_storm
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target

	option = {
		name = cstorms.storm_gathered.a
		spawn_random_storm = {
			type = particle_storm
			immediate = yes
			cosmic_storm_start_position = target.solar_system
		}
	}
	after = { destroy_situation = this }
}

# Spawn Gravity Storm
situation_event = {
	id = cstorms.2040
	title = cstorms.2040.name
	desc = cstorms.2040.desc
	picture = GFX_evt_cosmic_storms_gravity_storm
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target

	option = {
		name = cstorms.storm_gathered.a
		spawn_random_storm = {
			type = gravity_storm
			immediate = yes
			cosmic_storm_start_position = target.solar_system
		}
	}
	after = { destroy_situation = this }
}

# Spawn Celestial Storm
situation_event = {
	id = cstorms.2045
	title = cstorms.2045.name
	desc = cstorms.2045.desc
	picture = GFX_evt_cosmic_storms_celestial_storm
	show_sound = event_energy_field
	is_triggered_only = yes
	location = target

	option = {
		name = cstorms.storm_gathered.a
		spawn_random_storm = {
			type = celestial_storm
			immediate = yes
			cosmic_storm_start_position = target.solar_system
		}
	}
	after = { destroy_situation = this }
}
