effect · random_character
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
Executes children effects on random characters that fulfills the "limit" trigger. tooltip=key can be added to override tooltip title
random_characterCOUNTRYnoneExecutes children effects on random characters that fulfills the "limit" trigger. tooltip=key can be added to override tooltip title
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
random_character 常用于需要对国家内随机一名符合条件的角色执行一次性操作的场景,例如在事件中随机给一名将领添加特质、随机晋升一名顾问,或为随机一名特工执行状态变更。相比 every_character(作用于所有符合者),它只影响其中一个,适合"抽签式"叙事设计。
# 示例:随机选取一名陆军指挥官,给其添加一个特质
random_character = {
limit = {
is_army_leader = yes
has_trait = old_guard
}
add_trait = brilliant_strategist
}
limit 块中用于筛选角色兵种身份,确保操作只命中目标类型的将领。limit 中进一步过滤拥有特定特质的角色,避免重复赋予或产生冲突。has_character_flag 条件防止同一角色被重复选中。limit 导致范围过宽:不加 limit 时会从国家内所有角色(包括顾问、间谍等)中随机选取,执行效果可能命中意料之外的角色;务必在 limit 内用 is_army_leader、is_operative 等触发器精确限定范围。random_character 只对恰好一个符合条件的角色生效,若需对所有符合条件的角色统一操作,应改用 every_character(但该命令需确认在当前白名单可用,若无则拆分处理),切勿用 random_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.
random_character is commonly used when you need to perform a one-time operation on a single randomly selected character within a country — for example, adding a trait to a random general during an event, randomly promoting an advisor, or changing the status of a random operative. Unlike every_character (which affects all matching characters), it only targets one, making it well-suited for "lottery-style" narrative design.
# Example: randomly select an army commander and add a trait to them
random_character = {
limit = {
is_army_leader = yes
has_trait = old_guard
}
add_trait = brilliant_strategist
}
limit block to filter characters by their military role, ensuring the operation only targets the intended type of commander.limit to characters with a specific trait, preventing duplicate assignment or conflicting results.has_character_flag in subsequent conditions to prevent the same character from being picked again.limit, causing an overly broad scope: Without a limit block, the scope draws from all characters in the country — including advisors, operatives, and others — so the effect may land on an unintended character. Always use triggers such as is_army_leader or is_operative inside limit to precisely restrict the candidate pool.random_character affects exactly one matching character. If you need to apply an operation to every qualifying character, use every_character instead (verify it is available in your current whitelist; if not, handle the cases separately). Never loop random_character in an attempt to simulate "select all" behavior.