﻿namespace = stewardship_duty


# Stewardship (Duty) Events
	# 0001  	  - The Diplomatic craft - Mediating between disagreeing subjects, by Mathilda Bjarnehed
	# 0017  	  - Conflict at the Council, by Mathilda Bjarnehed
	# 1055		  - Unwanted Pregnancy, by Sean Hughes
	# 1062 - 1069 - Wealth Aplenty, by Sean Hughes
	# 1071 - 1072 - Serf Refugees, by Sean Hughes
	# 4010 - 4019 - Vassal Factionalism - Persuade a vassal to leave a faction for 10 years, by Sean Hughes
	# 4040 - 4044 - Altering the Deal - Persuade a vassal to accept a contract change, by Sean Hughes
	# 4060 - 4067 - Faction Organizing - Lower a faction's discontent during wartime, by Sean Hughes
	# 5021 		  - A Vassal cheats their contract, by Linnéa Thimrén
	# 7001  	  - Resolve a war between two ai vassals, by Linnéa Thimrén
	# 7023  	  - About that Favor, by Stephen Arthur and Sean Hughes

# Stewardship (Duty) Special Events
	# 1201 - 1299 - Map Painting Journey, by Petter Vilberg
	# 2000 - 2099 - Vassal Mediation, by Petter Vilberg

####################################
# The Diplomatic Craft 				
# Mediating between disagreeing subjects (vassals/courtiers
# by Mathilda Bjarnehed
# 0001
####################################

scripted_trigger stewardship_duty_0001_argumentative_trigger = {
	OR = {
		has_trait = wrathful
		has_trait = impatient
		has_trait = arrogant
		has_trait = ambitious
		has_trait = paranoid
		has_trait = callous
		has_trait = stubborn
		has_trait = vengeful
	}
}

scripted_trigger stewardship_duty_0001_complaisant_trigger = {
	OR = {
		has_trait = wrathful
		has_trait = impatient
		has_trait = arrogant
		has_trait = ambitious
		has_trait = paranoid
		has_trait = callous
		has_trait = stubborn
		has_trait = vengeful
	}
}

scripted_trigger stewardship_duty_0001_could_argue_with_arguer_1 = {
	basic_is_available_ai = yes
	is_adult = yes
	NOT = { this = scope:arguer_1 }
	opinion = {
		value < 20
		target = scope:arguer_1
	}
	reverse_opinion = {
		value < 20
		target = scope:arguer_1
	}
}

stewardship_duty.0001 = {
	type = character_event
	title = stewardship_duty.0001.t
	desc = {
		desc = stewardship_duty.0001.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:arguer_1
					exists = scope:arguer_2
					any_vassal = { this = scope:arguer_1 }
					any_vassal = { this = scope:arguer_2 }
				}
				desc = stewardship_duty.0001.vassals.desc
			}
			desc = stewardship_duty.0001.vassalandcourtier.desc
		}
		desc = stewardship_duty.0001.end.desc
	}
	
	theme = stewardship_duty_focus

	left_portrait = {
		character = scope:arguer_1
		animation = dismissal
	}

	right_portrait = {
		character = scope:arguer_2
		animation = anger
	}

	
	trigger = {
		is_in_civil_war = no
		NOT = { has_character_flag = had_event_stewardship_duty_0001 }
		any_vassal = { #Is there a vassal who has a mutual grudge with other vassal or courtier?
			is_ai = yes
			save_temporary_scope_as = arguer_1
			liege = {
				OR = {
					any_vassal = { stewardship_duty_0001_could_argue_with_arguer_1 = yes }
					any_courtier = { stewardship_duty_0001_could_argue_with_arguer_1 = yes }
				}
			}
		}	
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stewardship_duty_0001
			days = 1825
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}
		random_vassal = { #Find that vassal
			limit = {
				is_ai = yes
				save_temporary_scope_as = arguer_1
				liege = {	
					OR = {
						any_vassal = { stewardship_duty_0001_could_argue_with_arguer_1 = yes }
						any_courtier = { stewardship_duty_0001_could_argue_with_arguer_1 = yes }
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					any_relation = {
						type = rival
						exists = liege
						liege = root
					}
					factor = 10
				}
				modifier = {
					is_powerful_vassal = yes
					factor = 5
				}
				modifier = {
					stewardship_duty_0001_argumentative_trigger = yes
					factor = 3
				}
				modifier = {
					OR = {
						stewardship_duty_0001_complaisant_trigger = yes
					}
					factor = 0.5
				}
			}
			save_scope_as = arguer_1
		}

		#And their unfriend
		random_vassal = {
			limit = {
				stewardship_duty_0001_could_argue_with_arguer_1 = yes
			}
			weight = {
				base = 1
				modifier = {
					any_relation = { type = rival this = scope:arguer_1 }
					factor = 5
				}
				modifier = {
					is_powerful_vassal = yes
					factor = 5
				}
				modifier = {
					OR = {
						opinion = {
							value < 0
							target = scope:arguer_1
						}
						reverse_opinion = {
							value < 0
							target = scope:arguer_1
						}	
					}
					factor = 5
				}
				modifier = {
					stewardship_duty_0001_argumentative_trigger = yes
					factor = 3
				}
				modifier = {
					OR = {
						stewardship_duty_0001_complaisant_trigger = yes
					}
					factor = 0.5
				}
			}
			save_scope_as = arguer_2
		}

		if = {
			limit = { NOT = { exists = scope:arguer_2 } }

			random_courtier = {
				limit = {
					stewardship_duty_0001_could_argue_with_arguer_1 = yes
				}
				weight = {
					base = 1
					modifier = {
						any_relation = { type = rival this = scope:arguer_1 }
						factor = 5
					}
					modifier = {
						OR = {
							opinion = {
								value < 0
								target = scope:arguer_1
							}
							reverse_opinion = {
								value < 0
								target = scope:arguer_1
							}	
						}
						factor = 5
					}
					modifier = {
					stewardship_duty_0001_argumentative_trigger = yes
					factor = 3
					}
					modifier = {
						OR = {
							stewardship_duty_0001_complaisant_trigger = yes
						}
						factor = 0.5
					}
				}
				save_scope_as = arguer_2
			}
		}
	}

	#Attempt to mediate
	option = {
		name = stewardship_duty.0001.a

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			skill = diplomacy
			value = decent_skill_rating
			15 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				desc = stewardship_duty.0001.a.success.tt

				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty.0001.a.success.tt
					left_icon = scope:arguer_1
					right_icon = scope:arguer_2

					add_prestige = medium_prestige_gain
					custom_tooltip = stewardship_duty_0001_mediation_success.tt
				}
				hidden_effect = {
					scope:arguer_1 = {
						add_opinion = {
							modifier = respect_opinion
							opinion = 20
							target = scope:arguer_2
						}
					}
					scope:arguer_2 = {
						add_opinion = {
							modifier = respect_opinion
							opinion = 20
							target = scope:arguer_1
						}
					}
				}
			}
			12 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = stewardship_duty.0001.a.failure.tt
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_duty.0001.a.failure.tt
					left_icon = scope:arguer_1
					right_icon = scope:arguer_2

					scope:arguer_1 = {
						add_opinion = {
							modifier = angry_opinion
							opinion = -10
							target = root
						}
					}
					scope:arguer_2 = {
						add_opinion = {
							modifier = angry_opinion
							opinion = -10
							target = root
						}
					}
				}
			}
		}

		stress_impact = {
			wrathful = minor_stress_gain
			craven = minor_stress_gain
			shy = minor_stress_gain
		}
	}

	#Gain points with arguer 1
	option = {
		name = stewardship_duty.0001.b

		scope:arguer_1 = {
			add_opinion = {
				modifier = belittled_my_enemy
				years = 5
				target = root
			}
		}

		stress_impact = {
			honest = minor_stress_gain
			just = minor_stress_gain
			compassionate = minor_stress_gain
		}
	}
	
	#Gain points with arguer 2
	option = {
		name = stewardship_duty.0001.c
		
		scope:arguer_2 = {
			add_opinion = {
				modifier = belittled_my_enemy
				years = 5
				target = root
			}
		}

		stress_impact = {
			honest = minor_stress_gain
			just = minor_stress_gain
			compassionate = minor_stress_gain
		}
	}
}

####################################
# Conflict at the Council				
# by Mathilda Bjarnehed
# 0017
####################################

stewardship_duty.0017 = {
	type = character_event
	title = stewardship_duty.0017.t
	desc = {
		desc = stewardship_duty.0017.start.desc
		random_valid = {
			triggered_desc = {
				trigger = { is_at_war = yes }
				desc = stewardship_duty.0017.war.desc
			}
			triggered_desc = {
				trigger = {
					primary_title = {
						has_order_of_succession = election
					}
				}
				desc = stewardship_duty.0017.election.desc
			}
			triggered_desc = {
				trigger = { gold > 0 }
				desc = stewardship_duty.0017.building_projects.desc
			}
			desc = stewardship_duty.0017.troop_training.desc
			triggered_desc = {
				trigger = {
					OR = {
						ai_compassion > 0
						ai_zeal > 0
					}
				}
				desc = stewardship_duty.0017.charity_projects.desc
			}
			triggered_desc = {
				trigger = {
					OR = {
						ai_compassion > 0
						ai_zeal > 0
					}
				}
				desc = stewardship_duty.0017.religious_minorities.desc
			}
			triggered_desc = {
				trigger = {
					OR = {
						any_vassal = { has_epidemic_disease_trigger = yes }
						any_courtier = { has_epidemic_disease_trigger = yes }
					}
				}
				desc = stewardship_duty.0017.health_issues.desc
			}
		}
		desc = stewardship_duty.0017.end.desc
	}
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:councillor_1
		animation = anger
	}
	right_portrait = {
		character = scope:councillor_2
		animation = dismissal
	}


	
	trigger = {
		NOT = { has_character_flag = had_event_stewardship_duty_0017 }
		is_commanding_army = no
		any_normal_councillor = {
			count >= 2
			is_available_ai_adult = yes
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stewardship_duty_0017
			days = 1825
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}
		hidden_effect = {
			#Find councillors
			random_normal_councillor = {
				limit = { is_available_ai_adult = yes }
				weight = {
					base = 1
					modifier = {
						is_powerful_vassal_of = root
						factor = 3
					}
					modifier = {
						ai_boldness >= medium_positive_boldness
						factor = 2
					}
					modifier = {
						ai_greed >= medium_positive_greed
						factor = 2
					}
					modifier = {
						ai_boldness <= low_negative_boldness
						factor = 0.5
					}
					modifier = {
						ai_greed <= low_negative_greed
						factor = 0.5
					}
				}
				save_scope_as = councillor_1
			}
			random_normal_councillor = {
				limit = {
					is_available_ai_adult = yes
					NOT = { this = scope:councillor_1 }
				}
				weight = {
					base = 1
					modifier = {
						is_powerful_vassal_of = root
						factor = 3
					}
					modifier = {
						opinion = {
							value < 0
							target = scope:councillor_1
						}
						factor = 3
					}
					modifier = {
						ai_boldness >= medium_positive_boldness
						factor = 2
					}
					modifier = {
						ai_greed >= medium_positive_greed
						factor = 2
					}
					modifier = {
						ai_boldness <= low_negative_boldness
						factor = 0.5
					}
					modifier = {
						ai_greed <= low_negative_greed
						factor = 0.5
					}
				}
				save_scope_as = councillor_2
			}
		}
	}

	#Take the side of councillor 1
	option = {
		name = stewardship_duty.0017.a

		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:councillor_1
			opinion = 15
		}
	}

	#Take the side of councillor 2
	option = {
		name = stewardship_duty.0017.b

		reverse_add_opinion = {
			modifier = respect_opinion
			target = scope:councillor_2
			opinion = 15
		}
	}
	
	#Compromise
	option = {
		name = stewardship_duty.0017.c

		duel = {
			skill = diplomacy
			value = medium_skill_rating
			5 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -4
				}
				trigger = {
					NAND = {
						has_hook = scope:councillor_1
						has_hook = scope:councillor_2
					}
				}
				desc = stewardship_duty.0017.c.criticial_success.tt
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty.0017.c.criticial_success.tt
					left_icon = scope:councillor_1
					right_icon = scope:councillor_2
					if = {
						limit = {
							can_add_hook = {
								target = scope:councillor_1
								type = favor_hook
							}
						}
						add_hook = {
							target = scope:councillor_1
							type = favor_hook
						}
					}
					if = {
						limit = {
							can_add_hook = {
								target = scope:councillor_2
								type = favor_hook
							}
						}
						add_hook = {
							target = scope:councillor_2
							type = favor_hook
						}
					}
				}
				# To keep the toast display smaller	
				reverse_add_opinion = {
					modifier = respect_opinion
					target = scope:councillor_1
					opinion = 15
				}
				reverse_add_opinion = {
					modifier = respect_opinion
					target = scope:councillor_2
					opinion = 15
				}
			}
			15 = {
				desc = stewardship_duty.0017.c.success.tt
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty.0017.c.success.tt
					left_icon = scope:councillor_1
					right_icon = scope:councillor_2
					reverse_add_opinion = {
						modifier = respect_opinion
						target = scope:councillor_1
						opinion = 15
					}
					reverse_add_opinion = {
						modifier = respect_opinion
						target = scope:councillor_2
						opinion = 15
					}
				}
			}
			10 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				desc = stewardship_duty.0017.c.failure.tt
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_duty.0017.c.failure.tt
					left_icon = scope:councillor_1
					right_icon = scope:councillor_2
					reverse_add_opinion = {
						modifier = disappointed_opinion
						target = scope:councillor_1
						opinion = -10
					}
					reverse_add_opinion = {
						modifier = disappointed_opinion
						target = scope:councillor_2
						opinion = -10
					}
				}
			}
		}
	}
}

##################################
# An Unwanted Pregnancy
# 1055
# by Sean Hughes
##################################

#Minimum requirements for the daughter/son/spouse/concubine.
scripted_trigger stewardship_duty_1055_minimum_et_requirements = {
	is_available_ai_adult = yes

	#Must not be landed, as their parent/spouse/employer is going to be advocating for them.
	is_landed = no

	#Must not currently be pregnant.
	is_pregnant = no
	fertility > 0

	#Must be of an age where having children is likely.
	age >= 16
	age < 40

	#Must not be chaste (since they allegedly had extramarital relations, and it could feel odd to the player if they are chaste).
	NOT = { has_trait = chaste }
}

#Ideal requirements for us to use a vassal's child as one of the event targets (creates more drama/choices for player).
scripted_trigger stewardship_duty_1055_is_unwed_child = {

	#Meets all of the minimum requirements.
	stewardship_duty_1055_minimum_et_requirements = yes

	#Is not married and has not had any other kids (if female).
	is_married = no

	OR = {
		NOT = {
			any_child = {
				exists = this
			}
		}
		is_female = no
	}


	#Must have the same dynasty as their parent (no bastards).
	dynasty = prev.dynasty
}

#Requirements for Vassal 1 (the mother's parent or spouse).
scripted_trigger stewardship_duty_1055_valid_mother_parent_or_spouse = {
	is_available_ai_adult = yes
	highest_held_title_tier > 1

	#Must be of a different dynasty than Root.
	NOT = { dynasty = root.dynasty}

	#Must have either...
	OR = {
		#A non-pregnant, unmarried daughter(preferred).
		any_child = {
			is_female = yes
			stewardship_duty_1055_is_unwed_child = yes
		}
		#Or a non-pregnant wife or concubine(acceptable).
		any_consort = {
			is_female = yes
			mgr_can_seduce = yes
			stewardship_duty_1055_minimum_et_requirements = yes
		}
	}
}

# Requirements for Vassal 2 (the father's parent).
scripted_trigger stewardship_duty_1055_valid_father_parent = {
	is_available_ai_adult = yes
	highest_held_title_tier > 1

	# Must be of a different dynasty than Root or Vassal 1.
	NOR = {
		dynasty = root.dynasty
		dynasty = scope:vassal_1.dynasty
	}

	# Must not be the vassal of the mother's parent.
	NOT = {
		is_vassal_of = scope:vassal_1
	}

	# Must have an unmarried son.
	any_child = {
		is_male = yes
		mgr_can_seduce = yes
		stewardship_duty_1055_is_unwed_child = yes
	}
}

stewardship_duty.1055 = {
	type = character_event
	title = stewardship_duty.1055.t
	desc = stewardship_duty.1055.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	left_portrait = {
		character = scope:new_mothers_parent
		animation = anger
	}
	lower_left_portrait = scope:new_mother
	right_portrait = {
		character = scope:new_fathers_parent
		animation = disapproval
	}	
	lower_right_portrait = scope:new_father
	
	trigger = {
		NOT = { has_character_flag = had_event_stewardship_duty_1055 }
		#We must have a vassal with a different dynasty who has an unwed daughter.
		any_vassal_or_below = {
			is_vassal_of = root
			stewardship_duty_1055_valid_mother_parent_or_spouse = yes

			save_temporary_scope_as = vassal_1

			#We also must have a vassal from a diffent family who has an unwed son.
			root = {
				any_vassal_or_below = {
					stewardship_duty_1055_valid_father_parent = yes
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = 	had_event_stewardship_duty_1055
			years = 5
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}
		#Find a vassal to serve as the advocate for our female event target.
		random_vassal_or_below = {
			#Ideally we want a vassal who has an unwed daughter.
			limit = {
				is_vassal_of = root
				stewardship_duty_1055_valid_mother_parent_or_spouse = yes
				any_child = {
					is_female = yes
					stewardship_duty_1055_is_unwed_child = yes
				}
				save_temporary_scope_as = vassal_1

				#Ensure that if we pick this vassal, there will still be at least one choice for the male event target.
				root = {
					any_vassal_or_below = {
						stewardship_duty_1055_valid_father_parent = yes
					}
				}
			}
			#If none are available, settle for a vassal who has a non-pregnant wife or concubine.
			alternative_limit = {
				is_vassal_of = root
				stewardship_duty_1055_valid_mother_parent_or_spouse = yes
				save_temporary_scope_as = vassal_1

				#Ensure that if we pick this vassal, there will still be at least one choice for the male event target.
				root = {
					any_vassal_or_below = {
						stewardship_duty_1055_valid_father_parent = yes
					}
				}
			}

			#Heavily weight the chosen vassal to be our direct vassal, ideally one who is powerful and/or has a high tier.
			weight = {
				base = 100
				modifier = {
					factor = 10
					is_vassal_of = root
				}
				modifier = {
					factor = 100
					is_powerful_vassal_of = root

				}
				compare_modifier = {
					factor = highest_held_title_tier
					multiplier = 10
				}
			}

			save_scope_as = vassal_1 # Keep it for limit.
			# Save the scope of this vassal as the new_mothers_parent.
			save_scope_as = new_mothers_parent

			#Select a character to be the new_mother.
			if = {
				#Ideally we will pick their unwed daughter, if they have one.
				limit = {
					any_child = {
						is_female = yes
						stewardship_duty_1055_is_unwed_child = yes
					}
				}
				random_child = {
					limit = {
						is_female = yes
						stewardship_duty_1055_is_unwed_child = yes
					}

					#Prefer younger, lustful characters.
					weight = {
						base = 100

						compare_modifier = {
							value = age
							multiplier = -2.5
						}
						modifier = {
							has_trait = lustful
							add = 100
						}

						#Also up the odds if this character stands to inherit a title (especially the primary one).
						modifier = {
							factor = 10
							is_primary_heir_of = scope:new_mothers_parent
						}
						modifier = {
							factor = 3
							is_heir_of = scope:new_mothers_parent
						}
					}

					save_scope_as = new_mother
				}
			}
			else = {
				#Otherwise, select one of their wives or concubines who isn't currently pregnant.
				random_consort = {
					limit = {
						is_female = yes
						mgr_can_seduce = yes
						stewardship_duty_1055_minimum_et_requirements = yes
					}

					#Prefer younger, lustful characters.
					weight = {
						base = 100

						compare_modifier = {
							value = age
							multiplier = -2.5
						}
						modifier = {
							has_trait = lustful
							add = 100
						}

						#Also up the odds if this character stands to inherit a title (especially the primary one).
						modifier = {
							factor = 10
							is_primary_heir_of = scope:new_mothers_parent
						}
						modifier = {
							factor = 3
							is_heir_of = scope:new_mothers_parent
						}
					}

					save_scope_as = new_mother
				}
			}
		}

		#Find a 2nd vassal of a different dynasty who has an unwed son
		random_vassal_or_below = {
			limit = {
				is_vassal_of = root
				stewardship_duty_1055_valid_father_parent = yes
			}
			alternative_limit = {
				stewardship_duty_1055_valid_father_parent = yes
			}

			#Heavily weight the chosen vassal to be our direct vassal, ideally one who is powerful and/or has a high tier.
			weight = {
				base = 100
				modifier = {
					factor = 100
					is_powerful_vassal_of = root

				}
				compare_modifier = {
					factor = highest_held_title_tier
					multiplier = 10
				}
			}
			save_scope_as = new_fathers_parent

			#Select one of their sons to be the new father.
			random_child = {
				limit = {
					is_male = yes
					mgr_can_seduce = yes
					stewardship_duty_1055_is_unwed_child = yes
				}

				#Favor younger, lustful characters.
				weight = {
					base = 100
					
					compare_modifier = {
						value = age
						multiplier = -2.5
					}
					modifier = {
						has_trait = lustful
						add = 100
					}

					#Also up the odds if this character stands to inherit a title (especially the primary one).				
					modifier = {
						factor = 10
						is_primary_heir_of = scope:new_fathers_parent
					}
					modifier = {
						factor = 3
						is_heir_of = scope:new_fathers_parent
					}
				}
				save_scope_as = new_father
			}
		}


		#Pregnancy Set-Up
		hidden_effect = {
			scope:new_mother = {
				make_pregnant = {
					father = scope:new_father
				}
			}
		}
		#Reveal the illigitimate pregnancy to all event characters
		scope:new_mother = {
			set_known_bastard_on_pregnancy = yes
			add_character_flag = {
				flag = pregnancy_real_father_of_bastard_is_known_flag
				months = 10
			}
		}

	}

	#Option 1: Side with the mother's family, and force the father's family to pay renumeration.
	option = {
		name = stewardship_duty.1055.a

		scope:new_mothers_parent = {
			#Mother's parent is pleased you sided with them.
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 20
			}
		}

		scope:new_fathers_parent = {
			#Since this event already has so many conditions, we will magic the gold into existance instead of needing a vassal who actually has it.
			show_as_tooltip = {
				pay_short_term_gold = {
					target = scope:new_mothers_parent
					gold = medium_gold_value
				}
			}
			hidden_effect = {
				scope:new_mothers_parent = {
					add_gold = medium_gold_value
				}
			}
			#Father's parent is still angry at being 'forced' to pay the gold, though.
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -20
			}
		}

		#Gain focus progress for making a legal decision.
		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		#AI will only side with the mother's family if they are of a higher rank than the father's.
		ai_chance = {
			base = 1

			modifier = {
				scope:new_mothers_parent.highest_held_title_tier > scope:new_fathers_parent.highest_held_title_tier
				add = 500
			}

			modifier = {
				scope:new_mothers_parent = {
					is_vassal_of = root
				}
				add = 100
			}

			modifier = {
				has_trait = chaste
				add = 100
			}
		}
	}

	#Option 2: Side with the father's family, and declare no renumeration needs to be paid at all.
	option = {
		name = stewardship_duty.1055.b
		scope:new_fathers_parent = {
			#Father's parent is pleased you sided with them.
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 20
			}
		}
		scope:new_mothers_parent = {
			#Mother's parent is angry at being spurned by you.
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -20
			}
		}

		#Gain focus progress for making a legal decision.
		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		#AI will only side with the father's family if they are of a higher rank than the mother's.
		ai_chance = {
			base = 1

			modifier = {
				scope:new_fathers_parent.highest_held_title_tier > scope:new_mothers_parent.highest_held_title_tier
				add = 500
			}

			modifier = {
				AND = {
					has_trait = just
					scope:new_mother.faith = {
						NOT = { has_doctrine_parameter = bastards_none }
					}
				}
				add = 250
			}

			modifier = {
				scope:new_fathers_parent = {
					is_vassal_of = root
				}
				add = 100
			}

			modifier = {
				has_trait = lustful
				add = 100
			}
		}
	}	

	#Option 3: Delcare that this is a waste of your time and that your vassals shouldn't bother you.
	option = {
		name = stewardship_duty.1055.e

		#Gain prestige for exerting your authority.
		add_prestige = medium_prestige_gain

		#But both parents dislike you somewhat.
		scope:new_fathers_parent = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -10
			}
		}
		scope:new_mothers_parent = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -10
			}
		}

		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_compassion = -200
				ai_honor = -200
				ai_energy = -200
			}
		}
	}
}

