namespace = bp1_yearly
####
# bp1_yearly.2020 - A consort attempts to influence you into changing your heir
# bp1_yearly.2030 - Mopey consort wants some guidance
# bp1_yearly.2040 - Two consorts are disagreeing
# bp1_yearly.2050 - Friendly consorts want to start a study circle
# bp1_yearly.2060 - Friendly consorts want to tutor other consort's child
# bp1_yearly.2070 - Childless older soulmate spouse ponders your relationship
#
####

##################################################
# #A spouse/consort attempts to influence you into changing your heir
# by Filippa Gannholm Kirsten
# #bp1_yearly.2020-2023
##################################################
scripted_trigger bp1_yearly_2020_relevant_consort_trigger = {
	is_available_ai_adult = yes
	NOT = { has_relation_rival = root }
	any_child = { 
		NOT = { 
			this = { is_primary_heir_of = root }
		}
	}
	any_child = {
		count > 0
		bp1_yearly_2020_relevant_child_trigger = yes
	}
}

scripted_trigger bp1_yearly_2020_relevant_child_trigger = {
	age >= 13
	is_available_child = yes
	NOT = { has_relation_rival = root }
	trigger_if = {
		limit = {
			root = {
				has_realm_law = male_only_law
			}
		}
		is_male = yes
	}
	trigger_else_if = {
		limit = {
			root = {
				has_realm_law = female_only_law
			}
		}
		is_female = yes
	}
	trigger_else = {
		always = yes
	}
}

scripted_effect bp1_yearly_2020_duel_effect = {
	duel = {
		skill = $SKILL$
		target = scope:bp1_yearly_2020_target
		#They brute force kill the rival/nemesis
		25 = {
			modifier = {
				$SKILL$ = martial
				factor = 0.5
			}
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = { intrigue > martial }
				}
				scope:bp1_yearly_2020_target = {
					death = {
						death_reason = death_murder
						killer = scope:bp1_yearly_2020_influencing_partner
					}
				}
			}
			else = {
				scope:bp1_yearly_2020_target = {
					death = {
						death_reason = death_defenestration
						killer = scope:bp1_yearly_2020_influencing_partner
					}
				}
			}
			#Set designated heir-event
			root = {
				add_character_flag = bp1_yearly_2020_target_killed
				trigger_event = {
					id = bp1_yearly.2023
					days = { 2 5 }
				}
			}
		}
		#They are imprisoned by the rival/nemesis
		25 = {
			#Needs to have a prison to imprison
			trigger = {
				scope:bp1_yearly_2020_target = {
					is_landed = yes
				}
			}
			#To block narration-breaking notification events
			scope:bp1_yearly_2020_influencing_partner = { 
				add_character_flag = {
					flag = bp1_yearly_2020_block_imprisonment_event
					days = 1
				}
			}
			rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2020_influencing_partner IMPRISONER = scope:bp1_yearly_2020_target }
			#Imprisonment letter
			root = {
				trigger_event = {
					id = bp1_yearly.2022
					days = 3
				}
			}
		}
		#They are killed by the rival/nemesis
		25 = {
			scope:bp1_yearly_2020_influencing_partner = {
				death = {
					death_reason = death_defenestration
					killer = scope:bp1_yearly_2020_target
				}
			}
			#Death letter
			root = {
				trigger_event = {
					id = bp1_yearly.2022
					days = 3
				}
			}
		}
	}
}

scripted_effect bp1_yearly_2020_chance_of_murderous_partner_effect = {
	$MURDEROUS_PARTNER$ = {
		random_list = {
			#Attempt to murder heir
			25 = {
				trigger = {
					OR = {
						has_trait = vengeful
						has_trait = deceitful
						has_trait = sadistic
						has_trait = ambitious
						has_trait = wrathful
					}
					can_start_scheme = {
						type = murder
						target_character = root.player_heir
					}
				}
				#If they killed our rival/nemesis we probably deserve some payback
				modifier = {
					has_character_flag = bp1_yearly_2020_target_killed
					factor = 2
				}
				#If we took the person option but didn't pick anyone, they can sort of understand
				modifier = {
					NOT = { exists = scope:bp1_yearly_2021_new_courtier }
					factor = 1.25
				}
				#MURDER VENGEANCE reeee
				start_scheme = {
					type = murder
					target_character = root.player_heir
				}
			}
			50 = {
				modifier = {
					NOR = {
						has_character_flag = bp1_yearly_2020_target_killed
						exists = scope:bp1_yearly_2021_new_courtier
					}
					factor = 1.5
				}
				#Do nothing
			}
		}
	}
}

scripted_trigger bp1_yearly_2020_landed_partners_parent_trigger = {
	is_available_ai_adult = yes
	is_at_war = no
	is_landed = yes
	opinion = {
		target = scope:bp1_yearly_2020_influencing_partner
		value >= 0
	}
}

scripted_effect bp1_yearly_2020_rival_nemesis_progress_effect = {
	$PERSON$ = {
		save_temporary_scope_as = new_heir_parent
	}
	if = {
		limit = {
			OR = {
				can_set_relation_potential_rival_trigger = { CHARACTER = scope:new_heir_parent }
				can_set_relation_rival_trigger = { CHARACTER = scope:new_heir_parent }
			}
		}
		progress_towards_rival_effect = { CHARACTER = scope:new_heir_parent OPINION = default_rival_opinion REASON = rival_succession_scheme }
	}
	else_if = {
		limit = {
			NOR = {
				can_set_relation_potential_rival_trigger = { CHARACTER = scope:new_heir_parent }
				can_set_relation_rival_trigger = { CHARACTER = scope:new_heir_parent }
			}
			can_set_relation_nemesis_trigger = { CHARACTER = scope:new_heir_parent }
		}
		set_relation_nemesis = {
			reason = nemesis_heir_ousted
			copy_reason = rival
			target = scope:new_heir_parent
		}
	}
}

scripted_effect bp1_yearly_2020_heir_change_opinions_effect = {
	reverse_add_opinion = {
		target = root.player_heir
		modifier = primary_heir_replaced_opinion
		opinion = -50
	}
	#Apply opinion & rivalry to the appropriate opposite-sex biological parent
	if = {
		limit = {
			scope:bp1_yearly_2020_influencing_partner = { is_female = yes }
		}
		if = {
			limit = {
				exists = root.player_heir.mother
				root.player_heir.mother = { is_alive = yes }
			}
			root.player_heir.mother = {
				add_opinion = {
					target = root
					modifier = parent_primary_heir_replaced_opinion
					opinion = -50
				}
				save_scope_as = bp1_yearly_2020_scorned_parent
				if = {
					limit = { 
						scope:bp1_yearly_2020_influencing_partner = { is_alive = yes }
					}
					bp1_yearly_2020_rival_nemesis_progress_effect = { PERSON = scope:bp1_yearly_2020_influencing_partner }
				}	
			}
		}
	}
	else_if = {
		limit = { 
			exists = root.player_heir.father 
			root.player_heir.father = { is_alive = yes }
		}
		root.player_heir.father = {
			add_opinion = {
				target = root
				modifier = parent_primary_heir_replaced_opinion
				opinion = -50
			}
			save_scope_as = bp1_yearly_2020_scorned_parent
			if = {
				limit = { 
					scope:bp1_yearly_2020_influencing_partner = { is_alive = yes }
				}
				bp1_yearly_2020_rival_nemesis_progress_effect = { PERSON = scope:bp1_yearly_2020_influencing_partner }
			}	
		}
	}
	reverse_add_opinion = {
		target = scope:bp1_yearly_2020_child_to_become_heir
		modifier = pleased_opinion
		opinion = 50
	}
	if = {
		limit = {
			scope:bp1_yearly_2020_influencing_partner = { is_alive = yes }
		}
		reverse_add_opinion = {
			target = scope:bp1_yearly_2020_influencing_partner
			modifier = pleased_opinion
			opinion = 50
		}
	}
}

