﻿###EK NOTE: Removed references to vanilla religions

namespace = yearly

### Yearly Events 5
# 5001, 5008 - Catching Lover and Spouse fighting, by Flavio Verna
# 5010, 5011 - Vassal jealous of helpful vassal, by Flavio Verna
# 5020/5024 - Councilor offers to help heir, by Flavio Verna
# 5030 - Powerful Vassal offers to reveal secret of other Powerful Vassal to liege, by Flavio Verna
# 5040/5043 - Two unimportant courtiers caught talking about powerful vassal, by Flavio Verna
# 5050/5054 - Spouse is slighted by courtier, by Flavio Verna

#yearly.8000 - # Vassal offers liege a gift, by Alexander Oltner
#yearly.8100 - # The peasantry of a Domain province gives you a gift, by Alexander Oltner
#yearly.8200 - # Your realm priest offers you part of a large donation, by Alexander Oltner
#yearly.8300 - # A group of vassals collectively wish to contribute to your war effort, by Alexander Oltner
#yearly.8400 - # Discover that a guest is a deviant, by Alexander Oltner

# 9020 - Elephant gift, by Emil Tisander

#######################
# by Flavio Verna
#######################

scripted_trigger yearly_5001_valid_spouse_trigger = {
	is_available_ai = yes
	is_adult = yes
}

scripted_trigger yearly_5001_valid_lover_trigger = {
	always = yes
	is_available_ai = yes
	is_adult = yes
	is_courtier_of = root
	NOT = { is_consort_of = root }
}

scripted_trigger yearly_5001_can_be_jealous_of_trigger = {
	# Must have a reason to be jealous of the target.
	is_attracted_to_gender_of = root
	OR = {
		has_personality_malicious_trigger = yes
		has_relation_rival = $TARGET$
	}

	# Can't be jealous of ourselves!
	NOT = { this = $TARGET$ }

	# Polyamorous characters are explicitly non-jealous.
	NOT = { faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active } }
}

yearly.5001 = {
	type = character_event
	title = yearly.5001.t
	desc = {
		first_valid = { #Hearing familiar voices, attacker makes first move...
			triggered_desc = {
				trigger = {
					has_character_flag = flag_bickering_duel
				}
				desc = yearly.5001.duelling.desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_bickering_intrigue
				}
				desc = yearly.5001.backstabbing.desc
			}
		}
		first_valid = { #...determine who wins.
			triggered_desc = {
				trigger = {
					has_character_flag = flag_bickering_duel
					scope:bickering_attacker = { this = scope:bickering_winner }
				}
				desc = yearly.5001.duelling.attackerwins.desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_bickering_intrigue
					scope:bickering_attacker = { this = scope:bickering_winner }
				}
				desc = yearly.5001.backstabbing.attackerwins.desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_bickering_duel
					scope:bickering_defender = { this = scope:bickering_winner }
				}
				desc = yearly.5001.duelling.defenderwins.desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_bickering_intrigue
					scope:bickering_defender = { this = scope:bickering_winner }
				}
				desc = yearly.5001.backstabbing.defenderwins.desc
			}
		}
		first_valid = { #...determine who wins.
			triggered_desc = {
				trigger = {
					scope:bickering_winner = { has_relation_lover = root }
				}
				desc = yearly.5001.lover.epilogue.desc
			}
			triggered_desc = {
				trigger = {
					any_spouse = { this = scope:bickering_winner }
				}
				desc = yearly.5001.spouse.epilogue.desc
			}
		}
	}
	theme = seduction
	left_portrait = {
		character = scope:bickering_spouse
		animation = rage
	}
	right_portrait = {
		character = scope:bickering_lover
		animation = anger
	}

	trigger = {
		NOT = {
			has_character_flag = flag_yearly_5001_cooldown
		}
		is_adult = yes
		is_available = yes
		is_married = yes
		num_of_relation_lover >= 1
		OR = {
			AND = { #Either the spouse starts the fuss...
				any_relation = {
					type = lover
					yearly_5001_valid_lover_trigger = yes
					save_temporary_scope_as = bickering_defender_tmp
				}
				any_spouse = {
					yearly_5001_valid_spouse_trigger = yes
					yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_defender_tmp }
				}
			}
			AND = { #...Or the lover does.
				any_spouse = {
					yearly_5001_valid_spouse_trigger = yes
					save_temporary_scope_as = bickering_defender_tmp
				}
				any_relation = {
					type = lover
					yearly_5001_valid_lover_trigger = yes
					yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_defender_tmp }
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {  #Attractive ruler more likely to be sought after.
			value = attraction
			offset = medium_positive_attraction
			multiplier = 0.02
		}
	}

	immediate = {
		save_scope_as = scoped_ruler
		# Determine who goes on the offense.
		hidden_effect = {
			add_character_flag = {
				flag = flag_yearly_5001_cooldown
				days = 7200
			}
			if = {
				limit = { # Lover tries to go first (more drama).
					any_spouse = {
						yearly_5001_valid_spouse_trigger = yes
						save_temporary_scope_as = bickering_target_spouse
					}
					any_relation = {
						type = lover
						yearly_5001_valid_lover_trigger = yes
						yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_target_spouse }
						#always = no
					}
				}
				random_spouse = {
					limit = {
						yearly_5001_valid_spouse_trigger = yes
						save_temporary_scope_as = bickering_target_spouse
						root = {					
							any_relation = {
								type = lover
								yearly_5001_valid_lover_trigger = yes
								yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_target_spouse }
							}
						}
					}
					save_scope_as = bickering_spouse
					save_scope_as = bickering_defender
				}
				random_relation = {
					type = lover
					limit = {
						yearly_5001_valid_lover_trigger = yes
						yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_defender }
					}
					save_scope_as = bickering_lover
					save_scope_as = bickering_attacker
				}
			}
			else = { # Else spouse goes.
				random_relation = {
					type = lover
					limit = {
						yearly_5001_valid_lover_trigger = yes
						save_temporary_scope_as = bickering_target_lover
						root = {
							any_spouse = {
								yearly_5001_valid_spouse_trigger = yes
								yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_target_lover }
							}
						}
					}
					save_scope_as = bickering_lover
					save_scope_as = bickering_defender
				}
				random_spouse = {
					limit = {
						yearly_5001_valid_spouse_trigger = yes
						yearly_5001_can_be_jealous_of_trigger = { TARGET = scope:bickering_defender }
					}
					save_scope_as = bickering_spouse
					save_scope_as = bickering_attacker
				}
			}

			#Now determine who wins the fight.
			if = {
				limit = { #If soldier, starts duel...
					scope:bickering_attacker = { has_trait = education_martial }
				}
				add_character_flag = {
					flag = flag_bickering_duel
					days = 3650
				}
				scope:bickering_attacker = {
					duel = {
						skill = prowess
						target = scope:bickering_defender
						10 = {
							compare_modifier = {
								value = scope:duel_value
								multiplier = 1
							}
							save_scope_as = bickering_winner
							scope:bickering_defender = { save_scope_as = bickering_loser }
						}
						10 = {
							compare_modifier = {
								value = scope:duel_value
								multiplier = -0.5
							}
							save_scope_as = bickering_loser
							scope:bickering_defender = { save_scope_as = bickering_winner }
						}
					}
				}
			}

			else = { #...else uses poison.
				add_character_flag = {
					flag = flag_bickering_intrigue
					days = 3650
				}
				scope:bickering_attacker = {
					duel = {
						skill = intrigue
						target = scope:bickering_defender
						10 = {
							compare_modifier = {
								value = scope:duel_value
								multiplier = 1
							}
							save_scope_as = bickering_winner
							scope:bickering_defender = { save_scope_as = bickering_loser }
						}
						10 = {
							compare_modifier = {
								value = scope:duel_value
								multiplier = -0.5
							}
							save_scope_as = bickering_loser
							scope:bickering_defender = { save_scope_as = bickering_winner }
						}
					}
				}
			}
		}

		#Spouse death notification would be redundant.
		add_character_flag = {
			flag = knows_of_spouse_death_flag
			days = 15
		}
		add_death_event_blocker_effect = {
			DEAD = scope:bickering_loser
		}

		#Loser is killed.
		scope:bickering_loser = {
			death = {
				death_reason = death_murder
				killer = scope:bickering_winner
			}
		}

		# Winner gets murder secret
		scope:bickering_winner = {
			add_secret = {
				type = secret_murder
				target = scope:bickering_loser
			}
		}
	}

	# Keep secret, forgive.
	# Keep secret, reject. (attacker won)
	# Keep secret, gain hook. (callous)
	# Expose secret, reject.
	# Expose secret, marry. (defender lover won)
	# Expose secret, comfort. (defender won)
	# Expose secret, imprison. (just)
	# Keep secret, rekindled. (sadist)

	option = { #Forgive and forget.
		name = {
			trigger = {
				has_trait = forgiving
				scope:bickering_winner = { this = scope:bickering_spouse }
			}
			text = yearly.5001.a.a.spouse
		}
		name = {
			trigger = {
				has_trait = forgiving
				scope:bickering_winner = { this = scope:bickering_lover }
			}
			text = yearly.5001.a.a.lover
		}
		name = {
			trigger = {
				scope:bickering_winner = { this = scope:bickering_spouse }
				OR = {
					has_trait = sadistic
					has_trait = callous
				}
			}
			text = yearly.5001.a.b.spouse
		}
		name = {
			trigger = {
				scope:bickering_winner = { this = scope:bickering_lover }
				OR = {
					has_trait = sadistic
					has_trait = callous
				}
			}
			text = yearly.5001.a.b.lover
		}
		name = {
			trigger = {
				scope:bickering_winner = { this = scope:bickering_spouse }
			}
			text = yearly.5001.a.c.spouse
		}
		name = {
			trigger = {
				scope:bickering_winner = { this = scope:bickering_lover }
			}
			text = yearly.5001.a.c.lover
		}
		if = {
			limit = {
				scope:bickering_winner = { this = scope:bickering_attacker }
			}
			scope:bickering_winner = {
				add_opinion = {
					target = root
					modifier = forgiven_opinion
				}
			}
		}
		if = {
			limit = {
				scope:bickering_winner = { this = scope:bickering_defender }
			}
			scope:bickering_winner = {
				add_opinion = {
					target = root
					modifier = comforted_opinion
				}
			}
		}
		stress_impact = {
			honest = minor_stress_impact_gain
			just = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		hidden_effect = { #Regret
			if = {
				limit = {
					scope:bickering_winner = { stress > high_stress this = scope:bickering_attacker }
				}
				scope:bickering_winner = {
					add_character_flag = {
						flag = flag_bickering_winner_was_forgiven
						days = 365
					}
					trigger_event = { id = yearly.5002 days = 180 }
				}
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 100
				ai_vengefulness = -50
			}
		}
	}

	option = { #Keep quiet, but reject.
		name = yearly.5001.b
		trigger = {
			scope:bickering_winner = { this = scope:bickering_attacker }
		}
		if = {
			limit = {
				scope:bickering_winner = { has_relation_lover = root }
			}
			remove_relation_lover = scope:bickering_winner
		}
		if = {
			limit = {
				NOT = { scope:bickering_winner = { has_relation_lover = root } }
			}
			add_opinion = {
				target = scope:bickering_winner
				modifier = rejected_opinion
			}
			scope:bickering_winner = {
				add_opinion = {
					target = root
					modifier = rejected_opinion
				}
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		hidden_effect = { #Regret
			if = {
				limit = {
					scope:bickering_winner = { stress > high_stress this = scope:bickering_attacker }
				}
				scope:bickering_winner = {
					trigger_event = { id = yearly.5002 days = 180 }
				}
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -50
				ai_vengefulness = -50
				ai_honor = -100
			}
		}
	}

	option = { #Keep quiet, grant hook.
		name = yearly.5001.c
		trigger = {
			scope:bickering_winner = { this = scope:bickering_attacker }
			has_trait = callous
		}
		trait = callous
		if = {
			limit = {
				scope:bickering_winner = { has_relation_lover = root }
			}
			remove_relation_lover = scope:bickering_winner
		}
		scope:bickering_winner = {
			add_opinion = {
				target = root
				modifier = blackmailing_me_opinion
			}
		}
		scope:bickering_winner = {
			random_secret = {
				limit = {
					secret_type = secret_murder
					secret_target = scope:bickering_loser
				}
				reveal_to = root
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
		}
		hidden_effect = { #Regret
			if = {
				limit = {
					scope:bickering_winner = { stress > high_stress this = scope:bickering_attacker }
				}
				scope:bickering_winner = {
					trigger_event = { id = yearly.5002 days = 180 }
				}
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -50
				ai_vengefulness = 50
				ai_honor = -100
			}
		}
	}

	option = { #Expose and reject.
		name = yearly.5001.d
		trigger = {
			scope:bickering_winner = { this = scope:bickering_attacker }
		}
		scope:bickering_winner = {
			random_secret = {
				limit = {
					secret_type = secret_murder
					secret_target = scope:bickering_loser
				}
				expose_secret = prev
			}
		}
		if = {
			limit = {
				scope:bickering_winner = { has_relation_lover = root }
			}
			remove_relation_lover = scope:bickering_winner
		}
		if = {
			limit = {
				NOT = { scope:bickering_winner = { has_relation_lover = root } }
			}
			add_opinion = {
				target = scope:bickering_winner
				modifier = rejected_opinion
			}
			scope:bickering_winner = {
				add_opinion = {
					target = root
					modifier = rejected_opinion
				}
			}
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -50
				ai_vengefulness = 100
				ai_honor = 100
			}
		}
	}

	option = { #Expose attempt, marry surviving lover. (defender won)
		name = yearly.5001.e
		trigger = {
			scope:bickering_winner = {
				this = scope:bickering_defender
				can_marry_trigger = yes
				#To account for a person marrying their concubines
				trigger_if = {
					limit = {
						is_concubine = yes
					}
					is_concubine_of = root
				}
			}
			OR = {
				AND = {
					is_female = yes
					scope:bickering_winner = { is_female = no }
				}
				AND = {
					is_female = no
					scope:bickering_winner = { is_female = yes }
				}
			}
		}
		scope:bickering_winner = {
			add_opinion = {
				target = root
				modifier = comforted_opinion
			}
		}
		if = {
			limit = { is_female = no }
			root = { marry = scope:bickering_winner }
		}
		if = {
			limit = { is_female = yes }
			root = { marry_matrilineal = scope:bickering_winner }
		}
		scope:bickering_loser = {
			if = {
				limit = {
					exists = scope:bickering_loser.dynasty
					NOT = { dynasty = root.dynasty }
				}
				dynasty = { add_dynasty_prestige = major_dynasty_prestige_loss }
			}
			else = {
				every_close_family_member = {
					limit = {
						NOT = { this = scope:bickering_winner }
					}
					add_opinion = {
						target = root
						modifier = smeared_opinion
					}
				}
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 100
				ai_vengefulness = 50
				ai_honor = -50
			}
		}
	}

	option = { #Expose attempt, comfort. (defender won)
		name = yearly.5001.f
		trigger = {
			scope:bickering_winner = { this = scope:bickering_defender }
		}
		scope:bickering_winner = {
			add_opinion = {
				target = root
				modifier = comforted_opinion
			}
		}
		scope:bickering_loser = {
			if = {
				limit = {
					exists = dynasty
					NOT = { dynasty = root.dynasty }
				}
				dynasty = { add_dynasty_prestige = major_dynasty_prestige_loss }
			}
			else = {
				every_close_family_member = {
						limit = {
							NOT = { this = scope:bickering_winner }
						}
					add_opinion = {
						target = root
						modifier = smeared_opinion
					}
				}
			}
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 50
				ai_vengefulness = 100
				ai_honor = 50
			}
		}
	}

	option = { #Expose and imprison.
		name = yearly.5001.g
		trigger = {
			OR = {
				has_trait = just
				scope:bickering_winner = { this = scope:bickering_lover }
			}
		}
		trait = just
		scope:bickering_winner = {
			random_secret = {
				limit = {
					secret_type = secret_murder
					secret_target = scope:bickering_loser
				}
				expose_secret = prev
			}
		}
		imprison = {
			target = scope:bickering_winner
			type = dungeon
		}
		if = {
			limit = {
				scope:bickering_winner = { has_relation_lover = root }
			}
			remove_relation_lover = scope:bickering_winner
		}
		if = {
			limit = {
				NOT = { scope:bickering_winner = { has_relation_lover = root } }
			}
			add_opinion = {
				target = scope:bickering_winner
				modifier = rejected_opinion
			}
			scope:bickering_winner = {
				add_opinion = {
					target = root
					modifier = rejected_opinion
				}
			}
		}
		stress_impact = {
			deceitful = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -50
				ai_vengefulness = 100
				ai_honor = 100
			}
		}
	}
	option = { #Sadist is intrigued.
		name = yearly.5001.i
		trigger = {
			has_trait = sadistic
		}
		trait = sadistic
		if = {
			limit = {
				can_set_relation_lover_trigger = { CHARACTER = scope:bickering_winner }
			}
			set_relation_lover = { reason = lover_murdered_lover target = scope:bickering_winner involved_character = scope:bickering_loser }
		}
		hidden_effect = { #Escalation
			if = {
				limit = {
					scope:bickering_winner = { this = scope:bickering_attacker has_trait = sadistic }
				}
				scope:bickering_winner = {
					trigger_event = { id = yearly.5007 days = 180 }
				}
			}
		}
		ai_chance = {
			base = 30
			modifier = {
				add = 40
				has_trait = lustful
			}
		}
	}

	#Clean flags
	after = {
		hidden_effect = {
			remove_character_flag = flag_bickering_duel
			remove_character_flag = flag_bickering_intrigue
		}
	}
}