##################################
# Wealth Aplenty
# 1062-1069
# by Sean Hughes
##################################

#You sure have a lot of gold there, boy-o. Maybe you should find someone to patronize?
stewardship_duty.1062 = {
	type = character_event
	title = stewardship_duty.1062.t
	desc = stewardship_duty.1062.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = scope:client_1
	right_portrait = scope:client_2
	lower_center_portrait = scope:client_3

	trigger = {
		OR = {
			AND = {
				is_ai = no
				gold > medium_gold_value
			}
			AND = {
				is_ai = yes
				short_term_gold > medium_gold_value
			}
		}
		NOT = { has_character_flag = had_stewardship_duty_1062_event }
		exists = capital_province # Need a pool to put characters into
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_stewardship_duty_1062_event
			days = 3650
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}

		#Get a character for our gardener.
		stewardship_duty_1062_get_client_effect = {
			FLAG = governance_1062_gardener_flag
			CLIENT_SCOPE = client_1
		}
		if = {
			limit = {
				NOT = { exists = scope:client_1 }
			}
			stewardship_duty_1062_create_gardener_effect = { CLIENT_SCOPE = client_1 }
		}
		#Get a character for our poet
		stewardship_duty_1062_get_client_effect = {
			FLAG = governance_1062_poet_flag
			CLIENT_SCOPE = client_2
		}
		if = {
			limit = {
				NOT = { exists = scope:client_2 }
			}
			stewardship_duty_1062_create_poet_effect = { CLIENT_SCOPE = client_2 }
		}
		#Get a character for our philosopher
		stewardship_duty_1062_get_client_effect = {
			FLAG = governance_1062_philosopher_flag
			CLIENT_SCOPE = client_3
		}
		if = {
			limit = {
				NOT = { exists = scope:client_3 }
			}
			stewardship_duty_1062_create_philosopher_effect = { CLIENT_SCOPE = client_3 }
		}
	}

	#Option A: Patronize a gardener for prestige.
	option = {
		name = stewardship_duty.1062.a

		#Pay gold to be their patron.
		remove_short_term_gold = medium_gold_value

		#Add client to court.
		add_courtier = scope:client_1
		scope:client_1 = {
			set_variable = {
				name = stewardship_duty_1062_employer
				value = root
			}
			#Re-save the scope to make the scripting for follow-up events more straightforward.
			save_scope_as = client
			hidden_effect = {
				give_nickname = nick_the_gardener
			}
		}

		#Gain a bonus to monthly prestige.
		add_character_modifier = {
			modifier = governance_1062_immaculate_gardens_modifier
			years = 5
		}


		stress_impact = {
			greedy = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 1.5
				ai_honor = 1.5
				ai_greed = -1
			}
		}

	}

	#Option B: Patronize a tapestier for piety.
	option = {
		name = stewardship_duty.1062.b

		#Pay gold to be their patron.
		remove_short_term_gold = medium_gold_value

		#Add client to court.
		add_courtier = scope:client_2
		scope:client_2 = {
			set_variable = {
				name = stewardship_duty_1062_employer
				value = root
			}
			#Re-save the scope to make the scripting for follow-up events more straightforward.
			save_scope_as = client
			hidden_effect = {
				give_nickname = nick_the_poet
			}
		}

		#Gain a bonus to monthly piety.
		add_character_modifier = {
			modifier = governance_1062_religious_tapestries_modifier
			years = 5
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			cynical = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_zeal = 3
				ai_greed = -1
			}
		}
	}
	
	#Option C: Patronize a natural philosopher for innovations.
	option = {
		name = stewardship_duty.1062.c

		#Pay gold to be their patron.
		remove_short_term_gold = medium_gold_value

		#Add client to court.
		add_courtier = scope:client_3
		scope:client_3 = {
			set_variable = {
				name = stewardship_duty_1062_employer
				value = root
			}
			#Re-save the scope to make the scripting for follow-up events more straightforward.
			save_scope_as = client
			hidden_effect = {
				give_nickname = nick_the_philosopher
			}
		}

		#Gain a bonus to cultural innovation discovery.
		add_character_modifier = {
			modifier = governance_1062_natural_philosopher_modifier
			years = 5
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			dull = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1.5
				ai_rationality = 1.5
				ai_greed = -1
			}
		}
	}

	#Option D: Opt-out. Miniscule prestige loss for hoarding funds.
	option = {
		name = stewardship_duty.1062.d
		trigger = {
			NOT = { has_trait = greedy }
		}
		
		add_prestige = minor_prestige_loss

		stress_impact = {
			gregarious = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
			shrewd = minor_stress_impact_gain
			
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 2
				ai_rationality = -1
			}
		}
	}

	#Option D (Greedy): I'm just going to bask in my gold's presence.
	option = {
		name = stewardship_duty.1062.e
		trigger = {
			has_trait = greedy
		}
		trait = greedy
		
		stress_impact = {
			greedy = medium_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 10
			}
		}
	}

	after = {
		#Trigger the renewal event in 5 years.
		trigger_event = {
			id = stewardship_duty.1063
			days = 1820 #Just under 5 years, so we can fire it before our old buff expires.
		}
	}
}

#Patronage renewal event after 5 years elapse
stewardship_duty.1063 = {
	type = character_event
	title = stewardship_duty.1063.t
	desc = stewardship_duty.1063.desc
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = scope:client

	trigger = {
		exists = scope:client
		scope:client = {
			is_alive = yes
			has_variable = stewardship_duty_1062_employer
		}
	}

	option = {
		name = stewardship_duty.1063.a

		#Remove the standard patronage cost.
		remove_short_term_gold = medium_gold_value

		#Extend the duration of your client's patron buff.
		stewardship_duty_1064_extend_patronage_term_effect = {
			CLIENT = scope:client
		}

		#Trigger the renewal event in 5 years.
		trigger_event = {
			id = stewardship_duty.1063
			days = 1820 #Just under 5 years, so we can fire it before our old buff expires.
		}
	}

	option = {
		name = stewardship_duty.1063.b

		#Give your client a 20% bonus for an opinion boost.
		remove_short_term_gold = {
			value = medium_gold_value
			multiply = 1.2
		}
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:client
			opinion = 20
		}

		#Extend the duration of your client's patron buff.
		stewardship_duty_1064_extend_patronage_term_effect = {
			CLIENT = scope:client
		}

		#Trigger the renewal event in 5 years.
		trigger_event = {
			id = stewardship_duty.1063
			days = 1820 #Just under 5 years, so we can fire it before our old buff expires.
		}
	}
	

	option = {
		name = stewardship_duty.1063.c

		#Remove the client's patronage buff.
		if = {
			limit = {
				has_character_modifier = governance_1062_immaculate_gardens_modifier
			}
			remove_character_modifier = governance_1062_immaculate_gardens_modifier
		}
		else_if = {
			limit = {
				has_character_modifier = governance_1062_religious_tapestries_modifier
			}
			remove_character_modifier = governance_1062_religious_tapestries_modifier
		}
		else_if = {
			limit = {
				has_character_modifier = governance_1062_natural_philosopher_modifier
			}
			remove_character_modifier = governance_1062_natural_philosopher_modifier
		}

		#Return the client to the character pool.
		remove_courtier_or_guest = scope:client
	}
}

#Client leaves court and no longer works for you.
stewardship_duty.1064 = {
	hidden = yes
	
	trigger = {
		exists = this
		is_alive = yes
		has_variable = stewardship_duty_1062_employer
		NAND = {
			is_imprisoned = yes
			imprisoner = root
		}
	}

	immediate = {
		save_scope_as = client
		var:stewardship_duty_1062_employer = {
			send_interface_message = {
				type = event_stewardship_bad
				title = stewardship_duty.1064.desc
				left_icon = scope:client

				#Remove the buff you have from your client.
				stewardship_duty_1064_remove_patrons_buff_effect = { CLIENT = scope:client }
			}
		}
	}
}

#Client dies and can no longer work for you.
stewardship_duty.1065 = {
	hidden = yes

	trigger = {
		exists = this
		has_variable = stewardship_duty_1062_employer
	}
	
	immediate = {
		save_scope_as = client
		var:stewardship_duty_1062_employer = {

			if = {
				limit = {
					OR = {
						AND = {
							exists = scope:killer
							this = scope:killer
						}
						any_secret = {
							secret_type = secret_murder
							secret_target = root
						}
					}
				}
				# If we killed our client, change the description from passive voice to active in order to make the message more impactful.
				send_interface_message = {
					type = event_stewardship_neutral
					title = stewardship_duty.1065.guilty.desc
					left_icon = scope:client

					#Remove the buff you have from your client.
					stewardship_duty_1064_remove_patrons_buff_effect = { CLIENT = scope:client }
				}
			}
			else = {
				send_interface_message = {
					type = event_stewardship_bad
					title = stewardship_duty.1065.desc
					left_icon = scope:client

					#Remove the buff you have from your client.
					stewardship_duty_1064_remove_patrons_buff_effect = { CLIENT = scope:client }
				}
			}
		}
	}
}

#You imprison your client so they can no longer work for you.
stewardship_duty.1066 = {
	hidden = yes

	trigger = {
		exists = this
		has_variable = stewardship_duty_1062_employer
		imprisoner = var:stewardship_duty_1062_employer
	}
	
	immediate = {
		save_scope_as = client
		var:stewardship_duty_1062_employer = {
			send_interface_message = {
				type = event_stewardship_neutral
				title = stewardship_duty.1066.desc
				left_icon = scope:client

				#Remove the buff you have from your client.
				stewardship_duty_1064_remove_patrons_buff_effect = { CLIENT = scope:client }
			}
		}
	}
}

#When you die, your clients return to the character pool.
stewardship_duty.1067 = {
	hidden = yes

	#Only occurs if you are employing any clients.
	trigger = {
		any_courtier = {
			has_variable = stewardship_duty_1062_employer
		}
	}

	#Every client will return to the character pool after removing their employment reference.
	immediate = {
		every_courtier = {
			limit = {
				has_variable = stewardship_duty_1062_employer
			}
			remove_variable = stewardship_duty_1062_employer
			root = {
				remove_courtier_or_guest = prev
			}
		}
	}
}

#If you are patronizing a client, they will occasionally do something cool and beneficial for you.
scripted_trigger stewardship_duty_1068_vassal_trigger = {
	is_available_healthy_ai_adult = yes
	opinion = {
		target = root
		value > -10
	}
}

stewardship_duty.1068 = {
	hidden = yes

	trigger = {
		#Only valid if we have a client
		any_courtier = {
			has_variable = stewardship_duty_1062_employer
			# If our client is a gardener, we must also have a vassal who can be impressed by them.
			trigger_if = {
				limit = {
					has_character_flag = governance_1062_gardener_flag
				}
				any_vassal = {
					stewardship_duty_1068_vassal_trigger = yes
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}
	
	immediate = {
		#Save the scope for our client.
		random_courtier = {
			limit = {
				has_variable = stewardship_duty_1062_employer
				trigger_if = {
					limit = {
						has_character_flag = governance_1062_gardener_flag
					}
					any_vassal = {
						stewardship_duty_1068_vassal_trigger = yes
					}
				}
			}
			save_scope_as = client
		}
		
		#Applies a bonus based on what type of client we have.
		if = {
			limit = {
				scope:client = {
					has_character_flag = governance_1062_gardener_flag
				}
			}
			#Finds a vassal who can visit us, and who we would benefit from improved relations with.
			random_vassal = {
				limit = {
					highest_held_title_tier >= 2
					stewardship_duty_1068_vassal_trigger = yes
				}
				alternative_limit = {
					stewardship_duty_1068_vassal_trigger = yes
				}

				weight = {
					base = 10
					modifier = {
						add = 90
						opinion = {
							target = root
							value <= 60
						}
					}
					compare_modifier = {
						multiplier = 10
						factor = highest_held_title_tier
					}
				}
				save_scope_as = my_vassal
			}

			#Vassal is impressed by your gardens.
			send_interface_message = {
				type = event_stewardship_good
				title = stewardship_duty.1068.desc.a
				left_icon = scope:my_vassal
				right_icon = scope:client

				reverse_add_opinion = {
					modifier = respect_opinion
					target = scope:my_vassal
					opinion = 25
				}
			}
		}
		else_if = {
			limit = {
				scope:client = {
					has_character_flag = governance_1062_poet_flag
				}
			}
			#Clergy approves of your poet's writings
			send_interface_message = {
				type = event_stewardship_good
				title = stewardship_duty.1068.desc.b
				left_icon = scope:client

				add_piety = medium_piety_gain
			}
		}
		else_if = {
			limit = {
				scope:client = {
					has_character_flag = governance_1062_philosopher_flag
				}
			}
			#Philosopher makes an important breakthrough
			send_interface_message = {
				type = event_stewardship_good
				title = stewardship_duty.1068.desc.c
				left_icon = scope:client

				random_held_title = {
					limit = {
						tier = tier_county
						development_level < 100
					}
					if = {
						limit = {
							development_level < 20
						}
						random_list = {
							5 = {
								change_development_level = 1
							}
							20 = {
								change_development_progress_with_overflow = 75
							}
							75 = {
								change_development_progress_with_overflow = 50
							}
						}
					}
					else_if = {
						limit = {
							development_level < 50
						}
						random_list = {
							10 = {
								change_development_progress_with_overflow = 75
							}
							90 = {
								change_development_progress_with_overflow = 50
							}
						}
					}
					else = {
						change_development_progress_with_overflow = 50
					}
				}
			}
		}
	}
}


##################################
# Serf Refugees
# 1071-1072
# by Sean Hughes
##################################

scripted_trigger stewardship_duty_1071_abusive_ruler = {

	#Neighboring province must be held by an AI Feudal Lord who is not our liege.
	has_government = feudal_government
	NOT = {this = root}
	NOT = {
		root = {
			target_is_liege_or_above = prev
		}
	}
	is_ai = yes

	#Holder must have a personality which could lead to abuse of the peasants.
	OR = {
		has_trait = torturer
		has_trait = sadistic
		has_trait = wrathful
		has_trait = arbitrary
	}
	NOR = {
		has_trait = just
		has_trait = compassionate
	}
}

#Triggers for validating the county that the serfs are fleeing from.
scripted_trigger stewardship_duty_1071_valid_origin_county = {
	
	#County cannot have already be involved in this event within the past 10 years.
	tier = tier_county
	NOR = {
		has_county_modifier = governance_1071_extra_serfs_modifier
		has_county_modifier = governance_1071_missing_serfs_modifier
	}

	#County must be held by an abusive ruler.
	holder = {
		stewardship_duty_1071_abusive_ruler = yes
	}
}

#Trigger for validating the county the serfs are fleeing to.
scripted_trigger stewardship_duty_1071_valid_target_county = {

	#County cannot have already be involved in this event within the past 10 years.
	tier = tier_county
	NOR = {
		has_county_modifier = governance_1071_extra_serfs_modifier
		has_county_modifier = governance_1071_missing_serfs_modifier
	}

	#County must be adjacent to a county held by an abusive AI ruler.
	any_neighboring_county = {
		stewardship_duty_1071_valid_origin_county = yes
	}
}

#Serfs fleeing from an abusive lord have arrived in your domain. What do you do?
stewardship_duty.1071 = {
	type = character_event
	title = stewardship_duty.1071.t
	desc = stewardship_duty.1071.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	left_portrait = scope:origin_county_owner
	lower_left_portrait = scope:origin_county_owner_liege
	
	trigger = {
		#Must be a feudal lord.
		has_government = feudal_government

		#Must not be malevolent or unjust.
		NOR = {
			has_trait = torturer
			has_trait = sadistic
			has_trait = wrathful
			has_trait = arbitrary
		}

		#Must hold a county which is adjacent to the county of an abusive feudal lord.
		any_held_title = {
			stewardship_duty_1071_valid_target_county = yes
		}

		#Must not have had this event within the past 10 years.
		NOT = { has_character_flag = had_event_stewardship_duty_1071 }
	}

	weight_multiplier = {
		base = 0.6

		#More likely to occur for Just characters, and much more likely to occur for Compassionate ones.
		modifier = {
			has_trait = compassionate
			add = 0.6
		}
		modifier = {
			has_trait = just
			add = 0.2
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		#Flag this event as having occurred.
		add_character_flag = {
			flag = had_event_stewardship_duty_1071
			years = 10
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}

		#Find a valid county for the runaway serfs to flee to.
		random_held_title = {
			limit = {
				stewardship_duty_1071_valid_target_county = yes
			}
			save_scope_as = target_county

			random_neighboring_county = {
				limit = {
					stewardship_duty_1071_valid_origin_county = yes

					#Prefer picking malevolent characters over simply unjust ones.
					holder = {
						OR = {
							has_trait = torturer
							has_trait = sadistic
						}
					}
				}
				alternative_limit = {
					stewardship_duty_1071_valid_origin_county = yes
				}
				save_scope_as = origin_county

				#Save the origin county's holder as a separate scope.
				holder = {
					save_scope_as = origin_county_owner

					#If this lord is one of our sub-vassals, also save their direct liege(our vassal).
					if = {
						limit = {
							target_is_liege_or_above = root
							NOT = { liege = root }
						}
						liege = {
							save_scope_as = origin_county_owner_liege
						}
						
					}
				}
			}
		}
	}

	#Option A: Return the serfs to their lord.
	option = {
		name = stewardship_duty.1071.a

		#The lord is grateful to have their serfs back.
		scope:origin_county_owner = {
			add_opinion = {
				modifier = grateful_opinion
				target = root
				opinion = 25
			}
		}

		#The serfs are likely to suffer greatly for this, which will weigh on some character's consciences.
		stress_impact = {
			compassionate = medium_stress_impact_gain
			forgiving = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -300
				ai_boldness = -100
				ai_greed = -100
			}
		}
	}

	#Option B: Return the serfs to their lord, but chastise them for abusing their serfs.
	option = {
		name = stewardship_duty.1071.b

		#The lord loses prestige due to appearing weak (more so if you are their liege).
		if = {
			limit = {
				target_is_liege_or_above = root
			}
			root = { #Gain prestige for your show of strength over the abusive lord.
				add_prestige = major_prestige_gain
			}
			scope:origin_county_owner = {
				add_prestige = major_prestige_loss
			}
		}
		else = {
			root = { #Gain prestige for your show of strength over the abusive lord.
				add_prestige = medium_prestige_gain
			}
			scope:origin_county_owner = {
				add_prestige = medium_prestige_loss
			}
		}

		#The lord is angry for being chastized.
		scope:origin_county_owner = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -10
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 100
				ai_greed = -100
			}
		}
	}
	
	#Option C: Whether out of greed or compassion, settle the runaway serfs on your lands.
	option = {
		#Special option text if you are compassionate.
		name = {
			trigger = {
				NOT = { has_trait = compassionate }
			}
			text = stewardship_duty.1071.c
		}
		name = {
			trigger = {
				has_trait = compassionate
			}
			text = stewardship_duty.1071.c.compassionate
		}
		flavor = stewardship_duty.1071.c.flavor


		#Apply economic modifiers due to the serf refugees.
		scope:origin_county = {
			add_county_modifier = {
				modifier = governance_1071_missing_serfs_modifier
				years = 10
			}
		}

		#Bonus county opinion if you are compassionate.
		trait = compassionate
		if = {
			limit = {
				has_trait = compassionate
			}
			scope:target_county = {
				add_county_modifier = {
					modifier = governance_1071_grateful_serfs_modifier
					years = 10
				}
			}
		}
		else = {
			scope:target_county = {
				add_county_modifier = {
					modifier = governance_1071_extra_serfs_modifier
					years = 10
				}
			}
		}

		#Send follow-up letter event from the other lord to our character.
		hidden_effect = {
			random_list = {
				25 = {
					# Lazy or sick characters might just not care about the missing serfs.
					compare_modifier = {
						value = scope:origin_county_owner.ai_energy
						multiplier = -0.5
					}

					# Unintelligent characters might not even realize their serfs are missing (or if they do, that you had anything to do with it).
					modifier = {
						add = 50
						has_trait = dull
					}
					modifier = {
						add = 30
						has_trait = intellect_bad_1
					}
					modifier = {
						add = 50
						has_trait = intellect_bad_2
					}
					modifier = {
						add = 100
						has_trait = intellect_bad_3
					}

				}
				75 = {
					trigger = {
						scope:origin_county_owner = {
							is_available = yes
						}
					}

					# Vengeful and Greedy characters are more likely to press the issue.
					compare_modifier = {
						value = scope:origin_county_owner.ai_vengefulness
						multiplier = 0.5
					}
					compare_modifier = {
						value = scope:origin_county_owner.ai_greed
						multiplier = 0.5
					}

					modifier = { # Intimidated characters are less likely to press the issue, even if they know you're behind it.
						factor = 0.2
						dread_modified_ai_boldness = {
							dreaded_character = root
							value <= -40
						}
					}
					modifier = { # Cowed characters are will never press the issue, even if they know you're behind it.
						factor = 0
						dread_modified_ai_boldness = {
							dreaded_character = root
							value < -75
						}
					}

					trigger_event = {
						id = stewardship_duty.1072
						days = { 10 14 }
					}
				}
			}
		}


		stress_impact = {
			craven = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 300
				ai_boldness = -200
				ai_greed = 300
			}
		}
	}
}