bp1_yearly.2020 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2020.t
	desc = bp1_yearly.2020.desc
	theme = family
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = paranoid
			}
			animation = paranoia
		}
		animation = worry
	}
	right_portrait = {
		character = scope:bp1_yearly_2020_influencing_partner
		animation = personality_greedy
	}
	lower_center_portrait = {
		character = scope:bp1_yearly_2020_child_to_become_heir
	}
	lower_right_portrait = {
		trigger = { exists = scope:bp1_yearly_2020_influencing_partners_parent }
		character = scope:bp1_yearly_2020_influencing_partners_parent
	}
	#Set up the cooldown
	cooldown = { years = 5 }
	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_ai = no
		is_landed = yes
		exists = root.primary_heir
		#Do we have any marital-like relationships with partners whose child is not your primary heir
		any_consort = { bp1_yearly_2020_relevant_consort_trigger = yes }
		any_relation = {
			type = rival # Includes nemeses
			is_available_at_peace_adult = yes 
			highest_held_title_tier <= tier_county
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			any_consort = {
				bp1_yearly_2020_relevant_consort_trigger = yes
				has_trait = family_first
			}
			add = 2
		}
		modifier = {
			any_consort = {
				bp1_yearly_2020_relevant_consort_trigger = yes
				has_trait_rank = {
					trait = education_intrigue
					rank >= 3
				}
			}
			add = 2
		}
		modifier = {
			any_consort = {
				bp1_yearly_2020_relevant_consort_trigger = yes
				has_trait = schemer
			}
			add = 2
		}
		modifier = {
			any_consort = {
				bp1_yearly_2020_relevant_consort_trigger = yes
				has_trait = ambitious
			}
			add = 2
		}
		modifier = {
			any_consort = {
				bp1_yearly_2020_relevant_consort_trigger = yes
				short_term_gold >= root.massive_gold_value
			}
			add = 2
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_secret"
		#Pick a relevant, weighted partner
		random_consort = {
			limit = { bp1_yearly_2020_relevant_consort_trigger = yes }
			weight = {
				base = 1
				modifier = {
					has_trait = ambitious
					add = 2
				}
				modifier = {
					has_trait = arrogant
					add = 2
				}
				modifier = {
					has_trait = diligent
					add = 2
				}
				modifier = {
					has_trait = deceitful
					add = 5
				}
				modifier = {
					has_trait = schemer
					add = 5
				}
				modifier = {
					has_trait = family_first
					add = 10
				}
				modifier = {
					has_trait_rank = {
						trait = education_intrigue
						rank >= 3
					}
					add = 10
				}
				modifier = {
					short_term_gold >= massive_gold_value
					add = 100
				}
				modifier = {
					has_trait = forgiving
					add = -2
				}
				modifier = {
					has_trait = compassionate
					add = -2
				}
				modifier = {
					has_trait = generous
					add = -2
				}
				modifier = {
					has_trait = dull
					add = -3
				}
				modifier = {
					has_trait = lazy
					add = -5
				}
				modifier = {
					has_trait_rank = {
						trait = intellect_bad
						rank > 0
					}
					add = -5
				}
			}
			save_scope_as = bp1_yearly_2020_influencing_partner
		}
		#Pick a child
		scope:bp1_yearly_2020_influencing_partner = {
			random_child = {
				limit = {
					bp1_yearly_2020_relevant_child_trigger = yes
					#_Tradeoff_ they said
					OR = {
						has_trait = clubfooted
						has_trait = hunchbacked
						has_trait = lisping
						has_trait = stuttering
						has_trait = dwarf
						has_trait = giant
						has_trait = inbred
						has_trait = weak
						has_trait = dull
						has_trait = spindly
						has_trait = scaly
						has_trait = albino
						has_trait = wheezing
						has_trait = bleeder
						has_trait_rank = {
							trait = beauty_bad
							rank >= 1
						}
						has_trait_rank = {
							trait = intellect_bad
							rank >= 1
						}
						has_trait_rank = {
							trait = physique_bad
							rank >= 1
						}
						has_trait = maimed
						has_trait = one_eyed
						has_trait = one_legged
						has_trait = disfigured
						has_trait = scarred
						has_trait = blind
						has_trait = depressed_genetic
						has_trait = lunatic_genetic
						has_trait = possessed_genetic
						has_trait = ill
						has_trait = leper
					}
				}
				alternative_limit = {
					bp1_yearly_2020_relevant_child_trigger = yes
				}
				save_scope_as = bp1_yearly_2020_child_to_become_heir
			}
		}
		#Set up a rival/nemesis, if any
		random_relation = {
			type = rival
			limit = {
				has_relation_nemesis = root
				is_available_at_peace_adult = yes 
				highest_held_title_tier <= tier_county
			}
			alternative_limit = { 
				is_available_at_peace_adult = yes 
				highest_held_title_tier <= tier_county
			}
			save_scope_as = bp1_yearly_2020_target
		}
		#Saving scope for halfsies comparisons
		save_scope_value_as = {
			name = half_gold_check_2020
			value = {
				value = root.massive_gold_value
				multiply = 0.5
			}
		}
		#Look for a hookable landed parent of your partner
		scope:bp1_yearly_2020_influencing_partner = {
			#If our partner has enough gold, we only need a hookable landed parent
			if = {
				limit = { short_term_gold >= root.massive_gold_value }
				random_parent = {
					limit = { bp1_yearly_2020_landed_partners_parent_trigger = yes }
					save_scope_as = bp1_yearly_2020_influencing_partners_parent_only_hook
					#For the portrait
					save_scope_as = bp1_yearly_2020_influencing_partners_parent
				}
			}
			#Else check if they can go halfsies on the gold
			else_if = {
				limit = {
					short_term_gold < root.massive_gold_value
					short_term_gold >= scope:half_gold_check_2020
				}
				random_parent = {
					limit = {
						short_term_gold < root.massive_gold_value
						bp1_yearly_2020_landed_partners_parent_trigger = yes
					}
					#For the portrait
					save_scope_as = bp1_yearly_2020_influencing_partners_parent
					#Do they have enough gold together to warrant the root.massive_gold_value
					save_scope_value_as = {
						name = halfsies_check_2020
						value = {
							value = scope:bp1_yearly_2020_influencing_partner.gold
							add = scope:bp1_yearly_2020_influencing_partners_parent.gold
						}
					}
					if = {
						limit = {
							scope:halfsies_check_2020 >= root.massive_gold_value
						}
						scope:bp1_yearly_2020_influencing_partners_parent = {
							save_scope_as = bp1_yearly_2020_influencing_partners_parent_halfsies
						}
					}
				}
			}
			#Else the partner parent pays and gets hooked
			else_if = {
				limit = {
					short_term_gold < root.massive_gold_value
				}
				random_parent = {
					limit = {
						short_term_gold >= root.massive_gold_value
						bp1_yearly_2020_landed_partners_parent_trigger = yes 
					}
					save_scope_as = bp1_yearly_2020_influencing_partners_parent_pays
					#For the portrait
					save_scope_as = bp1_yearly_2020_influencing_partners_parent
				}
			}
		}
	}
	#Martial/intrigue brute force duel
	option = {
		name = bp1_yearly.2020.a
		trigger = { exists = scope:bp1_yearly_2020_target }
		#To block the narration-breaking default death notification
		add_character_flag = {
			flag = bp1_yearly_2020_suppress_death_events
			days = 5
		}
		if = {
			#Prioritize intrigue duel, less chance of death
			limit = {
				scope:bp1_yearly_2020_influencing_partner = { intrigue > martial }
			}
			scope:bp1_yearly_2020_influencing_partner = {
				bp1_yearly_2020_duel_effect = { SKILL = intrigue }
			}
		}
		else = {
			scope:bp1_yearly_2020_influencing_partner = {
				bp1_yearly_2020_duel_effect = { SKILL = martial }
			}
		}
		stress_impact = {
			vengeful = medium_stress_impact_gain
			family_first = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}
	#Pay you a massive amount of gold + a hook
	option = {
		name = bp1_yearly.2020.c
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { exists = scope:bp1_yearly_2020_influencing_partners_parent_only_hook }
					desc = bp1_yearly.2020.c_tt_only_hook
				}
				triggered_desc = {
					trigger = {
						exists = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
						can_add_hook = {
							target = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
							type = favor_hook
						}
					}
					desc = bp1_yearly.2020.c_tt_halfsies
				}
				triggered_desc = {
					trigger = { 
						exists = scope:bp1_yearly_2020_influencing_partners_parent_pays
						can_add_hook = {
							target = scope:bp1_yearly_2020_influencing_partners_parent_pays
							type = favor_hook
						}
					}
					desc = bp1_yearly.2020.c_tt_pay_and_hook
				}
			}
		}
		trigger = {
			OR = {
				#If our partner has enough gold
				scope:bp1_yearly_2020_influencing_partner = { short_term_gold >= root.massive_gold_value }
				#Or if they can go halfsies
				AND = {
					scope:bp1_yearly_2020_influencing_partner = { 
						short_term_gold < root.massive_gold_value
						short_term_gold >= scope:half_gold_check_2020
					}
					exists = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
				}
				#Or if partner's parent has enough gold
				exists = scope:bp1_yearly_2020_influencing_partners_parent_pays
			}	
		}
		#Partner pays
		if = {
			limit = {
				scope:bp1_yearly_2020_influencing_partner = { short_term_gold >= root.massive_gold_value }
			}
			scope:bp1_yearly_2020_influencing_partner = {
				pay_short_term_gold = {
					target = root
					gold = root.massive_gold_value
				}
			}
			#Hook partner's parent first
			if = {
				limit = { exists = scope:bp1_yearly_2020_influencing_partners_parent_only_hook }
				add_hook = {
					target = scope:bp1_yearly_2020_influencing_partners_parent_only_hook
					type = favor_hook
				}
			}
			#Else hook partner
			else_if = {
				limit = {
					can_add_hook = {
						target = scope:bp1_yearly_2020_influencing_partner
						type = favor_hook
					}
				}
				add_hook = {
					target = scope:bp1_yearly_2020_influencing_partner
					type = favor_hook
				}
			}
		}
		#They go halfsies
		else_if = {
			limit = { 
				exists = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
				can_add_hook = {
					target = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
					type = favor_hook
				}
			}
			scope:bp1_yearly_2020_influencing_partner = {
				pay_short_term_gold = {
					target = root
					gold = scope:half_gold_check_2020
				}
			}
			scope:bp1_yearly_2020_influencing_partners_parent_halfsies = {
				pay_short_term_gold = {
					target = root
					gold = scope:half_gold_check_2020
				}
			}
			#Hook partner's parent first
			if = {
				limit = { 
					exists = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
					can_add_hook = {
						target = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
						type = favor_hook
					}
				}
				add_hook = {
					target = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
					type = favor_hook
				}
			}
			#Else hook partner
			else_if = {
				limit = {
					can_add_hook = {
						target = scope:bp1_yearly_2020_influencing_partner
						type = favor_hook
					}
				}
				add_hook = {
					target = scope:bp1_yearly_2020_influencing_partner
					type = favor_hook
				}
			}
		}
		#Partner's parent pays
		else_if = {
			limit = { exists = scope:bp1_yearly_2020_influencing_partners_parent_pays }
			scope:bp1_yearly_2020_influencing_partners_parent_pays = {
				pay_short_term_gold = {
					target = root
					gold = root.massive_gold_value
				}
			}
			#Hook partner's parent first
			if = {
				limit = { 
					exists = scope:bp1_yearly_2020_influencing_partners_parent_pays
					can_add_hook = {
						target = scope:bp1_yearly_2020_influencing_partners_parent_pays
						type = favor_hook
					} 
				}
				add_hook = {
					target = scope:bp1_yearly_2020_influencing_partners_parent_pays
					type = favor_hook
				}
			}
			#Else hook partner
			else_if = {
				limit = {
					root = {
						can_add_hook = {
							target = scope:bp1_yearly_2020_influencing_partner
							type = favor_hook
						}
					}
				}
				add_hook = {
					target = scope:bp1_yearly_2020_influencing_partner
					type = favor_hook
				}
			}
		}
		#Deal with opinion reactions to this
		bp1_yearly_2020_heir_change_opinions_effect = yes
		if = {
			limit = { exists = scope:bp1_yearly_2020_influencing_partners_parent_only_hook }
			reverse_add_opinion = {
				target = scope:bp1_yearly_2020_influencing_partners_parent_only_hook
				modifier = pleased_opinion
				opinion = 50
			}
		}
		else_if = {
			limit = { exists = scope:bp1_yearly_2020_influencing_partners_parent_halfsies }
			reverse_add_opinion = {
				target = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
				modifier = pleased_opinion
				opinion = 50
			}
		}
		else_if = {
			limit = { exists = scope:bp1_yearly_2020_influencing_partners_parent_pays }
			reverse_add_opinion = {
				target = scope:bp1_yearly_2020_influencing_partners_parent_pays
				modifier = pleased_opinion
				opinion = 50
			}
		}
		send_interface_toast = {
			title = designate_heir_interaction_notification
			left_icon = root					
			right_icon = scope:bp1_yearly_2020_child_to_become_heir
			set_designated_heir = scope:bp1_yearly_2020_child_to_become_heir
		}
		hidden_effect = {
			if = {
				limit = { exists = scope:bp1_yearly_2020_scorned_parent }
				bp1_yearly_2020_chance_of_murderous_partner_effect = { MURDEROUS_PARTNER = scope:bp1_yearly_2020_scorned_parent }
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
	#Summon an interesting person to join your court
	option = {
		name = bp1_yearly.2020.b
		trigger = {
			#Mutually exclusive to the money + gold option
			NOR = {
				scope:bp1_yearly_2020_influencing_partner = { short_term_gold >= root.massive_gold_value }
				exists = scope:bp1_yearly_2020_influencing_partners_parent_halfsies
				exists = scope:bp1_yearly_2020_influencing_partners_parent_pays
			}
		}
		custom_tooltip = bp1_yearly.2020.b_tt
		trigger_event = {
			id = bp1_yearly.2021
			days = 2
		}
		ai_chance = {
			base = 100
		}
	}
	#Imprison them for merely suggesting this
	option = {
		name = bp1_yearly.2020.d
		trigger = {
			OR = {
				has_trait = sadistic
				has_trait = callous
				has_trait = irritable
				has_trait = paranoid
				has_trait = craven
				has_trait = fickle
			}
		}
		flavor = bp1_yearly.2020.d_tt
		rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2020_influencing_partner IMPRISONER = root }
		stress_impact = {
			craven = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
	#Not interested
	option = {
		name = bp1_yearly.2020.e
		reverse_add_opinion = {
			target = scope:bp1_yearly_2020_influencing_partner
			modifier = insulted_opinion
			opinion = -20
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
		}
		hidden_effect = {
			bp1_yearly_2020_chance_of_murderous_partner_effect = { MURDEROUS_PARTNER = scope:bp1_yearly_2020_influencing_partner }
		}
		ai_chance = {
			base = 100
		}
	}
}

scripted_trigger bp1_yearly_2021_relevant_dynasty_person_trigger = {
	this != scope:bp1_yearly_2020_influencing_partner
	NOT = { is_child_of = scope:bp1_yearly_2020_influencing_partner }
	NOT = { is_primary_heir_of = liege }
	has_any_bad_relationship_with_root_trigger = no
	opinion = {
		target = scope:bp1_yearly_2020_influencing_partner
		value >= 0
	}
	is_landed_or_landless_administrative = no
	is_available_at_peace_ai_adult = yes
	$SKILL$ >= $TARGET$.$SKILL$
}

scripted_trigger bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = {
	this != scope:bp1_yearly_2020_influencing_partner
	NOT = { is_child_of = scope:bp1_yearly_2020_influencing_partner }
	NOT = { is_primary_heir_of = liege }
	has_any_bad_relationship_with_root_trigger = no
	opinion = {
		target = scope:bp1_yearly_2020_influencing_partner
		value >= 0
	}
	is_landed_or_landless_administrative = no
	is_available_at_peace_ai_adult = yes
	$SKILL$ >= high_skill_rating
}

scripted_effect bp1_yearly_2021_add_interesting_courtier_effect = {
	random_list = {
		#Martial Person
		1 = {
			trigger = {
				NOT = { exists = scope:bp1_yearly_2021_martial_person }
			}
			#Let's inject a partner dynasty member if we can
			modifier = {
				scope:bp1_yearly_2020_influencing_partner = {
					exists = dynasty
					OR = {
						AND = {
							exists = scope:bp1_yearly_2021_marshal_scope
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = martial TARGET = scope:bp1_yearly_2021_marshal_scope }
								}
							}
						}
						dynasty = {
							any_dynasty_member = {
								bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = martial }
							}
						}
					}
				}
				add = 20
			}
			modifier = {
				OR = {
					AND = {
						exists = scope:bp1_yearly_2021_marshal_scope
						scope:bp1_yearly_2021_marshal_scope.martial < high_skill_rating
					}
					NOT = { exists = scope:bp1_yearly_2021_marshal_scope }
				}
				add = 10
			}
			#Look for a dynasty member of the consort first
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = {
						exists = dynasty
						OR = {
							AND = {
								exists = scope:bp1_yearly_2021_marshal_scope
								dynasty = {
									any_dynasty_member = {
										bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = martial TARGET = scope:bp1_yearly_2021_marshal_scope }
									}
								}
							}
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = martial }
								}
							}
						}
					}
				}
				scope:bp1_yearly_2020_influencing_partner = {
					#If a marshal currently exists and our dynast has more martial
					if = {
						limit = { exists = scope:bp1_yearly_2021_marshal_scope }
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = martial TARGET = scope:bp1_yearly_2021_marshal_scope }
								}
								save_scope_as = bp1_yearly_2021_martial_person
							}
						}
					}
					#Else just check if the dynast has above 15 martial
					else = {
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = martial }
								}
								save_scope_as = bp1_yearly_2021_martial_person
							}
						}
					}
				}
			}
			else = {
				create_character = {
					location = root.location
					template = bp1_yearly_2021_martial_person_template
					save_scope_as = bp1_yearly_2021_martial_person
				}
				scope:bp1_yearly_2021_martial_person = {
					set_variable = {
						name = created_in_bp1_yearly_2021
						value = yes
						days = 60
					}
				}
			}
		}
		#Learning Person
		1 = {
			trigger = {
				NOT = { exists = scope:bp1_yearly_2021_learning_person }
			}
			#Let's inject a partner dynasty member if we can
			modifier = {
				#If we can change our learning councillor and have an appropriate dynast
				faith = { has_doctrine = doctrine_clerical_succession_temporal_appointment }
				scope:bp1_yearly_2020_influencing_partner = {
					exists = dynasty
					OR = {
						AND = {
							exists = scope:bp1_yearly_2021_chaplain_scope
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = learning TARGET = scope:bp1_yearly_2021_chaplain_scope }
								}
							}
						}
						dynasty = {
							any_dynasty_member = {
								bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = learning }
							}
						}
					}
				}
				add = 20
			}
			modifier = {
				OR = {
					#If we can change our learning councillor and they don't exist
					AND = {
						faith = { has_doctrine = doctrine_clerical_succession_temporal_appointment }
						NOT = { exists = scope:bp1_yearly_2021_chaplain_scope }
					}
					#If we can change our learning councillor and they have less than 15 learning
					AND = {
						faith = { has_doctrine = doctrine_clerical_succession_temporal_appointment }
						exists = scope:bp1_yearly_2021_chaplain_scope
						scope:bp1_yearly_2021_chaplain_scope.learning < high_skill_rating
					}
				}
				add = 10
			}
			#Look for a dynasty member of the consort first
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = {
						exists = dynasty
						OR = {
							AND = {
								exists = scope:bp1_yearly_2021_chaplain_scope
								dynasty = {
									any_dynasty_member = {
										bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = learning TARGET = scope:bp1_yearly_2021_chaplain_scope }
									}
								}
							}
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = learning }
								}
							}
						}
					}
				}
				scope:bp1_yearly_2020_influencing_partner = {
					#If a chaplain currently exists and our dynast has more learning
					if = {
						limit = { exists = scope:bp1_yearly_2021_chaplain_scope }
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = learning TARGET = scope:bp1_yearly_2021_chaplain_scope }
								}
								save_scope_as = bp1_yearly_2021_learning_person
							}
						}
					}
					#Else just check if the dynast has above 15 learning
					else = {
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = learning }
								}
								save_scope_as = bp1_yearly_2021_learning_person
							}
						}	
					}
				}
			}
			else = {
				if = {
					#If witchcraft is accepted, create a witch
					limit = {
						faith = { has_doctrine = doctrine_witchcraft_accepted }
					}
					create_character = {
						location = root.location
						template = bp1_yearly_2021_learning_witch_template
						save_scope_as = bp1_yearly_2021_learning_person
					}
					scope:bp1_yearly_2021_learning_person = {
						set_variable = {
							name = created_in_bp1_yearly_2021
							value = yes
							days = 60
						}
					}
				}
				else = {
					create_character = {
						location = root.location
						template = bp1_yearly_2021_learning_person_template
						save_scope_as = bp1_yearly_2021_learning_person
					}
					scope:bp1_yearly_2021_learning_person = {
						set_variable = {
							name = created_in_bp1_yearly_2021
							value = yes
							days = 60
						}
					}
				}
			}
		}
		#Stewardship Person
		1 = {
			trigger = {
				NOT = { exists = scope:bp1_yearly_2021_stewardship_person }
			}
			#Let's inject a partner dynasty member if we can
			modifier = {
				scope:bp1_yearly_2020_influencing_partner = {
					exists = dynasty
					OR = {
						AND = {
							exists = scope:bp1_yearly_2021_steward_scope
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = stewardship TARGET = scope:bp1_yearly_2021_steward_scope }
								}
							}
						}
						dynasty = {
							any_dynasty_member = {
								bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = stewardship }
							}
						}
					}
				}
				add = 20
			}
			modifier = {
				OR = {
					AND = {
						exists = scope:bp1_yearly_2021_steward_scope
						scope:bp1_yearly_2021_steward_scope.stewardship < high_skill_rating
					}
					NOT = { exists = scope:bp1_yearly_2021_steward_scope }
				}
				add = 10
			}
			#Look for a dynasty member of the consort first
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = {
						exists = dynasty
						OR = {
							AND = {
								exists = scope:bp1_yearly_2021_steward_scope
								dynasty = {
									any_dynasty_member = {
										bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = stewardship TARGET = scope:bp1_yearly_2021_steward_scope }
									}
								}
							}
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = stewardship }
								}
							}
						}
					}
				}
				scope:bp1_yearly_2020_influencing_partner = {
					#If a steward currently exists and our dynast has more stewardship
					if = {
						limit = { exists = scope:bp1_yearly_2021_steward_scope }
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = stewardship TARGET = scope:bp1_yearly_2021_steward_scope }
								}
								save_scope_as = bp1_yearly_2021_stewardship_person
							}
						}
					}
					#Else just check if the dynast has above 15 stewardship
					else = {
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = stewardship }
								}
								save_scope_as = bp1_yearly_2021_stewardship_person
							}
						}
					}
				}
			}
			else = {
				create_character = {
					location = root.location
					template = bp1_yearly_2021_stewardship_person_template
					save_scope_as = bp1_yearly_2021_stewardship_person
				}
				scope:bp1_yearly_2021_stewardship_person = {
					set_variable = {
						name = created_in_bp1_yearly_2021
						value = yes
						days = 60
					}
				}
			}
		}
		#Diplomacy Person
		1 = {
			trigger = {
				NOT = { exists = scope:bp1_yearly_2021_diplomacy_person }
			}
			#Let's inject a partner dynasty member if we can
			modifier = {
				scope:bp1_yearly_2020_influencing_partner = {
					exists = dynasty
					OR = {
						AND = {
							exists = scope:bp1_yearly_2021_chancellor_scope
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = diplomacy TARGET = scope:bp1_yearly_2021_chancellor_scope }
								}
							}
						}
						dynasty = {
							any_dynasty_member = {
								bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = diplomacy }
							}
						}
					}
				}
				add = 20
			}
			modifier = {
				OR = {
					AND = {
						exists = scope:bp1_yearly_2021_chancellor_scope
						scope:bp1_yearly_2021_chancellor_scope.diplomacy < high_skill_rating
					}
					NOT = { exists = scope:bp1_yearly_2021_chancellor_scope }
				}
				add = 10
			}
			#Look for a dynasty member of the consort first
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = {
						exists = dynasty
						OR = {
							AND = {
								exists = scope:bp1_yearly_2021_chancellor_scope
								dynasty = {
									any_dynasty_member = {
										bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = diplomacy TARGET = scope:bp1_yearly_2021_chancellor_scope }
									}
								}
							}
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = diplomacy }
								}
							}
						}
					}
				}
				scope:bp1_yearly_2020_influencing_partner = {
					#If a chancellor currently exists and our dynast has more diplomacy
					if = {
						limit = { exists = scope:bp1_yearly_2021_chancellor_scope }
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = diplomacy TARGET = scope:bp1_yearly_2021_chancellor_scope }
								}
								save_scope_as = bp1_yearly_2021_diplomacy_person
							}
						}	
					}
					#Else just check if the dynast has above 15 diplomacy
					else = {
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = diplomacy }
								}
								save_scope_as = bp1_yearly_2021_diplomacy_person
							}
						}
					}
				}
			}
			else = {
				create_character = {
					location = root.location
					template = bp1_yearly_2021_diplomacy_person_template
					save_scope_as = bp1_yearly_2021_diplomacy_person
				}
				scope:bp1_yearly_2021_diplomacy_person = {
					set_variable = {
						name = created_in_bp1_yearly_2021
						value = yes
						days = 60
					}
				}
			}
		}
		#Intrigue Person
		1 = {
			trigger = {
				NOT = { exists = scope:bp1_yearly_2021_intrigue_person }
			}
			#Let's inject a partner dynasty member if we can
			modifier = {
				scope:bp1_yearly_2020_influencing_partner = {
					exists = dynasty
					OR = {
						AND = {
							exists = scope:bp1_yearly_2021_spymaster_scope
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = intrigue TARGET = scope:bp1_yearly_2021_spymaster_scope }
								}
							}
						}
						dynasty = {
							any_dynasty_member = {
								bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = intrigue }
							}
						}
					}
				}
				add = 20
			}
			modifier = {
				OR = {
					AND = {
						exists = scope:bp1_yearly_2021_spymaster_scope
						scope:bp1_yearly_2021_spymaster_scope.intrigue < high_skill_rating
					}
					NOT = { exists = scope:bp1_yearly_2021_spymaster_scope }
				}
				add = 10
			}
			#Look for a dynasty member of the consort first
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = {
						exists = dynasty
						OR = {
							AND = {
								exists = scope:bp1_yearly_2021_spymaster_scope
								dynasty = {
									any_dynasty_member = {
										bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = intrigue TARGET = scope:bp1_yearly_2021_spymaster_scope }
									}
								}
							}
							dynasty = {
								any_dynasty_member = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = intrigue }
								}
							}
						}
					}
				}
				scope:bp1_yearly_2020_influencing_partner = {
					#If a spymaster currently exists and our dynast has more intrigue
					if = {
						limit = { exists = scope:bp1_yearly_2021_spymaster_scope }
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_trigger = { SKILL = intrigue TARGET = scope:bp1_yearly_2021_spymaster_scope }
								}
								save_scope_as = bp1_yearly_2021_intrigue_person
							}
						}
					}
					#Else just check if the dynast has above 15 intrigue
					else = {
						dynasty = {
							random_dynasty_member = {
								limit = {
									bp1_yearly_2021_relevant_dynasty_person_no_target_trigger = { SKILL = intrigue }
								}
							}
							save_scope_as = bp1_yearly_2021_intrigue_person
						}
					}
				}
			}
			else = {
				create_character = {
					location = root.location
					template = bp1_yearly_2021_intrigue_person_template
					save_scope_as = bp1_yearly_2021_intrigue_person
				}
				scope:bp1_yearly_2021_intrigue_person = {
					set_variable = {
						name = created_in_bp1_yearly_2021
						value = yes
						days = 60
					}
				}
			}
		}
	}
}