#Bickering_winner regrets murder.
yearly.5002 = {
	type = character_event
	title = yearly.5002.t
	desc = {
		first_valid = { #Check who it was.
			triggered_desc = {
				trigger = {
					this = scope:bickering_spouse
				}
				desc = yearly.5002.spouse.desc
			}
			triggered_desc = {
				trigger = {
					this = scope:bickering_lover
				}
				desc = yearly.5002.lover.desc
			}
		}
		first_valid = { #Check if murder was forgiven.
			triggered_desc = {
				trigger = {
					root = { has_character_flag = flag_bickering_winner_was_forgiven }
				}
				desc = yearly.5002.forgiven.desc
			}
			triggered_desc = {
				trigger = {
					NOT = { root = { has_character_flag = flag_bickering_winner_was_forgiven } }
				}
				desc = yearly.5002.unforgiven.desc
			}
		}
	}
	theme = seduction
	left_portrait = {
		character = scope:bickering_loser
		animation = sadness
	}
	right_portrait = {
		character = scope:scoped_ruler
		animation = shame
	}

	trigger = {
		is_adult = yes
		is_available = yes
		stress >= low_stress
	}

	# Endure stress.
	# Go to monastery.
	# Suicide.

	option = {
		name = yearly.5002.a
		show_as_tooltip = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		hidden_effect = { #Inform ruler.
			scope:scoped_ruler = {
				trigger_event = { id = yearly.5003 }
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_rationality = 100
				ai_honor = -100
			}
		}
	}
	option = {
		name = yearly.5002.b
		trigger = {
			faith = { has_doctrine = tenet_monasticism }
			NOT = { has_trait = devoted }
		}
		show_as_tooltip = {
			if = {
				limit = { is_married = yes }
				add_character_modifier = {
					modifier = rejected_from_marriage_bed_modifier
				}
			}
			add_trait = devoted
		}
		hidden_effect = { #Inform ruler.
			scope:scoped_ruler = {
				trigger_event = { id = yearly.5006 }
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_rationality = -50
				ai_honor = 50
			}
		}
	}
	option = {
		name = yearly.5002.c
		trigger = {
			has_trait = depressed
		}
		trait = depressed_1
		trait = depressed_genetic
		death = { death_reason = death_suicide }
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_rationality = -150
			}
		}
	}
}

#Witness notified of stress.
yearly.5003 = {
	type = character_event
	title = yearly.5002.t
	desc = {
		first_valid = { #Check who it was.
			triggered_desc = {
				trigger = {
					scope:bickering_winner = scope:bickering_spouse
				}
				desc = yearly.5003.spouse.desc
			}
			triggered_desc = {
				trigger = {
					scope:bickering_winner = scope:bickering_lover
				}
				desc = yearly.5003.lover.desc
			}
		}
		first_valid = { #Check if murder was forgiven.
			triggered_desc = {
				trigger = {
					scope:bickering_winner = { has_character_flag = flag_bickering_winner_was_forgiven }
				}
				desc = yearly.5003.forgiven.desc
			}
			triggered_desc = {
				trigger = {
					NOT = { scope:bickering_winner = { has_character_flag = flag_bickering_winner_was_forgiven } }
				}
				desc = yearly.5003.unforgiven.desc
			}
		}
	}
	theme = seduction
	left_portrait = {
		character = scope:bickering_winner
		animation = worry
	}
	right_portrait = {
		character = scope:bickering_loser
		animation = sadness
	}

	# Comfort.
	# Do nothing.
	# Sadist twists knife.

	option = { #Comfort.
		name = yearly.5003.a
		trigger = {
			NOT = { scope:bickering_winner = { has_character_flag = flag_bickering_winner_was_forgiven } }
		}
		scope:bickering_winner = {
			add_opinion = {
				target = root
				modifier = comforted_opinion
			}
		}
		if = { #If secret known, forget it.
			limit = {
				scope:bickering_winner = {
					any_secret = {
						is_known_by = root
						secret_owner = root
						secret_type = secret_murder
						secret_target = scope:bickering_loser
					}
				}
			}
			scope:bickering_winner = {
				random_secret = {
					limit = {
						is_known_by = root
						secret_owner = root
						secret_type = secret_murder
						secret_target = scope:bickering_loser
					}
					remove_secret = yes
				}
			}
		}
		if = {
			limit = {
				has_hook = scope:bickering_winner
			}
			remove_hook = { target = scope:bickering_winner }
		}
		stress_impact = {
			just = minor_stress_impact_gain
			callous = major_stress_impact_gain
			sadistic = major_stress_impact_gain
		}
		hidden_effect = { #Inform bickering_winner.
			scope:bickering_winner = {
				trigger_event = { id = yearly.5004 }
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 100
				ai_honor = 50
			}
		}
	}
	option = { #Do nothing.
		name = {
			trigger = { scope:bickering_winner = { has_character_flag = flag_bickering_winner_was_forgiven } }
			text = yearly.5003.b.forgiven
		}
		name = {
			trigger = { NOT = { scope:bickering_winner = { has_character_flag = flag_bickering_winner_was_forgiven } } }
			text = yearly.5003.b.forgotten
		}
		name = {
			trigger = {
				NOT = { scope:bickering_winner = { has_character_flag = flag_bickering_winner_was_forgiven } }
				has_trait = callous
			}
			text = yearly.5003.b.callous
		}
		scope:bickering_winner = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		ai_chance = {
			base = 0
		}
	}
	option = { #Sadistic.
		name = yearly.5003.c
		trigger = {
			has_trait = sadistic
		}
		trait = sadistic
		stress_impact = {
			just = minor_stress_impact_gain
		}
		scope:bickering_winner = {
			stress_impact = {
				base = major_stress_impact_gain
			}
		}
		hidden_effect = { #Inform bickering_winner.
			scope:bickering_winner = {
				trigger_event = { id = yearly.5005 }
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_honor = -0.25
			}
		}
	}
	#Clean flags
	after = {
		hidden_effect = {
			scope:bickering_winner = {
				remove_character_flag = flag_bickering_winner_was_forgiven
			}
		}
	}
}

#Bickering_winner is comforted.
yearly.5004 = {
	type = character_event
	title = yearly.5002.t
	desc = yearly.5004.desc
	theme = seduction
	left_portrait = {
		character = scope:scoped_ruler
		animation = personality_compassionate
	}
	right_portrait = {
		character = scope:bickering_loser
		animation = sadness
	}

	option = {
		name = yearly.5004.a
		show_as_tooltip = {
			stress_impact = {
				base = medium_stress_impact_loss
			}
		}
	}
}

#Bickering_winner is shamed.
yearly.5005 = {
	type = character_event
	title = yearly.5002.t
	desc = yearly.5005.desc
	theme = seduction
	left_portrait = {
		character = scope:scoped_ruler
		animation = shame
	}
	right_portrait = {
		character = scope:bickering_loser
		animation = sadness
	}

	option = {
		name = yearly.5005.a
		show_as_tooltip = {
			stress_impact = {
				base = major_stress_impact_gain
			}
		}
	}
}

#Witness notified of vows.
yearly.5006 = {
	type = character_event
	title = yearly.5002.t
	desc = {
		first_valid = { #Check who it was.
			triggered_desc = {
				trigger = {
					scope:bickering_winner = scope:bickering_spouse
				}
				desc = yearly.5003.spouse.desc
			}
			triggered_desc = {
				trigger = {
					scope:bickering_winner = scope:bickering_lover
				}
				desc = yearly.5003.lover.desc
			}
			desc = yearly.5006.epilogue.desc
		}
	}
	theme = seduction
	left_portrait = {
		character = scope:bickering_winner
		animation = shame
	}
	right_portrait = {
		character = scope:bickering_loser
		animation = sadness
	}

	option = {
		name = {
			trigger = {
				OR = {
					has_trait = just
					has_trait = zealous
					has_trait = forgiving
				}
			}
			text = yearly.5006.b.forgiven
		}
		name = {
			trigger = {
				OR = {
					has_trait = arbitrary
					has_trait = lustful
					has_trait = vengeful
				}
			}
			text = yearly.5006.b.upset
		}
		name = {
			trigger = {
				NOR = {
					has_trait = just
					has_trait = zealous
					has_trait = forgiving
					has_trait = arbitrary
					has_trait = lustful
					has_trait = vengeful
				}
			}
			text = yearly.5006.b.default
		}
		scope:bickering_winner = {
			if = {
				limit = { is_married = yes }
				add_character_modifier = {
					modifier = rejected_from_marriage_bed_modifier
				}
			}
			if = {
				limit = { has_relation_lover = root }
				remove_relation_lover = scope:bickering_winner
			}
			add_trait = devoted
		}
		stress_impact = {
		  	lustful = medium_stress_impact_gain
		}
	}
}

#Bickering_winner wants to kill again.
yearly.5007 = {
	type = character_event
	title = yearly.5007.t
	desc = yearly.5007.desc
	theme = intrigue
	left_portrait = {
		character = scope:scoped_ruler
		animation = shock
	}
	right_portrait = {
		character = scope:bickering_loser
		animation = sadness
	}

	option = {
		name = yearly.5007.a
		custom_tooltip = yearly.5007.a.tt
		show_as_tooltip = {
			add_opinion = {
				target = scope:scoped_ruler
				modifier = murder_partner_opinion
			}
		}
		hidden_effect = {
			scope:scoped_ruler = {
				trigger_event = { id = yearly.5008 }
			}
		}
		ai_chance = {
			factor = 100
		}
	}
	option = {
		name = yearly.5007.b
		ai_chance = {
			factor = 0
		}
	}
}

#Witness notified.
yearly.5008 = {
	type = character_event
	title = yearly.5007.t
	desc = yearly.5008.desc
	theme = intrigue
	left_portrait = {
		character = scope:bickering_winner
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:bickering_loser
		animation = shock
	}

	option = {
		name = yearly.5008.a
		scope:bickering_winner = {
			add_opinion = {
				target = root
				modifier = murder_partner_opinion
			}
		}
		add_opinion = {
			target = root
			modifier = murder_partner_opinion
		}
		stress_impact = {
		  	compassionate = minor_stress_impact_gain
		  	forgiving = minor_stress_impact_gain
		  	craven = minor_stress_impact_gain
		}
		ai_chance = {
			factor = 100
		}
	}
	option = {
		name = yearly.5008.b
		show_as_tooltip = {
			scope:bickering_winner = {
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -40
				}
				stress_impact = {
				  	sadistic = medium_stress_impact_gain
				}
			}
		}
		stress_impact = {
		  	sadistic = medium_stress_impact_gain
		}
		hidden_effect = {
			scope:bickering_winner = {
				send_interface_message = {
					type = event_diplomacy_bad
					left_icon = scope:bickering_loser
					right_icon = scope:scoped_ruler
					title = yearly.5009.desc
					add_opinion = {
						target = scope:scoped_ruler
						modifier = angry_opinion
						opinion = -40
					}
					stress_impact = {
					  	sadistic = medium_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			factor = 0
		}
	}
}

#######################################

scripted_trigger bickering_vassal_1_yearly_5010_trigger = {
	is_available_ai_adult = yes
	has_personality_benevolent_trigger = yes
	is_powerful_vassal = yes
	can_set_relation_friend_trigger = { CHARACTER = root }
}

scripted_trigger bickering_vassal_2_yearly_5010_trigger = {
	is_available_ai_adult = yes
	is_powerful_vassal = yes
}

#Vassal shows compassion to stressed/sick ruler, incurs the jealousy of another vassal.
yearly.5010 = {
	type = character_event
	title = yearly.5010.t
	desc = yearly.5010.desc
	theme = intrigue
	left_portrait = {
		character = scope:bickering_vassal_1
		animation = dismissal
	}
	right_portrait = {
		character = scope:bickering_vassal_2
		animation = disgust
	}

	trigger = {
		NOT = {
			has_character_flag = flag_yearly_5010_cooldown
		}
		is_adult = yes
		is_available = yes
		OR = {
			stress > high_medium_stress
			has_treatable_disease_trigger = yes
			any_character_war = {
				OR = {
					using_cb = independence_faction_war
					using_cb = liberty_faction_war
					using_cb = peasant_war
					using_cb = claimant_faction_war
					using_cb = depose_war
					using_cb = refused_liege_demand_war
				}
			}
		}
		any_vassal = {
			bickering_vassal_1_yearly_5010_trigger = yes
			save_temporary_scope_as = potential_compassionate_vassal
		}
		any_vassal = {
			bickering_vassal_2_yearly_5010_trigger = yes
			NOT = { this = scope:potential_compassionate_vassal }
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {  #Prestigious ruler more likely to be fought over.
			value = prestige
			offset = massive_prestige_value
			multiplier = 0.01
		}
		modifier = { #More likely if the second vassal is actually a friend/lover.
			add = 0.3
			any_vassal = {
				bickering_vassal_1_yearly_5010_trigger = yes
				save_temporary_scope_as = potential_compassionate_vassal
			}
			any_vassal = {
				bickering_vassal_2_yearly_5010_trigger = yes
				NOT = { this = scope:potential_compassionate_vassal }
				OR = {
					has_relation_lover = root
					has_relation_friend = root
				}
			}
		}
	}

	immediate = {
		hidden_effect = {
			add_character_flag = {
				flag = flag_yearly_5010_cooldown
				days = 7200
			}
			random_vassal = { #Pick compassionate vassal.
				limit = {
					save_temporary_scope_as = potential_compassionate_vassal
					bickering_vassal_1_yearly_5010_trigger = yes
					root = {
						any_vassal = {
							bickering_vassal_2_yearly_5010_trigger = yes
							NOT = { this = scope:potential_compassionate_vassal }
							save_temporary_scope_as = potential_angry_vassal
						}
						NOT = {
							has_hook_of_type = {
								target = scope:potential_compassionate_vassal
								type = favor_hook
							}
						}
					}
					reverse_opinion = {
						target = scope:potential_angry_vassal
						value <= 0
					}
				}
				alternative_limit = {
					bickering_vassal_1_yearly_5010_trigger = yes
				}
				save_scope_as = bickering_vassal_1
			}
			random_vassal = {
				limit = {
					bickering_vassal_2_yearly_5010_trigger = yes
					NOT = { this = scope:bickering_vassal_1 }
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
				alternative_limit = {
					bickering_vassal_2_yearly_5010_trigger = yes
					opinion = {
						target = scope:potential_compassionate_vassal
						value <= 0
					}
					NOT = { this = scope:bickering_vassal_1 }
					opinion = {
						target = root
						value >= 20
					}
				}
				alternative_limit = {
					bickering_vassal_2_yearly_5010_trigger = yes
					NOT = { this = scope:bickering_vassal_1 }
				}
				save_scope_as = bickering_vassal_2
			}
		}
	}

	# Accept Friendship offer.
	# Midway solution. (diplomacy duel)
	# Refuse Friendship offer.
	# Manipulate vassals. (intrigue duel)

	option = { #Accept new Friendship offer.
		name = yearly.5010.a
		set_relation_friend = { reason = friend_councel_and_aid target = scope:bickering_vassal_1 }

		if = {
			limit = {
				can_add_hook = {
					target = scope:bickering_vassal_1
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:bickering_vassal_1
				type = favor_hook
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:bickering_vassal_1
				modifier = grateful_opinion
				opinion = 25
			}
		}
		
		if = {
			limit = {
				scope:bickering_vassal_1 = { has_relation_rival = root }
			}
			scope:bickering_vassal_2 = {
				add_opinion = {
					target = root
					modifier = insulted_opinion
				}
			}
		}
		else_if = {
			limit = {
				scope:bickering_vassal_1 = { NOR = { has_relation_friend = root has_relation_rival = root } }
			}
			set_relation_rival = {
				target = scope:bickering_vassal_2
				reason = rival_bickering
			}
		}
		else_if = {
			limit = {
				scope:bickering_vassal_1 = { has_relation_friend = root }
			}
			remove_relation_friend = scope:bickering_vassal_2
		}
		stress_impact = {
			base = medium_stress_impact_loss
			fickle = minor_stress_impact_loss
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 100
				ai_honor = -100
			}
		}
	}
	option = { #Midway solution (diplomatic duel)
		name = yearly.5010.b
		duel = {
			skill = diplomacy
			value = medium_skill_rating
			10 = { #Success.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				desc = tooltip.5010.b.success
				send_interface_toast = {
					left_icon = scope:bickering_vassal_1
					right_icon = scope:bickering_vassal_2
					title = tooltip.5010.b.success
					scope:bickering_vassal_1 = {
						add_opinion = {
							target = root
							modifier = befriended_opinion
						}
					}
					if = {
						limit = {
							scope:bickering_vassal_1 = { has_relation_rival = scope:bickering_vassal_2 }
						}
						scope:bickering_vassal_1 = { remove_relation_rival = scope:bickering_vassal_2 }
					}
					hidden_effect = {
						add_opinion = {
							target = scope:bickering_vassal_1
							modifier = befriended_opinion
						}
					 	scope:bickering_vassal_1 = {
							add_opinion = {
								target = scope:bickering_vassal_2
								modifier = befriended_opinion
							}
						}
					 	scope:bickering_vassal_2 = {
							add_opinion = {
								target = scope:bickering_vassal_1
								modifier = befriended_opinion
							}
						}
					}
					scope:bickering_vassal_2 = {
						add_opinion = {
							target = root
							modifier = pacified_opinion
						}
					}
					add_diplomacy_skill = 1
					add_prestige = medium_prestige_gain
					stress_impact = {
						base = medium_stress_impact_loss
						just = minor_stress_impact_loss
						impatient = minor_stress_impact_gain
					}
				}
			}
			10 = { #Fail.
				desc = tooltip.5010.b.fail
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.75
				}
				send_interface_toast = {
					left_icon = scope:bickering_vassal_1
					right_icon = scope:bickering_vassal_2
					title = tooltip.5010.b.fail
					add_prestige = minor_prestige_loss
				}
			}
			5 = { #Critical fail.
				desc = tooltip.5010.b.critfail
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				send_interface_toast = {
					left_icon = scope:bickering_vassal_1
					right_icon = scope:bickering_vassal_2
					title = tooltip.5010.b.critfail
					scope:bickering_vassal_1 = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -25
						}
					}
					scope:bickering_vassal_2 = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -25
						}
					}
				}
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_boldness = -100
				ai_rationality = 50
				ai_honor = 100
			}
		}
	}
	option = { #Refuse Friendship offer.
		name = yearly.5010.c
		scope:bickering_vassal_1 = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
			}
		}
		scope:bickering_vassal_2 = {
			add_opinion = {
				target = root
				modifier = scheme_followed_my_advice_opinion
			}
		}
		add_dread = minor_dread_loss
		stress_impact = {
			base = medium_stress_impact_loss
			just = minor_stress_impact_loss
			fickle = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -50
			}
		}
	}
	option = { #Push vassals into fighting each other.
		name = yearly.5010.d
		trigger = {
			scope:bickering_vassal_1 = {
				OR = {
					AND = {
						is_female = no
						liege = {
							OR = {
								has_realm_law = male_only_law
								has_realm_law = male_preference_law
							}
						}
					}
					AND = {
						is_female = yes
						liege = {
							OR = {
								has_realm_law = female_only_law
								has_realm_law = female_preference_law
							}
						}
					}
				}
			}
			scope:bickering_vassal_2 = {
				OR = {
					AND = {
						is_female = no
						liege = {
							OR = {
								has_realm_law = male_only_law
								has_realm_law = male_preference_law
							}
						}
					}
					AND = {
						is_female = yes
						liege = {
							OR = {
								has_realm_law = female_only_law
								has_realm_law = female_preference_law
							}
						}
					}
				}
			}
		}
		duel = {
			skill = intrigue
			value = decent_skill_rating
			7 = { #Success.
				desc = tooltip.5010.d.vassalsfight
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				custom_tooltip = tooltip.5010.d.vassalsfight.effect
				hidden_effect = {
					trigger_event = yearly.5011
				}
			}
			10 = { #Fail.
				desc = tooltip.5010.d.vassalsfightfail
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				send_interface_toast = {
					left_icon = scope:bickering_vassal_1
					right_icon = scope:bickering_vassal_2
					title = tooltip.5010.d.vassalsfightfail
					add_prestige = minor_prestige_loss
					scope:bickering_vassal_1 = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -25
						}
					}
					scope:bickering_vassal_2 = {
						add_opinion = {
							target = root
							modifier = angry_opinion
							opinion = -25
						}
					}
				}
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			deceitful = minor_stress_impact_loss
			sadistic = medium_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = -125
			}
		}
	}
}

