Hands-On Usage
all_of_scopes is commonly used when you need to validate a condition against every element in a dynamic array — for example, checking whether all countries stored in an array meet a certain variable threshold, or verifying that a player-assembled list of provinces all satisfy construction requirements. It forms a natural complement to any_of_scopes: the former requires every element to be true, while the latter only requires one.
# Check whether all countries in the array target_countries exist
trigger = {
all_of_scopes = {
array = target_countries
country_exists = THIS
}
}
Synergy
- add_to_array / add_to_temp_array: The most common prerequisite pattern — push each scope you want to check into the array before evaluating
all_of_scopes.
- any_of_scopes: The semantic counterpart to
all_of_scopes, expressing "any one is true" versus "all are true." The two are frequently combined inside the same and/or block to build complex conditions.
- is_in_array: Used inside the loop body to further check whether the current scope also appears in another array, effectively implementing an array-intersection check.
- check_variable: The most frequently used inner trigger inside loop bodies — evaluates a numeric variable associated with each scope against a threshold.
Common Pitfalls
- Missing the
array field or using an uninitialized array: If array points to a variable name that has never been written to by add_to_array, the array will be empty and all_of_scopes will return true immediately (a universal statement over an empty set is vacuously true). This is counterintuitive and can cause conditions to pass unexpectedly.
- Accidentally using effect commands inside
all_of_scopes: This is a trigger-side construct and may only contain condition checks (trigger-side commands). Writing effects such as set_variable or add_to_array inside the loop body will cause a script parse error or be silently ignored. Use for_each_scope_loop instead when you need to iterate over an array and execute effects.