scripted_effect bp1_yearly_2021_set_up_portrait_effect = {
	$SCOPE$ = {
		if = {
			limit = {
				NOT = { exists = scope:bp1_yearly_2021_first_person }
			}
			save_scope_as = bp1_yearly_2021_first_person
		}
		else_if = {
			limit = {
				NOT = { exists = scope:bp1_yearly_2021_second_person }
			}
			save_scope_as = bp1_yearly_2021_second_person
		}
		else_if = {
			limit = {
				NOT = { exists = scope:bp1_yearly_2021_third_person }
			}
			save_scope_as = bp1_yearly_2021_third_person
		}
	}
}

scripted_trigger bp1_yearly_2021_clean_up_character_trigger = {
	exists = scope:bp1_yearly_2021_$SKILL$_person
	scope:bp1_yearly_2021_$SKILL$_person = {
		has_variable = created_in_bp1_yearly_2021
		NOT = { has_character_flag = bp1_yearly_2021_chosen_courtier }
	}
}

scripted_effect bp1_yearly_2021_clean_up_character_effect = {
	scope:bp1_yearly_2021_$SKILL$_person = {
		death = {
			death_reason = death_vanished
		}
	}
}

#Summon up a person to your liking
bp1_yearly.2021 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2021.t
	desc = bp1_yearly.2021.desc
	theme = family
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:bp1_yearly_2020_influencing_partner
		animation = chancellor
	}
	#First Person
	lower_left_portrait = {
		trigger = { exists = scope:bp1_yearly_2021_first_person }
		character = scope:bp1_yearly_2021_first_person
	}
	#Second Person
	lower_center_portrait = {
	 	trigger = { exists = scope:bp1_yearly_2021_second_person }
		character = scope:bp1_yearly_2021_second_person
	}
	#Third Person
	lower_right_portrait = {
		trigger = { exists = scope:bp1_yearly_2021_third_person }
		character = scope:bp1_yearly_2021_third_person
	}
	immediate = {
		if = {
			limit = { exists = cp:councillor_marshal }
			cp:councillor_marshal = { save_scope_as = bp1_yearly_2021_marshal_scope }
		}
		if = {
			limit = { exists = cp:councillor_court_chaplain }
			cp:councillor_court_chaplain = { save_scope_as = bp1_yearly_2021_chaplain_scope }
		}
		if = {
			limit = { exists = cp:councillor_steward }
			cp:councillor_steward = { save_scope_as = bp1_yearly_2021_steward_scope }
		}
		if = {
			limit = { exists = cp:councillor_chancellor }
			cp:councillor_chancellor = { save_scope_as = bp1_yearly_2021_chancellor_scope }
		}
		if = {
			limit = { exists = cp:councillor_spymaster }
			cp:councillor_spymaster = { save_scope_as = bp1_yearly_2021_spymaster_scope }
		}
		#Conjure up 3 interesting courtiers
		bp1_yearly_2021_add_interesting_courtier_effect = yes
		bp1_yearly_2021_add_interesting_courtier_effect = yes
		bp1_yearly_2021_add_interesting_courtier_effect = yes
		#Set up portraits to display
		if = {
			limit = { exists = scope:bp1_yearly_2021_martial_person }
			bp1_yearly_2021_set_up_portrait_effect = { SCOPE = scope:bp1_yearly_2021_martial_person }
		}
		if = {
			limit = { exists = scope:bp1_yearly_2021_learning_person }
			bp1_yearly_2021_set_up_portrait_effect = { SCOPE = scope:bp1_yearly_2021_learning_person }
		}
		if = {
			limit = { exists = scope:bp1_yearly_2021_stewardship_person }
			bp1_yearly_2021_set_up_portrait_effect = { SCOPE = scope:bp1_yearly_2021_stewardship_person }
		}
		if = {
			limit = { exists = scope:bp1_yearly_2021_diplomacy_person }
			bp1_yearly_2021_set_up_portrait_effect = { SCOPE = scope:bp1_yearly_2021_diplomacy_person }
		}
		if = {
			limit = { exists = scope:bp1_yearly_2021_intrigue_person }
			bp1_yearly_2021_set_up_portrait_effect = { SCOPE = scope:bp1_yearly_2021_intrigue_person }
		}
	}
	#Pick Martial 
	option = {
		name = bp1_yearly.2021.a
		trigger = { exists = scope:bp1_yearly_2021_martial_person }
		send_interface_toast = {
			title = bp1_yearly.2021.a_tt
			left_icon = scope:bp1_yearly_2021_martial_person
			add_courtier = scope:bp1_yearly_2021_martial_person
			scope:bp1_yearly_2021_martial_person = {
				add_character_flag = bp1_yearly_2021_chosen_courtier
			}
			reverse_add_opinion = {
				target = scope:bp1_yearly_2021_martial_person
				modifier = pleased_opinion
				opinion = 40
			}
		}
		save_scope_as = bp1_yearly_2021_new_courtier
	}
	#Pick Learning
	option = {
		name = bp1_yearly.2021.b
		trigger = { exists = scope:bp1_yearly_2021_learning_person }
		send_interface_toast = {
			title = bp1_yearly.2021.b_tt
			left_icon = scope:bp1_yearly_2021_learning_person
			add_courtier = scope:bp1_yearly_2021_learning_person
			scope:bp1_yearly_2021_learning_person = {
				add_character_flag = bp1_yearly_2021_chosen_courtier
			}
			reverse_add_opinion = {
				target = scope:bp1_yearly_2021_learning_person
				modifier = pleased_opinion
				opinion = 40
			}
		}
		save_scope_as = bp1_yearly_2021_new_courtier
	}
	#Pick Stewardship
	option = {
		name = bp1_yearly.2021.c
		trigger = { exists = scope:bp1_yearly_2021_stewardship_person }
		send_interface_toast = {
			title = bp1_yearly.2021.c_tt
			left_icon = scope:bp1_yearly_2021_stewardship_person
			add_courtier = scope:bp1_yearly_2021_stewardship_person
			scope:bp1_yearly_2021_stewardship_person = {
				add_character_flag = bp1_yearly_2021_chosen_courtier
			}
			reverse_add_opinion = {
				target = scope:bp1_yearly_2021_stewardship_person
				modifier = pleased_opinion
				opinion = 40
			}
		}
		save_scope_as = bp1_yearly_2021_new_courtier
	}
	#Pick Diplomacy
	option = {
		name = bp1_yearly.2021.d
		trigger = { exists = scope:bp1_yearly_2021_diplomacy_person }
		send_interface_toast = {
			title = bp1_yearly.2021.d_tt
			left_icon = scope:bp1_yearly_2021_diplomacy_person
			add_courtier = scope:bp1_yearly_2021_diplomacy_person
			scope:bp1_yearly_2021_diplomacy_person = {
				add_character_flag = bp1_yearly_2021_chosen_courtier
			}
			reverse_add_opinion = {
				target = scope:bp1_yearly_2021_diplomacy_person
				modifier = pleased_opinion
				opinion = 40
			}
		}
		save_scope_as = bp1_yearly_2021_new_courtier
	}
	#Pick Intrigue
	option = {
		name = bp1_yearly.2021.e
		trigger = { exists = scope:bp1_yearly_2021_intrigue_person }
		send_interface_toast = {
			title = bp1_yearly.2021.e_tt
			left_icon = scope:bp1_yearly_2021_intrigue_person
			add_courtier = scope:bp1_yearly_2021_intrigue_person
			scope:bp1_yearly_2021_intrigue_person = {
				add_character_flag = bp1_yearly_2021_chosen_courtier
			}
			reverse_add_opinion = {
				target = scope:bp1_yearly_2021_intrigue_person
				modifier = pleased_opinion
				opinion = 40
			}
		}
		save_scope_as = bp1_yearly_2021_new_courtier
	}
	#Actually, I have changed my mind
	option = {
		name = bp1_yearly.2021.f
		add_character_flag = bp1_yearly_2021_picked_none
		stress_impact = {
			fickle = miniscule_stress_impact_loss
		}
	}
	after = {
		hidden_effect = {
			#...clean up the unused characters
			if = {
				limit = {
					bp1_yearly_2021_clean_up_character_trigger = { SKILL = martial }	
				}
				bp1_yearly_2021_clean_up_character_effect = { SKILL = martial }
			}
			if = {
				limit = {
					bp1_yearly_2021_clean_up_character_trigger = { SKILL = learning }	
				}
				bp1_yearly_2021_clean_up_character_effect = { SKILL = learning }
			}
			if = {
				limit = {
					bp1_yearly_2021_clean_up_character_trigger = { SKILL = stewardship }	
				}
				bp1_yearly_2021_clean_up_character_effect = { SKILL = stewardship }
			}
			if = {
				limit = {
					bp1_yearly_2021_clean_up_character_trigger = { SKILL = diplomacy }	
				}
				bp1_yearly_2021_clean_up_character_effect = { SKILL = diplomacy }	
			}
			if = {
				limit = {
					bp1_yearly_2021_clean_up_character_trigger = { SKILL = intrigue }	
				}
				bp1_yearly_2021_clean_up_character_effect = { SKILL = intrigue }
			}
		}
		trigger_event = {
			id = bp1_yearly.2023
			days = { 2 5 }
		}
	}
}

