activity_camp_party = {
	is_shown = {
		has_ep3_dlc_trigger = yes
		has_government = landless_adventurer_government
		is_adult = yes
		#Every other activity must be blocked until an uncrowned AI crowns themselves
		trigger_if = {
			limit = {
				is_ai = yes
			}
			NOT = {
				has_realm_law = uncrowned
			}
		}
	}

	can_start_showing_failures_only = {
		NOT = { is_activity_type_on_cooldown = activity_camp_party }
		is_available = yes
		age >= 16
	}

	is_valid = {
		scope:host = {
			is_alive = yes
			is_imprisoned = no
			has_government = landless_adventurer_government
			NOT = { is_incapable = yes }
		}
	}

	on_invalidated = {
		# Host becomes incapable
		if = {
			limit = {
				scope:host = { is_incapable = yes }
			}
			scope:activity = {
				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
			}
		}
	}

	province_filter = domicile_domain
	ai_province_filter = domicile_domain

	max_province_icons = 1
	allow_zero_guest_invites = no
	open_invite = no

	province_description = {
		desc = activity_camp_party_province_desc
	}

	province_score = {
		add = camp_party_province_reference_value
	}

	cost = {
		gold = {
			add = {
				add = {
					value = standard_camp_party_activity_cost
					desc = hunt_base_cost
				}
				if =  {
					limit = {
						has_character_modifier = journey_communal_modifier
					}
					multiply = {
						value = 0.8
						desc = journey_communal_modifier
					}
				}
			}
		}
	}

	ui_predicted_cost = {
		gold = {
			# Base Cost
			value = standard_camp_party_activity_cost
			# Make it a multiple of 5 (rounded up)
			divide = 5
			ceiling = yes
			multiply = 5
		}
	}

	cooldown = { years = standard_camp_party_cooldown_time	}

	###################
	# PHASES AND OPTIONS
	###################

	phases = {
		phase_camp_party = {
			is_predefined = yes
			location_source = pickable

			ai_will_do = {
				value = 0
				add = {
					value = 30
					desc = "Base test value"
				}
			}

			on_phase_active = {
				if = {
					limit = { this = scope:host }

					scope:host = {
						trigger_event = {
							id = ep3_camp_party.0009
							days = 89
						}
					}

					scope:activity = {
						#Phase progression
						progress_activity_phase_after = { days = 90 }
						#Loc
						activity_location = { save_scope_as = location }
					}
					#Arrival event
					trigger_event = ep3_camp_party.0001
				}
			}

			on_monthly_pulse = {
				if = {
					limit = { this = scope:host }
					trigger_event = { on_action = camp_party_destination_events }
				}
			}
		}
	}

	options = {
		#Food options: upgrades locked behind Supply Tent
		camp_party_option_food = {
			camp_party_food_none = { #Default
				default = yes

				ai_will_do = {
					value = 0
					# Financial preference.
					add = activity_option_likes_cheap_expense_value
					# Quantity preference.
					add = activity_option_food_prefers_small_volume_value
				}
			}
			camp_party_food_simple = { #locked behind Supply Tent
				is_shown = { always = yes }

				is_valid = {
					custom_tooltip = {
						text = camp_party_food_options_invalid
						domicile ?= {
							has_domicile_parameter = camp_unlocks_camp_party_food_option
						}
					}
				}

				cost = {
					gold = {
						add = {
							desc = camp_party_food_simple
							add = {
								value = 5
								desc = camp_party_food_simple
							}
							add = {
								value = 5
								multiply = activity_cost_scale_by_tier
								subtract = 5
								desc = activity_cost_scale_by_tier_desc
							}
							add = {
								value = 5
								multiply = activity_cost_scale_by_era
								subtract = 5
								desc = activity_cost_scale_by_era_desc
							}
							if = {
								limit = {
									dynasty ?= {
										has_dynasty_perk = law_legacy_1
									}
								}
								subtract = {
									value = 5
									add = {
										value = 5
										multiply = activity_cost_scale_by_tier
										subtract = 5
									}
									add = {
										value = 5
										multiply = activity_cost_scale_by_era
										subtract = 5
									}
									multiply = law_legacy_cost_reduction_mult
									desc = law_legacy_1_name
								}
							}
							min = 0
						}
					}
				}

				ai_will_do = {
					value = 0
					# Financial preference.
					add = activity_option_likes_middling_expense_value
					# Quantity preference.
					## We just use slightly reduced quantity prefs here.
					add = {
						value = activity_option_prefers_large_volume_value
						multiply = 0.3
					}
				}
			}
			camp_party_food_lavish = {
				is_shown = { always = yes }

				is_valid = {
					custom_tooltip = {
						text = camp_party_food_options_invalid
						domicile ?= {
							has_domicile_parameter = camp_unlocks_camp_party_food_option
						}
					}
				}

				cost = {
					gold = {
						add = {
							desc = camp_party_food_lavish
							add = {
								value = 15
								desc = camp_party_food_lavish
							}
							add = {
								value = 15
								multiply = activity_cost_scale_by_tier
								subtract = 15
								desc = activity_cost_scale_by_tier_desc
							}
							add = {
								value = 15
								multiply = activity_cost_scale_by_era
								subtract = 15
								desc = activity_cost_scale_by_era_desc
							}
							if = {
								limit = {
									dynasty ?= {
										has_dynasty_perk = law_legacy_1
									}
								}
								subtract = {
									value = 15
									add = {
										value = 15
										multiply = activity_cost_scale_by_tier
										subtract = 15
									}
									add = {
										value = 15
										multiply = activity_cost_scale_by_era
										subtract = 15
									}
									multiply = law_legacy_cost_reduction_mult
									desc = law_legacy_1_name
								}
							}
							min = 0
						}
					}
				}

				ai_will_do = {
					value = 0
					# Financial preference.
					add = activity_option_likes_middling_expense_value
					# Quantity preference.
					## We just use slightly reduced quantity prefs here.
					add = {
						value = activity_option_prefers_large_volume_value
						multiply = 0.6
					}
				}
			}
		}
		#Drinks options: upgrades locked behind Mess Tent & Mobile Brewery
		camp_party_option_drinks = {
			camp_party_drinks_none = { #Default
				default = yes

				ai_will_do = {
					value = 0
					# Financial preference.
					add = activity_option_likes_cheap_expense_value
					# Quantity preference.
					add = activity_option_food_prefers_small_volume_value
				}
			}
			camp_party_drinks_adequate = { #locked behind Mess Tent
				is_shown = { always = yes }

				is_valid = {
					custom_tooltip = {
						text = camp_party_drinks_adequate_invalid
						domicile ?= {
							has_domicile_building_or_higher = mess_tent_01
						}
					}
				}

				cost = {
					gold = {
						add = {
							desc = camp_party_drinks_adequate
							add = {
								value = 10
								desc = camp_party_drinks_adequate
							}
							add = {
								value = 10
								multiply = activity_cost_scale_by_tier
								subtract = 10
								desc = activity_cost_scale_by_tier_desc
							}
							add = {
								value = 10
								multiply = activity_cost_scale_by_era
								subtract = 10
								desc = activity_cost_scale_by_era_desc
							}
							if = {
								limit = {
									dynasty ?= {
										has_dynasty_perk = law_legacy_1
									}
								}
								subtract = {
									value = 10
									add = {
										value = 10
										multiply = activity_cost_scale_by_tier
										subtract = 10
									}
									add = {
										value = 10
										multiply = activity_cost_scale_by_era
										subtract = 10
									}
									multiply = law_legacy_cost_reduction_mult
									desc = law_legacy_1_name
								}
							}
							min = 0
						}
					}
				}

				ai_will_do = {
					value = 0
					# Financial preference.
					add = activity_option_likes_middling_expense_value
					# Quantity preference.
					## We just use slightly reduced quantity prefs here.
					add = {
						value = activity_option_prefers_large_volume_value
						multiply = 0.3
					}
				}
			}
			camp_party_drinks_abundant = { #locked behind Mobile Brewery
				is_shown = { always = yes }

				is_valid = {
					custom_tooltip = {
						text = camp_party_drinks_abundant_invalid
						domicile ?= {
							has_domicile_building_or_higher = mess_tent_brewers
						}
					}
				}

				cost = {
					gold = {
						add = {
							desc = camp_party_drinks_abundant
							add = {
								value = 20
								desc = camp_party_drinks_abundant
							}
							add = {
								value = 20
								multiply = activity_cost_scale_by_tier
								subtract = 20
								desc = activity_cost_scale_by_tier_desc
							}
							add = {
								value = 20
								multiply = activity_cost_scale_by_era
								subtract = 20
								desc = activity_cost_scale_by_era_desc
							}
							if = {
								limit = {
									dynasty ?= {
										has_dynasty_perk = law_legacy_1
									}
								}
								subtract = {
									value = 35
									add = {
										value = 35
										multiply = activity_cost_scale_by_tier
										subtract = 35
									}
									add = {
										value = 35
										multiply = activity_cost_scale_by_era
										subtract = 35
									}
									multiply = law_legacy_cost_reduction_mult
									desc = law_legacy_1_name
								}
							}
							min = 0
						}
					}
				}

				ai_will_do = {
					value = 0
					# Financial preference.
					add = activity_option_likes_middling_expense_value
					# Quantity preference.
					## We just use slightly reduced quantity prefs here.
					add = {
						value = activity_option_prefers_large_volume_value
						multiply = 0.6
					}
				}
			}
		}
	}

	max_guest_arrival_delay_time = { weeks = 1 }

	###################
	# ACTIVITY-SPECIFIC PULSES
	###################

	pulse_actions = {
		entries = {
			apa_bonded_by_fire
			apa_taught_repair
			apa_revelry_hangover_camp
			apa_local_food_camp
			apa_lauded_food_camp
			apa_guest_of_honor_impressed
			apa_cultural_acceptance
			apa_camp_host_gifted
			apa_fireside_chat_shared_stories_martial
			apa_fireside_chat_shared_stories_learning
			apa_fireside_chat_shared_stories_diplomacy
			apa_fireside_chat_shared_stories_stewardship
			apa_fireside_chat_shared_stories_intrigue
			apa_fireside_chat_shared_drinks
			apa_fireside_chat_inspiring_speech
			apa_camp_party_sad_lonesome
			apa_camp_party_shadows_in_the_dark
			apa_camp_party_fortress_of_solitude
			apa_camp_party_lecture
			apa_camp_party_tales_of_distant_lands
			apa_camp_party_tales_of_war
			apa_camp_party_tales_of_lands_lost
			apa_camp_party_blademaster_sparring
			apa_camp_party_tales_of_piety

			#Re-used
			host_gains_diplo_xp
			host_gains_intrigue_xp
			hook_trusting_guest
		}
		chance_of_no_event = 2
	}

	on_start = {
		scope:activity ?= {
			activity_setup_special_type_progression_effect = yes
			if = {
				limit = {
					has_activity_option = {
						category = camp_party_option_food
						option = camp_party_food_simple
					}
				}
				activity_special_type_progression_variable = { NUM = 25 }
			}
			else_if = {
				limit = {
					has_activity_option = {
						category = camp_party_option_food
						option = camp_party_food_lavish
					}
				}
				activity_special_type_progression_variable = { NUM = 50 }
			}
		}
	}

	###################
	# AI VALUES
	###################

	# desc is only shown in debug AI watch window
	ai_will_do = {
		value = 50

		if = {
			limit = {
				has_trait = lazy
			}
			add = -10
		}

		#Can you actually afford this?
		if = {
			limit = {
				domicile.provisions <= 100
			}
			add = -75
		}
	}

	ai_check_interval = 60

	ai_will_select_province = {
		value = 10
	}

	###################
	# GUEST HANDLING
	###################

	host_intents = {
		default = reduce_stress_intent
		intents = { reduce_stress_intent befriend_attendee_intent fireside_chat_intent }
	}

	guest_intents = {
		intents = { reduce_stress_intent befriend_attendee_intent }
		default = reduce_stress_intent
	}

	can_be_activity_guest = {
		OR = { #Follower
			AND = {
				is_healthy = yes
				is_available = yes
				age >= 16
				is_ai = yes
				liege = scope:host
				location = scope:host.location
			}
			AND = { #Local lord
				is_healthy = yes
				is_available = yes
				age >= 16
				is_ai = yes
				top_liege = this
				location = scope:host.location
			}
		}
	}

	guest_invite_rules = {
		defaults = {
			1 = activity_invite_rule_followers
			2 = activity_invite_rule_local_lord
			2 = activity_invite_rule_friends
			2 = activity_invite_rule_potential_friends
			2 = activity_invite_rule_lovers
			2 = activity_invite_rule_potential_lovers
		}
	}

	special_guests = {
		camp_party_honorary_guest = {
			is_required = no

			can_pick = {
				this != scope:host
				is_healthy = yes
				is_available = yes
				age >= 16
				is_ai = yes
				top_liege = this
				location = scope:host.location
			}

			ai_will_do = {
				value = 10
			}
		}
	}

	travel_entourage_selection = {
		weight = {
			value = 10
			if = {
				limit = {
					NOT = { is_in_list = special_guests }
				}
				multiply = 0
			}
		}

		invite_rule_order = 1

		# Up to how many characters to select for a player
		max = 2

		# Up to how many characters to select for an AI
		ai_max = 2
	}

	max_guests = 50 #Theoretically everyone, practically only around 2-10 usually

	guest_join_chance = {
		base = 50 #Everyone should accept, but...
		base_activity_modifier = yes

		# Scripted Modifiers
		activity_guest_shared_ai_accept_modifier = yes

		modifier = {
			is_courtier_of = scope:host
			scope:host = {
				has_government = landless_adventurer_government
			}
			add = 100
			desc = ACTIVITY_GUEST_ADVENTURER_REASON
		}

		modifier = { #Emperors
			primary_title.tier = tier_empire
			add = -100
			desc = ACTIVITY_GUEST_LANDLESS_REASON
		}
		modifier = { #Kings
			primary_title.tier = tier_kingdom
			add = -75
			desc = ACTIVITY_GUEST_LANDLESS_REASON
		}
		modifier = { #Dukes
			primary_title.tier = tier_duchy
			add = -50
			desc = ACTIVITY_GUEST_LANDLESS_REASON
		}
		modifier = { #Counts
			primary_title.tier = tier_county
			add = -25
			desc = ACTIVITY_GUEST_LANDLESS_REASON
		}
		modifier = { #Barons
			primary_title.tier = tier_barony
			add = -5
			desc = ACTIVITY_GUEST_LANDLESS_REASON
		}
	}

	###################
	# GRAPHICS
	###################

	#Backgrounds mostly not needed here
	background = {	#Campfire
		trigger = {
			scope:host.location = scope:activity.activity_location
		}
		texture = "gfx/interface/illustrations/event_scenes/ep3_campfire.dds"
		environment = "environment_event_bp1_bonfire"
		ambience = "event:/SFX/Events/Backgrounds/burning_building"
	}

	### Plug in widgets
	activity_window_widgets = {
		activity_special_type_progression = "activity_plugin_widgets_summary"
	}

	window_characters = {
		guest = {
			camera = camera_body_right

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					every_attending_character = {
						limit = {
							location = scope:activity.activity_location
							this != scope:host
						}
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						always = yes
					}
					animation = { drink_goblet happiness flirtation throne_room_conversation_3 throne_room_conversation_1 instrument_idle alto_flute_active }
				}
			}
		}

		#Guest of Honor
		guest = {
			camera = camera_body

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
						any_attending_character = {
							this = scope:activity.special_guest:camp_party_honorary_guest
							location = scope:activity.activity_location
						}
					}
					every_attending_character = {
						limit = {
							this = scope:activity.special_guest:camp_party_honorary_guest
							location = scope:activity.activity_location
						}
						add_to_list = characters
					}
				}
				else = {
					every_attending_character = {
						limit = {
							location = scope:activity.activity_location
							this != scope:host
						}
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = shy }
					}
					animation = { worry stress boredom fear disbelief paranoia eyeroll drink drink_goblet }
				}
				triggered_animation = {
					trigger = {
						scope:character = {
							NOT = { has_trait = shy }
						}
					}
					animation = { ecstasy wedding_priest chaplain personality_honorable personality_bold hero_flex }
				}
				#Fallback
				animation = toast_goblet
			}
		}

		host = {
			camera = camera_body

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}
			scripted_animation = {
				triggered_animation = {
					trigger = {
						always = yes
					}
					animation = { toast_goblet toast lute_active }
				}
			}
		}

		guest = {
			camera = camera_body

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					every_attending_character = {
						limit = {
							location = scope:activity.activity_location
							this != scope:host
						}
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = shy }
					}
					animation = { worry stress boredom fear disbelief paranoia eyeroll drink drink_goblet }
				}
				triggered_animation = {
					trigger = {
						scope:character = {
							NOT = { has_trait = shy }
						}
					}
					animation = { dancing laugh throne_room_conversation_2 }
				}
				#Fallback
				animation = toast
			}
		}

		guest = {
			camera = camera_body_left

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					every_attending_character = {
						limit = {
							location = scope:activity.activity_location
							this != scope:host
						}
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = { has_trait = shy }
					}
					animation = { worry stress boredom fear disbelief paranoia eyeroll drink drink_goblet }
				}
				triggered_animation = {
					trigger = {
						scope:character = {
							NOT = { has_trait = shy }
						}
					}
					animation = { drink eavesdrop wedding_drunk instrument_active }
				}
				#Fallback
				animation = toast
			}
		}
	}
}
