Wiki

effect · change_tag_from

Definition

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

Description

Changes player to other country

实战 · 配合 · 坑

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

实战用法

change_tag_from 常用于剧本事件中实现"玩家视角跳转",例如在傀儡国建立后让玩家无缝切换到新成立的国家,或在分裂剧情中将操控权转移给分裂出的政权。以下示例演示在事件 option 中将玩家从当前国切换到目标国:

# 在某个 country_event 的 option 中
option = {
    name = my_event.1.a
    # 先执行其他状态变更...
    change_tag_from = ROOT   # 将"曾经控制 ROOT 的玩家"切换为控制当前 scope 国家
}

配合关系

  • [hidden_effect](/wiki/effect/hidden_effect):通常将 change_tag_from 包裹在 hidden_effect 中,避免触发多余的界面提示,使切换过程更流畅。
  • [save_global_event_target_as](/wiki/effect/save_global_event_target_as):切换前将原国家保存为全局事件目标,方便切换后继续对旧国家执行后续 effect。
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip):由于切换行为对玩家不够直观,配合此命令在 UI 上给出友好的提示说明。
  • [country_exists](/wiki/trigger/country_exists):在执行切换前用此 trigger 校验目标国是否存在,防止因目标国尚未创建而导致脚本报错或逻辑失效。

常见坑

  1. scope 方向搞反change_tag_from 的语义是"把原本控制 <target> 所指国家的玩家,转移来控制当前 scope 国家",而非"把当前 scope 玩家转移到 target"。新手容易将 scope 与 target 对调,导致切换目标完全相反。
  2. 在 AI 国家 scope 下调用:若当前 scope 所在国家没有人类玩家控制,效果会静默失败,不会有任何报错,极难排查——务必在调用前确认 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

change_tag_from is commonly used in scripted events to implement "player perspective switching," such as seamlessly transferring the player to a newly established puppet state after its creation, or shifting control to a breakaway faction in secession scenarios. The following example demonstrates switching the player from the current nation to a target nation within an event option:

# Within an option block of a country_event
option = {
    name = my_event.1.a
    # Execute other state changes first...
    change_tag_from = ROOT   # Transfers the player who previously controlled ROOT to now control the current scope nation
}

Synergy

  • [hidden_effect](/wiki/effect/hidden_effect): Typically wrap change_tag_from inside hidden_effect to avoid triggering unnecessary UI notifications and make the transition smoother.
  • [save_global_event_target_as](/wiki/effect/save_global_event_target_as): Save the original nation as a global event target before switching, allowing continued execution of effects on the old nation after the switch completes.
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): Since the switching behavior may not be immediately intuitive to players, pair this command to provide a user-friendly explanation in the UI.
  • [country_exists](/wiki/trigger/country_exists): Use this trigger to validate that the target nation exists before executing the switch, preventing script errors or logic failures caused by the target nation not yet being created.

Common Pitfalls

  1. Reversed scope direction: The semantics of change_tag_from mean "transfer the player who was controlling the nation specified by <target> to now control the current scope nation," not "transfer the current scope player to target." Beginners often swap scope and target, resulting in the switch targeting the opposite nation entirely.
  2. Calling under an AI nation's scope: If the current scope nation has no human player controlling it, the effect fails silently with no error message, making it extremely difficult to debug. Always confirm before calling that the scope nation is actually under player control, or protect the call with conditional checks.