﻿#######################
# ACTIVITY REWARDS
# by Chad Uhl
#######################
disburse_tournament_activity_rewards = {
	# for the loc
	save_scope_as = root_scope

	# Rewards based on amount of Contests
	if = {
		limit = {
			scope:activity = {
				num_phases > 5
			}
		}

		# Host Rewards
		# Prestige Gain
		if = {
			limit = {
				culture = { has_cultural_era_or_later = culture_era_high_medieval }
			}
			add_prestige = 1800
		}
		else = {
			add_prestige = 1500
		}
		dynasty = { add_dynasty_prestige = massive_dynasty_prestige_value }

		# Glory Hound Vassal Opinion
		every_vassal_or_below = {
			vassal_stance = glory_hound
			limit = {
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_glory_hound_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 25
			}
		}
		# Belligerent Vassal Opinion
		every_vassal_or_below = {
			limit = {
				has_vassal_stance = belligerent
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_belligerent_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 25
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				num_phases = 5
			}
		}
		# Host Rewards
		# Prestige Gain
		if = {
			limit = {
				culture = { has_cultural_era_or_later = culture_era_high_medieval }
			}
			add_prestige = 1500
		}
		else = {
			add_prestige = 1200
		}
		dynasty = { add_dynasty_prestige = major_dynasty_prestige_value }

		# Glory Hound Vassal Opinion
		every_vassal_or_below = {
			vassal_stance = glory_hound
			limit = {
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_glory_hound_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 20
			}
		}
		# Belligerent Vassal Opinion
		every_vassal_or_below = {
			limit = {
				has_vassal_stance = belligerent
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_belligerent_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 20
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				num_phases = 4
			}
		}
		dynasty = { add_dynasty_prestige = medium_dynasty_prestige_value }

		# Host Rewards
		# Prestige Gain
		if = {
			limit = {
				culture = { has_cultural_era_or_later = culture_era_high_medieval }
			}
			add_prestige = 1200
		}
		else = {
			add_prestige = 1000
		}

		# Glory Hound Vassal Opinion
		every_vassal_or_below = {
			vassal_stance = glory_hound
			limit = {
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_glory_hound_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 15
			}
		}
		# Belligerent Vassal Opinion
		every_vassal_or_below = {
			limit = {
				has_vassal_stance = belligerent
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_belligerent_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 15
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				num_phases = 3
			}
		}

		# Host Rewards
		# Prestige Gain
		if = {
			limit = {
				culture = { has_cultural_era_or_later = culture_era_high_medieval }
			}
			add_prestige = 1000
		}
		else = {
			add_prestige = 800
		}

		# Glory Hound Vassal Opinion
		every_vassal_or_below = {
			vassal_stance = glory_hound
			limit = {
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_glory_hound_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 10
			}
		}
		# Belligerent Vassal Opinion
		every_vassal_or_below = {
			limit = {
				has_vassal_stance = belligerent
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_belligerent_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 10
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				num_phases = 2
				OR = {
					has_activity_option = {
						category = tournament_option_accommodations
						option = tournament_accommodations_good
					}
					has_activity_option = {
						category = tournament_option_accommodations
						option = tournament_accommodations_normal
					}
				}
			}
		}

		# Host Rewards
		# Prestige Gain
		if = {
			limit = {
				culture = { has_cultural_era_or_later = culture_era_high_medieval }
			}
			add_prestige = 800
		}
		else = {
			add_prestige = 600
		}

		# Glory Hound Vassal Opinion
		every_vassal_or_below = {
			vassal_stance = glory_hound
			limit = {
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_glory_hound_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 5
			}
		}
		# Belligerent Vassal Opinion
		every_vassal_or_below = {
			limit = {
				has_vassal_stance = belligerent
				is_participant_in_activity = scope:activity
			}
			custom = every_participating_belligerent_vassal
			add_opinion = {
				modifier = hosted_tournament_opinion
				target = root
				opinion = 5
			}
		}
	}
	else = { # 2 phases, bad accommodation
		# Host Rewards
		# Prestige Gain
		if = {
			limit = {
				culture = { has_cultural_era_or_later = culture_era_high_medieval }
			}
			add_prestige = 600
		}
		else = {
			add_prestige = 400
		}
	}
	# Add some bonuses from accolades.
	accolades_development_growth_for_least_developed_county_effect = yes

	scope:activity = {
		if = {
			limit = {
				scope:activity = {
					num_phases > 2
				}
			}
			activity_location = {
				add_province_modifier = {
					modifier = tournament_men_at_arms_reward_modifier
					years = 10
				}
			}
		}
		## Distribute glory to our _lucky winners_.
		every_guest_subset = {
			name = winner
			limit = {
				NOT = { scope:melee_winner ?= this }
				accolade ?= { is_accolade_active = yes }
			}
			custom = tournament_accolade_winner_tt
			accolade = {
				# For a bit of nuance, we want glory to be relative to how big the Tourney is. A less magnificent tourney is less glorious to win, after all.
				## Great stonking gads of glory.
				## High glory.
				if = {
					limit = {
						scope:activity = {
							num_phases > 4
						}
					}
					add_glory = monumental_glory_gain
				}
				## Moderate glory.
				else_if = {
					limit = {
						scope:activity = {
							num_phases > 3
						}
					}
					add_glory = massive_glory_gain
				}
				## Low glory.
				else_if = {
					limit = {
						scope:activity = {
							num_phases > 2
						}
					}
					add_glory = major_glory_gain
				}
				## Otherwise... well otherwise I don't even know how this qualified as *grand*.
				else = { add_glory = medium_glory_gain }
			}
		}
		## Plus, some consolation glory for every participant.
		every_guest_subset = {
			name = qualified
			limit = {
				save_temporary_scope_as = new_list_member_temp
				NOT = {
					scope:activity = {
						any_guest_subset = {
							name = winner
							this = scope:new_list_member_temp
						}
					}
				}
				accolade ?= { is_accolade_active = yes }
			}
			custom = tournament_accolade_qualified_tt
			accolade = { add_glory = minor_glory_gain }
		}
		# accolade bonus xp for the Contender
		every_attending_character = {
			limit = {
				is_acclaimed = yes
				accolade = {
					is_accolade_active = yes
					OR = {
						has_accolade_parameter = accolade_tournament_xp_gain_contender_only_low
						has_accolade_parameter = accolade_tournament_xp_gain_contender_only
						has_accolade_parameter = accolade_tournament_xp_gain_contender_only_high
					}
				}
			}
			save_scope_as = contender
			accolades_contender_tournament_xp_gain_effect = yes
		}
		# accolade trait xp for all knights who hang with a Contender
		every_attending_character = {
			limit = {
				# Does the knight have a comrade with this bonus?
				exists = liege
				is_knight = yes
				liege = {
					any_active_accolade = {
						OR = {
							has_accolade_parameter = accolade_tournament_xp_gain_all_knights
							has_accolade_parameter = accolade_tournament_xp_gain_all_knights_high
						}
					}
				}
				# Can the knight get it? Or get it the self-training one?
				NAND = {
					is_acclaimed = yes
					accolade = {
						has_accolade_type = contender_attribute
					}
				}
			}
			custom = tournament_accolade_attendees_tt
			accolades_all_knights_liege_tournament_xp_gain_effect = yes
		}
	}

	# If character had the reduce stress intent, give them stress loss
	disburse_activity_stress_loss = yes
}

