Wiki

effect · set_character_flag

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

set character flag

实战 · 配合 · 坑

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

实战用法

set_character_flag 常用于记录某个角色的特定状态或事件进度,例如标记某将领已经历过某场特殊战役、完成了某个任务链节点,以便后续事件或决策通过 flag 判断是否触发。典型场景是在角色相关事件的 immediate 块中打标记,防止同一事件重复触发。

# 在将领事件中标记"已接受秘密任务"
character_event = {
    id = my_mod.1
    immediate = {
        set_character_flag = accepted_secret_mission
    }
    option = {
        name = my_mod.1.a
        # 后续效果...
    }
}

配合关系

  • [has_character_flag](/wiki/trigger/has_character_flag) — 设置 flag 后,通常需要用此触发器检测该 flag 是否存在,从而控制后续事件或决策的触发条件。
  • [clr_character_flag](/wiki/effect/clr_character_flag) — 与 set_character_flag 相对,用于在角色状态改变后清除不再需要的 flag,避免脏数据残留。
  • [modify_character_flag](/wiki/effect/modify_character_flag) — 当需要对 flag 进行数值累加或修改(而非简单的开/关标记)时,与 set_character_flag 配合管理角色状态的数值型 flag。
  • [operative_leader_event](/wiki/effect/operative_leader_event) — 在特工任务事件中常配合使用,先用事件触发设旗,再通过旗帜驱动后续情报链剧情。

常见坑

  1. Scope 错误set_character_flag 必须在 CHARACTER scope 下执行。新手常在国家 scope(如 country_event 的 option 中)直接调用,导致脚本报错或 flag 打在错误对象上,应先用 every_character / specific_character 等方式切换到正确的角色 scope。
  2. Flag 命名冲突:flag 名称是全局字符串,不同 mod 或事件链若使用相同的 flag 名(如 doneflag_1),会造成跨角色或跨事件的状态误判,建议加上 mod 前缀作为命名规范(如 mymod_character_accepted_mission)。

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_character_flag is commonly used to record a specific state or event progress for a character—for instance, marking that a general has participated in a particular battle, completed a quest node, or achieved a milestone. Subsequent events or decisions can then check this flag to determine whether to trigger. A typical scenario is setting flags in the immediate block of character-related events to prevent the same event from firing repeatedly.

# Mark "accepted secret mission" on a character event
character_event = {
    id = my_mod.1
    immediate = {
        set_character_flag = accepted_secret_mission
    }
    option = {
        name = my_mod.1.a
        # Subsequent effects...
    }
}

Synergy

  • [has_character_flag](/wiki/trigger/has_character_flag) — Once a flag is set, this trigger is typically used to check whether that flag exists, thereby controlling the firing conditions of subsequent events or decisions.
  • [clr_character_flag](/wiki/effect/clr_character_flag) — The counterpart to set_character_flag, used to clear flags that are no longer needed after a character's state changes, preventing stale data from accumulating.
  • [modify_character_flag](/wiki/effect/modify_character_flag) — When you need to perform numeric increments or modifications on a flag (rather than simple on/off toggles), use this alongside set_character_flag to manage numeric-type character state flags.
  • [operative_leader_event](/wiki/effect/operative_leader_event) — Frequently paired in operative task events: first set a flag via an event trigger, then drive subsequent intelligence chain narratives through that flag.

Common Pitfalls

  1. Scope Mismatchset_character_flag must execute within a CHARACTER scope. Beginners often call it directly in a country scope (such as within an option in country_event), causing script errors or flags being set on the wrong target. Use every_character or specific_character to properly switch to the correct character scope first.
  2. Flag Name Collisions — Flag names are global strings; if different mods or event chains use the same flag name (e.g., done, flag_1), it can cause state confusion across characters or events. Adopt a naming convention with a mod prefix (e.g., mymod_character_accepted_mission) to avoid conflicts.