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 }
add_random_traitCHARACTERnoneadd random trait from specified list to unit leader. add_random_trait = { old_guard brilliant_strategist inflexible_strategist }
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
add_random_trait 常用于角色随机成长系统或历史事件中,为将领赋予不确定性特质,增加游戏可重玩性。例如在"晋升将领"事件中,从多个候选特质里随机挑选一个,避免每局结果固定。
# 在某个将领晋升事件的 option 块中
character_event = {
id = my_mod.10
option = {
name = my_mod.10.a
# 当前 scope 已是 CHARACTER
add_random_trait = {
old_guard
brilliant_strategist
inflexible_strategist
}
}
}
[has_trait](/wiki/trigger/has_trait) — 在添加随机特质前先检查角色是否已持有某特质,避免重复叠加冲突特质。[add_skill_level](/wiki/effect/add_skill_level) — 随机特质往往与技能提升同步触发,共同模拟将领的综合成长。[add_trait](/wiki/effect/add_trait) — 当需要确定性赋予某特质(而非随机)时作为补充手段,两者搭配可实现"保底+随机"组合逻辑。[can_select_trait](/wiki/trigger/can_select_trait) — 在执行前验证目标角色是否满足选取特质的条件,防止因特质互斥而触发报错或静默失败。common/unit_leader 相关文件中逐一核对特质定义名称。any_character / 具名角色将 scope 切换到 CHARACTER 再调用该命令。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.
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
}
}
}
[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/unit_leader related files.any_character or a specific character reference before calling this command in country-level events.