Wiki

trigger · any_unit_leader

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Checks if at least one Unit Leader of the Country in scope matches the triggers.
tooltip=key can be defined to override title.
ex: GER = {
  any_unit_leader = {
	tooltip = my_loc_key # Optional
	include_invisible = yes # Optional - default = no
    ... character scope triggers ...
  }
}

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

常用于检测某国是否拥有满足特定条件的将领,例如在决策或事件的 available / trigger 块里判断是否有高技能或特定特质的指挥官,以此解锁剧本内容或触发特殊事件。

# 示例:只有当德国至少有一名同时拥有 "panzer_leader" 特质且技能 ≥ 4 的陆军将领时,决策才可用
available = {
    GER = {
        any_unit_leader = {
            is_corps_commander = yes
            has_trait = panzer_leader
            skill >= 4
        }
    }
}

配合关系

  • has_trait — 最常见的内层条件,用于筛选持有某具体特质的将领,与 any_unit_leader 组合可精确定位目标人物。
  • is_field_marshal — 在内层区分元帅与将军身份,避免检测范围过宽。
  • skill — 对将领的综合技能或子技能数值设置门槛,常与特质检测并列使用。
  • has_unit_leader_flag — 检测是否已对某将领设置过自定义标记,防止同一事件链重复触发。

常见坑

  1. 作用域错误any_unit_leader 只能在 COUNTRY scope 下调用;若当前已经在 character scope 内(如 every_unit_leader 的循环体里)再嵌套 any_unit_leader,需先用 ROOT/PREV 等关键字回到国家 scope,否则会因 scope 不匹配而静默返回 false。
  2. 把它当 effect 使用any_unit_leader 是 trigger,无法产生任何效果;若想对所有符合条件的将领执行操作,应改用 effect 侧的 every_unit_leader(带 limit = { ... } 内层过滤)。

Hands-On Notes

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.

Hands-On Usage

Commonly used to check whether a country has at least one unit leader meeting specific conditions — for example, inside an available or trigger block of a decision or event, to verify whether a commander with a high skill rating or a particular trait exists, thereby unlocking scripted content or firing special events.

# Example: the decision is only available if Germany has at least one corps commander
# who possesses the "panzer_leader" trait and has skill >= 4
available = {
    GER = {
        any_unit_leader = {
            is_corps_commander = yes
            has_trait = panzer_leader
            skill >= 4
        }
    }
}

Synergy

  • has_trait — The most common inner condition; filters for leaders that hold a specific trait. Paired with any_unit_leader, it lets you pinpoint an exact target character.
  • is_field_marshal — Used inside the inner scope to distinguish field marshals from corps commanders, preventing the check from casting too wide a net.
  • skill — Sets a threshold on a leader's overall skill or sub-skill value; frequently used alongside trait checks.
  • has_unit_leader_flag — Checks whether a custom flag has already been set on a leader, preventing the same event chain from triggering more than once.

Common Pitfalls

  1. Wrong scope: any_unit_leader can only be called from a COUNTRY scope. If you are already inside a character scope (e.g., inside the body of an every_unit_leader loop) and try to nest any_unit_leader, you must first return to a country scope via ROOT, PREV, or a similar keyword — otherwise the scope mismatch will cause it to silently return false.
  2. Using it as an effect: any_unit_leader is a trigger and cannot produce any effects. If you want to perform an operation on every leader that meets certain conditions, use the effect-side every_unit_leader instead (with a limit = { ... } block for inner filtering).