namespace = fp3_yearly

# Daylight Censors (The Drunkenness of Ali Nushtgin)
# Go out drunk/high in broad daylight and risk being caught by your liege's censors?
fp3_yearly.2000 = {
	type = character_event
	title = fp3_yearly.2000.t
	desc = {
		triggered_desc = {
			trigger = { exists = scope:out_late_drinking }
			desc = fp3_yearly.2000.desc_drinking
		}
		triggered_desc = {
			trigger = { exists = scope:out_late_hash }
			desc = fp3_yearly.2000.desc_hashish
		}
		desc = fp3_yearly.2000.desc_warning
	}
	theme = crown
	override_background = {
		reference = alley_day
	}
	left_portrait = {
		character = root
		animation = laugh
	}
	right_portrait = {
		character = scope:cautious_vassal
		animation = worry
	}
	cooldown = { years = 10 }

	trigger = {
		has_fp3_dlc_trigger = yes
		is_landed_or_landless_administrative = yes
		OR = {
			has_trait = drunkard
			has_trait = hashishiyah
		}
		liege ?= {
			# You have at least one fellow vassal who would partake in alcohol/hashish with you (at least in moderation)
			any_vassal = {
				is_ai = yes
				NOR = {
					this = root
					has_trait = zealous
				}
			}
			# Faith must condemn drunkard/hashishiyah
			faith = {
				religion = religion:islam_religion
				NOR = {
					trait_is_virtue = drunkard
					trait_is_virtue = hashishiyah
				}
			}
			# Liege should not be a hypocrite
			NOR = {
				has_trait = drunkard
				has_trait = hashishiyah
			}
			# Liege hasn't had the follow-up event in the last 5 years
			NOT = { has_character_flag = had_event_fp3_yearly_2001 }
		}
	}

	immediate = {
		# Are we out late drinking or hashishing?
		random_list = {
			1 = {
				trigger = {
					has_trait = drunkard
					NOT = { faith = { trait_is_virtue = drunkard } }
				}
				save_scope_value_as = { name = out_late_drinking value = yes }
			}
			1 = {
				trigger = {
					has_trait = hashishiyah
					NOT = { faith = { trait_is_virtue = hashishiyah } }
				}
				save_scope_value_as = { name = out_late_hash value = yes }
			}
		}
		liege = {
			save_scope_as = prudish_liege
			random_vassal = {
				limit = {
					NOR = {
						this = root
						has_trait = zealous
					}
				}
				save_scope_as = cautious_vassal
			}
		}
		add_stress = minor_stress_impact_loss
	}

	option = { # Stay inside, be cautious
		name = fp3_yearly.2000.a
		add_prestige = minor_prestige_loss
		stress_impact = {
			arrogant = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = { ai_boldness = -0.5 }
		}
	}

	option = { # Risk going out
		name = fp3_yearly.2000.b
		flavor = fp3_yearly.2000.b_flavor
		if = {
			limit = { scope:prudish_liege = { is_ai = yes } }
			random_list = {
				50 = { # You get away with it
					show_chance = no
					desc = fp3_yearly.2000.b_success
					send_interface_toast = {
						title = fp3_yearly.2000.b_success
						left_icon = root
					}
				}
				50 = { # You get caught and flogged
					show_chance = no
					desc = fp3_yearly.2000.b_failure
					send_interface_toast = {
						type = event_toast_effect_bad
						title = fp3_yearly.2000.b_failure
						left_icon = root
						increase_wounds_effect = { REASON = flogged_by_censors }
					}
					hidden_effect = {
						add_opinion = {
							modifier = fp3_flogged_me
							target = scope:prudish_liege
						}
					}
				}
			}
		}
		# If liege is player, then trigger event for them to decide what to do with this uppity vassal
		else = {
			show_as_tooltip = {
				random_list = {
					# This is a tooltip-only version of the above to communicate the possible consequences of this option
					1 = {
						show_chance = no
						desc = fp3_yearly.2000.b_success
					}
					1 = {
						show_chance = no
						desc = fp3_yearly.2000.b_failure
						increase_wounds_effect = { REASON = flogged_by_censors }
					}
				}
			}
			save_scope_as = intoxicated
			scope:prudish_liege = { trigger_event = fp3_yearly.2001 }
		}
		stress_impact = {
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = { ai_boldness = 0.5 }
			# This option is more interesting for players, so make AI attempt it more often if the liege is a player
			modifier = {
				scope:prudish_liege = { is_ai = no }
				add = 100
			}
		}
	}
}

scripted_trigger fp3_yearly_2001_is_valid_druggie = {
	is_available_ai_adult = yes
	is_of_major_interest_to_root_trigger = yes
	OR = {
		has_trait = hashishiyah
		has_trait = drunkard
	}
	NOT = { has_trait = craven }
}

# Public Intoxication
# Your vassal/courtier/family is drunk in broad daylight, have them flogged or no?
fp3_yearly.2001 = {
	type = character_event
	title = fp3_yearly.2001.t
	desc = {
		desc = fp3_yearly.2001.desc_intro
		triggered_desc = {
			trigger = { exists = scope:out_late_drinking }
			desc = fp3_yearly.2001.desc_drinking
		}
		triggered_desc = {
			trigger = { exists = scope:out_late_hash }
			desc = fp3_yearly.2001.desc_hashish
		}
		desc = fp3_yearly.2001.desc_outro
	}
	theme = crown
	override_background = {
		reference = alley_day
	}
	left_portrait = {
		character = scope:intoxicated
		animation = laugh
	}

	trigger = {
		has_fp3_dlc_trigger = yes
		is_landed_or_landless_administrative = yes
		# This event can be fired from either the yearly pulse or fp3_yearly.2000
		# If the former is true, then the offending druggie does not yet exist and we need to find one
		OR = {
			exists = scope:intoxicated
			AND = {
				NOT = { has_character_flag = had_event_fp3_yearly_2001 }
				religion = religion:islam_religion
				NOR = {
					has_trait = drunkard
					has_trait = hashishiyah
				}
				OR = {
					any_vassal = { fp3_yearly_2001_is_valid_druggie = yes }
					any_courtier_or_guest = { fp3_yearly_2001_is_valid_druggie = yes }
					any_consort = { fp3_yearly_2001_is_valid_druggie = yes }
				}
			}
		}
	}

	immediate = {
		save_scope_as = prudish_liege
		if = {
			limit = { NOT = { exists = scope:intoxicated } }
			# 10 year cooldown if fired from yearly pulse
			add_character_flag = {
				flag = had_event_fp3_yearly_2001
				years = 10
			}
			every_vassal = {
				limit = { fp3_yearly_2001_is_valid_druggie = yes }
				add_to_temporary_list = valid_druggies
			}
			every_courtier_or_guest = {
				limit = { fp3_yearly_2001_is_valid_druggie = yes }
				add_to_temporary_list = valid_druggies
			}
			every_consort = {
				limit = { fp3_yearly_2001_is_valid_druggie = yes }
				add_to_temporary_list = valid_druggies
			}
			random_in_list = {
				list = valid_druggies
				save_scope_as = intoxicated
			}
			random_list = {
				1 = {
					trigger = {
						scope:intoxicated = {
							has_trait = drunkard
							NOT = { faith = { trait_is_virtue = drunkard } }
						}
					}
					save_scope_value_as = { name = out_late_drinking value = yes }
				}
				1 = {
					trigger = {
						scope:intoxicated = {
							has_trait = hashishiyah
							NOT = { faith = { trait_is_virtue = hashishiyah } }
						}
					}
					save_scope_value_as = { name = out_late_hash value = yes }
				}
			}
		}
	}

	option = { # Flog them
		name = fp3_yearly.2001.a
		scope:intoxicated = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = fp3_yearly.2000.b_failure
				left_icon = root
				increase_wounds_effect = { REASON = flogged_by_censors }
			}
		}
		add_piety = minor_piety_gain
		reverse_add_opinion = {
			target = scope:intoxicated
			modifier = fp3_flogged_me
		}
		if = {
			limit = { has_relation_friend = scope:intoxicated }
			remove_relation_friend = scope:intoxicated
		}
		stress_impact = {
			sadistic = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = { ai_zeal = 0.5 }
		}
	}

	option = { # Ignore them
		name = fp3_yearly.2001.b
		add_piety = medium_piety_loss
		scope:intoxicated = {
			send_interface_toast = {
				title = fp3_yearly.2000.b_success
				left_icon = root
			}
		}
		stress_impact = {
			zealous = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = { ai_energy = -0.5 }
		}
	}
}