#Vassals were tricked into dueling each other.
yearly.5011 = {
	type = character_event
	title = yearly.5010.t
	desc = yearly.5011.desc
	theme = intrigue
	left_portrait = {
		character = scope:bickering_vassal_1
		animation = anger
	}
	right_portrait = {
		character = scope:bickering_vassal_2
		animation = rage
	}

	immediate = {
		hidden_effect = {
			scope:bickering_vassal_1 = {
				duel = {
					skill = prowess
					target = scope:bickering_vassal_2
					10 = {
						compare_modifier = {
							value = scope:duel_value
							multiplier = 1
						}
						save_scope_as = bickering_vassal_winner
						scope:bickering_vassal_2 = { save_scope_as = bickering_vassal_loser }
					}
					10 = {
						compare_modifier = {
							value = scope:duel_value
							multiplier = -0.5
						}
						save_scope_as = bickering_vassal_loser
						scope:bickering_vassal_2 = {
							save_scope_as = bickering_vassal_winner
						}
					}
				}
			}
		}
		scope:bickering_vassal_loser = { #Loser is killed.
			death = {
				death_reason = death_duel
				killer = scope:bickering_vassal_winner
			}
		}
	}

	# Take winner as lover.
	# Befriend winner.
	# Fickle refusal.

	option = {
		name = yearly.5011.a.new
		trigger = {
			has_relation_potential_lover = scope:bickering_vassal_winner
			can_set_relation_lover_trigger = { CHARACTER = scope:bickering_vassal_winner }
		}
		set_relation_lover = { reason = lover_slew_other_vassal target = scope:bickering_vassal_winner involved_character = scope:bickering_vassal_loser }
		ai_chance = {
			base = 40
		}
	}

	option = {
		name = {
			trigger = { scope:bickering_vassal_winner = { this = scope:bickering_vassal_1 } }
			text = yearly.5011.b.new
		}
		name = {
			trigger = { scope:bickering_vassal_winner = { this = scope:bickering_vassal_2 } }
			text = yearly.5011.b.old
		}
		if = {
			limit = {
				scope:bickering_vassal_winner = {
					can_set_relation_friend_trigger = { CHARACTER = root }
				}
			}
			set_relation_friend = { reason = friend_slew_other_vassal target = scope:bickering_vassal_winner involved_character = scope:bickering_vassal_loser }
		}
		else = {
			root = {
				scope:bickering_vassal_winner = {
					add_opinion = {
						target = root
						modifier = strengthened_friendship_opinion
					}
				}
				add_opinion = {
					target = scope:bickering_vassal_winner
					modifier = strengthened_friendship_opinion
				}
			}
		}
		ai_chance = {
			base = 0
		}
	}
	option = { #Fickle
		name = yearly.5011.c
		trigger = {
			has_trait = fickle
		}
		trait = fickle
		add_dread = minor_dread_gain
		add_prestige = minor_prestige_gain
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 0
		}
	}
}

#######################################

#Councilor offers to teach heir.
yearly.5020 = {
	type = letter_event
	opening = {
		desc = yearly.5020.opening
	}
	desc = {
		desc = yearly.5020.intro.desc
		first_valid = { #Age flavor.
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { age >= scope:scoped_heir.age }
				}
				desc = yearly.5020.older.desc
			}
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { age <= scope:scoped_heir.age }
				}
				desc = yearly.5020.younger.desc
			}
		}
		first_valid = { #Check what councillor is offering help.
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { has_council_position = councillor_chancellor }
				}
				desc = yearly.5020.chancellor.desc
			}
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { has_council_position = councillor_marshal }
				}
				desc = yearly.5020.marshal.desc
			}
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { has_council_position = councillor_steward }
				}
				desc = yearly.5020.steward.desc
			}
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { has_council_position = councillor_spymaster }
				}
				desc = yearly.5020.spymaster.desc
			}
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { has_council_position = councillor_court_chaplain }
				}
				desc = yearly.5020.court_chaplain.desc
			}
			triggered_desc = {
				trigger = {
					scope:helpful_councillor = { is_kurultai_trigger = yes }
				}
				desc = yearly.5020.kurultai.desc
			}
		}
	}
	sender = scope:helpful_councillor
	cooldown = { years = 20 }
	trigger = {
		is_adult = yes
		is_available = yes
		OR = {
			AND = {
				exists = cp:councillor_chancellor
				cp:councillor_chancellor = {
					is_available_ai = yes
					diplomacy > high_skill_rating
				}
			}
			AND = {
				exists = cp:councillor_marshal
				cp:councillor_marshal = {
					is_available_ai = yes
					martial > high_skill_rating
				}
			}
			AND = {
				exists = cp:councillor_steward
				cp:councillor_steward = {
					is_available_ai = yes
					stewardship > high_skill_rating
				}
			}
			AND = {
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = {
					is_available_ai = yes
					intrigue > high_skill_rating
				}
			}
			AND = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_available_ai = yes
					learning > high_skill_rating
				}
			}
			AND = {
				any_court_position_holder = {
					type = second_camp_officer
					is_available_ai = yes
					OR = {
						diplomacy > high_skill_rating
						martial > high_skill_rating
						stewardship > high_skill_rating
						intrigue > high_skill_rating
						learning > high_skill_rating
					}
				}
			}
			any_councillor = {
				is_kurultai_trigger = yes
				is_available_ai = yes
				OR = {
					diplomacy > high_skill_rating
					martial > high_skill_rating
					stewardship > high_skill_rating
					intrigue > high_skill_rating
					learning > high_skill_rating
				}
			}
		}
		exists = player_heir.liege
		player_heir = {
			is_available_ai = yes
			is_child_of = root
			age >= 12
			liege = root
			NOR = {
				age >= 35
				diplomacy > high_skill_rating
				martial > high_skill_rating
				stewardship > high_skill_rating
				intrigue > high_skill_rating
				learning > high_skill_rating
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		hidden_effect = {
			random_court_position_holder = {
				type = second_camp_officer
				limit = {
					is_available_ai = yes
					OR = {
						diplomacy > high_skill_rating
						martial > high_skill_rating
						stewardship > high_skill_rating
						intrigue > high_skill_rating
						learning > high_skill_rating
					}
				}
				save_scope_as = high_skilled_second
			}
			if = {
				limit = {
					has_any_kurultai_trigger = yes
				}
				random_councillor = {
					limit = {
						is_kurultai_trigger = yes
						is_available_ai = yes
						OR = {
							diplomacy > high_skill_rating
							martial > high_skill_rating
							stewardship > high_skill_rating
							intrigue > high_skill_rating
							learning > high_skill_rating
						}
					}
					save_scope_as = high_skilled_second
				}
			}
			player_heir = {
				save_scope_as = scoped_heir
			}
			random_list = { #Pick random valid councillor first.
				10 = {
					trigger = {
						OR = {
							cp:councillor_chancellor ?= {
								is_available_ai = yes
								diplomacy > high_skill_rating
							}
							scope:high_skilled_second ?= {
								diplomacy > high_skill_rating
							}
						}
					}
					modifier = {
						add = 5
						cp:councillor_chancellor ?= { has_relation_mentor = scope:scoped_heir }
					}
					cp:councillor_chancellor ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_diplomacy
							days = 300
						}
					}
					scope:high_skilled_second ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_diplomacy
							days = 300
						}
					}
				}
				10 = {
					trigger = {
						OR = {
							cp:councillor_marshal ?= {
								is_available_ai = yes
								martial > high_skill_rating
							}
							scope:high_skilled_second ?= {
								martial > high_skill_rating
							}
						}
					}
					modifier = {
						add = 5
						cp:councillor_marshal ?= { has_relation_mentor = scope:scoped_heir }
					}
					cp:councillor_marshal ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_martial
							days = 300
						}
					}
					scope:high_skilled_second ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_martial
							days = 300
						}
					}
				}
				10 = {
					trigger = {
						OR = {
							cp:councillor_steward ?= {
								is_available_ai = yes
								stewardship > high_skill_rating
							}
							scope:high_skilled_second ?= {
								stewardship > high_skill_rating
							}
						}
					}
					modifier = {
						add = 5
						cp:councillor_steward ?= { has_relation_mentor = scope:scoped_heir }
					}
					cp:councillor_steward ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_stewardship
							days = 300
						}
					}
					scope:high_skilled_second ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_stewardship
							days = 300
						}
					}
				}
				10 = {
					trigger = {
						OR = {
							cp:councillor_spymaster ?= {
								is_available_ai = yes
								intrigue > high_skill_rating
							}
							scope:high_skilled_second ?= {
								intrigue > high_skill_rating
							}
						}
					}
					modifier = {
						add = 5
						cp:councillor_spymaster ?= {
							has_relation_mentor = scope:scoped_heir
						}
					}
					cp:councillor_spymaster ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_intrigue
							days = 300
						}
					}
					scope:high_skilled_second ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_stewardship
							days = 300
						}
					}
				}
				10 = {
					trigger = {
						OR = {
							cp:councillor_court_chaplain ?= {
								is_available_ai = yes
								learning > high_skill_rating
							}
							scope:high_skilled_second ?= {
								learning > high_skill_rating
							}
						}
					}
					modifier = {
						add = 5
						cp:councillor_court_chaplain ?= { has_relation_mentor = scope:scoped_heir }
					}
					cp:councillor_court_chaplain ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_learning
							days = 300
						}
					}
					scope:high_skilled_second ?= {
						save_scope_as = helpful_councillor
						add_character_flag = {
							flag = flag_yearly_5020_stewardship
							days = 300
						}
					}
				}
			}
			scope:helpful_councillor = { #Now determine if the councillor is genuine or not.
				if = {
					limit = { #0 chance if the councillor is the child's
						NOR = {
							exists = scope:helpful_councillor.var:treacherous_councillor
							is_parent_of = scope:scoped_heir
							has_relation_friend = scope:scoped_heir
							has_relation_lover = scope:scoped_heir
							has_relation_mentor = scope:scoped_heir
						}
					}
					random = {
						chance = 10
						modifier = {
							add = -50
							has_trait = honest
						}
						modifier = {
							add = 20
							has_trait = deceitful
						}
						modifier = {
							add = 50
							has_any_bad_relationship_with_root_trigger = yes
						}
						modifier = {
							add = 30
							has_relation_rival = scope:scoped_heir
						}
						modifier = {
							add = 40
							OR = {
								opinion = {
									target = scope:scoped_heir
									value < -20
								}
								opinion = {
									target = root
									value < -20
								}
							}
							ai_vengefulness >= medium_positive_vengefulness
						}
						scope:helpful_councillor = {
							set_variable = {
								name = treacherous_councillor
								value = yes
								days = 100
							}
						}
					}
				}
			}
		}
		if = { #Ruler might decide to do the tutoring instead.
			limit = {
				OR = {
					diplomacy > high_skill_rating
					martial > high_skill_rating
					stewardship > high_skill_rating
					intrigue > high_skill_rating
					learning > high_skill_rating
				}
			}
			hidden_effect = {
				random_list = {
					20 = {
						trigger = {
							diplomacy > high_skill_rating
						}
						add_character_flag = {
							flag = flag_5020_ruler_teaching_diplomacy
							days = 100
						}
					}
					20 = {
						trigger = {
							martial > high_skill_rating
						}
						add_character_flag = {
							flag = flag_5020_ruler_teaching_martial
							days = 100
						}
					}
					20 = {
						trigger = {
							stewardship > high_skill_rating
						}
						add_character_flag = {
							flag = flag_5020_ruler_teaching_stewardship
							days = 100
						}
					}
					20 = {
						trigger = {
							intrigue > high_skill_rating
						}
						add_character_flag = {
							flag = flag_5020_ruler_teaching_intrigue
							days = 100
						}
					}
					20 = {
						trigger = {
							learning > high_skill_rating
						}
						add_character_flag = {
							flag = flag_5020_ruler_teaching_learning
							days = 100
						}
					}
				}
			}
		}
	}

	# Allow mentoring.
	# Forbid mentoring.
	# (Paranoid) Spy on councillor.

	option = { #Allow mentoring.
		name = yearly.5020.a
		if = {
			limit = {
				has_character_flag = flag_yearly_5020_diplomacy
			}
			custom_tooltip = yearly.5020.councillor.diplomacy.tt
		}
		if = {
			limit = {
				has_character_flag = flag_yearly_5020_martial
			}
			custom_tooltip = yearly.5020.councillor.martial.tt
		}
		if = {
			limit = {
				has_character_flag = flag_yearly_5020_stewardship
			}
			custom_tooltip = yearly.5020.councillor.stewardship.tt
		}
		if = {
			limit = {
				has_character_flag = flag_yearly_5020_intrigue
			}
			custom_tooltip = yearly.5020.councillor.intrigue.tt
		}
		if = {
			limit = {
				has_character_flag = flag_yearly_5020_learning
			}
			custom_tooltip = yearly.5020.councillor.learning.tt
		}
		if = {
			limit = {
				has_hook = scope:helpful_councillor
			}
			remove_hook = {
				target = scope:helpful_councillor
			}
		}
		else_if = {
			limit = {
				NOT = { has_hook = scope:helpful_councillor }
				scope:helpful_councillor = {
					can_add_hook = {
						target = root
						type = favor_hook
					}
				}
			}
			scope:helpful_councillor = {
				add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		if = {
			limit = {
				scope:scoped_heir = { NOT = { has_relation_mentor = scope:helpful_councillor } }
			}
			scope:scoped_heir = { set_relation_mentor = scope:helpful_councillor }
		}
		custom_tooltip = yearly.5020.a.e.tt
		hidden_effect = {
			trigger_event = { id = yearly.5024 days = { 30 50 } }
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_trait = trusting
			}
			ai_value_modifier = {
				ai_compassion = 50
				ai_honor = 50
			}
		}
	}
	option = { #Forbid mentoring.
		name = {
			trigger = {
				NOR = {
					has_character_flag = flag_5020_ruler_teaching_diplomacy
					has_character_flag = flag_5020_ruler_teaching_martial
					has_character_flag = flag_5020_ruler_teaching_stewardship
					has_character_flag = flag_5020_ruler_teaching_intrigue
					has_character_flag = flag_5020_ruler_teaching_learning
				}
			}
			text = yearly.5020.b.a
		}
		name = {
			trigger = {
				OR = {
					has_character_flag = flag_5020_ruler_teaching_diplomacy
					has_character_flag = flag_5020_ruler_teaching_martial
					has_character_flag = flag_5020_ruler_teaching_stewardship
					has_character_flag = flag_5020_ruler_teaching_intrigue
					has_character_flag = flag_5020_ruler_teaching_learning
				}
			}
			text = yearly.5020.b.b
		}
		if = {
			limit = {
				OR = {
					has_character_flag = flag_5020_ruler_teaching_diplomacy
					has_character_flag = flag_5020_ruler_teaching_martial
					has_character_flag = flag_5020_ruler_teaching_stewardship
					has_character_flag = flag_5020_ruler_teaching_intrigue
					has_character_flag = flag_5020_ruler_teaching_learning
				}
			}
			hidden_effect = {
				trigger_event = { id = yearly.5025 days = { 10 30 } }
			}
		}
		if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_diplomacy
			}
			custom_tooltip = yearly.5020.ruler.diplomacy.tt
		}
		if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_martial
			}
			custom_tooltip = yearly.5020.ruler.martial.tt
		}
		if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_stewardship
			}
			custom_tooltip = yearly.5020.ruler.stewardship.tt
		}
		if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_intrigue
			}
			custom_tooltip = yearly.5020.ruler.intrigue.tt
		}
		if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_learning
			}
			custom_tooltip = yearly.5020.ruler.learning.tt
		}

		add_prestige = minor_prestige_loss
		scope:helpful_councillor = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
			}
		}
		stress_impact = {
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 10
				has_trait = paranoid
			}
		}
	}
	option = { #Allow but spy.
		name = yearly.5020.c
		if = {
			limit = {
				scope:helpful_councillor = { NOT = { has_relation_mentor = scope:scoped_heir } }
			}
			scope:helpful_councillor = { set_relation_mentor = scope:scoped_heir }
		}
		duel = {
			skill = intrigue
			target = scope:helpful_councillor
			10 = { #Successful inquiry.
				desc = tooltip.5020.c.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				custom_tooltip = tooltip.5020.c.success.effect
				hidden_effect = {
					trigger_event = { id = yearly.5021 days = { 5 15 } }
				}
			}
			10 = { #Failed inquiry.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.75
				}
				desc = tooltip.5020.c.fail
				custom_tooltip = tooltip.5020.c.fail.effect
				hidden_effect = {
					trigger_event = { id = yearly.5022 days = { 5 15 } }
				}
			}
			3 = { #Councillor discovered inquiry.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = tooltip.5020.c.critfail
				custom_tooltip = tooltip.5020.c.critfail.effect
				hidden_effect = {
					trigger_event = { id = yearly.5023 days = { 5 15 } }
				}
			}
		}
		stress_impact = {
			trusting = minor_stress_impact_gain
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 30
				has_trait = paranoid
			}
		}
	}
}

