﻿add_namespace = NATO

#Warning event when justifying against a NATO country
country_event = {

	id = NATO.1
	title = NATO.1.t
	desc = NATO.1.d
	
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	trigger = {
		NOT = {	has_country_flag = Justifying_against_@FROM }
		FROM = {
			has_idea = NATO_member
		}
	}
	
	immediate = {
		set_country_flag = Justifying_against_@FROM
	}
	
	option = {
		name = NATO.1.a
		log = "[GetDateText]: [This.GetName]: NATO.1.a executed"
		ai_chance = { factor = 100 }
	}
}

#NATO call to arms
country_event = {

	id = NATO.2
	title = NATO.2.t
	desc = NATO.2.d
	
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {
		name = NATO.2.a
		log = "[GetDateText]: [This.GetName]: NATO.2.a executed" 	#Call NATO
		ai_chance = { 
			factor = 100
			modifier = {				#If we are attacked by a weak country, don't call people
				factor = 0.20			
				any_enemy_country = {
					has_country_flag = Attacked_NATO
					strength_ratio = { tag = ROOT ratio < 0.6 }
				}
			}
		}
		create_faction = NATO
		set_global_flag = NATO_called_to_arms
		set_country_flag = Leader_of_NATO
		every_other_country = {
			limit = {
				has_idea = NATO_member
				NOT = { has_war_with = ROOT }		#Just in case someone starts a war between NATO countries
				is_subject = no
			}
			country_event = NATO.3
		}
	}
	option = {
		name = NATO.2.b
		log = "[GetDateText]: [This.GetName]: NATO.2.b executed"		#We can handle this
		ai_chance = { 
			factor = 0 
			modifier = {				#If we are attacked by a weak country, don't call people
				add = 80
				any_enemy_country = {
					has_country_flag = Attacked_NATO
					strength_ratio = { tag = ROOT ratio < 0.6 }
				}
			}
		}
	}
}

#NATO member response
country_event = {
	
	id = NATO.3
	title = NATO.3.t
	desc = NATO.3.d
	
	picture = GFX_NATO_picture
	
	is_triggered_only = yes

	trigger = {
		NOT = { is_in_faction_with = FROM }
	}
	
	option = {
		name = NATO.3.a
		log = "[GetDateText]: [This.GetName]: NATO.3.a executed"		#Respect call to arms
		ai_chance = { 
			factor = 95
			modifier = {		#We'll definitely join if already at war with the attacker
				factor = 100
				any_enemy_country = {
					has_war_with = FROM
					has_country_flag = Attacked_NATO
				}
			}
			modifier = {		#If the attacker is weak, less reluctant to join
				factor = 0.3
				FROM = {
					any_enemy_country = {
						has_country_flag = Attacked_NATO
						strength_ratio = { tag = FROM ratio < 0.6 }
					}
				}
			}
		}
		FROM = { add_to_faction = ROOT }
	}
	option = {
		name = NATO.3.b
		log = "[GetDateText]: [This.GetName]: NATO.3.b executed"		#Stay out of it
		ai_chance = { 
			factor = 5 
			modifier = {		#We'll definitely join if already at war with the attacker
				factor = 0
				any_enemy_country = {
					has_war_with = FROM
				}
			}
			modifier = {		#If the attacker is weak, less reluctant to join
				factor = 14
				FROM = {
					any_enemy_country = {
						has_country_flag = Attacked_NATO
						strength_ratio = { tag = FROM ratio < 0.6 }
					}
				}
			}
		}
		FROM = {
			add_opinion_modifier = {
				target = ROOT
				modifier = faction_traitor 
			}
		}
	}
}

#Disband NATO once war is over
country_event = {

	id = NATO.4
	title = NATO.4.t
	desc = NATO.4.d
	
	picture = GFX_NATO_picture
	
	trigger = {
		has_country_flag = Leader_of_NATO
		NOT = {
			any_enemy_country = {
				has_country_flag = Attacked_NATO
			}
		}
	}
	
	mean_time_to_happen = {
		days = 7
	}
	
	immediate = {
		hidden_effect = {
			clr_country_flag = Leader_of_NATO
			clr_global_flag = NATO_called_to_arms
			dismantle_faction = yes
			every_country = {
				limit = { 
					has_country_flag = Attacked_NATO
					NOT = { has_war_with = ROOT }
				}
				clr_country_flag = Attacked_NATO
			}
		}
	}
	
	option = {
		name = NATO.4.a
		log = "[GetDateText]: [This.GetName]: NATO.4.a executed"
		ai_chance = { factor = 100 }
		custom_effect_tooltip = TT_NATO_DISBANDED
		every_other_country = {
			limit = { has_idea = NATO_member }
			country_event = { id = NATO.5 hours = 6 }
		}
	}
}
country_event = {

	id = NATO.5
	title = NATO.5.t
	desc = NATO.5.d
	
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {
		name = NATO.5.a
		log = "[GetDateText]: [This.GetName]: NATO.5.a executed"
		ai_chance = { factor = 100 }
	}
}

news_event = {
	
	id = NATO.6
	title = NATO.6.t
	desc = NATO.6.d
	
	picture = GFX_news_nato
	
	is_triggered_only = yes
	
	option = {
		name = NATO.6.a
		log = "[GetDateText]: [This.GetName]: NATO.6.a executed"
		ai_chance = { factor = 100 }
	}
}

