Wiki

trigger · has_project_flag

Definition

  • Supported scope:SPECIAL_PROJECT
  • Supported target:any

Description

Check if flag has been set within the special project in scope.
May checks on the value or date/days since last modified date.
Examples:
has_project_flag = my_flag
has_project_flag = {
	flag = my_flag (mandatory)
	value < 12 (optional)
	date > 1936.3.25 (optional, compare with the date where the flag was last modified )
	days > 365 (optional, compare with the number of days since the flag was last modified )
}

实战 · 配合 · 坑

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

实战用法

在特殊项目(Special Project)的推进逻辑中,has_project_flag 常用于判断某个研究阶段是否已经触发过特定事件或达成过某个里程碑,从而控制后续奖励或分支条件是否开放。例如在一个核武器研发项目中,可检查"完成材料提纯"标志是否存在、设置多久,再决定是否解锁下一阶段选项:

available = {
    has_project_flag = {
        flag = material_purification_done
        days > 30
    }
}

配合关系

  • [set_project_flag](/wiki/effect/set_project_flag):最直接的搭档,先用 effect 打上标志,再用 has_project_flag 在其他条件块中检测该标志是否存在及其时效。
  • [clr_project_flag](/wiki/effect/clr_project_flag):当需要重置某一阶段状态时先清除标志,可用 has_project_flag 作为清除前的保护判断,避免对不存在的标志执行无意义操作。
  • [modify_project_flag](/wiki/effect/modify_project_flag):用于修改标志的数值,配合 has_project_flagvalue 比较,可实现累计计数器式的进度门控逻辑。
  • [hidden_trigger](/wiki/trigger/hidden_trigger):将复杂的 has_project_flag 组合条件包裹在 hidden_trigger 中,使 UI 提示更整洁,避免玩家看到内部实现细节。

常见坑

  1. 忘记 scope 限制has_project_flag 只能在 SPECIAL_PROJECT scope 下使用,新手常在国家或角色 scope 里直接调用,导致脚本报错或条件永远为假,需确保外层已通过类似 any_special_project 等方式切换到正确 scope。
  2. 混淆 datedays 的语义date 比较的是标志最后一次被修改时的绝对日期,而 days 比较的是距今已过去的天数,两者容易在逻辑上颠倒使用,导致条件在意料之外的时间点触发或永远不触发。

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

In the progression logic of Special Projects, has_project_flag is commonly used to determine whether a specific event has been triggered or a milestone has been achieved in a certain research stage, thereby controlling whether subsequent rewards or branch conditions are unlocked. For example, in a nuclear weapons development project, you can check whether the "material purification completed" flag exists and how long it has been set, then decide whether to unlock the next stage options:

available = {
    has_project_flag = {
        flag = material_purification_done
        days > 30
    }
}

Synergy

  • [set_project_flag](/wiki/effect/set_project_flag): The most direct companion. First use the effect to set a flag, then use has_project_flag in other condition blocks to check whether the flag exists and its time validity.
  • [clr_project_flag](/wiki/effect/clr_project_flag): When you need to reset the state of a certain stage, first clear the flag. You can use has_project_flag as a protective check before clearing to avoid performing meaningless operations on non-existent flags.
  • [modify_project_flag](/wiki/effect/modify_project_flag): Used to modify the numeric value of a flag. Combined with the value comparison in has_project_flag, this can implement accumulative counter-style progress gating logic.
  • [hidden_trigger](/wiki/trigger/hidden_trigger): Wrap complex has_project_flag combination conditions in hidden_trigger to make UI tooltips cleaner and prevent players from seeing implementation details.

Common Pitfalls

  1. Forgetting scope restrictions: has_project_flag can only be used under the SPECIAL_PROJECT scope. Beginners often call it directly in country or character scopes, causing script errors or conditions to always evaluate as false. Make sure the outer scope has already been switched to the correct scope through methods like any_special_project.
  2. Confusing the semantics of date and days: date compares the absolute date when the flag was last modified, while days compares the number of days elapsed since now. These two are easily reversed in logic, causing conditions to trigger at unexpected times or never trigger at all.