﻿#EK NOTE: Disabling building_gfx lines
@bp2_yearly_0601_minimum_cooldown_years = 20
@bp2_yearly_0621_standard_gold_cost = major_gold_value

namespace = bp2_yearly

##################################################
# #Standard Yearlies
# 0601 - 0610	Ruling Rightly - Regent tries to teach you about state.
# 0611 - 0620	PrimaryTitle's Second Capital - Far away regent never seems to visit.
# 0621 - 0630	AuntUncle RegentFirstName - Nearby regents visits often.
# 0631 - 0640	Whispered Words - Courtier-regent turns you against a rival for the regency.
# 0641 - 0650	Quid Pro Quo - Regent offers special present in exchange for your agreement on some documents.
# 0651 - 0660	Whenever You Need HerHim - Regent makes time for your interests, be they play or poetry.
# 0661 - 0670	A Tool for the Wielding - Regent quarrels with your family about access to you.
# 0671 - 0680	Signed & Sealed - Regent tries to trick you out of land that they want.
#
# #Flavour Yearlies
# 0511 - 0520	The GirlBoy-Monarch - Fight with regent about them not giving you any responsibility.
# 0521 - 0530	Behind Closed Doors - Regent tries to shut you out of power.
##################################################










##################################################
# MISC EFFECTS & TRIGGERS

# Saves us having to double-side events - don't affect the player with this stuff unless there's someone who'll relay the effects.
scripted_trigger filter_players_for_agency_trigger = {
	OR = {
		diarch = { is_ai = yes }
		AND = {
			is_ai = no
			diarch = { is_ai = no }
		}
	}
}

# Does this character not get on with the diarch?
scripted_trigger has_antipathy_with_diarch_trigger = {
	OR = {
		has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = root.diarch }
		reverse_opinion = {
			target = root.diarch
			value <= medium_negative_opinion
		}
	}
	NOT = {
		has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root.diarch }
	}
}












##################################################
# STANDARD YEARLIES

##################################################
# Ruling Rightly
# by Ewan Cowhig Croft
# 0601 - 0610
##################################################

# Is this a disloyal diarch who likes root?
scripted_trigger bp2_yearly_0601_disloyal_trigger = {
	diarch_loyalty <= diarch_loyalty_visibly_disloyal_threshold
	# Lazy self-interested diarchs will just never bother.
	NOT = { has_trait = lazy }
	# But also, they have to like you a decent amount.
	opinion = {
		target = root
		value >= high_positive_opinion
	}
}
# Is this a self-interested diarch who likes root or just works hard?
scripted_trigger bp2_yearly_0601_neutral_trigger = {
	diarch_has_situational_loyalty_trigger = yes
	# Situational diarchs will educate you if they have a firm work ethic or they just like you enough.
	OR = {
		has_trait = diligent
		opinion = {
			target = root
			value >= medium_positive_opinion
		}
	}
}

# Default stress gain in options when there's no variant education at work.
scripted_effect bp2_yearly_0601_fallback_stress_gain_effect = {
	stress_impact = {
		base = major_stress_impact_gain
		diligent = miniscule_stress_impact_loss
		lazy = minor_stress_impact_gain
	}
}
# Stress gain in options when there *is* a variant education available.
scripted_effect bp2_yearly_0601_lesson_variant_stress_gain_effect = {
	stress_impact = {
		base = major_stress_impact_gain
		diligent = miniscule_stress_impact_loss
		$LOSS_TRAIT$ = minor_stress_impact_loss
		lazy = minor_stress_impact_gain
		$GAIN_TRAIT$ = medium_stress_impact_gain
	}
}
# Unified stress gains for the options, so you gain the same stress whichever benefit you pick.
scripted_effect bp2_yearly_0601_diplomacy_stress_gain_effect = {
	# Do we have a lesson variant to account for?
	if = {
		limit = { exists = scope:lesson_variant }
		if = {
			limit = { scope:lesson_variant = flag:arrogant }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = arrogant
				GAIN_TRAIT = humble
			}
		}
		else_if = {
			limit = { scope:lesson_variant = flag:humble }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = humble
				GAIN_TRAIT = arrogant
			}
		}
	}
	# Otherwise, it's a regular stress gain block.
	else = { bp2_yearly_0601_fallback_stress_gain_effect = yes }
}
scripted_effect bp2_yearly_0601_martial_stress_gain_effect = {
	# Do we have a lesson variant to account for?
	if = {
		limit = { exists = scope:lesson_variant }
		if = {
			limit = { scope:lesson_variant = flag:wrathful }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = wrathful
				GAIN_TRAIT = calm
			}
		}
		else_if = {
			limit = { scope:lesson_variant = flag:calm }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = calm
				GAIN_TRAIT = wrathful
			}
		}
	}
	# Otherwise, it's a regular stress gain block.
	else = { bp2_yearly_0601_fallback_stress_gain_effect = yes }
}
scripted_effect bp2_yearly_0601_stewardship_stress_gain_effect = {
	# Do we have a lesson variant to account for?
	if = {
		limit = { exists = scope:lesson_variant }
		if = {
			limit = { scope:lesson_variant = flag:greedy }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = greedy
				GAIN_TRAIT = generous
			}
		}
		else_if = {
			limit = { scope:lesson_variant = flag:generous }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = generous
				GAIN_TRAIT = greedy
			}
		}
	}
	# Otherwise, it's a regular stress gain block.
	else = { bp2_yearly_0601_fallback_stress_gain_effect = yes }
}
scripted_effect bp2_yearly_0601_intrigue_stress_gain_effect = {
	# Do we have a lesson variant to account for?
	if = {
		limit = { exists = scope:lesson_variant }
		if = {
			limit = { scope:lesson_variant = flag:compassionate }
			stress_impact = {
				base = medium_stress_impact_gain
				diligent = miniscule_stress_impact_loss
				compassionate = minor_stress_impact_loss
				lazy = minor_stress_impact_gain
				callous = medium_stress_impact_gain
				sadistic = medium_stress_impact_gain
			}
		}
		else_if = {
			limit = { scope:lesson_variant = flag:callous }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = callous
				GAIN_TRAIT = compassionate
			}
		}
		else_if = {
			limit = { scope:lesson_variant = flag:sadistic }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = sadistic
				GAIN_TRAIT = compassionate
			}
		}
	}
	# Otherwise, it's a regular stress gain block.
	else = { bp2_yearly_0601_fallback_stress_gain_effect = yes }
}
scripted_effect bp2_yearly_0601_learning_stress_gain_effect = {
	# Do we have a lesson variant to account for?
	if = {
		limit = { exists = scope:lesson_variant }
		if = {
			limit = { scope:lesson_variant = flag:shy }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = shy
				GAIN_TRAIT = gregarious
			}
		}
		else_if = {
			limit = { scope:lesson_variant = flag:gregarious }
			bp2_yearly_0601_lesson_variant_stress_gain_effect = {
				LOSS_TRAIT = gregarious
				GAIN_TRAIT = shy
			}
		}
	}
	# Otherwise, it's a regular stress gain block.
	else = { bp2_yearly_0601_fallback_stress_gain_effect = yes }
}

# Apply extra skill points to root depending on their regent's education trait rank.
scripted_effect bp2_yearly_0601_apply_extra_skill_points_effect = {
	scope:regent = {
		switch = {
			trigger = has_trait
			education_$SKILL$_1 = { # Rank 1 education.
				root = { add_$SKILL$_skill = 1 }
			}
			education_$SKILL$_2 = { # Rank 2 education.
				root = { add_$SKILL$_skill = 2 }
			}
			education_$SKILL$_3 = { # Rank 3 education.
				root = { add_$SKILL$_skill = 3 }
			}
			education_$SKILL$_4 = { # Rank 4 education.
				root = { add_$SKILL$_skill = 4 }
			}
			education_$SKILL$_5 = { # Rank 5 education.
				root = { add_$SKILL$_skill = 5 }
			}
		}
	}
}

# Give root variable perk points in a lifestyle depending on their regent's education trait rank.
scripted_effect bp2_yearly_0601_apply_extra_lifestyle_perk_points_effect = {
	scope:regent = {
		switch = {
			trigger = has_trait
			education_$SKILL$_1 = {
				# Terrible character, gain half a perk's worth of XP.
				root = { add_$SKILL$_lifestyle_xp = massive_lifestyle_xp }
			}
			education_$SKILL$_2 = {
				# One perk.
				root = { add_$SKILL$_lifestyle_perk_points = 1 }
			}
			education_$SKILL$_3 = {
				# Decent character, one perk _plus_ half a perk's worth of XP.
				root = {
					add_$SKILL$_lifestyle_perk_points = 1
					add_$SKILL$_lifestyle_xp = massive_lifestyle_xp
				}
			}
			education_$SKILL$_4 = {
				# Excellent characters, two perks.
				root = { add_$SKILL$_lifestyle_perk_points = 2 }
			}
			education_$SKILL$_5 = {
				# Wicked sick characters, two perks _plus_ half a perk's worth of XP.
				root = {
					add_$SKILL$_lifestyle_perk_points = 2
					add_$SKILL$_lifestyle_xp = massive_lifestyle_xp
				}
			}
		}
	}
}