#Successfully spied on Councillor.
yearly.5021 = {
	type = character_event
	title = yearly.5020.t
	desc = {
		first_valid = { #Tell if the councillor's intentions were pure or not.
			triggered_desc = {
				trigger = {
					exists = scope:helpful_councillor.var:treacherous_councillor
				}
				desc = yearly.5021.deceitfulcouncillor.desc
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:helpful_councillor.var:treacherous_councillor }
				}
				desc = yearly.5021.honestcouncillor.desc
			}
		}
	}
	theme = intrigue
	left_portrait = {
		character = root
		animation = personality_content
	}
	right_portrait = {
		character = scope:helpful_councillor
		animation = personality_honorable
	}
	lower_right_portrait = scope:scoped_heir

	trigger = {
		scope:scoped_heir = {
			is_alive = yes
			is_available = yes
		}
		scope:helpful_councillor = {
			is_alive = yes
			is_available = yes
		}
	}

	#Allow mentoring to continue.
	#Stop mentoring.
	#Fire councillor.

	option = { #Allow mentoring to continue.
		name = yearly.5021.a
		trigger = { NOT = { exists = scope:helpful_councillor.var:treacherous_councillor } }
		custom_tooltip = yearly.5020.a.e.tt
		hidden_effect = {
			trigger_event = { id = yearly.5024 days = { 15 25 } }
		}
		ai_chance = {
			base = 10
		}
	}
	option = { #Stop mentoring.
		name = {
			trigger = { exists = scope:helpful_councillor.var:treacherous_councillor }
			text = yearly.5021.b.a
		}
		name = {
			trigger = { NOT = { exists = scope:helpful_councillor.var:treacherous_councillor } }
			text = yearly.5021.b.b
		}
		if = {
			limit = {
				scope:helpful_councillor = { has_relation_mentor = scope:scoped_heir }
			}
			scope:helpful_councillor = { remove_relation_mentor = scope:scoped_heir }
		}
		if = {
			limit = {
				exists = scope:helpful_councillor.var:treacherous_councillor
			}
			add_opinion = {
				target = scope:helpful_councillor
				modifier = angry_opinion
				opinion = -50
			}
		}
		scope:helpful_councillor = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
			}
		}
		ai_chance = {
			base = 0
		}
	}
	option = { #Fire councillor.
		name = yearly.5021.c
		trigger = {
			exists = scope:helpful_councillor.var:treacherous_councillor
			scope:helpful_councillor = {
				exists = liege
				liege = root
				OR = {
					has_council_position = councillor_chancellor
					has_council_position = councillor_marshal
					has_council_position = councillor_steward
					has_council_position = councillor_spymaster
					has_council_position = councillor_court_chaplain
				}
				can_be_fired_from_council_trigger = { COURT_OWNER = root }
			}
		}
		if = {
			limit = {
				scope:helpful_councillor = { is_councillor_of = root }
			}
			root = { fire_councillor = scope:helpful_councillor }
		}
		if = {
			limit = {
				scope:helpful_councillor = { has_relation_mentor = scope:scoped_heir }
			}
			scope:helpful_councillor = { remove_relation_mentor = scope:scoped_heir }
		}
		if = {
			limit = {
				exists = scope:helpful_councillor.var:treacherous_councillor
			}
			add_opinion = {
				target = scope:helpful_councillor
				modifier = angry_opinion
				opinion = -50
			}
		}
		scope:helpful_councillor = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
			}
		}
		ai_chance = {
			base = 60
		}
	}
}

#Failed to spy on Councillor.
yearly.5022 = {
	type = character_event
	title = yearly.5020.t
	desc = yearly.5021.honestcouncillor.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = personality_content
	}
	right_portrait = {
		character = scope:helpful_councillor
		animation = personality_honorable
	}
	lower_right_portrait = scope:scoped_heir

	trigger = {
		scope:scoped_heir = {
			is_alive = yes
			is_available = yes
		}
		scope:helpful_councillor = {
			is_alive = yes
			is_available = yes
		}
	}
	#Allow mentoring to continue.
	#Stop mentoring.

	option = { #Allow mentoring to continue.
		name = yearly.5022.a
		custom_tooltip = tooltip_yearly_5022_a
		hidden_effect = {
			trigger_event = { id = yearly.5024 days = { 15 25 } }
		}
		ai_chance = {
			base = 10
		}
	}
	option = { #Stop mentoring.
		name = yearly.5021.b.b
		if = {
			limit = {
				scope:helpful_councillor = { has_relation_mentor = scope:scoped_heir }
			}
			scope:helpful_councillor = { remove_relation_mentor = scope:scoped_heir }
		}
		scope:helpful_councillor = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
			}
		}
		ai_chance = {
			base = 0
		}
	}
}

#Councillor discovered spy.
yearly.5023 = {
	type = character_event
	title = yearly.5020.t
	desc = yearly.5023.desc
	theme = intrigue
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:helpful_councillor
		animation = disgust
	}
	lower_right_portrait = scope:scoped_heir

	trigger = {
		scope:scoped_heir = {
			is_alive = yes
			is_available = yes
		}
		scope:helpful_councillor = {
			is_alive = yes
			is_available = yes
		}
	}

	option = { #Stop mentoring.
		name = yearly.5023.a
		add_prestige = medium_prestige_loss
		if = {
			limit = {
				scope:helpful_councillor = { has_relation_mentor = scope:scoped_heir }
			}
			scope:helpful_councillor = { remove_relation_mentor = scope:scoped_heir }
		}
		scope:helpful_councillor = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
			}
		}
	}
}

#Outcome of the Chancellor's tutelage:
yearly.5024 = {
	type = character_event
	title = yearly.5020.t
	desc = {
		first_valid = { #Outcome.
			triggered_desc = {
				trigger = {
					has_character_flag = flag_5024_deceitful_councillor
				}
				desc = yearly.5024.deceitfulcouncillor.desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_5024_deadly_councillor
				}
				desc = yearly.5024.deadlycouncillor.desc
			}
			triggered_desc = {
				trigger = {
					NOR = {
						has_character_flag = flag_5024_deadly_councillor
						has_character_flag = flag_5024_deceitful_councillor
					}
				}
				desc = yearly.5024.honestcouncillor.desc
			}
		}
	}
	theme = education
	left_portrait = {
		character = scope:scoped_heir
		animation = happiness
	}
	right_portrait = {
		character = scope:helpful_councillor
		animation = personality_honorable
	}

	trigger = {
		scope:scoped_heir = {
			is_alive = yes
			is_available = yes
		}
		scope:helpful_councillor = {
			is_alive = yes
			is_available = yes
		}
	}

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					exists = scope:helpful_councillor.var:treacherous_councillor
				}
				random_list = {
					50 = {
						add_character_flag = {
							flag = flag_5024_deceitful_councillor
							days = 365
						}
					}
					25 = {
						trigger = {
							OR = {
								has_trait = sadistic
								AND = {
									has_trait = callous
									OR = {
										opinion = {
											target = scope:scoped_heir
											value < -20
										}
										opinion = {
											target = root
											value < -20
										}
									}
									ai_vengefulness >= medium_positive_vengefulness	
								}
							}
						}
						modifier = {
							add = 10
							has_council_position = councillor_spymaster
						}
						add_character_flag = {
							flag = flag_5024_deadly_councillor
							days = 365
						}
					}
				}
			}
		}
		if = {
			limit = { has_character_flag = flag_5024_deadly_councillor }
			show_as_tooltip = {
				scope:scoped_heir = {
					death = {
						death_reason = death_accident
					}
				}
			}
			hidden_effect = {
				unknown_murder_effect = { 
					VICTIM = scope:scoped_heir 
					MURDERER = scope:helpful_councillor 
					REASON = death_accident
				}
			}
		}
		else_if = {
			limit = {
				has_character_flag = flag_5024_deceitful_councillor
				NOT = { has_relation_rival = scope:scoped_heir }
			}
			set_relation_rival = {
				target = scope:scoped_heir
				reason = rival_turned_on_parent_by_tutor
			}
		}
		else_if = {
			limit = {
				has_character_flag = flag_5024_deceitful_councillor
				has_relation_rival = scope:scoped_heir
			}
			scope:scoped_heir = {
				add_opinion = {
					target = root
					modifier = hate_opinion
					opinion = -40
				}
				add_opinion = {
					target = scope:helpful_councillor
					modifier = mentored_me_opinion
				}
			}
		}
		else_if = {
			limit = {
				NOT = { exists = scope:helpful_councillor.var:treacherous_councillor }
				scope:helpful_councillor = { has_character_flag = flag_yearly_5020_diplomacy }
			}
			scope:scoped_heir = {
				add_diplomacy_skill = 2
				add_opinion = {
					target = scope:helpful_councillor
					modifier = mentored_me_opinion
				}
			}
		}
		else_if = {
			limit = {
				NOT = { exists = scope:helpful_councillor.var:treacherous_councillor }
				scope:helpful_councillor = { has_character_flag = flag_yearly_5020_martial }
			}
			scope:scoped_heir = {
				add_martial_skill = 2
				add_opinion = {
					target = scope:helpful_councillor
					modifier = mentored_me_opinion
				}
			}
		}
		else_if = {
			limit = {
				NOT = { exists = scope:helpful_councillor.var:treacherous_councillor }
				scope:helpful_councillor = { has_character_flag = flag_yearly_5020_stewardship }
			}
			scope:scoped_heir = {
				add_stewardship_skill = 2
				add_opinion = {
					target = scope:helpful_councillor
					modifier = mentored_me_opinion
				}
			}
		}
		else_if = {
			limit = {
				NOT = { exists = scope:helpful_councillor.var:treacherous_councillor }
				scope:helpful_councillor = { has_character_flag = flag_yearly_5020_intrigue }
			}
			scope:scoped_heir = {
				add_intrigue_skill = 2
				add_opinion = {
					target = scope:helpful_councillor
					modifier = mentored_me_opinion
				}
			}
		}
		else_if = {
			limit = {
				NOT = { exists = scope:helpful_councillor.var:treacherous_councillor }
				scope:helpful_councillor = { has_character_flag = flag_yearly_5020_learning }
			}
			scope:scoped_heir = {
				add_learning_skill = 2
				add_opinion = {
					target = scope:helpful_councillor
					modifier = mentored_me_opinion
				}
			}
		}
	}

	option = { #Aftermath.
		name = {
			trigger = { NOT = { exists = scope:helpful_councillor.var:treacherous_councillor } }
			text = yearly.5024.a.a
		}
		name = {
			trigger = { has_character_flag = flag_5024_deceitful_councillor }
			text = yearly.5024.a.b
		}
		name = {
			trigger = { has_character_flag = flag_5024_deadly_councillor }
			text = yearly.5024.a.c
		}
		if = {
			limit = { NOT = { exists = scope:helpful_councillor.var:treacherous_councillor } }
			add_opinion = {
				target = scope:helpful_councillor
				modifier = mentored_my_heir_opinion
			}
		}
		if = {
			limit = { has_character_flag = flag_5024_deceitful_councillor }
			add_opinion = {
				target = scope:helpful_councillor
				modifier = ruined_my_heir_opinion
			}
		}
		if = {
			limit = { has_character_flag = flag_5024_deadly_councillor }
			stress_impact = {
				base = medium_stress_impact_gain
				callous = minor_stress_impact_loss
			}
		}
	}

	option = { #Paranoid knows.
		name = yearly.5024.b
		trigger = {
			has_trait = paranoid
			scope:helpful_councillor = {
				any_secret = {
					secret_type = secret_murder
					secret_target = scope:scoped_heir
				}
			}
		}
		trait = paranoid
		
		scope:helpful_councillor = {
			random_secret = {	
				limit = {
					secret_type = secret_murder
					secret_target = scope:scoped_heir
				}
				reveal_to_without_events_effect = { CHARACTER = root }
			}
		}
	}

	after = {
		hidden_effect = {
			remove_character_flag = flag_5024_deceitful_councillor
			remove_character_flag = flag_5024_deadly_councillor
			scope:helpful_councillor = {
				remove_character_flag = flag_yearly_5020_diplomacy
				remove_character_flag = flag_yearly_5020_martial
				remove_character_flag = flag_yearly_5020_stewardship
				remove_character_flag = flag_yearly_5020_intrigue
				remove_character_flag = flag_yearly_5020_learning
			}
		}
	}
}

#Outcome of ruler's tutelage.
yearly.5025 = {
	type = character_event
	title = yearly.5020.t
	desc = {
		first_valid = { #Tell if the councillor's intentions were pure or not.
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = flag_5024_ruler_teaching_fails }
				}
				desc = yearly.5025.desc.a
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_5024_ruler_teaching_fails
				}
				desc = yearly.5025.desc.b
			}
		}
	}
	theme = education
	left_portrait = {
		character = scope:scoped_heir
		animation = happiness
	}
	right_portrait = {
		character = root
		animation = personality_honorable
	}

	trigger = {
		scope:scoped_heir = {
			is_alive = yes
			is_available = yes
		}
	}
	immediate = {
		hidden_effect = {
			random = {
				chance = 30
				modifier = {
					add = -20
					probably_intelligent_trigger = yes
				}
				modifier = {
					add = 20
					probably_unintelligent_trigger = yes
				}
				add_character_flag = {
					flag = flag_5024_ruler_teaching_fails
					days = 60
				}
			}
		}
	}

	option = {
		name = yearly.5025.a
		trigger = { NOT = { has_character_flag = flag_5024_ruler_teaching_fails } }
		if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_diplomacy
			}
			scope:scoped_heir = {
				add_diplomacy_skill = 1
			}
		}
		else_if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_martial
			}
			scope:scoped_heir = {
				add_martial_skill = 1
			}
		}
		else_if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_stewardship
			}
			scope:scoped_heir = {
				add_stewardship_skill = 1
			}
		}
		else_if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_intrigue
			}
			scope:scoped_heir = {
				add_intrigue_skill = 1
			}
		}
		else_if = {
			limit = {
				has_character_flag = flag_5020_ruler_teaching_learning
			}
			scope:scoped_heir = {
				add_learning_skill = 1
			}
		}
	}
	option = {
		name = yearly.5025.b
		trigger = { has_character_flag = flag_5024_ruler_teaching_fails }
	}
	after = {
		remove_character_flag = flag_5020_ruler_teaching_diplomacy
		remove_character_flag = flag_5020_ruler_teaching_martial
		remove_character_flag = flag_5020_ruler_teaching_stewardship
		remove_character_flag = flag_5020_ruler_teaching_intrigue
		remove_character_flag = flag_5020_ruler_teaching_learning
		remove_character_flag = flag_5024_ruler_teaching_fails
	}
}

