Hands-On Usage
every_unit_leader is commonly used when a war is won or a specific national focus is completed, to bulk-add traits or raise skill levels for all generals, or to clean up leaders that meet certain conditions during game events (such as removing a specific trait). For example, it can be used to uniformly grant experience rewards to all participating commanders after a major victory.
# After a national focus completes, add an attack trait to all army leaders
GER = {
every_unit_leader = {
limit = {
is_army_leader = yes
NOT = { has_trait = brilliant_strategist }
}
add_unit_leader_trait = aggressive_assaulter
gain_xp = 10
}
}
Synergy
- is_army_leader / is_navy_leader: Use inside a
limit block to filter leaders by branch, preventing effects from accidentally being applied to naval or air commanders.
- add_unit_leader_trait: The most common pairing target — bulk-adding traits to leaders is the quintessential use case for this loop.
- has_trait: Use together with
NOT inside limit to prevent adding the same trait twice, which can cause script errors or unexpected behavior.
- add_skill_level: Pairs with
every_unit_leader to bulk-increase leader skill levels; frequently used in initialization logic for formable nations or specific scenario startups.
Common Pitfalls
- Forgetting
limit causes the effect to apply to every leader: Without a limit, the effect targets all Unit Leaders belonging to that country (including naval and air commanders). If add_unit_leader_trait adds a trait exclusive to army leaders, this will generate warnings in the log or silently fail. Always use triggers such as is_army_leader / is_navy_leader to explicitly narrow the scope.
- Assuming a fixed order when used with
random_select_amount: Once random_select_amount is added, each execution randomly picks the specified number of leaders, making the result non-reproducible. If you need to reliably target a specific leader, use if + has_id or operate directly in the corresponding character file instead of relying on random selection.