> For the complete documentation index, see [llms.txt](https://enchantedmobs.superiormc.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enchantedmobs.superiormc.cn/ultimatequest-zhong-wen-wen-dang/pei-zhi/rewards/random.md).

# 随机奖励

random 选择加权奖励组并发放抽中组的所有奖励，内联 random 与外部 pool 二选一。

| 字段                          | 默认值        | 说明              |
| --------------------------- | ---------- | --------------- |
| type                        | 必填         | random。         |
| count                       | 1          | 正整数抽取次数。        |
| repeat                      | false      | 本次抽取是否允许重复选项。   |
| random                      | 无 pool 时必填 | 具名加权选项。         |
| random..rate                | 0          | 有限非负权重，总和为有限正数。 |
| random..rewards             | 必填         | 抽中组的非空完整奖励映射。   |
| display.name / display.lore | 自动生成       | 可选预览覆盖。         |

```yaml
rewards:
  supply:
    type: random
    count: 2
    repeat: false
    random:
      food:
        rate: 70
        rewards:
          bread:
            type: item
            item: {material: BREAD, amount: 8}
      mineral:
        rate: 25
        rewards:
          iron:
            type: item
            item: {material: IRON_INGOT, amount: 4}
      treasure:
        rate: 5
        rewards:
          diamond:
            type: item
            item: {material: DIAMOND, amount: 1}
```

## 权重与重复

权重按相对比例，不需凑成 100，0 权重不参与。无重复时选中组移出候选，count 不超过正权重候选数；repeat true 时保留并可再次发放。不同组/轮次中的同名嵌套奖励独立保留。

单项可预览概率，多项显示权重，首轮概率不是最终入选概率。随机最多 8 层，错误数量/类型/权重/引用通过 ErrorManager 报错并拒绝加载。

## 抽取时机

普通接取和周期实例创建时立即抽取。卷轴发放保存目标/奖励定义，首次激活创建实例时抽取。阶段奖励解锁时抽取。rewards-snapshot/已解锁的阶段奖励让重载/重登保留结果，与执行时才抽取的[随机动作](/ultimatequest-zhong-wen-wen-dang/pei-zhi/actions/orchestration.md)不同。
