Hands-On Usage
random_country_division is commonly used in mods to modify the combat state of a random division belonging to a specific country — for example, reducing a random unit's organization after an event fires, or swapping a random division's template to simulate a refit. Typical scenarios include a random division suffering losses from a surprise attack at the outbreak of war, or a scripted event assigning a new commander to a random division that meets certain conditions.
# A country is caught off guard — a random infantry division loses organization
GER = {
random_country_division = {
limit = {
division_has_majority_template = {
template = "Infantry Division"
}
}
set_unit_organization = 0.1
}
}
Synergy
- division_has_majority_template: Used inside a
limit block to filter for divisions built around a specific template, ensuring the effect only applies to the intended unit type rather than any arbitrary division.
- set_unit_organization: Directly sets the organization of the selected random division — one of the most common follow-up operations paired with this command.
- change_division_template: Used alongside this command to replace the randomly selected division's template with a new one, simulating a refit or order-of-battle reform.
- hidden_effect: Wraps
random_country_division inside hidden_effect when you don't want the player to see which division was randomly selected in the message log or tooltip.
Common Pitfalls
- Forgetting that the scope must be COUNTRY:
random_country_division can only be called within a country scope. If written inside a state scope or division scope, the parser will either silently ignore it or throw an error. A frequent mistake among newcomers is accidentally using this command inside an every_state block.
- Leaving
limit empty and causing unintended behavior: Omitting the limit block means the effect can fire on any division — including reserves or overseas garrisons. It is strongly recommended to always narrow the target pool using conditions such as division_has_majority_template or unit_strength, to avoid hitting an unintended division.