#	 Regent tries to teach you about state.
bp2_yearly.0601 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.0601.t
	desc = {
		desc = bp2_yearly.0601.desc.intro
		# Why is your diarch trying to tutor you?
		first_valid = {
			# Is this a disloyal diarch who likes root?
			triggered_desc = {
				trigger = {
					diarch = { bp2_yearly_0601_disloyal_trigger = yes }
				}
				desc = bp2_yearly.0601.desc.rationale.disloyal.likes_you
			}
			# Is this a self-interested diarch who likes root or just works hard?
			triggered_desc = {
				trigger = {
					diarch = { bp2_yearly_0601_neutral_trigger = yes }
				}
				desc = bp2_yearly.0601.desc.rationale.neutral.likes_you
			}
			# Is this a loyal diarch due to root's predecessor?
			triggered_desc = {
				trigger = {
					diarch = { diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold }
					has_hook_of_type = {
						target = scope:regent
						type = predecessor_loyalty_hook
					}
				}
				desc = bp2_yearly.0601.desc.rationale.loyal.predecessor_hook
			}
			# Is this a loyal diarch due to a loyalty hook from root?
			triggered_desc = {
				trigger = {
					diarch = { diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold }
					has_hook_of_type = {
						target = scope:regent
						type = loyalty_hook
					}
				}
				desc = bp2_yearly.0601.desc.rationale.loyal.loyalty_hook
			}
			# Is this a loyal diarch due to their own personal code of honour?
			triggered_desc = {
				trigger = {
					diarch = {
						diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold
						ai_honor >= max_positive_honor
					}
				}
				desc = bp2_yearly.0601.desc.rationale.loyal.honourable
			}
			# Is this a loyal diarch for any other reason?
			triggered_desc = {
				trigger = {
					diarch = { diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold }
				}
				desc = bp2_yearly.0601.desc.rationale.loyal.fallback
			}
			# Fallback in case something goofs.
			desc = bp2_yearly.0601.desc.rationale.fallback
		}
		# What are they trying to teach you?
		## Preamble.
		desc = bp2_yearly.0601.desc.skill.boilerplate
		## Diplomacy.
		triggered_desc = {
			trigger = { scope:lesson = flag:diplomacy }
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:arrogant }
						desc = bp2_yearly.0601.desc.diplomacy.arrogant
					}
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:humble }
						desc = bp2_yearly.0601.desc.diplomacy.humble
					}
					desc = bp2_yearly.0601.desc.diplomacy.fallback
				}
			}
		}
		## Martial.
		triggered_desc = {
			trigger = { scope:lesson = flag:martial }
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:wrathful }
						desc = bp2_yearly.0601.desc.martial.wrathful
					}
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:calm }
						desc = bp2_yearly.0601.desc.martial.calm
					}
					desc = bp2_yearly.0601.desc.martial.fallback
				}
			}
		}
		## Stewardship.
		triggered_desc = {
			trigger = { scope:lesson = flag:stewardship }
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:greedy }
						desc = bp2_yearly.0601.desc.stewardship.greedy
					}
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:generous }
						desc = bp2_yearly.0601.desc.stewardship.generous
					}
					desc = bp2_yearly.0601.desc.stewardship.fallback
				}
			}
		}
		## Intrigue.
		triggered_desc = {
			trigger = { scope:lesson = flag:intrigue }
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:compassionate }
						desc = bp2_yearly.0601.desc.intrigue.compassionate
					}
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:callous }
						desc = bp2_yearly.0601.desc.intrigue.callous
					}
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:sadistic }
						desc = bp2_yearly.0601.desc.intrigue.sadistic
					}
					desc = bp2_yearly.0601.desc.intrigue.fallback
				}
			}
		}
		## Learning.
		triggered_desc = {
			trigger = { scope:lesson = flag:learning }
			desc = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:shy }
						desc = bp2_yearly.0601.desc.learning.shy
					}
					triggered_desc = {
						trigger = { scope:lesson_variant ?= flag:gregarious }
						desc = bp2_yearly.0601.desc.learning.gregarious
					}
					desc = bp2_yearly.0601.desc.learning.fallback
				}
			}
		}
		# What is your reaction?
		first_valid = {
			triggered_desc = {
				trigger = { scope:child_reaction = flag:disgust }
				desc = bp2_yearly.0601.desc.child_reaction.disgust
			}
			triggered_desc = {
				trigger = { scope:child_reaction = flag:admiration }
				desc = bp2_yearly.0601.desc.child_reaction.admiration
			}
			triggered_desc = {
				trigger = { scope:child_reaction = flag:boredom }
				desc = bp2_yearly.0601.desc.child_reaction.boredom
			}
		}
	}
	theme = education
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:child_reaction = flag:disgust }
			animation = disgust
		}
		triggered_animation = {
			trigger = { scope:child_reaction = flag:admiration }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:child_reaction = flag:boredom }
			animation = boredom
		}
	}
	right_portrait = {
		character = scope:regent
		animation = chancellor
	}
	override_background = {
		trigger = {
			OR = {
				#location.culture ?= { has_building_gfx = indian_building_gfx } #EK DISABLED
				location.culture ?= { has_graphical_mena_culture_group_trigger = yes }
				location.culture ?= { has_graphical_african_culture_group_trigger = yes }
				location.culture ?= { has_graphical_steppe_culture_group_trigger = yes }
				#location.culture ?= { has_building_gfx = berber_group_building_gfx } #EK DISABLED
				#location.culture ?= { has_building_gfx = norse_building_gfx } #EK DISABLED
			}
		}
		reference = study
	}
	override_background = {
		reference = council_chamber
	}

	cooldown = { years = @bp2_yearly_0601_minimum_cooldown_years }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		# Check root is old enough to be worth teaching.
		child_old_enough_for_responsibility_trigger = yes
		# Regent isn't a player _unless_ they're both players.
		filter_players_for_agency_trigger = yes
		# Regent checks.
		diarch = {
			# Must be available to take the time.
			is_available_adult = yes
			# Regent must actually _want_ to teach you.
			OR = {
				# Disloyal regents will if they like you enough.
				bp2_yearly_0601_disloyal_trigger = yes
				# Self-interested regents will if they like you or are diligent.
				bp2_yearly_0601_neutral_trigger = yes
				# Loyal regents will always tutor you.
				diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold
			}
		}
	}

	weight_multiplier = {
		base = 1
		
		# Lazy diarchs can't be arsed.
		modifier = {
			add = -0.75
			diarch ?= { has_trait = lazy }
		}
	}

	immediate = {
		# Grab some scopes for loc'n'ease.
		## Our regent.
		diarch = { save_scope_as = regent }
		# Right, what lesson are they trying to teach?
		diarch = {
			# Diplomacy.
			if = {
				limit = { has_trait = education_diplomacy }
				save_scope_value_as = {
					name = lesson
					value = flag:diplomacy
				}
				# Do we need to mark out any special differences due to teaching style?
				## Arrogant.
				if = {
					limit = { has_trait = arrogant }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:arrogant
					}
				}
				## Humble.
				if = {
					limit = { has_trait = humble }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:humble
					}
				}
			}
			# Martial.
			else_if = {
				limit = { has_trait = education_martial }
				save_scope_value_as = {
					name = lesson
					value = flag:martial
				}
				# Do we need to mark out any special differences due to teaching style?
				## Wrathful.
				if = {
					limit = { has_trait = wrathful }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:wrathful
					}
				}
				## Calm.
				if = {
					limit = { has_trait = calm }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:calm
					}
				}
			}
			# Stewardship.
			else_if = {
				limit = { has_trait = education_stewardship }
				save_scope_value_as = {
					name = lesson
					value = flag:stewardship
				}
				# Do we need to mark out any special differences due to teaching style?
				## Greedy.
				if = {
					limit = { has_trait = greedy }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:greedy
					}
				}
				## Generous.
				if = {
					limit = { has_trait = generous }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:generous
					}
				}
			}
			# Intrigue.
			else_if = {
				limit = { has_trait = education_intrigue }
				save_scope_value_as = {
					name = lesson
					value = flag:intrigue
				}
				# Do we need to mark out any special differences due to teaching style?
				## Compassionate.
				if = {
					limit = { has_trait = compassionate }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:compassionate
					}
				}
				## Callous.
				if = {
					limit = { has_trait = callous }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:callous
					}
				}
				## Sadistic.
				if = {
					limit = { has_trait = sadistic }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:sadistic
					}
				}
			}
			# Learning.
			else_if = {
				limit = { has_trait = education_learning }
				save_scope_value_as = {
					name = lesson
					value = flag:learning
				}
				# Do we need to mark out any special differences due to teaching style?
				## Shy.
				if = {
					limit = { has_trait = shy }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:shy
					}
				}
				## Gregarious.
				if = {
					limit = { has_trait = gregarious }
					save_scope_value_as = {
						name = lesson_variant
						value = flag:gregarious
					}
				}
			}
		}
		# Process our reaction to it.
		if = {
			limit = { exists = scope:lesson_variant }
			# Arrogant reactions.
			if = {
				limit = { scope:lesson_variant = flag:arrogant }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = arrogant
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = humble
							has_trait = pensive
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Humble reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:humble }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = humble
							has_trait = pensive
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = arrogant
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Wrathful reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:wrathful }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = wrathful
							has_trait = rowdy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = calm
							has_trait = pensive
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Calm reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:calm }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = calm
							has_trait = pensive
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = wrathful
							has_trait = rowdy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Greedy reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:greedy }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = greedy
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = generous
							has_trait = charming
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Generous reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:generous }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = generous
							has_trait = charming
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = greedy
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Compassionate reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:compassionate }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = compassionate
							has_trait = charming
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = callous
							has_trait = sadistic
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Callous reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:callous }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = callous
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = compassionate
							has_trait = charming
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Sadistic reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:sadistic }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = sadistic
							has_trait = bossy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = compassionate
							has_trait = charming
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Shy reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:shy }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = shy
							has_trait = pensive
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = gregarious
							has_trait = rowdy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
			# Gregarious reactions.
			else_if = {
				limit = { scope:lesson_variant = flag:gregarious }
				# Do we appreciate such a lesson?
				if = {
					limit = {
						OR = {
							has_trait = gregarious
							has_trait = rowdy
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:admiration
					}
				}
				# Or are we horrified instead?
				else_if = {
					limit = {
						OR = {
							has_trait = shy
							has_trait = pensive
						}
					}
					save_scope_value_as = {
						name = child_reaction
						value = flag:disgust
					}
				}
			}
		}
		## If we've not set a scope:child_reaction yet, give us the default one.
		if = {
			limit = {
				NOT = { exists = scope:child_reaction }
			}
			# ... which is interested, if the child is curious.
			if = {
				limit = { has_trait = curious }
				save_scope_value_as = {
					name = child_reaction
					value = flag:admiration
				}
			}
			# ... and otherwise, bored.
			else = {
				save_scope_value_as = {
					name = child_reaction
					value = flag:boredom
				}
			}
		}
	}

	# Diplomacy Skill Gain.
	option = {
		name = bp2_yearly.0601.a
		trigger = { scope:lesson = flag:diplomacy }

		# Boost the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_skill_points_effect = { SKILL = diplomacy }

		bp2_yearly_0601_diplomacy_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_skill_modifier = yes
		}
	}
	
	# Diplomacy Perk Gain.
	option = {
		name = bp2_yearly.0601.b
		trigger = { scope:lesson = flag:diplomacy }

		# Boost lifestyle XP in the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_lifestyle_perk_points_effect = { SKILL = diplomacy }

		bp2_yearly_0601_diplomacy_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_perk_modifier = yes
		}
	}
	
	# Martial Skill Gain.
	option = {
		name = bp2_yearly.0601.c
		trigger = { scope:lesson = flag:martial }

		# Boost the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_skill_points_effect = { SKILL = martial }

		bp2_yearly_0601_martial_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_skill_modifier = yes
		}
	}
	
	# Martial Perk Gain.
	option = {
		name = bp2_yearly.0601.d
		trigger = { scope:lesson = flag:martial }

		# Boost lifestyle XP in the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_lifestyle_perk_points_effect = { SKILL = martial }

		bp2_yearly_0601_martial_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_perk_modifier = yes
		}
	}
	
	# Stewardship Skill Gain.
	option = {
		name = bp2_yearly.0601.e
		trigger = { scope:lesson = flag:stewardship }

		# Boost the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_skill_points_effect = { SKILL = stewardship }

		bp2_yearly_0601_stewardship_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_skill_modifier = yes
		}
	}
	
	# Stewardship Perk Gain.
	option = {
		name = bp2_yearly.0601.f
		trigger = { scope:lesson = flag:stewardship }

		# Boost lifestyle XP in the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_lifestyle_perk_points_effect = { SKILL = stewardship }

		bp2_yearly_0601_stewardship_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_perk_modifier = yes
		}
	}
	
	# Intrigue Skill Gain.
	option = {
		name = bp2_yearly.0601.g
		trigger = { scope:lesson = flag:intrigue }

		# Boost the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_skill_points_effect = { SKILL = intrigue }

		bp2_yearly_0601_intrigue_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_skill_modifier = yes
		}
	}
	
	# Intrigue Perk Gain.
	option = {
		name = bp2_yearly.0601.h
		trigger = { scope:lesson = flag:intrigue }

		# Boost lifestyle XP in the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_lifestyle_perk_points_effect = { SKILL = intrigue }

		bp2_yearly_0601_intrigue_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_perk_modifier = yes
		}
	}
	
	# Learning Skill Gain.
	option = {
		name = bp2_yearly.0601.i
		trigger = { scope:lesson = flag:learning }

		# Boost the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_skill_points_effect = { SKILL = learning }

		bp2_yearly_0601_learning_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_skill_modifier = yes
		}
	}
	
	# Learning Perk Gain.
	option = {
		name = bp2_yearly.0601.j
		trigger = { scope:lesson = flag:learning }

		# Boost lifestyle XP in the relevant skill according to your regent's ranks in education.
		bp2_yearly_0601_apply_extra_lifestyle_perk_points_effect = { SKILL = learning }

		bp2_yearly_0601_learning_stress_gain_effect = yes
		ai_chance = {
			base = 1
			bp2_yearly_0601_ai_weight_option_perk_modifier = yes
		}
	}
	
	# Opt out: daydream.
	option = {
		name = bp2_yearly.0601.k

		# Consolation modifier.
		add_character_modifier = {
			modifier = frequent_daydreamer_modifier
			years = @bp2_yearly_0601_minimum_cooldown_years
		}

		stress_impact = {
			base = medium_stress_impact_loss
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_boldness = 1
				ai_energy = -1
			}
		}
	}
}