scripted_effect fp3_yearly_2010_create_baker_effect = {
	create_character = {
		age = { 35 50 }
		dynasty = none
		location = root.capital_province
		gender_female_chance = root_faith_dominant_gender_female_chance
		faith = root.capital_province.faith
		culture = scope:bakers_county.culture 
		# Personality Traits
		trait = greedy
		random_traits_list = {
			count = 2
			brave = {}
			craven = {}
			wrathful = {}
			lustful = {}
			ambitious = {}
			diligent = {}
			stubborn = {}
			vengeful = {}
			deceitful = {}
			arrogant = {}
			arbitrary = {}
			impatient = {}
			gluttonous = {}
		}
		random_traits_list = {
			count = 1
			education_diplomacy_2 = {}
			education_stewardship_2 = {}
			education_stewardship_3 = {}
			education_stewardship_4 = {}
			education_learning_1 = {}
			education_learning_2 = {}
		}
		# Flavor Traits
		trait = administrator
		random_traits_list = {
			count = { 0 2 }
			gout_ridden = {}
			leper = {}
			lovers_pox = {}
			pneumonic = {}
			dwarf = {}
			giant = {}
			hunchbacked = {}
			weak = {}
			clubfooted = {}
			lisping = {}
			stuttering = {}
			wheezing = {}
			albino = {}
			scaly = {}
			spindly = {}
			maimed = {}
			one_eyed = {}
			one_legged = {}
			disfigured = {}
			blind = {}
		}
		random_traits = yes
		diplomacy = { 8 13 }
		martial = { 6 10 }
		stewardship = { 8 13 }
		intrigue = { 8 13 }
		learning = { 13 18 }
		prowess = { 3 8 }
		after_creation = {
			random_list = {
				50 = {
					# Character is of average weight, nothing happens
				}
				25 = {
					change_current_weight = 25
				}
				25 = {
					change_current_weight = 75
				}
			}
			add_character_flag = peasant_outfit
		}
		save_scope_as = greedy_baker
	}
	
}

