Wiki

effect · remove_building

Definition

  • Supported scope:STATE, COUNTRY
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

Removes a building in a targeted state or province.
Example:

remove_building = {
	type = air_base
	level = 1 # how many levels to remove
	state = 32 # or a variable like var:target_state
}

The building can also be specified through tags.
Example:
remove_building = {
	tags = facility # can be a single tag or a { }-wrapped list of tags
	level = 1 # how many levels to remove
	province = 500 # or a variable like var:target_province
}

You can manually specify either a state or province as per the examples above. Both values and variables are supported.
The effect can also be called without specifying province or state if used within a state scope:

remove_building = {
	type = air_base
	level = 1 # how many levels to remove
}

In this case, the building type must be a state building.

Note that this effect will NOT recursively find province buildings from a state when no province has been specified.

实战 · 配合 · 坑

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

实战用法

remove_building 常用于剧本事件或国策中拆除某国/某州的基础设施,例如战后惩罚性条约拆除败者工业、间谍行动破坏机场等场景。在 STATE scope 下可以省略 state/province 字段直接指定州级建筑,非常适合批量处理被占领州的建设:

# 国策效果:拆除目标州的空军基地一级(STATE scope 内)
every_controlled_state = {
    limit = {
        is_on_same_continent_as = ROOT
    }
    remove_building = {
        type = air_base
        level = 1
    }
}

配合关系

  • [free_building_slots](/wiki/trigger/free_building_slots):拆除建筑前先检查当前剩余建筑槽,确保拆除逻辑与槽位管理联动,避免出现负数槽位的意外情况。
  • [add_building_construction](/wiki/effect/add_building_construction):常与拆除配对,先拆除旧建筑再重建新建筑,实现建筑"替换"效果,例如将基础工厂升级为军工厂的剧本实现。
  • [damage_building](/wiki/effect/damage_building):两者都能降低建筑等级,damage_building 侧重战斗/轰炸造成的损毁表现,而 remove_building 侧重主动脚本移除;理解两者区别有助于选择更符合叙事语境的指令。
  • [has_built](/wiki/trigger/has_built):在执行拆除前用此触发器确认该建筑确实存在,防止对不存在的建筑执行拆除导致脚本报错或产生非预期日志警告。

常见坑

  1. 省级建筑必须指定 province:新手在 STATE scope 下直接写 type = air_base 但忘记指定 province 来拆除省级建筑(如机场),官方文档明确指出不指定 province 时不会递归查找省级建筑,结果是指令静默无效,非常难以排查。
  2. COUNTRY scope 下必须显式指定 state 或 province:在国家 scope 中调用时若省略 state = ...province = ... 字段,游戏无法确定目标位置,效果同样不会生效,必须明确传入数值或变量(如 var:target_state)。

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

remove_building is commonly used in scripted events or national focuses to demolish infrastructure in a specific country or state, such as dismantling industrial facilities as punitive post-war measures or destroying airports through espionage operations. Within STATE scope, you can omit the state/province field and directly specify state-level buildings, making it ideal for batch processing of occupied territories:

# National focus effect: remove one level of air base from target state (within STATE scope)
every_controlled_state = {
    limit = {
        is_on_same_continent_as = ROOT
    }
    remove_building = {
        type = air_base
        level = 1
    }
}

Synergy

  • [free_building_slots](/wiki/trigger/free_building_slots): Check remaining building slots before removal to ensure removal logic synchronizes with slot management and prevents unexpected negative slot counts.
  • [add_building_construction](/wiki/effect/add_building_construction): Frequently paired with removal—demolish old buildings then reconstruct new ones to achieve a "replacement" effect, such as upgrading basic factories to military factories in scripted scenarios.
  • [damage_building](/wiki/effect/damage_building): Both can reduce building levels, but damage_building emphasizes damage from combat or bombing, while remove_building focuses on active script-driven removal. Understanding this distinction helps you choose the command that better matches your narrative intent.
  • [has_built](/wiki/trigger/has_built): Confirm the building actually exists before executing removal to prevent script errors or unexpected log warnings from attempting to demolish non-existent structures.

Common Pitfalls

  1. Province-level buildings must specify province: Beginners working in STATE scope write type = air_base but forget to specify province for province-level buildings (such as airports). The official documentation clearly states that without specifying province, the command will not recursively search for province-level buildings, resulting in a silent failure that is extremely difficult to debug.
  2. COUNTRY scope must explicitly specify state or province: When called within country scope, omitting the state = ... or province = ... field leaves the game unable to determine the target location, causing the effect to fail silently. You must explicitly provide numeric values or variables (such as var:target_state).