﻿###########################
# Yugoslavian Events
###########################

add_namespace = yugoslavia

# Britain to Back Coup in Yugoslavia
country_event = {
	id = yugoslavia.1
	title = yugoslavia.1.t
	desc = yugoslavia.1.d
	picture = GFX_report_event_yugoslavian_king_peter

	fire_only_once = yes
	
	trigger = {
		tag = ENG
		NOT = {
			has_dlc = "Death or Dishonor"
		}
		YUG = {
			OR = {
				is_in_faction_with = GER
				gives_military_access_to = GER
			}
		}
		HUN = { owns_state = 76 }
		GER = {
			OR = {
				AND = { is_in_faction_with = ITA is_in_faction_with = HUN }
				AND = { is_in_faction_with = ITA is_in_faction_with = BUL }
				AND = { is_in_faction_with = HUN is_in_faction_with = BUL }
			}
		}
		ENG = { has_completed_focus = uk_balkan_strategy }
		ENG = { NOT = { is_in_faction_with = GER } }
		ENG = { NOT = { has_country_flag = has_already_decided_yugo_coup_flag } }
		
	}

	immediate = {
		hidden_effect = { 
			remove_ideas = anti_german_military 
			ENG = { set_country_flag = has_already_decided_yugo_coup_flag }
			YUG = { set_country_flag = has_already_decided_yugo_coup_flag }
		}
	}

	mean_time_to_happen = {
		days = 14
	}
	
	option = {
		name = yugoslavia.1.a
		add_political_power = -50
		YUG = {
			country_event = { id = yugoslavia.2 }
		}
	}

	option = {
		name = yugoslavia.1.b
		ai_chance = { factor = 0 }
		YUG = { remove_opinion_modifier = { target = ENG modifier = balkan_strategy_good } }
	}
}

# Yugoslavian Coup
country_event = {
	id = yugoslavia.2
	title = yugoslavia.2.t
	desc = yugoslavia.2.d
	picture = GFX_report_event_yugoslavian_king_peter

	is_triggered_only = yes

	immediate = {
		hidden_effect = { remove_ideas = anti_german_military }
	}

	option = {
		name = yugoslavia.2.a
		hidden_effect = {
			if = {
				limit = {
					date > 1941.09.06
				}
				remove_trait = {
					character = YUG_peter_ii
					ideology = despotism
					trait = underage_monarch
				}
				remove_trait = {
					character = YUG_peter_ii
					ideology = conservatism
					trait = underage_monarch
				}				
				set_country_flag = peter_is_of_age
				YUG_peter_ii = {
					set_portraits = {
						civilian = {
					    	large="GFX_portrait_yugoslavia_peter_ii_old"
						}
					}					
				}
			}
		}
		retire_country_leader = yes
		YUG_peter_ii = {
			promote_character = { ideology = despotism }
		}
		add_timed_idea = { idea = anti_nazi_coup days = 730 }
		add_opinion_modifier = { target = GER modifier = anti_german_coup }
		diplomatic_relation = {
			country = GER
			relation = non_aggression_pact
			active = no
		}
		if = {
			limit = { is_in_faction_with = GER }
			GER = { remove_from_faction = YUG }
		}
		if = {
			limit = { gives_military_access_to = GER }
			GER = {
				diplomatic_relation = {
					country = YUG
					relation = military_access
					active = no
				}
			}
		}
		news_event = { hours = 6 id = news.150 }
	}

	option = {
		name = yugoslavia.2.b
		ai_chance = { factor = 0 }
		remove_ideas = { king_peter_1 }
		if = {
			limit = {
				has_completed_focus = YUG_dissolve_serbia
			}
			start_civil_war = { ideology = democratic size = 0.6 capital = 107 states = { 108 803 } }
		}
		else = {
			start_civil_war = { ideology = democratic size = 0.6 capital = 107 states = { 108 803 802 106 105 } }
		}
		random_country = {
			limit = {
				original_tag = YUG
				NOT = { tag = ROOT }
				has_government = democratic
			}
			add_ideas = { king_peter_1 }
			if = {
				limit = {
					PREV = { has_completed_focus = YUG_dissolve_serbia }
				}
				puppet = KOS
				puppet = MNT
				puppet = MAC
			}
			if = {
				limit = {
					PREV = { has_completed_focus = YUG_divide_bosnia }
				}
				puppet = HRZ
			}
			every_other_country = {
				limit = {
					is_subject_of = PREV
				}
				set_country_flag = yugoslav_puppet_flag
				add_to_war = { 
					targeted_alliance = PREV 
					enemy = PREV.PREV
					hostility_reason = asked_to_join
				}
			}
			every_other_country = {
				limit = {
					is_subject_of = PREV.PREV
				}
				set_country_flag = yugoslav_puppet_flag #transfer puppets at the end of the war
				add_to_war = { 
					targeted_alliance = PREV.PREV
					enemy = PREV
					hostility_reason = asked_to_join
				}
			}
			if = {
				limit = {
					PREV = {
						has_cosmetic_tag = SER
					}
				}
				set_cosmetic_tag = SER
			}
			retire_country_leader = yes
			set_popularities = {
				democratic = 50
				neutrality = 40
				fascism = 5
				communism = 5
			}
			set_capital = { state = 107 }
			YUG_peter_ii = {
				promote_character = { ideology = despotism }
				promote_character = { ideology = conservatism }
			}
			if = {
				limit = {
					date > 1941.09.06
				}
				YUG_peter_ii = {
					swap_country_leader_traits = { 
						remove = underage_monarch
						add = legitimate_heir
					}
				}
				hidden_effect = { 
					set_country_flag = peter_is_of_age 
					YUG_peter_ii = {
						set_portraits = {
							civilian = {
						    	large="GFX_portrait_yugoslavia_peter_ii_old"
							}
						}
					}
				}
			}
		}
	}
}



