situation_living_snow = {
	picture = GFX_evt_arctic
	complete_icon_frame = GFX_situation_outcome_frame_blue
	complete_icon = GFX_situation_outcome_unknown
	situation_log_category = developments
	on_progress_complete = {
		custom_tooltip = situation_unknown_outcome_approach
		hidden_effect = {
			if = {
				limit = { current_situation_approach = situation_snow_hostile }
				situation_event = { id = situation.180 }
			}
			else = {
				situation_event = { id = situation.185 }
			}
		}
	}
	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 25
			custom_tooltip = stage_unknown_effects
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_blue
			end = 80
			on_first_enter = {
				situation_event = { id = situation.155 }
			}
			custom_tooltip = stage_unknown_effects
		}
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_blue
			end = 100
			on_first_enter = {
				situation_event = { id = situation.165 }
			}
			custom_tooltip = stage_unknown_effects
		}
	}
	approach = {
		name = situation_snow_hostile
		icon = GFX_situation_approach_fist
		icon_background = GFX_situation_approach_bg_red
		potential = {
			NOT = { current_stage = stage_1 }
		}
		allow = {
			custom_tooltip = {
				fail_text = too_late_to_change_approach
				OR = {
					NOT = { has_situation_flag = path_locked }
					current_situation_approach = situation_snow_hostile
				}
			}
		}
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		resources = {
			category = situations
			upkeep = {
				energy = 10
			}
			upkeep = {
				trigger = {
					has_situation_flag = very_hostile
				}
				energy = 5
			}
		}
		target_modifier = {
			planet_stability_add = 5
		}
		triggered_target_modifier = {
			potential = {
				NOT = { has_situation_flag = lackadaisical }
			}
			modifier = { planet_stability_add = 5 }
		}
	}
	approach = {
		name = situation_snow_observation
		icon = GFX_situation_approach_research
		icon_background = GFX_situation_approach_bg_yellow
		default = yes
		allow = {
			custom_tooltip = {
				fail_text = too_late_to_change_approach
				OR = {
					NOT = { has_situation_flag = path_locked }
					current_situation_approach = situation_snow_observation
				}
			}
		}
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		resources = {
			category = situations
			produces = {
				trigger = {
					NOT = { current_stage = stage_1 }
				}
				society_research = 5
				physics_research = 5
				engineering_research = 5
			}
			upkeep = {
				trigger = {
					NOT = { current_stage = stage_1 }
				}
				unity = 10
			}
			upkeep = {
				trigger = { has_situation_flag = higher_observe_upkeep }
				unity = 5
			}
		}
	}
	on_monthly = {
		random_events = {
			120 = 0
			20 = situation.160
			15 = situation.170
			10 = situation.175
		}
	}
	monthly_progress = {
		base = 5
		modifier = {
			add = 5
			desc = situation_snow_very_hostile_tt
			current_situation_approach = situation_snow_hostile
			has_situation_flag = very_hostile
		}
	}
	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
		}
	}
}

