Wiki

trigger · has_unit_leader_flag

Definition

  • Supported scope:CHARACTER
  • Supported target:any

Description

This trigger is deprecated in favor of has_character_flag (which does the same)has a character flag been setCheck flag val date set and days since set.
Example: has_unit_leader_flag = test_flag
has_unit_leader_flag = { 
	flag = <name> (mandatory)
	value < <int> (optional)
	date > <date> (optional)
	days > <int> (optional)
}

实战 · 配合 · 坑

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

实战用法

has_unit_leader_flag 主要用于检查某个将领/角色是否被打上了特定的自定义标记,常见于事件链中判断角色是否已经历过某个特殊情节(如受伤、晋升仪式、秘密任务等),从而决定后续分支走向。由于官方已将其标记为过时,新 mod 应优先使用 has_character_flag,但维护旧 mod 时仍会频繁遇到它。

# 检查将领是否被标记为"经历过前线受伤事件"
character_event = {
    id = my_mod.10
    trigger = {
        is_corps_commander = yes
        has_unit_leader_flag = frontline_wounded
    }
    # ...后续事件内容
}

# 带天数条件的写法:标记设置超过 30 天后才触发
trigger = {
    has_unit_leader_flag = {
        flag = secret_mission_assigned
        days > 30
    }
}

配合关系

  • [set_unit_leader_flag](/wiki/effect/set_unit_leader_flag):设置标记的对应效果命令,通常在事件或 on_action 中先用它打上标记,再用本 trigger 检查该标记是否存在,形成"写入→检测"的完整逻辑闭环。
  • [clr_unit_leader_flag](/wiki/effect/clr_unit_leader_flag):清除标记,与本 trigger 配合实现"一次性触发"机制——检测到标记后执行逻辑,随即清除,防止重复触发。
  • [has_character_flag](/wiki/trigger/has_character_flag):本 trigger 的官方推荐替代品,行为完全相同,新写的条件块应直接换用此命令以保持前向兼容。
  • [is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal):将领标记通常只对特定职位的角色有意义,先过滤角色类型再检查标记,可避免对非目标角色产生误判。

常见坑

  1. 在非 CHARACTER scope 中使用:本 trigger 只能作用于 CHARACTER scope,若在 COUNTRY 或 STATE 等 scope 下直接调用会静默失败或报错,需先通过 any_characterevery_character 等方式进入正确 scope 再使用。
  2. 忘记迁移到 has_character_flag:新 mod 沿用此命令虽然短期内不会报错,但官方随时可能在后续版本彻底移除它;应养成习惯,凡新增逻辑一律改写为 has_character_flag,避免日后批量替换的维护成本。

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

has_unit_leader_flag is primarily used to check whether a specific character/leader has been assigned a custom flag, commonly appearing in event chains to determine whether a character has already experienced a particular narrative moment (such as being wounded, undergoing a promotion ceremony, or completing a secret mission), thereby branching the subsequent event flow accordingly. Since the official maintainers have marked it as deprecated, new mods should prioritize has_character_flag instead; however, it remains frequently encountered when maintaining legacy mods.

# Check if a leader has been flagged as "experienced frontline wound event"
character_event = {
    id = my_mod.10
    trigger = {
        is_corps_commander = yes
        has_unit_leader_flag = frontline_wounded
    }
    # ...subsequent event content
}

# Variant with day condition: only trigger after the flag has been set for more than 30 days
trigger = {
    has_unit_leader_flag = {
        flag = secret_mission_assigned
        days > 30
    }
}

Synergy

  • [set_unit_leader_flag](/wiki/effect/set_unit_leader_flag): The corresponding effect command for setting flags; typically used first in events or on_action handlers to apply a flag, then checked with this trigger to form a complete "write→detect" logic cycle.
  • [clr_unit_leader_flag](/wiki/effect/clr_unit_leader_flag): Clears a flag; used in conjunction with this trigger to implement a "fire-once" mechanism—detect the flag after execution, then immediately clear it to prevent repeated triggering.
  • [has_character_flag](/wiki/trigger/has_character_flag): The official recommended replacement for this trigger with identical behavior; new conditional blocks should directly use this command to maintain forward compatibility.
  • [is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal): Leader flags typically only have meaning for characters in specific positions; filtering character types before checking flags prevents false positives on unintended characters.

Common Pitfalls

  1. Using outside CHARACTER scope: This trigger only functions within CHARACTER scope; calling it directly in COUNTRY, STATE, or other scopes will silently fail or error. You must enter the correct scope first using any_character, every_character, or similar commands before applying this trigger.
  2. Forgetting to migrate to has_character_flag: While reusing this command in new mods won't cause immediate errors, official maintainers could remove it entirely in a future patch; adopt the habit of rewriting all new logic to use has_character_flag instead, avoiding the maintenance burden of mass replacements later.