﻿# BP1: FOES & FOLLOWERS EVENTS - CHAD

namespace = bp1_yearly

############################
## 3000-3999
## by Chad Uhl
############################
# Friend Events
# bp1_yearly.3001 - Friend spots you some cash
# bp1_yearly.3002 - You spot a friend some cash
# bp1_yearly.3003 - Someone who's good at the economy, help me
# bp1_yearly.3004 - Surprise Birthday Party 
# bp1_yearly.3006 - Remembering your birthday party
# bp1_yearly.3007 - Spouse's family member wants funding for an inspiration
# bp1_yearly.3100 - A courtier between friends
# bp1_yearly.3101 - A county between friends

# Nemesis & Rival Events
# bp1_yearly.3201 - Your nemesis gives you a fake feast invite
# bp1_yearly.3202 - You show up to the "feast" unannounced and embarass yourself
# bp1_yearly.3203-4 - Single combat management events

# Pilgrimage Related Events 
# bp1_yearly.3300 - Remembering a pilgrimage 
# bp1_yearly.3301 - Remembering a pilgrimage with a friend

############################
## Friend spots you some cash
## 3001
## by Chad Uhl
############################

scripted_trigger bp1_yearly_3000_meets_gold_expectation_trigger = {
	# Different title levels should have different gold expectations. This trigger handles that by matching up pre-scripted values with different title levels.
	trigger_if = {
		limit = {
			$CHARACTER$.highest_held_title_tier = tier_county
		}
		gold > $CHARACTER$.minor_gold_value
	}
	trigger_else_if = {
		limit = {
			$CHARACTER$.highest_held_title_tier = tier_duchy
		}
		gold > $CHARACTER$.medium_gold_value
	}
	trigger_else_if = {
		limit = {
			$CHARACTER$.highest_held_title_tier = tier_kingdom
		}
		gold > $CHARACTER$.major_gold_value
	}
	trigger_else_if = {
		limit = {
			$CHARACTER$.highest_held_title_tier = tier_empire
		}
		gold > $CHARACTER$.massive_gold_value
	}
	trigger_else = {
		gold > 100
	}
}

bp1_yearly.3001 = { # A Friend Indeed 
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3001.t
	desc = bp1_yearly.3001.desc
	theme = friendly
	override_background = { reference = relaxing_room }

	cooldown = { years = 20 }

	left_portrait = { 
		character = root
		animation = happiness
	}

	right_portrait = { 
		character = scope:friend
		animation = admiration
	}

	trigger = {
		has_bp1_dlc_trigger = yes
		gold < -20
		highest_held_title_tier >= tier_county
		OR = {
			any_relation = {
				type = best_friend
				is_available_ai_adult = yes
				bp1_yearly_3000_meets_gold_expectation_trigger = { CHARACTER = root }
			}
			any_relation = {
				type = friend
				is_available_ai_adult = yes
				bp1_yearly_3000_meets_gold_expectation_trigger = { CHARACTER = root }
				# Your friend must be generous or loyal
				OR = {
					has_trait = generous
					has_trait = loyal
				}	
			}
		}
	}

	weight_multiplier = {
		base = 1
		#Weight event by how in-debt the character is
		modifier = {
			add = {
				value = root.gold 
				divide = -10
			}
		}
	}

	immediate = {
		#play_music_cue = "mx_cue_positive_effect"

		# Check for a best friend first, take a regular friend second.
		if = {
			limit = {
				any_relation = {
					type = best_friend
					bp1_yearly_3000_meets_gold_expectation_trigger = { CHARACTER = root }
				}
			}
			random_relation = {
				type = best_friend
				limit = {
					bp1_yearly_3000_meets_gold_expectation_trigger = { CHARACTER = root }
				}
				# Weighted to find generous and compassionate friend and try to ignore greedy and callous friends
				weight = {
					base = 1 
					modifier = {
						add = 5 
						OR = {
							has_trait = generous
							has_trait = compassionate
							has_trait = loyal
						}
					}
					modifier = {
						add = -5
						OR = {
							has_trait = callous
						}
					}
					modifier = {
						add = -10
						OR = {
							has_trait = greedy
						}
					}
					modifier = {
						add = {
							value = ai_compassion 
							multiply = 0.25
						}
					}
					modifier = {
						add = {
							value = ai_greed 
							multiply = -0.25
						}
					}
					opinion_modifier = {
						opinion_target = root 
						multiplier = 1
					}
				}
				save_scope_as = friend
			}
		}
		else = {
			random_relation = {
				type = friend
				limit = {
					bp1_yearly_3000_meets_gold_expectation_trigger = { CHARACTER = root }
				}
				# Same weights as above
				weight = {
					base = 1 
					modifier = {
						add = 5 
						OR = {
							has_trait = generous
							has_trait = compassionate
							has_trait = loyal
						}
					}
					modifier = {
						add = -5
						OR = {
							has_trait = callous
						}
					}
					modifier = {
						add = -10
						OR = {
							has_trait = greedy
						}
					}
					modifier = {
						add = {
							value = ai_compassion 
							multiply = 0.25
						}
					}
					modifier = {
						add = {
							value = ai_greed 
							multiply = -0.25
						}
					}
					opinion_modifier = {
						opinion_target = root 
						multiplier = 1
					}
				}
				save_scope_as = friend
			}
		}
	}

	option = { # Praise the WealthGod for this glorious surprise!
		name = bp1_yearly.3001.a
		# Apply the correct amount of gold based on title tier
		if = {
			limit = {
				highest_held_title_tier = tier_county
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = minor_gold_value
				}
			} 
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_duchy
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = medium_gold_value
				}
			} 
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_kingdom
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = major_gold_value
				}
			} 
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_empire
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = {
						value = monumental_gold_value
						multiply = 0.75
					}
				}
			} 
		}
		else = { # Fallback case that's probably unneeded but ¯\_(ツ)_/¯
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = 100
				}
			}
		}

		# Your friend gets a weak favor hook if possible
		scope:friend = {
			if = {
				limit = {
					can_add_hook = {
						type = favor_hook
						target = root
					}
				}
				add_hook = {
					type = favor_hook
					target = root
				}
			}
		}

		# If he's not your best friend, he might be soon
		progress_towards_friend_effect = {
			REASON = friend_gave_gold
			CHARACTER = scope:friend 
			OPINION = 0
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			ambitious = minor_stress_impact_gain
			content = medium_stress_impact_gain
			arrogant = major_stress_impact_gain
		}

		ai_chance = {
			base = 5
			modifier = {
				factor = 0 
				OR = {
					has_trait = arrogant 
					has_trait = generous
				}
			}
		}
	}

	option = { # Politely decline
		name = bp1_yearly.3001.b
		add_prestige = minor_prestige_gain

		stress_impact = {
			greedy = major_stress_impact_gain
			content = minor_stress_impact_loss
			humble = minor_stress_impact_loss
		}

		ai_chance = {
			base = 2 
			modifier = {
				factor = 2 
				OR = {
					has_trait = content 
					has_trait = humble 
				}
			}
		}
	}

	option = { # Let's get drunk instead
		name = bp1_yearly.3001.c
		flavor = bp1_yearly.3001.c.tt
		trigger = {
			has_trait = drunkard
		}
		add_stress = medium_stress_loss
		
		if = {
			limit = {
				scope:friend = { has_trait = drunkard }
			}
			reverse_add_opinion = {
				target = scope:friend
				modifier = pleased_opinion
				opinion = 25
			}
			if = {
				limit = {
					can_set_relation_best_friend_trigger = { CHARACTER = scope:friend } 
				}
				set_relation_best_friend = scope:friend
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:friend
				modifier = disapproving_opinion
				opinion = -25
			}
		}

		scope:friend = {
			if = {
				limit = {
					can_add_hook = {
						type = favor_hook
						target = root
					}
				}
				add_hook = {
					type = favor_hook
					target = root
				}
			}
		}

		ai_chance = {
			base = 2 
		}
	}

	option = { # Avaricious Trait Option
		name = bp1_yearly.3001.d

		trigger = {
			has_trait = avaricious
		}

		if = {
			limit = {
				highest_held_title_tier = tier_county
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = {
						value = minor_gold_value
						add = tiny_gold_value
					}
				}
			} 
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_duchy
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = {
						value = medium_gold_value
						add = tiny_gold_value
					}
				}
			} 
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_kingdom
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = {
						value = major_gold_value
						add = tiny_gold_value
					}
				}
			} 
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_empire
			}
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = {
						value = monumental_gold_value
						multiply = 0.75
						add = tiny_gold_value
					}
				}
			} 
		}
		else = {
			scope:friend = {
				pay_short_term_gold = {
					target = root 
					gold = 100
				}
			}
		}

		reverse_add_opinion = {
			target = scope:friend
			modifier = insulted_opinion
			opinion = -25
		}

		scope:friend = {
			if = {
				limit = {
					can_add_hook = {
						type = favor_hook
						target = root
					}
				}
				add_hook = {
					type = favor_hook
					target = root
				}
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			ambitious = minor_stress_impact_gain
			content = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}

		ai_chance = {
			base = 5 
		}
	}
}