situation_mysterious_labyrinth = {
	picture = GFX_evt_astral_rift_library
	initial_progress = 50
	progress_direction = bidirectional
	complete_icon_frame = GFX_situation_outcome_frame_blue
	complete_icon = GFX_situation_outcome_unknown
	fail_icon_frame = GFX_situation_outcome_frame_blue
	fail_icon = GFX_situation_outcome_unknown
	situation_log_category = developments
	on_start = {
		set_situation_locked = yes
	}
	monthly_progress = {
		modifier = {
			desc = string_current_approach
			current_situation_approach = approach_investigate
			add = 2.5
		}
		modifier = {
			desc = string_current_approach
			OR = {
				current_situation_approach = approach_observe
				current_situation_approach = approach_cordon_off
			}
			subtract = 2.5
		}
		modifier = {
			desc = string_current_approach
			current_situation_approach = approach_destroy
			subtract = 5
		}
	}
	approach = {
		name = approach_investigate
		icon = GFX_situation_approach_research
		icon_background = GFX_situation_approach_bg_yellow
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		resources = {
			category = situations
			upkeep = {
				energy = 5
			}
			upkeep = {
				trigger = { has_situation_flag = harder_to_study }
				unity = 10
			}
		}
	}
	approach = {
		name = approach_observe
		icon = GFX_situation_approach_shrug
		icon_background = GFX_situation_approach_bg_yellow
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		potential = {
			NOT = { has_situation_flag = observe_not_an_option }
		}
	}
	approach = {
		name = approach_cordon_off
		icon = GFX_situation_approach_suspicious
		icon_background = GFX_situation_approach_bg_yellow
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		resources = {
			category = situations
			upkeep = {
				energy = 10
			}
			upkeep = {
				trigger = { has_situation_flag = cute_kittens }
				unity = 10
			}
		}
		potential = {
			has_situation_flag = observe_not_an_option
		}
	}
	approach = {
		name = approach_destroy
		icon = GFX_situation_approach_fist
		icon_background = GFX_situation_approach_bg_red
		on_select = {
			custom_tooltip = approach_destroy_labyrinth_tooltip
		}
		resources = {
			category = situations
			upkeep = {
				energy = 10
			}
			upkeep = {
				trigger = { has_situation_flag = cute_kittens }
				unity = 10
			}
		}
	}
	on_fail = {
		custom_tooltip = situation_unknown_outcome_approach
		hidden_effect = {
			if = {
				limit = { current_situation_approach = approach_destroy }
				situation_event = { id = situation.25 }
			}
			else_if = { #obstinance is rewarded
				limit = { has_situation_flag = labyrinth_timer }
				situation_event = { id = situation.20 }
			}
			else = {
				random_list = {
					1 = {
						situation_event = { id = situation.20 }
					}
					1 = { #but if you doubt, you have a chance of getting a lesser outcome
						situation_event = { id = situation.30 }
					}
				}
			}
		}
	}
	stages = {
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_blue
			end = 20
			on_first_enter = {
				if = {
					limit = { current_situation_approach = approach_destroy }
					situation_event = { id = situation.25 }
				}
				else = {
					situation_event = { id = situation.15 }
				}
			}
			custom_tooltip = stage_unknown_effects
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_blue
			end = 40
			on_first_enter = {
				situation_event = { id = situation.10 }
			}
			custom_tooltip = stage_unknown_effects
		}
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 60
		}
		stage_2_alt = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_blue
			end = 80
			on_first_enter = {
				situation_event = { id = situation.40 }
			}
			custom_tooltip = stage_unknown_effects
		}
		stage_3_alt = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_blue
			end = 100
			on_first_enter = {
				situation_event = { id = situation.45 }
			}
			custom_tooltip = stage_unknown_effects
		}
	}
	on_progress_complete = {
		custom_tooltip = situation_unknown_outcome_approach
		hidden_effect = {
			if = {
				limit = { has_situation_flag = labyrinth_timer }
				random_list = {
					1 = {
						situation_event = { id = situation.50 }
					}
					1 = {
						situation_event = { id = situation.55 }
					}
				}
			}
			else = {
				situation_event = { id = situation.50 }
			}
		}
	}

	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
		}
	}
}

leviathan_celebration_opportunity = {
	complete_icon_frame = GFX_situation_outcome_frame_green
	complete_icon = GFX_situation_outcome_positive
	fail_icon_frame = GFX_situation_outcome_frame_red
	fail_icon = GFX_situation_outcome_meh
	situation_log_category = developments
	picture = {
		trigger = {
			target = { is_planet_class = pc_desert }
		}
		picture = GFX_evt_desert
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_tropical }
		}
		picture = GFX_evt_tropical
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_arid }
		}
		picture = GFX_evt_arid
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_continental }
		}
		picture = GFX_evt_continental
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_alpine }
		}
		picture = GFX_evt_alpine_city
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_savannah }
		}
		picture = GFX_evt_savannah
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_ocean }
		}
		picture = GFX_evt_ocean
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_tundra }
		}
		picture = GFX_evt_tundra
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_arctic }
		}
		picture = GFX_evt_arctic
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_gaia }
		}
		picture = GFX_evt_gaia
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_nuked }
		}
		picture = GFX_evt_tomb_world
	}
	picture = {
		trigger = {
			target = {
				OR = {
					is_planet_class = pc_ringworld_habitable
					is_planet_class = pc_ringworld_habitable_damaged
					is_planet_class = pc_cybrex
				}
			}
		}
		picture = GFX_evt_ringworld
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_habitat }
		}
		picture = GFX_evt_habitat
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_hive }
		}
		picture = GFX_evt_infested
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_machine }
		}
		picture = GFX_evt_ai_planet
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_city }
		}
		picture = GFX_evt_city_planet
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_ark }
		}
		picture = GFX_evt_arkship_life
	}
	picture = {
		trigger = {
			target = { is_planet_class = pc_volcanic }
		}
		picture = GFX_evt_molten
	}

	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_green
			end = 50
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_leviathan_2_tooltip
			on_first_enter = {
				situation_event = { id = situation.1045 }
				situation_event = { id = situation.1050 }
				situation_event = { id = situation.1055 }
				situation_event = { id = situation.1060 }
				situation_event = { id = situation.1065 }
				situation_event = { id = situation.1070 }
				situation_event = { id = situation.1075 }
				situation_event = { id = situation.1080 }
				situation_event = { id = situation.1100 }
				situation_event = { id = situation.1110 }
				situation_event = { id = situation.1120 }
			}
			end = 70
		}
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = stage_leviathan_3_tooltip
			end = 100
		}
	}

	category = positive

	on_progress_complete = {
		custom_tooltip = leviathan_celebration_opportunity_finish_tooltip
		hidden_effect = {
			situation_event = { id = situation.1000 }
			situation_event = { id = situation.1005 }
		}
	}
	on_start = { situation_event = { id = situation.1105 } }
	on_fail = {
		custom_tooltip = leviathan_celebration_opportunity_fail_tooltip
		hidden_effect = { situation_event = { id = situation.1180 } }
	}

	modifier = {
	}
	on_monthly = {
	}
	approach = {#Encourage
		name = approach_encourage
		allow = {
			NOT = { current_situation_approach = approach_reorganize }
		}
		on_select = {
			custom_tooltip = leviathan_celebration_encourage_effect
		}
		icon = GFX_situation_approach_amenities
		icon_background = GFX_situation_approach_bg_green
		ai_weight = {
			base = 10
		}
		default = yes
	}
	approach = {#Discourage
		allow = {
			NOT = { current_situation_approach = approach_reorganize }
		}
		name = approach_discourage
		on_select = {
			custom_tooltip = leviathan_celebration_discourage_effect
		}
		icon = GFX_situation_approach_shrug
		icon_background = GFX_situation_approach_bg_yellow
		ai_weight = {
			base = 0
		}
	}
	approach = {#Reorganize
		name = approach_reorganize
		icon = GFX_situation_approach_influence
		icon_background = GFX_situation_approach_bg_yellow
		allow = {
			owner = {
				hidden_trigger = { NOT = { has_country_flag = reorganizing_leviathan_parade } } #To ensure that the player is not reorganizing multiple parades at once
				resource_stockpile_compare = {
					resource = unity
					value > 1000
				}
			}
			NOR = {
				situation_progress > 49
				situation_monthly_progress <= 0
			}
		}
		on_select = {
			target = {
				planet = { set_carrier_flag = no_reorganize }
			}
			custom_tooltip = approach_reorganize_effect
			owner = {
				add_resource = { unity = -1000 }
			}
			owner = {
				set_country_flag = reorganizing_leviathan_parade
			}
			set_situation_locked = yes
		}
		ai_weight = {
			base = 0
		}
	}

	monthly_progress = {
		base = 4
		modifier = {
			add = 2
			desc = string_current_approach
			current_situation_approach = approach_encourage
		}
		 modifier = {
			add = -8
			desc = string_current_approach
			current_situation_approach = approach_discourage
		}
		modifier = {
			factor = 0
			desc = leviathan_celebration_voidspawn_effect
			AND = {
				has_situation_flag = celebration_voidspawn
				owner = {
					any_situation = {
						is_situation_type = situation_tainted_voidspawn
					}
				}
			}
		}
		modifier = {
			factor = 0
			desc = string_current_approach
			current_situation_approach = approach_reorganize
		}
	}

	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
		}
	}
}

