###TRIGGER LIST
#is_busy_in_events_unlocalised 						- already in an involved event chain
#is_in_pseudo_activity_trigger	- character is involved in a pseudo-activity
#has_contagious_deadly_disease_trigger
#is_healthy
#is_available
#is_available_ai
#is_available_adult
#is_available_healthy_adult
#is_available_ai_adult
#is_available_healthy_ai_adult
#is_capable_adult
#is_capable_adult_ai
#liege_is_boss_trigger
#can_select_lifestyle_focus
#can_marry
#can_become_concubine
#is_busy_in_events_localised

# Despite the name, there are rare instances in which these may become visible to the player - if you add to this list, add localization also
is_busy_in_events_unlocalised = {
	OR = {
		has_character_flag = is_in_diplomacy_foreign_special_event
		has_character_flag = is_in_diplomacy_family_special_event
		has_character_flag = is_in_diplomacy_majesty_special_event
		has_character_flag = is_in_martial_special_event
		has_character_flag = is_in_stewardship_domain_special_event
		has_character_flag = is_in_stewardship_duty_special_event
		has_character_flag = is_in_stewardship_wealth_special_event
		has_character_flag = is_in_intrigue_special_event
		has_character_flag = is_in_learning_special_event
		has_character_flag = is_in_task_contract_event_chain
		has_character_flag = migration_events_1060_rode_ahead
	}
}

# For flags that *may* be seen by the player, and thus need to be cloaked in a custom description to look nice.
is_busy_in_events_localised = {
	custom_description = {
		text = "yearly_1010_abducted"
		NOT = { has_character_flag = yearly_1010_abducted }
	}
	custom_description = {
		text = "yearly_1010_abductor"
		NOT = { has_character_flag = yearly_1010_abductor }
	}
}

has_contagious_deadly_disease_trigger = {
	OR = {
		has_trait = bubonic_plague
		has_trait = smallpox
		has_trait = typhus
		has_trait = consumption
		has_trait = measles
		has_trait = dysentery
	}
}

is_healthy = {
	custom_tooltip = {
		text = not_poor_health_tt
		health >= fine_health
	}
	NOR = {
		has_trait = infirm
		has_trait = incapable
		has_trait = wounded_2
		has_trait = wounded_3
	}
	has_contagious_deadly_disease_trigger = no
}

basic_is_available_ai = {
	is_alive = yes
	is_imprisoned = no
	is_ai = yes
	is_incapable = no
	has_contagious_deadly_disease_trigger = no
}

is_available_allow_travelling = {
	is_alive = yes
	is_in_army = no
	is_imprisoned = no
	is_incapable = no
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = homage_liege_scope
			has_character_flag = meditation_character_flag
			has_character_flag = petition_liege_character_flag
			has_character_flag = holding_court_character_flag
			is_being_visited_on_tour_strict = yes
		}
	}
	custom_description = {
		text = ALREADY_PLANNING_ACTIVITY
		NOT = { has_character_flag = planning_an_activity }
	}
	# Variable set within the adventure inspiration events
	NOT = { has_variable = gone_adventuring }
}

is_available = {
	is_travelling = no
	is_available_allow_travelling = yes
}

is_available_travelling = {
	is_alive = yes
	is_in_army = no
	is_imprisoned = no
	is_incapable = no
	is_travelling = yes
	has_contagious_deadly_disease_trigger = no
	NOT = { has_variable = gone_adventuring }
	is_busy_in_events_unlocalised = no
}

is_available_travelling_adult = {
	is_adult = yes
	is_available_travelling = yes
}

is_available_travelling_ai_adult = {
	is_adult = yes
	is_ai = yes
	is_available_travelling = yes
}

is_physically_able = {
	is_alive = yes
	is_imprisoned = no
	is_incapable = no
}

is_physically_able_ai = {
	is_ai = yes
	is_alive = yes
	is_imprisoned = no
	is_incapable = no
}

is_physically_able_adult = {
	is_adult = yes
	is_physically_able = yes
}

is_physically_able_ai_adult = {
	is_ai = yes
	is_adult = yes
	is_physically_able_adult = yes
}

is_available_ai = {
	is_ai = yes
	is_available = yes
}

is_available_child = {
	is_adult = no
	is_available = yes
}

is_available_child_allow_travel = {
	is_adult = no
	is_available_allow_travelling = yes
}

is_available_ai_child = {
	is_adult = no
	is_available = yes
	is_ai = yes
}

is_available_healthy_child = {
	is_available_child = yes
	is_healthy = yes
}

is_available_healthy_ai_child = {
	is_available_healthy_child = yes
	is_ai = yes
}

is_available_adult = {
	is_adult = yes
	is_available = yes
}

is_available_ai_adult = {
	is_available_adult = yes
	is_ai = yes
}

