﻿namespace = bp2_yearly
####
# bp2_yearly.1000 - Parent/Guardian: Your child/ward walks in on you performing your stress trait
# bp2_yearly.1001 - Follow-up; the child is mimicking your stress behavior
# bp2_yearly.1005 - Child: You notice your parent/guardian performing a stress trait
#
# bp2_yearly.1010 - Parent/Guardian: Your child gives you a hug
# bp2_yearly.1015 - Parent/Guardian: Your child/ward found a pouch of gold while exploring
# bp2_yearly.1020 - Parent/Guardian: Your child/ward has found a secret in court
#
# bp2_yearly.1030 - Parent: Your child does not have the same educational trait as you. Change?
# bp2_yearly.1035 - Parent/Guardian: Your child/ward has a rock collection
# bp2_yearly.1040 - Parent/Guardian: Your child/ward has a text about martial arts
# bp2_yearly.1045 - Parent/Guardian: There is a brawl among some children
#
#################
## Event Chain ##
## The Builder ##
## 1050 - 1072 ##
#################
# bp2_yearly.1050 - The tide/sandstorm is ruining your sandcastle!
# bp2_yearly.1051 - Follow-up: Curse you, tide!
# bp2_yearly.1055 - You are challenged to a den-building competition
# bp2_yearly.1056 - Follow-up: Things went down in the woods
# bp2_yearly.1060 - Appreciate the architecture of your capital
# bp2_yearly.1061 - Follow-up: You spend the day with WhatsTheirFace
# bp2_yearly.1065 - Your input is desired on the next building target
# bp2_yearly.1070 - All of our efforts have culminated into _this_
# bp2_yearly.1071 - Follow-up: Get the sweet sweet loo... I mean, sweet sweet effects!
# bp2_yearly.1072 - Clean up: You dun messed up, son


scripted_trigger bp2_yearly_1000_is_appropriate_child = {
	age > 4
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	NOT = { has_variable = witnessed_trait }
	OR = {
		AND = {
			root = { has_trait = drunkard }
			NOT = { has_trait = drunkard }
		}
		AND = {
			root = { has_trait = reclusive }
			NOT = { has_trait = reclusive }
		}
		AND = {
			root = { has_trait = irritable }
			NOT = { has_trait = irritable }
		}
		AND = {
			root = { has_trait = flagellant }
			NOT = { has_trait = flagellant }
		}
		AND = {
			root = { has_trait = profligate }
			NOT = { has_trait = profligate }
		}
		AND = {
			root = { has_trait = improvident }
			NOT = { has_trait = improvident }
		}
		AND = {
			root = { has_trait = comfort_eater }
			NOT = { has_trait = comfort_eater }
		}
		AND = {
			root = { has_trait = inappetetic }
			NOT = { has_trait = inappetetic }
		}
		AND = {
			root = { has_trait = journaller }
			NOT = { has_trait = journaller }
		}
		AND = {
			root = { has_trait = hashishiyah }
			NOT = { has_trait = hashishiyah }
			any_courtier_or_guest = { 
				is_available_adult = yes
				has_any_bad_relationship_with_root_trigger = no
			}
		}
		AND = {
			NOT = { has_trait = confider }
			root = {
				has_trait = confider
				any_relation = {
					type = friend
					is_available = yes
					location = root.location
				}
			}
		}
		AND = {
			root = {
				has_trait = athletic 
				NOT = { has_trait = one_legged }
			}
			NOT = {
				has_trait = athletic
				has_trait = one_legged
			}
		}
	}
}

scripted_effect bp2_yearly_1000_award_trait_effect = {
	if = {
		limit = { exists = scope:triggered_trait }
		this = {
			switch = {
				trigger = scope:triggered_trait
				flag:drunkard = { add_trait = drunkard }
				flag:hashishiyah = { add_trait = hashishiyah }
				flag:reclusive = { add_trait = reclusive }
				flag:irritable = { add_trait = irritable }
				flag:flagellant = { add_trait = flagellant }
				flag:profligate = { add_trait = profligate }
				flag:improvident = { add_trait = improvident }
				flag:contrite = { add_trait = contrite }
				flag:comfort_eater = { add_trait = comfort_eater }
				flag:inappetetic = { add_trait = inappetetic }
				flag:journaller = { add_trait = journaller }
				flag:confider = { add_trait = confider }
				flag:athletic = { add_trait = athletic }
			}
		}
	}
	else_if = {
		limit = { exists = var:witnessed_trait }
		this = {
			switch = {
				trigger = var:witnessed_trait
				flag:drunkard = { add_trait = drunkard }
				flag:hashishiyah = { add_trait = hashishiyah }
				flag:reclusive = { add_trait = reclusive }
				flag:irritable = { add_trait = irritable }
				flag:flagellant = { add_trait = flagellant }
				flag:profligate = { add_trait = profligate }
				flag:improvident = { add_trait = improvident }
				flag:contrite = { add_trait = contrite }
				flag:comfort_eater = { add_trait = comfort_eater }
				flag:inappetetic = { add_trait = inappetetic }
				flag:journaller = { add_trait = journaller }
				flag:confider = { add_trait = confider }
				flag:athletic = { add_trait = athletic }
			}
		}
	}
}

#Parent/Guardian: Your child/ward walks in on you performing your stress trait
bp2_yearly.1000 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1000.t
	desc = {
		#Hoppsan
		first_valid = {
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:drunkard }
				desc = bp2_yearly.1000.desc_drunkard
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:hashishiyah }
				desc = bp2_yearly.1000.desc_hashishiyah
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:reclusive }
				desc = bp2_yearly.1000.desc_reclusive
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:irritable }
				desc = bp2_yearly.1000.desc_irritable
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:flagellant }
				desc = bp2_yearly.1000.desc_flagellant
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:profligate }
				desc = bp2_yearly.1000.desc_profligate
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:improvident }
				desc = bp2_yearly.1000.desc_improvident
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:contrite }
				desc = bp2_yearly.1000.desc_contrite
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:comfort_eater }
				desc = bp2_yearly.1000.desc_comfort_eater
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:inappetetic }
				desc = bp2_yearly.1000.desc_inappetetic
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:journaller }
				desc = bp2_yearly.1000.desc_journaller
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:confider }
				desc = bp2_yearly.1000.desc_confider
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:athletic }
				desc = bp2_yearly.1000.desc_athletic
			}
		}
		#Is it a *good* stress trait or a *bad* stress trait?
		first_valid = {
			#Hmm, this isn't _great_
			triggered_desc = {
				trigger = {
					OR = {
						scope:triggered_trait = flag:drunkard
						scope:triggered_trait = flag:hashishiyah
						scope:triggered_trait = flag:irritable
						scope:triggered_trait = flag:flagellant
						scope:triggered_trait = flag:comfort_eater
					}
				}
				desc = bp2_yearly.1000.outro_bad
			}
			#Meh, it's fine
			desc = bp2_yearly.1000.outro
		}
	}
	theme = family
	#Let's be in a couple of different places
	override_background = { 
		trigger = { 
			OR = {
				scope:triggered_trait = flag:drunkard
				scope:triggered_trait = flag:irritable
				scope:triggered_trait = flag:contrite
				scope:triggered_trait = flag:inappetetic
				scope:triggered_trait = flag:confider
			}
		}
		reference = feast_event
	}
	override_background = { 
		trigger = {
			OR = {
				scope:triggered_trait = flag:hashishiyah
				scope:triggered_trait = flag:comfort_eater
				scope:triggered_trait = flag:journaller
			}
		}
		reference = relaxing_room
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:reclusive }
		reference = study
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:flagellant }
		reference = dungeon
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:profligate }
		reference = market
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:athletic }
		reference = courtyard
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:improvident }
		reference = temple
	}
	#Fallback
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:drunkard }
			animation = drink_goblet
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:improvident }
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = { 
				OR = {
					scope:triggered_trait = flag:irritable
					AND = {
						has_trait = eccentric
						scope:triggered_trait = flag:reclusive
					}
				}
			}
			animation = rage
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:reclusive }
			animation = personality_cynical
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:journaller }
			animation = reading
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:flagellant }
			animation = pain
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:contrite }
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:confider }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:athletic }
			animation = ecstasy
		}
		triggered_animation = {
			trigger = { 
				scope:triggered_trait = flag:profligate
				has_trait = eccentric
			}
			animation = steward
		}
		triggered_animation = {
			trigger = { 
				OR = {
					has_trait = eccentric
					has_trait = lunatic
					scope:triggered_trait = flag:hashishiyah
				}
			}
			animation = personality_irrational
		}
		animation = stress
	}
	right_portrait = {
		character = scope:appropriate_child
		triggered_animation = {
			trigger = {
				OR = {
					scope:triggered_trait = flag:drunkard
					scope:triggered_trait = flag:hashishiyah
					scope:triggered_trait = flag:irritable
					scope:triggered_trait = flag:flagellant
					scope:triggered_trait = flag:comfort_eater
				}
			}
			animation = shock
		}
		animation = thinking
	}
	lower_left_portrait = {
		trigger = { exists = scope:portrait_to_display }
		character = scope:portrait_to_display
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_landed_or_landless_administrative = yes
		is_ai = no
		#Longer cooldown if you removed a stress trait
		NOT = { has_character_flag = bp2_yearly_1001_removed_stress_trait }
		#Check if we have a stress trait; and if an appropriate child does not have the stress trait (so it's transferrable)
		OR = {
			any_child = {
				bp2_yearly_1000_is_appropriate_child = yes
			}
			any_relation = {
				type = ward
				bp2_yearly_1000_is_appropriate_child = yes
			}
			any_warden_hostage = {
				opinion = {
					target = root
					value >= low_negative_opinion
				}
				bp2_yearly_1000_is_appropriate_child = yes
			}
		}
	}
	weight_multiplier = {
		base = 0
		#The more stress traits; the higher chance
		modifier = {
			has_trait = drunkard
			add = 1
		}
		modifier = {
			has_trait = hashishiyah
			add = 1
		}
		modifier = {
			has_trait = reclusive
			add = 1
		}
		modifier = {
			has_trait = irritable
			add = 1
		}
		modifier = {
			has_trait = flagellant
			add = 1
		}
		modifier = {
			has_trait = profligate
			add = 1
		}
		modifier = {
			has_trait = improvident
			add = 1
		}
		modifier = {
			has_trait = contrite
			add = 1
		}
		modifier = {
			has_trait = comfort_eater
			add = 1
		}
		modifier = {
			has_trait = inappetetic
			add = 1
		}
		modifier = {
			has_trait = journaller
			add = 1
		}
		modifier = {
			has_trait = confider
			add = 1
		}
		modifier = {
			has_trait = athletic
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_stress"
		#Your own children first
		if = {
			limit = {
				any_child = {
					bp2_yearly_1000_is_appropriate_child = yes
				}
			}
			random_child = {
				#A child you care about
				limit = { 
					opinion = {
						target = root
						value >= low_positive_opinion
					}
					bp2_yearly_1000_is_appropriate_child = yes 
				}
				#Otherwise pick whoever
				alternative_limit = { bp2_yearly_1000_is_appropriate_child = yes }
				save_scope_as = appropriate_child
			}
		}
		#Otherwise a ward
		else_if = {
			limit = {
				any_relation = {
					type = ward
					bp2_yearly_1000_is_appropriate_child = yes
				}
			}
			random_relation = {
				type = ward
				#A child you care about
				limit = {
					opinion = {
						target = root
						value >= low_positive_opinion
					}
					bp2_yearly_1000_is_appropriate_child = yes
				}
				#Otherwise pick whoever
				alternative_limit = { bp2_yearly_1000_is_appropriate_child = yes }
				save_scope_as = appropriate_child
			}
		}
		else_if = {
			limit = {
				any_warden_hostage = {
					opinion = {
						target = root
						value >= low_negative_opinion
					}
					bp2_yearly_1000_is_appropriate_child = yes
				}
			}
			random_warden_hostage = {
				limit = {
					opinion = {
						target = root
						value >= low_negative_opinion
					}
					bp2_yearly_1000_is_appropriate_child = yes
				}
				save_scope_as = appropriate_child
			}
		}
		random_list = {
			#Set a trait to work from and remember it; weights what stress coping events the child may get later in life
			1 = {
				trigger = { has_trait = drunkard }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:drunkard
					}
				}
			}
			1 = {
				trigger = { has_trait = hashishiyah }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:hashishiyah
					}
				}
			}
			1 = {
				trigger = { has_trait = reclusive }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:reclusive
					}
				}
			}
			1 = {
				trigger = { has_trait = irritable }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:irritable
					}
				}
				random_dummy_gender_effect = yes
			}
			1 = {
				trigger = { has_trait = flagellant }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:flagellant
					}
				}
				add_character_flag = should_be_topless
			}
			1 = {
				trigger = { has_trait = profligate }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:profligate
					}
				}
				random_dummy_gender_effect = yes
			}
			1 = {
				trigger = { has_trait = improvident }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:improvident
					}
				}
			}
			1 = {
				trigger = { 
					has_trait = contrite
					any_courtier_or_guest = { 
						is_available_adult = yes 
						has_any_bad_relationship_with_root_trigger = no
					}
				}
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:contrite
					}
				}
				random_courtier_or_guest = { 
					limit = { 
						is_available_adult = yes 
						has_any_bad_relationship_with_root_trigger = no
					}
					save_scope_as = other_guest
					save_scope_as = portrait_to_display
				}
			}
			1 = {
				trigger = { has_trait = comfort_eater }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:comfort_eater
					}
					set_favorite_treat_effect = yes
				}
				set_favorite_treat_effect = yes
			}
			1 = {
				trigger = { has_trait = inappetetic }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:inappetetic
					}
				}
			}
			1 = {
				trigger = { has_trait = journaller }
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:journaller
					}
				}
			}
			1 = {
				trigger = { 
					has_trait = confider
					any_relation = {
						type = friend
						is_available = yes
						location = root.location
					}
				}
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:confider
					}
				}
				random_relation = {
					type = friend
					limit = {
						is_available = yes
						location = root.location
					}
					save_scope_as = confider_friend
					save_scope_as = portrait_to_display
				}
			}
			1 = {
				trigger = { 
					has_trait = athletic
					NOT = { has_trait = one_legged }
				}
				scope:appropriate_child = {
					set_variable = {
						name = witnessed_trait
						value = flag:athletic
					}
				}
				if = {
					limit = { is_male = yes } #Yes, this is a boring restriction but it's the current lense for how things worked back then, I suspect
					add_character_flag = should_be_topless
				}
			}
		}
		#To save us some script lines in the rest of the event, let's refer to a scope instead
		scope:appropriate_child = {
			if = {
				limit = { exists = var:witnessed_trait }
				switch = {
					trigger = scope:appropriate_child.var:witnessed_trait
					flag:drunkard = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:drunkard
						}
					}
					flag:hashishiyah = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:hashishiyah
						}
					}
					flag:reclusive = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:reclusive
						}
					}
					flag:irritable = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:irritable
						}
					}
					flag:flagellant = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:flagellant
						}
					}
					flag:profligate = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:profligate
						}
					}
					flag:improvident = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:improvident
						}
					}
					flag:contrite = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:contrite
						}
					}
					flag:comfort_eater = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:comfort_eater
						}
					}
					flag:inappetetic = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:inappetetic
						}
					}
					flag:journaller = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:journaller
						}
					}
					flag:confider = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:confider
						}
					}
					flag:athletic = { 
						save_scope_value_as = {
							name = triggered_trait
							value = flag:athletic
						}
					}
				}
			}
		}
		if = {
			limit = {
				scope:triggered_trait = flag:hashishiyah
			}
			add_character_flag = is_naked
		}
	}
	#Hmm.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							OR = {
								scope:triggered_trait = flag:drunkard
								scope:triggered_trait = flag:hashishiyah
								scope:triggered_trait = flag:irritable
								scope:triggered_trait = flag:flagellant
								scope:triggered_trait = flag:profligate
								scope:triggered_trait = flag:comfort_eater
								scope:triggered_trait = flag:inappetetic
							}
						}
						desc = bp2_yearly.1000.a
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:reclusive }
						desc =  bp2_yearly.1000.b_reclusive
					}
					desc = bp2_yearly.1000.a_good
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							scope:triggered_trait = flag:drunkard
							scope:triggered_trait = flag:hashishiyah
							scope:triggered_trait = flag:reclusive
							scope:triggered_trait = flag:irritable
							scope:triggered_trait = flag:flagellant
							scope:triggered_trait = flag:profligate
							scope:triggered_trait = flag:improvident
						}
					}
					desc = bp2_yearly.1000.a.flavor
				}
				desc = bp2_yearly.1000.a.flavor_good
			}
		}
		custom_tooltip = bp2_yearly.1000.a.tt
		#We're not too concerned that we got caught doing these; enjoy the stress loss
		if = {
			limit = {
				OR = {
					scope:triggered_trait = flag:reclusive
					scope:triggered_trait = flag:improvident
					scope:triggered_trait = flag:contrite
					scope:triggered_trait = flag:journaller
					scope:triggered_trait = flag:confider
					scope:triggered_trait = flag:athletic
				}
			}
			stress_impact = {
				base = miniscule_stress_impact_loss
			}
		}
		trigger_event = {
			days = 5
			id = bp2_yearly.1001
		}
		#AI won't be getting this event
	}
	#Toot-toot, stress trait schmesh trait...
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:drunkard }
						desc = bp2_yearly.1000.b_drunkard
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:contrite }
						desc = bp2_yearly.1000.b_contrite
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:inappetetic }
						desc = bp2_yearly.1000.b_inappetetic
					}
					triggered_desc = {
						trigger = { 
							scope:triggered_trait = flag:confider 

						}
						desc = bp2_yearly.1000.b_us
					}
					triggered_desc = {
						trigger = {
							OR = {
								scope:triggered_trait = flag:reclusive
								scope:triggered_trait = flag:irritable
							}
						}
						desc = bp2_yearly.1000.b_agitated
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:hashishiyah }
						desc =  bp2_yearly.1000.b_hashishiyah
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:flagellant }
						desc =  bp2_yearly.1000.b_flagellant
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:improvident }
						desc =  bp2_yearly.1000.b_improvident
					}
					triggered_desc = {
						trigger = { scope:triggered_trait = flag:athletic }
						desc =  bp2_yearly.1000.b_athletic
					}
					desc = bp2_yearly.1000.b
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							scope:triggered_trait = flag:reclusive
							scope:triggered_trait = flag:irritable
						}
					}
					desc = bp2_yearly.1000.b.flavor_agitated
				}
				triggered_desc = {
					trigger = { scope:triggered_trait = flag:contrite }
					desc = bp2_yearly.1000.b.flavor_contrite
				}
				triggered_desc = {
					trigger = { scope:triggered_trait = flag:inappetetic }
					desc = bp2_yearly.1000.b.flavor_inappetetic
				}
				triggered_desc = {
					trigger = { scope:triggered_trait = flag:confider }
					desc = bp2_yearly.1000.b.flavor_confider
				}
				triggered_desc = {
					trigger = { scope:triggered_trait = flag:flagellant }
					desc = bp2_yearly.1000.b.flavor_flagellant
				}
				triggered_desc = {
					trigger = { scope:triggered_trait = flag:improvident }
					desc = bp2_yearly.1000.b.flavor_improvident
				}
				triggered_desc = {
					trigger = { scope:triggered_trait = flag:athletic }
					desc = bp2_yearly.1000.b.flavor_athletic
				}
				desc = bp2_yearly.1000.b.flavor
			}
		}
		trigger = { has_trait = eccentric }
		scope:appropriate_child = { bp2_yearly_1000_award_trait_effect = yes }
		#If it's not a chummy stress trait, let's lash out...
		if = {
			limit = {
				OR = {
					scope:triggered_trait = flag:reclusive
					scope:triggered_trait = flag:irritable
				}
			}
			reverse_add_opinion = {
				target = scope:appropriate_child
				modifier = stress_lashed_out_opinion
				opinion = -40
			}
			stress_impact = {
				base = major_stress_impact_loss
			}
		}
		#Otherwise indulge them
		else = {
			reverse_add_opinion = {
				target = scope:appropriate_child
				modifier = teaching_moment_opinion
				opinion = 25
			}
			#More stress relief trade-off for worse inflicted stress traits
			if = {
				limit = {
					OR = {
						scope:triggered_trait = flag:journaller
						scope:triggered_trait = flag:confider
						scope:triggered_trait = flag:athletic
					}
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			else_if = {
				limit = {
					OR = {
						scope:triggered_trait = flag:improvident
						scope:triggered_trait = flag:contrite
					}
				}
				stress_impact = {
					base = medium_stress_impact_loss
				}
			}
			else = {
				stress_impact = {
					base = major_stress_impact_loss
				}
			}
		}
		#AI won't be getting this event
	}
	after = {
		if = {
			limit = { has_character_flag = should_be_topless }
			remove_character_flag = should_be_topless
		}
		if = {
			limit = { has_character_flag = is_naked }
			remove_character_flag = is_naked
		}
	}
}

