Hands-On Usage
has_state_flag is commonly used to track whether a specific region has triggered a particular event or completed a specific action, such as determining whether a state has experienced a custom milestone like "rebellion outbreak" or "reconstruction complete". It is especially prevalent in resistance movement, occupation event chains, or regional development mods, and can be combined with optional parameters to precisely control the flag's value range or duration.
# Only allow the next phase event to trigger after this state is marked as "reconstruction complete" and the flag has been set for more than 30 days
available = {
has_state_flag = {
flag = reconstruction_done
days > 30
}
}
Synergy
[set_state_flag](/wiki/effect/set_state_flag): The most direct pairing—use set_state_flag to write the flag first, then use has_state_flag in subsequent conditions to read it, forming a "write→read" loop.
[clr_state_flag](/wiki/effect/clr_state_flag): After conditions are met and corresponding logic is executed, call clr_state_flag to clear the flag, preventing duplicate triggers in the same event chain.
[modify_state_flag](/wiki/effect/modify_state_flag): When cumulative counting of a flag is needed (incrementing value), combine it with has_state_flag's value < parameter to detect the current count threshold, enabling multi-stage progress tracking.
[has_dynamic_modifier](/wiki/trigger/has_dynamic_modifier): Both often appear simultaneously in the same limit block, jointly constraining a dynamic modifier to only take effect when both the specific flag and dynamic modifier exist concurrently.
Common Pitfalls
- Wrong scope placement:
has_state_flag must be called within STATE scope. Beginners sometimes write this trigger directly in a limit block under COUNTRY scope, causing script errors or always returning false—use any_neighbor_state / capital_scope and similar commands to switch to STATE scope first before checking.
- Overlooking default behavior when flag is never set: If the corresponding flag is never written by
set_state_flag, has_state_flag simply returns false without error, easily misleading developers into thinking the condition logic is correct when actually the flag name has a typo (case or underscore mismatch), so the flag never exists.