## Black Hole
situation_gravity_well = {
	picture = GFX_evt_black_hole
	category = neutral
	complete_icon_frame = GFX_situation_outcome_frame_red
	complete_icon = GFX_situation_outcome_negative
	fail_icon_frame = GFX_situation_outcome_frame_blue
	fail_icon = GFX_situation_outcome_meh
	situation_log_category = developments

	on_start = {
		set_situation_locked = yes
	}

	on_progress_complete = {
		# fall into the black hole
		custom_tooltip = situation_gravity_well_finish_tooltip
		hidden_effect = {
			situation_event = { id = situation.590 }
		}
	}

	on_fail = {
		# escape
		custom_tooltip = situation_gravity_well_fail_tooltip
		hidden_effect = {
			situation_event = { id = situation.595 }
		}
	}

	initial_progress = 25
	progress_direction = monodirectional

	on_monthly = {
		random_events = {
			120 = 0
			5 = situation.510 # Mutiny - forward
			5 = situation.511 # Mutiny - fleeing
			10 = situation.520 # Closer than we thought
			10 = situation.530 # Scientific boon
			5 = situation.540 # The Penrose Process
		}
	}

	# Stage
	# Getting closer to the black hole should give you physics research and dark matter
	stages = {
		gravity_well_low = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 50
			triggered_modifier = {
				potential = {
					NOT = { has_situation_flag = escaped }
				}
				country_situations_sr_dark_matter_produces_add = 1
				country_situations_physics_research_produces_add = 5
			}
		}

		gravity_well_mid = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_green
			end = 70
			modifier = {
				country_situations_sr_dark_matter_produces_add = 2
				country_situations_physics_research_produces_add = 10
			}
		}

		gravity_well_high = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_green
			end = 80
			modifier = {
				country_situations_sr_dark_matter_produces_add = 5
				country_situations_physics_research_produces_add = 15
			}
		}

		gravity_well_no_return = {
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_red
			end = 100
			on_first_enter = {
				situation_event = { id = situation.580 }
			}
			modifier = {
				# high dark matter production because the station
				# is only gonna last a month or so in this zone anywau
				country_situations_sr_dark_matter_produces_add = 10
				country_situations_physics_research_produces_add = 20
			}
		}
	}


	# Approaches

	approach = { # Get Away
		name = approach_retreat
		icon = GFX_situation_approach_fleet
		icon_background = GFX_situation_approach_bg_green
		potential = {
			NOT = { has_situation_flag = mutiny }
		}
		allow = {
			custom_tooltip = {
				fail_text = mutiny_tooltip
				NOT = { has_situation_flag = mutiny }
			}
		}
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		resources = {
			category = situations
			upkeep = {
				energy = 10
			}
		}
	}

	approach = { # Stand still
		name = approach_stand
		icon = GFX_situation_approach_fleet
		icon_background = GFX_situation_approach_bg_yellow
		potential = {
			NOT = { has_situation_flag = mutiny }
		}
		allow = {
			custom_tooltip = {
				fail_text = mutiny_tooltip
				NOT = { has_situation_flag = mutiny }
			}
		}
		resources = {
			category = situations
			upkeep = {
				energy = 5
			}
		}
	}

	approach = { # Get Closer
		name = approach_advance
		icon = GFX_situation_approach_fleet
		icon_background = GFX_situation_approach_bg_red
		on_select = {
			custom_tooltip = approach_outcome_tooltip
		}
		potential = {
			NOT = { has_situation_flag = mutiny }
		}
		allow = {
			custom_tooltip = {
				fail_text = mutiny_tooltip
				NOT = { has_situation_flag = mutiny }
			}
		}
	}

	# Progress
	# 0	   50   70 80   100
	# ___________|____|__|____
	#    low      mid high no_return
	#
	# The closer you are to the black hole, the stronger the pull
	# goal: make players think "just a bit closer, just a little more Dark Matter..."
	# and then oops they cross the point of no return

	monthly_progress = {
		base = 5
		# Gravitational Pull of the black hole
		modifier = {
			add = 2
			desc = string_gravitational_pull
			current_stage = gravity_well_mid
		}
		modifier = {
			add = 3
			desc = string_gravitational_pull
			current_stage = gravity_well_high
		}
		modifier = {
			add = 7
			desc = string_gravitational_pull
			current_stage = gravity_well_no_return
		}
		# Approaches
		modifier = {
			add = -10
			desc = string_current_approach
			current_situation_approach = approach_retreat
		}
		modifier = {
			add = -3
			desc = string_current_approach
			current_situation_approach = approach_stand
		}
		modifier = {
			add = 3
			desc = string_current_approach
			current_situation_approach = approach_advance
		}
	}

	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
		}
	}
}