#Follow-up; the child is mimicking your stress behavior
bp2_yearly.1001 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1001.t
	desc = {
		#Hoppsan
		first_valid = {
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:drunkard }
				desc = bp2_yearly.1001.desc_drunkard
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:hashishiyah }
				desc = bp2_yearly.1001.desc_hashishiyah
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:reclusive }
				desc = bp2_yearly.1001.desc_reclusive
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:irritable }
				desc = bp2_yearly.1001.desc_irritable
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:flagellant }
				desc = bp2_yearly.1001.desc_flagellant
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:profligate }
				desc = bp2_yearly.1001.desc_profligate
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:improvident }
				desc = bp2_yearly.1001.desc_improvident
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:contrite }
				desc = bp2_yearly.1001.desc_contrite
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:comfort_eater }
				desc = bp2_yearly.1001.desc_comfort_eater
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:inappetetic }
				desc = bp2_yearly.1001.desc_inappetetic
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:journaller }
				desc = bp2_yearly.1001.desc_journaller
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:confider }
				desc = bp2_yearly.1001.desc_confider
			}
			triggered_desc = {
				trigger = { scope:triggered_trait = flag:athletic }
				desc = bp2_yearly.1001.desc_athletic
			}
		}
		first_valid = {
			#Hmm, this isn't _great_
			triggered_desc = {
				trigger = {
					OR = {
						scope:triggered_trait = flag:drunkard
						scope:triggered_trait = flag:hashishiyah
						scope:triggered_trait = flag:reclusive
						scope:triggered_trait = flag:irritable
						scope:triggered_trait = flag:flagellant
						scope:triggered_trait = flag:profligate
						scope:triggered_trait = flag:comfort_eater
						scope:triggered_trait = flag:inappetetic
						scope:triggered_trait = flag:improvident
						scope:triggered_trait = flag:contrite
					}
				}
				desc = bp2_yearly.1001.outro_bad
			}
		}
	}
	theme = family
	#Let's be in a couple of different places
	override_background = { 
		trigger = { 
			OR = {
				scope:triggered_trait = flag:irritable
				scope:triggered_trait = flag:inappetetic
			}
		}
		reference = feast_event
	}
	override_background = { 
		trigger = {
			OR = {
				scope:triggered_trait = flag:hashishiyah
				scope:triggered_trait = flag:comfort_eater
			}
		}
		reference = study
	}
	override_background = { 
		trigger = {
			OR = {
				scope:triggered_trait = flag:reclusive
				scope:triggered_trait = flag:journaller
			}
		}
		reference = bp2_nursery
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:flagellant }
		reference = dungeon
	}
	override_background = { 
		trigger = { 
			OR = {
				scope:triggered_trait = flag:athletic
				scope:triggered_trait = flag:contrite
			}
		}
		reference = courtyard
	}
	override_background = { 
		trigger = { scope:triggered_trait = flag:drunkard }
		reference = bp1_wine_cellar
	}
	override_background = { 
		trigger = { 
			OR = {
				scope:triggered_trait = flag:profligate
				scope:triggered_trait = flag:improvident
				scope:triggered_trait = flag:confider 
			}
		}
		reference = market
	}
	#Fallback
	override_background = { reference = throne_room }
	left_portrait = {
		character = scope:appropriate_child
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:drunkard }
			animation = sick
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:improvident }
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:irritable }
			animation = rage
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:reclusive }
			animation = anger
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:journaller }
			animation = thinking
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:flagellant }
			animation = pain
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:hashishiyah }
			animation = personality_irrational
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:contrite }
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:confider }
			animation = admiration
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:comfort_eater }
			animation = shame
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:profligate }
			animation = steward
		}
		triggered_animation = {
			trigger = { scope:triggered_trait = flag:athletic }
			animation = ecstasy
		}
		animation = stress
	}
	right_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					scope:triggered_trait = flag:drunkard
					scope:triggered_trait = flag:hashishiyah
					scope:triggered_trait = flag:reclusive
					scope:triggered_trait = flag:flagellant
					scope:triggered_trait = flag:comfort_eater
				}
			}
			animation = shock
		}
		triggered_animation = {
			trigger = {
				OR = {
					scope:triggered_trait = flag:profligate
					scope:triggered_trait = flag:journaller
					scope:triggered_trait = flag:confider
					scope:triggered_trait = flag:athletic
					scope:triggered_trait = flag:improvident
				}
			}
			animation = thinking
		}
		animation = eavesdrop
	}
	immediate = {
		#play_music_cue = "mx_cue_stress"
		if = {
			limit = { scope:triggered_trait = flag:contrite }
			random_dummy_gender_effect = yes
		}
		scope:appropriate_child = {
			if = {
				limit = { 
					scope:triggered_trait = flag:athletic
					is_male = yes
				}
				add_character_flag = should_be_topless
			}
		}
	}
	#Teach them better
	option = {
		name = bp2_yearly.1001.a
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							scope:triggered_trait = flag:journaller
							scope:triggered_trait = flag:confider
							scope:triggered_trait = flag:athletic
						}
					}
					desc = bp2_yearly.1001.a.flavor_good
				}
				desc = bp2_yearly.1001.a.flavor
			}
		}
		#These traits are net positive
		if = {
			limit = {
				OR = {
					scope:triggered_trait = flag:journaller
					scope:triggered_trait = flag:confider
					scope:triggered_trait = flag:athletic
				}
			}
			duel = {
				skill = learning
				value = average_skill_rating
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					opinion_modifier = {
						opinion_target = scope:appropriate_child
						multiplier = 3
						step = 5
					}
					modifier = {
						has_trait = family_first
						add = 25
					}
					modifier = {
						has_trait = diplomat
						add = 10
					}
					desc = bp2_yearly.1001.a.trait.desc
					send_interface_toast = {
						type = event_toast_effect_good
						title = bp2_yearly.1001.a.trait.t
						left_icon = root
						right_icon = scope:appropriate_child
						scope:appropriate_child = { bp2_yearly_1000_award_trait_effect = yes }
						reverse_add_opinion = {
							target = scope:appropriate_child
							modifier = teaching_moment_opinion
							opinion = 25
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = bp2_yearly.1001.a.no_trait.desc
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = bp2_yearly.1001.a.no_trait.t
						left_icon = root
						right_icon = scope:appropriate_child
						reverse_add_opinion = {
							target = scope:appropriate_child
							modifier = teaching_moment_opinion
							opinion = 25
						}
					}
				}
			}
		}
		#These traits are to be avoided
		else = {
			duel = {
				skill = learning
				value = average_skill_rating
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					opinion_modifier = {
						opinion_target = scope:appropriate_child
						multiplier = 2
						step = 5
					}
					modifier = {
						has_trait = family_first
						add = 25
					}
					modifier = {
						has_trait = diplomat
						add = 10
					}
					desc = bp2_yearly.1001.a.no_trait.desc
					send_interface_toast = {
						type = event_toast_effect_good
						title = bp2_yearly.1001.a.no_trait.t
						left_icon = root
						right_icon = scope:appropriate_child
						reverse_add_opinion = {
							target = scope:appropriate_child
							modifier = teaching_moment_opinion
							opinion = 25
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = 5
					}
					desc = bp2_yearly.1001.a.trait.desc
					send_interface_toast = {
						type = event_toast_effect_bad
						title = bp2_yearly.1001.a.trait.t
						left_icon = root
						right_icon = scope:appropriate_child
						scope:appropriate_child = { bp2_yearly_1000_award_trait_effect = yes }
					}
				}
			}
		}
		#AI won't be getting this event
	}
	#I should change my ways
	option = {
		name = bp2_yearly.1001.b
		flavor = bp2_yearly.1001.b.flavor
		#Doesn't make sense to lose these traits
		trigger = {
			NOR = {
				scope:triggered_trait = flag:journaller
				scope:triggered_trait = flag:confider
				scope:triggered_trait = flag:athletic
			}
		}
		switch = {
			trigger = scope:triggered_trait
			flag:drunkard = { remove_trait = drunkard }
			flag:hashishiyah = { remove_trait = hashishiyah }
			flag:reclusive = { remove_trait = reclusive }
			flag:irritable = { remove_trait = irritable }
			flag:flagellant = { remove_trait = flagellant }
			flag:profligate = { remove_trait = profligate }
			flag:improvident = { remove_trait = improvident }
			flag:contrite = { remove_trait = contrite }
			flag:comfort_eater = { remove_trait = comfort_eater }
			flag:inappetetic = { remove_trait = inappetetic }
		}
		#Longer cooldown if you actually changed your ways
		add_character_flag = {
			flag = bp2_yearly_1001_removed_stress_trait
			years = 20
		}
		#You're stressed about losing your outlet; but also proud about changing your ways
		add_character_modifier = {
			modifier = changed_ways_modifier
			years = 10
		}
		#Massive gain
		stress_impact = {
			base = major_stress_impact_gain
			#Some mitigation
			whole_of_body = minor_stress_impact_loss
			stubborn = minor_stress_impact_loss
		}
		#AI won't be getting this event
	}
	#Meh, guess it's out of my hands
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							has_trait = sadistic
							has_trait = eccentric
						}
						#That's my girl!
						desc = bp2_yearly.1001.c_ecc_sadist
					}
					triggered_desc = {
						trigger = { has_trait = callous }
						#Who am I to interrupt
						desc = bp2_yearly.1001.c.flavor_callous
					}
					desc = bp2_yearly.1001.c
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:triggered_trait = flag:flagellant
						has_trait = sadistic
						has_trait = eccentric
					}
					#Let the flesh sing
					desc = bp2_yearly.1001.c.flavor_ecc_sadist
				}
				triggered_desc = {
					trigger = { has_trait = callous }
					#Who said child-rearing was difficult
					desc = bp2_yearly.1001.c.flavor_callous
				}
				desc = bp2_yearly.1001.c.flavor
			}
		}
		#Doesn't make sense to not encourage these
		trigger = {
			NOR = {
				scope:triggered_trait = flag:journaller
				scope:triggered_trait = flag:confider
				scope:triggered_trait = flag:athletic
			}
		}
		random_list = {
			50 = {
				send_interface_toast = {
					type = event_toast_effect_bad
					title = bp2_yearly.1001.a.trait.t
					right_icon = scope:appropriate_child
					scope:appropriate_child = { bp2_yearly_1000_award_trait_effect = yes }
				}
			}
			50 = {
				#Nothing happens
			}
		}
		#Sadists be sadists
		if = {
			limit = {
				OR = {
					scope:triggered_trait = flag:irritable
					scope:triggered_trait = flag:flagellant
				}
				has_trait = sadistic
			}
			stress_impact = {
				diligent = miniscule_stress_impact_gain
				lazy = miniscule_stress_impact_loss
				sadistic = medium_stress_impact_loss
			}
		}
		else = {
			stress_impact = {
				diligent = miniscule_stress_impact_gain
				lazy = miniscule_stress_impact_loss
			}
		}
		#AI won't be getting this event
	}
	after = {
		scope:appropriate_child = { 
			if = {
				limit = { has_character_flag = should_be_topless }
				remove_character_flag = should_be_topless 
			}
		}
	}
}

scripted_trigger bp2_yearly_1005_is_stressed_adult = {
	location = root.location
	OR = {
		AND = {
			has_trait = drunkard
			#Is the trait transferrable?
			NOT = { 
				root = { has_trait = drunkard }
			}
		}
		AND = {
			has_trait = hashishiyah
			NOT = { 
				root = { has_trait = hashishiyah }
			}
		}
		AND = {
			has_trait = reclusive
			NOT = { 
				root = { has_trait = reclusive }
			}
		}
		AND = {
			has_trait = irritable
			NOT = { 
				root = { has_trait = irritable }
			}
		}
		AND = {
			has_trait = flagellant
			NOT = { 
				root = { has_trait = flagellant }
			}
		}
		AND = {
			has_trait = profligate
			NOT = { 
				root = { has_trait = profligate }
			}
		}
		AND = {
			has_trait = improvident
			NOT = { 
				root = { has_trait = improvident }
			}
		}
		AND = {
			has_trait = contrite
			NOT = { 
				root = { has_trait = contrite }
			}
		}
		AND = {
			has_trait = comfort_eater
			NOT = { 
				root = { has_trait = comfort_eater }
			}
		}
		AND = {
			has_trait = inappetetic
			NOT = { 
				root = { has_trait = inappetetic }
			}
		}
		AND = {
			has_trait = journaller
			NOT = { 
				root = { has_trait = journaller }
			}
		}
		AND = {
			has_trait = confider
			any_relation = {
				type = friend
				is_available = yes
				location = this.location
			}
			NOT = { 
				root = { has_trait = confider }
			}
		}
		AND = {
			has_trait = athletic
			NOT = { 
				root = { has_trait = athletic }
			}
		}
	}
}