##################################################
# PrimaryTitle's Second Capital
# by Ewan Cowhig Croft
# 0611 - 0620
##################################################

# Roll for charming children (if such a thing can be said to exist) to try for a hook with their highest skill.
scripted_effect bp2_yearly_0611_charming_roll_for_hook_effect = {
	duel = {
		skill = $SKILL$
		# Looks like a value, but we're actually taking scope:regent's skill with some extra bits.
		value = {
			value = scope:regent.$SKILL$
			# If SheHe likes you, then they limit their skills.
			if = {
				limit = {
					reverse_opinion = {
						target = scope:regent
						value >= 1
					}
				}
				multiply = 0.5
				max = high_skill_rating
			}
			else = { max = very_high_skill_rating }
		}
		# Success! A hook is yours.
		60 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			min = 5
			desc = bp2_yearly.0611.d.tt.success
			send_interface_toast = {
				title = bp2_yearly.0611.d.tt.success
				left_icon = scope:regent
				add_hook = {
					type = favor_hook
					target = scope:regent
				}
				raise_diarch_opinion_with_loyalty_update_effect = {
					OPINION_TYPE = amused_opinion
					OPINION_AMOUNT = 20
				}
			}
		}
		# Failure! No hook, bit of lost opinion (probably).
		40 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -49
			}
			min = 5
			desc = bp2_yearly.0611.d.tt.failure
			send_interface_toast = {
				title = bp2_yearly.0611.d.tt.failure
				left_icon = scope:regent
				# Deceitful regents respect the hustle.
				if = {
					limit = {
						scope:regent = { has_trait = deceitful }
					}
					custom_tooltip = bp2_yearly.0611.d.tt.failure.deceitful
					raise_diarch_opinion_with_loyalty_update_effect = {
						OPINION_TYPE = amused_opinion
						OPINION_AMOUNT = 35
					}
				}
				# Everyone else is annoyed.
				else = {
					raise_diarch_opinion_with_loyalty_update_effect = {
						OPINION_TYPE = annoyed_opinion
						OPINION_AMOUNT = -20
					}
				}
			}
		}
	}
}

#	Far away regent never seems to visit.
bp2_yearly.0611 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.0611.t
	desc = {
		# What do you think of them?
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
				}
				desc = bp2_yearly.0611.desc.intro.bad_history
			}
			desc = bp2_yearly.0611.desc.intro.fallback
		}
		# What does your regent think of you?
		## We're deliberately not tying this to loyalty because then we need to account for the three special loyalty condition variants anyway, and it's just a whole lotta hassle.
		first_valid = {
			# They like you.
			triggered_desc = {
				trigger = {
					reverse_opinion = {
						target = scope:regent
						value >= high_positive_opinion
					}
				}
				desc = bp2_yearly.0611.desc.regent_opinion.positive
			}
			# They hate you.
			triggered_desc = {
				trigger = {
					reverse_opinion = {
						target = scope:regent
						value <= high_negative_opinion
					}
				}
				desc = bp2_yearly.0611.desc.regent_opinion.negative
			}
			# They're neutral about you.
			desc = bp2_yearly.0611.desc.regent_opinion.fallback
		}
		# Check gubermint type for some loc niceties.
		first_valid = {
			triggered_desc = {
				trigger = { government_has_flag = government_is_tribal }
				desc = bp2_yearly.0611.desc.government.tribal
			}
			desc = bp2_yearly.0611.desc.government.fallback
		}
		desc = bp2_yearly.0611.desc.outro
	}
	theme = education
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:regent
		animation = chancellor
		camera = camera_event_right_pointing_left
	}
	override_background = { reference = courtyard }

	cooldown = { years = 5 }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		diarch = {
			is_available = yes
			is_landed = yes
		}
		# Root can communicate their feelings externally to a decent level.
		child_not_infant_trigger = yes
		# Regent isn't a player _unless_ they're both players.
		filter_players_for_agency_trigger = yes
	}

	immediate = {
		# Grab some scopes for loc'n'ease.
		## Our regent.
		diarch = {
			save_scope_as = regent
			# And HerHis capital.
			capital_county = { save_scope_as = regent_capital }
		}
	}

	# Write a letter begging HerHim to visit more often.
	option = {
		name = bp2_yearly.0611.a
		
		# Raise opinion with your diarch.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = compliment_opinion
			OPINION_AMOUNT = 30
		}

		stress_impact = {
			pensive = miniscule_stress_impact_loss
			humble = miniscule_stress_impact_loss
			bossy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_sociability = 1
				ai_rationality = 0.25
			}
		}
	}
	
	# Throw a tantrum about being usurped.
	option = {
		name = bp2_yearly.0611.b
		flavor = bp2_yearly.0611.b.tt
		
		# Gain some swing.
		update_diarchy_swing_with_perspective_effect = {
			SWING = medium_sop_swing_liege_gain
			LIEGE = root
		}
		# Lower opinion with your diarch.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = respect_opinion
			OPINION_AMOUNT = -30
		}

		stress_impact = {
			bossy = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			pensive = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 0.5
			}
		}
	}
	
	# Rowdy: use the free time to play in the garden as much as possible.
	option = {
		name = bp2_yearly.0611.c
		trigger = { has_trait = rowdy }
		trait = rowdy

		# Gain opinion with the rest of the children at court.
		every_courtier_or_guest = {
			limit = {
				child_not_infant_trigger = yes
				is_available = yes
			}
			custom = custom.every_child_in_court
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 40
			}
		}

		stress_impact = { rowdy = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Charming: try to extract a hook instead.
	option = {
		name = bp2_yearly.0611.d
		trigger = { has_trait = charming }
		trait = charming

		# If you don't have a hook, try for a hook.
		if = {
			limit = {
				can_add_hook = {
					target = scope:regent
					type = favor_hook
					years = 10
				}
			}
			# Next, we try to use the child's highest skill relative to the other character.
			## Set up the values.
			save_scope_value_as = {
				name = relative_diplomacy
				value = {
					value = diplomacy
					subtract = scope:regent.diplomacy
				}
			}
			save_scope_value_as = {
				name = relative_intrigue
				value = {
					value = intrigue
					subtract = scope:regent.intrigue
				}
			}
			## Now, is diplo higher?
			if = {
				# > rather than >= to simulate the natural inclination for deviousness that lurks in the hearts of all children.
				limit = { scope:relative_diplomacy > scope:relative_intrigue }
				bp2_yearly_0611_charming_roll_for_hook_effect = { SKILL = diplomacy }
			}
			## Else, go for intrigue.
			else = {
				bp2_yearly_0611_charming_roll_for_hook_effect = { SKILL = intrigue }
			}
		}
		# Otherwise, we just give a nice big opinion bonus.
		else = {
			raise_diarch_opinion_with_loyalty_update_effect = {
				OPINION_TYPE = amused_opinion
				OPINION_AMOUNT = 40
			}
		}

		stress_impact = { charming = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 3 }
		}
	}
	
	# Curious: snoop around your regent's things, see what they actually _do_.
	option = {
		name = bp2_yearly.0611.e
		trigger = { has_trait = curious }
		trait = curious

		# Nice lil bonus.
		add_intrigue_skill = 1

		stress_impact = { curious = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_rationality = 1
				ai_honor = -0.5
			}
		}
	}
	
	# Pensive: go find a new book to read.
	option = {
		name = {
			trigger = { child_likely_reader_trigger = no }
			text = bp2_yearly.0611.f.young
		}
		name = {
			trigger = { child_likely_reader_trigger = yes }
			text = bp2_yearly.0611.f.fallback
		}
		trigger = { has_trait = pensive }
		trait = pensive

		# Nice lil bonus.
		add_learning_skill = 1

		stress_impact = { pensive = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_energy = -0.25
				ai_sociability = -1
			}
		}
	}
	
	# Bossy: organise your own playtime.
	option = {
		name = bp2_yearly.0611.g
		trigger = { has_trait = bossy }
		trait = bossy

		# If we already have the credit, just get some prestige.
		if = {
			limit = { has_variable = free_meet_peers_credit }
			add_prestige = medium_prestige_gain
		}
		# Otherwise, assign a free playdate credit.
		else = {
			# One free meet peers.
			custom_tooltip = bp2_yearly.0611.g.tt
			set_variable = free_meet_peers_credit
		}

		stress_impact = { bossy = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_boldness = 1
				ai_energy = 1
			}
		}
	}
}

##################################################
# AuntUncle RegentFirstName
# by Ewan Cowhig Croft
# 0621 - 0630
##################################################

