namespace = bp2_yearly

########################
## BP2 Yearly Events
## 2000-2999
## by Chad Uhl
########################
##
## In Their Footsteps (House Founder)			bp2_yearly.2000
## In Their Footsteps (Ancestor)				bp2_yearly.2001
## In Their Footsteps (Artifact follow-up)		bp2_yearly.2002
##
#### Imaginary Friend Story Cycle Events 		bp2_yearly.2010-99
## Introduction Event							bp2_yearly.2010
## Playdate Event								bp2_yearly.2011
## Regent Shenanigans							bp2_yearly.2012
## Change a personality trait 					bp2_yearly.2013
## Pursue a crush 								bp2_yearly.2014
## Fight back against your bully 				bp2_yearly.2015
## Flower crowns								bp2_yearly.2016
## Study up or go practice swordsmanship		bp2_yearly.2017
## Gain the confider or poet trait 				bp2_yearly.2018
## Gain Eccentric trait 						bp2_yearly.2019
## Adulthood Events - Evil 						bp2_yearly.2020-29
##		bp2_yearly.2020 # Your imaginary friend wants you to kill someone
##		bp2_yearly.2021 # Why haven't you started your scheme?
##		bp2_yearly.2022 # Murder Success - Another target?
##		bp2_yearly.2023 # Murder Invalidated
##		bp2_yearly.2024 # Murder Failed, try again
##		bp2_yearly.2025 # Murder special ending
## Adulthood Events - Good 						bp2_yearly.2030-39
##		bp2_yearly.2030 # Imaginary friend reveals they are an angel
##		bp2_yearly.2031 # Honor your Imaginary Friend at the Holy Site
## Adulthood Events - Neutral					bp2_yearly.2040
##		bp2_yearly.2040 # Neutral ending
### END Imaginary Friend Events
##
## Laying Foundations							bp2_yearly.2100
##
#### Trait Specific Events
## Gain Humble or Arrogant 						bp2_yearly.2110
## Gain Temperate or Gluttonous					bp2_yearly.2120
## Gain Generous or Greedy						bp2_yearly.2130
## Gain Honest or Deceitful						bp2_yearly.2140
## Gain Herbalist or Gardener					bp2_yearly.2150
## Gain Compassionate or Sadistic				bp2_yearly.2160
##
########################

scripted_trigger relevant_story_teller_trigger = {
	OR = {
		any_close_or_extended_family_member = {
			is_relevant_to_child = yes
		}
		any_courtier_or_guest = {
			is_relevant_to_child = yes
		}
		any_knight = {
			is_relevant_to_child = yes
		}
		any_councillor = {
			is_relevant_to_child = yes
		}
		any_court_position_holder = {
			is_relevant_to_child = yes
		}
	}
}
# You hear a story about your house founder
bp2_yearly.2000 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2000.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:story_teller.dynasty = root.dynasty }
				desc = bp2_yearly.2000.desc_dynasty
			}
			desc = bp2_yearly.2000.desc
		}
	}
	theme = education

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:story_teller
		animation = admiration
	}
	lower_center_portrait = scope:root_house_founder

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		number_of_personality_traits < 3
		exists = house
		root.house.house_founder ?= {
			is_alive = no
			number_of_personality_traits_in_common = {
				target = root
				value < 3
			}
			number_of_opposing_personality_traits = {
				target = root
				value < 3
			}
		}
		relevant_story_teller_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 3
			culture = {
				OR = {
					has_cultural_tradition = tradition_mystical_ancestors
					has_cultural_tradition = tradition_storytellers
				}
			}
		}
		modifier = {
			factor = 4
			is_ai = no
		}
	}

	immediate = {
		house.house_founder = {
			save_scope_as = root_house_founder
		}
		# Grab someone to tell their story
		grab_learning_char_relevant_to_child = {
			CHILD = root
			SCOPE_OUTPUT = story_teller
		}
		scope:root_house_founder = {
			every_character_trait = {
				if = {
					limit = {
						# Must be a personality trait
						has_trait_category = personality
						# Child does not already have this trait
						root = {
							NOT = { has_trait = prev }
						}
						# Child does not already have the opposite of this trait
						any_opposite_trait = {
							root = {
								NOT = { has_trait = prev }
							}
						}
					}
					add_to_list = target_traits
				}
			}
		}

		random_in_list = {
			list = target_traits
			save_scope_as = target_trait
			random_opposite_trait = {
				save_scope_as = target_trait_opposite
			}
		}

		random_court_position_holder = {
			type = court_artificer_court_position
			save_scope_as = artificer
		}

	}

	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							OR = {
								scope:target_trait = trait:callous
								scope:target_trait = trait:deceitful
								scope:target_trait = trait:lazy
								faith = { trait_is_sin = scope:target_trait }
							}
						}
						desc = bp2_yearly.2000.a.negative
					}
					desc = bp2_yearly.2000.a
				}
			}
		}
		add_trait = scope:target_trait
		hidden_effect = {
			create_character_memory = {
				type = ancestor_trait_memory
				participants = {
					ancestor = scope:root_house_founder
				}
			}
			scope:new_memory = {
				set_variable = {
					name = target_trait
					value = scope:target_trait
				}
				if = {
					limit = { exists = var:target_trait }
					#To prevent 'unused except in loc' errors
				}
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2000.b
		add_trait = scope:target_trait_opposite
		hidden_effect = {
			create_character_memory = {
				type = ancestor_opposite_trait_memory
				participants = {
					ancestor = scope:root_house_founder
				}
			}
			scope:new_memory = {
				set_variable = {
					name = target_trait_opposite
					value = scope:target_trait_opposite
				}
				if = {
					limit = { exists = var:target_trait_opposite }
					#To prevent 'unused except in loc' errors
				}
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2000.c
		trigger = {
			employs_court_position = court_artificer_court_position
		}
		custom_tooltip = bp2_yearly.2000.c.tt
		remove_short_term_gold = medium_gold_value
		trigger_event = {
			id = bp2_yearly.2002
			days = { 7 21 }
		}

		ai_chance = {
			base = 30
		}
	}

	option = {
		name = bp2_yearly.2000.d
		ai_chance = {
			base = 0
		}
	}
}

# You hear a story about your ancestor
bp2_yearly.2001 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2000.t
	desc = bp2_yearly.2001.desc
	theme = education

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:story_teller
		animation = admiration
	}
	lower_center_portrait = scope:ancestor

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		number_of_personality_traits < 3
		any_ancestor = {
			even_if_dead = yes
			is_alive = no
			age >= 25
			number_of_personality_traits_in_common = {
				target = root
				value < 3
			}
			number_of_opposing_personality_traits = {
				target = root
				value < 3
			}
		}
		relevant_story_teller_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 3
			culture = {
				OR = {
					has_cultural_tradition = tradition_mystical_ancestors
					has_cultural_tradition = tradition_storytellers
				}
			}
		}
		modifier = {
			factor = 4
			is_ai = no
		}
	}

	immediate = {
		ordered_ancestor = {
			even_if_dead = yes
			limit = {
				is_alive = no
				age >= 25
				number_of_personality_traits_in_common = {
					target = root
					value < 3
				}
				number_of_opposing_personality_traits = {
					target = root
					value < 3
				}
			}
			order_by = highest_held_title_tier
			save_scope_as = ancestor
		}
		# Grab someone to tell their story
		grab_learning_char_relevant_to_child = {
			CHILD = root
			SCOPE_OUTPUT = story_teller
		}
		scope:ancestor = {
			every_character_trait = {
				if = {
					limit = {
						# Must be a personality trait
						has_trait_category = personality
						# Child does not already have this trait
						root = {
							NOT = { has_trait = prev }
						}
						# Child does not already have the opposite of this trait
						any_opposite_trait = {
							root = {
								NOT = { has_trait = prev }
							}
						}
					}
					add_to_list = target_traits
				}
			}
		}

		random_in_list = {
			list = target_traits
			save_scope_as = target_trait
			random_opposite_trait = {
				save_scope_as = target_trait_opposite
			}
		}

		random_court_position_holder = {
			type = court_artificer_court_position
			save_scope_as = artificer
		}

	}

	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							OR = {
								scope:target_trait = trait:callous
								scope:target_trait = trait:deceitful
								scope:target_trait = trait:lazy
								faith = { trait_is_sin = scope:target_trait }
							}
						}
						desc = bp2_yearly.2000.a.negative
					}
					desc = bp2_yearly.2001.a
				}
			}
		}
		#custom_tooltip = bp2_yearly.2000.a.tt
		add_trait = scope:target_trait
		hidden_effect = {
			create_character_memory = {
				type = ancestor_trait_memory
				participants = {
					ancestor = scope:ancestor
				}
			}
			scope:new_memory = {
				set_variable = {
					name = target_trait
					value = scope:target_trait
				}
				if = {
					limit = { exists = var:target_trait }
					#To prevent 'unused except in loc' errors
				}
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2000.b
		add_trait = scope:target_trait_opposite
		hidden_effect = {
			create_character_memory = {
				type = ancestor_opposite_trait_memory
				participants = {
					ancestor = scope:ancestor
				}
			}
			scope:new_memory = {
				set_variable = {
					name = target_trait_opposite
					value = scope:target_trait_opposite
				}
				if = {
					limit = { exists = var:target_trait_opposite }
					#To prevent 'unused except in loc' errors
				}
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2000.c
		trigger = {
			employs_court_position = court_artificer_court_position
		}
		custom_tooltip = bp2_yearly.2000.c.tt
		remove_short_term_gold = medium_gold_value
		trigger_event = {
			id = bp2_yearly.2002
			days = { 7 21 }
		}

		ai_chance = {
			base = 30
		}
	}

	option = {
		name = bp2_yearly.2000.d
		ai_chance = {
			base = 0
		}
	}
}

# Artifact follow-up
bp2_yearly.2002 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2000.t
	desc = bp2_yearly.2002.desc
	theme = education

	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:artificer
		animation = personality_honorable
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_bp2_dlc_trigger = yes
	}

	immediate = {
		random_list = {
			1 = { # Ring
			 	create_artifact_ring_effect = {
					OWNER = root
					SMITH = scope:artificer
				}
				if = {
					limit = { exists = scope:newly_created_artifact }
					scope:newly_created_artifact = {
						set_artifact_name = house_founder_ring_name
						set_artifact_description = house_founder_ring_desc
					}
				}
		 	}
		 	1 = { # Necklace
				create_artifact_necklace_effect = {
					OWNER = root
					SMITH = scope:artificer
				}
				if = {
					limit = { exists = scope:newly_created_artifact }
					scope:newly_created_artifact = {
						set_artifact_name = house_founder_necklace_name
						set_artifact_description = house_founder_necklace_desc
					}
				}
		 	}
		 	1 = { # Brooch
				create_artifact_brooch_effect = {
					OWNER = root
					SMITH = scope:artificer
				}
		 		if = {
					limit = { exists = scope:newly_created_artifact }
					scope:newly_created_artifact = {
						set_artifact_name = house_founder_brooch_name
						set_artifact_description = house_founder_brooch_desc
					}
				}
		 	}
		}
	}

	option = {
		name = bp2_yearly.2002.a
		show_as_tooltip = {
			scope:newly_created_artifact = { set_owner = root }
		}
	}
}

