Function generate_item_from_template

Source
pub fn generate_item_from_template(
    template: &ItemTemplate,
    rarity: ItemRarity,
    level: i64,
    optional_count: u64,
    game_config: &GameConfig,
    rng: &mut StdRng,
) -> Item
Expand description

optional_count is passed in rather than read off the template.

A2-BAL-003 §3.3 makes it a property of the CHEST — 0 at L1, 1 at L2..5, 2 at L6+ — so the same sword rolls a different number of extras depending on where it dropped. Ten templates also carried three, above the signed maximum of two. Paths that are not a chest roll (bundles, cheats, bot fixtures) pass the template’s own count and keep their previous behaviour.