Wiki

effect · modify_country_flag

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

modify country flag. Only modifies if flag already exists.
Example: modify_country_flag = { flag = <name> value = <number> }

实战 · 配合 · 坑

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

实战用法

modify_country_flag 常用于需要对已有计数器旗标进行累加或修改的场景,例如记录某国完成某事件的次数、追踪资源消耗积分等动态数值型旗标。注意它只会修改已存在的旗标,因此通常配合初始化旗标的逻辑一起设计。

# 每次触发事件时将计数器旗标 +1
if = {
    limit = { has_country_flag = war_escalation_counter }
    modify_country_flag = {
        flag = war_escalation_counter
        value = 1
    }
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):在执行修改前先判断旗标是否存在,避免因旗标不存在而导致命令静默失败,是最直接的前置检查。
  • [clr_country_flag](/wiki/effect/clr_country_flag):当计数器累积到阈值后用于重置旗标,与 modify_country_flag 构成"累加→清除"的完整生命周期管理。
  • [country_event](/wiki/effect/country_event):通常在旗标数值达到某个条件时触发后续事件,与旗标修改配合实现分阶段剧情推进。
  • [add_political_power](/wiki/effect/add_political_power) 等状态修改 effect:常在同一 option 块中与旗标修改并列,用旗标记录本次操作已执行,防止效果重复叠加。

常见坑

  1. 对不存在的旗标使用此命令不会自动创建旗标,命令会被静默跳过而不报错,导致逻辑看似正常运行却完全没有效果——应先在 on_actions 或游戏开始时用 set_country_flag 初始化旗标,再使用本命令修改。
  2. 误将 value 理解为"设置为该值",实际上 value 是在原有数值基础上的增量(delta),若要将旗标直接设为特定值应使用 set_country_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

modify_country_flag is commonly used in scenarios where you need to increment or modify an existing counter flag, such as tracking the number of times a country completes a specific event, or maintaining dynamic numerical flags that record resource consumption scores. Note that it only modifies existing flags, so it should typically be designed alongside initialization logic for those flags.

# Increment the counter flag by 1 each time the event is triggered
if = {
    limit = { has_country_flag = war_escalation_counter }
    modify_country_flag = {
        flag = war_escalation_counter
        value = 1
    }
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Check whether the flag exists before performing the modification to avoid silent command failure due to a missing flag. This is the most straightforward pre-condition check.
  • [clr_country_flag](/wiki/effect/clr_country_flag): Used to reset the flag once the counter reaches a threshold, forming a complete "accumulate → clear" lifecycle management pattern with modify_country_flag.
  • [country_event](/wiki/effect/country_event): Typically triggers subsequent events when the flag value meets certain conditions, working in tandem with flag modification to implement staged narrative progression.
  • [add_political_power](/wiki/effect/add_political_power) and other state-modifying effects: Often placed alongside flag modifications within the same option block, using the flag to record that this operation has been executed and prevent effect stacking.

Common Pitfalls

  1. Using this command on a non-existent flag will not automatically create it. The command will be silently skipped without error, resulting in logic that appears to execute but has no actual effect. Always initialize the flag first using set_country_flag in on_actions or at game start, then use this command to modify it.
  2. Misinterpreting value as "set to this value": In reality, value is a delta (increment) applied to the existing value. If you need to set the flag directly to a specific value, use set_country_flag instead of this command.