#Child: You notice your parent/guardian performing a stress trait
bp2_yearly.1005 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1005.t
	desc = {
		desc = bp2_yearly.1005.intro
		#Well, this is an interesting behavior...
		first_valid = {
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:drunkard }
				desc = bp2_yearly.1005.desc_drunkard
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:hashishiyah }
				desc = bp2_yearly.1005.desc_hashishiyah
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:reclusive }
				desc = bp2_yearly.1005.desc_reclusive
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:irritable }
				desc = bp2_yearly.1005.desc_irritable
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:flagellant }
				desc = bp2_yearly.1005.desc_flagellant
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:profligate }
				desc = bp2_yearly.1005.desc_profligate
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:improvident }
				desc = bp2_yearly.1005.desc_improvident
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:contrite }
				desc = bp2_yearly.1005.desc_contrite
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:comfort_eater }
				desc = bp2_yearly.1005.desc_comfort_eater
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:inappetetic }
				desc = bp2_yearly.1005.desc_inappetetic
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:journaller }
				desc = bp2_yearly.1005.desc_journaller
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:confider }
				desc = bp2_yearly.1005.desc_confider
			}
			triggered_desc = {
				trigger = { var:witnessed_trait ?= flag:athletic }
				desc = bp2_yearly.1005.desc_athletic
			}
		}
	}
	theme = family
	#Let's be in a couple of different places
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:inappetetic }
		reference = feast_event
	}
	override_background = { 
		trigger = {
			OR = {
				var:witnessed_trait ?= flag:hashishiyah
				var:witnessed_trait ?= flag:comfort_eater
				var:witnessed_trait ?= flag:journaller
			}
		}
		reference = relaxing_room
	}
	override_background = { 
		trigger = { 
			OR = {
				var:witnessed_trait ?= flag:contrite
				var:witnessed_trait ?= flag:confider
			}
		}
		reference = corridor_day
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:drunkard }
		reference = bp1_wine_cellar
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:irritable }
		reference = bedchamber
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:reclusive }
		reference = study
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:flagellant }
		reference = dungeon
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:profligate }
		reference = market
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:athletic }
		reference = ep2_tournament
	}
	override_background = { 
		trigger = { var:witnessed_trait ?= flag:improvident }
		reference = temple
	}
	#Fallback
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:stressed_adult
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:drunkard }
			}
			animation = drink_goblet
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:improvident }
			}
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = {
				root = { 
					OR = {
						var:witnessed_trait ?= flag:reclusive
						var:witnessed_trait ?= flag:inappetetic
					}
				}
			}
			animation = personality_cynical
		}
		triggered_animation = {
			trigger = { 
				root = { var:witnessed_trait ?= flag:journaller } 
			}
			animation = thinking
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:flagellant }
			}
			animation = pain
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:contrite }
			}
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:confider }
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:athletic }
			}
			animation = ecstasy
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:profligate }
			}
			animation = steward
		}
		triggered_animation = {
			trigger = {
				root = { var:witnessed_trait ?= flag:irritable }
			}
			animation = rage
		}
		triggered_animation = {
			trigger = { 
				OR = {
					has_trait = eccentric
					has_trait = lunatic
					root = { var:witnessed_trait ?= flag:hashishiyah }
				}
			}
			animation = personality_irrational
		}
		animation = stress
	}
	lower_right_portrait = {
		trigger = { exists = scope:confidant_friend }
		character = scope:confidant_friend
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available_child = yes
		age >= 6
		age <= 14 
		is_landed = yes
		is_ai = no
		OR = {
			any_relation = {
				type = guardian
				bp2_yearly_1005_is_stressed_adult = yes
			}
			any_parent = { bp2_yearly_1005_is_stressed_adult = yes }
		}
		NOT = { has_variable = witnessed_trait }
	}
	weight_multiplier = {
		base = 0
		#The more stress traits; the higher chance
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = drunkard
				}
				any_parent = { 
					location = root.location
					has_trait = drunkard 
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = hashishiyah
				}
				any_parent = { 
					location = root.location
					has_trait = hashishiyah 
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = reclusive
				}
				any_parent = { 
					location = root.location
					has_trait = reclusive 
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = irritable
				}
				any_parent = { 
					location = root.location
					has_trait = irritable 
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = flagellant
				}
				any_parent = { 
					location = root.location
					has_trait = flagellant
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = profligate
				}
				any_parent = { 
					location = root.location
					has_trait = profligate
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = improvident
				}
				any_parent = { 
					location = root.location
					has_trait = improvident
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = contrite
				}
				any_parent = { 
					location = root.location
					has_trait = contrite
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = comfort_eater
				}
				any_parent = { 
					location = root.location
					has_trait = comfort_eater
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = inappetetic
				}
				any_parent = { 
					location = root.location
					has_trait = inappetetic
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = journaller
				}
				any_parent = { 
					location = root.location
					has_trait = journaller
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = confider
				}
				any_parent = { 
					location = root.location
					has_trait = confider
				}
			}
			add = 1
		}
		modifier = {
			OR = {
				any_relation = {
					type = guardian
					location = root.location
					has_trait = athletic
				}
				any_parent = { 
					location = root.location
					has_trait = athletic
				}
			}
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_stress"
		#Your guardian first (you probably spend more time together)
		random_relation = {
			type = guardian
			limit = { bp2_yearly_1005_is_stressed_adult = yes }
			save_scope_as = stressed_adult
		}	
		#Then a parent
		if = {
			limit = {
				NOT = { exists = scope:stressed_adult }
			}
			random_parent = {
				#A parent you care about
				limit = { 
					opinion = {
						target = root
						value >= low_positive_opinion
					}
					bp2_yearly_1005_is_stressed_adult = yes 
				}
				#Otherwise pick whoever
				alternative_limit = { bp2_yearly_1005_is_stressed_adult = yes }
				save_scope_as = stressed_adult
			}
		}
		random_list = {
			#Set a trait to work from and remember it; weights what stress coping events the child may get later in life
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = drunkard }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:drunkard
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = hashishiyah }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:hashishiyah
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = reclusive }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:reclusive
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = irritable }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:irritable
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = flagellant }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:flagellant
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = profligate }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:profligate
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = improvident }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:improvident
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = contrite }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:contrite
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = comfort_eater }
				}
				scope:stressed_adult = { set_favorite_treat_effect = yes }
				set_variable = {
					name = witnessed_trait
					value = flag:comfort_eater
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = inappetetic }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:inappetetic
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = journaller }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:journaller
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { 
						has_trait = confider
						any_relation = {
							type = friend
							is_available = yes
							location = this.location
						}
					}
				}
				scope:stressed_adult = {
					random_relation = {
						type = friend
						limit = {
							is_available = yes
							location = this.location
						}
						save_scope_as = confidant_friend
					}
				}
				set_variable = {
					name = witnessed_trait
					value = flag:confider
				}
			}
			1 = {
				trigger = { 
					scope:stressed_adult = { has_trait = athletic }
				}
				set_variable = {
					name = witnessed_trait
					value = flag:athletic
				}
			}
		}
	}
	#_What's the worst thing that could happen_
	option = {
		name = bp2_yearly.1005.a
		flavor = bp2_yearly.1005.a.flavor
		random_list = {
			25 = {
				trigger = {
					NOR = {
						var:witnessed_trait ?= flag:confider
						var:witnessed_trait ?= flag:journaller
						var:witnessed_trait ?= flag:athletic
					}
				}
				desc = bp2_yearly.1005.a.insight.desc
				send_interface_toast = {
					type = event_toast_effect_good
					title = bp2_yearly.1005.a.insight.t
					left_icon = root
					add_character_modifier = {
						modifier = stress_insight_modifier
						#Reflecting on yourself is half the battle
					}
				}
			}
			25 = {
				desc = bp2_yearly.1005.a.stressed.desc
				send_interface_toast = {
					type = event_toast_effect_bad
					title = bp2_yearly.1005.a.stressed.t
					left_icon = root
					stress_impact = { base = miniscule_stress_impact_gain }
				}
			}
			50 = {
				desc = bp2_yearly.1005.a.trait.desc
				bp2_yearly_1000_award_trait_effect = yes
				stress_impact = { base = medium_stress_impact_loss }
			}
		}
		#AI won't be getting this event
	}
	#Nah
	option = {
		name = bp2_yearly.1005.b
		#AI won't be getting this event
	}
}

scripted_trigger bp2_yearly_1010_is_hugging_child = {
	age >= 2
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
}

#Parent/Guardian: Your child/ward gives you a hug
bp2_yearly.1010 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1010.t
	desc = {
		desc = bp2_yearly.1010.intro
		first_valid = {
			#Age 2 kid doesn't speak
			triggered_desc = {
				trigger = {
					scope:hugging_child = { age = 2 }
				}
				desc = bp2_yearly.1010.desc_toddler
			}
			#Age 3-5 kid speaks... ish
			triggered_desc = {
				trigger = {
					scope:hugging_child = {
						age > 2
						age < 6
					}
				}
				desc = bp2_yearly.1010.desc_rambler
			}
			#Age 6-10 kid speaks
			triggered_desc = {
				trigger = {
					scope:hugging_child = {
						age > 5
						age < 11
					}
				}
				desc = bp2_yearly.1010.desc_kid
			}
			#Age 10-15 teenager
			triggered_desc = {
				trigger = {
					scope:hugging_child = {
						age > 10
						age <= 15
					}
				}
				desc = bp2_yearly.1010.desc_teenager
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { has_trait = callous }
				desc = bp2_yearly.1010.outro_callous
			}
			triggered_desc = {
				trigger = {
					scope:hugging_child = {
						age >= 2
						age < 11
					}
				}
				desc = bp2_yearly.1010.outro_young
			}
			desc = bp2_yearly.1010.outro_older
		}
	}
	theme = family
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = personality_cynical
		}
		animation = shock
	}
	right_portrait = {
		character = scope:hugging_child
		animation = personality_content
	}
	#Set up the cooldown
	cooldown = { years = 5 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		static_group_filter = {
			group = bp2_yearly.1010
			match = 0.25
		}
		stress > 0
		is_available = yes
		is_physically_able_adult = yes
		is_landed = yes
		OR = {
			any_child = { 
				bp2_yearly_1010_is_hugging_child = yes
			}
			any_relation = {
				type = ward
				bp2_yearly_1010_is_hugging_child = yes
			}
			any_warden_hostage = {
				bp2_yearly_1010_is_hugging_child = yes
			}
		}
	}
	weight_multiplier = {
		base = 1
		#The more stress; the higher chance
		modifier = {
			stress_level > 0
			add = 1
		}
		modifier = {
			stress_level > 1
			add = 1
		}
		modifier = {
			stress_level > 2
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_touching_moment"
		#Your own children first
		random_list = {
			33 = {
				trigger = { any_child = { bp2_yearly_1010_is_hugging_child = yes } }
				random_child = {
					#A child you care about
					limit = { bp2_yearly_1010_is_hugging_child = yes }
					save_scope_as = hugging_child
				}
			}
			33 = {
				trigger = {
					any_relation = {
						type = ward
						bp2_yearly_1010_is_hugging_child = yes
					}
				}
				random_relation = {
					type = ward
					#A child you care about
					limit = { bp2_yearly_1010_is_hugging_child = yes }
					save_scope_as = hugging_child
				}
			}
			33 = {
				trigger = {
					any_warden_hostage = {
						bp2_yearly_1010_is_hugging_child = yes
					}
				}
				random_warden_hostage = {
					#A child you care about
					limit = { bp2_yearly_1010_is_hugging_child = yes }
					save_scope_as = hugging_child
				}
			}
		}
	}
	#Have some stress relief
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_trait = callous }
						desc = bp2_yearly.1010.a_callous
					}
					desc = bp2_yearly.1010.a
				}
			}
		}		
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_trait = callous }
					desc = bp2_yearly.1010.a.flavor_callous
				}
				desc = bp2_yearly.1010.a.flavor
			}
		}
		stress_impact = { base = minor_stress_impact_loss }
	}
}

scripted_trigger bp2_yearly_1015_is_golden_child = {
	age >= 7
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
	NOT = { has_variable = had_bp2_yearly_1015_stewardship_event }
}

#Parent/Guardian: Your child/ward found a pouch of gold while exploring
bp2_yearly.1015 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1015.t
	desc = {
		desc = bp2_yearly.1015.intro
		first_valid = {
			triggered_desc = {
				trigger = { is_parent_of = scope:golden_child }
				desc = bp2_yearly.1015.desc_parent
			}
			desc = bp2_yearly.1015.desc_guardian
		}
		desc = bp2_yearly.1015.outro
	}
	theme = family
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = personality_cynical
		}
		triggered_animation = {
			trigger = { has_trait = greedy }
			animation = personality_greedy
		}
		animation = personality_compassionate
	}
	right_portrait = {
		character = scope:golden_child
		animation = steward
	}
	#Set up the cooldown
	cooldown = { years = 5 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		OR = {
			any_child = { bp2_yearly_1015_is_golden_child = yes }
			any_relation = {
				type = ward
				bp2_yearly_1015_is_golden_child = yes
			}
			any_warden_hostage = {
				bp2_yearly_1015_is_golden_child = yes
			}
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_child = { 
					bp2_yearly_1015_is_golden_child = yes
					has_focus = education_stewardship
				}
				any_relation = {
					type = ward
					bp2_yearly_1015_is_golden_child = yes
					has_focus = education_stewardship
				}
				any_warden_hostage = {
					bp2_yearly_1015_is_golden_child = yes
					has_focus = education_stewardship
				}
			}
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		#Your own children first
		random_child = {
			limit = { 
				bp2_yearly_1015_is_golden_child = yes
				has_focus = education_stewardship
			}
			alternative_limit = { bp2_yearly_1015_is_golden_child = yes }
			save_scope_as = golden_child
		}
		random_list = {
			33 = {
				trigger = { any_child = { bp2_yearly_1015_is_golden_child = yes } }
				random_child = {
					limit = { 
						bp2_yearly_1015_is_golden_child = yes
						has_focus = education_stewardship
						this = root.player_heir
					}
					alternative_limit = {
						bp2_yearly_1015_is_golden_child = yes
						this = root.player_heir
					}
					alternative_limit = {
						bp2_yearly_1015_is_golden_child = yes
						has_focus = education_stewardship
					}
					alternative_limit = { bp2_yearly_1015_is_golden_child = yes }
					save_scope_as = golden_child
				}
				modifier = {
					any_child = {
						bp2_yearly_1015_is_golden_child = yes
						this = root.player_heir
					}
					add = 50
				}
			}
			33 = {
				trigger = {
					any_relation = {
						type = ward
						bp2_yearly_1015_is_golden_child = yes
					}
				}
				random_relation = {
					type = ward
					limit = { 
						bp2_yearly_1015_is_golden_child = yes
						has_focus = education_stewardship
					}
					alternative_limit = { bp2_yearly_1015_is_golden_child = yes }
					save_scope_as = golden_child
				}
			}
			33 = {
				trigger = {
					any_warden_hostage = {
						bp2_yearly_1015_is_golden_child = yes
					}
				}
				random_warden_hostage = {
					#A child you care about
					limit = { 
						bp2_yearly_1015_is_golden_child = yes
						has_focus = education_stewardship
					}
					alternative_limit = { bp2_yearly_1015_is_golden_child = yes }
					save_scope_as = golden_child
				}
			}
		}
		scope:golden_child = {
			set_variable = {
				name = had_bp2_yearly_1015_stewardship_event
				value = flag:yes
			}
		}
	}
	#Have some gold
	option = {
		name = bp2_yearly.1015.a		
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_trait = greedy }
					desc = bp2_yearly.1015.a.flavor_greedy
				}
				desc = bp2_yearly.1015.a.flavor
			}
		}
		add_gold = minor_gold_value
		ai_chance = {
			base = 100
		}
	}
	#Have some education
	option = {
		name = bp2_yearly.1015.b
		trigger = {
			scope:golden_child = { has_focus = education_stewardship }
		}
		#More points for a matching education
		if = {
			limit = { has_trait = education_stewardship }
			custom_tooltip = bp2_yearly.1015.b.tt_matching
			hidden_effect = {
				scope:golden_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = mid }
				}
			}
		}
		else = {
			custom_tooltip = bp2_yearly.1015.b.tt
			hidden_effect = {
				scope:golden_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = low }
				}
			}
		}
		reverse_add_opinion = {
			target = scope:golden_child
			modifier = teaching_moment_opinion
			opinion = 15
		}
		stress_impact = { greedy = minor_stress_impact_gain }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
}

scripted_trigger bp2_yearly_1020_is_secrety_child = {
	age >= 7
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
	NOT = { has_variable = had_bp2_yearly_1020_intrigue_event }
}

scripted_trigger bp2_yearly_1020_is_relevant_secret = {
	is_known_by = prev #A courtier
	NOR = { 
		secret_owner = root
		is_known_by = root
	}
}

#Parent/Guardian: Your child/ward has found a secret in court
bp2_yearly.1020 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1020.t
	desc = {
		desc = bp2_yearly.1020.intro
		first_valid = {
			triggered_desc = {
				trigger = { is_parent_of = scope:secrety_child }
				desc = bp2_yearly.1020.desc_parent
			}
			desc = bp2_yearly.1020.desc_guardian
		}
		desc = bp2_yearly.1020.desc
	}
	theme = family
	override_background = { reference = study }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = personality_cynical
		}
		triggered_animation = {
			trigger = { has_trait = deceitful }
			animation = schadenfreude
		}
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:secrety_child
		animation = ecstasy
	}
	lower_center_portrait = {
		character = scope:secret_keeper
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		is_adult = yes
		OR = {
			any_child = { 
				bp2_yearly_1020_is_secrety_child = yes
				save_temporary_scope_as = child_check
			}
			any_relation = {
				type = ward
				bp2_yearly_1020_is_secrety_child = yes
				save_temporary_scope_as = child_check
			}
			any_warden_hostage = {
				bp2_yearly_1020_is_secrety_child = yes
				save_temporary_scope_as = child_check
			}
		}
		any_courtier = { 
			NOR = { 
				this = scope:child_check
				this = root
				is_parent_of = scope:child_check #Don't rat out your parents
			} 
			any_secret = { 
				bp2_yearly_1020_is_relevant_secret = yes 
				NOR = {
					trigger_if = { 
						limit = { exists = secret_target }
						secret_target = scope:child_check
					}
					secret_owner = scope:child_check #Or yourself
				} 
			}
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_child = { 
					bp2_yearly_1020_is_secrety_child = yes
					has_focus = education_intrigue
				}
				any_relation = {
					type = ward
					bp2_yearly_1020_is_secrety_child = yes
					has_focus = education_intrigue
				}
				any_warden_hostage = {
					bp2_yearly_1020_is_secrety_child = yes
					has_focus = education_intrigue
				}
			}
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		random_list = {
			33 = {
				trigger = { any_child = { bp2_yearly_1020_is_secrety_child = yes } }
				random_child = {
					limit = { 
						bp2_yearly_1020_is_secrety_child = yes
						has_focus = education_intrigue
						this = root.player_heir
					}
					alternative_limit = { 
						bp2_yearly_1020_is_secrety_child = yes
						has_focus = education_intrigue 
					}
					alternative_limit = { bp2_yearly_1020_is_secrety_child = yes }
					save_scope_as = secrety_child
				}
				modifier = {
					any_child = {
						bp2_yearly_1020_is_secrety_child = yes
						this = root.player_heir
					}
					add = 50
				}
			}
			33 = {
				trigger = {
					any_relation = {
						type = ward
						bp2_yearly_1020_is_secrety_child = yes
					}
				}
				random_relation = {
					type = ward
					limit = { 
						bp2_yearly_1020_is_secrety_child = yes
						has_focus = education_stewardship
					}
					alternative_limit = { bp2_yearly_1020_is_secrety_child = yes }
					save_scope_as = secrety_child
				}
			}
			33 = {
				trigger = {
					any_warden_hostage = {
						bp2_yearly_1020_is_secrety_child = yes
					}
				}
				random_warden_hostage = {
					#A child you care about
					limit = { 
						bp2_yearly_1020_is_secrety_child = yes
						has_focus = education_stewardship
					}
					alternative_limit = { bp2_yearly_1020_is_secrety_child = yes }
					save_scope_as = secrety_child
				}
			}
		}
		#Find the secret to reveal
		random_courtier = {
			limit = { 
				NOR = { 
					this = scope:secrety_child
					this = root
					is_parent_of = scope:secrety_child #Don't rat out your parents
				}
				any_secret = { 
					bp2_yearly_1020_is_relevant_secret = yes
					NOR = { 
						trigger_if = { 
							limit = { exists = secret_target }
							secret_target = scope:secrety_child
						}
						secret_owner = scope:secrety_child #Or yourself
					} 
				}
			}
			save_scope_as = secret_keeper
			random_secret = {
				limit = { 
					bp2_yearly_1020_is_relevant_secret = yes
					NOR = { 
						trigger_if = { 
							limit = { exists = secret_target }
							secret_target = scope:secrety_child
						}
						secret_owner = scope:secrety_child
					} 
				}
				hidden_effect = {
					if = {
						limit = {
							NOT = { is_known_by = scope:secrety_child }
						}
						reveal_to = scope:secrety_child
					}
				}
				save_scope_as = bp2_yearly_1020_secret_to_reveal
			}
		}
		scope:secrety_child = {
			set_variable = {
				name = had_bp2_yearly_1020_intrigue_event
				value = flag:yes
			}
		}
	}
	#Have a secret
	option = {
		name = bp2_yearly.1020.a
		custom_tooltip = bp2_yearly.1020.a.tt
		hidden_effect = {
			send_interface_toast = {
				type = event_toast_effect_good
				title = bp2_yearly.1020.a.secret.t
				left_icon = root
				right_icon = scope:secret_keeper
				scope:bp2_yearly_1020_secret_to_reveal = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 100
		}
	}
	#Have some education
	option = {
		name = bp2_yearly.1020.b
		trigger = {
			scope:secrety_child = { has_focus = education_intrigue }
		}
		#More points for a matching education
		if = {
			limit = { has_trait = education_intrigue }
			custom_tooltip = bp2_yearly.1020.b.tt_matching
			hidden_effect = {
				scope:secrety_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = mid }
				}
			}
		}
		else = {
			custom_tooltip = bp2_yearly.1020.b.tt
			hidden_effect = {
				scope:secrety_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = low }
				}
			}
		}
		reverse_add_opinion = {
			target = scope:secrety_child
			modifier = teaching_moment_opinion
			opinion = 15
		}
		stress_impact = { deceitful = minor_stress_impact_gain }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = deceitful
				factor = 0
			}
		}
	}
}