#Letter event where the other lord confronts you about stealing their serfs.
stewardship_duty.1072 = {
	type = letter_event
	opening = {
		desc = stewardship_duty.1072.opening
	}
	sender = {
		character = scope:origin_county_owner
		animation = anger
	}

	#Letter will be written differently depending on your relationship with the other person.
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_relation_lover = scope:origin_county_owner
						has_relation_friend = scope:origin_county_owner
					}
				}
				desc = stewardship_duty.1072.desc.relationship
			}
				triggered_desc = {
				trigger = {
					scope:origin_county_owner = {
						liege = root
					}
				}
				desc = stewardship_duty.1072.desc.vassal
			}
			triggered_desc = {
				trigger = {
					scope:origin_county_owner = {
						target_is_liege_or_above = root
					}
				}
				desc = stewardship_duty.1072.desc.subvassal
			}
			desc = {
				desc = stewardship_duty.1072.desc.rival
			}
		}
	}	

	immediate = {
		scope:origin_county_owner = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -10
			}
		}
	}

	#Option A: Return the serfs to avoid relationship status change (though you suffer a small opinion penalty).
	option = {
		name = stewardship_duty.1072.a

		#Reverse the economic modifiers from the serf refugees.
		scope:target_county = {
			if = {
				limit = {
					scope:target_county = {
						has_county_modifier = governance_1071_grateful_serfs_modifier
					}
				}
				remove_county_modifier = governance_1071_grateful_serfs_modifier
			}
			else = {
				remove_county_modifier = governance_1071_extra_serfs_modifier
			}
		}
		scope:origin_county = {
			remove_county_modifier = governance_1071_missing_serfs_modifier
		}

		stress_impact = {
			brave = medium_stress_impact_gain
			stubborn = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}

		#If the AI already made the decision to keep the serfs, they won't back out now.
		ai_chance = {
			base = 0
		}
	}

	#Option B: Stand your ground and keep the serfs.
	option = {
		#Special option text if you are compassionate.
		name = {
			trigger = {
				NOT = { has_trait = compassionate }
			}
			text = stewardship_duty.1072.b
		}
		name = {
			trigger = {
				has_trait = compassionate
			}
			text = stewardship_duty.1072.b.compassionate
		}

		scope:origin_county_owner = {
			if = {
				#If we are friends or lovers with the other lord...
				limit = {
					OR = {
						has_relation_friend = root
						has_relation_lover = root
					}
				}

				#Suffer a relationship malus with them.
				add_opinion = {
					modifier = angry_opinion
					target = root
					opinion = -10
				}

				#Then remove friend and lover status.
				if = {
					limit = {
						has_relation_friend = root
					}
					remove_relation_friend = root
				}
				if = {
					limit = {
						has_relation_lover = root
					}
					remove_relation_lover = root
				}
			}
			else_if = {
				#If the other lord is a vassal or sub-vassal under us...
				limit = {
					target_is_liege_or_above = root
				}
				#Add a harsh opinion penalty for them...
				add_opinion = {
					modifier = angry_opinion
					target = root
					opinion = -25
				}
				if = {
					#And if they serve a different lord under us...
					limit = {
						exists = scope:origin_county_owner_liege
					}
					scope:origin_county_owner_liege = {
						#Give them an opinion penalty too.
						add_opinion = {
							modifier = angry_opinion
							target = root
							opinion = -10
						}
					}
				}
			}
			else = {
				#Add a harsh opinion penalty
				add_opinion = {
					modifier = angry_opinion
					target = root
					opinion = -25
				}
				#Possibility of becomming rivals with the other lord.
				if = {
					limit = {
						NOT = {
							# Not already rivals
							has_relation_rival = root
						}
					}
					set_relation_rival = root
				}
			}
		}

		stress_impact = {
			craven = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}
	}
}

################################################
# Vassal Factionalism
# Getting vassal to leave a faction for 10 years
# 4010-4019
# by Sean Hughes
################################################

scripted_trigger stewardship_duty_4010_valid_targeting_faction_trigger = {
	
	OR = {
		# This should be all the faction types, but if new ones get added we don't want the event breaking.
		faction_is_type = independence_faction
		faction_is_type = liberty_faction
		faction_is_type = peasant_faction
		faction_is_type = claimant_faction
	}

	#Ensure that the faction has a member who is not the leader.
	any_faction_member = {
		stewardship_duty_4010_valid_faction_member_trigger = yes
	}
}

scripted_trigger stewardship_duty_4010_valid_faction_member_trigger = {
	is_available_ai_adult = yes
	NOT = { this = prev.faction_leader}
}

#Main event. Choose from 1 of 3 ways to bribe your vassal into leaving their faction.
stewardship_duty.4010 = {
	type = character_event
	title = stewardship_duty.4010.t
	desc = {
		desc = stewardship_duty.4010.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:targeting_faction = {
						faction_is_type = claimant_faction
					}
				}
				desc = stewardship_duty.4010.desc.claimant
			}
			triggered_desc = {
				trigger = {
					scope:targeting_faction = {
						faction_is_type = independence_faction
					}
				}
				desc = stewardship_duty.4010.desc.independence
			}
			triggered_desc = {
				trigger = {
					scope:targeting_faction = {
						faction_is_type = liberty_faction
					}
				}
				desc = stewardship_duty.4010.desc.liberty
			}
			triggered_desc = {
				trigger = {
					scope:targeting_faction = {
						faction_is_type = peasant_faction
					}
				}
				desc = stewardship_duty.4010.desc.peasant
			}
		}
		desc = stewardship_duty.4010.desc.end
	}
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	
	left_portrait = {
		character = scope:faction_member
		animation = schadenfreude
	}

	trigger = {
		is_available_adult_or_is_commanding = yes
		NOT = { has_character_flag = had_stewardship_duty_4010_event }

		#Check if we have a targeting faction with at least one non-leading character.
		any_targeting_faction = {
			stewardship_duty_4010_valid_targeting_faction_trigger = yes
		}
	}

	# This event has a higher-than-normal weight due to it's impact score.
	weight_multiplier = {
		base = 1

		# Greatly increased chance if there is an active faction whose power rivals or exceeds yours.
		modifier = {
			any_targeting_faction = {
				faction_power > 80
			}
			add = 0.2 # 120%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 90
			}
			add = 0.2 # 140%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 100
			}
			add = 0.4 # 180%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 110
			}
			add = 0.4 # 220%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 125
			}
			add = 0.8 # 300%
		}

		# Chance multiplier if the faction is likely to revolt soon.
		modifier = {
			has_focus = stewardship_duty_focus
			any_targeting_faction = {
				faction_discontent > 50
			}
			factor = 2 # Up to 600%
		}
		modifier = {
			has_focus = stewardship_duty_focus
			any_targeting_faction = {
				faction_discontent > 75
			}
			factor = 2 # Up to 1200%
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_stewardship_duty_4010_event
			years = 5
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}

		#Pull a faction member as an event target from one of our targeting factions.
		random_targeting_faction = {
			limit = {
				faction_power > 100
				stewardship_duty_4010_valid_targeting_faction_trigger = yes
			}
			alternative_limit = {
				faction_power > 80
				stewardship_duty_4010_valid_targeting_faction_trigger = yes
			}
			alternative_limit = {
				stewardship_duty_4010_valid_targeting_faction_trigger = yes
			}

			save_scope_as = targeting_faction

			faction_leader = {
				save_scope_as = faction_leader
			}
			random_faction_member = {
				limit = {
					stewardship_duty_4010_valid_faction_member_trigger = yes
				}

				weight = {
					base = 10

					modifier = {
						has_trait = greedy
						add = 5
					}
					modifier = {
						has_trait = ambitious
						add = 5
					}
					modifier = {
						AND = {
							has_trait = zealous
							faith = root.faith
						}
						add = 5
					}
					modifier = {
						has_trait = arrogant
						add = 5
					}

					compare_modifier = {
						factor = highest_held_title_tier
						multiplier = 2
					}
					modifier = {
						is_powerful_vassal = yes
						factor = 2
					}



				}
				save_scope_as = faction_member
			}
		}

		save_scope_as = my_liege #For later events
	}

	#Pay gold.
	option = {
		name = stewardship_duty.4010.bribe
		flavor = stewardship_duty.4010.bribe.flavor

		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= major_gold_value_check
			}
			NOT = {
				scope:faction_member = {
					can_add_hook = {
						type = favor_hook
						target = root
					}
				}
			}
		}

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		show_as_tooltip = {
			random_list = {
				desc = stewardship_duty.4010.attempt.tt
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.success
					pay_short_term_gold = {
						target = scope:faction_member
						gold = major_gold_value

					}
					scope:faction_member = {
						leave_faction_with_cooldown_effect = {
							FACTION = scope:targeting_faction
							YEARS = 20
						}
					}
				}
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.failure
					reverse_add_opinion = {
						target = scope:faction_member
						modifier = insult_opinion
						opinion = -10
					}
				}
			}
		}

		scope:faction_member = {
			trigger_event = {
				id = stewardship_duty.4011
				days = { 5 7 }
			}
		}

		ai_chance = {
			base = 25
			
			modifier = {
				AND = {
					ai_rationality >= 10 # Onlt 'intelligent' AIs should make informed decisions; others will guess randomly.
					scope:faction_member = {
						ai_greed >= 25 # Offer this option if the faction member is greedy
					}
				}
				add = 475
			}
		}
	}

	#Offer a Favor.
	option = {
		name = stewardship_duty.4010.favor
		flavor = stewardship_duty.4010.favor.flavor

		trigger = {
			scope:faction_member = {
				can_add_hook = {
					type = favor_hook
					target = root
				}
			}
		}

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		show_as_tooltip = {
			random_list = {
				desc = stewardship_duty.4010.attempt.tt
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.success
					scope:faction_member = {
						add_hook = {
							type = favor_hook
							target = root
						}
						leave_faction_with_cooldown_effect = {
							FACTION = scope:targeting_faction
							YEARS = 20
						}
					}
				}
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.failure
					reverse_add_opinion = {
						target = scope:faction_member
						modifier = insult_opinion
						opinion = -10
					}
				}
			}
		}

		scope:faction_member = {
			trigger_event = {
				id = stewardship_duty.4012
				days = { 5 7 }
			}
		}

		ai_chance = {
			base = 25
			
			modifier = {
				AND = {
					ai_rationality >= 10 # Onlt 'intelligent' AIs should make informed decisions; others will guess randomly.
					scope:faction_member = {
						ai_greed >= 25 # Offer this option if the faction member is greedy
					}
				}
				add = 475
			}
		}
	}

	#Pay prestige.
	option = {
		name = stewardship_duty.4010.prestige
		flavor = stewardship_duty.4010.prestige.flavor

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		show_as_tooltip = {
			random_list = {
				desc = stewardship_duty.4010.attempt.tt
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.success
					add_prestige = major_prestige_loss			
					scope:faction_member = {
						leave_faction_with_cooldown_effect = {
							FACTION = scope:targeting_faction
							YEARS = 20
						}
						add_prestige = major_prestige_gain
					}
				}
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.failure
					reverse_add_opinion = {
						target = scope:faction_member
						modifier = insult_opinion
						opinion = -10
					}
				}
			}
		}

		scope:faction_member = {
			trigger_event = {
				id = stewardship_duty.4013
				days = { 5 7 }
			}
		}

		ai_chance = {
			base = 25
			
			modifier = {
				AND = {
					ai_rationality >= 10 # Onlt 'intelligent' AIs should make informed decisions; others will guess randomly.
					scope:faction_member = {
						OR = {
							ai_boldness >= 25 # Offer this option if the faction member is bold or honorable (more likely to accept it).
							ai_honor >= 25
						}
					}
				}
				add = 475
			}
		}
	}

	#Pay piety.
	option = {
		name = stewardship_duty.4010.piety
		flavor = stewardship_duty.4010.piety.flavor

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		show_as_tooltip = {
			random_list = {
				desc = stewardship_duty.4010.attempt.tt
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.success
					add_piety = major_piety_loss			
					scope:faction_member = {
						leave_faction_with_cooldown_effect = {
							FACTION = scope:targeting_faction
							YEARS = 20
						}
						add_piety = major_piety_gain
					}
				}
				1 = {
					show_chance = no
					desc = stewardship_duty.4010.failure
					reverse_add_opinion = {
						target = scope:faction_member
						modifier = insult_opinion
						opinion = -10
					}
				}
			}
		}

		scope:faction_member = {
			trigger_event = {
				id = stewardship_duty.4014
				days = { 5 7 }
			}
		}

		ai_chance = {
			base = 25
			
			modifier = {
				AND = {
					ai_rationality >= 10 # Only 'intelligent' AIs should make informed decisions; others will guess randomly.
					scope:faction_member = {
						ai_zeal >= 25 # Offer this option if the faction member is zealous and of my faith.
						faith = root.faith
					}
				}
				add = 475
			}
		}
	}

	#Do nothing.
	option = {
		name = stewardship_duty.4010.decline
		flavor = stewardship_duty.4010.decline.tt
		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:faction_member
			opinion = 10
		}

		ai_chance = {
			base = 25
			
			ai_value_modifier = {
				ai_energy = -25
			}
		}
	}
}

#Vassal can accept or decline the gold.
stewardship_duty.4011 = {
	type = character_event
	title = stewardship_duty.4011.t
	desc = {
		desc = stewardship_duty.4011-4.desc.start
		desc = stewardship_duty.4011.desc
	}
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	
	left_portrait = {
		character = scope:my_liege
		animation = beg
	}


	trigger = {
		# Faction must still exist.
		exists = scope:targeting_faction

		# Event target must still be a member of the faction.
		scope:targeting_faction = {
			any_faction_member = {
				this = scope:faction_member
			}
		}
	}
	on_trigger_fail = {
		# If either is false, abort the event chain and send notification to the event owner.
		scope:my_liege = {
			trigger_event = stewardship_duty.4020
		}
	}

	option = {
		name = stewardship_duty.4011.a

		leave_faction_with_cooldown_effect = {
			FACTION = scope:targeting_faction
			YEARS = 10
		}
		
		scope:my_liege = {
			pay_short_term_gold = {
				target = root
				gold = major_gold_value
			}
			trigger_event = stewardship_duty.4015
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 500 # Money money money
				ai_zeal = -200 # Doesn't want to betray principles
				ai_energy = -200 # Lazy characters take the easy way out.
			}

			modifier = {
				has_trait = greedy
				add = 10000
			}
		}

	}

	option = {
		name = stewardship_duty.4011-4.b

		custom_tooltip = stewardship_duty.4011-4.b.tt

		scope:my_liege = {
			trigger_event = stewardship_duty.4019
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -500 # Doesn't want to turn down money
				ai_honor = -200 # Perfers plotting and scheming.
				ai_boldness = 200 # Would rather take a high-risk, high reward choice.
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
		}
	}
}

#Vassal can accept or decline the favor.
stewardship_duty.4012 = {
	type = character_event
	title = stewardship_duty.4012.t
	desc = {
		desc = stewardship_duty.4011-4.desc.start
		desc = stewardship_duty.4012.desc
	}
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	
	left_portrait = {
		character = scope:my_liege
		animation = beg
	}

	trigger = {
		# Faction must still exist.
		exists = scope:targeting_faction

		# Event target must still be a member of the faction.
		scope:targeting_faction = {
			any_faction_member = {
				this = scope:faction_member
			}
		}
	}
	on_trigger_fail = {
		# If either is false, abort the event chain and send notification to the event owner.
		scope:my_liege = {
			trigger_event = stewardship_duty.4020
		}
	}

	option = {
		name = stewardship_duty.4012.a

		leave_faction_with_cooldown_effect = {
			FACTION = scope:targeting_faction
			YEARS = 20
		}
		add_hook = {
			type = favor_hook
			target = scope:my_liege
			years = 20
		}

		scope:my_liege = {
			trigger_event = stewardship_duty.4016
		}

		ai_chance = {
			base = 500 #Favors are quite valuable, so the AI has a higher base chance of accepting this.
			ai_value_modifier = {
				ai_greed = 500 # Personal gain is quite alluring.
				ai_rationality = 250 # Favors are an excellent thing to have.
				ai_zeal = -250 # Doesn't want to betray principles.
			}

			compare_modifier = { # Compassionate characters are more likely to acquiese to their liege's wishes, but mean/spiteful characters won't necessarily reufuse the offer if it otherwise suits them.
				value = ai_compassion
				multiplier = 500
				min = 0
			}

			modifier = { # Ambitious characters can get a lot done with a favor.
				has_trait = ambitious
				add = 100000
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
	}

	option = {
		name = stewardship_duty.4011-4.b

		custom_tooltip = stewardship_duty.4011-4.b.tt

		scope:my_liege = {
			trigger_event = stewardship_duty.4019
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -500 # Doesn't want to turn down money
				ai_honor = -500 # More likely to stay in faction if prefers scheming and plotting.
				ai_boldness = 500 # More likely to try for a higher risk, higher reward faction demand.
			}
		}

		stress_impact = {
			compassionate = minor_stress_impact_gain
		}
	}
}

#Vassal can accept or decline the prestige.
stewardship_duty.4013 = {
	type = character_event
	title = stewardship_duty.4013.t
	desc = {
		desc = stewardship_duty.4011-4.desc.start
		desc = stewardship_duty.4013.desc
	}
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	
	left_portrait = {
		character = scope:my_liege
		animation = beg
	}

	trigger = {
		# Faction must still exist.
		exists = scope:targeting_faction

		# Event target must still be a member of the faction.
		scope:targeting_faction = {
			any_faction_member = {
				this = scope:faction_member
			}
		}
	}
	on_trigger_fail = {
		# If either is false, abort the event chain and send notification to the event owner.
		scope:my_liege = {
			trigger_event = stewardship_duty.4020
		}
	}

	immediate = {
		assign_quirk_effect = yes
	}

	option = {
		name = stewardship_duty.4013.a

		leave_faction_with_cooldown_effect = {
			FACTION = scope:targeting_faction
			YEARS = 20
		}
		add_prestige = major_prestige_gain
		scope:my_liege = {
			add_prestige = major_prestige_loss
			trigger_event = stewardship_duty.4017
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -200 # While Prestige is nice to have vassals generally have limited uses for it.
				ai_honor = 500 # Honorable characters tend to have higher opinions of themselves (humble notwithstanding).
				ai_boldness = 500 # Bold characters tend to have a higher opinion of themselves.
				ai_zeal = -250 # Doesn't want to betray principles.
			}

			modifier = { # Because of course Arrogant characters respond to flattery well.
				has_trait = arrogant
				add = 100000
			}

			modifier = { # Flattery is actively distasteful to Humble characters.
				has_trait = humble
				add = -100000
			}
		}

		stress_impact = {
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
	}

	option = {
		name = stewardship_duty.4011-4.b

		custom_tooltip = stewardship_duty.4011-4.b.tt

		scope:my_liege = {
			trigger_event = stewardship_duty.4019
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_zeal = 250 # Believes in a higher cause than themselves.
			}

			modifier = { # Paranoid characters are skeptical of flattery.
				has_trait = paranoid
				add = 10000
			}
		}

		stress_impact = {
			arrogant = medium_stress_impact_gain
		}
	}
}