# Maunds of Wheat (The Bakers of Ghaznain)
# Your royal baker is hoarding bread, how shall you deal with them?
fp3_yearly.2010 = {
	type = court_event
	title = fp3_yearly.2010.t
	desc = fp3_yearly.2010.desc
	theme = court
	cooldown = { years = 5 }
	court_scene = {
		button_position_character = root
		roles = {
			scope:greedy_baker = {
				group = event_group
			}
			root = {
				group = event_group
				animation = personality_rational
			}
			scope:random_courtier = {
				group = event_group
				animation = beg
			}
		}
	}

	trigger = {
		has_fp3_dlc_trigger = yes
		has_royal_court = yes
		has_court_event_flag = no
		is_available = yes
		government_has_flag = government_is_clan
		any_sub_realm_county = {
			NOR = {
				has_county_modifier = fp3_generous_bakers_modifier
				has_county_modifier = fp3_wheat_shortage_modifier
			}
		}
		any_courtier = {
			is_available_ai_adult = yes
			has_court_event_flag = no
		}
	}

	immediate = {
		court_event_character_flag_effect = yes
		random_courtier = {
			limit = {
				is_available_ai_adult = yes
				has_court_event_flag = no
			}
			save_scope_as = random_courtier
			court_event_character_flag_effect = yes
		}
		random_sub_realm_county = {
			save_scope_as = bakers_county
		}
		fp3_yearly_2010_create_baker_effect = yes
		scope:greedy_baker = { court_event_character_flag_effect = yes }
	}

	option = { # Trample to death
		name = {
			text = {
				desc = fp3_yearly.2010.a
				first_valid = {
					triggered_desc = {
						trigger = { culture = { has_innovation = innovation_elephantry } }
						desc = fp3_yearly.2010.a_elephants
					}
					triggered_desc = {
						trigger = { culture = { has_innovation = innovation_elephantry } }
						desc = fp3_yearly.2010.a_camels
					}
					desc = fp3_yearly.2010.a_horses
				}
			}
		}
		flavor = fp3_yearly.2010.a.tt
		stress_impact = {
			greedy = minor_stress_impact_gain
			just = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
		}
		scope:greedy_baker = {
			death = {
				death_reason = death_trampled
				killer = root
			}
		}
		add_prestige = minor_prestige_loss
		remove_treasury_or_gold = minor_treasury_or_gold_value
		scope:bakers_county = {
			add_county_modifier = {
				modifier = fp3_generous_bakers_modifier
				years = 15
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}

	option = { # Recruit
		name = fp3_yearly.2010.b
		stress_impact = {
			just = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			arbitrary = minor_stress_impact_loss
		}
		add_courtier = scope:greedy_baker
		scope:bakers_county = {
			add_county_modifier = {
				modifier = fp3_wheat_shortage_modifier
				years = 10
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}

	option = { # Take the extra money
		name = fp3_yearly.2010.c
		add_treasury_or_gold = medium_treasury_or_gold_value
		stress_impact = {
			just = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		scope:bakers_county = {
			add_county_modifier = {
				modifier = fp3_wheat_shortage_modifier
				years = 10
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = generous
				factor = 0
			}
		}
	}

	after = {
		clear_court_event_participation = yes
		scope:greedy_baker = { clear_court_event_participation = yes }
		scope:random_courtier = { clear_court_event_participation = yes }
	}
}

# Maunds of Wheat (Non-Royal Court Version)
fp3_yearly.2011 = {
	type = character_event
	title = fp3_yearly.2010.t
	desc = fp3_yearly.2010.desc
	theme = crown
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:random_courtier
		animation = beg
	}
	lower_left_portrait = scope:greedy_baker
	cooldown = { years = 10 }

	trigger = {
		has_fp3_dlc_trigger = yes
		government_has_flag = government_is_clan
		highest_held_title_tier >= tier_kingdom
		any_courtier = {
			is_available_ai_adult = yes
		}
		any_sub_realm_county = {
			NOR = {
				has_county_modifier = fp3_generous_bakers_modifier
				has_county_modifier = fp3_wheat_shortage_modifier
			}
		}
	}

	immediate = {
		random_courtier = {
			limit = {
				is_available_ai_adult = yes
			}
			save_scope_as = random_courtier
		}
		random_sub_realm_county = {
			save_scope_as = bakers_county
		}
		fp3_yearly_2010_create_baker_effect = yes
	}

	option = { # Trample to death
		name = {
			text = {
				desc = fp3_yearly.2010.a
				first_valid = {
					triggered_desc = {
						trigger = { culture = { has_innovation = innovation_elephantry } }
						desc = fp3_yearly.2010.a_elephants
					}
					triggered_desc = {
						trigger = { culture = { has_innovation = innovation_elephantry } }
						desc = fp3_yearly.2010.a_camels
					}
					desc = fp3_yearly.2010.a_horses
				}
			}
		}
		flavor = fp3_yearly.2010.a.tt
		stress_impact = {
			greedy = minor_stress_impact_gain
			just = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
		}
		scope:greedy_baker = {
			death = { death_reason = death_trampled }
		}
		add_prestige = minor_prestige_loss
		remove_treasury_or_gold = minor_treasury_or_gold_value
		scope:bakers_county = {
			add_county_modifier = {
				modifier = fp3_generous_bakers_modifier
				years = 15
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}

	option = { # Recruit
		name = fp3_yearly.2010.b
		add_courtier = scope:greedy_baker
		scope:bakers_county = {
			add_county_modifier = {
				modifier = fp3_wheat_shortage_modifier
				years = 10
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			arbitrary = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}

	option = { # Take the extra money
		name = fp3_yearly.2010.c
		add_treasury_or_gold = major_treasury_or_gold_value
		stress_impact = {
			just = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		scope:bakers_county = {
			add_county_modifier = {
				modifier = fp3_wheat_shortage_modifier
				years = 10
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = generous
				factor = 0
			}
		}
	}
}

# This tax collector is guilty of at least one vice condemned of public officials in the Quran
scripted_trigger fp3_yearly_2020_is_valid_tax_collector = {
	is_available_ai_adult = yes
	OR = {
		AND = {
			has_trait = greedy
			faith = {
				NOR = {
					trait_is_virtue = greedy
					trait_is_sin = generous
				}
			}
		}
		AND = {
			has_trait = arbitrary
			faith = {
				NOR = {
					trait_is_virtue = arbitrary
					trait_is_sin = just
				}
			}
		}
		AND = {
			has_trait = cynical
			faith = {
				NOR = {
					trait_is_virtue = cynical
					trait_is_sin = zealous
				}
			}
		}
		AND = {
			has_trait = contrite
			NOT = { faith = { trait_is_virtue = contrite } }
		}
	}
}

# Set the Scale: Vassal Version
# The tax collector in charge of you is corrupt, shall you petition to your liege to have them removed?
fp3_yearly.2020 = {
	type = character_event
	title = fp3_yearly.2020.t
	desc = {
		desc = fp3_yearly.2020.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_greedy }
				desc = fp3_yearly.2020.desc_greedy
			}
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_arbitrary }
				desc = fp3_yearly.2020.desc_arbitrary
			}
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_cynical }
				desc = fp3_yearly.2020.desc_cynical
			}
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_contrite }
				desc = fp3_yearly.2020.desc_contrite
			}
		}
		desc = fp3_yearly.2020.desc_outro
	}
	theme = stewardship
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:sinful_tax_collector
		animation = shock
	}
	lower_left_portrait = scope:liege

	trigger = {
		is_landed = yes
		has_religion = religion:islam_religion
		piety_level > low_negative_piety_level
		liege ?= {
			has_religion = religion:islam_religion
			employs_tax_collector = yes
			any_tax_collector = {
				this != root
				any_tax_collector_vassal = { this = root }
				fp3_yearly_2020_is_valid_tax_collector = yes
			}
			# Liege has not been bothered about this tax collector in the last 5 years
			NOT = { has_character_flag = had_event_fp3_yearly_2021 }
		}
	}

	# This event is more likely to trigger if you are your liege's steward (because the effects are more interesting)
	weight_multiplier = {
		modifier = {
			add = 0.5
			has_council_position = councillor_steward
		}
	}

	immediate = {
		liege = {
			save_scope_as = liege
			add_character_flag = {
				flag = had_event_fp3_yearly_2021
				years = 5
			}
			random_tax_collector = {
				limit = {
					this != root
					any_tax_collector_vassal = { this = root }
					fp3_yearly_2020_is_valid_tax_collector = yes
				}
				save_scope_as = sinful_tax_collector
				# Choose which flaw to criticize in this tax collector
				random_list = {
					1 = {
						trigger = {
							has_trait = greedy
							NOT = { faith = { trait_is_virtue = greedy } }
						}
						save_scope_value_as = {
							name = tax_collector_is_greedy
							value = yes
						}
					}
					1 = {
						trigger = {
							has_trait = arbitrary
							NOT = { faith = { trait_is_virtue = arbitrary } }
						}
						save_scope_value_as = {
							name = tax_collector_is_arbitrary
							value = yes
						}
					}
					1 = {
						trigger = {
							has_trait = cynical
							NOT = { faith = { trait_is_virtue = cynical } }
						}
						save_scope_value_as = {
							name = tax_collector_is_cynical
							value = yes
						}
					}
					1 = {
						trigger = {
							has_trait = contrite
							NOT = { faith = { trait_is_virtue = contrite } }
						}
						save_scope_value_as = {
							name = tax_collector_is_contrite
							value = yes
						}
					}
				}
			}
		}
	}

	option = { # Petition to have them removed
		name = fp3_yearly.2020.a
		reverse_add_opinion = {
			target = scope:sinful_tax_collector
			modifier = fp3_denounced_me
		}
		if = { #If Liege is AI we can fire the tax collector here
			limit = { scope:liege = { is_ai = yes } }
			progress_towards_rival_effect = {
				CHARACTER = scope:sinful_tax_collector
				REASON = rival_tried_to_remove_tax_collector
				OPINION = 0
			}
			duel = {
				skill = learning
				value = scope:liege.learning

				7 = { # Tax collector is removed forever
					desc = fp3_yearly.2020.a_success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.25
					}
					send_interface_toast = {
						type = event_toast_effect_good
						title = fp3_yearly.2020.a_success
						left_icon = root
						right_icon = scope:sinful_tax_collector
						add_piety = medium_piety_gain
						scope:liege = { fire_tax_collector = scope:sinful_tax_collector }
						scope:sinful_tax_collector = {
							add_character_modifier = fp3_incapable_tax_collector_modifier
						}
					}
				}
				3 = { # Tax collector starts problems with you
					desc = fp3_yearly.2020.a_failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -0.25
					}
					send_interface_toast = {
						type = event_toast_effect_bad
						title = fp3_yearly.2020.a_failure
						left_icon = root
						right_icon = scope:sinful_tax_collector
						if = {
							limit = { has_council_position = councillor_steward }
							custom_tooltip = fp3_yearly.2020.a_failure.tt
						}
					}
					if = {
						limit = {
							has_council_position = councillor_steward
							# Don't give the liege two stories of the same type
							scope:liege = { NOT = { any_owned_story = { type = story_cycle_tax_rivalry } } }
						}
						# Create the tax rivalry story, if applicable
						scope:liege = {
							set_variable = {
								name = story_steward
								value = root
								days = 1
							}
							set_variable = {
								name = story_tax_collector
								value = scope:sinful_tax_collector
								days = 1
							}
							create_tax_rivalry_story_effect = yes
						}
					}
				}
			}
		}
		else = { #If Liege is not AI this is resolved in an event for liege
			show_as_tooltip = {
				# The actual progress effect will happen in fp3_yearly.2021
				# This is so that the liege's tooltip accurately reflects on the depth of rivalry
				progress_towards_rival_effect = {
					CHARACTER = scope:sinful_tax_collector
					REASON = rival_tried_to_remove_tax_collector
					OPINION = 0
				}
				random_list = {
					1 = {
						show_chance = no
						desc = fp3_yearly.2020.a_success
						fire_tax_collector = scope:sinful_tax_collector
						scope:sinful_tax_collector = {
							add_character_modifier = fp3_incapable_tax_collector_modifier
						}
					}
					1 = {
						show_chance = no
						desc = fp3_yearly.2020.a_failure
						custom_tooltip = fp3_yearly.2020.a_failure.tt
					}
				}
			}
			save_scope_as = denouncing_taxpayer
			scope:liege = { trigger_event = fp3_yearly.2021 }
		}
		stress_impact = {
			shy = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			just = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_zeal = 0.25
				ai_greed = 0.5
			}
		}
	}

	option = { # Publicly expose them (causes their learning to tank, meaning they have less aptitude and you will owe fewer taxes to your liege)
		name = fp3_yearly.2020.b
		reverse_add_opinion = {
			target = scope:sinful_tax_collector
			modifier = fp3_denounced_me
		}
		progress_towards_rival_effect = {
			CHARACTER = scope:sinful_tax_collector
			REASON = rival_tried_to_remove_tax_collector
			OPINION = 0
		}
		# Tank the collector's aptitude and inform the liege
		save_scope_as = denouncing_taxpayer
		add_piety = minor_piety_gain
		liege = {
			send_interface_message = {
				type = event_tax_collector_bad_with_text
				title = fp3_yearly.2020.b.t
				desc = fp3_yearly.2020.b.desc
				scope:sinful_tax_collector = {
					add_character_modifier = {
						modifier = fp3_impious_tax_collector_modifier
						years = 30
					}
				}
				left_icon = scope:sinful_tax_collector
				right_icon = scope:denouncing_taxpayer
			}
		}
		stress_impact = {
			shy = medium_stress_impact_gain
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0 
		}
	}

	option = { # Pray for their soul (opt-out)
		name = fp3_yearly.2020.c
		add_piety = minor_piety_gain
		stress_impact = {
			greedy = medium_stress_impact_gain
			just = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			lazy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				has_trait = greedy
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
		}
	}
}

