activity_survey = {
	is_shown = {
		OR = {
			has_bp3_dlc_trigger = yes
			has_tgp_dlc_trigger = yes
			has_ep3_dlc_trigger = yes
		}
		highest_held_title_tier >= tier_county
		is_adult = yes
		government_has_flag = government_is_settled
		#Every other activity must be blocked until an uncrowned AI crowns themselves
		trigger_if = {
			limit = {
				is_ai = yes
			}
			NOT = {
				has_realm_law = uncrowned
			}
		}
		OR = {
			has_perk = local_inspection_perk
			government_allows = administrative
			faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
		}
		trigger_if = { # Small AI's pace themselves more
			limit = {
				is_ai = yes
			}
			sub_realm_size > 1
		}
		trigger_else = {
			sub_realm_size >= 1
		}
	}

	can_always_plan = no

	can_start_showing_failures_only = {
		NOT = { is_activity_type_on_cooldown = activity_survey }
		#Trigger if chain for good DLC dependent tooltips:
		#If I  lack both DLC this never shows.
		trigger_if = { #I have BP3 only - I need the perk
			limit = {
				has_bp3_dlc_trigger  = yes
				NOR = {
					has_ep3_dlc_trigger = yes
					has_tgp_dlc_trigger = yes
				}
			}
			has_perk = local_inspection_perk
		}
		trigger_else_if = { #I have both TGP/EP3 and BP3
			limit = {
				OR = {
					has_ep3_dlc_trigger = yes
					has_tgp_dlc_trigger = yes
				}
				has_bp3_dlc_trigger = yes
			}
			custom_tooltip = {
				text = neither_local_inspection_perk_nor_merit
				OR = {
					has_perk = local_inspection_perk
					government_allows = administrative
					faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
				}
			}
		}
		trigger_else_if = { #I have only TGP/EP3 - I am required to have a bureaucratic government form (i.e. admin based).
			limit = {
				OR = {
					has_ep3_dlc_trigger = yes
					has_tgp_dlc_trigger = yes
				}
				has_bp3_dlc_trigger = no
			}
			OR = {
				government_allows = administrative
				faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
			}
		}
		trigger_else = {
			always = no
		}
		is_available = yes
		is_landed = yes
		age >= 16
	}

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

	is_location_valid = {
		trigger_if = {
			limit = {
				scope:host = {
					is_governor = no
				}
			}
			custom_tooltip = {
				text = survey_activity_not_capital
				this != scope:host.capital_province	
			}
		}
		trigger_if = {
			limit = {
				scope:host = { has_variable_list = recently_visited_inspection }
			}
			custom_tooltip = {
				text = survey_activity_on_cooldown
				scope:host = {
					NOT = {
						is_target_in_variable_list = {
							name = recently_visited_inspection
							target = root
						}
					}
				}
			}
		}
		trigger_if = {
			limit = {
				scope:host = { is_ai = yes }
			}
			county.holder = scope:host
		}
		is_county_capital = yes
	}

	on_start = {
		set_variable = {
			name = inspection_success_chance
			value = inspection_success_chance_value
		}
		scope:host = {
			switch = {
				trigger = has_variable
				inspection_activity_border_focus = { remove_variable = inspection_activity_border_focus }
				inspection_activity_bureaucracy_focus = { remove_variable = inspection_activity_bureaucracy_focus }
				inspection_activity_domain_focus = { remove_variable = inspection_activity_domain_focus }
			}
			switch = {
				trigger = has_variable
				inspection_activity_border_vassal_focus = { remove_variable = inspection_activity_border_vassal_focus }
				inspection_activity_border_claim_focus = { remove_variable = inspection_activity_border_claim_focus }
				inspection_activity_bureaucracy_tax_focus = { remove_variable = inspection_activity_bureaucracy_tax_focus }
				inspection_activity_bureaucracy_development_focus = { remove_variable = inspection_activity_bureaucracy_development_focus }
				inspection_activity_bureaucracy_control_focus = { remove_variable = inspection_activity_bureaucracy_control_focus }
				inspection_activity_domain_levy_focus = { remove_variable = inspection_activity_domain_levy_focus }
				inspection_activity_domain_opinion_focus = { remove_variable = inspection_activity_domain_opinion_focus }
				inspection_activity_domain_popular_focus = { remove_variable = inspection_activity_domain_popular_focus }
			}
			add_to_variable_list = {
				name = recently_visited_inspection
				target = scope:activity.activity_location
				years = 5
			}
		}
		scope:host = {
			if = {
				limit = {
					has_character_flag = free_inspection
				}
				remove_character_flag = free_inspection
			}
		}
	}

	on_enter_travel_state = {
		
	}

	on_invalidated = {
		invalidation_imprisoned_effect = yes
		invalidation_incapable_effect = yes
		invalidation_unlanded_effect = yes
	}

	on_complete = {

	}

	on_enter_active_state = {
		surveyor_no_stone_unturned_perk_effect = yes
		if = {
			limit = {
				this = scope:host
				has_perk = personal_touch_perk
			}
			location.county = {
				local_adjudicate_effect = yes
			}
		}
	}

	on_host_death = {
		invalidation_host_death_effect = yes
	}

	province_filter = realm
	ai_province_filter = realm

	max_province_icons = 3
	allow_zero_guest_invites = yes
	open_invite = no

	province_description = {
		desc = activity_survey_province_desc
		first_valid = {
			triggered_desc = {
				trigger = {
					county = {
						any_neighboring_county = {
							exists = holder
							holder.top_liege != root.county.holder.top_liege
						}
					}
				}
				desc = survey_border_county
			}
			triggered_desc = {
				trigger = {
					scope:host = { top_liege != this }
					county = {
						any_neighboring_county = {
							exists = holder
							holder.top_liege = root.county.holder.top_liege
							NOT = {
								holder = {
									OR = {
										is_vassal_of = scope:host 
										this = scope:host
									}
								}
							}
						}
					}
				}
				desc = survey_bordering_other_vassals_county
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					county.county_control <= 25
				}
				desc = survey_very_low_county_control
			}
			triggered_desc = {
				trigger = {
					county.county_control <= 50
				}
				desc = survey_low_county_control
			}
			triggered_desc = {
				trigger = {
					county.county_control <= 75
				}
				desc = survey_medium_county_control
			}
		}
	}

	province_score = {
		add = survey_province_reference_value
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
					NOR = {
						faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
						has_character_flag = free_inspection
					}
				}
				add = {
					value = standard_survey_activity_cost
					desc = hunt_base_cost
				}
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
					NOR = {
						faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
						has_character_flag = free_inspection
					}
				}
				add = {
					value = standard_survey_activity_cost
					desc = hunt_base_cost
				}
			}
		}
		piety = {
			value = 0
			if = {
				limit = {
					faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
					NOT = { has_character_flag = free_inspection }
				}
				add = {
					value = standard_survey_activity_cost
					desc = hunt_base_cost
				}
			}
		}
	}

	ui_predicted_cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
					NOR = {
						faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
						has_character_flag = free_inspection
					}
				}
				add = {
					# Base Cost
					value = standard_survey_activity_cost
					# Make it a multiple of 5 (rounded up)
					divide = 5 
					ceiling = yes 
					multiply = 5
				}
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
					NOR = {
						faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
						has_character_flag = free_inspection
					}
				}
				add = {
					# Base Cost
					value = standard_survey_activity_cost
					# Make it a multiple of 5 (rounded up)
					divide = 5 
					ceiling = yes 
					multiply = 5
				}
			}
		}
		piety = {
			value = 0
			if = {
				limit = {
					faith = { has_doctrine_parameter = inspections_unlocked_and_costs_piety }
					NOT = { has_character_flag = free_inspection }
				}
				add = {
					# Base Cost
					value = standard_survey_activity_cost
					# Make it a multiple of 5 (rounded up)
					divide = 5 
					ceiling = yes 
					multiply = 5
				}
			}
		}
	}

	cooldown = { years = 2 }

	###################
	# PHASES
	###################

	phases = {
		phase_surveying = {
			is_predefined = yes
			location_source = pickable

			on_phase_active = {
				if = {
					limit = {
						this = scope:host
					}
					scope:activity = { progress_activity_phase_after = { months = 2 } }
					trigger_event = { id = bp3_survey.0005 }
					trigger_event = {
						on_action = random_survey_first_event_pulse
						weeks = 2
					}
					trigger_event = {
						on_action = random_survey_mid_event_pulse
						months = 1
					}
					trigger_event = {
						on_action = random_survey_second_event_pulse
						weeks = 6
					}
					trigger_event = {
						id = bp3_survey.0010
						days = 59
					}
				}
			}

			on_end = {
				
			}
		}
	}

	options = {
		inspection_option_allocated_funds = {
			inspection_no_funding = {
				default = yes
			}
			inspection_small_fund = {
				cost = {
					gold = {
						value = 0
						if = {
							limit = {
								has_treasury = no
							}
							if = {
								limit = {
									NOT = { has_character_flag = free_inspection }
								}
								add = {
									value = 20
									multiply = {
										value = root.highest_held_title_tier
										subtract = 1
										divide = 2
										min = 1
									}
									multiply = {
										value = current_year
										subtract = 900
										divide = 2
										min = 100
										max = 300
										divide = 100
										ceiling = yes
									}
									desc = inspection_small_fund
								}
							}
						}
					}
					treasury = {
						value = 0
						if = {
							limit = {
								has_treasury = yes
							}
							if = {
								limit = {
									NOT = { has_character_flag = free_inspection }
								}
								add = {
									value = 20
									multiply = {
										value = root.highest_held_title_tier
										subtract = 1
										divide = 2
										min = 1
									}
									multiply = {
										value = current_year
										subtract = 900
										divide = 2
										min = 100
										max = 300
										divide = 100
										ceiling = yes
									}
									desc = inspection_small_fund
								}
							}
						}
					}
				}
			}
			inspection_large_fund = {
				cost = {
					gold = {
						value = 0
						if = {
							limit = {
								has_treasury = no
							}
							if = {
								limit = {
									NOT = { has_character_flag = free_inspection }
								}
								add = {
									value = 40
									multiply = {
										value = root.highest_held_title_tier
										subtract = 1
										divide = 2
										min = 1
									}
									multiply = {
										value = current_year
										subtract = 900
										divide = 2
										min = 100
										max = 300
										divide = 100
										ceiling = yes
									}
									desc = inspection_large_fund
								}
							}
						}
					}
					treasury = {
						value = 0
						if = {
							limit = {
								has_treasury = yes
							}
							if = {
								limit = {
									NOT = { has_character_flag = free_inspection }
								}
								add = {
									value = 40
									multiply = {
										value = root.highest_held_title_tier
										subtract = 1
										divide = 2
										min = 1
									}
									multiply = {
										value = current_year
										subtract = 900
										divide = 2
										min = 100
										max = 300
										divide = 100
										ceiling = yes
									}
									desc = inspection_large_fund
								}
							}
						}
					}
				}
			}
		}
	}

	max_guest_arrival_delay_time = { months = 1 }
	
	
	###################
	# ACTIVITY-SPECIFIC PULSES
	###################
	
	pulse_actions = {
		entries = {
			apa_survey_bad_harvest
			apa_survey_good_harvest
			apa_survey_bad_merchant_guild
			apa_survey_good_merchant_guild
			apa_survey_bad_noble
			apa_survey_good_noble
			apa_survey_tax_problems
			apa_survey_extra_taxes
			apa_survey_old_bridge
			apa_survey_bad_mercenaries
			apa_survey_good_mercenaries
			apa_survey_small_festival
			apa_survey_fishing_rights
			apa_survey_city_walls
			apa_survey_local_gift
		}
		chance_of_no_event = 0
	}

	###################
	# 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 = {
				NOT = { can_make_expensive_purchase_trigger = { PRICE = activity_minor_gold_value } }
			}
			add = -75
		}
	}

	ai_check_interval = 60

	ai_will_select_province = {
		value = 10
	}

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

	host_intents = {
		default = survey_overseer_intent
		intents = { survey_overseer_intent survey_learning_intent }
	}

	guest_intents = {
		intents = { survey_learning_intent_guest }
		default = survey_learning_intent_guest
	}

	can_be_activity_guest = {
		is_ai = yes
		court_owner ?= scope:host
		is_healthy = yes
		is_landed = no
		age >= 12
		OR = {
			is_knight_of = scope:host
			is_councillor_of = scope:host
			is_child_of = scope:host
			is_heir_of = scope:host
			is_spouse_of = scope:host
			is_consort_of = scope:host
			has_relation_ward = scope:host
			has_relation_friend = scope:host
			has_relation_lover = scope:host
		}
	}

	travel_entourage_selection = {
		weight = 1

		# Up to how many characters to select for a player
		max = 20
		
		# Up to how many characters to select for an AI
		ai_max = 15

		invite_rule_order = 1
	}

	max_guests = 20

	guest_join_chance = {
		base = 10
	}

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

	# Travel
	background = { # Bridge
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				is_riverside_province = yes
				geographical_region = world_europe
				OR = {
					terrain = farmlands
					terrain = plains
					terrain = mountains
					terrain = hills
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_bridge.dds"
		environment = "environment_travel_bridge"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #Rice Fields - If we have Paddy fields AND/or terraced hills
	#This goes before other terrain since it can override in many different terrains if built
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				terrain = farmlands
				OR = {
					terrain = terraced_hills
					has_building_or_higher = paddy_fields_01
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/tgp_rice_fields.dds"
		environment = "environment_tgp_rice_fields"
		ambience = "event:/DLC/EP4/SFX/Events/Event_Backgrounds/tgp_rice_fields"
	}

	background = { #Farmlands - East Asia
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				terrain = farmlands
				culture = { has_graphical_east_asia_culture_group_trigger = yes }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/tgp_farm_asia.dds"
		environment = "environment_tgp_farm_asia"
		ambience = "event:/DLC/EP4/SFX/Events/Event_Backgrounds/tgp_farm_asia"
	}
	
	background = { # Farmland, settled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				terrain = farmlands
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_farm.dds"
		environment = "environment_travel_farmlands"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { # Farmland, unsettled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				terrain = farmlands
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/farms.dds"
		environment = "environment_event_farms"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #Desert, settled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_desert_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_desert.dds"
		environment = "environment_travel_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}
	background = { #Desert, unsettled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_desert_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/desert.dds"
		environment = "environment_event_bp1_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}

	background = { #forest snowy
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location ?= { hunt_snowy_forest_trigger = yes }
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_hunt_snowy_forest.dds"
		environment = "environment_hunt_snowy_forest"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #forest_pine
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_forest_pine_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/forest_pine.dds"
		environment = "environment_event_forest_pine"
		ambience = "event:/SFX/Events/Backgrounds/coniferous_forest_day"
	}

	background = { #forest
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_forest_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/forest.dds"
		environment = "environment_event_forest"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #mountains, settled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_mountains_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
		environment = "environment_travel_mountain_settlement"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}
	background = { #mountains, unsettled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_mountains_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mountains.dds"
		environment = "environment_event_mountains"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	background = { #steppe, settled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_steppe_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_steppe.dds"
		environment = "environment_travel_steppe_settlement"
		ambience = "event:/SFX/Events/Backgrounds/steppe_day"
	}
	background = { #steppe, unsettled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_steppe_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/steppe.dds"
		environment = "environment_event_steppe"
		ambience = "event:/SFX/Events/Backgrounds/steppe_day"
	}

	background = { #drylands (formerly desert)
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_drylands_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/drylands.dds"
		environment = "environment_event_desert"
		ambience = "event:/SFX/Events/Backgrounds/desert_day"
	}

	background = { #wetlands
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_wetlands_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_wetlands.dds"
		environment = "environment_event_bp1_wetlands" 
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #jungle
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_wilderness_jungle_trigger = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_jungle.dds"
		environment = "environment_event_bp1_jungle"
		ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	}

	background = { #plains, settled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_plains_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_hills.dds"
		environment = "environment_travel_hills_settlement"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #plains, unsettled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_plains_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_plains.dds"
		environment = "environment_event_bp1_plains"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}

	background = { #hills, settled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_hills_trigger = yes
				exists = province_owner
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_hills.dds"
		environment = "environment_travel_hills_settlement"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #hills, unsettled
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				graphical_hills_trigger = yes
				NOT = { exists = province_owner }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_hills.dds"
		environment = "environment_event_bp1_hills"
		ambience = "event:/SFX/Events/Backgrounds/fields_farms_day"
	}
	background = { #Nomads and steppe tribals
		trigger = {
			scope:activity = {
				OR = {
					activity_host = { government_has_flag = government_is_nomadic }
					AND = {
						activity_host = { government_has_flag = government_is_tribal }
						activity_location.culture ?= { has_graphical_steppe_culture_group_trigger = yes }
					}
					AND = {
						is_landless_adventurer = yes
						activity_location.culture ?= { has_graphical_steppe_culture_group_trigger = yes }
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mpo_camp_steppe.dds"
		environment = "environment_mpo_camp_steppe"
		ambience = "event:/DLC/CE2/Events/Event_Images/mpo_camp_steppe"
	}
	background = {
		trigger = {
			scope:activity ?= {
				activity_location.county = title:c_byzantion
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep3_constantinople.dds"
		environment = "environment_ep3_constantinople"
		ambience = "event:/DLC/EP3/SFX/Events/Event_Images/ep3_evn_eventimage_constantinople" 
	}
	background = {	#FP2
		trigger = {
			scope:activity ?= {
				activity_location = {
					OR = {
						culture = { has_building_gfx = iberian_building_gfx }
						geographical_region = world_europe_west_iberia
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp2_courtyard.dds"
		environment = "environment_event_fp2_courtyard" 
		ambience = "event:/DLC/FP2/SFX/Events/courtyard" 
	}
	background = {	#Indian Courtyard
		trigger = {
			scope:activity ?= {
				activity_location ?= {
					OR = {
						culture = { has_graphical_india_culture_group_trigger = yes }
						steppe_building_gfx_use_indian_trigger = yes
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_courtyard_indian.dds"
		environment = "environment_event_bp1_courtyard_indian" 
		ambience = "event:/SFX/Events/Backgrounds/castle_courtyard_western"
	}
	background = {	#MENA Courtyard
		trigger = {
			scope:activity ?= {
				activity_location = {
					OR = {
						culture ?= { has_graphical_mena_culture_group_trigger = yes }
						culture ?= { has_building_gfx = iranian_building_gfx }
						steppe_building_gfx_use_mena_trigger = yes 
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp1_courtyard_mena.dds"
		environment = "environment_event_bp1_courtyard_mena"
		ambience = "event:/SFX/Events/Backgrounds/castle_courtyard_western"
	}
	background = { #East Asia
		trigger = {
			scope:activity.activity_location ?= {
				OR = {
					culture ?= { has_graphical_east_asia_culture_group_trigger = yes }
					steppe_building_gfx_use_east_asian_trigger = yes
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/tgp_courtyard_asia.dds"
		environment = "environment_tgp_courtyard_asia"
		ambience = "event:/DLC/EP4/SFX/Events/Event_Backgrounds/tgp_courtyard_asia"
	}
	background = { # Fallback
		texture = "gfx/interface/illustrations/event_scenes/bp2_courtyard.dds"
		environment = "environment_bp2_courtyard"
		ambience = "event:/DLC/FP2/SFX/Events/courtyard" 
	}

	window_characters = {
		guest = {
			camera = camera_body_left
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					if = {
						limit = {
							any_attending_character = {
								is_councillor_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
						}
						every_attending_character = {
							limit = {
								is_councillor_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
					else_if = {
						limit = {
							any_attending_character = {
								is_knight_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
						}
						every_attending_character = {
							limit = {
								is_knight_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
					else = {
						every_attending_character = {
							limit = {
								is_adult = yes
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
				}
			}

			scripted_animation = {
				animation = writing
			}
		}

		host = {
			camera = camera_body
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				animation = debating
			}
		}
		
		travel_host = {
			camera = camera_event_horse_left
			
			effect = {
				if = {
					limit = {
						scope:host.location != scope:activity.activity_location
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character.location = { is_sea_province = yes }
					}
					animation = { idle }
				}
				triggered_animation = {
					trigger = { scope:character = { has_trait = impatient } }
					animation = { jockey_gallop }
				}
				animation = jockey_walk
			}
		}

		guest = {
			camera = camera_body
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					if = {
						limit = {
							any_attending_character = {
								age >= 12
								is_primary_heir_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
						}
						every_attending_character = {
							limit = {
								age >= 12
								is_primary_heir_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
					else_if = {
						limit = {
							any_attending_character = {
								is_consort_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
						}
						every_attending_character = {
							limit = {
								is_consort_of = scope:host
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
					else_if = {
						limit = {
							any_attending_character = {
								age >= 12
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								this != scope:host
							}
						}
						every_attending_character = {
							limit = {
								age >= 12
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
					else = {
						every_attending_character = {
							limit = {
								location = scope:activity.activity_location
								this != scope:host
							}
							add_to_list = characters
						}
					}
				}
			}

			scripted_animation = {
				animation = survey
			}
		}
	}

	activity_window_widgets = {
		inspection_success_chance = "activity_plugin_widgets_summary"
	}
}