disburse_tour_activity_rewards = {
	# for the loc
	save_scope_as = root_scope

	# Rewards based on Magnficence level
	# Rewards based on Tour Type are handed out at the end of each stop

	# Success rewards (includes Magnificence points)
	# Max 50 points: 25 Magnificence levels + 25 from events
	#Level 5
	if = {
		limit = {
			var:tour_success_var >= 100
		}
		custom_tooltip = level_5_reward_tt
		scope:activity = {
			add_activity_log_entry = {
				key = level_5_reward_tt
				tags = { good major completed }
				show_in_conclusion = yes
				character = scope:root_scope

				# Effects
				root = {
					add_character_modifier = { #10 years
						modifier = mega_itinerant_liege_modifier
						years = 20
					}
					add_prestige = tour_level_5_prestige_reward
					if = {
						limit = {
							OR = {
								this.dynasty.dynast ?= this
								is_ai = no
							}
						}
						dynasty ?= { add_dynasty_prestige = major_dynasty_prestige_gain }
					}
					# Parochial Vassal Opinion
					every_vassal_or_below = {
						vassal_stance = parochial
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_participating_parochial_vassal
						add_opinion = {
							modifier = hosted_tour_opinion
							target = root
							opinion = 50
						}
					}
				}
				# Increase Vassal Opinion
				every_in_list = {
					variable = tour_visited_vassals
					custom = every_visited_vassal
					limit = {
						is_alive = yes
					}
					add_opinion = {
						modifier = tour_visited_vassal_opinion
						target = root
						opinion = 30
					}
				}
			}
		}
		create_character_memory = {
			type = legendary_tour
		}
	}
	#Level 4
	else_if = {
		limit = {
			var:tour_success_var >= 80
		}
		custom_tooltip = level_4_reward_tt
		scope:activity = {
			add_activity_log_entry = {
				key = level_4_reward_tt
				tags = { good major completed }
				show_in_conclusion = yes
				character = scope:root_scope

				# Effects
				root = {
					add_character_modifier = { #10 years
						modifier = itinerant_liege_modifier
						years = 20
					}
					add_prestige = tour_level_4_prestige_reward
					if = {
						limit = {
							OR = {
								this.dynasty.dynast ?= this
								is_ai = no
							}
						}
						dynasty ?= { add_dynasty_prestige = major_dynasty_prestige_gain }
					}
					# Parochial Vassal Opinion
					every_vassal_or_below = {
						vassal_stance = parochial
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_participating_parochial_vassal
						add_opinion = {
							modifier = hosted_tour_opinion
							target = root
							opinion = 40
						}
					}
				}

				# Increase Vassal Opinion
				every_in_list = {
					variable = tour_visited_vassals
					custom = every_visited_vassal
					limit = {
						is_alive = yes
					}
					add_opinion = {
						modifier = tour_visited_vassal_opinion
						target = root
						opinion = 25
					}
				}
			}
		}
		create_character_memory = {
			type = good_tour
		}
	}
	#Level 3
	else_if = {
		limit = {
			var:tour_success_var >= 60
		}
		custom_tooltip = level_3_reward_tt

		scope:activity = {
			add_activity_log_entry = {
				key = level_3_reward_tt
				tags = { good major completed }
				show_in_conclusion = yes
				character = scope:root_scope

				# Effects
				root = {
					add_prestige = tour_level_3_prestige_reward
					if = {
						limit = {
							OR = {
								this.dynasty.dynast ?= this
								is_ai = no
							}
						}
						dynasty ?= { add_dynasty_prestige = medium_dynasty_prestige_gain }
					}
					# Parochial Vassal Opinion
					every_vassal_or_below = {
						vassal_stance = parochial
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_participating_parochial_vassal
						add_opinion = {
							modifier = hosted_tour_opinion
							target = root
							opinion = 35
						}
					}
				}

				# Increase Vassal Opinion
				scope:activity = {
					every_in_list = {
						variable = tour_visited_vassals
						custom = every_visited_vassal
						limit = {
							is_alive = yes
						}
						add_opinion = {
							modifier = tour_visited_vassal_opinion
							target = root
							opinion = 20
						}
					}
				}
			}
		}
		create_character_memory = {
			type = good_tour
		}
	}
	#Level 2
	else_if = {
		limit = {
			var:tour_success_var >= 40
		}
		custom_tooltip = level_2_reward_tt

		scope:activity = {
			add_activity_log_entry = {
				key = level_2_reward_tt
				tags = { good major completed }
				show_in_conclusion = yes
				character = scope:root_scope

				# Effects
				root = {
					add_prestige = tour_level_2_prestige_reward
					if = {
						limit = {
							OR = {
								this.dynasty.dynast ?= this
								is_ai = no
							}
						}
						dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
					}
					# Parochial Vassal Opinion
					every_vassal_or_below = {
						vassal_stance = parochial
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_participating_parochial_vassal
						add_opinion = {
							modifier = hosted_tour_opinion
							target = root
							opinion = 30
						}
					}
				}
			}
		}
		create_character_memory = {
			type = good_tour
		}
	}
	#Level 1
	else_if = {
		limit = {
			var:tour_success_var >= 20
		}
		custom_tooltip = level_1_reward_tt

		scope:activity = {
			add_activity_log_entry = {
				key = level_1_reward_tt
				tags = { good major completed }
				show_in_conclusion = yes
				character = scope:root_scope

				# Effects
				root = {
					add_prestige = tour_level_1_prestige_reward
				}
			}
		}
		create_character_memory = {
			type = underwhelming_tour
		}
	}

	# No reward - var < 20
	else = {
		custom_tooltip = failed_to_get_reward_tt

		scope:activity = {
			add_activity_log_entry = {
				key = failed_to_get_reward_tt
				tags = { good major completed }
				show_in_conclusion = yes
				character = scope:root_scope

				# Effects
				root = {
					add_prestige = 200 #pity prize
				}
			}
		}
		create_character_memory = {
			type = underwhelming_tour
		}
	}
	# If character had the reduce stress intent, give them stress loss
	disburse_activity_stress_loss = yes
	# Accolade - politicker attribute reward modifier
	add_character_modifier = {
		modifier = dutiful_realm_knights_modifier
		years = 10
	}

	# Glory management.
	## We want to toss out a little glory to knights who go socialize and make themselves known
	accolades_activity_complete_tour_glory_effect = yes
	# LEGITIMACY GAIN FOR GRAND ACTIVITY PARTICIPATION - TOUR
	grand_activity_participation_legitimacy_effect = yes
}

disburse_witch_ritual_host_rewards_effect = {
	scope:activity = {
		add_activity_log_entry = {
			key = host_witch_ritual
			tags = { completed }
			# this line below adds the entry to the Effects section of the conclusion UI
			show_in_conclusion = yes
			character = scope:host

			scope:host = {
				add_stress = major_stress_loss
			}
		}
	}
}

disburse_murder_wedding_host_rewards = {
	# for the loc
	save_scope_as = root_scope
	if = {
		limit = {
			has_variable = murder_feast_liege_var
		}
		add_prestige_level = -3
	}
	if = {
		limit = {
			has_variable = murder_feast_head_of_faith_var
		}
		add_piety_level = -3
	}
	if = {
		limit = {
			culture = { #if this is a cultural thing, people don't really love it
				has_cultural_tradition = tradition_wedding_ceremonies
			}
		}
		add_prestige = major_prestige_loss
	}
	if = {
		limit = {
			faith = { #if this is a religious thing, people don't really love it
				has_doctrine = tenet_ritual_celebrations
			}
		}
		add_piety = major_piety_loss
	}
	if = {
		limit = { has_variable = bloody_wedding_murder_family_var } #you've killed EVERYONE
		if = {
			limit = {
				faith = { #if you can get excommunicated by kinslaying we do so
					has_doctrine_parameter = excommunication_active
					NOR = {
						has_doctrine = doctrine_kinslaying_accepted
						has_doctrine = doctrine_kinslaying_shunned
					}
				}
			}
			add_trait_force_tooltip = excommunicated
			scope:activity = {
				add_activity_log_entry = {
					key = host_bloody_wedding_excommunication
					tags = { completed }
					show_in_conclusion = yes
					character = scope:host

					scope:host = {
						add_excommunication_actual_effect_5_years_version = yes
					}
				}
			}
		}
		else = {
			add_piety_level = -1
		}
		scope:activity = {
			add_activity_log_entry = {
				key = host_bloody_wedding_family_kill
				tags = { completed }
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:host

				scope:host = {
					add_dread = monumental_dread_gain
					add_legitimacy = major_legitimacy_loss
					add_character_modifier = {
						modifier = gwedding_hosted_murder_wedding_modifier
						years = 15
					}
					set_variable = just_widowed_var
				}
			}
		}
	}
	else = { #Rewards for a "normal" feast
		if = { #if you failed your attempt it doesn't look great
			limit = { has_variable = bloody_murder_fail }
			add_legitimacy = minor_legitimacy_loss
			add_prestige = minor_prestige_loss
			if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = wedding_option_entertainment
							option = wedding_entertainment_good
						}
					}
				}
				custom_tooltip = host_wedding_entertainment_good
				scope:activity = {
					add_activity_log_entry = {
						key = host_wedding_entertainment_good
						tags = { completed }
						score = 100
						# this line below adds the entry to the Effects section of the conclusion UI
						show_in_conclusion = yes
						character = scope:host

						scope:host = {
							add_prestige = minor_prestige_gain
						}
						every_attending_character = {
							limit = {
								NOR = {
									this = scope:host
									this = scope:spouse_1
								}
							}
							custom = custom.every_activity_guest
							add_prestige = minor_prestige_gain
						}
					}
				}
			}
			else_if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = wedding_option_entertainment
							option = wedding_entertainment_normal
						}
					}
				}
				custom_tooltip = host_wedding_entertainment_normal
				scope:activity = {
					add_activity_log_entry = {
						key = host_wedding_entertainment_normal
						tags = { completed }
						score = 100
						# this line below adds the entry to the Effects section of the conclusion UI
						show_in_conclusion = yes
						character = scope:root_scope

						scope:host = { add_prestige = miniscule_prestige_gain }
					}
				}
			}

			# Food
			if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = wedding_option_food
							option = wedding_food_good
						}
					}
				}
				custom_tooltip = host_wedding_food_good
				scope:activity = {
					add_activity_log_entry = {
						key = host_wedding_food_good
						tags = { completed }
						score = 100
						# this line below adds the entry to the Effects section of the conclusion UI
						show_in_conclusion = yes
						character = scope:host

						every_attending_character = {
							limit = { this != scope:host }
							custom = custom.every_attending_character
							add_opinion = {
								target = scope:host
								modifier = impressed_opinion
								opinion = 10
							}
						}
						every_attending_character = {
							limit = {
								NOR = {
									this = scope:host
									this = scope:spouse_1
								}
							}
							custom = custom.every_activity_guest
							# Guest opinion from host and spouses
							if = {
								limit = {
									scope:host = { is_ai = yes }
								}
								custom_tooltip = came_to_my_wedding_opinion_host_high
								hidden_effect = {
									reverse_add_opinion = {
										target = scope:host
										modifier = came_to_my_wedding_opinion
										opinion = 5
									}
								}
							}
							if = {
								limit = {
									scope:spouse_1 = { is_ai = yes }
								}
								custom_tooltip = came_to_my_wedding_opinion_spouse_1_high
								hidden_effect = {
									reverse_add_opinion = {
										target = scope:spouse_1
										modifier = came_to_my_wedding_opinion
										opinion = 5
									}
								}
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = wedding_option_food
							option = wedding_food_normal
						}
					}
				}
				custom_tooltip = host_wedding_food_normal
				scope:activity = {
					add_activity_log_entry = {
						key = host_wedding_food_normal
						tags = { completed }
						score = 100
						# this line below adds the entry to the Effects section of the conclusion UI
						show_in_conclusion = yes
						character = scope:host

						every_attending_character = {
							limit = { this != scope:host }
							custom = custom.every_attending_character
							add_opinion = {
								target = scope:host
								modifier = impressed_opinion
								opinion = 5
							}
						}
					}
				}
			}

			# Decoration
			if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = wedding_option_decoration
							option = wedding_decoration_good
						}
					}
				}
				custom_tooltip = host_wedding_decoration_good
				scope:activity = {
					add_activity_log_entry = {
						key = host_wedding_decoration_good
						tags = { completed }
						score = 100
						# this line below adds the entry to the Effects section of the conclusion UI
						show_in_conclusion = yes
						character = scope:host

						scope:host = {
							every_vassal_or_below = {
								vassal_stance = courtly
								custom = every_courtly_vassal
								add_opinion = {
									modifier = hosted_wedding_opinion
									target = root
									opinion = 10
								}
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = wedding_option_decoration
							option = wedding_decoration_normal
						}
					}
				}
				custom_tooltip = host_wedding_decoration_normal
				scope:activity = {
					add_activity_log_entry = {
						key = host_wedding_decoration_normal
						tags = { completed }
						score = 100
						# this line below adds the entry to the Effects section of the conclusion UI
						show_in_conclusion = yes
						character = scope:host

						root = {
							every_vassal_or_below = {
								vassal_stance = courtly
								custom = every_courtly_vassal
								add_opinion = {
									modifier = hosted_wedding_opinion
									target = root
									opinion = 5
								}
							}
						}
					}
				}
			}
		}
		else_if = { #if you've killed your target you get these
			limit = {
				NOT = { has_variable = bloody_murder_fail }
				NOT = { has_variable = bloody_wedding_murder_family_var }
			}
			scope:activity = {
				add_activity_log_entry = {
					key = host_bloody_wedding_solo_kill
					tags = { completed }
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:host

					scope:host = {
						add_dread = massive_dread_gain
						add_legitimacy = medium_legitimacy_loss
						add_character_modifier = {
							modifier = gwedding_hosted_murder_wedding_modifier
							years = 10
						}
						set_variable = just_widowed_var
					}
				}
			}
		}
		# Regular wedding hosting rewards - smaller
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = wedding_option_entertainment
						option = wedding_entertainment_good
					}
				}
			}
			custom_tooltip = host_wedding_entertainment_good
			scope:activity = {
				add_activity_log_entry = {
					key = host_wedding_entertainment_good
					tags = { completed }
					score = 100
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:host

					scope:host = { add_prestige = minor_prestige_gain }
					every_attending_character = {
						limit = {
							NOR = {
								this = scope:host
								this = scope:spouse_1
							}
						}
						custom = custom.every_activity_guest
						add_prestige = minor_prestige_gain
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = wedding_option_entertainment
						option = wedding_entertainment_normal
					}
				}
			}
			custom_tooltip = host_wedding_entertainment_normal
			scope:activity = {
				add_activity_log_entry = {
					key = host_wedding_entertainment_normal
					tags = { completed }
					score = 100
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:root_scope

					scope:host = { add_prestige = miniscule_prestige_gain }
				}
			}
		}

		# Food
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = wedding_option_food
						option = wedding_food_good
					}
				}
			}
			custom_tooltip = host_wedding_food_good
			scope:activity = {
				add_activity_log_entry = {
					key = host_wedding_food_good
					tags = { completed }
					score = 100
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:host

					every_attending_character = {
						limit = { this != scope:host }
						custom = custom.every_attending_character
						add_opinion = {
							target = scope:host
							modifier = impressed_opinion
							opinion = 10
						}
					}
					every_attending_character = {
						limit = {
							NOR = {
								this = scope:host
								this = scope:spouse_1
							}
						}
						custom = custom.every_activity_guest
						# Guest opinion from host and spouses
						if = {
							limit = {
								scope:host = { is_ai = yes }
							}
							custom_tooltip = came_to_my_wedding_opinion_host_high
							hidden_effect = {
								reverse_add_opinion = {
									target = scope:host
									modifier = came_to_my_wedding_opinion
									opinion = 5
								}
							}
						}
						if = {
							limit = {
								scope:spouse_1 = { is_ai = yes }
							}
							custom_tooltip = came_to_my_wedding_opinion_spouse_1_high
							hidden_effect = {
								reverse_add_opinion = {
									target = scope:spouse_1
									modifier = came_to_my_wedding_opinion
									opinion = 5
								}
							}
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = wedding_option_food
						option = wedding_food_normal
					}
				}
			}
			custom_tooltip = host_wedding_food_normal
			scope:activity = {
				add_activity_log_entry = {
					key = host_wedding_food_normal
					tags = { completed }
					score = 100
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:host

					every_attending_character = {
						limit = { this != scope:host }
						custom = custom.every_attending_character
						add_opinion = {
							target = scope:host
							modifier = impressed_opinion
							opinion = 5
						}
					}
				}
			}
		}

		# Decoration
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = wedding_option_decoration
						option = wedding_decoration_good
					}
				}
			}
			custom_tooltip = host_wedding_decoration_good
			scope:activity = {
				add_activity_log_entry = {
					key = host_wedding_decoration_good
					tags = { completed }
					score = 100
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:host

					scope:host = {
						every_vassal_or_below = {
							vassal_stance = courtly
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_wedding_opinion
								target = root
								opinion = 10
							}
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = wedding_option_decoration
						option = wedding_decoration_normal
					}
				}
			}
			custom_tooltip = host_wedding_decoration_normal
			scope:activity = {
				add_activity_log_entry = {
					key = host_wedding_decoration_normal
					tags = { completed }
					score = 100
					# this line below adds the entry to the Effects section of the conclusion UI
					show_in_conclusion = yes
					character = scope:host

					root = {
						every_vassal_or_below = {
							vassal_stance = courtly
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_wedding_opinion
								target = root
								opinion = 5
							}
						}
					}
				}
			}
		}
	}
	# # Vassal Opinion
	every_vassal_or_below = {
		limit = {
			OR = {
				has_trait = torturer
				has_trait = sadistic
				has_trait = vengeful
				has_trait = callous
			}
		}
		custom = every_cruel_vassal
		add_opinion = {
			modifier = respect_opinion
			target = scope:host
			opinion = 20
		}
	}
	every_vassal_or_below = {
		limit = {
			NOR = {
				has_trait = torturer
				has_trait = sadistic
				has_trait = vengeful
				has_trait = callous
			}
		}
		custom = wedding_every_other_vassal
		add_opinion = {
			modifier = suspicion_opinion
			target = scope:host
			opinion = -25
		}
	}

	# Accolade glory gain
	accolades_activity_complete_wedding_glory_effect = yes
}

