########################################
# Events for Mutapa
#
# written by Ogulcan Yildirim
########################################

namespace = flavor_zim
normal_or_historical_nations = yes

#Resource exhaustion in Zimbabwe
country_event = {
	id = flavor_zim.1
	title = flavor_zim.1.t
	desc = flavor_zim.1.d
	picture = AFRICAN_CARAVAN_eventPicture
	fire_only_once = yes

	trigger = {
		has_mission = zim_decline_of_zimbabwe
		NOT = { mission_completed = zim_decline_of_zimbabwe }
		has_dlc = "Origins"
		is_year = 1445
		owns_core_province = 1184
	}

	mean_time_to_happen = {
		months = 1
		modifier = {
			factor = 0.1
			is_year = 1450
		}
	}

	option = {
		name = flavor_zim.1.a
		add_stability = -1
		1184 = {
			add_devastation = 33
			add_permanent_province_modifier = {
				name = zim_declining_city
				duration = -1
			}
			if = {
				limit = {
					has_great_project = {
						tier = 1
						type = monument
					}
				}
				add_great_project_tier = {
					type = khami_ruins
					tier = -1
				}
			}
		}
		while = {
			limit = {
				1184 = {
					base_tax = 2
				}
			}
			1184 = { add_base_tax = -1 }
			random_owned_province = {
				limit = { is_state = yes NOT = { province_id = 1184 } NOT = { province_id = 1185 } NOT = { province_id = 1189 } }
				add_base_tax = 1
			}
		}
		while = {
			limit = {
				1184 = {
					base_production = 2
				}
			}
			1184 = { add_base_production = -1 }
			random_owned_province = {
				limit = { is_state = yes NOT = { province_id = 1184 } NOT = { province_id = 1185 } NOT = { province_id = 1189 } }
				add_base_production = 1
			}
		}
		while = {
			limit = {
				1184 = {
					base_manpower = 2
				}
			}
			1184 = { add_base_manpower = -1 }
			random_owned_province = {
				limit = { is_state = yes NOT = { province_id = 1184 } NOT = { province_id = 1185 } NOT = { province_id = 1189 } }
				add_base_manpower = 1
			}
		}
		custom_tooltip = flavor_zim.1.a.tt

		custom_tooltip = flavor_zim.1.a.at

		hidden_effect = {
			set_global_flag = zim_zimbabwe_mass_movement
		}

		ai_chance = {
			factor = 1
		}
	}
}

#Great Zimbabwe Empire
country_event = {
	id = flavor_zim.2
	title = flavor_zim.2.t
	desc = flavor_zim.2.d
	picture = AFRICAN_CHIEFTAIN_eventPicture
	is_triggered_only = yes

	option = {
		name = flavor_zim.2.a		
		change_tag = GZI
		on_change_tag_effect = yes
		add_country_modifier = {
			name = "centralization_modifier"
			duration = 7300
		}
		add_prestige = 25
		if = {
			limit = {
				has_custom_ideas = no
				NOT = { has_idea_group = GZI_ideas }
			}
			country_event = { id = ideagroups.1 } #Swap Ideas
		}
		set_country_flag = formed_zimbabwe_flag

		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = flavor_zim.2.b
		custom_tooltip = flavor_zim.2.b.tt
		hidden_effect = {
			set_country_flag = zim_can_form_gzi
		}

		ai_chance = {
			factor = 1
		}
	}
}

