########################################
# Events for Songhai
#
# written by Johan Andersson
########################################

namespace = flavor_son
normal_or_historical_nations = yes

	
# The Clergy of Timbuktu
country_event = {
	id = flavor_son.1
	title = flavor_son.1.t
	desc = flavor_son.1.d
	picture = muslimgfx_PRAYING_eventPicture
	fire_only_once = yes

	trigger = {
		tag = SON
		owns = 1132
		NOT = {
			piety = 0
		}
		1132 = {
			NOT = { is_core = SON }
		}
	}

	mean_time_to_happen = {
		months = 12
	}
	
	
	option = { 
		name = flavor_son.1.a
		add_piety = -0.5
		1132 = { pretender_rebels = 2	}
	}
	option = {
		name = flavor_son.1.b
		add_prestige = -5
		add_piety = 0.50		
	}	
}


# Golden age in Timbuktu
country_event = {
	id = flavor_son.2
	title = flavor_son.2.t
	desc = flavor_son.2.d
	picture = muslimgfx_CITY_DEVELOPMENT_eventPicture
	fire_only_once = yes

	trigger = {
		tag = SON
		owns = 1132
		is_core = 1132
		OR = {
			has_ruler_flag = son_askia_the_great
			AND = {
				adm = 3
				dip = 3
				mil = 3
			}
		}
		religion_group = muslim
	}

	mean_time_to_happen = {
		months = 100
		modifier = {
			factor = 0.1
			has_ruler_flag = son_askia_the_great
		}
	}

	option = { 
		name = flavor_son.2.a
		add_ruler_modifier = {
			name = golden_age_of_timbuktu
			duration = -1
		}
		add_innovativeness_big_effect = yes
	}
}


# Tarikh al-Sudan
country_event = {
	id = flavor_son.3
	title = flavor_son.3.t
	desc = flavor_son.3.d
	picture = BIG_BOOK_eventPicture
	fire_only_once = yes

	trigger = {
		tag = SON
		is_year = 1625
		NOT = { is_year = 1660 }
		religion_group = muslim
	}

	mean_time_to_happen = {
		months = 200
	}

	option = { 
		name = flavor_son.3.a
		add_prestige = 25
		add_stability_or_adm_power = yes
		add_legitimacy = 25
	}
	
}

########################################
# More events for Songhai
#
# written by Ogulcan Yildirim
########################################

# Rise of Askia Muhammed
country_event = {
	id = flavor_son.4
	title = flavor_son.4.t
	desc = flavor_son.4.d
	picture = ASKIA_eventPicture
	fire_only_once = yes

	trigger = {
		tag = SON
		is_year = 1480
		NOT = { is_year = 1525 }
		OR = {
			AND = {
				NOT = { adm = 3 }
				NOT = { dip = 3 }
				NOT = { mil = 3 }
			}
			dynasty = "000"
			NOT = { legitimacy = 50 }
		}
	}

	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 0.1
			is_year = 1490
		}
	}

	option = { 
		name = flavor_son.4.a
		add_stability = -1
		#kill_heir = yes
		define_ruler = {
			name = "00000"
			dynasty = "0000"
			min_age = 25
			max_age = 40
			claim = 75
			adm = 6
			dip = 3
			mil = 6
			culture = soninke
			religion = sunni
		}
		hidden_effect = {
			define_ruler_to_general = { fire = 3 shock = 4 manuever = 4 siege = 1 trait = master_of_arms_personality }
			set_ruler_flag = son_askia_the_great
		}

		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				OR = {
					adm = 5
					dip = 5
					mil = 5
				}
			}
		}
	}

	option = { 
		name = flavor_son.4.b
		capital_scope = {
			spawn_rebels = {
				type = pretender_rebels
				size = 3
				leader = "Muhammad"
				leader_dynasty = "Askia"
				culture = soninke
				religion = sunni
			}
		}

		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				NOT = { adm = 5 }
				NOT = { dip = 5 }
				NOT = { mil = 5 }
			}
		}
	}	
}