############################
## You spot a friend some cash
## 3002-3
## by Chad Uhl
############################

bp1_yearly.3002 = { # A Friend In Need 
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3002.t
	desc = bp1_yearly.3002.desc
	theme = friendly
	override_background = { reference = relaxing_room }

	cooldown = { years = 20 }

	left_portrait = { 
		character = root
		animation = worry
	}

	right_portrait = { 
		character = scope:friend
		animation = sadness
	}

	trigger = {
		has_bp1_dlc_trigger = yes
		trigger_if = {
			limit = {
				any_relation = {
					type = best_friend
					highest_held_title_tier >= tier_county
					is_available_ai_adult = yes
					gold < -20
					save_temporary_scope_as = temp_friend
				}
			}
			bp1_yearly_3000_meets_gold_expectation_trigger = {
				CHARACTER = scope:temp_friend
			}
		}
		trigger_else = {
			any_relation = {
				type = friend
				highest_held_title_tier >= tier_county
				is_available_ai_adult = yes
				gold < -20
				save_temporary_scope_as = temp_friend
			}
			bp1_yearly_3000_meets_gold_expectation_trigger = {
				CHARACTER = scope:temp_friend
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 3
			has_trait = generous
		}
	}

	immediate = {
		# Prefer best friend over regular friend
		if = {
			limit = {
				any_relation = {
					type = best_friend
					# broke, not woke
					gold < -20
					root = {
						bp1_yearly_3000_meets_gold_expectation_trigger = {
							CHARACTER = prev
						}
					}
				}
			}
			random_relation = {
				type = best_friend
				limit = {
					#broke, not woke
					gold < -20
					root = {
						bp1_yearly_3000_meets_gold_expectation_trigger = {
							CHARACTER = prev
						}
					}
				}
				save_scope_as = friend
			}
		}
		else = {
			random_relation = {
				type = friend
				limit = {
					gold < -20
					root = {
						bp1_yearly_3000_meets_gold_expectation_trigger = {
							CHARACTER = prev
						}
					}
				}
				save_scope_as = friend
			}
		}
	}

	option = { # Help out your friend
		name = bp1_yearly.3002.a
		if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_county
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = minor_gold_value
			}
		}
		else_if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_duchy
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = medium_gold_value
			}
		}
		else_if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_kingdom
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = major_gold_value
			}
			add_character_modifier = {
				modifier = generous_friend_modifier
				years = 5
			}
		}
		else_if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_empire
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = {
					value = monumental_gold_value
					multiply = 0.75
				}
			}
			add_character_modifier = {
				modifier = generous_friend_modifier
				years = 10
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:friend 
				gold = 100
			}
		}

		progress_towards_friend_effect = {
			REASON = friend_gave_gold
			CHARACTER = scope:friend 
			OPINION = 0
		}

		if = {
			limit = {
				can_add_hook = {
					target = scope:friend 
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:friend 
				type = favor_hook
			}
		}

		reverse_add_opinion = {
			target = scope:friend
			modifier = grateful_opinion
			opinion = 25 
		}

		stress_impact = {
			greedy = massive_stress_impact_gain
			generous = minor_stress_impact_loss
			compassionate = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -25
				ai_compassion = 25
			}
			modifier = {
				factor = 0 
				has_trait = greedy
			}
		}
	}

	option = { # Scram
		name = bp1_yearly.3002.b
		flavor = bp1_yearly.3002.b.tt

		scope:friend = {
			add_opinion = {
				target = root 
				modifier = disappointed_opinion
				opinion = -25
			}
		}

		stress_impact = {
			fickle = miniscule_stress_impact_loss
			callous = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}

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

	option = { # Get wasted together
		name = bp1_yearly.3002.c
		flavor = bp1_yearly.3002.c.tt
		trigger = {
			OR = {
				has_trait = lifestyle_reveler
				has_trait = drunkard 
				has_trait = hashishiyah 
			}
		}
		remove_short_term_gold = medium_gold_value

		add_stress = medium_stress_loss
		scope:friend = { add_stress = medium_stress_loss }

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 10
				ai_boldness = 10
			}
		}
	}

	option = { # Look over their ledgers
		name = bp1_yearly.3002.d
		custom_tooltip = bp1_yearly.3002.d.tt

		trigger = {
			scope:friend = { has_trait = eccentric }
			OR = {
				has_stewardship_lifestyle_trait_trigger = yes 
				has_trait = education_stewardship_3 
				has_trait = education_stewardship_4
				has_trait = education_stewardship_5
			}
		}

		trigger_event = {
			id = bp1_yearly.3003
			days = 5
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = 25
				ai_compassion = 25
			}
		}
	}
}

bp1_yearly.3003 = { # Someone who's good at the economy, help me 
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3002.t
	desc = bp1_yearly.3003.desc
	theme = friendly 
	override_background = { reference = relaxing_room }

	left_portrait = { 
		character = root
		animation = shock
	}

	right_portrait = { 
		character = scope:friend
		animation = shame
	}

	immediate = {
		add_stewardship_lifestyle_xp = medium_lifestyle_xp
		add_character_modifier = {
			modifier = financial_support_modifier
			years = 10
		}
	}

	option = { # Help them out
		name = bp1_yearly.3003.a
		if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_county
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = minor_gold_value
			}
		}
		else_if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_duchy
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = medium_gold_value
			}
		}
		else_if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_kingdom
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = major_gold_value
			}
		}
		else_if = {
			limit = {
				scope:friend.highest_held_title_tier = tier_empire
			}
			pay_short_term_gold = {
				target = scope:friend 
				gold = {
					value = monumental_gold_value
					multiply = 0.75
				}
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:friend 
				gold = 100
			}
		}

		progress_towards_friend_effect = {
			REASON = friend_gave_gold
			CHARACTER = scope:friend 
			OPINION = 0
		}

		if = {
			limit = {
				can_add_hook = {
					target = scope:friend 
					type = favor_hook
				}
			}
			add_hook = {
				target = scope:friend 
				type = favor_hook
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			generous = medium_stress_impact_loss
			compassionate = minor_stress_impact_loss
		}


		ai_chance = {
			base = 50 
			ai_value_modifier = {
				ai_greed = -50
				ai_compassion = 25
			}
		}
	}

	option = { # Leave them to wallow in shame
		name = bp1_yearly.3003.b
		reverse_add_opinion = {
			target = scope:friend
			modifier = insulted_opinion
			opinion = -30
		}

		ai_chance = {
			base = 50 
			ai_value_modifier = {
				ai_greed = 25
				ai_compassion = 50
			}
		}
	}
}


