Hands-On Usage
every_state is commonly used in mods to batch-modify states that meet specific conditions — for example, reducing resistance across all states controlled by a country that have active resistance forces when an event fires, or transferring all of a victor's core states during a post-war peace script. The example below adds cores and transfers control for all of a country's core states that it does not yet own:
# Executed inside a country event option:
every_state = {
limit = {
is_core_of = ROOT
NOT = { is_owned_by = ROOT }
}
add_core_of = ROOT
set_state_controller_to = ROOT
}
You can also combine it with random_select_amount to apply effects to a random subset of states, which works well for randomized event scenarios:
every_state = {
random_select_amount = 3
limit = {
is_on_continent = europe
is_controlled_by = ROOT
}
add_resistance = -10
}
Synergy
- is_core_of: Used inside a
limit block to filter target states, ensuring effects only apply to a specific country's core states — one of the most common filtering conditions.
- transfer_state_to: After iterating over qualifying states, transfers them to a target country; typically used in post-peace-conference territorial reorganization scripts.
- set_resistance: Combined with
every_state to bulk-reset resistance levels across occupied territories, useful in mod scenarios that trigger large-scale political upheaval.
- add_building_construction: Queues construction in all qualifying states at once; commonly seen as a reward effect after industrial events or national focus completions.
Common Pitfalls
- Forgetting
limit, causing the effect to apply to every state on the map: every_state iterates over every state in the game by default. Without a limit to narrow the scope, operations such as bulk-adding buildings or modifying resistance will affect all states, leading to performance issues or outright logic errors. Always explicitly constrain the target range inside limit.
- Using effect commands inside
limit (or triggers outside it): The limit block only accepts triggers (condition checks) — effects such as add_core_of or set_state_controller_to must not be placed inside it. Conversely, trigger checks do not belong in the execution body outside limit; when conditional branching is needed there, nest it with if = { limit = { ... } }.