Hands-On Usage
random_controlled_state is commonly used in country events or decisions to apply a one-time effect to a randomly selected state controlled by that country — for example, adding resistance, resources, or buildings in occupied territories. Pair it with limit to precisely filter states that meet certain conditions, and use prioritize to ensure key states (such as those near the capital) are given selection priority.
# Country event: add resistance in a random controlled state that is not a core of ROOT
random_controlled_state = {
limit = {
NOT = { is_core_of = ROOT }
is_controlled_by = ROOT
}
prioritize = { 42 43 }
add_resistance = 15
set_state_flag = resistance_triggered_flag
}
Synergy
- is_controlled_by: Used inside a
limit block to confirm the state is actually under the current country's control, preventing enemy-occupied states from being selected.
- is_core_of: Used inside
limit to exclude or include the country's own core states, so the effect only applies to occupied or colonial territories.
- add_resistance: One of the most typical child effects — directly applies a resistance value to the randomly selected controlled state.
- set_state_flag: Places a flag on the selected state to prevent the same event chain from triggering the same logic more than once.
Common Pitfalls
- Scope confusion:
random_controlled_state must be called from a COUNTRY scope. Writing it inside a child block that is already in STATE scope will cause an error or silent failure. A common beginner mistake is nesting this command inside every_state, at which point the scope is already STATE rather than COUNTRY.
prioritize is not a guarantee: prioritize only raises the likelihood that the specified states are selected — if those states do not satisfy the limit conditions, they will still be skipped. Beginners often assume that listing a state in prioritize guarantees it will be chosen, and consequently omit the correct filtering conditions from limit.