trigger · is_attacker
Definition
- Supported scope:
COMBATANT - Supported target:
none
Description
check if attacker side in combat
is_attackerCOMBATANTnonecheck if attacker side in combat
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
is_attacker 常用于战斗事件或战斗修正器中,根据当前部队是进攻方还是防守方来施加不同的效果或条件判断。例如,在自定义战斗 modifier mod 里,可以让进攻方在特定地形获得额外士气加成,或在特定 focus/决策链中只对进攻战斗触发某段文本。
# 战斗事件中:只对进攻方触发特殊对话选项
combat_event = {
id = my_mod.1
trigger = {
is_attacker = yes
is_fighting_in_terrain = { terrain = forest }
}
...
}
is_attacker 互为对立,通常成对出现以覆盖进攻/防守两种分支逻辑,避免条件遗漏。is_attacker 只能在 COMBATANT(战斗参与方)scope 下使用,若写在国家或将领 scope 中会静默失败或报错,新手容易将其误放在 division_leader 或顶层国家 scope 里。is_attacker = no 并不等同于"是防守方"——当该单位不在任何战斗中时,两者均可能返回 no,应搭配 is_defender = yes 明确判断,而非单纯对 is_attacker 取反。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.
is_attacker is commonly used in combat events or combat modifiers to apply different effects or conditional logic based on whether the current unit is attacking or defending. For example, in a custom combat modifier mod, you can grant the attacking side additional morale bonuses in specific terrain, or trigger certain text blocks only for attacking combats within specific focus/decision chains.
# In combat events: trigger special dialogue options only for the attacking side
combat_event = {
id = my_mod.1
trigger = {
is_attacker = yes
is_fighting_in_terrain = { terrain = forest }
}
...
}
is_attacker, typically used together to cover both attacking and defending branches, preventing logical gaps.is_attacker can only be used within COMBATANT (combat participant) scope. Placing it in country or commander scopes will silently fail or throw errors—newcomers often mistakenly put it in division_leader or top-level country scope.is_attacker = no does not equate to "is defending"—when the unit is not in any combat, both can return no. You should pair it with is_defender = yes for explicit checking, rather than simply negating is_attacker.