# Set the Scale: Liege Version
# One of your tax collectors is corrupt and your vassal is demanding you fire them
fp3_yearly.2021 = {
	type = character_event
	title = fp3_yearly.2020.t
	desc = {
		desc = fp3_yearly.2021.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_greedy }
				desc = fp3_yearly.2021.desc_greedy
			}
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_arbitrary }
				desc = fp3_yearly.2021.desc_arbitrary
			}
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_cynical }
				desc = fp3_yearly.2021.desc_cynical
			}
			triggered_desc = {
				trigger = { exists = scope:tax_collector_is_contrite }
				desc = fp3_yearly.2021.desc_contrite
			}
		}
		desc = fp3_yearly.2021.desc_outro
	}
	theme = stewardship


	left_portrait = {
		character = scope:denouncing_taxpayer
		animation = anger
	}
	right_portrait = {
		character = scope:sinful_tax_collector
		animation = shame
	}

	cooldown = { years = 5 }

	trigger = {
		has_religion = religion:islam_religion
		employs_tax_collector = yes
		any_tax_collector = {
			any_tax_collector_vassal = {
				has_religion = religion:islam_religion
				piety_level > low_negative_piety_level
				is_available_adult = yes
				trigger_if = {
					limit = { NOT = { exists = scope:denouncing_taxpayer } } # If this event isn't a redirect from fp3_yearly.2020, then the featured taxpayer must be an ai
					is_ai = yes
					NOT = { has_trait = shy } # B/c shy vassals are unlikely to take the denounce option in fp3_yearly.2020.a
				}
			}
			fp3_yearly_2020_is_valid_tax_collector = yes
		}
	}

	immediate = {
		if = {
			limit = { NOT = { exists = scope:sinful_tax_collector } }
			random_tax_collector = {
				limit = {
					any_tax_collector_vassal = {
						has_religion = religion:islam_religion
						piety_level > low_negative_piety_level
						is_available_adult = yes
						trigger_if = {
							limit = { NOT = { exists = scope:denouncing_taxpayer } } # If this event isn't a redirect from fp3_yearly.2020, then the featured taxpayer must be an ai
							is_ai = yes
							NOT = { has_trait = shy } # B/c shy vassals are unlikely to take the denounce option in fp3_yearly.2020.a
						}
					}
					fp3_yearly_2020_is_valid_tax_collector = yes
				}
				save_scope_as = sinful_tax_collector
				# Choose which flaw to criticize in this tax collector
				random_list = {
					1 = {
						trigger = {
							has_trait = greedy
							NOT = { faith = { trait_is_virtue = greedy } }
						}
						save_scope_value_as = {
							name = tax_collector_is_greedy
							value = yes
						}
					}
					1 = {
						trigger = {
							has_trait = arbitrary
							NOT = { faith = { trait_is_virtue = arbitrary } }
						}
						save_scope_value_as = {
							name = tax_collector_is_arbitrary
							value = yes
						}
					}
					1 = {
						trigger = {
							has_trait = cynical
							NOT = { faith = { trait_is_virtue = cynical } }
						}
						save_scope_value_as = {
							name = tax_collector_is_cynical
							value = yes
						}
					}
					1 = {
						trigger = {
							has_trait = contrite
							NOT = { faith = { trait_is_virtue = contrite } }
						}
						save_scope_value_as = {
							name = tax_collector_is_contrite
							value = yes
						}
					}
				}
				if = {
					limit = { NOT = { exists = scope:denouncing_taxpayer } }
					random_tax_collector_vassal = {
						limit = {
							is_available_ai_adult = yes
							has_religion = religion:islam_religion
							piety_level > low_negative_piety_level
							NOT = { has_trait = shy }
						}
						# More likely to choose a zealous denouncer
						weight = {
							base = 1
							ai_value_modifier = {
								ai_zeal = 0.1
							}
						}
						save_scope_as = denouncing_taxpayer
					}
				}
			}
		}
		scope:denouncing_taxpayer = {
			assign_quirk_effect = yes
		}
		scope:denouncing_taxpayer = {
			progress_towards_rival_effect = {
				CHARACTER = scope:sinful_tax_collector
				REASON = rival_tried_to_remove_tax_collector
				OPINION = 0
			}
		}
	}

	option = { # Fire the tax collector
		name = fp3_yearly.2021.a
		add_piety = minor_piety_gain
		fire_tax_collector = scope:sinful_tax_collector
		scope:sinful_tax_collector = {
			add_character_modifier = fp3_incapable_tax_collector_modifier
		}
		scope:denouncing_taxpayer = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
			# If this is a follow-up from fp3_yearly.2020, then send that player a toast
			if = {
				limit = { is_ai = no }
				send_interface_toast = {
					type = event_toast_effect_good
					title = fp3_yearly.2020.a_success
					left_icon = root
					right_icon = scope:sinful_tax_collector
				}
			}
		}
		if = {
			limit = { #Complainer is a house member - collector is not
				exists = scope:denouncing_taxpayer.house
				scope:denouncing_taxpayer.house = house
				trigger_if = {
					limit = {
						exists = scope:sinful_tax_collector.house
					}
					scope:sinful_tax_collector.house != house
				}
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:denouncing_taxpayer
				VALUE = minor_unity_gain
				DESC = clan_unity_tax_collector_fired_on_request.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		else_if = {
			limit = { #Complainer is not a clan member but the tax collector is
				exists = scope:sinful_tax_collector.house
				scope:sinful_tax_collector.house = house
				trigger_if = {
					limit = {
						exists = scope:denouncing_taxpayer.house
					}
					scope:denouncing_taxpayer.house != house
				}
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:sinful_tax_collector
				VALUE = minor_unity_loss
				DESC = clan_unity_tax_collector_fired.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		} #If neither is of your house, or if both are we don't adjust unity.

		stress_impact = {
			greedy = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			just = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}

	option = { # Ignore
		name = fp3_yearly.2021.b
		add_piety = medium_piety_loss
		scope:denouncing_taxpayer = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
			if = {
				limit = { is_ai = no }
				send_interface_toast = {
					type = event_toast_effect_bad
					title = fp3_yearly.2020.a_failure
					left_icon = root
					right_icon = scope:sinful_tax_collector
					custom_tooltip = fp3_yearly.2020.a_failure.tt
				}
			}
		}
		# Create the tax rivalry story if the denouncer is your steward
		if = {
			limit = {
				scope:denouncing_taxpayer = { has_council_position = councillor_steward }
				# Don't give yourself two stories of the same type
				NOT = { any_owned_story = { type = story_cycle_tax_rivalry } }
			}
			set_variable = {
				name = story_steward
				value = scope:denouncing_taxpayer
				days = 30
			}
			set_variable = {
				name = story_tax_collector
				value = scope:sinful_tax_collector
				days = 30
			}
			create_tax_rivalry_story_effect = yes
		}
		if = {
			limit = { #Complainer is a house member - collector is not
				exists = scope:denouncing_taxpayer.house
				scope:denouncing_taxpayer.house = house
				trigger_if = {
					limit = {
						exists = scope:sinful_tax_collector.house
					}
					scope:sinful_tax_collector.house != house
				}
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:denouncing_taxpayer
				VALUE = minor_unity_loss
				DESC = clan_unity_ignore_tax_collector_complaint.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		else_if = {
			limit = { #Complainer is not a clan member but the tax collector is
				exists = scope:sinful_tax_collector.house
				scope:sinful_tax_collector.house = house
				trigger_if = {
					limit = {
						exists = scope:denouncing_taxpayer.house
					}
					scope:denouncing_taxpayer.house != house
				}
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = root
				TARGET = scope:sinful_tax_collector
				VALUE = minor_unity_gain
				DESC = clan_unity_protected_tax_collector_against_complaint.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		} #If neither is of your house, or if both are we don't adjust unity.

		stress_impact = {
			just = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
			arrogant = minor_stress_impact_loss
			greedy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}
}

# A Beautiful Rule (The Ugliness of Sultan Mahmud)
# You are ugly, but your courtier suggests your beautiful actions are more important to your rule
#Triggers shortly after succession
fp3_yearly.2030 = {
	type = character_event
	title = fp3_yearly.2030.t
	desc = {
		desc = fp3_yearly.2030.desc_intro
		# Look in the mirror at your "ugly" feature
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_beauty_bad }
				desc = fp3_yearly.2030.desc_beauty_bad
			}
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_spindly }
				desc = fp3_yearly.2030.desc_spindly
			}
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_disfigured }
				desc = fp3_yearly.2030.desc_disfigured
			}
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_scaly }
				desc = fp3_yearly.2030.desc_scaly
			}
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_albino }
				desc = fp3_yearly.2030.desc_albino
			}
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_hunchbacked }
				desc = fp3_yearly.2030.desc_hunchbacked
			}
			triggered_desc = {
				trigger = { has_character_flag = fp3_yearly_2030_inbred }
				desc = fp3_yearly.2030.desc_inbred
			}
		}
		desc = fp3_yearly.2030.desc_outro
	}
	theme = crown
	override_background = {
		reference = sitting_room
	}
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:reassuring_courtier
		animation = personality_compassionate
	}

	cooldown = { years = 100 }

	trigger = {
		has_fp3_dlc_trigger = yes
		is_available_adult = yes
		is_landed = yes
		OR = {
			has_trait = beauty_bad
			has_trait = spindly
			has_trait = disfigured
			has_trait = scaly
			has_trait = albino
			has_trait = hunchbacked
			has_trait = inbred
		}
		NOR = {
			has_trait = callous
			has_trait = sadistic
			has_trait = beauty_good
		}
		faith = {
			trait_is_virtue = generous
		}
	}

	immediate = {
		# Figure out which ugliness we will pick at
		random_list = {
			1 = {
				trigger = { has_trait = beauty_bad }
				add_character_flag = {
					flag = fp3_yearly_2030_beauty_bad
					days = 1
				}
			}
			1 = {
				trigger = { has_trait = spindly }
				add_character_flag = {
					flag = fp3_yearly_2030_spindly
					days = 1
				}
			}
			1 = {
				trigger = { has_trait = disfigured }
				add_character_flag = {
					flag = fp3_yearly_2030_disfigured
					days = 1
				}
			}
			1 = {
				trigger = { has_trait = scaly }
				add_character_flag = {
					flag = fp3_yearly_2030_scaly
					days = 1
				}
			}
			1 = {
				trigger = { has_trait = albino }
				add_character_flag = {
					flag = fp3_yearly_2030_albino
					days = 1
				}
			}
			1 = {
				trigger = { has_trait = hunchbacked }
				add_character_flag = {
					flag = fp3_yearly_2030_hunchbacked
					days = 1
				}
			}
			1 = {
				trigger = { has_trait = inbred }
				add_character_flag = {
					flag = fp3_yearly_2030_inbred
					days = 1
				}
			}
		}
		# Figure out which courtier should reassure us
		# If we have a lady in waiting, then use her
		if = {
			limit = {
				employs_court_position = lady_in_waiting_court_position
				is_available_ai_adult = yes
				has_contagious_deadly_disease_trigger = no
			}
			random_court_position_holder = {
				type = lady_in_waiting_court_position
				save_scope_as = reassuring_courtier
			}
		}
		# Otherwise, pick court jester
		else_if = {
			limit = {
				employs_court_position = court_jester_court_position
				is_available_ai_adult = yes
				has_contagious_deadly_disease_trigger = no
			}
			random_court_position_holder = {
				type = court_jester_court_position
				save_scope_as = reassuring_courtier
			}
		}
		# Otherwise, pick some (weighted) rando
		else = {
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
					has_contagious_deadly_disease_trigger = no
				}
				weight = {
					base = 100
					opinion_modifier = {
						opinion_target = root
					}
					modifier = {
						has_trait = zealous
						add = 50
					}
					modifier = {
						has_trait = cynical
						add = -50
					}
					modifier = {
						has_trait = generous
						add = 50
					}
					modifier = {
						has_trait = greedy
						add = -50
					}
				}
				save_scope_as = reassuring_courtier
			}
		}
	}

	
	option = { # Act generously (even if it is instrumental and not in your nature)
		name = fp3_yearly.2030.a
		trigger = {
			NOT = { has_trait = generous }
		}
		remove_short_term_gold = medium_gold_value
		add_character_modifier = {
			modifier = generous_beauty
			years = 10
		}
		stress_impact = {
			greedy = major_stress_impact_gain
			arrogant = minor_stress_impact_gain
			deceitful = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			temperate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Actions will speak louder than words
		name = fp3_yearly.2030.d
		add_prestige = minor_prestige_value
		stress_impact = {
			base = medium_stress_impact_gain
			wrathful = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
			temperate = minor_stress_impact_loss
			trusting = minor_stress_impact_loss
			humble = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Bask in your generosity
		name = fp3_yearly.2030.b
		trigger = {
			has_trait = generous
		}
		trait = generous
		add_prestige = medium_prestige_gain
		give_nickname = nick_the_beautiful_generous
		remove_short_term_gold = medium_gold_value
		add_character_modifier = {
			modifier = generous_beauty
			years = 10
		}
		stress_impact = {
			generous = major_stress_impact_loss
			arrogant = minor_stress_impact_loss
			temperate = minor_stress_impact_loss
			deceitful = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Gain dread
		name = fp3_yearly.2030.c
		add_dread = medium_dread_gain
		scope:reassuring_courtier = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
		imprison_character_effect = { #We kill the messenger, so to speak
			TARGET = scope:reassuring_courtier
			IMPRISONER = root
		}
		add_character_modifier = {
			modifier = dreaded_beauty
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
			content = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			deceitful = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				has_trait = compassionate
				factor = 0
			}
			modifier = {
				has_trait = content
				factor = 0
			}
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = humble
				factor = 0
			}
		}
	}
}