# Imaginary Friend - Story Cycle Start
bp2_yearly.2010 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2010.t
	desc = {
		desc = bp2_yearly.2010.desc
		random_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						mother ?= { is_ruler = yes }
						father ?= { is_ruler = yes }
					}
				}
				desc = bp2_yearly.2010.desc.landed
			}
			triggered_desc = {
				trigger = {
					mother ?= { is_alive = no }
					father ?= { is_alive = no }
				}
				desc = bp2_yearly.2010.desc.parents_dead
			}
		}
		desc = bp2_yearly.2010.outro
	}
	theme = friend_relation
	override_background = { reference = bp2_nursery }

	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = crying
		hide_info = yes
	}

	trigger = {
		is_ai = no
		is_landed = yes
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		age >= 6
		age <= 12
		NOT = {
			any_owned_story = {
				type = story_cycle_imaginary_friend
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 4
			has_trait = eccentric
		}

		modifier = {
			factor = 2
			any_parent = {
				even_if_dead = yes
				has_trait = eccentric
			}
		}
		modifier = {
			factor = 2
			any_relation = {
				type = guardian
				has_trait = eccentric
			}
		}

	}

	immediate = {
		create_character = {
			template = bp2_imaginary_friend_template
			dynasty = none
			location = root.location
			save_scope_as = imaginary_friend
		}

		set_variable = {
			name = imaginary_friend_char
			value = scope:imaginary_friend
		}

		create_story = story_cycle_imaginary_friend
		set_favorite_toy_effect = yes

		# Pick three random culture names - sorry for this being a bit cursed
		root.faith = {
			random_faith_character = {
				limit = {
					culture = root.culture
					trigger_if = {
						limit = { root = { is_female = yes } }
						is_male = yes
					}
					trigger_if = {
						limit = { root = { is_female = no } }
						is_female = yes
					}
				}
				save_scope_as = name_option_1
			}
			random_faith_character = {
				limit = {
					culture = root.culture
					this != scope:name_option_1
					trigger_if = {
						limit = { root = { is_female = yes } }
						is_male = yes
					}
					trigger_if = {
						limit = { root = { is_female = no } }
						is_female = yes
					}
				}
				save_scope_as = name_option_2
			}
			random_faith_character = {
				limit = {
					culture = root.culture
					NOR = {
						this = scope:name_option_1
						this = scope:name_option_2
					}
					trigger_if = {
						limit = { root = { is_female = yes } }
						is_male = yes
					}
					trigger_if = {
						limit = { root = { is_female = no } }
						is_female = yes
					}
				}
				save_scope_as = name_option_3
			}
		}

		# for loc
		if = {
			limit = {
				OR = {
					mother ?= {
						is_ruler = yes
					}
					father ?= { is_ruler = yes }
				}
			}
			if = {
				limit = { mother ?= { is_ruler = yes } }
				mother ?= { save_scope_as = ruler_parent }
			}
			else = {
				father ?= { save_scope_as = ruler_parent }
			}
		}
	}

	option = {
		name = bp2_yearly.2010.a
		set_variable = {
			name = imaginary_friend_name
			value = scope:name_option_1
		}
		random_owned_story = {
			type = story_cycle_imaginary_friend
			set_variable = {
				name = imaginary_friend_name
				value = scope:name_option_1
			}
		}
		create_character_memory = {
			type = imaginary_friend_gained_memory
			duration = { years = memory_default_duration }
		}
		random_memory = {
			memory_type = imaginary_friend_gained_memory
			set_variable = {
				name = imaginary_friend_name
				value = scope:name_option_1
			}
		}
	}

	option = {
		name = bp2_yearly.2010.b
		set_variable = {
			name = imaginary_friend_name
			value = scope:name_option_2
		}
		random_owned_story = {
			type = story_cycle_imaginary_friend
			set_variable = {
				name = imaginary_friend_name
				value = scope:name_option_2
			}
		}
		create_character_memory = {
			type = imaginary_friend_gained_memory
			duration = { years = memory_default_duration }
		}
		random_memory = {
			memory_type = imaginary_friend_gained_memory
			set_variable = {
				name = imaginary_friend_name
				value = scope:name_option_2
			}
		}
	}

	option = {
		name = bp2_yearly.2010.c
		set_variable = {
			name = imaginary_friend_name
			value = scope:name_option_3
		}
		random_owned_story = {
			type = story_cycle_imaginary_friend
			set_variable = {
				name = imaginary_friend_name
				value = scope:name_option_3
			}
		}
		create_character_memory = {
			type = imaginary_friend_gained_memory
			duration = { years = memory_default_duration }
		}
		random_memory = {
			memory_type = imaginary_friend_gained_memory
			set_variable = {
				name = imaginary_friend_name
				value = scope:name_option_3
			}
		}
	}

	after = {
		send_interface_toast = {
			title = gained_imaginary_friend
			left_icon = root
		}
		scope:imaginary_friend = {
			silent_disappearance_effect = yes
		}
		add_character_modifier = {
			modifier = imaginary_friend_modifier
		}
	}
}

scripted_effect necromance_imaginary_friend_character_effect = {
	create_character = {
		template = bp2_imaginary_friend_template
		dynasty = none
		location = root.location
		save_scope_as = imaginary_friend
	}
}

scripted_effect increase_progress_to_eccentricity_effect = {
	random_owned_story = {
		type = story_cycle_imaginary_friend
		change_variable = {
			name = progress_to_eccentric_trait
			add = $VALUE$
		}
	}
	if = {
		limit = { $VALUE$ <= 2 }
		custom_tooltip = imaginary_friend_increase_relationship
	}
	else_if = {
		limit = { $VALUE$ >= 3 }
		custom_tooltip = imaginary_friend_significantly_increase_relationship
	}
}

scripted_effect decrease_progress_to_eccentricity_effect = {
	random_owned_story = {
		type = story_cycle_imaginary_friend
		change_variable = {
			name = progress_to_eccentric_trait
			subtract = $VALUE$
		}
	}
	custom_tooltip = imaginary_friend_decrease_relationship
}

