trigger · has_unit_leader
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
check if country has unit leader with specified ID. Don't localize this. Tooltip only for debug.
has_unit_leaderCOUNTRYnonecheck if country has unit leader with specified ID. Don't localize this. Tooltip only for debug.
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_unit_leader 常用于检测某位特定将领是否仍在某国麾下,例如在事件或决策中判断某个剧情关键人物(如特定 ID 的将领)是否还存活、未被俘虏,从而决定是否触发后续剧情链。也可用于 available 块中锁定某决策,只有当玩家拥有该将领时方可执行。
# 示例:某决策仅在拥有 ID 为 500 的将领时可用
decision_example = {
available = {
has_unit_leader = 500
}
...
}
[any_unit_leader](/wiki/trigger/any_unit_leader):当不需要精确 ID、只需检查是否存在满足某条件的将领时,两者形成互补——has_unit_leader 精确定位,any_unit_leader 泛化筛选。[every_unit_leader](/wiki/effect/every_unit_leader):确认该将领存在后,用 every_unit_leader 对其批量添加特性或修改属性,配合使用保证操作安全不报错。[has_character](/wiki/trigger/has_character):若将领同时以顾问/角色形式存在,has_character 可检测其角色状态,两者联合使用可覆盖同一人物的多重身份判断。[add_trait](/wiki/effect/add_trait):在确认将领存在后为其添加特性,避免在将领不存在时执行特性添加导致脚本报错或静默失效。id = XXX),而非 name 字段或 character 标签。新手常误用本地化名称或 character key 作为参数,导致条件永远不满足。trigger_tooltip 块中向玩家呈现会造成说明文本缺失或显示乱码,应改用其他更直观的条件做可读性替代。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_unit_leader is commonly used to check whether a specific unit leader remains under a particular country's command. For example, it can be used in events or decisions to determine whether a key story character (such as a leader with a specific ID) is still alive and not captured, thereby deciding whether to trigger subsequent story chains. It can also be used in the available block to lock a decision, allowing execution only when the player possesses that leader.
# Example: A decision is only available when possessing a leader with ID 500
decision_example = {
available = {
has_unit_leader = 500
}
...
}
[any_unit_leader](/wiki/trigger/any_unit_leader): When precise ID matching is unnecessary and you only need to check whether a leader exists that meets certain conditions, the two form a complementary pair — has_unit_leader provides exact pinpointing while any_unit_leader enables generalized filtering.[every_unit_leader](/wiki/effect/every_unit_leader): After confirming the leader exists, use every_unit_leader to batch-add traits or modify attributes to them. Using them together ensures operations are safe and error-free.[has_character](/wiki/trigger/has_character): If a leader simultaneously exists as an advisor or character, has_character can detect their character status. Using both together allows you to cover multi-faceted identity checks for the same person.[add_trait](/wiki/effect/add_trait): After confirming the leader exists, add traits to them to avoid executing trait additions when a leader doesn't exist, which could cause script errors or silent failures.id = XXX), not the name field or character key. Beginners often mistakenly use localized names or character keys as parameters, causing the condition to never be satisfied.trigger_tooltip block to show players will result in missing or garbled description text. Use other more intuitive conditions as readable alternatives instead.