namespace = fp3_yearly

########EVENT INDEX############
#fp3_yearly.8037 - A Cure for Acedia (the Melancholia Chain)
	#fp3_yearly.8038 - Black Bile 
	#fp3_yearly.8039 - Herbs & Humors
	#fp3_yearly.8040 - Psychic Potency
	#fp3_yearly.8041 - The Solace of Silence 
	#fp3_yearly.8042 - The Undying Spirit 
	#fp3_yearly.8043 - Remedies' End 
	#fp3_yearly.8044 - The Light of the World
#fp3_yearly.8045 - The Mysterious Bundle (Chess-Playing Monkey Chain)
	#fp3_yearly.8046 - Monkey Medicine
	#fp3_yearly.8047 - Feeling Better?
	#fp3_yearly.8048 - Hidden event, triggering toast about monkey's death
#fp3_yearly.8050 - The Fate of the Dead
#fp3_yearly.8051 - The Purest Fire
 	#fp3_yearly.8052 - Chasing the Clouds
 	#fp3_yearly.8053 - The Fire of Victory
	

##################################
# A Cure for Acedia - the Melancholica chain
# By Ola Jentzsch
###################################

fp3_yearly.8037 = { #A Cure for Acedia
	type = character_event
	title = fp3_yearly.8037.t
	desc = fp3_yearly.8037.desc
	theme = mental_health
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:court_physician
		animation = personality_bold
	}
	lower_left_portrait = {
		character = scope:persian_polymath
	}

	override_background = { reference = corridor_night }

	trigger = {

		#standard sanity checks
		has_fp3_dlc_trigger = yes
		is_landed_or_landless_administrative = yes
		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no
		root.capital_province = { geographical_region = world_persian_empire }

		OR = {
			has_trait = depressed_1 #non-genetic melancholia
			has_trait = depressed_genetic #or the genetic kind, but they won't be able to cure this one...
		}

		employs_court_position = court_physician_court_position

		any_court_position_holder = {
   			type = court_physician_court_position
   			is_available_healthy_ai_adult = yes 
   			NOT = { has_trait = arrogant }
   			learning < excellent_skill_level #he can't be too smart for this story to work 
   		}
 	}

 	cooldown = { years = 50 }

 	weight_multiplier = { #more likely to trigger if historical scholars can be used
		base = 0.4
	 	modifier = {
		 	OR = {
			 	AND = { #for Rhazes
					current_year >= 895
				 	current_year < 935
			 	}
			 	AND = { #for Al-Akhwayni 
			 		current_year >= 936
				 	current_year < 983
			 	}
			 	AND = { #for Avicenna 
				 	current_year >= 1000
				 	current_year < 1040
			 	}
		 	}
		 	add = 1.6
	 	}
 	}

 	immediate = {

 		save_court_physician_as_effect = { SCOPE_NAME = court_physician } #so we can use him in the event

 		if = { #This looks to see if one of two historical alchemists will be used in the event 
		 	limit = { #their rough period of activity
		 		is_ai = no
			 	AND = {
				 	current_year >= 895
				 	current_year < 935
			 	}
			 	NOT = { exists = global_var:rhazes_created } #makes sure that he wasn't already spawned by any event elsewhere
		 	}
		 	create_character = { 
				location = root.capital_province
				template = fp3_rhazes_template
				save_scope_as = persian_polymath 	#this saves him as a scope so we can get nice effects to bounce off him! 
			}
			set_global_variable = rhazes_created 
		}
		else_if = { #This looks to see if one of two historical alchemists will be used in the event 
		 	limit = { #their rough period of activity
		 		is_ai = no
			 	AND = {
				 	current_year >= 936
				 	current_year < 983
			 	}
			 	NOT = { exists = global_var:al_akhwayni_created } #makes sure that he wasn't already spawned by any event elsewhere
		 	}
		 	create_character = { 
				location = root.capital_province
				template = fp3_al_akhwayni_template
				save_scope_as = persian_polymath 	#this saves him as a scope so we can get nice effects to bounce off him! 
			}
			set_global_variable = al_akhwayni_created 
		}
		else_if = {
		 	limit = { #their rough period of activity
			 	is_ai = no
			 	AND = {
				 	current_year >= 1000
				 	current_year < 1040
			 	}
			 	NOT = { exists = global_var:avicenna_created } #makes sure that he wasn't already spawned by any event elsewhere
		 	}
		 	create_character = { 
				location = root.capital_province
				template = fp3_avicenna_template
				save_scope_as = persian_polymath 	#this saves him as a scope so we can get nice effects to bounce off him! 
			}
			set_global_variable = avicenna_created 
		}
		else = {
			create_character = {
				age = { 32 50 }
			 	location = root.capital_province
			 	template = scholar_character
			 	trait = education_learning_3
			 	trait = lifestyle_herbalist 
			 	trait = lifestyle_physician
			 	random_traits_list = {
				 	count = 3
				 	diligent = {}
				 	patient = {}
				 	cynical = {}
				 	humble = {}
				 	greedy = {}
			 	}
			 	random_traits_list = { #for flavor
				 	count = 1
				 	lunatic_1 = {}
				 	deviant = {}
				 	lifestyle_mystic = {}
				 	hashishiyah = {}
				 	witch = {}
			 	}
			 	culture = culture:persian
			 	faith = root.faith
			 	save_scope_as = persian_polymath

				after_creation = {
					add_trait_xp = {
						trait = lifestyle_physician
						value = 100
					}
					add_random_tiered_trait_xp_effect = {
						TRAIT = lifestyle_mystic
						LEVEL_1 = yes
						LEVEL_3 = no
					}
				}
			}
		}
 	}

 	option = {
 		name = fp3_yearly.8037.a

 		remove_short_term_gold = medium_gold_value

 		trigger_event = { 
 			id = fp3_yearly.8038 
 			days = { 5 10 }
 		}

 		stress_impact = { 
   			content = minor_stress_impact_gain 
   		}

 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = 0.5
            	ai_sociability = 0.5
        	}
   		}	
 	}

 	option = {
 		name = fp3_yearly.8037.b

 		stress_impact = { 
   			base = miniscule_stress_impact_loss
   			content = miniscule_stress_impact_loss 
   			shy = miniscule_stress_impact_loss 
   		}

   		ai_chance = { #most depressed AI would rather not deal with the situation
        	base = 150
        	ai_value_modifier = {
            	ai_energy = -0.9
            	ai_sociability = -0.5
        	}
   		}		
 	}
}

