Wiki

effect · goto_state

Definition

  • Supported scope:any
  • Supported target:none

Description

Goes to stated state.

实战 · 配合 · 坑

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

实战用法

goto_state 常用于焦点树、事件或决策中,将玩家视角(镜头)快速切换到某个特定地块,适合用在剧情事件触发时引导玩家注意关键战场或刚刚发生变化的省份。例如在一场战争宣告事件中,让镜头自动跳转到冲突核心地区:

immediate = {
    goto_state = 42  # 镜头跳转至 42 号地块(法兰西岛)
}

配合关系

  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip)goto_state 本身不产生任何文字反馈,配合此命令可以在事件选项中为玩家显示"镜头已跳转"之类的提示,改善 UI 可读性。
  • [hidden_effect](/wiki/effect/hidden_effect):将 goto_state 包裹在 hidden_effect 中,可以让镜头静默跳转而不在事件选项日志里留下多余的效果行,保持界面整洁。
  • [if](/wiki/effect/if):配合 if 条件块,可以根据当前局势(如某地块归属)动态决定跳转目标,避免无条件跳到无关地区。

常见坑

  1. 混淆地块 ID 与省份 IDgoto_state 接收的是 state(地块)ID,而非 province ID,初学者常把两者搞混,导致跳转到错误位置或脚本报错。
  2. 在 AI 执行路径中滥用:该命令对 AI 国家执行时无实际意义但仍会被解析,若放在所有国家都会触发的 every_country 循环内,会产生大量无用的镜头指令调用,建议用 [is_tutorial](/wiki/trigger/is_tutorial) 或玩家标签判断将其限定在人类玩家的执行路径下。

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

goto_state is commonly used in focus trees, events, or decisions to quickly switch the player's viewport (camera) to a specific state, making it ideal for guiding player attention to critical battlefields or recently changed provinces when story events trigger. For example, in a war declaration event, you can automatically pan the camera to the conflict's core region:

immediate = {
    goto_state = 42  # Camera pans to state 42 (Île-de-France)
}

Synergy

  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): goto_state itself produces no text feedback. Pairing it with this command allows you to display messages like "Camera panned" in event options, improving UI readability.
  • [hidden_effect](/wiki/effect/hidden_effect): Wrapping goto_state in hidden_effect lets the camera pan silently without leaving extraneous effect lines in the event log, keeping the interface clean.
  • [if](/wiki/effect/if): Combined with if conditional blocks, you can dynamically determine the pan target based on current circumstances (such as state ownership), avoiding unintended pans to irrelevant regions.

Common Pitfalls

  1. Confusing state ID with province ID: goto_state takes a state ID, not a province ID. Beginners often mix these up, resulting in panning to the wrong location or script errors.
  2. Overusing in AI execution paths: This command has no practical effect when executed by AI nations but is still parsed. If placed inside every_country loops that trigger for all nations, it generates numerous useless camera instruction calls. Use [is_tutorial](/wiki/trigger/is_tutorial) or player flags to restrict execution to human players only.