Wiki

effect · add_unit_medal_to_latest_entry

Definition

  • Supported scope:(none)
  • Supported target:none

Description

add_unit_medal_to_latest_entry = { unit_medals = key }

实战 · 配合 · 坑

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

实战用法

add_unit_medal_to_latest_entry 用于在师级战斗日志(unit journal entry)的最新条目上附加勋章,常见于自定义战役事件或成就系统中,当玩家的部队完成特定任务时自动颁发荣誉。例如在一个关卡事件中,当某支精锐师完成包围战后触发:

# 在事件的 immediate 块中,对最新日志条目追加勋章
immediate = {
    add_unit_medal_to_latest_entry = {
        unit_medals = my_mod_iron_cross
    }
}

配合关系

由于当前 scope 白名单中暂无其他已收录的配套 effect 或 trigger 命令,无法列出合规的交叉引用条目。在实际工程中,该指令通常出现在专门管理师级日志的脚本链路里,建议结合日志条目创建类指令一并使用,确保"最新条目"确实存在再执行本指令。

常见坑

  1. 条目不存在即调用:本指令作用于"最新条目",若在调用时尚未通过对应指令创建任何日志条目,勋章将无处附加,效果静默失败且不报错,导致勋章丢失。务必确认日志条目已先行创建。
  2. unit_medals 键名拼写错误key 必须与 common/unit_medals/ 下定义的标识符完全一致(区分大小写),若键名不匹配,游戏不会崩溃但勋章不会显示,排查时容易被忽视。

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

add_unit_medal_to_latest_entry attaches a medal to the latest entry in a division's unit journal, commonly used in custom campaign events or achievement systems to automatically award honors when player units complete specific tasks. For example, in a level event triggered after an elite division completes an encirclement:

# In the immediate block of an event, append a medal to the latest journal entry
immediate = {
    add_unit_medal_to_latest_entry = {
        unit_medals = my_mod_iron_cross
    }
}

Synergy

Currently, no other compatible effects or trigger commands are listed in the scope whitelist, so relevant cross-references cannot be provided. In practical implementations, this instruction typically appears in script chains dedicated to managing division-level journals. It is recommended to use it alongside journal entry creation commands to ensure the "latest entry" actually exists before executing this instruction.

Common Pitfalls

  1. Calling without an existing entry: This instruction operates on the "latest entry." If no journal entries have been created through corresponding commands at the time of invocation, the medal has nowhere to attach, resulting in silent failure with no error message and lost medals. Always confirm that journal entries are created beforehand.

  2. Misspelled unit_medals key: The key must exactly match the identifier defined under common/unit_medals/ (case-sensitive). If the key name does not match, the game will not crash but the medal will not display, making it easy to overlook during debugging.