Wiki

effect · remove_advisor_role

Definition

  • Supported scope:COUNTRY, CHARACTER
  • Supported target:none

Description

remove advisor role to character

Example:
remove_advisor_role = {
	character = "GER_Character_Token" # optional if inside character scope
	slot = air_chief}

实战 · 配合 · 坑

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

实战用法

remove_advisor_role 常用于角色事件链中动态调整人物身份,例如当某位顾问因政变、退休或叛变而失去职务时,从代码层面解除其顾问槽位绑定。典型场景包括:国家焦点触发人物转型(顾问→将领),或事件中清除旧政治顾问以便后续用 add_advisor_role 赋予新职责。

# 某国顾问因事件被迫离职,转为普通角色
country_event = {
    id = my_mod.42
    option = {
        name = my_mod.42.a
        remove_advisor_role = {
            character = GER_heinrich_advisor
            slot = political_advisor
        }
    }
}

配合关系

  • [add_advisor_role](/wiki/effect/add_advisor_role):最直接的搭档,先移除旧顾问角色,再赋予新的顾问角色,实现顾问职位的"换岗"逻辑。
  • [deactivate_advisor](/wiki/effect/deactivate_advisor):在移除角色前先停用顾问,确保游戏状态一致,避免仍处于激活状态时强制移除引发异常。
  • [has_advisor_role](/wiki/trigger/has_advisor_role):在执行移除前用此触发器校验角色当前是否确实持有目标顾问槽,防止对不存在的角色槽位进行操作。
  • [set_can_be_fired_in_advisor_role](/wiki/effect/set_can_be_fired_in_advisor_role):配套管理顾问解雇权限,移除角色后可借此重置该角色未来能否被解雇的标记。

常见坑

  1. 忘记指定 character 字段:只有在 CHARACTER scope 下执行时才可省略 character,在 COUNTRY scope 下调用时若漏写该字段,游戏将无法定位目标角色,效果静默失效且不报错,极难排查。
  2. slot 与实际绑定槽位不匹配:若角色持有的顾问槽位类型(如 army_chief)与脚本中写的 slot(如 political_advisor)不一致,移除操作不会生效,角色仍保留原槽位,后续 add_advisor_role 也可能因冲突而出错。

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

remove_advisor_role is commonly used in character event chains to dynamically adjust a character's position. Typical use cases include removing an advisor from their slot when they lose office due to a coup, retirement, or defection, then unbinding them from the advisor slot at the code level. Common scenarios involve national focus triggering a character transition (advisor → general), or clearing an old political advisor in an event before assigning new responsibilities via add_advisor_role.

# An advisor from a certain country is forced to leave office via event, becoming a regular character
country_event = {
    id = my_mod.42
    option = {
        name = my_mod.42.a
        remove_advisor_role = {
            character = GER_heinrich_advisor
            slot = political_advisor
        }
    }
}

Synergy

  • [add_advisor_role](/wiki/effect/add_advisor_role): The most direct pairing—remove the old advisor role first, then assign a new advisor role to implement advisor position "rotation" logic.
  • [deactivate_advisor](/wiki/effect/deactivate_advisor): Deactivate the advisor before removing their role to ensure consistent game state and avoid exceptions from forced removal while still active.
  • [has_advisor_role](/wiki/trigger/has_advisor_role): Use this trigger before executing removal to verify the character currently holds the target advisor slot, preventing operations on non-existent slots.
  • [set_can_be_fired_in_advisor_role](/wiki/effect/set_can_be_fired_in_advisor_role): Manage advisor dismissal permissions in tandem—after removing a role, use this to reset whether that character can be fired in future advisor roles.

Common Pitfalls

  1. Forgetting to specify the character field: The character parameter can only be omitted when executing within CHARACTER scope. When called in COUNTRY scope without this field, the game cannot locate the target character, causing the effect to silently fail without error, making it extremely difficult to debug.
  2. slot mismatch with actual bound slot: If the advisor slot type the character holds (e.g., army_chief) does not match the slot written in the script (e.g., political_advisor), the removal will not take effect and the character retains their original slot. Subsequent add_advisor_role calls may then fail due to conflicts.