#Your partner is imprisoned/dead
bp1_yearly.2022 = {
	type = letter_event
	opening = bp1_yearly.2022.t
	desc = {
		desc = bp1_yearly.2022.desc_intro
		first_valid = {
			#Your partner is imprisoned
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2020_influencing_partner = { is_alive = yes }
				}
				desc = bp1_yearly.2022.desc_imprisoned
			}
			#Your partner died
			triggered_desc = {
				desc = bp1_yearly.2022.desc_dead
			}
		}
	}
	sender = scope:bp1_yearly_2020_target
	#Oh no!
	option = {
		name = {
			text = {
				first_valid = {
					#If our partner was imprisoned
					triggered_desc = {
						trigger = { 
							scope:bp1_yearly_2020_influencing_partner = { is_alive = yes }
						}
						desc = bp1_yearly.2022.a_imprisoned
					}
					#Else they died
					triggered_desc = {
						desc = bp1_yearly.2022.b_dead
					}
				}
			}
		}
		#If our partner was imprisoned or killed by rival, deepen rivalry
		if = {
			limit = {
				scope:bp1_yearly_2020_influencing_partner = {
					OR = {
						is_imprisoned_by = scope:bp1_yearly_2020_target
						is_alive = no
					}
				}
				can_set_relation_nemesis_trigger = { CHARACTER = scope:bp1_yearly_2020_target }
			}
			# Split set_relation nemesis into two cases based on what the reason should be. - Chad
			if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = { is_imprisoned_by = scope:bp1_yearly_2020_target }
				}
				set_relation_nemesis = {
					reason = nemesis_imprisoned_partner
					target = scope:bp1_yearly_2020_target
					involved_character = scope:bp1_yearly_2020_influencing_partner
				}
			}
			else_if = {
				limit = {
					scope:bp1_yearly_2020_influencing_partner = { is_alive = no }
				}
				set_relation_nemesis = {
					reason = nemesis_killed_partner
					target = scope:bp1_yearly_2020_target
					involved_character = scope:bp1_yearly_2020_influencing_partner
				}
			}
		}
		if = {
			limit = {
				scope:bp1_yearly_2020_influencing_partner = { is_alive = no }
			}
			stress_impact = {
				vengeful = medium_stress_impact_gain
				wrathful = medium_stress_impact_gain
				family_first = medium_stress_impact_gain
				just = minor_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				vengeful = minor_stress_impact_gain
				wrathful = minor_stress_impact_gain
				family_first = minor_stress_impact_gain
				just = miniscule_stress_impact_gain
			}
		}
		trigger_event = {
			id = bp1_yearly.2023
			days = { 2 5 }
		}
	}
}

scripted_effect bp1_yearly_2023_apply_dis_or_honorable_modifier_effect = {
	#If we already have the modifier, refresh it
	if = {
		limit = {
			NOT = { has_character_modifier = bp1_yearly_2023_$REMOVE$_modifier }
			has_character_modifier = bp1_yearly_2023_$ADD$_modifier
		}
		remove_character_modifier = bp1_yearly_2023_$ADD$_modifier
		add_character_modifier = {
			modifier = bp1_yearly_2023_$ADD$_modifier
			years = 30
		}
	}
	#If we already have the modifier, remove and replace
	else_if = {
		limit = { has_character_modifier = bp1_yearly_2023_$REMOVE$_modifier }
		remove_character_modifier = bp1_yearly_2023_$REMOVE$_modifier
		add_character_modifier = {
			modifier = bp1_yearly_2023_$ADD$_modifier
			years = 30
		}
	}
	#If we don't have any previously, get ADD
	else_if = {
		limit = {
			NOR = { 
				has_character_modifier = bp1_yearly_2023_$ADD$_modifier
				has_character_modifier = bp1_yearly_2023_$REMOVE$_modifier
			}
		}
		add_character_modifier = {
			modifier = bp1_yearly_2023_$ADD$_modifier
			years = 30
		}
	}
}

#Handle the set_designated_heir
bp1_yearly.2023 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2023.t
	desc = {
		first_valid = {
			triggered_desc = {
				#They completed their task
				trigger = {
					OR = {
						has_character_flag = bp1_yearly_2020_target_killed
						exists = scope:bp1_yearly_2021_new_courtier
					}
				}
				desc = bp1_yearly.2023.desc_triumphant
			}
			triggered_desc = {
				#They died while trying to kill your rival/nemesis
				trigger = {
					exists = scope:bp1_yearly_2020_target
					scope:bp1_yearly_2020_influencing_partner = {
						OR = {
							is_imprisoned_by = scope:bp1_yearly_2020_target
							is_alive = no
						}
					}
				}
				desc = bp1_yearly.2023.desc_sad
			}
			triggered_desc = {
				#They killed your rival/nemesis, is presenting their head
				trigger = { 
					NOT = { exists = scope:bp1_yearly_2021_new_courtier }
				}
				desc = bp1_yearly.2023.desc_hesitant
			}
		}
		first_valid = {
			#They attempted to kill your rival/nemesis
			triggered_desc = {
				#They killed your rival/nemesis, is presenting their head
				trigger = {
					exists = scope:bp1_yearly_2020_target
					has_character_flag = bp1_yearly_2020_target_killed
				}
				desc = bp1_yearly.2023.desc_killed_target
			}
			triggered_desc = {
				#They are imprisoned by your rival/nemesis
				trigger = {
					exists = scope:bp1_yearly_2020_target
					scope:bp1_yearly_2020_influencing_partner = {
						is_imprisoned_by = scope:bp1_yearly_2020_target
					}
				}
				desc = bp1_yearly.2023.desc_imprisoned
			}
			triggered_desc = {
				#They died attempting to kill your rival/nemesis
				trigger = {
					exists = scope:bp1_yearly_2020_target
					scope:bp1_yearly_2020_influencing_partner = { is_alive = no }
				}
				desc = bp1_yearly.2023.desc_died
			}
			#They summoned a person of your liking to court
			triggered_desc = {
				#You picked the martial person
				trigger = { 
					exists = scope:bp1_yearly_2021_new_courtier
					# CU: added check for error suppression
					exists = scope:bp1_yearly_2021_martial_person
					scope:bp1_yearly_2021_new_courtier = scope:bp1_yearly_2021_martial_person
				}
				desc = bp1_yearly.2023.desc_picked_martial
			}
			triggered_desc = {
				#You picked the learning person
				trigger = { 
					exists = scope:bp1_yearly_2021_new_courtier
					# CU: added check for error suppression
					exists = scope:bp1_yearly_2021_learning_person
					scope:bp1_yearly_2021_new_courtier = scope:bp1_yearly_2021_learning_person
				}
				desc = bp1_yearly.2023.desc_picked_learning
			}
			triggered_desc = {
				#You picked the stewardship person
				trigger = { 
					exists = scope:bp1_yearly_2021_new_courtier
					# CU: added check for error suppression
					exists = scope:bp1_yearly_2021_stewardship_person
					scope:bp1_yearly_2021_new_courtier = scope:bp1_yearly_2021_stewardship_person
				}
				desc = bp1_yearly.2023.desc_picked_stewardship
			}
			triggered_desc = {
				#You picked the diplomacy person
				trigger = { 
					exists = scope:bp1_yearly_2021_new_courtier
					# CU: added check for error suppression
					exists = scope:bp1_yearly_2021_diplomacy_person
					scope:bp1_yearly_2021_new_courtier = scope:bp1_yearly_2021_diplomacy_person
				}
				desc = bp1_yearly.2023.desc_picked_diplomacy
			}
			triggered_desc = {
				#You picked the intrigue person
				trigger = { 
					exists = scope:bp1_yearly_2021_new_courtier
					# CU: added check for error suppression
					exists = scope:bp1_yearly_2021_intrigue_person
					scope:bp1_yearly_2021_new_courtier = scope:bp1_yearly_2021_intrigue_person
				}
				desc = bp1_yearly.2023.desc_picked_intrigue
			}
			triggered_desc = {
				#You didn't pick any of the summoned people
				trigger = { 
					NOT = { exists = scope:bp1_yearly_2021_new_courtier }
				}
				desc = bp1_yearly.2023.desc_picked_none
			}
		}
		first_valid = {
			#If they did something for us and we're supposed to honor our agreement
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = bp1_yearly_2020_target_killed
						exists = scope:bp1_yearly_2021_new_courtier
					}
				}
				desc = bp1_yearly.2023.desc_outro
			}
			#If the partner is imprisoned or dead
			triggered_desc = {
				trigger = {
					exists = scope:bp1_yearly_2020_target
					scope:bp1_yearly_2020_influencing_partner = {
						OR = {
							is_imprisoned_by = scope:bp1_yearly_2020_target
							is_alive = no
						}
					}
				}
				desc = bp1_yearly.2023.desc_outro_sad
			}
		}	
	}
	theme = family
	override_background = { reference = bp1_kitchen_western }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_character_flag = bp1_yearly_2020_target_killed }
			animation = disbelief
		}
		triggered_animation = {
			trigger = { 
				scope:bp1_yearly_2020_influencing_partner = {
					OR = {
						is_imprisoned = yes
						is_alive = no
					}
				}
			}
			animation = sadness
		}
		animation = personality_rational
	}
	#If the partner isn't dead or imprisoned, display them
	right_portrait = {
		trigger = {
			scope:bp1_yearly_2020_influencing_partner = {
				is_imprisoned = no
				is_alive = yes
			}
		}
		character = scope:bp1_yearly_2020_influencing_partner
		animation = war_over_win
	}
	#If we picked one of the people to join our court, display that person
	lower_left_portrait = {
		trigger = { exists = scope:bp1_yearly_2021_new_courtier }
		character = scope:bp1_yearly_2021_new_courtier
	}
	#Display the 'new heir' in question
	lower_center_portrait = {
		character = scope:bp1_yearly_2020_child_to_become_heir
	}
	lower_right_portrait = {
		trigger = { 
			scope:bp1_yearly_2020_influencing_partner = { is_alive = no }
		}
		character = scope:bp1_yearly_2020_influencing_partner
	}
	immediate = {
		#Lose the stress you were supposed to lose when rival/nemesis died
		if = {
			limit = { has_character_flag = bp1_yearly_2020_target_killed }
			stress_impact = {
				base = minor_stress_impact_loss
			}
		}
	}
	#Set designated heir
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:bp1_yearly_2020_influencing_partner = {
								OR = {
									is_imprisoned_by = scope:bp1_yearly_2020_target
									is_alive = no
								}
							}
						}
						desc = bp1_yearly.2023.a_imprisoned_dead
					}
					triggered_desc = {
						desc = bp1_yearly.2023.a
					}
				}
			}
		}
		#Deal with opinion reactions to this
		bp1_yearly_2020_heir_change_opinions_effect = yes
		if = {
			limit = {
				scope:bp1_yearly_2020_influencing_partner = { is_alive = no }
			}
			bp1_yearly_2023_apply_dis_or_honorable_modifier_effect = { ADD = honorable REMOVE = dishonorable }
			stress_impact = {
				family_first = miniscule_stress_impact_loss
				honest = miniscule_stress_impact_loss
			}
		}
		send_interface_toast = {
			title = designate_heir_interaction_notification
			left_icon = root					
			right_icon = scope:bp1_yearly_2020_child_to_become_heir
			set_designated_heir = scope:bp1_yearly_2020_child_to_become_heir
		}
		hidden_effect = {
			if = {
				limit = { exists = scope:bp1_yearly_2020_scorned_parent }
				bp1_yearly_2020_chance_of_murderous_partner_effect = { MURDEROUS_PARTNER = scope:bp1_yearly_2020_scorned_parent }
			}
		}
	}
	#No, imprison them
	option = {
		name = {
			text = {
				first_valid = {
					#If they successfully killed the rival/nemesis
					triggered_desc = {
						trigger = { has_character_flag = bp1_yearly_2020_target_killed }
						desc = bp1_yearly.2023.b_killer
					}
					#If we just don't trust them
					triggered_desc = {
						desc = bp1_yearly.2023.b
					}
				}
			}
		}
		trigger = {
			scope:bp1_yearly_2020_influencing_partner = {
				is_imprisoned = no
				is_alive = yes
			}
		}
		rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2020_influencing_partner IMPRISONER = root }
		#Sting more if they actually killed your rival/nemesis
		if = {
			limit = { has_character_flag = bp1_yearly_2020_target_killed }
			bp1_yearly_2023_apply_dis_or_honorable_modifier_effect = { ADD = dishonorable REMOVE = honorable }
			reverse_add_opinion = {
				target = scope:bp1_yearly_2020_influencing_partner
				modifier = betrayed_me_opinion
				opinion = -50
			}
			stress_impact = {
				family_first = minor_stress_impact_gain
				honest = medium_stress_impact_gain
				craven = miniscule_stress_impact_loss
				paranoid = minor_stress_impact_loss
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:bp1_yearly_2020_influencing_partner
				modifier = betrayed_me_opinion
				opinion = -30
			}
			stress_impact = {
				honest = minor_stress_impact_gain
				craven = miniscule_stress_impact_loss
				paranoid = minor_stress_impact_loss
			}
		}
	}
	#No, I've changed my mind
	option = {
		name = {
			text = {
				first_valid = {
					#I mean, _technically_ they didn't finish the job...
					triggered_desc = {
						trigger = { 
							scope:bp1_yearly_2020_influencing_partner = {
								OR = {
									is_imprisoned_by = scope:bp1_yearly_2020_target
									is_alive = no
								}
							}
						}
						desc = bp1_yearly.2023.c_imprisoned_dead
					}
					#This isn't right
					triggered_desc = {
						desc = bp1_yearly.2023.c
					}
				}
			}
		}
		#If the partner is available
		if = {
			limit = {
				scope:bp1_yearly_2020_influencing_partner = {
					is_imprisoned = no
					is_alive = yes
				}
			}
			#And we took the person option but didn't pick anyone, they can sort of understand
			if = {
				limit = { has_character_flag = bp1_yearly_2021_picked_none }
				reverse_add_opinion = {
					target = scope:bp1_yearly_2020_influencing_partner
					modifier = insulted_opinion
					opinion = -20
				}
				stress_impact = {
					craven = miniscule_stress_impact_gain
					paranoid = minor_stress_impact_gain
				}
			}
			#Otherwise, if they killed our rival/nemesis we're just being an ass
			else_if = {
				limit = { has_character_flag = bp1_yearly_2020_target_killed }
				reverse_add_opinion = {
					target = scope:bp1_yearly_2020_influencing_partner
					modifier = betrayed_me_opinion
					opinion = -50
				}
				bp1_yearly_2023_apply_dis_or_honorable_modifier_effect = { ADD = dishonorable REMOVE = honorable }
				stress_impact = {
					family_first = minor_stress_impact_gain
					honest = medium_stress_impact_gain
					craven = minor_stress_impact_gain
					paranoid = medium_stress_impact_gain
				}
			}
			hidden_effect = {
				bp1_yearly_2020_chance_of_murderous_partner_effect = { MURDEROUS_PARTNER = scope:bp1_yearly_2020_influencing_partner }
			}
		}
		#If they're dead or imprisoned, nothing happens	
	}
	after = {
		remove_character_flag = bp1_yearly_2020_target_killed
		remove_character_flag = bp1_yearly_2021_picked_none
	}
}