disburse_wedding_activity_rewards = {
	# for the loc
	save_scope_as = root_scope

	scope:activity = {
		### Rewards based on Options
		# Entertainment
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_good
				}
			}
			add_activity_log_entry = {
				key = host_wedding_entertainment_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				root = { add_prestige = 900 }
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
				 	add_prestige = major_prestige_gain
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_normal
				}
			}
			add_activity_log_entry = {
				key = host_wedding_entertainment_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				root = { add_prestige = 600 }
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
				 	add_prestige = medium_prestige_gain
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_bad
				}
			}
			add_activity_log_entry = {
				key = host_wedding_entertainment_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				root = { add_prestige = 300 }
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
				 	add_prestige = minor_prestige_gain
				}
			}
		}

		# Food
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_good
				}
			}
			add_activity_log_entry = {
				key = host_wedding_food_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				every_attending_character = {
					limit = { this != root }
					custom = custom.every_activity_guest
					add_opinion = {
						target = root
						modifier = impressed_opinion
						opinion = 30
					}
				}
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
					# Guest opinion from host and spouses
					if = {
						limit = {
							scope:host = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_host_high
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:host
								modifier = came_to_my_wedding_opinion
								opinion = 15
							}
						}
					}
					if = {
						limit = {
							scope:spouse_1 = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_spouse_1_high
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:spouse_1
								modifier = came_to_my_wedding_opinion
								opinion = 15
							}
						}
					}
					if = {
						limit = {
							scope:spouse_2 = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_spouse_2_high
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:spouse_2
								modifier = came_to_my_wedding_opinion
								opinion = 15
							}
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			add_activity_log_entry = {
				key = host_wedding_food_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				every_attending_character = {
					limit = { this != root }
					custom = custom.every_activity_guest
					add_opinion = {
						target = root
						modifier = impressed_opinion
						opinion = 20
					}
				}
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
					# Opinion from host and spouses
					if = {
						limit = {
							scope:host = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_host_medium
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:host
								modifier = came_to_my_wedding_opinion
								opinion = 10
							}
						}
					}
					if = {
						limit = {
							scope:spouse_1 = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_spouse_1_medium
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:spouse_1
								modifier = came_to_my_wedding_opinion
								opinion = 10
							}
						}
					}
					if = {
						limit = {
							scope:spouse_2 = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_spouse_2_medium
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:spouse_2
								modifier = came_to_my_wedding_opinion
								opinion = 10
							}
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			add_activity_log_entry = {
				key = host_wedding_food_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				every_attending_character = {
					limit = { this != root }
					custom = custom.every_activity_guest
					add_opinion = {
						target = root
						modifier = impressed_opinion
						opinion = 5
					}
				}
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
					# Opinion from host and spouses
					if = {
						limit = {
							scope:host = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_host_low
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:host
								modifier = came_to_my_wedding_opinion
								opinion = 5
							}
						}
					}
					if = {
						limit = {
							scope:spouse_1 = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_spouse_1_low
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:spouse_1
								modifier = came_to_my_wedding_opinion
								opinion = 5
							}
						}
					}
					if = {
						limit = {
							scope:spouse_2 = { is_ai = yes }
						}
						custom_tooltip = came_to_my_wedding_opinion_spouse_2_low
						hidden_effect = {
							reverse_add_opinion = {
								target = scope:spouse_2
								modifier = came_to_my_wedding_opinion
								opinion = 5
							}
						}
					}
				}
			}
		}

		# Decoration
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_good
				}
			}
			add_activity_log_entry = {
				key = host_wedding_decoration_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				root = {
					add_character_modifier = {
						modifier = gwedding_magnificent_host_modifier
						years = 20
					}
					if = {
						limit = {
							any_vassal_or_below = {
								vassal_stance = courtly
							}
						}
						every_vassal_or_below = {
							vassal_stance = courtly
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_wedding_opinion
								target = root
								opinion = 30
							}
						}
					}
				}
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
					}
					custom = custom.every_activity_guest
					add_character_modifier = {
						modifier = wedding_of_the_century_modifier
						years = 20
					}
					if = {
						limit = {
							has_trait = lifestyle_reveler
						}
						add_trait_xp = {
							trait = lifestyle_reveler
							value = 10
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_normal
				}
			}
			add_activity_log_entry = {
				key = host_wedding_decoration_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				root = {
					add_character_modifier = {
						modifier = gwedding_gracious_host_modifier
						years = 20
					}
					if = {
						limit = {
							any_vassal_or_below = {
								vassal_stance = courtly
							}
						}
						every_vassal_or_below = {
							vassal_stance = courtly
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_wedding_opinion
								target = root
								opinion = 20
							}
						}
					}
				}
				every_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							this = scope:spouse_1
							this = scope:spouse_2
						}
						has_trait = lifestyle_reveler
					}
					custom = custom.every_activity_guest
					add_trait_xp = {
						trait = lifestyle_reveler
						value = 5
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_bad
				}
			}
			add_activity_log_entry = {
				key = host_wedding_decoration_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				root = {
					if = {
						limit = {
							has_trait = lifestyle_reveler
						}
						add_trait_xp = {
							trait = lifestyle_reveler
							value = 10
						}
					}
					else = {
						add_trait = lifestyle_reveler
					}
					if = {
						limit = {
							any_vassal_or_below = {
								vassal_stance = courtly
							}
						}
						every_vassal_or_below = {
							vassal_stance = courtly
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_wedding_opinion
								target = root
								opinion = 5
							}
						}
					}
				}
				scope:activity = {
					every_attending_character = {
						limit = {
							NOR = {
								this = scope:host
								this = scope:spouse_1
								this = scope:spouse_2
							}
							has_trait = lifestyle_reveler
						}
						custom = custom.every_activity_guest
						add_trait_xp = {
							trait = lifestyle_reveler
							value = 3
						}
					}
				}
			}
		}
	}

	# Bonuses for location
	if = {
		limit = {
			scope:wedding_venue = {
				OR = {
					has_building_or_higher = royal_garden_01
					has_building_or_higher = leisure_palace_01
					barony = { is_holy_site_of = scope:host.faith }
					barony = { is_holy_site_of = scope:spouse_1.faith }
					barony = { is_holy_site_of = scope:spouse_2.faith }
					this = scope:host.capital_province
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = host_wedding_venue
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope

				if = {
					limit = {
						OR = {
							scope:wedding_venue = { has_building_or_higher = royal_garden_03 }
							scope:wedding_venue = { has_building_or_higher = leisure_palace_03 }
						}
					}
					root = {
						stress_impact = {
							base = massive_stress_impact_loss
						}
						dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
					}
				}
				else_if = {
					limit = {
						OR = {
							scope:wedding_venue = { has_building_or_higher = royal_garden_02 }
							scope:wedding_venue = { has_building_or_higher = leisure_palace_02 }
						}
					}
					root = {
						stress_impact = {
							base = major_stress_impact_loss
						}
						dynasty ?= { add_dynasty_prestige = miniscule_dynasty_prestige_gain }
					}
				}
				else_if = {
					limit = {
						OR = {
							scope:wedding_venue = { has_building_or_higher = royal_garden_01 }
							scope:wedding_venue = { has_building_or_higher = leisure_palace_01 }
						}
					}
					root = {
						stress_impact = {
							base = medium_stress_impact_loss
						}
						dynasty ?= { add_dynasty_prestige = 10 }
					}
				}
				if = {
					limit = {
						scope:wedding_venue = {
							barony = { is_holy_site_of = scope:host.faith }
						}
					}
					root = {
						add_piety = major_piety_gain
					}
				}
				if = {
					limit = {
						scope:wedding_venue = {
							this = root.capital_province
						}
					}
					# Replace marriage_effect.2001
					root = {
						add_gold = minor_gold_value
					}
				}
				if = {
					limit = {
						scope:wedding_venue.barony = { is_holy_site_of = scope:spouse_1.faith }
					}
					scope:spouse_1 = { add_piety = massive_piety_gain }
				}
				if = {
					limit = {
						scope:wedding_venue.barony = { is_holy_site_of = scope:spouse_2.faith }
					}
					scope:spouse_2 = { add_piety = massive_piety_gain }
				}
			}
		}
	}

	# If character had the reduce stress intent, give them stress loss
	root = { disburse_activity_stress_loss = yes }
	scope:activity = {
		every_attending_character = {
			limit = {
				NOR = {
					this = scope:host
					this = scope:spouse_1
					this = scope:spouse_2
				}
			}
			custom = custom.every_activity_guest
			disburse_activity_stress_loss = yes
		}
	}

	# Accolade glory gain
	accolades_activity_complete_wedding_glory_effect = yes
}

