Wiki

effect · swap_country_leader_traits

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

swap 2 traits on a country leader. 
 Syntax: swap_country_leader_traits = { remove = <trait> add = <trait> [ideology = <ideology>] }

实战 · 配合 · 坑

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

实战用法

swap_country_leader_traits 常用于剧情事件中动态改变领袖特质,例如某位领袖经历战争洗礼后,将"新手政客"替换为"老练政治家"。也可用于 focus tree 完成后自动调整领袖特质,模拟政策转变或性格成长的叙事效果。

# 在某个 focus 完成事件中,将领袖特质从温和派换成强硬派
country_event = {
    id = my_mod.42
    ...
    option = {
        name = my_mod.42.a
        # 此时 scope 为 CHARACTER(通过 country_leader 触发)
        swap_country_leader_traits = {
            remove = trait_pacifist_leader
            add = trait_warlord_leader
            ideology = fascism
        }
    }
}

配合关系

  • [is_country_leader](/wiki/trigger/is_country_leader) — 在执行 swap 前先校验当前角色确实担任国家领袖,避免对非领袖角色误操作。
  • [has_trait](/wiki/trigger/has_trait) — 确认角色身上确实拥有要被移除的 trait,防止因 trait 不存在导致效果静默失败。
  • [add_country_leader_trait](/wiki/effect/add_country_leader_trait) — 若只需新增特质而非替换,可与之配合分支处理,保持 trait 管理逻辑统一。
  • [set_leader_description](/wiki/effect/set_leader_description) — 换完特质后同步更新领袖描述文本,让 UI 展示与逻辑状态保持一致。

常见坑

  1. 忽略 ideology 字段的必要性:若领袖同时拥有多个意识形态角色(如同时担任民族主义与法西斯领袖),不指定 ideology 时游戏可能对错误的意识形态角色执行 swap,务必显式声明目标意识形态。
  2. remove 的 trait 不存在时不报错:游戏不会抛出错误提示,swap 会静默失败(整条命令无效),新手常误以为 add 成功了,实际上角色既没有移除旧 trait 也没有获得新 trait,应配合 [has_trait](/wiki/trigger/has_trait) 在执行前做保护性检查。

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

swap_country_leader_traits is commonly used in scripted events to dynamically modify leader traits. For example, after a leader experiences the crucible of war, you can replace "inexperienced_politician" with "seasoned_statesman". It can also be applied upon focus tree completion to automatically adjust leader traits, creating narrative effects that simulate policy shifts or character growth.

# In a focus completion event, swap the leader trait from pacifist to warmonger
country_event = {
    id = my_mod.42
    ...
    option = {
        name = my_mod.42.a
        # At this point, scope is CHARACTER (triggered via country_leader)
        swap_country_leader_traits = {
            remove = trait_pacifist_leader
            add = trait_warlord_leader
            ideology = fascism
        }
    }
}

Synergy

  • [is_country_leader](/wiki/trigger/is_country_leader) — Validate before executing the swap that the current character actually holds a country leader position, avoiding unintended operations on non-leader characters.
  • [has_trait](/wiki/trigger/has_trait) — Confirm the character actually possesses the trait being removed, preventing silent failures due to non-existent traits.
  • [add_country_leader_trait](/wiki/effect/add_country_leader_trait) — If you only need to add traits rather than swap, use this in parallel conditional branches to maintain unified trait management logic.
  • [set_leader_description](/wiki/effect/set_leader_description) — After trait replacement, sync the leader description text to keep UI display consistent with game state.

Common Pitfalls

  1. Overlooking the necessity of the ideology field: If a leader simultaneously holds multiple ideological positions (e.g., serving as both nationalist and fascist leader), omitting ideology may cause the game to execute the swap on the wrong ideological variant. Always explicitly declare the target ideology.
  2. No error when remove trait doesn't exist: The game will not throw an error; the swap silently fails without any indication, making it easy for new modders to mistakenly believe the add succeeded when in fact neither the old trait was removed nor the new one acquired. Always pair this with a [has_trait](/wiki/trigger/has_trait) guard check before execution.