namespace = Plus

#reserved: Plus.1900 to Plus.1999

#######################################
# MUSLIM HERESY EVENTS
# Adapted from Heretic Pride by Rylock
#######################################

### ANARCHY AT SAMARRA EVENTS

# Caliphate administration seized from a weak caliph
narrative_event = {
	id = Plus.1900
	title = EVTNAME_Plus_1900
	desc = EVTDESC_Plus_1900
	picture = GFX_evt_throne_room_arabic
	
	major = yes
	hide_from = yes
	show_ROOT = yes
	
	only_rulers = yes
	only_playable = yes
	only_men = yes
	prisoner = no
	ai = yes
	
	trigger = {
		has_landed_title = d_sunni
		year = 800
		realm_size = 200
		NOR = {
			diplomacy = 10
			martial = 10
			stewardship = 10
			intrigue = 10
			has_global_flag = anarchy_at_samarra
			d_sunni = { has_title_flag = anarchy_at_samarra_happened }
		}
	}
	
	major_trigger = {
		OR = {
			religion_group = muslim
			capital_scope = {
				ROOT = {
					capital_scope = {
						NOT = {
							distance = {
								where = PREVPREV
								value = 600	# Same part of the world
							}
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 12
		modifier = {
			factor = 0.5
			NOR = {
				diplomacy = 5
				martial = 5
				stewardship = 5
				intrigue = 5
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1900
		trigger = { has_landed_title = d_sunni }
		set_global_flag = anarchy_at_samarra
		d_sunni = { set_title_flag = anarchy_at_samarra_happened }
		add_trait = court_anarchy
		hidden_tooltip = {
			crownlaw_title = { add_law = infighting_0 }
		}
	}
	
	option = {
		name = EVTOPTB_Plus_1900
		trigger = {
			NOT = { has_landed_title = d_sunni }
			religion_group = muslim
		}
		tooltip = {
			ROOT = { add_trait = court_anarchy }
		}
	}
	option = {
		name = EVTOPTC_Plus_1900
		trigger = {
			NOT = { has_landed_title = d_sunni }
			NOT = { religion_group = muslim }
		}
		tooltip = {
			ROOT = { add_trait = court_anarchy }
		}
	}
}
	
# Succeeding caliph remains a prisoner
character_event = {
	id = Plus.1901
	desc = EVTDESC_Plus_1901
	picture = GFX_evt_throne_room_arabic
	
	is_triggered_only = yes
	has_global_flag = anarchy_at_samarra
	
	trigger = {
		FROM = { title = d_sunni }
		NOT = { trait = court_anarchy }
	}

	option = {
		name = EVTOPTA_Plus_1901
		add_trait = court_anarchy
		hidden_tooltip = {
			FROMFROM = { remove_trait = court_anarchy }
		}
	}
}

# Caliph succeeds at restoring order (fired from decision)
narrative_event = {
	id = Plus.1902
	title = EVTNAME_Plus_1902
	desc = EVTDESC_Plus_1902
	picture = GFX_evt_throne_room_arabic

	major = yes
	hide_from = yes
	show_ROOT = yes
	
	is_triggered_only = yes
	
	major_trigger = {
		OR = {
			religion_group = muslim
			capital_scope = {
				ROOT = {
					capital_scope = {
						NOT = {
							distance = {
								where = PREVPREV
								value = 600	# Same part of the world
							}
						}
					}
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1902
		trigger = { has_landed_title = d_sunni }
		clr_global_flag = anarchy_at_samarra
		hidden_tooltip = {
			crownlaw_title = { revoke_law = infighting_0 }
		}
	}
	option = {
		name = EVTOPTB_Plus_1902
		trigger = {
			NOT = { has_landed_title = d_sunni }
			religion_group = muslim
		}
		if = {
			limit = { trait = court_anarchy }
			remove_trait = court_anarchy
		}
	}
	option = {
		name = OK
		trigger = {
			NOT = { has_landed_title = d_sunni }
			NOT = { religion_group = muslim }
		}
	}
	
	after = {
		clear_event_target = imprisoned_regent
	}
}

# A random realm lord will declare independent while the anarchy reigns
character_event = {
	id = Plus.1903

	hide_window = yes
	
	only_rulers = yes
	only_playable = yes
	only_men = yes
	
	trigger = {
		has_landed_title = d_sunni
		trait = court_anarchy
		has_global_flag = anarchy_at_samarra
	}
	
	mean_time_to_happen = {
		years = 3
	}

	immediate = {
		random_vassal = {
			limit = {
				war = no
				in_revolt = no
				real_tier = KING
				any_demesne_province = {
					any_neighbor_province = {
						owner = { NOT = { same_realm = ROOT } }
					}
				}
				NOR = {
					dynasty = ROOT
					opinion = { who = ROOT value = 0 }
					has_character_flag = refuse_caliph_breakaway
				}
			}
			character_event = { id = Plus.1904 }
			break = yes
		}
		random_vassal = {
			limit = {
				war = no
				in_revolt = no
				real_tier = KING
				NOR = {
					dynasty = ROOT
					opinion = { who = ROOT value = 0 }
					has_character_flag = refuse_caliph_breakaway
				}
			}
			character_event = { id = Plus.1904 }
			break = yes
		}
		random_vassal = {
			limit = {
				war = no
				in_revolt = no
				higher_tier_than = COUNT
				any_demesne_province = {
					any_neighbor_province = {
						owner = { NOT = { same_realm = ROOT } }
					}
				}
				NOR = {
					dynasty = ROOT
					opinion = { who = ROOT value = 0 }
					has_character_flag = refuse_caliph_breakaway
				}
			}
			character_event = { id = Plus.1904 }
			break = yes
		}
		random_vassal = {
			limit = {
				war = no
				in_revolt = no
				higher_tier_than = COUNT
				NOR = {
					dynasty = ROOT
					opinion = { who = ROOT value = 0 }
					has_character_flag = refuse_caliph_breakaway
				}
			}
			character_event = { id = Plus.1904 }
			break = yes
		}
		random_vassal = {
			limit = {
				war = no
				in_revolt = no
				higher_tier_than = COUNT
				any_demesne_province = {
					any_neighbor_province = {
						owner = { NOT = { same_realm = ROOT } }
					}
				}
				NOR = {
					dynasty = ROOT
					opinion = { who = ROOT value = 50 }
					has_character_flag = refuse_caliph_breakaway
				}
			}
			character_event = { id = Plus.1904 }
			break = yes
		}
		random_vassal = {
			limit = {
				war = no
				in_revolt = no
				higher_tier_than = COUNT
				NOR = {
					dynasty = ROOT
					opinion = { who = ROOT value = 50 }
					has_character_flag = refuse_caliph_breakaway
				}
			}
			character_event = { id = Plus.1904 }
		}
	}
}

# Ruler decides whether or not to break free of the caliph
character_event = {
	id = Plus.1904
	desc = EVTDESC_Plus_1904
	picture = GFX_evt_throne_room
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1904
		ai_chance = {
			factor = 4
		}
		log = "[Root.GetBestName] has broken away from [Root.Liege.GetBestName] due to the Anarchy at Samarra"
		set_defacto_liege = ROOT
		pf_liege_change_effect = yes
		FROM = { character_event = { id = Plus.1905 } }
	}
	option = {
		name = EVTOPTB_Plus_1904
		ai_chance = {
			factor = 1
		}
		set_character_flag = refuse_caliph_breakaway
		piety = 50
	}
}

# Caliph hears of the ruler breaking free
character_event = {
	id = Plus.1905
	desc = EVTDESC_Plus_1905
	picture = GFX_evt_throne_room
	
	is_triggered_only = yes
	
	option = {
		name = CURSES
		opinion = {
			who = FROM
			modifier = opinion_rightful_vassal
			years = 20
		}
	}
}

### KHARIJITE REBELLION

# Kharijite rebels rise up in Mosul during the Anarchy at Samarra
province_event = {
	id = Plus.1906

	hide_window = yes
	
	trigger = {
		province_id = 697
		owner = {
			OR = {
				has_landed_title = d_sunni
				any_liege = { has_landed_title = d_sunni }
			}
		}
		has_global_flag = anarchy_at_samarra
		e_placeholder = { had_title_flag = { flag = startup days = 730 } }
		NOT = { has_province_flag = kharijite_revolt }
	}
	
	mean_time_to_happen = {
		years = 5
		modifier = {
			factor = 0.1
			year = 866
		}
	}
	
	immediate = {	
		set_province_flag = kharijite_revolt
		if = {
			limit = { NOT = { religion = kharijite } }
			religion = kharijite
		}
		
		create_character = {
			random_traits = yes
			dynasty = none
			name = "Musawir"
			religion = kharijite
			culture = ROOT
			female = no
			age = 32
			attributes = {
				martial = 15
				learning = 7
			}
			trait = heresiarch
			trait = zealous
			trait = skilled_tactician
			trait = unyielding_leader
			trait = holy_warrior
		}		

		new_character = {
			set_character_flag = heretic_revolter			
			create_title = {
				tier = DUKE
				landless = yes
				temporary = yes
				rebel = yes
				culture = ROOT
				name = "KHARIJITE_REBELLION"
				holder = THIS
				ruler = "IMAM"
				ruler_female = "CALIPHA"
				foa = "CALIPH_FOA"
			}			
			spawn_unit = {
				province = ROOT
				home = ROOT
				owner = THIS
				#leader = THIS
				scaled_by_biggest_garrison = 1.8
				troops = {
					archers = { 6 6 }
					light_cavalry = { 4 4 }
					light_infantry = { 10 10 }
				}
				attrition = 0
				maintenance_multiplier = 0
				cannot_inherit = yes
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = kharijite
				culture = THIS
				female = no
				age = 30
				attributes = {
					martial = 7
				}
				trait = skilled_tactician
				trait = peasant_leader
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					scaled_by_biggest_garrison = 1.8
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 0.0
					disband_on_peace = yes
					maintenance_multiplier = 0
				}
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = THIS
				culture = THIS
				female = no
				age = 23
				attributes = {
					martial = 7
				}
				trait = skilled_tactician
				trait = peasant_leader
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					scaled_by_biggest_garrison = 1.8
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 0.0
					disband_on_peace = yes
					maintenance_multiplier = 0
				}
			}
			
			# DoW on the province top liege
			ROOT = {
				owner = {
					top_liege = {
						reverse_war = {
							target = PREVPREVPREV
							casus_belli = heretic_revolt
							thirdparty_title = ROOT
						}
						reverse_opinion = {
							who = PREVPREVPREV
							modifier = opinion_evil_tyrant
						}
					}
				}
			}
		}
		
		#inform the lieges
		owner = {
			top_liege = {
				character_event = { id = Plus.1907 }
			}
		}
	}
}

# Rulers informed of the kharajite uprising
character_event = {
	id = Plus.1907
	desc = EVTDESC_Plus_1907
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	major = yes
	
	major_trigger = {
		OR = {
			same_realm = ROOT
			capital_scope = {
				ROOT = {
					capital_scope = {
						NOT = {
							distance = {
								where = PREVPREV
								value = 600	# Same part of the world
							}
						}
					}
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1907
		trigger = {
			NOT = { religion = sunni }
		}
	}
	option = {
		name = EVTOPTB_Plus_1907
		trigger = {
			religion = sunni
		}
	}
}

### ADDITIONAL DECADENCE EVENTS

# Rulers of a very large empire may gain decadence
character_event = {
	id = Plus.1910
	desc = EVTDESC_Plus_1910
	picture = GFX_evt_sultan
	
	only_independent = yes
	religion_group = muslim
	only_men = yes
	
	trigger = {
		uses_decadence = yes
		realm_size = 150
		any_dynasty_member = { is_alive = yes count = 3 } # Does not trigger for tiny dynasties
		OR = {
			NOT = { has_character_flag = decadence_change_empire }
			had_character_flag = { flag = decadence_change_empire days = 3650 }
		}
	}
	
	mean_time_to_happen = {
		months = 240
		modifier = {
			factor = 0.8
			realm_size = 175
		}
		modifier = {
			factor = 0.8
			realm_size = 200
		}
		modifier = {
			factor = 0.8
			realm_size = 225
		}
		modifier = {
			factor = 0.8
			realm_size = 250
		}
		modifier = {
			factor = 0.8
			realm_size = 275
		}
		modifier = {
			factor = 0.8
			realm_size = 300
		}
		modifier = {
			factor = 1.2
			decadence = 50
		}
		modifier = {
			factor = 1.2
			decadence = 60
		}
		modifier = {
			factor = 1.2
			decadence = 70
		}
		modifier = {
			factor = 1.2
			decadence = 80
		}
		modifier = {
			factor = 1.2
			decadence = 90
		}
		modifier = {
			factor = 0.75
			trait = decadent
		}
	}

	option = {
		name = EVTOPTA_Plus_1910
		trigger = { NOT = { trait = decadent } }
		set_character_flag = decadence_change_empire
		decadence = 5
	}
	option = {
		name = EVTOPTB_Plus_1910
		trigger = { trait = decadent }
		set_character_flag = decadence_change_empire
		decadence = 5
	}
}

# Provinces under the ruler of a very decadent dynasty may gain unrest
province_event = {
	id = Plus.1911

	hide_window = yes
	
	trigger = {
		owner = {
			top_liege = {
				religion_group = muslim
				religion_group = ROOT
				OR = {
					trait = dynasty_decadence_med
					trait = dynasty_decadence_high
				}
				OR = {
					NOT = { has_character_flag = decadence_unrest_event }
					had_character_flag = { flag = decadence_unrest_event days = 730 }
				}
			}
		}
		OR = {
			NOT = { has_province_flag = crushed_decadence_unrest }
			had_province_flag = { flag = crushed_decadence_unrest days = 3650 }
		}
		NOT = { has_province_modifier = decadence_unrest }
	}
	
	mean_time_to_happen = {
		months = 1200
		modifier = {
			factor = 2
			owner = { top_liege = { trait = dynasty_decadence_med } }
		}
		modifier = {
			factor = 1.5
			owner = {
				top_liege = {
					any_realm_province = {
						has_province_modifier = decadence_unrest
						count = 5
					}
				}
			}
		}
		modifier = {
			factor = 2.0
			owner = {
				top_liege = {
					any_realm_province = {
						has_province_modifier = decadence_unrest
						count = 10
					}
				}
			}
		}
	}
	
	immediate = {
		owner = {
			top_liege = {
				set_character_flag = decadence_unrest_event
				character_event = { id = Plus.1912 }
			}
		}
	}
}

character_event = {
	id = Plus.1912
	desc = EVTDESC_Plus_1912
	picture = GFX_evt_imam
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1912 #Ignore it
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = diligent
			}
			modifier = {
				factor = 0.5
				trait = paranoid
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
		FROM = {
			add_province_modifier = {
				name = decadence_unrest
				duration = 1825
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1912 #Deal harshly with those responsible
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = kind
			}
			modifier = {
				factor = 0.5
				trait = slothful
			}
			modifier = {
				factor = 0.5
				trait = trusting
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 0.25
				trait = decadent
			}
			modifier = {
				factor = 0
				OR = {
					trait = tyrant10
					trait = tyrant11
					trait = tyrant12
					trait = tyrant13
					trait = tyrant14
					trait = tyrant15
					trait = tyrant16
					trait = tyrant17
					trait = tyrant18
					trait = tyrant19
					trait = tyrant20
				}
			}
		}
		FROM = { set_province_flag = crushed_decadence_unrest }
		tyrant_plus_1_effect = yes
	}
}	

# Province with decadence unrest calms down if decadence is reduced
province_event = {
	id = Plus.1913
	
	hide_window = yes
	
	trigger = {
		has_province_modifier = decadence_unrest
		NOT = {
			owner = {
				top_liege = {
					religion_group = muslim
					religion_group = ROOT
					OR = {
						trait = dynasty_decadence_med
						trait = dynasty_decadence_high
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	immediate = {
		remove_province_modifier = decadence_unrest
	}
}

### KHARIJITE EVENTS

# Liege declares a subject as kafir (triggered via decision)
letter_event = {
	id = Plus.1915
	desc = EVTDESC_Plus_1915
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1915
		add_trait = kharijite_kafir
		piety = -100
	}
}

# Vassal declares a liege as kafir (triggered via decision)
letter_event = {
	id = Plus.1916
	desc = EVTDESC_Plus_1916
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1915
		add_trait = kharijite_kafir
		piety = -100
	}
}

# Public execution (triggered via decision)
long_character_event = {
	id = Plus.1917
	picture = GFX_evt_beheading
	border = GFX_event_long_frame_religion
	
	desc = {
		text = EVTDESC_Plus_1917_family
		trigger = {
			ROOT = {
				OR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_spouse
		trigger = {
			ROOT = {
				is_married = FROM
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_dynasty
		trigger = {
			ROOT = {
				dynasty = FROM
				NOR = {
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_saoshyant
		trigger = {
			ROOT = {
				OR = {
					trait = saoshyant
					trait = saoshyant_descendant
				}
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_pope
		trigger = {
			ROOT = {
				has_landed_title = k_papal_state
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_patriarch
		trigger = {
			ROOT = {
				has_landed_title = k_orthodox
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_caliph
		trigger = {
			ROOT = {
				controls_religion = yes
				religion_group = muslim
				NOR = {
					religion = ROOT
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_jewish_head
		trigger = {
			ROOT = {
				controls_religion = yes
				religion_group = jewish_group
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_zoro_head
		trigger = {
			ROOT = {
				controls_religion = yes
				religion_group = zoroastrian_group
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_king_israel
		trigger = {
			ROOT = {
				has_landed_title = k_israel
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
				}
			}
		}
	}	
	desc = {
		text = EVTDESC_Plus_1917_emperor
		trigger = {
			ROOT = {
				real_tier = EMPEROR
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_christian_head
		trigger = {
			ROOT = {
				controls_religion = yes
				religion_group = christian
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = KING
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_pagan_head
		trigger = {
			ROOT = {
				controls_religion = yes
				is_pagan_religion = yes
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = KING
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_king
		trigger = {
			ROOT = {
				real_tier = KING
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = KING
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_crusader
		trigger = {
			ROOT = {
				trait = crusader
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = DUKE
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_sayyid
		trigger = {
			ROOT = {
				trait = sayyid
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = DUKE
					trait = crusader
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_duke
		trigger = {
			ROOT = {
				real_tier = DUKE
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = DUKE
					trait = crusader
					trait = sayyid
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_kafir
		trigger = {
			ROOT = {
				trait = kharijite_kafir
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					trait = crusader
					trait = sayyid
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_pirate
		trigger = {
			ROOT = {
				trait = viking
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_genius
		trigger = {
			ROOT = {
				trait = genius
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_imbecile
		trigger = {
			ROOT = {
				trait = imbecile
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					trait = genius
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_count
		trigger = {
			ROOT = {
				real_tier = COUNT
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					trait = genius
					trait = imbecile
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1917_generic
		trigger = {
			ROOT = {
				NOR = {
					dynasty = FROM
					is_married = FROM
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = BARON
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					trait = genius
					trait = imbecile
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
	}	
	
	is_triggered_only = yes
	major = yes
	
	major_trigger = {
		OR = {
			character = ROOT
			character = FROM
			is_liege_or_above = ROOT
			is_liege_or_above = FROM
			dynasty = ROOT
			is_close_relative = ROOT
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1917_family
		trigger = {
			character = FROM
			ROOT = {
				OR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = -50
		piety = 100
	}
	option = {
		name = EVTOPTA_Plus_1917_spouse
		trigger = {
			character = FROM
			ROOT = {
				is_married = FROM
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = -25
		piety = 50
	}
	option = {
		name = EVTOPTA_Plus_1917_dynasty
		trigger = {
			character = FROM
			ROOT = {
				dynasty = FROM
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = -25
		piety = 25
	}
	option = {
		name = EVTOPTA_Plus_1917_saoshyant
		trigger = {
			character = FROM
			ROOT = {
				OR = {
					trait = saoshyant
					trait = saoshyant_descendant
				}
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 100
		piety = 1000
	}
	option = {
		name = EVTOPTA_Plus_1917_pope
		trigger = {
			character = FROM
			ROOT = {
				has_landed_title = k_papal_state
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}
	option = {
		name = EVTOPTA_Plus_1917_patriarch
		trigger = {
			character = FROM
			ROOT = {
				has_landed_title = k_orthodox
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}
	option = {
		name = EVTOPTA_Plus_1917_caliph
		trigger = {
			character = FROM
			ROOT = {
				controls_religion = yes
				religion_group = muslim
				NOR = {
					religion = ROOT
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}
	option = {
		name = EVTOPTA_Plus_1917_jewish_head
		trigger = {
			character = FROM
			ROOT = {
				controls_religion = yes
				religion_group = jewish_group
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}
	option = {
		name = EVTOPTA_Plus_1917_zoro_head
		trigger = {
			character = FROM
			ROOT = {
				controls_religion = yes
				religion_group = zoroastrian_group
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}
	option = {
		name = EVTOPTA_Plus_1917_king_israel
		trigger = {
			character = FROM
			ROOT = {
				has_landed_title = k_israel
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}	
	option = {
		name = EVTOPTA_Plus_1917_emperor
		trigger = {
			character = FROM
			ROOT = {
				real_tier = EMPEROR
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 250
	}
	option = {
		name = EVTOPTA_Plus_1917_christian_head
		trigger = {
			character = FROM
			ROOT = {
				controls_religion = yes
				religion_group = christian
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = KING
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 500
	}
	option = {
		name = EVTOPTA_Plus_1917_pagan_head
		trigger = {
			character = FROM
			ROOT = {
				controls_religion = yes
				is_pagan_religion = yes
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = KING
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 50
		piety = 250
	}
	option = {
		name = EVTOPTA_Plus_1917_king
		trigger = {
			character = FROM
			ROOT = {
				real_tier = KING
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = KING
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 25
		piety = 250
	}
	option = {
		name = EVTOPTA_Plus_1917_crusader
		trigger = {
			character = FROM
			ROOT = {
				trait = crusader
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = DUKE
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 20
		piety = 100
	}
	option = {
		name = EVTOPTA_Plus_1917_sayyid
		trigger = {
			character = FROM
			ROOT = {
				trait = sayyid
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = DUKE
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 15
		piety = 100
	}
	option = {
		name = EVTOPTA_Plus_1917_duke
		trigger = {
			character = FROM
			ROOT = {
				real_tier = DUKE
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = DUKE
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 15
		piety = 50
	}
	option = {
		name = EVTOPTA_Plus_1917_kafir
		trigger = {
			character = FROM
			ROOT = {
				trait = kharijite_kafir
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 10
		piety = 50
	}
	option = {
		name = EVTOPTA_Plus_1917_pirate
		trigger = {
			character = FROM
			ROOT = {
				trait = viking
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 10
		piety = 50
	}
	option = {
		name = EVTOPTA_Plus_1917_genius
		trigger = {
			character = FROM
			ROOT = {
				trait = genius
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 10
		piety = 25
	}
	option = {
		name = EVTOPTA_Plus_1917_imbecile
		trigger = {
			character = FROM
			ROOT = {
				trait = imbecile
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					trait = genius
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = -50
		piety = 10
	}
	option = {
		name = EVTOPTA_Plus_1917_count
		trigger = {
			character = FROM
			ROOT = {
				real_tier = COUNT
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_child_of = FROM
					is_married = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					trait = genius
					trait = imbecile
					has_landed_title = k_papal_state
					has_landed_title = k_orthodox
					has_landed_title = k_israel
					higher_real_tier_than = COUNT
					AND = {
						controls_religion = yes
						religion_group = muslim
					}
					AND = {
						controls_religion = yes
						religion_group = jewish_group
					}
					AND = {
						controls_religion = yes
						religion_group = zoroastrian_group
					}
					AND = {
						controls_religion = yes
						religion_group = christian
					}
					AND = {
						controls_religion = yes
						is_pagan_religion = yes
					}
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 10
		piety = 25
	}
	option = {
		name = EVTOPTA_Plus_1917_generic
		trigger = {
			character = FROM
			ROOT = {
				NOR = {
					sibling = FROM
					is_father = FROM
					is_mother = FROM
					is_married = FROM
					is_child_of = FROM
					dynasty = FROM
					trait = saoshyant
					trait = saoshyant_descendant
					trait = crusader
					trait = sayyid
					trait = kharijite_kafir
					trait = viking
					trait = genius
					trait = imbecile
					higher_real_tier_than = BARON
					AND = {
						controls_religion = yes
						OR = {
							religion_group = christian
							religion_group = muslim
							religion_group = jewish_group
							religion_group = zoroastrian_group
							is_pagan_religion = yes
						}
					}	
				}
			}
		}
		ROOT = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
		prestige = 10
		piety = 10
	}
	option = {
		name = EVTOPTB_Plus_1917
		trigger = {
			character = ROOT
		}
		tooltip = {
			death = {
				death_reason = death_execution
				killer = FROM
			}
		}
	}
	option = {
		name = EVTOPTC_Plus_1917
		trigger = {
			NOR = {
				character = ROOT
				character = FROM
			}
			OR = {
				is_liege_or_above = ROOT
				dynasty = ROOT
				is_close_relative = ROOT
				NOT = { religion_group = muslim }
			}
		}
		tooltip = {
			ROOT = {
				death = {
					death_reason = death_execution
					killer = FROM
				}
			}
		}
	}
	option = {
		name = EVTOPTD_Plus_1917
		trigger = {
			NOR = {
				character = ROOT
				character = FROM
				is_liege_or_above = ROOT
				dynasty = ROOT
				is_close_relative = ROOT
			}
			religion_group = muslim
		}
		tooltip = {
			ROOT = {
				death = {
					death_reason = death_execution
					killer = FROM
				}
			}
		}
	}
}

# Bounce for execution event
character_event = {
	id = Plus.1918
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			long_character_event = { id = Plus.1917 }
		}
	}
}

# Kafir attempts to remove gluttonous
character_event = {
	id = Plus.1920
	desc = EVTDESC_Plus_1920
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1920
		hidden_tooltip = {
			add_character_modifier = {
				name = do_not_disturb
				hidden = yes
				duration = 10
			}
			character_event = { id = Plus.1921 days = 10 }
		}
	}
}

# Gluttonous removed after fasting completed
character_event = {
	id = Plus.1921
	desc = EVTDESC_Plus_1921
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1921
		remove_trait = gluttonous
		random_list = {
			10 = {
				modifier = {
					factor = 0
					is_weak_trigger = yes
				}
				modifier = {
					factor = 0.5
					is_strong_trigger = yes
				}
				add_trait = feeble
			}
			30 = {
				modifier = {
					factor = 0
					trait = temperate
				}
				add_trait = temperate
			}
			60 = {
				modifier = {
					factor = 1.5
					is_weak_trigger = yes
				}
				modifier = {
					factor = 0.5
					is_strong_trigger = yes
				}
				health = -1
			}
		}
	}
}

# Kafir attempts to remove greedy
character_event = {
	id = Plus.1922
	desc = EVTDESC_Plus_1922
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1922
		remove_trait = greedy
		random = {
			chance = 25
			modifier = {
				factor = 2
				trait = kind
			}
			modifier = {
				factor = 1.5
				trait = humble
			}
			modifier = {
				factor = 1.5
				trait = content
			}
			modifier = {
				factor = 0.75
				trait = proud
			}
			modifier = {
				factor = 0.75
				trait = ambitious
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = envious
			}
			add_trait = charitable
		}
	}
}

# Kafir attempts to remove slothful
character_event = {
	id = Plus.1923
	desc = EVTDESC_Plus_1923
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1923
		remove_trait = slothful
		random = {
			chance = 50
			add_trait = stressed
		}
	}
}

# Kafir attempts to remove arbitrary	
character_event = {
	id = Plus.1924
	desc = EVTDESC_Plus_1924
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1924
		remove_trait = arbitrary
		random_list = {
			50 = { change_stewardship = -1 }
			35 = { change_stewardship = -2 }
			15 = { }
		}
	}
}

# Kafir attempts to remove cynical
character_event = {
	id = Plus.1925
	desc = EVTDESC_Plus_1925
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1925
		trigger = { NOT = { trait = deceitful } }
		remove_trait = cynical
		random_list = {
			50 = { add_trait = deceitful  }
			50 = { add_trait = zealous }
		}
	}
	option = {
		name = EVTOPTB_Plus_1925
		trigger = { trait = deceitful }
		tooltip_info = deceitful
		remove_trait = cynical
	}
}

# Kafir attempts to remove drunkard
character_event = {
	id = Plus.1926
	desc = EVTDESC_Plus_1926
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1926
		remove_trait = drunkard 
		random_list = {
			50 = {
				modifier = {
					factor = 0
					trait = humble
				}
				add_trait = humble
			}
			10 = { change_diplomacy = 1 }
			10 = { change_martial = 1 }
			10 = { change_intrigue = 1 }
			20 = {
				modifier = {
					factor = 1.5
					is_weak_trigger = yes
				}
				modifier = {
					factor = 0.5
					is_strong_trigger = yes
				}
				health = -1
			}
		}
	}
}

# Kafir attempts to remove hedonist
character_event = {
	id = Plus.1927
	desc = EVTDESC_Plus_1927
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1926
		remove_trait = hedonist
		random_list = {
			50 = {
				modifier = {
					factor = 0
					trait = humble
				}
				add_trait = humble
			}
			10 = { change_diplomacy = 1 }
			10 = { change_martial = 1 }
			10 = { change_intrigue = 1 }
			20 = { add_trait = chaste }
		}
	}
}

# Kafir attempts to remove decadent
character_event = {
	id = Plus.1928
	desc = EVTDESC_Plus_1928
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1926
		remove_trait = decadent
		random_list = {
			50 = {
				modifier = {
					factor = 0
					trait = humble
				}
				add_trait = humble
			}
			10 = { change_diplomacy = 1 }
			10 = { change_martial = 1 }
			10 = { change_intrigue = 1 }
			20 = { }
		}
	}
}

# Kafir clears their name
character_event = {
	id = Plus.1929
	desc = EVTDESC_Plus_1929
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	major = yes
	
	major_trigger = {
		religion = kharijite
		OR = {
			character = ROOT
			same_realm = ROOT
			dynasty = ROOT
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1929
		trigger = { character = ROOT }
		remove_trait = kharijite_kafir 
		piety = 100
	}
	option = {
		name = EVTOPTB_Plus_1929
		trigger = { NOT = { character = ROOT } }
		tooltip = { ROOT = { remove_trait = kharijite_kafir } }
	}
}

### HURUFI EVENTS

# Hurufi writes a Grand Poem
character_event = {
	id = Plus.1930
	desc = EVTDESC_Plus_1930
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	religion = hurufi
	min_age = 20
	only_men = yes
	capable_only = yes
	prisoner = no
	is_sick = no
	
	trigger = {
		in_command_trigger = no
		#is_ill = no
		OR = {
			has_focus = focus_scholarship
			trait = poet
			trait = hurufi_diwan
			diplomacy = 15
			learning = 15
		}
		NOR = {
			war = yes
			liege = { war = yes }
			trait = incapable
			is_dumb_trigger = yes
			trait = depressed
			trait = stressed
			has_character_modifier = writing_epic_poem
		}
		is_not_busy_trigger = yes
	}
	
	mean_time_to_happen = {
		years = 4
		modifier = {
			factor = 0.5
			trait = hurufi_diwan
		}
		modifier = {
			factor = 0.75
			trait = poet
		}
		modifier = {
			factor = 0.75
			trait = diligent
		}
		modifier = {
			factor = 4.0
			trait = slothful
		}
		modifier = {
			factor = 0.75
			trait = ambitious
		}
		modifier = {
			factor = 1.5
			trait = content
		}
	}
	
	option = {
		name = EXCELLENT
		piety = 25
		prestige = 50
		if = {
			limit = { NOT = { trait = hurufi_diwan } }
			random = {
				chance = 20
				add_trait = hurufi_diwan
			}
		}	
		random_list = {
			10 = { change_learning = 1 }
			10 = { change_intrigue = 1 }
			10 = { change_diplomacy = 1 }
			70 = {}
		}
	}
}

# Bounce event for writing Epic Poem
character_event = {
	id = Plus.1931

	hide_window = yes
	is_triggered_only = yes
	
	religion = hurufi
	
	trigger = {
		trait = hurufi_diwan
		has_character_modifier = writing_epic_poem
	}

	immediate = {
		if = {
			limit = {
				OR = {
					is_ill = yes
					war = yes
					liege = { war = yes }
					prisoner = yes
					trait = incapable
					trait = depressed
					trait = stressed
				}
			}
			character_event = { id = Plus.1932 }
			break = yes
		}	
		if = {
			limit = { is_variable_equal = { which = poem_completeness value = 4 } }
			character_event = { id = Plus.1940 }
			break = yes
		}
		random_list = {
			10 = { character_event = { id = Plus.1933 } } #Need inspiration
			10 = { character_event = { id = Plus.1934 } } #Topics of study
			10 = {
				modifier = {
					factor = 0
					OR = {
						trait = eunuch
						trait = celibate
					}
				}
				character_event = { id = Plus.1935 } #Object of desire
			}
			10 = { character_event = { id = Plus.1936 } } #Writer's Block
			10 = { character_event = { id = Plus.1937 } } #Giving into despair
			10 = { character_event = { id = Plus.1938 } } #Giving into procrastination
			40 = { character_event = { id = Plus.1939 } } #Breakthrough
		}
	}
}

# Work on the Epic Poem is delayed
character_event = {
	id = Plus.1932
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESC_Plus_1932_incapable
		trigger = { trait = incapable }
	}
	desc = {
		text = EVTDESC_Plus_1932_prisoner
		trigger = {
			NOT = { trait = incapable }
			prisoner = yes
		}
	}
	desc = {
		text = EVTDESC_Plus_1932_depressed
		trigger = {
			NOT = { trait = incapable }
			prisoner = no
			trait = depressed
		}
	}
	desc = {
		text = EVTDESC_Plus_1932_stressed
		trigger = {
			NOT = { trait = depressed }
			NOT = { trait = incapable }
			prisoner = no
			trait = stressed
		}
	}
	desc = {
		text = EVTDESC_Plus_1932_sick
		trigger = {
			NOT = { trait = stressed }
			NOT = { trait = depressed }
			NOT = { trait = incapable }
			prisoner = no
			is_ill = yes
		}
	}
	desc = {
		text = EVTDESC_Plus_1932_war
		trigger = {
			NOT = { trait = stressed }
			NOT = { trait = depressed }
			NOT = { trait = incapable }
			prisoner = no
			is_ill = no
			OR = {
				war = yes
				liege = { war = yes }
			}
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = CURSES
		if = {
			limit = {
				OR = {
					trait = incapable
					prisoner = yes
				}
			}
			remove_character_modifier = writing_epic_poem
		}
		if = {
			limit = {
				OR = {
					trait = depressed
					trait = stressed
				}
			}
			random = {
				chance = 50
				remove_character_modifier = writing_epic_poem
			}
		}
	}
}

# Need inspiration for the Epic Poem
character_event = { 
	id = Plus.1933
	desc = EVTDESC_Plus_1933
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = {
			text = EVTOPTA_Plus_1933_women
			trigger = { NOT = { trait = homosexual } }
		}
		name = {
			text = EVTOPTA_Plus_1933_men
			trigger = { trait = homosexual }
		}
		random_list = {
			10 = {
				modifier = {
					factor = 0
					trait = decadent
				}
				modifier = {
					factor = 2
					trait = lustful
				}
				modifier = {
					factor = 3
					trait = hedonist
				}
				add_trait = decadent
			}
			90 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 1 }
					}
				}
			}
		}
		piety = -50
		if = {
			limit = {
				trait = lustful
				NOT = { trait = hedonist }
			}
			add_trait = hedonist
		}
		if = {
			limit = { NOT = { trait = lustful } }
			add_trait = lustful
		}
	}
	option = {
		name = EVTOPTB_Plus_1933 #Wine
		random_list = {
			10 = {
				modifier = {
					factor = 0
					trait = decadent
				}
				modifier = {
					factor = 3
					trait = drunkard
				}
				add_trait = decadent
			}
			90 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 1 }
					}
				}
			}
		}
		piety = -50
		if = {
			limit = { NOT = { trait = drunkard } }
			add_trait = drunkard
		}
	}
	option = {
		name = EVTOPTC_Plus_1933 #Song
		random_list = {
			20 = {
				modifier = {
					factor = 0
					trait = decadent
				}
				add_trait = decadent
			}
			80 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 1 }
					}
				}
			}
		}
		piety = -100
		prestige = -100
	}
	option = {
		name = EVTOPTD_Plus_1933 #All At Once!
		random_list = {
			5 = {
				modifier = {
					factor = 0
					trait = decadent
				}
				modifier = {
					factor = 2
					trait = drunkard
				}
				modifier = {
					factor = 2
					trait = lustful
				}
				modifier = {
					factor = 3
					trait = hedonist
				}
				add_trait = decadent
			}
			60 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 1 }
					}
				}
			}
			35 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES_MORE
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 2 }
					}
				}
			}
		}
		piety = -100
		prestige = 100
		if = {
			limit = {
				trait = lustful
				NOT = { trait = hedonist }
			}
			add_trait = hedonist
		}
		if = {
			limit = { NOT = { trait = lustful } }
			add_trait = lustful
		}
		if = {
			limit = { NOT = { trait = drunkard } }
			add_trait = drunkard
		}
	}
}

# Topics of study for the Epic Poem
character_event = {
	id = Plus.1934
	desc = EVTDESC_Plus_1934
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1934 #Study Nobility
		random = {
			chance = 50
			change_diplomacy = 1
		}
		random = {
			chance = 70
			custom_tooltip = {
				text = EPIC_POEM_ADVANCES
				hidden_tooltip = {
					change_variable = { which = poem_completeness value = 1 }
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1934 #Study War
		random = {
			chance = 50
			change_martial = 1
		}
		random = {
			chance = 70
			custom_tooltip = {
				text = EPIC_POEM_ADVANCES
				hidden_tooltip = {
					change_variable = { which = poem_completeness value = 1 }
				}
			}
		}
	}
	option = {
		name = EVTOPTC_Plus_1934 #Study Library
		random = {
			chance = 50
			change_learning = 1
		}
		random = {
			chance = 70
			custom_tooltip = {
				text = EPIC_POEM_ADVANCES
				hidden_tooltip = {
					change_variable = { which = poem_completeness value = 1 }
				}
			}
		}
	}
}

# Object of desire appears to be beyond reach
character_event = {
	id = Plus.1935
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC_Plus_1935_female
		trigger = { NOT = { trait = homosexual } }
	}
	desc = {
		text = EVTDESC_Plus_1935_male
		trigger = { trait = homosexual }
	}
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1935 #Visit whorehouse
		if = {
			limit = {
				trait = lustful
				NOT = { trait = hedonist }
			}
			add_trait = hedonist
		}
		if = {
			limit = { NOT = { trait = lustful } }
			add_trait = lustful
		}
		piety = -100
		random = {
			chance = 60
			custom_tooltip = {
				text = EPIC_POEM_ADVANCES
				hidden_tooltip = {
					change_variable = { which = poem_completeness value = 1 }
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1935 #Unrequited love
		piety = 100
		if = {
			limit = { NOT = { trait = chaste } }
			add_trait = chaste
		}
		random = {
			chance = 40
			custom_tooltip = {
				text = EPIC_POEM_ADVANCES
				hidden_tooltip = {
					change_variable = { which = poem_completeness value = 1 }
				}
			}
		}
	}
	option = {
		name = {
			text = EVTOPTC_Plus_1935_female
			trigger = { NOT = { trait = homosexual } }
		}
		name = {
			text = EVTOPTC_Plus_1935_male
			trigger = { trait = homosexual }
		}
		trigger = {
			NOT = { num_of_lovers = 3 }
		}
		piety = -50
		custom_tooltip = {
			text = EPIC_POEM_ADVANCES
			hidden_tooltip = {
				change_variable = { which = poem_completeness value = 1 }
			}
		}
		random_list = {
			5 = { add_trait = depressed }
			5 = { add_trait = stressed }
			20 = {
				modifier = {
					factor = 0
					trait = homosexual
				}
				modifier = {
					factor = 0
					is_married = yes
				}
				modifier = {
					factor = 0
					NOT = { age = 43 }
				}
				modifier = {
					factor = 0
					has_character_modifier = cradle_robber
				}
				add_character_modifier = {
					name = cradle_robber
					years = 5
				}
			}
			20 = {
				modifier = {
					factor = 0
					trait = homosexual
				}
				modifier = {
					factor = 0
					is_married = no
				}
				modifier = {
					factor = 0
					has_character_modifier = adulterer
				}
				add_character_modifier = {
					name = adulterer
					years = 10
				}
			}
			20 = {
				modifier = {
					factor = 0
					has_character_modifier = known_sodomite
				}
				modifier = {
					factor = 0
					NOT = { trait = homosexual }
				}
				add_character_modifier = {
					name = known_sodomite
					years = 20
				}
			}
			30 = {
				modifier = {
					factor = 0
					trait = homosexual
				}
				create_random_diplomat = {
					random_traits = yes
					dynasty = random
					female = yes
					age = 18
					religion = ROOT
					culture = ROOT
					trait = fair
				}
				new_character = {
					add_lover = ROOT
				}
			}
			30 = {
				modifier = {
					factor = 0
					NOT = { trait = homosexual }
				}
				create_random_diplomat = {
					random_traits = yes
					dynasty = random
					female = no
					age = 18
					religion = ROOT
					culture = ROOT
					trait = fair
				}
				new_character = {
					add_lover = ROOT
				}
			}
		}
	}
}

# Suffering from writer's block
character_event = {
	id = Plus.1936
	desc = EVTDESC_Plus_1936
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1936 #Enjoy Life!
		prestige = 100
		random_list = {
			10 = {
				modifier = {
					factor = 0
					OR = {
						NOT = { trait = lustful }
						NOT = { trait = gluttonous }
						NOT = { trait = drunkard }
						NOT = { trait = decadent }
					}
				}
				health = -1
			}
			20 = {
				modifier = {
					factor = 0
					trait = lustful
				}
				add_trait = lustful
			}
			20 = {
				modifier = {
					factor = 0
					trait = gluttonous
				}
				add_trait = gluttonous
			}
			20 = {
				modifier = {
					factor = 0
					trait = drunkard
				}
				add_trait = drunkard
			}
			20 = {
				modifier = {
					factor = 0
					trait = decadent
				}
				add_trait = decadent
			}
			20 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 1 }
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1936 #Fast and pray
		piety = 100
		random_list = {
			20 = {
				modifier = {
					factor = 0
					trait = temperate
				}
				add_trait = temperate
			}
			20 = {
				health = -1
			}
			20 = {
				give_ill_effect = yes
			}
			20 = {
				modifier = {
					factor = 0
					trait = diligent
				}
				add_trait = diligent
			}
			20 = {
				custom_tooltip = {
					text = EPIC_POEM_ADVANCES
					hidden_tooltip = {
						change_variable = { which = poem_completeness value = 1 }
					}
				}
			}
		}
	}
}

# Giving into despair
character_event = {
	id = Plus.1937
	desc = EVTDESC_Plus_1937
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1937 #Give up
		remove_character_modifier = writing_epic_poem
	}
	option = {
		name = EVTOPTB_Plus_1937 #Try even harder
		trigger = { NOT = { trait = slothful } }
		random = {
			chance = 50
			add_trait = depressed
		}
		random = {
			chance = 50
			add_trait = stressed
		}
		if = {
			limit = { NOT = { trait = diligent } }
			random = {
				chance = 50
				add_trait = diligent
			}
		}
		custom_tooltip = {
			text = EPIC_POEM_ADVANCES
			hidden_tooltip = {
				change_variable = { which = poem_completeness value = 1 }
			}
		}
	}
}

# Giving into procrastination
character_event = {
	id = Plus.1938
	desc = EVTDESC_Plus_1938
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1938 # I'll get around to it someday 
		if = {
			limit = { NOT = { trait = slothful } }
			random = {
				chance = 50
				add_trait = slothful
			}
		}
		random = {
			chance = 30
			custom_tooltip = {
				text = EPIC_POEM_ADVANCES
				hidden_tooltip = {
					change_variable = { which = poem_completeness value = 1 }
				}
			}
		}
	}
}

# Break through
character_event = {
	id = Plus.1939
	desc = EVTDESC_Plus_1939
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1939 #I'm pretty good at this
		prestige = 50
		custom_tooltip = {
			text = EPIC_POEM_ADVANCES
			hidden_tooltip = {
				change_variable = { which = poem_completeness value = 1 }
			}
		}
	}
}

# Epic Poem is completed!
character_event = {
	id = Plus.1940
	desc = EVTDESC_Plus_1940
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1940 #Finally!
		prestige = 1000
		piety = 500
		remove_character_modifier = writing_epic_poem
		add_character_modifier = {
            name = wrote_epic_poem
            duration = -1
        }
		hidden_tooltip = {
			random_list = {
				30 = {
					modifier = {
						factor = 2
						trait = decadent
					}
					modifier = {
						factor = 1.5
						NOR = {
							diplomacy = 15
							learning = 15
						}
					}
					character_event = { id = Plus.1941 days = 2 random = 2 } # Bad Result
				}
				70 = {
					modifier = {
						factor = 1.5
						diplomacy = 15
					}
					modifier = {
						factor = 1.5
						diplomacy = 20
					}
					character_event = { id = Plus.1942 days = 2 random = 2 } # Good Result
				}
			}
		}
	}
}

# Epic Poem is not received well by the court 
character_event = {
	id = Plus.1941
	desc = EVTDESC_Plus_1941
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	major = yes
	hide_from = yes
	show_ROOT = yes
	
	major_trigger = {
		same_realm = ROOT
	}

	option = {
		name = EVTOPTA_Plus_1941
		trigger = { character = ROOT }
		prestige = -200
		random_list = {
			80 = {
				add_trait = shy
			}
			20 = {
				add_trait = paranoid
			}
		}
	}
	option = {
		name = I_SEE
		trigger = { NOT = { character = ROOT } }
	}
}

# Epic Poem is well-received by the court 
character_event = {
	id = Plus.1942
	desc = EVTDESC_Plus_1942
	picture = GFX_evt_diwan_poetry
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	major = yes
	hide_from = yes
	show_ROOT = yes
	
	major_trigger = {
		same_realm = ROOT
	}

	option = {
		name = EVTOPTA_Plus_1942
		trigger = { character = ROOT }
		prestige = 100
		random_list = {
			70 = {
				change_diplomacy = 1
			}
			30 = {
				add_trait = genius
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1942
		trigger = { NOT = { character = ROOT } }
	}
}

# Bounce event for studying
character_event = {
	id = Plus.1943
	
	hide_window = yes
	is_triggered_only = yes
	
	religion = hurufi
	
	trigger = {
		has_character_modifier = hurufi_studying
	}
	
	immediate = {
		if = {
			limit = {
				OR = {
					NOT = { religion = hurufi }
					prisoner = yes
					trait = incapable
				}
			}
			remove_character_modifier = hurufi_studying
			remove_do_not_disturb_effect = yes
			clr_character_flag = hurufi_studying_1
			clr_character_flag = hurufi_studying_2
			clr_character_flag = hurufi_studying_3
			break = yes
		}
		random_list = {
			5 = { 
				modifier = {
					factor = 0
					NOT = { age = 50 }
				}
				modifier = {
					factor = 2
					trait = infirm
				}
				modifier = {
					factor = 2
					OR = {
						has_character_flag = hurufi_studying_2
						has_character_flag = hurufi_studying_3
					}
				}
				character_event = { id = Plus.1944 } #Go blind
			}
			10 = {
				modifier = {
					factor = 1.5
					has_character_flag = hurufi_studying_2
				}
				modifier = {
					factor = 0
					has_character_flag = hurufi_studying_3
				}
				character_event = { id = Plus.1945 } #Increase attributes
			}
			15 = {
				modifier = {
					factor = 0
					is_weak_trigger = yes
				}
				modifier = {
					factor = 0.65
					has_character_flag = hurufi_studying_2
				}
				modifier = {
					factor = 0.35
					has_character_flag = hurufi_studying_3
				}
				character_event = { id = Plus.1946 } #Becomes weak
			}
			5 = {
				modifier = {
					factor = 0
					is_smart_trigger = yes
				}
				modifier = {
					factor = 2
					has_character_flag = hurufi_studying_2
				}
				modifier = {
					factor = 0
					has_character_flag = hurufi_studying_3
				}
				character_event = { id = Plus.1947 } #Becomes quick
			}
			10 = {
				modifier = {
					factor = 0
					lifestyle_traits = 1
				}
				modifier = {
					factor = 0
					OR = {
						has_character_flag = hurufi_studying_2
						has_character_flag = hurufi_studying_3
					}
				}
				character_event = { id = Plus.1948 } #Becomes mystic
			}
			5 = {
				modifier = {
					factor = 0
					OR = {
						has_character_flag = hurufi_studying_2
						has_character_flag = hurufi_studying_3
					}
				}
				character_event = { id = Plus.1949 } #Becomes depressed
			}
			10 = {
				modifier = {
					factor = 0
					trait = chaste
				}
				modifier = {
					factor = 0.5
					has_character_flag = hurufi_studying_3
				}
				character_event = { id = Plus.1950 } #Becomes chaste
			}
			5 = {
				modifier = {
					factor = 0
					OR = {
						trait = elusive_shadow
						trait = grey_eminence
						trait = midas_touched
						trait = brilliant_strategist
						trait = mastermind_theologian
					}
				}
				modifier = {
					factor = 2
					OR = {
						has_character_flag = hurufi_studying_2
						has_character_flag = hurufi_studying_3
					}
				}
				character_event = { id = Plus.1951 } #Increases education trait
			}
			5 = {
				modifier = {
					factor = 0
					trait = genius
				}
				modifier = {
					factor = 0
					has_character_flag = hurufi_studying_1
				}
				modifier = {
					factor = 2
					has_character_flag = hurufi_studying_3
				}
				character_event = { id = Plus.1952 } #Gains genius
			}
			10 = {
				modifier = {
					factor = 0
					trait = ill
				}
				character_event = { id = Plus.1953 } #Becomes ill
			}
			15 = {
				modifier = {
					factor = 0
					OR = {
						has_character_flag = hurufi_studying_1
						has_character_flag = hurufi_studying_2
					}
				}
				character_event = { id = Plus.1954 } #Wrong omen
			}
			30 = {
				modifier = {
					factor = 0
					OR = {
						has_character_flag = hurufi_studying_1
						has_character_flag = hurufi_studying_2
					}
				}
				character_event = { id = Plus.1955 } #Good omen
			}
			15 = {
				modifier = {
					factor = 0
					OR = {
						has_character_flag = hurufi_studying_1
						has_character_flag = hurufi_studying_2
					}
				}
				character_event = { id = Plus.1956 } #Bad omen
			}
			30 = {
				character_event = { id = Plus.1957 } #Gains piety
			}
		}
		remove_do_not_disturb_effect = yes
		clr_character_flag = hurufi_studying_1
		clr_character_flag = hurufi_studying_2
		clr_character_flag = hurufi_studying_3
	}
}

# Studying character becomes blind
character_event = {
	id = Plus.1944
	desc = EVTDESC_Plus_1944
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_Plus_1944
		remove_character_modifier = hurufi_studying
		add_trait = blinded
	}
}

# Studying character gains attributes
character_event = {
	id = Plus.1945
	desc = EVTDESC_Plus_1945
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		remove_character_modifier = hurufi_studying
		change_learning = 2
		random_list = {
			20 = { change_diplomacy = 1 }
			20 = { change_martial = 1 }
			20 = { change_stewardship = 1 }
			20 = { change_intrigue = 1 }
		}	
	}
}

# Studying character becomes weak
character_event = {
	id = Plus.1946
	desc = EVTDESC_Plus_1946
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}

	option = {
		name = CURSES
		remove_character_modifier = hurufi_studying
		change_learning = 2
		if = {
			limit = {
				NOT = { is_strong_trigger = yes }
				NOT = { is_weak_trigger = yes }
			}
			add_trait = feeble
		}
		if = {
			limit = { is_strong_trigger = yes }
			remove_trait = strong
			remove_trait = robust
		}
	}
}

# Studying character becomes quick
character_event = {
	id = Plus.1947
	desc = EVTDESC_Plus_1947
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		remove_character_modifier = hurufi_studying
		change_learning = 2
		add_trait = quick
	}
}

# Studying character becomes mystic
character_event = {
	id = Plus.1948
	desc = EVTDESC_Plus_1948
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		remove_character_modifier = hurufi_studying
		change_learning = 2
		add_trait = mystic
	}
}

# Studying character becomes depressed
character_event = {
	id = Plus.1949
	desc = EVTDESC_Plus_1949
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = CURSES
		remove_character_modifier = hurufi_studying
		change_learning = -1
		add_trait = depressed
	}
}

# Studying character becomes chaste
character_event = {
	id = Plus.1950
	desc = EVTDESC_Plus_1950
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = OK
		remove_character_modifier = hurufi_studying
		change_learning = 2
		add_trait = chaste
		piety = 50
	}
}

# Studying character increases education trait
character_event = {
	id = Plus.1951
	desc = EVTDESC_Plus_1951
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		remove_character_modifier = hurufi_studying
		change_learning = 2
		if = {
			limit = { trait = skilled_tactician }
			remove_trait = skilled_tactician
			add_trait = brilliant_strategist
		}
		if = {
			limit = { trait = tough_soldier }
			remove_trait = tough_soldier
			add_trait = skilled_tactician
		}
		if = {
			limit = { trait = misguided_warrior }
			remove_trait = misguided_warrior
			add_trait = tough_soldier
		}	
		if = {
			limit = { trait = intricate_webweaver }
			remove_trait = intricate_webweaver
			add_trait = elusive_shadow
		}
		if = {
			limit = { trait = flamboyant_schemer }
			remove_trait = flamboyant_schemer
			add_trait = intricate_webweaver
		}
		if = {
			limit = { trait = amateurish_plotter }
			remove_trait = amateurish_plotter
			add_trait = flamboyant_schemer
		}	
		if = {
			limit = { trait = charismatic_negotiator }
			remove_trait = charismatic_negotiator
			add_trait = grey_eminence
		}
		if = {
			limit = { trait = underhanded_rogue }
			remove_trait = underhanded_rogue
			add_trait = charismatic_negotiator
		}
		if = {
			limit = { trait = naive_appeaser }
			remove_trait = naive_appeaser
			add_trait = underhanded_rogue
		}		
		if = {
			limit = { trait = fortune_builder }
			remove_trait = fortune_builder
			add_trait = midas_touched
		}
		if = {
			limit = { trait = thrifty_clerk }
			remove_trait = thrifty_clerk
			add_trait = fortune_builder
		}
		if = {
			limit = { trait = indulgent_wastrel }
			remove_trait = indulgent_wastrel
			add_trait = thrifty_clerk
		}
		if = {
			limit = { trait = scholarly_theologian }
			remove_trait = scholarly_theologian
			add_trait = mastermind_theologian
		}
		if = {
			limit = { trait = martial_cleric }
			remove_trait = martial_cleric
			add_trait = scholarly_theologian
		}
		if = {
			limit = { trait = detached_priest }
			remove_trait = detached_priest
			add_trait = martial_cleric
		}
	}
}

# Studying character becomes genius
character_event = {
	id = Plus.1952
	desc = EVTDESC_Plus_1952
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		remove_character_modifier = hurufi_studying
		change_learning = 2
		add_trait = genius
	}
}

# Studying character becomes ill
character_event = {
	id = Plus.1953
	desc = EVTDESC_Plus_1953
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = OK
		remove_character_modifier = hurufi_studying
		change_learning = 2
		if = { 
			limit = { 
				NOT = { 
					has_dlc = "Reapers" 
				} 
			} 
			add_trait = ill 
		} 
		if = { 
			limit = { 
				has_dlc = "Reapers" 
			} 
			add_symptom_effect = yes 
		}
	}
}

# Wrong Omen
character_event = {
	id = Plus.1954
	desc = EVTDESC_Plus_1954
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = CURSES
		if = {
			limit = { has_character_modifier = hurufi_studying }
			remove_character_modifier = hurufi_studying
			add_trait = depressed
			change_learning = -1
		}
		add_character_modifier = {
			name = wrong_omen
			duration = 365
		}
	}
}

# Good Omen
character_event = {
	id = Plus.1955
	desc = EVTDESC_Plus_1955
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		if = {
			limit = { has_character_modifier = hurufi_studying }
			remove_character_modifier = hurufi_studying
			change_learning = 2
		}
		add_character_modifier = {
			name = good_omen
			duration = 365
		}
	}
}

# Bad Omen
character_event = {
	id = Plus.1956
	desc = EVTDESC_Plus_1956
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = OK
		if = {
			limit = { has_character_modifier = hurufi_studying }
			remove_character_modifier = hurufi_studying
			change_learning = 2
		}
		add_character_modifier = {
			name = bad_omen
			duration = 365
		}
	}
}

# Studying character receives bonus piety
character_event = {
	id = Plus.1957
	desc = EVTDESC_Plus_1957
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				learning = 20
				trait = hurufi_mystic_b
			}
			remove_trait = hurufi_mystic_b
			add_trait = hurufi_mystic_c
		}
		if = {
			limit = {
				learning = 14
				trait = hurufi_mystic_a
			}
			remove_trait = hurufi_mystic_a
			add_trait = hurufi_mystic_b
		}
		if = {
			limit = {
				learning = 8
				NOR = { 
					trait = hurufi_mystic_a
					trait = hurufi_mystic_b
					trait = hurufi_mystic_c
				}
			}
			add_trait = hurufi_mystic_a
		}
	}
	
	option = {
		name = EXCELLENT
		if = {
			limit = { has_character_modifier = hurufi_studying }
			remove_character_modifier = hurufi_studying
			change_learning = 2
		}
		piety = 150
		prestige = 150
	}
}

# Bounce event for reading omens
character_event = {
	id = Plus.1958
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		remove_do_not_disturb_effect = yes
		add_character_modifier = {
			name = hurufi_prediction
			duration = 730
		}
		random_list = {
			10 = { character_event = { id = Plus.1954 } } #Wrong Omen
			50 = { character_event = { id = Plus.1955 } } #Good Omen
			20 = { character_event = { id = Plus.1956 } } #Bad Omen
			20 = { character_event = { id = Plus.1957 } } #Extra Piety
		}
	}
}

# al-Hurufi appears
narrative_event = {
	id = Plus.1959
	title = EVTNAME_Plus_1959
	desc = EVTDESC_Plus_1959
	picture = GFX_evt_imam
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	only_rulers = yes
	only_playable = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		year = 1390
		any_demesne_province = {
			religion_group = muslim
			NOT = { religion = hurufi }
			region = custom_azerbaijan
		}
		NOR = {
			religion = hurufi
			has_global_flag = alhurufi
		}
	}
	
	major_trigger = {
		OR = {
			character = ROOT
			religion = hurufi
			capital_scope = {
				NOT = {
					distance = {
						where = 668 # Shirvan
						value = 600	# Same part of the world
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	immediate = {
		set_global_flag = alhurufi
		random_demesne_province = {
			limit = {
				religion_group = muslim
				NOT = { religion = hurufi }
				region = custom_azerbaijan
			}
			save_event_target_as = hurufi_province
			religion = hurufi
			add_province_modifier = {
				name = heretic_stronghold
				duration = 3650
			}
			any_neighbor_province = {
				limit = {
					religion_group = muslim
					NOT = { religion = hurufi }
				}
				random = {
					chance = 75
					religion = hurufi
				}
			}
		}
		create_character = {
			random_traits = no
			dynasty = 1000124392 #Astarabadi
			name = "Fazlallah"
			culture = persian
			religion = hurufi
			age = 40
			female = no
			attributes = {
				diplomacy = 12
				intrigue = 15
				learning = 15
			}
			trait = quick
			trait = mastermind_theologian
			trait = heresiarch
			trait = hurufi_mystic_c
			trait = diligent
			trait = ambitious
			trait = gregarious
			trait = poet
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1959 #Convert
		trigger = {
			character = ROOT
			religion_group = muslim
			controls_religion = no
			is_heretic = no
			NOT = { trait = zealous }
		}
		piety = -100
		religion_authority = {
			modifier = ruler_converted_from
		}
		religion = hurufi
		religion_authority = {
			modifier = ruler_converted_to
		}
		668 = { remove_province_modifier = heretic_stronghold }
		hidden_tooltip = {
			any_courtier = {
				limit = {
					is_adult = no
					is_ruler = no
					dynasty = ROOT
				}
				religion = ROOT
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1959 #Refuse
		trigger = {
			character = ROOT
		}
	}
	option = {
		name = EVTOPTC_Plus_1959
		trigger = {
			religion = hurufi
		}
	}
	option = {
		name = EVTOPTD_Plus_1959
		trigger = {
			religion_group = muslim
			NOT = { religion = hurufi }
			NOT = { character = ROOT }
		}
	}
	option = {
		name = I_SEE
		trigger = {
			NOT = { religion_group = muslim }
			NOT = { character = ROOT }
		}
	}
}

### SHIITE EVENTS

# Shiite Imamah passes on trait to heir
character_event = {
	id = Plus.1960
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		trait = shiite_claimant
	}
	
	immediate = {
		remove_trait = shiite_claimant
		#pass it onto heir first, if one exists
		if = {
			limit = {
				current_heir = {
					is_female = no
					religion = shiite
					NOT = { trait = incapable }
				}
			}
			current_heir = {
				set_character_flag = is_shiite_claimant
				add_trait = shiite_claimant
				if = {
					limit = { d_shiite = { has_holder = yes } }
					add_claim = d_shiite
				}
			}		
			break = yes
		}
		#then pass onto eldest son
		random_child = {
			limit = {
				is_alive = yes
				is_female = no
				religion = shiite
				NOR = {
					trait = bastard
					trait = incapable
					any_sibling = {
						is_alive = yes
						is_female = no
						religion = shiite
						NOT = { trait = bastard }
						is_older_than = PREV
					}
				}
			}
			set_character_flag = is_shiite_claimant
			add_trait = shiite_claimant
			if = {
				limit = { d_shiite = { has_holder = yes } }
				add_claim = d_shiite
			}
			break = yes
		}
		#then pass onto eldest brother
		random_sibling = {
			limit = {
				is_alive = yes
				is_female = no
				trait = sayyid
				religion = shiite
				NOR = {
					trait = bastard
					trait = incapable
					any_sibling = {
						is_alive = yes
						is_female = no
						religion = shiite
						trait = sayyid
						NOT = { trait = bastard }
						NOT = { character = ROOT }
						is_older_than = PREV
					}
				}
			}
			set_character_flag = is_shiite_claimant
			add_trait = shiite_claimant
			if = {
				limit = { d_shiite = { has_holder = yes } }
				add_claim = d_shiite
			}
			break = yes
		}
		#then pass onto eldest grandson
		random_dynasty_member = {
			limit = {
				is_alive = yes
				is_female = no
				trait = sayyid
				religion = shiite
				father_even_if_dead = {
					is_child_of = ROOT
					NOT = { trait = bastard }
				}
				NOR = {
					trait = bastard
					trait = incapable
					any_dynasty_member = {
						is_older_than = PREV
						is_alive = yes
						is_female = no
						trait = sayyid
						religion = shiite
						father_even_if_dead = {
							is_child_of = ROOT
							NOT = { trait = bastard }
						}
					}
				}
			}
			set_character_flag = is_shiite_claimant
			add_trait = shiite_claimant
			if = {
				limit = { d_shiite = { has_holder = yes } }
				d_shiite = { add_claim = PREV }
			}
			break = yes
		}
		#then pass onto eldest dynasty member
		random_dynasty_member = {
			limit = {
				is_alive = yes
				is_female = no
				trait = sayyid
				religion = shiite
				NOR = {
					trait = bastard
					trait = incapable
					any_dynasty_member = {
						is_older_than = PREV
						is_alive = yes
						is_female = no
						trait = sayyid
						religion = shiite
					}
				}
			}
			set_character_flag = is_shiite_claimant
			add_trait = shiite_claimant
			if = {
				limit = { d_shiite = { has_holder = yes } }
				add_claim = d_shiite
			}
			break = yes
		}
	}
}

# Existing Shiite Imamah starts uprising
character_event = {
	id = Plus.1961
	
	hide_window = yes
	
	religion = shiite
	only_men = yes
	min_age = 16
	max_age = 50
	capable_only = yes
	prisoner = no
	ai = yes

	trigger = {
		year = 870
		trait = shiite_claimant
		d_shiite = { has_holder = no }
		NOR = {
			higher_tier_than = DUKE
			trait = incapable
			trait = content
			trait = cynical
			trait = imbecile
			trait = inbred
			has_global_flag = shia_caliphate_revolt
			has_global_flag = shia_caliphate_revolt_ongoing
		}
		any_independent_ruler = {
			ai = yes
			is_landed = yes
			higher_tier_than = DUKE
			religion_group = muslim
			NOT = { religion = shiite }
			OR = {
				NOT = { is_liege_of = ROOT }
				NOT = { reverse_opinion = { who = ROOT value = 0 } }
			}
			capital_scope = {
				OR = {
					region = custom_persia
					region = custom_syria
					region = custom_egypt
					region = custom_africa
					region = custom_algiers
				}
			}
			any_realm_province = {
				OR = {
					region = custom_persia
					region = custom_syria
					region = custom_egypt
					region = custom_africa
					region = custom_algiers
				}
				kingdom = {
					OR = {
						has_holder = no
						holder_scope = { character = PREVPREVPREV }
					}
					num_title_realm_provs = {
						who = PREVPREV
						value = 6
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 100
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.75
			trait = zealous
		}
		modifier = {
			factor = 1.25
			trait = humble
		}
		modifier = {
			factor = 1.25
			NOT = { diplomacy = 4 }
		}
		modifier = {
			factor = 1.25
			NOT = { diplomacy = 8 }
		}
		modifier = {
			factor = 0.8
			diplomacy = 12
		}
		modifier = {
			factor = 0.8
			diplomacy = 14
		}
		modifier = {
			factor = 0.8
			diplomacy = 16
		}
		modifier = {
			factor = 0.8
			diplomacy = 18
		}
		modifier = {
			factor = 0.8
			diplomacy = 20
		}
		modifier = {
			factor = 1.25
			NOT = { martial = 4 }
		}
		modifier = {
			factor = 1.25
			NOT = { martial = 8 }
		}
		modifier = {
			factor = 0.8
			martial = 12
		}
		modifier = {
			factor = 0.8
			martial = 14
		}
		modifier = {
			factor = 0.8
			martial = 16
		}
		modifier = {
			factor = 0.8
			martial = 18
		}
		modifier = {
			factor = 0.8
			martial = 20
		}
		modifier = {
			factor = 1.1
			NOT = { intrigue = 4 }
		}
		modifier = {
			factor = 1.1
			NOT = { intrigue = 8 }
		}
		modifier = {
			factor = 0.9
			intrigue = 12
		}
		modifier = {
			factor = 0.9
			intrigue = 14
		}
		modifier = {
			factor = 0.9
			intrigue = 16
		}
		modifier = {
			factor = 0.9
			intrigue = 18
		}
		modifier = {
			factor = 0.9
			intrigue = 20
		}
		modifier = {
			factor = 1.5
			NOR = {
				diplomacy = 12
				martial = 12
				intrigue = 12
			}
		}
		modifier = {
			factor = 0.5
			year = 900
		}
		modifier = {
			factor = 0.5
			year = 950
		}
		modifier = {
			factor = 0.25
			year = 1000
		}
		modifier = {
			factor = 0.25
			year = 1050
		}
		modifier = {
			factor = 0.25
			year = 1100
		}
	}
	
	immediate = {
		log = "[Root.GetTitledName] is an existing Shiite Imamah who has become the Shiite Caliphate Uprising"
		set_character_flag = shia_caliphate_pretender
		set_global_flag = shia_caliphate_revolt
		save_event_target_as = shiite_revolter
		
		#give priority to Africa
		random_independent_ruler = {
			limit = {
				ai = yes
				is_landed = yes
				higher_tier_than = DUKE
				religion_group = muslim
				NOT = { religion = shiite }
				OR = {
					NOT = { is_liege_of = ROOT }
					NOT = { reverse_opinion = { who = ROOT value = -25 } }
				}
				capital_scope = {
					OR = {
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
				}
				any_realm_province = {
					region = custom_africa
					kingdom = {
						OR = {
							has_holder = no
							holder_scope = { character = PREVPREVPREV }
						}
						num_title_realm_provs = {
							who = PREVPREV
							value = 6
						}
					}
				}
			}
			save_event_target_as = shiite_revolt_target
			random_realm_province = {
				limit = {
					region = custom_africa
					kingdom = {
						OR = {
							has_holder = no
							holder_scope = { character = PREVPREVPREV }
						}
						num_title_realm_provs = {
							who = PREVPREV
							value = 6
						}
					}
				}
				kingdom = { save_event_target_as = shiite_revolt_target_title }
			}
			if = {
				limit = {
					is_ruler = yes
					primary_title = {
						NOT = { kingdom = { title = event_target:shiite_revolt_target_title } }
					}
				}
				set_character_flag = abdicated_claimant
				primary_title = { save_event_target_as = abdicated_title }
				current_heir = {
					ROOT = { transfer_scaled_wealth = { to = PREV value = all } }
				}
				abdicate = yes
			}
			event_target:shiite_revolter = {
				narrative_event = { id = Plus.1962 }
			}
			break = yes
		}
		
		#then anywhere else on continental Africa
		random_independent_ruler = {
			limit = {
				ai = yes
				is_landed = yes
				higher_tier_than = DUKE
				religion_group = muslim
				NOT = { religion = shiite }
				OR = {
					NOT = { is_liege_of = ROOT }
					NOT = { reverse_opinion = { who = ROOT value = -25 } }
				}
				capital_scope = {
					OR = {
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
				}
				any_realm_province = {
					OR = {
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
					kingdom = {
						OR = {
							has_holder = no
							holder_scope = { character = PREVPREVPREV }
						}
						num_title_realm_provs = {
							who = PREVPREV
							value = 6
						}
					}
				}
			}
			save_event_target_as = shiite_revolt_target
			random_realm_province = {
				limit = {
					OR = {
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
					kingdom = {
						OR = {
							has_holder = no
							holder_scope = { character = PREVPREVPREV }
						}
						num_title_realm_provs = {
							who = PREVPREV
							value = 6
						}
					}
				}
				kingdom = { save_event_target_as = shiite_revolt_target_title }
			}
			if = {
				limit = {
					is_ruler = yes
					primary_title = {
						NOT = { kingdom = { title = event_target:shiite_revolt_target_title } }
					}
				}
				set_character_flag = abdicated_claimant
				primary_title = { save_event_target_as = abdicated_title }
				current_heir = {
					ROOT = { transfer_scaled_wealth = { to = PREV value = all } }
				}
				abdicate = yes
			}
			event_target:shiite_revolter = {
				narrative_event = { id = Plus.1962 }
			}
			break = yes
		}

		#failing that, anywhere will do
		random_independent_ruler = {
			limit = {
				ai = yes
				is_landed = yes
				higher_tier_than = DUKE
				religion_group = muslim
				NOT = { religion = shiite }
				OR = {
					NOT = { is_liege_of = ROOT }
					NOT = { reverse_opinion = { who = ROOT value = -25 } }
				}
				capital_scope = {
					OR = {
						region = custom_persia
						region = custom_syria
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
				}
				any_realm_province = {
					OR = {
						region = custom_persia
						region = custom_syria
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
					kingdom = {
						OR = {
							has_holder = no
							holder_scope = { character = PREVPREVPREV }
						}
						num_title_realm_provs = {
							who = PREVPREV
							value = 6
						}
					}
				}
			}
			save_event_target_as = shiite_revolt_target
			random_realm_province = {
				limit = {
					OR = {
						region = custom_persia
						region = custom_syria
						region = custom_egypt
						region = custom_africa
						region = custom_algiers
					}
					kingdom = {
						OR = {
							has_holder = no
							holder_scope = { character = PREVPREVPREV }
						}
						num_title_realm_provs = {
							who = PREVPREV
							value = 6
						}
					}
				}
				kingdom = { save_event_target_as = shiite_revolt_target_title }
			}
		}		
		if = {
			limit = {
				is_ruler = yes
				primary_title = {
					NOT = { kingdom = { title = event_target:shiite_revolt_target_title } }
				}
			}
			set_character_flag = abdicated_claimant
			primary_title = { save_event_target_as = abdicated_title }
			current_heir = {
				ROOT = { transfer_scaled_wealth = { to = PREV value = all } }
			}
			abdicate = yes
		}
		event_target:shiite_revolter = {
			narrative_event = { id = Plus.1962 }
		}
	}
}

# New Shi'a Caliphate Revolt event
narrative_event = {
	id = Plus.1962
	title = EVTNAME39640
	picture = GFX_evt_bishop_muslim
	border = GFX_event_narrative_frame_religion
	
	desc = {
		text = EVTDESC_Plus_1962_found
		trigger = {
			event_target:shiite_revolter = {
				has_character_flag = found_claimant
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1962_abdicate
		trigger = {
			event_target:shiite_revolter = {
				NOT = { has_character_flag = found_claimant }
				has_character_flag = abdicated_claimant
			}
		}
	}
	desc = {
		text = EVTDESC_Plus_1962
		trigger = {
			event_target:shiite_revolter = {
				NOT = { has_character_flag = found_claimant }
				NOT = { has_character_flag = abdicated_claimant }
			}
		}
	}

	is_triggered_only = yes
	hide_from = yes
	show_ROOT = yes
	major = yes
	
	immediate = {
		set_global_flag = shia_caliphate_revolt_ongoing
		event_target:shiite_revolt_target = {
			random_realm_province = {
				limit = { kingdom = { title = event_target:shiite_revolt_target_title } }
				event_target:shiite_revolter = {
					create_title = {
						tier = KING
						landless = yes
						temporary = yes
						culture = THIS
						name = SHIA_CALIPHATE_REVOLT
						holder = THIS
						ruler = "IMAM"
						ruler_female = "CALIPHA"
						foa = "CALIPH_FOA"
					}
					primary_title = {
						add_law = succ_turkish_succession
					}
					any_dynasty_member = {
						limit = {
							is_ruler = no
							is_close_relative = PREV
						}
						move_character = PREV
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 30
						trait = brilliant_strategist
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.5
							attrition = 0.25
							maintenance_multiplier = 0
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 27
						trait = brilliant_strategist
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.3
							attrition = 0.25
							maintenance_multiplier = 0
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 25
						trait = skilled_tactician
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 23
						trait = skilled_tactician
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 27
						trait = skilled_tactician
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 24
						trait = skilled_tactician
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 32
						trait = brilliant_strategist
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							cannot_inherit = yes
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 25
						trait = skilled_tactician
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							cannot_inherit = yes
							disband_on_peace = yes
						}
					}
					create_character = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 28
						trait = skilled_tactician
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
						spawn_unit = {
							province = PREVPREV
							home = PREVPREV
							owner = PREV
							match_character = PREVPREVPREV
							match_mult = 0.15
							attrition = 0.25
							maintenance_multiplier = 0
							cannot_inherit = yes
							disband_on_peace = yes
						}
					}
					create_random_priest = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 50
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
					}
					create_random_diplomat = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 40
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
					}
					create_random_intriguer = {
						random_traits = yes
						dynasty = none
						religion = THIS
						culture = THIS
						female = no
						age = 40
					}
					new_character = {
						opinion = { who = PREV modifier = loyal_vassal years = 100 }
					}
					war = {
						target = PREVPREV
						casus_belli = shia_caliphate_rising
						thirdparty_title = PREV
						tier = KING
						infamy = 0
					}
					recalc_succession = yes
				}
			}
		}
	}
	
	option = {
		name = "EVTOPTA39640"
		trigger = { character = event_target:shiite_revolt_target }
	}
	option = {
		name = "EVTOPTB39640"
		trigger = { religion = shiite }
	}
	option = {
		name = "EVTOPTC39640"
		trigger = {
			religion_group = muslim
			NOT = { religion = shiite }
			NOT = { character = event_target:shiite_revolt_target }
		}
	}
	option = {
		name = "EVTOPTD39640"
		trigger = {
			NOT = { religion_group = muslim }
			NOT = { character = event_target:shiite_revolt_target }
		}
	}
}

# Event troops received upon forming the Shiite Caliphate
character_event = {
	id = Plus.1963
	desc = EVTDESC_Plus_1963
	picture = GFX_evt_bishop_muslim
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		d_shiite = { set_title_flag = shiite_followers }
		capital_scope = {
			ROOT = {
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 1600 1600 }
						light_cavalry = { 840 840 }
						heavy_infantry = { 210 210 }
						knights = { 55 55 }
					}
					attrition = 1.0
					maintenance_multiplier = 0
					earmark = shiite_claimant
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 1600 1600 }
						light_cavalry = { 840 840 }
						heavy_infantry = { 210 210 }
						knights = { 55 55 }
					}
					attrition = 1.0
					maintenance_multiplier = 0
					earmark = shiite_claimant
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					troops = {
						light_infantry = { 1600 1600 }
						light_cavalry = { 840 840 }
						heavy_infantry = { 210 210 }
						knights = { 55 55 }
					}
					attrition = 1.0
					maintenance_multiplier = 0
					earmark = shiite_claimant
				}
			}
		}		
	}
}

# Prompt AI shiite claimant to marry
character_event = {
	id = Plus.1970
	
	hide_window = yes

	min_age = 16
	capable_only = yes
	has_character_flag = is_shiite_claimant
	prisoner = no
	ai = yes
	is_married = no
	is_sick = no
	
	trigger = {
		#is_ill = no
		fertility = 0.33
	}
	
	mean_time_to_happen = {
		months = 6
	}
	
	immediate = {
		if = {
			limit = { is_ruler = no }
			liege = {
				create_character = {
					random_traits = yes
					dynasty = random
					female = yes
					age = 17
					culture = ROOT
					religion = ROOT
				}
				new_character = {
					log = "[This.GetTitledName] marries [Root.GetTitledName] (Spouse Finder - new character)"
					add_spouse = ROOT
				}
				break = yes
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			female = yes
			age = 17
			culture = ROOT
			religion = ROOT
		}
		new_character = {
			log = "[This.GetTitledName] marries [Root.GetTitledName] (Spouse Finder - new character)"
			add_spouse = ROOT
		}
	}
}
		
# Prompt AI shiite claimant to have children
character_event = {
	id = Plus.1971
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	has_character_flag = is_shiite_claimant
	prisoner = no
	ai = yes
	is_married = yes
	
	trigger = {
		fertility = 0.33
		NOR = {
			any_child = {
				is_female = no
				NOT = { trait = bastard }
			}
			any_spouse = { is_pregnant = yes }
		}
		any_spouse = {
			is_pregnant = no
			is_ill = no
			prisoner = no
			NOT = { trait = incapable }
			fertility = 0.33
		}
	}
	
	mean_time_to_happen = {
		months = 6
	}
	
	immediate = {
		random_spouse = {
			limit = {
				is_pregnant = no
				is_ill = no
				prisoner = no
				NOT = { trait = incapable }
				fertility = 0.33
			}
			ROOT = { impregnate = PREV }
		}
	}
}
	
### DRUZE EVENTS

# Druze becomes Uqqal after studying
character_event = {
	id = Plus.1965
	desc = EVTDESC_Plus_1965
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	religion = druze
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		learning = 8
		trait = druze_juhhal
		piety = 0
		OR = { 
			has_focus = focus_theology
			has_ambition = obj_druze_esoteric_learning
		}
		OR = {
			trait = just
			trait = temperate
			trait = charitable
			trait = humble
			has_ambition = obj_druze_esoteric_learning
		} 
		NOR = {
			trait = druze_uqqal
			trait = druze_ajawid
			trait = cynical
			has_character_flag = no_druze_initiate
		}
	}
	
	mean_time_to_happen = {
		years = 5
		modifier = {
			factor = 0.8
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = temperate
		}
		modifier = {
			factor = 0.8
			trait = charitable
		}
		modifier = {
			factor = 0.8
			trait = humble
		}
		modifier = {
			factor = 1.5
			trait = arbitrary
		}
		modifier = {
			factor = 1.5
			trait = gluttonous
		}
		modifier = {
			factor = 1.5
			trait = greedy
		}
		modifier = {
			factor = 1.5
			trait = proud
		}
		modifier = {
			factor = 0.9
			piety = 100
		}
		modifier = {
			factor = 0.8
			learning = 10
		}
		modifier = {
			factor = 0.8
			learning = 12
		}
		modifier = {
			factor = 0.8
			learning = 14
		}
		modifier = {
			factor = 0.8
			learning = 16
		}
		modifier = {
			factor = 0.8
			learning = 18
		}
		modifier = {
			factor = 0.8
			learning = 20
		}
		modifier = {
			factor = 0.5
			has_focus = focus_theology
			has_ambition = obj_druze_esoteric_learning
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1965
		narrative_event = { id = Plus.1966 days = 1 random = 2 }
	}	
	option = {
		name = EVTOPTB_Plus_1965
		set_character_flag = no_druze_initiate
		piety = -50
	}
}

narrative_event = {
	id = Plus.1966
	title = EVTNAME_Plus_1966
	desc = EVTDESC_Plus_1966
	picture = GFX_evt_imam
	border = GFX_event_narrative_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1966
		add_trait = druze_uqqal
	}
}

# Druze Uqqal becomes Ajawid
character_event = {
	id = Plus.1967
	desc = EVTDESC_Plus_1967
	picture = GFX_evt_imam
	border = GFX_event_normal_frame_religion
	
	religion = druze
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		trait = druze_uqqal
		piety = 250
		learning = 12
		calc_true_if = {
			amount = 2
			trait = just
			trait = temperate
			trait = charitable
			trait = humble
			learning = 15
			piety = 500
		}
		NOR = {
			trait = druze_ajawid
			trait = cynical
			trait = slothful
			trait = cruel
			trait = lunatic
			trait = decadent
		}
	}
	
	mean_time_to_happen = {
		years = 10
		modifier = {
			factor = 0.8
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = temperate
		}
		modifier = {
			factor = 0.8
			trait = charitable
		}
		modifier = {
			factor = 0.8
			trait = humble
		}
		modifier = {
			factor = 1.5
			trait = arbitrary
		}
		modifier = {
			factor = 1.5
			trait = gluttonous
		}
		modifier = {
			factor = 1.5
			trait = greedy
		}
		modifier = {
			factor = 1.5
			trait = proud
		}
		modifier = {
			factor = 0.9
			piety = 500
		}
		modifier = {
			factor = 0.9
			piety = 750
		}
		modifier = {
			factor = 0.9
			piety = 1000
		}
		modifier = {
			factor = 0.5
			has_focus = focus_theology
		}
		modifier = {
			factor = 1.5
			top_liege = { 
				any_realm_character = {
					trait = druze_ajawid
				}
			}
		}
		modifier = {
			factor = 2.0
			top_liege = { 
				any_realm_character = {
					trait = druze_ajawid
					count = 2
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1967
		piety = 200
		add_trait = druze_ajawid
	}
}

# Druze Shaykh becomes religion head
narrative_event = {
	id = Plus.1968
	title = EVTNAME_Plus_1968
	desc = EVTDESC_Plus_1968
	picture = GFX_evt_imam
	border = GFX_event_narrative_frame_religion

	is_triggered_only = yes
	major = yes
	
	immediate = {
		set_global_flag = druze_shaykh
		set_parent_religion = { religion = druze parent = 0 }
	}
	
	option = {
		name = EVTOPTA_Plus_1968
		trigger = { religion = druze }
	}
	option = {
		name = EVTOPTB_Plus_1968
		trigger = {
			NOT = { religion = druze }
			religion_group = muslim
		}
	}
	option = {
		name = EVTOPTC_Plus_1968
		trigger = {
			NOT = { religion_group = muslim }
		}
	}
}