disburse_wedding_spouse_activity_rewards = {
	# for the loc
	save_scope_as = root_scope
	if = {
		limit = {
			this = scope:spouse_1
		}
		scope:spouse_2 = { save_scope_as = other_spouse }
	}
	else_if = {
		limit = {
			this = scope:spouse_2
		}
		scope:spouse_1 = { save_scope_as = other_spouse }
	}

	scope:activity = {
		### Rewards based on Options
		# Entertainment
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_good
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_entertainment_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = { add_prestige = 800 }
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_normal
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_entertainment_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = { add_prestige = 600 }
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_bad
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_entertainment_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = { add_prestige = 400 }
			}
		}

		# Food
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_good
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_food_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:activity = {
					every_attending_character = {
						limit = {
							NOR = {
								this = scope:root_scope
								this = scope:host
								this = scope:other_spouse
							}
						}
						custom = custom.every_activity_guest
						add_opinion = {
							target = scope:root_scope
							modifier = impressed_opinion
							opinion = 25
						}
					}
				}
				scope:root_scope = {
					if = {
						limit = {
							has_trait = lifestyle_reveler
						}
						add_trait_xp = {
							trait = lifestyle_reveler
							value = 15
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_food_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:activity = {
					every_attending_character = {
						limit = {
							NOR = {
								this = scope:root_scope
								this = scope:host
								this = scope:other_spouse
							}
						}
						custom = custom.every_activity_guest
						add_opinion = {
							target = scope:root_scope
							modifier = impressed_opinion
							opinion = 15
						}
					}
				}
				scope:root_scope = {
					if = {
						limit = {
							has_trait = lifestyle_reveler
						}
						add_trait_xp = {
							trait = lifestyle_reveler
							value = 7
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_food_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:activity = {
					every_attending_character = {
						limit = {
							NOR = {
								this = scope:root_scope
								this = scope:host
								this = scope:other_spouse
							}
						}
						custom = custom.every_activity_guest
						add_opinion = {
							target = scope:root_scope
							modifier = impressed_opinion
							opinion = 5
						}
					}
				}
				scope:root_scope = {
					if = {
						limit = {
							has_trait = lifestyle_reveler
						}
						add_trait_xp = {
							trait = lifestyle_reveler
							value = 3
						}
					}
				}
			}
		}

		# Decoration
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_good
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_decoration_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = {
					add_character_modifier = {
						modifier = gwedding_magnificent_wedding_modifier
						years = 20
					}
					dynasty ?= {
						add_dynasty_prestige = medium_dynasty_prestige_gain
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_normal
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_decoration_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = {
					add_character_modifier = {
						modifier = gwedding_grandiose_wedding_modifier
						years = 20
					}
					dynasty ?= {
						add_dynasty_prestige = minor_dynasty_prestige_gain
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_bad
				}
			}
			add_activity_log_entry = {
				key = spouse_wedding_decoration_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = {
					add_character_modifier = {
						modifier = gwedding_grand_wedding_modifier
						years = 20
					}
					dynasty ?= {
						add_dynasty_prestige = miniscule_dynasty_prestige_gain
					}
				}
			}
		}
	}

	# If character had the reduce stress intent, give them stress loss
	disburse_activity_stress_loss = yes

	# LEGITIMACY GAIN FOR GRAND ACTIVITY PARTICIPATION - WEDDING
	grand_activity_participation_legitimacy_effect = yes
}

tooltip_disburse_wedding_host_activity_rewards = {
	scope:activity = {
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_good
				}
			}
			root = { add_prestige = 1200 }
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_normal
				}
			}
			root = { add_prestige = 800 }
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_bad
				}
			}
			root = { add_prestige = 400 }
		}
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_good
				}
			}
			every_attending_character = {
				limit = { this != root }
				custom = custom.every_activity_guest
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 30
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			every_attending_character = {
				limit = { this != root }
				custom = custom.every_activity_guest
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 20
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			every_attending_character = {
				limit = { this != root }
				custom = custom.every_activity_guest
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 5
				}
			}
		}
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_good
				}
			}
			root = {
				add_character_modifier = {
					modifier = gwedding_magnificent_host_modifier
					years = 20
				}
				if = {
					limit = {
						any_vassal_or_below = {
							vassal_stance = courtly
						}
					}
					every_vassal_or_below = {
						vassal_stance = courtly
						custom = every_courtly_vassal
						add_opinion = {
							modifier = hosted_wedding_opinion
							target = root
							opinion = 30
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_normal
				}
			}
			root = {
				add_character_modifier = {
					modifier = gwedding_gracious_host_modifier
					years = 20
				}
				if = {
					limit = {
						any_vassal_or_below = {
							vassal_stance = courtly
						}
					}
					every_vassal_or_below = {
						vassal_stance = courtly
						custom = every_courtly_vassal
						add_opinion = {
							modifier = hosted_wedding_opinion
							target = root
							opinion = 20
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_bad
				}
			}
			root = {
				if = {
					limit = {
						has_trait = lifestyle_reveler
					}
					add_trait_xp = {
						trait = lifestyle_reveler
						value = 10
					}
				}
				else = {
					add_trait = lifestyle_reveler
				}
				if = {
					limit = {
						any_vassal_or_below = {
							vassal_stance = courtly
						}
					}
					every_vassal_or_below = {
						vassal_stance = courtly
						custom = every_courtly_vassal
						add_opinion = {
							modifier = hosted_wedding_opinion
							target = root
							opinion = 5
						}
					}
				}
			}
		}
		if = {
			limit = {
				OR = {
					scope:wedding_venue = { has_building_or_higher = royal_garden_03 }
					scope:wedding_venue = { has_building_or_higher = leisure_palace_03 }
				}
			}
			root = {
				stress_impact = {
					base = massive_stress_impact_loss
				}
				dynasty ?= { add_dynasty_prestige = minor_dynasty_prestige_gain }
			}
		}
		else_if = {
			limit = {
				OR = {
					scope:wedding_venue = { has_building_or_higher = royal_garden_02 }
					scope:wedding_venue = { has_building_or_higher = leisure_palace_02 }
				}
			}
			root = {
				stress_impact = {
					base = major_stress_impact_loss
				}
				dynasty ?= { add_dynasty_prestige = miniscule_dynasty_prestige_gain }
			}
		}
		else_if = {
			limit = {
				OR = {
					scope:wedding_venue = { has_building_or_higher = royal_garden_01 }
					scope:wedding_venue = { has_building_or_higher = leisure_palace_01 }
				}
			}
			root = {
				stress_impact = {
					base = medium_stress_impact_loss
				}
				dynasty ?= { add_dynasty_prestige = 10 }
			}
		}
		if = {
			limit = {
				scope:wedding_venue = {
					barony = { is_holy_site_of = scope:host.faith }
				}
			}
			root = {
				add_piety = major_piety_gain
			}
		}
		if = {
			limit = {
				scope:wedding_venue = {
					this = root.capital_province
				}
			}
			# Replace marriage_effect.2001
			root = {
				add_gold = minor_gold_value
			}
		}
	}
	# If character had the reduce stress intent, give them stress loss
	root = { disburse_activity_stress_loss = yes }

	# Accolade glory gain
	accolades_activity_complete_wedding_glory_effect = yes

	# LEGITIMACY GAIN FOR GRAND ACTIVITY PARTICIPATION - WEDDING
	grand_activity_participation_legitimacy_effect = yes
}

tooltip_disburse_wedding_guest_activity_rewards = {
	scope:activity = {
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_good
				}
			}
			root = { add_prestige = major_prestige_gain }
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_normal
				}
			}
			root = { add_prestige = medium_prestige_gain }
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_entertainment
					option = wedding_entertainment_bad
				}
			}
			root = { add_prestige = minor_prestige_gain }
		}
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_good
				}
			}
			if = {
				limit = {
					scope:host = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_host_high
			}
			if = {
				limit = {
					scope:spouse_1 = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_spouse_1_high
			}
			if = {
				limit = {
					scope:spouse_2 = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_spouse_2_high
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_normal
				}
			}
			if = {
				limit = {
					scope:host = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_host_medium
			}
			if = {
				limit = {
					scope:spouse_1 = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_spouse_1_medium
			}
			if = {
				limit = {
					scope:spouse_2 = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_spouse_2_medium
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_food
					option = wedding_food_bad
				}
			}
			if = {
				limit = {
					scope:host = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_host_low
			}
			if = {
				limit = {
					scope:spouse_1 = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_spouse_1_low
			}
			if = {
				limit = {
					scope:spouse_2 = { is_ai = yes }
				}
				custom_tooltip = came_to_my_wedding_opinion_spouse_2_low
			}
		}
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_good
				}
			}
			root = {
				add_character_modifier = {
					modifier = wedding_of_the_century_modifier
					years = 20
				}
				if = {
					limit = {
						has_trait = lifestyle_reveler
					}
					add_trait_xp = {
						trait = lifestyle_reveler
						value = 10
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_normal
				}
			}
			root = {
				if = {
					limit = {
						has_trait = lifestyle_reveler
					}
					add_trait_xp = {
						trait = lifestyle_reveler
						value = 5
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_bad
				}
			}
			root = {
				if = {
					limit = {
						has_trait = lifestyle_reveler
					}
					add_trait_xp = {
						trait = lifestyle_reveler
						value = 3
					}
				}
			}
		}
	}
	disburse_activity_stress_loss = yes

	# Accolade glory gain
	accolades_activity_complete_wedding_glory_effect = yes

	# LEGITIMACY GAIN FOR GRAND ACTIVITY PARTICIPATION - WEDDING
	grand_activity_participation_legitimacy_effect = yes
}

disburse_wedding_spouse_host_activity_rewards = {
	# for the loc
	save_scope_as = root_scope
	if = {
		limit = {
			root = scope:spouse_1
		}
		scope:spouse_2 = { save_scope_as = other_spouse }
	}
	else_if = {
		limit = {
			root = scope:spouse_2
		}
		scope:spouse_1 = { save_scope_as = other_spouse }
	}

	scope:activity = {
		if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_good
				}
			}
			add_activity_log_entry = {
				key = host_wedding_decoration_good
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = {
					add_character_modifier = {
						modifier = gwedding_magnificent_wedding_modifier
						years = 20
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_normal
				}
			}
			custom_tooltip = host_wedding_decoration_normal
			add_activity_log_entry = {
				key = host_wedding_decoration_normal
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = {
					add_character_modifier = {
						modifier = gwedding_grandiose_wedding_modifier
						years = 20
					}
				}
			}
		}
		else_if = {
			limit = {
				has_activity_option = {
					category = wedding_option_decoration
					option = wedding_decoration_bad
				}
			}
			custom_tooltip = host_wedding_decoration_bad
			add_activity_log_entry = {
				key = host_wedding_decoration_bad
				tags = { completed }
				score = 100
				# this line below adds the entry to the Effects section of the conclusion UI
				show_in_conclusion = yes
				character = scope:root_scope
				target = scope:other_spouse

				scope:root_scope = {
					add_character_modifier = {
						modifier = gwedding_grand_wedding_modifier
						years = 20
					}
				}
			}
		}
	}

	# LEGITIMACY GAIN FOR GRAND ACTIVITY PARTICIPATION - WEDDING
	grand_activity_participation_legitimacy_effect = yes
}