## Geomagnetic Storm
situation_geomagnetic_storm = {
	complete_icon_frame = GFX_situation_outcome_frame_red
	complete_icon = GFX_situation_outcome_negative
	picture = GFX_evt_supernova
	category = negative
	situation_log_category = developments

	on_start = {
		set_situation_locked = yes
	}

	on_progress_complete = {
		custom_tooltip = situation_geomagnetic_storm_outcome
		# Worst end: lost all drones
		situation_event = { id = situation.290 }
	}

	on_abort = {
		# Storm has ended
		situation_event = { id = situation.289 }
	}

	initial_progress = 0

	# the situation automatically ends after 5 years
	# progress bar: amount of radiation damage
	# goal: keep the droids shielded to avoid accumulating radiation damage
	# different endings after 5 year depending on the amount of damage suffered

	on_monthly = {
		events = {
			situation.204 # Update the variables used to calculate shielding costs every month
		}
		random_events = {
		 	250 = 0
		 	5 = situation.210 # malfunctioning drones
		 	5 = situation.213 # Faulty Assembly Line
			5 = situation.214 # Miscalculation
		 	10 = situation.250 # Disappearing pop
		}
	}

	# Stages
	stages = {
		radiation_damage_low = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_red
			end = 40
			target_modifier = {
				planet_jobs_simple_drone_produces_mult = -0.20
				planet_jobs_complex_drone_produces_mult = -0.20
			}
		}
		radiation_damage_mid = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_red
			end = 70
			target_modifier = {
				planet_jobs_simple_drone_produces_mult = -0.25
				planet_jobs_complex_drone_produces_mult = -0.25
				planet_stability_add = -30
			}
		}
		radiation_damage_high = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_red
			end = 100
			target_modifier = {
				planet_jobs_simple_drone_produces_mult = -0.30
				planet_jobs_complex_drone_produces_mult = -0.30
				planet_stability_add = -60
				country_unity_produces_mult = -0.10
			}
		}
	}

	# Approaches
	approach = { #Protect everydrone
		name = protect_everydrone
		icon = GFX_situation_approach_influence
		icon_background = GFX_situation_approach_bg_green
		potential = {
			target = {
				any_owned_pop_group = {
					is_robot_pop_group = yes
				}
			}
		}
		on_select = {
			custom_tooltip = approach_protect_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 1
				multiplier = target.total_drones_cost
			}
		}
		target_modifier = {
			# drones work better bc they're shielded, countering the situation's negative modifier
			planet_jobs_simple_drone_produces_mult = 0.20
			planet_jobs_complex_drone_produces_mult = 0.20
		}
	}

	approach = { #Protect simple drones
		name = protect_simple_drones
		icon = GFX_situation_approach_pop
		icon_background = GFX_situation_approach_bg_yellow
		potential = {
			target = {
				any_owned_pop_group = {
					is_robot_pop_group = yes
					is_pop_category = simple_drone
				}
			}
		}
		on_select = {
			custom_tooltip = approach_protect_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 1
				multiplier  = target.simple_drones_cost
				# multiply this value by the number
				# of drones we're protecting
			}
		}
		target_modifier = {
			# drones work better bc they're shielded, countering the situation's negative modifier
			planet_jobs_simple_drone_produces_mult = 0.20
		}
	}

	approach = { #Protect complex drones
		name = protect_complex_drones
		icon_background = GFX_situation_approach_bg_yellow
		icon = GFX_situation_approach_pop
		potential = {
			target = {
				any_owned_pop_group = {
					is_robot_pop_group = yes
					is_pop_category = complex_drone
				}
			}
		}
		on_select = {
			custom_tooltip = approach_protect_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 1
				multiplier = target.complex_drones_cost
			}
		}
		target_modifier = {
			# drones work better bc they're shielded, countering the situation's negative modifier
			planet_jobs_complex_drone_produces_mult = 0.20
		}
	}

	approach = { #Do Nothing
 		name = protect_nobody
		icon = GFX_situation_approach_shrug
		icon_background = GFX_situation_approach_bg_red
		default = yes
		on_select = {
			custom_tooltip = approach_protect_nobody_effect
		}
 	}


	#Progress
	# 1 year in stellaris = 12 months = 360 days
	# Situation automatically ends after 5 years
	# Default: reach worst ending in about 2 years (20 months) if you do nothing
	# 100 / 20 = 5

	monthly_progress = {
		base = 5
		modifier = {
			desc = string_current_approach
			current_situation_approach = protect_everydrone
			subtract = target.total_drones_percentage
		}
		modifier = {
			desc = string_current_approach
			current_situation_approach = protect_simple_drones
			subtract = target.simple_drones_percentage
		}
		modifier = {
			desc = string_current_approach
			current_situation_approach = protect_complex_drones
			subtract = target.complex_drones_percentage
		}
	}

	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
			#target = { NOT = { has_planet_modifier = magnetic_disruption } }
		}
	}
}