# Yugoslavia (British and (possibly) French Support)
country_event = {
	id = yugoslavia.3
	title = yugoslavia.3.t
	desc = {
		text = yugoslavia.3.d 
		trigger = {
			NOT = { has_global_flag = FRA_abandoned_yugoslavia }
		}
	}
	desc = {
		text = yugoslavia.3.d_FRA_abandoned_yugoslavia
		trigger = {
			has_global_flag = FRA_abandoned_yugoslavia
		}
	}
	picture = GFX_report_event_chamberlain_announce
	
	is_triggered_only = yes
	
	option = {
		name = yugoslavia.3.a
		effect_tooltip = {
			GER = {
				create_wargoal = {
					type = take_state_focus
					target = YUG
					generator = { 102 853 }
				}
			}
		}
	}
}

# Yugoslavia (French Support)
country_event = {
	id = yugoslavia.4
	title = yugoslavia.3.t
	desc = yugoslavia.4.d
	picture = GFX_report_event_chamberlain_announce
	
	is_triggered_only = yes
	
	option = {
		name = yugoslavia.4.a
		effect_tooltip = {
			GER = {
				create_wargoal = {
					type = take_state_focus
					target = YUG
					generator = { 102 853 }
				}
			}
		}
	}
}

# Yugoslavia (Abandoned)
country_event = {
	id = yugoslavia.5
	title = yugoslavia.5.t
	desc = yugoslavia.5.d
	picture = GFX_report_event_generic_croatia_handshake
	
	is_triggered_only = yes
	
	option = { # Surrender Slovenia
		name = yugoslavia.5.a
		ai_chance = {
			factor = 90
			modifier = { # Decrease chance YUG resists if AUS isn't taken first
				AUS = { exists = yes }
				factor = 0.5
			}
			modifier = { # If they stand a chance to hold the line they will fight
				factor = 0.1
				strength_ratio = {
					tag = GER
					ratio > 0.70
				}
			}
			modifier = { #decrease if in faction
				factor = 0.5
				is_in_faction = yes
			}
			modifier = { # Increase it again if other bordering nations are in Axis
				any_neighbor_country = {
					NOT = { tag = GER }
					is_in_faction_with = GER
				}
				factor = 2.0
			}
		}
		GER = { country_event = germany.94 } #Germany gets Slovenia
	}
	option = { # Refuse anyway
		name = yugoslavia.5.b
		ai_chance = { factor = 10 }
		GER = {
			country_event = germany.95 #Germany gains wargoal
			effect_tooltip = {
				create_wargoal = {
					type = take_state_focus
					target = YUG
					generator = { 102 853 }
				}
			}
		}
	}
}


# Yugoslavia (Italian Support)
country_event = {
	id = yugoslavia.6
	title = yugoslavia.3.t
	desc = yugoslavia.6.d
	picture = GFX_report_event_fascists_posing
	
	is_triggered_only = yes
	
	option = {
		name = yugoslavia.6.a
		effect_tooltip = {
			GER = {
				create_wargoal = {
					type = take_state_focus
					target = YUG
					generator = { 102 853 }
				}
			}
		}
	}
}

