Wiki

trigger · has_advisor_role

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

has_advisor_role = 'character_slot_name' - Checks if the character in scope has an advisor role for the given slot

实战 · 配合 · 坑

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

实战用法

has_advisor_role 常用于在顾问招募或事件脚本中检查某个角色是否已被配置了特定顾问槽位的角色定义,从而决定是否显示某个选项或触发特定事件分支。例如在 DLC 角色包 mod 中,可以用它来避免重复给同一角色添加同类顾问角色:

# 在 focus 或 event option 的 available 块中
available = {
    FROM = {         # FROM 指向目标角色 (CHARACTER scope)
        NOT = {
            has_advisor_role = political_advisor
        }
    }
}

配合关系

  • [is_advisor](/wiki/trigger/is_advisor) — 先用 is_advisor 判断角色当前是否正在被雇用,再配合 has_advisor_role 确认其所属槽位类型,两者叠用可精准定位"正在担任某槽顾问"的角色。
  • [add_advisor_role](/wiki/effect/add_advisor_role) — 在 effect 块中给角色追加新顾问角色前,先用 has_advisor_role 做存在性检查,防止重复定义同一槽位导致脚本报错或逻辑冲突。
  • [remove_advisor_role](/wiki/effect/remove_advisor_role) — 移除顾问角色的前提往往是确认该角色确实拥有对应角色定义,用 has_advisor_role 作为 limit/trigger 保护可避免对不存在角色的无效移除。
  • [is_hired_as_advisor](/wiki/trigger/is_hired_as_advisor)has_advisor_role 只检查角色定义了哪个槽位,而 is_hired_as_advisor 检查是否已被雇用,两者组合才能完整区分"有资格但未上岗"与"已在岗"两种状态。

常见坑

  1. 混淆"拥有角色定义"与"正在被雇用"has_advisor_role 仅判断角色档案里是否注册了对应槽位的 advisor role,即使该角色未被任何国家雇用也会返回真,因此不能用它代替 is_hired_as_advisor 来判断顾问是否在职。
  2. Scope 必须是 CHARACTER 而非 Country:新手常在国家 scope 下直接写此 trigger,导致脚本静默失败或报错;正确做法是先通过 any_characterevery_character 或具名角色变量切换到 CHARACTER scope 后再调用。

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_advisor_role is commonly used in advisor recruitment or event scripts to check whether a character has been assigned a specific advisor role definition for a particular advisor slot, allowing you to decide whether to display certain options or trigger specific event branches. For example, in DLC character pack mods, you can use it to prevent adding duplicate advisor roles of the same type to the same character:

# In the available block of a focus or event option
available = {
    FROM = {         # FROM points to the target character (CHARACTER scope)
        NOT = {
            has_advisor_role = political_advisor
        }
    }
}

Synergy

  • [is_advisor](/wiki/trigger/is_advisor) — First use is_advisor to determine whether a character is currently employed, then combine with has_advisor_role to confirm which slot type they belong to. Using both together allows you to precisely identify characters "currently serving as an advisor in a specific slot."
  • [add_advisor_role](/wiki/effect/add_advisor_role) — Before adding a new advisor role to a character in an effect block, first use has_advisor_role to check existence and prevent duplicate definitions of the same slot, which could cause script errors or logic conflicts.
  • [remove_advisor_role](/wiki/effect/remove_advisor_role) — Before removing an advisor role, the prerequisite is usually to confirm that the character actually possesses the corresponding role definition. Using has_advisor_role as a limit/trigger guard prevents invalid removals of non-existent roles.
  • [is_hired_as_advisor](/wiki/trigger/is_hired_as_advisor)has_advisor_role only checks which slots a character's definition includes, while is_hired_as_advisor checks whether they are actually employed. Combining both allows you to fully distinguish between "qualified but not deployed" and "currently in service" states.

Common Pitfalls

  1. Confusing "has role definition" with "is currently employed": has_advisor_role only checks whether the corresponding advisor role is registered in a character's profile for a given slot. It will return true even if that character is not employed by any country, so it cannot be used as a substitute for is_hired_as_advisor to determine whether an advisor is actively serving.
  2. Scope must be CHARACTER, not Country: Beginners often write this trigger directly under country scope, causing silent script failures or errors. The correct approach is to first switch to CHARACTER scope using any_character, every_character, or a named character variable before calling this trigger.