situation_tainted_voidspawn = {
	complete_icon_frame = GFX_situation_outcome_frame_green
	complete_icon = GFX_situation_outcome_positive
	picture = GFX_evt_voidspawn
	category = neutral
	situation_log_category = developments
	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 100
		}
	}
	initial_progress = 0
	on_progress_complete = {
		custom_tooltip = situation_tainted_voidspawn_finish_effect
		hidden_effect = {
			situation_event = { id = situation.1115 }
		}
	}
	approach = {
		name = approach_clean_the_contaminant
		icon = GFX_situation_approach_whip
		icon_background = GFX_situation_approach_bg_green
		default = yes
		ai_weight = {
			base = 10
		}
		on_select = {
			custom_tooltip = approach_clean_the_contaminant_effect
		}
		triggered_target_modifier = {
			potential = { owner = { is_gestalt = no } }
			planet_jobs_worker_produces_mult = -0.05
		}
		triggered_target_modifier = {
			potential = { owner = { is_gestalt = yes } }
			planet_jobs_simple_drone_produces_mult = -0.05
		}
	}
	approach = {
		name = approach_study_the_contaminant
		icon = GFX_situation_approach_research
		icon_background = GFX_situation_approach_bg_green
		resources = {
			category = situations
			produces = {
				society_research = 15
			}
		}
		on_select = {
			custom_tooltip = approach_study_the_contaminant_effect
		}
		triggered_target_modifier = {
			potential = { owner = { is_gestalt = no } }
			planet_jobs_specialist_produces_mult = -0.05
		}
		triggered_target_modifier = {
			potential = { owner = { is_gestalt = yes } }
			planet_jobs_complex_drone_produces_mult = -0.05
		}
	}
	monthly_progress = {
		base = 0
		modifier = {
			desc = string_current_approach
			add = 6
			current_situation_approach = approach_clean_the_contaminant
		}
		modifier = {
			desc = string_current_approach
			add = 4
			current_situation_approach = approach_study_the_contaminant
		}
	}
	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
		}
	}
	on_abort = {
		target = { clean_up_voidspawn_situation = yes }
	}
}

