﻿
# Events for the Party Baron story cycle

namespace = party_baron

### Triggers and effects
scripted_trigger potential_party_baron_trigger = {
	is_available_ai_adult = yes
	highest_held_title_tier = tier_barony
	diplomacy >= high_skill_rating
	NOR = { # Block certain traits
		has_trait = shy
		has_trait = callous
		has_trait = sadistic
	}
	ai_sociability >= high_positive_ai_value
	# Make sure they're likely to not die immediately
	age < 50
	health >= fine_health
}

scripted_trigger potential_party_baron_friend_trigger = {
	is_available_ai_adult = yes
	is_landed = yes
	highest_held_title_tier > tier_barony
	num_of_relation_best_friend < 1
	num_of_relation_friend < 2
	can_set_relation_friend_trigger = { CHARACTER = scope:party_baron }
	trigger_if = {
		limit = { exists = scope:friend_1 }
		this != scope:friend_1
	}
	trigger_if = {
		limit = { exists = scope:friend_2 }
		this != scope:friend_2
	}
}

scripted_trigger invalidate_friendly_path_trigger = {
	scope:party_baron = {
		NOT = { has_relation_rival = scope:story.story_owner }
		NOT = {
			opinion = {
				target = scope:story.story_owner
				value < -30
			}
		}
	}
}

scripted_trigger invalidate_unfriendly_path_trigger = {
	scope:party_baron = {
		NOT = { has_relation_friend = scope:story.story_owner }
	}
}

scripted_effect find_party_baron_friends_effect = {
	root = {
		if = {
			limit = {
				any_vassal_or_below = {
					potential_party_baron_friend_trigger = yes
				}
			}
			random_vassal_or_below = {
				limit = {
					potential_party_baron_friend_trigger = yes
				}
				weight = {
					base = 1
					# Slightly increase the chance of the Party Baron befriending someone interesting
					modifier = {
						add = 3
						liege = root
					}
					modifier = {
						add = 2
						is_powerful_vassal_of = root
					}
					modifier = {
						add = 2
						has_trait = lifestyle_reveler
					}
				}
				save_scope_as = friend_1
			}
		}
		if = {
			limit = {
				any_vassal_or_below = {
					potential_party_baron_friend_trigger = yes
					this != scope:friend_1
				}
			}
			random = {
				chance = 50
				random_vassal_or_below = {
					limit = {
						potential_party_baron_friend_trigger = yes
						this != scope:friend_1
					}
					weight = {
						base = 1
						# Slightly increase the chance of the Party Baron befriending someone interesting
						modifier = {
							add = 3
							liege = root
						}
						modifier = {
							add = 2
							is_powerful_vassal_of = root
						}
						modifier = {
							add = 2
							has_trait = lifestyle_reveler
						}
					}
					save_scope_as = friend_2
				}
			}
		}
		if = {
			limit = {
				exists = scope:friend_2
				any_vassal_or_below = {
					potential_party_baron_friend_trigger = yes
					NOR = {
						this = scope:friend_1
						this = scope:friend_2
					}
				}
			}
			random = {
				chance = 25
				random_vassal_or_below = {
					limit = {
						potential_party_baron_friend_trigger = yes
						NOR = {
							this = scope:friend_1
							this = scope:friend_2
						}
					}
					weight = {
						base = 1
						# Slightly increase the chance of the Party Baron befriending someone interesting
						modifier = {
							add = 3
							liege = root
						}
						# Note, no powerful vassal preference for this one
						modifier = {
							add = 2
							has_trait = lifestyle_reveler
						}
					}
					save_scope_as = friend_3
				}
			}
		}
	}
	if = {
		limit = { exists = scope:friend_1 }
		scope:friend_1 = {
			add_opinion = {
				target = scope:party_baron
				modifier = friendliness_opinion
				opinion = 30
			}
			reverse_add_opinion = {
				target = scope:party_baron
				modifier = friendliness_opinion
				opinion = 30
			}
			set_relation_friend = { reason = friend_aggressively_befriended target = scope:party_baron }
		}
	}
	if = {
		limit = { exists = scope:friend_2 }
		scope:friend_2 = {
			add_opinion = {
				target = scope:party_baron
				modifier = friendliness_opinion
				opinion = 30
			}
			reverse_add_opinion = {
				target = scope:party_baron
				modifier = friendliness_opinion
				opinion = 30
			}
			set_relation_friend = { reason = friend_aggressively_befriended target = scope:party_baron }
		}
	}
	if = {
		limit = { exists = scope:friend_3 }
		scope:friend_3 = {
			add_opinion = {
				target = scope:party_baron
				modifier = friendliness_opinion
				opinion = 30
			}
			reverse_add_opinion = {
				target = scope:party_baron
				modifier = friendliness_opinion
				opinion = 30
			}
			set_relation_friend = { reason = friend_aggressively_befriended target = scope:party_baron }
		}
	}
}

