Wiki

effect · random_allied_country

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Executes children effects on a random Allied Country different from the one in scope that fulfills the `limit` trigger.
`tooltip` can be used to override tooltip title (supports [bindable localization](script_concept_documentation.md#bindable-localization)).

### Example

ENG = { random_allied_country = { tooltip = my_loc_key # Optional bindable localization limit = my_limit_trigger # Optional ... country scope effects ... } }

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

random_allied_country 常用于需要对盟友之一施加随机效果的场景,例如在同盟战争中随机向一个盟国转移资源、装备或触发外交事件,避免手动枚举每个盟国带来的冗余逻辑。limit 块可进一步筛选符合条件的盟国(如已参战、存在且未亡国),确保效果只作用于有意义的目标。

GER = {
    random_allied_country = {
        limit = {
            has_war = yes
            is_major = yes
        }
        country_event = { id = axis_support.1 }
    }
}

配合关系

  • any_allied_country:先用 any_allied_country 判断是否存在满足条件的盟国,确认有可选目标后再调用本 effect,避免在无合适盟国时静默失败。
  • has_war:作为 limit 内的常用筛选条件,确保随机目标当前处于战争状态,避免对处于和平期的盟国执行战时逻辑。
  • send_equipment:在效果体内对随机盟国发送装备,实现"随机援助一个盟友"的战时支援机制。
  • add_war_support:对随机选中的盟国提升战争支持度,模拟盟军士气联动效果。

常见坑

  1. scope 混淆random_allied_country 的 scope 必须是国家(COUNTRY),若写在省份或状态块内会导致脚本报错或无效执行,需确保外层 scope 是正确的国家标签或国家 scope 块。
  2. 未使用 limit 导致意外目标:不加 limit 时游戏会从所有盟国中随机选取,包括已投降(has_capitulated = yes)或不存在的国家,应在 limit 中至少加 exists = yes 来过滤无效目标,防止效果作用于已不存在的国家而引发逻辑错误。

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

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

  1. 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.
  2. 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.