# Checks whether any of the character's provinces recognize the caliph as their HOF
scripted_trigger fp3_yearly_2040_attackers_provinces_respect_caliph = {
	any_held_title = {
		title_tier = county
		faith.religious_head = root
	}
}

# All counties that respect the caliph as their HOF get a massive levy size penalty
# NB: Scope:caliph needs to be set before this effect is called
scripted_effect fp3_yearly_2040_religious_desertion_effect = {
	every_held_county = {
		limit = { faith.religious_head = scope:caliph }
		add_county_modifier = {
			modifier = fp3_religious_desertion_modifier
			years = 5
		}
	}
}

# Commander of the Faithful (The Army of Ya'qub ibn Laith)
# As the Caliph, if someone is warring you and has counties that obey you as their HOF, then you have the option of pleading with their army to stand down
fp3_yearly.2040 = {
	type = character_event
	title = fp3_yearly.2040.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					any_character_war = {
						primary_attacker = { faith.religion = religion:islam_religion }
					}
				}
				desc = fp3_yearly.2040.desc_attacker_is_muslim
			}
			desc = fp3_yearly.2040.desc_attacker_is_not_muslim
		}
	}
	theme = martial
	override_background = {
		reference = terrain_scope
	}
	left_portrait = {
		character = scope:infidel
		animation = war_attacker
	}
	cooldown = { years = 5 }
	
	trigger = {
		has_fp3_dlc_trigger = yes
		# Below triggers are similar to is_available_adult but without is_in_army
		is_adult = yes
		is_alive = yes
		exists = location
		is_imprisoned = no
		has_contagious_deadly_disease_trigger = no
		NOT = { has_trait = incapable }
		NOT = { has_variable = gone_adventuring }
		NOT = { has_character_flag = planning_an_activity }
		faith.religion = religion:islam_religion
		is_at_war_as_defender = yes
		any_character_war = {
			primary_defender = root
			primary_attacker = {
				exists = location
				fp3_yearly_2040_attackers_provinces_respect_caliph = yes
			}
		}
	}

	immediate = {
		save_scope_as = caliph
		if = {
			limit = { exists = cp:councillor_court_chaplain }
			cp:councillor_court_chaplain = { save_scope_as = imam }
		}
		random_character_war = {
			limit = {
				primary_defender = root
				primary_attacker = {
					exists = location
					fp3_yearly_2040_attackers_provinces_respect_caliph = yes
				}
			}
			primary_attacker = {
				save_scope_as = infidel
				location = { save_scope_as = background_terrain_scope } # For event_bg
			}
		}
	}

	option = { # Make a plea
		name = fp3_yearly.2040.a
		flavor = fp3_yearly.2040.a.flavor
		duel = {
			skill = learning
			target = scope:infidel

			70 = { # Shouldn't be too difficult to succeed
				desc = fp3_yearly.2040.a_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -55
					max = 35
				}
				# More pious caliphs should be able to succeed more easily
				modifier = {
					add = {
						value = piety_level
						subtract = 1
					}
				}
				modifier = {
					add = {
						value = num_virtuous_traits
					}
				}
				scope:infidel = {
					# If the attacker is a player, notify them of the penalty they just suffered
					if = {
						limit = { is_ai = no }
						trigger_event = fp3_yearly.2041
						show_as_tooltip = { fp3_yearly_2040_religious_desertion_effect = yes } # tt only, the actual effect happens in fp3_yearly.2041
					}
					else = {
						fp3_yearly_2040_religious_desertion_effect = yes 
					}
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = fp3_yearly.2040.a_success
					left_icon = scope:infidel
					reverse_add_opinion = {
						target = scope:infidel
						modifier = fp3_sabotaged_me
					}
				}
			}
			30 = {
				desc = fp3_yearly.2040.a_failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -35
					max = 55
				}
				modifier = {
					add = {
						value = piety_level
						subtract = 1
						multiply = -1
					}
				}
				modifier = {
					add = {
						value = num_sinful_traits
					}
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = fp3_yearly.2040.a_failure
					left_icon = root
					add_prestige = medium_prestige_loss
					increase_wounds_effect = { REASON = piteously_cut_down }
				}
			}
		}
		stress_impact = {
			craven = major_stress_impact_gain
			shy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 0.5
			}
			# Add only negative % chance due to shyness
			modifier = {
				add = {
					value = ai_sociability
					multiply = -1
					max = 0
				}
			}
			# Is the caliph's or imam's learning higher?
			compare_modifier = {
				target = scope:imam
				value = learning
				multiplier = -5
			}
		}
	}

	option = { # Have your imam make a plea. Ignores your own learning/piety
		name = fp3_yearly.2040.b
		flavor = fp3_yearly.2040.b.flavor
		trigger = { exists = scope:imam }
		scope:imam = {
			duel = {
				skill = learning
				target = scope:infidel
				
				60 = { # Harder for your imam to succeed
					desc = fp3_yearly.2040.b_success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 2.5
						min = -55
						max = 35
					}
					scope:infidel = {
						# If the attacker is a player, notify them of this huge penalty
						if = {
							limit = { is_ai = no }
							trigger_event = fp3_yearly.2041
							show_as_tooltip = { fp3_yearly_2040_religious_desertion_effect = yes } # tt only, the actual effect happens in fp3_yearly.2041
						}
						else = {
							fp3_yearly_2040_religious_desertion_effect = yes 
						}
					}
					scope:caliph = {
						send_interface_toast = {
							type = event_toast_effect_good
							title = fp3_yearly.2040.b_success
							left_icon = scope:infidel
							reverse_add_opinion = {
								target = scope:infidel
								modifier = fp3_sabotaged_me
							}
						}
					}
				}
				40 = { # Is killed
					desc = fp3_yearly.2040.b_failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -2.5
						min = -35
						max = 55
					}
					scope:caliph = {
						send_interface_toast = {
							type = event_toast_effect_bad
							title = fp3_yearly.2040.b_failure
							left_icon = scope:imam
							scope:imam = { death = { death_reason = death_piteously_cut_down } }
						}
					}
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = 0.5
			}
			# Is the caliph's or imam's learning higher?
			compare_modifier = {
				target = scope:imam
				value = learning
				multiplier = 5
			}
		}
	}

	option = { # Do nothing
		name = fp3_yearly.2040.c
		stress_impact = {
			brave = major_stress_impact_gain
			vengeful = minor_stress_impact_gain
			wrathful = medium_stress_impact_gain
			zealous = major_stress_impact_gain
		}
		ai_chance = {
			base = 0 # Should be low, we want the AI to take the other two options
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_energy = -1
			}
		}
	}
}