situation_stellarite_infested_star = {
	complete_icon_frame = GFX_situation_outcome_frame_red
	complete_icon = GFX_situation_outcome_negative
	fail_icon_frame = GFX_situation_outcome_frame_green
	fail_icon = GFX_situation_outcome_meh
	picture = GFX_evt_star_yellow
	category = negative
	situation_log_category = urgent_matters
	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = stage_unknown_effects
			end = 20
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = stage_unknown_effects
			on_first_enter = {
				situation_event = { id = situation.1155 }
			}
			end = 50
		}
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = stage_unknown_effects
			on_first_enter = {
				owner = {
					country_event = { id = situation.1160 }
				}
			}
			end = 60
		}
		stage_4 = {
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = stage_unknown_effects
			end = 100
		}
	}
	initial_progress = 10

	on_progress_complete = {
		custom_tooltip = situation_stellarite_infested_star_fail_tooltip
		hidden_effect = {
			situation_event = { id = situation.1170 }
		}
	}
	on_fail = {
		custom_tooltip = situation_stellarite_infested_star_finish_tooltip
		hidden_effect = {
			situation_event = { id = situation.1175 }
		}
	}
	approach = {
		name = approach_search_for_a_cure
		icon = GFX_situation_approach_research
		icon_background = GFX_situation_approach_bg_red
		default = yes
		ai_weight = {
			base = 10
		}
		on_select = {
			custom_tooltip = approach_search_for_a_cure_effect
		}
	}
	approach = {
		name = approach_cure_it
		icon = GFX_situation_approach_this_is_fine
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = studied_stellarite_infestation
			}
		}
		on_select = {
			custom_tooltip = approach_cure_it_effect
		}
		ai_weight = {
			base = 5
			modifier = {
				add = 100
				owner = {
					has_country_flag = studied_stellarite_infestation
				}
			}
			modifier = {
				factor = 0
				owner = {
					has_country_flag = will_not_stop_devourers
				}
			}
		}
	}
	monthly_progress = {
		base = 3
		modifier = {
			desc = string_current_approach
			add = -1
			current_situation_approach = approach_search_for_a_cure
		}
		modifier = {
			desc = string_current_approach
			add = -10
			current_situation_approach = approach_cure_it
		}
	}

	abort_trigger = {
		OR = {
			NOT = { exists = target.space_owner }
			target.space_owner = { NOT = { is_same_value = root.owner } }
		}
	}
}

