Wiki

effect · add_random_valid_trait_from_unit

Definition

  • Supported scope:(none)
  • Supported target:none

Description

for use ONLY with root scope unit, target scope: character add_random_valid_trait_from_unit = FROM

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

This effect is specifically designed for combat-related events. When a character (such as a general) gains skill growth through battle experience, it randomly draws a valid trait from the available trait pool of their assigned unit and grants it to that character. A typical scenario is dynamically accumulating combat experience traits for generals during battle victories or casualty events, making the general growth system more random and immersive.

# In an option within a combat event, grant FROM (character) a random valid trait from their unit
option = {
    name = my_battle_event.1.a
    add_random_valid_trait_from_unit = FROM
}

Synergy

Since there are no other commands with the same scope currently in the whitelist, no cross-reference commands can be listed. Please refer to the actual whitelist contents to avoid referencing non-existent commands.

Common Pitfalls

  1. Incorrect Scope Usage: This effect requires execution within a context where the root scope is a unit. If used directly in a standard country or character scope without ensuring root is a unit, the script will silently fail or throw an error. Beginners often mistakenly place it at the top-level scope of a character event while overlooking this prerequisite.

  2. Incorrect target Parameter: FROM in this context must point to a valid character. If event chain propagation causes FROM to reference a non-character object (such as a country or the unit itself), the trait will not be correctly granted, and the game typically provides no obvious error message, making it difficult to debug.