#######################################

#Powerful Vassal offers to reveal secret of other Powerful Vassal to liege.

scripted_trigger suitable_vassal_secret_yearly_5030_trigger = {
	NOT = { is_known_by = root }
	secret_owner = scope:blackmailed_vassal
	trigger_if = {
		limit = {
			exists = secret_target
		}
		NOT = { secret_target = prev }
	}
}
scripted_trigger suitable_vassal_yearly_5030_trigger = {
	is_available_ai_adult = yes
	is_powerful_vassal = yes
	NOR = {
		any_relation = {
			type = friend
			is_powerful_vassal_of = root
		}
		any_relation = {
			type = lover
			is_powerful_vassal_of = root
		}
		has_hook = root #Because an option might give them a favor later
	}
}

yearly.5030 = {
	type = letter_event
	opening = {
		desc = yearly.5030.opening
	}
	desc = {
		first_valid = { #Intentions:
			triggered_desc = {
				trigger = {
					has_character_flag = flag_5030_earnest_vassal
				}
				desc = yearly.5030.earnestvassal.desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_5030_selfish_vassal
				}
				desc = yearly.5030.selfishvassal.desc
			}
		}
	}
	sender = {
		character = scope:squealing_vassal
		animation = shock
	}

	trigger = {
		NOT = { has_character_flag = flag_5030_cooldown }
		any_vassal = {
			suitable_vassal_yearly_5030_trigger = yes
			count >= 2
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		hidden_effect = {
			add_character_flag = {
				flag = flag_5030_cooldown
				days = 3650
			}
			#Pick powerful vassal, possibly with secret to be blackmailed with.
			random_vassal = {
				limit = {
					suitable_vassal_yearly_5030_trigger = yes
					any_relation = {
						type = rival
						is_powerful_vassal_of = root
					}
					any_secret = {
						NOT = { is_known_by = root }
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
					save_temporary_scope_as = potential_first_vassal
					root = {
						any_vassal = {
							is_powerful_vassal = yes
							opinion = {
								target = scope:potential_first_vassal
								value < -10
							}
						}
					}
					any_secret = {
						NOT = { is_known_by = root }
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
					any_secret = {
						NOT = { is_known_by = root }
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
				}
				save_scope_as = blackmailed_vassal
			}

			random_vassal = { #Then pick squealer.
				limit = {
					suitable_vassal_yearly_5030_trigger = yes
					NOT = { this = scope:blackmailed_vassal }
					has_relation_rival = scope:blackmailed_vassal
					any_known_secret = { suitable_vassal_secret_yearly_5030_trigger = yes }
					NOT = {
						has_hook_of_type = {
							target = root
							type = favor_hook
						}
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
					NOT = { this = scope:blackmailed_vassal }
					has_relation_rival = scope:blackmailed_vassal
					NOT = {
						has_hook_of_type = {
							target = root
							type = favor_hook
						}
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
					NOT = { this = scope:blackmailed_vassal }
					opinion = {
						target = scope:blackmailed_vassal
						value < -10
					}
					NOT = {
						has_hook_of_type = {
							target = root
							type = favor_hook
						}
					}
					any_known_secret = { suitable_vassal_secret_yearly_5030_trigger = yes }
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
					NOT = { this = scope:blackmailed_vassal }
					opinion = {
						target = scope:blackmailed_vassal
						value < -10
					}
					NOT = {
						has_hook_of_type = {
							target = root
							type = favor_hook
						}
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5030_trigger = yes
					NOT = { this = scope:blackmailed_vassal }
				}
				save_scope_as = squealing_vassal
			}
			#If vassals do not hate each other already, make them.
			if = {
				limit = {
					scope:blackmailed_vassal = {
					NOT = { has_relation_rival = scope:squealing_vassal }
					opinion = {
							target = scope:squealing_vassal
							value > 0
						}
					}
				}
				scope:blackmailed_vassal = {
					set_relation_rival = {
						target = scope:squealing_vassal
						reason = rival_squealing
					}
				}
			}

			if = { #Check if a secret already exists.
				limit = {
					scope:blackmailed_vassal = {
						any_secret = {
							suitable_vassal_secret_yearly_5030_trigger = yes
						}
					}
				}
				scope:blackmailed_vassal = {
					random_secret = {
						limit = {
							suitable_vassal_secret_yearly_5030_trigger = yes
						}
						save_scope_as = scoped_secret
					}
				}
			}
			else = { #Else just make up one.
				scope:blackmailed_vassal = {
					give_random_likely_secret_effect = yes
					if = {
						limit = {
							scope:blackmailed_vassal = {
								any_secret = {
									NOT = { is_known_by = scope:squealing_vassal }
									suitable_vassal_secret_yearly_5030_trigger = yes
								}
							}
						}
						scope:blackmailed_vassal = {
							random_secret = {
								limit = {
									NOT = { is_known_by = scope:squealing_vassal }
									suitable_vassal_secret_yearly_5030_trigger = yes
								}
								save_scope_as = scoped_secret
							}
						}
					}
					else = {
						set_while_counter_variable_effect = yes
						while = {
							limit = {
								NOT = { exists = scope:scoped_secret }
								var:while_counter < 5
							}
							give_random_secret_effect = yes
							increase_while_counter_variable_effect = yes
							random_secret = {
								limit = {
									NOT = { is_known_by = scope:squealing_vassal }
									suitable_vassal_secret_yearly_5030_trigger = yes
								}
								save_scope_as = scoped_secret
							}
						}
						remove_while_counter_variable_effect = yes
					}
				}
			}
			#Finally, determine if the squealer is acting selfishly or not.
			scope:squealing_vassal = {
				random_list = {
					50 = {
						opinion_modifier = {
							opinion_target = root
							min = -30
							max = 30
						}
						modifier = {
							add = 15
							has_personality_submissive_trigger = yes
						}
						root = {
							add_character_flag = {
								flag = flag_5030_earnest_vassal
								days = 365
							}
						}
					}
					50 = {
						ai_value_modifier = {
							ai_compassion = 0.5
							ai_honor = 0.25
						}
						trigger = {
							NOT = {
								has_hook_of_type = {
									target = root
									type = favor_hook
								}
							}
						}
						modifier = {
							add = 10
							has_personality_malicious_trigger = yes
						}
						root = {
							add_character_flag = {
								flag = flag_5030_selfish_vassal
								days = 365
							}
						}
					}
				}
			}
		}
	}

	#Accept Exchange
	#Intimidate Squealer

	option = { #Accept Exchange.
		trigger = {
			exists = scope:scoped_secret
		}
		name = {
			trigger = { has_character_flag = flag_5030_earnest_vassal }
			text = yearly.5030.a.a
		}
		name = {
			trigger = { has_character_flag = flag_5030_selfish_vassal }
			text = yearly.5030.a.b
		}
		custom_tooltip = yearly.5030.a.tt
		if = {
			limit = { has_character_flag = flag_5030_selfish_vassal }
			if = {
				limit = {
					has_hook = scope:squealing_vassal
				}
				remove_hook = {
					target = scope:squealing_vassal
				}
			}
			else_if = {
				limit = {
					scope:squealing_vassal = {
						can_add_hook = {
							target = root
							type = favor_hook
						}
					}
				}
				scope:squealing_vassal = {
					add_hook = {
						target = root
						type = favor_hook
					}
				}
			}
		}
		else = {
			hidden_effect = {
				add_opinion = {
					target = scope:squealing_vassal
					modifier = helpful_vassal_opinion
				}
			}
		}
		scope:blackmailed_vassal = {
			add_opinion = {
				target = root
				modifier = intrusive_liege_opinion
			}
		}
		hidden_effect = {
			send_interface_toast = {
				#type = event_intrigue_good
				left_icon = scope:blackmailed_vassal
				right_icon = scope:squealing_vassal
				title = yearly.5030.secret.desc
				scope:scoped_secret = {
					reveal_to = root
				}
			}
			if = {
				limit = {
					scope:squealing_vassal = {
						can_add_hook = {
							target = scope:blackmailed_vassal
							type = threat_hook
						}
					}
				}
				scope:squealing_vassal = {
					add_hook = {
						target = scope:blackmailed_vassal
						type = threat_hook
					}
				}
			}
		}
		stress_impact = {
			honest = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -100
				ai_vengefulness = 125
			}
		}
	}

	option = { #Intimidate Squealer.
		name = yearly.5030.c
		scope:blackmailed_vassal = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 30
			}
		}
		scope:squealing_vassal = {
			custom_tooltip = yearly.5030.c.tt
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -10
			}
		}

		stress_impact = {
			deceitful = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_honor = 100
			}
			opinion_modifier = {
				opinion_target = scope:blackmailed_vassal
			}
		}
	}

	after = {
		hidden_effect = {
			remove_character_flag = flag_5030_earnest_vassal
			remove_character_flag = flag_5030_selfish_vassal
		}
	}
}

#######################################

#Two unimportant courtiers caught talking about powerful vassal.

scripted_trigger suitable_scheme_yearly_5040_trigger = {
	hostile_scheme_trigger = yes
	is_scheme_exposed = no
	OR = {
		scheme_target_character = root
		scheme_target_character = { is_close_or_extended_family_of = root }
	}
}
scripted_trigger suitable_secret_yearly_5040_trigger = {
	NOR = {
		is_known_by = root
		secret_type = secret_lover
	}
}

scripted_trigger suitable_vassal_yearly_5040_trigger = {
	is_available_ai_adult = yes
	is_powerful_vassal = yes
	OR = {
		any_scheme = {
			suitable_scheme_yearly_5040_trigger = yes
		}
		any_secret = {
			suitable_secret_yearly_5040_trigger = yes
		}
	}
}

scripted_trigger suitable_courtier_yearly_5040_trigger = {
	is_ruler = no
	is_available_ai_adult = yes
	NOR = {
		is_of_major_interest_trigger = { CHARACTER = root }
		is_close_or_extended_family_of = root
	}
}

yearly.5040 = {
	type = character_event
	title = yearly.5040.t
	desc = yearly.5040.desc
	right_portrait = {
		character = scope:whisperer_1
		animation = paranoia
	}
	left_portrait = {
		character = scope:whisperer_2
		animation = worry
	}
	lower_left_portrait = scope:scoped_vassal

	theme = intrigue
	override_background = { reference = garden }

	trigger = {
		is_available_adult = yes
		NOT = { has_character_flag = flag_5040_cooldown }
		any_vassal = {
			is_available_ai_adult = yes
			is_powerful_vassal = yes
		}
		any_courtier = {
			suitable_courtier_yearly_5040_trigger = yes
			count >= 2
		}
	}

	weight_multiplier = {
		base = 1
		modifier = { #More likely if there is actually something to talk about.
			add = 1.5
			any_vassal = {
				suitable_vassal_yearly_5040_trigger = yes
			}
		}
	}

	immediate = {
		hidden_effect = {
			add_character_flag = {
				flag = flag_5040_cooldown
				days = 3650
			}
			random_vassal = { #The vassal the two courtiers are talking about.
				limit = {
					suitable_vassal_yearly_5040_trigger = yes
					save_temporary_scope_as = scoped_potential_vassal
					has_relation_rival = root
					root = {
						any_courtier = {
							suitable_courtier_yearly_5040_trigger = yes
							dynasty = scope:scoped_potential_vassal.dynasty
						}
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5040_trigger = yes
					save_temporary_scope_as = scoped_potential_vassal
					root = {
						any_courtier = {
							suitable_courtier_yearly_5040_trigger = yes
							dynasty = scope:scoped_potential_vassal.dynasty
						}
					}
				}
				alternative_limit = {
					suitable_vassal_yearly_5040_trigger = yes
				}
				alternative_limit = {
					is_available_ai_adult = yes
					is_powerful_vassal = yes
				}
				save_scope_as = scoped_vassal
				if = { #Make secret if the vassal did not have anything to hide.
					limit = {
						NOT = { suitable_vassal_yearly_5040_trigger = yes }
					}
					give_random_likely_secret_effect = yes
					if = {
						limit = {
							scope:scoped_vassal = {
								any_secret = {
									suitable_secret_yearly_5040_trigger = yes
								}
							}
						}
						scope:scoped_vassal = {
							random_secret = {
								limit = {
									suitable_secret_yearly_5040_trigger = yes
								}
								save_scope_as = scoped_secret
							}
						}
					}
					else = {
						give_random_secret_effect = yes
						random_secret = {
							limit = {
								suitable_secret_yearly_5040_trigger = yes
							}
							save_scope_as = scoped_secret
						}
					}
				}
				else = { #Else pick an existing scheme/secret
					random_list = {
						50 = {
							trigger = {
								any_scheme = {
									suitable_scheme_yearly_5040_trigger = yes
								}
							}
							random_scheme = {
								limit = {
									suitable_scheme_yearly_5040_trigger = yes
								}
								save_scope_as = scoped_scheme
							}
						}
						25 = {
							trigger = {
								any_secret = {
									suitable_secret_yearly_5040_trigger = yes
								}
							}
							random_secret = {
								limit = {
									suitable_secret_yearly_5040_trigger = yes
								}
								save_scope_as = scoped_secret
							}
						}
					}
				}
			}
			#Now pick blabbermouths.
			random_courtier = {
				limit = {
					suitable_courtier_yearly_5040_trigger = yes
					dynasty = scope:scoped_vassal.dynasty
				}
				alternative_limit = {
					suitable_courtier_yearly_5040_trigger = yes
				}
				save_scope_as = whisperer_1
			}
			random_courtier = {
				limit = {
					suitable_courtier_yearly_5040_trigger = yes
					dynasty = scope:scoped_vassal.dynasty
					NOT = { this = scope:whisperer_1 }
				}
				alternative_limit = {
					suitable_courtier_yearly_5040_trigger = yes
					NOT = { this = scope:whisperer_1 }
				}
				save_scope_as = whisperer_2
			}
		}
	}

	#Expose and ship them to vassal.
	#Spy on them.
	#Imprison and torture information out of them.


	option = { #Expose and ship them to vassal.
		name = {
			trigger = { scope:scoped_vassal = { has_personality_malicious_trigger = yes } }
			text = yearly.5040.a.a
		}
		name = {
			trigger = { NOT = { scope:scoped_vassal = { has_personality_malicious_trigger = yes } } }
			text = yearly.5040.a.b
		}
		if = {
			limit = {
				scope:scoped_vassal = {
					has_personality_malicious_trigger = yes
				}
			}
			reverse_add_opinion = {
				target = scope:scoped_vassal
				modifier = grateful_opinion
				opinion = 15
			}
			show_as_tooltip = {
				scope:scoped_vassal = {
					imprison = {
						target = scope:whisperer_1
						type = dungeon
					}
					imprison = {
						target = scope:whisperer_2
						type = dungeon
					}
				}
			}
			hidden_effect = {
				imprison_character_effect = {
					TARGET = scope:whisperer_1
					IMPRISONER = scope:scoped_vassal
				}
				imprison_character_effect = {
					TARGET = scope:whisperer_2
					IMPRISONER = scope:scoped_vassal
				}
			}
		}
		if = {
			limit = {
				scope:scoped_vassal = {
					has_personality_malicious_trigger = no
				}
			}
			reverse_add_opinion = {
				target = scope:scoped_vassal
				modifier = grateful_opinion
				opinion = 25
			}
			reverse_add_opinion = {
				target = scope:whisperer_1
				modifier = disappointed_opinion
				opinion = -25
			}
			reverse_add_opinion = {
				target = scope:whisperer_2
				modifier = disappointed_opinion
				opinion = -25
			}
		}
		stress_impact = {
			deceitful = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 125
				ai_vengefulness = -50
			}
		}
	}

	option = { #Spy on them.
		name = yearly.5040.b
		duel = {
			skill = intrigue
			value = decent_skill_rating
			10 = { #Success.
				desc = yearly.5040.b.success.desc.tt
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = 0
				}
				custom_tooltip = yearly.5040.b.success.effect.tt
				hidden_effect = {
					trigger_event = yearly.5041
				}
			}
			8 = { #Fail.
				desc = yearly.5040.b.failure.desc.tt
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
				}
				send_interface_toast = {
					left_icon = scope:whisperer_1
					right_icon = scope:whisperer_2
					title = yearly.5040.b.failure.desc.tt
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			honest = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -125
				ai_vengefulness = 50
			}
			modifier = {
				add = 20
				has_trait = paranoid
			}
			modifier = {
				add = -20
				has_trait = trusting
			}
			modifier = {
				add = -40
				OR = {
					has_relation_friend = scope:whisperer_1
					has_relation_friend = scope:whisperer_2
					has_relation_lover = scope:whisperer_1
					has_relation_lover = scope:whisperer_2
				}
			}
		}
	}
	option = { #Imprison and torture information out of them.
		name = {
			trigger = { has_personality_malicious_trigger = yes dread >= high_dread }
			text = yearly.5040.c.a
		}
		name = {
			trigger = {
				NAND = {
					has_personality_malicious_trigger = yes
					dread >= high_dread
				}
			}
			text = yearly.5040.c.b
		}
		add_dread = medium_dread_gain
		random_list = {
			8 = { #Success.
				compare_modifier = {
					value = root.dread
					multiplier = 0.5
				}
				desc = yearly.5040.c.success.tt
				custom_tooltip = yearly.5040.b.success.effect.tt
				hidden_effect = {
					random = {
						chance = 15
						modifier = {
							add = 20
							has_trait = sadistic
						}
						add_character_flag = {
							flag = flag_yearly_5040_deadly_interrogation
							days = 120
						}					
					}
					trigger_event = yearly.5042
				}
			}
			10 = { #Fail.
				desc = yearly.5040.c.failure.tt
				custom_tooltip = yearly.5040.b.failure.effect.tt
				hidden_effect = {
					random_list = {
						5 = {
							modifier = {
								add = 10
								has_trait = sadistic
							}
							trigger_event = yearly.5043  		
						}	
						10 = {
							send_interface_toast = {
								left_icon = scope:whisperer_1
								right_icon = scope:whisperer_2
								title = yearly.5040.torturefail.desc
							}	 		
						}					
					}
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -100
				ai_vengefulness = 125
			}
			modifier = {
				add = -20
				dread < medium_dread
			}
			modifier = {
				add = 20
				has_trait = sadistic
			}
			modifier = {
				add = -50
				OR = {
					has_relation_friend = scope:whisperer_1
					has_relation_friend = scope:whisperer_2
					has_relation_lover = scope:whisperer_1
					has_relation_lover = scope:whisperer_2
				}
			}
		}
	}
	option = { #Do nothing.
		name = yearly.5040.d
		add_dread = minor_dread_loss
		stress_impact = {
			paranoid = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
		}
	}
}

#Successful spying
yearly.5041 = {
	type = character_event
	title = yearly.5040.t
	desc = {
		first_valid = { #Might be a secret or a scheme.
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:scoped_secret }
					scope:scoped_scheme = { scheme_target_character = root }
				}
				desc = yearly.5041.desc.a
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:scoped_secret }
					NOT = { scope:scoped_scheme = { scheme_target_character = root } }
				}
				desc = yearly.5041.desc.b
			}
			triggered_desc = {
				trigger = {
					exists = scope:scoped_secret
				}
				desc = yearly.5041.desc.c
			}
		}
	}
	left_portrait = {
		character = scope:whisperer_1
		animation = paranoia
	}
	right_portrait = {
		character = scope:whisperer_2
		animation = worry
	}
	theme = intrigue

	option = {
		name = yearly.5041.a
		if = {
			limit = {
				exists = scope:scoped_secret
			}
			scope:scoped_secret = { reveal_to = root }
		}
		if = {
			limit = {
				exists = scope:scoped_scheme
			}
			scope:scoped_scheme = { expose_scheme = yes }
		}
	}
}

