Skip to main content
The Deno 2 Release Candidate is here
Learn more
class LocationGenerator
import { LocationGenerator } from "https://deno.land/x/sptaki@1.2.0/generators/mod.ts";

Constructors

new
LocationGenerator(
logger: ILogger,
databaseServer: DatabaseServer,
jsonUtil: JsonUtil,
objectId: ObjectId,
randomUtil: RandomUtil,
itemHelper: ItemHelper,
mathUtil: MathUtil,
seasonalEventService: SeasonalEventService,
containerHelper: ContainerHelper,
presetHelper: PresetHelper,
localisationService: LocalisationService,
configServer: ConfigServer,
)

Properties

protected
configServer: ConfigServer
protected
containerHelper: ContainerHelper
protected
databaseServer: DatabaseServer
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
locationConfig: ILocationConfig
protected
logger: ILogger
protected
mathUtil: MathUtil
protected
objectId: ObjectId
protected
presetHelper: PresetHelper
protected
randomUtil: RandomUtil
protected
seasonalEventService: SeasonalEventService

Methods

protected
addForcedLoot(
lootLocationTemplates: SpawnpointTemplate[],
forcedSpawnPoints: SpawnpointsForced[],
locationName: string,
): void

Add forced spawn point loot into loot parameter array

protected
addLootToContainer(
staticContainer: IStaticContainerData,
staticForced: IStaticForcedProps[],
staticLootDist: Record<string, IStaticLootDetails>,
staticAmmoDist: Record<string, IStaticAmmoDetails[]>,
locationName: string,
): IStaticContainerData

Choose loot to put into a static container based on weighting Handle forced items + seasonal item removal when not in season

protected
createDynamicLootItem(
chosenComposedKey: string,
spawnPoint: Spawnpoint,
staticAmmoDist: Record<string, IStaticAmmoDetails[]>,
): IContainerItem

Create array of item (with child items) and return

protected
createStaticLootItem(
chosenTpl: string,
staticAmmoDist: Record<string, IStaticAmmoDetails[]>,
parentId?: string,
): IContainerItem
protected
getContainerMapping(containerTpl: string): number[][]

Get a 2d grid of a containers item slots

protected
getContainersByProbabilty(groupId: string, containerData: IContainerGroupCount): string[]

Choose a number of containers based on their probabilty value to fulfil the desired count in containerData.chosenCount

protected
getGroupIdToContainerMappings(staticContainerGroupData: IStaticContainer | Record<string, IContainerMinMax>, staticContainersOnMap: IStaticContainerData[]): Record<string, IContainerGroupCount>

Get a mapping of each groupid and the containers in that group + count of containers to spawn on map

Get containers with 100% spawn rate or have a type on the randomistion ignore list

protected
getItemInArray(items: Item[], chosenTpl: string): Item

Find an item in array by its _tpl, handle differently if chosenTpl is a weapon

protected
getLooseLootMultiplerForLocation(location: string): number
protected
getPossibleLootItemsForContainer(containerTypeId: string, staticLootDist: Record<string, IStaticLootDetails>): ProbabilityObjectArray<string, number>

Get all possible loot items that can be placed into a container Do not add seasonal items if found + current date is inside seasonal event

Get containers with a non-100% chance to spawn OR are NOT on the container type randomistion blacklist

protected
getStaticLootMultiplerForLocation(location: string): number
protected
getWeightedCountOfContainerItems(
containerTypeId: string,
staticLootDist: Record<string, IStaticLootDetails>,
locationName: string,
): number

Look up a containers itemcountDistribution data and choose an item count based on the found weights

protected
reparentItemAndChildren(itemWithChildren: Item[], newId?: string): void

Replace the _id value for base item + all children items parentid value

generateDynamicLoot(
dynamicLootDist: ILooseLoot,
staticAmmoDist: Record<string, IStaticAmmoDetails[]>,
locationName: string,
): SpawnpointTemplate[]

Create array of loose + forced loot using probability system

generateStaticContainers(locationBase: ILocationBase, staticAmmoDist: Record<string, IStaticAmmoDetails[]>): SpawnpointTemplate[]

Create an array of container objects with randomised loot