﻿activity_ecumenical_council = {

	notify_player_can_join_activity = yes
	
	activity_group_type = grand
	
	is_shown = {
		has_pam_dlc_trigger = yes
		can_hold_ecumenical_council_trigger = yes
		# Don't offer a regular ecumenical council while this faith has an Investiture Council pending (it would preempt it).
		NOT = { faith = { has_variable = investiture_council_pending } }
	}
	
	can_start_showing_failures_only = {
		is_available_adult = yes
		is_landless_adventurer = no
		NOT = { is_activity_type_on_cooldown = activity_ecumenical_council }
		# The shared activity has a ten-year engine cooldown for Orthodox synods.
		# Other faiths still honour their original 25-year council cooldown.
		trigger_if = {
			limit = { NOT = { religion = religion:eastern_orthodox_religion } }
			custom_tooltip = {
				text = neow_regular_council_faith_cooldown_tt
				NOT = { faith = { has_variable = recent_ecumenical_council } }
			}
		}
		# Same guard as is_shown: block a routine council while the special one is pending.
		NOT = { faith = { has_variable = investiture_council_pending } }
		# Hard block, unlike the AI-only window below: two councils at once would fight over the same rite.
		custom_tooltip = {
			text = ecumenical_council_already_ongoing_tt
			NOT = { faith = { has_variable = ecumenical_council_ongoing } }
		}
		custom_tooltip = {
			text = can_host_ecumenical_council_tt
			OR = {
				any_held_title = { is_head_of_faith = yes }
				top_participant_group:the_christian_church ?= { participant_group_type = christian_clerical_main_power_rulers }
				government_has_flag = government_is_ecclesiastical
				has_theological_agent_puppet_trigger = yes
			}
		}
		trigger_if = {
			limit = { faith ?= { has_doctrine_parameter = has_clerical_regions } }
			custom_tooltip = {
				text = ecumenical_council_faith_needs_clerical_region_holders_tt
				faith = {
					any_faith_ruler = {
						count >= ecumenical_council_min_clerical_region_holders
						pam_is_clerical_region_holder_trigger = yes
					}
				}
			}
		}
	}

	is_valid = {
		scope:host = {
			is_physically_able = yes
			custom_tooltip = {
				text = can_host_ecumenical_council_tt
				OR = {
					any_held_title = { is_head_of_faith = yes }
					top_participant_group:the_christian_church ?= { participant_group_type = christian_clerical_main_power_rulers }
					government_has_flag = government_is_ecclesiastical
					has_theological_agent_puppet_trigger = yes
				}
			}
		}
		# If no one shows up
		trigger_if = {
			limit = { is_current_phase_active = yes }
			has_attending_activity_guests = yes
		}
		trigger_if = {
			limit = { is_current_phase_active = yes }
			custom_tooltip = {
				text = ecumenical_council_needs_clerical_region_quorum_tt
				pam_ecumenical_council_has_quorum_trigger = yes
			}
		}
	}

	on_invalidated = {
		# Read off the activity because the host may already be dead by the time we get here.
		if = {
			limit = { exists = var:ec_throttled_faith }
			var:ec_throttled_faith = { remove_variable = ecumenical_council_ongoing }
			# A council that collapsed before ruling on anything gives the faith its window back.
			if = {
				limit = { NOT = { exists = var:first_debate_resolution } }
				var:ec_throttled_faith = { remove_variable = recent_ecumenical_council }
			}
		}
		# A council cut short after ruling on something still owes the faith an account of it.
		if = {
			limit = {
				OR = {
					var:first_debate_resolution ?= flag:passed
					var:second_debate_resolution ?= flag:passed
					var:third_debate_resolution ?= flag:passed
				}
			}
			pam_ecumenical_council_send_ruling_letter_effect = yes
		}
		if = {
			limit = {
				scope:host = { is_landed = no }
			}
			every_attending_character = { trigger_event = activity_system.0321 }
		}
		else = {
			invalidation_incapable_effect = yes
			invalidation_imprisoned_effect = yes
			invalidation_nobody_present_effect = yes
			invalidation_host_isolated_effect = yes
			if = {
				limit = {
					NOT = { has_variable = invalidation_effect_set }
					NOT = { pam_ecumenical_council_has_quorum_trigger = yes }
				}
				every_attending_character = {
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = ecumenical_council_no_quorum_toast
						left_icon = scope:host
						custom_tooltip = ecumenical_council_no_quorum_toast_tt
					}
				}
			}
		}
	}

	on_host_death = {
		invalidation_host_death_effect = yes
	}
	
	is_location_valid = {
		custom_tooltip = {
			text = ecumenical_council_not_valid_province
			OR = {
				AND = { # Holy Sites held by someone of our faith
					barony ?= { is_holy_site_of = scope:host.faith }
					county.holder.faith ?= scope:host.faith
				}
				AND = { # Grand Cathedral of our faith
					county.holder.faith ?= scope:host.faith
					has_cathedral_great_project_building_trigger = yes
				}
				AND = { # Large Religious centers of our faith
					county.faith ?= scope:host.faith
					is_religious_studies_location = yes
				}
			}
		}
	}

	province_description = {
		# Is it a Holy Site?
		triggered_desc = {
			trigger = {
				barony = { is_holy_site_of = scope:host.faith }
			}
			desc = activity_ecumenical_council_holy_site_province
		}
		# Is it a Cathedral?
		triggered_desc = {
			trigger = {
				OR = {
					is_religious_studies_location = yes
					has_cathedral_great_project_building_trigger = yes
				}
			}
			desc = activity_ecumenical_council_cathedral_province
		}
		# Is it your capital?
		triggered_desc = {
			trigger = { this = scope:host.capital_province }
			desc = activity_ecumenical_capital_province
		}
	}
	
	province_score = {
		add = ecumenical_council_province_reference_value
	}

	province_filter = all
	ai_province_filter = holy_sites

	# desc is only shown in debug AI watch window
	ai_will_do = {
		value = 0
		# Base
		add = {
			value = 50
			desc = "base"
		}
		# We add their Learning
		add = {
			value = learning
			max = 30
			desc = "learning"
		}
		# More likely during a Crisis phase
		if = {
			limit = {
				situation:the_christian_church ?= {
					has_situation_top_phase_parameter = the_christian_church_cheaper_ecumenical_councils
				}
			}
			add = {
				value = 30
				desc = CHRISTIAN_CHURCH_PHASE_REASON
			}
		}
		# Personality
		if = { # Avoids responsibilities
			limit = { has_trait = lazy }
			add = {
				value = -20
				desc = lazy
			}
		}
		if = { # Likes showing off
			limit = { has_trait = arrogant }
			add = {
				value = 20
				desc = arrogant
			}
		}
		else_if = { # Or not
			limit = { has_trait = humble }
			add = {
				value = -10
				desc = humble
			}
		}
		if = { # Likes this kind of thing
			limit = {
				has_trait = erudite
			}
			add = {
				value = 20
				desc = erudite
			}
		}
		if = { # Likes this kind of thing
			limit = {
				has_trait = theologian
			}
			add = {
				value = 20
				desc = theologian
			}
		}
		if = { # Doesn't like this kind of thing
			limit = { has_trait = reclusive }
			add = {
				value = -25
				desc = reclusive
			}
		}

		add = activity_general_ai_will_do_value

		# Only holders of clerical titles call councils, and every such title is duchy tier or above.
		if = {
			limit = {
				NOR = {
					any_held_title = { has_clerical_region = yes }
					any_held_title = { is_head_of_faith = yes }
					this = rite.head_of_rite
					exists = clerical_elector_title
				}
			}
			multiply = {
				value = 0
				desc = "holds no clerical title"
			}
		}
		# One council per faith per generation.
		if = {
			limit = {
				faith = { has_variable = recent_ecumenical_council }
			}
			multiply = {
				value = 0
				desc = "faith already held a council recently"
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 60 # 5y
		kingdom = 60 # 5y
		empire = 60 # 5y
		hegemony = 60 # 5y
	}

	ai_will_select_province = {
		# Base
		add = {
			value = 5
			desc = "base"
		}
		if = {
			limit = {
				barony = { is_holy_site_of = scope:host.faith }
			}
			add = {
				value = 50
				desc = activity_ecumenical_council_holy_site_province
			}
		}
		if = {
			limit = {
				OR = {
					is_religious_studies_location = yes
					has_cathedral_great_project_building_trigger = yes
				}
			}
			add = {
				value = 25
				desc = activity_ecumenical_council_cathedral_province
			}
		}
		if = {
			limit = {
				this = scope:host.capital_province
			}
			add = {
				value = 15 # Even if the first Vatican EC was in the 19th c, the Lateran ECs (the medieval residence of the Pope) were very important
				desc = activity_ecumenical_capital_province
			}
		}
	}

	###################
	# PARAMETERS
	###################

	is_single_location = yes

	cooldown = { years = 10 }

	max_province_icons = 3

	max_route_deviation_mult = 3.0
	
	cost = {
		# This is the original council for everyone except Eastern Orthodox hosts.
		treasury = {
			if = {
				limit = { has_treasury = yes NOT = { religion = religion:eastern_orthodox_religion } }
				value = ecumenical_council_scaled_cost
			}
		}
		gold = {
			if = {
				limit = { has_treasury = no NOT = { religion = religion:eastern_orthodox_religion } }
				value = ecumenical_council_scaled_cost
			}
		}
		piety = {
			if = {
				limit = { religion = religion:eastern_orthodox_religion }
				value = ecumenical_council_scaled_cost
				multiply = 2
			}
		}
	}

	ui_predicted_cost = {
		treasury_or_gold = {
			if = {
				limit = { NOT = { religion = religion:eastern_orthodox_religion } }
				value = ecumenical_council_scaled_cost
			}
		}
		piety = {
			if = {
				limit = { religion = religion:eastern_orthodox_religion }
				value = ecumenical_council_scaled_cost
				multiply = 2
			}
		}
	}

	conclusion_description = {
		desc = ecumenical_council_conclusion.intro
	}

	###################
	# OPTIONS
	###################

	special_option_category = special_type

	options = {
		special_type = {
			# Tenet/Doctrinal council
			ecumenical_council_type_doctrine = {
				default = yes
				tenet_doctrine_based_activity = yes
				tenet_1 = known_character
				tenet_2 = known_character
				# Players can only pick doctrines their faith holds, so the AI follows the same rule
				doctrine_1 = active_rite
				ai_will_do = {
					value = 100
				}
			}
		}
	}

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

	phases = {
		# Summons Phase
		ecumenical_council_phase_summons = {
			order = 1
			is_predefined = yes

			on_phase_active = {
				if = {
					limit = { this = scope:host }
					# Add all the clergy characters to the clergy group
					ecumenical_council_gather_clergy_effect = yes
					# Add all non-clergy characters as non-clergy
					ecumenical_council_gather_non_clergy_effect = yes
				}
				# Trigger starting event
				trigger_event = ecumenical_council_events.0002
				# Progress phase
				if = {
					limit = {
						this = scope:host
					}
					scope:activity = { progress_activity_phase_after = { months = 1 } }
				}
			}

			on_weekly_pulse = {
				trigger_event = { on_action = ecumenical_council_summons_events }
			}
		}

		# First Debate
		ecumenical_council_phase_first_debate = {
			order = 2
			is_predefined = yes

			on_enter_phase = {
				scope:activity = {
					# Clear leftover current_topic or this debate's ruling lands on it
					if = {
						limit = { exists = activity_tenet:1 }
						activity_tenet:1 = {
							save_scope_as = ec_debate_topic_1
						}
						set_variable = {
							name = current_topic
							value = scope:ec_debate_topic_1
						}
					}
					else = {
						remove_variable = current_topic
					}
				}
				# First Debate starting event
				if = {
					limit = { this = scope:host }
					trigger_event = ecumenical_council_events.0010
					scope:activity = { progress_activity_phase_after = { days = 3 } }
				}
			}

			on_phase_active = {
				# Progress phase
				if = {
					limit = {
						this = scope:host
					}
					scope:activity = { progress_activity_phase_after = { months = 1 } }
				}
			}

			on_weekly_pulse = {
				trigger_event = { on_action = pam_ecumenical_council_debate_tenets_events }
			}

			# Resolve the debate vote (tally innovators vs conservatives, apply outcome)
			on_end = {
				if = {
					limit = { this = scope:host }
					trigger_event = ecumenical_council_events.0080
				}
			}
		}

		# Second Debate
		ecumenical_council_phase_second_debate = {
			order = 3
			is_predefined = yes

			on_enter_phase = {
				scope:activity = { progress_activity_phase_after = { days = 3 } }
			}

			on_phase_active = {
				scope:activity = {
					if = {
						limit = { exists = activity_tenet:2 }
						activity_tenet:2 = {
							save_scope_as = ec_debate_topic_2
						}
						set_variable = {
							name = current_topic
							value = scope:ec_debate_topic_2
						}
					}
					else = {
						remove_variable = current_topic
					}
				}
				# Second Debate starting event, all other events (including the weekly pulse) go through here
				if = {
					limit = { this = scope:host }
					trigger_event = ecumenical_council_events.0020
					scope:activity = { progress_activity_phase_after = { days = 3 } }
				}
				# Progress phase
				if = {
					limit = {
						this = scope:host
					}
					scope:activity = { progress_activity_phase_after = { months = 1 } }
				}
			}

			on_weekly_pulse = {
				trigger_event = { on_action = pam_ecumenical_council_debate_tenets_events }
			}

			# Resolve the debate vote (tally innovators vs conservatives, apply outcome)
			on_end = {
				if = {
					limit = { this = scope:host }
					trigger_event = ecumenical_council_events.0080
				}
			}
		}

		# Third Debate
		ecumenical_council_phase_third_debate = {
			order = 4
			is_predefined = yes

			on_enter_phase = {
				scope:activity = { progress_activity_phase_after = { days = 3 } }
			}

			on_phase_active = {
				scope:activity = {
					if = {
						limit = { exists = activity_doctrine:1 }
						activity_doctrine:1 = {
							save_scope_as = ec_debate_topic_3
						}
						set_variable = {
							name = current_topic
							value = scope:ec_debate_topic_3
						}
					}
					else = {
						remove_variable = current_topic
					}
				}
				# Guest event 0031 fires from the sub-event after, not here
				if = {
					limit = { this = scope:host }
					if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_monogamy
								scope:ec_debate_topic_3 = doctrine:doctrine_polygamy
								scope:ec_debate_topic_3 = doctrine:doctrine_concubines
							}
						}
						trigger_event = ecumenical_council_events.0050
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_divorce_disallowed
								scope:ec_debate_topic_3 = doctrine:doctrine_divorce_approval
								scope:ec_debate_topic_3 = doctrine:doctrine_divorce_allowed
							}
						}
						trigger_event = ecumenical_council_events.0051
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_bastardry_none
								scope:ec_debate_topic_3 = doctrine:doctrine_bastardry_legitimization
								scope:ec_debate_topic_3 = doctrine:doctrine_bastardry_all
							}
						}
						trigger_event = ecumenical_council_events.0052
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_homosexuality_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_homosexuality_shunned
								scope:ec_debate_topic_3 = doctrine:doctrine_homosexuality_accepted
							}
						}
						trigger_event = ecumenical_council_events.0053
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_deviancy_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_deviancy_shunned
								scope:ec_debate_topic_3 = doctrine:doctrine_deviancy_accepted
								scope:ec_debate_topic_3 = doctrine:doctrine_deviancy_virtuous
							}
						}
						trigger_event = ecumenical_council_events.0054
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_adultery_men_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_adultery_men_shunned
								scope:ec_debate_topic_3 = doctrine:doctrine_adultery_men_accepted
							}
						}
						trigger_event = ecumenical_council_events.0055
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_adultery_women_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_adultery_women_shunned
								scope:ec_debate_topic_3 = doctrine:doctrine_adultery_women_accepted
							}
						}
						trigger_event = ecumenical_council_events.0056
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_kinslaying_any_dynasty_member_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_kinslaying_extended_family_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_kinslaying_close_kin_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_kinslaying_shunned
								scope:ec_debate_topic_3 = doctrine:doctrine_kinslaying_accepted
							}
						}
						trigger_event = ecumenical_council_events.0057
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_witchcraft_crime
								scope:ec_debate_topic_3 = doctrine:doctrine_witchcraft_shunned
								scope:ec_debate_topic_3 = doctrine:doctrine_witchcraft_accepted
								scope:ec_debate_topic_3 = doctrine:doctrine_witchcraft_virtuous
							}
						}
						trigger_event = ecumenical_council_events.0058
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_gender_male_dominated
								scope:ec_debate_topic_3 = doctrine:doctrine_gender_equal
								scope:ec_debate_topic_3 = doctrine:doctrine_gender_female_dominated
							}
						}
						trigger_event = ecumenical_council_events.0059
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_consanguinity_dynastic
								scope:ec_debate_topic_3 = doctrine:doctrine_consanguinity_restricted
								scope:ec_debate_topic_3 = doctrine:doctrine_consanguinity_cousins
								scope:ec_debate_topic_3 = doctrine:doctrine_consanguinity_aunt_nephew_and_uncle_niece
								scope:ec_debate_topic_3 = doctrine:doctrine_consanguinity_unrestricted
							}
						}
						trigger_event = ecumenical_council_events.0060
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_pluralism_fundamentalist
								scope:ec_debate_topic_3 = doctrine:doctrine_pluralism_righteous
								scope:ec_debate_topic_3 = doctrine:doctrine_pluralism_pluralistic
							}
						}
						trigger_event = ecumenical_council_events.0061
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_theocracy_temporal
								scope:ec_debate_topic_3 = doctrine:doctrine_theocracy_lay_clergy
							}
						}
						trigger_event = ecumenical_council_events.0062
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_no_head
								scope:ec_debate_topic_3 = doctrine:doctrine_spiritual_head
								scope:ec_debate_topic_3 = doctrine:doctrine_temporal_head
							}
						}
						trigger_event = ecumenical_council_events.0063
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_function_taxation
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_function_alms_and_pacification
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_function_recruitment
							}
						}
						trigger_event = ecumenical_council_events.0064
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_gender_male_only
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_gender_female_only
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_gender_either
							}
						}
						trigger_event = ecumenical_council_events.0065
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_marriage_allowed
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_marriage_disallowed
							}
						}
						trigger_event = ecumenical_council_events.0066
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_succession_temporal_appointment
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_succession_spiritual_appointment
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_succession_temporal_fixed_appointment
								scope:ec_debate_topic_3 = doctrine:doctrine_clerical_succession_spiritual_fixed_appointment
							}
						}
						trigger_event = ecumenical_council_events.0067
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_pilgrimage_forbidden
								scope:ec_debate_topic_3 = doctrine:doctrine_pilgrimage_encouraged
								scope:ec_debate_topic_3 = doctrine:doctrine_pilgrimage_local_rites
								scope:ec_debate_topic_3 = doctrine:doctrine_pilgrimage_mandatory
								scope:ec_debate_topic_3 = doctrine:doctrine_pilgrimage_mandatory_hajj
							}
						}
						trigger_event = ecumenical_council_events.0068
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_funeral_stoic
								scope:ec_debate_topic_3 = doctrine:doctrine_funeral_bewailment
								scope:ec_debate_topic_3 = doctrine:doctrine_funeral_cremation
								scope:ec_debate_topic_3 = doctrine:doctrine_funeral_sky_burial
								scope:ec_debate_topic_3 = doctrine:doctrine_funeral_mummification
								scope:ec_debate_topic_3 = doctrine:doctrine_family_rites
							}
						}
						trigger_event = ecumenical_council_events.0069
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_no_anointment
								scope:ec_debate_topic_3 = doctrine:doctrine_anointment_permitted
								scope:ec_debate_topic_3 = doctrine:doctrine_imperial_anointment
							}
						}
						trigger_event = ecumenical_council_events.0070
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_monotheist
								scope:ec_debate_topic_3 = doctrine:doctrine_polytheist
							}
						}
						trigger_event = ecumenical_council_events.0071
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_monasticism_encouraged
								scope:ec_debate_topic_3 = doctrine:doctrine_monasticism_accepted
								scope:ec_debate_topic_3 = doctrine:doctrine_monasticism_absent
								scope:ec_debate_topic_3 = doctrine:doctrine_monasticism_forbidden
							}
						}
						trigger_event = ecumenical_council_events.0072
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_sacraments_central
								scope:ec_debate_topic_3 = doctrine:doctrine_sacraments_absent
							}
						}
						trigger_event = ecumenical_council_events.0073
					}
					else_if = {
						limit = {
							OR = {
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_none
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_latin
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_koine
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_church_slavonic
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_irish
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_armenian
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_classical_georgian
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_church_romanian
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_arabic
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_hebrew
								scope:ec_debate_topic_3 = doctrine:doctrine_liturgical_language_esperanto
							}
						}
						trigger_event = ecumenical_council_events.0074
					}
				}
				# Progress phase
				if = {
					limit = {
						this = scope:host
					}
					scope:activity = { progress_activity_phase_after = { months = 1 } }
				}
			}

			on_weekly_pulse = {
				trigger_event = { on_action = pam_ecumenical_council_debate_doctrines_events }
			}

			# Resolve the debate vote (tally innovators vs conservatives, apply outcome)
			on_end = {
				if = {
					limit = { this = scope:host }
					trigger_event = ecumenical_council_events.0080
				}
			}
		}
	}

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

	open_invite = yes

	max_guests = 100

	can_be_activity_guest = {
		# Standar Checks
		is_adult = yes
		is_healthy = yes
		in_diplomatic_range = scope:host
		# Specific Checks
		NOT = { government_has_flag = government_is_republic }
		NOT = { government_has_flag = government_is_landless_adventurer }
		NOT = { government_has_flag = government_is_mercenary }
		OR = {
			is_clergy = yes
			# You must be a king+
			highest_held_title_tier >= tier_kingdom
			# Or a very pious/nearby duke
			AND = {
				highest_held_title_tier >= tier_duchy
				OR = {
					piety_level >= 3
					location = { squared_distance = { target = scope:host.capital_province value < squared_distance_medium } }
				}
			}
		}
		# You and the host have the same faith
		religion = scope:host.religion
		# Must be the right gender or a player
		trigger_if = {
			limit = { is_ai = yes }
			trigger_if = {
				limit = { is_clergy = yes }
				scope:host.rite = { rite_has_allowed_gender_for_clergy = prev }
			}
			trigger_else = {
				scope:host.rite = { rite_has_dominant_ruling_gender = prev }
			}
		}
	}

	host_intents = {
		intents = { spiritual_intent_host fervor_intent murder_attendee_intent befriend_attendee_intent }
		default = spiritual_intent_host
	}

	guest_intents = {
		intents = { spiritual_intent fervor_intent clerical_appointment_intent alliance_intent murder_attendee_intent befriend_attendee_intent }
		default = spiritual_intent
	}

	guest_join_chance = {
		base = 5
		base_activity_modifier = yes
		# Scripted Modifiers
		activity_guest_shared_ai_accept_modifier = yes
		activity_guest_health_ai_accept_modifier = yes

		# don't flood into it if you are not same faith
		modifier = {
			faith != scope:host.faith
			NOR = {
				is_clergy = yes
				rite.head_of_rite = this
				has_trait = theologian
				has_trait = heresiarch
				has_trait = herald
			}
			factor = 0
		}
	}

	guest_subsets = {
		clergy
		non_clergy
		innovator
		conservative
	}

	wait_time_before_start = {
		months = ecumenical_council_wait_time_before_start_months
	}

	max_guest_arrival_delay_time = { months = 5 }

	guest_invite_rules = {
		defaults = {
			1 = activity_invite_hof_and_hor
			1 = activity_invite_cardinals
			1 = activity_invite_archbishops
			1 = activity_invite_clergy
			2 = activity_invite_neighbouring_rulers
			2 = activity_invite_rule_all_lieges
			2 = activity_invite_rule_vassals
			3 = activity_invite_rule_fellow_vassals
			3 = activity_invite_rule_councillors
			4 = activity_invite_rule_courtiers
			5 = activity_invite_rule_guests
		}
	}

	travel_entourage_selection = {
		weight = {
			value = standard_travel_entourage_additions
			if = {
				limit = {
					is_landed = no
					is_faith_dominant_gender = yes
					court_owner = scope:owner
					is_available = yes
					is_ai = yes
					is_adult = yes
					location = scope:owner.location
					# Remove diarchs from the list.
					bannable_serving_diarch_trigger = no
				}
				add = 50
			}
		}

		max = 15
		ai_max = 7
		invite_rule_order = 1
   	}
	
	###################
	# ON ACTIONS
	###################

	pulse_actions = {
		entries = {
			apa_friendly_discussions
			apa_forging_alliances
			apa_preaching_wrath_of_god
			apa_studying_scripture
			apa_prayer
			apa_silent_contemplation
			apa_communal_prayer
			apa_comet_sighted
			apa_good_omen
			apa_charity_for_the_poor
			apa_spiritual_journey
			apa_overcome_with_emotion
			apa_night_on_books
			apa_local_food
			guest_brawl
			apa_passive_religious_learning_host
			apa_passive_religious_learning_guest
		}
		chance_of_no_event = 5
	}
	
	on_start = {
		add_activity_log_entry = {
			key = ecumenical_council_start_log
			character = scope:host
			score = 10
		}
		# Closed at planning time so rival clerics cannot summon competing councils.
		scope:host.faith = {
			if = {
				limit = { scope:host = { religion = religion:eastern_orthodox_religion } }
				set_variable = {
					name = recent_ecumenical_council
					value = yes
					years = 10
				}
			}
			else = {
				set_variable = {
					name = recent_ecumenical_council
					value = yes
					years = ecumenical_council_faith_cooldown_years
				}
			}
			# Cleared on completion and on invalidation; the duration is only a self-healing backstop.
			set_variable = {
				name = ecumenical_council_ongoing
				value = yes
				years = ecumenical_council_ongoing_backstop_years
			}
		}
		set_variable = {
			name = ec_throttled_faith
			value = scope:host.faith
		}
		# Feast-style host-scoped catalyst at planning confirm
		scope:host = {
			pam_ecumenical_council_host_start_catalyst_effect = yes
		}
	}

	on_enter_passive_state = {
		trigger_event = ecumenical_council_events.0001
	}

	# Effects run when the activity completes after its last phase
	# root = character in this phase
	# scope:activity = the activity
	# scope:host = host of the activity
	on_complete = {
		# Run conclusion stuff here
		if = {
			limit = { this = scope:host }
			location = { save_scope_as = activity_location }
			save_scope_as = root_scope
			trigger_event = ecumenical_council_events.0040
			scope:host.faith = { remove_variable = ecumenical_council_ongoing }
			# Rulers of the faith who stayed home hear what was decided from their own chaplain.
			scope:activity = { pam_ecumenical_council_send_ruling_letter_effect = yes }
		}
		# Conclusion event for guests
		else = {
			if = {
				limit = {
					is_alive = yes
					is_imprisoned = no
				}
				trigger_event = ecumenical_council_events.0041
			}
		}
	}

	activity_window_widgets = {
		coronation_supporter_detractor_widget = "window_activity_contestants_right_bar_container"
	}

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

	header_background = "gfx/interface/illustrations/activity_header_backgrounds/activity_ecumenical_council.dds"

	# 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 = { #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"
	}
	### Summons - Temple exterior
	background = { #Jerusalem
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location.county = title:c_jerusalem
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_jerusalem.dds"
		environment = "environment_jerusalem"
		ambience = "event:/DLC/EP2/SFX/Events/Backgrounds/evn_background_jerusalem"
	}
	background = { #Mecca
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location.county = title:c_mecca
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_mecca.dds"
		environment = "environment_mecca"
		ambience = "event:/DLC/EP2/SFX/Events/Backgrounds/evn_background_holysite_mena"
	}
	background = {	#Constantinople
		trigger = {
			scope:activity ?= {
				activity_location.county = title:c_byzantion
				has_current_phase = ecumenical_council_phase_summons
			}
		}
		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 = { # Orthodox generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location = {
					religion = religion:christianity_religion
					OR = {
						geographical_region = graphical_mena
						geographical_region = graphical_india
						geographical_region = world_europe_south_east
						geographical_region = world_asia_minor
						rite = {
							rite_has_doctrine = special_doctrine_is_eastern_christian_faith
						}
					}
					NOT = {
						rite = {
							rite_has_doctrine = special_doctrine_is_western_christian_faith
						}
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep3_holysite_orthodox.dds"
		environment = "environment_ep3_holysite_orthodox"
		ambience = "event:/DLC/EP3/SFX/Events/Event_Images/ep3_evn_eventimage_orthodox_holy_site"
	}
	background = { #East Asia
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				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_holysite_asia.dds"
		environment = "environment_tgp_holysite_asia"
		ambience = "event:/DLC/EP4/SFX/Events/Event_Backgrounds/tgp_holysite_asia"
	}
	background = { # MPO - Tengri
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location = {
					OR = {
						religion = {
							OR = {
								this = religion:tengrism_religion
								this = religion:magyar_religion
								this = religion:siberian_religion
							}
						}
						AND = {
							religion = religion:buddhism_religion
							OR = {
								geographical_region = world_steppe_east
								geographical_region = world_steppe_central
								geographical_region = world_steppe_west
								geographical_region = world_asia_north_east
							}
						}
						AND = {
							religion = religion:buddhism_religion
							OR = {
								geographical_region = world_tibet
								geographical_region = world_steppe_tarim
							}
							county.title_province ?= {
								OR = {
									has_holding_type = tribal_holding
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
						}
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mpo_temple_steppe.dds"
		environment = "environment_mpo_temple_steppe"
		ambience = "event:/DLC/CE2/Events/Event_Images/mpo_temple_steppe"
	}
	background = {	#Mandala shrine
		trigger = {
			scope:activity ?= {
				activity_location = {
					culture = { has_building_gfx = southeast_asian_building_gfx }
				}
				has_current_phase = ecumenical_council_phase_summons
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_indian.dds"
		environment = "environment_indian_holy_site"
		ambience = "event:/DLC/EP2/SFX/Events/Backgrounds/evn_background_jungle"
	}
	background = { #MENA generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location = {
					OR = {
						culture ?= { has_graphical_mena_culture_group_trigger = yes }
						steppe_building_gfx_use_mena_trigger = yes
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_mena.dds"
		environment = "environment_generic_holy_site_mena"
		ambience = "event:/DLC/EP2/SFX/Events/Backgrounds/evn_background_holysite_mena"
	}
	background = { #Indian generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location = {
					OR = {
						culture ?= { has_graphical_india_culture_group_trigger = yes }
						steppe_building_gfx_use_indian_trigger = yes
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_indian.dds"
		environment = "environment_indian_holy_site"
		ambience = "event:/DLC/EP2/SFX/Events/Backgrounds/evn_background_jungle"
	}
	background = { #Western generic holy site, gothic
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location ?= {
					NOT = {
						religion ?= { is_in_family = rf_pagan }
					}
				}
				activity_host ?= {
					rite = {
						rite_has_doctrine = special_doctrine_is_western_christian_faith
					}
					pam_church_event_background_is_grand_western_trigger = yes
				}
			}
			current_year >= 900
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_wedding_ceremony_western.dds"
		environment = "environment_western_wedding"
		ambience = "event:/DLC/EP2/SFX/Events/Grand_Activities/Weddings/ep2_event_grand_wedding"
	}
	background = { #Western generic holy site, mediterranean
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location ?= {
					NOT = {
						religion ?= { is_in_family = rf_pagan }
					}
				}
				activity_host ?= {
					rite = {
						rite_has_doctrine = special_doctrine_is_western_christian_faith
					}
					OR = {
						pam_church_event_background_is_grand_western_pre_gothic_trigger = yes
						AND = {
							pam_church_event_background_is_developed_trigger = yes
							scope:activity.activity_location = { pam_church_background_location_is_mediterranean_or_urban_trigger = yes }
						}
					}
				}
			}
			current_year >= 900
		}
		texture = "gfx/interface/illustrations/event_scenes/pam_romanesque_church_exterior.dds"
		environment = "environment_pam_romanesque_church_exterior"
		ambience = "event:/DLC/CE3/SFX/Events/romanesque_church_exterior" #AUDIO CE3
	}
	background = { #Western generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location ?= {
					NOT = {
						religion ?= { is_in_family = rf_pagan }
					}
				}
				activity_host ?= {
					rite = {
						rite_has_doctrine = special_doctrine_is_western_christian_faith
					}
					pam_church_event_background_is_developed_trigger = yes
				}
			}
			current_year >= 900
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_western.dds"
		environment = "environment_western_holy_site"
		ambience = "event:/SFX/Events/Backgrounds/temple_christian"
	}
	background = { #Tribal
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location ?= {
					county.title_province ?= {
						has_holding_type = tribal_holding
					}
					NOT = {
						has_holding_type = church_holding
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_tribal.dds"
		environment = "environment_event_garden"
		ambience = "event:/DLC/FP1/SFX/Events/event_temple" 
	}
	background = {  #Pre-Romanesque Western generic holy site... and fallback
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_host.faith.religion = religion:christianity_religion
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/pam_pre-romanesque_church_exterior.dds"
		environment = "environment_pam_preromanesque_church_exterior"
		ambience = "event:/DLC/CE3/SFX/Events/pre-romanesque_church_exterior" #AUDIO CE3
	}
	
	## Debates -- Temple Interior
	background = { # Hagia Sophia
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location.county = title:c_byzantion
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep3_hagia_sophia.dds"
		environment = "environment_ep3_hagia_sophia"
		ambience = "event:/DLC/EP3/SFX/Events/Event_Images/ep3_evn_eventimage_hagia_sophia"
	}
	background = { #Zoroastrian generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				OR = {
					activity_host.religion = religion:zoroastrianism_religion
					activity_location = {
						religion = religion:zoroastrianism_religion
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp3_temple.dds"
		environment = "environment_event_fp3_temple"
		ambience = "event:/DLC/FP1/SFX/Events/event_temple"
	}
	background = { #East Asian
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location ?= {
					OR = {
						faith.religion = {
							OR = {
								is_in_family = rf_eastern
								is_in_family = rf_sinitic
								this = religion:shintoism_religion
							}
						}
						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_temple_asia.dds"
		environment = "environment_tgp_temple_asia"
		ambience = "event:/DLC/EP4/SFX/Events/Event_Backgrounds/tgp_temple_asia"
	}
	background = { # MPO - Tengri
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location = {
					OR = {
						religion = {
							OR = {
								this = religion:tengrism_religion
								this = religion:magyar_religion
								this = religion:siberian_religion
							}
						}
						AND = {
							religion = religion:buddhism_religion
							OR = {
								geographical_region = world_steppe_east
								geographical_region = world_steppe_central
								geographical_region = world_steppe_west
								geographical_region = world_asia_north_east
							}
						}
						AND = {
							religion = religion:buddhism_religion
							OR = {
								geographical_region = world_tibet
								geographical_region = world_steppe_tarim
							}
							county.title_province ?= {
								OR = {
									has_holding_type = tribal_holding
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
						}
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/mpo_temple_steppe.dds"
		environment = "environment_mpo_temple_steppe"
		ambience = "event:/DLC/CE2/Events/Event_Images/mpo_temple_steppe"
	}
	background = { #Christian - Grand Cathedral (Western pre-Gothic)
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_host = { pam_church_event_background_is_grand_western_pre_gothic_trigger = yes }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/church.dds"
		environment = "environment_event_church"
		ambience = "event:/SFX/Events/Backgrounds/temple_christian"
	}
	background = { #Christian - Grand Cathedral, Gothic
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_host = { pam_church_event_background_is_grand_western_trigger = yes }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/pam_gothic_cathedral_interior.dds"
		environment = "environment_pam_gothic_cathedral_interior"
		ambience = "event:/DLC/CE3/SFX/Events/gothic_cathedral_interior"
	}
	background = { # Christian - Grand Cathedral Eastern (Hagia Sophia)
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_host = { pam_church_event_background_is_grand_eastern_trigger = yes }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep3_hagia_sophia.dds"
		environment = "environment_ep3_hagia_sophia"
		ambience = "event:/DLC/EP3/SFX/Events/Event_Images/ep3_evn_eventimage_hagia_sophia"
	}
	background = { #Christian - Developed Church
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_host = {
					faith = { religion = religion:christianity_religion }
					pam_church_event_background_is_developed_trigger = yes
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/pam_romanesque_church_interior.dds"
		environment = "environment_pam_romanesque_church_interior"
		ambience = "event:/DLC/CE3/SFX/Events/romanesque_church_interior"
	}
	background = { #General Christian
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_host = {
					faith = { religion = religion:christianity_religion }
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/pam_simple_church_western_interior.dds"
		environment = "environment_pam_simple_church_western_interior"
		ambience = "event:/DLC/CE3/SFX/Events/simple_western_church_interior"
	}
	background = { #Norse generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location = {
					culture = { has_graphical_norse_culture_group_trigger = yes }
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp1_tribal_temple.dds"
		environment = "environment_event_fp1_tribal_temple"
		ambience = "event:/DLC/FP1/SFX/Events/event_temple"
	}
	background = { #MENA generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase = ecumenical_council_phase_summons
				activity_location = {
					OR = {
						culture ?= { has_graphical_mena_culture_group_trigger = yes }
						steppe_building_gfx_use_mena_trigger = yes
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp2_temple.dds"
		environment = "environment_event_fp2_temple"
		ambience = "event:/DLC/FP2/SFX/Events/temple"
	}
	background = { #Iberian generic holy site
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location.culture ?= { has_graphical_iberian_culture_group_trigger = yes }
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/fp2_temple.dds"
		environment = "environment_event_fp2_temple"
		ambience = "event:/DLC/FP2/SFX/Events/temple"
	}
	background = { #Pagan generic holy site (Outdoors)
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location.county.holder ?= {
					OR = {
						government_has_flag = government_is_tribal
						government_has_flag = government_is_nomadic
						government_has_flag = government_is_herder
					}
					religion = { is_in_family = rf_pagan }
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_tribal.dds"
		environment = "environment_event_garden"
		ambience = "event:/DLC/FP1/SFX/Events/event_temple"
	}

	background = { #Dharmic (Outdoors)
		trigger = {
			scope:activity ?= {
				has_current_phase_any_debate_trigger = yes
				activity_location = {
					OR = {
						culture = { has_graphical_india_culture_group_trigger = yes }
						steppe_building_gfx_use_indian_trigger = yes
						faith.religion ?= {	is_in_family = rf_eastern }
					}
				}
			}
		}
		texture = "gfx/interface/illustrations/event_scenes/ep2_holysite_indian.dds"
		environment = "environment_indian_holy_site"
		ambience = "event:/DLC/EP2/SFX/Events/Backgrounds/evn_background_jungle"
	}
	background = { # Western generic fallback
		texture = "gfx/interface/illustrations/event_scenes/temple.dds"
		environment = "environment_event_temple"
		ambience = "event:/SFX/Events/Backgrounds/temple_generic"
	}

	window_characters = {
		player_traveling = {
			camera = camera_activity_horse
			effect = {
				scope:player ?= {
					if = {
						limit = {
							NOT = {
								location = scope:activity.activity_location
							}
						}
						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
			}
		}
		player_guest = {
			camera = camera_event_center
			effect = {
				scope:player ?= {
					if = {
						limit = {
							this != scope:activity.activity_host
							location = scope:activity.activity_location
						}
						add_to_list = characters
					}
				}
				
			}
			scripted_animation = ecumenical_council_lay_guest_animation
		}
		non_clergy_guest_travelling = {
			camera = camera_activity_horse

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					ordered_attending_character = {
						limit = {
							is_clergy = no
							this != scope:host
							location != scope:activity.activity_location
						}
						order_by = {
							value = 1
							add = {
								value = highest_held_title_tier
								multiply = 15
							}
							add = {
								value = domain_size
								multiply = 3
							}
							add = realm_size
						}
						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
			}
		}
		clergy_guest_travelling = {
			camera = camera_activity_horse

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					ordered_attending_character = {
						limit = {
							is_clergy = yes
							this != scope:host
							location != scope:activity.activity_location
						}
						order_by = {
							value = 1
							add = {
								value = highest_held_title_tier
								multiply = 15
							}
						}
						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
			}
		}
		# Clerical guests stand to the host's right (list before host, matching coronation/feast)
		clergy_guest_arrived = {
			camera = camera_body_right

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					ordered_attending_character = {
						limit = {
							is_clergy = yes
							this != scope:host
							location = scope:activity.activity_location
						}
						order_by = {
							value = 1
							add = {
								value = highest_held_title_tier
								multiply = 15
							}
						}
						add_to_list = characters
					}
				}
			}
			scripted_animation = ecumenical_council_clergy_guest_animation_alt
		}
		clergy_guest = {
			camera = camera_body_right

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					ordered_attending_character = {
						limit = {
							is_clergy = yes
							this != scope:host
							location = scope:activity.activity_location
						}
						order_by = {
							value = 1
							add = {
								value = highest_held_title_tier
								multiply = 15
							}
						}
						check_range_bounds = no
						position = 1
						add_to_list = characters
					}
				}
			}
			scripted_animation = ecumenical_council_clergy_guest_animation
		}
		host = {
			camera = camera_body
			effect = {
				if = {
					limit = { scope:host = { location = scope:activity.activity_location } }
				}
				scope:host ?= { add_to_list = characters }
			}
			scripted_animation = ecumenical_council_host_animation
		}
		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
			}
		}
		# Lay guests stand to the host's left
		non_clergy_guest_arrived = {
			camera = camera_body_left_slight

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					ordered_attending_character = {
						limit = {
							is_clergy = no
							this != scope:host
							location = scope:activity.activity_location
						}
						order_by = {
							value = 1
							add = {
								value = highest_held_title_tier
								multiply = 15
							}
							add = {
								value = domain_size
								multiply = 3
							}
							add = realm_size
						}
						add_to_list = characters
					}
				}
			}
			scripted_animation = ecumenical_council_lay_guest_animation_alt
		}
		non_clergy_guest = {
			camera = camera_body_left

			effect = {
				if = {
					limit = {
						scope:host.location = scope:activity.activity_location
					}
					ordered_attending_character = {
						limit = {
							is_clergy = no
							this != scope:host
							location = scope:activity.activity_location
						}
						order_by = {
							value = 1
							add = {
								value = highest_held_title_tier
								multiply = 15
							}
							add = {
								value = domain_size
								multiply = 3
							}
							add = realm_size
						}
						check_range_bounds = no
						position = 1
						add_to_list = characters
					}
				}
			}
			scripted_animation = ecumenical_council_lay_guest_animation
		}
	}
}