scripted_effect fetch_party_baron_scope_effect = {
	scope:story.var:party_baron = {
		save_scope_as = party_baron
	}
}

scripted_effect iterate_party_baron_event_counter_effect = {
	scope:story = {
		change_variable = {
			name = event_counter
			add = 1
		}
	}
}

scripted_effect positive_party_baron_attitude_move_effect = {
	if = {
		limit = { scope:story.var:party_baron_attitude = flag:negative }
		custom_description_no_bullet = {
			text = party_baron_negative_attitude_counter_stress_tt
			object = scope:party_baron
		}
		add_stress = minor_stress_impact_gain
	}
	else_if = {
		limit = {
			OR = {
				AND = {
					scope:story.var:party_baron_attitude = flag:positive
					scope:story.var:party_baron_kind_acts > 3
				}
				AND = { # They should be friends before this, but if not...
					NOT = { has_relation_friend = scope:party_baron }
					scope:story.var:party_baron_attitude = flag:positive
					scope:story.var:party_baron_kind_acts > 5
				}
			}
		}
		progress_towards_friend_effect = {
			CHARACTER = scope:party_baron
			OPINION = 0
			REASON = friend_party_baron
		}
	}
	scope:story = {
		if = {
			limit = { var:party_baron_attitude = flag:negative }
			custom_tooltip = party_baron_move_towards_positive_tt
			change_variable = {
				name = attitude_change_buildup
				add = 1
			}
			if = {
				limit = {
					var:attitude_change_buildup > 2
				}
				set_variable = {
					name = party_baron_attitude
					value = flag:positive
				}
				set_variable = {
					name = attitude_change_buildup
					value = 0
				}
			}
		}
	}
}

scripted_effect negative_party_baron_attitude_move_effect = {
	if = {
		limit = { scope:story.var:party_baron_attitude = flag:positive }
		custom_description_no_bullet = {
			text = party_baron_positive_attitude_counter_stress_tt
			object = scope:party_baron
		}
		add_stress = minor_stress_impact_gain
	}
	scope:story = {
		if = {
			limit = { var:party_baron_attitude = flag:positive }
			custom_tooltip = party_baron_move_towards_negative_tt
			change_variable = {
				name = attitude_change_buildup
				add = 1
			}
			if = {
				limit = {
					var:attitude_change_buildup > 2
				}
				set_variable = {
					name = party_baron_attitude
					value = flag:negative
				}
				set_variable = {
					name = attitude_change_buildup
					value = 0
				}
			}
		}
		change_variable = {
			name = negative_actions_counter
			add = 1
		}
		# If enough is enough, fire rivalry event
		if = {
			limit = {
				var:negative_actions_counter >= 5
				var:party_baron_kind_acts >= 3
			}
			set_variable = {
				name = enough_is_enough
				value = yes
			}
			story_owner = {
				trigger_event = {
					id = party_baron.4002
					days = 10
				}
			}
		}
	}
}

