### Red Giant Origin situation
# Scope = Situation
# Owner = Player that has the origin+situation
# target = Sun thats expanding
situation_red_giant_expansion = {
	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
	picture = GFX_evt_star_yellow
	category = neutral
	initial_progress = 10
	situation_log_category = empire_concerns

	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = situation_red_giant_expansion_stage_1
			end = 300
			on_enter = {
				target.solar_system = {
					every_system_planet_colony = {
						remove_modifier = red_giant_stage_2
						add_modifier = {
							modifier = "red_giant_stage_1"
							days  = -1
						}
					}
				}
			}
			target_modifier = {
				habitability_ceil_add = -0.1
				planet_jobs_physics_research_produces_mult = 0.10
				planet_jobs_energy_produces_mult = 0.10
			}
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = situation_red_giant_expansion_stage_2
			end = 600
			on_first_enter = {
				situation_event = { id = infernals.65 days = 1 }
			}
			on_enter = {
				target.solar_system = {
					every_system_planet_colony = {
						remove_modifier = red_giant_stage_1
						remove_modifier = red_giant_stage_3
						add_modifier = {
							modifier = "red_giant_stage_2"
							days  = -1
						}
					}
				}
			}
			target_modifier = {
				habitability_ceil_add = -0.2
				planet_jobs_physics_research_produces_mult = 0.20
				planet_jobs_energy_produces_mult = 0.10
			}
		}
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = situation_red_giant_expansion_stage_3
			end = 900
			on_first_enter = {
				situation_event = { id = infernals.70 days = 1 }
			}
			on_enter = {
				target.solar_system = {
					every_system_planet_colony = {
						remove_modifier = red_giant_stage_2
						remove_modifier = red_giant_stage_4
						add_modifier = {
							modifier = "red_giant_stage_3"
							days  = -1
						}
					}
				}
			}
			target_modifier = {
				habitability_ceil_add = -0.4
				planet_jobs_upkeep_mult = 0.2
				planet_jobs_physics_research_produces_mult = 0.30
				planet_jobs_energy_produces_mult = 0.10
			}
		}
		stage_4 = {
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = situation_red_giant_expansion_stage_4
			end = 1200
			on_first_enter = {
				situation_event = { id = infernals.75 days = 5 }
			}
			on_enter = {
				target.solar_system = {
					every_system_planet_colony = {
						remove_modifier = red_giant_stage_3
						remove_modifier = red_giant_stage_5
						add_modifier = {
							modifier = "red_giant_stage_4"
							days  = -1
						}
					}
				}
			}
			target_modifier = {
				habitability_ceil_add = -0.6
				planet_jobs_upkeep_mult = 0.4
				planet_jobs_physics_research_produces_mult = 1.0
				planet_jobs_energy_produces_mult = 0.10
			}
		}
		stage_5 = {
			icon = GFX_situation_stage_5
			icon_background = GFX_situation_stage_frame_red
			custom_tooltip = situation_red_giant_expansion_stage_5
			end = 1500
			on_first_enter = {
				target = {
					carrier_event = { id = infernals.80 days = 5 }
				}
			}
			on_enter = {
				target.solar_system = {
					every_system_planet_colony = {
						remove_modifier = red_giant_stage_4
						add_modifier = {
							modifier = "red_giant_stage_5"
							days  = -1
						}
					}
				}
			}
			target_modifier = {
				habitability_ceil_add = -0.8
				planet_jobs_upkeep_mult = 0.8
				planet_jobs_physics_research_produces_mult = 1.5
				planet_jobs_energy_produces_mult = 0.10
			}
		}
	}

	on_progress_complete = { #explosive nova-like event
		custom_tooltip = situation_red_giant_expansion_fail_tooltip
		hidden_effect = {
			situation_event = { id = infernals.50 }
			owner = {
				set_country_flag = situation_red_giant_ended
			}
		}
	}
	on_fail = {	#successfully deflated
		custom_tooltip = situation_red_giant_expansion_finish_tooltip
		hidden_effect = {
			situation_event = { id = infernals.60 }
			owner = {
				set_country_flag = situation_red_giant_ended
			}
		}
	}
	on_abort = {
		owner = {
			set_country_flag = situation_red_giant_ended
		}
	}
	approach = {
		default = yes
		name = approach_reassure_public
		icon = GFX_situation_approach_amenities
		icon_background = GFX_situation_approach_bg_red
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach1
			}
		}
		resources = {
			category = situations
			produces = {
				unity = 10
			}
		}

		ai_weight = {
			base = 10
		}
		on_select = {
			custom_tooltip = approach_reassure_public_effect
		}
	}
	approach = {
		name = approach_find_the_cause
		icon = GFX_situation_approach_research
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach1
			}
		}
		modifier = {
			country_physics_research_produces_mult = -0.10
		}
		on_select = {
			custom_tooltip = approach_find_the_cause_effect
		}
		ai_weight = {
			base = 5
		}
	}
	approach = {
		name = approach_suppress_unrest2
		icon = GFX_situation_approach_scales
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach2
			}
		}
		on_select = {
			custom_tooltip = approach_suppress_unrest2_effect
		}
		ai_weight = {
			base = 5
		}
	}
	approach = {
		name = approach_disrupt_subspace_tunnels2
		icon = GFX_situation_approach_disrupt
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach2
			}
		}
		on_select = {
			custom_tooltip = approach_disrupt_subspace_tunnels2_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 20
			}
		}
		ai_weight = {
			base = 5
		}
	}
	approach = {
		name = approach_add_fuel_to_the_fire3
		icon = GFX_situation_approach_this_is_fine
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach3
			}
		}
		on_select = {
			custom_tooltip = approach_add_fuel_to_the_fire3_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 10
			}
		}
		ai_weight = {
			base = 0
		}
	}
	approach = {
		name = approach_wait_and_see3
		icon = GFX_situation_approach_shrug
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach3
			}
		}
		on_select = {
			custom_tooltip = approach_wait_and_see3_effect
		}
		ai_weight = {
			base = 15
		}
	}
	approach = {
		name = approach_siphon_stellar_material3
		icon = GFX_situation_approach_dark_matter
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach3
			}
		}
		on_select = {
			custom_tooltip = approach_siphon_stellar_material3_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 70
			}
		}
		ai_weight = {
			base = 15
		}
	}
	approach = {
		name = approach_continue_siphoning4
		icon = GFX_situation_approach_dark_matter
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				OR = {
					has_country_flag = situation_red_giant_continue_siphoning
					has_country_flag = situation_red_giant_expansion_approach4
				}
			}
		}
		on_select = {
			custom_tooltip = approach_continue_siphoning4_effect
		}
		resources = {
			category = situations
			produces = {
				sr_dark_matter = 20
				physics_research = 10
			}
			upkeep = {
				energy = 10
			}
		}
		ai_weight = {
			base = 0
		}
	}
	approach = {
		name = approach_stabilize_the_star4
		icon = GFX_situation_approach_unity
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				OR = {
					has_country_flag = situation_red_giant_stabilize_the_star
					has_country_flag = situation_red_giant_expansion_approach4
				}
			}
		}
		on_select = {
			custom_tooltip = approach_stabilize_the_star4_effect
		}
		ai_weight = {
			base = 5
		}
	}
	approach = {
		name = approach_cease_activity4
		icon = GFX_situation_approach_shrug
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				has_country_flag = situation_red_giant_expansion_approach4
			}
		}
		on_select = {
			custom_tooltip = approach_cease_activity4_effect
		}
		ai_weight = {
			base = 5
		}
	}
	approach = {
		name = approach_reverse_inflation4
		icon = GFX_situation_approach_handshake
		icon_background = GFX_situation_approach_bg_green
		potential = {
			owner = {
				OR = {
					has_country_flag = situation_red_giant_reverse_inflation
					has_country_flag = situation_red_giant_expansion_approach4
				}
			}
		}
		on_select = {
			custom_tooltip = approach_reverse_inflation4_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 15
			}
		}
		ai_weight = {
			base = 50
		}
	}
	approach = {
		name = approach_at_any_cost
		icon = GFX_situation_approach_disrupt
		icon_background = GFX_situation_approach_bg_red
		potential = {
			OR = {
				current_stage = stage_4
				current_stage = stage_5
			}
			owner = {
				OR = {
					has_country_flag = situation_red_giant_expansion_approach1
					has_country_flag = situation_red_giant_expansion_approach2
				}
			}
		}
		on_select = {
			custom_tooltip = approach_at_any_cost_effect
		}
		resources = {
			category = situations
			upkeep = {
				energy = 150
			}
		}
		ai_weight = {
			base = 0
		}
	}
	monthly_progress = {
		base = 0
		modifier = {
			desc = string_current_approach
			add = 7
			current_situation_approach = approach_reassure_public
		}
		modifier = {
			desc = string_current_approach
			add = 7
			current_situation_approach = approach_find_the_cause
		}
		modifier = {
			desc = string_current_approach
			add = 7
			current_situation_approach = approach_suppress_unrest2
		}
		modifier = {
			desc = string_current_approach
			add = 3
			current_situation_approach = approach_disrupt_subspace_tunnels2
		}
		modifier = {
			desc = string_current_approach
			add = 50
			current_situation_approach = approach_add_fuel_to_the_fire3
		}
		modifier = {
			desc = string_current_approach
			add = -3
			current_situation_approach = approach_wait_and_see3
		}
		modifier = {
			desc = string_current_approach
			add = -25
			current_situation_approach = approach_siphon_stellar_material3
		}
		modifier = {
			desc = string_current_approach
			add = 50
			current_situation_approach = approach_continue_siphoning4
		}
		modifier = {
			desc = string_current_approach
			add = 0
			current_situation_approach = approach_stabilize_the_star4
		}
		modifier = {
			desc = string_current_approach
			add = -3
			current_situation_approach = approach_cease_activity4
		}
		modifier = {
			desc = string_current_approach
			add = -50
			current_situation_approach = approach_reverse_inflation4
		}
		modifier = {
			desc = string_current_approach
			add = 0.5
			current_situation_approach = approach_at_any_cost
		}
	}
	# Events
	on_monthly = {
		events = {
			infernals.85 # Update red giant size progress
		}
	}
}

