Wiki

trigger · is_unit_leader

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

is_unit_leader = yes/no - Checks if the current character is a unit leader

实战 · 配合 · 坑

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

实战用法

is_unit_leader 常用于角色事件或决策中,区分某个角色当前是否担任野战指挥官职务,从而决定是否允许其转型为顾问或国家领袖。例如在一个自定义角色晋升系统中,只有尚未担任部队指挥的角色才能立即被任命为政治顾问:

available = {
    is_unit_leader = no
    is_advisor = no
}

也可反向使用,确保只有正在带兵的将领才能触发特定战场事件。

配合关系

  • [is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal):与 is_unit_leader 配合可进一步细化"是指挥官"的具体级别,is_unit_leader = yes 作为宽泛前置检查,再用这两者区分军长与元帅。
  • [is_leading_army](/wiki/trigger/is_leading_army):仅判断角色是指挥官还不够,追加此条件可确认其正处于实际统兵状态,避免对已解除指挥的将领触发错误逻辑。
  • [remove_unit_leader](/wiki/effect/remove_unit_leader):在 is_unit_leader = yes 确认身份后,用此 effect 安全地撤销其指挥官身份,防止对非指挥官角色调用该 effect 导致报错或无效执行。
  • [add_advisor_role](/wiki/effect/add_advisor_role):常见的"将领转顾问"流程先以 is_unit_leader = no 把关,再调用此 effect 赋予顾问职能,两者形成完整的身份切换逻辑。

常见坑

  1. Scope 混用:此 trigger 只在 CHARACTER scope 下有效,若在 country scope 的 limit 块中直接书写会静默失败或报错,需先用 any_character/specific character token 切换到角色 scope 再进行判断。
  2. 未区分"是指挥官"与"正在带兵"is_unit_leader = yes 仅说明角色拥有指挥官角色,即使当前没有部队跟随也会返回真;若逻辑依赖"正在统帅军队",必须额外加上 [is_leading_army](/wiki/trigger/is_leading_army) 才能准确筛选。

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

is_unit_leader is commonly used in character events or decisions to distinguish whether a character currently holds an active field command position, thereby determining whether they can transition into an advisor role or national leader. For example, in a custom character promotion system, only characters not yet assigned to unit command can be immediately appointed as political advisors:

available = {
    is_unit_leader = no
    is_advisor = no
}

It can also be used inversely to ensure that only generals actively commanding troops trigger specific battlefield events.

Synergy

  • [is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal): Combined with is_unit_leader, these allow further refinement of the specific rank level of "being a commander". Use is_unit_leader = yes as a broad prerequisite check, then differentiate between corps commanders and field marshals with these two.
  • [is_leading_army](/wiki/trigger/is_leading_army): Simply checking if a character is a commander is insufficient; adding this condition confirms they are actively commanding troops, preventing erroneous logic from triggering on generals who have been relieved of command.
  • [remove_unit_leader](/wiki/effect/remove_unit_leader): After confirming identity with is_unit_leader = yes, use this effect to safely revoke their commander status, preventing errors or failed execution when calling this effect on non-commander characters.
  • [add_advisor_role](/wiki/effect/add_advisor_role): The common "general-to-advisor" workflow first gates with is_unit_leader = no, then calls this effect to grant advisor functions, forming a complete identity-switching logic between the two.

Common Pitfalls

  1. Scope Mixing: This trigger is only valid in CHARACTER scope. Writing it directly in a limit block within country scope will silently fail or error. You must first switch to character scope using any_character or a specific character token before performing the check.
  2. Conflating "Is a Commander" with "Is Actively Leading Troops": is_unit_leader = yes only indicates the character holds a commander role; it returns true even if no units currently follow them. If your logic depends on "is actively commanding an army", you must additionally include [is_leading_army](/wiki/trigger/is_leading_army) to accurately filter.