Wiki

trigger · has_country_flag

Definition

  • Supported scope:COUNTRY
  • Supported target:any

Description

has country flag been set.Check flag val date set and days since set.
Example: has_country_flag = test_flag
has_country_flag = { 
	flag = <name> (mandatory)
	value < <int> (optional)
	date > <date> (optional)
	days > <int> (optional)
}

实战 · 配合 · 坑

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

实战用法

has_country_flag 常用于追踪玩家或 AI 已完成某个关键决策/事件分支的状态,例如防止同一事件链重复触发、记录外交协议达成等。在 focus/decision 的 available 块中判断前置条件是否满足,或在事件 trigger 中检查某段历史是否已经发生,是它最典型的用途。

# 只有在之前通过事件设置过 signed_pact_flag 的情况下,该决策才可用
available = {
    has_country_flag = {
        flag = signed_pact_flag
        days > 30        # 该 flag 设置至少 30 天后才开放
    }
}

配合关系

  • [clr_country_flag](/wiki/effect/clr_country_flag):设置 flag 完成其使命后,用此命令清除,防止"一次性"逻辑被重复触发,两者构成"写入→检查→清除"完整闭环。
  • [country_event](/wiki/effect/country_event):在确认 flag 存在后,触发对应的后续事件,常用于事件链的跳转控制。
  • [has_completed_focus](/wiki/trigger/has_completed_focus):与 has_country_flag 搭配双重校验,既确认国策已完成,又验证事件链内部状态,避免仅靠国策判断带来的漏洞。
  • [has_decision](/wiki/trigger/has_decision):与 flag 联合使用,区分"正在执行决策中"和"决策已完成并留下 flag"两种不同阶段的逻辑分支。

常见坑

  1. 忘记 flag = 关键字:简写形式 has_country_flag = my_flag 与块形式 { flag = my_flag ... } 不能混用附加字段——一旦需要加 days >value <,必须使用块形式,否则解析报错或字段被静默忽略。
  2. Flag 作用域写错has_country_flag 只在 COUNTRY scope 下有效;如果当前 scope 是 STATE 或 CHARACTER,需要先用 ROOT/FROM 等跳回国家 scope,否则 flag 永远读取不到,条件静默返回 false 且不报错,极难排查。

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

has_country_flag is commonly used to track whether a player or AI has completed a critical decision/event branch, for example preventing the same event chain from triggering repeatedly or recording the completion of diplomatic agreements. Its most typical use cases are checking prerequisites in the available block of a focus/decision, or verifying whether a particular historical event has occurred in an event's trigger block.

# This decision is only available if signed_pact_flag was previously set via an event
available = {
    has_country_flag = {
        flag = signed_pact_flag
        days > 30        # The flag must be set for at least 30 days before this opens
    }
}

Synergy

  • [clr_country_flag](/wiki/effect/clr_country_flag): After a flag has completed its purpose, use this command to clear it, preventing "one-time" logic from being triggered repeatedly. Together with has_country_flag, they form a complete cycle of "write → check → clear".
  • [country_event](/wiki/effect/country_event): After confirming a flag exists, trigger the corresponding follow-up event, commonly used for controlling event chain transitions.
  • [has_completed_focus](/wiki/trigger/has_completed_focus): Combined with has_country_flag for dual verification, confirming both that the focus is completed and that the event chain's internal state is valid, avoiding gaps from relying solely on focus checks.
  • [has_decision](/wiki/trigger/has_decision): Used together with flags to distinguish between two different stages: "decision currently executing" and "decision completed with flag left behind" for branching logic.

Common Pitfalls

  1. Forgetting the flag = keyword: The shorthand form has_country_flag = my_flag and the block form { flag = my_flag ... } cannot be mixed when adding extra fields. Once you need to add days > or value <, you must use the block form, otherwise parsing fails or fields are silently ignored.
  2. Wrong flag scope: has_country_flag is only valid in COUNTRY scope. If the current scope is STATE or CHARACTER, you must first jump back to country scope using ROOT/FROM or similar, otherwise the flag can never be read and the condition silently returns false without error, making it extremely difficult to debug.