###TRIGGER LIST
#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

has_contagious_deadly_disease_trigger = {
	has_trait_with_flag = contagious_deadly_disease
}

is_healthy = {
	custom_tooltip = {
		text = not_poor_health_tt
		health >= fine_health
	}
	NOT = {
		has_trait_with_flag = is_healthy_trigger_flag
	}
	has_contagious_deadly_disease_trigger = no
}

basic_is_available_ai = {
	is_available_quick = {
		ai = yes
		alive = yes
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
}

is_available_allow_travelling = {
	is_available_quick = {
		alive = yes
		imprisoned = no
		incapable = no
		in_army = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
	# Variable set on Mandala succession
	custom_tooltip = {
		text = busy_in_mandala_succession
		NOT = { has_variable = busy_in_mandala_succession }
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available = {
	is_available_quick = {
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
	# Variable set on Mandala succession
	custom_tooltip = {
		text = busy_in_mandala_succession
		NOT = { has_variable = busy_in_mandala_succession }
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_travelling = {
	is_available_quick = {
		alive = yes
		in_army = no
		imprisoned = no
		incapable = no
		travel = yes
	}
	has_contagious_deadly_disease_trigger = no
	NOR = {
		has_character_flag = is_in_task_contract_event_chain
		has_variable = gone_adventuring
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_travelling_adult = {
	is_available_quick = {
		travel = yes
		adult = yes
		alive = yes
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	NOR = {
		has_character_flag = is_in_task_contract_event_chain
		has_variable = gone_adventuring
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_travelling_ai_adult = {
	is_available_quick = {
		travel = yes
		adult = yes
		ai = yes
		alive = yes
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	NOR = {
		has_character_flag = is_in_task_contract_event_chain
		has_variable = gone_adventuring
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_physically_able = {
	is_available_quick = {
		alive = yes
		imprisoned = no
		incapable = no
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_physically_able_ai = {
	is_available_quick = {
		ai = yes
		alive = yes
		imprisoned = no
		incapable = no
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_physically_able_adult = {
	is_available_quick = {
		adult = yes
		alive = yes
		imprisoned = no
		incapable = no
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_physically_able_ai_adult = {
	is_available_quick = {
		ai = yes
		adult = yes
		alive = yes
		imprisoned = no
		incapable = no
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_ai = {
	is_available_quick = {
		ai = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_child = {
	is_available_quick = {
		adult = no
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}

	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_child_allow_travel = {
	is_available_quick = {
		adult = no
		alive = yes
		in_army = no
		imprisoned = no
		incapable = no
	}

	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_ai_child = {
	is_available_quick = {
		adult = no
		ai = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_healthy_child = {
	is_available_quick = {
		adult = no
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	is_healthy = yes
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_healthy_ai_child = {
	is_available_quick = {
		ai = yes
		adult = no
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	is_healthy = yes
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_adult = {
	is_available_quick = {
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_ai_adult = {
	is_available_quick = {
		ai = yes
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_healthy_adult = {
	is_available_quick = {
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	is_healthy = yes
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_healthy_ai_adult = {
	is_available_quick = {
		ai = yes
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	is_healthy = yes
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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_adult_or_is_commanding = {
	OR = {
		is_commanding_army = yes
		is_available_adult = yes
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_at_peace = {
	is_available_quick = {
		at_war = no
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_at_peace_adult = {
	is_available_quick = {
		at_war = no
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}
	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_at_peace_ai_adult = {
	is_available_quick = {
		ai = yes
		adult = yes
		alive = yes
		imprisoned = no
		incapable = no
		travel = no
		in_army = no
		at_war = no
	}

	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_available_at_peace_adult_lenient = {
	is_available_quick = {
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
		at_war = no
	}

	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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 }
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
# Meaning you may be at war, but you're still located in your capital.
is_available_even_at_war_adult = {
	is_available_quick = {
		adult = yes
		alive = yes
		travel = no
		in_army = no
		imprisoned = no
		incapable = no
	}

	has_contagious_deadly_disease_trigger = no
	custom_description = {
		text = ALREADY_IN_ACTIVITY
		NOR = {
			exists = involved_activity
			has_variable = {
				name = homage_liege_scope
				name = meditation_character_flag
				name = local_shrine_rite
				name = petition_liege_character_flag
				name = 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_capable_adult = {
	is_available_quick = {
		adult = yes
		incapable = no
	}
}

is_capable_adult_ai = {
	is_available_quick = {
		ai = yes
		adult = yes
		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_available_quick = {
		imprisoned = no
		incapable = no
	}
	OR = {
		is_travelling = no
		has_government = landless_adventurer_government
	}
	NOR = {
		has_character_flag = is_in_task_contract_event_chain
		exists = involved_activity
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_valid_for_narrow_yearly_events = {
	is_available_quick = {
		at_war = no
		imprisoned = no
		incapable = no
	}
	is_commanding_army = no
	is_playable_character = yes
	OR = {
		is_travelling = no
		has_government = landless_adventurer_government
	}
	NOR = {
		has_character_flag = is_in_task_contract_event_chain
		exists = involved_activity
	}
}

# If you update one of the available triggers, update all of them. It's a lot better for performance to not have scripted triggers within scripted triggers when they're checked as often as these ones are.
is_valid_for_narrow_yearly_events_adult = {
	is_available_quick = {
		adult = yes
		at_war = no
		imprisoned = no
		incapable = no
	}
	is_commanding_army = no
	is_playable_character = yes
	OR = {
		is_travelling = no
		has_government = landless_adventurer_government
	}
	NOR = {
		has_character_flag = is_in_task_contract_event_chain
		exists = involved_activity
	}
}

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_available_quick = {
		ruler = yes
		landed = 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 = {
	OR = {
		government_has_flag = government_is_landless_adventurer
		government_has_flag = government_is_landless_minority
	}
}

# This trigger checks if a character is a governor in an admin realm (implying they are landed)
is_governor = {
	government_allows = administrative
	is_landed = yes
	top_liege != this
	OR = {
		highest_held_title_tier >= main_administrative_tier
		highest_held_title_tier >= min_title_maa_tier
	}
	tgp_is_ceremonial_liege_trigger = no
}
is_governor_or_admin_count = {
	government_allows = administrative
	is_landed = yes
	top_liege != this
	highest_held_title_tier >= tier_county
	tgp_is_ceremonial_liege_trigger = no
}

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

# Checks if a character is a landless house_head within a feudal realm
is_landless_soryo = {
	government_has_flag = government_is_japan_feudal
	is_landed = no
	is_house_head = yes
	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, a landless adventurer, a landless soryo, or a minister
is_playable_character = {
	OR = {
		government_has_flag = government_is_prepublic
		government_has_flag = government_is_urepublic
		is_landed = yes
		is_landless_administrative = yes
		is_landless_adventurer = yes
		is_landless_nomad = yes
		is_landless_soryo = yes
		tgp_is_any_minister = yes # To keep ministers playable, regardless of having a nobel family title or not
	}
}

roman_restoration_is_valid_roman_empire_trigger = {
	is_ai = no
	is_roman_emperor_trigger = yes
	OR = {
		faith.religion = religion:eastern_orthodox_religion
		faith.religion = religion:catholic_religion
		faith.religion = religion:protestant_religion
		religion = religion:theomach_religion #Or Hellenic
	}
	NOT = { has_ep3_dlc_trigger = yes }
}

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