fp3_yearly.8038 = { #Black Bile
	type = character_event
	title = fp3_yearly.8038.t
	desc = fp3_yearly.8038.desc
	theme = mental_health
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:persian_polymath
		animation = personality_rational
	}

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		OR = {
			has_trait = depressed_1 #non-genetic melancholia
			has_trait = depressed_genetic #or the genetic kind, but they won't be able to cure this one...
		}

		exists = scope:persian_polymath
		scope:persian_polymath = { is_alive = yes }
	}

	immediate = {

		add_courtier = scope:persian_polymath

		hidden_effect = {
   			scope:persian_polymath = {
   				set_knight_status = forbid #this is to prevent him being auto-turned into a knight during his stay. The player can still make him a knight manually if they insist on it. 
   			}
   		}
	}

	option = {
 		name = fp3_yearly.8038.a

 		add_character_modifier = {
 			modifier = fp3_lackluster_diet_modifier 
 			years = 10
 		}

 		if = { 
 			limit = {
 				has_trait = comfort_eater
 			}
 			custom_tooltip = lackluster_diet.tt
 		}

 		trigger_event = { 
 			id = fp3_yearly.8039 
 			days = { 200 400 }
 		}

 		stress_impact = { 
   			temperate = minor_stress_impact_loss 
   			gluttonous = major_stress_impact_gain 
   			comfort_eater = massive_stress_impact_gain
   			gregarious = medium_stress_impact_gain
   		}
 		

 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = 0.5
            	ai_sociability = 0.5
        	}
   		}	
 	}

 	option = {
 		name = fp3_yearly.8038.b

 		if = {
			limit = {
				OR = {
					exists = global_var:avicenna_created
					exists = global_var:rhazes_created
					exists = global_var:al_akhwayni_created 
				}
			}
			scope:persian_polymath = { #Let's keep the historical characters around, if they were created
				move_to_pool = yes 
			}
		}
		else = {
			scope:persian_polymath = { #otherwise, let's just have him disappear 
				move_to_pool = yes
				silent_disappearance_effect = yes
			}
		}

		stress_impact = { 
   			lazy = minor_stress_impact_loss 
   			ambitious = minor_stress_impact_gain
   			diligent = minor_stress_impact_gain
   			stubborn = minor_stress_impact_loss
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = 0.5
            	ai_sociability = 0.5
        	}
   		}	
 	}
}


fp3_yearly.8039 = { #Herbs & Humors
	type = character_event
	title = fp3_yearly.8039.t
	desc = fp3_yearly.8039.desc
	theme = mental_health
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:persian_polymath
		animation = personality_cynical
	}

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		OR = {
			has_trait = depressed_1 #non-genetic melancholia
			has_trait = depressed_genetic #or the genetic kind, but they won't be able to cure this one...
		}

		has_character_modifier = fp3_lackluster_diet_modifier

		exists = scope:persian_polymath

		scope:persian_polymath = {
			is_courtier_of = root
		}
	}

	option = {
 		name = fp3_yearly.8039.a

 		remove_character_modifier = fp3_lackluster_diet_modifier 
 		
 		add_character_modifier = {
 			modifier = fp3_herbal_remedies_modifier
 		}

 		trigger_event = { 
 			id = fp3_yearly.8040
 			days = { 200 400 }
 		}

 		stress_impact = { 
   			temperate = minor_stress_impact_gain
   			content = minor_stress_impact_gain
   		}
 		

 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_boldness = 0.5
            	ai_rationality = 1
        	}
   		}	
 	}

 	option = {
 		name = fp3_yearly.8039.b

 		trigger_event = { 
 			id = fp3_yearly.8040
 			days = { 200 400 }
 		}

 		stress_impact = { 
   			content = minor_stress_impact_loss 
   			temperate = minor_stress_impact_loss 
   			gluttonous = major_stress_impact_gain
   			comfort_eater = massive_stress_impact_gain
   			gregarious = medium_stress_impact_gain
   		}
 		

 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = 0.5
            	ai_sociability = -0.1
        	}
   		}	
 	}

 	option = {
 		name = fp3_yearly.8039.c

 		if = {
			limit = {
				OR = {
					exists = global_var:avicenna_created
					exists = global_var:rhazes_created
					exists = global_var:al_akhwayni_created 
				}
			}
			scope:persian_polymath = { #Let's keep the historical characters around, if they were created
				move_to_pool = yes 
			}
		}
		else = {
			scope:persian_polymath = { #otherwise, let's just have him disappear 
				move_to_pool = yes
				silent_disappearance_effect = yes
			}
		}

		stress_impact = { 
   			impatient = minor_stress_impact_loss
   			wrathful = minor_stress_impact_loss
   			ambitious = minor_stress_impact_gain
   			patient = minor_stress_impact_gain
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = -0.5
            	ai_vengefulness = 0.5
        	}
   		}	
 	}
}

