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.
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_id 常用于需要精确定位某个特定角色的场景,例如在剧本事件或国策中判断"当前操作的角色是否就是那个我们预设的特殊将领",从而触发专属分支逻辑。典型场景包括:限制某个隐藏国策只对特定 ID 的将领生效,或在 on_action 触发时过滤掉非目标角色。
# 在某个将领相关事件的 trigger 块中,确认触发者是目标角色
character_event = {
id = my_mod.1
trigger = {
# scope 为 CHARACTER
has_id = 123
}
...
}
[is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal):在确认 ID 匹配之后,进一步校验该角色当前的军事职位,避免对职位已变更的角色误触发逻辑。[has_trait](/wiki/trigger/has_trait):与 has_id 并列使用,确认指定 ID 的角色是否同时持有某特质,常用于解锁专属特质链。[add_trait](/wiki/effect/add_trait)(即 [add_trait](/wiki/effect/add_trait)):has_id 作为前置条件通过后,在 effect 块中安全地为该特定角色添加特质,防止 trait 误发给其他角色。[has_character_flag](/wiki/trigger/has_character_flag):与 has_id 配合做"已处理"标记检查,防止同一角色的专属事件链被重复触发。charinfo 命令实时确认目标角色的真实 ID 再写入脚本。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.