Skip to main content
Deno 2 is finally here 🎉️
Learn more
class LootGenerator
import { LootGenerator } from "https://deno.land/x/sptaki@1.2.0/generators/mod.ts";

Constructors

new
LootGenerator(
logger: ILogger,
hashUtil: HashUtil,
databaseServer: DatabaseServer,
randomUtil: RandomUtil,
jsonUtil: JsonUtil,
itemHelper: ItemHelper,
presetHelper: PresetHelper,
inventoryHelper: InventoryHelper,
weightedRandomHelper: WeightedRandomHelper,
localisationService: LocalisationService,
ragfairLinkedItemService: RagfairLinkedItemService,
itemFilterService: ItemFilterService,
)

Properties

protected
databaseServer: DatabaseServer
protected
hashUtil: HashUtil
protected
inventoryHelper: InventoryHelper
protected
itemFilterService: ItemFilterService
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
presetHelper: PresetHelper
protected
ragfairLinkedItemService: RagfairLinkedItemService
protected
randomUtil: RandomUtil
protected
weightedRandomHelper: WeightedRandomHelper

Methods

protected
armorIsDesiredProtectionLevel(armor: IPreset, options: LootRequest): boolean

Filter armor items by their front plates protection level - top if its a helmet

protected
findAndAddRandomItemToLoot(
items: [string, ITemplateItem][],
itemTypeCounts: Record<string, { current: number; max: number; }>,
options: LootRequest,
result: LootItem[],
): boolean

Find a random item in items.json and add to result array

protected
findAndAddRandomPresetToLoot(
presetPool: IPreset[],
itemTypeCounts: Record<string, { current: number; max: number; }>,
itemBlacklist: string[],
result: LootItem[],
): boolean

Find a random item in items.json and add to result array

protected
getRandomisedStackCount(item: ITemplateItem, options: LootRequest): number

Get a randomised stack count for an item between its StackMinRandom and StackMaxSize values

Get non-weapon mod rewards for a sealed container

protected
getSealedContainerWeaponModRewards(
linkedItemsToWeapon: ITemplateItem[],
chosenWeaponPreset: IPreset,
): Item[][]

Iterate over the container weaponModRewardLimits settings and create an array of weapon mods to reward player

protected
initItemLimitCounter(limits: Record<string, number>): Record<string, ItemLimit>

Construct item limit record to hold max and current item count for each item type

Generate a list of items based on configuration options parameter

getRandomLootContainerLoot(rewardContainerDetails: RewardDetails): Item[][]

Handle event-related loot containers - currently just the halloween jack-o-lanterns that give food rewards

Sealed weapon containers have a weapon + associated mods inside them + assortment of other things (food/meds)