fp3_yearly.8040 = { #Psychic Potency 
	type = character_event
	title = fp3_yearly.8040.t
	desc = fp3_yearly.8040.desc
	theme = mental_health
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:persian_polymath
		animation = personality_compassionate
	}

	lower_left_portrait = {
		character = scope:court_chaplain
	}

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		OR = {
			has_trait = depressed_1 #non-genetic melancholia
			has_trait = depressed_genetic #or the genetic kind, but they won't be able to cure this one...
		}

		exists = scope:persian_polymath

		scope:persian_polymath = {
			is_courtier_of = root
		}
	}

	immediate = {

		if = {	
			limit = { 
				exists = cp:councillor_court_chaplain 
				cp:councillor_court_chaplain = { 
					AND = {
						is_available_healthy_ai_adult = yes 
						this != scope:persian_polymath
					}
				}
			}
			cp:councillor_court_chaplain = { save_scope_as = court_chaplain }
		}
	}

	option = {
 		name = fp3_yearly.8040.a

 		trigger = {
 			AND = {
 				has_religion = religion:islam_religion 
 				NOT = {	has_character_modifier = fp3_sufi_initiate_modifier }
 			}
 		}

 		trigger_event = { 
 			id = fp3_yearly.8041
 			days = { 5 15 }
 		}

 		stress_impact = { 
   			#none for this option
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_zeal = 0.9
            	ai_boldness = 0.9
        	}
   		}	
 	}


 	option = {
 		name = fp3_yearly.8040.b

 		trigger = { exists = scope:court_chaplain }

 		trigger_event = fp3_yearly.8042

 		stress_impact = { 
   			#none for this option
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_zeal = 0.5
            	ai_sociability = 0.8
            	ai_compassion = 0.5
            	ai_vengefulness = -0.5
        	}
   		}	
 	}

 	option = {
 		name = fp3_yearly.8040.c
 		flavor = fp3_refusing_faith_treatment_flavor

 		trigger_event = { 
 			id = fp3_yearly.8043
 			days = { 150 250 }
 		}

 		stress_impact = { 
   			zealous = medium_stress_impact_loss
   			cynical = medium_stress_impact_gain 
   			humble = medium_stress_impact_gain
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_zeal = 1
            	ai_vengefulness = 0.5
        	}
   		}	
 	}

 	option = {
 		name = fp3_yearly.8040.d

 		if = {
			limit = {
				OR = {
					exists = global_var:avicenna_created
					exists = global_var:rhazes_created
					exists = global_var:al_akhwayni_created 
				}
			}
			scope:persian_polymath = { #Let's keep the historical characters around, if they were created
				move_to_pool = yes 
			}
		}
		else = {
			scope:persian_polymath = { #otherwise, let's just have him disappear 
				move_to_pool = yes
				silent_disappearance_effect = yes
			}
		}

		stress_impact = { 
   			cynical = minor_stress_impact_loss
   			impatient = minor_stress_impact_loss
   			forgiving = medium_stress_impact_gain
   			patient = medium_stress_impact_gain
   			zealous = medium_stress_impact_gain 
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = -0.5
            	ai_vengefulness = 1
        	}
   		}	
 	}
}


###############################################################
# The Solace of Silence - by Ola Jentzsch
###############################################################