#Vassal can accept or decline the piety.
stewardship_duty.4014 = {
	type = character_event
	title = stewardship_duty.4014.t
	desc = {
		desc = stewardship_duty.4011-4.desc.start
		desc = stewardship_duty.4014.desc
	}
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	
	left_portrait = {
		character = scope:my_liege
		animation = beg
	}

	trigger = {
		# Faction must still exist.
		exists = scope:targeting_faction

		# Event target must still be a member of the faction.
		scope:targeting_faction = {
			any_faction_member = {
				this = scope:faction_member
			}
		}
	}
	on_trigger_fail = {
		# If either is false, abort the event chain and send notification to the event owner.
		scope:my_liege = {
			trigger_event = stewardship_duty.4020
		}
	}

	option = {
		name = stewardship_duty.4014.a

		leave_faction_with_cooldown_effect = {
			FACTION = scope:targeting_faction
			YEARS = 20
		}
		add_piety = major_piety_gain
		scope:my_liege = {
			add_piety = major_piety_loss
			trigger_event = stewardship_duty.4018
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 500 # Swayed by religious convictions.
				ai_greed = -200 # Hard to turn piety into personal power.
				ai_rationality = -200 # Giving up personal goals for what?
			}

			modifier = { # Extremely willing to accept if the liege is of the same faith.
				AND = {
					has_trait = zealous
					faith = scope:my_liege.faith
				}
				add = 100000
			}
			modifier = {
				AND = { # Somewhat more willing to accept if liege's faith is at least not Hostile or worse.
					faith = {
						faith_hostility_level = {
					 		target = scope:my_liege.faith
					 		value < religious_cb_enabled_hostility_level
					 	}
					}
				}
				add = 500
			}
		}

		stress_impact = {
			cynical = medium_stress_impact_gain
		}		
	}

	option = {
		name = stewardship_duty.4011-4.b

		custom_tooltip = stewardship_duty.4011-4.b.tt

		scope:my_liege = {
			trigger_event = stewardship_duty.4019
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -500 # Perfers plotting and scheming to compromise.
				ai_boldness = 500 # Would rather take a high-risk, high-reward path.
			}

			modifier = { # Cynical characters reject this argument outright.
				has_trait = cynical
				add = 10000
			}
			modifier = { # Characters who consider their liege to be an infidel/heathen/heretic will never accept this argument.
				faith = {
					faith_hostility_level = {
				 		target = scope:my_liege.faith
				 		value >= religious_cb_enabled_hostility_level
				 	}
				}
				add = 1000000
			}
		}

		if = {
			limit = {
				faith = scope:my_liege.faith
			}
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
	}
}

#Response event indicating vassal accepted the gold.
stewardship_duty.4015 = {
	type = character_event
	title = stewardship_duty.4015.t
	desc = stewardship_duty.4015.desc
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	
	left_portrait = {
		character = scope:faction_member
		animation = happiness
	}


	immediate = {
		show_as_tooltip = {
			scope:faction_member = {
				leave_faction_with_cooldown_effect = {
					FACTION = scope:targeting_faction
					YEARS = 20
				}
			}
			pay_short_term_gold = {
				target = scope:faction_member
				gold = major_gold_value
			}
		}
	}

	option = {
		name = stewardship_duty.4015.a
	}
}

#Response event indicating vassal accepted the favor.
stewardship_duty.4016 = {
	type = character_event
	title = stewardship_duty.4015.t
	desc = stewardship_duty.4015.desc
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	
	left_portrait = {
		character = scope:faction_member
		animation = happiness
	}

	immediate = {
		show_as_tooltip = {
			scope:faction_member = {
				leave_faction_with_cooldown_effect = {
					FACTION = scope:targeting_faction
					YEARS = 20
				}
				add_hook = {
					type = favor_hook
					target = root
				}
			}
		}
	}

	option = {
		name = stewardship_duty.4015.a
	}
}


#Response event indicating vassal accepted the prestige.
stewardship_duty.4017 = {
	type = character_event
	title = stewardship_duty.4015.t
	desc = stewardship_duty.4015.desc
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	
	left_portrait = {
		character = scope:faction_member
		animation = happiness
	}


	immediate = {
		show_as_tooltip = {
			scope:faction_member = {
				leave_faction_with_cooldown_effect = {
					FACTION = scope:targeting_faction
					YEARS = 20
				}
				add_prestige = major_prestige_gain
			}
			add_prestige = major_prestige_loss
		}
	}

	option = {
		name = stewardship_duty.4015.a
	}
}

#Response event indicating vassal accepted the piety.
stewardship_duty.4018 = {
	type = character_event
	title = stewardship_duty.4015.t
	desc = stewardship_duty.4015.desc
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	
	left_portrait = {
		character = scope:faction_member
		animation = happiness
	}


	immediate = {
		show_as_tooltip = {
			scope:faction_member = {
				leave_faction_with_cooldown_effect = {
					FACTION = scope:targeting_faction
					YEARS = 20
				}
				add_piety = major_piety_gain
			}
			add_piety = major_piety_loss
		}
	}

	option = {
		name = stewardship_duty.4015.a
	}
}

#Response event indicating vassal rejected the offer.
stewardship_duty.4019 = {
	type = character_event
	title = stewardship_duty.4019.t
	desc = stewardship_duty.4019.desc
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}

	left_portrait = {
		character = scope:faction_member
		animation = disapproval
	}


	option = {
		name = stewardship_duty.4019.a

		reverse_add_opinion = {
			target = scope:faction_member
			modifier = insult_opinion
			opinion = -10
		}
	}
}

stewardship_duty.4020 = {
	hidden = yes

	immediate = {
		send_interface_message = {
			type = event_stewardship_neutral_with_text
			title = stewardship_duty.4020.t
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = {
							any_targeting_faction = {
								any_faction_member = {
									this = scope:faction_member
								}
							}
						}
						desc = stewardship_duty.4020.desc.switch
					}
					desc = stewardship_duty.4020.desc
				}
			}
			left_icon = scope:faction_member

			add_stewardship_lifestyle_xp = minor_lifestyle_xp
		}
	}
}

################################################
# Altering the Deal
# Trying to get a vassal to change their contract
# 4040
# by Sean Hughes
################################################

scripted_trigger stewardship_duty_4040_valid_target = {

	is_available_ai_adult = yes
	vassal_contract_obligation_level_can_be_increased = feudal_government_taxes

	# We do not want to increase the obligations of our own heir, as when they inherit those changes would become meaningless or even counter-productive.
	OR = {
		NOT = {	exists = root.player_heir }
		NOT = { this = root.player_heir }
	}
}


stewardship_duty.4040 = {
	type = character_event
	title = stewardship_duty.4040.t
	desc = stewardship_duty.4040.desc
	theme = stewardship_duty_focus
	
	left_portrait = scope:my_vassal
	
	trigger = {
		NOT = { has_character_flag = had_stewardship_duty_4040_event }

		any_vassal = {
			stewardship_duty_4040_valid_target = yes
		}


	}

	weight_multiplier = {
		base = 0.5

		# More likely to be selected if we have a vassal with an altered vassal contract.
		modifier = {
			any_vassal = {
				vassal_contract_has_modifiable_obligations = yes
				NOT = { vassal_contract_obligation_level:feudal_government_taxes = feudal_tax_normal_level }
			}
			add = 1
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_stewardship_duty_4040_event
			years = 5
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}

		random_vassal = {
			limit = {
				stewardship_duty_4040_valid_target = yes

				# Do not pull Barons if there are more important vassals we could pull.
				NOT = { highest_held_title_tier = 1 }
			}
			alternative_limit = {
				stewardship_duty_4040_valid_target = yes
			}

			weight = {
				base = 10
				modifier = {
					is_powerful_vassal = yes
					factor = 3
				}
				compare_modifier = {
					factor = highest_held_title_tier
					multiplier = 3
				}
				modifier = { # More likely to be selected if our contract is already changed from default.
					NOT = { vassal_contract_obligation_level:feudal_government_taxes = feudal_tax_normal_level }
					factor = 3
				}

				modifier = { # More likely to pick vassals who are intimidated by you.
					dread_modified_ai_boldness = {
						dreaded_character = root
						value <=-40
					}
					add = 20
				}
			}

			save_scope_as = my_vassal
		}
	}

	#Attempt to bribe your vassal.
	option = {
		name = stewardship_duty.4040.a
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= major_gold_value_check
			}
		}

		pay_short_term_gold = {
			target = scope:my_vassal
			gold = major_gold_value
		}
		scope:my_vassal = {
			vassal_contract_increase_obligation_level = feudal_government_taxes
		}


		stress_impact = {
			greedy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -200
			}
		}
	}

	#Attempt to persuade your vassal.
	option = {
		name = stewardship_duty.4040.b

		duel = {
			skill = diplomacy
			target = scope:my_vassal
			desc = outcome_in_a_few_days
			50 = {
				desc = stewardship_duty.4040.b.success

				compare_modifier = {
					value = scope:duel_value
					multiplier = 5
					min = -49
				}

				compare_modifier = {
					value = scope:my_vassal.ai_compassion
					multiplier = 0.2
				}

				#If target likes liege, increase chances of accepting this offer.
				modifier = {
					reverse_opinion = {
						target = scope:my_vassal
						value >= 30
					}
					factor = 2
				}

				show_as_tooltip = {
					scope:my_vassal = {
						vassal_contract_increase_obligation_level = feudal_government_taxes
					}
				}

				trigger_event = {
					id = stewardship_duty.4041
					days = { 7 11 }
				}

			}
			50 = {
				desc = stewardship_duty.4040.b.failure

				compare_modifier = {
					value = scope:duel_value
					multiplier = -5
					min = -49
				}

				# Vassals who dislike their liege are less likely to accept a worse contract.
				opinion_modifier = {
					opinion_target = root
					who = scope:my_vassal
					multiplier = -2
					min = 0
				}

				show_as_tooltip = {
					add_stress = minor_stress_impact_gain
				}

				trigger_event = {
					id = stewardship_duty.4042
					days = { 7 11 }
				}
			}
		}


		stress_impact = {
			shy = medium_stress_impact_gain
			generous = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 200
				ai_compassion = 100
			}
		}

	}
	
	#Attempt to coerce your vassal.
	option = {
		name = stewardship_duty.4040.c

		scope:my_vassal = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -20
			}
		}

		random_list = {
			desc = outcome_in_a_few_days
			20 = {
				desc = stewardship_duty.4040.c.success

				show_as_tooltip = {
					scope:my_vassal = {
						vassal_contract_increase_obligation_level = feudal_government_taxes
					}
					add_dread = minor_dread_gain
					set_nickname_effect = { NICKNAME = nick_the_bully }
				}

				trigger_event = {
					id = stewardship_duty.4043
					days = { 7 11 }
				}
			}
			80 = {
				desc = stewardship_duty.4040.c.failure

				modifier = { # 20/260: Only an 8% chance of success if Boldness is significantly positive.
					scope:my_vassal = {
						dread_modified_ai_boldness = {
							dreaded_character = root
							value >= 25
						}
					}
					factor = 3
				}
				modifier = { # 20/48: Below 0 (neutral) Boldness. 42% chance of success.
					scope:my_vassal = {
						dread_modified_ai_boldness = {
							dreaded_character = root
							value <= 0
						}
					}
					factor = 0.35
				}
				modifier = { #20/28: Intimidated Threshold. 71% chance of success.
					scope:my_vassal = {
						dread_modified_ai_boldness = {
							dreaded_character = root
							value <= -40
						}
					}
					factor = 0.3
				}
				modifier = { #20/22: Halfway between Intitmiated and Cowed. 90% chance of success
					scope:my_vassal = {
						dread_modified_ai_boldness = {
							dreaded_character = root
							value <= -55
						}
					}
					factor = 0.25
				}
				modifier = { #20/20: Cowed Threshold. 100% chance of success.
					scope:my_vassal = {
						dread_modified_ai_boldness = {
							dreaded_character = root
							value <= -75
						}
					}
					factor = 0
				}

				show_as_tooltip = {
					add_prestige = minor_prestige_loss
				}

				trigger_event = {
					id = stewardship_duty.4044
					days = { 7 11 }
				}
			}
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -200
				ai_boldness = 100
				ai_vengefulness = 50
				ai_rationality = -50
				ai_compassion = -200
			}
		}

	}

	#Do not try to change the contract.
	option = {
		name = stewardship_duty.4040.d

		flavor = stewardship_duty.4040.d.tt

		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:my_vassal
			opinion = 15
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			just = minor_stress_impact_gain

		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -200
				ai_compassion = 100
				ai_vengefulness = -100
				ai_energy = -100
			}
		}
	}
}

#Informing the player that the persuasion attempt succeeded
stewardship_duty.4041 = {
	type = character_event
	title = stewardship_duty.4040.t
	desc = stewardship_duty.4041.desc
	theme = stewardship_duty_focus
	
	left_portrait = {
		character = scope:my_vassal
		animation = happiness
	}


	trigger = {
		scope:my_vassal = { is_vassal_of = root } # This event is fired on a 7-10 day delay, so the vassal status might change
	}

	option = {
		name = stewardship_duty.4041.a

		scope:my_vassal = {
			vassal_contract_increase_obligation_level = feudal_government_taxes
		}
	}
}

#Informing the player that the persuasion attempt failed
stewardship_duty.4042 = {
	type = character_event
	title = stewardship_duty.4040.t
	desc = stewardship_duty.4042.desc
	theme = stewardship_duty_focus
	
	left_portrait = {
		character = scope:my_vassal
		animation = dismissal
	}


	option = {
		name = stewardship_duty.4042.a

		add_stress = minor_stress_impact_gain

	}
}

#Informing the player that the coersion attempt succeeded
stewardship_duty.4043 = {
	type = character_event
	title = stewardship_duty.4040.t
	desc = stewardship_duty.4043.desc
	theme = stewardship_duty_focus
	
	left_portrait = {
		character = scope:my_vassal
		animation = happiness
	}


	option = {
		name = stewardship_duty.4043.a

		add_dread = minor_dread_gain
		set_nickname_effect = { NICKNAME = nick_the_bully }
		scope:my_vassal = {
			vassal_contract_increase_obligation_level = feudal_government_taxes
		}
	}
}

#Informing the player that the coersion attempt failed
stewardship_duty.4044 = {
	type = character_event
	title = stewardship_duty.4040.t
	desc = stewardship_duty.4044.desc
	theme = stewardship_duty_focus
	
	left_portrait = {
		character = scope:my_vassal
		animation = disapproval
	}


	option = {
		name = stewardship_duty.4044.a

		add_prestige = minor_prestige_loss
	}
}

#####################################################
# Faction Organizing
# Try to lower a faction's discontent during wartime.
# 4060
# by Sean Hughes
#####################################################

scripted_trigger stewardship_duty_4060_valid_targeting_faction_trigger = {
	exists = faction_leader
	faction_leader = {
		is_ai = yes
	}
	any_faction_member = { #Factions must have at least one additional faction member.
		count >= 1
		is_a_faction_leader = no
	}
	# Faction must be a reasonable threat, and must be likely to revolt soon.
	faction_power >= faction_power_threshold
	faction_discontent >= massive_discontent_loss
}

stewardship_duty.4060 = {
	type = character_event
	title = stewardship_duty.4060.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:targeting_faction = {
						faction_is_type = claimant_faction

						# Check if faction leader is pressing their own claim.
						special_character = {
							this = scope:faction_leader
						}
					}
				}
				desc = stewardship_duty.4060.desc.self_claim
			}
			triggered_desc = {
				trigger = {
					scope:targeting_faction = {
						faction_is_type = claimant_faction
					}
				}
				desc = stewardship_duty.4060.desc.other_claim
			}
			desc = stewardship_duty.4060.desc.default
		}
		desc = stewardship_duty.4060.desc.end
	}
	theme = stewardship_duty_focus
	
	left_portrait = {
		character = scope:faction_leader
		animation = schadenfreude
	}
	
	trigger = {
		NOT = { has_character_flag = had_stewardship_duty_4060_event }

		# Check that we are at war.
		is_at_war = yes
		is_available_adult_or_is_commanding = yes

		# Check that we have a faction that is about to revolt.
		any_targeting_faction = {
			stewardship_duty_4060_valid_targeting_faction_trigger = yes
		}
	}

	weight_multiplier = {
		base = 20 # Much higher base chance due to the rarity of when this event will be valid and the importance of it!

		# Greatly increased chance if there is an active faction whose power rivals or exceeds yours.
		modifier = {
			any_targeting_faction = {
				faction_power > 85
			}
			add = 5 # 2500%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 95
			}
			add = 10 # 3500%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 105
			}
			add = 20 # 5500%
		}
		modifier = {
			any_targeting_faction = {
				faction_power > 115
			}
			add = 30 # 8500%
		}

		# Higher chance the closer to revolting the faction is.
		modifier = {
			any_targeting_faction = {
				faction_discontent >= 65
			}
			factor = 2 # Up to 16000%
		}
		modifier = {
			any_targeting_faction = {
				faction_discontent >= 80
			}
			factor = 2 # Up to 32000%
		}
		modifier = {
			any_targeting_faction = {
				faction_discontent >= 90
			}
			factor = 2 # Up to 64000%
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }		
	}

	immediate = {
		save_scope_as = scoped_ruler
		random_targeting_faction = {
			limit = {
				stewardship_duty_4060_valid_targeting_faction_trigger = yes
			}
			save_scope_as = targeting_faction

			faction_leader = {
				save_scope_as = faction_leader
			}
		}

		add_character_flag = {
			flag = had_stewardship_duty_4060_event
			years = 5
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}
	}

	#Attempt to persuade through diplomacy.
	option = {
		trigger = {
			scope:faction_leader = {
				is_ai = yes
			}
		}
		name = stewardship_duty.4060.a

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			target = scope:faction_leader
			skill = diplomacy
			desc = outcome_in_a_few_days
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 4
					min = -49
				}
				desc = stewardship_duty.4060.a.success

				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty.4060.a.success
					left_icon = scope:faction_leader

					scope:targeting_faction = {
						# Reduce faction discontent.
						add_faction_discontent = massive_discontent_loss

						# If there are any members of the faction other than faction leader, they will be impressed by our speech and gain respect opinion.
						if = {
							limit = {
								any_faction_member = {
									NOT = {this = scope:faction_leader}
								}
							}
							every_faction_member = {
								limit = {
									NOT = { this = scope:faction_leader }
								}
								custom = stewardship_duty.4060.a.success.every_faction_member
								add_opinion = {
									modifier = respect_opinion
									target = root
									opinion = 10
								}
							}
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -4
					min = -49
				}
				desc = stewardship_duty.4060.a.failure

				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_duty.4060.a.failure
					left_icon = scope:faction_leader

					add_prestige = medium_prestige_loss

					stress_impact = {
						base = minor_stress_impact_gain
						arrogant = minor_stress_impact_gain						
					}	
				}
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
			craven = minor_stress_impact_gain

		}	

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 50
				ai_vengefulness = -50
			}

			# Intelligent AIs know when they have good odds of winning a duel.
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = diplomacy
				multiplier = 500
			}
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = scope:faction_leader.diplomacy
				multiplier = -500
			}
		}
	}

	#Offer a bribe.
	option = {
		name = stewardship_duty.4060.b
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= medium_gold_value_check
			}
		}

		pay_short_term_gold = {
			target = scope:faction_leader
			gold = medium_gold_value
		}
		scope:targeting_faction = {
			add_faction_discontent = massive_discontent_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -100
				ai_rationality = 50
			}

			# Rational AIs are more likely to take a guaranteed discontent reduction if the faction is very strong.
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = scope:targeting_faction.faction_power
				multiplier = 10
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
		}	
	}



	#Try to imprison
	option = {
		name = stewardship_duty.4060.c

		trigger = {
			NOT = {
				scope:faction_leader = {
					has_hook = root
				}
			}
		}

		# Imprison the faction leader. May cause tyranny, depending on circumstances.
		imprison_character_effect = {
			TARGET = scope:faction_leader
			IMPRISONER = root
		}
		add_dread = minor_dread_gain

		# If the faction still exists, everyone in it gets really angry at this.
		if = {
			limit = {
				exists = scope:targeting_faction
			}
			scope:targeting_faction = {
				add_faction_discontent = major_discontent_gain
			}
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			honest = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}	

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -50
				ai_boldness = -50
				ai_rationality = -50
				ai_compassion = 100
			}

			# Rational AIs are more likely to take a guaranteed discontent reduction if the faction is very strong.
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = scope:targeting_faction.faction_power
				multiplier = -1
			}
		}
	}

	#Ignore the faction.
	option = {
		name = stewardship_duty.4060.d

		custom_tooltip = stewardship_duty.4060.decline.tt
		stress_impact = {
			base = minor_stress_impact_loss
			diligent = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -100
				ai_rationality = -50
			}
		}
	}
}

##################################
# A Vassal cheats their contract
# 5021
# by Linnéa Thimrén
##################################


scripted_trigger stewardship_duty_5021_cheating_vassal_trigger = {
	is_ai = yes
	has_government = feudal_government # Only feudal use obligations needed to check the script value
	OR = {
		opinion = {
			target = root
			value <= 0
		}
		ai_greed >= high_positive_ai_value
		ai_honor <= high_negative_ai_value
	}
	NOT = { has_trait = honest }
}