# You try to play with your imaginary friend at a playdate
bp2_yearly.2011 = {
	type = activity_event
	content_source = dlc_009
	title = bp2_yearly.2011.t
	desc = bp2_yearly.2011.desc
	theme = playdate_activity
	override_background = { reference = bp2_nursery }

	left_portrait = {
		character = root
		animation = anger
	}
	center_portrait = {
		character = scope:imaginary_friend
		animation = worry
		hide_info = yes
	}
	right_portrait = {
		character = scope:participant
		animation = schadenfreude
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		any_owned_story = {
			type = story_cycle_imaginary_friend
		}
		NOT = { has_character_flag = had_event_bp2_yearly_2011 }
	}

	immediate = {
		add_character_flag = had_event_bp2_yearly_2011

		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes

		# Pick out a fitting activity guest to bully you
		involved_activity = {
			ordered_attending_character = {
				limit = {
					this != root
					is_ai = yes
				}
				order_by = {
					value = age
					if = { # Childhood traits
						limit = {
							OR = {
								has_trait = rowdy
								has_trait = bossy
							}
						}
						add = 10
					}
					if = { # They or their parent have a higher title than you
						limit = {
							root = { is_landed = yes }
							OR = {
								AND = {
									exists = highest_held_title_tier
									highest_held_title_tier > root.highest_held_title_tier
								}
								AND = {
									exists = mother.highest_held_title_tier
									mother.highest_held_title_tier > root.highest_held_title_tier
								}
								AND = {
									exists = father.highest_held_title_tier
									father.highest_held_title_tier > root.highest_held_title_tier
								}
							}
						}
						add = 50
					}
					else_if = { # They or their parent have a higher title than your dad
						limit = {
							root = { is_landed = no }
							root.father = { is_landed = yes }
							OR = {
								AND = {
									exists = highest_held_title_tier
									highest_held_title_tier > root.father.highest_held_title_tier
								}
								AND = {
									exists = mother.highest_held_title_tier
									mother.highest_held_title_tier > root.father.highest_held_title_tier
								}
								AND = {
									exists = father.highest_held_title_tier
									father.highest_held_title_tier > root.father.highest_held_title_tier
								}
							}
						}
						add = 50
					}
					else_if = { # They or their parent have a higher title than your mom
						limit = {
							root = { is_landed = no }
							root.mother = { is_landed = yes }
							OR = {
								AND = {
									exists = highest_held_title_tier
									highest_held_title_tier > root.mother.highest_held_title_tier
								}
								AND = {
									exists = mother.highest_held_title_tier
									mother.highest_held_title_tier > root.mother.highest_held_title_tier
								}
								AND = {
									exists = father.highest_held_title_tier
									father.highest_held_title_tier > root.mother.highest_held_title_tier
								}
							}
						}
						add = 50
					}
				}
				save_scope_as = participant
			}
		}
	}

	option = {
		name = bp2_yearly.2011.a
		increase_progress_to_eccentricity_effect = { VALUE = 3 }
		stress_impact = {
			pensive = miniscule_stress_impact_gain
			rowdy = minor_stress_impact_loss
			bossy = miniscule_stress_impact_loss
		}
		send_interface_toast = {
			title = bp2_yearly.2011.bully.toast
			left_icon = root
			right_icon = scope:participant
			set_relation_bully = {
				target = scope:participant
				reason = bully_childhood_imaginary_friend
			}
		}
		create_character_memory = {
			type = tormented_me_during_childhood
			participants = {
				tormentor = scope:participant
			}
		}
		scope:participant = {
			create_character_memory = {
				type = childhood_started_bullying_positive
				participants = {
					victim = root
				}
			}
		}
	}

	option = {
		name = bp2_yearly.2011.b
		increase_progress_to_eccentricity_effect = { VALUE = 1 }
		add_prestige = miniscule_prestige_loss
		stress_impact = {
			rowdy = minor_stress_impact_loss
			bossy = miniscule_stress_impact_loss
		}
	}

	option = {
		name = bp2_yearly.2011.c
		# Rejected existence of Imaginary Friend
		decrease_progress_to_eccentricity_effect = { VALUE = 5 }
		stress_impact = {
			pensive = miniscule_stress_impact_loss
			bossy = miniscule_stress_impact_gain
			rowdy = miniscule_stress_impact_gain
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Regent Shenanigans
bp2_yearly.2012 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2012.t
	desc = bp2_yearly.2012.desc
	theme = friend_relation
	override_background = { reference = courtyard }

	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = thinking
		hide_info = yes
	}
	lower_center_portrait = scope:regent_scope

	cooldown = { years = 10 }

	trigger = {
		has_bp2_dlc_trigger = yes
		number_of_personality_traits < personality_trait_limit
		has_active_diarchy = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_trait = rowdy
			add = 1
		}
		modifier = {
			is_ai = yes
			factor = 0.1
		}
	}

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		diarch = { save_scope_as = regent_scope }
	}

	option = { # Gregarious
		name = bp2_yearly.2012.a
		if = {
			limit = {
				NOR = {
					has_trait = gregarious
					has_trait = shy
				}
			}
			add_trait = gregarious
		}
		duel = {
			skill = diplomacy
			target = scope:regent_scope
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = bp2_yearly.2012.a.success
				send_interface_toast = {
					title = bp2_yearly.2012.a.success
					left_icon = root
					right_icon = scope:regent_scope
					change_diarchy_swing = medium_sop_swing_liege_gain
					scope:regent_scope = {
						add_prestige = minor_prestige_loss
					}
				}
			}
			# Defeat!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = bp2_yearly.2012.a.failure
				send_interface_toast = {
					title = bp2_yearly.2012.a.failure
					left_icon = root
					right_icon = scope:regent_scope

					scope:regent_scope = {
						add_prestige = major_prestige_gain
					}
				}
			}
		}
		increase_progress_to_eccentricity_effect = { VALUE = 1 }
	}

	option = { # Deceitful
		name = bp2_yearly.2012.b
		trigger = {
			NOR = {
				has_trait = deceitful
				has_trait = trusting
			}
		}
		add_trait = deceitful

		duel = {
			skill = intrigue
			value = low_skill_rating
			# Victory!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = bp2_yearly.2012.b.success
				send_interface_toast = {
					title = bp2_yearly.2012.b.success
					left_icon = root
					right_icon = scope:regent_scope
					change_diarchy_swing = medium_sop_swing_liege_gain
					scope:regent_scope = {
						add_prestige = minor_prestige_loss
					}
				}
			}
			# Defeat!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = bp2_yearly.2012.b.failure
				send_interface_toast = {
					title = bp2_yearly.2012.b.failure
					left_icon = root
					right_icon = scope:regent_scope

					scope:regent_scope = {
						add_opinion = {
							target = root
							modifier = hate_opinion
							opinion = -20
						}
					}
				}
			}
		}
		increase_progress_to_eccentricity_effect = { VALUE = 2 }
	}

	option = {
		name = bp2_yearly.2012.c
		decrease_progress_to_eccentricity_effect = { VALUE = 1 }

		ai_chance = { # We want the AI to choose this so traits aren't imbalanced
			base = 100
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Chance to lose/change a personality trait
bp2_yearly.2013 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2013.t
	desc = bp2_yearly.2013.desc
	theme = friend_relation
	override_background = { reference = garden }

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = disapproval
		hide_info = yes
	}

	cooldown = { years = 16 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_ai = no # the ai doesn't need this event
		is_available_child = yes
		number_of_personality_traits >= 1
	}

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		# Pick a trait to target
		random_character_trait = {
			limit = { has_trait_category = personality }
			save_scope_as = target_trait
		}
		scope:target_trait = {
			random_opposite_trait = {
				save_scope_as = opposite_trait
			}
		}
	}

	option = { # Keep the trait
		name = bp2_yearly.2013.a
		decrease_progress_to_eccentricity_effect = { VALUE = 1 }
	}

	option = { # Lose the trait
		name = bp2_yearly.2013.b
		increase_progress_to_eccentricity_effect = { VALUE = 1 }
		remove_trait = scope:target_trait
	}

	option = { # Trade the trait
		name = bp2_yearly.2013.c
		increase_progress_to_eccentricity_effect = { VALUE = 2 }
		remove_trait = scope:target_trait
		add_trait_force_tooltip = scope:opposite_trait
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Imaginary Friend inspires you to pursue a crush
bp2_yearly.2014 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2014.t
	desc = bp2_yearly.2014.desc
	theme = friend_relation
	override_background = { reference = garden }

	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = flirtation
		hide_info = yes
	}
	lower_center_portrait = scope:crush

	cooldown = { years = 16 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		age >= 10
		num_of_relation_crush <= 0
		NOT = {
			has_trait = chaste
		}
		OR = {
			has_sexuality = heterosexual
			has_sexuality = bisexual
			has_sexuality = homosexual
		}
		# Ensure we have a character to crush on
		OR = {
			any_vassal = {
				save_good_crush_character_trigger_check = yes
			}
			any_vassal = {
				any_child = {
					save_good_crush_character_trigger_check = yes
				}
			}
			any_courtier_or_guest = {
				save_good_crush_character_trigger_check = yes
			}
			AND = {
				top_liege != this
				liege ?= {
					save_good_crush_character_trigger_check = yes
				}
			}
			AND = {
				top_liege != this
				liege ?= {
					any_vassal = {
						save_good_crush_character_trigger_check = yes
					}
				}
			}
			AND = {
				top_liege != this
				liege ?= {
					any_vassal = {
						any_child = {
							save_good_crush_character_trigger_check = yes
						}
					}
				}
			}
			AND = {
				top_liege != this
				liege ?= {
					any_courtier_or_guest = {
						save_good_crush_character_trigger_check = yes
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_trait = charming
			add = 1
		}
	}

	immediate = {
		play_music_cue = "mx_cue_touching_moment"
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		# Pick someone to crush on
		every_vassal = {
			limit = {
				save_good_crush_character_trigger_check = yes
			}
			add_to_list = crushes
		}
		every_vassal = {
			every_child = {
				limit = {
					save_good_crush_character_trigger_check = yes
				}
				add_to_list = crushes
			}
		}
		every_courtier_or_guest = {
			limit = {
				save_good_crush_character_trigger_check = yes
			}
			add_to_list = crushes
		}
		if = {
			limit = {
				top_liege != this
				liege ?= {
					save_good_crush_character_trigger_check = yes
				}
			}
			liege = {
				add_to_list = crushes
			}
		}
		if = {
			limit = {
				top_liege != this
				liege ?= {
					any_vassal = {
						save_good_crush_character_trigger_check = yes
					}
				}
			}
			liege = {
				every_vassal = {
					limit = {
						save_good_crush_character_trigger_check = yes
					}
					add_to_list = crushes
				}
			}
		}
		if = {
			limit = {
				top_liege != this
				liege ?= {
					any_vassal = {
						any_child = {
							save_good_crush_character_trigger_check = yes
						}
					}
				}
			}
			liege = {
				every_vassal = {
					every_child = {
						limit = {
							save_good_crush_character_trigger_check = yes
						}
						add_to_list = crushes
					}
				}
			}
		}
		if = {
			limit = {
				top_liege != this
				liege ?= {
					any_courtier_or_guest = {
						save_good_crush_character_trigger_check = yes
					}
				}
			}
			liege = {
				every_courtier_or_guest = {
					limit = {
						save_good_crush_character_trigger_check = yes
					}
					add_to_list = crushes
				}
			}
		}

		random_in_list = {
			list = crushes
			weight = {
				base = 1
				modifier = {
					add = 10
					top_liege != this
					exists = liege
					is_primary_heir_of = liege
				}
				modifier = {
					add = 5
					top_liege != this
					exists = liege
					is_heir_of = liege
				}
				modifier = {
					add = 10
					any_parent = {
						is_powerful_vassal_of = root
					}
				}
				modifier = {
					add = 5
					any_parent = {
						is_vassal_of = root
					}
				}
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = crush
		}
	}

	option = { # Raunchy Advance
		name = bp2_yearly.2014.a
		increase_progress_to_eccentricity_effect = { VALUE = 2 }
		if = { # Add lustful if we can
			limit = {
				number_of_personality_traits < 4
				NOT = { has_trait = lustful }
			}
			add_trait = lustful
		}
		set_relation_crush = scope:crush
		# Determine if they return the crush
		random_list = {
			50 = {
				send_interface_toast = {
					title = bp2_yearly.2014.a.success
					left_icon = root
					right_icon = scope:crush
					scope:crush = { set_relation_crush = root }
				}
				modifier = {
					has_trait = charming
					add = 10
				}
				modifier = {
					has_trait = lustful
					add = 10
				}
				modifier = {
					has_trait = gregarious
					add = 10
				}
				modifier = {
					has_trait = shy
					add = -20
				}
				modifier = {
					has_trait = chaste
					add = -30
				}
				modifier = {
					has_trait = temperate
					add = -10
				}
			}
			50 = {}
		}

		ai_chance = {
			base = 20
			modifier = {
				has_trait = lustful
				factor = 3
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
		}
	}

	option = { # Charming Advance
		name = bp2_yearly.2014.b
		increase_progress_to_eccentricity_effect = { VALUE = 1 }
		set_relation_crush = scope:crush
		# Determine if they return the crush
		random_list = {
			50 = {
				send_interface_toast = {
					title = bp2_yearly.2014.a.success
					left_icon = root
					right_icon = scope:crush
					scope:crush = { set_relation_crush = root }
				}
				modifier = {
					has_trait = charming
					add = 10
				}
				modifier = {
					has_trait = lustful
					add = 10
				}
				modifier = {
					has_trait = gregarious
					add = 10
				}
				modifier = {
					has_trait = shy
					add = -10
				}
			}
			50 = {}
		}

		ai_chance = {
			base = 30
			modifier = {
				has_trait = charming
				factor = 2
			}
			modifier = {
				has_trait = lustful
				factor = 0
			}
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
			charming = minor_stress_impact_loss
		}
	}

	option = { # I'm more interested in #EMP you#!
		name = bp2_yearly.2014.c
		increase_progress_to_eccentricity_effect = { VALUE = 3 }

		ai_chance = {
			base = 30
		}
	}

	option = { # Aw you're too afraid of love?
		name = bp2_yearly.2014.d
		decrease_progress_to_eccentricity_effect = { VALUE = 1 }
		if = {
			limit = {
				scope:crush = {
					is_ai = yes
				}
			}
			progress_towards_friend_effect = {
				CHARACTER = scope:crush
				OPINION = 10
				REASON = friend_childhood_friendzoned
			}
		}

		ai_chance = {
			base = 20
			modifier = {
				OR = {
					has_trait = lustful
					has_trait = charming
				}
				factor = 0
			}
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Imaginary friend inspires you to fight back against your bully
bp2_yearly.2015 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2015.t
	desc = bp2_yearly.2015.desc
	theme = friend_relation
	override_background = { reference = bp2_nursery }

	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = worry
		hide_info = yes
	}
	lower_center_portrait = scope:bully

	trigger = {
		has_bp2_dlc_trigger = yes
		is_ai = no
		is_available_child = yes
		# make sure they have a bully
		any_relation = { type = bully }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_relation = { type = bully }
			add = 2
		}
	}

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		# Save the bully
		random_relation = {
			type = bully
			save_scope_as = bully
			set_favorite_toy_effect = yes
		}
	}

	option = { # Fight them
		name = bp2_yearly.2015.a
		if = {
			limit = { has_trait = craven }
			remove_trait = craven
			add_trait_force_tooltip = brave
		}
		else_if = {
			limit = {
				number_of_personality_traits < 4
				NOR = {
					has_trait = brave
					any_character_trait = {
						any_opposite_trait = {
							this = trait:brave
						}
					}
				}
			}
			add_trait = brave
		}

		duel = {
			skill = prowess
			target = scope:bully

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 50
				}
				desc = bp2_yearly.2015.a.success
				send_interface_toast = {
					title = bp2_yearly.2015.a.success
					left_icon = root
					right_icon = scope:bully
					add_prowess_skill = 1
					remove_relation_bully = scope:bully
					increase_progress_to_eccentricity_effect = { VALUE = 3 }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = bp2_yearly.2015.a.failure
				send_interface_toast = {
					title = bp2_yearly.2015.a.failure
					left_icon = root
					right_icon = scope:bully
					add_prestige = minor_prestige_loss
					increase_progress_to_eccentricity_effect = { VALUE = 1 }
				}
			}
		}
	}

	option = { # Spread an embarrasing rumor
		name = bp2_yearly.2015.b

		if = {
			limit = {
				number_of_personality_traits < 4
				NOR = {
					has_trait = vengeful
					any_character_trait = {
						any_opposite_trait = {
							this = trait:vengeful
						}
					}
				}
			}
			add_trait = vengeful
		}

		duel = {
			skill = intrigue
			target = scope:bully

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 50
				}
				desc = bp2_yearly.2015.b.success
				send_interface_toast = {
					title = bp2_yearly.2015.b.success
					left_icon = root
					right_icon = scope:bully
					add_intrigue_skill = 1
					remove_relation_bully = scope:bully
					increase_progress_to_eccentricity_effect = { VALUE = 3 }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = bp2_yearly.2015.b.failure
				send_interface_toast = {
					title = bp2_yearly.2015.b.failure
					left_icon = root
					right_icon = scope:bully
					add_prestige = minor_prestige_loss
					increase_progress_to_eccentricity_effect = { VALUE = 1 }
				}
			}
		}
	}

	option = { # Run away and cry in your room
		name = bp2_yearly.2015.c
		if = {
			limit = { has_trait = brave }
			remove_trait = brave
			add_trait_force_tooltip = craven
		}
		else_if = {
			limit = {
				number_of_personality_traits < 4
				NOR = {
					has_trait = craven
					any_character_trait = {
						any_opposite_trait = {
							this = trait:craven
						}
					}
				}
			}
			add_trait = craven
		}
		decrease_progress_to_eccentricity_effect = { VALUE = 2 }
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Imaginary Friend invites you to pick flowers and make flower crowns
bp2_yearly.2016 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2016.t
	desc = bp2_yearly.2016.desc
	theme = friend_relation
	override_background = { reference = garden }

	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = admiration
		hide_info = yes
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		number_of_personality_traits < 3
	}

	cooldown = { years = 15 }

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
	}

	option = {
		name = bp2_yearly.2016.a
		if = {
			limit = {
				NOR = {
					has_trait = compassionate
					any_character_trait = {
						any_opposite_trait = {
							this = trait:compassionate
						}
					}
				}
			}
			add_trait = compassionate
		}
		else_if = {
			limit = {
				NOR = {
					has_trait = calm
					any_character_trait = {
						any_opposite_trait = {
							this = trait:calm
						}
					}
				}
			}
			add_trait = calm
		}
		else_if = {
			limit = {
				NOR = {
					has_trait = content
					any_character_trait = {
						any_opposite_trait = {
							this = trait:content
						}
					}
				}
			}
			add_trait = content
		}
		else_if = {
			limit = {
				NOR = {
					has_trait = humble
					any_character_trait = {
						any_opposite_trait = {
							this = trait:humble
						}
					}
				}
			}
			add_trait = humble
		}

		increase_progress_to_eccentricity_effect = { VALUE = 1 }

		stress_impact = {
			base = medium_stress_loss
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2016.b
		add_dread = minor_dread_gain
		decrease_progress_to_eccentricity_effect = { VALUE = 1 }

		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = rowdy
					has_trait = pensive
					has_trait = callous
					has_trait = sadistic
				}
				add = 30
			}
		}

		stress_impact = {
			pensive = minor_stress_impact_loss
			rowdy = minor_stress_impact_loss
			charming = minor_stress_impact_gain
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# If you are bookish in any way, your imaginary friend encourages you to stay up and study all the books
bp2_yearly.2017 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2017.t
	desc = bp2_yearly.2017.desc
	theme = friend_relation
	override_background = { reference = study }

	left_portrait = {
		character = root
		animation = reading
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = reading
		hide_info = yes
	}

	cooldown = { years = 16 }

	weight_multiplier = {
		base = 1
		# We don't need a ton of smart or healthy ais running 'round
		modifier = {
			is_ai = yes
			factor = 0
		}
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		OR = { # Are they a nerd?
			has_focus = education_learning
			has_trait = shrewd
			has_trait = pensive
		}
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
	}

	option = {
		name = bp2_yearly.2017.a
		if = { # increase learning education if you have it
			limit = { has_focus = education_learning }
			custom_tooltip = bp2_yearly.2017.a.tt
			education_point_acquisition_additional_points_effect = { LEVEL = mid }
		}
		if = { # chance to gain the shrewd trait
			limit = { NOT = { has_trait = shrewd } }
			random = {
				chance = 30
				add_trait = shrewd
			}
		}
		increase_progress_to_eccentricity_effect = { VALUE = 1 }


		stress_impact = {
			pensive = minor_stress_impact_loss
			shrewd = minor_stress_impact_loss
			rowdy = minor_stress_impact_gain
			curious = minor_stress_impact_gain
		}
	}

	option = {
		name = bp2_yearly.2017.b
		if = { # increase martial education if you have it
			limit = { has_focus = education_martial }
			custom_tooltip = bp2_yearly.2017.b.tt
			education_point_acquisition_additional_points_effect = { LEVEL = mid }
		}
		if = { # chance to gain the athletic trait
			limit = { NOT = { has_trait = athletic } }
			random = {
				chance = 50
				add_trait = athletic
			}
		}
		decrease_progress_to_eccentricity_effect = { VALUE = 1 }

		stress_impact = {
			pensive = minor_stress_impact_gain
			shrewd = minor_stress_impact_gain
			rowdy = minor_stress_impact_loss
			curious = minor_stress_impact_loss
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Chance to get the confider or poet trait
bp2_yearly.2018 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2018.t
	desc = bp2_yearly.2018.desc
	theme = friend_relation
	override_background = { reference = relaxing_room }

	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = admiration
		hide_info = yes
	}

	cooldown = { years = 16 }

	trigger = {
		 has_bp2_dlc_trigger = yes
		 NAND = {
		 	has_trait = confider
		 	has_trait = lifestyle_poet
		 }
		 stress >= normal_baseline_stress
	}

	weight_multiplier = {
		base = 1
		# We don't need a ton of ai poets and confiders running 'round
		modifier = {
			is_ai = yes
			factor = 0
		}
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
	}

	option = { # Channel your stress into the confider trait
		name = bp2_yearly.2018.a
		trigger = { NOT = { has_trait = confider } }
		add_trait = confider
		increase_progress_to_eccentricity_effect = { VALUE = 3 }

		stress_impact = {
			base = minor_stress_impact_loss
		}
	}

	option = { # Channel your stress into the poet trait
		name = bp2_yearly.2018.b
		trigger = { NOT = { has_trait = lifestyle_poet } }
		add_trait = lifestyle_poet
		increase_progress_to_eccentricity_effect = { VALUE = 1 }

		stress_impact = {
			base = minor_stress_impact_loss
		}
	}

	option = { # opt out
		name = bp2_yearly.2018.c
		if = { # increase martial education if you have it
			limit = { has_focus = education_martial }
			education_point_acquisition_additional_points_effect = { LEVEL = mid }
		}
		add_prowess_skill = 1
		stress_impact = {
			base = minor_stress_impact_loss
		}
		decrease_progress_to_eccentricity_effect = { VALUE = 1 }

		stress_impact = {
			pensive = minor_stress_impact_gain
			shrewd = minor_stress_impact_gain
			rowdy = minor_stress_impact_loss
			curious = minor_stress_impact_loss
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Chance to gain the Eccentric Trait
bp2_yearly.2019 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2019.t
	desc = {
		desc = bp2_yearly.2019.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:target_councilor = cp:councillor_court_chaplain
				}
				desc = bp2_yearly.2019.desc.chaplain
			}
			triggered_desc = {
				trigger = { scope:target_councilor = cp:councillor_court_chaplain }
				desc = bp2_yearly.2019.desc.chaplain_unlanded
			}
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:target_councilor = cp:councillor_steward
				}
				desc = bp2_yearly.2019.desc.steward
			}
			triggered_desc = {
				trigger = { scope:target_councilor = cp:councillor_steward }
				desc = bp2_yearly.2019.desc.steward_unlanded
			}
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:target_councilor = cp:councillor_marshal
				}
				desc = bp2_yearly.2019.desc.marshal
			}
			triggered_desc = {
				trigger = { scope:target_councilor = cp:councillor_marshal }
				desc = bp2_yearly.2019.desc.marshal_unlanded
			}
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:target_councilor = cp:councillor_spymaster
				}
				desc = bp2_yearly.2019.desc.spymaster
			}
			triggered_desc = {
				trigger = { scope:target_councilor = cp:councillor_spymaster }
				desc = bp2_yearly.2019.desc.spymaster_unlanded
			}
			triggered_desc = {
				trigger = {
					is_landed = yes
					scope:target_councilor = cp:councillor_chancellor
				}
				desc = bp2_yearly.2019.desc.chancellor
			}
			triggered_desc = {
				trigger = { scope:target_councilor = cp:councillor_chancellor }
				desc = bp2_yearly.2019.desc.chancellor_unlanded
			}
			triggered_desc = {
				trigger = { scope:target_councilor = { is_kurultai_trigger = yes } }
				desc = bp2_yearly.2019.desc.kurultai
			}
		}
		desc = bp2_yearly.2019.desc.outro
	}
	theme = friend_relation

	override_background = { reference = relaxing_room }

	left_portrait = {
		character = root
		animation = manic
	}
	right_portrait = {
		character = scope:target_councilor
		triggered_animation = {
			trigger = {
				scope:target_councilor = {
					has_council_position = councillor_court_chaplain
				}
			}
			animation = chaplain
		}
		triggered_animation = {
			trigger = {
				scope:target_councilor = {
					has_council_position = councillor_steward
				}
			}
			animation = steward
		}
		triggered_animation = {
			trigger = {
				scope:target_councilor = {
					has_council_position = councillor_marshal
				}
			}
			animation = marshal
		}
		triggered_animation = {
			trigger = {
				scope:target_councilor = {
					has_council_position = councillor_spymaster
				}
			}
			animation = spymaster
		}
		triggered_animation = {
			trigger = {
				scope:target_councilor = {
					has_council_position = councillor_chancellor
				}
			}
			animation = chancellor
		}
	}
	lower_center_portrait = {
		character = scope:imaginary_friend
		hide_info = yes
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_landless_adventurer = no
		NOT = { has_character_flag = had_bp2_yearly_2019 }
		# Doesn't have the opposites of Eccentric
		NOR = {
			has_trait = stubborn
			has_trait = fickle
		}
		any_owned_story = {
			type = story_cycle_imaginary_friend
			has_variable = progress_to_eccentric_trait
			var:progress_to_eccentric_trait >= 5
		}
		OR = { # ensure we have a councilor to grab
			exists = cp:councillor_court_chaplain
			exists = cp:councillor_steward
			exists = cp:councillor_marshal
			exists = cp:councillor_spymaster
			exists = cp:councillor_chancellor
			exists = cp:councillor_kurultai_1
			exists = cp:councillor_kurultai_2
			exists = cp:councillor_kurultai_3
			exists = cp:councillor_kurultai_4
		}
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
		random_list = {
			1 = {
				trigger = { exists = cp:councillor_court_chaplain }
				cp:councillor_court_chaplain = { save_scope_as = target_councilor }
			}
			1 = {
				trigger = { exists = cp:councillor_steward }
				cp:councillor_steward = { save_scope_as = target_councilor }
			}
			1 = {
				trigger = { exists = cp:councillor_marshal }
				cp:councillor_marshal = { save_scope_as = target_councilor }
			}
			1 = {
				trigger = { exists = cp:councillor_spymaster }
				cp:councillor_spymaster = { save_scope_as = target_councilor }
			}
			1 = {
				trigger = { exists = cp:councillor_chancellor }
				cp:councillor_chancellor = { save_scope_as = target_councilor }
			}
			1 = {
				trigger = { 
					any_councillor = {
						is_kurultai_trigger = yes
					}
				}
				random_councillor = {
					limit = {
						is_kurultai_trigger = yes
					}
					save_scope_as = target_councilor
				}
			}
		}
		add_character_flag = {
			flag = had_bp2_yearly_2019
			years = 16
		}
		# for option tooltips
		save_scope_as = root_scope
	}

	option = {
		name = bp2_yearly.2019.a
		flavor = bp2_yearly.2019.a.tt
		add_trait = eccentric
		every_vassal = {
			vassal_stance = courtly
			custom = every_courtly_vassal
			add_opinion = {
				target = root
				modifier = courtly_imaginary_friend_opinion
				opinion = -10
			}
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2019.b
		flavor = bp2_yearly.2019.b.tt
		add_trait = paranoid
		# Follow-up where your imaginary friend leaves

		ai_chance = {
			base = 50
		}
	}

	after = { scope:imaginary_friend = { silent_disappearance_effect = yes } }
}