## The Kaleidoscope
situation_kaleidoscope = {
	picture = GFX_evt_kaleidoscopic_lights
	category = neutral
	complete_icon_frame = GFX_situation_outcome_frame_blue
	complete_icon = GFX_situation_outcome_unknown
	situation_log_category = crises

	on_start = {
		owner = {
			set_variable = {
				which = kaleidoscope_owner_expenses
				value = 0
			}
			export_trigger_value_to_variable = {
				trigger = expenses
				variable = kaleidoscope_owner_expenses
				rounded = yes
			}
		}
	}

	on_progress_complete = {
		# Kaleidoscope bursts
		custom_tooltip = situation_unknown_outcome_kaleidoscope
		random_list = {
			10 = { # Good ending
				modifier = {
					add = value:kaleidoscope_good_ending_chances
				}
				situation_event = { id = situation.2041 }
			}
			90 = { # Bad ending
				modifier = {
					subtract = value:kaleidoscope_good_ending_chances
				}
				situation_event = { id = situation.2043 }
			}
		}
	}

	on_abort = { # effects handled by on_country_destroyed
	}

	abort_trigger = {
		OR = {
			NOT = { exists = target }
			target = {
				NOT = { is_same_value = root.owner }
			}
		}
	}

	triggered_modifier = {
		potential = {
			has_situation_flag = kaleidoscope_unnerving_patterns
		}
		modifier = {
			planet_stability_add = -5
		}
	}
	triggered_modifier = {
		potential = {
			has_situation_flag = kaleidoscope_ominous_patterns
		}
		modifier = {
			pop_happiness = -0.1
		}
	}
	triggered_modifier = {
		potential = {
			has_situation_flag = kaleidoscope_pilfering_patterns
		}
		modifier = {
			ship_speed_mult = -0.1
		}
	}
	triggered_modifier = {
		potential = {
			has_situation_flag = kaleidoscope_soothing_patterns
		}
		modifier = {
			planet_stability_add = 5
		}
	}
	triggered_modifier = {
		potential = {
			has_situation_flag = kaleidoscope_dazzling_patterns
		}
		modifier = {
			planet_resettlement_unemployed_destination_mult = 1.0
		}
	}

	# Progress
	initial_progress = 0
	stages = {
		kaleidoscope_progress = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 100
			custom_tooltip = stage_unknown_effects
		}
	}

	# 10 years of overfeeding to make it burst
	# 100 / 120 months = 0.8 (let's round it to 1)
	monthly_progress = {
		base = 0
		modifier = {
			add = 0.5
			desc = situation_kaleidoscope_monthly_change_tooltip
			current_situation_approach = approach_little_food
		}
		modifier = {
			add = 1.5
			desc = situation_kaleidoscope_monthly_change_tooltip
			current_situation_approach = approach_a_lot_of_food
		}
	}

	# Approaches
	approach = {
		name = approach_no_food
		icon = GFX_situation_approach_energy_credits
		icon_background = GFX_situation_approach_bg_red
		default = yes
		on_select = {
			custom_tooltip = approach_no_food_tooltip
			hidden_effect = {
				# gets angry and istantly lowers its mood
				event_target:global_event_country = {
					if = {
						limit = {
							check_variable = {
								which = kaleidoscope_global_mood
								value > 12
							}
						}
						set_variable = {
							which = kaleidoscope_global_mood
							value = 12
						}
					}
				}
			}
		}
		ai_weight = {
			base = 10
			# Are we in a deficit?
			modifier = {
				add = 10
				owner = {
					has_deficit = energy
				}
			}
			# Is the situation close to completion, so it's worth pushing through it?
			modifier = {
				add = -30
				situation_progress >= 85
				check_variable = {
					which = kaleidoscope_global_mood
					value >= 15
				}
			}
			# Don't let it explode in our face!
			modifier = {
				add = 10
				situation_progress >= 90
				check_variable = {
					which = kaleidoscope_global_mood
					value <= 5
				}
			}
			# Are we producing enough to mantain it?
			modifier = {
				add = -5
				owner = {
					resource_income_to_expenditure_balance_ratio = {
						resource = energy
						value >= 1
					}
				}
			}
			# Or do we have stockpiled energy to feed it?
			modifier = {
				add = -5
				owner = {
					resource_stockpile_compare = {
						resource = energy
						value >= owner.kaleidoscope_owner_expenses
					}
				}
			}
			# Do we hate xenos?
			modifier = {
				add = 20
				owner = {
					OR = {
						is_unfriendly = yes
						values_others = no
					}
				}
			}
			# Are we at war?
			modifier = {
				add = 10
				owner = {
					is_at_war = yes
				}
			}
			# Are we ready to send it to someone, or are we doing it already? Then we should anger it first
			modifier = {
				add = 50
				owner = {
					has_country_flag = previous_kaleidoscope_owner
					any_spynetwork = {
						has_available_spy_power >= 10
					}
				}
			}
		}
	}

	approach = {
		name = approach_little_food
		icon = GFX_situation_approach_energy_credits
		icon_background = GFX_situation_approach_bg_yellow
		on_select = {
			custom_tooltip = approach_little_food_tooltip
		}
		modifier = {
			country_energy_produces_mult = -0.30
		}
		ai_weight = {
			base = 5
			# Are we in a deficit?
			modifier = {
				add = -5
				owner = {
					has_deficit = energy
				}
			}
			# Is the situation close to completion, so it's worth pushing through it?
			modifier = {
				add = 10
				situation_progress >= 85
				check_variable = {
					which = kaleidoscope_global_mood
					value >= 15
				}
			}
			# Don't let it explode in our face!
			modifier = {
				add = 5
				situation_progress >= 90
				check_variable = {
					which = kaleidoscope_global_mood
					value <= 5
				}
			}
			# Are we producing enough to mantain it?
			modifier = {
				add = 10
				owner = {
					resource_income_to_expenditure_balance_ratio = {
						resource = energy
						value >= 1.3
					}
				}
			}
			# Or do we have stockpiled energy to feed it?
			modifier = {
				add = 5
				owner = {
					resource_stockpile_compare = {
						resource = energy
						value >= owner.kaleidoscope_owner_expenses
					}
				}
			}
			# Do we hate xenos?
			modifier = {
				add = 0
				owner = {
					OR = {
						is_unfriendly = yes
						values_others = no
					}
				}
			}
			# Are we at war?
			modifier = {
				add = 5
				owner = {
					is_at_war = yes
				}
			}
			# Are we ready to send it to someone, or are we doing it already? Then we should anger it first
			modifier = {
				factor = 0
				owner = {
					has_country_flag = previous_kaleidoscope_owner
					any_spynetwork = {
						has_available_spy_power >= 10
					}
				}
			}
		}
	}

	approach = {
		name = approach_a_lot_of_food
		icon = GFX_situation_approach_energy_credits
		icon_background = GFX_situation_approach_bg_green
		on_select = {
			custom_tooltip = approach_a_lot_of_food_tooltip
		}
		modifier = {
			country_energy_produces_mult = -0.60
		}
		ai_weight = {
			base = 0
			# Are we in a deficit?
			modifier = {
				add = -10
				owner = {
					has_deficit = energy
				}
			}
			# Is the situation close to completion, so it's worth pushing through it?
			modifier = {
				add = 20
				situation_progress >= 90
				check_variable = {
					which = kaleidoscope_global_mood
					value >= 15
				}
			}
			# Are we producing enough to mantain it?
			modifier = {
				add = 20
				owner = {
					resource_income_to_expenditure_balance_ratio = {
						resource = energy
						value >= 1.7
					}
				}
			}
			# Or do we have stockpiled energy to feed it?
			modifier = {
				add = 10
				owner = {
					resource_stockpile_compare = {
						resource = energy
						value >= owner.kaleidoscope_owner_expenses
					}
				}
			}
			# Do we hate xenos?
			modifier = {
				add = -5
				owner = {
					OR = {
						is_unfriendly = yes
						values_others = no
					}
				}
			}
			# Are we at war?
			modifier = {
				add = -5
				owner = {
					is_at_war = yes
				}
			}
			# Are we ready to send it to someone, or are we doing it already? Then we should anger it first
			modifier = {
				factor = 0
				owner = {
					has_country_flag = previous_kaleidoscope_owner
					any_spynetwork = {
						has_available_spy_power >= 10
					}
				}
			}
		}
	}

	# Events
	on_monthly = {
		events = {
			situation.2001 # Update global progress
		}
		random_events = {
			100 = 0
			1 = situation.2030 # Negative 1 - infests another planet
			1 = situation.2031 # Negative 2 - eats energy building
			1 = situation.2032 # Negative 3 - unnerving patterns (- pop happiness)
			1 = situation.2033 # Negative 4 - ominous patterns (spiritualists)
			1 = situation.2034 # Negative 5 - slow ships
			1 = situation.2037 # Positive 1 - soothing patterns (unity)
			1 = situation.2038 # Positive 2 - dazzling patterns (science)
			2 = situation.2048 # Kaleidoscope could get a Dyson sphere?
		}
	}
}

