﻿spouse_skill_diplomacy_improves = {
	icon = marriage
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host.primary_spouse ?= {
			involved_activity ?= scope:activity
			is_physically_able_ai_adult = yes
			NOR = {
				has_trait = dull
				has_trait = intellect_bad
				diplomacy >= 25
				has_character_flag = spouse_skill_diplomacy_improves
			}
			location = scope:province
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_extroverted_trigger = yes
				}
			}
			add = 1
		}
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_introverted_trigger = yes
				}
			}
			add = -1
		}
	}

	effect = {
		scope:host.primary_spouse = {
			save_scope_as = first
			add_character_flag = {
				flag = spouse_skill_diplomacy_improves
				days = 730
			}
		}

		add_activity_log_entry = {
			key = spouse_skill_diplomacy_improves
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_diplomacy_skill = 1
			}
		}
	}
}

spouse_gives_host_prestige = {
	icon = marriage
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host.primary_spouse ?= {
			involved_activity ?= scope:activity
			is_physically_able_ai_adult = yes
			likes_character_trigger = { CHARACTER = scope:host }
			OR = {
				diplomacy >= 12
				has_trait = diplomat
			}
			location = scope:province
		}
		any_attending_character = {
			this != scope:host
			this != scope:host.primary_spouse
			OR = {
				is_ruler = yes
				is_councillor = yes
			}
			is_physically_able_ai_adult = yes
			location = scope:province
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					diplomacy >= 16
				}
			}
			add = 0.5
		}
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_introverted_trigger = yes
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host.primary_spouse = {
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:host.primary_spouse
				OR = {
					is_ruler = yes
					is_councillor = yes
				}
				is_physically_able_ai_adult = yes
				location = scope:province
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = spouse_gives_host_prestige
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:host = {
				add_prestige = medium_prestige_gain
			}
			scope:second = {
				add_opinion = {
					modifier = impressed_opinion
					target = scope:host
					opinion = 10
				}
			}
		}
	}
}

spouse_manages_feast_splendidly = {
	icon = marriage
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host.primary_spouse ?= {
			involved_activity ?= scope:activity
			is_physically_able_ai_adult = yes
			likes_character_trigger = { CHARACTER = scope:host }
			OR = {
				stewardship >= 12
				has_trait = architect
			}
			location = scope:province
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					stewardship >= 16
				}
			}
			add = 0.5
		}
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_submissive_trigger = yes
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		scope:host.primary_spouse = {
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = spouse_manages_feast_splendidly
			tags = { pulse_action }
			character = scope:first
			
			scope:province.county = {
				if = {
					limit = {
						uses_county_fertility = yes 
					}
					change_county_fertility = 8
				}
				else = {
					change_development_progress_with_overflow = 20
				}
			}
			scope:host = {
				if = {
					limit = {
						any_vassal = {
							vassal_stance = parochial
						}
					}
					every_vassal = {
						custom = every_parochial_vassal_no_count
						add_opinion = {
							modifier = impressed_opinion
							opinion = 5
							target = scope:host
						}
					}
				}
			}
		}
	}
}

spouse_impresses_clergy = {
	icon = marriage
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host.primary_spouse ?= {
			involved_activity ?= scope:activity
			is_physically_able_ai_adult = yes
			likes_character_trigger = { CHARACTER = scope:host }
			OR = {
				learning >= 12
				has_trait = theologian
			}
			location = scope:province
		}
		any_attending_character = {
			this != scope:host
			this != scope:host.primary_spouse
			OR = {
				is_clergy = yes
				has_council_position = councillor_court_chaplain
			}
			is_physically_able_ai_adult = yes
			location = scope:province
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					learning >= 16
				}
			}
			add = 0.5
		}
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_extroverted_trigger = yes
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		scope:host.primary_spouse = {
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:host.primary_spouse
				OR = {
					is_clergy = yes
					has_council_position = councillor_court_chaplain
				}
				is_physically_able_ai_adult = yes
				location = scope:province
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = spouse_impresses_clergy
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:host = {
				add_piety = minor_piety_gain
			}
			scope:second = {
				add_opinion = {
					modifier = impressed_opinion
					target = scope:host
					opinion = 20
				}
			}
		}
	}
}