#Successful torturing
yearly.5042 = {
	type = character_event
	title = yearly.5040.t
	desc = {
		first_valid = { #Torture might be fatal.
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = flag_yearly_5040_deadly_interrogation }
				}
				desc = yearly.5042.desc.safetorture
			}
			triggered_desc = {
				trigger = {
					has_character_flag = flag_yearly_5040_deadly_interrogation
				}
				desc = yearly.5042.desc.deadlytorture
			}
		}
		first_valid = { #Might be a secret or a scheme.
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:scoped_secret }
					scope:scoped_scheme = { scheme_target_character = root }
				}
	  			desc = yearly.5042.desc.a
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:scoped_secret }
					NOT = { scope:scoped_scheme = { scheme_target_character = root } }
				}
	  			desc = yearly.5042.desc.b
			}
			triggered_desc = {
				trigger = {
					exists = scope:scoped_secret
				}
				desc = yearly.5042.desc.c
			}
		}
	}
	left_portrait = {
		character = scope:whisperer_1
		animation = fear
	}
	right_portrait = {
		character = scope:whisperer_2
		animation = beg
	}
	theme = dungeon
	immediate = {
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_jailor_gender }
	}
	option = {
		name = {
			trigger = { has_personality_malicious_trigger = yes }
			text = yearly.5042.a.a
		}
		name = {
			trigger = { has_personality_malicious_trigger = no }
			text = yearly.5042.a.b
		}
		if = {
			limit = {
				exists = scope:scoped_secret
			}
			scope:scoped_secret = { reveal_to = root }
		}
		if = {
			limit = {
				exists = scope:scoped_scheme
			}
			scope:scoped_scheme = { expose_scheme = yes }
		}
		if = {
			limit = {
				has_character_flag = flag_yearly_5040_deadly_interrogation
			}
			scope:whisperer_1 = {
				death = { death_reason = death_dungeon killer = root }
			}
			scope:whisperer_2 = {
				death = { death_reason = death_dungeon killer = root }
			}
			remove_character_flag = flag_yearly_5040_deadly_interrogation
		}
	}
}

#Deadly failure in torturing.
yearly.5043 = {
	type = character_event
	title = yearly.5040.t
	desc = yearly.5043.torturedeadlyfail.desc
	left_portrait = {
		character = scope:whisperer_1
		animation = beg
	}
	right_portrait = {
		character = scope:whisperer_2
		animation = fear
	}
	theme = dungeon

	option = {
		name = {
			trigger = { has_personality_malicious_trigger = yes }
			text = yearly.5043.a.a
		}
		name = {
			trigger = { has_personality_malicious_trigger = no }
			text = yearly.5043.a.b
		}
		scope:whisperer_1 = {
			death = { death_reason = death_dungeon killer = root }
		}
		scope:whisperer_2 = {
			death = { death_reason = death_dungeon killer = root }
		}
	}
}

#######################################

#Spouse feels slighted by courtier.

scripted_trigger suitable_courtier_yearly_5050_trigger = {
	is_available_ai_adult = yes
	is_ruler = no
	NOR = {
		is_spouse_of = root
		is_close_or_extended_family_of = root
		is_theocratic_lessee = yes # Your wife cannot ask you to banish your bishop!
		
		any_relation = {
			type = friend
			is_spouse_of = root
		}
		any_relation = {
			type = lover
			is_spouse_of = root
		}
	}
}

scripted_trigger suitable_spouse_yearly_5050_trigger = {
	is_available_ai_adult = yes
}

yearly.5050 = {
	type = character_event
	title = yearly.5050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = { has_personality_dominant_trigger = yes }
				}
				desc = yearly.5050.desc.a
			}
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = { has_personality_dominant_trigger = no }
				}
				desc = yearly.5050.desc.b
			}
		}
	}
	theme = marriage
	left_portrait = {
		character = scope:slighting_courtier
		animation = dismissal
	}
	right_portrait = {
		character = scope:scoped_spouse
		animation = disgust
	}

	trigger = {
		OR = { # Expensive, so we restrict the AI use of this
			is_ai = no
			highest_held_title_tier > tier_county
		}
		is_available_adult = yes
		is_married = yes
		NOT = { has_character_flag = flag_5050_cooldown }
		any_spouse = {
			suitable_spouse_yearly_5050_trigger = yes
		}
		any_courtier = {
			suitable_courtier_yearly_5050_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if the spouse is petty.
			add = 1.0
			any_spouse = {
				OR = {
					has_trait = fickle
					has_trait = arrogant
					has_trait = arbitrary
					has_character_flag = flag_spouse_lying #Already did so in the past.
				}
			}
		}
	}

	immediate = {
		hidden_effect = {
			add_character_flag = {
				flag = flag_5050_cooldown
				days = 7200
			}
			random_courtier = { #Select courtier allegedly insulting spouse.
				limit = {
					suitable_courtier_yearly_5050_trigger = yes
					OR = {
						has_trait = fickle
						has_trait = arrogant
						has_trait = arbitrary
						has_trait = stubborn
						has_trait = wrathful
						has_trait = callous
						has_trait = sadistic
					}
					save_temporary_scope_as = potential_courtier
					OR = {
						any_relation = {
							type = rival
							is_spouse_of = root
						}
						root = {
							any_spouse = {
								suitable_spouse_yearly_5050_trigger = yes
								opinion = {
									target = scope:potential_courtier
									value <= -30
								}
								number_of_opposing_traits = {
									target = scope:potential_courtier
									value >= 1
								}
							}
						}
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
					save_temporary_scope_as = potential_courtier
					OR = {
						root = {
							any_spouse = {
								suitable_spouse_yearly_5050_trigger = yes
								opinion = {
									target = scope:potential_courtier
									value <= -30
								}
								number_of_opposing_traits = {
									target = scope:potential_courtier
									value >= 1
								}
							}
						}
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
					save_temporary_scope_as = potential_courtier
					OR = {
						root = {
							any_spouse = {
								suitable_spouse_yearly_5050_trigger = yes
								opinion = {
									target = scope:potential_courtier
									value <= 0
								}
							}
						}
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
				}
				save_scope_as = slighting_courtier
			}
			random_spouse = { #Select spouse.
				limit = {
					suitable_spouse_yearly_5050_trigger = yes
					OR = {
						has_trait = arrogant
						has_trait = fickle
					}
					save_temporary_scope_as = potential_spouse
					scope:slighting_courtier = {
						OR = {
							has_relation_rival = scope:potential_spouse
							opinion = {
								target = scope:potential_spouse
								value <= -30
							}
						}
					}
				}
				alternative_limit = {
					suitable_spouse_yearly_5050_trigger = yes
					OR = {
						has_trait = arrogant
						has_trait = fickle
					}
					save_temporary_scope_as = potential_spouse
					scope:slighting_courtier = {
						opinion = {
							target = scope:potential_spouse
							value <= 0
						}
					}
				}
				alternative_limit = {
					suitable_spouse_yearly_5050_trigger = yes
					OR = {
						has_trait = arrogant
						has_trait = fickle
					}
				}
				alternative_limit = {
					suitable_spouse_yearly_5050_trigger = yes
				}
				save_scope_as = scoped_spouse
			}
			scope:scoped_spouse = {
				random_list = { #Now determine if the spouse is lying or not.
					10 = {
						ai_value_modifier = {
							ai_honor = -0.75
							ai_vengefulness = 0.75
						}
						opinion_modifier = {
							opinion_target = scope:scoped_spouse
							who = scope:slighting_courtier
							multiplier = -0.5
						}
						modifier = {
							add = 10
							has_relation_rival = scope:slighting_courtier
						}
						modifier = {
							add = 10
							has_trait = deceitful
						}
						modifier = {
							add = 5
							has_trait = fickle
						}
						modifier = {
							add = 5
							has_trait = arrogant
						}
						modifier = {
							add = 5
							has_trait = wrathful
						}
						add_character_flag = {
							flag = flag_spouse_lying
							days = 7200
						}
					}
					10 = { #Nothing.
					}
				}
			}
		}
	}

	#Punish courtier.
	#Dismiss spouse.
	#Investigate matter.

	option = { #Punish courtier.
		name = yearly.5050.a.a
		scope:scoped_spouse = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = smeared_opinion
			}
		}
		if = {
			limit = { is_landed = yes }
			scope:slighting_courtier = { banish = yes } # banish_effect not used for unlanded
		}
		else = {
			scope:slighting_courtier = { move_to_pool = yes }
		}
		if = {
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
				}
			}
			hidden_effect = {
				trigger_event = {
					id = yearly.5053 days = { 365 500 }
				}
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
			ai_value_modifier = {
				ai_honor = -100
				ai_vengefulness = 100
			}
			modifier = {
				add = 10
				has_trait = trusting
			}
		}
	}
	option = { #Dismiss spouse.
		name = {
			trigger = { has_personality_malicious_trigger = yes }
			text = yearly.5050.b.a
		}
		name = {
			trigger = { scope:slighting_courtier = { has_personality_benevolent_trigger = yes } }
			text = yearly.5050.b.b
		}
		name = {
			trigger = {
				has_personality_malicious_trigger = no
				scope:slighting_courtier = { has_personality_benevolent_trigger = no }
			}
			text = yearly.5050.b.c
		}
		scope:scoped_spouse = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -20
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:slighting_courtier
			}
			ai_value_modifier = {
				ai_honor = -100
			}
		}
	}
	option = { #Investigate story.
		name = yearly.5050.c
		duel = {
			skill = intrigue
			value = mediocre_skill_rating
			7 = { #Success.
				desc = yearly.5050.c.success.desc.tt
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = 0
				}
				custom_tooltip = yearly.5050.c.success.effect.tt
				hidden_effect = {
					trigger_event = { id = yearly.5051 days = 1 }
				}
			}
			10 = { #Fail.
				desc = yearly.5050.c.failure.desc.tt
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				custom_tooltip = yearly.5050.c.failure.effect.tt
				hidden_effect = {
					trigger_event = { id = yearly.5052 days = 1 }
				}
			}
		}
		stress_impact = {
			arbitrary = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 30
				has_trait = paranoid
			}
		}
	}
}

#Ruler successfully investigated the matter.
yearly.5051 = {
	type = character_event
	title = yearly.5050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = { has_character_flag = flag_spouse_lying }
				}
				desc = yearly.5051.desc.a.a
			}
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = {
						NOT = { has_character_flag = flag_spouse_lying }
					}
				}
				desc = yearly.5051.desc.a.b
			}
		}
	}
	theme = marriage
	left_portrait = {
		character = scope:slighting_courtier
		animation = dismissal
	}
	right_portrait = {
		character = scope:scoped_spouse
		animation = shock
	}
	

	trigger = {
		scope:scoped_spouse = { is_alive = yes }
		is_spouse_of = scope:scoped_spouse
	}
	
	option = { #Hook spouse.
		name = yearly.5051.z
		trigger = {
			scope:scoped_spouse = { has_character_flag = flag_spouse_lying }
			NOT = { has_hook = scope:scoped_spouse }
		}
		if = {
			limit = {
				scope:scoped_spouse = { has_hook = root }
			}
			scope:scoped_spouse = { remove_hook = { target = root } }
		}
		else = {
			add_hook = {
				target = scope:scoped_spouse
				type = favor_hook
			}
		}
		scope:scoped_spouse = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = blackmailing_me_opinion
			}
		}
		stress_impact = {
			honest = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:slighting_courtier
			}
			ai_value_modifier = {
				ai_honor = -125
			}
		}
	}
	option = { #Berate spouse.
		name = yearly.5051.a
		trigger = {
			scope:scoped_spouse = { has_character_flag = flag_spouse_lying }
		}
		add_prestige = medium_prestige_gain
		scope:scoped_spouse = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -20
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		stress_impact = {
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:slighting_courtier
			}
			ai_value_modifier = {
				ai_honor = 100
			}
		}
	}
	option = { #Take spouse's side regardless.
		name = yearly.5051.b
		trigger = {
			scope:scoped_spouse = { has_character_flag = flag_spouse_lying }
			has_trait = arbitrary
		}
		trait = arbitrary
		add_prestige = minor_prestige_loss
		scope:scoped_spouse = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 40
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = smeared_opinion
			}
		}
		if = {
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
				}
			}
			hidden_effect = {
				trigger_event = {
					id = yearly.5053 days = { 365 730 }
				}
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
			ai_value_modifier = {
				ai_honor = -100
			}
		}
	}
	option = { #Punish courtier.
		name = yearly.5051.c
		trigger = {
			NOT = { scope:scoped_spouse = { has_character_flag = flag_spouse_lying } }
		}
		add_prestige = medium_prestige_gain
		scope:scoped_spouse = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}
		scope:slighting_courtier = {
			add_prestige = medium_prestige_loss
			add_opinion = {
				target = root
				modifier = smeared_opinion
			}
		}
		scope:slighting_courtier = { banish = yes } # banish_effect not used for unlanded
		if = {
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
				}
			}
			hidden_effect = {
				trigger_event = {
					id = yearly.5053 days = { 365 730 }
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
		}
	}
	option = { #Take courtier's side regardless.
		name = yearly.5051.d
		trigger = {
			scope:scoped_spouse = { NOT = { has_character_flag = flag_spouse_lying } }
		}
		add_prestige = medium_prestige_gain
		scope:scoped_spouse = {
			add_prestige = medium_prestige_loss
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -40
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 40
			}
		}
		stress_impact = {
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:slighting_courtier
			}
		}
	}
}

