trigger · can_select_trait
Definition
- Supported scope:
CHARACTER,COMBATANT - Supported target:
none
Description
check if leader can select a trait
can_select_traitCHARACTER, COMBATANTnonecheck if leader can select a trait
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
can_select_trait 常用于 mod 中为指挥官设计自定义晋升系统或特质解锁界面时,判断当前角色是否处于可以选取新特质的状态,从而决定是否显示或激活相关按钮/选项。例如在一个将领成长系统中,只有满足条件才弹出特质选择事件:
# 在某个 unit_leader_event 的 trigger 块中
trigger = {
can_select_trait = yes
is_corps_commander = yes
skill > 2
}
[has_trait](/wiki/trigger/has_trait):与 can_select_trait 搭配,先确认角色尚未拥有目标特质,再判断是否可以选取,避免重复授予同一特质。[add_trait](/wiki/effect/add_trait):在确认 can_select_trait = yes 后,于 effect 块中执行实际的特质添加操作,形成"条件检查→状态修改"的完整流程。[has_unit_leader_flag](/wiki/trigger/has_unit_leader_flag):用于标记该角色本次特质选择流程是否已触发过,配合 can_select_trait 防止事件重复触发。[add_max_trait](/wiki/effect/add_max_trait):扩展角色可持有的特质上限后,再用 can_select_trait 验证是否真正解锁了选取资格,确保上限扩展与选取逻辑同步。can_select_trait,导致脚本静默失败或报错。该 trigger 仅在 CHARACTER / COMBATANT scope 下有效,务必确认当前作用域已切换到具体的角色或战斗单位。can_select_trait 只判断选取资格,并不保证特质槽位充足。若未配合 add_max_trait 提前扩展上限,直接执行 add_trait 可能因槽位已满而无效,且不会有任何错误提示。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.
can_select_trait is commonly used in mods to implement custom promotion systems or trait unlock interfaces for commanders, checking whether the current character is eligible to select a new trait and determining whether to display or activate relevant buttons/options. For example, in a general growth system, a trait selection event only triggers when conditions are met:
# In the trigger block of a unit_leader_event
trigger = {
can_select_trait = yes
is_corps_commander = yes
skill > 2
}
[has_trait](/wiki/trigger/has_trait): Used in conjunction with can_select_trait to first confirm that the character does not yet possess the target trait before checking eligibility, avoiding duplicate trait assignments.[add_trait](/wiki/effect/add_trait): After confirming can_select_trait = yes, execute the actual trait addition in the effect block, forming a complete "condition check → state modification" workflow.[has_unit_leader_flag](/wiki/trigger/has_unit_leader_flag): Used to mark whether this character's trait selection process has already been triggered, working with can_select_trait to prevent duplicate event triggers.[add_max_trait](/wiki/effect/add_max_trait): After expanding the maximum number of traits a character can hold, use can_select_trait to verify whether selection eligibility is truly unlocked, ensuring the limit expansion and selection logic remain synchronized.can_select_trait under country scope or province scope, causing the script to fail silently or throw errors. This trigger is only valid under CHARACTER / COMBATANT scope; always ensure the current scope has switched to the specific character or combat unit.can_select_trait only checks selection eligibility and does not guarantee sufficient trait slots. If add_max_trait is not used beforehand to expand the limit, executing add_trait directly may be ineffective if slots are full, and no error message will be displayed.