##############################################################
# Structure
#
# Situations are short or long running objects that are bound to a region, which go through phases.
# Characters can be a participant in the situation, and then will belong to one participant group.
##############################################################

situation_type = {

	### Brief: window ( enum )
	# What code functions will be available for the gui window.
	# Default is 'situation'.
	#
	# Enums:
	#	situation
	# 	the_great_steppe
	# 	silk_road
	# 	dynastic_cycle
	#
	window = situation

	### Brief: gui_window_name ( string )
	# Which gui window to use for this situation. Notice you can mix and match code 'window' with any gui window.
	# Expects a file to be located under "gui/" and will automatically apply the ".gui" file ending, containing a widget
	# with the specified name.
	# Default is "window_situation"
	#
	gui_window_name = window_situation

	### Brief: gui_participation_window_name ( string )
	# Which gui window to use for the situation participation sub-window.
	# Expects a file to be located under "gui/" and will automatically apply the ".gui" file ending, containing a widget
	# with the specified name.
	# Default is "window_situation_participation"
	#
	gui_participation_window_name = window_situation_participation

	### Brief: gui_tooltip_group_focused (bool )
	# If phase effect tooltips display effects by Participant Group, instead of by Named Modifier Set (modifier_named_sets)
	#
	gui_tooltip_group_focused = no

	# Path to illustration shown in the situation list window
	illustration = "path/to/image.dds"

	# Triggered icon for the situation, accessible via [Situation.GetIcon].
	# Write one entry per icon. The trigger is based on a Situation scope.
	# If no empty triggered asset is defined, the default will be the situation_type icon.
	icon = {
		trigger = { ... }
		reference = "icon_path.dds"
	}

	# Foldable situation group type where to put this situation in the gui.
	# Defaults to the 'minor' group.
	situation_group_type = <key>

	# The order that the situation should show up within its situation group in the gui.
	# Higher number is sorted first, tie breaking is on definition order if same sort order.
	# Defaults to 0.
	sort_order = integer

	### Brief: map_mode ( enum )
	# Which map mode to use for this situation type
	# Default is participant_groups
	#
	# Enums:
	#	participant_groups
	# 	sub_regions
	#
	map_mode = participant_groups

	### What geographical sub-regions this Situation has
	# - Each sub-region has their own list of characters for each participant group (see below)
	# - Each sub-region will also have their own current active phase (same phases and flow for all sub-regions, as defined in 'phases' below
	# - You are required to have at least 1 sub-region (otherwise the situation doesn't affect anything)
	# - You are restricted to max 255 sub-regions. This is needed to properly identify participant groups within the region (see below)
	# - Subregions cannot overlap
	sub_regions = {

		# Note: Every region type added below is counted as part of this sub-region <key>'s area
		my_sub_region_key = {
			# (optional) Path to illustration shown in the situation windows, texture can be accessed in GUI: "[SituationSubRegion.GetIllustration]"
			illustration = "path/to/image.dds"
			# (optional) Path to icon shown in the situation windows, texture can be accessed in GUI: "[SituationSubRegion.GetIcon]"
			icon = "path/to/image.dds"

			# (optional) The color of the sub-region, used for some map modes
			map_color = { 1 0.5 0.2 }

			# (optional) Add array of pre-defined geographical regions
			geographical_regions = { world_mesopotamia special_mongol_empire_start_region }
		}

		my_other_region_key = {
			...
		}
	}

	### Define one or more participant groups.
	# Participating characters can only belong to one participant group at a time, for each sub-region.
	# Characters being considered for participation will be placed in the *first* group they are valid for.
	# You are restricted to max 255 participant groups. This is needed to properly identify participant groups within a specific region.
	# There is a set of groups for each sub-region.
	participant_groups = {

		# One group with characters
		my_group_key = {
			# (optional) Path to icon for group
			icon = "path/to/image.dds"

			### Should this group automatically consider all landed rulers in a sub-region as potential participants
			# Rulers still need to satisfy the other conditions of this group to be automatically added to it.
			# If this is 'no', then you will need to manually add/remove landed rulers to the Situation instead
			# (default: yes)
			auto_add_rulers = yes

			### Should this group automatically consider all rulers with their domicile in a sub-region as potential participants
			# Landless rulers still need to satisfy the other conditions of this group to be automatically added to it.
			# If this is 'no', then you will need to manually add/remove landless characters to the Situation instead
			# (default: yes)
			auto_add_landless_rulers = yes

			# (optional) The color of the participant group, used for some map modes
			map_color = { 1 0.5 0.2 }

			# Is it required that the capital of participants is in the region?
			# (default: no)
			require_capital_in_sub_region = no
			# Is it required that some part of the domain of participants is in the region?
			# (default: no)
			require_domain_in_sub_region = no
			# Is it required that some part of the realm of participants is in the region?
			# (default: yes)
			require_realm_in_sub_region = yes
			# Is it required that the character's domicile, if any, is in the region?
			# Character without domicile will still satisfy this requirement.
			# (default: no)
			require_domicile_in_sub_region = no

			### Trigger determining if a character is valid to be added / can stay in this group (optional)
			# root = character
			# scope:situation = situation
			# scope:situation_sub_region = situation sub region
			is_character_valid = {}

			### Effect run when character joins
			# root = character
			# scope:situation = situation
			# scope:situation_participant_group = situation participant group
			# scope:situation_sub_region = situation sub region
			on_join = {}
			### Effect run when character leaves the participant group (note: not fired when the situation ends)
			# root = character
			# scope:situation = situation
			# scope:situation_participant_group = situation participant group
			# scope:situation_sub_region = situation sub region
			on_leave = {}
		}
	}

	### Effect run when Situation starts (and initial setup has been completed)
	# Root = situation
	on_start = {}

	### Effect run when Situation ends
	# Root = situation
	on_end = {}

	### Effect run every month
	# Root = situation
	on_monthly = {}

	### Effect run every year
	# Root = situation
	on_yearly = {}

	### Effect run on Character as they join the situation
	# Root = character
	on_join = {}

	### Effect run on Character as they leave the situation (note: not fired when the situation ends)
	# Root = character
	on_leave = {}

	### If this situation type can only exist once in the world
	# (this allows access via scope `situation:<name_of_type>`)
	# Default: no
	is_unique = no

	# Enables full catalyst history for the situation if set to yes.
	# The catalyst history can become very big, only use this flag if needed.
	keep_full_history = no

	### If rulers involved in this situation should migrate in search for better fetrility
	# Migration AI is a complex part of AI logic, so it needs to be explicitly enabled here
	# Rules that are involved insituation and who use county fertility will migrate
	# Default: no
	migration = no

	# Which phase should this situation start in (if none if given on situation creation)
	start_phase = my_phase_key

	# Are the situation phase icons flat or not? Mismatch here gives weird appearance in tooltips.
	# Default: yes
	use_situation_phase_flat_icons = yes

	# Which phases can this Situation Type be in? (at least one needs to exist)
	phases = {

		# Definition of one phase
		my_phase_key = {

			### Brief: parameters ( parameter list )
			# Arbitrary parameters related to the phase type
			# Can be checked in gui by: SituationPhaseType.HasParameter('string')
			# Note: Requires loc format "situation_parameter_<key>" to show up in tooltips
			#
			# Differenting from the parameters in modifier_named_sets in that these
			# are always the same on the phase type regardless of involved characters
			#
			parameters = {
				some_parameter = yes
			}

			# Effect run when phase is started in a specific sub region
			# Root = situation
			# scope:situation = situation
			# scope:situation_sub_region = situation sub region this phase belongs to
			on_start = { }
			# Effect run when phase in a specific sub region is being ended (and next phase has been determined)
			# Root = situation
			# scope:situation = situation
			# scope:situation_sub_region = situation sub region this phase belongs to
			on_end = { }

			# (optional) Path to illustration shown in the situation windows
			# Texture can be accessed in GUI: "[SituationPhaseType.GetIllustration]" or "[SituationSubRegion.GetCurrentPhase.GetType.GetIllustration]"
			illustration = "path/to/image.dds"

			# (optional) Path to icon for group
			icon = "path/to/image.dds"

			# (optional) Map province effect applied to all provinces of the sub-region if this phase is active
			map_province_effect = map_province_effect_key

			# (optional) Map province effect intensity (range 0.0-1.0, default 1.0)
			map_province_effect_intensity = 1.0

			# (optional) Maximum duration (days) this phase will run.
			# `max_duration_next_phase` will determine which phase will be next, if max_duration is met
			# [Scripted Duration]
			# root - situation
			# scope:situation_sub_region = situation sub region this phase belongs to
			max_duration = { days = 1234 }

			# How a next phase is selected, if this phase ends by running out of duration (without a phase taking it over before that).
			#
			# Possible values:
			# 	(default) highest_points - whichever of the 'future_phases' has accumulated the most 'points'
			# 	weighted_random_points - randomly picks one of the 'future_phases', weighted by their current 'points'
			# 	random_non_takeover - randomly picks one of the 'future_phases' with equal weight, only picking from phases that have `takeover_type = none`
			# 	weighted_non_takover - picks one of the 'future_phases' with highest 'weight' value
			max_duration_next_phase = weighted_random_points

			# Which phases could this phase transition into?
			future_phases = {

				# 'phase_key' of possible future phase
				my_future_phase_key = {

					### (optional) If this phase can take over a currently active phase, and how.
					#
					# Possible values:
					#	none - (default) It cannot take over an active phase
					#	points - when the phase accumulates enough catalyst points, specified by `takeover_points`
					#	duration - when the current active phase has been active for a specific duration, specified by `takeover_duration`
					takeover_type = duration

					### (optional) Scripted value determining when this phase takes over an active phase in catalyst points
					# Cannot be used together with `takeover_duration`
					takeover_points = 1234

					### (optional) Scripted value determining when this phase takes over for the next phase
					weight = 10

					### Scripted value determining when this phase takes over an active phase, if that phase has been active for a duration. (scripted duration)
					# Cannot be used together with `takeover_points`
					# Root = situation
					# scope:situation_sub_region = situation sub region this phase belongs to
					takeover_duration = { days = 1234 }

					### (optional) Which catalysts contribute to this phase taking over? Value is "number of points" added to future phase total.
					# If 'takeover_type = points', this can trigger an automatic take-over of the current phase by this future phase.
					# (possible catalysts are defined in common/situation/catalyst)
					catalysts = {
						catalyst_betrayed_alliance = 25
						catalyst_something_something = 30
					}
				}

				# Another possible future phase
				other_future_phase_key = {
					# More catalysts here
				}
			}

			# Which modifiers and other effects are active while this phase is active
			modifier_named_sets = {

				### Named "set of modifiers"
				# Apply modifiers / parameters to current situation phase & participants
				# Examples: "War Effects", "Diplomacy Effects"
				# Note: The arbitrary name you set will be used as it's localization key
				#
				war_effects_and_stuff_set = {

					### Brief: icon ( string )
					# Path to icon texture displayed in situation windows
					icon = "path/to/image.dds"

					### Applied to all participant groups in the situation
					# (see `my_participant_group_type_key` below for examples)
					all = {
						county_modifier = {}
						character_modifier = {}
						parameters = {}
						doctrine_character_modifier = {}
					}

					# Only for one specific participant group
					my_participant_group_type_key = {
						# (optional) Modifier applied to the character participant
						character_modifier = {}
						# (optional) Modifier applied to all domain counties of a ruler participant
						county_modifier = {}
						# (optional) One or more situation parameters that are active while this phase is active
						parameters = {
							cheaper_to_convert_to_struggle_faith = yes
							county_faith_conversion_in_region_proceeds_faster = yes
						}

						# Applied to involved characters if they have the given doctrine (can define multiple 'doctrine_character_modifier')
						doctrine_character_modifier = {
							name = name_of_doctrine_localization_key
							doctrine = doctrine_theocracy_lay_clergy
							same_faith_opinion = 3
						}
						doctrine_character_modifier = {
							name = name_of_other_doctrine_localization_key
							doctrine = doctrine_theocracy_temporal
							same_faith_opinion = -3
						}
					}
				}

				another_named_set = {
					...
				}
			}
		}
	}
}