################################
# Assign a Party Baron
################################
party_baron.0001 = {
	hidden = yes

	trigger = {
		NOT = { exists = global_var:had_party_baron_story }
		any_sub_realm_barony = {
			holder ?= {
				potential_party_baron_trigger = yes
			}
		}
	}

	immediate = {
		random_sub_realm_barony = {
			limit = {
				holder ?= { potential_party_baron_trigger = yes }
			}
			weight = {
				base = 1
				modifier = { # Vastly prefer someone the player has direct contact with
					add = 10
					holder.liege = root
				}
			}
			holder = {
				add_trait = diplomat
				add_trait = lifestyle_reveler
				hidden_effect = {
					add_trait_xp = {
						trait = lifestyle_reveler
						value = 50
					}
				}
				save_scope_as = party_baron
				add_character_flag = is_party_baron
				add_character_modifier = party_baron_beloved_by_all_modifier
				add_character_flag = {
					flag = immune_to_disease
					years = 10
				}
				add_character_flag = block_seduce_attempts
				find_party_baron_friends_effect = yes
			}
		}
		create_story = {
			type = story_party_baron
			save_scope_as = story
		}
		scope:story = {
			set_variable = {
				name = party_baron
				value = scope:party_baron
			}
		}

		trigger_event = party_baron.1001
	}
}


################################
# Party Baron in Your Realm
# by Petter Vilberg
################################
party_baron.1001 = {
	type = character_event
	title = party_baron.1001.t
	desc = party_baron.1001.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes
	}
	
	option = { # Sounds like a good example to follow!
		name = party_baron.1001.a
		add_character_modifier = {
			modifier = party_baron_making_efforts_modifier
			years = 5
		}
		custom_tooltip = party_baron_move_towards_positive_tt
		scope:story = {
			set_variable = {
				name = party_baron_attitude
				value = flag:positive
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			shy = minor_stress_impact_gain
		}
	}

	option = { # What have they got that I don't?
		name = party_baron.1001.b
		add_prestige = minor_prestige_gain
		add_character_modifier = {
			modifier = party_baron_self_aggrandizing_modifier
			years = 5
		}
		custom_tooltip = party_baron_move_towards_negative_tt
		scope:story = {
			set_variable = {
				name = party_baron_attitude
				value = flag:negative
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
		}
	}

	option = { # Get to know them!
		name = party_baron.1001.c
		trigger = {
			OR = {
				has_trait = diplomat
				AND = {
					has_trait = lifestyle_reveler
					has_trait_xp = {
						trait = lifestyle_reveler
						value >= 50
					}
				}
			}
		}
		trait = diplomat
		trait = lifestyle_reveler
		custom_tooltip = party_baron.1001.c.tt
		trigger_event = {
			id = party_baron.1002
			days = 20
		}
		scope:story = {
			set_variable = {
				name = party_baron_attitude
				value = flag:positive
			}
		}
	}
}


#########################################
# Party Baron Appreciates Your Efforts
# by Petter Vilberg
#########################################
party_baron.1002 = {
	type = letter_event
	opening = party_baron.1002.opening
	desc = party_baron.1002.desc
	sender = scope:party_baron
	
	trigger = {
		scope:party_baron = {
			is_alive = yes
			NOT = { has_relation_rival = root }
		}
	}

	option = {
		name = party_baron.1002.a
		scope:party_baron = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 30
			}
		}
		custom_tooltip = party_baron_move_towards_positive_tt
		progress_towards_friend_effect = {
			CHARACTER = scope:party_baron
			OPINION = 0
			REASON = friend_party_baron
		}
	}
}

################################
# Party Baron is My Liege
# by Petter Vilberg
################################
party_baron.1003 = {
	type = character_event
	title = party_baron_header
	desc = party_baron.1003.desc
	theme = realm
	orphan = yes
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		target_is_liege_or_above = scope:party_baron
	}

	option = {
		name = party_baron.1003.a
		trigger = {
			scope:story.var:party_baron_attitude = flag:positive
		}
		reverse_add_opinion = {
			target = scope:party_baron
			modifier = friendliness_opinion
			opinion = 20
		}
	}

	option = {
		name = party_baron.1003.b
		trigger = {
			scope:story.var:party_baron_attitude = flag:negative
		}
		reverse_add_opinion = {
			target = scope:party_baron
			modifier = friendliness_opinion
			opinion = 20
		}
	}

	after = {
		scope:story = {
			end_story = yes # Little point in continuing
		}
	}
}


