###########################
# French Events
###########################

add_namespace = france

# Japan demands Indochina
country_event = {
	id = france.1
	title = france.1.t
	desc = france.1.d
	picture = GFX_report_event_japan_army_mountainside
	
	is_triggered_only = yes
	
	option = { # Accept demands
		name = france.1.a
		ai_chance = {
			factor = 25 
			modifier = {
				factor = 50
				has_war = yes
				any_enemy_country = {
					strength_ratio = { 
						tag = ROOT 
						ratio < 0.4
					}
				}
			}
			modifier = {
				factor = 75
				16 = { NOT = { is_controlled_by = FRA } } #Paris	
			}
		} 
		JAP = {
			country_event = { days = 5 id = japan.6 }
		}
	}
	option = { # Refuse
		name = france.1.b
		ai_chance = { 
			factor = 25 
			modifier = {
				is_historical_focus_on = yes
				factor = 0
			}
		}
		JAP = {
			country_event = { days = 5 id = japan.7 }
		}
	}
}

# Maginot Line Extension
country_event = {
	id = france.2
	title = france.2.t
	desc = france.2.d
	picture = GFX_report_event_bunker_01
	
	is_triggered_only = yes
	
	option = {
		name = france.2.a
		18 = {
			add_building_construction = {
				type = bunker
				province = 5291
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 3560
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 9472
				level = 2
				instant_build = yes
			}
		}
		29 = {
			add_building_construction = {
				type = bunker
				province = 11606
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 11483
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 575
				level = 2
				instant_build = yes
			}
		}
		785 = {
			add_building_construction = {
				type = bunker
				province = 3447
				level = 2
				instant_build = yes
			}
		}
	}
}

# Alpine Line Extension
country_event = {
	id = france.3
	title = france.3.t
	desc = france.3.d
	picture = GFX_report_event_bunker_01

	is_triggered_only = yes
	
	option = {
		name = france.3.a
		735 = {
			add_building_construction = {
				type = bunker
				province = 764
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 9909
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 3959
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 6975
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 3764
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 9745
				level = 2
				instant_build = yes
			}
			add_building_construction = {
				type = bunker
				province = 778
				level = 2
				instant_build = yes
			}
		}
	}
}

# De Gaulle becomes leader
country_event = {
	id = france.20
	title = france.20.t
	desc = france.20.d
	picture = GFX_report_event_degaulle_churchill
	
	is_triggered_only = yes
	
	option = {
		custom_effect_tooltip = france.20.a_tt
		set_country_flag = france_de_gaulle
		hidden_effect =  {
			add_country_leader_role = {
				character = FRA_charles_de_gaulle
				country_leader = {
					expire = "1965.1.1"
					ideology = conservatism
					traits = {
					}	
				}
				promote_leader = yes				
			}		
		}
		name = france.20.a
	}
}

# French strikes
country_event = {
	id = france.21
	title = france.21.t
	desc = france.21.d
	picture = GFX_report_event_worker_protests
	
	trigger = {
		NOT = { has_government = communism }
		NOT = { has_idea = FRA_matignon_agreements }
		has_completed_focus = FRA_form_the_popular_front
		NOT = { has_country_flag = FRA_popular_front_cooldown }
		tag = FRA
		date > 1936.4.1
		date < 1938.1.1
	}

	fire_only_once = yes
	
	mean_time_to_happen = {	days = 60 }

	option = {
		ai_chance = {
			base = 15
		}
		name = france.21.a
		add_timed_idea = {
			idea = FRA_factory_strikes
			days = 360
		}
	}
}

# French strikes
country_event = {
	id = france.22
	title = france.21.t
	desc = france.21.d
	picture = GFX_report_event_worker_protests
	
	is_triggered_only = yes

	option = {
		ai_chance = {
			base = 15
		}
		name = france.21.a
		add_timed_idea = {
			idea = FRA_factory_strikes
			days = 60
		}
		hidden_effect = {
			country_event = { id = france.23 days = 60 }
		}
	}

	option = {
		ai_chance = {
			base = 85
		}
		name = france.21.b
		add_political_power = -50
	}
}

# Strikes are over
country_event = {
	id = france.23
	title = france.23.t
	desc = france.23.d
	picture = GFX_report_event_airplane_factory

	is_triggered_only = yes

	fire_only_once = yes

	option = {
		name = france.23.a
	}
}