scripted_trigger bp2_yearly_1030_is_focus_child = {
	age >= 5
	age < 16 
	is_available = yes
	is_ai = yes
	OR = { # A focus is selected
		has_focus = education_martial
		has_focus = education_intrigue
		has_focus = education_learning
		has_focus = education_stewardship
		has_focus = education_diplomacy
		has_focus = education_nht_prowess
		has_focus = education_nht_leadership	
	}
	OR = {
		AND = {
			root = { has_trait = education_martial }
			NOT = { has_focus = education_martial }
		}
		AND = {
			root = { has_trait = education_intrigue }
			NOT = { has_focus = education_intrigue }
		}
		AND = {
			root = { has_trait = education_learning }
			NOT = { has_focus = education_learning }
		}
		AND = {
			root = { has_trait = education_stewardship }
			NOT = { has_focus = education_stewardship }
		}
		AND = {
			root = { has_trait = education_diplomacy }
			NOT = { has_focus = education_diplomacy }
		}
		AND = {
			root = { has_trait = education_nht_prowess }
			NOT = { has_focus = education_nht_prowess  }
		}
		AND = {
			root = { has_trait = education_nht_leadership }
			NOT = { has_focus = education_nht_leadership }
		}
	}
	NOT = { has_variable = had_bp2_yearly_1030_focus_event }
}

#Parent: Your child does not have the same educational trait as you. Change?
bp2_yearly.1030 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1030.t
	desc = bp2_yearly.1030.desc
	theme = education
	override_background = { reference = bp2_nursery }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:focus_child
		animation = reading
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		is_adult = yes
		any_child = { bp2_yearly_1030_is_focus_child = yes }
	}
	weight_multiplier = {
		base = 1
		#The better educational trait; the higher chance
		modifier = {
			has_trait = education_martial_2
			add = 1
		}
		modifier = {
			has_trait = education_martial_3
			add = 2
		}
		modifier = {
			has_trait = education_martial_4
			add = 3
		}
		modifier = {
			has_trait = education_intrigue_2
			add = 1
		}
		modifier = {
			has_trait = education_intrigue_3
			add = 2
		}
		modifier = {
			has_trait = education_intrigue_4
			add = 3
		}
		modifier = {
			has_trait = education_learning_2
			add = 1
		}
		modifier = {
			has_trait = education_learning_3
			add = 2
		}
		modifier = {
			has_trait = education_learning_4
			add = 3
		}
		modifier = {
			has_trait = education_stewardship_2
			add = 1
		}
		modifier = {
			has_trait = education_stewardship_3
			add = 2
		}
		modifier = {
			has_trait = education_stewardship_4
			add = 3
		}
		modifier = {
			has_trait = education_diplomacy_2
			add = 1
		}
		modifier = {
			has_trait = education_diplomacy_3
			add = 2
		}
		modifier = {
			has_trait = education_diplomacy_4
			add = 3
		}
		### More Lifestyles
		modifier = {
			has_trait = education_nht_prowess_2
			add = 1
		}
		modifier = {
			has_trait = education_nht_prowess_3
			add = 2
		}
		modifier = {
			has_trait = education_nht_prowess_4
			add = 3
		}
		modifier = {
			has_trait = education_nht_leadership_2
			add = 1
		}
		modifier = {
			has_trait = education_nht_leadership_3
			add = 2
		}
		modifier = {
			has_trait = education_nht_leadership_4
			add = 3
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		random_child = {
			limit = {
				bp2_yearly_1030_is_focus_child = yes
				NOT = { has_variable = had_bp2_yearly_1030_focus_event }
			}
			save_scope_as = focus_child
		}
		scope:focus_child = {
			set_variable = {
				name = had_bp2_yearly_1030_focus_event
				value = flag:yes
			}
		}
	}
	#My way or the highway
	option = {
		name = bp2_yearly.1030.a		
		custom_tooltip = bp2_yearly.1030.a.tt_change
		custom_tooltip = bp2_yearly.1030.a.tt_tutor
		hidden_effect = {
			if = {
				limit = { has_trait = education_martial }
				scope:focus_child = { 
					set_focus = education_martial
					change_variable = {
						name = education_martial_variable
						add = age
					}
				}
			}
			else_if = {
				limit = { has_trait = education_intrigue }
				scope:focus_child = { 
					set_focus = education_intrigue
					change_variable = {
						name = education_intrigue_variable
						add = age
					}
				}
			}
			else_if = {
				limit = { has_trait = education_learning }
				scope:focus_child = { 
					set_focus = education_learning
					change_variable = {
						name = education_learning_variable
						add = age
					}
				}
			}
			else_if = {
				limit = { has_trait = education_stewardship }
				scope:focus_child = { 
					set_focus = education_stewardship
					change_variable = {
						name = education_stewardship_variable
						add = age
					}
				}
			}
			else_if = {
				limit = { has_trait = education_diplomacy }
				scope:focus_child = { 
					set_focus = education_diplomacy
					change_variable = {
						name = education_diplomacy_variable
						add = age
					}
				}
			}
			else_if = {
				limit = { has_trait = education_nht_prowess }
				scope:focus_child = { 
					set_focus = education_nht_prowess
					change_variable = {
						name = education_nht_prowess_variable
						add = age
					}
				}
			}
			else_if = {
				limit = { has_trait = education_nht_leadership }
				scope:focus_child = { 
					set_focus = education_nht_leadership
					change_variable = {
						name = education_nht_leadership_variable
						add = age
					}
				}
			}
		}
		stress_impact = { 
			base = medium_stress_impact_gain 
			diligent = minor_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
		}
	}
	#It's fine, I guess...
	option = {
		name = bp2_yearly.1030.b
		custom_tooltip = bp2_yearly.1030.b.tt
		#To avoid an empty random list
		hidden_effect = {
			scope:focus_child = { education_point_acquisition_effect = yes }
		}
		ai_chance = {
			base = 100
		}
	}
}

scripted_trigger bp2_yearly_1035_is_rock_child = {
	age >= 7
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
	NOT = { has_variable = had_bp2_yearly_1035_learning_event }
}

#Parent/Guardian: Your child/ward has a rock collection
bp2_yearly.1035 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1035.t
	desc = {
		desc = bp2_yearly.1035.desc
		first_valid = {
			triggered_desc = {
				trigger = { is_parent_of = scope:rock_child }
				desc = bp2_yearly.1035.desc_parent
			}
			desc = bp2_yearly.1035.desc_guardian
		}
	} 
	theme = family
	override_background = {
		trigger = {
			has_tgp_dlc_trigger = yes
			location = {
				geographical_region = world_asia_east	
			}
		}  
		reference = relaxing_room
	}
	override_background = { reference = bp2_nursery }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = personality_cynical
		}
		triggered_animation = {
			trigger = { has_trait = greedy }
			animation = personality_greedy
		}
		animation = personality_coward
	}
	right_portrait = {
		character = scope:rock_child
		animation = love
	}
	artifact = {
		target = scope:gemstone_trinket
		position = lower_center_portrait
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		is_adult = yes
		OR = {
			any_child = { bp2_yearly_1035_is_rock_child = yes }
			any_relation = {
				type = ward
				bp2_yearly_1035_is_rock_child = yes
			}
			any_warden_hostage = {
				bp2_yearly_1035_is_rock_child = yes
			}
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_child = { 
					bp2_yearly_1035_is_rock_child = yes
					has_focus = education_learning
				}
				any_relation = {
					type = ward
					bp2_yearly_1035_is_rock_child = yes
					has_focus = education_learning
				}
				any_warden_hostage = {
					bp2_yearly_1035_is_rock_child = yes
					has_focus = education_learning
				}
			}
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"

		random_list = {
			33 = {
				trigger = { any_child = { bp2_yearly_1035_is_rock_child = yes } }
				random_child = {
					limit = { 
						bp2_yearly_1035_is_rock_child = yes
						has_focus = education_learning
						this = root.player_heir
					}
					alternative_limit = { 
						bp2_yearly_1035_is_rock_child = yes
						has_focus = education_learning
					}
					alternative_limit = { bp2_yearly_1035_is_rock_child = yes }
					save_scope_as = rock_child
				}
				modifier = {
					any_child = {
						bp2_yearly_1035_is_rock_child = yes
						this = root.player_heir
					}
					add = 50
				}
			}
			33 = {
				trigger = {
					any_relation = {
						type = ward
						bp2_yearly_1035_is_rock_child = yes
					}
				}
				random_relation = {
					type = ward
					limit = { 
						bp2_yearly_1035_is_rock_child = yes
						has_focus = education_learning
					}
					alternative_limit = { bp2_yearly_1035_is_rock_child = yes }
					save_scope_as = rock_child
				}
			}
			33 = {
				trigger = {
					any_warden_hostage = {
						bp2_yearly_1035_is_rock_child = yes
					}
				}
				random_warden_hostage = {
					#A child you care about
					limit = { 
						bp2_yearly_1035_is_rock_child = yes
						has_focus = education_learning
					}
					alternative_limit = { bp2_yearly_1035_is_rock_child = yes }
					save_scope_as = rock_child
				}
			}
		}

		root.location = { save_scope_as = trinket_location }
		#Create the gemstone
		hidden_effect = {
			scope:rock_child = {
				random_list = {
					50 = {
						create_artifact = {
							name = gemstone_trinket_rough
							description = gemstone_trinket_rough.desc
							type = miscellaneous
							visuals = diamond
							modifier = artifact_monthly_minor_prestige_1_modifier
							modifier = artifact_learning_1_modifier
							save_scope_as = gemstone_trinket
							wealth = 15
							quality = 15
							max_durability = 30
							generate_history = no
						}
					}
					50 = {
						create_artifact = {
							name = gemstone_trinket_modest
							description = gemstone_trinket_modest.desc
							type = miscellaneous
							visuals = diamond
							modifier = artifact_monthly_minor_prestige_2_modifier
							modifier = artifact_learning_1_modifier
							save_scope_as = gemstone_trinket
							wealth = 15
							quality = 15
							max_durability = 40
							generate_history = no
						}
					}
					50 = {
						create_artifact = {
							name = gemstone_trinket_brilliant
							description = gemstone_trinket_brilliant.desc
							type = miscellaneous
							visuals = diamond
							modifier = artifact_monthly_minor_prestige_3_modifier
							modifier = artifact_learning_2_modifier
							save_scope_as = gemstone_trinket
							wealth = 15
							quality = 15
							max_durability = 50
							generate_history = no
						}
					}
				}
				
			}
		}
		scope:rock_child = {
			set_variable = {
				name = had_bp2_yearly_1035_learning_event
				value = flag:yes
			}
		}
	}
	#Have a gem trinket
	option = {
		name = bp2_yearly.1035.a		
		flavor = bp2_yearly.1035.a.flavor
		scope:gemstone_trinket = { set_owner = root }
		ai_chance = {
			base = 100
		}
	}
	#Have some education
	option = {
		name = bp2_yearly.1035.b
		trigger = {
			scope:rock_child = { has_focus = education_learning }
		}
		#More points for a matching education
		if = {
			limit = { has_trait = education_learning }
			custom_tooltip = bp2_yearly.1035.b.tt_matching
			hidden_effect = {
				scope:rock_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = mid }
				}
			}
		}
		else = {
			custom_tooltip = bp2_yearly.1035.b.tt
			hidden_effect = {
				scope:rock_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = low }
				}
			}
		}
		reverse_add_opinion = {
			target = scope:rock_child
			modifier = teaching_moment_opinion
			opinion = 15
		}
		stress_impact = { greedy = minor_stress_impact_gain }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
}

scripted_trigger bp2_yearly_1040_is_sparring_child = {
	age >= 7
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
	NOT = { has_variable = had_bp2_yearly_1040_martial_event }
}

#Parent/Guardian: Your child/ward has a text about martial
bp2_yearly.1040 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1040.t
	desc = bp2_yearly.1040.desc 
	theme = family
	override_background = {	reference = study }
	left_portrait = {
		character = root
		animation = reading
	}
	right_portrait = {
		character = scope:sparring_child
		animation = marshal_wooden_sword
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		is_adult = yes
		OR = {
			any_child = { bp2_yearly_1040_is_sparring_child = yes }
			any_relation = {
				type = ward
				bp2_yearly_1040_is_sparring_child = yes
			}
			any_warden_hostage = {
				bp2_yearly_1040_is_sparring_child = yes
			}
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_child = { 
					bp2_yearly_1040_is_sparring_child = yes
					has_focus = education_martial
				}
				any_relation = {
					type = ward
					bp2_yearly_1040_is_sparring_child = yes
					has_focus = education_martial
				}
				any_warden_hostage = {
					bp2_yearly_1040_is_sparring_child = yes
					has_focus = education_martial
				}
			}
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"


		random_list = {
			33 = {
				trigger = { any_child = { bp2_yearly_1040_is_sparring_child = yes } }
				random_child = {
					limit = { 
						bp2_yearly_1040_is_sparring_child = yes
						has_focus = education_martial
						this = root.player_heir
					}
					alternative_limit = { 
						bp2_yearly_1040_is_sparring_child = yes
						has_focus = education_martial
					}
					alternative_limit = { bp2_yearly_1040_is_sparring_child = yes }
					save_scope_as = sparring_child
				}
				modifier = {
					any_child = {
						bp2_yearly_1040_is_sparring_child = yes
						this = root.player_heir
					}
					add = 50
				}
			}
			33 = {
				trigger = {
					any_relation = {
						type = ward
						bp2_yearly_1040_is_sparring_child = yes
					}
				}
				random_relation = {
					type = ward
					limit = { 
						bp2_yearly_1040_is_sparring_child = yes
						has_focus = education_martial
					}
					alternative_limit = { bp2_yearly_1040_is_sparring_child = yes }
					save_scope_as = sparring_child
				}
			}
			33 = {
				trigger = {
					any_warden_hostage = {
						bp2_yearly_1040_is_sparring_child = yes
					}
				}
				random_warden_hostage = {
					#A child you care about
					limit = { 
						bp2_yearly_1040_is_sparring_child = yes
						has_focus = education_martial
					}
					alternative_limit = { bp2_yearly_1040_is_sparring_child = yes }
					save_scope_as = sparring_child
				}
			}
		}

		scope:sparring_child = {
			set_variable = {
				name = had_bp2_yearly_1040_martial_event
				value = flag:yes
			}
		}
	}
	#Have some martial
	option = {
		name = bp2_yearly.1040.a		
		flavor = bp2_yearly.1040.a.flavor
		add_martial_skill = 1
		ai_chance = {
			base = 100
		}
	}
	#Have some education
	option = {
		name = bp2_yearly.1040.b
		trigger = {
			scope:sparring_child = { has_focus = education_martial }
		}
		#More points for a matching education
		if = {
			limit = { has_trait = education_martial }
			custom_tooltip = bp2_yearly.1040.b.tt_matching
			hidden_effect = {
				scope:sparring_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = mid }
				}
			}
		}
		else = {
			custom_tooltip = bp2_yearly.1040.b.tt
			hidden_effect = {
				scope:sparring_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = low }
				}
			}
		}
		reverse_add_opinion = {
			target = scope:sparring_child
			modifier = teaching_moment_opinion
			opinion = 15
		}
		stress_impact = { craven = minor_stress_impact_gain }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
}

scripted_trigger bp2_yearly_1045_is_diplomacy_child = {
	age >= 7
	age < 16 
	is_available = yes
	is_ai = yes
	location = root.location
	opinion = {
		target = root
		value >= medium_positive_opinion
	}
	NOT = { has_variable = had_bp2_yearly_1045_diplomacy_event }
}