################################
# Party Baron Improves a Powerful Vassal's Opinion
# by Petter Vilberg
################################
scripted_trigger party_baron_2001_vassal_trigger = {
	is_available_ai_adult = yes
	is_powerful_vassal = yes
	opinion = {
		target = root
		value < 0
	}
	NOT = { has_character_flag = pv_had_opinion_improved_by_party_baron }
}

party_baron.2001 = {
	type = character_event
	title = party_baron.2001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:story.var:party_baron_attitude = flag:negative }
				desc = party_baron.2001.negative
			}
			desc = party_baron.2001.positive
		}
	}
	theme = realm
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	right_portrait = {
		character = scope:vassal
		animation = admiration
	}
	
	trigger = {
		any_vassal = {
			party_baron_2001_vassal_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.05
			exists = scope:story.var:had_party_baron_2001
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_party_baron_2001
				value = yes
			}
			change_variable = {
				name = party_baron_kind_acts
				add = 1
			}
		}
		random_vassal = {
			limit = { party_baron_2001_vassal_trigger = yes }
			save_scope_as = vassal
			hidden_effect = {
				add_character_flag = pv_had_opinion_improved_by_party_baron
				add_opinion = {
					target = scope:party_baron
					modifier = friendliness_opinion
					opinion = 30
				}
			}
		}
	}

	option = { # Wow, incredible
		name = party_baron.2001.a_positive
		name = {
			text = party_baron.2001.a_negative
			trigger = { scope:story.var:party_baron_attitude = flag:negative }
		}
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = reputation_opinion
				opinion = 30
			}
		}
		positive_party_baron_attitude_move_effect = yes
	}

	option = {
		name = party_baron.2001.b_negative
		name = {
			text = party_baron.2001.b_positive
			trigger = { scope:story.var:party_baron_attitude = flag:positive }
		}
		add_prestige = minor_prestige_gain
		scope:vassal = {
			add_opinion = {
				target = root
				modifier = reputation_opinion
				opinion = 10
			}
		}
		stress_impact = {
			humble = minor_stress_impact_gain
		}
		negative_party_baron_attitude_move_effect = yes
	}
}

################################
# Party Baron moves you towards friendship with one of their friends
# by Petter Vilberg
################################
scripted_trigger party_baron_2002_friend_trigger = {
	is_available_ai_adult = yes
	highest_held_title_tier >= tier_county
	has_relation_friend = scope:party_baron
	NOT = { has_relation_friend = root }
	NOT = { is_close_family_of = root }
	opinion = {
		target = root
		value > -30
	}
	OR = {
		target_is_liege_or_above = root
		AND = {
			exists = root.liege
			this = root.liege
		}
	}
}