scripted_effect bp2_yearly_0621_accept_basic_gift_effect = {
	# What gift are we giving?
	## Gold
	if = {
		limit = { scope:gift_type = flag:gold }
		scope:regent = {
			pay_short_term_gold = {
				target = root
				gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	## Prestige
	else_if = {
		limit = { scope:gift_type = flag:prestige }
		add_prestige = medium_prestige_gain
		scope:regent = {
			if = {
				# If we're in MP, don't deduct gold from a player regent.
				limit = { is_ai = yes }
				remove_short_term_gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	## Piety
	else_if = {
		limit = { scope:gift_type = flag:piety }
		add_piety = medium_piety_gain
		scope:regent = {
			if = {
				# If we're in MP, don't deduct gold from a player regent.
				limit = { is_ai = yes }
				remove_short_term_gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	## Event Troops
	else_if = {
		limit = { scope:gift_type = flag:event_troops }
		spawn_army = {
			name = event_troop_default_name
			men_at_arms = {
				type = armored_footmen
				stacks = 4
				inheritable = no
			}
			location = root.location
		}
		scope:regent = {
			if = {
				# If we're in MP, don't deduct gold from a player regent.
				limit = { is_ai = yes }
				remove_short_term_gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	## Dog
	else_if = {
		limit = { scope:gift_type = flag:dog }
		start_dog_story_cycle_effect = yes
		scope:regent = {
			if = {
				# If we're in MP, don't deduct gold from a player regent.
				limit = { is_ai = yes }
				remove_short_term_gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	## Cat
	else_if = {
		limit = { scope:gift_type = flag:cat }
		start_cat_story_cycle_effect = yes
		scope:regent = {
			if = {
				# If we're in MP, don't deduct gold from a player regent.
				limit = { is_ai = yes }
				remove_short_term_gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	## Eagle
	else_if = {
		limit = { scope:gift_type = flag:eagle }
		save_scope_value_as = {
			name = eagle_capture_method
			value = flag:gift
		}
		start_eagle_story_cycle_effect = yes
		scope:regent = {
			if = {
				# If we're in MP, don't deduct gold from a player regent.
				limit = { is_ai = yes }
				remove_short_term_gold = @bp2_yearly_0621_standard_gold_cost
			}
		}
	}
	# And, of course, this results in a bit of a swing.
	update_diarchy_swing_with_perspective_effect = {
		SWING = minor_sop_swing_diarch_gain
		LIEGE = root
	}
}

scripted_effect bp2_yearly_roll_chance_of_extra_stuff_effect = {
	random_list = {
		100 = {
			desc = bp2_yearly.0621.extra_stuff.success
			send_interface_toast = {
				title = bp2_yearly.0621.extra_stuff.success
				left_icon = scope:regent
				# What gift are we giving?
				## Gold
				if = {
					limit = { scope:gift_type = flag:gold }
					scope:regent = {
						pay_short_term_gold = {
							target = root
							gold = {
								value = @bp2_yearly_0621_standard_gold_cost
								multiply = 1.5
							}
						}
					}
				}
				## Prestige
				else_if = {
					limit = { scope:gift_type = flag:prestige }
					add_prestige = major_prestige_gain
				}
				## Piety
				else_if = {
					limit = { scope:gift_type = flag:piety }
					add_piety = major_piety_gain
				}
				## Event Troops
				else_if = {
					limit = { scope:gift_type = flag:event_troops }
					spawn_army = {
						name = event_troop_default_name
						men_at_arms = {
							type = armored_footmen
							stacks = 4
							inheritable = no
						}
						men_at_arms = {
							type = armored_footmen
							stacks = 4
							inheritable = no
						}
						location = root.location
					}
				}
				## Dog
				else_if = {
					limit = { scope:gift_type = flag:dog }
					start_dog_story_cycle_effect = yes
					add_character_modifier = {
						modifier = loyal_pack_of_hounds_modifier
						years = 20
					}
				}
				## Cat
				else_if = {
					limit = { scope:gift_type = flag:cat }
					start_cat_story_cycle_effect = yes
					add_character_modifier = {
						modifier = teeming_horde_of_cats_modifier
						years = 20
					}
				}
				## Eagle
				else_if = {
					limit = { scope:gift_type = flag:eagle }
					start_eagle_story_cycle_effect = yes
					add_character_modifier = {
						modifier = strong_flock_of_eagles_modifier
						years = 20
					}
				}
				# Plus, if we're not giving gold, remember to deduct the fee from scope:regent.
				if = {
					limit = {
						NOT = { scope:gift_type = flag:gold }
					}
					scope:regent = {
						if = {
							# If we're in MP, don't deduct gold from a player regent.
							limit = { is_ai = yes }
							remove_short_term_gold = {
								value = @bp2_yearly_0621_standard_gold_cost
								multiply = 1.5
							}
						}
					}
				}
			}
			# And, of course, this results in some a swing.
			update_diarchy_swing_with_perspective_effect = {
				SWING = medium_sop_swing_diarch_gain
				LIEGE = root
			}
			raise_diarch_opinion_with_loyalty_update_effect = {
				OPINION_TYPE = annoyed_opinion
				OPINION_AMOUNT = -25
			}
		}
		100 = {
			desc = bp2_yearly.0621.extra_stuff.failure
			send_interface_toast = {
				title = bp2_yearly.0621.extra_stuff.failure
				left_icon = scope:regent
				bp2_yearly_0621_accept_basic_gift_effect = yes
			}
			raise_diarch_opinion_with_loyalty_update_effect = {
				OPINION_TYPE = annoyed_opinion
				OPINION_AMOUNT = -10
			}
		}
	}
}

#	Nearby regents visits often.
bp2_yearly.0621 = {
	type = character_event
	content_source = dlc_009
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { is_close_family_of = diarch }
				desc = bp2_yearly.0621.t.close_family
			}
			desc = bp2_yearly.0621.t.fallback
		}
	}
	desc = {
		# What do you think of them?
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
				}
				desc = bp2_yearly.0621.desc.intro.bad_history
			}
			desc = bp2_yearly.0621.desc.intro.fallback
		}
		# Connect the sections.
		desc = bp2_yearly.0621.desc.midtro
		# What have they brought you?
		first_valid = {
			# Gold
			triggered_desc = {
				trigger = { scope:gift_type = flag:gold }
				desc = bp2_yearly.0621.desc.gift.gold
			}
			# Prestige
			triggered_desc = {
				trigger = { scope:gift_type = flag:prestige }
				desc = bp2_yearly.0621.desc.gift.prestige
			}
			# Piety
			triggered_desc = {
				trigger = { scope:gift_type = flag:piety }
				desc = bp2_yearly.0621.desc.gift.piety
			}
			# Event_troops
			triggered_desc = {
				trigger = { scope:gift_type = flag:event_troops }
				desc = bp2_yearly.0621.desc.gift.event_troops
			}
			# Dog
			triggered_desc = {
				trigger = { scope:gift_type = flag:dog }
				desc = bp2_yearly.0621.desc.gift.dog
			}
			# Cat
			triggered_desc = {
				trigger = { scope:gift_type = flag:cat }
				desc = bp2_yearly.0621.desc.gift.cat
			}
			# Eagle
			triggered_desc = {
				trigger = { scope:gift_type = flag:eagle }
				desc = bp2_yearly.0621.desc.gift.eagle
			}
		}
	}
	theme = education
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
			}
			animation = personality_vengeful
		}
		triggered_animation = {
			# Fallback.
			trigger = { always = yes }
			animation = happiness
		}
	}
	right_portrait = {
		character = scope:regent
		animation = admiration
	}
	override_background = { reference = courtyard }

	cooldown = { years = 5 }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		# Root can communicate their feelings externally to a decent level.
		child_not_infant_trigger = yes
		# Regent isn't a player _unless_ they're both players.
		filter_players_for_agency_trigger = yes
		# The regent needs to be in a good spot to make the gift.
		diarch = {
			is_available_adult = yes
			# Greedy regents won't give their gold away for any reason.
			NOT = { has_trait = greedy }
			# But otherwise, make sure they've got enough in the bank.
			OR = {
				# Courtiers we'll gift the money to stealthily, so that they can still compete.
				is_courtier = yes
				# Otherwise, do the full check.
				can_make_expensive_purchase_trigger = { PRICE = @bp2_yearly_0621_standard_gold_cost }
			}
		}
	}

	immediate = {
		# Grab some scopes for loc'n'ease.
		## Our regent.
		diarch = { save_scope_as = regent }
		# Right, now, roll what gift we'll be giving.
		random_list = {
			# Gold
			100 = {
				# Don't deduct gold from a player regent in MP.
				trigger = {
					scope:regent = { is_ai = yes }
				}
				modifier = {
					# 60% chance of education-dominant gift, 40% chance of the rest.
					add = 500
					scope:regent = { has_trait = education_stewardship }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:gold
				}
			}
			# Prestige
			100 = {
				modifier = {
					# 60% chance of education-dominant gift, 40% chance of the rest.
					add = 500
					scope:regent = { has_trait = education_diplomacy }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:prestige
				}
			}
			# Piety
			100 = {
				trigger = {
					scope:regent = {
						OR = {
							# If you're the same faith, no problem.
							faith = root.faith
							# Otherwise, regents'll make allowances as long as uhh... they aren't _too_strong-minded about faith.
							NOT = { has_trait = zealous }
						}
					}
				}
				modifier = {
					# 60% chance of education-dominant gift, 40% chance of the rest.
					add = 500
					scope:regent = { has_trait = education_learning }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:piety
				}
			}
			# Event Troops
			100 = {
				modifier = {
					# 60% chance of education-dominant gift, 40% chance of the rest.
					add = 500
					scope:regent = { has_trait = education_martial }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:event_troops
				}
				# And for loc.
				random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_soldier }	
			}
			# Pet
			100 = {
				trigger = { has_cat_or_dog_trigger = no }
				modifier = {
					# 60% chance of education-dominant gift, 40% chance of the rest.
					add = 500
					# Intrigue gives a pet because uhh... they know the easiest route into a child's good graces?
					scope:regent = { has_trait = education_intrigue }
				}
				# Rowdy characters get dogs.
				if = {
					limit = { has_trait = rowdy }
					save_scope_value_as = {
						name = gift_type
						value = flag:dog
					}
				}
				# Pensive characters get cats.
				else_if = {
					limit = { has_trait = pensive }
					save_scope_value_as = {
						name = gift_type
						value = flag:cat
					}
				}
				# All other characters get a toss up.
				else = {
					random_list = {
						100 = {
							save_scope_value_as = {
								name = gift_type
								value = flag:dog
							}
						}
						100 = {
							save_scope_value_as = {
								name = gift_type
								value = flag:cat
							}
						}
						#100 = {
						#	trigger = { location = { geographical_region = world_steppe } } #TODO_MPO - Nomad Trigger 
						#	save_scope_value_as = {
						#		name = gift_type
						#		value = flag:eagle
						#	}
						#}
					}
				}
			}
		}
		# Finally, give courtiers a bit of extra spending cash.
		diarch = {
			if = {
				# We don't check whether they can afford it or not - courtier income is basically non-existent, so even if they're rich, this'd still be a lot.
				limit = { is_courtier = yes }
				hidden_effect = { add_gold = @bp2_yearly_0621_standard_gold_cost }
			}
		}
		#TODO_CD_BP2_ECC; move this out of error suppression at some point — will need a future event using it or an official suppressor somewhere.
		save_scope_as = generous_purchase
		clear_saved_scope = generous_purchase
	}

	# Accept graciously.
	option = {
		name = bp2_yearly.0621.a

		bp2_yearly_0621_accept_basic_gift_effect = yes
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = pleased_opinion
			OPINION_AMOUNT = 15
		}

		# Everyone likes a nice gift, so we don't dole stress out here.
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 0.5
			}
		}
	}
	
	# Rowdy: challenge HerHim to arm wrestling for more.
	option = {
		name = bp2_yearly.0621.b
		trigger = { has_trait = rowdy }
		trait = rowdy

		bp2_yearly_roll_chance_of_extra_stuff_effect = yes

		stress_impact = {
			rowdy = medium_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
			}
		}
	}
	
	# Charming: try to wheedle more out of HerHim.
	option = {
		name = bp2_yearly.0621.c
		trigger = { has_trait = charming }
		trait = charming

		bp2_yearly_roll_chance_of_extra_stuff_effect = yes

		stress_impact = {
			charming = medium_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_boldness = 1
				ai_honor = -1
			}
		}
	}
	
	# Curious: ask about this and that till SheHe gives you more.
	option = {
		name = bp2_yearly.0621.d
		trigger = { has_trait = curious }
		trait = curious

		bp2_yearly_roll_chance_of_extra_stuff_effect = yes

		stress_impact = { curious = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = 2 }
		}
	}
	
	# Pensive: you've read a thing or two about how best to use this...
	option = {
		name = bp2_yearly.0621.e
		trigger = { has_trait = pensive }
		trait = pensive

		bp2_yearly_roll_chance_of_extra_stuff_effect = yes

		stress_impact = { pensive = medium_stress_impact_loss }
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = -2 }
		}
	}
	
	# Bossy: demand to know where the rest of it is.
	option = {
		name = bp2_yearly.0621.f
		trigger = { has_trait = bossy }
		trait = bossy

		bp2_yearly_roll_chance_of_extra_stuff_effect = yes

		stress_impact = {
			bossy = medium_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_boldness = 1
				ai_compassion = -1
			}
		}
	}
	
	# Refuse politely.
	option = {
		name = {
			trigger = {
				has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
			}
			text = bp2_yearly.0621.g.bad_blood
		}
		name = {
			trigger = {
				NOT = {
					has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
				}
			}
			text = bp2_yearly.0621.g.good_terms
		}

		update_diarchy_swing_with_perspective_effect = {
			SWING = minor_sop_swing_liege_gain
			LIEGE = root
		}
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = annoyed_opinion
			OPINION_AMOUNT = -20
		}

		# Vengeful stress loss.
		if = {
			limit = {
				has_trait = vengeful
				has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
			}
			stress_impact = {
				base = minor_stress_loss
				vengeful = major_stress_impact_loss
				humble = miniscule_stress_impact_loss
				greedy = minor_stress_impact_gain
			}
		}
		# Non-vengeful stress los.
		else = {
			stress_impact = {
				humble = miniscule_stress_impact_loss
				greedy = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_rationality = -2
			}
		}
	}
}