fp3_yearly.8041 = {
	type = character_event  
	title = fp3_yearly.8041.t
	desc = fp3_yearly.8041.desc	
	theme = learning_theology_focus

	left_portrait = {
		character = scope:sufi_mystic
		animation = personality_zealous
	}

	right_portrait = {
		character = root
		animation = worry 
	}

	override_background = {
		reference = relaxing_room
	}

 	immediate = {

 		if = {
			limit = { 
				any_relation = { 
					type = friend
					NOR = { 
						this = scope:persian_polymath 
						this = scope:court_chaplain 
					}
					fp3_sufism_enthusiast_trigger = yes 
				}
			}
			random_relation = {
				type = friend
				limit = { 
					AND = {
						fp3_sufism_enthusiast_trigger = yes
						NOR = { 
							this = scope:persian_polymath 
							this = scope:court_chaplain 
						}
					}
				}
				save_scope_as = sufi_mystic
			}
		}
		else_if = {
			limit = { 
				any_relation = { 
					type = lover
					NOR = { 
						this = scope:persian_polymath 
						this = scope:court_chaplain 
					}
					fp3_sufism_enthusiast_trigger = yes 
				}
			}
			random_relation = {
				type = lover
				limit = { 
					AND = {
						fp3_sufism_enthusiast_trigger = yes
						NOR = { 
							this = scope:persian_polymath 
							this = scope:court_chaplain 
						}
					}
				}
				save_scope_as = sufi_mystic
			}
		}
		else_if = {
			limit = { 
				any_courtier_or_guest = { 
					fp3_sufism_enthusiast_trigger = yes 
					NOR = { 
						this = scope:persian_polymath 
						this = scope:court_chaplain 
					}
				}
			}
			random_courtier_or_guest = {
				limit = { 
					AND = {
						fp3_sufism_enthusiast_trigger = yes
						NOR = { 
							this = scope:persian_polymath 
							this = scope:court_chaplain 
						}
					}
				}
				save_scope_as = sufi_mystic
			}
		}
		else = { 
			create_character = { 
				location = root.capital_province
				template = fp3_sufi_mystic
				gender_female_chance = root_faith_dominant_gender_female_chance
				culture = culture:persian
				save_scope_as = sufi_mystic	

				after_creation = {  
					hidden_effect = {
						root = {
							add_courtier = scope:sufi_mystic
						}
					}	
 				}
			}
		}

		hidden_effect = {

			scope:sufi_mystic = {
				add_character_modifier = {
 					modifier = fp3_sufi_initiate_modifier #Unlocks the "Meditate in Seclusion" decision if you are a ruler
 				}
 			}
 		}
 	}

 	option = {
 		name = fp3_yearly.8041.a

 		duel = {
			skill = learning
			value = medium_skill_rating

			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
				}
				root = {
					send_interface_toast = {
						title = learning_muraqaba_toast.success
						left_icon = root
				
						custom_tooltip = fp3_unlock_meditation.tt
						add_character_modifier = {
 							modifier = fp3_sufi_initiate_modifier #Unlocks the "Meditate in Seclusion" decision if you are a ruler
 						}
					}
				}	
			}
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
				}
				root = {
					send_interface_toast = {
						title = learning_muraqaba_toast.failure
						left_icon = root
						add_learning_lifestyle_xp = minor_lifestyle_experience
					}
				}
			}
		}

		scope:sufi_mystic = {
			add_opinion = {
				target = root
				modifier = trusted_friend_opinion 
			}	
		}

		trigger_event = { 
 			id = fp3_yearly.8043
 			days = { 150 250 }
 		}

 		stress_impact = { #while the stress mods here are low, note that they stack with the base modifier
   			base = medium_stress_impact_gain
   			zealous = minor_stress_impact_loss
   			patient = minor_stress_impact_loss
   			arrogant = medium_stress_impact_gain
   			paranoid = minor_stress_impact_gain
   			callous = medium_stress_impact_gain	
   			lazy = minor_stress_impact_gain
   			content = minor_stress_impact_gain
   			cynical = minor_stress_impact_gain
		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_compassion = 0.5
            	ai_boldness = 0.5
            	ai_energy = 0.5
            	ai_zeal = 1
        	}
   		}
 	}

 	option = {
 		name = fp3_yearly.8041.b

 		scope:sufi_mystic = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion 
				opinion = -15 
			}	
		}

		trigger_event = { 
 			id = fp3_yearly.8043
 			days = { 150 250 }
 		}

 		stress_impact = {
   			base = minor_stress_impact_loss 
   			zealous = medium_stress_impact_gain
   			ambitious = medium_stress_impact_gain	
		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = -0.5
            	ai_boldness = -0.5
            	ai_zeal = -0.5
        	}
   		}
 	}
}

##### The Undying Spirit #####

fp3_yearly.8042 = { #The Undying Spirit
	type = character_event
	title = fp3_yearly.8042.t
	desc = fp3_yearly.8042.desc
	theme = faith
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:court_chaplain
		animation = chancellor
	}

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		OR = {
			has_trait = depressed_1 #non-genetic melancholia
			has_trait = depressed_genetic #or the genetic kind, but they won't be able to cure this one...
		}

		exists = scope:court_chaplain
	}

	option = {
 		name = fp3_yearly.8042.a

 		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = trusted_me_opinion 
				opinion = 15
			}	
		}

		add_character_modifier = {
			modifier = focused_reading_modifier
			years = 10 
		}

		trigger_event = { 
 			id = fp3_yearly.8043
 			days = { 150 250 }
 		}

 		stress_impact = {
   			base = minor_stress_impact_gain
   			arrogant = medium_stress_impact_gain
   			impatient = medium_stress_impact_gain
   			dull = medium_stress_impact_gain	
		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = 0.5
            	ai_rationality = 0.5
            	ai_zeal = 0.5
        	}
   		}
 	}

 	option = {
 		name = fp3_yearly.8042.b

 		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = trusted_me_opinion 
				opinion = 15
			}	
		}

		add_character_modifier = {
			modifier = fp3_worshipping_in_solitude_modifier
			years = 10 
		}

		trigger_event = { 
 			id = fp3_yearly.8043
 			days = { 150 250 }
 		}

 		stress_impact = {
   			gregarious = medium_stress_impact_gain
   			cynical = medium_stress_impact_gain
   			impatient = medium_stress_impact_gain	
		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = 0.5
            	ai_rationality = 0.5
            	ai_zeal = 0.5
        	}
   		}
 	}

 	option = {
 		name = fp3_yearly.8042.c

 		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion 
				opinion = -15
			}	
		}

		trigger_event = { 
 			id = fp3_yearly.8043
 			days = { 150 250 }
 		}

 		stress_impact = {
   			base = minor_stress_impact_loss
   			humble = minor_stress_impact_gain
   			patient = medium_stress_impact_gain
   			trusting = medium_stress_impact_gain	
   			zealous = minor_stress_impact_gain
		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_energy = -0.5
            	ai_vengefulness = 0.5
        	}
   		}
 	}
}

##### Remedies' End #####