spouse_gives_hook = {
	icon = marriage
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host.primary_spouse ?= {
			involved_activity ?= scope:activity
			is_physically_able_ai_adult = yes
			likes_character_trigger = { CHARACTER = scope:host }
			OR = {
				intrigue >= 12
				has_trait = schemer
			}
			location = scope:province
		}
		any_attending_character = {
			this != scope:host
			this != scope:host.primary_spouse
			is_ruler = yes
			primary_title.tier > tier_barony
			intrigue < scope:host.primary_spouse.intrigue
			is_physically_able_ai_adult = yes
			location = scope:province
			scope:host = {
				can_add_hook = {
					target = prev
					type = manipulation_hook
				}
			}
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					intrigue >= 16
				}
			}
			add = 0.5
		}
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_benevolent_trigger = yes
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		scope:host.primary_spouse = {
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:host.primary_spouse
				is_ruler = yes
				primary_title.tier > tier_barony
				intrigue < scope:host.primary_spouse.intrigue
				is_physically_able_ai_adult = yes
				location = scope:province
				scope:host = {
					can_add_hook = {
						target = prev
						type = manipulation_hook
					}
				}
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = spouse_gives_hook
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:host = {
				add_hook = {
					type = manipulation_hook
					target = scope:second
				}
			}
			scope:second = {
				add_opinion = {
					modifier = suspicion_opinion
					target = scope:host.primary_spouse
					opinion = -10
				}
			}
		}
	}
}

relation_gains_friend = {
	icon = friend
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		any_attending_character = {
			this != scope:host
			OR = {
				is_close_family_of = scope:host
				is_spouse_of = scope:host
			}
			is_physically_able_ai_adult = yes
			num_of_relation_friend < 2
			location = scope:province
			save_temporary_scope_as = trait_check
		}
		any_attending_character = {
			this != scope:host
			this != scope:trait_check
			is_physically_able_ai_adult = yes
			num_of_relation_friend < 2
			location = scope:province
			can_set_relation_friend_trigger = { CHARACTER = scope:trait_check }
			number_of_traits_in_common = {
				target = scope:trait_check
				value >= 1
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				num_of_relation_friend < 2
				location = scope:province
				save_temporary_scope_as = check_scope
				scope:activity = {
					any_attending_character = {
						this != scope:host
						this != scope:check_scope
						OR = {
							is_close_family_of = scope:host
							is_spouse_of = scope:host
						}
						is_physically_able_ai_adult = yes
						num_of_relation_friend < 2
						location = scope:province
						can_set_relation_friend_trigger = { CHARACTER = scope:check_scope }
						number_of_traits_in_common = {
							target = scope:check_scope
							value >= 1
						}
					}
				}
			}
			save_scope_as = second
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:second
				OR = {
					is_close_family_of = scope:host
					is_spouse_of = scope:host
				}
				is_physically_able_ai_adult = yes
				num_of_relation_friend < 2
				location = scope:province
				can_set_relation_friend_trigger = { CHARACTER = scope:second }
				number_of_traits_in_common = {
					target = scope:second
					value >= 1
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = relation_gains_friend
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:second = {
				set_relation_friend = { reason = friend_feast_talking_and_laughing target = scope:first }
			}
		}
	}
}