disburse_hunt_activity_rewards = {
	# for the loc
	save_scope_as = root_scope
	if = { # To show correct tooltips for guests
		limit = { has_trait = lifestyle_hunter }
		add_character_flag = {
			flag = host_existing_hunter
			weeks = 1
		}
	}
	hunt_individual_guest_awards_effect = yes
	# Rewards based on Magnficence level
	# Host Rewards
	# Adventurer Provisions
	if = {
		limit = {
			has_government = landless_adventurer_government
		}
		domicile = {
			change_provisions = {
				value = hunt_provisions_reward_value
			}
		}
	}
	# Nomads gain dread and prowess from dangerous animal kills
	if = {
		limit = {
			government_has_flag = government_is_nomadic
			scope:activity = {
				var:hunt_success ?= flag:yes
				NOT = { exists = var:animal_spared }
				hunt_animal_type_dangerous_trigger = { VAR = var:animal_type }
			}
		}
		add_dread = massive_dread_gain
		add_prowess_skill = 1
	}
	# Nomad Discount Modifier for Feasts
	if = {
		limit = {
			government_has_flag = government_is_nomadic
			scope:activity.var:hunt_success ?= flag:yes
			NOT = { exists = scope:activity.var:animal_spared }
			scope:activity = {
				NOR = {
					var:animal_type ?= flag:hare
					var:animal_type ?= flag:fox
				}
			}
		}
		custom_tooltip = nomad_good_hunt_tt
		add_character_modifier = {
			modifier = mpo_si_slaughtered_animals
		}
	}
	else_if = {
		limit = {
			government_has_flag = government_is_nomadic
			scope:activity.var:hunt_success ?= flag:yes
			NOT = { exists = scope:activity.var:animal_spared }
		}
		custom_tooltip = nomad_meager_hunt_tt
	}
	# Prestige/Piety Gain
	if = {
		limit = {
			culture = { has_cultural_parameter = sacred_hunts }
		}
		add_prestige = hunt_prestige_with_piety_reward_value
		add_piety = hunt_piety_reward_value
	}
	else = { add_prestige = hunt_prestige_reward_value }
	# Triggered bonuses
	if = {
		limit = { has_character_flag = impressive_hunt }
		every_vassal = {
			add_opinion = {
				modifier = hosted_hunt_opinion
				target = scope:root_scope
				opinion = 5
			}
		}
		remove_character_flag = impressive_hunt
	}
	if = {
		limit = { has_character_flag = personal_hunt }
		if = {
			limit = { scope:activity.var:hunt_success ?= flag:yes }
			scope:activity = {
				random_attending_character = {
					limit = {
						NOR = {
							has_trait = loyal
							has_trait = disloyal
						}
						is_ai = yes
					}
					weight = {
						base = 1
						opinion_modifier = {
							opinion_target = root
						}
					}
					add_trait = loyal
				}
			}
		}
		else = {
			scope:activity = {
				random_attending_character = {
					limit = {
						NOR = {
							has_trait = loyal
							has_trait = disloyal
						}
						is_ai = yes
					}
					weight = {
						base = 1
						opinion_modifier = {
							opinion_target = root
						}
					}
					random = {
						chance = 50
						add_trait = loyal
					}
				}
			}
		}
		remove_character_flag = personal_hunt
	}
	if = {
		limit = { has_character_flag = glorious_hunt }
		if = {
			limit = { scope:activity.var:hunt_success ?= flag:yes }
			add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
		}
		else = {
			add_legitimacy_effect = { LEGITIMACY = miniscule_legitimacy_gain }
		}
		remove_character_flag = glorious_hunt
	}
	# Glory Hound Vassal Opinion
	set_variable = {
		name = attending_glory_hounds
		value = scope:root_scope.number_of_participating_glory_hound_vassals
	}
	every_vassal = {
		vassal_stance = glory_hound
		limit = {
			is_participant_in_activity = scope:activity
		}
		custom = every_participating_glory_hound_vassal
		add_opinion = {
			modifier = hosted_hunt_opinion
			target = scope:root_scope
			opinion = hunt_glory_hound_vassal_opinion_value
		}
	}
	remove_variable = attending_glory_hounds
	# Belligerent Vassal Opinion
	set_variable = {
		name = attending_belligerent
		value = scope:root_scope.number_of_participating_belligerent_vassals
	}
	every_vassal_or_below = {
		limit = {
			has_vassal_stance = belligerent
			is_participant_in_activity = scope:activity
		}
		custom = every_participating_belligerent_vassal
		add_opinion = {
			modifier = hosted_hunt_opinion
			target = scope:root_scope
			opinion = 15
		}
	}
	remove_variable = attending_belligerent
	scope:activity = {
		hidden_effect = {
			if = {
				limit = {
					activity_host = { has_trait = lifestyle_hunter }
				}
				add_to_variable_list = {
					name = trait_rewards
					target = trait:lifestyle_hunter
				}
			}
		}
		# People happy when their nobles clear dangerous beasts
		if = {
			limit = {
				var:hunt_success ?= flag:yes
				NOT = { exists = var:animal_spared }
				hunt_animal_type_predator_trigger = { VAR = var:animal_type }
				activity_location.county.holder.top_liege ?= scope:host.top_liege # own nobles
			}
			activity_location.county = {
				add_county_modifier = {
					modifier = hunt_dangerous_beast_slain_modifier
					years = 10
				}
			}
		}
		show_as_tooltip = {
			every_attending_character = {
				limit = {
					NOR = {
						this = scope:host
						this = root
					}
					is_adult = yes
					trigger_if = {
						limit = {
							scope:activity = {
								NOT = {
									has_activity_option = { category = special_type option = hunt_type_falconry }
								}
							}
						}
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:root_scope }
					}
					trigger_if = {
						limit = { is_clergy = yes }
						faith = { has_doctrine_parameter = clergy_can_fight }
					}
				}
				custom = hunt_every_other_hunter_tt
				add_prestige = hunt_prestige_guest_gain_value
				if = {
					limit = {
						government_has_flag = government_is_nomadic
						scope:activity = {
							var:hunt_success ?= flag:yes
							NOT = { exists = var:animal_spared }
							hunt_animal_type_dangerous_trigger = { VAR = var:animal_type }
						}
					}
					add_prowess_skill = 1
				}
			}
		}
	}

	# Remove strife if relevant.
	remove_strife_per_invited_powerful_vassal_effect = yes
}