### IMAGINARY FRIEND ADULT EVENTS
scripted_trigger is_valid_for_imaginary_friend_adult_event_trigger = {
	any_owned_story = {
		type = story_cycle_imaginary_friend
		save_temporary_scope_as = target_story_cycle
	}
	is_available_adult = yes
	is_travelling = no
	has_trait = eccentric
}

## EVIL IMAGINARY FRIEND

# Scripted effect for choosing murder target(s)
scripted_effect bp2_yearly_2020_choose_new_murder_target_effect = {
	random_list = { # Choose a random murder target
		1 = {
			trigger = {
				any_close_family_member = {
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = family_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:family_target
						}
					}
				}
			}
			random_close_family_member = {
				limit = {
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = family_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:family_target
						}
					}
				}
				save_scope_as = new_murder_target
			}
		}
		1 = {
			trigger = {
				primary_spouse ?= {
					is_alive = yes
					save_temporary_scope_as = spouse_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:spouse_target
						}
					}
				}
			}
			primary_spouse = {
				save_scope_as = new_murder_target
			}
		}
		1 = {
			trigger = {
				any_relation = {
					type = friend
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = friend_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:friend_target
						}
					}
				}
			}
			random_relation = {
				type = friend
				limit = {
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = friend_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:friend_target
						}
					}
				}
				save_scope_as = new_murder_target
			}
		}
		1 = {
			trigger = {
				any_relation = {
					type = best_friend
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = best_friend_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:best_friend_target
						}
					}
				}
			}
			random_relation = {
				type = best_friend
				limit = {
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = best_friend_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:best_friend_target
						}
					}
				}
				save_scope_as = new_murder_target
			}
		}
		1 = {
			trigger = {
				any_courtier_or_guest = {
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = guest_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:guest_target
						}
					}
				}
			}
			random_courtier_or_guest = {
				limit = {
					is_alive = yes
					is_adult = yes
					save_temporary_scope_as = guest_target
					root = {
						can_start_scheme = {
							type = murder
							target_character = scope:guest_target
						}
					}
				}
				save_scope_as = new_murder_target
			}
		}
	}
}

