Wiki

trigger · has_combat_modifier

Definition

  • Supported scope:COMBATANT
  • Supported target:none

Description

check if combatant has modifier

实战 · 配合 · 坑

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

实战用法

has_combat_modifier 常用于战斗事件或特殊机制 mod 中,根据交战方当前是否携带某个战斗修正来触发额外效果或决策,例如区分被"士气崩溃"修正压制的一方和正常交战方。也可用于战斗相关的动态 AI 行为脚本,检测特定增益/减益是否已经叠加,从而避免重复施加同名修正。

# 在战斗事件的触发条件中,仅当进攻方携带某修正时才激活
combat_event = {
    id = my_mod.1
    trigger = {
        is_attacker = yes
        has_combat_modifier = my_special_debuff
    }
    ...
}

配合关系

  • is_attacker — 通常先区分进攻/防守方身份,再检查该方是否持有特定修正,逻辑更精确。
  • is_winning — 配合胜负判断使用,例如"正在占优势且带有某增益修正"时才触发奖励事件。
  • has_trait — 将指挥官特质与战斗修正联合检查,用于区分"因特质而获得修正"与"通过其他途径获得修正"两种情况。
  • phase — 按战斗阶段过滤,确保只在特定阶段(如突破阶段)检查修正是否存在,避免错误时机触发。

常见坑

  1. 修正名拼写错误却不报错:游戏脚本对不存在的修正名通常不会抛出明显错误,而是静默返回 false,导致条件永远不满足。务必与定义该战斗修正的文件中的 key 严格保持一致,包括大小写。
  2. 在非 COMBATANT scope 中使用:此 trigger 仅在战斗参与方(COMBATANT)scope 下有效,若误写在普通国家 scope 或单位 scope 的条件块中,条件将无法正确求值,需通过战斗事件等正确入口进入对应 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

has_combat_modifier is commonly used in combat events or specialized mechanics mods to trigger additional effects or decisions based on whether a combatant currently carries a specific combat modifier. For example, it can distinguish between a side suppressed by a "morale collapse" modifier and a side engaged in normal combat. It can also be used in combat-related dynamic AI behavior scripts to detect whether specific buffs/debuffs have already been applied, thereby avoiding duplicate application of modifiers with the same name.

# In a combat event's trigger conditions, activate only when the attacker carries a specific modifier
combat_event = {
    id = my_mod.1
    trigger = {
        is_attacker = yes
        has_combat_modifier = my_special_debuff
    }
    ...
}

Synergy

  • is_attacker — Typically first distinguish between attacker/defender status, then check if that side possesses the specific modifier for more precise logic.
  • is_winning — Use in conjunction with victory/defeat assessments, for example, trigger a reward event only when "currently gaining an advantage and carrying a specific buff modifier".
  • has_trait — Combine commander traits with combat modifier checks to distinguish between "acquiring a modifier through traits" versus "acquiring a modifier through other means".
  • phase — Filter by combat phase to ensure you only check modifier presence during specific phases (such as breakthrough phase), avoiding incorrect timing triggers.

Common Pitfalls

  1. Typos in modifier names without error reporting: The game script typically does not throw obvious errors for non-existent modifier names; instead, it silently returns false, causing the condition to never be satisfied. Always keep the name strictly consistent with the key in the file that defines the combat modifier, including capitalization.
  2. Using outside COMBATANT scope: This trigger is only valid within the COMBATANT scope (active combatants). If mistakenly written in a condition block within normal country scope or unit scope, the condition will fail to evaluate correctly. You must enter the appropriate scope through proper entry points like combat events before invoking this trigger.