Wiki

effect · delete_unit

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

delete units of a country. no tooltip is generated. example: 

Example:
delete_unit = { 
	division_template = template_name # can be filtered a specific template 
	id = 42 # can be filtered to a given id in create unit effect 
	state = 64 # can be filtered by a given state 
	disband = yes # default is no. if set to yes the game will refund equipment/manpower
}

实战 · 配合 · 坑

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

实战用法

delete_unit 常用于事件触发战败/投降逻辑时强制清除某国部队,或在内战脚本中移除某一方的特定师模板部队,避免残余单位影响后续剧情走向。例如在某国被玩家事件吞并后,可精准删除其仍在战场上的部队并选择是否返还装备:

# 在某国投降事件的 immediate 块中删除其所有装甲师并返还装备
GER = {
    delete_unit = {
        division_template = "Panzer Division"
        disband = yes
    }
}

配合关系

  • [delete_unit_template_and_units](/wiki/effect/delete_unit_template_and_units):在彻底清除某个师模板的同时也删除该模板本身,两者配合可做到"模板+单位"的完全清理,delete_unit 适合只删单位但保留模板的场景。
  • [annex_country](/wiki/effect/annex_country):吞并一国前先用 delete_unit 清掉对方残余部队,可防止吞并后出现游荡的无主师团,逻辑更干净。
  • [has_army_size](/wiki/trigger/has_army_size):在触发 delete_unit 前用此触发器判断目标国是否仍有部队,避免在部队已为零时执行无意义操作或产生脚本警告。
  • [every_country_division](/wiki/effect/every_country_division):若需要逐师判断再删除,可先用此命令遍历所有师,再在满足条件时调用 delete_unit 精准处理。

常见坑

  1. 误以为会生成提示文本delete_unit 不会在界面上产生任何 tooltip,若需要让玩家看到"部队被解散"的反馈,必须另外配合 custom_effect_tooltip 手动补充说明文字,否则玩家完全看不出有任何事情发生。
  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_unit is commonly used to forcibly remove a nation's units when events trigger defeat/surrender logic, or in civil war scripts to remove specific division templates from one side, preventing residual units from affecting subsequent story progression. For example, after a nation is annexed by a player event, you can precisely delete its remaining units on the battlefield and optionally return equipment:

# Delete all armored divisions of a nation in its surrender event's immediate block and return equipment
GER = {
    delete_unit = {
        division_template = "Panzer Division"
        disband = yes
    }
}

Synergy

  • [delete_unit_template_and_units](/wiki/effect/delete_unit_template_and_units): Deletes both a division template and all units using that template simultaneously. Combined with delete_unit, this enables complete cleanup of "template + units". Use delete_unit when you only want to delete units while preserving the template.
  • [annex_country](/wiki/effect/annex_country): Before annexing a nation, use delete_unit to clear its remaining units, preventing orphaned divisions from appearing after annexation and keeping logic cleaner.
  • [has_army_size](/wiki/trigger/has_army_size): Before triggering delete_unit, use this trigger to check if the target nation still has units, avoiding meaningless operations or script warnings when units are already zero.
  • [every_country_division](/wiki/effect/every_country_division): If you need to evaluate and delete divisions one by one, use this command to iterate through all divisions first, then call delete_unit for precise handling when conditions are met.

Common Pitfalls

  1. Mistakenly expecting it to generate tooltip text: delete_unit produces no tooltip in the interface. If you want players to see feedback like "units disbanded", you must additionally use custom_effect_tooltip to manually add explanatory text, otherwise players won't notice anything happened.
  2. Easily overlooking the default disband value of no: Without disband = yes, equipment and manpower simply vanish into thin air. Missing this field in scenarios requiring resource return (such as peaceful disbandment or surrender compensation) causes numerical values to deviate from design intent, and is very difficult to detect during debugging.