scripted_trigger bp2_yearly_2020_is_there_a_new_murder_target_trigger = {
	OR = {
		any_close_family_member = {
			is_alive = yes
			is_adult = yes
			save_temporary_scope_as = family_target
			root = {
				can_start_scheme = {
					type = murder
					target_character = scope:family_target
				}
			}
		}
		primary_spouse ?= {
			is_alive = yes
			save_temporary_scope_as = spouse_target
			root = {
				can_start_scheme = {
					type = murder
					target_character = scope:spouse_target
				}
			}
		}
		any_relation = {
			type = friend
			is_alive = yes
			is_adult = yes
			save_temporary_scope_as = friend_target
			root = {
				can_start_scheme = {
					type = murder
					target_character = scope:friend_target
				}
			}
		}
		any_relation = {
			type = best_friend
			is_alive = yes
			is_adult = yes
			save_temporary_scope_as = best_friend_target
			root = {
				can_start_scheme = {
					type = murder
					target_character = scope:best_friend_target
				}
			}
		}
		any_courtier_or_guest = {
			is_alive = yes
			is_adult = yes
			save_temporary_scope_as = guest_target
			root = {
				can_start_scheme = {
					type = murder
					target_character = scope:guest_target
				}
			}
		}
	}
}

# Your imaginary friend wants you to kill someone
bp2_yearly.2020 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2020.t
	desc = bp2_yearly.2020.desc
	theme = friend_relation
	override_background = { reference = corridor_night }

	left_portrait = {
		character = root
		animation = fear
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = spymaster
		hide_info = yes
	}
	lower_center_portrait = scope:murder_target

	trigger = {
		has_bp2_dlc_trigger = yes
		is_valid_for_imaginary_friend_adult_event_trigger = yes
		scope:target_story_cycle.var:imaginary_friend_disposition = flag:devil
		NOT = { has_character_flag = had_bp2_yearly_2020 }
		bp2_yearly_2020_is_there_a_new_murder_target_trigger = yes
	}

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		add_character_flag = had_bp2_yearly_2020

		# Choose a random murder target
		bp2_yearly_2020_choose_new_murder_target_effect = yes
		scope:new_murder_target = {
			save_scope_as = murder_target
		}
	}

	option = {
		name = bp2_yearly.2020.a
		if = {
			limit = {
				can_start_scheme = {
					type = murder
					target_character = scope:murder_target
				}
			}
			start_scheme = {
				type = murder
				target_character = scope:murder_target
			}
		}

		# Set up an event where your imaginary friend scolds you if you haven't started the scheme within 2 months
		trigger_event = {
			id = bp2_yearly.2021
			days = 60
		}
		set_variable = {
			name = imaginary_friend_murder_target
			value = scope:murder_target
		}
		custom_tooltip = imaginary_friend_first_murder_scheme_tt
	}

	option = {
		name = bp2_yearly.2020.b

		stress_impact = {
			base = massive_stress_impact_gain
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
		if = {
			limit = {
				has_variable = imaginary_friend_murder_target
				any_scheme = {
					type = murder 
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
			}
			random_scheme = {
				type = murder 
				limit = {
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
				add_scheme_modifier = { type = imaginary_friend_murder_scheme_modifier }
			}
		}
	}
}

# Why haven't you started your scheme?
bp2_yearly.2021 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2021.t
	desc = bp2_yearly.2021.desc
	theme = friend_relation

	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = rage
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		any_owned_story = {
			type = story_cycle_imaginary_friend
		}
		has_variable = imaginary_friend_murder_target
		NOT = {
			any_scheme = {
				type = murder
				scheme_target_character = root.var:imaginary_friend_murder_target
			}
		}
	}

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		root.var:imaginary_friend_murder_target = {
			save_scope_as = new_murder_target
		}
	}

	option = {
		name = bp2_yearly.2021.a

		show_as_unavailable = {
			NOT = {
				can_start_scheme = {
					type = murder
					target_character = scope:new_murder_target
				}
			}
		}

		start_scheme = {
			type = murder
			target_character = scope:new_murder_target
		}
		# Recursively fire event in 90 days to check if the character has started a scheme
		trigger_event = {
			id = bp2_yearly.2021
			days = 90
		}

		ai_chance = {
			base = 100
		}
	}

	option = {
		name = bp2_yearly.2021.b

		# Recursively fire event in 90 days to check if the character has started a scheme
		trigger_event = {
			id = bp2_yearly.2021
			days = 90
		}

		stress_impact = {
			base = minor_stress_impact_gain
			craven = minor_stress_impact_loss
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2021.c

		random_owned_story = {
			type = story_cycle_imaginary_friend
			end_story = yes
		}

		stress_impact = {
			base = medium_stress_impact_gain
			compassionate = minor_stress_impact_loss
			calm = minor_stress_impact_loss
			craven = minor_stress_impact_gain
		}

		ai_chance = {
			base = 0
		}
	}
}