##################################################
# #Mopey consort wants some guidance
# by Filippa Gannholm Kirsten
# #bp1_yearly.2030
##################################################
scripted_trigger bp1_yearly_2030_is_relevant_consort_trigger = {
	is_available_ai_adult = yes
	NOR = {
		this = $TARGET$
		has_relation_nemesis = $TARGET$
		has_relation_best_friend = $TARGET$
	} 
}

scripted_effect bp1_yearly_2030_relationship_effect = {
	#Starting as Potential Friends
	if = {
		limit = {
			has_relation_potential_friend = $TARGET$
		}
		random_list = {
			#Increase friendship - Friends
			2 = {
				trigger = {
					can_set_relation_friend_trigger = { CHARACTER = $TARGET$ }
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$
						value >= 1
					}
					factor = 2
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 2
					}
					factor = 3
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 3
					}
					factor = 4
				}
				desc = bp1_yearly.2030.tt_friend
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_success
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							improve_relationship_effect = { 
								TARGET = $TARGET$ 
								REASON = generic_encouraged_bonding_at_court 
							}
						}
					}
				}
			}
			#Nothing happens
			1 = {
				desc = bp1_yearly.2030.tt_nothing
			}
			#Decrease friendship - Potential Rival
			2 = {
				desc = bp1_yearly.2030.tt_potential_rival
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_failure
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							worsen_relationship_effect = {
								TARGET = $TARGET$
								REASON = rival_forced_to_socialize
							}
						}
					}
				}
			}
		}
	}
	#Starting as Friends
	else_if = {
		limit = {
			has_relation_friend = $TARGET$
		}
		random_list = {
			#Increase friendship - Best Friend
			2 = {
				trigger = {
					can_set_relation_best_friend_trigger = { CHARACTER = $TARGET$ }
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$
						value >= 1
					}
					factor = 2
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 2
					}
					factor = 3
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 3
					}
					factor = 4
				}
				desc = bp1_yearly.2030.tt_best_friend
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_success
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							improve_relationship_effect = { 
								TARGET = $TARGET$ 
								REASON = best_friend_socializing 
							}
						}
					}
				}
			}
			#Nothing happens
			1 = {
				desc = bp1_yearly.2030.tt_nothing
			}
			#Decrease friendship - Potential Friend
			2 = {
				desc = bp1_yearly.2030.tt_potential_rival
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_failure
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							worsen_relationship_effect = {
								TARGET = $TARGET$
								REASON = rival_forced_to_socialize
							}
						}
					}
				}
			}
		}
	}
	#Starting as Potential Rivals
	else_if = {
		limit = {
			has_relation_potential_rival = $TARGET$
		}
		random_list = {
			#Increase friendship - Potential Friend
			2 = {
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$
						value >= 1
					}
					factor = 2
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 2
					}
					factor = 3
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 3
					}
					factor = 4
				}
				desc = bp1_yearly.2030.tt_potential_friend
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_success
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							improve_relationship_effect = { 
								TARGET = $TARGET$ 
								REASON = generic_encouraged_bonding_at_court 
							}
						}
					}
				}
			}
			#Nothing happens
			1 = {
				desc = bp1_yearly.2030.tt_nothing
			}
			#Decrease friendship - Rival
			2 = {
				desc = bp1_yearly.2030.tt_rival
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_failure
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							worsen_relationship_effect = {
								TARGET = $TARGET$
								REASON = rival_forced_to_socialize
							}
						}
					}
				}
			}
		}
	}
	#Starting as Rivals
	else_if = {
		limit = {
			has_relation_rival = $TARGET$
		}
		random_list = {
			#Increase friendship - Potential Friend
			2 = {
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$
						value >= 1
					}
					factor = 2
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 2
					}
					factor = 3
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 3
					}
					factor = 4
				}
				desc = bp1_yearly.2030.tt_potential_friend
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_success
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							improve_relationship_effect = { 
								TARGET = $TARGET$ 
								REASON = generic_encouraged_bonding_at_court 
							}
						}
					}
				}
			}
			#Nothing happens
			1 = {
				desc = bp1_yearly.2030.tt_nothing
			}
			#Decrease friendship - Nemesis
			2 = {
				desc = bp1_yearly.2030.tt_nemesis
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_failure
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							worsen_relationship_effect = {
								TARGET = $TARGET$
								REASON = rival_forced_to_socialize
							}
						}
					}
				}
			}
		}
	}
	#Blank Slate
	else = {
		random_list = {
			#Increase friendship - Potential Friend
			2 = {
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$
						value >= 1
					}
					factor = 2
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 2
					}
					factor = 3
				}
				modifier = {
					number_of_personality_traits_in_common = {
						target = $TARGET$ 
						value >= 3
					}
					factor = 4
				}
				desc = bp1_yearly.2030.tt_potential_friend
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_success
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							improve_relationship_effect = { 
								TARGET = $TARGET$ 
								REASON = generic_encouraged_bonding_at_court 
							}
						}
					}
				}
			}
			#Nothing happens
			1 = {
				desc = bp1_yearly.2030.tt_nothing
			}
			#Decrease friendship - Nemesis
			2 = {
				desc = bp1_yearly.2030.tt_potential_rival
				root = {
					send_interface_toast = {
						title = bp1_yearly.2030.tt_failure
						left_icon = scope:bp1_yearly_2030_mopey_consort
						right_icon = scope:bp1_yearly_2030_target_consort
						scope:bp1_yearly_2030_mopey_consort = {
							worsen_relationship_effect = {
								TARGET = $TARGET$
								REASON = rival_forced_to_socialize
							}
						}
					}
				}
			}
		}
	}
}

scripted_effect bp1_yearly_2030_improve_lowest_skill_effect = {
	random_list = {
		1 = {
			add_$SKILL$_skill = 1
		}
		1 = {
			add_character_modifier = {
				modifier = bp1_yearly_2030_failed_student_modifier
				years = 5
			}
		}
	}
}

#Credit to Hugo Cortell
scripted_effect bp1_yearly_2030_get_lowest_skill_effect = {
	save_scope_value_as = {
		name = lowest_character_skill
		value = flag:diplomacy
	}
	save_scope_value_as = {
		name = lowest_character_skill_value
		value = diplomacy
	}
	#Let's make it a bit more random in case you have the same level in a lot of skills
	random_list = {
		50 = {
			if = {
				limit = { martial <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:martial
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = martial
				}
			}
			if = {
				limit = { stewardship <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:stewardship
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = stewardship
				}
			}
			if = {
				limit = { intrigue <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:intrigue
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = intrigue
				}
			}
			if = {
				limit = { learning <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:learning
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = learning
				}
			}
		}
		50 = {
			if = {
				limit = { learning <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:learning
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = learning
				}
			}
			if = {
				limit = { intrigue <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:intrigue
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = intrigue
				}
			}
			if = {
				limit = { stewardship <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:stewardship
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = stewardship
				}
			}
			if = {
				limit = { martial <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:martial
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = martial
				}
			}
		}
		50 = {
			if = {
				limit = { learning <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:learning
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = learning
				}
			}
			if = {
				limit = { martial <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:martial
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = martial
				}
			}
			if = {
				limit = { intrigue <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:intrigue
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = intrigue
				}
			}
			if = {
				limit = { stewardship <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:stewardship
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = stewardship
				}
			}
		}
		50 = {
			if = {
				limit = { learning <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:learning
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = learning
				}
			}
			if = {
				limit = { martial <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:martial
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = martial
				}
			}
			if = {
				limit = { intrigue <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:intrigue
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = intrigue
				}
			}
			if = {
				limit = { stewardship <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:stewardship
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = stewardship
				}
			}
			if = {
				limit = { diplomacy <= scope:lowest_character_skill_value }
				save_scope_value_as = {
					name = lowest_character_skill
					value = flag:diplomacy
				}
				save_scope_value_as = {
					name = lowest_character_skill_value
					value = diplomacy
				}
			}
		}
	}
}

bp1_yearly.2030 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2030.t
	desc = bp1_yearly.2030.desc
	theme = friendly
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:bp1_yearly_2030_mopey_consort
		animation = sadness
	}
	lower_right_portrait = scope:bp1_yearly_2030_target_consort
	#Set up the cooldown
	cooldown = { years = 5 }
	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_playable_character = yes
		any_consort = { 
			is_available_ai_adult = yes
			save_temporary_scope_as = first_consort
		}
		any_consort = { 
			bp1_yearly_2030_is_relevant_consort_trigger = { TARGET = scope:first_consort }
		}
		is_at_war = no
	}
	weight_multiplier = {
		base = 1
		modifier = {
			any_consort = {
				count >= 3
			}
			add = 2
		}
		modifier = {
			any_consort = {
				count = 4
			}
			add = 2
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		#Find a consort
		random_consort = {
			limit = { is_available_ai_adult = yes }
			save_scope_as = bp1_yearly_2030_mopey_consort
		}
		#Find a ... lover to be?
		if = {
			limit = {
				OR = {
					has_trait = lustful
					has_trait = seducer
				}
				scope:bp1_yearly_2030_mopey_consort = {
					NOT = { has_trait = chaste }
					OR = {
						has_sexuality = bisexual
						has_sexuality = homosexual
					}
				}
				any_consort = {
					can_set_relation_lover_trigger = { CHARACTER = scope:bp1_yearly_2030_mopey_consort }
					is_available_ai_adult = yes
					this != scope:bp1_yearly_2030_mopey_consort
				}
			}
			random_consort = {
				limit = {
					NOT = { has_trait = chaste }
					can_set_relation_lover_trigger = { CHARACTER = scope:bp1_yearly_2030_mopey_consort }
					bp1_yearly_2030_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2030_mopey_consort }
				}
				save_scope_as = bp1_yearly_2030_target_consort
			}
			scope:bp1_yearly_2030_mopey_consort = { add_character_flag = bp1_yearly_2030_potential_lover_exists }
		}
		#Otherwise find another consort who can do relation stuff with this consort
		else = {
			random_consort = {
				limit = { 
					bp1_yearly_2030_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2030_mopey_consort } 
				}
				save_scope_as = bp1_yearly_2030_target_consort
			}
		}
		#Find the lowest skill to improve
		scope:bp1_yearly_2030_mopey_consort = { bp1_yearly_2030_get_lowest_skill_effect = yes }
	}
	#Befriend other consort
	option = {
		name = bp1_yearly.2030.a
		trigger = { exists = scope:bp1_yearly_2030_target_consort }
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							has_trait = craven
							has_trait = paranoid
							has_trait = reclusive
						}
					}
					#But what if they end up discussing me...
					desc = bp1_yearly.2030.a_tt_paranoia
				}
				triggered_desc = {
					trigger = { has_trait = gregarious }
					#I'm sure this will work out nicely.
					desc = bp1_yearly.2030.a_tt_gregarious
				}
			}
		}
		scope:bp1_yearly_2030_mopey_consort = {
			bp1_yearly_2030_relationship_effect = { TARGET = scope:bp1_yearly_2030_target_consort }
		}
		stress_impact = {
			craven = miniscule_stress_impact_gain
			reclusive = miniscule_stress_impact_gain
			paranoid = minor_stress_impact_gain
			gregarious = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 5
			#Paranoid be paranoid
			modifier = {
				has_trait = paranoid
				add = -50
			}
			modifier = {
				has_trait = gregarious
				add = 20
			}
			ai_value_modifier = {
				ai_sociability = 1
				ai_compassion = 0.5
			}
		}
	}
	#Befriend with benefits
	option = {
		name = bp1_yearly.2030.b
		trigger = { 
			scope:bp1_yearly_2030_mopey_consort = { has_character_flag = bp1_yearly_2030_potential_lover_exists }
			OR = {
				has_trait = lustful
				has_trait = seducer
			}
		}
		flavor = bp1_yearly.2030.b_tt
		scope:bp1_yearly_2030_mopey_consort = {
			random_list = {
				#Lover
				1 = {
					modifier = {
						number_of_personality_traits_in_common = {
							target = scope:bp1_yearly_2030_target_consort 
							value >= 1
						}
						factor = 2
					}
					modifier = {
						number_of_personality_traits_in_common = {
							target = scope:bp1_yearly_2030_target_consort 
							value >= 2
						}
						factor = 3
					}
					modifier = {
						number_of_personality_traits_in_common = {
							target = scope:bp1_yearly_2030_target_consort 
							value >= 3
						}
						factor = 4
					}
					desc = bp1_yearly.2030.tt_lover
					root = {
						send_interface_toast = {
							title = bp1_yearly.2030.tt_success
							left_icon = scope:bp1_yearly_2030_mopey_consort
							right_icon = scope:bp1_yearly_2030_target_consort
							scope:bp1_yearly_2030_mopey_consort = {
								set_relation_lover = { reason = lover_consorts_encouraged target = scope:bp1_yearly_2030_target_consort involved_character = root }
							}
							stress_impact = {
								lustful = miniscule_stress_impact_loss
							}
						}
					}
				}
				#Damage relation
				1 = {
					desc = bp1_yearly.2030.tt_potential_rival
					#No can do
					modifier = {
						scope:bp1_yearly_2030_target_consort = { has_trait = chaste }
						factor = 10
					}
					root = {
						send_interface_toast = {
							title = bp1_yearly.2030.tt_failure
							left_icon = scope:bp1_yearly_2030_mopey_consort
							right_icon = scope:bp1_yearly_2030_target_consort
							scope:bp1_yearly_2030_mopey_consort = {
								add_opinion = {
									target = scope:bp1_yearly_2030_target_consort
									modifier = awkward_opinion
									opinion = -15
								}
								reverse_add_opinion = {
									target = scope:bp1_yearly_2030_target_consort
									modifier = awkward_opinion
									opinion = -15
								}
							}
						}
					}
				}
			}
		}
		#This is a player option
		ai_chance = {
			base = 0
		}
	}
	#Improve a skill
	option = {
		name = bp1_yearly.2030.c
		scope:bp1_yearly_2030_mopey_consort = {
			switch = {
				trigger = scope:lowest_character_skill
				flag:diplomacy = {
					bp1_yearly_2030_improve_lowest_skill_effect = { SKILL = diplomacy }
				}
				flag:martial = {
					bp1_yearly_2030_improve_lowest_skill_effect = { SKILL = martial }
				}
				flag:stewardship = {
					bp1_yearly_2030_improve_lowest_skill_effect = { SKILL = stewardship }
				}
				flag:intrigue = {
					bp1_yearly_2030_improve_lowest_skill_effect = { SKILL = intrigue }
				}
				flag:learning = {
					bp1_yearly_2030_improve_lowest_skill_effect = { SKILL = learning }
				}
			}
		}
		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				has_trait = ambitious
				add = 20
			}
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}
	#I have more important matters to tend to
	option = {
		name = bp1_yearly.2030.d
		reverse_add_opinion = {
			target = scope:bp1_yearly_2030_mopey_consort
			modifier = insulted_opinion
			opinion = -15
		}
		stress_impact = {
			gregarious = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 5
			modifier = {
				has_trait = callous
				add = 20
			}
			ai_value_modifier = {
				ai_sociability = -1
			}
		}
	}
	after = {
		scope:bp1_yearly_2030_mopey_consort = {
			remove_character_flag = bp1_yearly_2030_potential_lover_exists
		}
	}
}