# Commander of the Faithful: Attacker Version
# The Caliph has asked your armies to stand down and they complied!
fp3_yearly.2041 = {
	type = character_event
	title = fp3_yearly.2040.t
	desc = {
		first_valid = {
			triggered_desc = {
				# You do not respect the caliph
				trigger = {
					OR = {
						has_trait = cynical
						faith.religious_head != scope:caliph
					}
				}
				desc = fp3_yearly.2041.desc_cynical
			}
			desc = fp3_yearly.2041.desc_fallback
		}
	}
	theme = martial
	override_background = {
		reference = terrain_scope
	}
	left_portrait = {
		character = scope:caliph
		animation = war_defender
	}

	immediate = {
		fp3_yearly_2040_religious_desertion_effect = yes
		scope:caliph.location = { save_scope_as = background_terrain_scope }
	}

	option = { # Curse them!
		name = fp3_yearly.2041.a
	}
}

# Futuwaa Lodges: Check if root has any valid members of futuwaa lodges. If so, trigger ongoing_futuwaa_lodges_events
fp3_yearly.2050 = {
	hidden = yes

	immediate = {
		every_courtier = {
			limit = { fp3_is_valid_futuwaa_member = { SPONSOR = root } }
			add_to_list = futuwaa_members
		}
		house ?= {
			every_house_member = {
				limit = {
					fp3_is_valid_futuwaa_member = { SPONSOR = root }
					NOT = { is_courtier_of = root }
				}
				add_to_list = futuwaa_members
			}
		}
		if = {
			limit = { any_in_list = { list = futuwaa_members } }
			trigger_event = { on_action = ongoing_futuwaa_lodges_events }
		}
	}
}

# Futuwaa Lodges: Prowess skill increased
fp3_yearly.2051 = {
	hidden = yes

	# This event is more likely to trigger if you have more futuwaa members
	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = list_size:futuwaa_members
				subtract = 1
			}
		}
	}

	immediate = {
		random_in_list = {
			list = futuwaa_members
			weight = {
				base = 1
				# Unskilled members are more likely to have their stats improved
				modifier = {
					add = {
						value = prowess
						multiply = -0.1
					}
				}
				# Virtuous members are more likely to benefit
				modifier = {
					add = {
						value = num_virtuous_traits
						subtract = num_sinful_traits
					}
				}
				# Martial members are more likely to... you get the idea
				modifier = {
					OR = {
						has_focus = education_martial
						has_education_martial_trigger = yes
					}
					add = 2
				}
				# AI energy (Diligent, lazy, etc.)
				modifier = {
					ai_energy <= high_negative_ai_value
					add = -2
				}
				modifier = {
					ai_energy >= high_positive_ai_value
					add = 2
				}
			}
			save_scope_as = improved_youth
		}
		send_interface_message = {
			type = event_martial_good
			title = fp3_yearly.2050.t
			left_icon = scope:improved_youth
			scope:improved_youth = { add_prowess_skill = 2 }
		}
	}
}

# Futuwaa Lodges: Martial skill increased (martial focus only)
fp3_yearly.2052 = {
	hidden = yes

	trigger = {
		any_in_list = {
			list = futuwaa_members
			OR = {
				has_focus = education_martial
				has_education_martial_trigger = yes
			}
		}
	}

	# This event is more likely to trigger if you have more futuwaa members
	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = list_size:futuwaa_members
				subtract = 1
			}
		}
	}

	immediate = {
		random_in_list = {
			list = futuwaa_members
			weight = {
				base = 1
				# Unskilled members are more likely to have their stats improved
				modifier = {
					add = {
						value = martial
						multiply = -0.1
					}
				}
				# Virtuous members are more likely to benefit
				modifier = {
					add = {
						value = num_virtuous_traits
						subtract = num_sinful_traits
					}
				}
				# AI energy (Diligent, lazy, etc.)
				modifier = {
					ai_energy <= high_negative_ai_value
					add = -2
				}
				modifier = {
					ai_energy >= high_positive_ai_value
					add = 2
				}
			}
			save_scope_as = improved_youth
		}
		send_interface_message = {
			type = event_martial_good
			title = fp3_yearly.2050.t
			left_icon = scope:improved_youth
			scope:improved_youth = { add_martial_skill = 2 }
		}
	}
}