#Parent/Guardian: There is a brawl among some children
bp2_yearly.1045 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1045.t
	desc = {
		desc = bp2_yearly.1045.intro
		first_valid = {
			triggered_desc = {
				trigger = { is_parent_of = scope:diplomacy_child }
				desc = bp2_yearly.1045.desc_parent
			}
			desc = bp2_yearly.1045.desc_guardian
		}
		desc = bp2_yearly.1045.desc 
	}
	theme = family
	override_background = { reference = alley_day }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = eccentric }
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = greedy
					has_trait = callous
				}
			}
			animation = personality_dishonorable
		}
		animation = worry
	}
	right_portrait = {
		character = scope:diplomacy_child
		animation = shock
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		is_adult = yes
		OR = {
			any_child = { bp2_yearly_1045_is_diplomacy_child = yes }
			any_relation = {
				type = ward
				bp2_yearly_1045_is_diplomacy_child = yes
			}
			any_warden_hostage = {
				bp2_yearly_1045_is_diplomacy_child = yes
			}
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_child = { 
					bp2_yearly_1045_is_diplomacy_child = yes
					has_focus = education_diplomacy
				}
				any_relation = {
					type = ward
					bp2_yearly_1045_is_diplomacy_child = yes
					has_focus = education_diplomacy
				}
				any_warden_hostage = {
					bp2_yearly_1045_is_diplomacy_child = yes
					has_focus = education_diplomacy
				}
			}
			add = 1
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"

		random_list = {
			33 = {
				trigger = { any_child = { bp2_yearly_1045_is_diplomacy_child = yes } }
				random_child = {
					limit = { 
						bp2_yearly_1045_is_diplomacy_child = yes
						has_focus = education_diplomacy
						this = root.player_heir
					}
					alternative_limit = { 
						bp2_yearly_1045_is_diplomacy_child = yes
						has_focus = education_diplomacy
					}
					alternative_limit = { bp2_yearly_1045_is_diplomacy_child = yes }
					save_scope_as = diplomacy_child
				}
				modifier = {
					any_child = {
						bp2_yearly_1045_is_diplomacy_child = yes
						this = root.player_heir
					}
					add = 50
				}
			}
			33 = {
				trigger = {
					any_relation = {
						type = ward
						bp2_yearly_1045_is_diplomacy_child = yes
					}
				}
				random_relation = {
					type = ward
					limit = { 
						bp2_yearly_1045_is_diplomacy_child = yes
						has_focus = education_diplomacy
					}
					alternative_limit = { bp2_yearly_1045_is_diplomacy_child = yes }
					save_scope_as = diplomacy_child
				}
			}
			33 = {
				trigger = {
					any_warden_hostage = {
						bp2_yearly_1040_is_sparring_child = yes
					}
				}
				random_warden_hostage = {
					#A child you care about
					limit = { 
						bp2_yearly_1045_is_diplomacy_child = yes
						has_focus = education_diplomacy
					}
					alternative_limit = { bp2_yearly_1045_is_diplomacy_child = yes }
					save_scope_as = diplomacy_child
				}
			}
		}

		scope:diplomacy_child = {
			set_variable = {
				name = had_bp2_yearly_1045_diplomacy_event
				value = flag:yes
			}
		}
	}
	#Have some diplomacy
	option = {
		name = bp2_yearly.1045.a
		flavor = bp2_yearly.1045.a.flavor
		add_prestige = minor_prestige_gain
		if = {
			limit = { 
				NOT = { has_perk = firm_hand_perk } 
			}
			random = {
				chance = 5
				send_interface_toast = {
					type = event_toast_effect_good
					title = bp2_yearly.1045.a.perk.t
					left_icon = root
					add_perk = firm_hand_perk
				}
			}
		}
		else_if = {
			limit = { has_lifestyle = diplomacy_lifestyle }
			add_learning_lifestyle_xp = minor_lifestyle_experience
		}
		else = {
			add_character_modifier = {
				modifier = august_presence_modifier
				years = 5
			}
		}
		ai_chance = {
			base = 100
		}
	}
	#Bet on the fight
	option = {
		name = bp2_yearly.1045.b
		flavor = bp2_yearly.1045.b.flavor
		trigger = {
			OR = {
				has_trait = greedy
				has_trait = eccentric
				has_trait = callous
			}
		}
		duel = {
			skill = learning
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = bp2_yearly.1045.b.win.desc
				send_interface_toast = {
					type = event_toast_effect_good
					title = bp2_yearly.1045.b.win.t
					left_icon = root
					add_gold = medium_gold_value
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = bp2_yearly.1045.b.loss.desc
				send_interface_toast = {
					type = event_toast_effect_good
					title = bp2_yearly.1045.b.loss.t
					left_icon = root
					remove_short_term_gold = minor_gold_value
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = compassionate
				factor = 0
			}
		}
	}
	#Have some education
	option = {
		name = bp2_yearly.1045.c
		trigger = {
			scope:diplomacy_child = { has_focus = education_diplomacy }
		}
		#More points for a matching education
		if = {
			limit = { has_trait = education_diplomacy }
			custom_tooltip = bp2_yearly.1045.c.tt_matching
			hidden_effect = {
				scope:diplomacy_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = mid }
				}
			}
		}
		else = {
			custom_tooltip = bp2_yearly.1045.c.tt
			hidden_effect = {
				scope:diplomacy_child = { 
					education_point_acquisition_additional_points_effect = { LEVEL = low }
				}
			}
		}
		reverse_add_opinion = {
			target = scope:diplomacy_child
			modifier = teaching_moment_opinion
			opinion = 15
		}
		stress_impact = { craven = minor_stress_impact_loss }
		ai_chance = {
			base = 100
		}
	}
}

#################
## Event Chain ##
## The Builder ##
## 1050 - 1072 ##
#################
#These effects keeps track of what our latest choice was
scripted_effect the_builder_stewardship_choice_tracker_effect = {
	#Record the latest choice
	if = {
		limit = {
			NOT = { exists = var:the_builder_latest_choice }
		}
		set_variable = {
			name = the_builder_latest_choice
			value = flag:stewardship
		}
	}
	else = {
		remove_variable = the_builder_latest_choice
		set_variable = {
			name = the_builder_latest_choice
			value = flag:stewardship
		}
	}
}

#These effects increments the amount of any particular choice (had to separate it to display the present/past effect correctly)
scripted_effect the_builder_stewardship_increment_effect = {
	#We stack
	if = {
		limit = {
			NOT = { exists = var:the_builder_stewardship_choices }
		}
		set_variable = {
			name = the_builder_stewardship_choices
			value = 1
		}
	}
	else = {
		change_variable = {
			name = the_builder_stewardship_choices
			add = 1
		}
	}
	#Pick something else and we reset
	if = {
		limit = { exists = var:the_builder_martial_choices }
		remove_variable = the_builder_martial_choices
	}
	if = {
		limit = { exists = var:the_builder_learning_choices }
		remove_variable = the_builder_learning_choices
	}
}

scripted_effect the_builder_martial_choice_tracker_effect = {
	#Record the latest choice
	if = {
		limit = {
			NOT = { exists = var:the_builder_latest_choice }
		}
		set_variable = {
			name = the_builder_latest_choice
			value = flag:martial
		}
	}
	else = {
		remove_variable = the_builder_latest_choice
		set_variable = {
			name = the_builder_latest_choice
			value = flag:martial
		}
	}	
}

scripted_effect the_builder_martial_increment_effect = {
	#We stack
	if = {
		limit = {
			NOT = { exists = var:the_builder_martial_choices }
		}
		set_variable = {
			name = the_builder_martial_choices
			value = 1
		}
	}
	else = {
		change_variable = {
			name = the_builder_martial_choices
			add = 1
		}
	}
	#Pick something else and we reset
	if = {
		limit = { exists = var:the_builder_learning_choices }
		remove_variable = the_builder_learning_choices
	}
	if = {
		limit = { exists = var:the_builder_stewardship_choices }
		remove_variable = the_builder_stewardship_choices
	}
}

scripted_effect the_builder_learning_choice_tracker_effect = {
	#Record the latest choice
	if = {
		limit = {
			NOT = { exists = var:the_builder_latest_choice }
		}
		set_variable = {
			name = the_builder_latest_choice
			value = flag:learning
		}
	}
	else = {
		remove_variable = the_builder_latest_choice
		set_variable = {
			name = the_builder_latest_choice
			value = flag:learning
		}
	}
}

scripted_effect the_builder_learning_increment_effect = {
	#We stack
	if = {
		limit = {
			NOT = { exists = var:the_builder_learning_choices }
		}
		set_variable = {
			name = the_builder_learning_choices
			value = 1
		}
	}
	else = {
		change_variable = {
			name = the_builder_learning_choices
			add = 1
		}
	}
	#Pick something else and we reset
	if = {
		limit = { exists = var:the_builder_stewardship_choices }
		remove_variable = the_builder_stewardship_choices
	}
	if = {
		limit = { exists = var:the_builder_martial_choices }
		remove_variable = the_builder_martial_choices
	}
}

#The tide/storm is ruining your sand/twigcastle!
bp2_yearly.1050 = {
	type = character_event
	content_source = dlc_009
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					root.location = {
						OR = {
							county = { is_coastal_county = yes }
							graphical_wilderness_desert_trigger = yes
						}
					}	
				}
				desc = bp2_yearly.1050.t
			}
			desc = bp2_yearly.1050.t_twig
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					root.location = { 
						county = { is_coastal_county = yes }
					}
				}
				desc = bp2_yearly.1050.desc
			}
			triggered_desc = {
				trigger = { 
					root.location = { graphical_wilderness_desert_trigger = yes }
				}
				desc = bp2_yearly.1050.desc_desert
			}
			desc = bp2_yearly.1050.desc_twig
		}
	}
	theme = education
	override_background = {
		trigger = {
			root.location = { 
				county = { is_coastal_county = yes }
			}
		}
		reference = bp3_coast
	}
	#Some more flavor than simply using reference = terrain
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_desert_trigger = yes }
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_forest_pine_trigger = yes }
		}
		reference = ep2_hunt_foggy_forest 
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_jungle_trigger = yes }
		}
		reference = wilderness_jungle
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_steppe_trigger = yes }
		}
		reference = ep2_travel_settlement_steppe
	}
	override_background = {
		trigger = {
			root.location = { graphical_drylands_trigger = yes }
		}
		reference = drylands
	}
	#Fallback
	override_background = { reference = ep2_hunt_foggy_forest }
	left_portrait = {
		character = root
		animation = thinking
	}
	trigger = {
		#DLC check
		has_bp2_dlc_trigger = yes
		#Standard checks
		is_available = yes
		is_landed_or_landless_administrative = yes
		age >= 4
		age <= 10
		NOT = { has_variable = had_builder_event_chain }
		#If the child is AI, we don't want a player regent to get snubbed by the AI builder child
		trigger_if = {
			limit = { is_ai = yes }
			has_active_diarchy = yes
			diarch = { is_ai = yes }
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			is_ai = no
			add = 10 #Should reach 50 in the on_action trigger for the chain to start
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		set_variable = { name = had_builder_event_chain }
	}
	#Bribe nature
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							root.location = { 
								county = { is_coastal_county = yes }
							}
						}
						desc = bp2_yearly.1050.a
					}
					desc = bp2_yearly.1050.a_twig
				}
			}
		}			
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						root.location = { 
							county = { is_coastal_county = yes }
						}
					}
					desc = bp2_yearly.1050.a.flavor
				}
				desc = bp2_yearly.1050.a.flavor_twig
			}
		}
		the_builder_stewardship_choice_tracker_effect = yes
		the_builder_stewardship_increment_effect = yes
		add_stewardship_skill = 1
		ai_chance = {
			base = 100
			modifier = {
				ai_has_pious_builder_personality = yes
				factor = 0
			}
			modifier = {
				ai_has_warlike_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	#Build walls
	option = {
		name = bp2_yearly.1050.b
		flavor = bp2_yearly.1050.b.flavor
		the_builder_martial_choice_tracker_effect = yes
		the_builder_martial_increment_effect = yes
		add_martial_skill = 1
		ai_chance = {
			base = 100
			modifier = {
				ai_has_pious_builder_personality = yes
				factor = 0
			}
			modifier = {
				ai_has_economical_boom_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#Build a tiny altar
	option = {
		name = bp2_yearly.1050.c
		flavor = bp2_yearly.1050.c.flavor
		the_builder_learning_choice_tracker_effect = yes
		the_builder_learning_increment_effect = yes
		add_learning_skill = 1
		ai_chance = {
			base = 100
			modifier = {
				ai_has_economical_boom_personality = yes
				factor = 0
			}
			modifier = {
				ai_has_warlike_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	after = {
		trigger_event = {
			id = bp2_yearly.1051
			days = 1
		}
	}
}

#Follow-up: Curse you, tide!
bp2_yearly.1051 = {
	type = character_event
	content_source = dlc_009
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					root.location = {
						OR = {
							county = { is_coastal_county = yes }
							graphical_wilderness_desert_trigger = yes
						}
					}	
				}
				desc = bp2_yearly.1051.t
			}
			desc = bp2_yearly.1051.t_twig
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					root.location = { 
						county = { is_coastal_county = yes }
					}
				}
				desc = bp2_yearly.1051.desc
			}
			triggered_desc = {
				trigger = { 
					root.location = { graphical_wilderness_desert_trigger = yes }
				}
				desc = bp2_yearly.1051.desc_desert
			}
			desc = bp2_yearly.1051.desc_twig
		}
		desc = bp2_yearly.1051.outro
	}
	theme = education
	#Oh beach background; where art thou
	override_background = {
		trigger = {
			root.location = { 
				county = { is_coastal_county = yes }
			}
		}
		reference = market_tribal #This is the closest to a beach -well this or wetlands and I personally have a hard time seeing a sand castle in a marsh- we have that doesn't star a massive longship atm
	}
	#Some more flavor than simply using reference = terrain
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_desert_trigger = yes }
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_forest_pine_trigger = yes }
		}
		reference = ep2_forest_managed
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_jungle_trigger = yes }
		}
		reference = wilderness_jungle
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_steppe_trigger = yes }
		}
		reference = ep2_travel_settlement_steppe
	}
	override_background = {
		trigger = {
			root.location = { graphical_drylands_trigger = yes }
		}
		reference = drylands
	}
	#Fallback
	override_background = { reference = wilderness_forest_pine }
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	artifact = {
		target = scope:iridescent_stone_trinket
		position = lower_center_portrait
	}
	immediate = {
		#play_music_cue = "mx_cue_positive_effect"
		if = {
			limit = { var:the_builder_latest_choice ?= flag:stewardship }
			create_artifact = {
				name = iridescent_stone_trinket
				description = iridescent_stone_trinket.desc
				type = miscellaneous
				visuals = diamond
				modifier = artifact_stewardship_1_modifier
				modifier = artifact_stewardship_lifestyle_xp_2_modifier
				save_scope_as = iridescent_stone_trinket
				wealth = 15
				quality = 15
				max_durability = 40
				history = { type = created_before_history }
			}
		}
		if = {
			limit = { var:the_builder_latest_choice ?= flag:martial }
			create_artifact = {
				name = iridescent_stone_trinket
				description = iridescent_stone_trinket.desc
				type = miscellaneous
				visuals = diamond
				modifier = artifact_martial_1_modifier
				modifier = artifact_martial_lifestyle_xp_2_modifier
				save_scope_as = iridescent_stone_trinket
				wealth = 15
				quality = 15
				max_durability = 40
				history = { type = created_before_history }
			}
		}
		if = {
			limit = { var:the_builder_latest_choice ?= flag:learning }
			create_artifact = {
				name = iridescent_stone_trinket
				description = iridescent_stone_trinket.desc
				type = miscellaneous
				visuals = diamond
				modifier = artifact_learning_1_modifier
				modifier = artifact_learning_lifestyle_xp_2_modifier
				save_scope_as = iridescent_stone_trinket
				wealth = 15
				quality = 15
				max_durability = 40
				history = { type = created_before_history }
			}
		}
	}
	#Curse you, tide/storm!
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							root.location = { 
								county = { is_coastal_county = yes }
							}
						}
						desc = bp2_yearly.1051.a
					}
					desc = bp2_yearly.1051.a_twig
				}
			}
		}
	}
	#We are 4-10 years
	after = {
		if = {
			limit = { age = 4 }
			trigger_event = {
				id = bp2_yearly.1055
				years = 4
			}
		}
		else_if = {
			limit = { age = 5 }
			trigger_event = {
				id = bp2_yearly.1055
				years = 3
			}
		}
		else_if = {
			limit = { age = 6 }
			trigger_event = {
				id = bp2_yearly.1055
				years = 2
			}
		}
		else_if = {
			limit = { age = 10 }
			trigger_event = {
				id = bp2_yearly.1055
				years = 1
			}
		}
		#7-9 years
		else = {
			trigger_event = {
				id = bp2_yearly.1055
				years = { 1 2 }
			}
		}	
	}
}

#################
#If we for whatever reason don't finish the event chain, clean up the flags and variables
scripted_effect the_builder_clean_up_flags_effect = {
	if = {
		limit = { exists = var:the_builder_latest_choice }
		remove_variable = the_builder_latest_choice
	}
	if = {
		limit = { exists = var:the_builder_stewardship_choices }
		remove_variable = the_builder_stewardship_choices
	}
	if = {
		limit = { exists = var:the_builder_martial_choices }
		remove_variable = the_builder_martial_choices
	}
	if = {
		limit = { exists = var:the_builder_learning_choices }
		remove_variable = the_builder_learning_choices
	}
}

