Wiki

trigger · reserves

Definition

  • Supported scope:COMBATANT
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

check amount of reserves

实战 · 配合 · 坑

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

实战用法

reserves 常用于战斗事件或决策中,判断某一参战方是否还有足够的预备队兵力,从而触发援军相关事件或修改战斗结果。例如在自定义战斗结局 mod 中,当预备队耗尽时触发撤退命令或特殊战役事件。

# 战斗事件:当攻击方预备队不足时触发
combat_event = {
    id = my_combat.1
    trigger = {
        is_attacker = yes
        reserves < 2
    }
    ...
}

配合关系

  • [has_reserves](/wiki/trigger/has_reserves):两者都检测预备队状态,has_reserves 返回是否存在预备队(布尔值),而 reserves 可做数量比较,常组合使用以区分"有无"与"多少"两种判断层次。
  • [is_attacker](/wiki/trigger/is_attacker) / [is_defender](/wiki/trigger/is_defender):战场上攻守双方的预备队状态通常需要分别检测,配合方向判断可以精确针对某一方的预备队数量写条件。
  • [is_winning](/wiki/trigger/is_winning):预备队数量与战场胜负往往相关,二者配合可描述"正在获胜但预备队已告急"等复杂战场状态,用于触发特定战斗叙事事件。
  • [phase](/wiki/trigger/phase):战斗阶段影响预备队的实际意义,在不同阶段(如冲击阶段 vs 巩固阶段)结合 reserves 判断,可实现更精细的战斗过程模拟。

常见坑

  1. 直接在非战斗 scope 下使用reserves 仅在 COMBATANT scope 中有效,新手容易将其写在国家或省份 scope 的事件触发条件里,导致脚本报错或静默失效,务必确认当前 scope 是战斗参与方。
  2. has_reserves 混用逻辑错误has_reserves 是布尔检测(有/无预备队),reserves 是数量比较,初学者有时用 reserves > 0 替代 has_reserves = yes,虽然在某些版本下功能相近,但语义上应优先使用专用布尔 trigger,避免因版本差异导致行为不一致。

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

reserves is commonly used in combat events or decisions to determine whether a combatant still has sufficient reserve forces, thereby triggering reinforcement-related events or modifying combat outcomes. For example, in custom battle resolution mods, you can trigger retreat commands or special campaign events when reserves are depleted.

# Combat event: triggered when attacker's reserves fall below threshold
combat_event = {
    id = my_combat.1
    trigger = {
        is_attacker = yes
        reserves < 2
    }
    ...
}

Synergy

  • [has_reserves](/wiki/trigger/has_reserves): Both check reserve status, but has_reserves returns a boolean indicating presence or absence of reserves, while reserves allows numerical comparison. They are commonly combined to distinguish between "existence" and "quantity" judgment layers.
  • [is_attacker](/wiki/trigger/is_attacker) / [is_defender](/wiki/trigger/is_defender): Reserve states for both sides of a battlefield typically need separate evaluation. Combined with directional checks, they enable precise conditions targeting one side's reserve count.
  • [is_winning](/wiki/trigger/is_winning): Reserve quantity and battlefield victory are often correlated. Together they can describe complex battle states such as "winning but reserves critically low," useful for triggering specific combat narrative events.
  • [phase](/wiki/trigger/phase): Combat phase affects the practical significance of reserves. Combining reserves checks across different phases (e.g., shock phase vs consolidation phase) enables more granular battle process simulation.

Common Pitfalls

  1. Using outside combat scope: reserves is only valid within COMBATANT scope. Beginners often mistakenly place it in event triggers under country or province scope, causing script errors or silent failures. Always verify the current scope is a combat participant.
  2. Logic errors mixing with has_reserves: has_reserves is a boolean check (reserves present/absent), while reserves performs numerical comparison. Inexperienced modders sometimes substitute reserves > 0 for has_reserves = yes. While functionally similar in certain versions, semantically you should prioritize the dedicated boolean trigger to avoid inconsistencies across patch versions.