party_baron.2002 = {
	type = character_event
	title = party_baron.2002.t
	desc = party_baron.2002.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	right_portrait = {
		character = scope:new_friend
		animation = admiration
	}
	
	trigger = {
		scope:party_baron = {
			any_relation = {
				type = friend
				party_baron_2002_friend_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.05
			exists = scope:story.var:had_party_baron_2002
		}
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes

		scope:story = {
			set_variable = {
				name = had_party_baron_2002
				value = yes
			}
			change_variable = {
				name = party_baron_kind_acts
				add = 1
			}
		}
		scope:party_baron = {
			random_relation = {
				type = friend
				limit = {
					party_baron_2002_friend_trigger = yes
				}
				weight = {
					base = 1
					# More interesting characters are prioritised
					modifier = {
						add = 1
						highest_held_title_tier >= tier_duchy
					}
					modifier = {
						add = 2
						highest_held_title_tier >= tier_kingdom
					}
					# Try to find someone who actually has a little in common with root
					modifier = {
						add = 2
						number_of_traits_in_common = {
							target = root
							value > 0
						}
					}
					modifier = {
						add = 2
						number_of_traits_in_common = {
							target = root
							value > 1
						}
					}
				}
				save_scope_as = new_friend
			}
		}
	}

	option = { # Great!
		name = party_baron.2002.a
		progress_towards_friend_effect = {
			CHARACTER = scope:new_friend
			OPINION = default_friend_opinion
			REASON = friend_introduced_by_common_friend
		}
		positive_party_baron_attitude_move_effect = yes
	}

	option = { # I know them as well as I feel I need to
		name = party_baron.2002.b
		add_character_modifier = {
			modifier = party_baron_friendly_enough_modifier
			years = 5
		}
		stress_impact = {
			gregarious = medium_stress_impact_gain
		}
	}
}

################################
# Party Baron stops a scheme against you
# by Petter Vilberg
################################
scripted_trigger party_baron_2003_scheme_trigger = {
	scheme_type = murder
	save_temporary_scope_as = scheme
	scheme_progress > scheme_progress_33
	scheme_owner = {
		is_ai = yes
		this != scope:party_baron
		OR = {
			top_liege = root.top_liege
			AND = {
				is_landed = yes
				any_held_title = {
					is_neighbor_to_realm = root
				}
			}
		}
	}
}

party_baron.2003 = {
	type = letter_event
	opening = party_baron.1002.opening # AppropriateGreetingPositive
	desc = party_baron.2003.desc
	sender = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		any_targeting_scheme = {
			party_baron_2003_scheme_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.05
			exists = scope:story.var:had_party_baron_2003
		}
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes

		scope:story = {
			set_variable = {
				name = had_party_baron_2003
				value = yes
			}
			change_variable = {
				name = party_baron_kind_acts
				add = 1
			}
		}
		random_targeting_scheme = {
			limit = { party_baron_2003_scheme_trigger = yes }
			weight = {
				base = 1
				modifier = {
					add = 2
					is_scheme_exposed = yes
				}
			}
			save_scope_as = scheme
			scheme_owner = { save_scope_as = owner }
		}
		# If you're trying to murder the Party Baron...
		if = {
			limit = {
				any_scheme = {
					type = murder
					scheme_target_character = scope:party_baron
				}
			}
			random_scheme = {
				type = murder
				limit = {
					scheme_target_character = scope:party_baron
				}
				save_scope_as = my_scheme
			}
		}
	}

	option = { # That's... good
		name = party_baron.2003.a
		scope:scheme = {
			end_scheme = yes
		}
		scope:owner = {
			add_opinion = {
				target = root
				modifier = repentant_opinion
				opinion = 30
			}
		}
		custom_tooltip = party_baron.2003.repentant_cannot_scheme
		positive_party_baron_attitude_move_effect = yes
	}

	option = { # Oh, they won't get away with this!
		name = party_baron.2003.b
		scope:scheme = {
			end_scheme = yes
		}
		add_opinion = {
			target = scope:owner
			modifier = attempted_murder_me_crime
		}
	}

	option = { # Um, you can discover schemes?
		name = party_baron.2003.c
		trigger = {
			exists = scope:my_scheme
		}
		exclusive = yes
		add_internal_flag = special
		scope:my_scheme = {
			add_scheme_progress = {
				value = scheme_progress_loss
				multiply = 2
			}
		}
		scope:scheme = {
			end_scheme = yes
		}
		scope:owner = {
			add_opinion = {
				target = root
				modifier = repentant_opinion
				opinion = 30
			}
		}
		custom_tooltip = party_baron.2003.repentant_cannot_scheme
	}
}


