Wiki

trigger · any_state_of

Definition

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

Description

Checks if any of the provided states fulfill the specified triggers.
The `target` supports script constants and `tooltip` supports bindable localization.

### Example

any_state_of = { tooltip = my_loc # Optional bindable localization target = { 1 42 1992 } controller = { has_defensive_war = yes } }

any_state_of = { tooltip = my_loc # Optional bindable localization target = constant:country_groups:nordics controller = { has_defensive_war = yes } }

实战 · 配合 · 坑

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

实战用法

any_state_of 常用于检查一组指定地块中是否有任何一个满足特定条件,例如判断某个战略区域内是否存在被敌方控制或发生抵抗的州,适合用于事件触发条件或决议的 available 块。也可配合脚本常量批量检查某一文化/势力相关的州集合,避免逐一枚举。

# 检查一组核心工业州中是否有任何一个不被我方完全控制
available = {
    any_state_of = {
        target = { 42 57 1992 }
        NOT = {
            is_fully_controlled_by = ROOT
        }
    }
}

配合关系

  • is_fully_controlled_by:判断目标州是否被指定国家完全控制,与 any_state_of 搭配可实现"某批州中至少一个落入敌手"的条件检测。
  • has_state_flag:在 any_state_of 内检查特定州是否设置了自定义 flag,适合追踪剧情进度或特殊事件标记。
  • is_controlled_by:比 is_fully_controlled_by 更宽松,仅检查控制权,与 any_state_of 配合用于战场态势判断。
  • has_resistance:在 any_state_of 内检查抵抗运动是否存在,常用于占领政策相关决议的触发条件。

常见坑

  1. target 必须是州 ID 列表或脚本常量,不能直接写国家 tag 或省份 ID。新手容易将省份编号或国家 tag 填入 target,导致条件始终不触发,应确保填写的是地块(state)的数字 ID(如 42)或指向州列表的 constant:
  2. 内层 trigger 的 scope 是 state,而非当前国家 scope。在 any_state_of 块内不能直接使用国家级 trigger(如 has_war),需要通过 controller = { ... }owner = { ... } 切换到国家 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

any_state_of is commonly used to check whether any state within a specified set meets a particular condition — for example, determining whether any state in a strategic region is under enemy control or experiencing resistance. It is well-suited for event trigger conditions or the available block of decisions. It can also be combined with scripted constants to batch-check a collection of states associated with a culture or faction, avoiding the need to enumerate each one individually.

# Check whether any state in a set of core industrial states is not fully controlled by our side
available = {
    any_state_of = {
        target = { 42 57 1992 }
        NOT = {
            is_fully_controlled_by = ROOT
        }
    }
}

Synergy

  • is_fully_controlled_by: Checks whether a target state is fully controlled by a specified country. Paired with any_state_of, this enables a condition such as "at least one state in a given set has fallen into enemy hands."
  • has_state_flag: Used inside any_state_of to check whether a specific state has a custom flag set, making it useful for tracking narrative progress or special event markers.
  • is_controlled_by: Less strict than is_fully_controlled_by — it checks control only rather than full control. Combine with any_state_of for battlefield situation assessments.
  • has_resistance: Used inside any_state_of to check whether a resistance movement is present in a state; commonly used as a trigger condition for occupation policy decisions.

Common Pitfalls

  1. target must be a list of state IDs or a scripted constant — country tags and province IDs are not valid here. Beginners often mistakenly enter province numbers or country tags into target, causing the condition to never fire. Make sure you are providing numeric state IDs (e.g. 42) or a constant: reference pointing to a list of states.
  2. The scope inside the inner trigger block is state, not the current country scope. Country-level triggers such as has_war cannot be used directly inside an any_state_of block. You must first switch to a country scope via controller = { ... } or owner = { ... } before making such checks; otherwise the script will either throw an error or silently fail.