fp3_yearly.8043 = { 
	type = character_event
	title = fp3_yearly.8043.t
	desc = fp3_yearly.8043.desc
	theme = mental_health
	left_portrait = {
		character = root
		animation = sadness 
	}
	right_portrait = {
		character = scope:persian_polymath
		animation = personality_coward
	}

	override_background = { reference = study }

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		OR = {
			has_trait = depressed_1 #non-genetic melancholia
			has_trait = depressed_genetic #or the genetic kind, but they won't be able to cure this one...
		}

		exists = scope:persian_polymath

		scope:persian_polymath = {
			is_courtier_of = root
		}
	}

	option = {
		name = fp3_yearly.8043.a
		flavor = fp3_polymath_stays_flavor

		remove_short_term_gold = medium_gold_value 

		hidden_effect = {
			if = {
				limit = { has_trait = depressed_1 }
				random = {
					chance = 50
					trigger_event = { 
 						id = fp3_yearly.8044
 						days = { 300 500 }
 					}
				}
			}
		}

		stress_impact = { 
   			greedy = minor_stress_impact_gain
   			arrogant = minor_stress_impact_gain
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_compassion = 0.5
            	ai_sociability = 1
            	ai_boldness = -0.7
        	}
   		}	
	}

	option = {
		name = fp3_yearly.8043.b

		hidden_effect = {
			if = {
				limit = { has_trait = depressed_1 }
				random = {
					chance = 50
					trigger_event = { 
 						id = fp3_yearly.8044
 						days = { 300 500 }
 					}
				}
			}
		}

		scope:persian_polymath = { #at this juncture, we want to keep the polymath around, and not disappeared, so the next event can trigger
			move_to_pool = yes
		}

		stress_impact = { 
   			vengeful = minor_stress_impact_loss
   			generous = minor_stress_impact_gain
   			patient = minor_stress_impact_gain 
   		}


 		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
            	ai_greed = 0.5
            	ai_vengefulness = 1
        	}
   		}	
	}
}


##### The Light of the World #####

fp3_yearly.8044 = { 
	type = character_event
	title = fp3_yearly.8044.t
	desc = fp3_yearly.8044.desc
	theme = mental_health
	left_portrait = {
		character = root
		animation = happiness
	}

	override_background = { reference = wilderness }

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		has_trait = depressed_1 #non-genetic melancholia
		
		exists = scope:persian_polymath

	}

	immediate = {

		remove_trait = depressed_1 
	}

	option = {
		name = fp3_yearly.8044.a 

		stress_impact = { 
   			base = medium_stress_impact_loss
   		}
	}
}

##################################
# The Mysterious Bundle 
# By Ola Jentzsch
###################################

fp3_yearly.8045 = { #The Mysterious Bundle (sick monkey chain)
	type = character_event
	title = fp3_yearly.8045.t
	desc = fp3_yearly.8045.desc
	theme = pet
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:buzina_enthusiast
		animation = newborn
	}
	lower_center_portrait = scope:court_physician

	override_background = { reference = fp3_courtyard_night }

	trigger = {
		has_fp3_dlc_trigger = yes
		is_landed = yes
		root.capital_province = { geographical_region = world_persian_empire }
		is_available = yes
		# Following checks that they are of the right age to play board games 
		can_start_board_game_eligibility_checks_trigger = yes 
		
		employs_tax_collector = yes 
		any_tax_collector = {
			is_available_healthy_ai_adult = yes
			opinion = {
				target = root
				value >= 0
			} 
			save_temporary_scope_as = tax_collector_temp
		}
		employs_court_position = court_physician_court_position
		any_court_position_holder = {
			type = court_physician_court_position
			is_available_healthy_ai_adult = yes 
			this != scope:tax_collector_temp
		}

		NOR = {
			has_character_flag = had_event_fp3_yearly_8045
			has_character_modifier = fp3_chess_playing_monkey_modifier
			has_character_modifier = fp3_sickly_monkey_modifier 
			culture = { has_cultural_parameter = may_challenge_to_board_games }
		}	
	}

	immediate = {
		add_character_flag = had_event_fp3_yearly_8045
		random_tax_collector = {
			limit = {
				is_available_healthy_ai_adult = yes
				opinion = {
					target = root
					value >= 0
				} 
			}
			save_scope_as = buzina_enthusiast
		}
		save_court_physician_as_effect = { SCOPE_NAME = court_physician }
	}

	option = { #My court physician can nurse her 
		name = fp3_yearly.8045.a 
		flavor = sick_monkey_flavor_desc

		scope:buzina_enthusiast = {
			add_opinion = {
				target = root
				modifier = grateful_opinion 
				opinion = 15
			}	
		}

		custom_tooltip = playing_with_monkey.tt

		add_character_modifier = {
			modifier = fp3_sickly_monkey_modifier 
			years = 10
		}

		trigger_event = { 
 			id = fp3_yearly.8046
 			days = { 1 2 }
 		}

		stress_impact = { 
			compassionate = minor_stress_impact_loss
			generous = minor_stress_impact_loss
			arrogant = minor_stress_impact_gain 
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_sociability = 0.5
				ai_vengefulness = -0.3
			}
			modifier = {
				factor = 0
				has_trait = arrogant
			}
		}	
	}

	option = { # You got yourself into this mess, you can handle it
		name = fp3_yearly.8045.b 

		add_prestige = minor_prestige_gain

		scope:buzina_enthusiast = {
			add_opinion = {
				target = root
				modifier = was_scolded_opinion 
				opinion = -15
			}
			add_character_flag = {
				flag = fp3_inspired_tax_collector
				years = 10
			}
			custom_tooltip = fp3_inspired_tax_collector
		}

		stress_impact = { 
			compassionate = minor_stress_impact_gain
			arrogant = medium_stress_impact_loss
		}


		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_sociability = 0.2
				ai_boldness = 0.3
				ai_energy = 0.7
			}
			modifier = {
				has_trait = compassionate
				factor = 0 
			}
		}	
	}

	option = { # Opt-out
		name = fp3_yearly.8045.c

		stress_impact = { 
			compassionate = minor_stress_impact_gain 
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_energy = -0.5
				ai_boldness = -0.9
			}
		}	
	}
}


