Wiki

trigger · impassable

Definition

  • Supported scope:STATE
  • Supported target:any

Description

checks if a state is impassable

实战 · 配合 · 坑

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

实战用法

impassable 常用于地图修改类 mod 中,筛选出不可通行的省份/地区,从而避免对这些区域执行无意义的建设或占领逻辑。例如在事件或决议的 available 块中排除不可通行地区,防止玩家触发非法操作:

available = {
    NOT = { impassable = yes }
    is_owned_by = ROOT
}

配合关系

  • [is_coastal](/wiki/trigger/is_coastal):同为地块属性判断,常组合使用来筛选"可通行且沿海"的地区,用于港口建设或登陆点逻辑。
  • [has_state_category](/wiki/trigger/has_state_category):不可通行地区通常有特殊类别,两者配合可精确定位特定类型的可用地区。
  • [any_neighbor_state](/wiki/trigger/any_neighbor_state):遍历相邻地区时,配合 impassable 排除不可通行的邻接地区,避免逻辑误判。
  • [add_building_construction](/wiki/effect/add_building_construction):在 effect 侧执行建设前,先用 impassable = no 作前置条件保护,防止在不可通行地区触发建设指令导致脚本报错。

常见坑

  1. 作用域混淆impassable 只能在 STATE scope 下使用,若在 COUNTRY 或 CHARACTER 等 scope 中直接调用会导致脚本静默失败或报错,需确保已通过 any_stateevery_state 等方式正确切换到地区 scope。
  2. 逻辑取反遗漏:新手常忘记用 NOT = { impassable = yes } 来表示"可通行",直接写 impassable = no 在部分版本解析下可能不如预期工作,建议统一使用 NOT 包裹来明确排除不可通行地区。

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

impassable is commonly used in map-modification mods to filter out impassable provinces/states, preventing meaningless construction or occupation logic from being applied to these regions. For example, in the available block of events or decisions, you can exclude impassable areas to prevent players from triggering invalid actions:

available = {
    NOT = { impassable = yes }
    is_owned_by = ROOT
}

Synergy

  • [is_coastal](/wiki/trigger/is_coastal): Both are state attribute checks; combine them to filter "passable and coastal" regions for port construction or landing point logic.
  • [has_state_category](/wiki/trigger/has_state_category): Impassable regions typically have special categories; use both together to precisely locate specific types of usable areas.
  • [any_neighbor_state](/wiki/trigger/any_neighbor_state): When iterating through adjacent states, pair impassable to exclude impassable neighbors, avoiding logical errors.
  • [add_building_construction](/wiki/effect/add_building_construction): Before executing construction on the effect side, use impassable = no as a precondition to protect against script errors caused by triggering construction commands in impassable regions.

Common Pitfalls

  1. Scope confusion: impassable can only be used under STATE scope. Calling it directly in COUNTRY or CHARACTER scopes will cause silent script failure or errors. Ensure you switch to state scope correctly via any_state, every_state, and similar commands.
  2. Forgotten logic negation: Beginners often forget to use NOT = { impassable = yes } to express "passable"; writing impassable = no directly may not work as expected in some game versions. It is recommended to consistently wrap with NOT to clearly exclude impassable regions.