lauded_food = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		OR = {
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_good
				}
			}
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_good
				}
			}
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_normal
				}
			}
			AND = {
				has_activity_type = activity_coronation
				has_current_phase = coronation_phase_feast
				OR = {
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_regular
					}
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_lavish
					}
				}
			}
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			OR = {
				likes_character_trigger = { CHARACTER = scope:host }
				loves_food_trigger = yes
			}
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_feast
					has_activity_option = {
						category = feast_option_food
						option = feast_food_normal
					}
				}
			}
			add = -0.5
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_wedding
					has_activity_option = {
						category = wedding_option_food
						option = wedding_food_normal
					}
				}
			}
			add = -0.5
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				OR = {
					likes_character_trigger = { CHARACTER = scope:host }
					loves_food_trigger = yes
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = lauded_food
			tags = { pulse_action }
			character = scope:first
			
			scope:host = {
				add_prestige = minor_prestige_gain
			}
			scope:first = {
				add_opinion = {
					modifier = impressed_opinion
					target = scope:host
					opinion = 5
				}
			}
		}
	}
}

guest_of_honor_impressed = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		OR = {
			has_activity_option = {
				category = feast_option_food
				option = feast_food_good
			}
			has_activity_option = {
				category = feast_option_courses
				option = feast_courses_good
			}
		}
		exists = special_guest:honorary_guest_regular
		
		special_guest:honorary_guest_regular = {
			is_alive = yes
			location ?= scope:province
			NOR = {
				has_trait = inappetetic
				has_trait = temperate
			}
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = feast_option_food
						option = feast_food_bad
					}
				}
			}
			add = -0.5
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = feast_option_courses
						option = feast_courses_bad
					}
				}
			}
			add = -0.5
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		special_guest:honorary_guest_regular = {
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = guest_of_honor_impressed
			tags = { pulse_action }
			character = scope:first
			
			scope:host = {
				add_stress = minor_stress_loss
			}
			
			scope:first = {
				add_opinion = {
					modifier = tasty_food_opinion
					target = scope:host
					opinion = 25
				}
			}
		}
	}
}

guest_of_honor_praised = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		exists = special_guest:honorary_guest_regular
		special_guest:honorary_guest_regular = {
			is_alive = yes
			location ?= scope:province
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		special_guest:honorary_guest_regular = {
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = guest_of_honor_praised
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_prestige = medium_prestige_gain
				add_opinion = {
					modifier = honored_opinion
					target = scope:host
					opinion = 10
				}
			}
		}
	}
}

children_bonding = {
	icon = friend
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		any_attending_character = {
			this != scope:host
			OR = {
				is_close_family_of = scope:host
				is_spouse_of = scope:host
			}
			is_physically_able_ai = yes
			is_adult = no
			num_of_relation_friend < 2
			location = scope:province
			save_temporary_scope_as = trait_check
		}
		any_attending_character = {
			this != scope:host
			this != scope:trait_check
			is_physically_able_ai = yes
			is_adult = no
			num_of_relation_friend < 2
			location = scope:province
			can_set_relation_friend_trigger = { CHARACTER = scope:trait_check }
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai = yes
				is_adult = no
				num_of_relation_friend < 2
				location = scope:province
				save_temporary_scope_as = check_scope
				scope:activity = {
					any_attending_character = {
						this != scope:host
						this != scope:check_scope
						OR = {
							is_close_family_of = scope:host
							is_spouse_of = scope:host
						}
						is_physically_able_ai = yes
						is_adult = no
						num_of_relation_friend < 2
						location = scope:province
						can_set_relation_friend_trigger = { CHARACTER = scope:check_scope }
					}
				}
			}
			save_scope_as = second
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:second
				OR = {
					is_close_family_of = scope:host
					is_spouse_of = scope:host
				}
				is_physically_able_ai = yes
				is_adult = no
				num_of_relation_friend < 2
				location = scope:province
				can_set_relation_friend_trigger = { CHARACTER = scope:second }
			}
			weight = {
				base = 1
				modifier = {
					factor = 10
					number_of_traits_in_common = {
						target = scope:second
						value >= 1
					}
				}
			}
			save_scope_as = first
			set_favorite_toy_effect = yes
		}

		add_activity_log_entry = {
			key = children_bonding
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:first = {
				set_relation_friend = { reason = friend_feast_bonding target = scope:second }
			}
		}
	}
}

