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
any_characterCOUNTRYnonecheck 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
}
}
any_character 循环体的核心过滤手段。any_character 配合,将检测范围缩窄到当前在职顾问,避免误匹配非顾问角色。any_character 内部区分国家领袖与其他角色,常用于判断领袖是否具备某条件。any_character 检测某角色是否被脚本打过标记旗帜,实现跨事件的状态追踪。any_character 只能在 COUNTRY scope 下使用,如果直接写在 UNIT_LEADER(将领)scope 的条件块里会静默失败或报错,新手需确认外层 scope 确实是国家。is_advisor、is_unit_leader)时,any_character 会扫描国家所有角色(含未雇用顾问、在野将领),只要其中任意一个满足条件即返回真,容易产生非预期的"总是为真"结果。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.
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
}
}
any_character loop.any_character to narrow the check to currently hired advisors, preventing false matches against non-advisor characters.any_character to distinguish the country leader from other characters, often to check whether the leader meets a certain condition.any_character to check whether a character has been tagged with a scripted flag, enabling state tracking across events.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.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.