Wiki

effect · random_scientist

Definition

  • Supported scope:any
  • Supported target:none

Description

Executes children effects on random scientists that fulfills the "limit" trigger. tooltip=key can be added to override tooltip title

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

random_scientist 常用于科研相关 mod 中,对满足条件的随机一名科学家执行奖励或惩罚,例如在某国完成特定国策后随机提升一名科学家的等级或添加特质。它与 every_active_scientist 的区别在于只作用于单个随机目标,适合"抽签式"奖励设计。

# 当某国完成科研国策时,随机给一名科学家添加特质并提升等级
focus = {
    id = research_breakthrough
    ...
    completion_reward = {
        random_scientist = {
            limit = {
                is_active_scientist = yes
                has_scientist_level = { level < 3 }
            }
            add_scientist_trait = { slot = research_speed_factor trait = scientific_genius }
            add_scientist_level = 1
        }
    }
}

配合关系

  • is_active_scientist:在 limit 块中过滤出当前处于激活状态的科学家,避免对未分配或未激活的角色生效。
  • add_scientist_trait:随机选中科学家后为其添加科研特质,是最常见的搭配用法。
  • add_scientist_level:与 random_scientist 配合实现随机科学家升级奖励。
  • add_scientist_xp:为随机选中的科学家增加经验值,用于渐进式成长设计。

常见坑

  1. 忽略 limit 导致作用范围过宽:不加 limitrandom_scientist 会从所有科学家(包括已退休或未激活的)中随机选取,建议始终配合 is_active_scientist = yes 等触发器收窄范围,避免效果作用在不符合预期的角色上。
  2. 误将 scope 当作 character scope 使用random_scientist 内部已自动切换到科学家 scope,无需也不应在其内部再写角色 scope 切换命令(如再嵌套 every_active_scientist),否则会造成 scope 嵌套错误或重复执行。

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

random_scientist is commonly used in research-focused mods to apply a reward or penalty to a single randomly selected scientist who meets the specified conditions — for example, boosting a random scientist's level or adding a trait after a country completes a particular national focus. The key difference from every_active_scientist is that it targets only one random individual, making it well-suited for "lottery-style" reward designs.

# When a country completes a research-related focus, add a trait and increase the level of one random scientist
focus = {
    id = research_breakthrough
    ...
    completion_reward = {
        random_scientist = {
            limit = {
                is_active_scientist = yes
                has_scientist_level = { level < 3 }
            }
            add_scientist_trait = { slot = research_speed_factor trait = scientific_genius }
            add_scientist_level = 1
        }
    }
}

Synergy

  • is_active_scientist: Use inside a limit block to filter for scientists who are currently active, preventing the effect from applying to unassigned or inactive characters.
  • add_scientist_trait: Adds a research trait to the randomly selected scientist — the most common pairing with random_scientist.
  • add_scientist_level: Combine with random_scientist to grant a random scientist a level-up reward.
  • add_scientist_xp: Grants experience to the randomly selected scientist, useful for incremental progression designs.

Common Pitfalls

  1. Omitting limit leads to an overly broad target pool: Without a limit block, random_scientist draws from all scientists, including retired or inactive ones. Always narrow the pool with a trigger such as is_active_scientist = yes to ensure the effect only applies to intended characters.
  2. Treating the scope as a character scope: random_scientist automatically switches into the scientist scope internally — you do not need to, and should not, add another scope-switching command inside it (such as nesting every_active_scientist). Doing so will cause scope-nesting errors or unintended repeated execution.