scripted_trigger stewardship_duty_5012_can_increase_vassal_contract_trigger = {
	vassal_contract_can_be_modified_trigger = yes
	vassal_contract_obligation_level_can_be_increased = feudal_government_taxes 
}


stewardship_duty.5021 = {
	type = character_event
	title = stewardship_duty.5021.t
	desc = stewardship_duty.5021.desc
	
	theme = stewardship_duty_focus
	left_portrait = scope:cheater_vassal
	
	trigger = {
		has_lifestyle = stewardship_lifestyle
		NOT = { has_character_flag = had_event_stewardship_duty_5021 }
		any_vassal = {
			stewardship_duty_5021_cheating_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1

		# Less likely if we don't have a good event target.
		modifier = {
			any_vassal = {
				stewardship_duty_5021_cheating_vassal_trigger = yes
				stewardship_duty_5012_can_increase_vassal_contract_trigger = no
			}
			add = -0.5
		}

		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }	
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stewardship_duty_5021
			days = 3650
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}
		random_vassal = {
			#First choice: someone who can have contract modified, preferably someone who has money
			limit = {
				stewardship_duty_5021_cheating_vassal_trigger = yes
				stewardship_duty_5012_can_increase_vassal_contract_trigger = yes
				short_term_gold >= stewardship_duty_5021_big_money #5 years of the income increase liege would have gotten by increasing vassal contract
			}
			alternative_limit = {
				stewardship_duty_5021_cheating_vassal_trigger = yes
				stewardship_duty_5012_can_increase_vassal_contract_trigger = yes
			}
			#Second choice: any valid vassal, preferably someone who has money
			alternative_limit = {
				stewardship_duty_5021_cheating_vassal_trigger = yes
				short_term_gold >= stewardship_duty_5021_big_money #5 years of the income increase liege would have gotten by increasing vassal contract
			}
			alternative_limit = { stewardship_duty_5021_cheating_vassal_trigger = yes }

			weight = {
				base = 50
				modifier = {
					add = 100
					ai_honor <= high_negative_honor
				}
				modifier = {
					add = 75
					ai_honor <= medium_negative_honor
				}
				modifier = {
					add = 50
					ai_honor <= low_negative_honor
				}

				modifier = {
					factor = 5
					is_powerful_vassal_of = root
				}
			}
			save_scope_as = cheater_vassal
		}
	}

	option = { #demand payment
		name = stewardship_duty.5021.a


		add_stewardship_lifestyle_xp = medium_lifestyle_xp

		duel = {
			skill = stewardship
			target = scope:cheater_vassal
			50 = {
				desc = stewardship_duty.5021.a.message_1

				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = 10
					has_realm_law = crown_authority_3
				}

				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty.5021.a.message_1
					left_icon = scope:cheater_vassal
					scope:cheater_vassal = {
						pay_short_term_gold = {
							gold = stewardship_duty_5021_big_money #5 years of the income increase liege would have gotten by increasing vassal contract
							target = root
						}
					}
				}
			}
			50 = {
				desc = stewardship_duty.5021.a.message_2

				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				send_interface_toast = {
					type = event_toast_effect_neutral
					title = stewardship_duty.5021.a.message_2
					left_icon = scope:cheater_vassal

					scope:cheater_vassal = {
						pay_short_term_gold = {
							gold = stewardship_duty_5021_small_money #2.5 years of the income increase liege would have gotten by increasing vassal contract
							target = root
						}
					}
					add_prestige = medium_prestige_loss
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_boldness = 0.25
			}
		}
	}

	option = { #Change contract to be more beneficial to root
		trigger = {
			scope:cheater_vassal = {
				stewardship_duty_5012_can_increase_vassal_contract_trigger = yes
			}
		}
		name = stewardship_duty.5021.b

		scope:cheater_vassal = {
			vassal_contract_increase_obligation_level = feudal_government_taxes
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -10
			}
		}


		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			content = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.75
			}
		}
	}
	
	option = { #who cares?
		name = stewardship_duty.5021.c

		
		if = {
			limit = {
				can_set_relation_friend_trigger = { CHARACTER = scope:cheater_vassal }
				scope:cheater_vassal = { stewardship_duty_5012_can_increase_vassal_contract_trigger = yes }

			}
			scope:cheater_vassal = { vassal_contract_decrease_obligation_level = feudal_government_taxes }
			set_relation_friend = scope:cheater_vassal
		}
		else = {
			reverse_add_opinion = {
				target = scope:cheater_vassal
				modifier = friendliness_opinion
				opinion = 20
			}
		}
		
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = forgiving
			}
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}
}

################################################
# Warring Vassals
# End an ongoing war between two vassals in your realm
# 7001
# by Linnéa Thimrén and Sean Hughes
################################################

scripted_trigger stewardship_duty_7001_valid_war_trigger = {
	always = yes
	casus_belli = {
		primary_attacker = {
			is_ai = yes
			is_vassal_of = root
		}
		primary_defender = {
			is_ai = yes
			is_vassal_of = root
		}
	}
}

stewardship_duty.7001 = {
	type = character_event
	title = stewardship_duty.7001.t
	desc = stewardship_duty.7001.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = battlefield
	}
	left_portrait = {
		character = scope:war_vassal
		animation = war_attacker
	}
	right_portrait = {
		character = scope:war_vassal_2
		animation = war_defender
	}
	
	trigger = {
		NOT = { has_character_flag = had_statecraft_7001_event }
		any_vassal = {
			any_character_war = {
				stewardship_duty_7001_valid_war_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }	
	}

	immediate = {
		add_character_flag = {
			flag = had_statecraft_7001_event
			days = 3650
		}
		add_character_flag = {
			flag = had_recent_lifestyle_ongoing_event
			years = ongoing_lifestyle_event_delay
		}

		# Find a vassal-to-vassal war for this event.
		random_vassal = {
			limit = {
				is_at_war = yes
				any_character_war = {
					stewardship_duty_7001_valid_war_trigger = yes
				}
			}
			random_character_war = {
				limit = {
					stewardship_duty_7001_valid_war_trigger = yes
				}
				save_scope_as = war_scope
				casus_belli = {
					primary_attacker = {
						save_scope_as = war_vassal
					}
					primary_defender = {
						save_scope_as = war_vassal_2
					}
				}
			}
		}
	}

	# Option A: Negotiate a white peace between your vassals.
	option = {
		name = stewardship_duty.7001.a

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			skill = diplomacy
			target = scope:war_vassal
			60 = {
				desc = stewardship_duty.7001.a.desc_1
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -59
				}

				# Safety event to ensure the war is still ongoing before we end it.
				trigger_event = stewardship_duty.7002

				# Show the player what effects the safety event will have if it is valid.
				show_as_tooltip = {
					scope:war_scope = {
						end_war = white_peace
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -39
				}

				desc = stewardship_duty.7001.a.desc_2
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_duty.7001.a.desc_2
					add_prestige = minor_prestige_loss
				}

				stress_impact = {
					arrogant = minor_stress_impact_gain
				}
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_compassion = 200
			}

			# Rational characters know when they have a good chance of winning the duel
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = {
					value = scope:war_vassal.diplomacy
					multiply = -1
					add = diplomacy
				}
				multiplier = 25
			}
		}
	}

	# Option B: Respect your vassal's autonomy, they like you more.
	option = {
		name = stewardship_duty.7001.b
		scope:war_vassal = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 15
			}
		}
		scope:war_vassal_2 = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 15
			}
		}
		stress_impact = {
			ambitious = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100

			ai_value_modifier = {
				ai_boldness = -100
				ai_energy = -100
			}
		}
	}

	# Option C: Force your vassals to end the war or else!
	option = {
		name = stewardship_duty.7001.c

		# Safety event to ensure the war is still ongoing before we end it.
		trigger_event = stewardship_duty.7003

		# Show the player what effects the safety event will have.
		show_as_tooltip = {
			scope:war_scope = {
				end_war = white_peace
			}
			add_dread = medium_dread_gain
			scope:war_vassal = {
				add_opinion = {
					modifier = respect_opinion
					target = root
					opinion = -10
				}
			}
			scope:war_vassal_2 = {
				add_opinion = {
					modifier = respect_opinion
					target = root
					opinion = -10
				}
			}
		}

		stress_impact = {
			craven = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			calm = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 200
				ai_compassion = -100
				ai_honor = -100
			}
		}
	}
}

# Safety event for Option A in stewardship_duty.7001 that ensures the war is still valid before executing option effects.
stewardship_duty.7002 = {
	hidden = yes

	immediate = {
		if = {
			limit = { #To check that they're still at war
				exists = scope:war_scope
				scope:war_vassal = {
					is_alive = yes
					is_participant_in_war = scope:war_scope
				}
				scope:war_vassal_2 = {
					is_alive = yes
					is_participant_in_war = scope:war_scope
				}
			}
			# Ends the war and gives the player statecraft progress.
			send_interface_toast = {
				type = event_toast_effect_good
				title = stewardship_duty.7002.toast.peace
				scope:war_scope = {
					end_war = white_peace
				}
			}
		}
		else = {
			# Sends failsafe toast indicating the war ended before the player could act.
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = stewardship_duty.7002.toast.invalid
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
		}
	}
}


# Safety event for Option C in stewardship_duty.7001 that ensures the war is still valid before executing option effects.
stewardship_duty.7003 = {
	hidden = yes

	immediate = {
		if = {
			limit = { #To check that they're still at war
				exists = scope:war_scope
				scope:war_vassal = {
					is_alive = yes
					is_participant_in_war = scope:war_scope
				}
				scope:war_vassal_2 = {
					is_alive = yes
					is_participant_in_war = scope:war_scope
				}
			}
			# Ends the war and gives the player dread.
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = stewardship_duty.7002.toast.peace
				scope:war_scope = {
					end_war = white_peace
				}
				add_dread = medium_dread_gain
				scope:war_vassal = {
					add_opinion = {
						modifier = respect_opinion
						target = root
						opinion = -10
					}
				}
				scope:war_vassal_2 = {
					add_opinion = {
						modifier = respect_opinion
						target = root
						opinion = -10
					}
				}
			}
		}
		else = {
			# Sends failsafe toast indicating the war ended before the player could act.
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = stewardship_duty.7002.toast.invalid
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
		}
	}
}

################################################
# About That Favor
# 7023
# by Stephen Arthur and Sean Hughes
################################################
stewardship_duty.7023 = {
	type = character_event
	title = stewardship_duty.7023.t
	desc = stewardship_duty.7023.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:hook_holder
		animation = schadenfreude
	}

	trigger = {
		is_landed = yes
		OR = {
			any_vassal = {
				has_hook_of_type = {
					target = root
					type = favor_hook
				}		
			}
			liege = {
				has_hook_of_type = {
					target = root
					type = favor_hook
				}			
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }	
	}

	immediate = {
		root = {
			save_scope_as = hooked_ruler
		}

		if = {
			limit = {
				liege = {
					has_hook_of_type = {
						target = root
						type = favor_hook
					}			
				}				
			}
			liege = {
				save_scope_as = hook_holder
			}
		}
		else = {
			random_vassal = {
				limit = {
					has_hook_of_type = {
						target = root
						type = favor_hook
					}
				}
				save_scope_as = hook_holder	
			}
		}

		# This is only here to stop the script system from throwing erroneous errors.
		# Note that EVERY options should overwrite this flag before triggering the next event, or the following events may become nonsensical.		
	}	

	# Pay it off with gold
	option = {
		name = stewardship_duty.7023.a
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= major_gold_value
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
		}

		if = { # If the hook holder is an AI, they auto-accept the offer.
			limit = {
				scope:hook_holder = {
					is_ai = yes
				}
			}
			pay_short_term_gold = {
				target = scope:hook_holder
				gold = major_gold_value
			}
			scope:hook_holder = {
				remove_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		else = { # Otherwise we need to send the offer to a player.
			# Inform the player what the possible outcomes will be.
			show_as_tooltip = {
				random_list = {
					1 = {
						desc = stewardship_duty.7023.a.success
						show_chance = no
						
						scope:hook_holder = {
							remove_hook = {
								target = root
								type = favor_hook
							}
						}
						pay_short_term_gold = {
							target = scope:hook_holder
							gold = major_gold_value
						}
					}
					1 = {
						desc = stewardship_duty.7023.failure
						show_chance = no
						custom_tooltip = stewardship_duty.7023.d.tt
					}
				}
			}

			# Set method flag and send the event to the other player.
			save_scope_value_as = {
				name = stewardship_duty_7023_method
				value = flag:gold
			}	
			scope:hook_holder = {
				trigger_event = {
					id = stewardship_duty.7025
					days = { 4 7 }
				}		
			}
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -500
			}
		}			
	}

	# Talk your way out of it
	option = {
		name = stewardship_duty.7023.b

		stress_impact = {
			shy = minor_stress_gain
		}

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		duel = {
			skill = diplomacy
			target = scope:hook_holder
			desc = outcome_in_a_few_days
			50 = {	
				desc = stewardship_duty.7023.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				# If the hook_holder accepts our debt will be waived.
				show_as_tooltip = {
					scope:hook_holder = {
						remove_hook = {
							target = root
							type = favor_hook
						}
					}
				}

				# If the hook_holder is AI, we will use this to determine what option they select.
				# Otherwise it influences how much Stress a player will receive if they refuse.
				save_scope_value_as = {
					name = stewardship_duty_7023_success
					value = yes
				}
			}
			50 = {	
				desc = stewardship_duty.7023.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				# If the hook_holder refuses we will still owe them a favor.
				custom_tooltip = stewardship_duty.7023.d.tt

				# Inform the player that if they hook_holder is another player, they may still be incentivized to waive the favor.
				if = {
					limit = {
						scope:hook_holder = {
							is_ai = no
						}
					}
					custom_tooltip = stewardship_duty.7023.player
				}

				# If the hook_holder is AI, we will use this to determine what option they select.
				# Otherwise it influences how much Stress a player will receive if they refuse.
				save_scope_value_as = {
					name = stewardship_duty_7023_success
					value = no
				}
			}
		}	

		save_scope_value_as = {
			name = stewardship_duty_7023_method
			value = flag:diplomacy
		}		
		scope:hook_holder = {
			trigger_event = {
				id = stewardship_duty.7025
				days = { 4 7 }
			}		
		}		
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 200
				ai_energy = 100
				ai_greed = 100

			}

			# Intelligent AIs know when they have good odds of winning a duel.
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = diplomacy
				multiplier = 500
			}
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = scope:hook_holder.diplomacy
				multiplier = -500
			}
		}				
	}

	# Intimidate your way out of it
	option = {
		name = stewardship_duty.7023.c

		stress_impact = {
			just = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		add_stewardship_lifestyle_xp = medium_lifestyle_experience

		random_list = {
			50 = {	
				desc = stewardship_duty.7023.success
				compare_modifier = {
					trigger = {
						scope:hook_holder = {
							is_vassal_of = root
						}
					}
					value = dread
					multiplier = 0.5
				}

				# If the hook_holder accepts our debt will be waived.
				show_as_tooltip = {
					scope:hook_holder = {
						remove_hook = {
							target = root
							type = favor_hook
						}
					}
				}

				# If the hook_holder is AI, we will use this to determine what option they select.
				# Otherwise it influences how much Stress a player will receive if they refuse.
				save_scope_value_as = {
					name = stewardship_duty_7023_success
					value = yes
				}
			}
			50 = {
				desc = stewardship_duty.7023.failure
				modifier = {
					is_vassal_of = scope:hook_holder
					add = 50
				}
				compare_modifier = {
					value = scope:hook_holder.ai_boldness
					multiplier = 0.5
					min = -49
				}

				# They don't like us for trying to threaten them.
				scope:hook_holder = {
					add_opinion = {
						modifier = angry_opinion
						target = root
						opinion = -10
					}
				}
				# If the hook_holder refuses we will still owe them a favor.
				custom_tooltip = stewardship_duty.7023.d.tt

				# Inform the player that if they hook_holder is another player, they may still be incentivized to waive the favor.
				if = {
					limit = {
						scope:hook_holder = {
							is_ai = no
						}
					}
					custom_tooltip = stewardship_duty.7023.player
				}

				# If the hook_holder is AI, we will use this to determine what option they select.
				# Otherwise it influences how much Stress a player will receive if they refuse.
				save_scope_value_as = {
					name = stewardship_duty_7023_success
					value = no
				}
			}
		}	

		save_scope_value_as = {
			name = stewardship_duty_7023_method
			value = flag:intimidation
		}
		scope:hook_holder = {
			trigger_event = {
				id = stewardship_duty.7025
				days = { 4 7 }
			}
		}

		stress_impact = {
			compassionate = major_stress_impact_gain
			just = medium_stress_impact_gain
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 200
				ai_compassion = -100
				ai_energy = 100
				ai_greed = 100

			}

			# Intelligent AIs know when they have good odds of winning a duel.
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = dread
				multiplier = 500
			}
			compare_modifier = {
				trigger = {
					ai_rationality >= 10
				}
				value = scope:hook_holder.ai_boldness
				multiplier = -500
			}
		}					
	}	

	# Affirm that you still owe your favor.
	option = {
		name = stewardship_duty.7023.d

		scope:hook_holder = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
		custom_tooltip = stewardship_duty.7023.d.tt

		stress_impact = {
			greedy = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_energy = -100
				ai_greed = -100
			}
		}
	}
}

# About that Favor: Hook holder gets a letter
stewardship_duty.7025 = {
	type = letter_event
	opening = stewardship_duty.7025.opening
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:gold
				}
				desc = stewardship_duty.7025.desc.gold
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:diplomacy
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = yes
				}
				desc = stewardship_duty.7025.desc.diplomacy.success
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:diplomacy
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = no
				}
				desc = stewardship_duty.7025.desc.diplomacy.failure
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:intimidation
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = yes
				}
				desc = statectaft_ongoing.7025.desc.intimidation.success
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:intimidation
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = no
				}
				desc = stewardship_duty.7025.desc.intimidation.failure
			}								
		}
	}
	sender = {
		character = scope:hooked_ruler
		animation = beg
	}

	trigger = {	# Ensure we still have a valid hook to execute on
		scope:hook_holder = {
			has_hook_of_type = {
				target = scope:hooked_ruler
				type = favor_hook
			}		
		}
	}

	on_trigger_fail = { # If we don't, about the event chain and send a toast to inform players about this.
		scope:hooked_ruler = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = stewardship_duty.7023.invalidated.hooked_ruler
				left_icon = scope:hooked_ruler
			}
		}
	}

	# Accept the offer
	option = {
		name = {
			trigger = { scope:stewardship_duty_7023_method = flag:gold }
			text = stewardship_duty.7025.gold.a
		}
		name = {
			trigger = {scope:stewardship_duty_7023_method = flag:diplomacy}
			text = stewardship_duty.7025.diplomacy.a
		}
		name = {
			trigger = {scope:stewardship_duty_7023_method = flag:intimidation}
			text = stewardship_duty.7025.intimidation.a
		}

		# Show the player what will happen if they accept.
		show_as_tooltip = {
			scope:hook_holder = {
				remove_hook = {
					target = scope:hooked_ruler
					type = favor_hook
				}
			}
			if = {
				limit = {
					scope:stewardship_duty_7023_method = flag:gold
				}
				scope:hooked_ruler = {
					pay_short_term_gold = {
						target = scope:hook_holder
						gold = major_gold_value
					}
				}
			}
			else = {
				scope:hooked_ruler = {
					add_opinion = {
						modifier = pleased_opinion
						target = scope:hook_holder
						opinion = 20
					}
				}
			}
		}

		# Save that we have accepted the offer.
		save_scope_value_as = {
			name = stewardship_duty_7025_accepted
			value = yes
		}	

		ai_chance = {
			base = 100
			
			# If the duel or indimidation challenge failed, the AI will not take this option.
			modifier = {
				AND = {
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = no
				}
				add = -100
			}
		}					
	}

	# Refuse the offer
	option = {
		name = {
			trigger = {scope:stewardship_duty_7023_method = flag:gold}
			text = stewardship_duty.7025.gold.b
		}
		name = {
			trigger = {scope:stewardship_duty_7023_method = flag:diplomacy}
			text = stewardship_duty.7025.diplomacy.b
		}
		name = {
			trigger = {scope:stewardship_duty_7023_method = flag:intimidation}
			text = stewardship_duty.7025.intimidation.b
		}
		flavor = {
			triggered_desc = {
				trigger = {
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = yes
				}
				desc = stewardship_duty.7025.stress.tt
			}
		}

		# Save that we have rejected the offer
		custom_tooltip = stewardship_duty.7025.refuse.tt
		save_scope_value_as = {
			name = stewardship_duty_7025_accepted
			value = no
		}

		# Stress Impacts
		if = {
			# Base Stress gain if the hooked_ruler succeeded at their diplomacy/indimidation challenge.
			limit = {
				exists = scope:stewardship_duty_7023_success
				scope:stewardship_duty_7023_success = yes
			}
			save_scope_value_as = {
				name = base_stress_impact_gain
				value = medium_stress_impact_gain
			}
		}
		else = {
			save_scope_value_as = {
				name = base_stress_impact_gain
				value = 0
			}
		}

		if = {
			# Greedy characters find it hard to turn down bribes.
			limit = {
				scope:stewardship_duty_7023_method = flag:gold
			}
			stress_impact = {
				base = scope:base_stress_impact_gain
				greedy = medium_stress_impact_gain
			}
		}
		else_if = {
			# Compassionate/forgiving characters tend to let others off the hook.
			limit = {
				scope:stewardship_duty_7023_method = flag:diplomacy
			}
			stress_impact = {
				base = scope:base_stress_impact_gain
				generous = medium_stress_impact_gain
				compassionate = medium_stress_impact_gain
				forgiving = medium_stress_impact_gain
			}
		}
		else_if = {
			# Craven/content characters are loathe to rock the boat.
			limit = {
				scope:stewardship_duty_7023_method = flag:intimidation
			}
			stress_impact = {
				base = scope:base_stress_impact_gain
				craven = medium_stress_impact_gain
				content = minor_stress_impact_gain
			}
		}

		ai_chance = {
			base = 0

			# If the duel or indimidation challenge failed, the AI will always take this option.
			modifier = {
				AND = {
					exists = scope:stewardship_duty_7023_success
					scope:stewardship_duty_7023_success = no
				}
				add = 100
			}
		}					
	}


	after = {
		scope:hooked_ruler = {
			trigger_event = {
				id = stewardship_duty.7027
				days = 0
			}
		}
	}
}

