develop_nuclear_weapon = {
	is_shown = {
		has_technology_researched = chicago_pile_one
		NOT = {
			has_variable = warhead_current_stockpile
		}
	}

	possible = {
		has_technology_researched = theories_of_strategic_strike
		NOT = {
			has_journal_entry = je_Mod_Nuclear_Atomic_Weapon_Tracker
		}
	}

	when_taken = {
		set_variable = {
			name = warhead_current_stockpile
			value = 0
		}
		set_variable = {
			name = strike_capacity_current_stockpile
			value = 0
		}
		add_journal_entry = {
			type = je_Mod_Nuclear_Atomic_Weapon_Tracker
		}
		add_journal_entry = {
			type = je_Mod_Nuclear_Delivery_Capacity_Tracker
		}
	}

	ai_chance = {
		base = 100		
		modifier = {
			OR = {
				is_diplomatic_play_committed_participant = yes
				is_at_war = yes
			}
			add = 1000
		}	
	}
}

launch_nuclear_strike = {
	is_shown = {
		has_journal_entry = je_Mod_Nuclear_Atomic_Weapon_Tracker
	}

	possible = {
		has_journal_entry = je_Mod_Nuclear_Atomic_Weapon_Tracker
		is_at_war = yes
		NOT = {
			has_variable = nuclear_strike_cooldown
		}
		var:warhead_current_stockpile >= 1
		var:strike_capacity_current_stockpile >= 1
		is_ai = no ## A specific one for AI
	}

	when_taken = {
		trigger_event = mod_nuclear_strategic_strike.1
		set_variable = {
			name = nuclear_strike_cooldown
			days = 3
		}
	}

	ai_chance = {
		base = 10
	}
}

launch_nuclear_strike_ai = {
	is_shown = {
		has_journal_entry = je_Mod_Nuclear_Atomic_Weapon_Tracker
	}

	possible = {
		var:warhead_current_stockpile >= 1
		var:strike_capacity_current_stockpile >= 1
		is_at_war = yes
		NOT = {
			has_variable = nuclear_strike_cooldown
		}
		OR = {
			has_variable = recent_nuclear_strike
			AND = {
				any_scope_war = {
					has_war_support = { 
						target = ROOT
						value <= -50
					}
				}
				is_at_war = yes
				OR = {
					any_scope_state = {
						is_capital = yes
						devastation > 0.6
					}
					any_scope_state = {
						OR = {
							is_incorporated = yes
							is_homeland_of_country_cultures = ROOT
						}
						devastation > 0.9
					}
				}
			}
		}
		is_ai = yes ## A specific one for AI
	}

	when_taken = {
		trigger_event = mod_nuclear_strategic_strike.1
		set_variable = {
			name = nuclear_strike_cooldown
			days = 3
		}
	}

	ai_chance = {
		base = 5000
	}
}
