Wiki

effect · set_division_template_lock

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Set lock status for a division template
Example: set_division_template_lock = { division_template = <name> is_locked = <bool (default:true)> }

实战 · 配合 · 坑

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

实战用法

set_division_template_lock 常用于剧本型 mod 中,在特定国策或事件触发后锁定某支精锐师团模板,防止玩家或 AI 随意修改其编制,以维持剧本设计的战略意图。例如在开局隐藏效果中锁定"近卫师"模板,待解锁科技或完成特定国策后再予以解锁。

# 在某国策完成时锁定一个精锐师团模板
complete_national_focus = {
    hidden_effect = {
        set_division_template_lock = {
            division_template = "Imperial Guard Division"
            is_locked = yes
        }
    }
}

# 在后续事件中解锁该模板
country_event = {
    option = {
        set_division_template_lock = {
            division_template = "Imperial Guard Division"
            is_locked = no
        }
    }
}

配合关系

  • [division_template](/wiki/effect/division_template):通常先用此命令创建师团模板,再立即用 set_division_template_lock 对其加锁,确保模板在创建后即处于受保护状态。
  • [country_lock_all_division_template](/wiki/effect/country_lock_all_division_template):当需要批量锁定所有模板时与之配合,前者管全体,后者处理需要差异化解锁的单个模板。
  • [complete_national_focus](/wiki/effect/complete_national_focus):常作为触发锁定/解锁的时机节点,通过国策完成来控制模板的可编辑状态,形成有节奏的剧本推进。
  • [has_completed_focus](/wiki/trigger/has_completed_focus):在条件判断中搭配使用,确认前置国策已完成后再执行解锁操作,避免提前开放模板编辑权限。

常见坑

  1. 模板名称大小写与空格必须与 division_template 定义块中的 name 字段完全一致,哪怕多一个空格或大小写不符都会导致命令静默失败,日志中不会报错,新手极难排查。
  2. 忘记写 is_locked 字段时默认为 true(锁定),若本意是解锁模板却漏写或写错布尔值,会得到与预期完全相反的结果,测试时务必验证实际锁定状态是否符合预期。

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_division_template_lock is commonly used in scenario-based mods to lock elite division templates after specific national focuses or events are triggered, preventing players or AI from arbitrarily modifying their organization and preserving the strategic intent of the scenario design. For example, locking the "Imperial Guard" template in the hidden startup effects, then unlocking it only after certain technologies are researched or specific national focuses are completed.

# Lock an elite division template upon completing a national focus
complete_national_focus = {
    hidden_effect = {
        set_division_template_lock = {
            division_template = "Imperial Guard Division"
            is_locked = yes
        }
    }
}

# Unlock the template in a subsequent event
country_event = {
    option = {
        set_division_template_lock = {
            division_template = "Imperial Guard Division"
            is_locked = no
        }
    }
}

Synergy

  • [division_template](/wiki/effect/division_template): Typically used first to create a division template, then immediately followed by set_division_template_lock to protect it, ensuring the template is safeguarded immediately upon creation.
  • [country_lock_all_division_template](/wiki/effect/country_lock_all_division_template): Used together when bulk-locking all templates is needed; the former handles all templates globally while the latter manages individual templates requiring differential unlock timing.
  • [complete_national_focus](/wiki/effect/complete_national_focus): Commonly serves as the trigger node for locking/unlocking operations, controlling template editability through focus completion and creating a rhythmic progression of scenario events.
  • [has_completed_focus](/wiki/trigger/has_completed_focus): Paired in conditional checks to confirm prerequisite focuses are completed before executing unlock operations, preventing premature granting of template editing permissions.

Common Pitfalls

  1. Template name casing and spacing must exactly match the name field in the division_template definition block. Even a single extra space or case mismatch will cause the command to fail silently with no error logged, making it extremely difficult for newcomers to troubleshoot.
  2. Omitting the is_locked field defaults to true (locked). If you intend to unlock a template but forget to write the field or specify the wrong boolean value, you'll get results completely opposite to expectations; always verify the actual lock state during testing to confirm it matches your intentions.