#Ruler was not able to discern sincerity.
yearly.5052 = {
	type = character_event
	title = yearly.5050.t
	desc = {
		desc = yearly.5052.desc.a
		first_valid = { #Romantic flavor.
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = {
						NOR = {
							has_trait = deceitful
							has_relation_lover = root
						}
					}
				}
				desc = yearly.5052.desc.b.a
			}
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = {
						OR = {
							has_trait = deceitful
							has_relation_lover = root
						}
					}
				}
				desc = yearly.5052.desc.b.b
			}
		}
	}
	theme = marriage
	left_portrait = {
		character = scope:slighting_courtier
		animation = shock
	}
	right_portrait = {
		character = scope:scoped_spouse
		animation = personality_dishonorable
	}

	trigger = {
		scope:scoped_spouse = { is_alive = yes }
		is_spouse_of = scope:scoped_spouse
	}
	
	option = { #Punish courtier.
		name = yearly.5052.a
		scope:scoped_spouse = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = smeared_opinion
			}
		}
		scope:slighting_courtier = { banish = yes } # banish_effect not used for unlanded
		if = {
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
				}
			}
			hidden_effect = {
				trigger_event = {
					id = yearly.5053 days = { 365 730 }
				}
			}
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
		}
	}
	option = { #Take courtier's side regardless.
		name = yearly.5052.b
		scope:scoped_spouse = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -40
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 40
			}
		}
		stress_impact = {
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
		}
	}
}

#Lying spouse finds next target.
yearly.5053 = {
	type = character_event
	title = yearly.5050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = {
						NOT = {
							root.var:lying_spouse_count_5040 > 3
						}
					}
				}
				desc = yearly.5053.desc.a
			}
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = {
						root.var:lying_spouse_count_5040 > 3
					}
				}
				desc = yearly.5053.desc.b
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_trait = trusting
						root.var:lying_spouse_count_5040 < 3
					}
				}
				desc = yearly.5053.desc.b.a
			}
			triggered_desc = {
				trigger = {
					root.var:lying_spouse_count_5040 >= 3
					NOT = { has_trait = trusting }
				}
				desc = yearly.5053.desc.b.b
			}
		}
	}
	theme = marriage
	left_portrait = {
		character = scope:slighting_courtier
		animation = shame
	}
	right_portrait = {
		character = scope:scoped_spouse
		animation = scheme
	}

	trigger = {
		scope:scoped_spouse = { is_alive = yes }
		is_spouse_of = scope:scoped_spouse
		scope:scoped_spouse = {
			has_character_flag = flag_spouse_lying
		}
		any_courtier = {
			suitable_courtier_yearly_5050_trigger = yes
		}
	}

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					NOT = { exists = root.var:lying_spouse_count_5040 }
				}
				set_variable = {
					name = lying_spouse_count_5040
					value = 0
				}
			}
			change_variable = {
				name = lying_spouse_count_5040 #Stress effect past a certain point.
				add = 1
			}
			random_courtier = { #Select courtier allegedly insulting spouse.
				limit = {
					suitable_courtier_yearly_5050_trigger = yes
					OR = {
						has_trait = fickle
						has_trait = stubborn
						has_trait = wrathful
					}
					OR = {
						has_relation_rival = scope:scoped_spouse
						opinion = {
							target = scope:scoped_spouse
							value <= -30
						}
					}
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = councillor_marshal
						has_council_position = councillor_steward
						has_council_position = councillor_spymaster
						has_council_position = councillor_court_chaplain
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
					OR = {
						has_relation_rival = scope:scoped_spouse
						opinion = {
							target = scope:scoped_spouse
							value <= 0
						}
					}
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = councillor_marshal
						has_council_position = councillor_steward
						has_council_position = councillor_spymaster
						has_council_position = councillor_court_chaplain
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
					OR = {
						has_relation_rival = scope:scoped_spouse
						opinion = {
							target = scope:scoped_spouse
							value <= 0
						}
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = councillor_marshal
						has_council_position = councillor_steward
						has_council_position = councillor_spymaster
						has_council_position = councillor_court_chaplain
					}
				}
				alternative_limit = {
					suitable_courtier_yearly_5050_trigger = yes
				}
				save_scope_as = slighting_courtier
			}
		}
	}
	option = { #Callous exemplar treatmnet.
		name = yearly.5053.a
		trigger = { has_trait = callous }
		trait = callous
		add_dread = medium_dread_gain
		scope:scoped_spouse = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 5
			}
		}
		scope:slighting_courtier = {
			death = { death_reason = death_execution killer = root }
			execute_opinion_effect = { VICTIM = scope:slighting_courtier EXECUTIONER = root }
		}
		hidden_effect = {
			every_courtier = {
				limit = {
					NOT = {
						this = scope:scoped_spouse
					}
				}
				add_opinion = {
					target = scope:scoped_spouse
					modifier = disgusted_opinion
					opinion = -50
				}
			}
		}
		if = { #Learned her lesson as well.
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
					NOT = { has_trait = sadistic }
				}
			}
			hidden_effect = {
				scope:scoped_spouse = { remove_character_flag = flag_spouse_lying }
				trigger_event = {
					id = yearly.5054 days = { 50 100 }
				}
			}
		}
		else_if = { #Else once again...
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
					has_trait = sadistic
				}
			}
			hidden_effect = {
				trigger_event = {
					id = yearly.5053 days = { 365 730 }
				}
			}
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
		}
	}
	option = { #Punish courtier.
		name = yearly.5053.b
		scope:scoped_spouse = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = smeared_opinion
			}
		}
		hidden_effect = {
			every_courtier = {
				limit = {
					NOT = {
						this = scope:scoped_spouse
					}
				}
				add_opinion = {
					target = scope:scoped_spouse
					modifier = smeared_opinion
				}
			}
		}
		scope:slighting_courtier = { banish = yes } # banish_effect not used for unlanded
		if = { #And once again...
			limit = {
				scope:scoped_spouse = {
					has_character_flag = flag_spouse_lying
				}
			}
			hidden_effect = {
				trigger_event = {
					id = yearly.5053 days = { 365 500 }
				}
			}
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
		}
	}
	option = { #Take courtier's side.
		name = yearly.5053.c
		add_prestige = minor_prestige_loss
		scope:scoped_spouse = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -40
			}
		}
		scope:slighting_courtier = {
			add_prestige = minor_prestige_gain
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		stress_impact = {
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			opinion_modifier = {
				opinion_target = scope:scoped_spouse
			}
		}
	}
}

#Spouse learned lesson, stopped pointing fingers.
yearly.5054 = {
	type = character_event
	title = yearly.5050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = { has_personality_benevolent_trigger = yes }
				}
				desc = yearly.5054.desc.a
			}
			triggered_desc = {
				trigger = {
					scope:scoped_spouse = { has_personality_benevolent_trigger = no }
				}
				desc = yearly.5054.desc.b
			}
		}
	}
	theme = marriage
	right_portrait = {
		character = scope:scoped_spouse
		animation = shame
	}

	trigger = {
		scope:scoped_spouse = { is_alive = yes }
		is_spouse_of = scope:scoped_spouse
		}

	option = {
		name = {
			trigger = { has_personality_malicious_trigger = yes }
			text = yearly.5054.a.a
		}
		name = {
			trigger = {
				has_personality_malicious_trigger = no
			}
			text = yearly.5054.a.b
		}
		if = {
			limit = {
				scope:scoped_spouse = {
					has_personality_benevolent_trigger = yes
					NOT = { has_trait = depressed }
				}
			}
			random = {
				chance = 10
				add_trait = depressed_1
			}
		}
	}
}

################################
# By Alexander Oltner
################################

scripted_trigger yearly_8000_vassal_trigger = {
	is_available_ai_adult = yes
	is_not_hostile_towards_root = yes
	is_at_war = no
	OR = {
		ai_greed <= high_negative_ai_value
		has_trait = generous
	}
	opinion = {
		target = root
		value >= neutral_opinion
	}
	OR = { # The vassal should be moderately loaded
		AND = {
			gold >= major_gold_value
			root = { is_ai = no }
		}
		short_term_gold >= major_gold_value
	}
	NOT = { has_trait = shy }
}

yearly.8000 = { # Vassal offers liege a gift, by Alexander Oltner
	type = character_event
	title = yearly.8000.t
	desc = {
		desc = yearly.8000.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = paranoid
				}
				desc = yearly.8000.desc.paranoid
			}
			triggered_desc = {
				trigger = {
					has_trait = cannibal
				}
				desc = yearly.8000.desc.cannibal
			}
			triggered_desc = {
				trigger = {
					has_trait = lunatic
				}
				desc = yearly.8000.desc.lunatic
			}
			desc = yearly.8000.desc.default
		}
	}
	theme = vassal
	left_portrait = {
		character = scope:vassal
		animation = personality_content
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_8000 }
		is_capable_adult = yes
		
		#Find a suitable vassal
		any_vassal = {
			yearly_8000_vassal_trigger = yes
			save_temporary_scope_as = vassal
		}
	}

	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_8000
			years = 10
		}
		random_vassal = {
			limit = {
				yearly_8000_vassal_trigger = yes
			}
			save_scope_as = vassal
		}
	}
	
	option = { # Paranoid option
		name = yearly.8000.d
		
		trigger = {
			has_trait = paranoid
		}
		
		if = {
			limit = {
				stress > 0
			}
			add_stress = minor_stress_loss
		}
		
		scope:vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = -15
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 900
				has_trait = paranoid
			}
		}
	}

	option = { # Accept the vassal's gift
		name = yearly.8000.a
		
		scope:vassal = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
			
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 15
			}
		}
		
		add_prestige = minor_prestige_value
		
		hidden_effect = {
			add_opinion = {
				modifier = respect_opinion
				target = scope:vassal
				opinion = 30
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					has_trait = generous
				}
			}
		}

		stress_impact = {
			paranoid = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}
	}
	
	option = { # Make the vassal pay more
		name = yearly.8000.b
		
		scope:vassal = {
			pay_short_term_gold = {
				target = root
				gold = major_gold_value
			}
			
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = -30
			}
		}
		
		add_prestige = medium_prestige_value

		ai_chance = {
			base = 25
			modifier = {
				factor = 0
				OR = {
					ai_honor > 0
					ai_greed < 0
				}
			}
			
			modifier = {
				factor = 2
				ai_honor < 0
				ai_greed > 0
			}
			
			modifier = {
				factor = 10
				ai_honor <= high_negative_ai_value
				ai_greed >= medium_positive_ai_value
			}
		}

		stress_impact = {
			paranoid = medium_stress_impact_gain
			generous = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
			temperate = major_stress_impact_gain
			content = major_stress_impact_gain
			just = major_stress_impact_gain
			honest = minor_stress_impact_gain
		}
	}
	
	option = { # Use the money to befriend the vassal
		name = yearly.8000.c
		
		trigger = {
			NAND = {
				OR = {
					has_trait = lunatic
					has_trait = possessed
					has_trait = sadistic
				}
				OR = {
					has_trait = cannibal
					any_secret = { secret_type = secret_cannibal }
				}
			}
		}
		
		scope:vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 35
			}
		}
		
		add_prestige = medium_prestige_value
		if = {
			limit = {
				has_lifestyle = diplomacy_lifestyle
			}
			add_diplomacy_lifestyle_xp = medium_lifestyle_experience
		}
		else = {
			add_diplomacy_lifestyle_xp = miniscule_lifestyle_experience
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					has_trait = generous
				}
			}
			modifier = {
				add = 900
				OR = {
					ai_greed <= -50
					has_trait = generous
				}
			}
			modifier = {
				factor = 0
				gold < major_gold_value_check
			}
		}

		stress_impact = {
			greedy = massive_stress_impact_gain
			shy = massive_stress_impact_gain
			arrogant = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
		}
	}
	
	option = { # Eat the vassal
		name = yearly.8000.e
		
		trigger = {
			OR = {
				has_trait = lunatic
				has_trait = possessed
				has_trait = sadistic
			}
			OR = {
				has_trait = cannibal
				any_secret = { secret_type = secret_cannibal }
			}
		}
		
		scope:vassal = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
			custom_tooltip = yearly.8000.e.tt_eat_vassal
		}
		custom_tooltip = yearly.8000.e.tt_secret
		hidden_effect = {
			unknown_murder_effect = {
				VICTIM = scope:vassal
				MURDERER = root
				REASON = death_eaten
			}
		}
		
		add_prestige = medium_prestige_value
		add_stress = massive_stress_loss
		random = {
			chance = 20
			show_as_tooltip = { add_trait = ill }
			hidden_effect = {
				trigger_event = {
					id = health.1001
					days = { 3 10 }
				}
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 900
				OR = {
					has_trait = cannibal
					any_secret = { secret_type = secret_cannibal }
				}
			}
		}
		
		stress_impact = {
			paranoid = medium_stress_impact_gain
		}
	}
}

scripted_trigger yearly_8100_county_trigger = {
	tier = tier_county
	county_opinion >= 0
	county_control = 100
	NOT = { has_county_modifier = reinvested_in_province_modifier }
}

yearly.8100 = { # The peasantry of a Domain province gives you a gift, by Alexander Oltner
	type = character_event
	title = yearly.8100.t
	desc = yearly.8100.desc
	theme = stewardship
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:portrait_peasant
		animation = steward
		outfit_tags = { beggar_rags }
		hide_info = yes
	}
	
	override_background = { reference = market }
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_8100 }
		is_capable_adult = yes
		
		#Find a suitable county
		any_held_title = {
			yearly_8100_county_trigger = yes
			save_temporary_scope_as = county
		}
	}

	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_8100
			years = 10
		}
		random_held_title = {
			limit = {
				yearly_8100_county_trigger = yes
			}
			save_scope_as = county
		}
		if = {
			limit = {
				exists = scope:county.title_province
				any_pool_character = {
					province = scope:county.title_province
					is_available_ai_adult = yes
					has_no_particular_noble_roots_trigger = yes
				}
			}
			random_pool_character = {
				province = scope:county.title_province
				limit = {
					is_available_ai_adult = yes
					has_no_particular_noble_roots_trigger = yes
				}
				save_scope_as = portrait_peasant
			}
		}
	}

	option = { # Accept the gift
		name = yearly.8100.a
		
		add_gold = minor_gold_value

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = generous
			}
		}

		stress_impact = {
			generous = medium_stress_impact_gain
		}
	}
	
	option = { # Make the County pay more
		name = yearly.8100.b
		
		add_gold = major_gold_value
		add_dread = medium_dread_gain
		scope:county = {
			change_county_control = massive_county_control_loss
		}

		ai_chance = {
			base = 25
			
			modifier = {
				factor = 10
				ai_honor <= high_negative_ai_value
				ai_greed >= medium_positive_ai_value
			}
		}

		stress_impact = {
			generous = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
			temperate = major_stress_impact_gain
			content = major_stress_impact_gain
			just = major_stress_impact_gain
			honest = minor_stress_impact_gain
		}
	}
	
	option = { # Reinvest the money
		name = yearly.8100.c
		
		scope:county = {
			add_county_modifier = {
				modifier = reinvested_in_province_modifier
				years = 10
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = greedy
			}
		}

		stress_impact = {
			greedy = major_stress_impact_gain
		}
	}
}

yearly.8200 = { # Your realm priest offers you part of a large donation, by Alexander Oltner
	type = character_event
	title = yearly.8200.t
	desc = {
		desc = yearly.8200.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = zealous
				}
				desc = yearly.8200.desc.zealous
			}
			triggered_desc = {
				trigger = {
					has_trait = generous
				}
				desc = yearly.8200.desc.generous
			}
			triggered_desc = {
				trigger = {
					has_trait = greedy
				}
				desc = yearly.8200.desc.greedy
			}
			desc = yearly.8200.desc.default
		}
	}
	theme = faith
	left_portrait = {
		character = scope:realm_priest
		animation = steward
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_8200 }
		is_capable_adult = yes
		piety > 0
		NOR = {
			government_has_flag = government_is_tribal
			government_has_flag = government_is_nomadic
		}
		
		exists = cp:councillor_court_chaplain
		cp:councillor_court_chaplain = {
			is_available_ai_adult = yes
			opinion = {
				target = root
				value >= neutral_opinion
			}
			ai_greed <= 0
			NOR = {
				has_trait = honest
				has_trait = zealous
			}
		}
	}

	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_8200
			years = 10
		}
		hidden_effect = {
			cp:councillor_court_chaplain = {
				save_scope_as = realm_priest
				if = {
					limit = {
						NOT = { gold >= root.medium_gold_value }
					}
					add_gold = root.medium_gold_value
				}
			}
		}
	}
	
	option = { # Have the priest denounced as a heretic and burned
		name = yearly.8200.a
		trait = zealous
		
		trigger = {
			has_trait = zealous
		}
		
		add_piety = medium_piety_gain
		add_dread = medium_dread_gain
		
		scope:realm_priest = {
			death = {
				killer = root
				death_reason = death_burned_witch
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOR = {
					has_trait = lunatic
					has_trait = possessed
					has_trait = sadistic
				}
			}
		}

		stress_impact = {
			compassionate = major_stress_impact_gain
			just = major_stress_impact_gain
			humble = major_stress_impact_gain
			forgiving = major_stress_impact_gain
			calm = medium_stress_impact_gain
			honest = minor_stress_impact_gain
		}
	}

	option = { # Accept the gift
		name = yearly.8200.b
		
		scope:realm_priest = {
			pay_short_term_gold = {
				target = root
				gold = root.minor_gold_value
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = generous
			}
		}

		stress_impact = {
			generous = medium_stress_impact_gain
		}
	}
	
	option = { # Make the Priest give you the entire donation
		name = yearly.8200.c
		
		scope:realm_priest = {
			pay_short_term_gold = {
				target = root
				gold = root.medium_gold_value
			}
			add_opinion = {
				modifier = impious_opinion
				target = root
				opinion = -20
			}
		}
		add_piety = minor_piety_loss

		ai_chance = {
			base = 25
			
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = compassionate
					has_trait = humble
					has_trait = temperate
					has_trait = content
					has_trait = just
					has_trait = honest
				}
			}
		}

		stress_impact = {
			generous = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			temperate = major_stress_impact_gain
			content = major_stress_impact_gain
			just = major_stress_impact_gain
			honest = minor_stress_impact_gain
		}
	}
	
	option = { # Donate it to the poor
		name = yearly.8200.d
		
		add_piety = major_piety_gain
		
		scope:realm_priest = {
			add_opinion = {
				modifier = pious_opinion
				target = root
				opinion = 35
			}
		}

		ai_chance = {
			base = 25
			
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = cynical
				}
			}
		}

		stress_impact = {
			greedy = major_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
	}
	
}

