Hands-On Usage
any_of_scopes is commonly used to iterate over a custom array and check whether at least one element satisfies a given condition — for example, determining whether any country stored in a country-tag array holds a global flag, or whether any value in a variable array has reached a threshold. Typical use cases include dynamic alliance checks and multi-target event trigger conditions.
# Check whether any country in my_countries_array holds a specific global flag
trigger = {
any_of_scopes = {
array = my_countries_array
has_global_flag = special_event_flag
}
}
Synergy
- add_to_array / add_to_temp_array: On the effect side, countries or states are written into an array one by one; on the trigger side,
any_of_scopes iterates over that array to check conditions. This is the most typical array-build → array-check workflow.
- all_of_scopes: The semantic counterpart of
any_of_scopes — it requires all elements in the array to satisfy the condition. The two are often used side by side to implement "at least one / all" dual checks.
- count_triggers: When you need to know the number of elements that satisfy a condition rather than simply whether any exist, use
count_triggers as a replacement or supplement. The two frequently appear together inside complex condition blocks.
- is_in_array: Used to check whether a specific value already exists in an array. Pairing it with
any_of_scopes allows for a quick existence pre-filter before iterating.
Common Pitfalls
- Forgetting to specify the
array field: any_of_scopes requires an explicit array = <array_name> declaration. Writing triggers inside the block without specifying array will cause the script to silently fail or throw an error. Beginners often assume it can be used like any_country, where the source scope declaration can be omitted.
- Mismatch between the scope type in the trigger and the scope type stored in the array: When the array stores country scopes, the triggers written inside must be valid for country scopes. If the array stores numeric variables rather than scope objects, using scope-based triggers to check them will have no effect — use numeric triggers such as
check_variable instead.