#These effects accurately checks and rewards your any particular stacked type of decision
scripted_effect the_builder_stacking_stewardship_rewards_effect = {
	#Stewardship
	if = {
		limit = { var:the_builder_latest_choice ?= flag:stewardship }
		if = {
			limit = { exists = var:the_builder_stewardship_choices }
			if = {
				limit = { var:the_builder_stewardship_choices >= 4 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_gold = major_gold_value
			}
			else_if = {
				limit = { var:the_builder_stewardship_choices = 3 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_gold = medium_gold_value
			}
			else_if = {
				limit = { var:the_builder_stewardship_choices = 2 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_gold = minor_gold_value
			}
			else_if = {
				limit = { var:the_builder_stewardship_choices = 1 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_gold = tiny_gold_value
			}
		}
	}
}

scripted_effect the_builder_stacking_martial_rewards_effect = {
	#Martial
	if = {
		limit = { var:the_builder_latest_choice ?= flag:martial }
		if = {
			limit = { exists = var:the_builder_martial_choices }
			if = {
				limit = { var:the_builder_martial_choices >= 4 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_prestige = major_prestige_gain
			}
			else_if = {
				limit = { var:the_builder_martial_choices = 3 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_prestige = medium_prestige_gain
			}
			else_if = {
				limit = { var:the_builder_martial_choices = 2 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_prestige = minor_prestige_gain
			}
			else_if = {
				limit = { var:the_builder_martial_choices = 1 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_prestige = miniscule_prestige_gain
			}
		}
	}
}

scripted_effect the_builder_stacking_learning_rewards_effect = {
	#Learning
	if = {
		limit = { var:the_builder_latest_choice ?= flag:learning }
		if = {
			limit = { exists = var:the_builder_learning_choices }
			if = {
				limit = { var:the_builder_learning_choices >= 4 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_piety = major_piety_gain
			}
			else_if = {
				limit = { var:the_builder_learning_choices = 3 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_piety = medium_piety_gain
			}
			else_if = {
				limit = { var:the_builder_learning_choices = 2 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_piety = minor_piety_gain
			}
			else_if = {
				limit = { var:the_builder_learning_choices = 1 }
				#To get that sweet sweet past version of the tooltip if the effect has already happened
				custom_description_no_bullet = { text = reminds_of_childhood_decision }
				add_piety = miniscule_piety_gain
			}
		}
	}
}
	
scripted_effect bp2_yearly_1055_economy_effect = {
	the_builder_stacking_stewardship_rewards_effect = yes
	add_stewardship_skill = 1
	worsen_relationship_effect = {
		TARGET = scope:den_challenger
		REASON = rival_paid_to_win
	}
}

scripted_effect bp2_yearly_1055_martial_effect = {
	the_builder_stacking_martial_rewards_effect = yes
	add_martial_skill = 1
	improve_relationship_effect = {
		TARGET = scope:den_challenger
		REASON = friend_built_den_together
	}
	if = {
		limit = { has_relation_bully = scope:den_challenger }
		add_prestige = minor_prestige_loss
	}
	if = {
		limit = {
			scope:den_challenger = {
				NOT = { is_in_the_same_court_as = root }
			}
		}
		add_courtier = scope:den_challenger
	}
}

scripted_effect bp2_yearly_1055_sacred_effect = {
	the_builder_stacking_learning_rewards_effect = yes
	create_artifact = {
		name = holy_stick
		description = holy_stick.desc
		type = spear
		visuals = spear
		modifier = artifact_learning_lifestyle_xp_1_modifier
		modifier = artifact_learning_2_modifier
		save_scope_as = holy_stick_artifact
		wealth = 25
		quality = 25
		max_durability = 40
		generate_history = no
	}
	add_learning_skill = 1
}

#You are challenged to a den-building competition
bp2_yearly.1055 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1055.t
	desc = {
		desc = bp2_yearly.1055.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						is_close_family_of = scope:den_challenger
						is_extended_family_of = scope:den_challenger
					}
				}
				desc = bp2_yearly.1055.desc_related
			}
			triggered_desc = {
				trigger = {
					OR = {
						has_relation_crush = scope:den_challenger
						has_relation_friend = scope:den_challenger
						has_relation_best_friend = scope:den_challenger
						has_relation_bully = scope:den_challenger
					}
				}
				desc = bp2_yearly.1055.desc_relations
			}
			desc = bp2_yearly.1055.desc_liege
		}
		desc = bp2_yearly.1055.outro
	}
	theme = education
	#Some more flavor than simply using reference = terrain
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_jungle_trigger = yes }
		}
		reference = wilderness_jungle
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_steppe_trigger = yes }
		}
		reference = ep2_travel_settlement_steppe
	}
	override_background = {
		trigger = {
			root.location = { 
				OR = {
					graphical_drylands_trigger = yes
					graphical_wilderness_desert_trigger = yes
				}
			}
		}
		reference = drylands
	}
	#Fallback
	override_background = { reference = ep2_hunt_forest_hut }
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:den_challenger
		animation = schadenfreude
	}
	trigger = {
		is_available = yes
		is_landed_or_landless_administrative = yes
		#If the child is AI, we don't want a player regent to get snubbed by the AI builder child
		trigger_if = {
			limit = { is_ai = yes }
			has_active_diarchy = yes
			diarch = { is_ai = yes }
		}
	}
	on_trigger_fail = { the_builder_clean_up_flags_effect = yes }
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		if = {
			limit = {
				any_relation = {
					type = bully
					is_available_ai = yes
				}
			}
			random_relation = {
				type = bully
				limit = { is_available_ai = yes }
				save_scope_as = den_challenger
			}
		}
		else_if = {
			limit = {
				any_courtier_or_guest = {
					is_available_ai = yes
					is_adult = no
					age > 8
				}
			}
			random_courtier = {
				limit = {
					is_available_ai = yes
					is_adult = no
					age > 8
				}
				save_scope_as = den_challenger
			}
		}
		else_if = {
			limit = {
				any_pool_character = {
					province = root.location
					is_available_ai = yes
					is_adult = no
					age > 8
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					is_available_ai = yes
					is_adult = no
					age > 8
				}
				save_scope_as = den_challenger
			}
		}
		else = {
			create_character = {
				location = root.location
				template = peasant_child_character
				age = { 9 13 }
				culture = root.location.culture
				faith = root.location.faith
				save_scope_as = den_challenger
				after_creation = {
					add_character_flag = created
				}
			}
		}
	}
	#Use the virtue of 'free' labor
	option = {
		name = bp2_yearly.1055.a		
		flavor = bp2_yearly.1055.a.flavor
		the_builder_stewardship_choice_tracker_effect = yes
		show_as_tooltip = { bp2_yearly_1055_economy_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = gregarious
				factor = 0
			}
		}
	}
	#Build higher walls _together_!
	option = {
		name = bp2_yearly.1055.b		
		flavor = bp2_yearly.1055.b.flavor
		the_builder_martial_choice_tracker_effect = yes
		show_as_tooltip = { bp2_yearly_1055_martial_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
		}
	}
	#Pft, only Deity can judge _me_
	option = {
		name = bp2_yearly.1055.c		
		flavor = bp2_yearly.1055.c.flavor
		the_builder_learning_choice_tracker_effect = yes
		show_as_tooltip = {
			the_builder_stacking_learning_rewards_effect = yes
			add_learning_skill = 1 
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				factor = 0
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
		}
	}
	after = {
		trigger_event = {
			id = bp2_yearly.1056
			days = 1
		}
		scope:den_challenger = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

#Follow-up: Things went down in the woods
bp2_yearly.1056 = {
	type = character_event
	content_source = dlc_009
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:stewardship }
				desc = bp2_yearly.1056.t_economy
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:martial }
				desc = bp2_yearly.1056.t_martial
			}
			desc = bp2_yearly.1056.t_pious
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:stewardship }
				desc = bp2_yearly.1056.desc_economy
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:martial }
				desc = bp2_yearly.1056.desc_martial
			}
			desc = bp2_yearly.1056.desc_pious
		}
	}
	theme = education
	#Some more flavor than simply using reference = terrain
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_jungle_trigger = yes }
		}
		reference = wilderness_jungle
	}
	override_background = {
		trigger = {
			root.location = { graphical_wilderness_steppe_trigger = yes }
		}
		reference = ep2_travel_settlement_steppe
	}
	override_background = {
		trigger = {
			root.location = { 
				OR = {
					graphical_drylands_trigger = yes
					graphical_wilderness_desert_trigger = yes
				}
			}
		}
		reference = drylands
	}
	#Fallback
	override_background = { reference = ep2_hunt_forest_cave }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { var:the_builder_latest_choice ?= flag:stewardship }
			animation = personality_dishonorable
		}
		triggered_animation = {
			trigger = { var:the_builder_latest_choice ?= flag:martial }
			animation = admiration
		}
		animation = disbelief
	}
	right_portrait = {
		trigger = {
			root = {
				OR = {
					var:the_builder_latest_choice ?= flag:stewardship
					var:the_builder_latest_choice ?= flag:martial
				}
			}
		}
		triggered_animation = {
			trigger = { 
				root = { var:the_builder_latest_choice ?= flag:stewardship }
			}
			animation = disapproval
		}
		character = scope:den_challenger
		animation = happiness
	}
	artifact = {
		trigger = { exists = scope:holy_stick_artifact }
		target = scope:holy_stick_artifact
		position = lower_center_portrait
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		if = {
			limit = { var:the_builder_latest_choice ?= flag:stewardship }
			bp2_yearly_1055_economy_effect = yes
			the_builder_stewardship_increment_effect = yes
		}
		else_if = {
			limit = { var:the_builder_latest_choice ?= flag:martial }
			bp2_yearly_1055_martial_effect = yes
			the_builder_martial_increment_effect = yes
		}
		else = { 
			bp2_yearly_1055_sacred_effect = yes
			the_builder_learning_increment_effect = yes
		}
	}
	#Alright
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { var:the_builder_latest_choice ?= flag:stewardship }
						desc = bp2_yearly.1056.a_economy
					}
					triggered_desc = {
						trigger = { var:the_builder_latest_choice ?= flag:martial }
						desc = bp2_yearly.1056.a_martial
					}
					desc = bp2_yearly.1056.a_pious
				}
			}
		}
		#Effects are handled in the immediate
	}
	#We are 8-11 years
	after = {
		if = {
			limit = { age = 8 }
			trigger_event = {
				id = bp2_yearly.1060
				years = { 4 5 }
			}
		}
		else_if = {
			limit = { age = 9 }
			trigger_event = {
				id = bp2_yearly.1060
				years = { 3 4 }
			}
		}
		#10-11 years
		else = {
			trigger_event = {
				id = bp2_yearly.1060
				years = { 1 2 }
			}
		}
	}
}

#################
scripted_trigger bp2_yearly_1060_appropriate_character_trigger = {
	NOR = {
		opinion = {
			target = root
			value < medium_negative_opinion
		}
		has_relation_rival = root
		has_relation_nemesis = root
		this = root
	}
	is_available_ai = yes
	location = root.location
}

scripted_effect bp2_yearly_1060_give_economical_reward_effect = {
	the_builder_stacking_stewardship_rewards_effect = yes
	scope:economical_architecture_book = {
		set_owner = root
		add_artifact_history = {
			location = root.location
			actor = scope:steward_character
			recipient = root
			type = given
		}
	}
	add_stewardship_skill = 1
	improve_relationship_effect = {
		TARGET = scope:steward_character
		REASON = friend_bonded_over_economical_architecture
	}
}

scripted_effect bp2_yearly_1060_give_martial_reward_effect = {
	the_builder_stacking_martial_rewards_effect = yes
	scope:martial_architecture_book = {
		set_owner = root
		add_artifact_history = {
			location = root.location
			actor = scope:martial_character
			recipient = root
			type = given
		}
	}
	add_martial_skill = 1
	improve_relationship_effect = {
		TARGET = scope:martial_character
		REASON = friend_bonded_over_martial_architecture
	}
}

scripted_effect bp2_yearly_1060_give_learned_reward_effect = {
	the_builder_stacking_learning_rewards_effect = yes
	scope:religious_architecture_book = {
		set_owner = root
		add_artifact_history = {
			location = root.location
			actor = scope:learned_character
			recipient = root
			type = given
		}
	}
	add_learning_skill = 1
	improve_relationship_effect = {
		TARGET = scope:learned_character
		REASON = friend_bonded_over_religious_architecture
	}
}