situation_cosmic_dawn = {
	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_negative
	picture = GFX_evt_molten
	category = positive
	situation_log_category = empire_concerns

	start_value = 0

	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = sit_cd_stage1_tt
			end = 100
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = sit_cd_stage2_tt
			end = 200
			on_first_enter = {
				situation_event = { id = infernals.2510 }
			}
		}
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = sit_cd_stage3_tt
			end = 300
			on_first_enter = {
				situation_event = { id = infernals.2515 }
			}
		}
		stage_4 = {
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = sit_cd_stage4_tt
			end = 400
			on_first_enter = {
				situation_event = { id = infernals.2540 }
			}
		}
		stage_5 = {
			icon = GFX_situation_stage_5
			icon_background = GFX_situation_stage_frame_green
			custom_tooltip = sit_cd_stage5_tt
			end = 500
			on_first_enter = {
				situation_event = { id = infernals.2555 }
			}
		}
	}

	triggered_blocked_desc = {
		trigger = {
			owner = {
				AND = {
					has_country_flag = CD_situation_trigger
					has_country_flag = has_cd_storm_project
				}
			}
		}
		text = "situation_cd_mod_storm"
	}
	triggered_blocked_desc = {
		trigger = {
			owner = {
				AND = {
					has_country_flag = CD_situation_trigger
					has_country_flag = has_cd_bribe_project
				}
			}
		}
		text = "situation_cd_mod_bribe"
	}

	approach = {
		name = approach_cd_mining
		icon = GFX_situation_approach_minerals
		icon_background = GFX_situation_approach_bg_yellow
		resources = {
			category = situations
			upkeep = {
				energy = 7
				mult = value:maxed_years_passed
			}
			upkeep = {
				energy = 30
			}
			produces = {
				minerals = 4
				mult = value:maxed_years_passed
			}
		}
		on_select = {
			custom_tooltip = approach_cd_mining_tt
		}
	}
	approach = {
		name = approach_cd_drilling
		icon = GFX_situation_approach_minerals
		icon_background = GFX_situation_approach_bg_green
		resources = {
			category = situations
			upkeep = {
				energy = 2
				mult = value:maxed_years_passed
			}
			produces = {
				minerals = 2
				mult = value:maxed_years_passed
			}
		}
		on_select = {
			custom_tooltip = approach_cd_drilling_tt
		}
	}
	approach = {
		name = approach_cd_financial
		icon = GFX_situation_approach_energy_credits
		icon_background = GFX_situation_approach_bg_green
		resources = {
			category = situations
			upkeep = {
				trade = 2
				mult = value:maxed_years_passed
			}
			produces = {
				minerals = 4
				mult = value:maxed_years_passed
			}
		}
		potential = {
			owner = { is_megacorp = yes }
		}
		on_select = {
			custom_tooltip = approach_cd_financial_tt
		}
	}

	monthly_progress = {
		base = 1
		modifier = {
			add = @approach_cd_mining
			current_situation_approach = approach_cd_mining
			desc = situation_cd_mod_mining
		}
		modifier = {
			add = @approach_cd_drilling
			current_situation_approach = approach_cd_drilling
			desc = situation_cd_mod_drilling
		}
		modifier = {
			add = @approach_cd_financial
			current_situation_approach = approach_cd_financial
			desc = situation_cd_mod_financial
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_country_flag = CD_situation_trigger
					has_country_flag = has_cd_storm_project
				}
			}
			desc = situation_cd_mod_storm
		}
		modifier = {
			factor = 0
			owner = {
				has_country_flag = CD_situation_trigger
				has_country_flag = has_cd_bribe_project
			}
			desc = situation_cd_mod_bribe
		}
	}

	on_progress_complete = {
		custom_tooltip = situation_cosmic_dawn_finish_tt
		hidden_effect = {
			situation_event = { id = infernals.2580 }
		}
	}
}