# French ban on communism
#country_event = {
#	id = france.24
#	title = france.24.t
#	desc = france.24.d
#	picture = GFX_report_event_molotov_ribentrop_handshake
#
#
#	trigger = {
#		tag = FRA
#		SOV = { has_government = communism }
#		has_government = democratic
#		communism < 0.5
#		has_global_flag = sov_yes_pact
#	}
#
#	fire_only_once = yes
#	
#	mean_time_to_happen = {	days = 2	}
#
#	option = {
#		ai_chance = {	factor = 10 }
#		add_political_power = -20
#		name = france.24.a
#		add_popularity = {
#			ideology = communism
#			popularity = -0.3
#		}
#		add_ideas = FRA_communism_banned
#
#		add_opinion_modifier = {
#			target = SOV
#			modifier = FRA_ban_communism
#		}
#		
#		every_other_country = {
#			limit = { 
#				has_government = communism
#			}
#			add_opinion_modifier = {
#				target = FRA
#				modifier = FRA_ban_communism
#			}
#		}
#		hidden_effect = {
#			news_event = { id = news.161 hours = 6 }
#		}
#
#	}
#	option = {
#		ai_chance = {	factor = 0 }
#		name = france.24.b
#	}
#}

# British abandon yugoslavia
country_event = {
	id = france.25
	title = france.25.t
	desc = france.25.d
	picture = GFX_report_event_hitler_croatia_handshake

	is_triggered_only	= yes	
	option = { # Follow Britain's lead
		name = france.25.a
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				OR = {
					is_in_faction_with = YUG
					has_war_with = GER
				}
			}
		}
		if = {
			limit = {
				has_guaranteed = YUG
			}
			diplomatic_relation = {
   				country = YUG
   				relation = guarantee
   				active = no
  			}
		}
		if = {
			limit = {
				ITA = {
					OR = {
						NOT = { has_completed_focus = ITA_balkan_ambition }						
						is_in_faction_with = GER
						exists = no
					}
				}
			}
			YUG = {
				add_opinion_modifier = { target = FRA modifier = western_betrayal }
				country_event = { id = yugoslavia.5 hours = 6 }
			}			
		}
		if = {
			limit = { 
				ITA = {
					has_completed_focus = ITA_balkan_ambition
					NOT = { is_in_faction_with = GER }
					NOT = { has_war_with = YUG }
				}
			}
			ITA = { country_event = { id = italy.12 } }
		}
	}
	option = { # Support the Yugoslavs alone
		name = france.25.b
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				is_in_faction_with = GER
			}
		}
		if = {
			limit = {
				NOT = {
					has_war_with = GER
				}
			}
			add_political_power = -200
			add_opinion_modifier = { target = GER modifier = condemn_aggression }
		}
		YUG = { 
			country_event = { id = yugoslavia.4 days = 1 }
			add_opinion_modifier = { target = FRA modifier = offered_support }
		}
		GER = {
			country_event = { id = germany.97 hours = 6 } #Generate wargoal
			effect_tooltip = {
				create_wargoal = {
					type = take_state_focus
					target = YUG
					generator = { 102 853 }
				}
			}
		}
		if = {
			limit = { 
				is_in_faction_with = ENG 
			}
			if = {
				limit = { ENG = { is_faction_leader = yes } }
				ENG = { 
					country_event = { id = britain.15 hours = 6 }
					remove_from_faction = FRA
				}
				else_if = {
					limit = {
						is_faction_leader = yes
					}
					remove_from_faction = ENG
				}
			}
		}
		if = {
			limit = { is_in_faction_with = GER }
			GER = { 
				remove_from_faction = FRA
			}
		}
		if = {
			limit = {
				is_in_faction = yes
				is_faction_leader = yes
				NOT = { is_in_faction_with = ENG }
				NOT = { is_in_faction_with = GER }
			}
			add_to_faction = YUG
			YUG = {
				add_ai_strategy = {
					type = alliance
					id = "FRA"
					value = 200
				}
			}
		}
		if = {
			limit = {
				OR = {
					is_in_faction = no
					is_faction_leader = no
					is_in_faction_with = ENG
					is_in_faction_with = GER
				}
			}
			create_faction = "french_alliance"
			add_to_faction = YUG
			YUG = {
				add_ai_strategy = {
					type = alliance
					id = "FRA"
					value = 200
				}
			}
		}
		if = {
			limit = { NOT = { has_completed_focus = FRA_strengthen_the_little_entente } }
			add_stability = 0.05
		}
	}
}

