Wiki

trigger · country_exists

Definition

  • Supported scope:any
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

check if the specified country exist

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

country_exists is commonly used to check whether a specific country tag still exists in the game (i.e., has not been eliminated or annexed). It serves as a precondition in events, decisions, or focuses to prevent invalid operations on countries that have ceased to exist. For example, in a diplomatic alliance event, display an option only if the target country still exists:

available = {
    country_exists = GER
    country_exists = SOV
}

It can also be combined with NOT to trigger special story branches when a country has been eliminated.


Synergy

  • [any_country](/wiki/trigger/any_country) — When iterating through all countries, country_exists is typically used in the limit clause to filter and ensure logic only applies to countries that still exist.
  • [scope_exists](/wiki/trigger/scope_exists) — Similar functionality but applies to different targets; when uncertain whether an event target is valid, scope_exists checks the scope itself, while country_exists specifically targets country tags. Often used together as a double-check.
  • [has_global_flag](/wiki/trigger/has_global_flag) — Frequently paired with country_exists in trigger / available blocks, first confirming the country exists, then checking related global flags to prevent incorrect judgments about flags belonging to dead nations.
  • [save_global_event_target_as](/wiki/effect/save_global_event_target_as) — Before saving a country as a global event target in an effect block, use country_exists to confirm the country still exists, avoiding the storage of an invalid scope.

Common Pitfalls

  1. Writing the tag as a variable or string: The parameter for country_exists must be a hardcoded country tag (e.g., GER); it cannot accept variable names or quoted strings. Beginners sometimes write country_exists = "GER" or attempt to pass var:some_tag, which silently fails or throws an error in most versions.
  2. Assuming it can be used directly in effect blocks: country_exists is a pure trigger and cannot be placed at the top level of an effect block. To use conditional branching within an effect, it must be wrapped inside the limit = { } of [if](/wiki/effect/if) to take effect; writing it directly in an effect block will be ignored by the parser.