Wiki

trigger · distance_to

Definition

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

Description

check distance between two states

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

distance_to is commonly used to determine whether two states are within "strategic influence range," such as restricting certain decisions to only apply near a capital or core territories, or in resistance mechanics to grant bonuses to states far from occupation centers. Typical use cases include: preventing construction or triggering events when a state exceeds a certain distance from a specific target.

# In the available block of a decision, require the current state to be within a specified distance from the ROOT country's capital
available = {
    distance_to = {
        target = CAPITAL
        max_distance < 500
    }
}

Synergy

  • [is_controlled_by](/wiki/trigger/is_controlled_by): Often paired with distance_to to first confirm that a state is controlled by a specific country before checking distance, preventing logic from triggering on distant enclaves.
  • [any_neighbor_state](/wiki/trigger/any_neighbor_state): When batch-checking "all adjacent states near a target," nesting distance_to within the limit of any_neighbor_state can further refine the scope.
  • [has_state_flag](/wiki/trigger/has_state_flag): Used to mark states that have passed distance checks. Combined with distance_to, it creates a two-stage conditional chain of "mark and re-evaluate," preventing duplicate triggers.
  • [resistance](/wiki/trigger/resistance): In resistance mechanics, distance_to can determine whether a state is far from control centers, then combined with resistance values to decide whether to apply additional penalties or bonuses.

Common Pitfalls

  1. Using a scope not on the whitelist for target: Beginners often directly write specific country TAGs (such as GER) into target, but this trigger only accepts fixed scope keywords like THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, and CAPITAL. Incorrect entries cause conditions to silently fail or throw errors.
  2. Using outside STATE scope: distance_to is only valid within STATE scope. Writing it in COUNTRY or CHARACTER condition blocks produces no syntax errors but will never return true, making it easy to overlook during debugging.