# About that Favor: Hooked ruler gets a response

stewardship_duty.7027 = {
	type = letter_event
	opening = {
		desc = stewardship_duty.7027.opening
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:gold
					scope:stewardship_duty_7025_accepted = yes
				}
				desc = stewardship_duty.7027.desc.accepted.gold
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:gold
					scope:stewardship_duty_7025_accepted = no
				}
				desc = stewardship_duty.7027.desc.refused.gold
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:diplomacy
					scope:stewardship_duty_7025_accepted = yes
				}
				desc = stewardship_duty.7027.desc.accepted.diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:diplomacy
					scope:stewardship_duty_7025_accepted = no
				}
				desc = stewardship_duty.7027.desc.refused.diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:intimidation
					scope:stewardship_duty_7025_accepted = yes
				}
				desc = stewardship_duty.7027.desc.accepted.intimidation
			}
			triggered_desc = {
				trigger = {
					scope:stewardship_duty_7023_method = flag:intimidation
					scope:stewardship_duty_7025_accepted = no
				}
				desc = stewardship_duty.7027.desc.refused.intimidation
			}
		}
	}
	sender = {
		character = scope:hook_holder
		triggered_animation = {
			trigger = {
				scope:stewardship_duty_7025_accepted = yes
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				scope:stewardship_duty_7025_accepted = yes
			}
			animation = dismissal
		}
	}

	trigger = {	# Ensure we still have a valid hook to execute on
		scope:hook_holder = {
			has_hook_of_type = {
				target = scope:hooked_ruler
				type = favor_hook
			}		
		}
	}

	on_trigger_fail = { # If we don't, about the event chain and send a toast to inform players about this.
		scope:hooked_ruler = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = stewardship_duty.7023.invalidated.hooked_ruler
				left_icon = scope:hook_holder
			}
		}
		scope:hook_holder = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = stewardship_duty.7023.invalidated.hook_holder
				left_icon = scope:hooked_ruler
			}
		}
	}

	immediate = {
		# Before anything has a chance to change, execute all pending event effect resolutions.
		if = {
			# If they accepted, remove the hook they have on us.
			limit = {
				scope:stewardship_duty_7025_accepted = yes
			}
			scope:hook_holder = {
				remove_hook = {
					target = root
					type = favor_hook
				}
			}
			if = {
				# If the reason they accepted was a payment, pay them that money.
				limit = {
					scope:stewardship_duty_7023_method = flag:gold
				}
				pay_short_term_gold = {
					target = scope:hook_holder
					gold = major_gold_value
				}
			}
			else = {
				# Otherwise, they gain opinion of us (hidden because players effectively do not have opinion of others.)
				# We do still want to add it to players though (in case they get taken over by AI in multiplayer, etc.)
				hidden_effect = {
					add_opinion = {
						modifier = pleased_opinion
						target = scope:hook_holder
						opinion = 20
					}
				}
			}
		}
	}

	# Acknowledge their response.
	option = {
		name = {
			trigger = {scope:stewardship_duty_7025_accepted = yes}
			text = stewardship_duty.7027.a
		}
		name = {
			trigger = {scope:stewardship_duty_7025_accepted = no}
			text = stewardship_duty.7027.b
		}

		if = { # If we did not get them to drop the favor, inform the player they they still owe one.
			limit = {
				scope:stewardship_duty_7025_accepted = no
			}
			custom_tooltip = stewardship_duty.7023.d.tt
		}
	}
}



###########################################################
# Events converted from the old Progress Event system.
# These events are all challenging event chains which should reward a perk point or some other significant benefit for successfully completing them.
namespace = stewardship_duty_special


##########################################
# MAP PAINTING JOURNEY
# by Petter Vilberg
# 1201-1299
##########################################
scripted_trigger stewardship_duty_special_1201_chain_validation_trigger = {
	exists = scope:painting_title.holder
	NOT = { scope:painting_title.holder = root }
}

scripted_effect stewardship_duty_special_1201_recover_land_owner_effect = {
	if = {
		limit = {
			OR = {
				scope:painting_land_owner = { is_alive = no }
				NOT = { scope:painting_title.holder = scope:painting_land_owner }
			}
		}
		scope:painting_title.holder = { save_scope_as = painting_land_owner }
		
	}
	scope:painting_title = {
		if = {
			limit = {
				tier = tier_duchy
			}
			title_capital_county.title_province = { save_scope_as = background_wilderness_scope }
		}
		else = {
			title_province = { save_scope_as = background_wilderness_scope }
		}
	}
}

#Set up the Activity
stewardship_duty_special.1201 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1201.desc
	
	left_portrait = {
		character = cp:councillor_steward
	}
	right_portrait = {
		character = scope:painting_land_owner
	}
	theme = stewardship_duty_focus
	
	trigger = {
		has_focus = stewardship_duty_focus
		exists = cp:councillor_steward
		cp:councillor_steward = { save_temporary_scope_as = tmp_steward }
		NOT = { has_character_flag = had_stewardship_duty_special_1201_this_lifetime } # Once per lifetime.
		NOT = { has_character_flag = is_in_stewardship_duty_special_event }
		OR = {
			AND = {
				highest_held_title_tier >= tier_kingdom
				any_sub_realm_duchy = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:tmp_steward }
					}
				}
			}
			AND = {
				highest_held_title_tier = tier_duchy
				any_sub_realm_county = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:tmp_steward }
					}
				}
			}
			AND = {
				highest_held_title_tier = tier_county
				any_sub_realm_barony = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:tmp_steward }
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		if = {
			limit = { exists = cp:councillor_steward }
			cp:councillor_steward = {
				save_scope_as = steward
			}
		}
		add_character_flag = {
			flag = is_in_stewardship_duty_special_event
			days = 500
		}
		add_character_flag = had_stewardship_duty_special_1201_this_lifetime

		#Find a good place to paint maps
		if = {
			limit = {
				highest_held_title_tier >= tier_kingdom
				any_sub_realm_duchy = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:steward }
					}
				}
			}
			random_sub_realm_duchy = {
				limit = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:steward }
					}
				}
				save_scope_as = painting_title
				holder = {
					save_scope_as = painting_land_owner
				}
			}
		}
		
		if = {
			limit = {
				highest_held_title_tier = tier_duchy
				any_sub_realm_county = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:steward }
					}
				}
			}
			random_sub_realm_county = {
				limit = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:steward }
					}
				}
				save_scope_as = painting_title
				holder = {
					save_scope_as = painting_land_owner
				}
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_county
				any_sub_realm_barony = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:steward }
					}
				}
			}
			random_sub_realm_barony = {
				limit = {
					holder = {
						is_ai = yes
						NOT = { this = root }
						NOT = { this = scope:steward }
					}
				}
				save_scope_as = painting_title
				holder = {
					save_scope_as = painting_land_owner
				}
			}
		}
	}

	option = {
		name = stewardship_duty_special.1201.a
		custom_tooltip = stewardship_lifestyle_rank_up_indication
		trigger_event = {
			id = stewardship_duty_special.1202
			days = { 10 20 }
		}
	}

	option = {
		name = stewardship_duty_special.1201.b
		
		stress_impact = {
			base = medium_stress_impact_loss
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		
		remove_character_flag = is_in_stewardship_duty_special_event
	}
}


#Arrival - greeted by land owner envoy
stewardship_duty_special.1202 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1202.desc
	
	theme = stewardship_duty_focus

	override_background = {
		event_background = wilderness_scope
	}
	left_portrait = root
	right_portrait = {
		character = scope:painting_land_owner
		animation = idle
	}

	immediate = {
		stewardship_duty_special_1201_recover_land_owner_effect = yes
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_gender }

	}
	
	option = { #Better get started!
		name = stewardship_duty_special.1202.a
		custom_tooltip = stewardship_duty_special.1202.a.tt
		trigger_event = {
			on_action = map_painting_event_selection
			days = { 5 15 }
		}
	}
}


#Bandits attack
stewardship_duty_special.1203 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1203.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = wilderness_scope
	}
	left_portrait = root

	trigger = {
		NOT = { exists = scope:had_1203 }
		stewardship_duty_special_1201_chain_validation_trigger = yes
	}

	immediate = {
		save_scope_value_as = {
			name = had_1203
			value = yes
		}
		stewardship_duty_special_1201_recover_land_owner_effect = yes
	}
	
	option = { #We fight them off!
		name = stewardship_duty_special.1203.a
		random = {
			chance = 30
			compare_modifier = {
				value = prowess
				multiplier = -1
			}
			increase_wounds_effect = { REASON = fight }
		}
		stress_impact = {
			craven = medium_stress_impact_gain
		}
	}
	
	option = { #Pay them off
		name = stewardship_duty_special.1203.b
		remove_short_term_gold = minor_gold_value
		stress_impact = {
			brave = medium_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
	}

	after = {
		stewardship_duty_special_1201_map_painting_journey_continuation_effect = yes
	}
}


#Rest by a body of water
stewardship_duty_special.1204 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1204.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = wilderness_scope
	}
	left_portrait = root
	
	trigger = {
		NOT = { exists = scope:had_1204 }
		stewardship_duty_special_1201_chain_validation_trigger = yes
	}

	immediate = {
		save_scope_value_as = {
			name = had_1204
			value = yes
		}
		stewardship_duty_special_1201_recover_land_owner_effect = yes
	}

	option = { #Stay for a few days - we're delayed
		name = stewardship_duty_special.1204.a
		custom_tooltip = stewardship_duty_special.1204.a.tt
		stress_impact = {
			base = medium_stress_loss
		}
		hidden_effect = {
			random_list = {
				70 = {
					trigger_event = {
						on_action = map_painting_event_selection
						days = { 20 30 }
					}
				}	
				30 = {
					modifier = {
						add = 30
						exists = scope:had_1203
					}
					modifier = {
						add = 30
						exists = scope:had_1204
					}
					modifier = {
						add = 30
						exists = scope:had_1205
					}
					modifier = {
						add = 30
						exists = scope:had_1206
					}
					modifier = {
						add = 30
						exists = scope:had_1207
					}
					modifier = {
						add = 30
						exists = scope:had_1208
					}
					trigger_event = {
						on_action = map_painting_outcome
						days = { 20 30 }
					}
				}
			}
		}
	}

	option = { #We move on swiftly
		name = stewardship_duty_special.1204.b
		stewardship_duty_special_1201_map_painting_journey_continuation_effect = yes
	}
}

#Encounter peasants
stewardship_duty_special.1205 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1205.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = wilderness_scope
	}
	left_portrait = root
	
	trigger = {
		NOT = { exists = scope:had_1205 }
		stewardship_duty_special_1201_chain_validation_trigger = yes
	}

	immediate = {
		save_scope_value_as = {
			name = had_1205
			value = yes
		}
		stewardship_duty_special_1201_recover_land_owner_effect = yes
	}

	option = { #Impress on the peasants that I am their ruler!
		name = stewardship_duty_special.1205.a
		add_prestige = medium_prestige_gain
		reverse_add_opinion = {
			modifier = governance_emphasised_authority_opinion
			target = scope:painting_land_owner
		}
		stress_impact = {
			humble = minor_stress_impact_gain
		}
	}

	option = { #Try to understand them
		name = stewardship_duty_special.1205.b
		add_character_modifier = {
			modifier = stewardship_duty_understanding_peasants_modifier
			years = 5
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
	}

	after = {
		stewardship_duty_special_1201_map_painting_journey_continuation_effect = yes
	}
}


#Study Forts
stewardship_duty_special.1206 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1206.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = wilderness_scope
	}
	left_portrait = root
	right_portrait = {
		character = scope:local_baron
		animation = idle
	}
	
	trigger = {
		NOT = { exists = scope:had_1206 }
		stewardship_duty_special_1201_chain_validation_trigger = yes
		scope:painting_land_owner = { is_alive = yes }
		scope:painting_land_owner = {
			any_sub_realm_barony = {
				title_province = {
					fort_level > 0
				}
				holder = {
					highest_held_title_tier = tier_barony
				}
			}
		}
	}

	immediate = {
		save_scope_value_as = {
			name = had_1206
			value = yes
		}
		scope:painting_land_owner = {
			random_sub_realm_barony = {
				limit = {
					title_province = { fort_level > 0 }
					holder = { highest_held_title_tier = tier_barony }
				}
				holder = {
					save_scope_as = local_baron
				}
			}
		}
	}

	option = { #Study their defensiveness
		name = stewardship_duty_special.1206.a
		add_character_modifier = {
			modifier = stewardship_duty_studied_fortifications_modifier
			years = 5
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
		}
	}

	option = { #Entertain the barons' company
		name = stewardship_duty_special.1206.b
		add_character_modifier = {
			modifier = stewardship_duty_entertaining_baronial_company
			years = 5
		}
		stress_impact = {
			shy = minor_stress_impact_gain
		}
	}

	after = {
		stewardship_duty_special_1201_map_painting_journey_continuation_effect = yes
	}
}


#Pay for a stay at an inn
stewardship_duty_special.1207 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1207.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = tavern
	}
	left_portrait = root
	
	trigger = {
		NOT = { exists = scope:had_1207 }
		stewardship_duty_special_1201_chain_validation_trigger = yes
	}

	immediate = {
		save_scope_value_as = {
			name = had_1207
			value = yes
		}
		stewardship_duty_special_1201_recover_land_owner_effect = yes
	}

	option = { #Offer to pay
		name = stewardship_duty_special.1207.a
		remove_short_term_gold = minor_gold_value
		add_character_modifier = {
			modifier = stewardship_duty_value_of_service_exchange_modifier
			years = 5
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
	}

	option = { #Demand board
		name = stewardship_duty_special.1207.b
		add_prestige = medium_prestige_gain
		stress_impact = {
			humble = medium_stress_impact_gain
		}
	}

	after = {
		stewardship_duty_special_1201_map_painting_journey_continuation_effect = yes
	}
}


#Follow Rivers
stewardship_duty_special.1208 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = stewardship_duty_special.1208.desc
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = wilderness_scope
	}
	left_portrait = root
	
	trigger = {
		NOT = { exists = scope:had_1208 }
		stewardship_duty_special_1201_chain_validation_trigger = yes
	}

	immediate = {
		save_scope_value_as = {
			name = had_1208
			value = yes
		}
		stewardship_duty_special_1201_recover_land_owner_effect = yes
	}

	option = { #Attempt to send secret messages
		name = stewardship_duty_special.1208.a
		add_character_modifier = {
			modifier = rulership_playful_experimentation_modifier
			days = 1095
		}
	}

	option = { #Attempt to rake the banks
		name = stewardship_duty_special.1208.b
		add_character_modifier = {
			modifier = rulership_mudraking_river_banks_modifier
			days = 1095
		}
	}

	after = {
		stewardship_duty_special_1201_map_painting_journey_continuation_effect = yes
	}
}

###
# Completion Events!
# 1281-1297
###

#Hand the maps over to the local lord
stewardship_duty_special.1281 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = {
		desc = stewardship_duty_special.1281.opening
		desc = stewardship_duty_special.1281.end
	}
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = root
	right_portrait = scope:painting_land_owner
	
	option = {
		name = stewardship_duty_special.1281.a
		add_stewardship_lifestyle_perk_points = 1
	}

	option = { #Offer the maps to the local lord
		name = stewardship_duty_special.1281.b
		reverse_add_opinion = {
			modifier = rulership_careful_mapping_of_my_realm_opinion
			target = scope:painting_land_owner
		}
	}

	after = {
		stewardship_duty_special_1201_conclude_map_painting_effect = yes
	}
}

#New ideas for fortifying the area
stewardship_duty_special.1282 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = {
		desc = stewardship_duty_special.1281.opening
		desc = stewardship_duty_special.1282.end
	}
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = root
	right_portrait = scope:painting_land_owner

	trigger = {
		scope:painting_land_owner = {
			target_is_liege_or_above = root
		}
	}

	option = { #Go for the rank up
		name = stewardship_duty_special.1282.a
		add_stewardship_lifestyle_perk_points = 1
	}
	
	option = { #I can use this to improve my fortifications!
		name = stewardship_duty_special.1282.b
		add_character_modifier = {
			modifier = stewardship_duty_defensive_understanding_modifier
			years = 10
		}
	}

	after = {
		stewardship_duty_special_1201_conclude_map_painting_effect = yes
	}
}

#Detailed map work
stewardship_duty_special.1283 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = {
		desc = stewardship_duty_special.1281.opening
		desc = stewardship_duty_special.1283.end
	}
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = root
	right_portrait = scope:painting_land_owner

	trigger = {
		scope:painting_land_owner = {
			target_is_liege_or_above = root
		}
	}
	
	option = { #Go for the rank up
		name = stewardship_duty_special.1283.a
		add_stewardship_lifestyle_perk_points = 1
	}
	
	option = { #Movement will be a lot easier around here now!
		name = stewardship_duty_special.1283.b
		add_character_modifier = {
			modifier = stewardship_duty_improved_paths_modifier
			years = 10
		}
	}

	after = {
		stewardship_duty_special_1201_conclude_map_painting_effect = yes
	}
}

#My retinue has been crossing a lot of rivers...
stewardship_duty_special.1284 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = {
		desc = stewardship_duty_special.1281.opening
		desc = stewardship_duty_special.1284.end
	}
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = root

	trigger = {
		number_of_commander_traits < 3
		NOT = { has_trait = military_engineer }
	}
	
	option = { #Go for the rank up
		name = stewardship_duty_special.1284.a
		add_stewardship_lifestyle_perk_points = 1
	}
	
	option = { #I've learned a lot about river crossings
		name = stewardship_duty_special.1284.b
		add_trait = military_engineer
	}

	after = {
		stewardship_duty_special_1201_conclude_map_painting_effect = yes
	}
}

#I've come up with some development plans!
stewardship_duty_special.1285 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = {
		desc = stewardship_duty_special.1281.opening
		desc = stewardship_duty_special.1285.end
	}
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = study
	}
	left_portrait = root
	right_portrait = scope:painting_land_owner

	trigger = {
		scope:painting_land_owner = {
			target_is_liege_or_above = root
		}
		stewardship > 7
	}
	
	option = { #Go for the rank up
		name = stewardship_duty_special.1285.a
		add_stewardship_lifestyle_perk_points = 1
	}
	
	option = { #Do this, and this, and this
		name = stewardship_duty_special.1285.b
		add_character_modifier = {
			modifier = stewardship_duty_development_plans_modifier
			years = 5
		}
	}

	after = {
		stewardship_duty_special_1201_conclude_map_painting_effect = yes
	}
}

#This is truly my realm
stewardship_duty_special.1286 = {
	type = character_event
	title = stewardship_duty_special.1201.t
	desc = {
		desc = stewardship_duty_special.1281.opening
		desc = stewardship_duty_special.1286.end
	}
	
	theme = stewardship_duty_focus
	override_background = {
		event_background = throne_room
	}
	left_portrait = root

	trigger = {
		scope:painting_land_owner = {
			target_is_liege_or_above = root
		}
	}

	immediate = {
		capital_barony = {
			save_scope_as = capital
		}
	}
	
	option = { #Go for the rank up
		name = stewardship_duty_special.1286.a
		add_stewardship_lifestyle_perk_points = 1
	}
	
	option = { #I am affirming my rule
		name = stewardship_duty_special.1286.b
		add_character_modifier = {
			modifier = stewardship_duty_affirmed_rule_modifier
			years = 5
		}
	}

	after = {
		stewardship_duty_special_1201_conclude_map_painting_effect = yes
	}
}

############################
# Mediation
# Mediate a dispute between two of your vassals
# 2000 - 2099
# by Petter Vilberg
############################

scripted_trigger stewardship_duty_special_2000_vassal_trigger = {
	target_is_liege_or_above = root
	is_available_ai_adult = yes
	NOT = { is_close_family_of = root }
	NOT = { has_any_scripted_relation = root }
	is_of_major_interest_to_root_trigger = no
	OR = {
		AND = {
			root = { highest_held_title_tier <= tier_duchy }
			highest_held_title_tier <= tier_county
		}
		AND = {
			root = { highest_held_title_tier >= tier_kingdom }
			highest_held_title_tier >= tier_county
		}
	}
}

scripted_trigger stewardship_duty_special_2000_second_vassal_trigger = {
	highest_held_title_tier = scope:vassal_1.highest_held_title_tier
	stewardship_duty_special_2000_vassal_trigger = yes
	NOT = { this = scope:vassal_1 }
}

