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
- 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.
- 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.