Wiki

trigger · is_assigned

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

is_assigned = yes/no - Checks if the current unit leader is assigned to command an army/navy

实战 · 配合 · 坑

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

实战用法

is_assigned 常用于动态角色管理场景,例如在将领被派遣上阵时禁止玩家对其执行某些操作(如晋升、退休或更换顾问职务),或者在事件/决策中判断某位角色当前是否处于指挥状态以给出不同的剧情分支。典型场景是:一名角色同时挂载了顾问角色,当其在统帅军队时不允许被解雇。

# 示例:仅当该角色未被分配指挥任务时,才允许解雇其顾问职务
advisor_can_be_fired = {
    limit = {
        NOT = { is_assigned = yes }
    }
}

配合关系

  • [is_leading_army](/wiki/trigger/is_leading_army):两者经常组合使用,is_assigned 判断角色是否绑定到任何指挥位置,is_leading_army 则进一步确认其是否正在实际统率一支陆军,二者形成粗粒度与细粒度的双重校验。
  • [advisor_can_be_fired](/wiki/trigger/advisor_can_be_fired):当需要保护正在出征的将领不被从顾问位解雇时,将 is_assigned 作为 advisor_can_be_fired 的否定前置条件,逻辑最为直接。
  • [retire](/wiki/effect/retire):在触发强制退役 effect 前用 is_assigned = no 做保护判断,避免将仍在指挥部队的将领直接退役导致部队失去统帅的逻辑错误。
  • [is_corps_commander](/wiki/trigger/is_corps_commander):配合使用可区分"被分配指挥的军团长"与"尚未分配的军团长",常见于按战场状态给予不同特质或经验奖励的脚本。

常见坑

  1. 混淆"拥有角色"与"已分配指挥":新手常误以为只要角色具备 corps_commanderfield_marshal 角色,is_assigned 就会返回 yes,实际上该 trigger 只有在角色被玩家/AI 实际拖入指挥位(绑定到具体军队/舰队)后才为真,未分配的将领即使有角色定义也返回 no
  2. 在 Country scope 下误用is_assigned 只在 CHARACTER scope 下有效,若在国家事件的 trigger 块中直接书写而不先用 any_character/specific character scope 切换作用域,脚本会静默失败或报错,排查时往往难以发现。

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_assigned is commonly used in dynamic character management scenarios, such as preventing players from performing certain operations (like promotions, retirement, or reassigning advisor roles) on a general when they are deployed in command, or determining in events/decisions whether a character is currently in command to branch the narrative accordingly. A typical scenario is: a character simultaneously holds an advisor role, and when commanding an army they cannot be dismissed.

# Example: Only allow dismissing the advisor role if the character is not assigned to any command position
advisor_can_be_fired = {
    limit = {
        NOT = { is_assigned = yes }
    }
}

Synergy

  • [is_leading_army](/wiki/trigger/is_leading_army): These two are frequently used in combination. is_assigned determines whether a character is bound to any command position, while is_leading_army further confirms whether they are actually commanding an army unit, forming a dual validation of coarse-grained and fine-grained checks.
  • [advisor_can_be_fired](/wiki/trigger/advisor_can_be_fired): When protecting a general on active deployment from being dismissed from their advisor position, using is_assigned as a negated precondition for advisor_can_be_fired provides the most direct logic.
  • [retire](/wiki/effect/retire): Use is_assigned = no as a protective check before triggering the force retirement effect, preventing the logical error of losing command when retiring a general still commanding troops.
  • [is_corps_commander](/wiki/trigger/is_corps_commander): Combined use allows distinguishing between "corps commanders assigned to command" and "unassigned corps commanders", commonly found in scripts that grant different traits or experience rewards based on battlefield status.

Common Pitfalls

  1. Confusing "character ownership" with "assigned to command": Beginners often mistakenly believe that if a character has the corps_commander or field_marshal role, is_assigned will return yes. In reality, this trigger only returns true after the character is actually dragged into a command position by the player/AI (bound to a specific army/fleet). Unassigned generals return no even if they have role definitions.
  2. Misusing in Country scope: is_assigned only works in CHARACTER scope. If written directly in a country event's trigger block without first switching scope using any_character/specific character scope, the script will silently fail or throw an error, making debugging difficult.