Hands-On Usage
any_neighbor_state is commonly used in territory-expansion and strategic-planning mods to check whether a state borders one controlled by a friendly or hostile country, thereby triggering events or unlocking decisions. A typical use case is checking whether any neighbor of a given state is owned by a specific nation in order to gate an invasion decision.
# Decision's available block: only usable when the target state has a neighbor owned by ROOT
available = {
any_neighbor_state = {
is_owned_by = ROOT
}
}
# Inside a trigger scoped to a state, check whether any neighbor meets a compound condition
any_neighbor_state = {
is_controlled_by = GER
is_coastal = yes
}
Synergy
- all_neighbor_state:
any_neighbor_state checks that at least one neighboring state meets the condition, while all_neighbor_state requires every neighboring state to meet it. The two are semantically complementary and frequently appear together in territorial logic.
- every_neighbor_state: A common pattern is to use
any_neighbor_state to confirm that at least one qualifying neighbor exists, then use every_neighbor_state to apply an effect to all matching neighbors — a clean "check → execute" combination.
- random_neighbor_state: Once
any_neighbor_state has guaranteed that at least one qualifying neighbor exists, random_neighbor_state can safely pick one at random to apply an effect to, avoiding an empty draw.
- is_owned_by: The most frequently used inner condition alongside
any_neighbor_state. Checking which country owns a neighboring state is the core building block for border-conflict and pre-annexation logic.
Common Pitfalls
- Wrong scope:
any_neighbor_state can only be used inside a STATE scope. If the current scope is a country (COUNTRY), you must first switch to a state scope — for example via capital_scope — otherwise the script will silently fail or throw an error.
- Inner scope confusion: Inside the curly braces of
any_neighbor_state, the scope is automatically set to the neighboring state (STATE). You do not need to — and must not — manually switch scope again. A common beginner mistake is writing country-level triggers such as has_war = yes directly inside the inner block, which produces incorrect logic.