stewardship_duty_special.2000 = {
	hidden = yes

	trigger = {
		has_focus = stewardship_duty_focus
		is_ai = no
		any_vassal_or_below = {
			stewardship_duty_special_2000_vassal_trigger = yes
			save_temporary_scope_as = vassal_1
		}
		OR = {
			any_vassal_or_below = {
				stewardship_duty_special_2000_second_vassal_trigger = yes
			}
			scope:vassal_1 = {
				any_neighboring_realm_same_rank_owner = {
					stewardship_duty_special_2000_second_vassal_trigger = yes
				}
			}
		}
		#Lifestyle progress tracking
		NOT = { has_character_flag = is_in_stewardship_duty_special_event}
		NOT = { has_character_flag = had_stewardship_duty_special_2000_this_lifetime}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = stewardship_duty_focus }	
	}

	immediate = {
		add_character_flag = {
			flag = is_in_stewardship_duty_special_event
			days = 100
		}
		add_character_flag = had_stewardship_duty_special_2000_this_lifetime
		#Find a suitable Vassal 1:
		random_vassal_or_below = {
			limit = {
				stewardship_duty_special_2000_vassal_trigger = yes
				save_temporary_scope_as = vassal_1
				OR = { # Confirm that a Vassal 2 can be found for this character
					any_neighboring_realm_same_rank_owner = {
						stewardship_duty_special_2000_second_vassal_trigger = yes
					}
					root = {
						any_vassal_or_below = {
							stewardship_duty_special_2000_second_vassal_trigger = yes
						}
					}
				}
			}
			save_scope_as = vassal_1

			if = { # Prioritize a neighbor of Vassal 1
				limit = {
					any_neighboring_realm_same_rank_owner = {
						stewardship_duty_special_2000_second_vassal_trigger = yes
					}
				}
				random_neighboring_realm_same_rank_owner = {
					limit = {
						stewardship_duty_special_2000_second_vassal_trigger = yes
					}
					save_scope_as = vassal_2
				}
			}
		}

		if = { # If there was no suitable neighbor of Vassal 1, pick another vassal+ to be Vassal 2
			limit = {
				NOT = { exists = scope:vassal_2 }
			}
			random_vassal_or_below = {
				limit = {
					stewardship_duty_special_2000_second_vassal_trigger = yes
				}
				save_scope_as = vassal_2
			}
		}

		trigger_event = stewardship_duty_special.2001 # Fire visible event for the player
	}
}


#####
# Two Vassals ask for Judgement
#####

stewardship_duty_special.2001 = {
	type = character_event
	title = stewardship_duty_special.2001.t
	desc = stewardship_duty_special.2001.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = dismissal
	}

	right_portrait = {
		character = scope:vassal_2
		animation = anger
	}


	immediate = {
		if = {
			limit = {
				exists = cp:councillor_chancellor
			}
			save_scope_as = chancellor
		}
	}

	option = {
		name = stewardship_duty_special.2001.a
		hidden_effect = { #Set up the Story
			set_variable = {
				name = stewardship_duty_special_mediation_vassal_1_setup
				value = scope:vassal_1
				days = 3
			}
			set_variable = {
				name = stewardship_duty_special_mediation_vassal_2_setup
				value = scope:vassal_2
				days = 3
			}
			create_story = story_diplomacy_lifestyle_mediation
		}
		custom_tooltip = stewardship_lifestyle_rank_up_indication
	}

	option = { #Let your Council handle it
		name = stewardship_duty_special.2001.b
		trigger = {
			exists = scope:chancellor
		}
		add_prestige = minor_prestige_gain
		remove_character_flag = is_in_stewardship_duty_special_event
	}

	option = { #Threaten them into conpliance
		name = stewardship_duty_special.2001.c
		trigger = {
			NOT = { exists = scope:chancellor }
		}
		add_dread = minor_dread_gain
		remove_character_flag = is_in_stewardship_duty_special_event
	}
}


################################
# Stage 1: The Vassals are presenting their case
# 2000-2019
################################

#Land Dispute
stewardship_duty_special.2011 = {
	type = character_event
	title = stewardship_duty_special.2011.t
	desc = stewardship_duty_special.2011.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = dismissal
	}

	right_portrait = {
		character = scope:vassal_2
		animation = anger
	}

	
	trigger = {
		scope:story = {
			NOT = {
				has_variable = had_event_stewardship_duty_special_2011
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2011
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
	}

	option = { #Discuss it until you can figure it out
		name = stewardship_duty_special.2011.a
		trigger = {
			diplomacy < high_skill_rating
		}
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 2
			}
		}
		custom_tooltip = statecraft_mediation_very_fair
		stress_impact = {
			base = medium_stress_gain
		}
	}

	option = { #Discuss it until its figured out
		name = stewardship_duty_special.2011.a
		trigger = {
			diplomacy >= high_skill_rating
		}
		skill = diplomacy
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 2
			}
		}
		custom_tooltip = statecraft_mediation_very_fair
		stress_impact = {
			base = minor_stress_gain
		}
	}

	option = { #Pay off vassal 1
		name = stewardship_duty_special.2011.b
		remove_short_term_gold = medium_gold_value
		custom_tooltip = statecraft_mediation_fair
		custom_tooltip = statecraft_mediation_favor_vassal_1
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
			change_variable = {
				name = favor_1
				add = 1
			}
		}
	}
	
	option = { #Side with vassal 2
		name = stewardship_duty_special.2011.c
		if = {
			limit = {
				can_add_hook = {
				  	type = favor_hook
				  	target = scope:vassal_2
				}
			}
			add_hook = {
	  			target = scope:vassal_2
	  			type = favor_hook
	 		}
		}
		else = {
			reverse_add_opinion = {
				target = scope:vassal_2
				modifier = pleased_opinion
				opinion = 30
			}
		}
		custom_tooltip = statecraft_mediation_unfair
		custom_tooltip = statecraft_mediation_favor_vassal_2
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = -2
			}
			change_variable = {
				name = favor_2
				add = 2
			}
		}
	}
}


#Family Dispute

stewardship_duty_special.2012 = {
	type = character_event
	title = stewardship_duty_special.2012.t
	desc = stewardship_duty_special.2012.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}
	right_portrait = {
		character = scope:vassal_2
		animation = rage
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2012 }
			var:vassal_1 = {
				is_close_or_extended_family_of = scope:story.var:vassal_2
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2012
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
	}

	option = { #Try to avoid upset
		name = stewardship_duty_special.2012.a
		duel = {
			skill = diplomacy
			value = 10
			15 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -14
				}
				desc = stewardship_duty_special.2012.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty_special.2012.a.success
					left_icon = scope:vassal_1
					right_icon = scope:vassal_2

					custom_tooltip = statecraft_mediation_fair
				}
				scope:story = {
					change_variable = {
						name = perceived_fairness
						add = 1
					}
				}
			}
			10 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
					min = -9
				}
				desc = stewardship_duty_special.2012.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_duty_special.2012.a.failure
					left_icon = scope:vassal_1
					right_icon = scope:vassal_2

					custom_tooltip = statecraft_mediation_unfair
					custom_tooltip = statecraft_mediation_favor_vassal_1
				}
				scope:story = {
					change_variable = {
						name = perceived_fairness
						add = -1
					}
					change_variable = {
						name = favor_1
						add = 1
					}
				}
			}
		}
	}

	option = { #Try to please both
		name = stewardship_duty_special.2012.b
		duel = {
			skill = diplomacy
			value = 10
			5 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -4
				}
				desc = stewardship_duty_special.2012.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = stewardship_duty_special.2012.a.success
					left_icon = scope:vassal_1
					right_icon = scope:vassal_2

					custom_tooltip = statecraft_mediation_fair
				
					scope:vassal_1.dynasty = {
						add_dynasty_prestige = medium_dynasty_prestige_gain
					}
				}
				scope:story = {
					change_variable = {
						name = perceived_fairness
						add = 2
					}
				}
			}
			10 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
					min = -9
				}
				desc = stewardship_duty_special.2012.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = stewardship_duty_special.2012.a.failure
					left_icon = scope:vassal_1
					right_icon = scope:vassal_2

					custom_tooltip = statecraft_mediation_unfair
				}
				scope:story = {
					change_variable = {
						name = perceived_fairness
						add = -2
					}
				}
			}
		}
	}
	
	option = { #Family is easy!
		name = stewardship_duty_special.2012.c
		trigger = {
			has_trait = family_first
		}
		trait = family_first
		scope:vassal_1.dynasty = {
			add_dynasty_prestige = medium_dynasty_prestige_gain
		}
		custom_tooltip = stewardship_duty_special.2012.c.major_progress
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 3
			}
			change_variable = {
				name = favor_1
				add = 1
			}
			change_variable = {
				name = favor_2
				add = 1
			}
		}
	}
}


#Tax Rights
stewardship_duty_special.2013 = {
	type = character_event
	title = stewardship_duty_special.2013.t
	desc = stewardship_duty_special.2013.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}

	right_portrait = {
		character = scope:vassal_2
		animation = dismissal
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2013 }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2013
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
	}

	option = {
		name = stewardship_duty_special.2013.a
		custom_tooltip = statecraft_mediation_unfair
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = -2
			}
		}
		add_gold = medium_gold_value
	}

	option = { #Side with vassal_2 (traiditon)
		name = stewardship_duty_special.2013.b
		custom_tooltip = statecraft_mediation_fair
		custom_tooltip = statecraft_mediation_favor_vassal_2
		scope:vassal_2 = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
			change_variable = {
				name = favor_2
				add = 2
			}
		}
	}
	
	option = { #Side with vassal_1 (legalism)
		name = stewardship_duty_special.2013.c
		custom_tooltip = statecraft_mediation_fair
		custom_tooltip = statecraft_mediation_favor_vassal_1
		add_prestige = minor_prestige_gain
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
			change_variable = {
				name = favor_1
				add = 2
			}
		}
	}
}




#Betrothal Dispute
scripted_trigger stewardship_duty_special_2014_betrothal_candidate_trigger = {
	NOR = {
		is_close_or_extended_family_of = scope:story.var:vassal_1
		is_close_or_extended_family_of = scope:story.var:vassal_2
		court_owner = scope:story.var:vassal_1
		court_owner = scope:story.var:vassal_2
	}
	is_betrothed = no
	can_marry_trigger = yes
	is_landed = no
	save_temporary_scope_as = betrothal_candidate
}

scripted_trigger stewardship_duty_special_2014_betrothal_candidate_existence_trigger = {
	any_vassal_or_below = {
		NOR = {
			this = scope:story.var:vassal_1
			this = scope:story.var:vassal_2
		}
		OR = {
			any_child = {
				stewardship_duty_special_2014_betrothal_candidate_trigger = yes
			}
			any_sibling = {
				stewardship_duty_special_2014_betrothal_candidate_trigger = yes
			}
		}
	}
}

scripted_trigger stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = {
	is_betrothed = no
	can_marry_trigger = yes
	is_landed = no
	OR = {
		AND = {
			is_male = yes
			scope:betrothal_candidate = {
				is_female = yes
			}
		}	
		AND = {
			is_female = yes
			scope:betrothal_candidate = {
				is_male = yes
			}
		}
	}
}

scripted_trigger stewardship_duty_special_2014_vassal_trigger = {
	OR = {
		any_child = {
			stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = yes
		}
		any_sibling = {
			stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = yes
		}
	}
}

stewardship_duty_special.2014 = {
	type = character_event
	title = stewardship_duty_special.2014.t
	desc = stewardship_duty_special.2014.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}
	lower_left_portrait = scope:vassal_2
	right_portrait = {
		character = scope:betrothal_candidate_lord
		animation = idle
	}
	lower_right_portrait = scope:betrothal_candidate
	
	trigger = {
		root = {
			stewardship_duty_special_2014_betrothal_candidate_existence_trigger = yes
		}
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2014 }
			var:vassal_1 = {
				stewardship_duty_special_2014_vassal_trigger = yes
			}
			var:vassal_2 = {
				stewardship_duty_special_2014_vassal_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2014
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		random_vassal_or_below = {
			limit = {
				NOR = {
					this = scope:vassal_1
					this = scope:vassal_2
				}
				OR = {
					any_child = {
						stewardship_duty_special_2014_betrothal_candidate_trigger = yes
					}
					any_sibling = {
						stewardship_duty_special_2014_betrothal_candidate_trigger = yes
					}
				}
			}
			random_child = {
				limit = {
					stewardship_duty_special_2014_betrothal_candidate_trigger = yes
				}
				save_scope_as = betrothal_candidate
			}
			if = {
				limit = {
					NOT = { exists = scope:betrothal_candidate }
				}
				random_sibling = {
					limit = {
						stewardship_duty_special_2014_betrothal_candidate_trigger = yes
					}
				}
			}
			save_scope_as = betrothal_candidate_lord
		}
		scope:vassal_1 = {
			random_child = {
				limit = {
					stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = yes
				}
				save_scope_as = vassal_1_betrothal_candidate
			}
			if = {
				limit = {
					NOT = { exists = scope:vassal_1_betrothal_candidate }
				}
				random_sibling = {
					limit = {
						stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = yes
					}
					save_scope_as = vassal_1_betrothal_candidate
				}
			}
		}
		scope:vassal_2 = {
			random_child = {
				limit = {
					stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = yes
				}
				save_scope_as = vassal_2_betrothal_candidate
			}
			if = {
				limit = {
					NOT = { exists = scope:vassal_2_betrothal_candidate }
				}
				random_sibling = {
					limit = {
						stewardship_duty_special_2014_vassal_betrothal_candidate_trigger = yes
					}
					save_scope_as = vassal_2_betrothal_candidate
				}
			}
		}
	}

	option = {
		name = stewardship_duty_special.2014.a
		scope:vassal_1_betrothal_candidate = {
			create_betrothal = scope:betrothal_candidate
		}
		custom_tooltip = statecraft_mediation_favor_vassal_1
		scope:vassal_1 = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 25
			}
		}
		scope:story = {
			change_variable = {
				name = favor_1
				add = 1
			}
		}
	}

	option = {
		name = stewardship_duty_special.2014.b
		scope:vassal_2_betrothal_candidate = {
			create_betrothal = scope:betrothal_candidate
		}
		custom_tooltip = statecraft_mediation_favor_vassal_2
		scope:vassal_2 = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 25
			}
		}
		scope:story = {
			change_variable = {
				name = favor_2
				add = 1
			}
		}
	}
	
	option = {
		name = stewardship_duty_special.2014.c
		custom_tooltip = statecraft_mediation_fair
		stress_impact = {
			base = minor_stress_loss
		}
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
		}
	}
}





#Questioned Judgement
stewardship_duty_special.2015 = {
	type = character_event
	title = stewardship_duty_special.2015.t
	desc = stewardship_duty_special.2015.desc
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}

	right_portrait = {
		character = scope:vassal_2
		animation = rage
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2015 }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2015
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes	
	}

	option = { # Demand the Thief's Execution
		name = stewardship_duty_special.2015.a
		scope:story = {
			change_variable = {
				name = favor_1
				add = 1
			}
		}
		custom_tooltip = statecraft_mediation_favor_vassal_1
		add_prestige = minor_prestige_gain
		stress_impact = {
			just = medium_stress_impact_gain
		}
	}

	option = { # Vassal 2 has judgement right
		name = stewardship_duty_special.2015.b
		scope:story = {
			change_variable = {
				name = favor_2
				add = 1
			}
		}
		custom_tooltip = statecraft_mediation_favor_vassal_2
		add_prestige = minor_prestige_gain
	}
	
	option = { # Call for a trial by your Chancellor
		name = stewardship_duty_special.2015.c
		custom_tooltip = statecraft_mediation_fair
		if = {
			limit = {
				exists = cp:councillor_chancellor
			}
			cp:councillor_chancellor = {
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
				add_stress = minor_stress_gain
			}
		}
		add_prestige = minor_prestige_loss
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 2
			}
		}
		stress_impact = {
			arbitrary = medium_stress_impact_gain
		}
	}
}


#Asks to be Favored


#Learn one of their Secrets


#Who breeds the famous horses
stewardship_duty_special.2018 = {
	type = character_event
	title = stewardship_duty_special.2018.t
	desc = stewardship_duty_special.2018.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}
	right_portrait = {
		character = scope:vassal_2
		animation = anger
	}
	
	trigger = {
		scope:story = {
			NOT = {
				has_variable = had_event_stewardship_duty_special_2018
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2018
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		scope:vassal_1 = {
			capital_province = {
				barony = {
					save_scope_as = barony_1
				}
			}
		}
		scope:vassal_2 = {
			capital_province = {
				barony = {
					save_scope_as = barony_2
				}
			}
		}
		primary_title = {
			save_scope_as = new_name
		}
	}

	option = { #Vassal 1 obviously has the right of it
		name = stewardship_duty_special.2018.a
		if = {
			limit = { exists = dynasty }
			dynasty = { add_dynasty_prestige = medium_dynasty_prestige_gain }
		}
		custom_tooltip = statecraft_mediation_favor_vassal_1
		scope:vassal_1 = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
		scope:story = {
			change_variable = {
				name = favor_1
				add = 1
			}
		}
	}

	option = { #They are horses from MY TITLE now
		name = stewardship_duty_special.2018.b
		add_prestige = medium_prestige_gain
		custom_tooltip = statecraft_mediation_fair
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
		}
	}
	
	option = { #Who cares about those horses
		name = stewardship_duty_special.2018.c
		add_gold = medium_gold_value
		scope:vassal_1 = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -20
			}
		}
	}
}


#Scammed by the same Quarry
stewardship_duty_special.2019 = {
	type = character_event
	title = stewardship_duty_special.2019.t
	desc = stewardship_duty_special.2019.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = shame
	}
	right_portrait = {
		character = scope:vassal_2
		animation = shame
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2019 }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2019
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s1_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
	}

	option = { #Divide it evenly
		name = stewardship_duty_special.2019.a
		custom_tooltip = statecraft_mediation_fair
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
		}
	}

	option = { #You both deserve to be scammed
		name = stewardship_duty_special.2019.b
		add_prestige = medium_prestige_gain
		add_dread = medium_dread_gain
		custom_tooltip = statecraft_mediation_unfair
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = -1
			}
		}
		scope:vassal_1 = {
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -15
			}
		}
		scope:vassal_2 = {
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -15
			}
		}
	}

	option = {
		name = stewardship_duty_special.2019.c
		add_dread = medium_dread_gain
		stress_impact = {
			compassionate = medium_stress_impact_gain
			forgiving = major_stress_impact_gain
		}
	}
	
	option = { #Stewardship or Learning: This is a treachery against the crown
		name = stewardship_duty_special.2019.d
		trigger = {
			learning > medium_skill_rating
		}
		skill = learning
		add_prestige = medium_prestige_gain
		add_dread = minor_dread_gain
	}
	
	option = { #Stewardship or Learning: This is a treachery against the crown
		name = stewardship_duty_special.2019.d
		trigger = {
			stewardship > medium_skill_rating
			learning <= medium_skill_rating
		}
		skill = stewardship
		add_prestige = medium_prestige_gain
		add_dread = minor_dread_gain
	}
}





###############################
# Stage 2: Dispute is deteriorating
# 2021-2027
###############################

#1 Refused 2's Vassals from Attending a Feast
stewardship_duty_special.2021 = {
	type = character_event
	title = stewardship_duty_special.2021.t
	desc = stewardship_duty_special.2021.desc
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = dismissal
	}
	right_portrait = {
		character = scope:vassal_2
		animation = anger
	}	

	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2021 }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2021
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s2_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		hidden_effect = {
			random_list = {
				1 = {
					scope:vassal_1 = {
						save_scope_as = host
					}
					scope:vassal_2 = {
						save_scope_as = uninvited
					}
				}
				1 = {
					scope:vassal_2 = {
						save_scope_as = host
					}
					scope:vassal_1 = {
						save_scope_as = uninvited
					}
				}
			}
		}
	}

	option = { #They are uninvited's vassals, after all
		name = stewardship_duty_special.2021.a
		add_prestige = minor_prestige_gain
		if = {
			limit = {
				scope:vassal_1 = scope:uninvited
			}
			custom_tooltip = statecraft_mediation_favor_vassal_1
			scope:story = {
				change_variable = {
					name = favor_1
					add = 1
				}
			}
		}
		else = {
			custom_tooltip = statecraft_mediation_favor_vassal_2
			scope:story = {
				change_variable = {
					name = favor_2
					add = 1
				}
			}	
		}
		stress_impact = {
			reveler_1 = medium_stress_impact_gain
			reveler_2 = medium_stress_impact_gain
			reveler_3 = major_stress_impact_gain
		}
	}

	option = { #Don't deny feasts
		name = stewardship_duty_special.2021.b
		add_character_modifier = {
			modifier = statecraft_encouraged_feasting_modifier
			days = 1825
		}
		if = {
			limit = {
				scope:vassal_1 = scope:uninvited
			}
			custom_tooltip = statecraft_mediation_favor_vassal_1
			scope:story = {
				change_variable = {
					name = favor_1
					add = 1
				}
			}
		}
		else = {
			custom_tooltip = statecraft_mediation_favor_vassal_2
			scope:story = {
				change_variable = {
					name = favor_2
					add = 1
				}
			}	
		}
	}
	
	option = { #You have to attend feasts
		name = stewardship_duty_special.2021.c
		custom_tooltip = statecraft_mediation_fair
		add_prestige = minor_prestige_gain
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
		}
	}
}