################################
# Party Baron Becomes Your Friend
# by Petter Vilberg
################################
party_baron.2004 = {
	type = character_event
	title = party_baron.2004.t
	desc = party_baron.2004.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		scope:story.var:event_counter >= 2
		has_relation_potential_friend = scope:party_baron
		scope:story.var:party_baron_attitude = flag:positive
		NOT = { exists = scope:story.var:had_party_baron_2004 }
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes
		scope:story = {
			set_variable = {
				name = had_party_baron_2004
				value = yes
			}
		}
	}

	option = {
		name = party_baron.2004.a
		progress_towards_friend_effect = {
			CHARACTER = scope:party_baron
			OPINION = 0
			REASON = friend_party_baron
		}
	}
}

################################
# Party Baron Becomes Your Best Friend
# by Petter Vilberg
################################
party_baron.2005 = {
	type = character_event
	title = party_baron.2005.t
	desc = party_baron.2005.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		scope:story.var:event_counter >= 5
		has_relation_friend = scope:party_baron
		can_set_relation_best_friend_trigger = {
			CHARACTER = scope:party_baron
		}
		scope:story.var:party_baron_attitude = flag:positive
	}

	option = {
		name = party_baron.2005.a
		set_relation_best_friend = { reason = best_friend_shared_revelries copy_reason = friend target = scope:party_baron }
		scope:story = {
			end_story = yes # A conclusion of sorts
		}
	}
}

################################
# What a Party
# by Petter Vilberg
################################
party_baron.2006 = {
	type = character_event
	title = party_baron_header
	desc = party_baron.2006.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.7
			exists = scope:story.var:had_party_baron_2006
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_party_baron_2006
				value = yes
			}
			change_variable = {
				name = party_baron_kind_acts
				add = 1
			}
		}
	}

	option = {
		name = party_baron.2006.a
		stress_impact = {
			base = medium_stress_impact_loss
		}
		positive_party_baron_attitude_move_effect = yes
	}

	option = {
		name = party_baron.2006.b
		stress_impact = {
			base = minor_stress_impact_loss
			honest = medium_stress_impact_gain
		}
		negative_party_baron_attitude_move_effect = yes
	}
}

################################
# Party Baron Shows Up With Volunteers
# by Petter Vilberg
################################
party_baron.2007 = {
	type = character_event
	title = party_baron_header
	desc = party_baron.2007.desc
	theme = war
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}

	trigger = {
		NOT = { exists = scope:story.var:had_party_baron_2007 }
		is_at_war = yes
		is_in_civil_war = no
		target_is_vassal_or_below = scope:party_baron
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_party_baron_2007
				value = yes
			}
			change_variable = {
				name = party_baron_kind_acts
				add = 1
			}
		}
	}

	option = { # Fantastic!
		name = party_baron.2007.a
		spawn_army = {
			name = party_baron_volunteer_levies
			location = capital_province
			inheritable = no
			levies = {
				add = max_military_strength
				multiply = 0.2
			}

			#men_at_arms = {
			#	type = light_cavalry
			#	stacks = 1
			#}
		}
		positive_party_baron_attitude_move_effect = yes
	}

	option = { # I would rather have professionals
		name = party_baron.2007.b
		flavor = party_baron.2007.b_flavor
		add_character_modifier = {
			modifier = party_baron_great_mercenary_deal_modifier
			years = 5
		}
		negative_party_baron_attitude_move_effect = yes
	}
}


################################
# Why Does Everyone Love Party Baron so much?
# by Petter Vilberg
################################
party_baron.3001 = {
	type = character_event
	title = party_baron.3001.t
	desc = party_baron.3001.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		scope:story.var:party_baron_attitude = flag:negative
		NOT = { exists = scope:story.var:had_party_baron_3001 }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes
		scope:story = {
			set_variable = {
				name = had_party_baron_3001
				value = yes
			}
		}
	}

	option = { # It drives me mad!
		name = party_baron.3001.a
		add_character_modifier = {
			modifier = party_baron_if_you_cannot_be_loved_modifier
			years = 10
		}
		negative_party_baron_attitude_move_effect = yes
	}

	option = { # Maybe I'm overly harsh...
		name = party_baron.3001.b
		add_character_modifier = {
			modifier = party_baron_accommodating_modifier
			years = 10
		}
		stress_impact = {
			stubborn = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
		positive_party_baron_attitude_move_effect = yes
	}
}