# British support yugoslavia
country_event = {
	id = france.26
	title = france.26.t
	desc = france.26.d
	picture = GFX_report_event_hitler_croatia_handshake

	is_triggered_only = yes

	option = { #stand together
		name = france.26.a
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				is_in_faction_with = GER
			}
		}
		if = {
			limit = {
				NOT = {
					has_guaranteed = YUG
				}
			}
			give_guarantee = YUG
		}
		if = {
			limit = { is_in_faction = no }
			ENG = { add_to_faction = FRA }
			FRA = {
				add_ai_strategy = {
					type = alliance
					id = "ENG"
					value = 200
				}
			}
		}
		add_opinion_modifier = { target = GER modifier = condemn_aggression }
		YUG = { 
			country_event = { id = yugoslavia.3 days = 1 }
			add_opinion_modifier = { target = FRA modifier = offered_support }
		}
		GER = {
			country_event = { id = germany.93 hours = 6 } #Generate wargoal
			effect_tooltip = {
				create_wargoal = {
					type = take_state_focus
					target = YUG
					generator = { 102 853 }
				}
			}
		}		
	}

	#Abandon
	option = {
		name = france.26.b
		trigger = { NOT = { is_in_faction_with = ENG } }
		ai_chance = { factor = 10 }
		set_global_flag = FRA_abandoned_yugoslavia
		if = {
			limit = {
				has_guaranteed = YUG
			}
			diplomatic_relation = {
   				country = YUG
   				relation = guarantee
   				active = no
  			}
		}
		YUG = {
			country_event = { id = yugoslavia.3 hours = 6 }
			add_opinion_modifier = { target = FRA modifier = western_betrayal }
		}
	}	
}

# Vichy France: Germany is handing over some of our land
country_event = {
	id = france.27
	title = france.27.t
	desc = { 
		text = france.27.d_1_state 
		trigger = {
			OR = {
				NOT = { has_global_flag = ITA_claims_on_france_735 }
				has_global_flag = ITA_claims_on_france_1
			}
			OR = {
				has_global_flag = ITA_claims_on_france_735
				NOT = { has_global_flag = ITA_claims_on_france_1 }
			}
		} 
	}
	desc = { 
		text = france.27.d_both
		trigger = { 
			has_global_flag = ITA_claims_on_france_735 
			has_global_flag = ITA_claims_on_france_1
		} 
	}
	picture = GFX_report_event_worried_french

	is_triggered_only	= yes

	option = {
		name = france.27.a
		
		effect_tooltip = {
			if = {
				limit = { has_global_flag = ITA_claims_on_france_735 }
				ITA = { transfer_state = 735 }
			}
			if = {
				limit = { has_global_flag = ITA_claims_on_france_1 }
				ITA = { transfer_state = 1 }
			}
		}

		if = {
			limit = {
				has_global_flag = ITA_claims_on_france_735
				has_global_flag = ITA_claims_on_france_1
				OR = {
					owns_state = 554
					owns_state = 677
					owns_state = 680
				}

			}
			random_other_country = {
				limit = {
					original_tag = FRA
					has_government = democratic
				}
				if = {
					limit = { ROOT = { owns_state = 554 } }
					transfer_state = 554
				}
				if = {
					limit = { ROOT = { owns_state = 677 } }
					transfer_state = 677
				}
				if = {
					limit = { ROOT = { owns_state = 680 } }
					transfer_state = 680
				}
				country_event = france.28
			}
		}
	}

}

# France - Syria defects to us
country_event = {
	id = france.28
	title = france.28.t
	desc = france.28.d
	picture = GFX_report_event_worried_french

	is_triggered_only	= yes

	option = {
		name = france.28.a
	}

}

# France - Britain accepts Ally request
country_event = {
	id = france.29
	title = france.29.t
	desc = france.29.d
	picture = GFX_report_event_generic_sign_treaty2

	is_triggered_only = yes

	option = {
		name = france.29.a
	}
}

# France - Britain denies Ally request
country_event = {
	id = france.30
	title = france.30.t
	desc = france.30.d
	picture = GFX_report_event_chamberlain

	is_triggered_only	= yes

	option = {
		name = france.30.a
	}
}

# Édouard Daladier Resigns
country_event = {
	id = france.31
	title = france.31.t
	desc = france.31.d
	picture = GFX_report_event_german_parade_paris

	fire_only_once = yes

	trigger = {
		original_tag = FRA
		has_government = democratic
		has_global_flag = fall_of_france
		NOT = { has_country_flag = france_de_gaulle }
	} 

	mean_time_to_happen = {
		days = 7
	}

	option = {
		name = france.31.a
		retire_country_leader = yes
		add_country_leader_role = {
			character = FRA_paul_reynaud
			country_leader = {
				expire = "1965.1.1"
				ideology = liberalism
				traits = {
				}
			}
			promote_leader = yes
		}
		set_country_flag = daladier_resigned
	}
}