#The Nguni Militarization
country_event = {
	id = flavor_zim.3
	title = flavor_zim.3.t
	desc = flavor_zim.3.d
	picture = AFRICAN_DISCIPLINE_eventPicture
	is_triggered_only = yes

	option = {	#Neat
		name = flavor_zim.3.a
		add_mil_power = 100
		add_country_modifier = {
			name = zim_nguni_militarization
			duration = 9125
		}
		custom_tooltip = flavor_zim.3.a.tt
		hidden_effect = {
			set_country_flag = can_attract_zulu
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {	#Make them to our march!
		name = flavor_zim.3.b
		789 = { add_core = ZUL cede_province = ZUL }
		1181 = { add_core = ZUL cede_province = ZUL }
		hidden_effect = {
			ZUL = {
				if = {
					limit = {
						is_year = 1810
					}
					define_ruler = {
						name = "Shaka"
						dynasty = "Zulu"
						adm = 5
						dip = 3
						mil = 6
						age = 23
						claim = 100
					}
					define_ruler_to_general = {
						fire = 4
						shock = 5
						manuever = 4
						siege = 2
					}
				}
				else = {
					define_ruler = {
						adm = 3
						dip = 3
						mil = 5
						age = 20
						claim = 100
					}
				}
				if = {
					limit = {
						has_dlc = "Rights of Man" 
					}
					hidden_effect = { add_ruler_personality_ancestor = { key = strict } }
				}
				change_government = tribal
				add_government_reform = shaka_regime
				set_capital = 789
				capital_scope = {
					change_province_name = "Bulawayo"
					rename_capital = "Bulawayo"
					add_base_tax = 3
					add_base_production = 3
					add_base_manpower = 2
					build_to_forcelimit = {
						infantry = 0.9
						cavalry = 0.1
					}
				}
				add_manpower = 15
				add_treasury = 300
				PA_random_army_exp_between_5_and_10_effect = yes    #PA: replaced flat gain with random dynamic gain. -- 200e200w
				add_army_tradition = 20
			}
		}
		create_march = ZUL

		ai_chance = {
			factor = 0
		}
	}

	option = {	#Play as the Zulu
		name = flavor_zim.3.c
		789 = { add_core = ZUL cede_province = ZUL }
		1181 = { add_core = ZUL cede_province = ZUL }
		hidden_effect = {
			ZUL = {
				if = {
					limit = {
						is_year = 1810
					}
					define_ruler = {
						name = "Shaka"
						dynasty = "Zulu"
						adm = 5
						dip = 3
						mil = 6
						age = 23
						claim = 100
					}
					define_ruler_to_general = {
						fire = 4
						shock = 5
						manuever = 4
						siege = 2
					}
				}
				else = {
					define_ruler = {
						adm = 3
						dip = 3
						mil = 5
						age = 20
						claim = 100
					}
				}
				if = {
					limit = {
						has_dlc = "Rights of Man" 
					}
					hidden_effect = { add_ruler_personality_ancestor = { key = strict } }
				}
				change_government = tribal
				add_government_reform = shaka_regime
				set_capital = 789
				capital_scope = {
					change_province_name = "Bulawayo"
					rename_capital = "Bulawayo"
					add_base_tax = 3
					add_base_production = 3
					add_base_manpower = 2
					build_to_forcelimit = {
						infantry = 0.9
						cavalry = 0.1
					}
				}
				add_manpower = 15
				add_treasury = 300
				PA_random_army_exp_between_5_and_10_effect = yes    #PA: replaced flat gain with random dynamic gain. -- 200e200w
				add_army_tradition = 20
			}
		}
		switch_tag = ZUL

		ai_chance = {
			factor = 0
		}
	}
}

#Remove abandon ruins modifier if Mutapa does not exist
country_event = {
	id = flavor_zim.4
	title = none
	desc = none
	picture = none
	hidden = yes

	trigger = {
		owns = 1184
		NOT = { tag = ZIM }
		NOT = { was_tag = ZIM }
		NOT = {
			any_country = {
				OR = {
					tag = ZIM
					was_tag = ZIM
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 1
	}

	option = {
		1184 = { remove_province_modifier = zim_declining_city }

		ai_chance = {
			factor = 1
		}
	}
}

#Decide between Muslim and Christian merchants
country_event = {
	id = flavor_zim.5
	title = flavor_zim.5.t
	desc = flavor_zim.5.desc
	picture = AFRICAN_EUROPEAN_DEBATE_eventPicture

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			random_known_country = {
				limit = {
					capital_scope = {
						continent = europe
					}
					OR = {
						alliance_with = ROOT
						has_opinion = {
							who = ROOT
							value = 75
						}
						has_guaranteed = ROOT
						overlord_of = ROOT
						is_subject_of = ROOT
					}
					religion_group = christian
				}
				save_event_target_as = zim_european_country
			}
			random_known_country = {
				limit = {
					capital_scope = {
						continent = africa
					}
					knows_country = ROOT
					religion_group = muslim
				}
				save_event_target_as = zim_muslim_country
			}
		}
	}

	option = {	#Christian traders
		name = flavor_zim.5.a
		custom_tooltip = flavor_zim.5.a.tt
		hidden_effect = {
			export_to_variable = {
				which = zim_new_ruler_religion
				value = ruler_religion
				who = event_target:zim_european_country
			}
			set_country_flag = zim_sided_with_christian_traders
		}
		reverse_add_opinion = {
			who = event_target:zim_european_country
			modifier = zim_preferred_by_mutapa
		}
		reverse_add_opinion = {
			who = event_target:zim_muslim_country
			modifier = zim_refused_by_mutapa
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {	#Muslim traders
		name = flavor_zim.5.b
		custom_tooltip = flavor_zim.5.b.tt
		hidden_effect = {
			export_to_variable = {
				which = zim_new_ruler_religion
				value = ruler_religion
				who = event_target:zim_muslim_country
			}
			set_country_flag = zim_sided_with_muslim_traders
		}
		reverse_add_opinion = {
			who = event_target:zim_muslim_country
			modifier = zim_preferred_by_mutapa
		}
		reverse_add_opinion = {
			who = event_target:zim_european_country
			modifier = zim_refused_by_mutapa
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {	#Balanced
		name = flavor_zim.5.c
		add_years_of_trade_income = {
			years = 2
			custom_tooltip = zim_dominate_upstream_trade_ct
		}
		reverse_add_opinion = {
			who = event_target:zim_muslim_country
			modifier = zim_exploited_merchants
		}
		reverse_add_opinion = {
			who = event_target:zim_european_country
			modifier = zim_exploited_merchants
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {	#Do I look like I care?
		name = flavor_zim.5.d
		add_mercantilism = 5
		add_stability = -1

		ai_chance = {
			factor = 1
		}
	}
}

#Accidental crusade / jihad
country_event = {
	id = flavor_zim.6
	title = flavor_zim.6.t
	desc = {
		desc = flavor_zim.6.d.a
		trigger = {
			has_country_flag = zim_sided_with_christian_traders
		}
	}
	desc = {
		desc = flavor_zim.6.d.b
		trigger = {
			has_country_flag = zim_sided_with_muslim_traders
		}
	}
	picture = AFRICAN_CHIEFTAIN_eventPicture
	fire_only_once = yes
	
	trigger = {
		OR = {
			has_country_flag = zim_sided_with_christian_traders
			has_country_flag = zim_sided_with_muslim_traders
		}
	}

	mean_time_to_happen = {
		months = 60
	}

	immediate = {
		hidden_effect = {
			set_ruler_religion = variable:zim_new_ruler_religion
		}
	}

	option = {	#We shall be Christians!
		name = flavor_zim.6.a
		trigger = {
			has_country_flag = zim_sided_with_christian_traders
		}
		add_stability = -3
		change_religion = variable:zim_new_ruler_religion

		ai_chance = {
			factor = 0
		}
	}

	option = {	#We shall be Muslims!
		name = flavor_zim.6.b
		trigger = {
			has_country_flag = zim_sided_with_muslim_traders
		}
		add_stability = -3
		change_religion = variable:zim_new_ruler_religion

		ai_chance = {
			factor = 0
		}
	}

	option = {	#Kill the ruler!
		name = flavor_zim.6.c
		kill_ruler = yes
		add_stability = 3

		ai_chance = {
			factor = 1
		}
	}

	option = {	#Eh whatever
		name = flavor_zim.6.d
		add_legitimacy = -20

		ai_chance = {
			factor = 0
		}
	}

	after = {
		clr_country_flag = zim_sided_with_christian_traders
		clr_country_flag = zim_sided_with_muslim_traders
		capital_scope = {
			change_religion = ROOT
		}
		if = {
			limit = {
				OR = {
					religion = catholic
					religion = reformed
					religion = protestant
					religion = anglican
					religion = hussite
				}
			}
			add_prestige = 100	#You always lose 100 prestige when converting...
		}
	}
}

#Maps of Middle East Trade routes
country_event = {
	id = flavor_zim.7
	title = flavor_zim.7.t
	desc = flavor_zim.7.d
	picture = SONGHAI_eventPicture
	
	is_triggered_only = yes

	option = {
		name = flavor_zim.7.a
		custom_tooltip = flavor_zim.7.a.tt
		hidden_effect = {
			swahili_coast_sea_area = { discover_country = ROOT }
			western_indian_ocean_area = { discover_country = ROOT }
			arabian_sea_region = { discover_country = ROOT }
			sakalava_area = { discover_country = ROOT }
			southern_madagascar = { discover_country = ROOT }
			madagascar_highlands_area = { discover_country = ROOT }
			betsimasaraka_area = { discover_country = ROOT }
			arabia_region = { discover_country = ROOT }
			mashriq_region = { discover_country = ROOT }
			horn_of_africa_region = { discover_country = ROOT }
			egypt_region = { discover_country = ROOT }
			discover_province = 504
			discover_province = 2999
			discover_province = 1179
			discover_province = 2334
			discover_province = 4276
			discover_province = 4322
			discover_province = 4321
		}

		ai_chance = {
			factor = 1
		}
	}
}

#Maps of Asian trade nodes
country_event = {
	id = flavor_zim.8
	title = flavor_zim.8.t
	desc = flavor_zim.8.d
	picture = SONGHAI_eventPicture
	
	is_triggered_only = yes

	option = {
		name = flavor_zim.8.a
		custom_tooltip = flavor_zim.8.a.tt
		hidden_effect = {
			discover_province = 524
			discover_province = 684
			discover_province = 584
			bay_of_bengal_area = { discover_country = ROOT }
			andaman_sea_area = { discover_country = ROOT }
			south_china_sea_area = { discover_country = ROOT }
			east_china_sea_area = { discover_country = ROOT }
		}

		ai_chance = {
			factor = 1
		}
	}
}

#Zimbabwe is not under our control!
country_event = {
	id = flavor_zim.9
	title = flavor_zim.9.t
	desc = flavor_zim.9.d
	picture = AFRICAN_REVOLT_eventPicture
	
	trigger = {
		has_mission = zim_restore_the_city
		NOT = { mission_completed = zim_restore_the_city }
		NOT = { has_country_modifier = zim_desecrated_kingdom }
		NOT = { owns = 1184 }
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		name = flavor_zim.9.a
		add_country_modifier = {
			name = zim_desecrated_kingdom
			duration = -1
			desc = zim_desecrated_kingdom_tt
		}

		ai_chance = {
			factor = 1
		}
	}
}

#Zimbabwe is ours again!
country_event = {
	id = flavor_zim.10
	title = flavor_zim.10.t
	desc = flavor_zim.10.d
	picture = AFRICAN_CARAVAN_eventPicture
	
	trigger = {
		OR = {
			mission_completed = zim_restore_the_city
			owns = 1184
		}
		has_country_modifier = zim_desecrated_kingdom
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		name = flavor_zim.10.a
		remove_country_modifier = zim_desecrated_kingdom

		ai_chance = {
			factor = 1
		}
	}
}