# Core Overdrive (ap_core_overdrive): the "Core Temperature" situation.
# Started by the apb_engage_overdrive edict. Bidirectional bar from 0 to 100, starting at 10.
# 100 = meltdown (penalties, 10-year lockout); 0 = cooled down (clean end).

apb_situation_core_overdrive = {
	picture = GFX_evt_machine_sapience
	situation_log_category = empire_concerns

	potential = {
		has_ascension_perk = ap_core_overdrive
	}

	start_value = 0
	initial_progress = 10
	progress_direction = bidirectional
	complete_category = negative
	fail_category = positive

	complete_icon = GFX_situation_outcome_negative
	complete_icon_frame = GFX_situation_outcome_frame_red
	fail_icon = GFX_situation_outcome_positive
	fail_icon_frame = GFX_situation_outcome_frame_green

	# Meltdown. Same pattern as vanilla relentless_industrialists_situation: the ending only fires a
	# situation_event; that event applies the effects (immediate) and ends the situation (after).
	# The situation flag makes sure the ending is handed over only once.
	on_progress_complete = {
		custom_tooltip = apb_overdrive_meltdown_tt
		hidden_effect = {
			if = {
				limit = { NOT = { has_situation_flag = apb_overdrive_ending } }
				set_situation_flag = apb_overdrive_ending
				situation_event = { id = apb_overdrive.10 }
			}
		}
	}

	# Vented down to 0
	on_fail = {
		custom_tooltip = apb_overdrive_cooled_tt
		hidden_effect = {
			if = {
				limit = { NOT = { has_situation_flag = apb_overdrive_ending } }
				set_situation_flag = apb_overdrive_ending
				situation_event = { id = apb_overdrive.11 }
			}
		}
	}

	stages = {
		apb_overdrive_stage_1 = {
			end = 25
			icon = GFX_situation_stage_1
			icon_background = GFX_situation_stage_frame_green
			modifier = {
				planet_jobs_produces_mult = 0.05
			}
		}
		apb_overdrive_stage_2 = {
			end = 50
			icon = GFX_situation_stage_2
			icon_background = GFX_situation_stage_frame_yellow
			modifier = {
				planet_jobs_produces_mult = 0.10
				ship_fire_rate_mult = 0.10
			}
		}
		apb_overdrive_stage_3 = {
			end = 75
			icon = GFX_situation_stage_3
			icon_background = GFX_situation_stage_frame_orange
			modifier = {
				planet_jobs_produces_mult = 0.20
				ship_fire_rate_mult = 0.20
			}
		}
		apb_overdrive_stage_4 = {
			end = 100
			icon = GFX_situation_stage_4
			icon_background = GFX_situation_stage_frame_red
			modifier = {
				planet_jobs_produces_mult = 0.35
				ship_fire_rate_mult = 0.30
				planet_stability_add = -5
			}
		}
	}

	monthly_progress = {
		base = 0
		modifier = {
			desc = apb_overdrive_push_progress
			current_situation_approach = apb_overdrive_push
			add = 6
		}
		modifier = {
			desc = apb_overdrive_hold_progress
			current_situation_approach = apb_overdrive_hold
			add = 1.5
		}
		modifier = {
			desc = apb_overdrive_vent_progress
			current_situation_approach = apb_overdrive_vent
			add = -5
		}
	}

	approach = {
		name = apb_overdrive_push
		icon = GFX_situation_approach_fist
		icon_background = GFX_situation_approach_bg_red
		on_select = {
			custom_tooltip = apb_overdrive_push_tt
		}
		modifier = {
			planet_jobs_produces_mult = 0.05
			ship_fire_rate_mult = 0.05
		}
		ai_weight = {
			base = 1
			modifier = {
				add = -10
				situation_progress > 50
			}
		}
	}

	approach = {
		name = apb_overdrive_hold
		icon = GFX_situation_approach_balance_sheet
		icon_background = GFX_situation_approach_bg_yellow
		default = yes
		on_select = {
			custom_tooltip = apb_overdrive_hold_tt
		}
		ai_weight = {
			base = 2
		}
	}

	approach = {
		name = apb_overdrive_vent
		icon = GFX_situation_approach_shrug
		icon_background = GFX_situation_approach_bg_green
		on_select = {
			custom_tooltip = apb_overdrive_vent_tt
		}
		modifier = {
			planet_jobs_produces_mult = -0.10
		}
		ai_weight = {
			base = 0
			modifier = {
				add = 10
				situation_progress > 70
			}
		}
	}

	on_monthly = {
		random_events = {
			100 = 0
			5 = apb_overdrive.20
			5 = apb_overdrive.21
			5 = apb_overdrive.22
		}
	}
}