fp3_yearly.8046 = { #Buzina
	type = character_event
	title = fp3_yearly.8046.t
	desc = fp3_yearly.8046.desc
	theme = medicine
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:court_physician
		animation = newborn
	}

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no

		has_character_modifier = fp3_sickly_monkey_modifier 
		
		exists = scope:court_physician	
	}

	option = {
		name = fp3_yearly.8046.a
		flavor = fp3_wait_and_see.tt
		remove_short_term_gold = minor_gold_value
		custom_tooltip = monkey_recover_better_chances_tt
		
		hidden_effect = {
			random_list = {
				80 = {
					trigger_event = { 
 						id = fp3_yearly.8047
 						days = { 30 100 }
 					}
				}
				20 = {
					trigger_event = { 
 						id = fp3_yearly.8048
 						days = { 100 200 }
 					}
				}
			}
		}

		stress_impact = { 
			compassionate = minor_stress_impact_loss
			generous = minor_stress_impact_loss
			greedy = medium_stress_impact_gain 
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 1
				ai_greed = -0.5
			}
		}	
	}

	option = {
		name = fp3_yearly.8046.b
		flavor = fp3_wait_and_see.tt
		hidden_effect = {
			random_list = {
				50 = {
					trigger_event = { 
 						id = fp3_yearly.8047
 						days = { 30 100 }
 					}
				}
				50 = {
					trigger_event = { 
 						id = fp3_yearly.8048
 						days = { 100 200 }
 					}
				}
			}
		}

		stress_impact = { 
			greedy = minor_stress_impact_loss
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
		}	
	}
}

fp3_yearly.8047 = {
	type = character_event
	title = fp3_yearly.8047.t
	desc = fp3_yearly.8047.desc
	theme = pet
	
	left_portrait = {
		character = root
		animation = chess_cocky
	}
	right_portrait = {
		character = scope:court_physician
		animation = newborn
	}

	trigger = { has_character_modifier = fp3_sickly_monkey_modifier }	

	immediate = {
		remove_character_modifier = fp3_sickly_monkey_modifier 
	}

	option = {
		name = fp3_yearly.8047.a
		add_character_modifier = {
			modifier = fp3_chess_playing_monkey_modifier  
			years = 15
		}
		custom_tooltip = playing_chess_with_monkey.tt
	}
}

fp3_yearly.8048 = {
	hidden = yes
	
	trigger = { has_character_modifier = fp3_sickly_monkey_modifier }

	immediate = {
		root = {
			send_interface_toast = {
				title = monkey_died_from_sickness_toast
				left_icon = root 
				remove_character_modifier = fp3_sickly_monkey_modifier
			}
		}

	}		
}

##################################
# The Fate of the Dead
# By Ola Jentzsch
###################################

