trigger · has_id
Definition
- Supported scope:
CHARACTER - Supported target:
none
Description
check unit leader has specified ID. Don't localize this. Tooltip only for debug.
has_idCHARACTERnonecheck unit leader has specified ID. Don't localize this. Tooltip only for debug.
Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.
has_id is commonly used in scenarios requiring precise targeting of a specific character, such as in scripted events or national focuses to determine "whether the character currently being acted upon is the special leader we predefined," thereby triggering exclusive branch logic. Typical use cases include: restricting a hidden national focus to apply only to leaders with a specific ID, or filtering out non-target characters when on_action is triggered.
# In the trigger block of a character-related event, confirm the triggering character matches the target
character_event = {
id = my_mod.1
trigger = {
# scope is CHARACTER
has_id = 123
}
...
}
[is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal): After confirming ID match, further verify the character's current military position to avoid misfiring logic on characters whose positions have changed.[has_trait](/wiki/trigger/has_trait): Used alongside has_id to confirm whether the specified ID character simultaneously possesses a certain trait, commonly used to unlock exclusive trait chains.[add_trait](/wiki/effect/add_trait): After has_id passes as a precondition, safely add traits to that specific character in the effect block, preventing traits from being accidentally applied to other characters.[has_character_flag](/wiki/trigger/has_character_flag): Combined with has_id to check "already processed" markers, preventing exclusive event chains for the same character from being triggered repeatedly.charinfo command in debug mode to confirm the target character's actual ID before writing it into scripts.