# Hidden event to add AI values for nationalist spain if France is going fascist
country_event = {
	id = france.32
	hidden = yes
 
    fire_only_once = yes

    is_triggered_only = yes

    immediate = {
    	if = {
    		limit = {
    			NOT = { has_dlc = "La Resistance" }
    		}
    		random_other_country = {
				limit = {
					original_tag = SPR
					has_government = fascism
				}
				FRA = {
					add_ai_strategy = {
						type = befriend
						id = PREV
						value = 200
					}
				}
			}
    	}
    	if = {
    		limit = {
    			has_dlc = "La Resistance"
    		}
			FRA = {
					add_ai_strategy = {
						type = befriend
					id = "SPA"
						value = 200
					}
			}
    	}
    }

    option = {
		name = france.32.a
    }
}

# Britain is at peace after annexing France in the Franco-British Union
# AI will tend to release France if historic mode is on or they are democratic

country_event = {
	id = france.33
	title = france.33.title
	desc = france.33.desc
	
	picture = GFX_report_event_generic_peaceful_annexation
	
	fire_only_once = yes
	
	trigger = {
		tag = ENG
		has_war = no
		is_subject = no
		has_global_flag = flag_franco_british_union
		any_owned_state = {
			is_core_of = FRA
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}

	option = { # Release
		name = france.33.a
		
		if = {
			limit = {
				has_cosmetic_tag = FRA_UK
			}
			drop_cosmetic_tag = yes
		}
		
		if = {
			limit = {
				NOT = { country_exists = FRA }
			}
			if = {
				limit = {
					has_government = democratic
				}
				FRA = {
					set_politics = {
						ruling_party = democratic
						elections_allowed = yes
					}
					set_popularities = {
						democratic = 60
						fascism = 20
						communism = 20
					}
				}
			}
			if = {
				limit = {
					has_government = fascism
				}
				FRA = {
					set_politics = {
						ruling_party = fascism
						elections_allowed = no
					}
					set_popularities = {
						democratic = 20
						fascism = 60
						communism = 20
					}
				}
			}
			if = {
				limit = {
					has_government = communism
				}
				FRA = {
					set_politics = {
						ruling_party = communism
						elections_allowed = no
					}
					set_popularities = {
						democratic = 20
						fascism = 20
						communism = 60
					}
				}
			}
			if = {
				limit = {
					has_government = neutrality
				}
				FRA = {
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}
					set_popularities = {
						democratic = 15
						neutrality = 55
						fascism = 15
						communism = 15
					}
				}
			}
			release = FRA
			
			set_autonomy = { target = FRA autonomy_state = autonomy_free }
		}
		
		every_state = {
			limit = {
				is_core_of = ENG
				is_core_of = FRA
			}
			remove_core_of = ENG
		}
		
		hidden_effect = { # This looks odd in the tooltip
			every_other_country = {
				limit = {
					is_subject_of = ENG
				}
				every_owned_state = {
					limit = {
						is_core_of = FRA
					}
					FRA = {
						transfer_state = PREV
					}
				}
			}
		}
		
		if = {
			limit = {
				is_faction_leader = yes
				FRA = {
					is_subject = no
					is_in_faction = no
				}
			}
			add_to_faction = FRA
		}
		
		every_unit_leader = {
			limit = {
				has_unit_leader_flag = {
					flag = flag_former_french_general
				}
			}
			set_nationality = FRA
		}
		
		hidden_effect =  {
			news_event = { id = france.34 days = 1 }
		}
		
		ai_chance = {
			factor = 60
			
			modifier = {
				factor = 2
				has_government = democratic
			}
		}
	}
	
	option = { # Don't release
		name = france.33.b
		
		add_war_support = -0.1
		add_stability = -0.2
		
		every_state = {
			limit = {
				is_core_of = ENG
				is_core_of = FRA
			}
			remove_core_of = ENG
		}
		
		every_unit_leader = {
			limit = {
				has_unit_leader_flag = {
					flag = flag_former_french_general
				}
			}
			set_nationality = FRA
		}
		
		ai_chance = {
			factor = 40
			
			modifier = {
				factor = 0.5
				has_stability < 0.5
			}
			modifier = {
				factor = 0.5
				has_war_support < 0.5
			}
			modifier = {
				factor = 2
				has_government = fascism
			}
			modifier = {
				factor = 0.5
				is_historical_focus_on = yes
			}
		}
	}
}

# News event for the release of France

news_event = {
	id = france.34
	title = france.34.title
	desc = france.34.desc
	
	picture = GFX_news_event_degaulle_churchill
	
	is_triggered_only = yes
	
	option = {
		name = france.34.a
		trigger = {
			OR = {
				tag = ENG
				tag = FRA
				is_in_faction_with = ENG
				is_subject_of = ENG
			}
		}
	}
	
	option = {
		name = france.34.b
		trigger = {
			NOT = {
				OR = {
					tag = ENG
					tag = FRA
					is_in_faction_with = ENG
					is_subject_of = ENG
				}
			}
		}
	}
}