# Hyperthermia countdown
situation_galactic_hyperthermia_timer = {
	picture = GFX_evt_hangar_bay
	complete_icon_frame = GFX_situation_outcome_frame_blue
	complete_icon = GFX_situation_outcome_unknown
	initial_progress = 1
	situation_log_category = ambitions

	on_progress_complete = {
		custom_tooltip = situation_gh_timer_outcome
		hidden_effect = {
			owner = { country_event = { id = infernals.1041 } }
			destroy_situation = this
			clear_variable = gh_crisis_difficulty_var
			clear_variable = gh_crisis_opponent_var
		}
	}

	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 140
			custom_tooltip = stage_unknown_effects
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_blue
			end = 150
			custom_tooltip = stage_unknown_effects
			on_first_enter = {
				owner = {
					country_event = { id = infernals.1035 }
				}
			}
		}
	}

	approach = {
		name = situation_gh_approach_timer
		icon = GFX_situation_approach_this_is_fine
		icon_background = GFX_situation_approach_bg_green
		default = yes
		on_select = {
			custom_tooltip = situation_gh_approach_timer_tt
		}
	}

	monthly_progress = {
		base = 3
		modifier = {
			add = owner.gh_crisis_difficulty_var
			desc = situation_gh_difficulty_progress
		}
		modifier = {
			add = owner.gh_crisis_opponent_var
			desc = situation_gh_opponent_progress
		}
	}
}