situation_negative_mass = {
	picture = GFX_evt_wormhole
	initial_progress = 75
	complete_icon_frame = GFX_situation_outcome_frame_red
	complete_icon = GFX_situation_outcome_negative
	fail_icon_frame = GFX_situation_outcome_frame_green
	fail_icon = GFX_situation_outcome_positive
	category = negative
	situation_log_category = urgent_matters
	on_start = {
		situation_event = { id = colony.9865 }
	}
	on_progress_complete = { #Lose the world
		custom_tooltip = situation_negative_mass_complete_tooltip
		owner = { country_event = { id = colony.9851 } }
	}
	on_fail = { #Save the world
		custom_tooltip = situation_negative_mass_fail_tooltip
		owner = { country_event = { id = colony.9850 } }
	}
	monthly_progress = {
		base = 3
		modifier = {
			desc = string_nmass_year
			check_variable = {
				which = situation_age
				value >= 0
			}
			check_variable = {
				which = situation_age
				value <= 5
			}
			add = situation_age
		}
		modifier = {
			desc = string_nmass_too_late
			check_variable = {
				which = situation_age
				value > 5
			}
			add = 10
		}
		modifier = {
			desc = string_current_approach
			current_situation_approach = approach_save_b_world
			subtract = 7
		}
		modifier = {
			desc = string_redoubled_efforts
			has_situation_flag = redoubled_efforts
			subtract = 3
		}
		modifier = {
			desc = string_took_pops
			has_situation_flag = took_pops
			add = 1
		}
	}
	approach = {
		name = approach_save_b_world
		icon = GFX_situation_approach_pop
		icon_background = GFX_situation_approach_bg_green
		potential = {
			has_situation_flag = willing_to_help
		}
		resources = {
			category = situations
			upkeep = {
				energy = 45
			}
		}
		triggered_modifier = {
			potential = {
				NOT = { has_situation_flag = redoubled_efforts }
			}
			country_physics_research_produces_mult = -0.10
			country_engineering_research_produces_mult = -0.10
			country_society_research_produces_mult = -0.10
		}
		triggered_modifier = {
			potential = { has_situation_flag = redoubled_efforts }
			country_physics_research_produces_mult = -0.30
			country_engineering_research_produces_mult = -0.30
			country_society_research_produces_mult = -0.30
		}
	}
	approach = {
		name = approach_observe_nmass
		icon = GFX_situation_approach_research
		icon_background = GFX_situation_approach_bg_red
		potential = {
			NOT = { has_situation_flag = willing_to_help }
		}
		modifier = {
			country_physics_research_produces_mult = 0.40
		}
	}
	approach = {
		name = approach_plunder_nmass
		icon = GFX_situation_approach_this_is_fine
		icon_background = GFX_situation_approach_bg_red
		potential = {
			NOT = { has_situation_flag = willing_to_help }
		}
		resources = {
			category = situations
			produces = {
				alloys = 35
				minerals = 50
				energy = 25
			}
			produces = {
				trigger = { owner = { country_uses_food = yes } }
				food = 30
			}
		}
	}
	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_red
			end = 30
			on_first_enter = {
				situation_event = { id = colony.9860 days = 12 } #Plundering famous works
				situation_event = { id = colony.9880 days = 12 }	#Desperate Drones
			}
		}
		stage_2 = {
			end = 74
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_red
			on_first_enter = {
				situation_event = { id = colony.9855 days = 33 } #immigrants
				situation_event = { id = colony.9875 days = 33 } #Offloading Optimization
			}
		}
		stage_3 = {
			end = 95
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_red
		}
		stage_4 = {
			end = 100
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_red
			on_first_enter = {
				situation_event = { id = colony.9870 } #Last plea
			}
		}
	}
	abort_trigger = {
		OR = {
			NOT = { exists = target.owner }
			target.owner = { NOT = { is_same_value = root.owner } }
		}
	}
}
