Wiki

effect · delete_unit_template_and_units

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Delete a template and its units
Example: delete_unit_template_and_units = { 
division_template = <name> 
disband = no #if yes, will refund equipment/manpower. default is no
}

实战 · 配合 · 坑

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

实战用法

常用于国家事件或决议中清理不再需要的师级模板,例如在内战结束后解散临时民兵模板、或在科技路线切换时移除过时装甲模板。disband = yes 时可回收装备和人力,适合资源紧张的情景;disband = no 则用于彻底销毁某支力量而不给玩家任何补偿。

country_event = {
    id = cleanup.1
    option = {
        name = cleanup.1.a
        # 内战结束,解散临时民兵模板并回收资源
        delete_unit_template_and_units = {
            division_template = "People's Militia"
            disband = yes
        }
    }
}

配合关系

  • [division_template](/wiki/effect/division_template):先用 division_template 动态创建一个临时模板,之后再用本命令将其连同部队一并删除,形成完整的"创建-销毁"生命周期。
  • [add_manpower](/wiki/effect/add_manpower):当 disband = no 导致人力白白消失时,可在同一 option 中补偿性地添加人力,弥补玩家损失。
  • [has_country_flag](/wiki/trigger/has_country_flag):执行删除前先检查标记,确保该模板确实已被创建,避免脚本在模板不存在时报错或产生意外行为。
  • [delete_units](/wiki/effect/delete_units):若只想清除部队而保留模板供后续再用,可改用 delete_units;二者对比使用,能精准控制是否保留模板定义。

常见坑

  1. 模板名称大小写必须与定义完全一致division_template 字段的值是字符串匹配,哪怕多一个空格或字母大小写不同,游戏都会静默失败——模板和部队都不会被删除,也不会报错提示,极难排查。
  2. 误以为 disband = no 是默认安全选项disband = no(默认值)会直接销毁部队及其携带的全部装备和人力,毫无补偿;若在玩家可见的事件选项中使用而没有任何说明,容易引发强烈的体验落差,建议在 disband = yesno 之间根据叙事逻辑明确选择并在描述文本中告知玩家。

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

Commonly used in country events or decisions to clean up division templates that are no longer needed—for example, disbanding temporary militia templates after a civil war ends, or removing obsolete armor templates when switching tech trees. When disband = yes, equipment and manpower can be recovered, making it suitable for resource-constrained scenarios; disband = no is used to completely destroy a force without giving the player any compensation.

country_event = {
    id = cleanup.1
    option = {
        name = cleanup.1.a
        # Civil war ends, disband temporary militia template and recover resources
        delete_unit_template_and_units = {
            division_template = "People's Militia"
            disband = yes
        }
    }
}

Synergy

  • [division_template](/wiki/effect/division_template): First use division_template to dynamically create a temporary template, then use this command to delete both the template and its units together, forming a complete "create-destroy" lifecycle.
  • [add_manpower](/wiki/effect/add_manpower): When disband = no causes manpower to disappear without compensation, you can add manpower in the same option to offset the player's losses.
  • [has_country_flag](/wiki/trigger/has_country_flag): Check a flag before executing the deletion to ensure the template has actually been created, avoiding script errors or unexpected behavior when the template doesn't exist.
  • [delete_units](/wiki/effect/delete_units): If you only want to remove units while preserving the template for later reuse, use delete_units instead; comparing the two allows precise control over whether to keep the template definition.

Common Pitfalls

  1. Template name capitalization must match the definition exactly: The division_template field value is string-matched; even a single extra space or incorrect capitalization will cause silent failure—the template and units won't be deleted, and no error will be reported, making it extremely difficult to troubleshoot.
  2. Mistaking disband = no as the safe default option: disband = no (the default value) will directly destroy the units and all their carried equipment and manpower with no compensation; using it in player-visible event options without clear explanation easily creates a jarring experience gap. It's recommended to make an explicit choice between disband = yes and no based on narrative logic and inform the player in the description text.