scripted_trigger yearly_8300_vassal_trigger = {
	is_available_ai_adult = yes
	is_not_hostile_towards_root = yes
	is_at_war = no
	ai_greed < 1
	opinion = {
		target = root
		value >= neutral_opinion
	}
	OR = { # The vassal should be moderately loaded
		AND = {
			gold >= medium_gold_value
			root = { is_ai = no }
		}
		short_term_gold >= medium_gold_value
	}
}

yearly.8300 = { # A group of vassals collectively wish to contribute to your war effort, by Alexander Oltner
	type = character_event
	title = yearly.8300.t
	desc = yearly.8300.desc
	theme = vassal
	left_portrait = {
		character = scope:vassal_1
		animation = happiness
	}
	right_portrait = {
		character = scope:vassal_3
		animation = admiration
	}
	lower_left_portrait = scope:vassal_2
	lower_right_portrait = scope:vassal_4
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_8300 }
		is_capable_adult = yes
		is_at_war = yes
		is_in_civil_war = no
		
		NOT = { gold >= major_gold_value }
		
		any_vassal = {
			count >= 4
			yearly_8300_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 5
			is_at_war = yes
			is_in_civil_war = no
		}
		modifier = {
			factor = 10
			is_at_war = yes
			is_in_civil_war = no
			gold < 0
		}
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_8300
			years = 10
		}
		every_vassal = {
			limit = {
				yearly_8300_vassal_trigger = yes
			}
			add_to_list = generous_vassals
		}
		random_in_list = {
			list = generous_vassals
			save_scope_as = vassal_1
		}
		random_in_list = {
			list = generous_vassals
			limit = {
				NOT = { this = scope:vassal_1 }
			}
			save_scope_as = vassal_2
		}
		random_in_list = {
			list = generous_vassals
			limit = {
				NOR = {
					this = scope:vassal_1
					this = scope:vassal_2
				}
			}
			save_scope_as = vassal_3
		}
		random_in_list = {
			list = generous_vassals
			limit = {
				NOR = {
					this = scope:vassal_1
					this = scope:vassal_2
					this = scope:vassal_3
				}
			}
			save_scope_as = vassal_4
		}
	}
	
	option = { # Lunatic: I'd much rather levy your pants!
		name = yearly.8300.d
		trait = lunatic_1
		trait = lunatic_genetic
		trigger = {
			OR = {
				has_trait = lunatic_1
				has_trait = lunatic_genetic
			}
		}
		
		add_prestige = major_prestige_value
		if = {
			limit = {
				stress > 0
			}
			add_stress = major_stress_impact_loss
		}
		
		scope:vassal_1 = {
			add_prestige = medium_prestige_loss
			add_opinion = {
				modifier = humiliated_opinion
				target = root
				opinion = -15
			}
		}
		scope:vassal_2 = {
			add_prestige = medium_prestige_loss
			add_opinion = {
				modifier = humiliated_opinion
				target = root
				opinion = -15
			}
		}
		scope:vassal_3 = {
			add_prestige = medium_prestige_loss
			add_opinion = {
				modifier = humiliated_opinion
				target = root
				opinion = -15
			}
		}
		scope:vassal_4 = {
			add_prestige = medium_prestige_loss
			add_opinion = {
				modifier = humiliated_opinion
				target = root
				opinion = -15
			}
		}

		ai_chance = {
			base = 100
		}
	}

	option = { # Accept the gift
		name = yearly.8300.a
		
		scope:vassal_1 = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
			hidden_effect = {
				add_prestige = minor_prestige_value
			}
		}
		scope:vassal_2 = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
			hidden_effect = {
				add_prestige = minor_prestige_value
			}
		}
		scope:vassal_3 = {
			pay_short_term_gold = {
				target = root
				gold = tiny_gold_value
			}
			hidden_effect = {
				add_prestige = minor_prestige_value
			}
		}
		scope:vassal_4 = {
			pay_short_term_gold = {
				target = root
				gold = tiny_gold_value
			}
			hidden_effect = {
				add_prestige = minor_prestige_value
			}
		}
		
		hidden_effect = {
			add_opinion = {
				modifier = respect_opinion
				target = scope:vassal_1
				opinion = 25
			}
			add_opinion = {
				modifier = respect_opinion
				target = scope:vassal_2
				opinion = 25
			}
			add_opinion = {
				modifier = respect_opinion
				target = scope:vassal_3
				opinion = 25
			}
			add_opinion = {
				modifier = respect_opinion
				target = scope:vassal_4
				opinion = 25
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = generous
			}
		}

		stress_impact = {
			generous = minor_stress_impact_gain
		}
	}
	
	option = { # Seize all they have
		name = yearly.8300.b
		
		scope:vassal_1 = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		scope:vassal_2 = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		scope:vassal_3 = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		scope:vassal_4 = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		add_tyranny = medium_tyranny_gain

		ai_chance = {
			base = 25
			
			modifier = {
				factor = 0
				OR = {
					ai_boldness > medium_positive_ai_value
					ai_greed < 0
				}
			}
			
			modifier = {
				factor = 4
				ai_greed >= medium_positive_ai_value
			}
		}

		stress_impact = {
			generous = major_stress_impact_gain
			just = major_stress_impact_gain
			brave = minor_stress_impact_gain
		}
	}
	
	option = { # Appreciate the gesture, but keep the money
		name = yearly.8300.c
		
		add_prestige = minor_prestige_value
		
		scope:vassal_1 = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 10
			}
		}
		scope:vassal_2 = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 10
			}
		}
		scope:vassal_3 = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 10
			}
		}
		scope:vassal_4 = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 10
			}
		}
		
		ai_chance = {
			base = 25
		}

		stress_impact = {
			greedy = major_stress_impact_gain
		}
	}
	
}

scripted_trigger yearly_8400_guest_trigger = {
	is_available_ai_adult = yes
	is_pool_guest = yes
	NOR = {
		has_trait = deviant
		any_secret = {
			secret_type = secret_deviant
			is_known_by = root
		}
	}
	save_temporary_scope_as = deviant_guest
	trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = scope:deviant_guest.faith GENDER_CHARACTER = scope:deviant_guest }
}

scripted_trigger yearly_8400_court_target_trigger = {
	exists = capital_province
	OR = {
		any_targeting_scheme = {
			OR = {
				scheme_type = murder
				scheme_type = abduct
			}
			scheme_owner = root
		}
		has_relation_rival = root
	}
}

yearly.8400 = { # Discover that a guest is a deviant, by Alexander Oltner
	type = character_event
	title = yearly.8400.t
	desc = yearly.8400.desc
	theme = seduction
	left_portrait = {
		character = scope:deviant_guest
		animation = shock
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_8400 }
		is_capable_adult = yes
		
		any_courtier_or_guest = {
			yearly_8400_guest_trigger = yes
		}
		
		trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:deviant_guest }
	}

	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_8400
		}
		hidden_effect = {
			random_courtier_or_guest = {
				limit = {
					yearly_8400_guest_trigger = yes
				}
				if = {
					limit = {
						NOT = {
							any_secret = {
								secret_type = secret_deviant
							}
						}
					}
					give_deviant_secret_or_trait_effect = yes
				}
				save_scope_as = deviant_guest
				random_secret = {
					limit = {
						NOT = { is_known_by = root }
						secret_type = secret_deviant
					}
					save_scope_as = deviant_guest_secret
				}
				if = {
					limit = {
						root = { is_ai = no }
					}
					add_character_flag = is_naked
				}
			}
		}
		
		if = {
			limit = {
				is_ai = no
			}
			if = {
				limit = {
					any_ruler = {
						yearly_8400_court_target_trigger = yes
					}
				}
				random_ruler = {
					limit = {
						yearly_8400_court_target_trigger = yes
					}
					save_scope_as = appropriate_court_target_owner
				}
			}
		}
		create_character_memory = {
			type = deviant_defiled_my_object
			participants = { deviant = scope:deviant_guest }
		}
	}

	option = { # Learn of the secret and force them to leave
		name = {
			trigger = { NOT = { exists = scope:appropriate_court_target_owner } }
			text = yearly.8400.a
		}
		name = {
			trigger = { exists = scope:appropriate_court_target_owner }
			text = yearly.8400.special
		}
		
		scope:deviant_guest_secret = {
			reveal_to = root
		}

		scope:deviant_guest = {
			if = {
				limit = {
					exists = scope:appropriate_court_target_owner
				}
				hidden_effect = {
					visit_court_of = scope:appropriate_court_target_owner
				}
				custom_tooltip = yearly.8400.a.tt
			}
			else = {
				select_and_move_to_pool_effect = yes
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = compassionate
					has_trait = just
				}
			}
		}

		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
	}
	
	option = { # Expose and throw them in jail
		name = yearly.8400.b
		
		add_piety = major_piety_gain
		
		scope:deviant_guest_secret = {
			expose_secret = root
		}

		rightfully_imprison_character_effect = {
			TARGET = scope:deviant_guest
			IMPRISONER = root
		}

		ai_chance = {
			base = 25
			
			modifier = {
				factor = 0
				ai_zeal < 0
			}
			
			modifier = {
				factor = 0
				has_trait = forgiving
			}
			
			modifier = {
				factor = 5
				ai_zeal >= medium_positive_ai_value
			}
		}

		stress_impact = {
			forgiving = major_stress_impact_gain
			deviant = massive_stress_impact_gain
		}
	}
	
	option = { # Learn of the secret and let them stay
		name = yearly.8400.c
		
		scope:deviant_guest_secret = {
			reveal_to = root
		}
		
		scope:deviant_guest = {
			add_opinion = {
				modifier = kindness_opinion
				target = root
				opinion = 25
			}
		}
			
		ai_chance = {
			base = 100
		}

		stress_impact = {
			zealous = major_stress_impact_gain
			just = medium_stress_impact_gain
		}
	}
	
	option = { # Learn of the secret, and... join in on the fun
		name = yearly.8400.d
		
		scope:deviant_guest_secret = {
			reveal_to = root
		}
		
		give_deviant_secret_or_trait_effect = yes
		
		if = {
			limit = {
				stress > 0
			}
			add_stress = monumental_stress_loss
		}
		
		if = {
			limit = {
				can_set_relation_friend_trigger = { CHARACTER = scope:deviant_guest }
			}
			set_relation_friend = { reason = friend_deviant_fun target = scope:deviant_guest }
		}
		
		ai_chance = {
			base = 5
			modifier = {
				add = 995
				has_trait = lustful
			}
		}

		stress_impact = {
			chaste = major_stress_impact_gain
			temperate = major_stress_impact_gain
		}
	}
	
	after = {
		scope:deviant_guest = {
			if = {
				limit = { has_character_flag = is_naked }
				remove_character_flag = is_naked
			}
		}
	}
}

yearly.8500 = { # Your Head of Faith sends you a gift if you're fighting heathens, by Alexander Oltner
	type = letter_event
	sender = {
		character = scope:current_head_of_faith
		animation = shock
	}
	opening = {
		desc = yearly.8500.opening
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = {
						has_doctrine = doctrine_pluralism_pluralistic
					}
				}
				desc = yearly.8500.desc.a
			}
			desc = yearly.8500.desc.b
		}
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_8500 }
		is_capable_adult = yes
		faith = {
			has_doctrine = doctrine_spiritual_head
			exists = religious_head
			religious_head = {
				is_available_ai_adult = yes
				opinion = {
					target = root
					value >= neutral_opinion
				}
				NOT = { ai_greed >= low_positive_ai_value }
				ai_zeal >= low_negative_ai_value
				gold >= root.head_of_faith_gold_value
			}
		}
		any_character_war = {
			using_holy_war_cb_trigger = yes
			casus_belli = {
				OR = {
					primary_defender = root
					primary_attacker = root
				}
			}
		}
		gold < major_gold_value
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 4
			gold < 0
		}
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_8500
			years = 5
		}
		faith.religious_head = {
			save_scope_as = current_head_of_faith
		}
	}
	
	option = {
		name = yearly.8500.a
		
		scope:current_head_of_faith = {
			pay_short_term_gold = {
				target = root
				gold = root.head_of_faith_gold_value
			}
		}
	}
	
	option = {
		name = yearly.8500.b
		
		add_piety = medium_piety_gain
		scope:current_head_of_faith = {
			add_opinion = {
				modifier = pious_opinion
				target = root
				opinion = 10
			}
		}
	}
}

################################
# A Mighty Elephant
# by Emil Tisander
################################
scripted_trigger yearly_9020_county_trigger = {
	tier = tier_county
	county_control = 100
}

scripted_trigger yearly_9020_knight_trigger = {
	is_available_adult = yes
	prowess >= 5
	is_councillor = no
	NOT = { has_character_modifier = yearly_9020_personal_war_elephant }
}

yearly.9020 = {
	type = character_event
	title = yearly.9020.t
	desc = yearly.9020.desc
	theme = martial
	override_background = {
		reference = throne_room
	}
	left_portrait = scope:marshal #cp:councillor_marshal
	right_portrait = scope:knight
	
	trigger = {
		NOT = { has_character_flag = had_event_yearly_9020 }
		NOT = { has_character_modifier = yearly_9020_personal_war_elephant }
		is_available_adult = yes
		is_at_war = no
		number_maa_regiments_of_type = {
			type = war_elephant
			value > 0
		}
		exists = cp:councillor_marshal
		any_knight = {
			yearly_9020_knight_trigger = yes
		}
		any_held_title = {
			yearly_9020_county_trigger = yes
		}
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_yearly_9020
			years = 25
		}
		
		cp:councillor_marshal = {
			save_scope_as = marshal
		}
		random_knight = {
			limit = {
				prowess >= 15
				is_councillor = no
				NOT = { has_character_modifier = yearly_9020_personal_war_elephant }
			}
			alternative_limit = {
				prowess >= 10
				is_councillor = no
				NOT = { has_character_modifier = yearly_9020_personal_war_elephant }
			}
			alternative_limit = {
				prowess >= 5
				is_councillor = no
				NOT = { has_character_modifier = yearly_9020_personal_war_elephant }
			}
			save_scope_as = knight
		}
		random_held_title = {
			limit = {
				yearly_9020_county_trigger = yes
			}
			save_scope_as = county
		}
	}
	
	option = { #Keep it yourself
		name = yearly.9020.a
		
		add_character_modifier = {
			modifier = yearly_9020_personal_war_elephant
			years = 40
		}
		add_prestige = minor_prestige_gain
		stress_impact = {
			generous = minor_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
			modifier = {
				add = 50
				has_trait = greedy
			}
			modifier = {
				add = 50
				prowess = 10
			}
		}
	}
	option = { #Gift it to your Marshal
		name = yearly.9020.b
		
		trigger = {
			exists = scope:marshal
			scope:marshal = {
				NOT = { has_character_modifier = yearly_9020_personal_war_elephant }
			}
		}
		
		scope:marshal = {
			add_character_modifier = {
				modifier = yearly_9020_personal_war_elephant
				years = 40
			}
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 20
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				add = 200
				reverse_opinion = {
					target = scope:marshal
					value <= 0
				}
			}
		}
	}
	option = { #Gift it to a Knight
		name = yearly.9020.c
		
		trigger = { exists = scope:knight }
		
		scope:knight = {
			add_character_modifier = {
				modifier = yearly_9020_personal_war_elephant
				years = 40
			}
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 20
			}
		}
		
		ai_chance = {
			base = 200
		}
	}
	
	###EK DISABLED: Hinduism does not exist in TES
	option = { #Release the Elephant
		name = {
			trigger = { always = no }
			# trigger = { religion = religion:hinduism_religion }
			text = yearly.9020.d1
		}
		name = {
			# trigger = { NOT = { religion = religion:hinduism_religion } }
			text = yearly.9020.d2
		}
		
		add_piety = medium_piety_gain
		
		ai_chance = {
			base = 100
		}
	}
}