# Murder Success - Another target?
bp2_yearly.2022 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2022.t
	desc = {
		desc = bp2_yearly.2022.desc
		triggered_desc = {
			trigger = {
				has_variable = imaginary_friend_murder_count
				var:imaginary_friend_murder_count >= 1
			}
			desc = bp2_yearly.2022.desc.next_target
		}
	}
	theme = friend_relation
	override_background = { reference = corridor_night }

	left_portrait = {
		character = root
		animation = paranoia
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = laugh
		hide_info = yes
	}
	lower_center_portrait = {
		character = scope:new_murder_target
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		bp2_yearly_2020_is_there_a_new_murder_target_trigger = yes
	}

	immediate = {
		# Revive a character to show as your imaginary friend
		necromance_imaginary_friend_character_effect = yes
		# Basic bonuses
		add_dread = medium_dread_gain
		add_stress = major_stress_loss
		# Add lunacy if they don't have it already
		if = {
			limit = {
				NOT = { has_trait = lunatic_1 }
			}
			add_trait = lunatic_1
		}
		# Increment murder count
		if = {
			limit = {
				NOT = { has_variable = imaginary_friend_murder_count }
			}
			set_variable = {
				name = imaginary_friend_murder_count
				value = 1
			}
		}
		else = {
			change_variable = {
				name = imaginary_friend_murder_count
				add = 1
			}
		}

		# Choose a random murder target
		bp2_yearly_2020_choose_new_murder_target_effect = yes
	}

	option = {
		name = bp2_yearly.2022.a
		flavor = bp2_yearly.2019.a.tt

		if = {
			limit = {
				can_start_scheme = {
					type = murder
					target_character = scope:new_murder_target
				}
			}
			start_scheme = {
				type = murder
				target_character = scope:new_murder_target
			}
		}
		custom_tooltip = imaginary_friend_future_murder_scheme_tt

		# Set up an event where your imaginary friend scolds you if you haven't started the scheme within 2 months
		trigger_event = {
			id = bp2_yearly.2021
			days = 60
		}
		set_variable = {
			name = imaginary_friend_murder_target
			value = scope:new_murder_target
		}

		ai_chance = 100
	}

	option = {
		name = bp2_yearly.2022.b
		flavor = bp2_yearly.2019.b.tt

		stress_impact = {
			base = medium_stress_impact_gain
		}

		ai_chance = 0
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
		if = {
			limit = {
				has_variable = imaginary_friend_murder_target
				any_scheme = {
					type = murder
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
			}
			random_scheme = {
				type = murder 
				limit = {
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
				add_scheme_modifier = { type = imaginary_friend_murder_scheme_modifier }
			}
		}
	}
}

# Murder Invalidated
bp2_yearly.2023 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2023.t
	desc = {
		desc = bp2_yearly.2023.desc
		desc = bp2_yearly.2022.desc.next_target
	}
	theme = friend_relation
	override_background = { reference = corridor_night }

	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = anger
		hide_info = yes
	}
	lower_center_portrait = scope:new_murder_target

	trigger = {
		has_bp2_dlc_trigger = yes
		bp2_yearly_2020_is_there_a_new_murder_target_trigger = yes
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
		# Choose a random murder target
		bp2_yearly_2020_choose_new_murder_target_effect = yes
	}

	option = {
		name = bp2_yearly.2023.a
		if = {
			limit = {
				can_start_scheme = {
					type = murder
					target_character = scope:new_murder_target
				}
			}
			start_scheme = {
				type = murder
				target_character = scope:new_murder_target
			}
		}
		else = {
			custom_tooltip = imaginary_friend_future_murder_scheme_tt
			set_variable = {
				name = imaginary_friend_murder_target
				value = scope:new_murder_target
			}
		}
		# Set up an event where your imaginary friend scolds you if you haven't started the scheme within 2 months
		trigger_event = {
			id = bp2_yearly.2021
			days = 60
		}
		set_variable = {
			name = imaginary_friend_murder_target
			value = scope:new_murder_target
		}
	}

	option = {
		name = bp2_yearly.2023.b
		stress_impact = {
			base = massive_stress_impact_gain
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
		if = {
			limit = {
				has_variable = imaginary_friend_murder_target
				any_scheme = {
					type = murder
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
			}
			random_scheme = {
				type = murder 
				limit = {
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
				add_scheme_modifier = { type = imaginary_friend_murder_scheme_modifier }
			}
		}
	}
}

# Murder Failed, try again
bp2_yearly.2024 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2024.t
	desc = {
		desc = bp2_yearly.2024.desc
		desc = bp2_yearly.2022.desc.next_target
	}
	theme = friend_relation
	override_background = { reference = corridor_night }

	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = anger
		hide_info = yes
	}
	lower_center_portrait = scope:new_murder_target

	trigger = {
		has_bp2_dlc_trigger = yes
		bp2_yearly_2020_is_there_a_new_murder_target_trigger = yes
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
		# Choose a random murder target
		bp2_yearly_2020_choose_new_murder_target_effect = yes
	}

	option = {
		name = bp2_yearly.2024.a
		if = {
			limit = {
				can_start_scheme = {
					type = murder
					target_character = scope:new_murder_target
				}
			}
			start_scheme = {
				type = murder
				target_character = scope:new_murder_target
			}
		}
		else = {
			custom_tooltip = imaginary_friend_future_murder_scheme_tt
			set_variable = {
				name = imaginary_friend_murder_target
				value = scope:new_murder_target
			}
		}
		# Set up an event where your imaginary friend scolds you if you haven't started the scheme within 2 months
		trigger_event = {
			id = bp2_yearly.2021
			days = 60
		}
		set_variable = {
			name = imaginary_friend_murder_target
			value = scope:new_murder_target
		}
	}

	option = {
		name = bp2_yearly.2024.b
		stress_impact = {
			base = massive_stress_impact_gain
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
		if = {
			limit = {
				has_variable = imaginary_friend_murder_target
				any_scheme = {
					type = murder
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
			}
			random_scheme = {
				type = murder 
				limit = {
					scheme_target_character = root.var:imaginary_friend_murder_target
				}
				add_scheme_modifier = { type = imaginary_friend_murder_scheme_modifier }
			}
		}
	}
}

# Murder special ending 2025
bp2_yearly.2025 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2025.t
	desc = bp2_yearly.2025.desc
	theme = friend_relation

	override_background = { reference = corridor_night }

	left_portrait = {
		character = root
		animation = manic
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = love
		hide_info = yes
	}
	lower_center_portrait = scope:target

	trigger = {
		has_bp2_dlc_trigger = yes
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
	}

	option = {
		name = bp2_yearly.2025.a
		set_nickname_effect = { NICKNAME = nick_the_mad }
		add_character_modifier = {
			modifier = imaginary_friend_mad_modifier
		}
		custom_tooltip = imaginary_friend_mad_modifier_bribe_discount
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
		random_owned_story = {
			type = story_cycle_imaginary_friend
			end_story = yes  
		}
		if = {
			limit = { has_character_modifier = imaginary_friend_modifier }
			remove_character_modifier = imaginary_friend_modifier
		}
	}
}

## GOOD IMAGINARY FRIEND
# Imaginary friend reveals they are an angel
bp2_yearly.2030 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2030.t
	desc = bp2_yearly.2030.desc
	theme = friend_relation
	override_background = { reference = relaxing_room }

	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = personality_content
		hide_info = yes
	}

	trigger = {
		 has_bp2_dlc_trigger = yes
		 is_valid_for_imaginary_friend_adult_event_trigger = yes
		 NOT = { has_character_flag = bp2_yearly_2030 }
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
		add_character_flag = bp2_yearly_2030
		# Pick a random holy site that you can pilgrimage to
		faith = {
			random_holy_site = { save_scope_as = target_holy_site }
		}
		random_owned_story = {
			type = story_cycle_imaginary_friend
			set_variable = {
				name = pilgrimage_destination
				value = scope:target_holy_site.title_province
			}
		}
	}

	option = { # Start a pilgrimage right now
		name = bp2_yearly.2030.a
		custom_tooltip = bp2_yearly.2030.a.tt
		open_view_data = {
			view = activity_list_detail_host_window
			data = activity_type:activity_pilgrimage
			player = root
		}
		add_character_flag = {
			flag = imaginary_friend_pilgrimage_discount
			years = 2
		}

		stress_impact = {
			zealous = minor_stress_impact_loss
			cynical = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				has_trait = cynical
			}
		}
	}

	option = { # cynical is baffled
		name = bp2_yearly.2030.b
		trigger = { has_trait = cynical }

		remove_trait = cynical
		add_trait_force_tooltip = zealous

		add_character_flag = {
			flag = imaginary_friend_pilgrimage_discount
			years = 2
		}

		stress_impact = {
			cynical = minor_stress_impact_loss
			zealous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 0
		}
	}

	option = { # Just pray here
		name = bp2_yearly.2030.c
		add_piety = medium_piety_gain

		stress_impact = {
			eccentric = major_stress_impact_gain
			zealous = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				has_trait = eccentric
			}
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
	}
}

