# East Africa War
add_namespace = east_africa_war

country_event = { #maurice finds out about all the shit in madagascar
	id = east_africa_war.1
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.1" }
	title = east_africa_war.1.t
	desc = east_africa_war.1.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.1.a
		hidden_effect = {
			country_event = {
				id = east_africa_war.2
				days = 6 random_days = 6
			}
		}
		set_politics = {
			ruling_party = social_conservative
			elections_allowed = no
		}
		add_stability = -0.02
	}
}

country_event = { #maurice finds out about all the shit in madagascar
	id = east_africa_war.2
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.2" }
	title = east_africa_war.2.t
	desc = east_africa_war.2.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.2.a
		add_stability = -0.01
		hidden_effect = {
			country_event = {
				id = east_africa_war.3
				days = 6 random_days = 6
			}
		}
	}
}

country_event = { #maurice finds out about all the shit in madagascar
	id = east_africa_war.3
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.3" }
	title = east_africa_war.3.t
	desc = east_africa_war.3.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.3.a
		add_political_power = -30
		hidden_effect = {
			country_event = {
				id = east_africa_war.4
				days = 6 random_days = 6
			}
		}
	}
}

country_event = { #maurice finds out about all the shit in madagascar
	id = east_africa_war.4
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.4" }
	title = east_africa_war.4.t
	desc = east_africa_war.4.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.4.a
		add_political_power = -20
		hidden_effect = {
			country_event = {
				id = east_africa_war.5
				days = 6 random_days = 6
			}
		}
	}
}

country_event = { #faction
	id = east_africa_war.5
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.5" }
	title = east_africa_war.5.t
	desc = east_africa_war.5.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.5.a
		create_faction = "Anti-Goering Pact"
		declare_war_on = {
			target = TZN
			type = annex_everything
		}
		hidden_effect = {
			country_event = {
				id = east_africa_war.11
				days = 62
			}
			country_event = {
				id = east_africa_war.8
				days = 3 random_days = 32
			}
		}
		set_global_flag = EAST_AFRICA_WAR
		if = {
			limit = {
				BRD = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			RWA = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				RWA = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			RWA = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				BRD = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			BRD = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				UGA = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			UGA = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				KEN = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			KEN = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				ZZB = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			ZZB = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				MLW = {
					exists = yes
					is_subject = no
					is_in_faction = no
				}
			}
			MLW = {
				country_event = {
					id = east_africa_war.6
					days = 3 random_days = 3
				}
			}
		}
	}
}

country_event = { #faction
	id = east_africa_war.6
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.6" }
	title = east_africa_war.6.t
	desc = east_africa_war.6.d
	is_triggered_only = yes

	option = {
		ai_chance = {
			factor = 10
			modifier = {
				factor = 20
				OR = {
					tag = BRD
					tag = RWA
				}
			}
			modifier = {
				factor = 0
				OR = {
					tag = KEN
					tag = ZZB
				}
			}
		}
		name = east_africa_war.6.a
		MAG = {
			add_to_faction = ROOT
		}
		set_country_flag = Joined_MAG_Faction
		if = {
			limit = {
				tag = KEN
				has_war_with = KIK
			}
			TZN = {
				country_event = {
					id = east_africa_war.7
					days = 3 random_days = 3
				}
			}
		}
		if = {
			limit = {
				tag = UGA
			}
			KEN = {
				white_peace_with_ROOT = yes
			}
		}
	}
	
	option = {
		name = east_africa_war.6.b
		ai_chance = {
			factor = 1
		}
	}
}

country_event = { #faction
	id = east_africa_war.7
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.7" }
	title = east_africa_war.7.t
	desc = east_africa_war.7.d
	picture = GFX_report_event_MAF_goering_castle_eventpic
	 
	is_triggered_only = yes

	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.7.a
	}
	option = {
		ai_chance = {
			factor = 0
		}
		name = east_africa_war.7.b
		create_faction = "East Africa Accord"
		TZN = {
			add_to_faction = KIK
		}
		set_global_flag = TZN_GOERING_DEAL_WITH_THE_DEVIL
		if = {
			limit = {
				ZAM = {
					has_government = paternal_autocrat
					owns_state = 956
				}
			}
			ZAM = {
				country_event = {
					id = east_africa_war.9
					days = 3 random_days = 3
				}
			}
		}
	}
}