################################
# Vassals Dislike That You Dislike Party Baron
# by Petter Vilberg
################################
party_baron.3002 = {
	type = character_event
	title = party_baron.3002.t
	desc = party_baron.3002.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		scope:story.var:party_baron_attitude = flag:negative
		NOT = { exists = scope:story.var:had_party_baron_3002 }
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes
		scope:story = {
			set_variable = {
				name = had_party_baron_3002
				value = yes
			}
		}
	}

	option = {
		name = party_baron.3002.a
		add_stress = medium_stress_loss
		add_character_modifier = {
			modifier = party_baron_condemned_pb_modifier
			years = 5
		}
		negative_party_baron_attitude_move_effect = yes
	}

	option = {
		name = party_baron.3002.b
		add_character_modifier = {
			modifier = party_baron_praised_pb_modifier
			years = 5
		}
		positive_party_baron_attitude_move_effect = yes
	}
}

################################
# Who Are You Kidding? Party Baron Befriends You
# by Petter Vilberg
################################
party_baron.3003 = {
	type = character_event
	title = party_baron_header
	desc = party_baron.3003.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = personality_forgiving
	}
	
	trigger = {
		scope:story.var:party_baron_attitude = flag:negative
		scope:story.var:event_counter >= 3
		scope:story.var:party_baron_kind_acts >= 1
		NOT = { has_relation_friend = scope:party_baron }
		NOT = { exists = scope:story.var:had_party_baron_3003 }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:story.var:party_baron_kind_acts >= 2
		}
		modifier = {
			add = 0.5
			scope:story.var:party_baron_kind_acts >= 3
		}
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes
		scope:story = {
			set_variable = {
				name = had_party_baron_3003
				value = yes
			}
			change_variable = {
				name = party_baron_kind_acts
				add = 1
			}
		}	
	}

	option = { # Who can resist?
		name = party_baron.3003.a
		set_relation_friend = { reason = friend_aggressively_befriended target = scope:party_baron }
	}

	option = { # No, I refuse!
		name = party_baron.3003.b
		stress_impact = {
			base = major_stress_impact_gain
			stubborn = medium_stress_impact_loss
		}
		negative_party_baron_attitude_move_effect = yes
	}
}

################################
# You Want to Do Something Against the Party Baron
# by Petter Vilberg
################################
party_baron.3004 = {
	type = character_event
	title = party_baron_header
	desc = party_baron.3004.desc
	theme = party
	left_portrait = {
		character = scope:party_baron
		animation = happiness
	}
	
	trigger = {
		NOT = { exists = scope:story.var:had_party_baron_3004 }
		scope:story.var:party_baron_attitude = flag:negative
		scope:story.var:event_counter >= 2
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		iterate_party_baron_event_counter_effect = yes
		scope:story = {
			set_variable = {
				name = had_party_baron_3004
				value = yes
			}
		}
	}

	option = {  # I'll get them somehow
		name = party_baron.3004.a
		add_character_modifier = {
			modifier = party_baron_subversive_tactics_modifier
			years = 10
		}
		scope:party_baron = {
			remove_character_modifier = party_baron_beloved_by_all_modifier
			add_character_modifier = {
				modifier = party_baron_beloved_by_all_except_modifier
			}
		}
		negative_party_baron_attitude_move_effect = yes
	}
	
	option = { # Perhaps I am going too far
		name = party_baron.3004.b
		add_character_modifier = {
			modifier = party_baron_reflection_modifier
			years = 5
		}
		positive_party_baron_attitude_move_effect = yes
	}
}


################################
# Party Baron Was Close With Your Predecessor
# by Petter Vilberg
################################
party_baron.4001 = {
	type = letter_event
	opening = party_baron.1002.opening
	desc = party_baron.4001.desc
	sender = {
		character = scope:party_baron
		animation = sadness
	}
	
	trigger = {
		is_ruler = yes
		is_ai = no
		scope:party_baron = {
			target_is_liege_or_above = root
			is_alive = yes
		}
	}

	option = {
		name = party_baron.4001.a
		add_character_modifier = {
			modifier = party_baron_endorsed_successor_modifier
			years = 10
		}
	}
}


