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
add_random_valid_trait_from_unitnonefor use ONLY with root scope unit, target scope: character add_random_valid_trait_from_unit = FROM
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
此 effect 专用于战斗相关事件中,当某个角色(如将领)通过战斗经历获得技能成长时,从其所属部队的可用特质池中随机抽取一个合法特质并授予该角色。典型场景是在战斗胜利或伤亡事件中为将领动态积累作战经验特质,令将领成长系统更具随机性与真实感。
# 在某战斗事件的 option 中,令 FROM(角色)获得其部队对应的随机合法特质
option = {
name = my_battle_event.1.a
add_random_valid_trait_from_unit = FROM
}
由于当前白名单中没有同 scope 可用的其他命令,无法列出真实的交叉引用命令。请以实际白名单内容为准,避免引用不存在的命令。
root scope 为 unit(部队单位)的上下文中调用,若在普通国家或角色 scope 中直接使用而未确保 root 是 unit,脚本将静默失败或报错,新手常误将其写在角色事件的顶层 scope 中而忽略这一前提。FROM 在此语境中必须指向一个合法的 character(角色),若事件链传递导致 FROM 指向非角色对象(如国家或部队本身),特质将无法正确授予,且游戏通常不会给出明显的报错提示,难以排查。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.
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
}
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.
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.
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.