Wiki

effect · random_country_division

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Executes children effects on a random division that fulfill the "limit" trigger. tooltip=key can be added to override tooltip title

实战 · 配合 · 坑

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

实战用法

random_country_division 常用于 mod 中对某国的随机一支师进行战斗状态修改,例如在事件触发后随机削弱一支部队的组织度,或为随机一支师更换模板以模拟装备改装。典型场景包括:战争爆发时随机一支师遭受奇袭损失、或通过剧本事件为随机满足条件的师赋予新指挥官。

# 某国遭遇突袭,随机一支步兵师损失组织度
GER = {
    random_country_division = {
        limit = {
            division_has_majority_template = {
                template = "Infantry Division"
            }
        }
        set_unit_organization = 0.1
    }
}

配合关系

  • division_has_majority_template:在 limit 块中筛选特定模板组成的师,确保效果只作用于目标类型部队而非任意一支。
  • set_unit_organization:对选中的随机师直接设置组织度,是最常见的后续操作之一。
  • change_division_template:与本命令配合,将随机命中的师替换为新模板,模拟换装或编制改革。
  • hidden_effect:将 random_country_division 包裹在 hidden_effect 中,当不希望玩家在日志/提示框中看到随机命中的具体结果时使用。

常见坑

  1. 忘记 scope 必须是 COUNTRYrandom_country_division 只能在国家 scope 下调用,若写在 state scope 或 division scope 内会被解析器静默忽略或报错,新手常在 every_state 嵌套内误用此命令。
  2. limit 留空导致逻辑混乱:省略 limit 块时效果会对任意一支师生效(包括预备役或海外驻军),建议始终用 [division_has_majority_template](/wiki/trigger/division_has_majority_template)[unit_strength](/wiki/trigger/unit_strength) 等条件明确缩小范围,避免出现意料之外的师被命中。

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_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

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