Wiki

effect · construct_building_in_random_province

Definition

  • Supported scope:STATE
  • Supported target:none

Description

Set facility level in a random province of state and country scope.
	ex:
    GER = {
        65 = {
			construct_building_in_random_province = {
				land_facility = 1
			}
		}
	}

实战 · 配合 · 坑

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

实战用法

construct_building_in_random_province 适合在事件或决议中,对某个州内的随机一个省份快速放置设施(如机场、雷达站等省级建筑),无需手动指定具体省份 ID,常用于随机化奖励或动态基础设施发展的 mod 场景。下面示例在某事件中让德国的 65 号州随机一省新增一级陆地设施:

GER = {
    65 = {
        construct_building_in_random_province = {
            land_facility = 1
        }
    }
}

配合关系

  • [any_province_building_level](/wiki/trigger/any_province_building_level) — 在触发条件中检查州内是否已有符合等级的省级建筑,避免重复建设超出上限。
  • [add_building_construction](/wiki/effect/add_building_construction) — 两者功能互补:前者针对省级设施随机放置,后者用于州级建筑的施工队列,常组合实现"同时升级基础设施"的完整效果。
  • [free_building_slots](/wiki/trigger/free_building_slots) — 在执行前确认州内还有可用建筑槽位,防止因槽位不足导致效果静默失败。
  • [add_extra_state_shared_building_slots](/wiki/effect/add_extra_state_shared_building_slots) — 当槽位不足时,先通过此命令扩充共享槽位,再调用本 effect,确保建设顺利执行。

常见坑

  1. 省级建筑与州级建筑混淆:本 effect 只能放置省级设施(如 land_facilityair_base 等省级字段),若误填州级建筑字段(如 industrial_complex),效果将不生效且通常不报错,新手容易长时间排查不出原因。
  2. 忽略双层 scope 嵌套:必须同时满足"国家 scope 在外、州 scope 在内"的结构,若直接在州 scope 下调用而省略外层国家 scope,游戏无法正确解析目标,导致效果无声失败。

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

construct_building_in_random_province is ideal for use in events or decisions to quickly place facilities (such as airports, radar stations, and other province-level buildings) in a random province within a state without needing to manually specify a particular province ID. It's commonly used in mod scenarios involving randomized rewards or dynamic infrastructure development. The example below shows how to add one level of land facility to a random province in state 65 for Germany in an event:

GER = {
    65 = {
        construct_building_in_random_province = {
            land_facility = 1
        }
    }
}

Synergy

  • [any_province_building_level](/wiki/trigger/any_province_building_level) — Check in trigger conditions whether the state already has province-level buildings at the required level to avoid duplicate construction exceeding the cap.
  • [add_building_construction](/wiki/effect/add_building_construction) — The two effects complement each other: the former targets random placement of province-level facilities, while the latter applies to state-level building construction queues. They're often combined to achieve the complete effect of "upgrading infrastructure simultaneously."
  • [free_building_slots](/wiki/trigger/free_building_slots) — Verify before execution that the state still has available building slots to prevent silent failure due to insufficient slots.
  • [add_extra_state_shared_building_slots](/wiki/effect/add_extra_state_shared_building_slots) — When slots are insufficient, first expand shared slots using this command, then invoke this effect to ensure successful construction.

Common Pitfalls

  1. Confusing province-level and state-level buildings: This effect can only place province-level facilities (such as land_facility, air_base, and other province-level fields). If you mistakenly enter state-level building fields (such as industrial_complex), the effect will not work and typically won't produce an error, making it easy for new users to spend considerable time debugging.
  2. Overlooking the two-layer scope nesting: You must satisfy the structure of "country scope on the outside, state scope on the inside" simultaneously. If you call the effect directly under state scope while omitting the outer country scope, the game cannot correctly parse the target, causing the effect to fail silently.