Wiki

trigger · any_character

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if any character meets the trigger. tooltip=key can be defined to override title

实战 · 配合 · 坑

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

实战用法

any_character 常用于国家级判断,例如检测某国是否已拥有带特定特质的将领/顾问,或在决议/事件 available 块中确认至少有一个符合条件的角色存在后才允许触发。典型场景包括:动态顾问系统中判断是否有某意识形态的顾问在职、或成就 mod 中检测某国存在高技能指挥官。

# 检测本国是否存在任意一个拥有 politically_connected 特质的角色
available = {
    any_character = {
        has_trait = politically_connected
        is_advisor = yes
    }
}

配合关系

  • has_trait:最常见的内层条件,用来筛选具备特定特质的角色,是 any_character 循环体的核心过滤手段。
  • is_advisor:与 any_character 配合,将检测范围缩窄到当前在职顾问,避免误匹配非顾问角色。
  • is_country_leader:在 any_character 内部区分国家领袖与其他角色,常用于判断领袖是否具备某条件。
  • has_character_flag:配合 any_character 检测某角色是否被脚本打过标记旗帜,实现跨事件的状态追踪。

常见坑

  1. 作用域混淆any_character 只能在 COUNTRY scope 下使用,如果直接写在 UNIT_LEADER(将领)scope 的条件块里会静默失败或报错,新手需确认外层 scope 确实是国家。
  2. 内层条件过宽导致误判:省略区分条件(如 is_advisoris_unit_leader)时,any_character 会扫描国家所有角色(含未雇用顾问、在野将领),只要其中任意一个满足条件即返回真,容易产生非预期的"总是为真"结果。

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

any_character is most commonly used in country-level checks — for example, detecting whether a country already has a general or advisor with a specific trait, or confirming inside a decision/event available block that at least one qualifying character exists before allowing it to fire. Typical use cases include: checking whether an advisor of a certain ideology is currently hired in a dynamic advisor system, or verifying that a high-skill commander exists in a country for an achievement mod.

# Check whether the current country has any character with the politically_connected trait who is an active advisor
available = {
    any_character = {
        has_trait = politically_connected
        is_advisor = yes
    }
}

Synergy

  • has_trait: The most common inner condition, used to filter characters with a specific trait — the core filtering tool inside an any_character loop.
  • is_advisor: Used alongside any_character to narrow the check to currently hired advisors, preventing false matches against non-advisor characters.
  • is_country_leader: Used inside any_character to distinguish the country leader from other characters, often to check whether the leader meets a certain condition.
  • has_character_flag: Used with any_character to check whether a character has been tagged with a scripted flag, enabling state tracking across events.

Common Pitfalls

  1. Scope confusion: any_character can only be used under a COUNTRY scope. Writing it directly inside a condition block scoped to UNIT_LEADER will cause a silent failure or an error. Beginners should always verify that the enclosing scope is indeed a country.
  2. Overly broad inner conditions causing false positives: If you omit narrowing conditions such as is_advisor or is_unit_leader, any_character will scan every character belonging to the country — including unslotted advisors and off-field generals. As long as any single one of them satisfies the condition the trigger returns true, which can easily produce unintended "always true" results.