guest_impressed_by_court_artifact = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:province = scope:host.capital_province
		scope:host = {
			any_character_artifact = {
				ep1_artifact_is_court_artifact_trigger = yes
				is_equipped = yes
			}
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		scope:host = {
			random_character_artifact = { #Unop: Changed to show the artifact in the activity journal
				limit = {
					ep1_artifact_is_court_artifact_trigger = yes
					is_equipped = yes
				}
				save_scope_as = second
			}
		}
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = guest_impressed_by_court_artifact
			tags = { pulse_action }
			character = scope:first
			artifact = scope:second #Unop: Changed to show the artifact in the activity journal
			
			scope:host = {
				add_prestige = minor_prestige_gain
			}
			scope:first = {
				add_opinion = {
					modifier = impressed_opinion
					target = scope:host
					opinion = 15
				}
			}
		}
	}
}

guest_chokes_on_bone = {
	icon = wound
	is_valid = {
		is_current_phase_active = yes
		OR = {
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_food
					option = feast_food_bad
				}
			}
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_food
					option = feast_food_normal
				}
			}
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			AND = {
				has_activity_type = activity_coronation
				has_current_phase = coronation_phase_feast
				OR = {
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_regular
					}
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_austere
					}
				}
			}
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			NOR = {
				has_trait = inappetetic
				has_trait = temperate
			}
			is_vegetarian_trigger = no
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_feast
					has_activity_option = {
						category = feast_option_food
						option = feast_food_normal
					}
				}
			}
			add = -0.75
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_wedding
					has_activity_option = {
						category = wedding_option_food
						option = wedding_food_normal
					}
				}
			}
			add = -0.75
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_coronation
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_regular
					}
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				NOR = {
					has_trait = inappetetic
					has_trait = temperate
				}
				is_vegetarian_trigger = no
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = guest_chokes_on_bone
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_stress = medium_stress_gain
			}
		}
	}
}

guest_brawl = {
	icon = wound
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			any_relation = {
				type = rival
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				any_relation = {
					type = rival
					this != scope:host
					is_physically_able_ai_adult = yes
					location = scope:province
				}
			}
			save_scope_as = first
			random_relation = {
				type = rival
				limit = {
					this != scope:host
					is_physically_able_ai_adult = yes
					location = scope:province
				}
				save_scope_as = second
			}
		}

		add_activity_log_entry = {
			key = guest_brawl
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:first = {
				hidden_effect = {
					increase_wounds_no_death_effect = { REASON = fight }
				}
				show_as_tooltip = {
					change_trait_rank = {
						trait = wounded
						rank = 1
						max = 3
					}
				}
			}
			
			scope:second = {
				hidden_effect = {
					increase_wounds_no_death_effect = { REASON = fight }
				}
				show_as_tooltip = {
					change_trait_rank = {
						trait = wounded
						rank = 1
						max = 3
					}
				}
			}
		}
	}
}

friend_lauds_efforts = {
	icon = friend
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			has_relation_friend = scope:host
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			is_ruler = yes
			NOT = { has_relation_friend = scope:host }
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				has_relation_friend = scope:host
			}
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				is_ruler = yes
				NOT = { has_relation_friend = scope:host }
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = friend_lauds_efforts
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:host = {
				add_stress = minor_stress_loss
			}
			
			scope:second = {
				add_opinion = {
					modifier = friendly_interaction
					target = scope:host
					opinion = 15
				}
			}
		}
	}
}

