Wiki

trigger · has_character

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Returns true if scoped country has character.

Example:
has_character = GER_erwin_rommel

实战 · 配合 · 坑

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

实战用法

has_character 常用于在国家焦点、决议或事件中判断某个关键角色是否仍然存在于该国,从而解锁特定的剧情分支或防止重复触发相关效果。例如在一个架空 mod 里,只有当隆美尔还在德国时才允许玩家解锁北非攻势焦点:

focus = {
    id = GER_north_africa_offensive
    available = {
        has_character = GER_erwin_rommel
    }
    ...
}

配合关系

  • [any_character](/wiki/trigger/any_character) — 当你需要检查某一角色(如具有特定 trait 的将领)而非特定人物时,与 has_character 互补使用,覆盖"精确匹配"与"模糊匹配"两种需求。
  • [generate_character](/wiki/effect/generate_character) — 在确认角色不存在(NOT = { has_character = ... })后,用此 effect 动态生成该角色,避免重复创建。
  • [activate_advisor](/wiki/effect/activate_advisor) — 先用 has_character 确认人物存在,再激活其顾问职位,防止因角色缺失导致脚本报错。
  • [has_country_leader](/wiki/trigger/has_country_leader) — 经常与 has_character 搭配,区分"此人是否在国家中"与"此人是否正担任国家领袖"两个不同的判断层级。

常见坑

  1. Scope 写错has_character 只能在 COUNTRY scope 下使用,新手有时在 stateunit_leader scope 里调用它,导致脚本静默失败或报错——务必确认外层 scope 是国家。
  2. 角色 tag 拼写依赖大小写:角色 ID(如 GER_erwin_rommel)必须与 /characters/ 文件夹里的定义完全一致,哪怕多一个下划线或大小写不符,条件永远返回 false 且不会有任何错误提示。

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 is commonly used in national focuses, decisions, or events to check whether a specific character still exists within that country, thereby unlocking particular story branches or preventing duplicate triggering of related effects. For example, in an alternate-history mod, players can only unlock the North Africa Offensive focus if Rommel is still in Germany:

focus = {
    id = GER_north_africa_offensive
    available = {
        has_character = GER_erwin_rommel
    }
    ...
}

Synergy

  • [any_character](/wiki/trigger/any_character) — When you need to check for a class of characters (such as officers with a specific trait) rather than a specific individual, use this alongside has_character to cover both "exact matching" and "fuzzy matching" scenarios.
  • [generate_character](/wiki/effect/generate_character) — After confirming a character does not exist (NOT = { has_character = ... }), use this effect to dynamically generate the character and avoid duplicate creation.
  • [activate_advisor](/wiki/effect/activate_advisor) — First use has_character to confirm the character exists, then activate their advisor position to prevent script errors caused by missing characters.
  • [has_country_leader](/wiki/trigger/has_country_leader) — Frequently paired with has_character to distinguish between "is this person in the country" and "is this person currently serving as the country's leader"—two different judgment levels.

Common Pitfalls

  1. Incorrect scopehas_character can only be used under COUNTRY scope. Beginners sometimes call it within state or unit_leader scope, causing scripts to fail silently or throw errors. Always verify that the outer scope is a country scope.
  2. Character tag spelling is case-sensitive — Character IDs (such as GER_erwin_rommel) must match exactly with the definitions in the /characters/ folder. Even a single extra underscore or incorrect capitalization will cause the condition to always return false with no error message whatsoever.