#Appreciate the architecture of your capital
bp2_yearly.1060 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1060.t
	desc = bp2_yearly.1060.desc 
	theme = education
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = thinking
	}
	lower_left_portrait = { character = scope:steward_character }
	lower_center_portrait = { character = scope:martial_character }
	lower_right_portrait = { character = scope:learned_character }
	trigger = {
		is_available = yes
		is_landed_or_landless_administrative = yes
		exists = capital_province
		#If the child is AI, we don't want a player regent to get snubbed by the AI builder child
		trigger_if = {
			limit = { is_ai = yes }
			has_active_diarchy = yes
			diarch = { is_ai = yes }
		}
	}
	on_trigger_fail = { the_builder_clean_up_flags_effect = yes }
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		set_variable = {
			name = the_builder_sightseed_capital
			value = capital_province
		}
		#Find a steward character
		if = {
			limit = { 
				cp:councillor_steward ?= { bp2_yearly_1060_appropriate_character_trigger = yes }
			}
			cp:councillor_steward = { save_scope_as = steward_character }
		}
		#Or a steward-savvy courtier
		else_if = {
			limit = {
				any_courtier_or_guest = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					stewardship >= medium_skill_rating
				}
			}
			random_courtier_or_guest = {
				limit = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					stewardship >= medium_skill_rating
				}
				add_to_list = potential_steward_characters
			}
			ordered_in_list = {
				list = potential_steward_characters
				order_by = stewardship
				save_scope_as = steward_character
			}
		}
		#Or a steward-savvy pool character
		else_if = {
			limit = {
				any_pool_character = {
					province = root.location
					bp2_yearly_1060_appropriate_character_trigger = yes
					stewardship >= medium_skill_rating
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					stewardship >= medium_skill_rating
				}
				save_scope_as = steward_character
			}
			#And add them to court
			hidden_effect = { add_courtier = scope:steward_character }
		}
		#Or simply create a steward-savvy character
		else = {
			create_character = {
				location = root.location
				template = bp1_yearly_2021_stewardship_person_template
				save_scope_as = steward_character
				after_creation = {
					add_character_flag = created
				}
			}
			#And add them to court
			hidden_effect = { add_courtier = scope:steward_character }
		}
		#Give them a steward architecture book
		hidden_effect_new_object = {
			scope:steward_character = {
				if = {
					limit = { artifacts_use_indian_books_trigger = yes }
					create_artifact = {
						name = economical_architecture_book
						description = economical_architecture_book_desc
						type = journal
						visuals = indian_book
						modifier = artifact_stewardship_lifestyle_xp_2_modifier
						modifier = artifact_stewardship_1_modifier
						modifier = artifact_city_holding_build_speed_add_1_modifier
						save_scope_as = economical_architecture_book
					}
				}
				else = {
					create_artifact = {
						name = economical_architecture_book
						description = economical_architecture_book_desc
						type = journal
						visuals = book
						modifier = artifact_stewardship_lifestyle_xp_2_modifier
						modifier = artifact_stewardship_1_modifier
						modifier = artifact_city_holding_build_speed_add_1_modifier
						save_scope_as = economical_architecture_book
					}
				}
			}
		}
		#Find a martial character
		if = {
			limit = { 
				cp:councillor_marshal ?= {
					bp2_yearly_1060_appropriate_character_trigger = yes
					this != scope:steward_character
				}
			}
			cp:councillor_marshal = { save_scope_as = martial_character }
		}
		#Or a martial-savvy courtier
		else_if = {
			limit = {
				any_courtier_or_guest = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					martial >= medium_skill_rating
					this != scope:steward_character
				}
			}
			random_courtier_or_guest = {
				limit = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					martial >= medium_skill_rating
					this != scope:steward_character
				}
				add_to_list = potential_martial_characters
			}
			ordered_in_list = {
				list = potential_martial_characters
				order_by = martial
				save_scope_as = martial_character
			}
		}
		else_if = {
			limit = {
				any_pool_character = {
					province = root.location
					bp2_yearly_1060_appropriate_character_trigger = yes
					martial >= medium_skill_rating
					this != scope:steward_character
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					martial >= medium_skill_rating
					this != scope:steward_character
				}
				save_scope_as = martial_character
			}
			#And add them to court
			hidden_effect = { add_courtier = scope:martial_character }
		}
		#Or simply create a martial-savvy character
		else = {
			create_character = {
				location = root.location
				template = bp1_yearly_2021_martial_person_template
				save_scope_as = martial_character
				after_creation = {
					add_character_flag = created
				}
			}
			#And add them to court
			hidden_effect = { add_courtier = scope:martial_character }
		}
		#Give them a martial architecture book
		hidden_effect_new_object = {
			scope:martial_character = {
				if = {
					limit = { artifacts_use_indian_books_trigger = yes }
					create_artifact = {
						name = martial_architecture_book
						description = martial_architecture_book_desc
						type = journal
						visuals = indian_book
						modifier = artifact_martial_lifestyle_xp_2_modifier
						modifier = artifact_martial_1_modifier
						modifier = artifact_castle_holding_build_speed_add_1_modifier
						save_scope_as = martial_architecture_book
					}
				}
				else = {
					create_artifact = {
						name = martial_architecture_book
						description = martial_architecture_book_desc
						type = journal
						visuals = book
						modifier = artifact_martial_lifestyle_xp_2_modifier
						modifier = artifact_martial_1_modifier
						modifier = artifact_castle_holding_build_speed_add_1_modifier
						save_scope_as = martial_architecture_book
					}
				}
			}
		}
		#Find a learned character
		if = {
			limit = { 
				cp:councillor_court_chaplain ?= {
					bp2_yearly_1060_appropriate_character_trigger = yes
					NOR = { 
						this = scope:steward_character
						this = scope:martial_character
					}
				}
			}
			cp:councillor_court_chaplain = { save_scope_as = learned_character }
		}
		#Or a learning-savvy courtier
		else_if = {
			limit = {
				any_courtier_or_guest = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					learning >= medium_skill_rating
					NOR = { 
						this = scope:steward_character
						this = scope:martial_character
					}
				}
			}
			random_courtier_or_guest = {
				limit = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					learning >= medium_skill_rating
					NOR = { 
						this = scope:steward_character
						this = scope:martial_character
					}
				}
				add_to_list = potential_learned_characters
			}
			ordered_in_list = {
				list = potential_learned_characters
				order_by = learning
				save_scope_as = learned_character
			}
		}
		#Or a learning-savvy pool character
		else_if = {
			limit = {
				any_pool_character = {
					province = root.location
					bp2_yearly_1060_appropriate_character_trigger = yes
					learning >= medium_skill_rating
					NOR = { 
						this = scope:steward_character
						this = scope:martial_character
					}
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					bp2_yearly_1060_appropriate_character_trigger = yes
					learning >= medium_skill_rating
					NOR = { 
						this = scope:steward_character
						this = scope:martial_character
					}
				}
				save_scope_as = learned_character
			}
			#And add them to court
			hidden_effect = { add_courtier = scope:learned_character }
		}
		#Or simply create a learning-savvy character
		else = {
			create_character = {
				location = root.location
				template = bp1_yearly_2021_learning_person_template
				save_scope_as = learned_character
				after_creation = {
					add_character_flag = created
				}
			}
			#And add them to court
			hidden_effect = { add_courtier = scope:learned_character }
		}
		#Give them a religious architecture book
		hidden_effect_new_object = {
			scope:learned_character = {
				if = {
					limit = { artifacts_use_indian_books_trigger = yes }
					create_artifact = {
						name = religious_architecture_book
						description = religious_architecture_book_desc
						type = journal
						visuals = indian_book
						modifier = artifact_learning_lifestyle_xp_2_modifier
						modifier = artifact_learning_1_modifier
						modifier = artifact_church_holding_build_speed_add_1_modifier
						save_scope_as = religious_architecture_book
					}
				}
				else = {
					create_artifact = {
						name = religious_architecture_book
						description = religious_architecture_book_desc
						type = journal
						visuals = book
						modifier = artifact_learning_lifestyle_xp_2_modifier
						modifier = artifact_learning_1_modifier
						modifier = artifact_church_holding_build_speed_add_1_modifier
						save_scope_as = religious_architecture_book
					}
				}
			}
		}
	}
	#Check out _that_ tradeport
	option = {
		name = bp2_yearly.1060.a		
		flavor = bp2_yearly.1060.a.flavor
		the_builder_stewardship_choice_tracker_effect = yes
		show_as_tooltip = { bp2_yearly_1060_give_economical_reward_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	#I like a good wall
	option = {
		name = bp2_yearly.1060.b		
		flavor = bp2_yearly.1060.b.flavor
		the_builder_martial_choice_tracker_effect = yes
		show_as_tooltip = { bp2_yearly_1060_give_martial_reward_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#The temple, obviously
	option = {
		name = bp2_yearly.1060.c		
		flavor = bp2_yearly.1060.c.flavor
		the_builder_learning_choice_tracker_effect = yes
		show_as_tooltip = { bp2_yearly_1060_give_learned_reward_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = craven
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	after = {
		trigger_event = {
			id = bp2_yearly.1061
			days = 1
		}
		scope:steward_character ?= {
			silent_disappearance_ai_if_created_effect = yes
		}
		scope:martial_character ?= {
			silent_disappearance_ai_if_created_effect = yes
		}
		scope:learned_character ?= {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

#Follow-up: You spend the day with WhatsTheirFace
bp2_yearly.1061 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1061.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:stewardship }
				desc = bp2_yearly.1061.desc_steward
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:martial }
				desc = bp2_yearly.1061.desc_martial
			}
			desc = bp2_yearly.1061.desc_religion
		}
		desc = bp2_yearly.1061.outro
	}
	theme = education
	override_background = { 
		trigger = { var:the_builder_latest_choice ?= flag:stewardship }
		reference = market
	}
	override_background = { 
		trigger = { var:the_builder_latest_choice ?= flag:martial }
		reference = armory
	}
	override_background = { 
		trigger = { var:the_builder_latest_choice ?= flag:learning }
		reference = holy_site_generic
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:architecture_character
		animation = personality_compassionate
	}
	artifact = {
		target = scope:book_to_get
		position = lower_center_portrait
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		#Save character for the portrait
		if = {
			limit = { var:the_builder_latest_choice ?= flag:stewardship }
			scope:steward_character = { save_scope_as = architecture_character }
			scope:economical_architecture_book = { save_scope_as = book_to_get }
			bp2_yearly_1060_give_economical_reward_effect = yes
			the_builder_stewardship_increment_effect = yes
		}
		else_if = {
			limit = { var:the_builder_latest_choice ?= flag:martial }
			scope:martial_character = { save_scope_as = architecture_character }
			scope:martial_architecture_book = { save_scope_as = book_to_get }
			bp2_yearly_1060_give_martial_reward_effect = yes
			the_builder_martial_increment_effect = yes
		}
		else = {
			scope:learned_character = { save_scope_as = architecture_character }
			scope:religious_architecture_book = { save_scope_as = book_to_get }
			bp2_yearly_1060_give_learned_reward_effect = yes
			the_builder_learning_increment_effect = yes
		}
	}
	#Alright
	option = {
		name = bp2_yearly.1061.a		
		flavor = bp2_yearly.1061.a.flavor
		#Effect is handled in immediate
	}
	#We are 12-13 years
	after = {
		trigger_event = {
			id = bp2_yearly.1065
			years = { 1 2 }
		}
	}
}

#################
scripted_trigger bp2_yearly.1065_appropriate_province_trigger = {
	trigger_if = {
		limit = { exists = barony.holder }
		barony.holder = { is_ai = yes }
	}
	has_holding = yes
	has_free_building_slot = yes 
}

scripted_trigger bp2_yearly_1065_can_build_building_trigger = {
	building_$BUILDING$_requirement_terrain = yes
	NOT = { has_building = $BUILDING$_08 }
}

scripted_effect bp2_yearly_1065_add_buff_effect = {
	if = {
		limit = { has_province_modifier = $DIRECTION$_improvements_modifier }
		remove_province_modifier = $DIRECTION$_improvements_modifier
		add_province_modifier = {
			modifier = $DIRECTION$_improvements_modifier
			years = 10
		}
	}
	else = {
		add_province_modifier = {
			modifier = $DIRECTION$_improvements_modifier
			years = 10
		}
	}
}

scripted_effect bp2_yearly_1065_determine_economical_building_effect = {
	#Can we actually build one of these buildings?
	if = {
		limit = {
			OR = {
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = common_tradeport }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = pastures }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = hunting_grounds }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = orchards }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = farm_estates }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = cereal_fields }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = logging_camps }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = peat_quarries }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = hill_farms }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = elephant_pens }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = plantations }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = quarries }
			}
		}
		#Yes? In that case, randomize which!
		random_list = {
			#Tradeport
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = common_tradeport }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:common_tradeport
				}
			}
			#Pastures
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = pastures }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:pastures
				}
			}
			#Hunting Grounds
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = hunting_grounds }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:hunting_grounds
				}
			}
			#Orchards
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = orchards }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:orchards
				}
			}
			#Farm Estates
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = farm_estates }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:farm_estates
				}
			}
			#Cereal Fields
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = cereal_fields }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:cereal_fields
				}
			}
			#Logging Camps
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = logging_camps }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:logging_camps
				}
			}
			#Peat Quarries
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = peat_quarries }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:peat_quarries
				}
			}
			#Hill Farms
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = hill_farms }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:hill_farms
				}
			}
			#Elephant Pens
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = elephant_pens }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:elephant_pens
				}
			}
			#Plantations
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = plantations }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:plantations
				}
			}
			#Quarries
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = quarries }
				}
				set_variable = {
					name = bp2_yearly_1065_economical_building
					value = flag:quarries
				}
			}
		}
	}
	#Otherwise you get a modifier
	else = {
		set_variable = {
			name = bp2_yearly_1065_economical_building
			value = flag:modifier
		}
	}
}

scripted_effect bp2_yearly_1065_add_economical_building_effect = {
	#Tradeport
	if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:common_tradeport }
		add_next_building_tier_effect = { BUILDING = common_tradeport }
	}
	#Pastures
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:pastures }
		add_next_building_tier_effect = { BUILDING = pastures }
	}
	#Hunting Grounds
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:hunting_grounds }
		add_next_building_tier_effect = { BUILDING = hunting_grounds }
	}
	#Orchards
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:orchards }
		add_next_building_tier_effect = { BUILDING = orchards }
	}
	#Farm Estates
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:farm_estates }
		add_next_building_tier_effect = { BUILDING = farm_estates }
	}
	#Cereal Fields
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:cereal_fields }
		add_next_building_tier_effect = { BUILDING = cereal_fields }
	}
	#Logging Camps
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:logging_camps }
		add_next_building_tier_effect = { BUILDING = logging_camps }
	}
	#Peat Quarries
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:peat_quarries }
		add_next_building_tier_effect = { BUILDING = peat_quarries }
	}
	#Hill Farms
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:hill_farms }
		add_next_building_tier_effect = { BUILDING = hill_farms }
	}
	#Elephant Pens
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:elephant_pens }
		add_next_building_tier_effect = { BUILDING = elephant_pens }
	}
	#Plantations
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:plantations }
		add_next_building_tier_effect = { BUILDING = plantations }
	}
	#Quarries
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:quarries }
		add_next_building_tier_effect = { BUILDING = quarries }
	}
	#You're all decked out; have a modifier
	else_if = {
		limit = { var:bp2_yearly_1065_economical_building ?= flag:modifier }
		bp2_yearly_1065_add_buff_effect = { DIRECTION = economical }
	}
}

scripted_effect bp2_yearly_1065_determine_martial_building_effect = {
	#Can we actually build one of these buildings?
	if = {
		limit = {
			OR = {
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = ramparts }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = curtain_walls }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = watchtowers }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = hill_forts }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = outposts }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = barracks }
				bp2_yearly_1065_can_build_building_trigger = { BUILDING = smiths }
			}
		}
		#Yes? In that case, randomize which!
		random_list = {
			#Ramparts
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = ramparts }
				}
				set_variable = {
					name = bp2_yearly_1065_martial_building
					value = flag:ramparts
				}
			}
			#Walls
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = curtain_walls }
				}
				set_variable = {
					name = bp2_yearly_1065_martial_building
					value = flag:curtain_walls
				}
			}
			#Watch Towers
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = watchtowers }
				}
				set_variable = {
					name = bp2_yearly_1065_martial_building
					value = flag:watchtowers
				}
			}
			#Hill Forts
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = hill_forts }
				}
				set_variable = {
					name = bp2_yearly_1065_martial_building
					value = flag:hill_forts
				}
			}
			#Barracks
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = barracks }
				}
				set_variable = {
					name = bp2_yearly_1065_martial_building
					value = flag:barracks
				}
			}
			#Smiths
			10 = {
				trigger = {
					bp2_yearly_1065_can_build_building_trigger = { BUILDING = smiths }
				}
				set_variable = {
					name = bp2_yearly_1065_martial_building
					value = flag:smiths
				}
			}
		}
	}
	#Otherwise you get a modifier
	else = {
		set_variable = {
			name = bp2_yearly_1065_martial_building
			value = flag:modifier
		}
	}
}

scripted_effect bp2_yearly_1065_add_martial_building_effect = {
	#Ramparts
	if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:ramparts }
		add_next_building_tier_effect = { BUILDING = ramparts }
	}
	#Curtain Walls
	else_if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:curtain_walls }
		add_next_building_tier_effect = { BUILDING = curtain_walls }
	}
	#Watch Towers
	else_if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:watchtowers }
		add_next_building_tier_effect = { BUILDING = watchtowers }
	}
	#Hill Fort
	else_if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:hill_forts }
		add_next_building_tier_effect = { BUILDING = hill_forts }
	}
	#Barracks
	else_if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:barracks }
		add_next_building_tier_effect = { BUILDING = barracks }
	}
	#Smiths
	else_if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:smiths }
		add_next_building_tier_effect = { BUILDING = smiths }
	}
	#You're all decked out; have a modifier
	else_if = {
		limit = { var:bp2_yearly_1065_martial_building ?= flag:modifier }
		bp2_yearly_1065_add_buff_effect = { DIRECTION = martial }
	}
}

scripted_effect bp2_yearly_1065_determine_pious_building_effect = {
	#Can we actually build one of these buildings?
	if = {
		limit = {
			OR = {
				county.holder.faith = { has_doctrine_parameter = can_build_megaliths }
				county.faith = { has_doctrine_parameter = can_build_megaliths }
				NOT = { has_building = monastic_schools_08 }
			}
		}
		#Yes? In that case, randomize which!
		random_list = {
			#Monastic Schools
			10 = {
				trigger = {
					NOT = { has_building = monastic_schools_08 }
				}
				set_variable = {
					name = bp2_yearly_1065_pious_building
					value = flag:monastic_schools
				}
			}
			#Megalith
			10 = {
				trigger = {
					OR = {
						county.holder.faith = { has_doctrine_parameter = can_build_megaliths }
						county.faith = { has_doctrine_parameter = can_build_megaliths }
					}
				}
				set_variable = {
					name = bp2_yearly_1065_pious_building
					value = flag:megalith
				}
			}
		}
	}
	#Otherwise you get a modifier
	else = {
		set_variable = {
			name = bp2_yearly_1065_pious_building
			value = flag:modifier
		}
	}
}

scripted_effect bp2_yearly_1065_add_pious_building_effect = {
	#Monastic Schools
	if = {
		limit = { var:bp2_yearly_1065_pious_building ?= flag:monastic_schools }
		add_next_building_tier_effect = { BUILDING = monastic_schools }
	}
	#Megalith
	else_if = {
		limit = { var:bp2_yearly_1065_pious_building ?= flag:megalith }
		add_next_building_tier_effect = { BUILDING = megalith }
	}
	#You're all decked out; have a modifier
	else_if = {
		limit = { var:bp2_yearly_1065_pious_building ?= flag:modifier }
		bp2_yearly_1065_add_buff_effect = { DIRECTION = pious }
	}
}