###########################
# Surprise Birthday Party
# 3004-6, 3008
# modified based on event by Chad Uhl
###########################

#Extra event to limit the surprise birthday party

bp1_yearly.3008 = {
	type = character_event
	title = bp1_yearly.3008.t
	desc = bp1_yearly.3008.desc
	theme = friendly
	
	left_portrait = { 
		character = root
		animation = personality_content
	}
	
	override_background = { reference = council_chamber }
	
	cooldown = { years = 50 }
	
	trigger = {
		is_landed = yes
		has_bp1_dlc_trigger = yes
		age >= 25
		is_travelling = no
		root.location = root.capital_province
	}
	
	weight_multiplier = {
		base = 1
		# More likely to occur the older you are
		modifier = {
			add = root.age
		}
	}
	
	option = {#glory
		name = bp1_yearly.3008.a
		
		add_prestige = medium_prestige_gain
		
		stress_impact = {
			arrogant = medium_stress_impact_loss
			shy = medium_stress_impact_gain
			ambitious = medium_stress_impact_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 0 
				has_trait = shy
			}
		}
	}
	
	option = {#gold
		name = bp1_yearly.3008.b
		
		add_gold = medium_gold_value
		
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			ambitious = medium_stress_impact_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 0 
				has_trait = generous
			}
		}
	}
	
	option = {#chill
		name = bp1_yearly.3008.c
		
		add_stress = major_stress_loss
		
		stress_impact = {
			lazy = medium_stress_impact_loss
			content = medium_stress_impact_loss
			shy = medium_stress_impact_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 0 
				has_trait = shy
			}
		}
	}
		
	option = {#ignore with a possibility of surprise party
		name = bp1_yearly.3008.d
		
		hidden_effect = {
			if = {
				limit = {
					any_relation = {
					type = friend
					is_available = yes
					count >= 2
					}
				}	
				trigger_event = {
					id = bp1_yearly.3004
					days = 1
				}
			}
			else = {
				add_character_modifier = {
					modifier = hard_work_mod
					years = 1
				}
			}
		}
		
		stress_impact = {
			diligent = minor_stress_impact_loss
			arbitrary = minor_stress_impact_loss
			cynical = minor_stress_impact_loss
		}
	}
}


bp1_yearly.3004 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3004.t
	desc = {
		desc = bp1_yearly.3004.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					is_married = yes 
				}
				desc = bp1_yearly.3004.spouse
			}
			triggered_desc = {
				trigger = {
					is_married = no 
				}
				desc = bp1_yearly.3004.friends
			}
		}
		desc = bp1_yearly.3004.end
	}
	theme = friendly

	left_portrait = { 
		character = root
		animation = sadness
	}

	override_background = { reference = corridor_night }

	immediate = {
		random_relation = {
			type = friend 
			limit = { is_available = yes }
			save_scope_as = friend1
		}
		random_relation = {
			type = friend 
			limit = {
				NOT = { this = scope:friend1 }
				is_available = yes
			}
			save_scope_as = friend2
		}
		if = {
			limit = {
				is_married = yes
				primary_spouse = {
					opinion = {
						target = root
						value > 0
					}
					is_available = yes
				}
			}
			root.primary_spouse = {
				save_scope_as = party_host
			}
		}
		else = {
			scope:friend1 = {
				save_scope_as = party_host
			}
		}
	}

	option = { # Investigate the noise
		name = bp1_yearly.3004.a
		trigger_event = {
			id = bp1_yearly.3005
			days = 1
		}

		stress_impact = {
			paranoid = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}

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

	option = { # Paranoid option to escape by repelling from the window
		name = bp1_yearly.3004.b 
		
		trigger = {
			OR = {
				has_trait = paranoid
				has_trait = shy
			}
		}

		add_character_modifier = {
			modifier = unpredictable_modifier
			years = 5
		}

		stress_impact = {
			eccentric = minor_stress_impact_loss
			craven = minor_stress_impact_loss
			shy = minor_stress_impact_loss
			brave = medium_stress_impact_gain
			gregarious = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}
}

bp1_yearly.3005 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3005.t
	desc = bp1_yearly.3005.desc
	theme = friendly

	override_background = { reference = feast }

	left_portrait = { 
		character = scope:friend1
		animation = toast_goblet
	}

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

	immediate = {
		create_character_memory = {
			type = birthday_party
			participants = {
				friend1 = scope:friend1
				friend2 = scope:friend2
			}
		}
	}

	option = { # Choose Big Gift
		name = bp1_yearly.3005.a
		custom_tooltip = bp1_yearly.3005.a.tt
		custom_tooltip = bp1_yearly.3005.opinion.tt

		hidden_effect = {
			every_relation = {
				type = friend 
				add_opinion = {
					modifier = gift_opinion 
					opinion = 30
					target = root 
				}	
			}
			random_list = {
				# You get a random, mostly useless trinket
				40 = {
					generate_trinket_effect = {
						TRINKET_RECEIVER = root
						TRINKET_GIVER = scope:friend2
						GRAB_ALL_TRINKETS = yes
						HISTORY_TYPE = given
					}
					if = {
						# Checks required for error suppression
						limit = { exists = scope:new_trinket }
						scope:new_trinket = {
							save_scope_as = newly_created_artifact
						}
					}
					send_interface_toast = {
						title = bp1_yearly.3005.t.gift
						left_icon = scope:newly_created_artifact
						show_as_tooltip = {
							if = {
								# Checks required for error suppression
								limit = { exists = scope:newly_created_artifact } 
								scope:newly_created_artifact = {
									set_owner = root
								}
							}
						}
					}
				}
				# You get a real gift
				60 = {
					set_signature_weapon_effect = yes
					# Gift #1 - A Signature Weapon
					if = {
						limit = { 
							has_variable = signature_weapon
							root.var:signature_weapon = flag:axe 
						}
						create_artifact_weapon_effect = {
							OWNER = root
							CREATOR = scope:friend2
							SET_WEAPON_TYPE = flag:artifact_weapon_type_axe
						}
					}
					else_if = {
						limit = { 
							has_variable = signature_weapon
							root.var:signature_weapon = flag:hammer 
						}
						create_artifact_weapon_effect = {
							OWNER = root
							CREATOR = scope:friend2
							SET_WEAPON_TYPE = flag:artifact_weapon_type_hammer
						}
					}
					else_if = {
						limit = { 
							has_variable = signature_weapon
							root.var:signature_weapon = flag:spear 
						}
						create_artifact_weapon_effect = {
							OWNER = root
							CREATOR = scope:friend2
							SET_WEAPON_TYPE = flag:artifact_weapon_type_spear
						}
					}
					else_if = {
						limit = { 
							has_variable = signature_weapon
							root.var:signature_weapon = flag:mace 
						}
						create_artifact_weapon_effect = {
							OWNER = root
							CREATOR = scope:friend2
							SET_WEAPON_TYPE = flag:artifact_weapon_type_mace
						}
					}
					else_if = {
						limit = { 
							has_variable = signature_weapon
							root.var:signature_weapon = flag:dagger 
						}
						create_artifact_weapon_effect = {
							OWNER = root
							CREATOR = scope:friend2
							SET_WEAPON_TYPE = flag:artifact_weapon_type_dagger
						}
					}
					else = { #For swords, but also as fallback
						create_artifact_weapon_effect = {
							OWNER = root
							CREATOR = scope:friend2
							SET_WEAPON_TYPE = flag:artifact_weapon_type_sword
						}
					}
					if = {
						limit = {
							exists = scope:newly_created_artifact
						}
						scope:newly_created_artifact = {
							add_artifact_history = {
								type = given
								actor = scope:friend2
								recipient = root
							}
						}
						send_interface_toast = {
							title = bp1_yearly.3005.t.gift
							left_icon = scope:newly_created_artifact
							show_as_tooltip = {
								scope:newly_created_artifact = {
									set_owner = root
								}
							}
						}
					}
				}
			}
		}
	}

	option = { # Choose Medium Gift
		name = bp1_yearly.3005.b
		custom_tooltip = bp1_yearly.3005.b.tt
		custom_tooltip = bp1_yearly.3005.opinion.tt

		hidden_effect = {
			every_relation = {
				type = friend 
				add_opinion = {
					modifier = gift_opinion 
					opinion = 30
					target = root 
				}	
			}

			# Gift #2 - A Book
			random_list = {
				# You get a random, mostly useless trinket
				40 = {
					generate_trinket_effect = {
						TRINKET_RECEIVER = root
						TRINKET_GIVER = scope:friend2
						GRAB_ALL_TRINKETS = yes
						HISTORY_TYPE = given
					}
					if = {
						# Checks required for error suppression
						limit = { exists = scope:new_trinket }
						scope:new_trinket = {
							save_scope_as = newly_created_artifact
						}
					}
					send_interface_toast = {
						title = bp1_yearly.3005.t.gift
						left_icon = scope:newly_created_artifact
						show_as_tooltip = {
							if = {
								# Checks required for error suppression
								limit = { exists = scope:newly_created_artifact } 
								scope:newly_created_artifact = {
									set_owner = root
								}
							}
						}
					}
				}
				# You get a real gift
				60 = {
					if = {
						limit = {
							root = {
								NOT = { has_royal_court = yes }
							}
						}
						save_temporary_scope_value_as = {
							name = should_be_trinket
							value = yes
						}
					}
					random_dummy_gender_effect = yes
					create_artifact_book_effect = {
						OWNER = root 
						CREATOR = scope:dummy_gender
						SET_SUBJECT = flag:no
						SET_TOPIC = flag:no
					}
					if = {
						limit = {
							exists = scope:newly_created_artifact
						}
						scope:newly_created_artifact = {
							add_artifact_history = {
								type = given
								actor = scope:friend2
								recipient = root
							}
						}
						send_interface_toast = {
							title = bp1_yearly.3005.t.gift
							left_icon = scope:newly_created_artifact
							show_as_tooltip = {
								scope:newly_created_artifact = {
									set_owner = root
								}
							}
						}
					}
				}
			}
		}
	}

	option = { # Choose Small Gift
		name = bp1_yearly.3005.c
		custom_tooltip = bp1_yearly.3005.c.tt
		custom_tooltip = bp1_yearly.3005.opinion.tt

		hidden_effect = {
			every_relation = {
				type = friend 
				add_opinion = {
					modifier = gift_opinion 
					opinion = 30
					target = root 
				}	
			}

			# Gift #3 - A Brooch
			random_list = {
				# You get a random, mostly useless trinket
				40 = {
					generate_trinket_effect = {
						TRINKET_RECEIVER = root
						TRINKET_GIVER = scope:friend2
						GRAB_ALL_TRINKETS = yes
						HISTORY_TYPE = given
					}
					if = {
						# Checks required for error suppression
						limit = { exists = scope:new_trinket }
						scope:new_trinket = {
							save_scope_as = newly_created_artifact
						}
					}
					send_interface_toast = {
						title = bp1_yearly.3005.t.gift
						left_icon = scope:newly_created_artifact
						show_as_tooltip = {
							if = {
								# Checks required for error suppression
								limit = { exists = scope:newly_created_artifact } 
								scope:newly_created_artifact = {
									set_owner = root
								}
							}
						}
					}
				}
				# You get a real gift
				60 = {
					create_artifact_brooch_effect = {
						OWNER = root
						SMITH = scope:friend2
					}
					if = {
						limit = {
							exists = scope:newly_created_artifact
						}
						scope:newly_created_artifact = {
							add_artifact_history = {
								type = given
								actor = scope:friend2
								recipient = root
							}
						}
						send_interface_toast = {
							title = bp1_yearly.3005.t.gift
							left_icon = scope:newly_created_artifact
							show_as_tooltip = {
								scope:newly_created_artifact = {
									set_owner = root
								}
							}
						}
					}
				}
			}
		}
	}

	after = {
		# Save the scoped artifact as a variable on the memory to access later
		random_memory = {
			limit = { has_memory_type = birthday_party }
			set_variable = {
				name = bday_artifact_gift
				value = scope:newly_created_artifact
			}
		}
	}
}

