Wiki

trigger · is_fighting_in_terrain

Definition

  • Supported scope:COMBATANT
  • Supported target:none

Description

check what terrain is in combat

实战 · 配合 · 坑

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

实战用法

is_fighting_in_terrain 常用于为特定地形中的战斗单位附加 modifier 或触发特殊事件,例如在沙漠、山地、丛林等地形赋予某些兵种专属加成。典型场景包括:制作地形专精特性 mod 时,限定只有在特定地形交战中才能触发某个决策或 on_action 事件。

# 在战斗事件中判断地形,给予沙漠作战加成
on_combat_phase = {
    limit = {
        is_attacker = yes
        is_fighting_in_terrain = desert
    }
    add_temporary_combat_modifier = {
        modifier = desert_warfare_bonus
    }
}

配合关系

  • is_attacker / is_defender:通常需要先区分进攻/防守方,再判断地形,避免双方都触发同一逻辑造成叠加。
  • is_fighting_in_weather:与天气判断并列使用,可组合出"沙漠暴风雪"等极端环境的复合条件,使地形与气候共同影响战斗结果。
  • has_trait:配合地形判断,校验单位是否拥有对应地形特性,从而决定是否解锁奖励或触发进阶事件。
  • phase:在特定战斗阶段(如火力阶段)结合地形检查,实现更细粒度的战斗逻辑控制。

常见坑

  1. Scope 用错导致脚本静默失败is_fighting_in_terrain 只在 COMBATANT scope 下有效,若写在 country 或 state scope 的条件块中,游戏不会报错但永远返回 false,新手容易误以为是地形值写错而反复调试地形名称。
  2. 地形值使用本地化名而非内部键名:地形参数必须使用 00_terrain.txt 中定义的内部键名(如 desertforestmountain),而非本地化显示文本,两者不一致时条件同样静默失败。

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_fighting_in_terrain is commonly used to apply modifiers to units engaged in combat within specific terrain types or trigger special events, such as granting exclusive bonuses to certain unit types in deserts, mountains, jungles, and other environments. Typical scenarios include creating terrain-specialization mods where specific decisions or on_action events are only triggered when combat occurs in designated terrain.

# Check terrain during combat event and apply desert warfare bonus
on_combat_phase = {
    limit = {
        is_attacker = yes
        is_fighting_in_terrain = desert
    }
    add_temporary_combat_modifier = {
        modifier = desert_warfare_bonus
    }
}

Synergy

  • is_attacker / is_defender: Usually required to first distinguish between attacker and defender before checking terrain, to avoid both sides triggering the same logic and causing stacking issues.
  • is_fighting_in_weather: Used alongside weather checks to compose complex conditions like "desert blizzard," allowing terrain and climate to jointly influence combat outcomes.
  • has_trait: Combined with terrain checks to verify whether a unit possesses the corresponding terrain trait, determining whether to unlock bonuses or trigger advanced events.
  • phase: Check terrain in specific combat phases (such as the fire phase) to implement finer-grained combat logic control.

Common Pitfalls

  1. Incorrect scope causes silent script failure: is_fighting_in_terrain is only valid in COMBATANT scope. If placed within a condition block in country or state scope, the game will not report an error but will always return false, leading inexperienced modders to repeatedly debug terrain names thinking they wrote the wrong terrain value.
  2. Using localized names instead of internal key identifiers for terrain: Terrain parameters must use the internal key names defined in 00_terrain.txt (such as desert, forest, mountain), not localized display text. When the two don't match, the condition likewise fails silently.