#Your input is desired on the next building target
bp2_yearly.1065 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1065.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { 
					scope:current_regent ?= {
						OR = {
							is_parent_of = root
							is_grandparent_of = root
							is_great_grandparent_of = root
						}
					}
				}
				desc = bp2_yearly.1065.intro_parent
			}
			triggered_desc = {
				trigger = { exists = scope:current_regent }
				desc = bp2_yearly.1065.intro_regent
			}
			desc = bp2_yearly.1065.intro
		}
		first_valid = {
			triggered_desc = {
				trigger = { 
					scope:current_regent ?= {
						OR = {
							is_parent_of = root
							is_grandparent_of = root
							is_great_grandparent_of = root
						}
					}
					exists = scope:province_holder
				}
				desc = bp2_yearly.1065.desc_parent_mayor
			}
			triggered_desc = {
				trigger = { 
					scope:current_regent ?= {
						OR = {
							is_parent_of = root
							is_grandparent_of = root
							is_great_grandparent_of = root
						}
					}
				}
				desc = bp2_yearly.1065.desc_parent_mayor
			}
			triggered_desc = {
				trigger = { 
					exists = scope:current_regent
					exists = scope:province_holder
				}
				desc = bp2_yearly.1065.desc_regent_mayor
			}
			triggered_desc = {
				trigger = { exists = scope:current_regent }
				desc = bp2_yearly.1065.desc_regent
			}
			triggered_desc = {
				trigger = { exists = scope:province_holder }
				desc = bp2_yearly.1065.desc_mayor
			}
			desc = bp2_yearly.1065.desc
		}
		desc = bp2_yearly.1065.outro
	}
	theme = education
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = { exists = scope:current_regent }
		character = scope:current_regent
		animation = disapproval
	}
	lower_right_portrait = {
		trigger = { exists = scope:province_holder }
		character = scope:province_holder
	}
	trigger = {
		is_available = yes
		is_landed_or_landless_administrative = yes
		#If the child is AI, we don't want a player regent to get snubbed by the AI builder child
		trigger_if = {
			limit = { is_ai = yes }
			has_active_diarchy = yes
			diarch = { is_ai = yes }
		}
	}
	on_trigger_fail = {
		if = {
			limit = { exists = var:the_builder_sightseed_capital }
			remove_variable = the_builder_sightseed_capital
		}
		the_builder_clean_up_flags_effect = yes
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		if = {
			limit = { has_active_diarchy = yes }
			diarch = { save_scope_as = current_regent }
		}
		#Find a holding to build a building in
		if = {
			limit = {
				OR = {
					any_held_title = { 
						title_tier = county
						any_county_province = { bp2_yearly.1065_appropriate_province_trigger = yes }
					}
					any_sub_realm_county = { 
						county.holder ?= { is_ai = yes }
						any_county_province = { bp2_yearly.1065_appropriate_province_trigger = yes }
					}
				}
			}
			#First one with an empty slot
			if = {
				limit = {
					any_held_title = { 
						title_tier = county
						any_county_province = { bp2_yearly.1065_appropriate_province_trigger = yes }
					}	
				}
				random_held_title = {
					title_tier = county
					limit = { 
						any_county_province = { bp2_yearly.1065_appropriate_province_trigger = yes }
					}
					save_scope_as = 1065_county_for_building
				}
			}
			#Or a sub-realm with an empty slot
			else_if = {
				limit = {
					any_sub_realm_county = {
						county.holder ?= { is_ai = yes }
						any_county_province = { bp2_yearly.1065_appropriate_province_trigger = yes }
					}
				}
				random_sub_realm_county = {
					limit = {
						county.holder ?= { is_ai = yes }
						any_county_province = { bp2_yearly.1065_appropriate_province_trigger = yes }
					}
					save_scope_as = 1065_sub_realm_county_for_building
				}
			}
		}
		else = {
			random_held_title = {
				title_tier = county
				random_county_province = { save_scope_as = 1065_province_for_buffing }
			}
		}
		#Find the scopes in the province
		if = {
			limit = { 
				NOT = { exists = scope:1065_province_for_buffing }
			}
			#Hash out which one of our own provinces to build in
			if = {
				limit = { exists = scope:1065_county_for_building }
				scope:1065_county_for_building = {
					random_county_province = {
						limit = { bp2_yearly.1065_appropriate_province_trigger = yes }
						save_scope_as = 1065_province_for_building
					}
				}
			}
			#... or a sub-realm province
			else = {
				scope:1065_sub_realm_county_for_building = {
					random_county_province = {
						limit = { bp2_yearly.1065_appropriate_province_trigger = yes }
						save_scope_as = 1065_province_for_building
					}
				}
			}
			#Save scopes for loc
			scope:1065_province_for_building = {
				if = {
					limit = {
						exists = barony.holder
						barony.holder != root
						trigger_if = {
							limit = { exists = scope:current_regent }
							barony.holder != scope:current_regent
						}
					}
					barony.holder = { save_scope_as = province_holder }
				}
			}
			set_variable = {
				name = the_builder_constructed_building_in
				value = scope:1065_province_for_building
			}
		}
		else = {
			#Save scopes for loc
			scope:1065_province_for_buffing = {
				if = {
					limit = {
						exists = barony.holder
						barony.holder != root
						trigger_if = {
							limit = { exists = scope:current_regent }
							barony.holder != scope:current_regent
						}
					}
					barony.holder = { save_scope_as = province_holder }
				}
			}
			set_variable = {
				name = the_builder_constructed_building_in
				value = scope:1065_province_for_buffing
			}
		}
		#Determine what buildings you should get to pick from - and actually give the effect in the option
		if = {
			limit = { exists = scope:1065_province_for_building }
			scope:1065_province_for_building = {
				bp2_yearly_1065_determine_economical_building_effect = yes
				bp2_yearly_1065_determine_martial_building_effect = yes
				bp2_yearly_1065_determine_pious_building_effect = yes
			}	
		}	
	}
	#Economical improvements
	option = {
		name = bp2_yearly.1065.a		
		flavor = bp2_yearly.1065.a.flavor
		the_builder_stacking_stewardship_rewards_effect = yes
		add_stewardship_skill = 1
		if = {
			limit = { exists = scope:1065_province_for_building }
			scope:1065_province_for_building = { bp2_yearly_1065_add_economical_building_effect = yes }
		}
		else_if = {
			limit = { exists = scope:1065_province_for_buffing }
			scope:1065_province_for_buffing = { 
				bp2_yearly_1065_add_buff_effect = { DIRECTION = economical } 
			}
		}
		the_builder_stewardship_choice_tracker_effect = yes
		the_builder_stewardship_increment_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				ai_has_warlike_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	#Martial improvements
	option = {
		name = bp2_yearly.1065.b		
		flavor = bp2_yearly.1065.b.flavor
		the_builder_stacking_martial_rewards_effect = yes
		add_martial_skill = 1
		if = {
			limit = { exists = scope:1065_province_for_building }
			scope:1065_province_for_building = { bp2_yearly_1065_add_martial_building_effect = yes }
		}
		else_if = {
			limit = { exists = scope:1065_province_for_buffing }
			scope:1065_province_for_buffing = { 
				bp2_yearly_1065_add_buff_effect = { DIRECTION = martial }
			}
		}
		the_builder_martial_choice_tracker_effect = yes
		the_builder_martial_increment_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				ai_has_economical_boom_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#Pious improvements, obviously
	option = {
		name = bp2_yearly.1065.c		
		flavor = bp2_yearly.1065.c.flavor
		the_builder_stacking_learning_rewards_effect = yes
		add_learning_skill = 1
		if = {
			limit = { exists = scope:1065_province_for_building }
			scope:1065_province_for_building = {
				if = {
					limit = {
						NOT = { has_holding_type = church_holding }
					}
					custom_tooltip = bp2_yearly.1065.c.tt
					set_holding_type = church_holding
				}
				bp2_yearly_1065_add_pious_building_effect = yes
			}
		}
		else_if = {
			limit = { exists = scope:1065_province_for_buffing }
			scope:1065_province_for_buffing = { 
				bp2_yearly_1065_add_buff_effect = { DIRECTION = pious }
			}
		}
		the_builder_learning_choice_tracker_effect = yes
		the_builder_learning_increment_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				ai_has_economical_boom_personality = yes
				factor = 0
			}
			modifier = {
				ai_has_warlike_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#We are 14-15
	after = {
		if = {
			limit = { exists = scope:1065_province_for_building }
			if = {
				limit = { exists = var:bp2_yearly_1065_economical_building }
				remove_variable = bp2_yearly_1065_economical_building
			}
			if = {
				limit = { exists = var:bp2_yearly_1065_martial_building }
				remove_variable = bp2_yearly_1065_martial_building
			}
			if = {
				limit = { exists = var:bp2_yearly_1065_pious_building }
				remove_variable = bp2_yearly_1065_pious_building
			}
		}
		trigger_event = {
			id = bp2_yearly.1070
			years = { 4 6 }
		}
	}
}

#################
#All of our efforts have culminated into _this_

scripted_effect bp2_yearly_1070_city_builder_effect = {
	the_builder_stacking_stewardship_rewards_effect = yes
	give_nickname = nick_the_city_builder
	add_trait = architect
	add_character_modifier = the_city_builder_modifier
}

scripted_effect bp2_yearly_1070_castle_builder_effect = {
	the_builder_stacking_martial_rewards_effect = yes
	give_nickname = nick_the_castle_builder
	add_trait = architect
	add_character_modifier = the_castle_builder_modifier
}

scripted_effect bp2_yearly_1070_temple_builder_effect = {
	the_builder_stacking_learning_rewards_effect = yes
	give_nickname = nick_the_temple_builder
	add_trait = architect
	add_character_modifier = the_temple_builder_modifier
}

bp2_yearly.1070 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1070.t
	desc = {
		desc = bp2_yearly.1070.intro
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:1070_province_to_build_in }
				desc = bp2_yearly.1070.desc
			}
			triggered_desc = {
				trigger = { exists = scope:1070_province_to_buff }
				desc = bp2_yearly.1070.desc_no_province
			}
		}
		#Actually none of the above apply
		triggered_desc = {
			trigger = {
				NOR = {
					exists = scope:1070_province_to_build_in
					exists = scope:1070_province_to_buff
				}
			}
			desc = bp2_yearly.1070.desc_no_province_no_buff
		}
	}
	theme = education
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = personality_compassionate
	}
	trigger = {
		is_available = yes
		is_landed_or_landless_administrative = yes
		has_active_diarchy = no
		has_variable = the_builder_sightseed_capital
	}
	on_trigger_fail = {
		the_builder_clean_up_flags_effect = yes
		if = {
			limit = { exists = var:the_builder_sightseed_capital }
			remove_variable = the_builder_sightseed_capital
		}
		if = {
			limit = { exists = var:the_builder_constructed_building_in }
			remove_variable = the_builder_constructed_building_in
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_positive_effect"
		var:the_builder_sightseed_capital ?= { save_scope_as = sightseed_capital }
		var:the_builder_constructed_building_in ?= { save_scope_as = constructed_building_in }
		#Find a holding to build
		if = {
			limit = {
				OR = {
					any_held_title = { county_has_empty_province_trigger = yes }
					any_sub_realm_county = { 
						county.holder ?= { is_ai = yes }
						any_county_province = { province_has_no_holding_trigger = yes }
					}
				}
			}
			#Build in our own area first
			ordered_held_title = {
				limit = { county_has_empty_province_trigger = yes }
				order_by = development_level
				save_scope_as = 1070_county_to_build_in
			}
			if = {
				limit = { 
					NOT = { exists = scope:1070_county_to_build_in }
				}
				#Then a sub realm
				ordered_sub_realm_county = {
					limit = { 
						county.holder ?= { is_ai = yes }
						any_county_province = { province_has_no_holding_trigger = yes }
					}
					order_by = development_level
					save_scope_as = 1070_county_to_build_in
				}
			}
			scope:1070_county_to_build_in = {
				random_county_province = {
					limit = { province_has_no_holding_trigger = yes }
					set_variable = { 
						name = the_builder_holding
						value = root
					}
					save_scope_as = 1070_province_to_build_in
				}
			}
			set_variable = {
				name = the_builder_constructed_holding
				value = scope:1070_province_to_build_in
			}
		}
		#If no empty provinces, buff a random holding
		else_if = {
			limit = {
				any_held_title = {
					title_tier = county
					any_county_province = {
						NOR = { 
							has_province_modifier = improved_by_the_city_builder_modifier
							has_province_modifier = improved_by_the_castle_builder_modifier 
							has_province_modifier = improved_by_the_temple_builder_modifier 
						}
					}
				}
				any_sub_realm_county = {
					any_county_province = {
						NOR = { 
							has_province_modifier = improved_by_the_city_builder_modifier
							has_province_modifier = improved_by_the_castle_builder_modifier 
							has_province_modifier = improved_by_the_temple_builder_modifier 
						}
					}
				}
			}
			#Least developed county
			ordered_held_title = {
				title_tier = county
				order_by = {
					value = development_level
					multiply = -1
				}
				save_scope_as = 1070_county_to_buff
			}
			if = {
				limit = {
					NOT = { exists = scope:1070_county_to_buff }
				}
				#Least developed sub realm county
				ordered_sub_realm_county = {
					limit = { 
						any_county_province = {
							NOR = { 
								has_province_modifier = improved_by_the_city_builder_modifier
								has_province_modifier = improved_by_the_castle_builder_modifier 
								has_province_modifier = improved_by_the_temple_builder_modifier 
							}
						}
					}
					order_by = {
						value = development_level
						multiply = -1
					}
					save_scope_as = 1070_county_to_buff
				}
			}
			scope:1070_county_to_buff = {
				ordered_county_province = {
					limit = {
						NOR = { 
							has_province_modifier = improved_by_the_city_builder_modifier
							has_province_modifier = improved_by_the_castle_builder_modifier 
							has_province_modifier = improved_by_the_temple_builder_modifier 
						}
					}
					#Least developed holdng
					order_by = {
						value = county.development_level
						multiply = -1
					}
					save_scope_as = 1070_province_to_buff
				}
			}
		} 
	}
	#Build or buff a city
	option = {
		name = {
			text = {
				first_valid = {
					#Build city
					triggered_desc = {
						trigger = { exists = scope:1070_province_to_build_in }
						desc = bp2_yearly.1070.a	
					}
					#Buff holding
					triggered_desc = {
						trigger = { exists = scope:1070_province_to_buff }
						desc = bp2_yearly.1070.a_buff	
					}
					#I would probs focus on economy
					desc = bp2_yearly.1070.a_none
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { exists = scope:1070_province_to_build_in }
					desc = bp2_yearly.1070.a.flavor
				}
				desc = bp2_yearly.1070.a.flavor_none
			}
		}
		the_builder_stewardship_choice_tracker_effect = yes
		#We build!
		if = {
			limit = { exists = scope:1070_province_to_build_in } 
			scope:1070_province_to_build_in = { 
				begin_create_holding = { type = city_holding }
			}
			#Some custom loc to look proper in tooltip
			custom_description_no_bullet = { text = upon_holding_completion }
			show_as_tooltip = { 
				bp2_yearly_1070_city_builder_effect = yes
				dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
			}
		}
		#We buff
		else_if = {
			limit = { exists = scope:1070_province_to_buff } 
			bp2_yearly_1070_city_builder_effect = yes
			scope:1070_province_to_buff = { add_province_modifier = improved_by_the_city_builder_modifier }
		}
		#... we really should never end up here. Have some renown, because obviously your domain is pristine.
		else = {
			bp2_yearly_1070_city_builder_effect = yes
			dynasty ?= { add_dynasty_prestige = medium_dynasty_prestige_gain }
		}
		ai_chance = {
			base = 100
			modifier = {
				ai_has_warlike_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	#Build or buff a castle
	option = {
		name = {
			text = {
				first_valid = {
					#Build castle
					triggered_desc = {
						trigger = { exists = scope:1070_province_to_build_in }
						desc = bp2_yearly.1070.b	
					}
					#Buff holding
					triggered_desc = {
						trigger = { exists = scope:1070_province_to_buff }
						desc = bp2_yearly.1070.b_buff	
					}
					#I would probs focus on defense
					desc = bp2_yearly.1070.b_none
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							exists = scope:1070_province_to_build_in
							exists = scope:1070_province_to_buff
						}
					}
					desc = bp2_yearly.1070.b.flavor	
				}
				desc = bp2_yearly.1070.b.flavor_none
			}
		}
		the_builder_martial_choice_tracker_effect = yes
		#We build!
		if = {
			limit = { exists = scope:1070_province_to_build_in } 
			scope:1070_province_to_build_in = { 
				begin_create_holding = { type = castle_holding }
			}
			#Some custom loc to look proper in tooltip
			custom_description_no_bullet = { text = upon_holding_completion }
			show_as_tooltip = { 
				bp2_yearly_1070_castle_builder_effect = yes
				dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
			}
		}
		#We buff
		else_if = {
			limit = { exists = scope:1070_province_to_buff } 
			bp2_yearly_1070_castle_builder_effect = yes
			scope:1070_province_to_buff = { add_province_modifier = improved_by_the_castle_builder_modifier }
		}
		#... we really should never end up here. Have some renown, because obviously your domain is pristine.
		else = {
			bp2_yearly_1070_castle_builder_effect = yes
			dynasty ?= { add_dynasty_prestige = medium_dynasty_prestige_gain }
		}
		ai_chance = {
			base = 100
			modifier = {
				ai_has_economical_boom_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#Build or buff a temple
	option = {
		name = bp2_yearly.1070.c
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							exists = scope:1070_province_to_build_in
							exists = scope:1070_province_to_buff
						}
					}
					desc = bp2_yearly.1070.c.flavor	
				}
				desc = bp2_yearly.1070.c.flavor_none
			}
		}
		the_builder_learning_choice_tracker_effect = yes
		#We build!
		if = {
			limit = { exists = scope:1070_province_to_build_in } 
			scope:1070_province_to_build_in = { 
				begin_create_holding = { type = church_holding }
			}
			#Some custom loc to look proper in tooltip
			custom_description_no_bullet = { text = upon_holding_completion }
			show_as_tooltip = { 
				bp2_yearly_1070_temple_builder_effect = yes
				dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
			}
		}
		#We buff
		else_if = {
			limit = { exists = scope:1070_province_to_buff } 
			bp2_yearly_1070_temple_builder_effect = yes
			scope:1070_province_to_buff = { add_province_modifier = improved_by_the_temple_builder_modifier }
		}
		#... we really should never end up here. Have some renown, because obviously your domain is pristine.
		else = {
			bp2_yearly_1070_temple_builder_effect = yes
			dynasty ?= { add_dynasty_prestige = medium_dynasty_prestige_gain }
		}
		ai_chance = {
			base = 100
			modifier = {
				ai_has_economical_boom_personality = yes
				factor = 0
			}
			modifier = {
				ai_has_warlike_personality = yes
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	after = {
		if = {
			limit = { exists = var:the_builder_sightseed_capital }
			remove_variable = the_builder_sightseed_capital
		}
		if = {
			limit = { exists = var:the_builder_constructed_building_in }
			remove_variable = the_builder_constructed_building_in
		}
		#If the player for whatever reason manually cancels the holding
		if = {
			limit = { exists = scope:1070_province_to_build_in }
			set_variable = {
				name = the_builder_holding_cancelled_safeguard
				value = scope:1070_province_to_build_in
				years = 6 #In general, a holding takes 5 years to build
			}
			#You dun messed up, son
			trigger_event = {
				id = bp2_yearly.1072
				years = 6
			}
		}
	}
}

#Follow-up: Get the sweet sweet loo... I mean, sweet sweet effects!
bp2_yearly.1071 = {
	type = character_event
	content_source = dlc_009
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:stewardship }
				desc = bp2_yearly.1071.t_city
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:martial }
				desc = bp2_yearly.1071.t_castle
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:learning }
				desc = bp2_yearly.1071.t_temple
			}
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:stewardship }
				desc = bp2_yearly.1071.desc_city
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:martial }
				desc = bp2_yearly.1071.desc_castle
			}
			triggered_desc = {
				trigger = { var:the_builder_latest_choice ?= flag:learning }
				desc = bp2_yearly.1071.desc_temple
			}
		}
		desc = bp2_yearly.1071.outro
	}
	theme = education
	override_background = { 
		trigger = { var:the_builder_latest_choice ?= flag:stewardship }
		reference = market
	}
	override_background = { 
		trigger = { var:the_builder_latest_choice ?= flag:martial }
		reference = courtyard
	}
	override_background = { 
		trigger = { var:the_builder_latest_choice ?= flag:learning }
		reference = holy_site_generic
	}
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	immediate = {
		#play_music_cue = "mx_cue_positive_effect"
		var:the_builder_constructed_holding ?= { save_scope_as = constructed_holding }
	}
	#Alright
	option = {
		name = bp2_yearly.1071.a		
		flavor = bp2_yearly.1071.a.flavor
		if = {
			limit = { var:the_builder_latest_choice ?= flag:stewardship }
			bp2_yearly_1070_city_builder_effect = yes
		}
		else_if = {
			limit = { var:the_builder_latest_choice ?= flag:martial }
			bp2_yearly_1070_castle_builder_effect = yes
		}
		else_if = {
			limit = { var:the_builder_latest_choice ?= flag:learning }
			bp2_yearly_1070_temple_builder_effect = yes
		}
		dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
	}
	after = {
		if = {
			limit = { has_variable = the_builder_constructed_holding }
			remove_variable = the_builder_constructed_holding
		}
		the_builder_clean_up_flags_effect = yes
	}
}

#Clean up: You dun messed up, son
bp2_yearly.1072 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.1072.t
	desc = bp2_yearly.1072.desc
	theme = education
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = sadness
	}
	trigger = {
		has_variable = the_builder_holding_cancelled_safeguard
	}
	immediate = {
		#play_music_cue = "mx_cue_negative"
		var:the_builder_holding_cancelled_safeguard = { save_scope_as = cancelled_holding }
	}
	#Wa-wa
	option = {
		name = bp2_yearly.1072.a
	}
	after = {
		if = {
			limit = { has_variable = the_builder_holding_cancelled_safeguard }
			remove_variable = the_builder_holding_cancelled_safeguard
		}
		the_builder_clean_up_flags_effect = yes
	}
}