##################################################
# Whispered Words
# by Ewan Cowhig Croft
# 0631 - 0640
##################################################

scripted_trigger bp2_yearly_0631_rival_successor_trigger = {
	# First, check that the two chars don't get on.
	has_antipathy_with_diarch_trigger = yes
	# Then, ensure this is a character not too distant in the succession score.
	OR = {
		this = root.diarchy_successor
		diarchy_regent_succession_score_value >= {
			value = root.diarchy_successor.diarchy_regent_succession_score_value
			add = -50
		}
	}
	# Filter out players & designated diarchs, who can't be removed like this.
	is_ai = yes
	is_designated_diarch = no
}

#	Courtier-regent turns you against a rival for the regency.
bp2_yearly.0631 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.0631.t
	desc = {
		# What's scope:regent's motivation here?
		first_valid = {
			triggered_desc = {
				trigger = { scope:regent_motivation = flag:positive }
				desc = bp2_yearly.0631.desc.intro.positive
			}
			triggered_desc = {
				trigger = { scope:regent_motivation = flag:negative }
				desc = bp2_yearly.0631.desc.intro.negative
			}
			triggered_desc = {
				trigger = { scope:regent_motivation = flag:vague }
				desc = bp2_yearly.0631.desc.intro.vague
			}
		}
		# Select a reason for scope:regent to be mad.
		first_valid = {
			# Opinions.
			## Nemesis.
			triggered_desc = {
				trigger = {
					scope:regent = { has_relation_nemesis = scope:rival_successor }
				}
				desc = bp2_yearly.0631.desc.rationale.nemesis
			}
			## Warmonger.
			triggered_desc = {
				trigger = {
					scope:regent = {
						has_any_war_opinion_against_character_trigger = { CHARACTER = scope:rival_successor }
					}
				}
				desc = bp2_yearly.0631.desc.rationale.warmonger
			}
			## Rival.
			triggered_desc = {
				trigger = {
					scope:regent = { has_relation_rival = scope:rival_successor }
				}
				desc = bp2_yearly.0631.desc.rationale.rival
			}
			## Revenge.
			triggered_desc = {
				trigger = {
					scope:regent = {
						has_any_major_revenge_opinion_against_character_trigger = { CHARACTER = scope:rival_successor }
					}
				}
				desc = bp2_yearly.0631.desc.rationale.revenge
			}
			# Traits.
			## Criminality.
			triggered_desc = {
				trigger = {
					has_any_criminal_trait_in_faith_trigger = {
						CHARACTER = scope:rival_successor
						FAITH = scope:regent.faith
					}
				}
				desc = bp2_yearly.0631.desc.rationale.criminality
			}
			## Opposing traits.
			triggered_desc = {
				trigger = {
					scope:regent = {
						number_of_opposing_personality_traits = {
							target = scope:rival_successor
							value >= 2
						}
					}
				}
				desc = bp2_yearly.0631.desc.rationale.opposing_traits
			}
			## Sins.
			triggered_desc = {
				trigger = {
					scope:rival_successor = {
						num_sinful_traits = {
							value >= 2
							faith = scope:regent.faith
						}
					}
				}
				desc = bp2_yearly.0631.desc.rationale.sins
			}
			# Fallbacks.
			## Petty opinions.
			triggered_desc = {
				trigger = {
					scope:regent = {
						has_any_petty_revenge_opinion_against_character_trigger = { CHARACTER = scope:rival_successor }
					}
				}
				desc = bp2_yearly.0631.desc.rationale.petty_opinions
			}
			## Hideousness.
			triggered_desc = {
				trigger = {
					scope:regent = {
						NOT = { has_trait = compassionate }
						has_easily_mocked_physical_attribute_trigger = no
					}
					scope:rival_successor = { has_easily_mocked_physical_attribute_trigger = yes }
				}
				desc = bp2_yearly.0631.desc.rationale.hideousness
			}
			## Generic.
			desc = bp2_yearly.0631.desc.rationale.generic
		}
		desc = bp2_yearly.0631.desc.outro
	}
	theme = education
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:regent
		animation = throne_room_chancellor
	}
	lower_center_portrait = scope:rival_successor
	override_background = { reference = bedchamber }

	cooldown = { years = 5 }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		# Check root is old enough to be worth teaching.
		child_old_enough_for_responsibility_trigger = yes
		# Regent checks.
		## Must be available to take the time, plus no real gain from the event if a player is your diarch.
		diarch = { is_available_ai_adult = yes }
		# Must have someone to poison you against.
		any_diarchy_succession_character ?= { bp2_yearly_0631_rival_successor_trigger = yes }
	}

	immediate = {
		# First, grab our diarch's scope for loc.
		diarch = { save_scope_as = regent }
		# Then we pick our target.
		## Sort candidates.
		every_diarchy_succession_character = {
			limit = { bp2_yearly_0631_rival_successor_trigger = yes }
			add_to_list = preliminary_potential_targets_list
		}
		## Now, filter out the top five highest scoring.
		ordered_in_list = {
			list = preliminary_potential_targets_list
			order_by = diarchy_regent_succession_score_value
			max = 5
			check_range_bounds = no
			add_to_list = final_potential_targets_list
		}
		## Cool, we've got our best bets. Now pick the most interesting candidate within these.
		ordered_in_list = {
			list = final_potential_targets_list
			order_by = {
				value = diarchy_regent_succession_score_value
				# Immediately, let's just make the score a bit more important before we start adding minor factors.
				multiply = 10
				# Right, now, weight up for actual relationships.
				## Nemeses.
				if = {
					limit = { has_relation_nemesis = scope:regent }
					add = 100
				}
				## Rivals.
				else_if = {
					limit = { has_relation_rival = scope:regent }
					add = 25
				}
				# Familial relations.
				## Close family.
				if = {
					limit = { is_close_family_of = root }
					add = 50
				}
				## Extended family.
				else_if = {
					limit = { is_extended_family_of = root }
					add = 25
				}
				## Same house.
				else_if = {
					limit = {
						exists = root.house
						house ?= root.house
					}
					add = 15
				}
				## Same dynasty.
				else_if = {
					limit = {
						exists = root.dynasty
						dynasty ?= root.dynasty
					}
					add = 5
				}
				# Prior actions.
				## Regent vs. target.
				save_temporary_scope_as = char_temp
				### Major.
				if = {
					limit = {
						scope:regent = {
							has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:char_temp }
						}
					}
					add = 50
				}
				### Minor.
				if = {
					limit = {
						scope:regent = {
							has_any_petty_revenge_opinion_against_character_trigger = { CHARACTER = scope:char_temp }
						}
					}
					add = 15
				}
				## Target vs. regent.
				### Major.
				if = {
					limit = {
						has_any_major_negative_opinion_against_character_trigger = { CHARACTER = scope:regent }
					}
					add = 50
				}
				### Minor.
				if = {
					limit = {
						has_any_petty_revenge_opinion_against_character_trigger = { CHARACTER = scope:regent }
					}
					add = 15
				}
			}
			save_scope_as = rival_successor
		}
		# Why is our diarch doing this?
		## Positive motivation.
		if = {
			limit = {
				OR = {
					diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold
					reverse_opinion = {
						target = scope:regent
						value >= medium_positive_opinion
					}
				}
			}
			save_scope_value_as = {
				name = regent_motivation
				value = flag:positive
			}
		}
		## Selfish motivation.
		else_if = {
			limit = {
				reverse_opinion = {
					target = scope:regent
					value <= medium_negative_opinion
				}
			}
			save_scope_value_as = {
				name = regent_motivation
				value = flag:negative
			}
		}
		## Vague motivation.
		else = {
			save_scope_value_as = {
				name = regent_motivation
				value = flag:vague
			}
		}
	}

	# Accept to please the regent.
	option = {
		name = bp2_yearly.0631.a

		# Gain opinion with your regent.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = pleased_opinion
			OPINION_AMOUNT = 40
		}
		# Plus a lil hook, if applicable.
		add_favour_hook_if_possible_simple_effect = { TARGET = scope:regent }
		# Then, filter out scope:rival_successor from the diarch succession.
		scope:rival_successor = {
			# RIP.
			set_variable = {
				name = diarch_succession_filtered_due_to_incumbents_politicking
				value = root
			}
			# Plus, there's fallout from this.
			progress_towards_rival_effect = {
				REASON = rival_poisoned_against_by_regent
				CHARACTER = root
				OPINION = -25
			}
		}

		stress_impact = {
			base = minor_stress_gain
			arbitrary = minor_stress_impact_loss
			bossy = minor_stress_impact_loss
			pensive = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -2 }
			opinion_modifier = { opinion_target = scope:regent }
		}
	}
	
	# Deny to please the target.
	option = {
		name = bp2_yearly.0631.b
		flavor = bp2_yearly.0631.b.tt

		# Scope:rival_successor is pleased.
		reverse_add_opinion = {
			target = scope:rival_successor
			modifier = pleased_opinion
			opinion = 30
		}
		# Plus you get a lil hook.
		add_favour_hook_if_possible_simple_effect = { TARGET = scope:rival_successor }
		# But scope:regent is not.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = refusal_opinion
			OPINION_AMOUNT = -25
		}

		stress_impact = {
			base = minor_stress_gain
			arbitrary = minor_stress_impact_loss
			bossy = minor_stress_impact_loss
			pensive = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 2 }
			opinion_modifier = { opinion_target = scope:rival_successor }
		}
	}
	
	# Childhood Trait: refuse to engage.
	option = {
		trigger = {
			OR = {
				has_trait = rowdy
				has_trait = charming
				has_trait = curious
				has_trait = pensive
				has_trait = bossy
			}
		}
		name = {
			text = {
				first_valid = {
					# Rowdy.
					triggered_desc = {
						trigger = { has_trait = rowdy }
						desc = bp2_yearly.0631.c.rowdy
					}
					# Charming.
					triggered_desc = {
						trigger = { has_trait = charming }
						desc = bp2_yearly.0631.c.charming
					}
					# Curious.
					triggered_desc = {
						trigger = { has_trait = curious }
						desc = bp2_yearly.0631.c.curious
					}
					# Pensive.
					triggered_desc = {
						trigger = { has_trait = pensive }
						desc = bp2_yearly.0631.c.pensive
					}
					# Bossy.
					triggered_desc = {
						trigger = { has_trait = bossy }
						desc = bp2_yearly.0631.c.bossy
					}
				}
			}
		}
		trait = rowdy
		trait = charming
		trait = curious
		trait = pensive
		trait = bossy

		# Trade a little opinion with both...
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = refusal_opinion
			OPINION_AMOUNT = -25
		}
		reverse_add_opinion = {
			target = scope:rival_successor
			modifier = trust_opinion
			opinion = -20
		}
		# ... for some SoP swing.
		update_diarchy_swing_with_perspective_effect = {
			SWING = minor_sop_swing_liege_gain
			LIEGE = root
		}

		stress_impact = {
			base = minor_stress_loss
			rowdy = minor_stress_impact_loss
			charming = minor_stress_impact_loss
			curious = minor_stress_impact_loss
			pensive = minor_stress_impact_loss
			bossy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_energy = 1
				ai_rationality = 0.25
			}
			opinion_modifier = {
				opinion_target = scope:regent
				multiplier = -0.5
			}
			opinion_modifier = {
				opinion_target = scope:rival_successor
				multiplier = -0.5
			}
		}
	}
}