disburse_feast_activity_rewards = {
	# for the loc
	save_scope_as = root_scope

	# Rewards based on Activity Options

	# Number of courses
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_good
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = courses_good_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards


					#Max Food Option will make Courtly Vassals more happy than other guests.
					#Court Amenities can increase this further.

					every_vassal_or_below = {
						vassal_stance = courtly
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_courtly_vassal
						add_opinion = {
							modifier = hosted_feast_opinion
							target = root
							opinion = feast_opinion_max_food_value
						}
					}
					# Vassal Opinion
					scope:activity = {
						every_attending_character = {
							limit = {
								this != root
								trigger_if = {
									limit = {
										is_vassal_of = root
									}
									NOT = { has_vassal_stance = courtly }
								}
							}
							custom = custom.every_attending_character_but_courtly
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = feast_opinion_max_food_value
							}
						}
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_normal
				}
			}
		}
		#With Middle Food Option
		scope:activity = {
			add_activity_log_entry = {
				key = courses_normal_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards

					#With Middle Food Option Courtly vassals have slightly higher opinion gain than others
					#Very High Court Amenities can increase it slightly.

					# Courtly Vassal Opinion
					every_vassal_or_below = {
						vassal_stance = courtly
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_courtly_vassal
						add_opinion = {
							modifier = hosted_feast_opinion
							target = root
							opinion = feast_opinion_medium_food_value
						}
					}
					# Vassal Opinion
					scope:activity = {
						every_attending_character = {
							limit = {
								this != root
								trigger_if = {
									limit = {
										is_vassal_of = root
									}
									NOT = { has_vassal_stance = courtly }
								}
							}
							custom = custom.every_attending_character_but_courtly
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = feast_opinion_medium_food_value
							}
						}
					}
				}
			}
		}
	}
	else = {
		scope:activity = {
			add_activity_log_entry = {
				key = courses_bad_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards

					#With Low food option the opinion gain with Courtly vassals is always lower than for normal guests. Even if you have very high court amenities (though they do mitigate it a bit).
					every_vassal_or_below = {
						vassal_stance = courtly
						limit = {
							is_participant_in_activity = scope:activity
						}
						custom = every_courtly_vassal
						add_opinion = {
							modifier = hosted_mediocre_feast_opinion
							target = root
							opinion = feast_opinion_mediocre_food_value
						}
					}

					# Vassal Opinion
					scope:activity = {
						#Other guests
						every_attending_character = {
							limit = {
								this != root
								trigger_if = {
									limit = {
										is_vassal_of = root
									}
									NOT = { has_vassal_stance = courtly }
								}
							}
							custom = custom.every_attending_character_but_courtly
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = feast_opinion_mediocre_food_value
							}
						}
					}
				}
			}
		}
	}

	# If you have an Estate, with the relevant upgrade, you get additional opinion
	# This does create a duplicate opinion entry in the list of effects, but is easier for script maintenance
	if = {
		limit = {
			scope:host = {
				domicile ?= {
					has_domicile_parameter = estate_improved_feast_opinion
					domicile_location = scope:activity_location
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = feast_estate_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				root = {
					scope:activity = {
						every_attending_character = {
							limit = {
								this != root
							}
							custom = custom.every_attending_character
							add_opinion = {
								target = root
								modifier = impressed_opinion
								opinion = 5
							}
						}
					}
				}
			}
		}
	}

	# Dish complexity
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_food
					option = feast_food_good
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = food_good_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					add_prestige = {
						value = 225
						scope:host = {
							if = {
								limit = {
									has_royal_court = yes
									has_dlc_feature = royal_court
									amenity_level = { target = court_food_quality value >= 5 }
								}
								multiply = 1.5
							}
							multiply = court_brewmaster_multiplier
						}
						if = {
							limit = {
								culture = {
									has_cultural_parameter = refined_feasts
								}
							}
							add = major_prestige_gain
						}
						if = {
							limit = {
								any_character_struggle = {
									involvement = involved
									has_struggle_phase_parameter = struggle_prestige_from_feast
								}
							}
							add = medium_prestige_gain
						}
						if = {
							limit = {
								confederation ?= { has_cohesion_level_parameter = any_member_increased_feast_rewards }
							}
							multiply = 1.1
						}
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_food
					option = feast_food_normal
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = food_normal_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					add_prestige = {
						value = 115
						scope:host = {
							if = {
								limit = {
									scope:host = {
										has_royal_court = yes
										has_dlc_feature = royal_court
										amenity_level = { target = court_food_quality value >= 5 }
									}
								}
								multiply = 2
							}
							else_if = {
								limit = {
									scope:host = {
										has_royal_court = yes
										has_dlc_feature = royal_court
										amenity_level = { target = court_food_quality value >= 3 }
									}
								}
								multiply = 1.5
							}
							multiply = court_brewmaster_multiplier
						}


						if = {
							limit = {
								culture = {
									has_cultural_parameter = refined_feasts
								}
							}
							add = major_prestige_gain
						}
						if = {
							limit = {
								any_character_struggle = {
									involvement = involved
									has_struggle_phase_parameter = struggle_prestige_from_feast
								}
							}
							add = medium_prestige_gain
						}
						if = {
							limit = {
								confederation ?= { has_cohesion_level_parameter = any_member_increased_feast_rewards }
							}
							multiply = 1.1
						}
					}
				}
			}
		}
	}
	else = {
		scope:activity = {
			add_activity_log_entry = {
				key = food_bad_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					# Host Rewards
					add_prestige = {
						value = 35
						scope:host = {
							if = {
								limit = {
									scope:host = {
										has_royal_court = yes
										has_dlc_feature = royal_court
										amenity_level = { target = court_food_quality value >= 5 }
									}
								}
								multiply = 2
							}
							else_if = {
								limit = {
									scope:host = {
										has_royal_court = yes
										has_dlc_feature = royal_court
										amenity_level = { target = court_food_quality value >= 3 }
									}
								}
								multiply = 1.5
							}
							multiply = court_brewmaster_multiplier
						}

						if = {
							limit = {
								culture = {
									has_cultural_parameter = refined_feasts
								}
							}
							add = major_prestige_gain
						}
						if = {
							limit = {
								any_character_struggle = {
									involvement = involved
									has_struggle_phase_parameter = struggle_prestige_from_feast
								}
							}
							add = medium_prestige_gain
						}
						if = {
							limit = {
								confederation ?= { has_cohesion_level_parameter = any_member_increased_feast_rewards }
							}
							multiply = 1.1
						}
					}
				}
			}
		}
	}

	# Estate Unlock: Wine Selection
	if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_wine
					option = feast_wine_extensive
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = wine_extensive_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					change_influence = {
						value = 15

						scope:activity = {
							every_attending_character = {
								limit = {
									NOR = {
										this = root
										is_courtier_of = root # Guest shouldn't originate from you own court
									}
								}
								add = 15
							}
						}
						scope:host = { multiply = court_brewmaster_multiplier }
						if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_3 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_3_value
							}
						}
						else_if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_2 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_2_value
							}
						}
						else_if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_1 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_1_value
							}
						}
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_wine
					option = feast_wine_normal
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = wine_normal_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					change_influence = {
						value = 10

						scope:activity = {
							every_attending_character = {
								limit = {
									NOR = {
										this = root
										is_courtier_of = root # Guest shouldn't originate from you own court
									}
								}
								add = 10
							}
						}
						scope:host = { multiply = court_brewmaster_multiplier }
						if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_3 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_3_value
							}
						}
						else_if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_2 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_2_value
							}
						}
						else_if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_1 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_1_value
							}
						}
					}
				}
			}
		}
	}
	else_if = {
		limit = {
			scope:activity = {
				has_activity_option = {
					category = feast_option_wine
					option = feast_wine_limited
				}
			}
		}
		scope:activity = {
			add_activity_log_entry = {
				key = wine_limited_reward_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				# Effects
				root = {
					change_influence = {
						value = 5

						scope:activity = {
							every_attending_character = {
								limit = {
									NOR = {
										this = root
										is_courtier_of = root # Guest shouldn't originate from you own court
									}
								}
								add = 5
							}
						}
						scope:host = { multiply = court_brewmaster_multiplier }
						if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_3 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_3_value
							}
						}
						else_if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_2 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_2_value
							}
						}
						else_if = {
							limit = {
								domicile ?= { has_domicile_parameter = estate_improved_wine_cellar_1 }
							}
							multiply = {
								value = 1
								add = estate_improved_wine_cellar_1_value
							}
						}
					}
				}
			}
		}
	}

	# We give you the regular rewards
	hosted_successful_feast_new_effect = yes
	# We give out the Reveler trait/xp
	disburse_feast_reveler_rewards = yes
	#Accolade glory gain
	accolades_activity_complete_feast_glory_effect = yes
	#Stress loss
	if = {
		limit = {
			OR = {
				has_trait = shy
				has_trait = reclusive
			}
		}
		custom_tooltip = host_feast_decision_desc_shy
	}
	else = {
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
					amenity_level = { target = court_food_quality value >= 5 }
			}
			stress_impact = {
				base = exotic_feast_stress_loss_value
				gluttonous = feast_stress_loss_value
				gregarious = feast_stress_loss_value
				lifestyle_reveler = feast_stress_loss_value
				drunkard = feast_stress_loss_value
				comfort_eater = feast_stress_loss_value
				generous = feast_stress_loss_value
				greedy = activity_stress_gain_impact
			}
		}
		else_if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { target = court_food_quality value >= 4 }
			}
			stress_impact = {
				base = lavish_feast_stress_loss_value
				gluttonous = feast_stress_loss_value
				gregarious = feast_stress_loss_value
				lifestyle_reveler = feast_stress_loss_value
				drunkard = feast_stress_loss_value
				comfort_eater = feast_stress_loss_value
				generous = feast_stress_loss_value
				greedy = activity_stress_gain_impact
			}
		}
	    else_if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { target = court_food_quality value >= 3 }
			}
			stress_impact = {
				base = medium_feast_stress_loss_value
				gluttonous = feast_stress_loss_value
				gregarious = feast_stress_loss_value
				lifestyle_reveler = feast_stress_loss_value
				drunkard = feast_stress_loss_value
				comfort_eater = feast_stress_loss_value
				generous = feast_stress_loss_value
				greedy = activity_stress_gain_impact
			}
		}
		else_if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
				amenity_level = { target = court_food_quality value <= 1 }
			}
			stress_impact = {
				base = meager_feast_stress_loss_value
				gluttonous = feast_stress_loss_value
				gregarious = feast_stress_loss_value
				lifestyle_reveler = feast_stress_loss_value
				drunkard = feast_stress_loss_value
				comfort_eater = feast_stress_loss_value
				generous = feast_stress_loss_value
				greedy = activity_stress_gain_impact
			}
		}
		else = {
			stress_impact = {
				base = feast_stress_loss_value
				gluttonous = activity_stress_loss_impact
				gregarious = activity_stress_loss_impact
				lifestyle_reveler = feast_stress_loss_value
				drunkard = activity_stress_loss_impact
				comfort_eater = activity_stress_loss_impact
				generous = activity_stress_loss_impact
				greedy = activity_stress_gain_impact
			}
		}
	}

	# Remove strife if relevant.
	remove_strife_per_invited_powerful_vassal_effect = yes
}