bp1_yearly.3006 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3006.t
	desc = {
		desc = bp1_yearly.3006.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:friend1 = { is_alive = no }
				}
				desc = bp1_yearly.3006.desc.friend1_dead
			}
			triggered_desc = {
				trigger = {
					scope:friend2 = { is_alive = no }
				}
				desc = bp1_yearly.3006.desc.friend2_dead
			}
		}
		triggered_desc = {
			trigger = {
				scope:friend2 = {
					is_alive = yes
					NOR = {
						has_relation_friend = root
						has_relation_best_friend = root
					}
				}
			}
			desc = bp1_yearly.3006.desc.artifact_negative
		}
		triggered_desc = {
			trigger = {
				scope:friend2 = {
					is_alive = yes
					OR = {
						has_relation_friend = root
						has_relation_best_friend = root
					}
				}
			}
			desc = bp1_yearly.3006.desc.artifact_positive
		}
		triggered_desc = {
			trigger = { exists = scope:bday_memory.var:bday_artifact_gift }
			desc = bp1_yearly.3006.desc.artifact_exists
		}
	}
	cooldown = { years = 15 }

	theme = friendly

	left_portrait = { 
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					scope:friend1 = { is_alive = no }
					scope:friend2 = { is_alive = no }
				}
			}
			animation = sadness
		}
		triggered_animation = {
			trigger = {
				scope:friend2 = {
					is_alive = yes
					NOR = {
						has_relation_friend = root
						has_relation_best_friend = root
					}
				}
			}
			animation = anger
		}
		triggered_animation = {
			trigger = {
				scope:friend1 = { is_alive = yes }
				scope:friend2 = { is_alive = yes }
			}
			animation = happiness
		}
	}
	
	lower_left_portrait = scope:friend1
	lower_right_portrait = scope:friend2

	artifact = {
		target = scope:old_bday_gift
		position = lower_center_portrait
		trigger = { exists = scope:old_bday_gift }
	}

	override_background = { reference = relaxing_room }

	trigger = {
		is_landed = yes #Fires from birthday pulse so the character may not be landed
		# DLC Check
		has_bp1_dlc_trigger = yes
		# Make sure you're old  
		age >= 50
		# Has the right memory 
		any_memory = {
			has_memory_type = birthday_party
		}
	}

	weight_multiplier = {
		base = 1
		# More likely to occur the older you are
		modifier = {
			add = {
				value = root.age
				divide = 100
			}
		}
	}

	immediate = {
		random_memory = {
			limit = { has_memory_type = birthday_party }
			save_scope_as = bday_memory
		}
		scope:bday_memory.memory_participant:friend1 = { save_scope_as = friend1 }
		scope:bday_memory.memory_participant:friend2 = { save_scope_as = friend2 }
		if = {
			limit = { exists = scope:bday_memory.var:bday_artifact_gift }
			scope:bday_memory.var:bday_artifact_gift = { save_scope_as = old_bday_gift }
		}
	}

	option = { # Reminisce about living friends
		name = bp1_yearly.3006.a

		trigger = {
			scope:friend1 = { is_alive = yes }
			scope:friend2 = {
				is_alive = yes
				OR = {
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
		}

		if = {
			limit = {
				scope:friend1 = { is_alive = yes }
				scope:friend2 = { is_alive = no }
			}
			scope:friend1 = {
				reverse_add_opinion = {
					modifier = friendliness_opinion 
					opinion = 15
					target = root 
				}	
			}
		}
		else_if = {
			limit = {
				scope:friend1 = { is_alive = no }
				scope:friend2 = { is_alive = yes }
			}
			scope:friend2 = {
				reverse_add_opinion = {
					modifier = friendliness_opinion 
					opinion = 15
					target = root 
				}	
			}
		}
		else = {
			scope:friend1 = {
				reverse_add_opinion = {
					modifier = friendliness_opinion 
					opinion = 15
					target = root 
				}	
			}
			scope:friend2 = {
				reverse_add_opinion = {
					modifier = friendliness_opinion 
					opinion = 15
					target = root 
				}	
			}
		}

		stress_impact = {
			base = minor_stress_impact_loss
		}
	}

	option = { # Mourn your dead friend
		name = bp1_yearly.3006.b 
		
		trigger = {
			# One of the friends who threw the party must be dead
			OR = {
				scope:friend1 = { is_alive = no }
				scope:friend2 = { is_alive = no }
			}
		}

		stress_impact = {
			base = medium_stress_impact_loss
		}
	}

	option = { # Destroy the artifact (if it exists) if you are currently not friends with friend2, who gave you the artifact
		name = bp1_yearly.3006.c
		trigger = {
			scope:friend2 = {
				is_alive = yes
				NOR = {
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
			exists = scope:old_bday_gift
		}

		destroy_artifact = scope:old_bday_gift
		
		stress_impact = {
			base = minor_stress_impact_loss
			wrathful = medium_stress_impact_loss
			vengeful = medium_stress_impact_loss
			forgiving = major_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
	}

	option = { # you already got rid of the artifact, you're not friends with friend2
		name = bp1_yearly.3006.d
		trigger = {
			scope:friend2 = {
				is_alive = yes
				NOR = {
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
			NOT = { exists = scope:old_bday_gift }
		}
		
		stress_impact = {
			base = medium_stress_impact_loss
			forgiving = major_stress_impact_gain
		}
	}
}

############################
## Spouse's family member wants funding
## 3007
## by Chad Uhl
############################

scripted_trigger bp1_yearly_3007_family_trigger = {
	NOR = {
		is_ruler = yes
		is_child_of = root
		exists = inspiration
		has_any_court_position = yes
		is_councillor = yes
		any_spouse = { is_ruler = yes }
	}
	is_available_healthy_ai_adult = yes
}

bp1_yearly.3007 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3007.t
	desc = {
		desc = bp1_yearly.3007.desc
		first_valid = {
			triggered_desc = {
				trigger = { has_royal_court = yes }
				desc = bp1_yearly.3007.desc.tapestry
			}
			triggered_desc = {
				trigger = { has_royal_court = no }
				desc = bp1_yearly.3007.desc.regalia
			}
		}
		desc = bp1_yearly.3007.desc.conc
	}
	theme = friendly 
	override_background = { reference = council_chamber }
	cooldown = { years = 10 }

	left_portrait = { 
		character = scope:spouse
		animation = admiration
	}

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

	trigger = {
		has_bp1_dlc_trigger = yes
		is_available_at_peace_adult = yes
		any_spouse =  {
			any_close_family_member = { bp1_yearly_3007_family_trigger = yes }
		}
		NOR = { 
			has_trait = blind
			any_spouse = { has_trait = blind }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		ordered_spouse = {
			limit = {
				any_close_family_member = {
					bp1_yearly_3007_family_trigger = yes
					save_temporary_scope_as = close_family_temp
				}
			}
			order_by = intrigue
			save_scope_as = spouse
			scope:close_family_temp = {
				if = { # If they have RoCo, make a tapestry
					limit = { root = { has_royal_court = yes } }
					create_inspiration = weaver_inspiration
				}
				else = { # If not, make regalia
					set_variable = {
						name = artifact_smith_type
						value = flag:smith_type_regalia
					}
					create_inspiration = smith_inspiration
				}
				save_scope_as = inspired_family_member
				inspiration = { save_scope_as = family_inspiration }
			}
		}
	}

	option = { # Sponsor them - tapestry
		name = bp1_yearly.3007.a.tapestry

		trigger = { has_royal_court = yes }

		show_as_unavailable = {
			NOT = { can_sponsor_inspiration = scope:inspired_family_member.inspiration }
		}

		if = {
			limit = {
				scope:inspired_family_member = {
					NOT = { is_courtier_of = root }
				}
			}
			add_courtier = scope:inspired_family_member
		}
		sponsor_inspiration = scope:family_inspiration

		reverse_add_opinion = {
			target = scope:spouse
			modifier = pleased_opinion
			opinion = 25
		}

		stress_impact = {
			profligate = medium_stress_impact_loss
			content = major_stress_impact_gain
			greedy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1.5
				ai_greed = 0.5 
			}
			modifier = {
				factor = 2
				has_trait = profligate
			}
		}
	}

	option = { # Sponsor them - regalia
		name = bp1_yearly.3007.a.regalia

		trigger = { has_royal_court = no }

		show_as_unavailable = {
			NOT = { can_sponsor_inspiration = scope:inspired_family_member.inspiration }
		}

		if = {
			limit = {
				scope:inspired_family_member = {
					NOT = { is_courtier_of = root }
				}
			}
			add_courtier = scope:inspired_family_member
		}
		sponsor_inspiration = scope:family_inspiration

		reverse_add_opinion = {
			target = scope:spouse
			modifier = pleased_opinion
			opinion = 25
		}

		stress_impact = {
			profligate = medium_stress_impact_loss
			content = major_stress_impact_gain
			greedy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1.5
				ai_greed = 0.5 
			}
			modifier = {
				factor = 2
				has_trait = profligate
			}
		}
	}

	option = { # Refuse
		name = bp1_yearly.3007.b

		progress_towards_rival_effect = {
			CHARACTER = scope:spouse
			REASON = rival_rejected_tapestries
			OPINION = 0
		}
		reverse_add_opinion = {
			target = scope:spouse
			modifier = refusal_opinion
			opinion = -25
		}

		stress_impact = {
			profligate = medium_stress_impact_gain
			greedy = minor_stress_impact_loss
			content = minor_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_greed = 1.5
			}
		}
	}
}

############################
## A Courtier Between Friends
## 3100
## by Chad Uhl
############################
scripted_trigger bp1_yearly_3100_is_skilled_courtier_trigger = {
	is_available_healthy_ai_adult = yes
	is_landed = no
	OR = {
		diplomacy > high_skill_rating
		martial > high_skill_rating
		stewardship > high_skill_rating
		intrigue > high_skill_rating
		learning > high_skill_rating
		prowess > high_skill_rating
	}
	trigger_if = {
		limit = { exists = liege }
		NOR = {
			is_spouse_of = liege
			is_heir_of = liege
			is_councillor_of = liege
		}
		liege = { is_available_ai_adult = yes }
	}
	trigger_else = {
		NOR = {
			is_spouse_of = employer
			is_heir_of = employer
			is_councillor_of = employer
		}
		employer = { is_available_ai_adult = yes }
	}
}

scripted_effect bp1_yearly_3100_pick_highest_skilled_courtiers = {
	# Saves scopes of courtiers with the highest skill in each type of skill
	ordered_in_list = {
		list = $LIST$
		order_by = diplomacy
		save_scope_as = 3100_diplomacy_courtier
	}
	ordered_in_list = {
		list = $LIST$
		order_by = intrigue
		save_scope_as = 3100_intrigue_courtier
	}
	ordered_in_list = {
		list = $LIST$
		order_by = martial
		save_scope_as = 3100_martial_courtier
	}
	ordered_in_list = {
		list = $LIST$
		order_by = stewardship
		save_scope_as = 3100_stewardship_courtier
	}
	ordered_in_list = {
		list = $LIST$
		order_by = learning
		save_scope_as = 3100_learning_courtier
	}
	ordered_in_list = {
		list = $LIST$
		order_by = prowess
		save_scope_as = 3100_prowess_courtier
	}
}

bp1_yearly.3100 = { # Vassal/Relative/Friend sends you a skilled courtier 
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3100.t
	desc = {
		desc = bp1_yearly.3100.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:3100_target_courtier = {
						highest_skill = diplomacy
					}
				}
				desc = bp1_yearly.3100.desc.diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:3100_target_courtier = {
						highest_skill = intrigue
					}
				}
				desc = bp1_yearly.3100.desc.intrigue
			}
			triggered_desc = {
				trigger = {
					scope:3100_target_courtier = {
						highest_skill = stewardship
					}
				}
				desc = bp1_yearly.3100.desc.stewardship
			}
			triggered_desc = {
				trigger = {
					scope:3100_target_courtier = {
						highest_skill = martial
					}
				}
				desc = bp1_yearly.3100.desc.martial
			}
			triggered_desc = {
				trigger = {
					scope:3100_target_courtier = {
						highest_skill = learning
					}
				}
				desc = bp1_yearly.3100.desc.learning
			}
			triggered_desc = {
				trigger = {
					scope:3100_target_courtier = {
						highest_skill_including_prowess = prowess
					}
				}
				desc = bp1_yearly.3100.desc.prowess
			}
		}
		desc = bp1_yearly.3100.desc.conc
	}
	theme = friendly 
	override_background = { reference = relaxing_room }

	left_portrait = { 
		character = root
		animation = happiness
	}

	right_portrait = { 
		character = scope:3100_courtier_liege
		animation = happiness
	}

	lower_center_portrait = {
		character = scope:3100_target_courtier
	}
	
	cooldown = { years = 10 }

	trigger = {
		# Check that there is at least one fitting courtier in any relation category
		OR = {
			any_vassal = {
				NOT = { is_at_war_with = root }
				any_courtier = {
					bp1_yearly_3100_is_skilled_courtier_trigger = yes
				}
			}
			any_relation = {
				type = friend
				is_landed = yes
				NOT = { is_at_war_with = root }
				any_courtier = {
					bp1_yearly_3100_is_skilled_courtier_trigger = yes
				}
			}
			any_relation = {
				type = best_friend
				is_landed = yes
				NOT = { is_at_war_with = root }
				any_courtier = {
					bp1_yearly_3100_is_skilled_courtier_trigger = yes
				}
			}
			any_close_or_extended_family_member = {
				NOT = { is_child_of = root }
				is_landed = yes
				NOT = { is_at_war_with = root }
				any_courtier = {
					bp1_yearly_3100_is_skilled_courtier_trigger = yes
				}
			}
		}
	}

	immediate = {
		# Create a list of all vassals/friends/family members
		every_vassal = {
			limit = { NOT = { is_at_war_with = root } }
			add_to_list = 3100_friend_list
		}
		every_relation = {
			type = friend
			limit = { NOT = { is_at_war_with = root } }
			add_to_list = 3100_friend_list
		}
		every_relation = {
			type = best_friend
			limit = { NOT = { is_at_war_with = root } }
			add_to_list = 3100_friend_list
		}
		every_close_or_extended_family_member = {
			limit = {
				is_landed = yes
				NOT = { is_child_of = root }
				NOT = { is_at_war_with = root }
			}
			add_to_list = 3100_friend_list
		}

		# Make a list of all their courtiers
		every_in_list = {
			list = 3100_friend_list
			every_courtier = {
				limit = { bp1_yearly_3100_is_skilled_courtier_trigger = yes }
				add_to_list = 3100_courtier_list
			}
		}
		# Find the highest skilled courtier based on which skill is needed
		bp1_yearly_3100_pick_highest_skilled_courtiers = { LIST = 3100_courtier_list }

		# Find the one with the overall highest skill
		if = {
			limit = {
				scope:3100_diplomacy_courtier.diplomacy > scope:3100_intrigue_courtier.intrigue
				scope:3100_diplomacy_courtier.diplomacy > scope:3100_martial_courtier.martial
				scope:3100_diplomacy_courtier.diplomacy > scope:3100_stewardship_courtier.stewardship
				scope:3100_diplomacy_courtier.diplomacy > scope:3100_learning_courtier.learning
				scope:3100_diplomacy_courtier.diplomacy > scope:3100_prowess_courtier.prowess
			}
			scope:3100_diplomacy_courtier = { save_scope_as = 3100_target_courtier }
		}
		else_if = {
			limit = {
				scope:3100_intrigue_courtier.intrigue > scope:3100_diplomacy_courtier.diplomacy
				scope:3100_intrigue_courtier.intrigue > scope:3100_martial_courtier.martial
				scope:3100_intrigue_courtier.intrigue > scope:3100_stewardship_courtier.stewardship
				scope:3100_intrigue_courtier.intrigue > scope:3100_learning_courtier.learning
				scope:3100_intrigue_courtier.intrigue > scope:3100_prowess_courtier.prowess
			}
			scope:3100_intrigue_courtier = { save_scope_as = 3100_target_courtier }
		}
		else_if = {
			limit = {
				scope:3100_martial_courtier.martial > scope:3100_diplomacy_courtier.diplomacy
				scope:3100_martial_courtier.martial > scope:3100_intrigue_courtier.intrigue
				scope:3100_martial_courtier.martial > scope:3100_stewardship_courtier.stewardship
				scope:3100_martial_courtier.martial > scope:3100_learning_courtier.learning
				scope:3100_martial_courtier.martial > scope:3100_prowess_courtier.prowess
			}
			scope:3100_martial_courtier = { save_scope_as = 3100_target_courtier }
		}
		else_if = {
			limit = {
				scope:3100_stewardship_courtier.stewardship > scope:3100_diplomacy_courtier.diplomacy
				scope:3100_stewardship_courtier.stewardship > scope:3100_intrigue_courtier.intrigue
				scope:3100_stewardship_courtier.stewardship > scope:3100_martial_courtier.martial
				scope:3100_stewardship_courtier.stewardship > scope:3100_learning_courtier.learning
				scope:3100_stewardship_courtier.stewardship > scope:3100_prowess_courtier.prowess
			}
			scope:3100_stewardship_courtier = { save_scope_as = 3100_target_courtier }
		}
		else_if = {
			limit = {
				scope:3100_learning_courtier.learning > scope:3100_diplomacy_courtier.diplomacy
				scope:3100_learning_courtier.learning > scope:3100_intrigue_courtier.intrigue
				scope:3100_learning_courtier.learning > scope:3100_martial_courtier.martial
				scope:3100_learning_courtier.learning > scope:3100_stewardship_courtier.stewardship
				scope:3100_learning_courtier.learning > scope:3100_prowess_courtier.prowess
			}
			scope:3100_learning_courtier = { save_scope_as = 3100_target_courtier }
		}
		else = {
			scope:3100_prowess_courtier = { save_scope_as = 3100_target_courtier }
		}

		# Save the scope of the courtier's owner 
		scope:3100_target_courtier.liege = { save_scope_as = 3100_courtier_liege }
	}

	option = { # Take the courtier
		name = bp1_yearly.3100.a

		send_interface_toast = {
			title = bp1_yearly_3100_courtier_gained
			left_icon = scope:3100_target_courtier
			add_courtier = scope:3100_target_courtier
		}
		add_prestige = minor_prestige_loss
		progress_towards_friend_effect = {
			REASON = friend_accepted_courtier
			CHARACTER = scope:3100_courtier_liege
			OPINION = default_friend_opinion
		}

		stress_impact = {
			arrogant = medium_stress_impact_gain
			paranoid = massive_stress_impact_gain
			trusting = minor_stress_impact_loss
		}

		ai_chance = {
			base = 50 
			ai_value_modifier = {
				ai_greed = -50
				ai_compassion = 25
			}
			modifier = {
				factor = 0
				has_trait = paranoid
			}
			modifier = {
				factor = 2
				has_trait = trusting
			}
			modifier = {
				factor = 0
				prestige <= minor_prestige_value
			}
		}
	}

	option = { # Leave the courtier
		name = bp1_yearly.3100.b
		
		add_prestige = medium_prestige_gain
		progress_towards_rival_effect = {
			CHARACTER = scope:3100_courtier_liege
			REASON = rival_rejected_courtier
			OPINION = default_rival_opinion 
		}

		stress_impact = {
			generous = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			paranoid = minor_stress_impact_loss
		}

		ai_chance = {
			base = 50 
			ai_value_modifier = {
				ai_greed = 25
				ai_compassion = 50
			}
		}
	}
}

