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>] }

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.