fp3_yearly.8050 = { #The Fate of the Dead 
	type = character_event
	title = fp3_yearly.8050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { 
					has_religion = religion:zoroastrianism_religion
				}
				desc = fp3_yearly.8050_zoroastrian.desc
			}
			desc = fp3_yearly.8050_unzoroastrian.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = { 
					current_year < 950 
				}
				desc = fp3_yearly.8050_early_period.desc
			}
			desc = fp3_yearly.8050_late_period.desc
		}
	}

	theme = skull 
	override_background = { reference = temple }
	left_portrait = {
		character = root
		animation = thinking 
	}
	right_portrait = {
		character = scope:dakhma_enthusiast
		animation = personality_bold
	}
	lower_left_portrait = {
		character = scope:architect 
	}

	cooldown = { years = 5 }

	weight_multiplier = { #more likely if root is zoroastrian
		base = 0.4
		modifier = { 
			has_religion = religion:zoroastrianism_religion 
			add = 0.6
		}
	}

	trigger = {

		#standard sanity checks
		has_fp3_dlc_trigger = yes
		is_ruler = yes
		is_available_healthy_adult = yes
		root.capital_province = { geographical_region = world_persian_empire }

		any_held_county = {
			faith = { religion_tag = zoroastrianism_religion }
			county_control <= 75 
			any_county_province = {
				has_holding_type = castle_holding
				has_special_building_slot = no
				has_special_building = no
				NOR = {
					has_building = tower_of_silence_01
					has_building = event_tower_of_silence_01
				}
			}
		}

		exists = cp:councillor_court_chaplain 
		cp:councillor_court_chaplain = { is_available_healthy_ai_adult = yes }
	}

	immediate = {

		cp:councillor_court_chaplain = { save_scope_as = dakhma_enthusiast }

		if = {
			limit = {
				employs_court_position = royal_architect_court_position
				any_court_position_holder = {
					has_court_position = royal_architect_court_position
					is_available_healthy_ai_adult = yes 
				}
   			}
			random_court_position_holder = {
				limit = {
					has_court_position = royal_architect_court_position
					is_available_healthy_ai_adult = yes 
				}
				save_scope_as = architect 
			}
		}

		random_held_county = {
			limit = {
				faith = { religion_tag = zoroastrianism_religion }
				county_control < 75 
				any_county_province = {
					has_holding_type = castle_holding
					has_special_building_slot = no
					has_special_building = no
					NOR = {
						has_building = tower_of_silence_01
						has_building = event_tower_of_silence_01
					}
				}
			}
			random_county_province = {
				limit = {
					has_holding_type = castle_holding
					has_special_building_slot = no
					has_special_building = no
				}
				save_scope_as = dakhma_province
			}
			save_scope_as = dakhma_county
		}
	}

	option = {
		name = fp3_yearly.8050.a

		flavor = fp3_cheap_architecture_flavor

		trigger = {
			exists = scope:architect
		}

		remove_treasury_or_gold = medium_treasury_or_gold_value

		scope:dakhma_province = {
			hidden_effect = { add_special_building_slot = event_tower_of_silence_01 }
			add_special_building = event_tower_of_silence_01					
		}

		scope:architect = {
			duel = {
				skill = learning
				value = average_skill_rating

				20 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 2
					}
					root = {
						send_interface_toast = {
							title = building_a_dakhma.success
							left_icon = scope:architect
							custom_tooltip = fp3_silence_architecture_success_toast

							scope:dakhma_county = { change_county_control = 15 }

							if = {
								limit = {
									OR = {
										faith = { religion_tag = zoroastrianism_religion }
										faith = { has_doctrine_parameter = sky_burials_active }
									}
								}
								add_piety = major_piety_gain 
							}
							else = {
								add_character_modifier = {
									modifier = fp3_promoting_zoroastrianism_modifier
									years = 20
								}
							}
						}
					}
				}	
				20 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -1
					}
					root = {
						send_interface_toast = {
							title = building_a_dakhma.failure
							left_icon = scope:architect
							custom_tooltip = fp3_silence_architecture_failure_toast
							
							scope:dakhma_county = {
								add_county_modifier = {
									modifier = fp3_bad_tower_of_silence_county_modifier
									years = 20
								}
							}
						}
					}
				}
			}
		}

		stress_impact = { 
			ambitious = minor_stress_impact_loss
			greedy = minor_stress_impact_loss
			trusting = medium_stress_impact_loss
			content = medium_stress_impact_gain
			generous = medium_stress_impact_gain 
		}


		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.7
				ai_boldness = 0.7
				ai_vengefulness = -0.3
			}
		}	
	}

	option = {
		name = fp3_yearly.8050.b

		remove_treasury_or_gold = major_treasury_or_gold_value

		scope:dakhma_province = {
			hidden_effect = { add_special_building_slot = event_tower_of_silence_01 }
			add_special_building = event_tower_of_silence_01
		}

		scope:dakhma_county = { change_county_control = 15 }

		if = { #if you're zoroastrian or like sky burials in general, you earn piety for this, otherwise you might get an opinion bonus from zoroastrian subjects 
			limit = {
				OR = {
					faith = { religion_tag = zoroastrianism_religion }
					faith = { has_doctrine_parameter = sky_burials_active }
				}
			}
			add_piety = medium_piety_gain 
		}
		else = {
			custom_tooltip = fp3_zoroastrian_courtiers_and_vassals_happy
			hidden_effect = {
				every_courtier_or_guest = {
					if = {
						limit = { 
							AND = {
								faith = { religion_tag = zoroastrianism_religion } 
								ai_zeal >= low_positive_ai_value
							}
						}
					}
					add_opinion = { 
						target = root
						opinion = 15
						modifier = fp3_built_a_dakhma_opinion
					}
				}
				every_vassal = {
					if = {
						limit = { 
							AND = {
								faith = { religion_tag = zoroastrianism_religion } 
								ai_zeal >= low_positive_ai_value
							}
						}
					}
					add_opinion = { 
						target = root
						opinion = 15
						modifier = fp3_built_a_dakhma_opinion
					}
				}
			}
		}

		stress_impact = { 
			generous = medium_stress_impact_loss
			greedy = major_stress_impact_gain
			callous = minor_stress_impact_gain			 
		}


		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_greed = -0.9
				ai_compassion = 0.7
				ai_rationality = 0.3
			}
		}	
	}

	option = {
		name = fp3_yearly.8050.c

		trigger = {
			NOT = {
				faith = { religion_tag = zoroastrianism_religion }
			}
		}

		scope:dakhma_enthusiast = {
			add_opinion = { 
				target = root
				opinion = -15
				modifier = disappointed_opinion
			}
		}

		stress_impact = { 
			zealous = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			cynical = minor_stress_impact_gain 
		}


		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
				ai_rationality = -0.5
				ai_vengefulness = 1
				ai_zeal = 1
			}
		}	
	}

	option = { #zoroastrian variant option, with slightly different stress gains and AI weights 
		name = fp3_yearly.8050.d

		trigger = {
			faith = { religion_tag = zoroastrianism_religion }
		}

		scope:dakhma_enthusiast = {
			add_opinion = { 
				target = root
				opinion = -15
				modifier = disappointed_opinion
			}
		}

		stress_impact = { 
			zealous = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			cynical = minor_stress_impact_loss
			greedy = medium_stress_impact_loss
		}


		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_zeal = -1
				ai_greed = 1
				ai_vengefulness = 1	
			}
		}	
	}
}


##################################
# The Purest Fire
# By Ola Jentzsch and Lucas Ribeiro Rodrigues 
###################################