##################################################
# Quid Pro Quo
# by Ewan Cowhig Croft
# 0641 - 0650
##################################################

#	Regent offers special present in exchange for your agreement on some documents.
bp2_yearly.0641 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.0641.t
	desc = {
		# Intro.
		first_valid = {
			triggered_desc = {
				trigger = { government_has_flag = government_is_tribal }
				desc = bp2_yearly.0641.desc.intro.tribal
			}
			desc = bp2_yearly.0641.desc.intro.fallback
		}
		desc = bp2_yearly.0641.desc.midtro
		# Vary desc a bit depending on what the gift modifier is.
		first_valid = {
			triggered_desc = {
				trigger = { scope:gift_type = flag:vs_courtly }
				desc = bp2_yearly.0641.desc.vs_courtly
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:vs_glory_hound }
				desc = bp2_yearly.0641.desc.vs_glory_hound
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:vs_parochial }
				desc = bp2_yearly.0641.desc.vs_parochial
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:vs_zealot }
				desc = bp2_yearly.0641.desc.vs_zealot
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:vs_minority }
				desc = bp2_yearly.0641.desc.vs_minority
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:vs_baron }
				desc = bp2_yearly.0641.desc.vs_baron
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:dynasty }
				desc = bp2_yearly.0641.desc.dynasty
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:fellow_vassals }
				desc = bp2_yearly.0641.desc.fellow_vassals
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:powerful_vassal }
				desc = bp2_yearly.0641.desc.powerful_vassal
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:hof }
				desc = bp2_yearly.0641.desc.hof
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:realm_priest }
				desc = bp2_yearly.0641.desc.realm_priest
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:maa_maintenance }
				desc = bp2_yearly.0641.desc.maa_maintenance
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:cowed_vassal }
				desc = bp2_yearly.0641.desc.cowed_vassal
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:war_income }
				desc = bp2_yearly.0641.desc.war_income
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:free_ho_hire }
				desc = bp2_yearly.0641.desc.free_ho_hire
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:mercenary_cost_reduction }
				desc = bp2_yearly.0641.desc.mercenary_cost_reduction
			}
			triggered_desc = {
				trigger = { scope:gift_type = flag:raid_speed }
				desc = bp2_yearly.0641.desc.raid_speed
			}
		}
		# Outro.
		first_valid = {
			triggered_desc = {
				trigger = { government_has_flag = government_is_tribal }
				desc = bp2_yearly.0641.desc.outro.tribal
			}
			desc = bp2_yearly.0641.desc.outro.fallback
		}
	}
	theme = education
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:regent
		animation = flirtation
	}
	override_background = { reference = study }

	cooldown = { years = 10 }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		# Check root is old enough to be worth teaching.
		child_old_enough_for_responsibility_trigger = yes
		# Regent isn't a player _unless_ they're both players.
		filter_players_for_agency_trigger = yes
		# Regent needs motivation.
		diarchy_swing <= diarch_wants_more_swing_event_threshold_value
		# Regent checks.
		diarch = {
			# Must be available to take the time.
			is_available_adult = yes
		}
	}

	immediate = {
		# Save our regent for loc.
		diarch = { save_scope_as = regent }
		# Random roll the gift they offer you.
		random_list = {
			# Vassal Stance boosts.
			## Courtly
			1 = {
				trigger = {
					any_vassal = { has_vassal_stance = courtly }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:vs_courtly
				}
				# Weight up depending on how many we have.
				modifier = {
					add = {
						every_vassal = {
							limit = { has_vassal_stance = courtly }
							add = 1
						}
					}
					always = yes
				}
			}
			## Glory_hound
			1 = {
				trigger = {
					any_vassal = { has_vassal_stance = glory_hound }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:vs_glory_hound
				}
				# Weight up depending on how many we have.
				modifier = {
					add = {
						every_vassal = {
							limit = { has_vassal_stance = glory_hound }
							add = 1
						}
					}
					always = yes
				}
			}
			## Parochial
			1 = {
				trigger = {
					any_vassal = { has_vassal_stance = parochial }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:vs_parochial
				}
				# Weight up depending on how many we have.
				modifier = {
					add = {
						every_vassal = {
							limit = { has_vassal_stance = parochial }
							add = 1
						}
					}
					always = yes
				}
			}
			## Zealot
			1 = {
				trigger = {
					any_vassal = { has_vassal_stance = zealot }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:vs_zealot
				}
				# Weight up depending on how many we have.
				modifier = {
					add = {
						every_vassal = {
							limit = { has_vassal_stance = zealot }
							add = 1
						}
					}
					always = yes
				}
			}
			## Minority
			1 = {
				trigger = {
					any_vassal = { has_vassal_stance = minority }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:vs_minority
				}
				# Weight up depending on how many we have.
				modifier = {
					add = {
						every_vassal = {
							limit = { has_vassal_stance = minority }
							add = 1
						}
					}
					always = yes
				}
			}
			## Minor Landholders
			1 = {
				trigger = {
					any_vassal = { has_vassal_stance = barons_and_minor_landholders }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:vs_baron
				}
				# Weight up depending on how many we have.
				modifier = {
					add = {
						every_vassal = {
							limit = { has_vassal_stance = barons_and_minor_landholders }
							add = 1
						}
					}
					always = yes
				}
			}
			# Opinion boosts.
			## Dynasty.
			1 = {
				trigger = {
					exists = dynasty
					# Require there to be a decent number of people to impress.
					dynasty = {
						any_dynasty_member = { count >= 5 }
					}
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:dynasty
				}
				# Weight up for landed dynasty members of your tier or higher.
				modifier = {
					add = {
						dynasty = {
							every_dynasty_member = {
								limit = { highest_held_title_tier >= root.highest_held_title_tier }
								add = 2
							}
						}
					}
					always = yes
				}
			}
			## Fellow Vassal.
			1 = {
				trigger = {
					is_independent_ruler = no
					liege = {
						any_vassal = { count >= 2 }
					}
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:fellow_vassals
				}
				# Weight up for co-vassals your tier or higher.
				modifier = {
					add = {
						liege = {
							every_vassal = {
								limit = { highest_held_title_tier >= root.highest_held_title_tier }
								add = 2
							}
						}
					}
					always = yes
				}
			}
			## Powerful Vassal.
			1 = {
				trigger = { number_of_powerful_vassals >= 1 }
				save_scope_value_as = {
					name = gift_type
					value = flag:powerful_vassal
				}
				# Weight up for every unhappy powerful vassal.
				modifier = {
					add = {
						every_powerful_vassal = {
							limit = {
								opinion = {
									target = root
									value <= -1
								}
							}
							add = 2
						}
					}
					always = yes
				}
			}
			## Religious Head.
			1 = {
				trigger = {
					exists = faith.religious_head
					scope:regent.faith.religious_head ?= root.faith.religious_head
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:hof
				}
				# Weight up if you've got a HoF who doesn't like you and the doctrine parameters to make you really care.
				modifier = {
					add = 10
					faith = {
						religious_head = {
							opinion = {
								target = root
								value <= -1
							}
						}
						OR = {
							has_doctrine_parameter = seek_indulgences_active
							has_doctrine_parameter = seek_indulgences_active_2
							has_doctrine_parameter = excommunication_active
						}
					}
				}
			}
			## Realm Priest.
			1 = {
				trigger = {
					faith = { has_doctrine_parameter = theocracy_temple_lease }
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:realm_priest
				}
				# Weight up if they aren't endorsing you.
				modifier = {
					add = 10
					cp:councillor_court_chaplain ?= {
						opinion = {
							target = root
							value <= -1
						}
					}
				}
			}
			# Econ.
			## MaA Maintenance.
			1 = {
				trigger = { number_of_maa_regiments >= 1 }
				save_scope_value_as = {
					name = gift_type
					value = flag:maa_maintenance
				}
				# Weight up at war.
				modifier = {
					add = 5
					is_at_war = yes
				}
			}
			## Cowed Vassal bonuses.
			1 = {
				trigger = {
					any_vassal = {
						has_dread_level_towards = {
							target = root
							level >= 2
						}
					}
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:cowed_vassal
				}
				# Weight up per cowed vassal.
				modifier = {
					add = {
						every_vassal = {
							limit = {
								has_dread_level_towards = {
									target = root
									level >= 2
								}
							}
							add = highest_held_title_tier
							# Account for barons/courtiers.
							add = -2
						}
					}
					always = yes
				}
			}
			## War income.
			1 = {
				trigger = { is_at_war = yes }
				save_scope_value_as = {
					name = gift_type
					value = flag:war_income
				}
				# Weight up for losing money.
				modifier = {
					add = 20
					monthly_character_income < 0
				}
			}
			# Military.
			## Free Holy Order hire.
			1 = {
				trigger = {
					faith = {
						any_faith_holy_order = {
							count = 1
							NOT = { holy_order_patron = root }
						}
					}
					OR = {
						faith = scope:regent.faith
						AND = {
							exists = scope:regent.faith.religious_head
							faith.religious_head ?= scope:regent.faith.religious_head
						}
					}
					any_neighboring_and_across_water_top_liege_realm = {
						holder.faith = {
							save_temporary_scope_as = faith_temp
							root.faith = {
								faith_hostility_level = {
									target = scope:faith_temp
									value <= faith_hostile_level
								}
							}
						}
					}
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:free_ho_hire
				}
				# Weight up for at war and they'd help.
				modifier = {
					add = 20
					any_primary_war_enemy = {
						faith = { save_temporary_scope_as = faith_temp }
						root.faith = {
							faith_hostility_level = {
								target = scope:faith_temp
								value <= faith_hostile_level
							}
						}
					}
				}
			}
			## Mercenary hire cost reduction.
			1 = {
				trigger = {
					# Must be losing a war as the primary side participant.
					any_character_war = {
						OR = {
							AND = {
								primary_attacker = root
								attacker_war_score <= -10
							}
							AND = {
								primary_defender = root
								defender_war_score <= -10
							}
						}
					}
				}
				save_scope_value_as = {
					name = gift_type
					value = flag:mercenary_cost_reduction
				}
				# Weight up for losing a war.
				modifier = {
					add = 100
					any_character_war = {
						OR = {
							AND = {
								primary_attacker = root
								attacker_war_score <= -50
							}
							AND = {
								primary_defender = root
								defender_war_score <= -50
							}
						}
					}
				}
			}
			## Raid Speed.
			1 = {
				trigger = { can_raid_trigger = yes }
				save_scope_value_as = {
					name = gift_type
					value = flag:raid_speed
				}
				# Weight up for anyone who's a smol boi.
				modifier = {
					add = 5
					highest_held_title_tier <= tier_duchy
				}
			}
		}
	}

	# Sign the documents.
	option = {
		name = bp2_yearly.0641.a

		# Which modifier do we assign?
		## Vassal Stance Courtly Opinion
		if = {
			limit = { scope:gift_type = flag:vs_courtly }
			add_character_modifier = {
				modifier = bp2_yearly_0641_vs_courtly_modifier
				years = 10
			}
		}
		## Vassal Stance Glory Hound Opinion
		if = {
			limit = { scope:gift_type = flag:vs_glory_hound }
			add_character_modifier = {
				modifier = bp2_yearly_0641_vs_glory_hound_modifier
				years = 10
			}
		}
		## Vassal Stance Parochial Opinion
		if = {
			limit = { scope:gift_type = flag:vs_parochial }
			add_character_modifier = {
				modifier = bp2_yearly_0641_vs_parochial_modifier
				years = 10
			}
		}
		## Vassal Stance Zealot Opinion
		if = {
			limit = { scope:gift_type = flag:vs_zealot }
			add_character_modifier = {
				modifier = bp2_yearly_0641_vs_zealot_modifier
				years = 10
			}
		}
		## Vassal Stance Minority Opinion
		if = {
			limit = { scope:gift_type = flag:vs_minority }
			add_character_modifier = {
				modifier = bp2_yearly_0641_vs_minority_modifier
				years = 10
			}
		}
		## Vassal Stance Baron Opinion
		if = {
			limit = { scope:gift_type = flag:vs_baron }
			add_character_modifier = {
				modifier = bp2_yearly_0641_vs_baron_modifier
				years = 10
			}
		}
		## Dynasty Opinion
		if = {
			limit = { scope:gift_type = flag:dynasty }
			add_character_modifier = {
				modifier = bp2_yearly_0641_dynasty_modifier
				years = 10
			}
		}
		## Fellow Vassal Opinion
		if = {
			limit = { scope:gift_type = flag:fellow_vassals }
			add_character_modifier = {
				modifier = bp2_yearly_0641_fellow_vassals_modifier
				years = 10
			}
		}
		## Powerful Vassal Opinion
		if = {
			limit = { scope:gift_type = flag:powerful_vassal }
			add_character_modifier = {
				modifier = bp2_yearly_0641_powerful_vassal_modifier
				years = 10
			}
		}
		## HoF Opinion
		if = {
			limit = { scope:gift_type = flag:hof }
			add_character_modifier = {
				modifier = bp2_yearly_0641_hof_modifier
				years = 10
			}
		}
		## Realm Priest Opinion
		if = {
			limit = { scope:gift_type = flag:realm_priest }
			add_character_modifier = {
				modifier = bp2_yearly_0641_realm_priest_modifier
				years = 10
			}
		}
		## Maa Maintenance Discount
		if = {
			limit = { scope:gift_type = flag:maa_maintenance }
			add_character_modifier = {
				modifier = bp2_yearly_0641_maa_maintenance_modifier
				years = 10
			}
		}
		## Cowed Vassal Bonuses
		if = {
			limit = { scope:gift_type = flag:cowed_vassal }
			add_character_modifier = {
				modifier = bp2_yearly_0641_cowed_vassal_modifier
				years = 10
			}
		}
		## War Income Mult
		if = {
			limit = { scope:gift_type = flag:war_income }
			add_character_modifier = {
				modifier = bp2_yearly_0641_war_income_modifier
				years = 10
			}
		}
		## One Free HO
		if = {
			limit = { scope:gift_type = flag:free_ho_hire }
			add_character_modifier = { modifier = next_free_ho_hire_modifier }
		}
		## Mercenary Cost Reduction
		if = {
			limit = { scope:gift_type = flag:mercenary_cost_reduction }
			add_character_modifier = {
				modifier = bp2_yearly_0641_mercenary_cost_reduction_modifier
				years = 10
			}
		}
		## Raid Speed
		if = {
			limit = { scope:gift_type = flag:raid_speed }
			add_character_modifier = {
				modifier = bp2_yearly_0641_raid_speed_modifier
				years = 10
			}
		}
		# Plus, swing the scales towards your regent.
		update_diarchy_swing_with_perspective_effect = {
			SWING = medium_sop_swing_diarch_gain
			LIEGE = root
		}

		stress_impact = {
			bossy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = -2 }
		}
	}
	
	# Chastise your regent for overstepping.
	option = {
		name = bp2_yearly.0641.b

		# Lose some opinion with them.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = insulted_opinion
			OPINION_AMOUNT = -25
		}
		# But: gain SoP swing.
		update_diarchy_swing_with_perspective_effect = {
			SWING = minor_sop_swing_liege_gain
			LIEGE = root
		}

		stress_impact = {
			bossy = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 2 }
		}
	}
	
	# Childhood Trait: disengage and let them do whatever.
	option = {
		trigger = {
			OR = {
				has_trait = rowdy
				has_trait = charming
				has_trait = curious
				has_trait = pensive
				has_trait = bossy
			}
		}
		name = {
			text = {
				first_valid = {
					# Rowdy.
					triggered_desc = {
						trigger = { has_trait = rowdy }
						desc = bp2_yearly.0641.c.rowdy
					}
					# Charming.
					triggered_desc = {
						trigger = { has_trait = charming }
						desc = bp2_yearly.0641.c.charming
					}
					# Curious.
					triggered_desc = {
						trigger = { has_trait = curious }
						desc = bp2_yearly.0641.c.curious
					}
					# Pensive.
					triggered_desc = {
						trigger = { has_trait = pensive }
						desc = bp2_yearly.0641.c.pensive
					}
					# Bossy.
					triggered_desc = {
						trigger = { has_trait = bossy }
						desc = bp2_yearly.0641.c.bossy
					}
				}
			}
		}
		flavor = bp2_yearly.0641.c.tt
		trait = rowdy
		trait = charming
		trait = curious
		trait = pensive
		trait = bossy

		# Some opinion gain for you.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = pleased_opinion
			OPINION_AMOUNT = 20
		}
		# A lil swing for the diarch.
		update_diarchy_swing_with_perspective_effect = {
			SWING = minor_sop_swing_diarch_gain
			LIEGE = root
		}
		# Plus, reduce stress.
		add_stress = medium_stress_loss

		# No stress impact, we're mostly handing out stress loss here.
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_energy = -2 }
		}
	}
}

