Wiki

trigger · has_character_flag

Definition

  • Supported scope:CHARACTER
  • Supported target:any

Description

has a character flag been setCheck flag val date set and days since set.
Example: has_unit_leader_flag = test_flag
has_character_flag = { 
	flag = <name> (mandatory)
	value < <int> (optional)
	date > <date> (optional)
	days > <int> (optional)
}

实战 · 配合 · 坑

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

实战用法

has_character_flag 常用于追踪某个角色是否已触发过特定事件或完成过某个流程,例如限制同一将领只能接受一次特殊训练奖励,或在任务链中判断角色是否已进入下一阶段。结合 days 参数还可实现"冷却期"逻辑,例如某个 buff 上次施加后需要等待一定天数才能再次触发。

# 确保某将领未曾获得过特殊奖励,且上次授予已超过 180 天
limit = {
    NOT = {
        has_character_flag = {
            flag = received_special_training
            days > 180
        }
    }
}

配合关系

  • [set_character_flag](/wiki/effect/set_character_flag):最直接的搭档——先用该 effect 打上旗标,再用 has_character_flag 检测它是否存在,构成完整的"写入→读取"闭环。
  • [clr_character_flag](/wiki/effect/clr_character_flag):当条件满足、流程结束后清除旗标,配合 has_character_flag 可实现可重置的状态机逻辑。
  • [modify_character_flag](/wiki/effect/modify_character_flag):用于对旗标的数值进行累加,与 has_character_flagvalue < 参数组合,可实现计数器式的多阶段判断。
  • [has_unit_leader_flag](/wiki/trigger/has_unit_leader_flag):功能几乎相同但作用于单位指挥官旗标,当不确定角色是否同时担任指挥官时,常需与 has_character_flag 并列检查以避免遗漏。

常见坑

  1. 忘记 flag 字段是 mandatory:新手常直接写 has_character_flag = my_flag(模仿简写形式),而该 trigger 的块语法要求必须用 flag = <name> 显式声明,否则解析器会报错或静默失败,导致条件永远不成立。
  2. 混淆 days > 的语义方向days > 30 表示旗标被设置后已超过 30 天,很多人误以为是"30 天内有效"而写反逻辑;若要表达"旗标设置后 30 天内",需配合 NOT 包裹。

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_character_flag is commonly used to track whether a character has triggered a specific event or completed a certain process, such as restricting a particular general to receive a special training bonus only once, or determining whether a character has progressed to the next stage in a quest chain. Combined with the days parameter, it can also implement "cooldown" logic—for example, requiring a certain number of days to pass before a buff can be applied again after its last use.

# Ensure a general has never received the special training bonus, and more than 180 days have passed since the last grant
limit = {
    NOT = {
        has_character_flag = {
            flag = received_special_training
            days > 180
        }
    }
}

Synergy

  • [set_character_flag](/wiki/effect/set_character_flag): The most direct partner—use this effect to set the flag first, then use has_character_flag to check if it exists, forming a complete "write → read" cycle.
  • [clr_character_flag](/wiki/effect/clr_character_flag): When conditions are met and the process ends, clear the flag. Combined with has_character_flag, this enables resettable state machine logic.
  • [modify_character_flag](/wiki/effect/modify_character_flag): Used to increment the numeric value of a flag. When combined with the value < parameter in has_character_flag, it enables counter-based multi-stage checks.
  • [has_unit_leader_flag](/wiki/trigger/has_unit_leader_flag): Functionally nearly identical but operates on unit commander flags. When uncertain whether a character simultaneously holds a commander position, it is often necessary to check both has_character_flag and this trigger in parallel to avoid omissions.

Common Pitfalls

  1. Forgetting that the flag field is mandatory: Beginners often write has_character_flag = my_flag directly (imitating shorthand syntax), but this trigger's block syntax requires explicitly declaring flag = <name>. Without this, the parser will error or fail silently, causing the condition to never evaluate to true.
  2. Confusing the semantic direction of days >: days > 30 means the flag has existed for more than 30 days, but many mistake it to mean "valid within 30 days" and reverse the logic. To express "within 30 days of flag creation," you need to wrap it with NOT.