﻿spiritual_retreat_jerusalem = {
	is_shown = {
		has_global_variable = restore_patriarchal_seat_jerusalem_cooldown
		faith = faith:orthodox
		highest_held_title_tier > tier_barony
		is_playable_character = yes
		trigger_if = {
			limit = {
				is_ai = yes
			}
			is_at_war = no
			ai_should_focus_on_building_in_their_capital = no
			ai_has_conqueror_personality = no
		}
	}
	can_start_showing_failures_only = {
		is_available = yes
	}
	is_valid = {
		scope:host = {
			is_imprisoned = no
			is_landed_or_landless_administrative = yes
			NOT = {
				is_incapable = yes
			}		
		}
	}
	on_invalidated = {
		if = {
			limit = {
				scope:host = { is_imprisoned = yes } 
			}
			scope:host = { trigger_event = bp2_adult_education.0005 }
		}
	}
	is_location_valid = {
		exists = province_owner
		province_owner.top_liege = scope:host.top_liege
	}

	is_single_location = yes
	province_filter = geographical_region
	ai_province_filter = geographical_region
	province_filter_target = jerusalem
	cooldown = {
		years = 10
	}
	wait_time_before_start = { days = 7 }
	max_province_icons = 1
	cost = {
		piety = {
			add = {
				value = 0
				if = {
					limit = {
						scope:province ?= {
							faith = {
								faith_hostility_level = {
									target = root.faith
									value >= faith_hostile_level
								}
							}
						}
					}
					add = {
						value = 0
						add = {
							value = medium_piety_value
							add = {
								value = medium_piety_value
								multiply = university_visit_activity_cost_scale_by_tier
								subtract = medium_piety_value
							}
						}
						desc = activity_cost_hostile_faith_desc
					}
				}
			}
		}
		gold = {
			add = {
				value = hunt_activity_base_cost
				desc = hunt_base_cost
			}
			add = {
				value = hunt_activity_base_cost
				multiply = activity_cost_scale_by_era
				subtract = hunt_activity_base_cost
				desc = activity_cost_scale_by_era_desc
			}
		}
	}
	ui_predicted_cost = {
		gold = {
			value = hunt_activity_base_cost
			multiply = activity_cost_scale_by_era
			subtract = hunt_activity_base_cost
			divide = 5
			ceiling = yes
			multiply = 5
		}
	}
	max_guest_arrival_delay_time = { months = 5 }
	on_start = {
		set_pilgrimage_distance_variable_effect = {
			PILGRIM = scope:host
			HOLY_SITE = scope:activity.activity_location
		}
	}
	phases = {
		jerusalem_first_phase = {
			order = 1
			is_predefined = yes
			is_shown = { }
			on_phase_active = {
				trigger_event = patriarchal_seats_events.1111
				if = {
					limit = { this = scope:host }
					scope:activity = { progress_activity_phase_after = { months = 3 } }
				}
			}
			on_end = {
				trigger_event = patriarchal_seats_events.1112
			}
		}

	}
	allow_zero_guest_invites = yes
	
	ai_will_do = {
		value = 20
		add = learning
		add = {
            value = ai_greed
            multiply = -0.25
            desc = "ai_greed"
        }
        add = {
        	value = ai_sociability
        	multiply = 0.25
        	desc = "ai_sociability"
        }
        add = {
        	value = ai_rationality
        	multiply = 0.25
        	desc = "ai_rationality"
        }
		if = {
			limit = {
				ai_energy < 0
			}
			add = {
				add = ai_energy
				desc = "ai_energy"
			}
		}
		if = {
			limit = {
				liege = { has_ongoing_grand_activity_trigger = yes }
			}
			desc = "Liege grand activities"
			add = -1000
		}
		if = {
			limit = {
				highest_held_title_tier >= tier_kingdom
			}
			desc = "Kings/Emperors more likely"
			add = 20
		}
		# Personality
		if = {
			limit = { has_trait = greedy }
			add = {
				value = -20
				desc = greedy
			}
		}
		if = {
			limit = { has_trait = impatient }
			add = {
				value = -20
				desc = impatient
			}
		}
		if = {
			limit = { has_trait = lazy }
			add = {
				value = -100
				desc = lazy
			}
		}
		if = {
			limit = {
				government_has_flag = government_is_tribal
			}
			add = {
				value = -50
				desc = government_is_tribal
			}
		}
		if = {
			limit = { has_trait = reclusive }
			add = {
				value = -100
				desc = lazy
			}
		}
		if = { # Likes to socialize
			limit = { has_trait = gregarious }
			add = {
				value = 20
				desc = gregarious
			}
		}
		if = {
			limit = { has_trait = shy }
			add = {
				value = -10
				desc = shy
			}
		}
		if = {
			limit = { has_trait = diligent }
			add = {
				value = 50
				desc = diligent
			}
		}
		if = {
			limit = { has_trait = humble }
			add = {
				value = 10
				desc = humble
			}
		}
		if = {
			limit = { has_trait = gregarious }
			add = {
				value = 20
				desc = gregarious
			}
		}
		if = {
			limit = { has_trait = ambitious }
			add = {
				value = 20
				desc = ambitious
			}
		}
		if = {
			limit = { has_trait = content }
			add = {
				value = -10
				desc = content
			}
		}
		if = {
			limit = { has_trait = zealous }
			add = {
				value = 20
				desc = zealous
			}
		}
		if = {
			limit = { has_trait = stubborn }
			add = {
				value = 20
				desc = stubborn
			}
		}
		# Lifestyle
		if = {
			limit = {
				OR = {
					has_focus = diplomacy_foreign_affairs_focus
					has_focus = martial_strategy_focus
					has_focus = intrigue_skulduggery_focus
					has_focus = stewardship_domain_focus
					has_focus = learning_scholarship_focus
					has_focus = learning_theology_focus
				}
			}
			add = {
				value = 20
				desc = focus
			}
		}
		if = {
			limit = { has_trait = strategist }
			add = {
				value = 10
				desc = strategist
			}
		}
		if = {
			limit = { has_trait = overseer }
			add = {
				value = 10
				desc = overseer
			}
		}
		if = {
			limit = { has_trait = architect }
			add = {
				value = 10
				desc = architect
			}
		}
		if = {
			limit = { has_trait = administrator }
			add = {
				value = 10
				desc = administrator
			}
		}
		if = {
			limit = { has_trait = scholar }
			add = {
				value = 50
				desc = scholar
			}
		}
		if = {
			limit = { has_trait = theologian }
			add = {
				value = 50
				desc = theologian
			}
		}
		# Education
		if = {
			limit = { has_trait = education_diplomacy }
			add = {
				value = 20
				desc = education_diplomacy
			}
		}
		if = {
			limit = { has_trait = education_stewardship }
			add = {
				value = 20
				desc = education_stewardship
			}
		}
		if = {
			limit = { has_trait = education_learning }
			add = {
				value = 50
				desc = education_learning
			}
		}
	}
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}
	max_route_deviation_mult = 3.0
	max_guests = 1
	host_intents = {
		default = reduce_stress_intent
	}
	guest_intents = {
		default = reduce_stress_intent
	}
	
	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 = { #sea
		trigger = {
			scope:host.location != scope:activity.activity_location
			scope:host.location = {
				is_sea_province = yes
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp1_ocean.dds"
		environment = "environment_event_fp1_ocean"
		ambience = "event:/DLC/FP1/SFX/Events/event_ocean_longship"
	}
	# End Travel
	background = { #Nomads
		trigger = {
			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 = {
					activity_host = {  is_landless_adventurer = yes }
					activity_host.culture ?= { has_graphical_steppe_culture_group_trigger = yes }
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mpo_hunt_steppe.dds"
		environment = "environment_mpo_hunt_steppe"
		ambience = "event:/DLC/CE2/Events/Event_Images/mpo_hunt_steppe"
	}
	background = {
		trigger = {
			activity_location = {
				OR = {
					geographical_region = world_europe_west_iberia
					culture = { has_building_gfx = iberian_building_gfx }
				}
			}
		}
		texture = "gfx/interface/illustrations/activity_backgrounds/fp2_garden.dds"
		environment = "environment_event_fp2_garden" 
		ambience = "event:/DLC/FP2/SFX/Events/garden"
	}
	background = {
		trigger = {
			activity_location = {
				OR = {
					culture ?= {
						has_graphical_mena_culture_group_trigger = yes
					}
					steppe_building_gfx_use_mena_trigger = yes
				}
			}
		}
		texture = "gfx/interface/illustrations/activity_backgrounds/bp1_garden_mena_day.dds"
		environment = "environment_event_fp2_garden" 
		ambience = "event:/DLC/FP2/SFX/Events/garden"
	}
	background = { #Indian
		trigger = {
			activity_location = {
				OR = {
					steppe_building_gfx_use_indian_trigger = yes
					culture ?= { has_graphical_india_culture_group_trigger = yes }
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/bp2_indian_garden.dds"
		environment = "environment_bp2_garden_india_day"
		ambience = "event:/SFX/Events/Backgrounds/castle_garden_day"
	}
	background = { #Asia Garden
		trigger = {
			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_garden_asia.dds"
		environment = "environment_tgp_garden_asia"
		ambience = "event:/DLC/EP4/SFX/Events/Event_Backgrounds/tgp_garden_asia"
	}
	background = {
		texture = "gfx/interface/illustrations/activity_backgrounds/garden.dds"
		environment = "environment_event_garden" 
		ambience = "event:/DLC/FP2/SFX/Events/garden"
	}
	window_characters = {
		pilgrim = {
			camera = camera_body
			
			effect = {
				every_attending_character = {
					limit = {
						this != scope:host
						OR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = {
							OR = {
								has_trait = cynical
								any_secret = { type = secret_non_believer }
							}
						}
					}
					animation = { boredom personality_cynical worry personality_vengeful dismissal }
				}
				triggered_animation = {
					trigger = {
						scope:character = { always = yes }
					}
					animation = { personality_compassionate chaplain reading }
				}
			}
		}

		pilgrim = { # Travel
			camera = camera_activity_horse
			
			effect = {
				every_attending_character = {
					limit = {
						this != scope:host
						NOR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				animation = jockey_walk
			}
		}
		
		host = {
			camera = camera_body
			
			effect = {
				if = {
					limit = {
						OR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					scope:host = { add_to_list = characters }
				}
			}
			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character.location = { is_sea_province = yes }
					}
					animation = { survey }
				}
				triggered_animation = {
					trigger = {
						scope:host = {
							OR = {
								has_trait = cynical
								any_secret = { type = secret_non_believer }
							}
						}
					}
					animation = { personality_cynical }
				}
				#Fallback
				animation = prayer
			}
		}
		
		travel_host = {
			camera = camera_activity_horse
			
			effect = {
				if = {
					limit = {
						NOR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					scope:host = {
						add_to_list = characters
					}
				}
			}
			scripted_animation = {
				triggered_animation = {
					trigger = { scope:character = { has_trait = impatient } }
					animation = { jockey_gallop }
				}
				animation = jockey_walk
			}
		}

		pilgrim = {
			camera = camera_body_right
			
			effect = {
				every_attending_character = {
					limit = {
						this != scope:host
						OR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				triggered_animation = {
					trigger = {
						scope:character = {
							OR = {
								has_trait = cynical
								any_secret = { type = secret_non_believer }
							}
						}
					}
					animation = { boredom personality_cynical worry personality_vengeful dismissal }
				}
				triggered_animation = {
					trigger = {
						scope:character = { always = yes }
					}
					animation = { page_flipping personality_content holding_staff }
				}
			}
		}

		pilgrim = { # Travel
			camera = camera_body
			
			effect = {
				every_attending_character = {
					limit = {
						this != scope:host
						NOR = {
							scope:host.location = scope:activity.activity_location
							scope:host.location = { is_sea_province = yes }
						}
					}
					add_to_list = characters
				}
			}

			scripted_animation = {
				animation = jockey_walk
			}
		}
	}
	
}
