Wiki

effect · set_global_flag

Definition

  • Supported scope:any
  • Supported target:none

Description

set global flag

实战 · 配合 · 坑

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

实战用法

set_global_flag 常用于跨国家、跨事件追踪全局剧情状态,例如标记某个历史事件已触发、某个世界级任务已完成。由于它作用于全局命名空间,任何国家 scope 都可以读取,非常适合用在多国联动剧本或成就解锁逻辑中。

# 某国完成核弹研发时,设置全局旗帜供其他国家事件检测
country_event = {
    id = my_mod.1
    option = {
        name = my_mod.1.a
        set_global_flag = first_nuclear_power_emerged
    }
}

配合关系

  • [has_global_flag](/wiki/trigger/has_global_flag):设置全局旗帜后,通常配合此触发器在其他事件或 focus 的 trigger 块中检测该旗帜是否已存在,形成"写-读"闭环。
  • [clr_global_flag](/wiki/effect/clr_global_flag):当剧情阶段结束或需要重置状态时,用它清除之前设置的旗帜,避免旗帜永久残留影响后续逻辑。
  • [modify_global_flag](/wiki/effect/modify_global_flag):若需要给旗帜附加数值(如计数器),可用此命令在已有旗帜基础上做修改,与 set_global_flag 配合实现有状态的全局计数。
  • [hidden_effect](/wiki/effect/hidden_effect):将 set_global_flag 包裹在隐藏效果块内,避免玩家在事件选项中看到不必要的内部状态变更提示。

常见坑

  1. 旗帜名拼写不统一set_global_flaghas_global_flag / clr_global_flag 使用的旗帜名必须完全一致(区分大小写),一旦某处手误改了大小写或下划线,触发器将永远检测不到该旗帜,且游戏不会报错,极难排查。
  2. 误用全局旗帜替代国家旗帜:全局旗帜对所有国家可见且只有一份,若你只想记录某一个特定国家的状态,应使用 set_country_flag 而非 set_global_flag,否则多周目或多国并存场景下会产生状态污染。

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

set_global_flag is commonly used to track global narrative states across countries and events, such as marking a historical event as triggered or a world-level mission as completed. Since it operates in the global namespace, any country scope can read it, making it ideal for multi-nation collaborative scripts or achievement unlock logic.

# When a country completes nuclear weapon research, set a global flag for other country events to detect
country_event = {
    id = my_mod.1
    option = {
        name = my_mod.1.a
        set_global_flag = first_nuclear_power_emerged
    }
}

Synergy

  • [has_global_flag](/wiki/trigger/has_global_flag): After setting a global flag, this trigger is typically paired in trigger blocks of other events or focuses to check whether the flag exists, forming a "write-read" closed loop.
  • [clr_global_flag](/wiki/effect/clr_global_flag): When a narrative phase concludes or state needs to be reset, use this command to clear previously set flags and prevent them from permanently lingering and affecting subsequent logic.
  • [modify_global_flag](/wiki/effect/modify_global_flag): If you need to attach numerical values to a flag (such as a counter), use this command to modify an existing flag, combined with set_global_flag to implement stateful global counting.
  • [hidden_effect](/wiki/effect/hidden_effect): Wrap set_global_flag inside a hidden effect block to prevent players from seeing unnecessary internal state change notifications in event options.

Common Pitfalls

  1. Inconsistent flag name spelling: The flag names used in set_global_flag and has_global_flag / clr_global_flag must match exactly (case-sensitive). If a typo changes the capitalization or underscores anywhere, the trigger will never detect that flag, and the game won't report an error, making it extremely difficult to debug.
  2. Mistakenly using global flags instead of country flags: Global flags are visible to all countries and only have one instance. If you only want to record the state of a specific country, use set_country_flag instead of set_global_flag. Otherwise, multi-playthrough or multi-nation coexistence scenarios will cause state pollution.