courtly_vassals_appeased = {
	icon = courtly
	is_valid = {
		is_current_phase_active = yes
		NOR = {
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_food
					option = feast_food_bad
				}
			}
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_bad
				}
			}
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			AND = {
				has_activity_type = activity_coronation
				has_current_phase = coronation_phase_feast
				has_activity_option = {
					category = ceremony_feast_type
					option = ceremony_feast_type_austere
				}
			}
		}
		any_attending_character = {
			count >= 2
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			is_vassal_of = scope:host
			has_vassal_stance = courtly
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_feast
					has_activity_option = {
						category = feast_option_food
						option = feast_food_normal
					}
				}
			}
			add = -0.5
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_feast
					has_activity_option = {
						category = feast_option_courses
						option = feast_courses_normal
					}
				}
			}
			add = -0.5
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_wedding
					has_activity_option = {
						category = wedding_option_food
						option = wedding_food_normal
					}
				}
			}
			add = -0.5
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_coronation
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_regular
					}
				}
			}
			add = -0.5
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				is_vassal_of = scope:host
				has_vassal_stance = courtly
			}
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:first
				is_physically_able_ai_adult = yes
				location = scope:province
				is_vassal_of = scope:host
				has_vassal_stance = courtly
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = courtly_vassals_appeased
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:host = {
				add_prestige = minor_prestige_gain
			}
			
			scope:first = {
				add_opinion = {
					modifier = admiration_opinion
					target = scope:host
					opinion = 10
				}
			}
			
			scope:second = {
				add_opinion = {
					modifier = admiration_opinion
					target = scope:host
					opinion = 10
				}
			}
		}
	}
}

spouse_insults_host = {
	icon = marriage
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host.primary_spouse ?= {
			involved_activity ?= scope:activity
			is_physically_able_ai_adult = yes
			OR = {
				has_relation_rival = scope:host
				opinion = {
					target = scope:host
					value <= 50
				}
			}
			NOR = {
				has_trait = honest
				has_trait = compassionate
				has_trait = loyal
			}
			location = scope:province
		}
		any_attending_character = {
			this != scope:host
			this != scope:host.primary_spouse
			is_physically_able_ai_adult = yes
			location = scope:province
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_malicious_trigger = yes
				}
			}
			add = 1
		}
		if = {
			limit = {
				scope:host.primary_spouse ?= {
					has_personality_submissive_trigger = yes
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host.primary_spouse = {
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				this != scope:host.primary_spouse
				is_physically_able_ai_adult = yes
				location = scope:province
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = spouse_insults_host
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:second = {
				add_opinion = {
					target = scope:host
					modifier = insult_opinion
					opinion = -20
				}
			}
		}
	}
}

host_gains_diplo_xp = {

	icon = diplomacy

	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host = {
			has_lifestyle = diplomacy_lifestyle
			location = scope:province
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = host_gains_diplo_xp
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:first = {
				add_diplomacy_lifestyle_xp = medium_lifestyle_xp
			}
			
			scope:second = {
				add_opinion = {
					target = scope:host
					modifier = respect_opinion
					opinion = 20
				}
			}
		}
	}
}

host_gains_steward_xp = {
	icon = stewardship
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host = {
			has_lifestyle = stewardship_lifestyle
			location = scope:province
		}
		exists = scope:province.county
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
		}
		
		scope:province.county = {
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = host_gains_steward_xp
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_stewardship_lifestyle_xp = medium_lifestyle_xp
			}
			
			scope:province.county = {
				if = {
					limit = {
						uses_county_fertility = yes 
					}
					change_county_fertility = 2
				}
				else = {
					change_development_progress_with_overflow = 5
				}
			}
		}
	}
}

