Hands-On Usage
random_allied_country is commonly used when you need to apply a random effect to one of your allies — for example, transferring resources or equipment to a random ally during a coalition war, or firing a diplomatic event, without having to enumerate every allied country individually. A limit block can further filter eligible targets (e.g., already at war, exists and has not capitulated), ensuring the effect only applies to a meaningful target.
GER = {
random_allied_country = {
limit = {
has_war = yes
is_major = yes
}
country_event = { id = axis_support.1 }
}
}
Synergy
- any_allied_country: Use
any_allied_country first to check whether any ally meets your conditions. Confirm a valid target exists before calling this effect, so you avoid a silent no-op when no suitable ally is available.
- has_war: A common filter inside
limit that ensures the randomly selected target is currently at war, preventing wartime logic from firing on an ally that is still at peace.
- send_equipment: Send equipment to the randomly selected ally inside the effect body, implementing a "randomly aid one ally" wartime support mechanic.
- add_war_support: Boost the war support of the randomly chosen ally, simulating a linked morale effect across coalition members.
Common Pitfalls
- Scope confusion:
random_allied_country requires a country scope (COUNTRY). Writing it inside a province or state block will cause a script error or silent failure — make sure the enclosing scope is a valid country tag or country scope block.
- Omitting
limit leads to unintended targets: Without a limit, the game picks from all allies at random, including countries that have already capitulated (has_capitulated = yes) or no longer exist. Always add at least exists = yes inside limit to filter out invalid targets and prevent the effect from firing on a country that no longer exists, which can cause logic errors downstream.