# Fate of Yugoslavia
country_event = {
	id = yugoslavia.7
	title = germany.98.t
	desc = {
		text = yugoslavia.7.d
	}
	picture = GFX_report_event_german_inspect_troops
	
	is_triggered_only = yes
	
	#Nope
	option = {
		name = yugoslavia.7.a
		ai_chance = { 
			factor = 5
		}

		GER = { country_event = { id = germany.111 days = 1 } 
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = YUG
				}
			}
		}
	}

	#Alrighty
	option = {
		name = yugoslavia.7.b
		ai_chance = { 
			factor = 10
			modifier = {
				factor = 0
				is_puppet = yes
			}
			modifier = {
				factor = 0
				any_other_country = {
					is_major = yes
					OR = {
						has_guaranteed = YUG
						is_in_faction_with = YUG
					}
				}
			}
		}
		custom_effect_tooltip = GAME_OVER_TT
		GER = {

			add_political_power = -75		
			add_named_threat = { threat = 5 name = GER_fate_of_yugoslavia }
			every_country = {
				limit = {
					is_subject_of = YUG
					OR = {
						original_tag = BOS
						original_tag = HRZ
						original_tag = CRO
						original_tag = MAC
						original_tag = SLV
						original_tag = KOS
						original_tag = MNT
						original_tag = HUN
						original_tag = ROM
					}
				}
				GER = { annex_country = { target = PREV transfer_troops = no } }
			}
			annex_country = { target = YUG transfer_troops = no }

			hidden_effect = {
				set_global_flag = GER_fate_of_yugoslavia_annex_YUG
				news_event = { hours = 6 id = news.169 }
			}
			GER_yugoslavia_modify_mefo_bills_or_economy_of_conquest = yes
			GER_seize_gold_reserves_in_europe_peacefully = yes
			add_to_variable = { var = GER_mefo_bill_counter value = -10 }
		}
	}
}

# Fate of Yugoslavia
country_event = {
	id = yugoslavia.8
	title = germany.98.t
	desc = {
		text = yugoslavia.8.d
	}
	picture = GFX_report_event_german_inspect_troops
	
	is_triggered_only = yes
	
	#Fuck that
	option = {
		name = yugoslavia.8.a
		ai_chance = { 
			factor = 10
		}

		GER = { country_event = { id = germany.111 days = 1 } 
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = YUG
				}
			}
		}
	}

	#Sure thing
	option = {
		name = yugoslavia.8.b

		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				any_other_country = {
					is_major = yes
					OR = {
						has_guaranteed = YUG
						is_in_faction_with = YUG
					}
				}
			}
			modifier = {
				factor = 0
				is_puppet = yes
			} 
		}

		trigger = { 
			YUG = { 
				OR = { 
					owns_state = 103
					owns_state = 104
					owns_state = 109
					owns_state = 804
				} 
			} 
		}

		GER = {		
			add_political_power = -25
			add_named_threat = { threat = 3 name = GER_fate_of_yugoslavia }
			
			CRO = {
				if = {
					limit = { YUG = { owns_state = 103 } }
					transfer_state = 103
				}
				if = {
					limit = { YUG = { owns_state = 104 } }
					transfer_state = 104
				}
				if = {
					limit = { YUG = { owns_state = 109 } }
					transfer_state = 109
				}	
				if = {
					limit = { YUG = { owns_state = 804 } }
					transfer_state = 804
				}
			}
			puppet = CRO
			annex_country = { target = YUG transfer_troops = no }

			hidden_effect = {
				set_global_flag = GER_fate_of_yugoslavia_puppet_CRO_annex_YUG
				news_event = { hours = 6 id = news.169 }
			}
			GER_yugoslavia_modify_mefo_bills_or_economy_of_conquest = yes
			GER_seize_gold_reserves_in_europe_peacefully = yes
			add_to_variable = { var = GER_mefo_bill_counter value = -10 }
		}
	}
}

# Fate of Yugoslavia
country_event = {
	id = yugoslavia.9
	title = germany.98.t
	desc = {
		text = yugoslavia.9.d
	}
	picture = GFX_report_event_german_inspect_troops
	
	is_triggered_only = yes
	
	#No way
	option = {
		name = yugoslavia.9.a
		ai_chance = { factor = 2 }

		GER = { country_event = { id = germany.111 days = 1 } 
			effect_tooltip = {
				create_wargoal = {
					type = annex_everything
					target = YUG
				}
			}
		}
	}

	#Seems fair
	option = {
		name = yugoslavia.9.b
		ai_chance = { 
			factor = 10
			modifier = {
				factor = 0
				any_other_country = {
					is_major = yes
					OR = {
						has_guaranteed = YUG
						is_in_faction_with = YUG
					}
				}
			}
			modifier = {
				factor = 0
				is_puppet = yes
			} 
		}

		GER = {

			add_named_threat = { threat = 2 name = GER_fate_of_yugoslavia }
			
			CRO = {
				if = {
					limit = { YUG = { owns_state = 103 } }
					transfer_state = 103
				}
				if = {
					limit = { YUG = { owns_state = 104 } }
					transfer_state = 104
				}
				if = {
					limit = { YUG = { owns_state = 109 } }
					transfer_state = 109
				}
				if = {
					limit = { YUG = { owns_state = 804 } }
					transfer_state = 804
				}				
			}
			puppet = CRO
			puppet = YUG


			hidden_effect = {
				set_global_flag = GER_fate_of_yugoslavia_puppet_CRO_YUG
				news_event = { hours = 6 id = news.169 }
			}
		}
	}
}