country_event = { #ethiopia
	id = east_africa_war.8
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.8" }
	title = east_africa_war.8.t
	desc = east_africa_war.8.d

	is_triggered_only = yes
	
	fire_only_once = yes
trigger = {
		tag = ETH
		SOM = {
			is_in_faction = no
			is_subject = no
		}
		KIK = {
			has_war_with = SOM
		}
	}

	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.8.a
		declare_war_on = {
			target = SOM
			type = annex_everything
		}
		add_stability = -0.03
		add_war_support = -0.03
		add_political_power = -30
	}
	option = {
		ai_chance = {
			factor = 10
		}
		name = east_africa_war.8.b
		add_stability = 0.01
	}
}

country_event = { #huttig
	id = east_africa_war.9
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.9" }
	title = east_africa_war.9.t
	desc = east_africa_war.9.d
	picture = GFX_report_event_MAF_goering_castle_eventpic
	
	is_triggered_only = yes
	
	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.9.a
		TZN = {
			add_to_faction = ROOT
		}
	}
	option = {
		ai_chance = {
			factor = 0
		}
		name = east_africa_war.9.b
	}
}

country_event = { #faction ded
	id = east_africa_war.10
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.10" }
	title = east_africa_war.10.t
	desc = east_africa_war.10.d
	picture = GFX_report_event_MAF_goering_castle_eventpic
	
	fire_only_once = yes
	
	mean_time_to_happen = {
		days = 90
	}
	
trigger = {
		tag = TZN
		has_war = no
		has_global_flag = TZN_GOERING_DEAL_WITH_THE_DEVIL
	}
	
	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.10.a
		dismantle_faction = yes
	}
}

country_event = { #askari uprising
	id = east_africa_war.11
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.11" }
	title = east_africa_war.11.t
	desc = east_africa_war.11.d
	picture = GFX_report_event_MAF_goering_castle_eventpic

	is_triggered_only = yes
	
	fire_only_once = yes
trigger = {
		tag = TZN
		has_war_with = MAG
	}
	
	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.11.a
		create_dynamic_country = {	#
			original_tag = TZN
			copy_tag = TZN

			#State
			transfer_state = 1032
			transfer_state = 918	
			add_state_core = 1032
			add_state_core = 918
					
			### Leader
			create_country_leader = {
				name = "Mohamed Husen"
				desc = "POLITICS_HUSAN_DESC"
				picture = "gfx/leaders/TZN/Portrait_TZN_Muhamed_Husan.png"
				expire = "1.1.1"
				ideology = authdem_junta_subtype
	
			}

			### Politics
			set_politics = {
				ruling_party = authoritarian_democrat
				last_election = "1888.6.15"
				election_frequency = 48
				elections_allowed = no
			}

			set_popularities = {
				totalist = 0
				radical_socialist = 0
				syndicalist = 0
				social_democrat = 0
				social_liberal = 5
				market_liberal = 5
				social_conservative = 10
				authoritarian_democrat = 20
				paternal_autocrat = 20
				national_populist = 40
			}
			save_global_event_target_as = Sane_Goeringia
			set_cosmetic_tag = TZN_GER_BUT_NOT_GOERING
			load_focus_tree = african_republic_authoritarian
			
			#Units
			division_template = {
				name = "Askari Division"
				division_names_group = GER_GAR_01

				regiments = {
					infantry = { x = 0 y = 0 }
					infantry = { x = 0 y = 1 }
					infantry = { x = 0 y = 2 }
					infantry = { x = 1 y = 0 }
					infantry = { x = 1 y = 1 }
					infantry = { x = 1 y = 2 }
				}
				priority = 0
			}
				
			1032 = {
				create_unit = {
					division = "division_template = \"Askari Division\" start_experience_factor = 0.1"
					owner = event_target:Sane_Goeringia
				}
				create_unit = {
					division = "division_template = \"Askari Division\" start_experience_factor = 0.1"
					owner = event_target:Sane_Goeringia
				}
			}
			918 = {
				create_unit = {
					division = "division_template = \"Askari Division\" start_experience_factor = 0.1"
					owner = event_target:Sane_Goeringia
				}
				create_unit = {
					division = "division_template = \"Askari Division\" start_experience_factor = 0.1"
					owner = event_target:Sane_Goeringia
				}
			}
			declare_war_on = {
				target = TZN
				type = annex_everything
			}
			
			MAG = {
				add_to_faction = event_target:Sane_Goeringia
			}
		}
	}
}

country_event = { #we ded
	id = east_africa_war.12
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.12" }
	title = east_africa_war.12.t
	desc = east_africa_war.12.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic

	mean_time_to_happen = {
		days = 90
	}
	
	fire_only_once = yes
trigger = {
		tag = MAG
		OR = {
			has_capitulated = yes
			surrender_progress > 0.20
			TZN = {
				surrender_progress < 0
			}
		}
	}
	
	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.12.a
		dismantle_faction = yes
		TZN = {
			white_peace_with_ROOT = yes
		}
	}
}

