namespace = UIMOD

# The unification of Islam (Sunni)
narrative_event = {
	id = UIMOD.002
	title = UIMOD_EVTNAME.002
	desc = UIMOD_EVTDESC.002
	picture = GFX_evt_bishop_muslim

	ai = no

	trigger = {
		prisoner = no
		NOT = { trait = incapable }
		has_landed_title = d_sunni
		NOT = { has_global_flag = uimod_islam_unified }
		religion = sunni
		war = no
			piety = 2000
			religion_authority = 0.9
			completely_controls = c_cordoba
			b_cordoba = { holder_scope = { religion = sunni } }
			completely_controls = c_mecca
			b_mecca = { holder_scope = { religion = sunni } }
			completely_controls = c_medina
			b_medina = { holder_scope = { religion = sunni } }
			completely_controls = c_jerusalem
			b_jerusalem = { holder_scope = { religion = sunni } }
			completely_controls = c_baghdad
			b_bagdad = { holder_scope = { religion = sunni } }
			completely_controls = c_debul
			b_landhi = { holder_scope = { religion = sunni } }
			completely_controls = c_esfahan
			b_khansar = { holder_scope = { religion = sunni } }
			completely_controls = c_palermo
			b_cefalu = { holder_scope = { religion = sunni } }
			completely_controls = c_damascus
			b_damascus = { holder_scope = { religion = sunni } }
			completely_controls = c_samarkand
			b_khokand = { holder_scope = { religion = sunni } }
			completely_controls = c_ifni
			completely_controls = c_muscat
			b_samail = { holder_scope = { religion = sunni } }
	}

	is_triggered_only = yes

	only_rulers = yes
	
	major_trigger = {
		ai = no	
	}
			
	option = { name = UIMOD_EVTOPTA.002
		set_parent_religion = { religion = shiite parent = sunni }
		set_global_flag = uimod_islam_unified
		give_nickname = nick_the_saint
		hidden_tooltip = {
			any_playable_ruler = {
				limit = {
					religion = shiite
					controls_religion = no
				}
				narrative_event = { id = UIMOD.004 }
			}
		}
	}
}

# Convert or not? (Sunni)
narrative_event = {
	id = UIMOD.004
	title = UIMOD_EVTNAME.004
	desc = UIMOD_EVTDESC.004
	
	picture = GFX_evt_bishop_muslim
	
	is_triggered_only = yes
	
	option = { #Yes
		name = UIMOD_EVTOPTA.004
		ai_chance = { factor = 75 }
		religion = sunni
		any_courtier = {
			religion = sunni
		}
		capital_scope = {
			religion = sunni
		}
	}
	option = { #No
		name = UIMOD_EVTOPTB.004
		ai_chance = { factor = 25 }
	}
}

# The unification of Islam (Shiite)
narrative_event = {
	id = UIMOD.003
	title = UIMOD_EVTNAME.003
	desc = UIMOD_EVTDESC.003
	major = yes
	picture = GFX_evt_bishop_muslim
	
	ai = no

	trigger = {
		prisoner = no
		NOT = { trait = incapable }
		has_landed_title = d_shiite
		NOT = { has_global_flag = uimod_islam_unified }
		religion = shiite
		war = no
			piety = 2000
			religion_authority = 0.9
			completely_controls = c_cordoba
			b_cordoba = { holder_scope = { religion = shiite } }
			completely_controls = c_mecca
			b_mecca = { holder_scope = { religion = shiite } }
			completely_controls = c_medina
			b_medina = { holder_scope = { religion = shiite } }
			completely_controls = c_jerusalem
			b_jerusalem = { holder_scope = { religion = shiite } }
			completely_controls = c_baghdad
			b_bagdad = { holder_scope = { religion = shiite } }
			completely_controls = c_debul
			b_landhi = { holder_scope = { religion = shiite } }
			completely_controls = c_esfahan
			b_khansar = { holder_scope = { religion = shiite } }
			completely_controls = c_palermo
			b_cefalu = { holder_scope = { religion = shiite } }
			completely_controls = c_damascus
			b_damascus = { holder_scope = { religion = shiite } }
			completely_controls = c_samarkand
			b_khokand = { holder_scope = { religion = shiite } }
			completely_controls = c_ifni
			completely_controls = c_muscat
			b_samail = { holder_scope = { religion = shiite } }
	}

	is_triggered_only = yes

	only_rulers = yes
	
	major_trigger = {
		ai = no	
	}
	
	option = { name = UIMOD_EVTOPTA.003
		set_parent_religion = { religion = sunni parent = shiite }
		set_global_flag = uimod_islam_unified
		give_nickname = nick_the_saint
		hidden_tooltip = {
			any_playable_ruler = {
				limit = {
					religion = sunni
					controls_religion = no
				}
				narrative_event = { id = UIMOD.005 }
			}
		}
	}
}

# Convert or not? (Shiite)
narrative_event = {
	id = UIMOD.005
	title = UIMOD_EVTNAME.005
	desc = UIMOD_EVTDESC.005
	
	picture = GFX_evt_bishop_muslim
	
	is_triggered_only = yes
	
	option = { #Yes
		name = UIMOD_EVTOPTA.005
		ai_chance = { factor = 75 }
		religion = shiite
		any_courtier = {
			religion = shiite
		}
		capital_scope = {
			religion = shiite
		}
	}
	option = { #No
		name = UIMOD_EVTOPTB.005
		ai_chance = { factor = 25 }
	}
}