Wiki

trigger · state

Definition

  • Supported scope:STATE
  • Supported target:THIS, ROOT, PREV, FROM, CAPITAL

Description

check state id

实战 · 配合 · 坑

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

实战用法

state trigger 最常见于需要精确指定某个省份/地块的条件判断,例如在决策(decision)或事件中限定只有当 scope 指向特定 state ID 时才触发。例如在一个"占领柏林"决策中,可以用它来确认当前操作的 state 是否是柏林所在 state:

# 在某个 state 作用域内(如 every_neighbor_state 遍历结果)
limit = {
    state = 64   # 64 为柏林 state ID
    is_controlled_by = ROOT
}

配合关系

  • [is_controlled_by](/wiki/trigger/is_controlled_by):最常搭配,确认指定 state 同时被特定国家控制,避免仅判断 ID 而忽略实际控制权。
  • [is_core_of](/wiki/trigger/is_core_of):配合使用,判断该 state 是否同时是某国核心,常用于领土主张或吞并逻辑。
  • [has_state_flag](/wiki/trigger/has_state_flag):用于在确认 state ID 后进一步检查是否设置了特定脚本标记,实现多阶段任务链。
  • [set_state_flag](/wiki/effect/set_state_flag):在 effect 块中配合,当 trigger 确认 state ID 命中后标记该 state,防止重复触发。

常见坑

  1. 直接在 COUNTRY scope 下使用state trigger 只在 STATE scope 下有效,新手常在国家事件选项里直接写 state = 64 而不先切换到 state scope(如用 64 = { ... }every_state = { limit = { state = 64 } }),导致脚本报错或永远不触发。
  2. 混淆 state ID 与 province ID:HOI4 中 state ID 和 province ID 是两套不同的编号体系,将 province ID 填入 state = 字段不会报错但逻辑永远为假,调试时需对照 map/definition.csvhistory/states/ 文件仔细核对。

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

The state trigger is most commonly used when you need to precisely specify a condition for a particular province or state block, such as in decisions or events to restrict triggering only when the scope points to a specific state ID. For example, in an "Occupy Berlin" decision, you can use it to verify whether the current state being operated on is Berlin's state:

# Within a state scope (such as results from every_neighbor_state iteration)
limit = {
    state = 64   # 64 is Berlin's state ID
    is_controlled_by = ROOT
}

Synergy

  • [is_controlled_by](/wiki/trigger/is_controlled_by): Most commonly paired; confirms the specified state is simultaneously controlled by a specific nation, avoiding logic errors from checking only ID without actual control status.
  • [is_core_of](/wiki/trigger/is_core_of): Used in combination to determine whether the state is also a core of a certain nation, commonly used in territorial claims or annexation logic.
  • [has_state_flag](/wiki/trigger/has_state_flag): After confirming the state ID, use this to further check whether a specific script flag has been set, enabling multi-stage task chains.
  • [set_state_flag](/wiki/effect/set_state_flag): Paired in effect blocks; when the trigger confirms the state ID matches, flag that state to prevent repeated triggering.

Common Pitfalls

  1. Using directly under COUNTRY scope: The state trigger only works within STATE scope. Beginners often write state = 64 directly in country event options without first switching to state scope (such as using 64 = { ... } or every_state = { limit = { state = 64 } }), causing script errors or permanent failure to trigger.
  2. Confusing state ID with province ID: In HOI4, state IDs and province IDs are two separate numbering systems. Filling a province ID into the state = field will not error but the logic will always be false. During debugging, carefully cross-reference map/definition.csv and history/states/ files to verify the correct IDs.