country_event = { #we ded
	id = east_africa_war.14
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.14" }
	title = east_africa_war.14.t
	desc = east_africa_war.14.d
	picture = GFX_report_event_MAF_goering_castle_eventpic
	
	fire_only_once = yes
trigger = {
		tag = MAG
		has_global_flag = EAST_AFRICA_WAR
		TZN = {
			has_capitulated = yes
		}
	}

	mean_time_to_happen = {
		days = 30
	}
	
	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.14.a
		dismantle_faction = yes
		set_global_flag = MAG_defeated_goering
		hidden_effect = {
			MAG = {
				country_event = {
					id = east_africa_war.19
					days = 34
				}
			}
		}
		TZN = {
			annex_country = {
				target = event_target:Sane_Goeringia
				transfer_troops = yes
			}
		}
		TZN = {
			set_cosmetic_tag = TZN_GER_BUT_NOT_GOERING
			create_country_leader = {
				name = "Bayume Mohamed Husen"
				desc = "POLITICS_HUSAN_DESC"
				picture = "gfx/leaders/TZN/Portrait_TZN_Muhamed_Husan.png"
				expire = "1.1.1"
				ideology = authdem_junta_subtype
			}
			set_politics = {
				ruling_party = authoritarian_democrat
			}
			load_focus_tree = african_republic_authoritarian
		}
	}
}

country_event = { #heydrich assasination
	id = east_africa_war.16
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.16" }
	title = east_africa_war.16.t
	desc = east_africa_war.16.d
	picture = GFX_report_event_MAF_goering_castle_eventpic
	
	is_triggered_only = yes
	
	option = { #take him out now
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.16.a
		custom_effect_tooltip = MAG_where_art_thou_tt
		random_list = {
			50 = { #he lives
				country_event = {
					id = east_africa_war.17
					days = 3 random_days = 3
				}		
			}
			50 = { #he dies
				country_event = {
					id = east_africa_war.18
					days = 3 random_days = 3
				}	
			}
		}
	}
	
	option = { #wait
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.16.b
		set_country_flag = MAG_waited
	}
}

country_event = { #heydrich survives
	id = east_africa_war.17
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.17" }
	title = east_africa_war.17.t
	desc = east_africa_war.17.d
	picture = GFX_report_event_MAG_heydrich
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.17.a
		add_political_power = -10
	}
}

country_event = { #heydrich dies
	id = east_africa_war.18
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.18" }
	title = east_africa_war.18.t
	desc = east_africa_war.18.d
	picture = GFX_report_event_MAG_heydrich
	
	is_triggered_only = yes

	option = {
		name = east_africa_war.18.a
		add_political_power = 10
		TZN = {
			random_unit_leader = {
				limit = { has_id = 36863 }			
				remove_unit_leader = yes
			}
		}
	}
}

country_event = { #heydrich trial
	id = east_africa_war.19
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.19" }
	title = east_africa_war.19.t
	desc = east_africa_war.19.d
	picture = GFX_report_event_MAG_heydrich
	
	mean_time_to_happen = { days = 30 }
	fire_only_once = yes
	
	trigger = {
		has_global_flag = MAG_defeated_goering
		tag = MAG
	}

	option = {
		name = east_africa_war.19.a
		add_political_power = 10
		TZN = {
			random_unit_leader = {
				limit = { has_id = 36863 }			
				remove_unit_leader = yes
			}
		}
	}
}

# News Event
news_event = {
	id = east_africa_war.15
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.15" }
	title = east_africa_war.15.t
	desc = east_africa_war.15.d
	picture = GFX_news_event_german_nigeria

	major = yes

	is_triggered_only = yes

trigger = {
		wants_world_news = yes
	}

	show_major = {
		OR = {
			regional_africa_news = yes
		}
	}

	option = {
		name = east_africa_war.15.a
	}
}

country_event = { #destroy faction
	id = east_africa_war.20
	immediate = { log = "[GetDateText]: [Root.GetName]: event east_africa_war.14" }
	title = east_africa_war.14.t
	desc = east_africa_war.14.d
	picture = GFX_report_event_MAG_Emil_Maurice_eventpic

	mean_time_to_happen = {
		days = 60
	}
	
	fire_only_once = yes
trigger = {
		tag = MAG
		is_faction_leader = yes
		has_war = no
        TZN = {
			OR = { 
				exists = no 
				is_in_faction_with = MAG
			}
		}
	}
	
	option = {
		ai_chance = {
			factor = 50
		}
		name = east_africa_war.14.a
		dismantle_faction = yes
	}
}