﻿#EK NOTE: disabled vanilla buildings in background triggers #EK TODO: add our own buildings in there

activity_journey = {

	is_shown = {
		has_bp3_dlc_trigger = yes
		highest_held_title_tier >= tier_county
		is_adult = yes
	}

	can_always_plan = no

	can_start_showing_failures_only = {
		has_perk = journey_perk
		is_available = yes
		age >= 16
	}

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

	is_location_valid = {
		any_journey_point_of_interest_trigger = yes
		# Check that you are within reach of the point of interest
		## If they have a liege, you have to be in range of the top liege. Otherwise you get some funky effects
		trigger_if = {
			limit = {
				inspired_journey_trigger = yes
			}
			custom_tooltip = {
				text = journey_activity_within_range
				trigger_if = {
					limit = {
						exists = root.county.holder
					}
					scope:host = { in_diplomatic_range = root.county.holder }
					trigger_if = {
						limit = {
							exists = root.county.holder.top_liege
						}
						scope:host = { in_diplomatic_range = root.county.holder.top_liege }
					}
				}
			}
		}
		trigger_if = {
			limit = {
				scope:host = { has_variable_list = visited_monument_exploration }
			}
			custom_tooltip = {
				text = journey_activity_already_visited

				NOT = {
					scope:host = {
						is_target_in_variable_list = {
							name = visited_monument_exploration
							target = root
						}
					}
				}
			}
		}
	}

	on_enter_travel_state = {
		
	}

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

	on_complete = {

	}

	on_host_death = {
		invalidation_host_death_effect = yes
	}

	province_filter = all
	ai_province_filter = top_realm

	max_province_icons = 10000
	allow_zero_guest_invites = yes
	open_invite = no

	province_description = {
		desc = activity_roaming_province_desc
		first_valid = {
			triggered_desc = {
				trigger = {
					inspired_journey_trigger = yes
					"scope:host.capital_province.squared_distance(root)" <= squared_distance_small
				}
				desc = journey_activity_province_desc_very_close
			}
			triggered_desc = {
				trigger = {
					inspired_journey_trigger = yes
					"scope:host.capital_province.squared_distance(root)" > squared_distance_small
					"scope:host.capital_province.squared_distance(root)" <= squared_distance_medium
				}
				desc = journey_activity_province_desc_close
			}
			triggered_desc = {
				trigger = {
					inspired_journey_trigger = yes
					"scope:host.capital_province.squared_distance(root)" > squared_distance_medium
					"scope:host.capital_province.squared_distance(root)" <= squared_distance_large
				}
				desc = journey_activity_province_desc_close
			}
			triggered_desc = {
				trigger = {
					inspired_journey_trigger = yes
					"scope:host.capital_province.squared_distance(root)" > squared_distance_large
					"scope:host.capital_province.squared_distance(root)" <= squared_distance_huge
				}
				desc = journey_activity_province_desc_medium_distance
			}
			triggered_desc = {
				trigger = {
					inspired_journey_trigger = yes
					"scope:host.capital_province.squared_distance(root)" > squared_distance_huge
					"scope:host.capital_province.squared_distance(root)" <= squared_distance_almost_massive
				}
				desc = journey_activity_province_desc_medium_distance
			}
			triggered_desc = {
				trigger = {
					inspired_journey_trigger = yes
					"scope:host.capital_province.squared_distance(root)" > squared_distance_almost_massive
				}
				desc = journey_activity_province_desc_long_distance
			}
		}
		triggered_desc = {
			trigger = {
				has_travel_point_of_interest = poi_special_buildings_wonder
			}
			desc = journey_activity_province_desc_special_buildings
		}
		triggered_desc = {
			trigger = {
				has_travel_point_of_interest = poi_special_buildings_martial
			}
			desc = journey_activity_province_desc_special_buildings
		}
		triggered_desc = {
			trigger = {
				has_travel_point_of_interest = poi_special_buildings_learning
			}
			desc = journey_activity_province_desc_special_buildings
		}
		triggered_desc = {
			trigger = {
				has_travel_point_of_interest = poi_special_buildings_religious
			}
			desc = journey_activity_province_desc_special_buildings
		}
		triggered_desc = {
			trigger = {
				has_travel_point_of_interest = poi_special_buildings_diplomatic
			}
			desc = journey_activity_province_desc_special_buildings
		}
		triggered_desc = {
			trigger = {
				has_travel_point_of_interest = poi_special_buildings_economic
			}
			desc = journey_activity_province_desc_special_buildings
		}
		triggered_desc = {
			trigger = {
				scope:host = { 
					has_variable_list = extra_journey_target 
					is_target_in_variable_list = {
						name = extra_journey_target
						target = root
					}
				}
			}
			desc = journey_activity_province_desc_inspired_journey
		}
		triggered_desc = {
			trigger = {
				OR = {
					has_province_modifier = inspection_proteted_poi_levy_modifier
					has_province_modifier = inspection_protected_holy_poi_levy_modifier
					has_province_modifier = inspection_protected_poi_gold_modifier
					has_province_modifier = inspection_protected_holy_poi_gold_modifier
				}
			}
			desc = journey_activity_province_desc_inspection_modifier
		}
	}

	province_score = {
		add = journey_province_reference_value
	}

	cost = {
		gold = {
			add = {
				value = standard_journey_activity_cost
				desc = hunt_base_cost
			}
		}
	}

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

	cooldown = { years = 3 }

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

	phases = {
		phase_experience = {
			cost = {
				gold = {
					add = {
						value = major_gold_value
						desc = pilgrimage_cost_distance
						
						if = {
							limit = { exists = scope:province }
							#Tier 0
							if = {
								limit = { "capital_province.squared_distance(scope:province)" <= squared_distance_small }
								subtract = medium_gold_value
							}
							#Tier 1
							else_if = {
								limit = {
									"capital_province.squared_distance(scope:province)" > squared_distance_small
									"capital_province.squared_distance(scope:province)" <= squared_distance_medium
								}
								multiply = {
									value = 0.2
									multiply = journey_inspired_journey_costs_value
								}
							}
							#Tier 2: Praha -> Cologne
							else_if = {
								limit = {
									"capital_province.squared_distance(scope:province)" > squared_distance_medium
									"capital_province.squared_distance(scope:province)" <= squared_distance_large
								}
								multiply = {
									value = 0.4
									multiply = journey_inspired_journey_costs_value
								}
							}
							#Tier 3
							else_if = {
								limit = {
									"capital_province.squared_distance(scope:province)" > squared_distance_large
									"capital_province.squared_distance(scope:province)" <= squared_distance_huge
								}
								multiply = {
									value = 0.6
									multiply = journey_inspired_journey_costs_value
								}
							}
							#Tier 4
							else_if = {
								limit = {
									"capital_province.squared_distance(scope:province)" > squared_distance_huge
									"capital_province.squared_distance(scope:province)" <= squared_distance_almost_massive
								}
								multiply = {
									value = 0.8
									multiply = journey_inspired_journey_costs_value
								}
							}
							#Tier 5
							else_if = {
								limit = {
									"capital_province.squared_distance(scope:province)" > squared_distance_almost_massive
								}
								multiply = {
									value = 1
									multiply = journey_inspired_journey_costs_value
								}
							}
						}
						multiply = activity_cost_scale_by_era
					}
				}
			}

			is_predefined = yes
			location_source = pickable

			on_phase_active = {
				scope:activity.activity_location = { save_scope_as = province }
				visiting_monument_exploration_effect = yes
				if = {
					limit = {
						this = scope:host
					}
					scope:activity = { progress_activity_phase_after = { days = 34 } }
				}
				trigger_event = { id = bp3_journey.0005 }
				trigger_event = {
					on_action = random_journey_event_pulse
					days = 5
				}
				trigger_event = {
					id = bp3_journey.0015
					days = 12
				}
				if = {
					limit = {
						scope:host = {
							has_variable_list = extra_journey_target
							is_target_in_variable_list = {
								name = extra_journey_target
								target = scope:activity.activity_location
							}
						}
					}
					scope:host = {
						send_interface_message = {
							title = destination_events.30.toast.title
							left_icon = root
							if = {
								limit = { exists = scope:province }
								if = {
									limit = { "capital_province.squared_distance(scope:province)" <= squared_distance_large }
									add_wanderer_lifestyle_xp = 500
								}
								else_if = {
									limit = {
										"capital_province.squared_distance(scope:province)" > squared_distance_large
										"capital_province.squared_distance(scope:province)" <= squared_distance_huge
									}
									add_wanderer_lifestyle_xp = 750
								}
								else_if = {
									limit = {
										"capital_province.squared_distance(scope:province)" > squared_distance_huge
										"capital_province.squared_distance(scope:province)" <= squared_distance_monstrous
									}
									add_wanderer_lifestyle_perk_points = 1
								}
								else_if = {
									limit = {
										"capital_province.squared_distance(scope:province)" > squared_distance_monstrous
									}
									add_wanderer_lifestyle_perk_points = 2
								}
							}
							else = {
								add_wanderer_lifestyle_xp = 500
							}
						}
						remove_list_variable = {
							name = extra_journey_target
							target = scope:activity.activity_location
						}
					}
				}
				trigger_event = {
					on_action = random_journey_event_pulse
					days = 19
				}
				trigger_event = {
					on_action = random_journey_event_pulse
					days = 26
				}
				trigger_event = {
					id = bp3_journey.0010
					days = 33
				}
			}

			on_end = {
				#trigger_event = { id = bp3_journey.0010 }
			}
		}
	}
	
	

	options = {
		journey_option_scribes = {
			journey_no_scribes = {
				default = yes
				
				ai_will_do = {
					value = 100
					if = {
						limit = {
							short_term_gold >= massive_gold_value
						}
						add = -100
					}
				}
			}
			journey_skilled_scribes = {

				cost = {
					gold = {
						add = {
							value = major_gold_value
							if = {
								limit = {
									has_perk = journey_planner_perk
								}
								multiply = {
									value = voyager_journey_planner_value
									desc = journey_planner_perk_name
								}
							}
							desc = journey_skilled_scribes
						}
					}
				}
				
				ai_will_do = {
					value = 0
					if = {
						limit = {
							short_term_gold >= major_gold_value
						}
						add = 100
					}
				}
			}
		}
	}

	max_guest_arrival_delay_time = { months = 1 }
	
	
	###################
	# ACTIVITY-SPECIFIC PULSES
	###################
	
	pulse_actions = {
		entries = {
			apa_child_learns_something
			apa_scribe_makes_notes
			apa_spotted_by_locals
			apa_vista_of_monument
			apa_spouse_learns_something
			apa_monument_insight
			apa_ate_local_food
			apa_entourage_stops_pickpocket
			apa_cultural_mingling
			apa_strange_markings
			apa_regional_story
			apa_legend_spreads
		}
		chance_of_no_event = 0
	}

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

	# desc is only shown in debug AI watch window
	ai_will_do = {
		value = 100
		
		if = {
			limit = {
				has_trait = lazy
			}
			add = -25
		}
		
		#Can you actually afford this?
		if = {
			limit = {
				NOT = { can_make_expensive_purchase_trigger = { PRICE = activity_minor_gold_value } }
			}
			add = -125
		}
	}

	ai_check_interval = 36

	ai_will_select_province = {
		value = 10
	}

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

	host_intents = {
		default = journey_knowledge_hoarding_intent
		intents = { journey_knowledge_hoarding_intent journey_curiosity_intent spread_legend_intent }
	}

	guest_intents = {
		intents = { journey_knowledge_hoarding_intent }
		default = journey_knowledge_hoarding_intent
	}

	can_be_activity_guest = {
		court_owner ?= scope:host
	}

	#guest_invite_rules = {
	#	defaults = {
	#		1 = activity_invite_rule_friends
	#		1 = activity_invite_rule_close_family
	#		1 = activity_invite_spouses
	#		1 = activity_invite_rule_knights
	#		1 = activity_invite_rule_lovers
	#	}
	#}

	travel_entourage_selection = {
		weight = {
			value = standard_travel_entourage_additions
			if = {
				limit = {
					court_owner ?= scope:host
					is_healthy = yes
					is_available = yes
					age >= 6
				}
				if = {
					limit = {
						OR = {
							is_player_heir_of = scope:owner
							is_primary_heir_of = scope:owner
							has_relation_ward = scope:owner
						}
					}
					add = 100
				}
				if = {
					limit = {
						OR = {
							is_consort_of = scope:owner
							is_heir_of = scope:owner
						}
					}
					add = 50
				}
				if = {
					limit = {
						OR = {
							has_relation_friend = scope:owner
							has_relation_lover = scope:owner
						}
					}
					add = 10
				}
				if = {
					limit = {
						OR = {
							is_knight_of = scope:owner
							is_close_family_of = scope:owner
						}
					}
					add = 5
				}
			}
		}

		# 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 = 200

	guest_join_chance = {
		base = 10
	}
	
	on_enter_passive_state = {
		if = {
			limit = { root = scope:host }
			scope:activity = { progress_activity_phase_after = { days = 1 } }
		}
	}

	on_enter_active_state = {
		surveyor_no_stone_unturned_perk_effect = yes
	}

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

	# Travel
	background = { # Bridge
		trigger = {
			NOT = { scope:host.location = scope:activity.activity_location }
			scope:host.location = {
				is_riverside_province = yes
				geographical_region = ek_graphical_europe_like #EK EDIT
				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 = { # Farmland, settled
		trigger = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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 = {
			NOT = { 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"
	}
	
	## Most fitting based on special building type
	#EK DISABLED
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = holy_site_great_mosque_of_mecca_01
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_mecca.dds"
	#	environment = "environment_mecca"
	#	ambience = "event:/SFX/Events/Backgrounds/town_market_middleeastern_day"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = dome_of_the_rock_01
	#					has_building_or_higher = temple_in_jerusalem_01
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_jerusalem.dds"
	#	environment = "environment_jerusalem"
	#	ambience = "event:/SFX/Events/Backgrounds/town_market_middleeastern_day"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = hagia_sophia_01
	#					has_building_or_higher = hagia_sophia_02
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep3_hagia_sophia.dds"
	#	# TODO_CD_EP3: update environment and ambience
	#	environment = "environment_mecca"
	#	ambience = "event:/SFX/Events/Backgrounds/town_market_middleeastern_day"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = church_of_the_theotokos
	#					has_building_or_higher = parthenon
	#					has_building_or_higher = hagios_demetrios
	#					has_building_or_higher = saint_lazarus
	#					has_building_or_higher = sumela_monastery_01
	#					has_building_or_higher = sumela_monastery_02
	#					has_building_or_higher = meteora_01
	#					has_building_or_higher = meteora_02
	#					has_building_or_higher = mount_athos_01
	#					has_building_or_higher = mount_athos_02
	#					has_building_or_higher = mount_athos_03
	#					has_building_or_higher = apollinare_nuovo
	#					has_building_or_higher = saint_catherine
	#					has_building_or_higher = jvari_monastery
	#					has_building_or_higher = etchmiadzin_cathedral
	#					has_building_or_higher = cattolica_stilo
	#					has_building_or_higher = hosios_loukas
	#					has_building_or_higher = sofia_ohrid
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep3_holysite_orthodox.dds"
	#	# TODO_CD_EP3: Update environment and ambience
	#	environment = "environment_event_fp3_temple"
	#	ambience = "event:/DLC/FP1/SFX/Events/event_temple"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = holy_site_imam_ali_mosque_01
	#					has_building_or_higher = holy_site_great_mosque_of_mecca_01
	#					has_building_or_higher = holy_site_great_mosque_of_cordoba_01
	#					has_building_or_higher = holy_site_great_mosque_of_djenne_01
	#					has_building_or_higher = holy_site_great_mosque_of_samarra_01
	#					has_building_or_higher = holy_site_prophetic_mosque_01
	#					has_building_or_higher = the_friday_mosque_01
	#					has_building_or_higher = imam_reza_shrine_01
	#					has_building_or_higher = minarets_and_remains_of_jam_01
	#					has_building_or_higher = tomb_of_cyrus_01
	#					has_building_or_higher = shah_i_zinda_01
	#					has_building_or_higher = shah_i_zinda_02
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_mena.dds"
	#	environment = "environment_generic_holy_site_mena"
	#	ambience = "event:/SFX/Events/Backgrounds/town_market_middleeastern_day"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = holy_site_mahabodhi_temple_01
	#					has_building_or_higher = buddhas_of_bamian_01
	#					has_building_or_higher = brihadeeswarar_temple_01
	#					has_building_or_higher = shwedagon_pagoda_01
	#					has_building_or_higher = ananda_temple_01
	#					has_building_or_higher = khajuraho_01
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_indian.dds"
	#	environment = "environment_indian_holy_site"
	#	ambience = "event:/SFX/Events/Backgrounds/deciduous_forest_day"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = holy_site_cologne_cathedral_01
	#					has_building_or_higher = holy_site_canterbury_cathedral_01
	#					has_building_or_higher = holy_site_canterbury_cathedral_02
	#					has_building_or_higher = holy_site_canterbury_cathedral_03
	#					has_building_or_higher = notre_dame_01
	#					has_building_or_higher = temple_of_uppsala_02
	#					has_building_or_higher = lund_cathedral_01
	#					has_building_or_higher = holy_site_basilica_santiago_01
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_western.dds"
	#	environment = "environment_western_holy_site"
	#	ambience = "event:/SFX/Events/Backgrounds/temple_christian"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = heddal_stave_church_01
	#					has_building_or_higher = temple_of_uppsala_01
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_tribal.dds"
	#	environment = "environment_event_garden"
	#	ambience = "event:/DLC/FP1/SFX/Events/event_temple"
	#}

#	## Mining Settlements use Markets
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				has_building_with_flag = travel_point_of_interest_economic
	#				OR = {
	#					geographical_region = mediteranean_coast
	#					geographical_region = world_asia_minor
	#					culture ?= { has_graphical_mediterranean_culture_group_trigger = yes }
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/ep3_medi_market.dds"
	#	# TODO_CD_EP3: update environment and ambience
	#	environment = "environment_event_courtyard"
	#	ambience = "event:/DLC/FP2/SFX/Events/courtyard"
	#}
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				has_building_with_flag = travel_point_of_interest_economic
	#				OR = {
	#					geographical_region = graphical_mena
	#					geographical_region = graphical_india
	#					culture ?= { has_building_gfx = iranian_building_gfx }
	#					AND = {
	#						geographical_region = world_europe_west_iberia
	#						faith ?= { religion = religion:islam_religion }
	#					}
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/market_east.dds"
	#	environment = "environment_event_market_east"
	#	ambience = "event:/SFX/Events/Backgrounds/town_market_middleeastern_day"
	#}
	background = {
		trigger = {
			scope:activity ?= {
				activity_location = {
					has_building_with_flag = travel_point_of_interest_economic
					province_owner ?= {
						OR = {
							government_has_flag = government_is_clan
							government_has_flag = government_is_tribal
						}
					}
					NOT = {
						geographical_region = graphical_mena
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/market_tribal.dds"
		environment = "environment_event_market_tribal"
		ambience = "event:/SFX/Events/Backgrounds/townmarket_day_tribal_pagan"
	}
	background = {
		trigger = {
			scope:activity ?= {
				activity_location = {
					has_building_with_flag = travel_point_of_interest_economic
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/market_west.dds"
		environment = "environment_event_market_west"
		ambience = "event:/SFX/Events/Backgrounds/townmarket_western_day"
	}

	
	## Mountain-based natural wonder
	background = {
		trigger = {
			scope:activity ?= {
				activity_location = {
					#EK EDIT
					OR = {
						has_building_or_higher = fang_lair_01
						has_building_or_higher = predator_mesa_01
						has_building_or_higher = ontus_quarry_01
						has_building_or_higher = torugs_tomb_01
					}
					#EK EDIT END
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_travel_mountains.dds"
		environment = "environment_travel_mountain_settlement"
		ambience = "event:/SFX/Events/Backgrounds/mountains_day"
	}

	#EK DISABLED
	## Desert Lake-based natural wonder
	#background = {
	#	trigger = {
	#		scope:activity ?= {
	#			activity_location = {
	#				OR = {
	#					has_building_or_higher = maharloo_lake_01
	#				}
	#			}
	#		}
	#	}
	#	texture = "gfx/interface/illustrations/event_scenes/fp4_legendary_oasis.dds"
	#	environment = "environment_ce1_legendary_oasis"
	#	ambience = "event:/SFX/Events/Backgrounds/FP4/fp4_magic_spring"
	#}

	# Nordic
	background = {
		trigger = {
			scope:activity ?= {
				activity_location.culture = {
					has_graphical_norse_culture_group_trigger = yes
				}
			}
		}
		texture = "gfx/interface/illustrations/activity_splash_screens/tour_arrival_norse_neutral.dds"
		environment = "environment_ep2_tour_arrival_norse_neutral" 
		ambience = "event:/SFX/Events/Backgrounds/camp_generic_day" 
	}
	# Tribal
	background = {
		trigger = {
			scope:activity ?= {
				activity_location.county.holder = { #Local Host
					OR = {
						should_use_tribal_realm_palace_graphics_trigger = yes
						culture = { has_graphical_steppe_culture_group_trigger = yes }
					}
				}
			}
		}

		texture = "gfx/interface/illustrations/activity_splash_screens/tour_arrival_tribal_neutral.dds"
		environment = "environment_ep2_tour_arrival_tribal_neutral" 
		ambience = "event:/SFX/Events/Backgrounds/camp_generic_day" 
	}
	# MENA
	background = {
		trigger = {
			scope:activity ?= {
				activity_location.culture = {
					OR = {
						has_graphical_mena_culture_group_trigger = yes
						has_building_gfx = iranian_building_gfx
					}
				}
			}
		}

		texture = "gfx/interface/illustrations/activity_splash_screens/tour_arrival_mena_neutral.dds"
		environment = "environment_ep2_tour_arrival_mena_neutral" 
		ambience = "event:/SFX/Events/Backgrounds/camp_generic_day" 
	}
	# Iberian
	background = {
		trigger = {
			scope:activity ?= {
				activity_location.culture = {
					has_graphical_iberian_culture_group_trigger = yes
				}
			}
		}

		texture = "gfx/interface/illustrations/activity_splash_screens/tour_arrival_iberian_neutral.dds"
		environment = "environment_ep2_tour_arrival_iberian_neutral" 
		ambience = "event:/SFX/Events/Backgrounds/camp_generic_day" 
	}
	# Indian
	background = {
		trigger = {
			scope:activity ?= {
				activity_location.culture = {
					has_graphical_india_culture_group_trigger = yes
				}
			}
		}

		texture = "gfx/interface/illustrations/activity_splash_screens/tour_arrival_indian_neutral.dds"
		environment = "environment_ep2_tour_arrival_indian_neutral" 
		ambience = "event:/SFX/Events/Backgrounds/camp_generic_day" 
	}
	# Western
	background = {
		trigger = {
			always = yes
		}

		texture = "gfx/interface/illustrations/activity_splash_screens/tour_arrival_western_neutral.dds"
		environment = "environment_ep2_tour_arrival_western_neutral" 
		ambience = "event:/SFX/Events/Backgrounds/camp_generic_day" 
	}

	window_characters = {
	
		guest = {
			camera = camera_body_left
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					if = {
						limit = {
							any_attending_character = {
								is_primary_heir_of = scope:host
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
						}
						every_attending_character = {
							limit = {
								is_primary_heir_of = scope:host
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
					else_if = {
						limit = {
							any_attending_character = {
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
						}
						every_attending_character = {
							limit = {
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
					else = {
						every_attending_character = {
							limit = {
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						always = yes
					}
					animation = { reading }
				}
			}
		}
		
		

		guest = {
			camera = camera_body_left_slight
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					if = {
						limit = {
							any_attending_character = {
								has_character_flag = generated_scribe
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
						}
						every_attending_character = {
							limit = {
								has_character_flag = generated_scribe
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
					else = {
						every_attending_character = {
							limit = {
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						always = yes
					}
					animation = { happy_teacher }
				}
			}
		}
		
		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 = { survey }
				}
			}
		}
		
		travel_host = {
			camera = camera_event_horse_left
			
			effect = {
				if = {
					limit = {
						NOT = {
							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 = {
								is_consort_of = scope:host
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
						}
						every_attending_character = {
							limit = {
								is_consort_of = scope:host
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
					else_if = {
						limit = {
							any_attending_character = {
								NOT = { is_primary_heir_of = scope:host }
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
						}
						every_attending_character = {
							limit = {
								NOT = { is_primary_heir_of = scope:host }
								OR = {
									is_child_of = scope:host
									is_grandchild_of = scope:host
								}
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
					else = {
						every_attending_character = {
							limit = {
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						always = yes
					}
					animation = { page_flipping }
				}
			}
		}
		
		

		guest = {
			camera = camera_body_right
			
			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					if = {
						limit = {
							any_attending_character = {
								has_character_flag = generated_scribe
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
						}
						every_attending_character = {
							limit = {
								has_character_flag = generated_scribe
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
					else = {
						every_attending_character = {
							limit = {
								location = scope:activity.activity_location
								NOT = {
									this = scope:host
								}
							}
							add_to_list = characters
						}
					}
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						always = yes
					}
					animation = { writing }
				}
			}
		}
	}
}
