Wiki

trigger · any_state

Definition

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

Description

check if any state meets the trigger. tooltip=key can be defined to override title

实战 · 配合 · 坑

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

实战用法

any_state 常用于判断地图上是否存在满足特定条件的州,例如检查敌方是否控制了某片资源丰富或具有战略意义的地区,从而触发决策或事件。典型场景包括:验证某个国家是否拥有至少一个沿海州、是否存在抵抗值超过阈值的占领地等。

# 示例:判断是否存在任何一个被 GER 控制且有激活抵抗的州
any_state = {
    is_controlled_by = GER
    has_active_resistance = yes
}

# 示例:判断是否存在任何一个属于 ROOT 核心且当前未被 ROOT 控制的州
any_state = {
    is_core_of = ROOT
    NOT = { is_controlled_by = ROOT }
    is_coastal = yes
}

配合关系

  • all_stateany_state 检查"至少一个",all_state 检查"所有",两者配对使用可以表达范围不同的条件逻辑。
  • is_controlled_by:常嵌套在 any_state 内部,用于筛选被特定国家控制的州,是最高频的内层 trigger 之一。
  • has_state_flag:在 any_state 内部检查是否有州被打上了特定标记,常用于追踪剧本进度或特殊事件已触发的州。
  • any_neighbor_stateany_state 找到候选州后,可在其内部继续用 any_neighbor_state 做邻接判断,实现多层地理条件的嵌套检查。

常见坑

  1. 忘记指定过滤条件导致范围过大any_state 默认遍历全地图所有州,若内部条件过于宽泛(如只写 is_coastal = yes),极易在意想不到的场合返回 true,建议配合 is_owned_byis_controlled_by 等缩小范围。
  2. 混淆 scope 归属any_state 内部的 scope 已切换为 state,此时使用 ROOTFROM 等仍指向外层 scope 的国家,若在内部误用国家级 trigger(如 has_war)而不加 OWNER 转换,逻辑会静默失效或报错。

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_state is commonly used to check whether any state on the map meets specific conditions — for example, verifying whether an enemy controls a resource-rich or strategically important region in order to fire a decision or event. Typical use cases include: checking whether a country owns at least one coastal state, or whether any occupied state has resistance above a certain threshold.

# Example: check whether any state is controlled by GER and has active resistance
any_state = {
    is_controlled_by = GER
    has_active_resistance = yes
}

# Example: check whether any state is a core of ROOT but is not currently controlled by ROOT
any_state = {
    is_core_of = ROOT
    NOT = { is_controlled_by = ROOT }
    is_coastal = yes
}

Synergy

  • all_state: any_state checks "at least one" while all_state checks "all of them" — using the two together lets you express conditional logic across different scopes of coverage.
  • is_controlled_by: Frequently nested inside any_state to filter states controlled by a specific country; one of the most commonly used inner triggers.
  • has_state_flag: Used inside any_state to check whether any state has been assigned a particular flag, often for tracking scripted progress or states where a special event has already fired.
  • any_neighbor_state: Once any_state identifies a candidate state, any_neighbor_state can be nested inside it to apply adjacency checks, enabling multi-layered geographic condition logic.

Common Pitfalls

  1. Omitting filter conditions leads to an overly broad scope: any_state iterates over every state on the map by default. If the inner conditions are too permissive (e.g., only is_coastal = yes), the trigger will return true in unexpected situations. It is strongly recommended to narrow the scope with conditions such as is_owned_by or is_controlled_by.
  2. Confusing scope ownership: Inside any_state the scope has already switched to state. References to ROOT, FROM, and similar keywords still point to the outer country scope, so if you mistakenly use a country-level trigger (such as has_war) inside without converting through OWNER, the logic will silently fail or throw an error.