namespace = fp3_struggle

### EVENT LIST ####################################################################
## 0001 - 0020	Internal Management Events by Hugo Cortell
## 0021 - 0030	Invalidation Events by Hugo Cortell
## 0031	- 0040	Empty block by Hugo Cortell
## 0051 - 0060	FP3 Struggle Intro Events by Hugo Cortell
## 0061 - 0070	Realm Shattering Events by Hugo Cortell
## 0071	- 0300	Struggle Endings by Thalassic Design Dept (Ola, Eren, Hugo)
## XXXX - XXXX	Event Name Here by Author Name Here
## XXXX - XXXX	Event Name Here by Author Name Here
## XXXX - XXXX	Event Name Here by Author Name Here
## 9980 - 9999	Integrity Validation Tools by Hugo Cortell
###################################################################################

###################################
# FP3 Maintenance Events
# By Ewan Cowhig Croft
###################################
#
#scripted_trigger fp3_struggle_0001_valid_ai_struggle_char_trigger = {
#	# Basic checks.
#	can_execute_decision = fp3_name_read_in_friday_prayer_decision
#	is_ai = yes
#	# Suitability for switchin' checks.
#	OR = {
#		# If they're gonna become a supporter, it should make sense.
#		AND = {
#			opinion = {
#				target = title:d_sunni.holder
#				value >= low_positive_opinion
#			}
#			OR = {
#				# We check for the opposite, since you're flipflopping.
#				has_trait = fp3_struggle_detractor
#				NOR = {
#					has_trait = fp3_struggle_supporter
#					has_trait = fp3_struggle_detractor
#				}
#			}
#		}
#		# If they're gonna become a detractor, that should make sense too.
#		AND = {
#			opinion = {
#				target = title:d_sunni.holder
#				value <= low_negative_opinion
#			}
#			OR = {
#				# We check for the opposite, since you're flipflopping.
#				has_trait = fp3_struggle_supporter
#				NOR = {
#					has_trait = fp3_struggle_supporter
#					has_trait = fp3_struggle_detractor
#				}
#			}
#		}
#	}
#}
#
#fp3_struggle.0001 = {
#	hidden = yes
#	scope = none
#	scope = struggle
#
#	# If the struggle ends, break the loop.
#	trigger = { exists = struggle:persian_struggle }
#
#	immediate = {
#		if = {
#			# If there isn't a caliph at present, then stop trying to make people talk about them.
#			limit = { exists = title:d_sunni.holder }
#			struggle:persian_struggle = {
#				every_involved_ruler = {
#					limit = { fp3_struggle_0001_valid_ai_struggle_char_trigger = yes }
#					random = {
#						chance = fp3_struggle_switch_sides_value
#						execute_decision = fp3_name_read_in_friday_prayer_decision
#					}
#				}
#				every_interloper_ruler = {
#					limit = { fp3_struggle_0001_valid_ai_struggle_char_trigger = yes }
#					random = {
#						chance = fp3_struggle_switch_sides_value
#						execute_decision = fp3_name_read_in_friday_prayer_decision
#					}
#				}
#			}
#		}
#		
#		# Cue this event up again for the next time around.
#		trigger_event = {
#			id = fp3_struggle.0001
#			years = { 3 5 }
#		}
#	}
#}
#
####################################
## FP3 Intro Events
## By Hugo Cortell, reworked by Ewan Cowhig Croft
####################################
#fp3_struggle.0051 = { # BOOKMARK EVENT
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0051.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						is_struggle_type = persian_struggle
#						is_struggle_phase = struggle_persia_phase_unrest
#					}
#				}
#				desc = fp3_struggle.0051.desc.unrest
#			}
#			desc = fp3_struggle.0051.desc.stabilization
#		}
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						is_struggle_type = persian_struggle
#						is_struggle_phase = struggle_persia_phase_stabilisation
#					}
#				}
#				desc =  fp3_struggle.0051.desc.stabilization_actor
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_supporter
#				}
#				desc = fp3_struggle.0051.desc.supporter
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_detractor
#				}
#				desc = fp3_struggle.0051.desc.detractor
#			}
#			triggered_desc = {
#				trigger = {
#					fp3_struggle_is_the_caliph = yes
#				}
#				desc = fp3_struggle.0051.desc.caliph
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = involved
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0051.desc.involved
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = interloper
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0051.desc.interloper
#			}
#		}
#	}
#	theme = realm
#	trigger = { # we need to prevent this from firing for all players when a new player joins in MP
#		is_ai = no
#		NOT = { has_character_flag = fp3_struggle_intro_event_flag }
#		any_character_struggle = { is_struggle_type = persian_struggle }
# 	}
#	override_background = { reference = fp3_fullscreen_intro }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	cooldown = { years = 100 }
#
#	widgets = {
#		widget = {
# 			gui = "event_window_widget_struggle_info"
# 			container = "dynamic_content_widget"
# 			controller = struggle_info
# 			setup_scope = { struggle:persian_struggle = { save_scope_as = struggle } }
#		}
#	}
#	immediate = {
#		play_music_cue = strugglestart_cue
#		add_character_flag = fp3_struggle_intro_event_flag
#		add_to_global_variable_list = { # List is only checked for removal, comparing it in the trigger would be needlessly expensive
#			name = fp3_intro_flag_character_list
#			target = root
#		}
#		save_scope_value_as = {
#			name = start
#			value = yes
#		}
#
#		# LOC SCOPES
#		character:34010	= { save_scope_as = Mutawakkil }	# Stabbed by guards
#		character:34012	= { save_scope_as = Muntasir }		# Poisoned probably
#		character:34013 = { save_scope_as = Mustain }		# Betrayed by bookmark character (?) (Note: this char is listed as 3933 in some other files for some reason)
#		character:34014	= { save_scope_as = Mostaza }		# Bookmark ruler
#	}
#	option = {
#		name = {
#			text = {
#				first_valid = {
#					triggered_desc = {
#						trigger = {
#							any_character_struggle = { is_struggle_type = persian_struggle }
#							has_title = character:34014.primary_title
#						}
#						desc = fp3_struggle.0051.b
#					}
#					desc = fp3_struggle.0051.a
#				}
#			}
#		}
#		clicksound = "event:/DLC/FP2/SFX/UI/fp2_struggle_start_select"
#	}
#}
#
##################################################
## Struggle Endings								#
## By Hugo Cortell, Maxence Voleau, Ola Jentzsch & Eren Humphrey #
####################################################################
## Script is set up in this way to prevent out of order executions #
####################################################################
#
#### STRENGTHEN CALIPHATE ENDING ### 0071 = 0080 ###
#fp3_struggle.0071 = { # Strengthen the Caliphate Ending
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0071.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					fp3_struggle_is_the_caliph = yes
#				}
#				desc = fp3_struggle.0071.desc.caliph
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_supporter
#				}
#				desc = fp3_struggle.0071.desc.supporter
#			}
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_strength }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	immediate = {
#		fp3_ending_effects_assertion = yes
#		character:34014 = { save_scope_as = Mostaza }		# Bookmark ruler
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0071.a
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#		
#		ai_chance = {
#			base = 75
#			
#			modifier = {
#				factor = 0.1
#				realm_size >= 250
#			}
#		}
#	}
#
#	option = {
#		trigger = {
#			has_dlc_feature = roads_to_power
#			fp3_struggle_is_the_caliph = yes
#			NOT = { government_has_flag = government_is_administrative }
#		}
#		name = fp3_struggle.0071.b
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#		
#		convert_to_administrative_from_feudalism_effect = { GOVERNMENT_TO_ADOPT = flag:administrative }
#		add_legitimacy_effect = { LEGITIMACY = admin_convert_legitimacy_value } #One Time Legitimacy Boost
#		
#		ai_chance = {
#			base = 0
#			
#			modifier = {
#				add = 25
#				realm_size >= 75
#			}
#			modifier = {
#				add = 25
#				realm_size >= 100
#			}
#			modifier = {
#				add = 25
#				realm_size >= 125
#			}
#			modifier = {
#				add = 25
#				realm_size >= 150
#			}
#			modifier = {
#				add = 50
#				realm_size >= 200
#			}
#		}
#	}
#
#	after = {
#		fp3_end_persian_struggle_effect = {
#			ENDING = struggle_persia_ending_assertion_decision
#			EVENT = fp3_struggle.0072
#			FLAG = flag:fp3_struggle_strengthen_caliphate_ending
#		}
#	}
#}
#
#fp3_struggle.0072 = { # Notification for relevant people
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0071.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					fp3_struggle_is_the_caliph = yes
#				}
#				desc = fp3_struggle.0072.desc.caliph
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_supporter
#				}
#				desc = fp3_struggle.0072.desc.supporter
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_detractor
#				}
#				desc = fp3_struggle.0072.desc.detractor
#			}
#
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = involved
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0072.desc.involved
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = interloper
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0072.desc.interloper
#			}
#			desc = fp3_struggle.0072.desc.uninvolved
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_strength }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	trigger = {
#		NOT = { has_character_flag = struggle_end_notification }
#	}
#
#	immediate = {
#		show_as_tooltip = { struggle:persian_struggle = { end_struggle = yes } }
#		add_character_flag = struggle_end_notification
#
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0072.a
#		trigger = {
#			OR = {
#				fp3_struggle_is_the_caliph = yes
#				has_trait = fp3_struggle_supporter
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = {
#		name = fp3_struggle.0072.a
#		trigger = {
#			NOR = {
#				fp3_struggle_is_the_caliph = yes
#				has_trait = fp3_struggle_supporter
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#	after = {
#		remove_character_flag = struggle_end_notification
#	}
#}
#
#### CONCESSION ENDING ### 0081 = 0090 ###
#
#fp3_struggle.0081 = { #
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0082.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = { has_trait = fp3_struggle_supporter }
#				desc = fp3_struggle.0082.desc.supporter
#			}
#			triggered_desc = {
#				trigger = { has_trait = fp3_struggle_detractor }
#				desc = fp3_struggle.0082.desc.detractor
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = involved
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = {
#					desc = fp3_struggle.0082.desc.intro
#					desc = fp3_struggle.0082.desc.involved
#				}
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = interloper
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = {
#					desc = fp3_struggle.0082.desc.intro
#					desc = fp3_struggle.0082.desc.interloper
#				}
#			}
#			desc = fp3_struggle.0082.desc.uninvolved
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_concession }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	immediate = {
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0082.a
#		show_as_tooltip = {
#			struggle:persian_struggle = { end_struggle = yes }
#			fp3_struggle_ending_concession_effects = yes
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#
#	after = {
#		fp3_end_persian_struggle_effect = {
#			ENDING = yes
#			EVENT = fp3_struggle.0082
#			FLAG = flag:fp3_struggle_concession_ending
#		}
#	}
#}
#
#fp3_struggle.0082 = { # Notification for relevant people
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0082.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = { has_trait = fp3_struggle_supporter }
#				desc = fp3_struggle.0082.desc.supporter
#			}
#			triggered_desc = {
#				trigger = { has_trait = fp3_struggle_detractor }
#				desc = fp3_struggle.0082.desc.detractor
#			}
#			triggered_desc = {
#				trigger = { exists = scope:involved }
#				desc = {
#					desc = fp3_struggle.0082.desc.intro
#					desc = fp3_struggle.0082.desc.involved
#				}
#			}
#			triggered_desc = {
#				trigger = { exists = scope:interloper }
#				desc = {
#					desc = fp3_struggle.0082.desc.intro
#					desc = fp3_struggle.0082.desc.interloper
#				}
#			}
#			desc = fp3_struggle.0082.desc.uninvolved
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_concession }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#	# There could, and should, be a event_window_widget_struggle_info widget here
#
#	immediate = {
#		if = {
#			limit = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = persian_struggle
#				}
#			}
#			save_scope_as = involved
#		}
#		else_if = {
#			limit = {
#				any_character_struggle = {
#					involvement = interloper
#					is_struggle_type = persian_struggle
#				}
#			}
#			save_scope_as = interloper
#		}
#		show_as_tooltip = {
#			struggle:persian_struggle ?= { end_struggle = yes }
#			fp3_struggle_ending_concession_effects = yes
#		}
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0082.b
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#}
#
#### FOUNDATION ENDINGS ### 0091 = 0180 ###
#fp3_struggle.0091 = { # Rekindle Iran
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0091.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_supporter
#				}
#				desc = fp3_struggle.0091.desc.supporter
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_detractor
#				}
#				desc = fp3_struggle.0091.desc.detractor
#			}
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_rekindle }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	immediate = {
#		save_scope_as = struggle_ender
#		# Save Sunni caliph or previous one as scope:struggle_liege
#		fp3_save_sunni_caliph_or_previous_effect = yes
#		title:e_persia = { save_scope_as = persia_loc } # Persia gets renamed under clan govs
#
#		fp3_struggle_rekindle_iran_effects = yes
#
#		play_music_cue = struggleend_cue
#
#		dynasty:1029100 = { save_scope_as = sassanid_dynasty }
#	}
#
#	option = {
#		name = fp3_struggle.0091.a
#		
#		show_as_tooltip = { struggle:persian_struggle = { end_struggle = yes } }
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	after = {
#		fp3_end_persian_struggle_effect = {
#			ENDING = struggle_persia_ending_rekindle_iran_decision
#			EVENT = fp3_struggle.0092
#			FLAG = flag:fp3_struggle_rekindle_iran_ending
#		}
#	}
#}
#
#fp3_struggle.0092 = { # Notification for relevant people
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0091.t
#	desc = {
#		desc = fp3_struggle.0092.intro
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					culture = { has_cultural_pillar = heritage_iranian }
#				}
#				desc = fp3_struggle.0092.desc.iranian
#			}
#			desc = fp3_struggle.0092.desc.non-iranian
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_rekindle }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#	# There could, and should, be a event_window_widget_struggle_info widget here
#
#	immediate = {
#		show_as_tooltip = {
#			struggle:persian_struggle = { end_struggle = yes }
#			fp3_struggle_rekindle_iran_effects = yes
#		}
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0092.a
#		trigger = {
#			culture = { has_cultural_pillar = heritage_iranian }
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = {
#		name = fp3_struggle.0092.a
#		trigger = {
#			NOT = {
#				culture = { has_cultural_pillar = heritage_iranian }
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#}
#
#fp3_struggle.0095 = { # Temper the Caliphate, Shia Ending
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0095.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					faith = {
#						OR = {
#							has_doctrine = muhammad_succession_shia_doctrine
#							has_doctrine = muhammad_succession_zandaqa_doctrine
#						}
#					}
#				}
#				desc = fp3_struggle.0095.desc.shia_and_zandaqa
#			}
#			triggered_desc = {
#				trigger = {
#					faith = {
#						has_doctrine = muhammad_succession_muhakkima_doctrine
#					}
#				}
#				desc = fp3_struggle.0095.desc.muhakkima
#			}
#			desc = fp3_struggle.0095.desc.fallback
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_temper }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	immediate = {
#		root = { save_scope_as = struggle_ender }
#		# Save Sunni caliph or previous one as scope:struggle_liege
#		fp3_save_sunni_caliph_or_previous_effect = yes
#		character:34005 = { save_scope_as = harun_the_rightly_guided }
#
#		fp3_struggle_ending_shia_caliphate_effects = yes
#
#		play_music_cue = struggleend_cue
#
#		character:33911 = { save_scope_as = ali } 
#
#	}
#
#	option = {
#		name = fp3_struggle.0095.a
#		show_as_tooltip = { struggle:persian_struggle = { end_struggle = yes } }
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	after = {
#		fp3_end_persian_struggle_effect = {
#			ENDING = struggle_persia_ending_foundation_decision
#			EVENT = fp3_struggle.0096
#			FLAG = flag:fp3_struggle_shia_caliphate_ending
#		}
#	}
#}
#
#fp3_struggle.0096 = { # Notification for relevant people
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0095.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_supporter
#				}
#				desc = fp3_struggle.0096.desc.supporter
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_detractor
#				}
#				desc = fp3_struggle.0096.desc.detractor
#			}
#
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = involved
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0096.desc.involved
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = interloper
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0096.desc.interloper
#			}
#			desc = fp3_struggle.0096.desc.uninvolved
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_temper }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#	# There could, and should, be a event_window_widget_struggle_info widget here
#
#	immediate = {
#		play_music_cue = struggleend_cue
#		show_as_tooltip = {
#			fp3_struggle_ending_shia_caliphate_effects = yes
#			struggle:persian_struggle = { end_struggle = yes }
#		}
#	}
#
#	option = {
#		name = fp3_struggle.0096.a
#		trigger = {
#			NOR = {
#				has_trait = fp3_struggle_supporter
#				faith = { has_doctrine = muhammad_succession_sunni_doctrine }
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = {
#		name = fp3_struggle.0096.a
#		trigger = {
#			OR = {
#				has_trait = fp3_struggle_supporter
#				faith = { has_doctrine = muhammad_succession_sunni_doctrine }
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#}
#
#fp3_struggle.0100 = { # Temper the Caliphate, Vassalize Caliphate Ending
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0100.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					faith = { 
#						OR = {
#							has_doctrine = muhammad_succession_shia_doctrine 
#							has_doctrine = muhammad_succession_zandaqa_doctrine 
#						}
#					}
#				}
#				desc = fp3_struggle.0100.desc.shia_and_zandaqa
#			}
#			triggered_desc = {
#				trigger = {
#					faith = { has_doctrine = muhammad_succession_muhakkima_doctrine }
#				}
#				desc =  fp3_struggle.0100.desc.muhakkima
#			}
#			desc = fp3_struggle.0100.desc
#		}
#	}
#
#	theme = court
#	override_background = { reference = fp3_fullscreen_temper }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	immediate = {
#		root = { save_scope_as = struggle_ender }
#		title:d_sunni.holder = { save_scope_as = struggle_liege }
#		fp3_struggle_ending_vassalize_caliph_effects = yes
#
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0100.a
#		show_as_tooltip = { struggle:persian_struggle = { end_struggle = yes } }
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	after = {
#		fp3_end_persian_struggle_effect = {
#			ENDING = struggle_persia_ending_foundation_decision
#			EVENT = fp3_struggle.0101
#			FLAG = flag:fp3_struggle_vassalize_caliph_ending
#		}
#	}
#}
#
#fp3_struggle.0101 = { # Notification for relevant people
#	type = character_event
#	window = fullscreen_event
#	title = fp3_struggle.0100.t
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_supporter
#				}
#				desc = fp3_struggle.0101.desc.supporter
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_detractor
#				}
#				desc = fp3_struggle.0101.desc.detractor
#			}
#
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = involved
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0101.desc.involved
#			}
#			triggered_desc = {
#				trigger = {
#					any_character_struggle = {
#						involvement = interloper
#						is_struggle_type = persian_struggle
#					}
#				}
#				desc = fp3_struggle.0101.desc.interloper
#			}
#			desc = fp3_struggle.0101.desc.uninvolved
#		}
#	}
#	theme = court
#	override_background = { reference = fp3_fullscreen_temper }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	immediate = {
#		show_as_tooltip = { struggle:persian_struggle = { end_struggle = yes } }
#
#		play_music_cue = struggleend_cue
#	}
#
#	option = {
#		name = fp3_struggle.0101.a
#		trigger = {
#			NOR = {
#				has_trait = fp3_struggle_supporter
#				faith = { has_doctrine = muhammad_succession_sunni_doctrine }
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = {
#		name = fp3_struggle.0101.a
#		trigger = {
#			OR = {
#				has_trait = fp3_struggle_supporter
#				faith = { has_doctrine = muhammad_succession_sunni_doctrine }
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#}
#
#### SUNDERING THE CALIPHATE ### 0191 = 0200 ###
#fp3_struggle.0191 = { # Sunder the Caliphate
#	type = character_event
#	title = fp3_struggle.0191.t
#	desc = fp3_struggle.0191.desc
#	theme = court
#	left_portrait = {
#		character = scope:sunderer
#		animation = war_over_win
#	}
#	lower_right_portrait = scope:struggle_liege
#
#	immediate = {
#		# Select the caliph and destroy their title
#		fp3_sundered_caliphate_effects = yes
#	}
#
#	option = {
#		name = fp3_struggle.0191.a
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#}
#
#fp3_struggle.0192 = { # Notification for relevant people
#	type = character_event
#	title = fp3_struggle.0192.t
#
#	desc = {
#		first_valid = {
#			triggered_desc = {
#				trigger = {
#					fp3_struggle_is_the_caliph = yes
#				}
#				desc = fp3_struggle.0192.desc.caliph
#			}
#			triggered_desc = {
#				trigger = {
#					OR = {
#						has_trait = fp3_struggle_supporter
#						is_vassal_of = scope:struggle_liege
#					}
#				}
#				desc = fp3_struggle.0192.desc.supporter_or_vassal
#			}
#			triggered_desc = {
#				trigger = {
#					has_trait = fp3_struggle_detractor
#				}
#				desc = fp3_struggle.0192.desc.detractor
#			}
#		}
#	}
#
#	
#	theme = court
#	override_background = { reference = fp3_fullscreen_sunder }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#	left_portrait = {
#		character = scope:sunderer
#		animation = war_over_win
#	}
#	lower_right_portrait = scope:struggle_liege
#
#	option = {
#		name = fp3_struggle.0192.c
#		trigger = {
#			NOR = {
#				fp3_struggle_is_the_caliph = yes
#				has_trait = fp3_struggle_supporter
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = {
#		name = fp3_struggle.0192.b
#		trigger = {
#			OR = {
#				fp3_struggle_is_the_caliph = yes
#				has_trait = fp3_struggle_supporter
#			}
#		}
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_negative"
#	}
#}
#
####################################
## FP3 casus belli events
## By Joe Parkin
####################################
#
## Install loyal puppet - declared puppet ping
#fp3_struggle.8000 = {
#	type = letter_event
#	opening = fp3_struggle.8000.t
#	desc = {
#		desc = fp3_struggle.8000.desc
#	}
#	sender = scope:attacker
#
#	immediate = {
#		send_interface_message = {
#			type = event_struggle_neutral
#			title = install_loyalist_puppet_declared_puppet
#			left_icon = scope:attacker
#			right_icon = scope:defender
#			show_as_tooltip = {
#				scope:attacker = {
#					start_war = {
#						casus_belli = "fp3_install_loyalist_cb"
#						target = scope:defender
#					}
#				}
#			}
#		}
#	}
#
#	# Indeed?
#	option = {
#		name = fp3_struggle.8000.a
#	}
#}
#
## Install loyal puppet - declared defender ping
#fp3_struggle.8001 = {
#	type = letter_event
#	opening = fp3_struggle.8000.t
#	desc = {
#		desc = fp3_struggle.8001.desc
#	}
#	sender = scope:attacker
#
#	immediate = {
#		send_interface_message = {
#			type = event_struggle_bad
#			title = install_loyalist_puppet_declared_defender
#			left_icon = scope:attacker
#			right_icon = scope:loyalist_puppet
#			show_as_tooltip = {
#				scope:attacker = {
#					start_war = {
#						casus_belli = "fp3_install_loyalist_cb"
#						target = scope:defender
#					}
#				}
#			}
#		}
#	}
#
#	# Outrageous!
#	option = {
#		name = fp3_struggle.8001.a
#	}
#}
#
## Install loyal puppet - won puppet ping
#fp3_struggle.8002 = {
#	type = letter_event
#	opening = fp3_struggle.8000.t
#	desc = {
#		desc = fp3_struggle.8002.desc
#	}
#	sender = scope:attacker
#
#	immediate = {
#		send_interface_message = {
#			type = event_struggle_good
#			title = install_loyalist_puppet_won_puppet
#			left_icon = scope:attacker
#			right_icon = scope:defender
#			show_as_tooltip = {
#				every_in_list = {
#					list = title_to_steal
#					save_scope_as = stolen_title
#					root = { get_title = scope:stolen_title }
#				}
#				custom_tooltip = fp3_struggle.8002.alliance_tt
#				if = {
#					limit = { scope:defender.imprisoner ?= root }
#					imprison = {
#						target = scope:defender
#						type = house_arrest
#					}
#				}
#			}
#		}
#	}
#
#	# Ok!
#	option = {
#		name = fp3_struggle.8002.a
#	}
#}
#

####################################
## Integrity Validation Events
## By Hugo Cortell
####################################
#fp3_struggle.9980 = { # Validation of title
#	type = character_event
#	orphan = yes
#	title = {
#		desc = Hugo
#		desc = game_concept_struggle_struggles
#		desc = number_two
#		desc = debug
#	}
#	desc = {
#		desc = historical_commander_trait.0003.d
#		desc = stress_threshold.3201.depressed.effect
#	}
#
#	theme = mental_break
#	left_portrait = title:e_arabia.holder
#
#	immediate = { title:e_arabia.holder = { add_piety = 30000 } } # Hard title validation
#
#	option = {
#		name = {
#			text = {
#				desc = martial_chivalry.2015.a
#				desc = rivalry.1016.a.exposed
#			}
#		}
#	}
#}
#
#fp3_struggle.9981 = { # Destroy e_arabia (used mostly for checking invalidations)
#	hidden = yes
#	orphan = yes
#	immediate = { destroy_title = title:e_arabia }
#}
#
#fp3_struggle.9982 = { # Revision 2 nav event, to make QA's life easier and avoid unecessary crashes
#	type = character_event
#	title = {
#		desc = Hugo
#		desc = CHARACTER_POSS
#		desc = intrigue_broken_modifier
#		desc = game_concept_struggle
#		desc = MENU
#	}
#	desc = {
#		desc = bp1_yearly.9018.c
#		desc = double_line_break
#		desc = childhood.7400_mother_dead
#		desc = double_line_break
#		desc = yearly.7021.b
#	}
#
#	orphan = yes
#	theme = mental_break
#
#	option = { # Dynamically start a struggle
#		trigger = { NOT = { exists = struggle:persian_struggle } }
#		name = FRONTEND_MP_GAME_SETUP_HOST_NEW_GAME
#
#		random_ruler = {
#			limit = {
#				top_liege = this
#				location ?= { geographical_region = world_persian_empire }
#			}
#			primary_title = { save_scope_as = debug_caliph }
#		}
#		start_struggle = {
#			struggle_type = persian_struggle
#			start_phase = struggle_persia_phase_stabilisation
#		}
#
#		send_interface_message = { # Informs you of who the "debug caliph" is
#			type = event_martial_bad
#			title = trait_beauty_bad_1_desc
#			left_icon = scope:debug_caliph
#			right_icon = scope:debug_caliph.holder
#		}
#	}
#	option = { # Go forward in the struggle flow
#		name = dynn_Daflos_motto
#		trigger = { exists = struggle:persian_struggle }
#
#		if = {
#			limit = { struggle:persian_struggle = { is_struggle_phase = struggle_persia_phase_unrest } }
#			struggle:persian_struggle = { change_struggle_phase = { struggle_phase = struggle_persia_ending_phase_concession } }
#		}
#		else_if = {
#			limit = { struggle:persian_struggle = { is_struggle_phase = struggle_persia_phase_stabilisation } }
#			struggle:persian_struggle = { change_struggle_phase = { struggle_phase = struggle_persia_phase_unrest with_transition = yes } }
#		}
#	}
#	option = { # Go backwards in the struggle flow
#		name = default_retreat
#		trigger = { exists = struggle:persian_struggle }
#
#		if = {
#			limit = { struggle:persian_struggle = { is_struggle_phase = struggle_persia_phase_unrest } }
#			struggle:persian_struggle = { change_struggle_phase = { struggle_phase = struggle_persia_phase_stabilisation } }
#		}
#	}
#	option = { name = EXIT_TO_DESKTOP } # Exit event without doing anything
#}
#
#fp3_struggle.9983 = { # Create Persian Empire Test
#	hidden = yes
#	orphan = yes
#	immediate = {
#		create_title_and_vassal_change = {
#			type = created
#			save_scope_as = change
#		}
#		title:e_persia = {
#			change_title_holder = {
#				holder = root
#				change = scope:change
#			}
#		}
#		resolve_title_and_vassal_change = scope:change
#	}
#}
#
#fp3_struggle.9984 = { # Ending simulator - Allows you to end the struggle in a clean way, works better/is safer than commands
#	type = character_event
#	window = fullscreen_event
#	title = ENDING_DECISION_AVAILABLE
#	desc = ENDING_DECISION_BUTTON_LABEL_MULTIPLE
#	orphan = yes
#	theme = realm
#	override_background = { reference = fp3_fullscreen_strength }
#	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }
#
#	widgets = {
#		widget = {
#			gui = "event_window_widget_struggle_info"
#			container = "dynamic_content_widget"
#			controller = struggle_info
#			setup_scope = { struggle:persian_struggle = { save_scope_as = struggle } }
#		}
#	}
#
#	immediate = {
#		# Save Sunni caliph or previous one as scope:struggle_liege
#		fp3_save_sunni_caliph_or_previous_effect = yes
#	}
#
#	option = { # Concession
#		name = struggle_persia_ending_phase_concession
#		save_scope_value_as = {
#			name = ending_to_simulate
#			value = flag:concession
#		}
#		trigger_event = fp3_struggle.9985
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#
#	option = { # Assertion (Strengthen)
#		name = struggle_persia_ending_assertion
#		save_scope_value_as = {
#			name = ending_to_simulate
#			value = flag:strength
#		}
#		trigger_event = fp3_struggle.9985
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = { # Sunni Caliphate
#		name = struggle_persia_ending_foundation_decision_option_shia
#		save_scope_value_as = {
#			name = ending_to_simulate
#			value = flag:sunni
#		}
#		trigger_event = fp3_struggle.9985
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = { # Consume/Vassalize
#		name = struggle_persia_ending_foundation_decision_option_vassalize
#		save_scope_value_as = {
#			name = ending_to_simulate
#			value = flag:vassal
#		}
#		trigger_event = fp3_struggle.9985
#		clicksound = "event:/DLC/FP3/SFX/UI/Notifications/Toasts/struggle_end_positive"
#	}
#
#	option = { name = EXIT_TO_DESKTOP }
#}
#
#fp3_struggle.9985 = { # Simulator Follow-up (keeps it hidden and clean to prevent QA panic)
#	hidden = yes
#	immediate = {
#		struggle:persian_struggle = {
#			# Ensure we are in the correct position to fire the ending
#			if = { 
#				limit = {
#					scope:ending_to_simulate = flag:strength
#					is_struggle_phase = struggle_persia_phase_unrest
#				}
#				change_struggle_phase = { struggle_phase = struggle_persia_phase_stabilisation }
#			}
#			else_if = {
#				limit = {
#					OR = {
#						scope:ending_to_simulate = flag:sunni
#						scope:ending_to_simulate = flag:vassal
#					}
#					is_struggle_phase = struggle_persia_phase_stabilisation
#				}
#				change_struggle_phase = { struggle_phase = struggle_persia_phase_unrest }
#			}
#		}
#		# Cases for firing the correct phase
#		switch = {
#			trigger = scope:ending_to_simulate
#			flag:concession	= { trigger_event = fp3_struggle.0081 }
#			flag:sunni = { trigger_event = fp3_struggle.0095 }
#			flag:vassal = { trigger_event = fp3_struggle.0100 }
#			flag:strength = { trigger_event = fp3_struggle.0071 }
#			
#			fallback = {
#				assert_if = {
#					limit = { always = yes }
#					text = "FP3 ENDING SIMULATION DEBUG TOOL ERROR: NO VALID scope:ending_to_simulate STATE!"
#				}
#			}
#		}
#	}
#}
#