##################################################
# #Consort is upset with other consort
# by Filippa Gannholm Kirsten
# #bp1_yearly.2040
##################################################
bp1_yearly.2040 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2040.t
	desc = {
		desc = bp1_yearly.2040.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2040_upset_consort = { has_trait = paranoid }
				}
				desc = bp1_yearly.2040.desc_paranoia
			}
			triggered_desc = {
				desc = bp1_yearly.2040.desc_default
			}
		}
		desc = bp1_yearly.2040.desc_outro
	}
	theme = unfriendly
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:bp1_yearly_2040_upset_consort
		animation = rage
	}
	lower_center_portrait = {
		character = scope:bp1_yearly_2040_target_consort
	}
	#Set up the cooldown
	cooldown = { years = 5 }
	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_playable_character = yes
		any_consort = { 
			is_available_ai_adult = yes
			save_temporary_scope_as = first_consort
		}
		any_consort = { 
			bp1_yearly_2030_is_relevant_consort_trigger = { TARGET = scope:first_consort }
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			any_consort = {
				count >= 3
			}
			add = 2
		}
		modifier = {
			any_consort = {
				count = 4
			}
			add = 2
		}
		modifier = {
			any_consort = {
				OR = {
					has_trait = vengeful
					has_trait = deceitful
					has_trait = sadistic
					has_trait = wrathful
				}
				has_trait = paranoid
			}
			add = 2
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		#Find a consort
		random_consort = {
			limit = { 
				is_available_ai_adult = yes
				has_trait = paranoid
			}
			alternative_limit = { is_available_ai_adult = yes }
			save_scope_as = bp1_yearly_2040_upset_consort
		}
		#Find a target consort
		random_consort = {
			limit = { 
				bp1_yearly_2030_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2040_upset_consort }
			}
			save_scope_as = bp1_yearly_2040_target_consort
		}
	}
	#Soothe them
	option = {
		name = bp1_yearly.2040.a
		flavor = bp1_yearly.2040.a_tt
		scope:bp1_yearly_2040_upset_consort = {
			random_list = {
				3 = {
					desc = bp1_yearly.2040.tt_success
					add_opinion = {
						target = scope:bp1_yearly_2040_target_consort
						modifier = friendliness_opinion
						opinion = 15
					}
					reverse_add_opinion = {
						target = scope:bp1_yearly_2040_target_consort
						modifier = friendliness_opinion
						opinion = 15
					}
				}
				4 = {
					desc = bp1_yearly.2040.tt_critical_success
					root = {
						send_interface_toast = {
							title = bp1_yearly.2030.tt_success
							left_icon = scope:bp1_yearly_2040_upset_consort
							right_icon = scope:bp1_yearly_2040_target_consort
							scope:bp1_yearly_2040_upset_consort = {
								improve_relationship_effect = { 
									TARGET = scope:bp1_yearly_2040_target_consort 
									REASON = generic_encouraged_bonding_at_court 
								}
							}
						}
					}
				}
				#_Befriend_ you say
				1 = {
					desc = bp1_yearly.2040.tt_severe_success
					trigger = {
						OR = {
							has_trait = gregarious
							has_trait = compassionate
							has_trait = diligent
							has_trait = ambitious
							has_trait = deceitful
						} 
						can_start_scheme = {
							type = befriend
							target_character = scope:bp1_yearly_2040_target_consort
						}
					}
					start_scheme = {
						type = befriend
						target_character = scope:bp1_yearly_2040_target_consort
					}
				}
			}
		}
		ai_chance = {
			base = 100
		}
	}
	#Egg them on
	option = {
		name = bp1_yearly.2040.b
		flavor = bp1_yearly.2040.b_tt
		scope:bp1_yearly_2040_upset_consort = {
			random_list = {
				3 = {
					desc = bp1_yearly.2040.tt_failure
					add_opinion = {
						target = scope:bp1_yearly_2040_target_consort
						modifier = unfriendly_opinion
						opinion = -15
					}
					reverse_add_opinion = {
						target = scope:bp1_yearly_2040_target_consort
						modifier = unfriendly_opinion
						opinion = -15
					}
				}
				4 = {
					desc = bp1_yearly.2040.tt_critical_failure
					root = {
						send_interface_toast = {
							title = bp1_yearly.2030.tt_failure
							left_icon = scope:bp1_yearly_2040_upset_consort
							right_icon = scope:bp1_yearly_2040_target_consort
							scope:bp1_yearly_2040_upset_consort = {
								worsen_relationship_effect = {
									TARGET = scope:bp1_yearly_2040_target_consort
									REASON = rival_spouses_do_not_get_along
								}
							}
						}
					}
				}
				#I have been slighted
				1 = {
					desc = bp1_yearly.2040.tt_severe_failure
					trigger = {
						OR = {
							has_trait = vengeful
							has_trait = deceitful
							has_trait = sadistic
							has_trait = wrathful
						} 
						has_trait = paranoid
						can_start_scheme = {
							type = murder
							target_character = scope:bp1_yearly_2040_target_consort
						}
					}
					modifier = {
						opinion = {
							target = scope:bp1_yearly_2040_target_consort
							value <= -10
						}
						factor = 1.5
					}
					#MURDER VENGEANCE reeee
					start_scheme = {
						type = murder
						target_character = scope:bp1_yearly_2040_target_consort
					}
				}
			}
		}
		stress_impact = {
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	#Diplomacy - amicable resolution
	option = {
		name = bp1_yearly.2040.c
		flavor = bp1_yearly.2040.c_tt
		trigger = { diplomacy >= 10 }
		send_interface_toast = {
			title = bp1_yearly.2030.tt_success
			left_icon = scope:bp1_yearly_2040_upset_consort
			right_icon = scope:bp1_yearly_2040_target_consort
			scope:bp1_yearly_2040_upset_consort = {
				improve_relationship_effect = { 
					TARGET = scope:bp1_yearly_2040_target_consort 
					REASON = generic_encouraged_bonding_at_court 
				}
			}
		}
		stress_impact = {
			just = miniscule_stress_impact_loss
			cynical = miniscule_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	#I have more important matters to tend to
	option = {
		name = bp1_yearly.2040.d
		flavor = bp1_yearly.2040.d_tt
		scope:bp1_yearly_2040_upset_consort = {
			random_list = {
				4 = {
					desc = bp1_yearly.2040.tt_success
					root = {
						send_interface_toast = {
							title = bp1_yearly.2030.tt_success
							left_icon = scope:bp1_yearly_2040_upset_consort
							right_icon = scope:bp1_yearly_2040_target_consort
							scope:bp1_yearly_2040_upset_consort = {
								improve_relationship_effect = { 
									TARGET = scope:bp1_yearly_2040_target_consort 
									REASON = generic_encouraged_bonding_at_court 
								}
							}
						}
					}
				}
				4 = {
					desc = bp1_yearly.2040.tt_failure
					root = {
						send_interface_toast = {
							title = bp1_yearly.2030.tt_failure
							left_icon = scope:bp1_yearly_2040_upset_consort
							right_icon = scope:bp1_yearly_2040_target_consort
							scope:bp1_yearly_2040_upset_consort = {
								worsen_relationship_effect = {
									TARGET = scope:bp1_yearly_2040_target_consort
									REASON = rival_spouses_do_not_get_along
								}
							}
						}
					}
				}
				#I have been slighted
				1 = {
					desc = bp1_yearly.2040.tt_severe_failure
					trigger = {
						OR = {
							has_trait = vengeful
							has_trait = deceitful
							has_trait = sadistic
							has_trait = wrathful
						} 
						has_trait = paranoid
						can_start_scheme = {
							type = murder
							target_character = scope:bp1_yearly_2040_target_consort
						}
					}
					modifier = {
						opinion = {
							target = scope:bp1_yearly_2040_target_consort
							value <= -10
						}
						factor = 1.5
					}
					#MURDER VENGEANCE reeee
					start_scheme = {
						type = murder
						target_character = scope:bp1_yearly_2040_target_consort
					}
				}
			}
		}
		reverse_add_opinion = {
			target = scope:bp1_yearly_2040_upset_consort
			modifier = ignored_concerns
			opinion = -15
		}
		stress_impact = {
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

##################################################
# #Friendly consorts want to start a study circle
# by Filippa Gannholm Kirsten
# #bp1_yearly.2050
##################################################
scripted_trigger bp1_yearly_2050_is_relevant_consort_trigger = {
	is_available_ai_adult = yes
	NOT = { this = $TARGET$ }
	OR = {
		has_relation_potential_friend = $TARGET$
		has_relation_friend = $TARGET$
		has_relation_best_friend = $TARGET$
		opinion = {
			target = $TARGET$
			value >= medium_positive_opinion
		}
	}
}

scripted_effect bp1_yearly_2050_find_subsequent_highest_skill_effect = {
	if = {
		limit = { diplomacy > scope:highest_consort_skill_value }
		save_scope_value_as = {
			name = highest_consort_skill
			value = flag:diplomacy
		}
		save_scope_value_as = {
			name = highest_consort_skill_value
			value = diplomacy
		}
		save_scope_as = highest_consort_skill_person
	}
	if = {
		limit = { martial > scope:highest_consort_skill_value }
		save_scope_value_as = {
			name = highest_consort_skill
			value = flag:martial
		}
		save_scope_value_as = {
			name = highest_consort_skill_value
			value = martial
		}
		save_scope_as = highest_consort_skill_person
	}
	if = {
		limit = { stewardship > scope:highest_consort_skill_value }
		save_scope_value_as = {
			name = highest_consort_skill
			value = flag:stewardship
		}
		save_scope_value_as = {
			name = highest_consort_skill_value
			value = stewardship
		}
		save_scope_as = highest_consort_skill_person
	}
	if = {
		limit = { intrigue > scope:highest_consort_skill_value }
		save_scope_value_as = {
			name = highest_consort_skill
			value = flag:intrigue
		}
		save_scope_value_as = {
			name = highest_consort_skill_value
			value = intrigue
		}
		save_scope_as = highest_consort_skill_person
	}
	if = {
		limit = { learning > scope:highest_consort_skill_value }
		save_scope_value_as = {
			name = highest_consort_skill
			value = flag:learning
		}
		save_scope_value_as = {
			name = highest_consort_skill_value
			value = learning
		}
		save_scope_as = highest_consort_skill_person
	}
}

scripted_effect bp1_yearly_2050_find_highest_skill_effect = {
	scope:bp1_yearly_2050_first_consort = {
		save_scope_value_as = {
			name = highest_consort_skill
			value = flag:diplomacy
		}
		save_scope_value_as = {
			name = highest_consort_skill_value
			value = diplomacy
		}
		save_scope_as = highest_consort_skill_person
		if = {
			limit = { martial > scope:highest_consort_skill_value }
			save_scope_value_as = {
				name = highest_consort_skill
				value = flag:martial
			}
			save_scope_value_as = {
				name = highest_consort_skill_value
				value = martial
			}
			save_scope_as = highest_consort_skill_person
		}
		if = {
			limit = { stewardship > scope:highest_consort_skill_value }
			save_scope_value_as = {
				name = highest_consort_skill
				value = flag:stewardship
			}
			save_scope_value_as = {
				name = highest_consort_skill_value
				value = stewardship
			}
			save_scope_as = highest_consort_skill_person
		}
		if = {
			limit = { intrigue > scope:highest_consort_skill_value }
			save_scope_value_as = {
				name = highest_consort_skill
				value = flag:intrigue
			}
			save_scope_value_as = {
				name = highest_consort_skill_value
				value = intrigue
			}
			save_scope_as = highest_consort_skill_person
		}
		if = {
			limit = { learning > scope:highest_consort_skill_value }
			save_scope_value_as = {
				name = highest_consort_skill
				value = flag:learning
			}
			save_scope_value_as = {
				name = highest_consort_skill_value
				value = learning
			}
			save_scope_as = highest_consort_skill_person
		}
	}
	scope:bp1_yearly_2050_second_consort = {
		bp1_yearly_2050_find_subsequent_highest_skill_effect = yes
	}
	if = {
		limit = { exists = scope:bp1_yearly_2050_third_consort }
		scope:bp1_yearly_2050_third_consort = {
			bp1_yearly_2050_find_subsequent_highest_skill_effect = yes
		}
	}
	if = {
		limit = { exists = scope:bp1_yearly_2050_fourth_consort }
		scope:bp1_yearly_2050_fourth_consort = {
			bp1_yearly_2050_find_subsequent_highest_skill_effect = yes
		}
	}
}

scripted_effect bp1_yearly_2050_apply_skill_effect = {
	scope:bp1_yearly_2050_first_consort = { 
		add_$SKILL$_skill = 1 
		add_opinion = {
			target = root
			modifier = grateful_opinion
			opinion = 20
		}
	}
	scope:bp1_yearly_2050_second_consort = { 
		add_$SKILL$_skill = 1 
		add_opinion = {
			target = root
			modifier = grateful_opinion
			opinion = 20
		}
	}
	if = {
		limit = { exists = scope:bp1_yearly_2050_third_consort }
		scope:bp1_yearly_2050_third_consort = { 
			add_$SKILL$_skill = 1 
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
	}
	if = {
		limit = { exists = scope:bp1_yearly_2050_fourth_consort }
		scope:bp1_yearly_2050_fourth_consort = { 
			add_$SKILL$_skill = 1 
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
	}
}

bp1_yearly.2050 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_trait = paranoid }
				desc = bp1_yearly.2050.desc_intro_paranoid
			}
			triggered_desc = {
				desc = bp1_yearly.2050.desc_intro
			}
		}
		desc = bp1_yearly.2050.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:highest_consort_skill = flag:diplomacy
				}
				desc = bp1_yearly.2050.desc_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:highest_consort_skill = flag:martial
				}
				desc = bp1_yearly.2050.desc_martial
			}
			triggered_desc = {
				trigger = {
					scope:highest_consort_skill = flag:stewardship
				}
				desc = bp1_yearly.2050.desc_stewardship
			}
			triggered_desc = {
				trigger = {
					scope:highest_consort_skill = flag:intrigue
				}
				desc = bp1_yearly.2050.desc_intrigue
			}
			triggered_desc = {
				trigger = {
					scope:highest_consort_skill = flag:learning
				}
				desc = bp1_yearly.2050.desc_learning
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:bp1_yearly_2050_fourth_consort
				}
				desc = bp1_yearly.2050.desc_quartet
			}
			triggered_desc = {
				trigger = {
					exists = scope:bp1_yearly_2050_third_consort
					NOT = { exists = scope:bp1_yearly_2050_fourth_consort }
				}
				desc = bp1_yearly.2050.desc_trio
			}
			triggered_desc = {
				trigger = {
					NOR = {
						exists = scope:bp1_yearly_2050_third_consort 
						exists = scope:bp1_yearly_2050_fourth_consort 
					}
				}
				desc = bp1_yearly.2050.desc_duo
			}
		}
		triggered_desc = {
			trigger = { has_trait = paranoid }
			desc = bp1_yearly.2050.desc_paranoid
		}
	}
	theme = friendly
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = paranoid }
			animation = personality_cynical
		}
		animation = personality_compassionate
	}
	right_portrait = {
		character = scope:bp1_yearly_2050_first_consort
		animation = personality_rational
	}
	lower_left_portrait = {
		trigger = { exists = scope:bp1_yearly_2050_fourth_consort }
		character = scope:bp1_yearly_2050_fourth_consort
	}
	lower_center_portrait = {
		trigger = { exists = scope:bp1_yearly_2050_third_consort }
		character = scope:bp1_yearly_2050_third_consort
	}
	lower_right_portrait = {
		trigger = { exists = scope:bp1_yearly_2050_second_consort }
		character = scope:bp1_yearly_2050_second_consort
	}
	#Set up the cooldown
	cooldown = { years = 10 }
	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_playable_character = yes
		any_consort = { 
			is_available_ai_adult = yes
			save_temporary_scope_as = first_consort
			root = {
				any_consort = { 
					bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:first_consort }
				}
			}
		}
	}
	weight_multiplier = {
		base = 1
		modifier = {
			any_consort = {
				count >= 3
			}
			add = 2
		}
		modifier = {
			any_consort = {
				count = 4
			}
			add = 2
		}
		modifier = {
			any_consort = {
				is_available_ai_adult = yes
				save_temporary_scope_as = first_consort
				root = {
					any_consort = {
						bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:first_consort }
					}
				}
			}
			add = 2
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		#Find a consort
		random_consort = {
			limit = { 
				is_available_ai_adult = yes
				save_temporary_scope_as = first_consort
				root = {
					any_consort = { 
						bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:first_consort }
					}
				}
			}
			save_scope_as = bp1_yearly_2050_first_consort
		}
		#Find our second consort
		random_consort = {
			limit = { 
				bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2050_first_consort }
			}
			save_scope_as = bp1_yearly_2050_second_consort
		}
		#Find any additional consort
		random_consort = {
			limit = {
				OR = {
					bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2050_first_consort }
					AND = {
						exists = scope:bp1_yearly_2050_second_consort
						bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2050_second_consort }
					}
				}
				NOR = {
					this = scope:bp1_yearly_2050_first_consort
					this = scope:bp1_yearly_2050_second_consort
				}
			}
			save_scope_as = bp1_yearly_2050_third_consort
		}
		random_consort = {
			limit = {
				OR = {
					bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2050_first_consort }
					AND = {
						exists = scope:bp1_yearly_2050_second_consort
						bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2050_second_consort }
					}
					AND = {
						exists = scope:bp1_yearly_2050_third_consort
						bp1_yearly_2050_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2050_third_consort }
					}
				}
				NOR = {
					this = scope:bp1_yearly_2050_first_consort
					this = scope:bp1_yearly_2050_second_consort
					this = scope:bp1_yearly_2050_third_consort
				}
			}
			save_scope_as = bp1_yearly_2050_fourth_consort
		}
		#See who is most knowledgable in the pinpointed skill to lead the teaching
		bp1_yearly_2050_find_highest_skill_effect = yes
		#If paranoid, this is a traumatic memory
		if = {
			limit = { 
				has_trait = paranoid 
				exists = scope:bp1_yearly_2050_fourth_consort
			}
			create_character_memory = {
				type = ganged_up_on_four_memory
				participants = {
					consort_1 = scope:bp1_yearly_2050_first_consort
					consort_2 = scope:bp1_yearly_2050_second_consort
					consort_3 = scope:bp1_yearly_2050_third_consort
					consort_4 = scope:bp1_yearly_2050_fourth_consort
				}
			}
		}
		#Three consorts
		else_if = {
			limit = { 
				has_trait = paranoid 
				exists = scope:bp1_yearly_2050_third_consort
				NOT = { exists = scope:bp1_yearly_2050_fourth_consort }
			}
			create_character_memory = {
				type = ganged_up_on_three_memory
				participants = {
					consort_1 = scope:bp1_yearly_2050_first_consort
					consort_2 = scope:bp1_yearly_2050_second_consort
					consort_3 = scope:bp1_yearly_2050_third_consort
				}
			}
		}
	}
	#Agree to their request
	option = {
		name = bp1_yearly.2050.a
		flavor = bp1_yearly.2050.a_tt
		pay_short_term_gold = {
			target = scope:highest_consort_skill_person
			gold = major_gold_value
		}
		capital_county = {
			add_county_modifier = {
				modifier = bp1_yearly_2050_development_modifier
				years = 10
			}
		}
		if = {
			limit = { scope:highest_consort_skill = flag:diplomacy }
			bp1_yearly_2050_apply_skill_effect = { SKILL = diplomacy }
		}
		else_if = {
			limit = { scope:highest_consort_skill = flag:martial }
			bp1_yearly_2050_apply_skill_effect = { SKILL = martial }
		}
		else_if = {
			limit = { scope:highest_consort_skill = flag:stewardship }
			bp1_yearly_2050_apply_skill_effect = { SKILL = stewardship }
		}
		else_if = {
			limit = { scope:highest_consort_skill = flag:intrigue }
			bp1_yearly_2050_apply_skill_effect = { SKILL = intrigue }
		}
		else_if = {
			limit = { scope:highest_consort_skill = flag:learning }
			bp1_yearly_2050_apply_skill_effect = { SKILL = learning }
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			paranoid = minor_stress_impact_gain
			generous = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
	#Compromise?
	option = {
		name = bp1_yearly.2050.b
		flavor = bp1_yearly.2050.b_tt_greedy
		trigger = { has_trait = greedy }
		pay_short_term_gold = {
			target = scope:highest_consort_skill_person
			gold = {
				value = major_gold_value
				multiply = 0.5
			}
		}
		capital_county = {
			add_county_modifier = {
				modifier = bp1_yearly_2050_compromise_development_modifier
				years = 10
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	#This is annoying/stressful - imprison them
	option = {
		name = bp1_yearly.2050.c
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_trait = paranoid }
					desc = bp1_yearly.2050.c_tt_paranoid
				}
				triggered_desc = {
					trigger = { 
						OR = {
							has_trait = sadistic
							has_trait = wrathful
							has_trait = irritable
						}
					}
					desc = bp1_yearly.2050.c_tt_irritable
				}
			}
		}
		trigger = {
			OR = {
				has_trait = sadistic
				has_trait = wrathful
				has_trait = irritable
				has_trait = paranoid
			}
		}
		rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2050_first_consort IMPRISONER = root }
		rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2050_second_consort IMPRISONER = root }
		if = {
			limit = { exists = scope:bp1_yearly_2050_third_consort }
			rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2050_third_consort IMPRISONER = root }
		}
		if = {
			limit = { exists = scope:bp1_yearly_2050_fourth_consort }
			rightfully_imprison_character_effect = { TARGET = scope:bp1_yearly_2050_fourth_consort IMPRISONER = root }
		}
		stress_impact = {
			paranoid = minor_stress_impact_loss
			irritable = minor_stress_impact_loss
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	#I don't believe in this
	option = {
		name = bp1_yearly.2050.d
		flavor = bp1_yearly.2050.d_tt
		reverse_add_opinion = {
			target = scope:bp1_yearly_2050_first_consort
			modifier = dismissed_me_opinion
			opinion = -15
		}
		reverse_add_opinion = {
			target = scope:bp1_yearly_2050_second_consort
			modifier = dismissed_me_opinion
			opinion = -15
		}
		if = {
			limit = { exists = scope:bp1_yearly_2050_third_consort }
			reverse_add_opinion = {
				target = scope:bp1_yearly_2050_third_consort
				modifier = dismissed_me_opinion
				opinion = -15
			}
		}
		if = {
			limit = { exists = scope:bp1_yearly_2050_fourth_consort }
			reverse_add_opinion = {
				target = scope:bp1_yearly_2050_fourth_consort
				modifier = dismissed_me_opinion
				opinion = -15
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

##################################################
# #Friendly consorts want to tutor other consort's child
# by Filippa Gannholm Kirsten
# #bp1_yearly.2060
##################################################
scripted_trigger bp1_yearly_2060_is_relevant_child_trigger = {
	is_available_ai = yes
	is_child_of = root
	age > 5
	age < 20
}

scripted_trigger bp1_yearly_2060_is_relevant_consort_trigger = {
	is_available_ai_adult = yes
	NOT = { this = $TARGET$ }
	OR = {
		has_relation_potential_friend = $TARGET$
		has_relation_friend = $TARGET$
		has_relation_best_friend = $TARGET$
		opinion = {
			target = $TARGET$
			value >= medium_positive_opinion
		}
	}
	any_child = { 
		bp1_yearly_2060_is_relevant_child_trigger = yes
	}
	highest_skill = $SKILL$
}

scripted_trigger bp1_yearly_2060_has_matching_consort_with_highest_skill_trigger = {
	is_available_ai_adult = yes
	save_temporary_scope_as = first_consort
	OR = {
		AND = {
			highest_skill = diplomacy
			root = {
				any_consort = { 
					bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:first_consort SKILL = diplomacy }
				}
			}
		}
		AND = {
			highest_skill = martial
			root = {
				any_consort = { 
					bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:first_consort SKILL = martial }
					highest_skill = martial
				}
			}
		}
		AND = {
			highest_skill = stewardship
			root = {
				any_consort = { 
					bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:first_consort SKILL = stewardship }
					highest_skill = stewardship
				}
			}
		}
		AND = {
			highest_skill = intrigue
			root = {
				any_consort = { 
					bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:first_consort SKILL = intrigue }
					highest_skill = intrigue
				}
			}
		}
		AND = {
			highest_skill = learning
			root = {
				any_consort = { 
					bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:first_consort SKILL = learning }
					highest_skill = learning
				}
			}
		}
	}
}

