Wiki

trigger · any_province_building_level

Definition

  • Supported scope:STATE
  • Supported target:any

Description

In the current state, checks if any province within the specified limit has a building of the specified level.
Example:
any_province_building_level = {
  province = {
    id = 421  # Only check specific provinces instead of all in state, can specify multiple provinces on multiple lines.
    all_provinces = yes  # default: no. Mutually exclusive with 'id = xxx']
    limit_to_border = yes  # default: no. Only border provinces.
    limit_to_coastal = yes  # default: no. Only coastal provinces.
    limit_to_victory_point = yes  # default: no. Only provinces with > 0 victory points.
    limit_to_naval_base = yes  # default: no. Only provinces with a naval base.
  }
  building = bunker  # Building type.
  level < 3  # Building level to check.
}

实战 · 配合 · 坑

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

实战用法

any_province_building_level 常用于防御工事检测场景,例如判断某州内是否存在低等级碉堡省份,从而触发强化建设决议;也可用于要塞或海军基地等级检查,配合占领或抵抗机制做条件分支。

# 决议 available 块:检查该州内任意省份碉堡等级低于 3,才允许执行强化建设决议
available = {
    any_province_building_level = {
        province = {
            limit_to_coastal = yes
        }
        building = coastal_bunker
        level < 3
    }
    is_controlled_by = ROOT
}

配合关系

  • set_building_level:检测到某省建筑等级不足后,用此 effect 直接提升到目标等级,形成"检测→补建"逻辑闭环。
  • add_building_construction:与 trigger 配合,当满足低等级条件时排队开工建设,比直接 set 更贴近游戏经济流程。
  • non_damaged_building_level:同为省级建筑等级相关 trigger,可与 any_province_building_level 联合使用,区分"名义等级"与"未损耗实际等级"两种语义。
  • free_building_slots:在决定是否新增建筑前,先用此 trigger 确认该州仍有空余建筑槽,避免触发无效建设。

常见坑

  1. scope 不对导致脚本报错any_province_building_level 只能在 STATE scope 下使用,若写在 COUNTRY scope 的 limittrigger 块内会静默失败或报错,需要先用 capital_scopeevery_state 等方式切换到 STATE scope。
  2. idall_provinces 互斥但同时写入province 子块中 id = xxxall_provinces = 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

any_province_building_level is most commonly used in defensive fortification checks — for example, detecting whether any province in a state has a bunker below a certain level in order to unlock a reinforcement decision. It also works well for fort or naval base level checks, enabling conditional branching alongside occupation or resistance mechanics.

# Decision available block: only allow the reinforcement decision if any coastal province
# in this state has a coastal_bunker below level 3
available = {
    any_province_building_level = {
        province = {
            limit_to_coastal = yes
        }
        building = coastal_bunker
        level < 3
    }
    is_controlled_by = ROOT
}

Synergy

  • set_building_level: Once the trigger detects that a province's building level is insufficient, use this effect to raise it directly to the desired level — forming a clean "detect → build up" loop.
  • add_building_construction: Pair with the trigger so that when the low-level condition is met, construction is queued rather than instantly set, which fits more naturally into the game's economic flow.
  • non_damaged_building_level: Another province-level building trigger; can be used alongside any_province_building_level to distinguish between a building's nominal level and its undamaged effective level.
  • free_building_slots: Before deciding to add new construction, use this trigger first to confirm the state still has open building slots, preventing invalid build orders from being queued.

Common Pitfalls

  1. Wrong scope causes script errors: any_province_building_level is only valid inside a STATE scope. Writing it inside a limit or trigger block at COUNTRY scope will cause a silent failure or an error. You must first switch into STATE scope via something like capital_scope or every_state.
  2. id and all_provinces are mutually exclusive but sometimes written together: Inside the province sub-block, id = xxx and all_provinces = yes cannot coexist. Using both at the same time results in undefined behavior. Beginners often assume this means "narrow down first, then scan all" — but in practice you must choose one or the other.