﻿
#########################
# Triggers for Titles
#########################

# has_mythical_founder_trigger - Does the title have a mythical or semi-mythical founder?


has_mythical_founder_trigger = {
	OR = {
		AND = { # Charles Martell (?)
			OR = {
				this = title:k_france
				this = title:e_france
			}
			current_date > 1000.1.1
		}
#		OR = { # Alexander		
#			this = title:k_thessalonika
#			this = title:k_hellas
#			this = title:k_egypt
#			AND = {
#				OR = {
#					this = title:k_persia
#					this = title:e_persia
#				}
#				NOR = {
#					root.faith.religion = religion:islam_religion
#					root.faith.religion = religion:zoroastrianism_religion
#				}
#			}
#			this = title:k_anatolia
#		}
#		this = title:k_poland # Lech
#		this = title:k_bohemia # Czech
#		OR = { # Rus
#			this = title:k_white_rus
#			this = title:k_ruthenia
#			this = title:e_russia
#		}
#		OR = { # Arthur
#			this = title:k_england
#			this = title:e_britannia
#		}
#		AND = {
#			OR = { # Belisarius
#				this = title:k_italy
#				this = title:k_romagna
#				this = title:k_sardinia
#				this = title:k_naples
#				this = title:e_italy
#			}
#			root.faith = faith:orthodox
#		}
#		OR = { # Romulus
#			this = title:k_italy
#			this = title:k_romagna
#			this = title:k_sardinia
#			this = title:e_italy
#			this = title:h_roman_empire
#			this = title:h_eastern_roman_empire
#		}
#		OR = { # Ardashir
#			this = title:k_persia
#			this = title:e_persia
#		}
#		AND = { # Pharaohs
#			this = title:k_egypt
#			NOT = { root.faith.religion = religion:islam_religion }
#		}
#		AND = { # Visigothic Kings
#			OR = {
#				this = title:k_castille
#				this = title:k_aragon
#				this = title:k_navarra
#				this = title:k_andalusia
#				this = title:k_portugal
#				this = title:e_spain
#			}
#			NOT = { root.faith.religion = religion:islam_religion }
#		}
#		AND = { # Abd al-Rahman
#			OR = {
#				this = title:k_castille
#				this = title:k_aragon
#				this = title:k_navarra
#				this = title:k_andalusia
#				this = title:k_portugal
#				this = title:e_spain
#			}
#			root.faith.religion = religion:islam_religion
#		}
#		AND = { # Zenobia
#			OR = {
#				this = title:k_syria
#				this = title:k_mesopotamia
#			}
#			NOT = { root.faith.religion = religion:islam_religion }
#		}
	}
}

has_too_many_held_duchies_trigger = {
	highest_held_title_tier >= tier_kingdom
	any_held_title = {
		count >= 3
		title_counts_towards_too_many_duchies_trigger = yes
	}
}

title_counts_towards_too_many_duchies_trigger = {
	tier = tier_duchy
	is_titular = no
}

# this = title
# VASSAL = Vassal to check tier against
# LIEGE = Liege of vassal
title_lost_from_realm_on_foreign_ruler_succession_trigger = {
	tier > $VASSAL$.highest_held_title_tier
	exists = holder  # Ignoring titles that will be created by confederate partition, cause that be magic and unlikely to make a warning anyway
	holder = {
		NOR = {
			this = $LIEGE$
			target_is_liege_or_above = $LIEGE$
			government_has_flag = government_is_special_administrative # Ignoring because admin counts do not take it with them, but immediately resign it when they inherit a governorship
		}
	}
}

# Would this character ever be travelling outside of their palace walls at random for the purposes of events?
## We don't care about personality, only whether it'd be immersion breaking in principle to run into this person at random/to have an event trigger where you are randomly wandering.
character_title_allows_off_screen_wandering_trigger = {
	NOR = {
		# No administrative or clan emperors.
		AND = {
			highest_held_title_tier >= tier_empire
			OR = {
				government_has_flag = government_is_special_administrative
				government_has_flag = government_is_clan
			}
		}
		# No administrative kings.
		AND = {
			highest_held_title_tier = tier_kingdom
			government_has_flag = government_is_special_administrative
		}
		# No religious heads.
		faith.religious_head ?= this
	}
}

county_held_or_vassal_to_target_trigger = {
	holder ?= {
		OR = {
			this = $TARGET$
			target_is_liege_or_above = $TARGET$
		}
	}
}