scripted_effect bp1_yearly_2060_find_high_skill_tutor_effect = {
	scope:bp1_yearly_2060_first_consort = {
		save_scope_as = bp1_yearly_2060_high_skill_tutoring_consort
	}
	if = {
		limit = { scope:bp1_yearly_2060_second_consort.$SKILL$ > scope:bp1_yearly_2060_high_skill_tutoring_consort.$SKILL$ }
		scope:bp1_yearly_2060_second_consort = {
			save_scope_as = bp1_yearly_2060_high_skill_tutoring_consort
		}
	}
}

scripted_effect bp1_yearly_2060_find_low_skill_tutor_effect = {
	scope:bp1_yearly_2060_first_consort = {
		save_scope_as = bp1_yearly_2060_low_skill_tutoring_consort
	}
	if = {
		limit = { scope:bp1_yearly_2060_second_consort.$SKILL$ > scope:bp1_yearly_2060_low_skill_tutoring_consort.$SKILL$ }
		scope:bp1_yearly_2060_second_consort = {
			save_scope_as = bp1_yearly_2060_low_skill_tutoring_consort
		}
	}
}

scripted_effect bp1_yearly_2060_bolstered_duel_effect = {
	duel = {
		skill = $SKILL$
		value = average_skill_rating
		75 = {
			desc = bp1_yearly.2060.tt_success
			scope:bp1_yearly_2060_target_child = {
				add_$SKILL$_skill = 1
				add_opinion = {
					target = scope:bp1_yearly_2060_first_consort
					modifier = tutored_me_opinion
					opinion = 10
				}
				add_opinion = {
					target = scope:bp1_yearly_2060_second_consort
					modifier = tutored_me_opinion
					opinion = 10
				}
			}
		}
		25 = {	
			desc = bp1_yearly.2060.tt_critical_success
			scope:bp1_yearly_2060_target_child = {
				add_$SKILL$_skill = 2
				add_opinion = {
					target = scope:bp1_yearly_2060_first_consort
					modifier = tutored_me_opinion
					opinion = 20
				}
				add_opinion = {
					target = scope:bp1_yearly_2060_second_consort
					modifier = tutored_me_opinion
					opinion = 20
				}
			}
		}
	}
}