disburse_murder_feast_activity_rewards = {
	if = {
		limit = {
			has_variable = murder_feast_liege_var
		}
		scope:activity = {
			add_activity_log_entry = {
				key = murder_feast_liege_kill_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				root = {
					add_prestige_level = -2
				}
			}
		}
	}
	if = {
		limit = {
			has_variable = murder_feast_head_of_faith_var
		}
		scope:activity = {
			add_activity_log_entry = {
				key = murder_feast_hof_kill_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				root = {
					add_piety_level = -2
				}
			}
		}
	}
	if = {
		limit = {
			faith = { #if this is a religious thing, people don't really love it
				has_doctrine = tenet_ritual_celebrations
			}
		}
		add_piety = medium_piety_loss
	}
	if = {
		limit = { has_variable = murder_feast_entourage_murder_var } #you've killed EVERYONE
		scope:activity = {
			add_activity_log_entry = {
				key = murder_feast_entourage_kill_tt
				tags = { completed }
				character = scope:root_scope
				show_in_conclusion = yes
				score = 50

				root = {
					add_dread = 35
					add_legitimacy = major_legitimacy_loss
					add_character_modifier = {
						modifier = murder_feast_great_murderer_modifier
						years = 15
					}
				}
			}
			# # Guest Opinion
			every_attending_character = {
				limit = {
					NOR = {
						has_trait = torturer
						has_trait = sadistic
						has_trait = vengeful
						has_trait = callous
					}
				}
				custom = feast_every_guest
				add_opinion = {
					modifier = suspicion_opinion
					target = scope:host
					opinion = -10
				}
			}
		}
	}
	else = { #Rewards for a "normal" feast
		if = { #if you failed your attempt it doesn't look great
			limit = { has_variable = murder_feast_murder_failure_var }
			scope:activity = {
				add_activity_log_entry = {
					key = murder_feast_failed_tt
					tags = { completed }
					character = scope:root_scope
					show_in_conclusion = yes
					score = 50

					root = {
						add_prestige = minor_prestige_loss
						add_legitimacy = minor_legitimacy_loss
					}
				}
			}
		}
		else_if = { #if you've killed your target you get these
			limit = { NOT = { has_variable = murder_feast_murder_failure_var } }
			scope:activity = {
				add_activity_log_entry = {
					key = murder_feast_solo_kill_tt
					tags = { completed }
					character = scope:root_scope
					show_in_conclusion = yes
					score = 50

					root = {
						add_dread = 25
						add_legitimacy = medium_legitimacy_loss
						add_character_modifier = {
							modifier = murder_feast_murderer_modifier
							years = 10
						}
					}
				}
				# # Guest Opinion
				every_attending_character = {
					limit = {
						NOR = {
							has_trait = torturer
							has_trait = sadistic
							has_trait = vengeful
							has_trait = callous
						}
					}
					custom = feast_every_guest
					add_opinion = {
						modifier = suspicion_opinion
						target = scope:host
						opinion = -5
					}
				}
			}
		}
		# Rewards based on Activity Options
		# Smaller than regular feasts for reasons apparent

		# Number of courses
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = feast_option_courses
						option = feast_courses_good
					}
				}
			}
			custom_tooltip = courses_good_reward_tt
			scope:activity = {
				add_activity_log_entry = {
					key = courses_good_reward_tt
					tags = { completed }
					character = scope:root_scope
					show_in_conclusion = yes
					score = 50

					# Effects
					root = {
						# Host Rewards

						# Courtly Vassal Opinion
						every_vassal_or_below = {
							vassal_stance = courtly
							limit = {
								is_participant_in_activity = scope:activity
							}
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_feast_opinion
								target = root
								opinion = 15
							}
						}
						# Vassal Opinion
						scope:activity = {
							every_attending_character = {
								limit = { this != root }
								custom = custom.every_attending_character
								add_opinion = {
									target = root
									modifier = impressed_opinion
									opinion = 10
								}
							}
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = feast_option_courses
						option = feast_courses_normal
					}
				}
			}
			custom_tooltip = courses_normal_reward_tt
			scope:activity = {
				add_activity_log_entry = {
					key = courses_normal_reward_tt
					tags = { completed }
					character = scope:root_scope
					show_in_conclusion = yes
					score = 50

					# Effects
					root = {
						# Host Rewards

						# Courtly Vassal Opinion
						every_vassal_or_below = {
							vassal_stance = courtly
							limit = {
								is_participant_in_activity = scope:activity
							}
							custom = every_courtly_vassal
							add_opinion = {
								modifier = hosted_feast_opinion
								target = root
								opinion = 5
							}
						}
						# Vassal Opinion
						scope:activity = {
							every_attending_character = {
								limit = { this != root }
								custom = custom.every_attending_character
								add_opinion = {
									target = root
									modifier = impressed_opinion
									opinion = 5
								}
							}
						}
					}
				}
			}
		}

		# Dish complexity
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = feast_option_food
						option = feast_food_good
					}
				}
			}
			custom_tooltip = food_good_reward_tt
			scope:activity = {
				add_activity_log_entry = {
					key = food_good_reward_tt
					tags = { completed }
					character = scope:root_scope
					show_in_conclusion = yes
					score = 50

					# Effects
					root = {
						# Host Rewards
						add_prestige = 100
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = feast_option_food
						option = feast_food_normal
					}
				}
			}
			custom_tooltip = food_normal_reward_tt
			scope:activity = {
				add_activity_log_entry = {
					key = food_normal_reward_tt
					tags = { completed }
					character = scope:root_scope
					show_in_conclusion = yes
					score = 50

					# Effects
					root = {
						# Host Rewards
						add_prestige = 50
					}
				}
			}
		}
	}
	# Stress loss according to traits in the ending event

	#Accolade glory gain
	accolades_activity_complete_feast_glory_effect = yes
}

disburse_activity_stress_loss = {
	stress_impact = {
		base = medium_stress_impact_loss
		shy = minor_stress_impact_gain
		reclusive = minor_stress_impact_gain
	}
}

disburse_feast_reveler_rewards = {
	if = {
		limit = {
			has_trait = lifestyle_reveler
			scope:activity = {
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_good
				}
			}
			scope:activity = {
				has_activity_option = {
					category = feast_option_food
					option = feast_food_good
				}
			}
		}
		add_trait_xp = {
			trait = lifestyle_reveler
			value = 15
		}
	}
	else_if = {
		limit = {
			has_trait = lifestyle_reveler
			scope:activity = {
				has_activity_option = {
					category = feast_option_food
					option = feast_food_good
				}
			}
		}
		add_trait_xp = {
			trait = lifestyle_reveler
			value = 10
		}
	}
	else_if = {
		limit = {
			has_trait = lifestyle_reveler
			scope:activity = {
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_good
				}
			}
		}
		add_trait_xp = {
			trait = lifestyle_reveler
			value = 10
		}
	}
	else_if = {
		limit = { has_trait = lifestyle_reveler }
		add_trait_xp = {
			trait = lifestyle_reveler
			value = 5
		}
	}
	else = { #progress towards reveler
		custom_tooltip = {
			text = progress_towards_reveler_tt
			reveler_points_gain_effect = {
				CHANGE = 1
				RANDOM_CHANGE = 1
			}
		}
	}
	# LEGITIMACY GAIN FOR STANDARD ACTIVITY PARTICIPATION - FEAST
	standard_activity_participation_legitimacy_effect = yes
}


##########################
# ACTIVITY WAR HANDLING
# by Chad Uhl
##########################

