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

Constructors

new
BotEquipmentModGenerator(
logger: ILogger,
jsonUtil: JsonUtil,
hashUtil: HashUtil,
randomUtil: RandomUtil,
probabilityHelper: ProbabilityHelper,
databaseServer: DatabaseServer,
itemHelper: ItemHelper,
botEquipmentFilterService: BotEquipmentFilterService,
itemFilterService: ItemFilterService,
profileHelper: ProfileHelper,
botWeaponModLimitService: BotWeaponModLimitService,
botHelper: BotHelper,
botGeneratorHelper: BotGeneratorHelper,
botWeaponGeneratorHelper: BotWeaponGeneratorHelper,
weightedRandomHelper: WeightedRandomHelper,
presetHelper: PresetHelper,
localisationService: LocalisationService,
botEquipmentModPoolService: BotEquipmentModPoolService,
configServer: ConfigServer,
)

Properties

protected
botConfig: IBotConfig
protected
botEquipmentFilterService: BotEquipmentFilterService
protected
botEquipmentModPoolService: BotEquipmentModPoolService
protected
botGeneratorHelper: BotGeneratorHelper
protected
botHelper: BotHelper
protected
botWeaponGeneratorHelper: BotWeaponGeneratorHelper
protected
botWeaponModLimitService: BotWeaponModLimitService
protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
hashUtil: HashUtil
protected
itemFilterService: ItemFilterService
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
presetHelper: PresetHelper
protected
probabilityHelper: ProbabilityHelper
protected
profileHelper: ProfileHelper
protected
randomUtil: RandomUtil
protected
weightedRandomHelper: WeightedRandomHelper

Methods

protected
addCompatibleModsForProvidedMod(
desiredSlotName: string,
modTemplate: ITemplateItem,
modPool: Mods,
botEquipBlacklist: EquipmentFilterDetails,
): void

Find mod tpls of a provided type and add to modPool

protected
adjustSlotSpawnChances(
modSpawnChances: ModsChances,
modSlotsToAdjust: string[],
newChancePercent: number,
): void

Set mod spawn chances to defined amount

protected
chooseModToPutIntoSlot(
modSlot: string,
isRandomisableSlot: boolean,
botWeaponSightWhitelist: Record<string, string[]>,
botEquipBlacklist: EquipmentFilterDetails,
itemModPool: Record<string, string[]>,
weapon: Item[],
ammoTpl: string,
parentTemplate: ITemplateItem,
modSpawnResult: ModSpawn,
): [boolean, ITemplateItem]
protected
createModItem(
modId: string,
modTpl: string,
parentId: string,
modSlot: string,
modTemplate: ITemplateItem,
botRole: string,
): Item

Create a mod item with parameters as properties

protected
fillCamora(
items: Item[],
modPool: Mods,
parentId: string,
parentTemplate: ITemplateItem,
): void

With the shotgun revolver (60db29ce99594040e04c4a27) 12.12 introduced CylinderMagazines. Those magazines (e.g. 60dc519adf4c47305f6d410d) have a "Cartridges" entry with a _max_count=0. Ammo is not put into the magazine directly but assigned to the magazine's slots: The "camora_xxx" slots. This function is a helper called by generateModsForItem for mods with parent type "CylinderMagazine"

protected
filterPlateModsForSlotByLevel(
modSlot: string,
existingPlateTplPool: string[],
armorItem: ITemplateItem,
): IFilterPlateModsForSlotByLevelResult

Filter a bots plate pool based on its current level

protected
filterSightsByWeaponType(
weapon: Item,
scopes: string[],
botWeaponSightWhitelist: Record<string, string[]>,
): string[]

Filter out non-whitelisted weapon scopes Controlled by bot.json weaponSightWhitelist e.g. filter out rifle scopes from SMGs

protected
filterWeaponModsByBlacklist(
allowedMods: string[],
botEquipBlacklist: EquipmentFilterDetails,
modSlot: string,
): string[]

Take a list of tpls and filter out blacklisted values using itemFilterService + botEquipmentBlacklist

protected
getAmmoContainers(): string[]

Get a list of containers that hold ammo e.g. mod_magazine / patron_in_weapon_000

protected
getDynamicModPool(
parentItemId: string,
modSlot: string,
botEquipBlacklist: EquipmentFilterDetails,
): string[]

Get the possible items that fit a slot

protected
getMatchingPreset(weaponTemplate: ITemplateItem, parentItemTpl: string): IPreset

Get default preset for weapon, get specific weapon presets for edge cases (mp5/silenced dvl)

protected
getModItemSlotFromDb(modSlot: string, parentTemplate: ITemplateItem): Slot

Get a Slot property for an item (chamber/cartridge/slot)

protected
getModPoolForSlot(
itemModPool: Record<string, string[]>,
modSpawnResult: ModSpawn,
parentTemplate: ITemplateItem,
weaponTemplate: ITemplateItem,
modSlot: string,
botEquipBlacklist: EquipmentFilterDetails,
isRandomisableSlot: boolean,
): string[]

Filter mod pool down based on various criteria: Is slot flagged as randomisable Is slot required Is slot flagged as default mod only

protected
getRandomModTplFromItemDb(
modTpl: string,
parentSlot: Slot,
modSlot: string,
items: Item[],
): string

Get a random mod from an items compatible mods Filter array

protected
isModValidForSlot(
modToAdd: [boolean, ITemplateItem],
slotAddedToTemplate: Slot,
modSlot: string,
parentTemplate: ITemplateItem,
botRole: string,
): boolean

Check if mod exists in db + is for a required slot

protected
mergeCamoraPoolsTogether(camorasWithShells: Record<string, string[]>): string[]

Take a record of camoras and merge the compatible shells into one array

protected
modIsFrontOrRearSight(modSlot: string, tpl: string): boolean

Is this modslot a front or rear sight

protected
modSlotCanHoldMuzzleDevices(modSlot: string, modsParentId: string): boolean
protected
modSlotCanHoldScope(modSlot: string, modsParentId: string): boolean

Does the provided mod details show the mod can hold a scope

protected
pickWeaponModTplForSlotFromPool(
modPool: string[],
parentSlot: Slot,
modSpawnResult: ModSpawn,
weapon: Item[],
modSlotname: string,
): IChooseRandomCompatibleModResult
protected
shouldModBeSpawned(
itemSlot: Slot,
modSlot: string,
modSpawnChances: ModsChances,
botEquipConfig: EquipmentFilters,
): ModSpawn

Randomly choose if a mod should be spawned, 100% for required mods OR mod is ammo slot

protected
sortModKeys(unsortedKeys: string[]): string[]
protected
weaponModComboIsIncompatible(weapon: Item[], modTpl: string): boolean

Temp fix to prevent certain combinations of weapons with mods that are known to be incompatible

generateModsForEquipment(
equipment: Item[],
parentId: string,
parentTemplate: ITemplateItem,
shouldForceSpawn?: boolean,
): Item[]

Check mods are compatible and add to array

generateModsForWeapon(
sessionId: string,
weapon: Item[],
modPool: Mods,
weaponId: string,
parentTemplate: ITemplateItem,
modSpawnChances: ModsChances,
ammoTpl: string,
botRole: string,
botLevel: number,
modLimits: BotModLimits,
botEquipmentRole: string,
): Item[]

Add mods to a weapon using the provided mod pool