Wiki

effect · delete_units

Definition

  • Supported scope:COUNTRY
  • Supported target:any

Description

deletes units that uses a specific template :
delete_units = { 
  division_template = "Template Name"
  disband = no # if yes, equipment will be returned to country equipment. default is no
}

实战 · 配合 · 坑

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

实战用法

delete_units 常用于剧本事件或国策完成后清除特定编制的部队,例如在内战结束、停战协议生效或特殊历史节点触发时,将某支临时武装力量从地图上抹去。配合 disband = yes 可以将其装备回收入国家库存,适合"溃散但保留物资"的叙事场景;而默认的 disband = no 则模拟部队被全歼或凭空消失的效果。

# 内战结束事件:解散叛军模板部队并回收装备
country_event = {
    id = civil_war.5
    immediate = {
        delete_units = {
            division_template = "Rebel Infantry"
            disband = yes
        }
    }
}

配合关系

  • [division_template](/wiki/effect/division_template):先用 division_template 定义或修改模板,再用 delete_units 将其实例全部删除,两者构成"建模—清场"的完整生命周期管理。
  • [add_manpower](/wiki/effect/add_manpower):当 disband = no 时人员直接消失,可在同一事件块中用 add_manpower 补偿一定兵员,模拟士兵投降后被遣散回乡的逻辑。
  • [any_country_division](/wiki/trigger/any_country_division):执行删除前先用此触发器检测是否存在该模板的部队,避免因模板不存在而产生无效调用或逻辑错误。
  • [delete_unit_template_and_units](/wiki/effect/delete_unit_template_and_units):如果目标是彻底移除模板本身及其所有部队,可在 delete_units 之后跟进此命令;两者职责不同,前者只删兵,后者同时删模板。

常见坑

  1. 模板名称大小写/拼写必须与 division_template 定义完全一致,哪怕多一个空格或字母大小写不同,游戏都会静默失败——部队不会被删除,也不会报错提示,极难排查。
  2. disband 默认值为 no,装备会直接蒸发,新手往往忘记写 disband = yes,导致宝贵的装备库存无故损失,尤其在清除装备精良的精锐模板时损失极大。

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

delete_units is commonly used in scripted events or focus completion to remove specific division templates from the map—such as when a civil war ends, a ceasefire takes effect, or at special historical moments to erase temporary armed forces. Combined with disband = yes, equipment can be salvaged back into the national stockpile, suitable for narrative scenarios of "forces dispersed but supplies retained"; whereas the default disband = no simulates units being completely wiped out or vanishing into thin air.

# Civil war conclusion event: disband rebel infantry template and recover equipment
country_event = {
    id = civil_war.5
    immediate = {
        delete_units = {
            division_template = "Rebel Infantry"
            disband = yes
        }
    }
}

Synergy

  • [division_template](/wiki/effect/division_template): First define or modify a template using division_template, then use delete_units to remove all instances of it—together they form a complete lifecycle management of "create-then-clear."
  • [add_manpower](/wiki/effect/add_manpower): When disband = no, personnel vanish directly; you can use add_manpower in the same event block to compensate for manpower loss, simulating the logic of soldiers surrendering and being discharged back home.
  • [any_country_division](/wiki/trigger/any_country_division): Before executing deletion, use this trigger to check whether units of that template exist, avoiding invalid calls or logic errors caused by a non-existent template.
  • [delete_unit_template_and_units](/wiki/effect/delete_unit_template_and_units): If the goal is to completely remove the template itself and all its units, follow up delete_units with this command; they have different responsibilities—the former deletes only units, the latter deletes both template and units.

Common Pitfalls

  1. Template name capitalization and spelling must match the division_template definition exactly—even a single extra space or incorrect letter case will cause silent failure in-game. Units will not be deleted and no error message will appear, making it extremely difficult to debug.
  2. The default value of disband is no, and equipment will vanish completely—newcomers often forget to write disband = yes, resulting in valuable equipment stockpile loss for no reason. This is especially costly when clearing elite templates with superior gear.