fp3_yearly.8051 = { #The Purest Fire
	type = character_event
	title = fp3_yearly.8051.t
	desc = {
		desc = fp3_yearly.8051_opening.desc
		random_valid = {
			desc = fp3_yearly.8051_torrential_rain
			desc = fp3_yearly.8051_earthquake
			desc = fp3_yearly.8051_sandstorm
			desc = fp3_yearly.8051_gust_of_wind
			desc = fp3_yearly.8051_islamic_zealots
			desc = fp3_yearly.8051_invisible_hand
		}
		desc = fp3_yearly.8051_ending.desc
	}

	theme = faith

	left_portrait = {
		character = root
		animation = personality_honorable 
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = ambitious
					has_trait = zealous
					has_trait = arrogant 
				}
			}
			animation = personality_zealous 
		}
	}
	right_portrait = {
		character = scope:magi
		animation = worry
	}

	cooldown = { years = 5 }

	trigger = {

		#standard sanity checks
		has_fp3_dlc_trigger = yes
		is_ruler = yes
		is_available_healthy_adult = yes
		root.capital_province = { geographical_region = world_persian_empire }
		faith = { religion_tag = zoroastrianism_religion }

		any_held_county = {
			faith = { religion_tag = zoroastrianism_religion }
			any_county_province = {
 				has_holding_type = church_holding
  			}
		}

		faith.religious_head != root

		NOT = { has_character_modifier = fp3_blessed_by_fire_modifier  } #this would make some of the rewards redundant

		OR = {
			AND = {
				exists = root.faith.religious_head
				root.faith.religious_head = { 
					is_available_healthy_ai_adult = yes
					opinion = { 
						target = root 
						value > 0
					}
				}
			}
			AND = {
				exists = cp:councillor_court_chaplain 
				cp:councillor_court_chaplain = { 
					is_available_healthy_ai_adult = yes 
					opinion = { 
						target = root 
						value > 0
					}
				}
			}
		}	
	}

	immediate = {
		random_held_county = {
			limit = {
				faith = { religion_tag = zoroastrianism_religion }
				any_county_province = {
 					has_holding_type = church_holding
  				}
			}
		}

		if = {
			limit = {
				exists = root.faith.religious_head
				root.faith.religious_head = {
					is_available_healthy_ai_adult = yes
					opinion = { 
						target = root 
						value > 0
					}
				}
			}
			root.faith.religious_head = { save_scope_as = magi }		
		}
		else = {
			cp:councillor_court_chaplain = { save_scope_as = magi }
		}
	}

	option = {
		name = fp3_yearly.8051.a

		scope:magi = {
			add_opinion = { 
				target = root
				opinion = 20
				modifier = happy_opinion
			}
		}

		custom_tooltip = fp3_yearly.8051_chasing_lightning.tt

		hidden_effect = {
			random_list = {
				75 = {
					trigger_event = {
						id = fp3_yearly.8052
						days = { 25 100 }
					}
				}
				25 = {
					trigger_event = {
						id = fp3_yearly.8053
						days = { 25 100 }
					}
				}
			}
		}

		stress_impact = { 
			ambitious = medium_stress_impact_loss
			content = medium_stress_impact_gain
			cynical = medium_stress_impact_gain
			lazy = major_stress_impact_gain
		}


		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_energy = 0.7
				ai_zeal = 1
				ai_rationality = -1
			}
		}	
	}

	option = {
		name = fp3_yearly.8051.b

		remove_short_term_gold = medium_gold_value

		add_piety = medium_piety_gain

		scope:magi = {
			add_opinion = { 
				target = root
				opinion = 10
				modifier = pleased_opinion
			}
		}

		stress_impact = { 
			ambitious = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_energy = 0.7
				ai_zeal = 1
				ai_rationality = -1
			}
		}
	}

	option = {
		name = fp3_yearly.8051.c

		scope:magi = {
			add_opinion = { 
				target = root
				opinion = -15
				modifier = disappointed_opinion
			}
		}

		stress_impact = { 
			cynical = minor_stress_impact_loss
			generous = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
			zealous = major_stress_impact_gain
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_greed = 0.7
				ai_rationality = 0.4
				ai_zeal = -1
				ai_energy = -0.5
			}
		}
	}
} 


fp3_yearly.8052 = { 
	type = character_event
	title = fp3_yearly.8052.t
	desc = fp3_yearly.8052.desc
	theme = faith

	left_portrait = {
		character = root
		animation = sadness
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = temperate 
					has_trait = patient 
					has_trait = calm 
				}
			}
			animation = stress
		}
	} 
	

	override_background = { reference = wilderness }

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no
	}

	option = {
		name = fp3_yearly.8052.a

		flavor = fp3_give_up_the_quest.flavor

		remove_short_term_gold = medium_gold_value

		add_piety = medium_piety_gain

		stress_impact = { 
			base = medium_stress_gain
			patient = minor_stress_impact_loss
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain 
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_zeal = 0.5
				ai_boldness = 0.5
				ai_rationality = -1
			}
		}
	}

	option = {
		name = fp3_yearly.8052.b

		flavor = fp3_give_up_the_quest.flavor

		stress_impact = { 
			impatient = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			content = minor_stress_impact_loss
			ambitious = medium_stress_impact_gain
			zealous = medium_stress_impact_gain 
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_energy = -1
				ai_zeal = 0.5
				ai_boldness = -0.5
				ai_rationality = 1
			}
		}
	}
}

fp3_yearly.8053 = { 
	type = character_event
	title = fp3_yearly.8053.t
	desc = fp3_yearly.8053.desc
	theme = faith

	left_portrait = {
		character = root
		animation = lantern
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = zealous
					has_trait = ambitious 
					has_trait = calm 
				}
			}
			animation = disbelief 
		}
	} 
	

	override_background = { reference = wilderness }

	trigger = {

		is_available = yes
		is_incapable = no
		has_contagious_deadly_disease_trigger = no
	}

	option = {
		name = fp3_yearly.8053.a

		add_character_modifier = {
			modifier = fp3_blessed_by_fire_modifier 
			years = 15 
		}

		stress_impact = { 
			base = medium_stress_loss
			zealous = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			trusting = minor_stress_impact_loss
			arrogant = minor_stress_impact_gain
			cynical = minor_stress_impact_gain 
		}

		ai_chance = { 
			base = 100
		}
	}
}


	



