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> }

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.