host_gains_intrigue_xp = {
	icon = intrigue
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		scope:host = {
			has_lifestyle = intrigue_lifestyle
			location = scope:province
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			scope:host = {
				can_add_hook = {
					target = prev
					type = manipulation_hook
				}
			}
		}
	}

	weight = {
		value = 1
	}

	effect = {
		scope:host = {
			save_scope_as = first
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				scope:host = {
					can_add_hook = {
						target = prev
						type = manipulation_hook
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 5
					has_trait = trusting
				}
			}
			save_scope_as = second
		}

		add_activity_log_entry = {
			key = host_gains_intrigue_xp
			tags = { pulse_action }
			character = scope:first
			target = scope:second
			
			scope:first = {
				add_intrigue_lifestyle_xp = medium_lifestyle_xp
				
				progress_towards_hook_effect = {
					CHARACTER = scope:second
					HOOK_TYPE = manipulation_hook
				}
			}
			
			scope:second = {
				add_opinion = {
					target = scope:host
					modifier = flattered_opinion
					opinion = 10
				}
			}
		}
	}
}

ridiculed_food = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		OR = {
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_food
					option = feast_food_bad
				}
			}
			AND = {
				has_activity_type = activity_feast
				has_activity_option = {
					category = feast_option_food
					option = feast_food_normal
				}
			}
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			AND = {
				has_activity_type = activity_wedding
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			AND = {
				has_activity_type = activity_coronation
				has_current_phase = coronation_phase_feast
				OR = {
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_regular
					}
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_austere
					}
				}
			}
		}
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			NOR = {
				has_trait = inappetetic
				has_trait = temperate
				has_trait = loyal
			}
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_feast
					has_activity_option = {
						category = feast_option_food
						option = feast_food_normal
					}
				}
			}
			add = -0.75
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_wedding
					has_activity_option = {
						category = wedding_option_food
						option = wedding_food_normal
					}
				}
			}
			add = -0.75
		}
		if = {
			limit = {
				scope:activity = {
					has_activity_type = activity_coronation
					has_activity_option = {
						category = ceremony_feast_type
						option = ceremony_feast_type_regular
					}
				}
			}
			add = -0.75
		}
	}

	effect = {
		scope:host = {
			save_scope_as = root_scope
		}
		
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				NOR = {
					has_trait = inappetetic
					has_trait = temperate
					has_trait = loyal
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = ridiculed_food
			tags = { pulse_action }
			character = scope:first
			
			scope:host = {
				add_prestige = minor_prestige_loss
			}
			scope:first = {
				add_opinion = {
					modifier = was_unimpressed_at_feast_opinion
					target = scope:host
					opinion = -10
				}
			}
		}
	}
}

guest_tells_fantastic_joke = {
	icon = public
	is_valid = {
		is_current_phase_active = yes
		coronation_feast_phase = yes # If Coronation, only in feast phase
		any_attending_character = {
			this != scope:host
			is_physically_able_ai_adult = yes
			location = scope:province
			OR = {
				has_court_position = court_jester_court_position
				AND = {
					aptitude:court_jester_court_position >= 2
					has_personality_extroverted_trigger = yes
					has_trait_levelheaded_trigger = no
				}
				aptitude:court_jester_court_position >= 4
			}
		}
	}

	weight = {
		value = 1
		if = {
			limit = {
				any_attending_character = {
					has_court_position = court_jester_court_position
				}
			}
			add = 0.5
		}
	}

	effect = {
		random_attending_character = {
			limit = {
				this != scope:host
				is_physically_able_ai_adult = yes
				location = scope:province
				OR = {
					has_court_position = court_jester_court_position
					AND = {
					aptitude:court_jester_court_position >= 2
						has_personality_extroverted_trigger = yes
						has_trait_levelheaded_trigger = no
					}
					aptitude:court_jester_court_position >= 4
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 5
					has_court_position = court_jester_court_position
				}
			}
			save_scope_as = first
		}

		add_activity_log_entry = {
			key = guest_tells_fantastic_joke
			tags = { pulse_action }
			character = scope:first
			
			scope:first = {
				add_prestige = medium_prestige_gain
			}
			
			every_attending_character = {
				custom = every_attending_guest
				add_stress = minor_stress_loss
			}
		}
	}
}