################################
# Enough is Finally Enough
# by Petter Vilberg
################################
party_baron.4002 = {
	type = letter_event
	opening = party_baron.1002.opening
	desc = party_baron.4002.desc
	sender = {
		character = scope:party_baron
		animation = personality_bold
	}
	
	trigger = {
		NOT = { has_relation_friend = scope:party_baron }
	}

	option = {
		name = party_baron.4002.a
		set_relation_rival = {
			target = scope:party_baron
			reason = rival_party_baron_spurned
		}
		scope:story = {
			end_story = yes
		}
	}
}


# Generic
### Event to fire if PB hosts feast
### Event to fire if PB is at feast
### PB is vicious and manipulative?? -- Suspicious PB line
### PB is my Chancellor
	# Negate Powerful Vassal opinion for a while
### Succession: PB reminiscises over your parent

# Positive path
### PB makes you more popular with people in your life
### Appoint PB as my Chancellor?
	# Negate Powerful Vassal opinion for a while

# Negative path
### A powerful vassal claims that PB would make a much better ruler!
### Bond with someone else who doesn't like PB
### Suspicion of PB boosts Scheme Defense
### Scheme bonus for wanting to do something against PB
### Receive gift from PB
### You have to admit that PB is pretty good...



#######################################################
### Maintenance
#######################################################
################################
# Party Baron has died
# by Petter Vilberg
################################
party_baron.9001 = {
	type = character_event
	title = party_baron.9001.t
	desc = party_baron.9001.desc
	theme = party
	left_portrait = scope:party_baron

	option = { # Tragic
		name = party_baron.9001.a
		custom_tooltip = party_baron.9001.a.tt
	}

	option = { # Good riddance
		name = party_baron.9001.b
		trigger = {
			scope:story.var:party_baron_attitude = flag:negative
		}
		exclusive = yes
		custom_tooltip = party_baron.9001.b.tt
	}

	after = {
		hidden_effect = {
			if = { # It is theoretically possible for the story to time out at the same time
				limit = { exists = scope:story }
				scope:story = { end_story = yes }
			}
		}
	}
}


################################
# Restock Party Baron friends
# by Petter Vilberg
################################
party_baron.9002 = {
	hidden = yes

	trigger = {
		any_vassal_or_below = {
			potential_party_baron_friend_trigger = yes
		}
	}

	immediate = {
		assert_if = {}
		find_party_baron_friends_effect = yes
	}
}

################################
# You Married the Party Baron
# by Petter Vilberg
################################
party_baron.9003 = {
	type = character_event
	title = party_baron.9003.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:story.var:party_baron_attitude = flag:negative }
				desc = party_baron.9003.desc_negative
			}
			desc = party_baron.9003.desc_positive
		}
	}
	theme = marriage
	left_portrait = {
		character = scope:party_baron
		animation = ecstasy
	}
	right_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = party_baron.9003.a_positive
		name = {
			text = party_baron.9003.a_negative
			trigger = { scope:story.var:party_baron_attitude = flag:negative }
		}
		if = {
			limit = {
				can_set_relation_soulmate_trigger = {
					CHARACTER = scope:party_baron
				}
			}
			set_relation_soulmate = { reason = soulmate_married_party_baron copy_reason = lover target = scope:party_baron }
		}
		else = {
			set_relation_lover = { reason = lover_party_baron target = scope:party_baron }
		}
		if = { # It is theoretically possible for the story to time out at the same time
			limit = { exists = scope:story }
			scope:story = { end_story = yes }
		}
	}
}

################################
# End the Story After a While
################################
party_baron.9999 = {
	hidden = yes

	immediate = {
		if = {
			limit = { exists = scope:story } # The story might already have ended
			scope:story = { end_story = yes }
		}
	}
}
