#historical events for hearts of iron 4 - initially created by CSRZ for 1.7.1 Hydra/Man the Guns
#Events for the formation of the United Nations and following expansion of the Allies

#now only cosmetic events

add_namespace = unitednations

#United Nations declaration
news_event = {
	id = unitednations.0
	title = unitednations.0.t
	desc = unitednations.0.d
	picture = GFX_news_event_united_nations
	
	major = yes
	
	#fire_only_once = yes

	is_triggered_only =  yes 

	option = {
		name = unitednations.0.a
		trigger = {
			OR = {
				has_government = fascism
			}
		}
	}

	option = {
		name = unitednations.0.b
		trigger = {
			NOT = {
				has_government = fascism
			}
		}
	}	
}

#USA proposes United Nations

country_event = {
	id = unitednations.1
	title = unitednations.1.t
	desc = unitednations.1.d
	picture = GFX_report_un_declaration

	fire_only_once = yes

	trigger = {
		tag = USA
		USA = { has_war_with = GER }
		#SOV = { has_war_with = GER }
		ENG = { has_war_with = GER }
		USA = { is_in_faction_with = ENG }
		GER = { has_government = fascism }
	}

	mean_time_to_happen = {
		days = 2
	}

	option = {
		name = unitednations.1.a
		ai_chance = { factor = 100 }
		ENG = {
			country_event = { id = unitednations.2 }
		}
	}

	option = {
		name = unitednations.1.b
	}	
}

country_event = {
	id = unitednations.2
	title = unitednations.2.t
	desc = unitednations.2.d
	picture = GFX_report_un_declaration
	
	is_triggered_only = yes
	
	option = { # Accept
		name = unitednations.2.a
		ai_chance = { factor = 100 }
		USA = {
			country_event = { id = unitednations.4 }
		}
		#custom_effect_tooltip = GAME_OVER_TT #It's not game over only a puppeting.
	}
	option = { # Refuse
		name = unitednations.2.b
		USA = {
			country_event = { id = unitednations.3 }
		}
	}
}

# ENG declines the offer
country_event = {
	id = unitednations.3
	title = unitednations.3.t
	desc = unitednations.3.d
	picture = GFX_report_un_declaration
	
	is_triggered_only = yes
	
	option = {
		name = unitednations.3.a
	}
}

# ENG accepts the offer
country_event = {
	id = unitednations.4
	title = unitednations.4.t
	desc = unitednations.4.d
	picture = GFX_report_un_declaration
	
	is_triggered_only = yes
	
	option = {
		name = unitednations.4.a
		hidden_effect = {
			news_event = { id = unitednations.0 hours = 6 }
		}
		set_global_flag = united_nations_formed_flag
		if = {
			limit = { 
				AND = {
					country_exists = DOM
					DOM = { has_war = no }
					DOM = { is_in_faction = no }
					DOM = { is_subject = no }
					DOM = { has_government = democratic }					
				}
			}
			DOM = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = HAI
					HAI = { has_war = no }
					HAI = { is_in_faction = no }
					HAI = { is_subject = no }	
					HAI = { has_government = democratic }				
				}
			}
			HAI = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = CUB
					CUB = { has_war = no }
					CUB = { is_in_faction = no }	
					CUB = { is_subject = no }
					CUB = { has_government = democratic }				
				}
			}
			CUB = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = GUA
					GUA = { has_war = no }
					GUA = { is_in_faction = no }	
					GUA = { is_subject = no }
					GUA = { has_government = democratic }				
				}
			}
			GUA = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = ELS
					ELS = { has_war = no }
					ELS = { is_in_faction = no }	
					ELS = { is_subject = no }
					ELS = { has_government = democratic }				
				}
			}
			ELS = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = HON
					HON = { has_war = no }
					HON = { is_in_faction = no }
					HON = { is_subject = no }
					HON = { has_government = democratic }					
				}
			}
			HON = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = NIC
					NIC = { has_war = no }
					NIC = { is_in_faction = no }	
					NIC = { is_subject = no }
					NIC = { has_government = democratic }				
				}
			}
			NIC = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = COS
					COS = { has_war = no }
					COS = { is_in_faction = no }	
					COS = { is_subject = no }
					COS = { has_government = democratic }				
				}
			}
			COS = { country_event = { id = unitednations.5 } }
		}
		if = {
			limit = { 
				AND = {
					country_exists = PAN
					PAN = { has_war = no }
					PAN = { is_in_faction = no }	
					PAN = { is_subject = no }
					PAN = { has_government = democratic }				
				}
			}
			PAN = { country_event = { id = unitednations.5 } }
		}		
	}
}

# Invite to United Nations
country_event = {
	id = unitednations.5
	title = unitednations.5.t
	desc = unitednations.5.d
	picture = GFX_report_un_declaration
	
	#fire_only_once = yes

	is_triggered_only = yes
	
	option = {
		name = unitednations.5.a
		ai_chance = { factor = 100 }
		USA = { add_to_faction = ROOT }
		ENG = { add_to_faction = ROOT }
		if = {
			limit = { 
				USA = { has_war_with = GER }
			}
			add_to_war = { 
				targeted_alliance = USA 
				enemy = GER 
				hostility_reason = asked_to_join
			}
		}
	}

	option = {
		name = unitednations.5.b
	}	
}