############################
## A County Between Friends
## 3101
## by Chad Uhl
############################

scripted_trigger 3101_is_valid_claim_with_valid_holder_trigger = {
	# Must be a county, duchy, or kingdom claim
	tier < tier_empire
	tier != tier_barony
	# Must be held by your friend or best friend
	exists = holder
	holder = {
		# Ensure we aren't going to screw anyone over in multiplayer
		is_available_ai_adult = yes
		top_liege ?= { is_ai = yes }
		# ty for being a friend
		OR = {
			has_relation_friend = root
			has_relation_best_friend = root
		}
		# Prevent someone from giving away their last county
		realm_size > 1
		save_temporary_scope_as = holder_temp
	}
	NOR = {
		this = scope:holder_temp.primary_title
		this = scope:holder_temp.capital_county
	}
	# Special requirements for duchies and higher 
	trigger_if = {
		limit = { tier = tier_duchy } # Duchy
		scope:holder_temp = {
			# Prevent someone from giving away their last duchy 
			any_claim = {
				count = 2 
				tier >= tier_duchy
			}
			#They need to have the right personality to sell a duchy
			OR = {
				has_trait = generous 
				has_trait = trusting 
				has_trait = loyal 
			}
		}
	}
	trigger_if = {
		limit = { tier = tier_kingdom } # Kingdom
		scope:holder_temp = {
			# Prevent someone from giving away their last kingdom
			any_claim = {
				count = 2 
				tier >= tier_kingdom
			}
			#They need to love you a lot to sell a kingdom
			has_relation_best_friend = root 
			has_trait = generous
			has_trait = loyal 
		}
	}
}