# The direction of Songhai
country_event = {
	id = flavor_son.5
	title = flavor_son.5.t
	desc = flavor_son.5.d
	picture = MUSLIM_PAGAN_DISPUTE_eventPicture
	
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			set_country_flag = son_had_focus_event
		}
	}

	option = {	#Modern Islam focus
		name = flavor_son.5.a
		custom_tooltip = flavor_son.5.a.tt
		hidden_effect = {
			set_country_flag = son_islamic_focus
			clr_country_flag = son_tolerance_focus
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = 10
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -10
		}
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = -10
		}

		ai_chance = {
			factor = 1
			modifier = {
				factor = 10
				has_ruler_flag = son_askia_the_great
			}
			modifier = {
				factor = 0
				has_idea_group = humanist_ideas
			}
			modifier = {
				factor = 2
				has_idea_group = religious_ideas
			}
		}
	}

	option = {	#Traditional Fetishist focus
		name = flavor_son.5.b
		custom_tooltip = flavor_son.5.b.tt
		hidden_effect = {
			set_country_flag = son_tolerance_focus
			clr_country_flag = son_islamic_focus
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -10
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = 10
		}
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = 10
		}

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0.1
				has_ruler_flag = son_askia_the_great
			}
			modifier = {
				factor = 0
				has_idea_group = religious_ideas
			}
			modifier = {
				factor = 2
				has_idea_group = humanist_ideas
			}
		}
	}

	after = {
		swap_non_generic_missions = yes
	}
}

# Ali Ber becomes heir
country_event = {
	id = flavor_son.6
	title = flavor_son.6.t
	desc = flavor_son.6.d
	picture = SONGHAI_RULER_eventPicture
	fire_only_once = yes
	trigger = {
		tag = SON
		is_year = 1450
		NOT = { adm = 3 }
		NOT = { mil = 5 }
		ruler_age = 40
		NOT = { is_year = 1480 }
	}

	mean_time_to_happen = {
		months = 120
	}

	option = {	#Let Ali on the throne
		name = flavor_son.6.a
		define_ruler = {
			name = "Al Ber"
			dynasty = "000"
			claim = 80
			adm = 4
			dip = 2
			mil = 6
			age = 15
		}
		hidden_effect = {
			define_ruler_to_general = {
				fire = 4
				shock = 3
				manuever = 3
				siege = 1
			}
			add_piety = -0.4
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {	#Naaah
		name = flavor_son.6.b
		add_prestige = 20

		ai_chance = {
			factor = 0
		}
	}
}

# Songhai becomes massive threat to Mali
country_event = {
	id = flavor_son.7
	title = flavor_son.7.t
	desc = flavor_son.7.d
	picture = ASKIA_eventPicture
	major = yes
	is_triggered_only = yes

	option = {
		name = flavor_son.7.a
		add_stability = -2
		if = {
			limit = {
				government_rank = 3
			}
			set_government_rank = 2
		}

		ai_chance = {
			factor = 1
		}
	}
}

# Askia's army reformation
country_event = {
	id = flavor_son.8
	title = flavor_son.8.t
	desc = flavor_son.8.d
	picture = TUAREG_OTTOMAN_eventPicture
	is_triggered_only = yes

	option = {
		name = flavor_son.8.a
		add_ruler_modifier = {
			name = son_professional_songhaian_army
			duration = -1
		}
		
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = flavor_son.8.b
		add_mil_power = 200
		
		ai_chance = {
			factor = 0
		}
	}
}

# The surrender of Djenne
country_event = {
	id = flavor_son.10
	title = flavor_son.10.t
	desc = flavor_son.10.d
	picture = AFRICAN_BATTLE_eventPicture
	goto = 1134
	fire_only_once = yes
	is_triggered_only = yes

	option = {
		name = flavor_son.10.a
		white_peace = FROM
		create_marriage = FROM
		vassalize = FROM
		if = {
			limit = {
				has_dlc = "Rights of Man"
				NOT = { has_reform = iqta }
			}
			define_consort = {
				culture = bozo
				religion = sunni
				female = yes
				country_of_origin = FROM
			}
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = flavor_son.10.b
		add_prestige = 10

		ai_chance = {
			factor = 0
		}
	}
}

# Glory of the Great Mosque of Djenne
country_event = {
	id = flavor_son.11
	title = flavor_son.11.t
	desc = flavor_son.11.d
	picture = MOSQUE_eventPicture
	goto = 1134
	is_triggered_only = yes

	option = {
		name = flavor_son.11.a
		add_piety = 0.33
		add_ruler_modifier = {
			name = son_embrace_legalism
			duration = 9125
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = flavor_son.11.b
		add_piety = -0.33
		add_ruler_modifier = {
			name = son_embrace_mysticism
			duration = 9125
		}

		ai_chance = {
			factor = 1
		}
	}
}

# Return to the Roots?
country_event = {
	id = flavor_son.12
	title = flavor_son.12.t
	desc = flavor_son.12.d
	picture = FETISHIST_FIRE_eventPicture

	is_triggered_only = yes

	option = {
		name = flavor_son.12.a
		custom_tooltip = son_fetishism_as_secondary_religion_tt
		hidden_effect = {
			add_country_modifier = {
				name = son_fetishism_as_secondary_religion
				duration = -1
				desc = son_fetishism_as_secondary_religion_desc
			}
			every_owned_province = {
				limit = {
					religion = shamanism
				}
				add_province_modifier = {
					name = son_fetishism_as_secondary_religion_province
					duration = -1
					desc = son_fetishism_as_secondary_religion_province_desc
				}
			}
		}

		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = flavor_son.12.b
		change_religion = shamanism
		custom_tooltip = flavor_son.12.b.tt
		hidden_effect = {
			every_owned_province = {
				limit = {
					religion = sunni
				}
				change_religion = shamanism
			}
		}
		enable_cult_for_heirs_mission = yes
		unlock_cult = islam_cult

		ai_chance = {
			factor = 0
		}
	}
}

# The surrender of Djenne - Ruler dies!
country_event = {
	id = flavor_son.13
	title = flavor_son.13.t
	desc = flavor_son.13.d
	picture = AFRICAN_BATTLE_eventPicture
	fire_only_once = yes
	is_triggered_only = yes
	
	immediate = { kill_ruler = yes }

	option = {	#Offer the Songhain a marriage!
		name = flavor_son.13.a
		tooltip = {
			white_peace = SON
			create_marriage = SON
			SON = {
				vassalize = JNN
			}
		}
		hidden_effect = {
			SON = {
				country_event = {
					id = flavor_son.10
				}
			}
		}

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				war_score_against = {
					who = SON
					value = 30
				}
			}
		}
	}

	option = {	#We will never submit!
		name = flavor_son.13.b
		add_prestige = 15
		add_war_exhaustion = 1

		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					war_score_against = {
						who = SON
						value = 30
					}
				}
			}
		}
	}
}

