Wiki

effect · destroy_unit

Definition

  • Supported scope:(none)
  • Supported target:none

Description

destroy currently scoped unit

实战 · 配合 · 坑

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

实战用法

destroy_unit 用于在特定事件或决议触发时将当前作用域内的单位彻底移除,常见于剧本事件(如内战结束后解散叛军部队)或任务链中清理临时生成的测试部队。需注意该 effect 直接作用于已进入 unit scope 的单位对象,通常配合 unit 范围迭代使用。

# 事件触发:内战结束,销毁所有叛军单位
country_event = {
    id = civil_war.5
    ...
    option = {
        name = civil_war.5.a
        # 遍历敌方阵营单位并逐一销毁
        enemy_country = {
            every_unit = {
                destroy_unit = yes
            }
        }
    }
}

配合关系

由于当前白名单中同 scope 下无其他可交叉引用的 effect 或 trigger 命令,暂无可列出的白名单内配合命令。实际开发中该指令通常依赖游戏原生的 every_unit 等迭代块来确定作用范围,但这些不在本次提供的白名单之内,请参阅官方 Wiki 获取完整列表。

常见坑

  1. scope 指向错误:新手常在 country scope 下直接写 destroy_unit = yes,而非先进入具体的 unit scope(如通过 every_unit 迭代),导致脚本报错或无效果,务必确认当前 scope 已经是目标单位本身。
  2. 误以为可以撤销destroy_unit 是永久销毁,无法像转移部队一样保留单位数据,若只是想让部队暂时消失或转移控制权,应考虑其他手段而非此指令,否则部队数据将彻底丢失。

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

destroy_unit is used to permanently remove units within the current scope when specific events or decisions are triggered. This is commonly employed in scripted events (such as disbanding rebel forces after a civil war ends) or in mission chains to clean up temporary test units. Note that this effect operates directly on unit objects already in unit scope, and is typically used in conjunction with unit scope iteration.

# Event trigger: Civil war ends, destroy all rebel units
country_event = {
    id = civil_war.5
    ...
    option = {
        name = civil_war.5.a
        # Iterate through enemy faction units and destroy them one by one
        enemy_country = {
            every_unit = {
                destroy_unit = yes
            }
        }
    }
}

Synergy

Since there are no other cross-referenceable effects or trigger commands within the same scope in the current whitelist, there are no whitelisted companion commands to list. In actual development, this command typically relies on native game iteration blocks like every_unit to determine the scope of application, but these are not included in the whitelist provided here. Please refer to the official Wiki for a complete list.

Common Pitfalls

  1. Incorrect scope targeting: Beginners often write destroy_unit = yes directly under country scope without first entering the specific unit scope (such as through every_unit iteration), resulting in script errors or no effect. Always verify that the current scope is the target unit itself.
  2. Mistaking it for a reversible action: destroy_unit is permanent destruction and cannot preserve unit data like transferring units would. If you only want units to temporarily disappear or transfer control, consider other methods instead of this command, otherwise unit data will be completely lost.