Wiki

effect · damage_units

Definition

  • Supported scope:any
  • Supported target:any

Description

damages units for given conditions. no tooltip generated
damage_units = {
  #specify a location
  province = 42
  state = 5
  region = 5
  limit = { always = yes } #you can add a trigger for country check
  damage = 0.5 #if defined will damage both org & str damage with this amount
  org_damage = 0.5
  str_damage = 0.5
  ratio = yes #will damage a ratio damage to total org/str of unit if set
  template = "template_name" #you can limit army templates to damage  army = yes #will damage armies
  navy = yes #will damage navies
}

实战 · 配合 · 坑

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

实战用法

damage_units 常用于事件、决议或剧本触发器中模拟战场损耗、灾难或特殊战斗效果,例如流行病导致驻扎部队战斗力下降、轰炸事件造成省份内部队受损。它不生成任何工具提示,因此通常包裹在 hidden_effect 中,再搭配 custom_effect_tooltip 手动向玩家显示说明文字。

# 事件效果:某省爆发疾病,削弱当地驻军组织度与兵力
hidden_effect = {
    damage_units = {
        province = 1234
        org_damage = 0.3
        str_damage = 0.1
    }
}
custom_effect_tooltip = disease_weakens_garrison_tt

配合关系

  • [hidden_effect](/wiki/effect/hidden_effect):由于 damage_units 不生成原生提示,几乎必须嵌套在 hidden_effect 内,再另行提供说明。
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip):配合 hidden_effect 使用,向玩家展示可读的伤害说明,弥补无提示的缺陷。
  • [if](/wiki/effect/if):在造成伤害前先通过条件分支判断目标省份或地区是否满足特定情况(如是否有驻军),避免空操作或逻辑错误。
  • [any_state](/wiki/trigger/any_state):在触发条件层面确认某个 state 内存在部队后,再决定是否执行伤害,提高脚本健壮性。

常见坑

  1. 忘记 damageorg_damage/str_damage 同时存在时的覆盖关系:若同时写了 damageorg_damage/str_damage,各字段会各自独立生效,容易导致伤害叠加超出预期;建议只选一种方式填写,不要混用。
  2. 误以为会自动生成提示:新手常直接把 damage_units 写在 option 块中却发现玩家界面毫无反馈,原因正是该 effect 明确说明"no tooltip generated",必须手动配合 custom_effect_tooltip 补充说明,否则玩家完全看不到任何伤害提示。

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

damage_units is commonly used in events, decisions, or scripted triggers to simulate battlefield attrition, disasters, or special combat effects—for example, an epidemic reducing the combat effectiveness of garrisoned troops, or bombing events damaging units within a province. It generates no native tooltip, so it is typically wrapped in hidden_effect and paired with custom_effect_tooltip to manually display explanatory text to the player.

# Event effect: disease outbreak in a province weakens local garrison organization and manpower
hidden_effect = {
    damage_units = {
        province = 1234
        org_damage = 0.3
        str_damage = 0.1
    }
}
custom_effect_tooltip = disease_weakens_garrison_tt

Synergy

  • [hidden_effect](/wiki/effect/hidden_effect): Since damage_units produces no native tooltip, it should almost always be nested within hidden_effect with a separate explanation provided.
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): Used in tandem with hidden_effect to display readable damage descriptions to the player, compensating for the lack of native feedback.
  • [if](/wiki/effect/if): Evaluate conditional branches before applying damage to verify that the target province or region meets specific criteria (such as having stationed units), preventing empty operations or logical errors.
  • [any_state](/wiki/trigger/any_state): Confirm at the trigger level that a state contains units before deciding whether to execute damage, improving script robustness.

Common Pitfalls

  1. Forgetting the override relationship when damage and org_damage/str_damage coexist: If both damage and org_damage/str_damage are written simultaneously, each field takes effect independently, easily causing damage to stack beyond expectations. It is recommended to use only one approach and avoid mixing them.
  2. Mistakenly assuming a tooltip is automatically generated: Beginners often write damage_units directly in an option block only to find no feedback in the player interface. The reason is that this effect explicitly states "no tooltip generated"—you must manually pair it with custom_effect_tooltip to provide an explanation, otherwise players see no damage indication whatsoever.