bp1_yearly.3101 = { # A County Between Friends
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3101.t
	desc = bp1_yearly.3101.desc
	theme = friendly
	override_background = { reference = corridor_day }

	cooldown = { years = 25 }

	left_portrait = { 
		character = root
		animation = happiness
	}

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

	trigger = {
		has_bp1_dlc_trigger = yes
		#No fun storytelling allowed for ep3 gameplay :(
		OR = {
			is_landless_adventurer = no
			is_landless_administrative = no
			is_governor = no
		}
		any_claim = {
			explicit = all 
			pressed = all
			3101_is_valid_claim_with_valid_holder_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_claim = {
			explicit = all 
			pressed = all
			limit = {
				3101_is_valid_claim_with_valid_holder_trigger = yes
			}
			save_scope_as = target_title
		}
		scope:target_title.holder = {
			save_scope_as = target_title_holder
		}
	}

	option = {
		name = bp1_yearly.3101.a

		remove_short_term_gold = major_gold_value
		if = {
			limit = { scope:target_title.tier > tier_county }
			create_title_and_vassal_change = {
				type = granted
				save_scope_as = change
			}
			scope:target_title = {
				change_title_holder_include_vassals = {
					holder = root 
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		else = {
			get_title = scope:target_title
		}

		scope:target_title_holder = {
			remove_claim = scope:target_title
			if = {
				limit = {
					can_add_hook = {
						type = favor_hook
						target = root
					}
				}
				add_hook = {
					type = favor_hook
					target = root
				}
			}
		}

		create_character_memory = {
			type = friend_granted_my_claim
			participants = { friend = scope:target_title_holder }
		}

		# TODO_CD_CU: This variable needs to be referenced somewhere besides localization in order for it not to produce errors. Add in if a bespoke memory event is created that will use the location here
		# Save which title was granted to the memory for loc and possible later uses
		#scope:new_memory = {
		#	set_variable = {
		#		name = title_granted
		#		value = scope:target_title
		#	}
		#}

		stress_impact = {
			content = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			compassionate = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -25
				ai_compassion = 25
			}
			modifier = {
				factor = 0 
				has_trait = greedy
			}
		}
	}

	option = {
		name = bp1_yearly.3101.b

		add_prestige = medium_prestige_gain 

		stress_impact = {
			ambitious = major_stress_impact_gain
			greedy = medium_stress_impact_gain
		}

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

############################
## Your nemesis/rival gives you a fake feast invite
## 3201-4
## by Chad Uhl
############################

bp1_yearly.3201 = { #Fake Feast Invitation
	type = letter_event
	opening = {
		desc = bp1_yearly.3201.opening
	}
	desc = bp1_yearly.3201.desc
	sender = scope:host
	
	cooldown = { years = 10 }

	trigger = {
		has_bp1_dlc_trigger = yes
		NOT = { has_character_flag = had_event_bp1_yearly_3201 }
		is_available_for_activity_trigger = yes

		# Checks for a host, if you are not independent, the host is your liege
		trigger_if = {
			limit = {
				is_independent_ruler = yes
			}
			OR = {
				any_relation = {
					type = potential_friend
					is_landed = yes 
					is_available_ai_adult = yes
					is_at_same_location = root
				}
				any_relation = {
					type = friend
					is_landed = yes 
					is_available_ai_adult = yes
					is_at_same_location = root
				}
			}
		}
		trigger_else = {
			liege = {
				is_landed = yes
				is_available_ai_adult = yes
			}
		}

		# Checks for a valid rival or nemesis
		OR = {
			any_relation = {
				type = rival
				is_available_ai_adult = yes
				is_at_same_location = root
			}
			any_relation = {
				type = nemesis
				is_available_ai_adult = yes
				is_at_same_location = root
			}
		}
	}

	immediate = {
		# Preference Order: potential_friend -> friend
		# If you are not independent, your liege is the host
		if = {
			limit = {
				is_independent_ruler = yes
			}
			if = {
				limit = {
					any_relation = {
						type = potential_friend
						is_landed = yes 
						is_available_ai_adult = yes
						is_at_same_location = root
					}
				}
				random_relation = {
					type = potential_friend
					limit = {
						is_landed = yes
						is_available_ai_adult = yes
						is_at_same_location = root
					}
					save_scope_as = host
				}
			}
			else = {
				random_relation = {
					type = friend
					limit = {
						is_landed = yes
						is_available_ai_adult = yes
						is_at_same_location = root
					}
					save_scope_as = host
				}
			}
		}
		else = {
			liege = {
				save_scope_as = host
			}
		}

		# Pick a bad guy
		if = {
			limit = {
				any_relation = {
					type = nemesis
					is_available_ai_adult = yes
					is_at_same_location = root
				}
			}
			random_relation = {
				type = nemesis
				limit = {
					is_available_ai_adult = yes
					is_at_same_location = root
				}
				save_scope_as = enemy
			}
		}
		else = {
			random_relation = {
				type = rival
				limit = {
					is_available_ai_adult = yes
					is_at_same_location = root
				}
				save_scope_as = enemy
			}
		}

		add_character_flag = had_event_bp1_yearly_3201
	}

	option = {
		name = feast.1503.a
		play_music_cue = mx_cue_banquet
		trigger_event = {
			id = bp1_yearly.3202
			days = 5
		}
		set_variable = {
			name = booked_for_a_party
			value = scope:host
			days = 10
		}
		stress_impact = {
			comfort_eater = minor_stress_loss
			drunkard = minor_stress_loss
			lifestyle_reveler = minor_stress_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = feast.1503.b
		stress_impact = {
			inappetetic = minor_stress_loss
			reclusive = minor_stress_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.2
			}
		}
	}
}

bp1_yearly.3202 = { # Embarrasing Moment with Host & Rival/Nemesis 
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3202.t
	desc = bp1_yearly.3202.desc
	theme = unfriendly
	override_background = throne_room

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

	right_portrait = {
		character = scope:enemy 
		animation = schadenfreude
	}

	immediate = {
		#play_music_cue = "mx_cue_stress"
		save_scope_as = root_for_loc # To show root's prowess in the duel tooltip
	}

	option = { # Just take it
		name = bp1_yearly.3202.a
		trigger = {
			is_independent_ruler = yes
		}
		add_prestige = medium_prestige_loss
		reverse_add_opinion = {
			target = scope:host
			modifier = disapproving_opinion
			opinion = -15
		}

		stress_impact = {
			wrathful = miniscule_stress_impact_gain
			arrogant = miniscule_stress_impact_gain
			ambitious = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			forgiving = minor_stress_impact_loss
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_boldness = -15
				ai_honor = -15
				ai_vengefulness = -15
			}
		}
	}

	option = { # Just take it, liege edition
		name = bp1_yearly.3202.a.liege
		trigger = {
			NOT = { is_independent_ruler = yes }
		}
		add_prestige = medium_prestige_loss
		reverse_add_opinion = {
			target = scope:host
			modifier = disapproving_opinion
			opinion = -15
		}

		stress_impact = {
			wrathful = miniscule_stress_impact_gain
			arrogant = miniscule_stress_impact_gain
			ambitious = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			forgiving = minor_stress_impact_loss
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_boldness = -15
				ai_honor = -15
				ai_vengefulness = -15
			}
		}
	}

	option = { # Argue your case
		name = bp1_yearly.3202.b

		duel = {
			skill = diplomacy
			target = scope:host
			40 = {
				desc = bp1_yearly.3202.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -39
					max = 59
				}
				send_interface_toast = {
					title = bp1_yearly.3202.b.success
					left_icon = root
					right_icon = scope:host
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
					if = {
						limit = {
							root = { has_relation_nemesis = scope:enemy }
						}
						add_character_modifier = {
							modifier = bested_nemesis_modifier
							years = 5
						}
					}
					else = {
						add_character_modifier = {
							modifier = bested_rival_modifier
							years = 5
						}
					}
					scope:host = {
						add_opinion = {
							target = scope:enemy 
							modifier = disapproving_opinion
							opinion = -35
						}
					}
				}
			}
			60 = {
				desc = bp1_yearly.3202.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -59
					max = 39
				}
				send_interface_toast = {
					title = bp1_yearly.3202.b.failure
					left_icon = root
					right_icon = scope:host
					reverse_add_opinion = {
						target = scope:host
						modifier = disapproving_opinion
						opinion = -25
					}
				}
			}
		}

		stress_impact = {
			lazy = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {			
				ai_rationality = 25 
				ai_boldness = 25 
				ai_vengefulness = -50
			}
		}
	} 
	
	option = { # Fight 'em
		name = bp1_yearly.3202.c
		custom_tooltip = bp1_yearly.3202.c.tt

		configure_start_single_combat_effect = {
			SC_INITIATOR = root
			SC_ATTACKER = root
			SC_DEFENDER = scope:enemy
			FATALITY = possible
			FIXED = no
			LOCALE = throne_room
			OUTPUT_EVENT = bp1_yearly.3203
			INVALIDATION_EVENT = bp1_yearly.3204
		}

		stress_impact = {
			wrathful = minor_stress_impact_loss
			vengeful = medium_stress_impact_loss
			craven = minor_stress_impact_gain
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_boldness = 50
				ai_vengefulness = 50
				ai_honor = 50 
			}
		}
	}
}