country_event = {
	
	id = NATO.7
	title = NATO.7.t
	desc = NATO.7.d
	
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {
		name = NATO.7.a
		log = "[GetDateText]: [This.GetName]: NATO.7.a executed"
		ai_chance = { factor = 100 }
	}
}

news_event = {
	
	id = NATO.8
	title = NATO.8.t
	desc = NATO.8.d
	
	picture = GFX_news_nato
	
	is_triggered_only = yes
	
	option = {
		name = NATO.8.a
		log = "[GetDateText]: [This.GetName]: NATO.8.a executed"
		ai_chance = { factor = 100 }
	}
}

country_event = {	#We receive an invitation to NATO
	id = NATO.9
	title = NATO.9.t
	desc = NATO.9.d
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {	#We accept!
		name = NATO.9.a
		log = "[GetDateText]: [This.GetName]: NATO.9.a executed"	
		set_country_flag = has_joined_NATO_by_event
		add_ideas = NATO_member
		hidden_effect = { USA = { country_event = { id = NATO.10 } } }
		hidden_effect = { news_event = { id = NATO.13 hours = 3 } } 
		ai_chance = {
			factor = 90
			
			modifier = {
				add = 70
				has_elections = yes
			}
			
			modifier = {
				add = 70
				original_tag = VIN
				country_exists = CHI
			}
		}
	}
	
	option = {	#We refuse
		name = NATO.9.b
		log = "[GetDateText]: [This.GetName]: NATO.9.b executed"
		add_political_power = 50
		USA = { country_event = NATO.11 }
		
		ai_chance = {
			factor = 10
			
			modifier = {
				add = 70
				has_elections = no
			}
			
			modifier = {
				factor = 0
				AND = {
					is_historical_focus_on = yes
					OR = {
						tag = EST
						tag = LAT
						tag = LIT
						tag = SLO
						tag = SLV
						tag = ROM
						tag = BUL
						tag = ALB
						tag = CRO
					}
				}
			}
		}
	}
}

country_event = {	#They accept!
	id = NATO.10
	title = NATO.10.t
	desc = NATO.10.d
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {
		name = NATO.10.a
		log = "[GetDateText]: [This.GetName]: NATO.10.a executed"
		USA = {
			add_opinion_modifier = {
				target = FROM
				modifier = NATO_member_modifier
			}
		}
	}
}

country_event = {	#They refuse!
	id = NATO.11
	title = NATO.11.t
	desc = NATO.11.d
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {
		name = NATO.11.o1
		log = "[GetDateText]: [This.GetName]: NATO.11.o1 executed"
		effect_tooltip = {
			add_opinion_modifier = {
				target = FROM
				modifier = recent_actions_negative
			}
		}
	}
}

#Drills on FROM soil
country_event = {
	id = NATO.12
	title = NATO.12.t
	desc = NATO.12.d
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {
		name = NATO.12.o1
		log = "[GetDateText]: [This.GetName]: NATO.12.o1 executed"
		
		add_political_power = -10
		army_experience = 5
		navy_experience = 5
		air_experience = 5
		
		FROM = { add_opinion_modifier = { target = ROOT modifier = took_part_in_NATO_drills } }
		
		ai_chance = { factor = 100 }
	}
	
	option = {
		name = NATO.12.o2
		log = "[GetDateText]: [This.GetName]: NATO.12.o2 executed"
		
		FROM = { add_opinion_modifier = { target = ROOT modifier = didnt_take_part_in_NATO_drills } }
		
		ai_chance = { factor = 0 }
	}
}

#News Event
news_event = {
	id = NATO.13
	title = NATO.13.t
	desc = NATO.13.d
	picture = GFX_news_nato
	
	is_triggered_only = yes
	major = yes
	
	option = {
		name = NATO.13.o1
		log = "[GetDateText]: [This.GetName]: NATO.13.o1 executed"
	}
}

country_event = {	#(USA) [FROM.GetName] requests to join NATO
	id = NATO.14
	title = NATO.14.t
	desc = NATO.14.d
	picture = GFX_NATO_picture
	
	is_triggered_only = yes
	
	option = {	#We accept!
		name = NATO.14.a
		log = "[GetDateText]: [This.GetName]: NATO.14.a executed"
		add_political_power = 25
		FROM = { country_event = { id = NATO.9 hours = 6 } }
		ai_chance = {
			factor = 50
		}
	}
	
	option = {	#We refuse
		name = NATO.14.b
		log = "[GetDateText]: [This.GetName]: NATO.14.b executed"
		add_political_power = -25
		FROM = { country_event = { id = NATO.15 hours = 6 } }
		
		ai_chance = {
			factor = 1
		}
	}
}

news_event = {	#[USA.GetName] refuses NATO membership request
	id = NATO.15
	title = NATO.15.t
	desc = NATO.15.d
	picture = GFX_news_nato
	
	is_triggered_only = yes
	
	option = {
		name = NATO.15.a
		log = "[GetDateText]: [This.GetName]: NATO.15.a executed"
		ai_chance = {
			factor = 1
		}
	}
}

#[Country] leaves NATO
news_event = {
	id = NATO.16
	title = NATO.16.t
	desc = NATO.16.d
	picture = GFX_news_nato
	
	is_triggered_only = yes
	major = yes
	
	option = {
		name = NATO.16.o1
		log = "[GetDateText]: [This.GetName]: NATO.16.o1 executed"
		trigger = { original_tag = FROM }
	}
	option = {
		name = NATO.16.o2
		log = "[GetDateText]: [This.GetName]: NATO.16.o2 executed"
		trigger = { NOT = { original_tag = FROM } }
	}
}