Wiki

effect · set_keyed_oob

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Registers an Order of Battle (OOB) file to be loaded for a country at game start, replacing any previously registered OOB (with the given key) on that country.
Only intended to be used within history files.

Example:
set_keyed_oob = {
	key = naval
	name = "ENG_1936_Naval"
}

实战 · 配合 · 坑

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

实战用法

set_keyed_oob 主要用于需要在历史文件中为某个国家注册多套不同用途的战斗序列文件的场景,例如同时存在陆军 OOB 和海军 OOB 时,通过不同的 key 加以区分而互不覆盖。在 mod 中常见于改写原版国家的初始部队编组,或为特定历史情境分支提供替换的起始兵力配置。

# 在 history/countries/ENG - Britain.txt 或对应 on_actions 初始化块中
set_keyed_oob = {
    key = army
    name = "ENG_1936_Army"
}
set_keyed_oob = {
    key = naval
    name = "ENG_1936_Naval"
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):在条件分支中检查特定国旗,决定是否为该国注册某套 OOB 文件,从而实现按玩家选择或剧本分支加载不同兵力。
  • [clr_country_flag](/wiki/effect/clr_country_flag):在完成 OOB 注册后清除临时标记,避免重复触发同一套初始化逻辑。
  • [division_template](/wiki/effect/division_template):OOB 文件引用的师模板需要预先通过此命令定义,两者共同构成完整的初始部队建立流程。
  • [delete_unit](/wiki/effect/delete_unit):若需要在 OOB 加载后动态移除特定部队,可配合使用以精细控制初始兵力。

常见坑

  1. key 相同时会覆盖而非叠加:同一国家下两次使用相同 key 值,后注册的 OOB 文件会替换前一个,而不是合并。若需同时保留多套 OOB,必须为每套使用唯一的 key,新手常误以为可以用相同 key 累加部队。
  2. 在非历史文件上下文中使用效果未必生效:该命令官方明确标注「只应在历史文件中使用」,若将其放入普通 event 或 focus 的 immediate 块中,行为未定义且极可能静默失败,不会报错但 OOB 也不会按预期加载。

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

set_keyed_oob is primarily used in scenarios where a country needs multiple distinct Order of Battle files registered in history files for different purposes. For example, when both army and naval OOBs exist simultaneously, different key values distinguish them and prevent overwriting. In mods, this is commonly seen when rewriting a vanilla nation's initial unit composition or providing alternative starting force configurations for specific historical branches.

# In history/countries/ENG - Britain.txt or corresponding on_actions initialization block
set_keyed_oob = {
    key = army
    name = "ENG_1936_Army"
}
set_keyed_oob = {
    key = naval
    name = "ENG_1936_Naval"
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Check specific country flags in conditional branches to determine whether to register a particular OOB file for that nation, enabling different force configurations to load based on player choices or scenario branches.
  • [clr_country_flag](/wiki/effect/clr_country_flag): Clear temporary flags after OOB registration to prevent the same initialization logic from triggering repeatedly.
  • [division_template](/wiki/effect/division_template): Division templates referenced by OOB files must be predefined using this command; together they form the complete initial force establishment workflow.
  • [delete_unit](/wiki/effect/delete_unit): If you need to dynamically remove specific units after OOB loading, use this in combination for fine-grained control over initial forces.

Common Pitfalls

  1. Identical key values cause overwriting, not stacking: When the same key value is used twice for a single nation, the later-registered OOB file replaces the earlier one rather than merging with it. To retain multiple OOBs simultaneously, each must use a unique key; newcomers often mistakenly believe identical keys will accumulate units.
  2. Effects may not work outside history file context: This command is officially marked as "should only be used in history files." Placing it in a regular event or focus immediate block results in undefined behavior and likely silent failure—no error message, but the OOB won't load as expected.