scripted_effect bp1_yearly_2060_duel_effect = {
	duel = {
		skill = $SKILL$
		value = average_skill_rating
		75 = {
			desc = bp1_yearly.2060.tt_success
			scope:bp1_yearly_2060_target_child = {
				add_$SKILL$_skill = 1
				add_opinion = {
					target = scope:bp1_yearly_2060_first_consort
					modifier = tutored_me_opinion
					opinion = 20
				}
				add_opinion = {
					target = scope:bp1_yearly_2060_second_consort
					modifier = tutored_me_opinion
					opinion = 20
				}
			}
		}
		25 = {	
			desc = bp1_yearly.2060.tt_failure
			#Nothing happens
		}
	}
}

bp1_yearly.2060 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2060.t
	desc = {
		desc = bp1_yearly.2060.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2060_first_consort = { highest_skill = diplomacy }
				}
				desc = bp1_yearly.2060.desc_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2060_first_consort = { highest_skill = martial }
				}
				desc = bp1_yearly.2060.desc_martial
			}
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2060_first_consort = { highest_skill = stewardship }
				}
				desc = bp1_yearly.2060.desc_stewardship
			}
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2060_first_consort = { highest_skill = intrigue }
				}
				desc = bp1_yearly.2060.desc_intrigue
			}
			triggered_desc = {
				trigger = {
					scope:bp1_yearly_2060_first_consort = { highest_skill = learning }
				}
				desc = bp1_yearly.2060.desc_learning
			}
		}
		desc = bp1_yearly.2060.desc_outro
	}
	theme = family
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = paranoid }
			animation = personality_cynical
		}
		animation = personality_rational
	}
	right_portrait = {
		character = scope:bp1_yearly_2060_first_consort
		animation = happiness
	}
	lower_center_portrait = {
		trigger = { exists = scope:bp1_yearly_2060_target_child }
		character = scope:bp1_yearly_2060_target_child
	}
	lower_right_portrait = {
		trigger = { exists = scope:bp1_yearly_2060_second_consort }
		character = scope:bp1_yearly_2060_second_consort
	}
	#Set up the cooldown
	cooldown = { years = 5 }
	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_playable_character = yes
		any_consort = { bp1_yearly_2060_has_matching_consort_with_highest_skill_trigger = yes }
	}
	weight_multiplier = {
		base = 1
		#The more the merrier
		modifier = {
			any_consort = {
				count >= 3
			}
			add = 2
		}
		modifier = {
			any_consort = {
				count = 4
			}
			add = 2
		}
		modifier = {
			any_consort = {
				has_trait = gregarious
			}
			add = 2
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_low_key_positive"
		#Find a consort
		random_consort = {
			limit = { bp1_yearly_2060_has_matching_consort_with_highest_skill_trigger = yes }
			save_scope_as = bp1_yearly_2060_first_consort
		}
		#Find our second consort
		random_consort = {
			limit = {
				OR = {
					AND = {
						scope:bp1_yearly_2060_first_consort = { highest_skill = diplomacy }
						bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2060_first_consort SKILL = diplomacy }
					}
					AND = {
						scope:bp1_yearly_2060_first_consort = { highest_skill = martial }
						bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2060_first_consort SKILL = martial }
					}
					AND = {
						scope:bp1_yearly_2060_first_consort = { highest_skill = stewardship }
						bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2060_first_consort SKILL = stewardship }
					}
					AND = {
						scope:bp1_yearly_2060_first_consort = { highest_skill = intrigue }
						bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2060_first_consort SKILL = intrigue }
					}
					AND = {
						scope:bp1_yearly_2060_first_consort = { highest_skill = learning }
						bp1_yearly_2060_is_relevant_consort_trigger = { TARGET = scope:bp1_yearly_2060_first_consort SKILL = learning }
					}
				}
			}
			save_scope_as = bp1_yearly_2060_second_consort
		}
		#Find a child
		scope:bp1_yearly_2060_second_consort = {
			random_child = {
				limit = { bp1_yearly_2060_is_relevant_child_trigger = yes }
				save_scope_as = bp1_yearly_2060_target_child
			}
		}
		#For localization
		scope:bp1_yearly_2060_target_child = {
			bp1_yearly_2030_get_lowest_skill_effect = yes
			switch = {
				trigger = scope:lowest_character_skill
				flag:diplomacy = { add_character_flag = bp1_yearly_2060_diplomacy_lowest_skill }
				flag:martial = { add_character_flag = bp1_yearly_2060_martial_lowest_skill }
				flag:stewardship = { add_character_flag = bp1_yearly_2060_stewardship_lowest_skill }
				flag:intrigue = { add_character_flag = bp1_yearly_2060_intrigue_lowest_skill }
				flag:learning = { add_character_flag = bp1_yearly_2060_learning_lowest_skill }
			}
		}
		#For determining which options to show, so we don't have Diplomacy on both options for instance
		scope:bp1_yearly_2060_first_consort = {
			switch = {
				trigger = highest_skill
				diplomacy = {
					save_scope_value_as = {
						name = consort_compare_skill
						value = flag:diplomacy
					}
				}
				martial = {
					save_scope_value_as = {
						name = consort_compare_skill
						value = flag:martial
					}
				}
				stewardship = {
					save_scope_value_as = {
						name = consort_compare_skill
						value = flag:stewardship
					}
				}
				intrigue = {
					save_scope_value_as = {
						name = consort_compare_skill
						value = flag:intrigue
					}
				}
				learning = {
					save_scope_value_as = {
						name = consort_compare_skill
						value = flag:learning
					}
				}
			}
		}
		#Find the consort with highest level of the intended skill for the duel
		scope:bp1_yearly_2060_first_consort = {
			switch = {
				trigger = highest_skill
				diplomacy = {
					bp1_yearly_2060_find_high_skill_tutor_effect = { SKILL = diplomacy }
				}
				martial = {
					bp1_yearly_2060_find_high_skill_tutor_effect = { SKILL = martial }
				}
				stewardship = {
					bp1_yearly_2060_find_high_skill_tutor_effect = { SKILL = stewardship }
				}
				intrigue = {
					bp1_yearly_2060_find_high_skill_tutor_effect = { SKILL = intrigue }
				}
				learning = {
					bp1_yearly_2060_find_high_skill_tutor_effect = { SKILL = learning }
				}
			}
		}
		#If the consort skill and the child skill are different, determine which consort has highest skill in the child skill and appoint them
		if = {
			limit = { 
				scope:consort_compare_skill != scope:lowest_character_skill 
			}
			switch = {
				trigger = scope:lowest_character_skill
				flag:diplomacy = {
					bp1_yearly_2060_find_low_skill_tutor_effect = { SKILL = diplomacy }
				}
				flag:martial = {
					bp1_yearly_2060_find_low_skill_tutor_effect = { SKILL = martial  }
				}
				flag:stewardship = {
					bp1_yearly_2060_find_low_skill_tutor_effect = { SKILL = stewardship  }
				}
				flag:intrigue = {
					bp1_yearly_2060_find_low_skill_tutor_effect = { SKILL = intrigue  }
				}
				flag:learning = {
					bp1_yearly_2060_find_low_skill_tutor_effect = { SKILL = learning  }
				}
			}
		}
	}
	#Let's go with the consort skill
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_trait = paranoid }
						desc = bp1_yearly.2060.a_paranoid
					}
					triggered_desc = {
						desc = bp1_yearly.2060.a
					}
				}
			}
		}
		#Who knows what else they're indoctrinating...
		flavor = {
			triggered_desc = {
				trigger = { has_trait = paranoid }
				desc = bp1_yearly.2060.a_tt_paranoid
			}
		}
		scope:bp1_yearly_2060_high_skill_tutoring_consort = {
			switch = {
				trigger = highest_skill
				diplomacy = {
					bp1_yearly_2060_bolstered_duel_effect = { SKILL = diplomacy }
				}
				martial = {
					bp1_yearly_2060_bolstered_duel_effect = { SKILL = martial }
				}
				stewardship = {
					bp1_yearly_2060_bolstered_duel_effect = { SKILL = stewardship }
				}
				intrigue = {
					bp1_yearly_2060_bolstered_duel_effect = { SKILL = intrigue }
				}
				learning = {
					bp1_yearly_2060_bolstered_duel_effect = { SKILL = learning }
				}
			}
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
			arrogant = miniscule_stress_impact_gain
			trusting = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 10
			#Paranoid be paranoid
			modifier = {
				has_trait = paranoid
				add = -50
			}
			modifier = {
				has_trait = arrogant
				add = -15
			}
			#Trusting and liking the intiating consort is beneficial
			modifier = {
				has_trait = trusting
				add = 20
			}
			opinion_modifier = {
				opinion_target = scope:bp1_yearly_2060_high_skill_tutoring_consort
				multiplier = -1
			}
			ai_value_modifier = {
				ai_rationality = 1
				ai_honor = 0.5
			}
		}
	}
	#Actually, please educate the child in it's lowest skill
	option = {
		name = bp1_yearly.2060.b
		trigger = { 
			scope:consort_compare_skill != scope:lowest_character_skill 
		}
		scope:bp1_yearly_2060_low_skill_tutoring_consort = {
			switch = {
				trigger = scope:lowest_character_skill
				flag:diplomacy = {
					bp1_yearly_2060_duel_effect = { SKILL = diplomacy }
				}
				flag:martial = {
					bp1_yearly_2060_duel_effect = { SKILL = martial  }
				}
				flag:stewardship = {
					bp1_yearly_2060_duel_effect = { SKILL = stewardship  }
				}
				flag:intrigue = {
					bp1_yearly_2060_duel_effect = { SKILL = intrigue  }
				}
				flag:learning = {
					bp1_yearly_2060_duel_effect = { SKILL = learning  }
				}
			}
		}
		ai_chance = {
			base = 5
			#Paranoid be paranoid
			modifier = {
				has_trait = paranoid
				add = -50
			}
			modifier = {
				has_trait = arrogant
				add = -15
			}
			#Trusting and liking the intiating consort is beneficial
			modifier = {
				has_trait = trusting
				add = 20
			}
			#They prefer the other consort
			opinion_modifier = {
				opinion_target = scope:bp1_yearly_2060_low_skill_tutoring_consort
				multiplier = -1
			}
			ai_value_modifier = {
				ai_rationality = 1
				ai_honor = 0.5
			}
		}
	}
	#If the consort's highest skill and the child's lowest skill are the same, opt out
	option = {
		name = bp1_yearly.2060.c
		trigger = { scope:consort_compare_skill = scope:lowest_character_skill }
		reverse_add_opinion = {
			target = scope:bp1_yearly_2060_first_consort
			modifier = dismissed_me_opinion
			opinion = -15
		}
		reverse_add_opinion = {
			target = scope:bp1_yearly_2060_second_consort
			modifier = dismissed_me_opinion
			opinion = -15
		}
		stress_impact = {
			ambitious = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 5
			#Paranoid be paranoid
			modifier = {
				has_trait = paranoid
				add = 50
			}
			modifier = {
				has_trait = ambitious
				add = -25
			}
			modifier = {
				has_trait = trusting
				add = -20
			}
			opinion_modifier = {
				opinion_target = scope:bp1_yearly_2060_first_consort
				multiplier = 1
			}
		}
	}
	after = {
		scope:bp1_yearly_2060_target_child = {
			remove_character_flag = bp1_yearly_2060_diplomacy_lowest_skill
			remove_character_flag = bp1_yearly_2060_martial_lowest_skill
			remove_character_flag = bp1_yearly_2060_stewardship_lowest_skill
			remove_character_flag = bp1_yearly_2060_intrigue_lowest_skill
			remove_character_flag = bp1_yearly_2060_learning_lowest_skill
		}
	}
}

##################################################
# #Childless older spouse ponders your relationship
# by Filippa Gannholm Kirsten
# #bp1_yearly.2070
##################################################
bp1_yearly.2070 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.2070.t
	desc = bp1_yearly.2070.desc
	theme = love
	override_background = { reference = wilderness }
	left_portrait = {
		character = root
		animation = love
	}
	right_portrait = {
		character = scope:bp1_yearly_2070_soulmate
		animation = sadness
	}
	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		is_playable_character = yes
		NOT = { has_character_flag = had_event_bp1_yearly_2070 }
		any_consort = { 
			is_available_ai_adult = yes
			has_relation_soulmate = root
			is_attracted_to_gender_of = root
			OR = {
				has_sexuality = homosexual
				fertility <= 0.1
			}		
			age > 40
			opinion = {
				target = root
				value >= 90
			}
			NOT = { 
				any_child = { exists = this } 
			}	
		}
	}
	immediate = {
		#play_music_cue = "mx_cue_touching_moment"
		#You only get this once in a lifetime.
		add_character_flag = had_event_bp1_yearly_2070
		#Find a consort
		random_consort = {
			limit = { 
				is_available_ai_adult = yes
				has_relation_soulmate = root
				is_attracted_to_gender_of = root
				opinion = {
					target = root
					value >= 90
				}
				NOT = { 
					any_child = { exists = this } 
				}
				OR = {
					has_sexuality = homosexual
					fertility <= 0.1
				}
				age > 40
			}
			save_scope_as = bp1_yearly_2070_soulmate
		}
		create_character_memory = {
			type = childless_soulmate_memory
			participants = {
				childless_soulmate = scope:bp1_yearly_2070_soulmate
			}
		}
	}
	#I got to spend all of this time with _you_
	option = {
		name = bp1_yearly.2070.a
		flavor = bp1_yearly.2070.a_tt
		add_character_modifier = {
			modifier = bp1_yearly_2070_accepting_modifier
		}
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
	#It was simply not HighGods will
	option = {
		name = bp1_yearly.2070.b
		flavor = bp1_yearly.2070.b_tt
		trigger = { 
			NOR = { 
				has_sexuality = homosexual
				scope:bp1_yearly_2070_soulmate = { has_sexuality = homosexual }
			}
		}
		add_character_modifier = {
			modifier = bp1_yearly_2070_zealous_modifier
		}
		stress_impact = {
			zealous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
	#You and I both know that is for the best
	option = {
		name = bp1_yearly.2070.c
		flavor = bp1_yearly.2070.c_tt
		trigger = {
			OR = {
				has_trait = cynical
				scope:bp1_yearly_2070_soulmate = { has_trait = cynical }
			}	
		}
		add_character_modifier = {
			modifier = bp1_yearly_2070_cynicism_modifier
		}
		stress_impact = {
			cynical = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
}