# The surrender of Djenne - Hidden event
country_event = {
	id = flavor_son.14
	title = none
	desc = none
	picture = none
	fire_only_once = yes
	is_triggered_only = yes
	hidden = yes

	trigger = {
		tag = SON
		war_with = JNN
		is_female = no
		JNN = {
			is_female = no
			is_free_or_tributary_trigger = yes
		}
		FROM = {
			owned_by = JNN
			is_capital_of = JNN
			province_id = 1134
		}
		has_dlc = "Origins"
	}

	option = {
		JNN = {
			country_event = {
				id = flavor_son.13
			}
		}

		ai_chance = {
			factor = 1
		}
	}
}

# Increase goods of all salt and cloth provinces
country_event = {
	id = flavor_son.100
	title = none
	desc = none
	picture = none
	hidden = yes

	trigger = {
		has_country_modifier = son_salt_cloth_trader
		any_owned_province = {
			OR = {
				trade_goods = cloth
				trade_goods = salt
			}
			NOT = { has_province_modifier = son_salt_cloth_production }
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		every_owned_province = {
			limit = {
				OR = {
					trade_goods = cloth
					trade_goods = salt
				}
				NOT = { has_province_modifier = son_salt_cloth_production }
			}
			add_province_modifier = {
				name = son_salt_cloth_production
				duration = -1
				desc = son_salt_cloth_production_tt	#Remains until son_salt_cloth_trader expired
			}
		}

		ai_chance = {
			factor = 1
		}
	}
}

# Remove all the province modifeirs when invalid
country_event = {
	id = flavor_son.101
	title = none
	desc = none
	picture = none
	hidden = yes

	trigger = {
		OR = {
			AND = {
				NOT = { has_country_modifier = son_salt_cloth_trader }
				any_owned_province = {
					has_province_modifier = son_salt_cloth_production
				}
			}
			AND = {
				has_country_modifier = son_salt_cloth_trader
				any_owned_province = {
					has_province_modifier = son_salt_cloth_production
					NOT = { trade_goods = cloth }
					NOT = { trade_goods = salt }
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	option = {
		if = {
			limit = {
				has_country_modifier = son_salt_cloth_trader
			}
			every_owned_province = {
				limit = {
					has_province_modifier = son_salt_cloth_production
					NOT = { trade_goods = cloth }
					NOT = { trade_goods = salt }
				}
				remove_province_modifier = son_salt_cloth_production
			}
		}
		else = {
			every_owned_province = {
				limit = {
					has_province_modifier = son_salt_cloth_production
				}
				remove_province_modifier = son_salt_cloth_production
			}
		}

		ai_chance = {
			factor = 1
		}
	}
}