##################################################
# Whenever You Need HerHim
# by Ewan Cowhig Croft
# 0651 - 0660
##################################################

scripted_trigger bp2_yearly_0651_opinion_compassionate_trigger = {
	has_trait = compassionate
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
}

scripted_trigger bp2_yearly_0651_opinion_loyal_trigger = {
	has_trait = loyal
	root = {
		NOR = {
			has_trait = disloyal
			has_trait = arbitrary
			has_trait = bossy
		}
	}
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
}

scripted_trigger bp2_yearly_0651_opinion_predecessor_trigger = {
	exists = scope:predecessor
	# Something's firing out of operation, so the error log'll scream without this trigger_if - mechanics all work, it's just being fussy about the variable not being there despite us already checking whether the variable is there at all, so we're dummying it up to shut the robot up.
	trigger_if = {
		limit = { exists = scope:predecessor }
		root = {
			number_of_personality_traits_in_common = {
				target = scope:predecessor
				value >= 2
			}
		}
	}
}

#	Regent makes time for your interests, be they play or poetry.
bp2_yearly.0651 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.0651.t
	desc = {
		desc = bp2_yearly.0651.desc.intro
		# What're your hobbies?
		random_valid = {
			# Rowdy
			## A new ball game you made up.
			triggered_desc = {
				trigger = { has_trait = rowdy }
				desc = bp2_yearly.0651.desc.story.rowdy.invented_game
			}
			## A tall roof you worked out how to climb.
			triggered_desc = {
				trigger = {
					has_trait = rowdy
					location_has_multi_story_buildings_trigger = { LOCATION = root.location }
				}
				desc = bp2_yearly.0651.desc.story.rowdy.climbed_roof
			}
			## A prank you played on a courtier.
			triggered_desc = {
				trigger = { has_trait = rowdy }
				desc = bp2_yearly.0651.desc.story.rowdy.prank
			}
			# Charming
			## A small poem you composed.
			triggered_desc = {
				trigger = { has_trait = charming }
				desc = bp2_yearly.0651.desc.story.charming.composed_poem
			}
			## A new friend you made.
			triggered_desc = {
				trigger = { has_trait = charming }
				desc = bp2_yearly.0651.desc.story.charming.new_friend
			}
			## A word you learnt recently.
			triggered_desc = {
				trigger = { has_trait = charming }
				desc = bp2_yearly.0651.desc.story.charming.new_word
			}
			# Curious
			## A far-away land you heard about for the first time.
			triggered_desc = {
				trigger = { has_trait = curious }
				desc = bp2_yearly.0651.desc.story.curious.distant_land
			}
			## A book someone bought you as a gift.
			triggered_desc = {
				trigger = { has_trait = curious }
				desc = bp2_yearly.0651.desc.story.curious.book_gift
			}
			## The strange bird you saw and tried to sketch.
			triggered_desc = {
				trigger = {
					has_trait = curious
					NOT = { has_trait = blind }
				}
				desc = bp2_yearly.0651.desc.story.curious.strange_bird
			}
			# Pensive
			## A letter you wrote to a distant noble.
			triggered_desc = {
				trigger = { has_trait = pensive }
				desc = bp2_yearly.0651.desc.story.pensive.distant_letter
			}
			## A strange custom you wish people here partook in.
			triggered_desc = {
				trigger = { has_trait = pensive }
				desc = bp2_yearly.0651.desc.story.pensive.foreign_custom
			}
			## The law you'd been thinking about trying to draft.
			triggered_desc = {
				trigger = { has_trait = pensive }
				desc = bp2_yearly.0651.desc.story.pensive.draft_law
			}
			# Bossy
			## A group of servants you caught slacking.
			triggered_desc = {
				trigger = { has_trait = bossy }
				desc = bp2_yearly.0651.desc.story.bossy.servants_caught
			}
			## The new court protocol you want to implement.
			triggered_desc = {
				trigger = { has_trait = bossy }
				desc = bp2_yearly.0651.desc.story.bossy.court_protocol
			}
			## A game you organised with several other children.
			triggered_desc = {
				trigger = { has_trait = bossy }
				desc = bp2_yearly.0651.desc.story.bossy.organised_game
			}
		}
		# Why do they make the effort?
		first_valid = {
			# Similarity to predecessor.
			triggered_desc = {
				trigger = {
					scope:regent = { bp2_yearly_0651_opinion_predecessor_trigger = yes }
				}
				desc = bp2_yearly.0651.desc.rationale.predecessor
			}
			# Loyalty.
			triggered_desc = {
				trigger = {
					scope:regent = { bp2_yearly_0651_opinion_loyal_trigger = yes }
				}
				desc = bp2_yearly.0651.desc.rationale.loyalty
			}
			# Compassion.
			triggered_desc = {
				trigger = {
					scope:regent = { bp2_yearly_0651_opinion_compassionate_trigger = yes }
				}
				desc = bp2_yearly.0651.desc.rationale.compassion
			}
			# You just get along.
			desc = bp2_yearly.0651.desc.rationale.fallback
		}
		desc = bp2_yearly.0651.desc.outro
	}
	theme = education
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:regent
		animation = personality_compassionate
	}
	override_background = {
		reference = relaxing_room
	}

	cooldown = { years = 5 }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		# Check root is old enough to be worth teaching.
		child_old_enough_for_responsibility_trigger = yes
		# Regent checks.
		diarch = {
			# Must be available to take the time.
			is_available_ai_adult = yes
			# And actually like you.
			## Including no nasty relationships.
			has_any_bad_relationship_with_root_trigger = no
			## And some kind of positive impetus.
			OR = {
				# Either genuinely.
				## No need for a scripted trigger here, because we won't be re-referencing it in the desc (as it acts as a fallback).
				opinion = {
					target = root
					value >= high_positive_opinion
				}
				# Because they're compassionate and make an effort.
				bp2_yearly_0651_opinion_compassionate_trigger = yes
				# They're loyal and you don't trample on that. At least, yet.
				bp2_yearly_0651_opinion_loyal_trigger = yes
				# You remind them of your predecessor.
				bp2_yearly_0651_opinion_predecessor_trigger = yes
			}
		}
	}

	immediate = {
		# Grab the regent for loc.
		diarch = {
			save_scope_as = regent
			# And, if they've got it, nab the predecessor scope too.
			if = {
				limit = { has_variable = promise_to_predecessor }
				var:promise_to_predecessor = { save_scope_as = predecessor }
			}
		}
	}

	# Earn a loyalty hook.
	option = {
		name = bp2_yearly.0651.a
		trigger = {
			scope:regent = {
				OR = {
					opinion = {
						target = root
						value >= very_high_positive_opinion
					}
					has_relation_friend = root
				}
				OR = {
					bp2_yearly_0651_opinion_loyal_trigger = yes
					AND = {
						bp2_yearly_0651_opinion_predecessor_trigger = yes
						NOR = {
							has_trait = arbitrary
							has_trait = disloyal
						}
					}
				}
			}
			can_add_hook = {
				target = scope:regent
				type = loyalty_hook
			}
		}

		# Gain a loyalty hook.
		add_hook = {
			target = scope:regent
			type = loyalty_hook
		}

		# No real stress to be gained here — everyone can accept an oath of personal loyalty.
		ai_chance = {
			# Weight up for a smart choice.
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_rationality = 1
			}
		}
	}

	# Embrace the relationship.
	option = {
		name = bp2_yearly.0651.b

		# Progress towards friendship.
		progress_towards_friend_effect = {
			REASON = friend_connected_during_regency
			CHARACTER = scope:regent
			OPINION = 40
		}

		stress_impact = {
			compassionate = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			shy = miniscule_stress_impact_loss
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 0.5
			}
		}
	}
	
	# Push them further away.
	option = {
		name = bp2_yearly.0651.c

		# Gain a bit of SoP swing.
		update_diarchy_swing_with_perspective_effect = {
			SWING = minor_sop_swing_liege_gain
			LIEGE = root
		}
		# But you hurt them a little.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = hurt_opinion
			OPINION_AMOUNT = -10
		}

		stress_impact = {
			callous = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_boldness = 2 }
		}
	}
	
	# Spend time with other people too.
	option = {
		name = bp2_yearly.0651.d

		# Some opinion with your regent.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = friendliness_opinion
			OPINION_AMOUNT = 10
		}
		# Plus, gain a bunch of opinion with the rest of your court.
		every_courtier_or_guest = {
			limit = {
				# Excepting the regent.
				NOT = { this = scope:regent }
				# And anyone who really, really hated you.
				NOR = {
					has_any_bad_relationship_with_root_trigger = yes
					opinion = {
						target = root
						value <= very_high_negative_opinion
					}
				}
			}
			custom = all_courtiers_and_guests
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 20
			}
		}

		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_energy = 2
				ai_sociability = 0.5
				ai_compassion = -0.5
			}
		}
	}
}

