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

Constructors

new
BotWeaponGenerator(
jsonUtil: JsonUtil,
logger: ILogger,
hashUtil: HashUtil,
databaseServer: DatabaseServer,
itemHelper: ItemHelper,
weightedRandomHelper: WeightedRandomHelper,
botGeneratorHelper: BotGeneratorHelper,
randomUtil: RandomUtil,
configServer: ConfigServer,
botWeaponGeneratorHelper: BotWeaponGeneratorHelper,
botWeaponModLimitService: BotWeaponModLimitService,
botEquipmentModGenerator: BotEquipmentModGenerator,
localisationService: LocalisationService,
repairService: RepairService,
inventoryMagGenComponents: IInventoryMagGen[],
)

Properties

protected
botConfig: IBotConfig
protected
botEquipmentModGenerator: BotEquipmentModGenerator
protected
botGeneratorHelper: BotGeneratorHelper
protected
botWeaponGeneratorHelper: BotWeaponGeneratorHelper
protected
botWeaponModLimitService: BotWeaponModLimitService
protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
hashUtil: HashUtil
protected
inventoryMagGenComponents: IInventoryMagGen[]
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
readonly
modMagazineSlotId: string
protected
pmcConfig: IPmcConfig
protected
randomUtil: RandomUtil
protected
repairConfig: IRepairConfig
protected
repairService: RepairService
protected
weightedRandomHelper: WeightedRandomHelper

Methods

protected
addAmmoToSecureContainer(
stackCount: number,
ammoTpl: string,
stackSize: number,
inventory: PmcInventory,
): void

Add ammo to the secure container

protected
addCartridgeToChamber(
weaponWithModsArray: Item[],
ammoTpl: string,
chamberSlotIds: string[],
): void

Insert a cartridge(s) into a weapon Handles all chambers - patron_in_weapon, patron_in_weapon_000 etc

protected
addOrUpdateMagazinesChildWithAmmo(
weaponWithMods: Item[],
magazine: Item,
chosenAmmoTpl: string,
magazineTemplate: ITemplateItem,
): void

Add cartridge item to weapon Item array, if it already exists, update

protected
addUbglGrenadesToBotInventory(
weaponMods: Item[],
generatedWeaponResult: GenerateWeaponResult,
inventory: PmcInventory,
): void

Add Grendaes for UBGL to bots vest and secure container

protected
constructWeaponBaseArray(
weaponTpl: string,
weaponParentId: string,
equipmentSlot: string,
weaponItemTemplate: ITemplateItem,
botRole: string,
): Item[]

Create array with weapon base as only element and add additional properties based on weapon type

protected
fillCamorasWithAmmo(
weaponMods: Item[],
magazineId: string,
ammoTpl: string,
): void

Fill each Camora with a bullet

protected
fillExistingMagazines(
weaponMods: Item[],
magazine: Item,
cartridgeTpl: string,
): void

Fill existing magazines to full, while replacing their contents with specified ammo

protected
fillUbgl(
weaponMods: Item[],
ubglMod: Item,
ubglAmmoTpl: string,
): void

Add desired ammo tpl as item to weaponmods array, placed as child to UBGL

protected
getMagazineTplFromWeaponTemplate(
weaponMods: Item[],
weaponTemplate: ITemplateItem,
botRole: string,
): string

Get a weapons magazine tpl from a weapon template

protected
getPresetWeaponMods(
weaponTpl: string,
equipmentSlot: string,
weaponParentId: string,
itemTemplate: ITemplateItem,
botRole: string,
): Item[]

Get the mods necessary to kit out a weapon to its preset level

protected
getWeaponCaliber(weaponTemplate: ITemplateItem): string

Get a weapons compatible cartridge caliber

protected
getWeightedCompatibleAmmo(ammo: Record<string, Record<string, number>>, weaponTemplate: ITemplateItem): string

Finds and return a compatible ammo tpl based on the bots ammo weightings (x.json/inventory/equipment/ammo)

protected
isWeaponValid(weaponItemArray: Item[], botRole: string): boolean

Checks if all required slots are occupied on a weapon and all it's mods

addExtraMagazinesToInventory(
generatedWeaponResult: GenerateWeaponResult,
magWeights: GenerationData,
inventory: PmcInventory,
botRole: string,
): void

Generates extra magazines or bullets (if magazine is internal) and adds them to TacticalVest and Pockets. Additionally, adds extra bullets to SecuredContainer

generateRandomWeapon(
sessionId: string,
equipmentSlot: string,
botTemplateInventory: Inventory,
weaponParentId: string,
modChances: ModsChances,
botRole: string,
isPmc: boolean,
botLevel: number,
): GenerateWeaponResult

Pick a random weapon based on weightings and generate a functional weapon

generateWeaponByTpl(
sessionId: string,
weaponTpl: string,
equipmentSlot: string,
botTemplateInventory: Inventory,
weaponParentId: string,
modChances: ModsChances,
botRole: string,
isPmc: boolean,
botLevel: number,
): GenerateWeaponResult

Generated a weapon based on the supplied weapon tpl

pickWeightedWeaponTplFromPool(equipmentSlot: string, botTemplateInventory: Inventory): string

Get a random weighted weapon from a bots pool of weapons