Wiki

effect · set_unit_leader_flag

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

set unit leader flag
This effect is deprecated in favor of set_character_flag.

实战 · 配合 · 坑

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

实战用法

set_unit_leader_flag 用于为将领角色设置自定义标记,常见于 mod 中追踪某位将领是否已触发过特定事件、是否处于某种特殊状态(如"已受伤""已获得密令"等)。由于该命令已被官方标记为过时,实际开发中建议仅在维护旧版 mod 时沿用,新项目应直接使用 set_character_flag

# 旧式写法(仍可运行,但不推荐用于新 mod)
some_character = {
    set_unit_leader_flag = received_secret_orders
}

配合关系

  • [has_unit_leader_flag](/wiki/trigger/has_unit_leader_flag):与 set_unit_leader_flag 直接对应的检查触发器,用于判断某将领是否已被打上对应标记,形成"设置→检查"的完整逻辑闭环。
  • [clr_unit_leader_flag](/wiki/effect/clr_unit_leader_flag):用于在合适时机清除已设置的标记,防止标记残留导致逻辑错误。
  • [set_character_flag](/wiki/effect/set_character_flag):官方推荐的替代命令,功能一致但适用范围更广,迁移旧 mod 时应优先改用此命令。
  • [unit_leader_event](/wiki/effect/unit_leader_event):常与标记配合使用,触发与将领相关的事件,并在事件内通过标记控制后续分支逻辑。

常见坑

  1. 忘记迁移到新命令:新手容易直接从旧 mod 或网络教程中复制 set_unit_leader_flag,却不知道它已被废弃。长期使用废弃命令可能在未来游戏版本更新后出现兼容性问题,应养成使用 set_character_flag 的习惯。
  2. Scope 用错:该命令必须在 CHARACTER scope 下执行,若在国家 scope 或省份 scope 中直接调用而不先切换到具体角色,脚本将静默失败且不报错,导致标记始终未被设置。

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_unit_leader_flag is used to set custom flags on character entities, commonly employed in mods to track whether a specific character has triggered certain events or is in a particular state (e.g., "wounded," "received orders," etc.). Since this command has been officially deprecated, it is recommended in actual development to use it only when maintaining legacy mods. New projects should use set_character_flag directly.

# Legacy syntax (still functional, but not recommended for new mods)
some_character = {
    set_unit_leader_flag = received_secret_orders
}

Synergy

  • [has_unit_leader_flag](/wiki/trigger/has_unit_leader_flag): The corresponding trigger that directly pairs with set_unit_leader_flag, used to check whether a character has been assigned a given flag, forming a complete "set → check" logic loop.
  • [clr_unit_leader_flag](/wiki/effect/clr_unit_leader_flag): Clears previously set flags at appropriate moments, preventing flag persistence from causing logic errors.
  • [set_character_flag](/wiki/effect/set_character_flag): The officially recommended alternative command with equivalent functionality but broader applicability. This should be prioritized when migrating legacy mods.
  • [unit_leader_event](/wiki/effect/unit_leader_event): Commonly used alongside flags to trigger character-related events, with flags controlling subsequent branch logic within the event.

Common Pitfalls

  1. Forgetting to migrate to the new command: Beginners often copy set_unit_leader_flag directly from legacy mods or online tutorials without realizing it has been deprecated. Prolonged use of deprecated commands may cause compatibility issues in future game updates. Adopt the habit of using set_character_flag instead.
  2. Incorrect scope usage: This command must execute within CHARACTER scope. If called directly in a country or province scope without first switching to the specific character, the script fails silently without error reporting, resulting in the flag never being set.