# Hyperthermia doomclock
situation_galactic_hyperthermia = {
	picture = GFX_evt_cosmic_storms_solar_storm
	complete_icon_frame = GFX_situation_outcome_frame_blue
	complete_icon = GFX_situation_outcome_unknown
	initial_progress = 10
	situation_log_category = ambitions
	desc = {
		trigger = {
			owner = { has_crisis_level = crisis_hyperthermia_level_5 }
		}
		text = situation_hyperthermia_desc_perp
	}
	desc = {
		trigger = {
			owner = { NOT = { has_crisis_level = crisis_hyperthermia_level_5 } }
		}
		text = situation_hyperthermia_desc
	}

	on_progress_complete = {
		custom_tooltip = situation_galactic_hyperthermia_outcome
		hidden_effect = {
			if = {
				limit = {
					owner = {
						has_crisis_level = crisis_hyperthermia_level_5
						is_same_value = event_target:hyperthermia_empire
					}
				}
				owner = {
					set_country_flag = INF_A_won_hyperthermia # Galactic Firestorm achievement
					country_event = { id = infernals.1055 days = 1 }
				}
				destroy_situation = this
			}
			else_if = {
				limit = {
					owner = { has_ascension_perk = ap_galactic_hyperthermia }
				}
				owner = { country_event = { id = infernals.1056 } }
				abort_situation = this
			}
		}
	}

	stages = {
		stage_1 = {
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_blue
			end = 10
			custom_tooltip = stage_unknown_effects
		}
		stage_2 = {
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_blue
			end = 200
			custom_tooltip = stage_unknown_effects
		}
		stage_3 = {
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_blue
			end = 300
			on_first_enter = {
				situation_event = { id = infernals.1045 }
			}
			custom_tooltip = stage_unknown_effects
		}
		stage_4 = {
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_blue
			end = 350
			custom_tooltip = stage_unknown_effects
		}
	}

	approach = {
		name = situation_gh_approach_perp
		icon = GFX_situation_approach_this_is_fine
		icon_background = GFX_situation_approach_bg_green
		default = yes
		potential = {
			owner = { is_same_value = event_target:hyperthermia_empire }
		}
		on_select = {
			custom_tooltip = situation_gh_approach_perp_tt
		}
	}
	approach = {
		name = situation_gh_approach_other
		icon = GFX_situation_approach_this_is_fine
		icon_background = GFX_situation_approach_bg_yellow
		potential = {
			owner = { NOT = { is_same_value = event_target:hyperthermia_empire } }
		}
		on_select = {
			custom_tooltip = situation_gh_approach_other_tt
		}
	}

	monthly_progress = {
		base = 0
		modifier = {
			add = event_target:hyperthermia_empire.gh_crisis_monthly_var
			desc = situation_galactic_hyperthermia_progress
		}
		modifier = {
			add = 0 # Won't do much except showing the player why it is currently on 0 (done via script)
			current_stage = stage_1
			desc = situation_galactic_hyperthermia_stage1
		}
	}
}