#2 Insulted 1's Spouse
stewardship_duty_special.2022 = {
	type = character_event
	title = stewardship_duty_special.2022.t
	desc = stewardship_duty_special.2022.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}
	lower_left_portrait = scope:spouse
	right_portrait = {
		character = scope:vassal_2
		animation = dismissal
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2022 }
			OR = {
				var:vassal_1 = {
					is_married = yes
				}
				var:vassal_2 = {
					is_married = yes
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2022
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s2_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		hidden_effect = {
			random_list = {
				1 = {
					trigger = {
						scope:vassal_1 = { is_married = yes }
					}
					scope:vassal_1 = {
						save_scope_as = insultee
						random_spouse = {
							save_scope_as = spouse
						}
					}
					scope:vassal_2 = {
						save_scope_as = insulter
					}
				}
				1 = {
					trigger = {
						scope:vassal_2 = { is_married = yes }
					}
					scope:vassal_2 = {
						save_scope_as = insultee
						random_spouse = {
							save_scope_as = spouse
						}
					}
					scope:vassal_1 = {
						save_scope_as = insulter
					}
				}
			}
		}
	}

	option = { #This demands a public apology!
		name = stewardship_duty_special.2022.a
		reverse_add_opinion = {
			target = scope:insulter
			modifier = disappointed_opinion
			opinion = -15
		}
		if = {
			limit = {
				scope:insultee = scope:vassal_1
			}
			custom_tooltip = statecraft_mediation_favor_vassal_1
			scope:story = {
				change_variable = {
					name = favor_1
					add = 1
				}
			}
		}
		else = {
			custom_tooltip = statecraft_mediation_favor_vassal_2
			scope:story = {
				change_variable = {
					name = favor_2
					add = 1
				}
			}	
		}
	}

	option = { #This is no matter for me
		name = stewardship_duty_special.2022.b
		stress_impact = {
			base = medium_stress_loss
		}
	}
	
	option = { #You meant it as a compliment, right?
		name = stewardship_duty_special.2022.c
		trigger = {
			diplomacy >= medium_skill_rating
		}
		skill = diplomacy
		custom_tooltip = statecraft_mediation_fair
		reverse_add_opinion = {
			target = scope:insultee
			modifier = respect_opinion
			opinion = 10
		}
		reverse_add_opinion = {
			target = scope:insulter
			modifier = kindness_opinion
			opinion = 20
		}
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 1
			}
		}
	}
}



#You have a hook on one of them
stewardship_duty_special.2025 = {
	type = character_event
	title = stewardship_duty_special.2025.t
	desc = stewardship_duty_special.2025.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:hooked_vassal
		animation = worry
	}
	right_portrait = {
		character = scope:other_vassal
		animation = anger
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2025 }
		}
		OR = {
			has_usable_hook = scope:story.var:vassal_1
			has_usable_hook = scope:story.var:vassal_2
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2025
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s2_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		random_list = {
			1 = {
				trigger = {
					has_usable_hook = scope:vassal_1
				}
				scope:vassal_1 = {
					save_scope_as = hooked_vassal
				}
				scope:vassal_2 = {
					save_scope_as = other_vassal
				}
			}
			1 = {
				trigger = {
					has_usable_hook = scope:vassal_2
				}
				scope:vassal_2 = {
					save_scope_as = hooked_vassal
				}
				scope:vassal_1 = {
					save_scope_as = other_vassal
				}
			}
		}
	}

	option = { #Use hook to make things easier
		name = stewardship_duty_special.2025.a
		use_hook = scope:hooked_vassal
		
		custom_tooltip = statecraft_mediation_progress_fairness
		every_vassal = {
			add_opinion = {
				target = root
				modifier = reputation_opinion
				opinion = 15
			}
		}
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 3
			}
		}
		stress_impact = {
			honest = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}
	}

	option = { #I'll sit on this
		name = stewardship_duty_special.2025.b
		add_prestige = minor_prestige_gain
		stress_impact = {
			deceitful = medium_stress_impact_gain
		}
	}
}


#One of them kills the other
stewardship_duty_special.2026 = {
	type = character_event
	title = stewardship_duty_special.2026.t
	desc = stewardship_duty_special.2026.desc
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:killer
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:victim
		animation = pain
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2026 }
			var:perceived_fairness = {
				compare_value <= 0
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			scope:story.var:perceived_fairness = {
				compare_value < 0
			}
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2026
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s2_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		random_list = {
			50 = {
				modifier = {
					add = 30
					scope:story = {
						var:favor_1 = {
							compare_value < scope:story.var:favor_2
						}
					}
				}
				modifier = {
					add = 50
					scope:vassal_1 = {
						OR = {
							has_trait = vengeful
							has_trait = wrathful
						}
					}
				}
				scope:vassal_1 = {
					save_scope_as = killer
					set_signature_weapon_effect = yes
				}
				scope:vassal_2 = {
					save_scope_as = victim
				}
			}
			50 = {
				modifier = {
					add = 30
					scope:story = {
						var:favor_2 = {
							compare_value < scope:story.var:favor_1
						}
					}
				}
				modifier = {
					add = 50
					scope:vassal_2 = {
						OR = {
							has_trait = vengeful
							has_trait = wrathful
						}
					}
				}
				scope:vassal_2 = {
					save_scope_as = killer
					set_signature_weapon_effect = yes
				}
				scope:vassal_1 = {
					save_scope_as = victim
				}
			}
		}
		scope:victim = {
			death = {
				death_reason = death_murder
				killer = scope:killer
			}
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}

	option = { #Kill the killer
		name = stewardship_duty_special.2026.a
		scope:killer = {
			death = {
				death_reason = death_execution
				killer = root
			}
		}
		add_prestige = minor_prestige_gain
		stress_impact = {
			just = minor_stress_impact_gain
		}
	}

	option = { #Into the dungeon!
		name = stewardship_duty_special.2026.b
		imprison = {
			target = scope:killer
			type = dungeon
		}
		add_character_modifier = {
			modifier = statecraft_just_judgements_modifier
			days = 1825
		}
	}
	
	option = { #Oh well
		name = stewardship_duty_special.2026.c
		reverse_add_opinion = {
			target = scope:killer
			modifier = kindness_opinion
			opinion = 50
		}
		if = {
			limit = {
				can_add_hook = {
					target = scope:killer
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:killer
				type = favor_hook
			}
		}
		stress_impact = {
			just = major_stress_impact_gain
		}
	}
}


#Long-term family feud
stewardship_duty_special.2027 = {
	type = character_event
	title = stewardship_duty_special.2027.t
	desc = stewardship_duty_special.2027.desc
	
	theme = stewardship_duty_focus
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}
	right_portrait = {
		character = scope:vassal_2
		animation = anger
	}
	
	trigger = {
		scope:story = {
			NOT = { has_variable = had_event_stewardship_duty_special_2027 }
			exists = scope:vassal_1.house
			exists = scope:vassal_2.house
			NOT = { scope:vassal_1.house = scope:vassal_2.house }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_event_stewardship_duty_special_2027
				value = yes
			}
		}
		stewardship_duty_special_2000_sc_mediation_increase_s2_event_count_effect = yes
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		if = {
			limit = {
				scope:vassal_1.dynasty.dynasty_prestige_level > scope:vassal_2.dynasty.dynasty_prestige_level
			}
			scope:vassal_1 = { save_scope_as = higher_prestige }
			scope:vassal_2 = { save_scope_as = lower_prestige }
		}
		else_if = {
			limit = {
				scope:vassal_2.dynasty.dynasty_prestige_level > scope:vassal_1.dynasty.dynasty_prestige_level
			}
			scope:vassal_2 = { save_scope_as = higher_prestige }
			scope:vassal_1 = { save_scope_as = lower_prestige }
		}
		else = {
			random_list = {
				50 = {
					scope:vassal_1 = {
						save_scope_as = higher_prestige
					}
					scope:vassal_2 = {
						save_scope_as = lower_prestige
					}
				}
				50 = {
					scope:vassal_2 = {
						save_scope_as = higher_prestige
					}
					scope:vassal_1 = {
						save_scope_as = lower_prestige
					}	
				}
			}
		}
	}

	option = {
		name = stewardship_duty_special.2027.a
		add_prestige = medium_prestige_gain
		custom_tooltip = statecraft_mediation_favor_higher_prestige
		if = {
			limit = {
				scope:higher_prestige = {
					this = scope:vassal_1
				}
			}
			scope:story = {
				change_variable = {
					name = favor_1
					add = 1
				}
			}
		}
		else = {
			scope:story = {
				change_variable = {
					name = favor_2
					add = 1
				}
			}
		}
	}

	option = {
		name = stewardship_duty_special.2027.b
		add_character_modifier = {
			modifier = statecraft_emphasises_unity_modifier
			days = 1825
		}
		custom_tooltip = statecraft_mediation_favor_lower_prestige
		if = {
			limit = {
				scope:lower_prestige = {
					this = scope:vassal_1
				}
			}
			scope:story = {
				change_variable = {
					name = favor_1
					add = 1
				}
			}
		}
		else = {
			scope:story = {
				change_variable = {
					name = favor_2
					add = 1
				}
			}
		}
	}
	
	option = {
		name = stewardship_duty_special.2027.c
		custom_tooltip = statecraft_mediation_fair
		add_prestige = medium_prestige_loss
		scope:story = {
			change_variable = {
				name = perceived_fairness
				add = 2
			}
		}
	}
}



##############################
# Background Events
# 2051-2053
##############################

#One of them gains a random Friend at court
scripted_trigger stewardship_duty_special_2051_potential_friend_trigger = {
	NOR = {
		has_relation_friend = scope:story.var:vassal_1
		has_relation_friend = scope:story.var:vassal_2
	}
	OR = {
		NOT = { exists = scope:quarreler }
		AND = {
			opinion = {
				target = scope:story.var:vassal_1
				value > 0
			}
			reverse_opinion = {
				target = scope:story.var:vassal_1
				value > 0
			}
		}
		AND = {
			NOT = { exists = scope:quarreler }
			opinion = {
				target = scope:story.var:vassal_2
				value > 0
			}
			reverse_opinion = {
				target = scope:story.var:vassal_2
				value > 0
			}
		}
		AND = {
			exists = scope:quarreler
			opinion = {
				target = scope:quarreler
				value > 0
			}
			reverse_opinion = {
				target = scope:quarreler
				value > 0
			}
		}
	}
}

stewardship_duty_special.2051 = {
	hidden = yes

	trigger = {
		scope:story = {
			OR = {
				var:vassal_1 = {
					num_of_relation_friend < 2
				}
				var:vassal_2 = {
					num_of_relation_friend < 2
				}
			}
		}
		OR = {
			any_courtier = {
				stewardship_duty_special_2051_potential_friend_trigger = yes
			}
			#any_councillor = {
			#	stewardship_duty_special_2051_potential_friend_trigger = yes
			#}
		}
	}

	immediate = {
		stewardship_duty_special_2000_sc_mediation_get_random_quarreler_effect = yes

		every_courtier = {
			limit = {
				stewardship_duty_special_2051_potential_friend_trigger = yes
			}
			add_to_list = potential_friends
		}
		#every_councillor = {
		#	limit = {
		#		stewardship_duty_special_2051_potential_friend_trigger = yes
		#	}
		#	add_to_list = potential_friends
		#}

		random_in_list = {
			list = potential_friends

			set_relation_friend = scope:quarreler
		}
	}
}

#One of them gains a random Lover at Court
scripted_trigger stewardship_duty_special_2052_potential_lover_trigger = {
	AND = {
		can_set_relation_lover_trigger = { CHARACTER = scope:story.var:vassal_1 }
		can_set_relation_lover_trigger = { CHARACTER = scope:story.var:vassal_2 }
	}
	OR = {
		NOT = { exists = scope:quarreler }
		AND = {
			opinion = {
				target = scope:story.var:vassal_1
				value > 0
			}
			reverse_opinion = {
				target = scope:story.var:vassal_1
				value > 0
			}
		}
		AND = {
			NOT = { exists = scope:quarreler }
			opinion = {
				target = scope:story.var:vassal_2
				value > 0
			}
			reverse_opinion = {
				target = scope:story.var:vassal_2
				value > 0
			}
		}
		AND = {
			exists = scope:quarreler
			opinion = {
				target = scope:quarreler
				value > 0
			}
			reverse_opinion = {
				target = scope:quarreler
				value > 0
			}
		}
	}
}

stewardship_duty_special.2052 = {
	hidden = yes

	trigger = {
		scope:story = {
			OR = {
				var:vassal_1 = {
					num_of_relation_lover < 2
				}
				var:vassal_2 = {
					num_of_relation_lover < 2
				}
			}
		}
		OR = {
			any_courtier = {
				stewardship_duty_special_2052_potential_lover_trigger = yes
			}
			#any_councillor = {
			#	stewardship_duty_special_2052_potential_lover_trigger = yes
			#}
		}
	}

	immediate = {
		stewardship_duty_special_2000_sc_mediation_get_random_quarreler_effect = yes

		every_courtier = {
			limit = {
				stewardship_duty_special_2052_potential_lover_trigger = yes
			}
			add_to_list = potential_lovers
		}
		#every_councillor = {
		#	limit = {
		#		stewardship_duty_special_2052_potential_lover_trigger = yes
		#	}
		#	add_to_list = potential_lovers
		#}

		random_in_list = {
			list = potential_lovers

			set_relation_lover = scope:quarreler
		}
	}
}



#One of them gains a random Rival at Court
scripted_trigger stewardship_duty_special_2053_potential_rival_trigger = {
	NOR = {
		has_relation_rival = scope:story.var:vassal_1
		has_relation_rival = scope:story.var:vassal_2
	}
	OR = {
		NOT = { exists = scope:quarreler }
		AND = {
			opinion = {
				target = scope:story.var:vassal_1
				value < 0
			}
			reverse_opinion = {
				target = scope:story.var:vassal_1
				value < 0
			}
		}
		AND = {
			NOT = { exists = scope:quarreler }
			opinion = {
				target = scope:story.var:vassal_2
				value < 0
			}
			reverse_opinion = {
				target = scope:story.var:vassal_2
				value < 0
			}
		}
		AND = {
			exists = scope:quarreler
			opinion = {
				target = scope:quarreler
				value < 0
			}
			reverse_opinion = {
				target = scope:quarreler
				value < 0
			}
		}
	}
}

stewardship_duty_special.2053 = {
	hidden = yes

	trigger = {
		scope:story = {
			OR = {
				var:vassal_1 = {
					num_of_relation_rival < 2
				}
				var:vassal_2 = {
					num_of_relation_rival < 2
				}
			}
		}
		OR = {
			any_courtier = {
				stewardship_duty_special_2053_potential_rival_trigger = yes
			}
			#any_councillor = {
			#	stewardship_duty_special_2053_potential_rival_trigger = yes
			#}
		}
	}

	immediate = {
		stewardship_duty_special_2000_sc_mediation_get_random_quarreler_effect = yes

		break_if = {
			NOR = {
				any_courtier = {
					stewardship_duty_special_2053_potential_rival_trigger = yes
				}
				#any_councillor = {
				#	stewardship_duty_special_2053_potential_rival_trigger = yes
				#}
			}
		}

		every_courtier = {
			limit = {
				stewardship_duty_special_2053_potential_rival_trigger = yes
			}
			add_to_list = potential_rivals
		}
		#every_councillor = {
		#	limit = {
		#		stewardship_duty_special_2053_potential_rival_trigger = yes
		#	}
		#	add_to_list = potential_rivals
		#}

		random_in_list = {
			list = potential_rivals

			set_relation_rival = scope:quarreler
		}
	}
}


###############################
# Outcomes
# 2070 - 2075
###############################

#Outcome Calculation
stewardship_duty_special.2070 = {
	hidden = yes

	immediate = {
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		random_list = {
			0 = { #Amazing success!
				compare_modifier = {
					value = scope:story.var:perceived_fairness
					multiplier = 15
				}
				trigger_event = stewardship_duty_special.2071
			}
			50 = { #Success!
				compare_modifier = {
					value = scope:story.var:perceived_fairness
					multiplier = 10
				}
				trigger_event = stewardship_duty_special.2072
			}
			50 = { #Failure, still rank up
				trigger_event = stewardship_duty_special.2073
			}
			10 = { #Failure, accused of favoritism
				trigger = {
					scope:story = {
						has_variable = favor_1
						has_variable = favor_2
						var:perceived_fairness < 2
					}
				}
				compare_modifier = {
					value = scope:story.var:favor_1
					trigger = {
						scope:story.var:favor_2 = {
							compare_value < scope:story.var:favor_1
						}
					}
					multiplier = 5
				}
				compare_modifier = {
					value = scope:story.var:favor_2
					trigger = {
						scope:story.var:favor_1 = {
							compare_value < scope:story.var:favor_2
						}
					}
					multiplier = 5
				}
				trigger_event = stewardship_duty_special.2074
			}
		}
	}
}



#Great Success
# They become friends
stewardship_duty_special.2071 = {
	type = character_event
	title = stewardship_duty_special.2071.t
	desc = stewardship_duty_special.2071.desc
	
	left_portrait = {
		character = scope:vassal_1
		animation = happiness
	}

	right_portrait = {
		character = scope:vassal_2
		animation = happiness
	}

	theme = stewardship_duty_focus
	
	immediate = {
		hidden_effect = {
			scope:vassal_1 = {
				if = {
					limit = {
						has_relation_rival = scope:vassal_2
					}
					remove_relation_rival = scope:vassal_2
				}
			}
		}
	}

	option = {
		name = stewardship_duty_special.2071.a
		add_stewardship_lifestyle_perk_points = 1
		scope:vassal_1 = {
			add_opinion = {
				target = scope:vassal_2
				modifier = respect_opinion
				opinion = 20
			}
			reverse_add_opinion = {
				target = scope:vassal_2
				modifier = respect_opinion
				opinion = 20
			}
			set_relation_friend = scope:vassal_2
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}


#Success
# You did well. They lose Rival status if relevant
stewardship_duty_special.2072 = {
	type = character_event
	title = stewardship_duty_special.2071.t
	desc = stewardship_duty_special.2072.desc
	
	left_portrait = {
		character = scope:vassal_1
		animation = idle
	}
	right_portrait = {
		character = scope:vassal_2
		animation = idle
	}
	theme = stewardship_duty_focus
	
	option = {
		name = stewardship_duty_special.2072.a
		add_stewardship_lifestyle_perk_points = 1
		if = {
			limit = {
				scope:vassal_1 = {
					has_relation_rival = scope:vassal_2
				}
			}
			scope:vassal_1 = {
				remove_relation_rival = scope:vassal_2
			}
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}



#Failure - Accused of favoritism
stewardship_duty_special.2073 = {
	type = character_event
	title = stewardship_duty_special.2073.t
	desc = stewardship_duty_special.2073.desc
	
	left_portrait = {
		character = scope:favorite
		animation = happiness
	}
	right_portrait = {
		character = scope:accuser
		animation = rage
	}
	theme = stewardship_duty_focus
	
	immediate = {
		if = {
			limit = {
				scope:story.var:favor_2 = {
					compare_value < scope:story.var:favor_1
				}
			}
			scope:vassal_2 = {
				save_scope_as = accuser
			}
			scope:vassal_1 = {
				save_scope_as = favorite
			}
		}
		else = {
			scope:vassal_1 = {
				save_scope_as = accuser
			}
			scope:vassal_2 = {
				save_scope_as = favorite
			}
		}
	}

	option = {
		name = stewardship_duty_special.2073.a
		scope:accuser = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -40
			}
		}
		scope:favorite = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}


#Failure
# They become Rivals
stewardship_duty_special.2074 = {
	type = character_event
	title = stewardship_duty_special.2074.t
	desc = stewardship_duty_special.2074.desc
	
	left_portrait = {
		character = scope:vassal_1
		animation = anger
	}
	right_portrait = {
		character = scope:vassal_2
		animation = rage
	}
	theme = stewardship_duty_focus
	
	immediate = {
	
	}

	option = {
		name = stewardship_duty_special.2074.a
		scope:vassal_1 = {
			set_relation_rival = scope:vassal_2
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}


#########################
# One of the vassals have died!
#########################

stewardship_duty_special.2081 = {
	type = character_event
	title = stewardship_duty_special.2081.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:vassal_1 = {
						is_alive = no
					}
					scope:vassal_2 = {
						is_alive = no
					}
				}
				desc = stewardship_duty_special.2081.both_dead
			}
			triggered_desc = {
				trigger = {
					scope:vassal_1 = {
						is_alive = no
					}
				}
				desc = stewardship_duty_special.2081.vassal_1
			}
			desc = stewardship_duty_special.2081.vassal_2
		}
	}
	
	theme = stewardship_duty_focus
	left_portrait = scope:vassal_1
	right_portrait = scope:vassal_2
	
	immediate = {
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}

	option = {
		name = stewardship_duty_special.2081.a
		custom_tooltip = stewardship_duty_special.2081.tt
	}
}

#####################
# One of them is in prison
#####################
stewardship_duty_special.2082 = {
	type = character_event
	title = stewardship_duty_special.2082.t
	desc = stewardship_duty_special.2082.desc
	
	theme = stewardship_duty_focus
	left_portrait = scope:vassal_1
	right_portrait = scope:vassal_2
	
	immediate = {
		stewardship_duty_special_2000_sc_mediation_saved_scopes_effect = yes
		random_list = {
			1 = {
				trigger = {
					scope:vassal_1 = {
						is_imprisoned = yes
					}
				}
				scope:vassal_1 = {
					save_scope_as = prisoner
				}
				scope:vassal_2 = {
					save_scope_as = other
				}
			}
			1 = {
				trigger = {
					scope:vassal_2 = {
						is_imprisoned = yes
					}
				}
				scope:vassal_2 = {
					save_scope_as = prisoner
				}
				scope:vassal_1 = {
					save_scope_as = other
				}
			}
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}

	option = {
		name = stewardship_duty_special.2082.a
		custom_tooltip = stewardship_duty_special.2081.tt
	}
}