Wiki

effect · add_random_trait

Definition

  • Supported scope:CHARACTER
  • Supported target:none

Description

add random trait from specified list to unit leader. add_random_trait = { old_guard brilliant_strategist inflexible_strategist }

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

add_random_trait is commonly used in character progression systems or historical events to assign random traits to generals, adding unpredictability and replayability. For example, in a "promote general" event, you can randomly select one trait from multiple candidates instead of having the same outcome every game.

# In an option block within a general promotion event
character_event = {
    id = my_mod.10
    option = {
        name = my_mod.10.a
        # Current scope is already CHARACTER
        add_random_trait = {
            old_guard
            brilliant_strategist
            inflexible_strategist
        }
    }
}

Synergy

  • [has_trait](/wiki/trigger/has_trait) — Check whether the character already has a trait before adding a random one to avoid duplicate or conflicting traits.
  • [add_skill_level](/wiki/effect/add_skill_level) — Random traits often trigger alongside skill increases to simulate a general's overall development.
  • [add_trait](/wiki/effect/add_trait) — Use as a complement when you need to assign a specific trait deterministically (rather than randomly); combining both enables a "guaranteed + random" logic pattern.
  • [can_select_trait](/wiki/trigger/can_select_trait) — Verify that the target character meets the conditions for selecting the trait before execution to prevent errors or silent failures due to trait conflicts.

Common Pitfalls

  1. Non-existent or misspelled trait keys in the list: The game won't crash but will silently skip that entry, causing the actual random pool to differ from expectations. Always cross-reference trait definition names in common/unit_leader related files.
  2. Calling outside CHARACTER scope: If the current scope is COUNTRY or STATE, the effect won't apply. Beginners often forget to switch scope to CHARACTER using any_character or a specific character reference before calling this command in country-level events.