is_available_healthy_adult = {
	is_available_adult = yes
	is_healthy = yes
}

is_available_healthy_ai_adult = {
	is_available_healthy_adult = yes
	is_ai = yes
}

is_available_adult_or_is_commanding = {
	OR = {
		is_commanding_army = yes
		is_available_adult = yes
	}
}

is_available_at_peace = {
	is_at_war = no
	is_available = yes
	is_busy_in_events_unlocalised = no
}

is_available_at_peace_adult = {
	is_at_war = no
	is_available_adult = yes
	is_busy_in_events_unlocalised = no
}

is_available_at_peace_ai_adult = {
	is_available_at_peace_adult = yes
	is_ai = yes
}

is_available_at_peace_adult_lenient = {
	is_at_war = no
	is_available_adult = yes
}

# Meaning you may be at war, but you're still located in your capital.
is_available_even_at_war_adult = {
	is_available_adult = yes
	is_busy_in_events_unlocalised = no
}

is_capable_adult = {
	is_adult = yes
	is_incapable = no
}

is_capable_adult_ai = {
	is_ai = yes
	is_adult = yes
	is_incapable = no
}

can_select_lifestyle_focus = {
	is_capable_adult = yes
	is_playable_character = yes
}

is_not_hostile_towards_root = {
	NOR = {
		is_a_faction_member = yes
		any_scheme = {
			hostile_scheme_trigger = yes
			scheme_target_character = root
		}
		is_at_war_with = root
	}
}

player_target_available_for_personal_scheme_ongoing_events_trigger = {
	$TARGET$ = {
		trigger_if = {
			limit = {
				is_ai = no
				$OWNER$ = { is_ruler = no }
			}
			is_at_war =  no
		}
		trigger_else = {
			always = yes
		}
	}
}


basic_is_valid_for_yearly_events_trigger = {
	is_playable_character = yes
	is_imprisoned = no
	is_incapable = no
	NOT = { exists = involved_activity }
	OR = {
		is_travelling = no
		is_landless_adventurer = yes
	}
	is_busy_in_events_unlocalised = no
}

is_valid_for_narrow_yearly_events = {
	is_at_war = no
	is_commanding_army = no
	basic_is_valid_for_yearly_events_trigger = yes
}

is_valid_for_narrow_yearly_events_adult = {
	is_adult = yes
	is_valid_for_narrow_yearly_events = yes
}

is_within_diplo_range = {
	capital_province ?= {
		save_temporary_scope_as = my_capital
		$CHARACTER$.capital_province ?= {
			squared_distance = {
				target = scope:my_capital
				value < 200000
			}
		}
	}
}

# This trigger checks if a character is a Nomad
is_nomad = {
	government_has_flag = government_is_nomadic
	is_ruler = yes
}

# This trigger checks if a character is a landed Nomad
is_landed_nomad = {
	government_has_flag = government_is_nomadic
	is_landed = yes
	is_ruler = yes
}

# Checks if a character is a landless nomad with a domicile
is_landless_nomad = {
	government_has_flag = government_is_nomadic
	is_landed = no
	has_domicile = yes
}

# This trigger checks if a character is a landless adventurer
is_landless_adventurer = {
	government_has_flag = government_is_landless_adventurer
	is_landed = no
	is_ruler = yes
}

# This trigger checks if a character is a governor in an admin realm (implying they are landed)
is_governor = {
	government_has_flag = government_is_administrative
	is_landed = yes
	is_independent_ruler = no
	highest_held_title_tier >= tier_duchy
}
is_governor_or_admin_count = {
	government_has_flag = government_is_administrative
	is_landed = yes
	is_independent_ruler = no
	highest_held_title_tier >= tier_county
}

# Checks if a character is a landless house_head within an admin realm
is_landless_administrative = {
	government_has_flag = government_is_administrative
	is_landed = no
	has_domicile = yes
}

# Checks if a character is either landed or an unlanded house head within an admin realm
is_landed_or_landless_administrative = {
	OR = {
		is_landed = yes
		is_landless_administrative = yes
	}
}

# Checks if a character is either landed, a landless house head within an admin realm, a landless nomad, or a landless adventurer
is_playable_character = {
	OR = {
		is_landed = yes
		is_landless_administrative = yes
		is_landless_adventurer = yes
		is_landless_nomad = yes
	}
}

roman_restoration_is_valid_roman_empire_trigger = {
	is_ai = no
	OR = {
		has_title = title:e_byzantium
		has_title = title:e_roman_empire
	}
	OR = {
		religion = religion:christianity_religion #Either Christian
		religion = religion:hellenism_religion #Or Hellenic
	}
	NOT = { has_ep3_dlc_trigger = yes }
}

is_eunuch_trigger = {
	OR = {
		has_trait = eunuch_1
		has_trait = beardless_eunuch
	}
}