# Honor your Imaginary Friend at the Holy Site
bp2_yearly.2031 = {
	type = activity_event
	content_source = dlc_009
	title = bp2_yearly.2031.t
	desc = bp2_yearly.2031.desc
	theme = friend_relation
	override_background = {
		trigger = {
			NOR = {
				faith = { religion = religion:hinduism_religion }
				faith = { religion = religion:buddhism_religion }
				faith = { religion = religion:jainism_religion }
			}
		}
		reference = temple
	}
	override_background = {
		trigger = {
			OR = {
				faith = { religion = religion:hinduism_religion }
				faith = { religion = religion:buddhism_religion }
				faith = { religion = religion:jainism_religion }
			}
		}
		reference = ep2_holy_site_indian
	}

	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = personality_zealous
		hide_info = yes
	}

	trigger = {
		 has_bp2_dlc_trigger = yes
	}

	immediate = {
		 necromance_imaginary_friend_character_effect = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_trait = zealous
			add = 1
		}
		modifier = {
			has_learning_lifestyle_trait_trigger = yes
			add = 1
		}
	}

	option = {
		name = bp2_yearly.2031.a
		# Effects
		if = {
			limit = {
				piety_level < max_piety_level
			}
			add_piety_level = 1
		}
		else = {
			add_piety = massive_piety_gain
		}

		if = {
			limit = {
				NOT = { has_trait = lifestyle_mystic }
			}
			add_trait = lifestyle_mystic
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = lifestyle_mystic
					value < 100
				}
			}
			add_trait_xp = {
				trait = lifestyle_mystic
				value = 50
			}
		}
		# Add activity log entry
		scope:activity = {
			add_activity_log_entry = {
				key = imaginary_friend_pilgrimage_log
				show_in_conclusion = yes
				score = 50
				character = scope:activity.activity_host
			}
		}
		# Add memory
		create_character_memory = { type = honored_imaginary_friend_memory }
		scope:new_memory = {
			set_variable = {
				name = location
				value = root.location
			}
			set_variable = {
				name = imaginary_friend_name
				value = root.var:imaginary_friend_name
			}
		}

		stress_impact = {
			base = major_stress_impact_loss
		}
	}

	after = {
		scope:imaginary_friend = { silent_disappearance_effect = yes }
		random_owned_story = {
			type = story_cycle_imaginary_friend
			end_story = yes
		}
		if = {
			limit = { has_character_modifier = imaginary_friend_modifier }
			remove_character_modifier = imaginary_friend_modifier
		}
	}
}

## NEUTRAL ENDING
bp2_yearly.2040 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2040.t
	desc = {
		desc = bp2_yearly.2040.desc
		triggered_desc = {
			trigger = { exists = scope:lover }
			desc = bp2_yearly.2040.desc.lover
		}
		triggered_desc = {
			trigger = { exists = scope:friend }
			desc = bp2_yearly.2040.desc.friend
		}
	}
	theme = friend_relation
	override_background = { reference = relaxing_room }

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:imaginary_friend
		animation = personality_compassionate
		hide_info = yes
	}

	lower_center_portrait = scope:lover
	lower_right_portrait = scope:friend

	trigger = {
		has_bp2_dlc_trigger = yes
		is_valid_for_imaginary_friend_adult_event_trigger = yes
		NOT = { has_character_flag = bp2_yearly_2030 }
		OR = {
			any_relation = {
				type = friend
				NOT = { has_relation_best_friend = root }
			}
			AND = {
				root = { num_of_relation_lover < 2 }
				any_courtier_or_guest = {
					trigger_if = {
						limit = {
							OR = {
								is_married = yes
								num_of_relation_lover = 1
							}
						}
						might_cheat_on_every_partner_trigger = yes
					}
					NOT = { has_relation_lover = root }
					num_of_relation_lover < 2
					is_physically_able_ai_adult = yes
					save_temporary_scope_as = temp_lover
					matching_gender_and_sexuality_trigger = {
						CHARACTER_1 = scope:temp_lover
						CHARACTER_2 = root
					}
				}
			}
		}
	}

	immediate = {
		necromance_imaginary_friend_character_effect = yes
		add_character_flag = bp2_yearly_2030
		# Find characters to manipulate
		# Friend -> best friend
		if = {
			limit = {
				any_relation = {
					type = friend
					NOT = { has_relation_best_friend = root }
				}
			}
			random_relation = {
				type = friend
				limit = {
					NOT = { has_relation_best_friend = root }
				}
				save_scope_as = friend
			}
			random_memory = {
				memory_type = became_friends
				limit = {
					has_memory_participant = scope:friend
				}
				save_scope_as = target_memory
			}
			get_period_of_time_word_setup_effect = {
				START_DATE = scope:target_memory.memory_creation_date
			}

		}
		# Lover
		random_courtier_or_guest = {
			limit = {
				trigger_if = {
					limit = {
						OR = {
							is_married = yes
							num_of_relation_lover = 1
						}
					}
					might_cheat_on_every_partner_trigger = yes
				}
				NOT = { has_relation_lover = root }
				num_of_relation_lover < 2
				is_physically_able_ai_adult = yes
				save_temporary_scope_as = temp_lover
				matching_gender_and_sexuality_trigger = {
					CHARACTER_1 = scope:temp_lover
					CHARACTER_2 = root
				}
			}
			save_scope_as = lover
		}

	}

	option = {
		name = bp2_yearly.2040.a
		trigger = { exists = scope:lover }
		set_relation_lover = {
			reason = lover_imaginary_friend
			target = scope:lover
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = bp2_yearly.2040.b
		trigger = { exists = scope:friend }
		set_relation_best_friend = {
			reason = best_friend_imaginary_friend
			target = scope:friend
		}

		stress_impact = {
			lustful = medium_stress_impact_loss
		}

		ai_chance = {
			base = 50
		}
	}

	after = {
		clean_up_period_of_time_word_effect = yes

		scope:imaginary_friend = { silent_disappearance_effect = yes }
		random_owned_story = {
			type = story_cycle_imaginary_friend
			end_story = yes  
		}
		if = {
			limit = { has_character_modifier = imaginary_friend_modifier }
			remove_character_modifier = imaginary_friend_modifier
		}
	}
}

##########################################
# Flavor Events

scripted_trigger bp2_yearly_2000_pick_child_interlocutor_trigger = {
	OR = {
		any_sibling = {
			is_available_ai_child = yes
			age > root.age_minus_3
			age >= 4
			location = root.location
		}
		location = {
			any_character_in_location = {
				is_available_ai_child = yes
				age > root.age_minus_3
				age >= 4
				OR = {
					liege = root
					is_courtier_of = root
					is_pool_guest_of = root
				}
				this != root
			}
		}
	}
}

scripted_effect bp2_yearly_2000_pick_child_interlocutor_effect = {
	if = {
		limit = {
			any_sibling = {
				is_available_ai_child = yes
				age > root.age_minus_3
				age >= 4
				location = root.location
			}
		}
		random_sibling = {
			limit = {
				is_available_ai_child = yes
				age > root.age_minus_3
				age >= 4
				location = root.location
			}
			save_scope_as = interlocutor
		}
	}
	else = {
		location = {
			random_character_in_location = {
				limit = {
					is_available_ai_child = yes
					age > root.age_minus_3
					age >= 4
					OR = {
						liege = root
						is_courtier_of = root
						is_pool_guest_of = root
					}
					this != root
				}
				save_scope_as = interlocutor
			}
		}
	}
}

# Build something with your friend, get a some xp I guess
bp2_yearly.2100 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2100.t
	desc = bp2_yearly.2100.desc
	theme = friend_relation
	override_background = { reference = garden }

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:interlocutor
		animation = happiness
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		age >= 5
		age <= 15
		bp2_yearly_2000_pick_child_interlocutor_trigger = yes
		OR = {
			has_variable = education_diplomacy_variable
			has_variable = education_martial_variable
			has_variable = education_stewardship_variable
			has_variable = education_intrigue_variable
			has_variable = education_learning_variable
		}
	}

	cooldown = { years = 16 }

	immediate = {
		# Pick an interlocutor
		bp2_yearly_2000_pick_child_interlocutor_effect = yes
		# Pick a random second option to show
		if = {
			limit = { has_variable = education_diplomacy_variable }
			add_character_flag = option_a
		}
		else_if = {
			limit = { has_variable = education_martial_variable }
			add_character_flag = option_b
		}
		else_if = {
			limit = { has_variable = education_stewardship_variable }
			add_character_flag = option_c
		}
		else_if = {
			limit = { has_variable = education_intrigue_variable }
			add_character_flag = option_d
		}
		else_if = {
			limit = { has_variable = education_learning_variable }
			add_character_flag = option_e
		}
		random_list = {
			1 = {
				trigger = {
					NOT = { has_character_flag = option_a }
				}
				add_character_flag = option_a
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_b }
				}
				add_character_flag = option_b
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_c }
				}
				add_character_flag = option_c
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_d }
				}
				add_character_flag = option_d
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_e }
				}
				add_character_flag = option_e
			}
		}
		random_list = {
			1 = {
				trigger = {
					NOT = { has_character_flag = option_a }
				}
				add_character_flag = option_a
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_b }
				}
				add_character_flag = option_b
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_c }
				}
				add_character_flag = option_c
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_d }
				}
				add_character_flag = option_d
			}
			1 = {
				trigger = {
					NOT = { has_character_flag = option_e }
				}
				add_character_flag = option_e
			}
		}
	}

	option = { # Diplomacy
		name = bp2_yearly.2100.a
		trigger = { has_character_flag = option_a }
		if = {
			limit = { has_variable = education_diplomacy_variable }
			#Award more points
			custom_tooltip = bp2_yearly.2100.a.tt
			change_variable = {
				name = education_diplomacy_variable
				add = 4
			}
		}
		else = {
			add_diplomacy_skill = 1
			progress_towards_friend_effect = {
				REASON = friend_wedding_relation_bond
				CHARACTER = scope:interlocutor
				OPINION = default_friend_opinion
			}
		}
	}

	option = { # Martial
		name = bp2_yearly.2100.b
		#trigger = { has_character_flag = option_b }
		if = {
			limit = { has_variable = education_martial_variable }
			#Award more points
			custom_tooltip = bp2_yearly.2100.b.tt
			change_variable = {
				name = education_martial_variable
				add = 4
			}
		}
		else = {
			add_martial_skill = 1
			progress_towards_friend_effect = {
				REASON = friend_wedding_relation_bond
				CHARACTER = scope:interlocutor
				OPINION = default_friend_opinion
			}
		}
	}

	option = { # Stewardship
		name = bp2_yearly.2100.c
		trigger = { has_character_flag = option_c }
		if = {
			limit = { has_variable = education_stewardship_variable }
			#Award more points
			custom_tooltip = bp2_yearly.2100.c.tt
			change_variable = {
				name = education_stewardship_variable
				add = 4
			}
		}
		else = {
			add_stewardship_skill = 1
			progress_towards_friend_effect = {
				REASON = friend_wedding_relation_bond
				CHARACTER = scope:interlocutor
				OPINION = default_friend_opinion
			}
		}
	}

	option = { # Intrigue
		name = bp2_yearly.2100.d
		trigger = { has_character_flag = option_d }
		if = {
			limit = { has_variable = education_intrigue_variable }
			#Award more points
			custom_tooltip = bp2_yearly.2100.d.tt
			change_variable = {
				name = education_intrigue_variable
				add = 4
			}
		}
		else = {
			add_intrigue_skill = 1
			progress_towards_friend_effect = {
				REASON = friend_wedding_relation_bond
				CHARACTER = scope:interlocutor
				OPINION = default_friend_opinion
			}
		}
	}

	option = { # Learning
		name = bp2_yearly.2100.e
		trigger = { has_character_flag = option_e }
		if = {
			limit = { has_variable = education_learning_variable }
			#Award more points
			custom_tooltip = bp2_yearly.2100.e.tt
			change_variable = {
				name = education_learning_variable
				add = 4
			}
		}
		else = {
			add_learning_skill = 1
			progress_towards_friend_effect = {
				REASON = friend_wedding_relation_bond
				CHARACTER = scope:interlocutor
				OPINION = default_friend_opinion
			}
		}
	}

	after = {
		if = {
			limit = { has_character_flag = option_a }
			remove_character_flag = option_a
		}
		if = {
			limit = { has_character_flag = option_b }
			remove_character_flag = option_b
		}
		if = {
			limit = { has_character_flag = option_c }
			remove_character_flag = option_c
		}
		if = {
			limit = { has_character_flag = option_d }
			remove_character_flag = option_d
		}
		if = {
			limit = { has_character_flag = option_e }
			remove_character_flag = option_e
		}
	}
}