bp1_yearly.3203 = { # Duel Output Event
	hidden = yes
	immediate = {
		# Inform the victor and the loser
		scope:sc_victor = {
			send_interface_toast = {
				title = bp1_yearly.3203.sc_result_won
				left_icon = scope:sc_victor
				right_icon = scope:sc_loser
			}
		}
		scope:sc_loser = {
			send_interface_toast = {
				title = bp1_yearly.3203.sc_result_lost
				left_icon = scope:sc_loser
				right_icon = scope:sc_victor
			}
		}
	}
}

bp1_yearly.3204 = { # Duel Invalidation Event
	hidden = yes
	immediate = {
		# Inform root that the duel has invalidated
		send_interface_toast = {	
			title = bp1_yearly.3204.sc_invalid
			left_icon = root
			right_icon = scope:enemy
		}
	}
}

############################
## You remember a pilgrimage you had
## 3300-3301
## by Chad Uhl
############################

bp1_yearly.3300 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3300.t
	desc = bp1_yearly.3300.desc

	theme = memory_positive

	left_portrait = { 
		character = root
		animation = happiness
	}

	cooldown = { years = 15 }

	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
	}

	trigger = {
		# DLC Check
		has_bp1_dlc_trigger = yes
		# Has the right memory 
		any_memory = {
			has_memory_type = completed_pilgrimage
			NOT = { var:pilgrimage_destination = root.location }
		}
		NOT = { has_trait = cynical	}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_memory = {
			limit = {
				has_memory_type = completed_pilgrimage
				NOT = { var:pilgrimage_destination = root.location }
			}
			save_scope_as = pilgrimage_memory
		}
		scope:pilgrimage_memory.var:pilgrimage_destination = { save_scope_as = pilgrimage_destination }
	}

	option = { # 
		name = bp1_yearly.3300.a
		
		add_piety = minor_piety_gain

		stress_impact = {
			base = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
	}
}

bp1_yearly.3301 = {
	type = character_event
	content_source = dlc_006
	title = bp1_yearly.3300.t
	desc = bp1_yearly.3301.desc

	theme = memory_positive

	left_portrait = { 
		character = root
		animation = happiness
	}

	cooldown = { years = 15 }

	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
	}

	trigger = {
		# DLC Check
		has_bp1_dlc_trigger = yes
		# Has the right memory 
		any_memory = {
			has_memory_type = completed_pilgrimage_friend
			NOT = { var:pilgrimage_destination = root.location }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_memory = {
			limit = {
				has_memory_type = completed_pilgrimage_friend
				NOT = { var:pilgrimage_destination = root.location }
			}
			save_scope_as = pilgrimage_memory
		}
		scope:pilgrimage_memory.var:pilgrimage_destination = { save_scope_as = pilgrimage_destination }
		scope:pilgrimage_memory.memory_participant:friend = { save_scope_as = pilgrimage_friend }
	}

	option = { 
		name = bp1_yearly.3301.a
		
		add_piety = minor_piety_gain

		stress_impact = {
			base = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
	}
}