# Called in the war_on_actions.txt file
# Used to send out the correct events if a character becomes involved in a war while attending an activity
activity_on_war_declared_events_effect = {
	trigger_event = religious_decision.0200 # Stop mediation in its tracks
	if = {
		limit = {
			this.involved_activity ?= {
				is_activity_complete = no
			}
		}
		this.involved_activity ?= {
			save_scope_as = target_activity
			activity_type = { save_scope_as = target_activity_type }
			activity_host = { save_scope_as = target_activity_host }
		}
		if = { # Send one event if you're the host
			limit = {
				exists = this.involved_activity
				this = this.involved_activity.activity_host
			}
			# This event fires follow-up events for the guests depending on the character's choice
			trigger_event = activity_system.0300
		}
		else_if = { # Send another if you're just a guest
			limit = {
				exists = this.involved_activity
				NOT = {
					any_war_enemy = { this = scope:target_activity_host }
				}
			}
			trigger_event = activity_system.0310
		}
		else_if = { # Just go home if you're at war with host
			limit = {
				exists = this.involved_activity
				any_war_enemy = { this = scope:target_activity_host }
			}
			send_interface_toast = {
				type = event_toast_effect_bad
				left_icon = scope:target_activity_host
				title = at_war_difficulty #"At war"
				current_travel_plan = { 
					if = {
						limit = { can_cancel = yes }
						cancel_travel_plan = yes
					}
				}
			}
			
		}
	}
}

#######################
# ACTIVITY SETUP
# by Filippa Gannholm Kirsten
#######################

#Set this in the on_start of your activity (note - NOT the PHASE on_start, but your ACTIVITY on_start)
activity_setup_special_type_progression_effect = {
	set_variable = {
		name = activity_special_type_progression
		value = 0
	}
}

#######################
# ACTIVITY SPECIAL TYPE PROGRESSION
# by Filippa Gannholm Kirsten
#######################

activity_special_type_progression_variable = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = $NUM$
		}
	}
}

activity_special_type_progression_miniscule = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = 1
		}
	}
}

activity_special_type_progression_tiny = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = 3
		}
	}
}

activity_special_type_progression_medium = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = 5
		}
	}
}

activity_special_type_progression_major = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = 10
		}
	}
}

activity_special_type_progression_huge = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = 20
		}
	}
}

activity_special_type_progression_massive = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = 40
		}
	}
}

activity_special_type_progression_negative_tiny = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = -3
		}
	}
}

activity_special_type_progression_negative = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = -5
		}
	}
}

activity_special_type_progression_negative_major = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = -10
		}
	}
}

activity_special_type_progression_negative_huge = {
	if = {
		limit = { exists = var:activity_special_type_progression }
		change_variable = {
			name = activity_special_type_progression
			add = -25
		}
	}	
}

#######################
# ACTIVITY ADD CHARACTER TO EVERYTHING
# by Arkadiusz Majewski
#######################

add_to_court_and_entourage_effect = {
	root = {
		add_courtier = prev
	}
	if = {
		limit = { exists = root.current_travel_plan }
		root.current_travel_plan = { add_companion = prev }
	}
	if = {
		limit = { exists = scope:activity }
		add_to_activity = scope:activity
	}
}

add_to_court_and_entourage_only_effect = {
	root = {
		add_courtier = prev
	}
	hidden_effect = {
		if = {
			limit = { exists = root.current_travel_plan }
			root.current_travel_plan = { add_companion = prev }
		}
	}
}



#The following effects take the CHAR_TO_ADD and NEW_COURT_OWNER scopes, determining if the CHAR_TO_ADD is a pool character since the add_companion automatically adds pool characters as a courtier, whereas if CHAR_TO_ADD is not a pool character, it does not.
# "X joins your Court"
add_to_entourage_court_and_activity_effect = {
	#If the character is a pool character
	$NEW_COURT_OWNER$ = {
		if = {
			limit = {
				#Pool characters get automatically added as courtiers
				$CHAR_TO_ADD$ = { is_pool_character = yes }
			}
			show_as_tooltip = { add_courtier = $CHAR_TO_ADD$ } #This already happens with add_companion
			hidden_effect = { # This must go above activity effect, or they will try and make their own travel plan!
				if = {
					limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
					$NEW_COURT_OWNER$.current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
				}
			}
			if = {
				limit = { exists = involved_activity }
				$CHAR_TO_ADD$ = { add_to_activity = $NEW_COURT_OWNER$.involved_activity }
			}
		}
		#If the character is NOT a pool character
		else = {
			if = {
				limit = {
					$CHAR_TO_ADD$ = {
						NOT = { is_courtier_of = $NEW_COURT_OWNER$ }
					}
				}
				add_courtier = $CHAR_TO_ADD$
			}
			hidden_effect = { # This must go above activity effect, or they will try and make their own travel plan!
				if = {
					limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
					$NEW_COURT_OWNER$.current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
				}
			}
			if = {
				limit = {
					exists = involved_activity
					$CHAR_TO_ADD$ = { can_join_activity = $NEW_COURT_OWNER$.involved_activity }
				}
				$CHAR_TO_ADD$ = { add_to_activity = $NEW_COURT_OWNER$.involved_activity }
			}
		}
	}
}

# "You recruit X to your Court"
recruit_to_entourage_court_and_activity_effect = {
	#If the character is a pool character
	$NEW_COURT_OWNER$ = {
		if = {
			limit = {
				#Pool characters get automatically added as courtiers
				$CHAR_TO_ADD$ = { is_pool_character = yes }
			}
			show_as_tooltip = { add_courtier = $CHAR_TO_ADD$ } #This already happens with add_companion
			hidden_effect = { # This must go above activity effect, or they will try and make their own travel plan!
				if = {
					limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
					current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
				}
			}
			if = {
				limit = { exists = involved_activity }
				$CHAR_TO_ADD$ = { add_to_activity = $NEW_COURT_OWNER$.involved_activity }
			}
		}
		#If the character is NOT a pool character
		else = {
			if = {
				limit = {
					$CHAR_TO_ADD$ = {
						NOT = { is_courtier_of = $NEW_COURT_OWNER$ }
					}
				}
				add_courtier = $CHAR_TO_ADD$
			}
			hidden_effect = { # This must go above activity effect, or they will try and make their own travel plan!
				if = {
					limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
					current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
				}
			}
			if = {
				limit = { exists = involved_activity }
				$CHAR_TO_ADD$ = { add_to_activity = $NEW_COURT_OWNER$.involved_activity }
			}
		}
	}
}

add_to_entourage_but_not_court_effect = {
	#If the character is a pool character
	$NEW_COURT_OWNER$ = {
		if = {
			limit = {
				exists = capital_province
				$CHAR_TO_ADD$ = { is_pool_character = yes }
			}
			current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
			$CHAR_TO_ADD$ = {
				hidden_effect = { move_to_pool_at = $NEW_COURT_OWNER$.capital_province }
			}
		}
		#If the character is NOT a pool character
		else = {
			if = {
				limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
				current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
			}
		}
	}
}

add_to_entourage_and_activity_but_not_court_effect = {
	#If the character is a pool character
	$NEW_COURT_OWNER$ = {
		if = {
			limit = {
				exists = capital_province
				$CHAR_TO_ADD$ = { is_pool_character = yes }
			}
			hidden_effect = { # This must go above activity effect, or they will try and make their own travel plan!
				if = {
					limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
					current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
				}
			}
			$CHAR_TO_ADD$ = {
				hidden_effect = { move_to_pool_at = $NEW_COURT_OWNER$.capital_province }
				if = {
					limit = { exists = $NEW_COURT_OWNER$.involved_activity }
					add_to_activity = $NEW_COURT_OWNER$.involved_activity
				}
			}

		}
		#If the character is NOT a pool character
		else = {
			if = { # This must go above activity effect, or they will try and make their own travel plan!
				limit = { $CHAR_TO_ADD$ = { NOT = { exists = current_travel_plan } } }
				current_travel_plan ?= { add_companion = $CHAR_TO_ADD$ }
			}
			if = {
				limit = { exists = $NEW_COURT_OWNER$.involved_activity }
				$CHAR_TO_ADD$ = { add_to_activity = $NEW_COURT_OWNER$.involved_activity }
			}
		}
	}
}

host_has_taken_freebie_activity_effect = {
	if = {
		limit = {
			this = scope:host
			dynasty ?= { has_dynasty_perk = ep2_activities_legacy_5 }
			this = house.house_head
		}
		set_variable = {
			name = ep2_activities_legacy_5_had_freebie
			value = yes
		}
	}
}

invalidation_incapable_effect = {
	if = {
		limit = {
			scope:host = { is_incapable = yes }
			scope:activity = { NOT = { has_variable = invalidation_effect_set } }
		}
		scope:activity = {
			set_variable = { name = invalidation_effect_set }
			activity_type = { save_scope_as = activity_type }
		}
		scope:host = {
			trigger_event = activity_system.0330
		}
		every_attending_character = {
			limit = { this != scope:host }
			trigger_event = activity_system.0331
		}
	}
}

invalidation_unlanded_effect = {
	if = {
		limit = {
			scope:host = { is_landed = no }
			scope:activity = { NOT = { has_variable = invalidation_effect_set } }
		}
		scope:activity = {
			set_variable = { name = invalidation_effect_set }
			activity_type = { save_scope_as = activity_type }
		}
		every_attending_character = {
			trigger_event = activity_system.0320
		}
	}
}

invalidation_host_death_effect = {
	scope:activity = {
		set_variable = { name = invalidation_effect_set }
		activity_type = { save_scope_as = activity_type }
	}
	every_attending_character = {
		limit = { is_alive = yes }
		trigger_event = {
			id = activity_system.0500
			days = 1 # So you don't get spammed
		}
	}
}

invalidation_imprisoned_effect = {
	if = {
		limit = {
			scope:host = { is_imprisoned = yes }
			scope:activity = { NOT = { has_variable = invalidation_effect_set } }
		}
		scope:activity = {
			set_variable = { name = invalidation_effect_set }
			activity_type = { save_scope_as = activity_type }
		}
		scope:host = { trigger_event = activity_system.0550 }
		every_attending_character = { trigger_event = activity_system.0551 }
	}
}