# Futuwaa Lodges: Virtuous trait added
fp3_yearly.2053 = {
	hidden = yes

	trigger = {
		any_in_list = {
			list = futuwaa_members
			number_of_personality_traits < childhood_personality_trait_gain_limit
		}
	}

	# This event is more likely to trigger if you have more futuwaa members
	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = list_size:futuwaa_members
				subtract = 1
			}
		}
	}

	immediate = {
		random_in_list = {
			list = futuwaa_members
			weight = {
				base = 1
				# More zealous members are more likely to benefit (and vice versa)
				modifier = {
					add = {
						value = ai_zeal
						divide = 100
					}
				}
			}
			save_scope_as = improved_youth
		}
		# Choose a random virtue to give the youth
		# I know... there is no better way to do this
		random_list = {
			# Brave
			1 = {
				trigger = {
					faith = { trait_is_virtue = brave }
					scope:improved_youth = {
						NOR = {
							has_trait = brave
							has_trait = craven
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:brave
				}
			}
			# Craven
			1 = {
				trigger = {
					faith = { trait_is_virtue = craven }
					scope:improved_youth = {
						NOR = {
							has_trait = brave
							has_trait = craven
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:craven
				}
			}
			# Calm
			1 = {
				trigger = {
					faith = { trait_is_virtue = calm }
					scope:improved_youth = {
						NOR = {
							has_trait = calm
							has_trait = wrathful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:calm
				}
			}
			# Wrathful
			1 = {
				trigger = {
					faith = { trait_is_virtue = wrathful }
					scope:improved_youth = {
						NOR = {
							has_trait = calm
							has_trait = wrathful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:wrathful
				}
			}
			# Chaste
			1 = {
				trigger = {
					faith = { trait_is_virtue = chaste }
					scope:improved_youth = {
						NOR = {
							has_trait = chaste
							has_trait = lustful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:chaste
				}
			}
			# Lustful
			1 = {
				trigger = {
					faith = { trait_is_virtue = lustful }
					scope:improved_youth = {
						NOR = {
							has_trait = chaste
							has_trait = lustful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:lustful
				}
			}
			# Content
			1 = {
				trigger = {
					faith = { trait_is_virtue = content }
					scope:improved_youth = {
						NOR = {
							has_trait = content
							has_trait = ambitious
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:content
				}
			}
			# Ambitious
			1 = {
				trigger = {
					faith = { trait_is_virtue = ambitious }
					scope:improved_youth = {
						NOR = {
							has_trait = content
							has_trait = ambitious
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:ambitious
				}
			}
			# Diligent
			1 = {
				trigger = {
					faith = { trait_is_virtue = diligent }
					scope:improved_youth = {
						NOR = {
							has_trait = diligent
							has_trait = lazy
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:diligent
				}
			}
			# Lazy
			1 = {
				trigger = {
					faith = { trait_is_virtue = lazy }
					scope:improved_youth = {
						NOR = {
							has_trait = diligent
							has_trait = lazy
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:lazy
				}
			}
			# Fickle
			1 = {
				trigger = {
					faith = { trait_is_virtue = fickle }
					scope:improved_youth = {
						NOR = {
							has_trait = fickle
							has_trait = stubborn
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:fickle
				}
			}
			# Stubborn
			1 = {
				trigger = {
					faith = { trait_is_virtue = stubborn }
					scope:improved_youth = {
						NOR = {
							has_trait = fickle
							has_trait = stubborn
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:stubborn
				}
			}
			# Forgiving
			1 = {
				trigger = {
					faith = { trait_is_virtue = forgiving }
					scope:improved_youth = {
						NOR = {
							has_trait = forgiving
							has_trait = vengeful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:forgiving
				}
			}
			# Vengeful
			1 = {
				trigger = {
					faith = { trait_is_virtue = vengeful }
					scope:improved_youth = {
						NOR = {
							has_trait = forgiving
							has_trait = vengeful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:vengeful
				}
			}
			# Generous
			1 = {
				trigger = {
					faith = { trait_is_virtue = generous }
					scope:improved_youth = {
						NOR = {
							has_trait = generous
							has_trait = greedy
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:generous
				}
			}
			# Greedy
			1 = {
				trigger = {
					faith = { trait_is_virtue = greedy }
					scope:improved_youth = {
						NOR = {
							has_trait = generous
							has_trait = greedy
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:greedy
				}
			}
			# Gregarious
			1 = {
				trigger = {
					faith = { trait_is_virtue = gregarious }
					scope:improved_youth = {
						NOR = {
							has_trait = gregarious
							has_trait = shy
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:gregarious
				}
			}
			# Shy
			1 = {
				trigger = {
					faith = { trait_is_virtue = shy }
					scope:improved_youth = {
						NOR = {
							has_trait = gregarious
							has_trait = shy
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:shy
				}
			}
			# Honest
			1 = {
				trigger = {
					faith = { trait_is_virtue = honest }
					scope:improved_youth = {
						NOR = {
							has_trait = honest
							has_trait = deceitful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:honest
				}
			}
			# Deceitful
			1 = {
				trigger = {
					faith = { trait_is_virtue = deceitful }
					scope:improved_youth = {
						NOR = {
							has_trait = honest
							has_trait = deceitful
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:deceitful
				}
			}
			# Humble
			1 = {
				trigger = {
					faith = { trait_is_virtue = humble }
					scope:improved_youth = {
						NOR = {
							has_trait = humble
							has_trait = arrogant
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:humble
				}
			}
			# Arrogant
			1 = {
				trigger = {
					faith = { trait_is_virtue = arrogant }
					scope:improved_youth = {
						NOR = {
							has_trait = humble
							has_trait = arrogant
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:arrogant
				}
			}
			# Just
			1 = {
				trigger = {
					faith = { trait_is_virtue = just }
					scope:improved_youth = {
						NOR = {
							has_trait = just
							has_trait = arbitrary
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:just
				}
			}
			# Arbitrary
			1 = {
				trigger = {
					faith = { trait_is_virtue = arbitrary }
					scope:improved_youth = {
						NOR = {
							has_trait = just
							has_trait = arbitrary
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:arbitrary
				}
			}
			# Patient
			1 = {
				trigger = {
					faith = { trait_is_virtue = patient }
					scope:improved_youth = {
						NOR = {
							has_trait = patient
							has_trait = impatient
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:patient
				}
			}
			# Impatient
			1 = {
				trigger = {
					faith = { trait_is_virtue = impatient }
					scope:improved_youth = {
						NOR = {
							has_trait = patient
							has_trait = impatient
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:impatient
				}
			}
			# Temperate
			1 = {
				trigger = {
					faith = { trait_is_virtue = temperate }
					scope:improved_youth = {
						NOR = {
							has_trait = temperate
							has_trait = gluttonous
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:temperate
				}
			}
			# Gluttonous
			1 = {
				trigger = {
					faith = { trait_is_virtue = gluttonous }
					scope:improved_youth = {
						NOR = {
							has_trait = temperate
							has_trait = gluttonous
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:gluttonous
				}
			}
			# Trusting
			1 = {
				trigger = {
					faith = { trait_is_virtue = trusting }
					scope:improved_youth = {
						NOR = {
							has_trait = trusting
							has_trait = paranoid
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:trusting
				}
			}
			# Paranoid
			1 = {
				trigger = {
					faith = { trait_is_virtue = paranoid }
					scope:improved_youth = {
						NOR = {
							has_trait = trusting
							has_trait = paranoid
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:paranoid
				}
			}
			# Zealous
			1 = {
				trigger = {
					faith = { trait_is_virtue = zealous }
					scope:improved_youth = {
						NOR = {
							has_trait = zealous
							has_trait = cynical
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:zealous
				}
			}
			# Cynical
			1 = {
				trigger = {
					faith = { trait_is_virtue = cynical }
					scope:improved_youth = {
						NOR = {
							has_trait = zealous
							has_trait = cynical
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:cynical
				}
			}
			# Compassionate
			1 = {
				trigger = {
					faith = { trait_is_virtue = compassionate }
					scope:improved_youth = {
						NOR = {
							has_trait = compassionate
							has_trait = callous
							has_trait = sadistic
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:compassionate
				}
			}
			# Callous
			1 = {
				trigger = {
					faith = { trait_is_virtue = callous }
					scope:improved_youth = {
						NOR = {
							has_trait = compassionate
							has_trait = callous
							has_trait = sadistic
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:callous
				}
			}
			# Sadistic
			1 = {
				trigger = {
					faith = { trait_is_virtue = sadistic }
					scope:improved_youth = {
						NOR = {
							has_trait = compassionate
							has_trait = callous
							has_trait = sadistic
						}
					}
				}
				save_scope_value_as = {
					name = virtuous_trait
					value = flag:sadistic
				}
			}
		}
		send_interface_message = {
			type = event_martial_good
			title = fp3_yearly.2050.t
			left_icon = scope:improved_youth
			scope:improved_youth = {
				if = {
					limit = { scope:virtuous_trait = flag:brave }
					add_trait = brave
				}
				if = {
					limit = { scope:virtuous_trait = flag:craven }
					add_trait = craven
				}
				if = {
					limit = { scope:virtuous_trait = flag:calm }
					add_trait = calm
				}
				if = {
					limit = { scope:virtuous_trait = flag:wrathful }
					add_trait = wrathful
				}
				if = {
					limit = { scope:virtuous_trait = flag:chaste }
					add_trait = chaste
				}
				if = {
					limit = { scope:virtuous_trait = flag:lustful }
					add_trait = lustful
				}
				if = {
					limit = { scope:virtuous_trait = flag:content }
					add_trait = content
				}
				if = {
					limit = { scope:virtuous_trait = flag:ambitious }
					add_trait = ambitious
				}
				if = {
					limit = { scope:virtuous_trait = flag:diligent }
					add_trait = diligent
				}
				if = {
					limit = { scope:virtuous_trait = flag:lazy }
					add_trait = lazy
				}
				if = {
					limit = { scope:virtuous_trait = flag:fickle }
					add_trait = fickle
				}
				if = {
					limit = { scope:virtuous_trait = flag:stubborn }
					add_trait = stubborn
				}
				if = {
					limit = { scope:virtuous_trait = flag:forgiving }
					add_trait = forgiving
				}
				if = {
					limit = { scope:virtuous_trait = flag:vengeful }
					add_trait = vengeful
				}
				if = {
					limit = { scope:virtuous_trait = flag:generous }
					add_trait = generous
				}
				if = {
					limit = { scope:virtuous_trait = flag:greedy }
					add_trait = greedy
				}
				if = {
					limit = { scope:virtuous_trait = flag:gregarious }
					add_trait = gregarious
				}
				if = {
					limit = { scope:virtuous_trait = flag:shy }
					add_trait = shy
				}
				if = {
					limit = { scope:virtuous_trait = flag:honest }
					add_trait = honest
				}
				if = {
					limit = { scope:virtuous_trait = flag:deceitful }
					add_trait = deceitful
				}
				if = {
					limit = { scope:virtuous_trait = flag:humble }
					add_trait = humble
				}
				if = {
					limit = { scope:virtuous_trait = flag:arrogant }
					add_trait = arrogant
				}
				if = {
					limit = { scope:virtuous_trait = flag:just }
					add_trait = just
				}
				if = {
					limit = { scope:virtuous_trait = flag:arbitrary }
					add_trait = arbitrary
				}
				if = {
					limit = { scope:virtuous_trait = flag:patient }
					add_trait = patient
				}
				if = {
					limit = { scope:virtuous_trait = flag:impatient }
					add_trait = impatient
				}
				if = {
					limit = { scope:virtuous_trait = flag:temperate }
					add_trait = temperate
				}
				if = {
					limit = { scope:virtuous_trait = flag:gluttonous }
					add_trait = gluttonous
				}
				if = {
					limit = { scope:virtuous_trait = flag:trusting }
					add_trait = trusting
				}
				if = {
					limit = { scope:virtuous_trait = flag:paranoid }
					add_trait = paranoid
				}
				if = {
					limit = { scope:virtuous_trait = flag:zealous }
					add_trait = zealous
				}
				if = {
					limit = { scope:virtuous_trait = flag:cynical }
					add_trait = cynical
				}
				if = {
					limit = { scope:virtuous_trait = flag:compassionate }
					add_trait = compassionate
				}
				if = {
					limit = { scope:virtuous_trait = flag:callous }
					add_trait = callous
				}
				if = {
					limit = { scope:virtuous_trait = flag:sadistic }
					add_trait = sadistic
				}
			}
		}
	}
}

# Madrasas: Check if root has any valid members of madrasas. If so, trigger ongoing_madrasas_events
fp3_yearly.2060 = {
	hidden = yes

	immediate = {
		every_courtier = {
			limit = { fp3_is_valid_madrasa_pupil = { SPONSOR = root } }
			add_to_list = madrasa_pupils
		}
		house ?= {
			every_house_member = {
				limit = {
					fp3_is_valid_madrasa_pupil = { SPONSOR = root }
					NOT = { is_courtier_of = root }
				}
				add_to_list = madrasa_pupils
			}
		}

		if = {
			limit = { any_in_list = { list = madrasa_pupils } }
			trigger_event = { on_action = ongoing_madrasas_events }
		}
	}
}

# Madrasas: Learning skill increased
fp3_yearly.2061 = {
	hidden = yes

	# This event is more likely to trigger if you have more madrasa pupils
	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = list_size:madrasa_pupils
				subtract = 1
			}
		}
	}

	immediate = {
		random_in_list = {
			list = madrasa_pupils
			weight = {
				base = 1
				# Skilled members are more likely to have their stats improved
				modifier = {
					add = {
						value = learning
						multiply = 0.1
					}
				}
				# Learning education members are more likely to gain more learning
				modifier = {
					has_focus = education_learning
					add = 2
				}
				# AI energy (Diligent, lazy, etc.)
				modifier = {
					ai_energy <= high_negative_ai_value
					add = -2
				}
				modifier = {
					ai_energy >= high_positive_ai_value
					add = 2
				}
			}
			save_scope_as = improved_youth
		}
		send_interface_message = {
			type = event_learning_good
			title = {
				first_valid = {
					# Call them madrasas if our capital is advanced enough
					triggered_desc = {
						trigger = {
							capital_county ?= {
								development_level >= bad_development_level
							}
						}
						desc = fp3_yearly.2060.t_madrasas
					}
					# Otherwise just say that the youth are being educated in houses of worship
					desc = fp3_yearly.2060.t_houses_of_worship
				}
			}
			left_icon = scope:improved_youth
			scope:improved_youth = { add_learning_skill = 2 }
		}
	}
}

# Madrasas: Physician experience gain
fp3_yearly.2062 = {
	hidden = yes

	# This event is more likely to trigger if you have more futuwaa members
	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = list_size:madrasa_pupils
				subtract = 1
			}
		}
	}

	immediate = {
		random_in_list = {
			list = madrasa_pupils
			weight = {
				base = 1
				# Members w/high learning are more likely to gain physician experience
				modifier = {
					add = {
						value = learning
						multiply = 0.1
					}
				}
				# AI energy (Diligent, lazy, etc.)
				modifier = {
					ai_energy <= high_negative_ai_value
					add = -2
				}
				modifier = {
					ai_energy >= high_positive_ai_value
					add = 2
				}
			}
			save_scope_as = improved_youth
		}
		send_interface_message = {
			type = event_learning_good
			# "Madrasas" vs "Schooling in Mosques"
			title = {
				first_valid = {
					# Call them madrasas if our capital is advanced enough
					triggered_desc = {
						trigger = {
							capital_county ?= {
								development_level >= bad_development_level
							}
						}
						desc = fp3_yearly.2060.t_madrasas
					}
					# Otherwise just say that the youth are being educated in houses of worship
					desc = fp3_yearly.2060.t_houses_of_worship
				}
			}
			left_icon = scope:improved_youth
			scope:improved_youth = {
				if = {
					limit = { has_trait = lifestyle_physician }
					add_trait_xp = {
						trait = lifestyle_physician
						value = {
							integer_range = {
								min = 5
								max = 10
							}
						}
					}
				}
				else = { add_trait = lifestyle_physician }
			}
		}
	}
}