# Take a trait... or don't... it's up to you
bp2_yearly.2110 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2110.t
	desc = bp2_yearly.2110.desc
	theme = friend_relation
	override_background = { reference = courtyard }

	left_portrait = {
		character = root
		animation = celebrate_sword
	}
	right_portrait = {
		character = scope:interlocutor
		animation = sword_yield_start
	}

	cooldown = { years = 20 }

	trigger = {
		is_ai = no
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		age >= 6
		number_of_personality_traits < 3
		NOR = {
			has_trait = humble
			has_trait = arrogant
		}
		bp2_yearly_2000_pick_child_interlocutor_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			is_ai = no
			factor = 10
		}
	}

	immediate = {
		bp2_yearly_2000_pick_child_interlocutor_effect = yes
	}

	option = { # Humble
		name = bp2_yearly.2110.a
		add_trait = humble

		ai_chance = {
			base = 30
		}

		stress_impact = {
			pensive = minor_stress_impact_loss
			rowdy = minor_stress_impact_gain
		}
	}

	option = { # Arrogant
		name = bp2_yearly.2110.b
		add_trait = arrogant

		ai_chance = {
			base = 30
		}

		stress_impact = {
			bossy = medium_stress_impact_loss
			rowdy = minor_stress_impact_loss
			pensive = minor_stress_impact_gain
		}
	}

	option = { # Remain Silent
		name = bp2_yearly.2110.c

		ai_chance = {
			base = 30
		}
	}
}

bp2_yearly.2120 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2120.t
	desc = bp2_yearly.2120.desc
	theme = friend_relation
	override_background = { reference = bp1_kitchen_western }

	left_portrait = {
		character = root
		animation = toast_goblet
	}
	right_portrait = {
		character = scope:interlocutor
		animation = worry
	}

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		is_ai = no
		age >= 6
		number_of_personality_traits < 3
		NOR = {
			has_trait = temperate
			has_trait = gluttonous
		}
		bp2_yearly_2000_pick_child_interlocutor_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			is_ai = no
			factor = 10
		}
	}

	immediate = {
		bp2_yearly_2000_pick_child_interlocutor_effect = yes
	}

	option = { # temperate
		name = bp2_yearly.2120.a
		add_trait = temperate

		ai_chance = {
			base = 30
		}

		stress_impact = {
			rowdy = minor_stress_impact_gain
			pensive = minor_stress_impact_loss
		}
	}

	option = { # gluttonous
		name = bp2_yearly.2120.b
		add_trait = gluttonous

		ai_chance = {
			base = 30
		}

		stress_impact = {
			pensive = minor_stress_impact_gain
		}
	}

	option = { # No way jose
		name = bp2_yearly.2110.c

		ai_chance = {
			base = 30
		}
	}
}

bp2_yearly.2130 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2130.t
	desc = bp2_yearly.2130.desc
	theme = friend_relation
	override_background = { reference = alley_day }

	left_portrait = {
		character = root
		animation = clutching_toy
	}
	right_portrait = {
		character = scope:interlocutor
		animation = sadness
	}

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_ai = no
		is_ruler = yes
		is_available_child = yes
		age >= 6
		number_of_personality_traits < 3
		NOR = {
			has_trait = generous
			has_trait = greedy
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			is_ai = no
			factor = 10
		}
	}

	immediate = {
		set_favorite_toy_effect = yes
		if = {
			limit = {
				any_pool_character = {
					province = root.location
					age >= root.age_minus_3
					is_available_ai_child = yes
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					age >= root.age_minus_3
					is_available_ai_child = yes
				}
				save_scope_as = interlocutor
			}
		}
		else = {
			create_character = {
				template = child_peasant_character
				dynasty = none
				location = root.location
				culture = root.culture
				faith = root.faith
				gender = root
				save_scope_as = interlocutor
			}
		}
	}

	option = { # generous
		name = bp2_yearly.2130.a
		flavor = bp2_yearly.2130.a.flavor
		add_trait = generous
		add_piety = minor_piety_gain

		ai_chance = {
			base = 30
		}

		stress_impact = {
			charming = minor_stress_impact_loss
			rowdy = minor_stress_impact_gain
		}
	}

	option = { # greedy
		name = bp2_yearly.2130.b
		add_trait = greedy

		ai_chance = {
			base = 30
		}

		stress_impact = {
			bossy = minor_stress_impact_loss
		}
	}

	option = { # No way jose
		name = bp2_yearly.2110.c

		ai_chance = {
			base = 30
		}
	}
}

bp2_yearly.2140 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2140.t
	desc = bp2_yearly.2140.desc
	theme = friend_relation
	override_background = { reference = corridor_night }

	left_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:interlocutor
		animation = disapproval
	}

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		is_ai = no
		age >= 6
		age < 12
		number_of_personality_traits < 3
		NOR = {
			has_trait = honest
			has_trait = deceitful
		}
		OR = {
			father ?= {
				is_alive = yes
				is_available_ai_adult = yes
			}
			mother ?= {
				is_alive = yes
				is_available_ai_adult = yes
			}
			any_relation = {
				type = guardian
				is_alive = yes
				is_available_ai_adult = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			is_ai = no
			factor = 10
		}
	}

	immediate = {
		set_favorite_treat_effect = yes
		if = {
			limit = {
				father ?= {
					is_alive = yes
					is_available_ai_adult = yes
				}
			}
			father = { save_scope_as = interlocutor }
		}
		else_if = {
			limit = {
				mother ?= {
					is_alive = yes
					is_available_ai_adult = yes
				}
			}
			mother = { save_scope_as = interlocutor }
		}
		else = {
			random_relation = {
				type = guardian
				save_scope_as = interlocutor
			}
		}
	}

	option = { # honest
		name = bp2_yearly.2140.a
		add_trait = honest

		ai_chance = {
			base = 30
		}

		stress_impact = {
			rowdy = minor_stress_impact_gain
		}
	}

	option = { # deceitful
		name = bp2_yearly.2140.b
		add_trait = deceitful

		ai_chance = {
			base = 30
		}

		stress_impact = {
			charming = minor_stress_impact_loss
		}
	}

	option = { # No way jose
		name = bp2_yearly.2110.c

		ai_chance = {
			base = 30
		}
	}
}

bp2_yearly.2150 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2150.t
	desc = bp2_yearly.2150.desc
	theme = friend_relation
	override_background = { reference = study }

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:interlocutor
		animation = admiration
	}

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		age >= 10
		NOR = {
			has_trait = lifestyle_herbalist
			has_trait = lifestyle_gardener
		}
		employs_court_position = court_physician_court_position
	}

	immediate = {
		random_court_position_holder = {
			type = court_physician_court_position
			save_scope_as = interlocutor
		}
	}

	option = { # herbalist
		name = bp2_yearly.2150.a
		add_trait = lifestyle_herbalist

		ai_chance = {
			base = 30
		}
	}

	option = { # gardener
		name = bp2_yearly.2150.b
		add_trait = lifestyle_gardener

		ai_chance = {
			base = 30
		}
	}

	option = { # No way jose
		name = bp2_yearly.2150.c

		ai_chance = {
			base = 30
		}
	}
}

bp2_yearly.2160 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.2160.t
	desc = bp2_yearly.2160.desc
	theme = friend_relation
	override_background = { reference = courtyard }

	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:interlocutor
		animation = severelywounded
	}

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_child = yes
		is_ai = no
		age >= 6
		number_of_personality_traits < 3
		NOR = {
			has_trait = compassionate
			has_trait = sadistic
		}
		bp2_yearly_2000_pick_child_interlocutor_trigger = yes
		OR = {
			exists = cp:councillor_marshal
			employs_court_position = second_camp_officer
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			is_ai = no
			factor = 10
		}
	}

	immediate = {
		bp2_yearly_2000_pick_child_interlocutor_effect = yes
		hidden_effect = {
			scope:interlocutor = {
				increase_wounds_no_death_effect = { REASON = fight }
			}
		}
		if = {
			limit = {
				employs_court_position = second_camp_officer
				any_court_position_holder = {
					type = second_camp_officer
					is_available_ai_adult = yes
				}
			}
			random_court_position_holder = {
				type = second_camp_officer
				limit = { is_available_ai_adult = yes }
				save_scope_as = marshal
			}
		}
		else = {
			cp:councillor_marshal = { save_scope_as = marshal }
		}
	}

	option = { # Compassionate
		name = bp2_yearly.2160.a
		add_trait = compassionate

		ai_chance = {
			base = 30
		}
	}

	option = { # sadistic
		name = bp2_yearly.2160.b
		custom_tooltip = bp2_yearly.2160.b.flavor
		add_trait = sadistic

		ai_chance = {
			base = 30
		}
	}

	option = { # No way jose
		name = bp2_yearly.2110.c

		ai_chance = {
			base = 30
		}
	}
}