##################################################
# A Tool for the Wielding
# by Ewan Cowhig Croft
# 0661 - 0670
##################################################

scripted_trigger bp2_yearly_0661_valid_family_member_trigger = {
	# General validity.
	is_available_ai_adult = yes
	OR = {
		is_courtier_of = root
		any_liege_or_above = { this = root }
	}
	# Plus they must have some kind of traits that make this likely.
	OR = {
		# Characters that don't get on with the regent.
		number_of_opposing_personality_traits = {
			target = root.diarch
			value >= 2
		}
		# Characters who want access on principle.
		has_trait = impatient
		has_trait = arrogant
		# Characters who want access for political reasons.
		has_trait = deceitful
		has_trait = ambitious
		# Characters who are naturally sceptical of motivation.
		has_trait = cynical
		# Characters who don't want a child to be without family.
		has_trait = compassionate
		has_trait = family_first
	}
	# Plus they need to be able to be a little bit at odds.
	## If they like each other too much we'll sort that later, so we're just checking whether they're in range of disliking each other atm.
	reverse_opinion = {
		target = root.diarch
		value <= medium_positive_opinion
	}
	NOT = {
		has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root.diarch }
	}
}

#	Regent quarrels with your family about access to you.
bp2_yearly.0661 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.0661.t
	desc = bp2_yearly.0661.desc
	theme = education
	left_portrait = {
		character = scope:regent
		animation = dismissal
	}
	right_portrait = {
		character = scope:offended_family
		animation = rage
	}
	lower_left_portrait = root
	override_background = { reference = corridor_day }

	cooldown = { years = 5 }

	trigger = {
		# DLC check.
		has_bp2_dlc_trigger = yes
		# Standard checks.
		is_available_child = yes
		is_landed = yes
		character_has_regency_diarchy_trigger = yes
		# Check root is old enough to understand the argument.
		child_not_infant_trigger = yes
		# Regent isn't a player _unless_ they're both players.
		filter_players_for_agency_trigger = yes
		# Plus, there should be a suitable family member around.
		any_close_or_extended_family_member = { bp2_yearly_0661_valid_family_member_trigger = yes }
		# Regent checks.
		diarch = {
			# Must be available to take the time.
			is_available_ai_adult = yes
			# Finally, check loyalty.
			OR = {
				## Selfish & situational diarchs constrict all access (since access here requires someone that they don't like).
				diarch_loyalty <= diarch_loyalty_visibly_disloyal_threshold
				diarch_has_situational_loyalty_trigger = yes
				## Selfless diarchs only constrict access against selfish family.
				AND = {
					diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold
					any_close_or_extended_family_member = {
						bp2_yearly_0661_valid_family_member_trigger = yes
						diarch_loyalty <= diarch_loyalty_visibly_disloyal_threshold
					}
				}
			}
		}
	}

	immediate = {
		# Let's set up some scopes!
		## First, we want scope:regent for loc.
		diarch = { save_scope_as = regent }
		## Ok, now sort us a scope:offended_family.
		### Grab every possible candidate.
		#### Selfless diarchs have slightly different criteria.
		if = {
			limit = { scope:regent.diarch_loyalty >= diarch_loyalty_visibly_loyal_threshold }
			every_close_or_extended_family_member = {
				limit = {
					bp2_yearly_0661_valid_family_member_trigger = yes
					diarch_loyalty <= diarch_loyalty_visibly_disloyal_threshold
				}
				add_to_list = offended_candidates_pre_filter_list
			}
		}
		#### Otherwise, do it the normal way.
		else = {
			every_close_or_extended_family_member = {
				limit = { bp2_yearly_0661_valid_family_member_trigger = yes }
				add_to_list = offended_candidates_pre_filter_list
			}
		}
		### Now we have to try and get characters with pre-existing beef.
		#### So look for valid candidates first...
		if = {
			limit = {
				any_in_list = {
					list = offended_candidates_pre_filter_list
					has_antipathy_with_diarch_trigger = yes
				}
			}
			every_in_list = {
				limit = { has_antipathy_with_diarch_trigger = yes }
				list = offended_candidates_pre_filter_list
				add_to_list = offended_candidates_list
			}
		}
		### ... bug if we don't have any, take the whole list and we'll sort an argument post-hoc.
		else = {
			every_in_list = {
				list = offended_candidates_pre_filter_list
				add_to_list = offended_candidates_list
			}
			save_scope_as = inspire_beef_afterwards_needed
		}
		### Next, we filter down to find the most interesting.
		ordered_in_list = {
			list = offended_candidates_list
			order_by = {
				# Tier gives us a nice base.
				value = highest_held_title_tier
				## Boost it a little so we can manipulate it more easily later.
				# Up-weight close family.
				add = 20
				# _Then_ up-weight by the triggers we used above 
				## Characters that don't get on with the regent.
				if = {
					limit = {
						number_of_opposing_personality_traits = {
							target = root.diarch
							value >= 1
						}
					}
					add = 1
					# And a few more for more disagreements.
					## 2.
					if = {
						limit = {
							number_of_opposing_personality_traits = {
								target = root.diarch
								value >= 2
							}
						}
						add = 1
					}
					## 3.
					if = {
						limit = {
							number_of_opposing_personality_traits = {
								target = root.diarch
								value >= 3
							}
						}
						add = 1
					}
				}
				## Characters who want access on principle.
				if = {
					limit = { has_trait = impatient }
					add = 1
				}
				if = {
					limit = { has_trait = arrogant }
					add = 2
				}
				## Characters who want access for political reasons.
				if = {
					limit = { has_trait = deceitful }
					add = 1
				}
				if = {
					limit = { has_trait = ambitious }
					add = 2
				}
				## Characters who are naturally sceptical of motivation.
				if = {
					limit = { has_trait = cynical }
					add = 1
				}
				## Characters who don't want a child to be without family.
				if = {
					limit = { has_trait = compassionate }
					add = 2
				}
				if = {
					limit = { has_trait = family_first }
					add = 1
				}
			}
			save_scope_as = offended_family
		}
		# Now, set them at loggerheads.
		scope:offended_family = {
			# Including a rivalry.
			progress_towards_rival_effect = {
				REASON = rival_regent_denied_access_to_family
				CHARACTER = scope:regent
				OPINION = default_rival_opinion
			}
			# And, if we missed it previously, our starting arguments.
			if = {
				limit = { exists = scope:inspire_beef_afterwards_needed }
				hidden_effect = {
					add_opinion = {
						target = scope:regent
						modifier = unfriendly_opinion
						opinion = -30
					}
					reverse_add_opinion = {
						target = scope:regent
						modifier = unfriendly_opinion
						opinion = -30
					}
				}
			}
		}
	}

	# Side with your regent.
	option = {
		name = bp2_yearly.0661.a

		# Gain substantial opinion with them.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = gloating_opinion
			OPINION_AMOUNT = 40
		}
		# Plus they swing the scales a little bit.
		update_diarchy_swing_with_perspective_effect = {
			SWING = miniscule_sop_swing_diarch_gain
			LIEGE = root
		}
		# And you upset your family member.
		reverse_add_opinion = {
			modifier = estranged_opinion
			target = scope:offended_family
			opinion = -20
		}

		stress_impact = {
			trusting = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
			opinion_modifier = { opinion_target = scope:regent }
		}
	}
	
	# Side with your family member.
	option = {
		name = bp2_yearly.0661.b


		# Gain substantial opinion with them.
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:offended_family
			opinion = 40
		}
		# Plus a lil hook, if applicable.
		add_favour_hook_if_possible_simple_effect = { TARGET = scope:offended_family }
		# Plus they swing the scales a little bit.
		update_diarchy_swing_with_perspective_effect = {
			SWING = miniscule_sop_swing_liege_gain
			LIEGE = root
		}
		# And you upset scope:regent.
		raise_diarch_opinion_with_loyalty_update_effect = {
			OPINION_TYPE = annoyed_opinion
			OPINION_AMOUNT = -30
		}

		stress_impact = {
			trusting = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = { ai_sociability = 1 }
			opinion_modifier = { opinion_target = scope:offended_family }
		}
	}
	
	# Childhood Trait: ignore the debate and make yourself scarce.
	option = {
		name = {
			text = {
				first_valid = {
					# Rowdy.
					triggered_desc = {
						trigger = { has_trait = rowdy }
						desc = bp2_yearly.0661.c.rowdy
					}
					# Charming.
					triggered_desc = {
						trigger = { has_trait = charming }
						desc = bp2_yearly.0661.c.charming
					}
					# Curious.
					triggered_desc = {
						trigger = { has_trait = curious }
						desc = bp2_yearly.0661.c.curious
					}
					# Pensive.
					triggered_desc = {
						trigger = { has_trait = pensive }
						desc = bp2_yearly.0661.c.pensive
					}
					# Bossy.
					triggered_desc = {
						trigger = { has_trait = bossy }
						desc = bp2_yearly.0661.c.bossy
					}
				}
			}
		}
		trigger = {
			OR = {
				has_trait = rowdy
				has_trait = charming
				has_trait = curious
				has_trait = pensive
				has_trait = bossy
			}
		}

		# Consolation prestige.
		add_prestige = minor_prestige_gain

		stress_impact = {
			paranoid = minor_stress_impact_loss
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_sociability = -2
			}
		}
	}
}
