namespace = apb_overdrive

# Meltdown (fired once from the situation's on_progress_complete).
# Applies the penalties in immediate and ends the situation in after, like vanilla toxoids.25/30.
situation_event = {
	id = apb_overdrive.10
	title = apb_overdrive.10.name
	desc = apb_overdrive.10.desc
	picture = GFX_evt_nuclear_explosion
	show_sound = event_bad_omen
	location = owner.capital_scope
	situation = this
	is_triggered_only = yes

	immediate = {
		owner = {
			add_modifier = { modifier = apb_overdrive_meltdown days = 3600 }
			set_timed_country_flag = { flag = apb_overdrive_locked days = 3600 }
			capital_scope? = {
				add_planet_devastation = 50
				add_modifier = { modifier = apb_overdrive_meltdown_capital days = 3600 }
			}
		}
	}

	option = {
		name = apb_overdrive.10.a
		custom_tooltip = apb_overdrive_meltdown_tt
	}

	after = {
		destroy_situation = this
	}
}

# Cooled down to 0 (fired once from the situation's on_fail); ends the situation in after
situation_event = {
	id = apb_overdrive.11
	title = apb_overdrive.11.name
	desc = apb_overdrive.11.desc
	picture = GFX_evt_machine_sapience
	show_sound = event_default
	situation = this
	is_triggered_only = yes

	option = {
		name = apb_overdrive.11.a
	}

	after = {
		destroy_situation = this
	}
}

# Gamble: coolant breach (heat 50+)
situation_event = {
	id = apb_overdrive.20
	title = apb_overdrive.20.name
	desc = apb_overdrive.20.desc
	picture = GFX_evt_generator_powerup
	show_sound = event_bad_omen
	situation = this
	is_triggered_only = yes

	trigger = {
		situation_progress >= 50
		NOT = { has_situation_flag = apb_overdrive_ending }
		owner = { NOT = { has_country_flag = apb_overdrive_gamble_cd } }
	}

	immediate = {
		owner = { set_timed_country_flag = { flag = apb_overdrive_gamble_cd days = 720 } }
	}

	option = {
		name = apb_overdrive.20.a
		allow = {
			owner = { has_resource = { type = alloys amount >= 300 } }
		}
		owner = { add_resource = { alloys = -300 } }
		add_situation_progress = -15
		ai_chance = { factor = 2 }
	}
	option = {
		name = apb_overdrive.20.b
		add_situation_progress = 5
		owner = {
			random_owned_planet = {
				limit = {
					is_colony = yes
					is_capital = no
				}
				add_modifier = { modifier = apb_overdrive_scorched days = 1800 }
			}
		}
		ai_chance = { factor = 1 }
	}
}

# Gamble: overclocked insight (heat 40+)
situation_event = {
	id = apb_overdrive.21
	title = apb_overdrive.21.name
	desc = apb_overdrive.21.desc
	picture = GFX_evt_engineering_research
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		situation_progress >= 40
		NOT = { has_situation_flag = apb_overdrive_ending }
		owner = { NOT = { has_country_flag = apb_overdrive_gamble_cd } }
	}

	immediate = {
		owner = { set_timed_country_flag = { flag = apb_overdrive_gamble_cd days = 720 } }
	}

	option = {
		name = apb_overdrive.21.a
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		add_situation_progress = 10
		ai_chance = { factor = 1 }
	}
	option = {
		name = apb_overdrive.21.b
		add_situation_progress = -5
		ai_chance = { factor = 1 }
	}
}

# Gamble: emergency coolant purge (heat 60+)
situation_event = {
	id = apb_overdrive.22
	title = apb_overdrive.22.name
	desc = apb_overdrive.22.desc
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_bad_omen
	situation = this
	is_triggered_only = yes

	trigger = {
		situation_progress >= 60
		NOT = { has_situation_flag = apb_overdrive_ending }
		owner = { NOT = { has_country_flag = apb_overdrive_gamble_cd } }
	}

	immediate = {
		owner = { set_timed_country_flag = { flag = apb_overdrive_gamble_cd days = 720 } }
	}

	option = {
		name = apb_overdrive.22.a
		random_list = {
			60 = {
				add_situation_progress = -25
			}
			40 = {
				add_situation_progress = 15
			}
		}
		ai_chance = { factor = 1 }
	}
	option = {
		name = apb_overdrive.22.b
		ai_chance = { factor = 1 }
	}
}
