Initial release for SPT 3.9
This commit is contained in:
50
types/helpers/AssortHelper.d.ts
vendored
Normal file
50
types/helpers/AssortHelper.d.ts
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { QuestHelper } from "@spt/helpers/QuestHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { ITraderAssort } from "@spt/models/eft/common/tables/ITrader";
|
||||
import { QuestStatus } from "@spt/models/enums/QuestStatus";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
export declare class AssortHelper {
|
||||
protected logger: ILogger;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected localisationService: LocalisationService;
|
||||
protected questHelper: QuestHelper;
|
||||
constructor(logger: ILogger, itemHelper: ItemHelper, databaseServer: DatabaseServer, localisationService: LocalisationService, questHelper: QuestHelper);
|
||||
/**
|
||||
* Remove assorts from a trader that have not been unlocked yet (via player completing corresponding quest)
|
||||
* @param pmcProfile Player profile
|
||||
* @param traderId Traders id the assort belongs to
|
||||
* @param traderAssorts All assort items from same trader
|
||||
* @param mergedQuestAssorts Dict of quest assort to quest id unlocks for all traders (key = started/failed/complete)
|
||||
* @returns Assort items minus locked quest assorts
|
||||
*/
|
||||
stripLockedQuestAssort(pmcProfile: IPmcData, traderId: string, traderAssorts: ITraderAssort, mergedQuestAssorts: Record<string, Record<string, string>>, flea?: boolean): ITraderAssort;
|
||||
/**
|
||||
* Get a quest id + the statuses quest can be in to unlock assort
|
||||
* @param mergedQuestAssorts quest assorts to search for assort id
|
||||
* @param assortId Assort to look for linked quest id
|
||||
* @returns quest id + array of quest status the assort should show for
|
||||
*/
|
||||
protected getQuestIdAndStatusThatShowAssort(mergedQuestAssorts: Record<string, Record<string, string>>, assortId: string): {
|
||||
questId: string;
|
||||
status: QuestStatus[];
|
||||
};
|
||||
/**
|
||||
* Remove assorts from a trader that have not been unlocked yet
|
||||
* @param pmcProfile player profile
|
||||
* @param traderId traders id
|
||||
* @param assort traders assorts
|
||||
* @returns traders assorts minus locked loyalty assorts
|
||||
*/
|
||||
stripLockedLoyaltyAssort(pmcProfile: IPmcData, traderId: string, assort: ITraderAssort): ITraderAssort;
|
||||
/**
|
||||
* Remove an item from an assort
|
||||
* @param assort assort to modify
|
||||
* @param itemID item id to remove from asort
|
||||
* @returns Modified assort
|
||||
*/
|
||||
removeItemFromAssort(assort: ITraderAssort, itemID: string, flea?: boolean): ITraderAssort;
|
||||
}
|
||||
67
types/helpers/BotDifficultyHelper.d.ts
vendored
Normal file
67
types/helpers/BotDifficultyHelper.d.ts
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { BotHelper } from "@spt/helpers/BotHelper";
|
||||
import { Difficulty } from "@spt/models/eft/common/tables/IBotType";
|
||||
import { IPmcConfig } from "@spt/models/spt/config/IPmcConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class BotDifficultyHelper {
|
||||
protected logger: ILogger;
|
||||
protected databaseService: DatabaseService;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected localisationService: LocalisationService;
|
||||
protected botHelper: BotHelper;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected pmcConfig: IPmcConfig;
|
||||
constructor(logger: ILogger, databaseService: DatabaseService, randomUtil: RandomUtil, localisationService: LocalisationService, botHelper: BotHelper, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Get a difficulty object modified to handle fighting other PMCs
|
||||
* @param pmcType 'bear or 'usec'
|
||||
* @param difficulty easy / normal / hard / impossible
|
||||
* @param usecType pmcUSEC
|
||||
* @param bearType pmcBEAR
|
||||
* @returns Difficulty object
|
||||
*/
|
||||
getPmcDifficultySettings(pmcType: "bear" | "usec", difficulty: string, usecType: string, bearType: string): Difficulty;
|
||||
/**
|
||||
* Add bot types to ENEMY_BOT_TYPES array
|
||||
* @param difficultySettings Bot settings to alter
|
||||
* @param typesToAdd Bot types to add to enemy list
|
||||
* @param typeBeingEdited Bot type to ignore and not add to enemy list
|
||||
*/
|
||||
protected addBotToEnemyList(difficultySettings: Difficulty, typesToAdd: string[], typeBeingEdited?: string): void;
|
||||
/**
|
||||
* Configure difficulty settings to be hostile to USEC and BEAR
|
||||
* Look up value in bot.json/chanceSameSideIsHostilePercent
|
||||
* @param difficultySettings pmc difficulty settings
|
||||
*/
|
||||
protected setDifficultyToHostileToBearAndUsec(difficultySettings: Difficulty): void;
|
||||
/**
|
||||
* Get difficulty settings for desired bot type, if not found use assault bot types
|
||||
* @param type bot type to retrieve difficulty of
|
||||
* @param difficulty difficulty to get settings for (easy/normal etc)
|
||||
* @returns Difficulty object
|
||||
*/
|
||||
getBotDifficultySettings(type: string, difficulty: string): Difficulty;
|
||||
/**
|
||||
* Get difficulty settings for a PMC
|
||||
* @param type "usec" / "bear"
|
||||
* @param difficulty what difficulty to retrieve
|
||||
* @returns Difficulty object
|
||||
*/
|
||||
protected getDifficultySettings(type: string, difficulty: string): Difficulty;
|
||||
/**
|
||||
* Translate chosen value from pre-raid difficulty dropdown into bot difficulty value
|
||||
* @param dropDownDifficulty Dropdown difficulty value to convert
|
||||
* @returns bot difficulty
|
||||
*/
|
||||
convertBotDifficultyDropdownToBotDifficulty(dropDownDifficulty: string): string;
|
||||
/**
|
||||
* Choose a random difficulty from - easy/normal/hard/impossible
|
||||
* @returns random difficulty
|
||||
*/
|
||||
chooseRandomDifficulty(): string;
|
||||
}
|
||||
103
types/helpers/BotGeneratorHelper.d.ts
vendored
Normal file
103
types/helpers/BotGeneratorHelper.d.ts
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
import { ApplicationContext } from "@spt/context/ApplicationContext";
|
||||
import { ContainerHelper } from "@spt/helpers/ContainerHelper";
|
||||
import { DurabilityLimitsHelper } from "@spt/helpers/DurabilityLimitsHelper";
|
||||
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { Inventory } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { Item, Repairable, Upd } from "@spt/models/eft/common/tables/IItem";
|
||||
import { Grid, ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { ItemAddedResult } from "@spt/models/enums/ItemAddedResult";
|
||||
import { IChooseRandomCompatibleModResult } from "@spt/models/spt/bots/IChooseRandomCompatibleModResult";
|
||||
import { EquipmentFilters, IBotConfig, IRandomisedResourceValues } from "@spt/models/spt/config/IBotConfig";
|
||||
import { IPmcConfig } from "@spt/models/spt/config/IPmcConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class BotGeneratorHelper {
|
||||
protected logger: ILogger;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected databaseService: DatabaseService;
|
||||
protected durabilityLimitsHelper: DurabilityLimitsHelper;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected inventoryHelper: InventoryHelper;
|
||||
protected containerHelper: ContainerHelper;
|
||||
protected applicationContext: ApplicationContext;
|
||||
protected localisationService: LocalisationService;
|
||||
protected configServer: ConfigServer;
|
||||
protected botConfig: IBotConfig;
|
||||
protected pmcConfig: IPmcConfig;
|
||||
constructor(logger: ILogger, randomUtil: RandomUtil, databaseService: DatabaseService, durabilityLimitsHelper: DurabilityLimitsHelper, itemHelper: ItemHelper, inventoryHelper: InventoryHelper, containerHelper: ContainerHelper, applicationContext: ApplicationContext, localisationService: LocalisationService, configServer: ConfigServer);
|
||||
/**
|
||||
* Adds properties to an item
|
||||
* e.g. Repairable / HasHinge / Foldable / MaxDurability
|
||||
* @param itemTemplate Item extra properties are being generated for
|
||||
* @param botRole Used by weapons to randomize the durability values. Null for non-equipped items
|
||||
* @returns Item Upd object with extra properties
|
||||
*/
|
||||
generateExtraPropertiesForItem(itemTemplate: ITemplateItem, botRole?: string): {
|
||||
upd?: Upd;
|
||||
};
|
||||
/**
|
||||
* Randomize the HpResource for bots e.g (245/400 resources)
|
||||
* @param maxResource Max resource value of medical items
|
||||
* @param randomizationValues Value provided from config
|
||||
* @returns Randomized value from maxHpResource
|
||||
*/
|
||||
protected getRandomizedResourceValue(maxResource: number, randomizationValues: IRandomisedResourceValues): number;
|
||||
/**
|
||||
* Get the chance for the weapon attachment or helmet equipment to be set as activated
|
||||
* @param botRole role of bot with weapon/helmet
|
||||
* @param setting the setting of the weapon attachment/helmet equipment to be activated
|
||||
* @param defaultValue default value for the chance of activation if the botrole or bot equipment role is undefined
|
||||
* @returns Percent chance to be active
|
||||
*/
|
||||
protected getBotEquipmentSettingFromConfig(botRole: string | undefined, setting: keyof EquipmentFilters, defaultValue: number): number;
|
||||
/**
|
||||
* Create a repairable object for a weapon that containers durability + max durability properties
|
||||
* @param itemTemplate weapon object being generated for
|
||||
* @param botRole type of bot being generated for
|
||||
* @returns Repairable object
|
||||
*/
|
||||
protected generateWeaponRepairableProperties(itemTemplate: ITemplateItem, botRole?: string): Repairable;
|
||||
/**
|
||||
* Create a repairable object for an armor that containers durability + max durability properties
|
||||
* @param itemTemplate weapon object being generated for
|
||||
* @param botRole type of bot being generated for
|
||||
* @returns Repairable object
|
||||
*/
|
||||
protected generateArmorRepairableProperties(itemTemplate: ITemplateItem, botRole?: string): Repairable;
|
||||
isWeaponModIncompatibleWithCurrentMods(itemsEquipped: Item[], tplToCheck: string, modSlot: string): IChooseRandomCompatibleModResult;
|
||||
/**
|
||||
* Can item be added to another item without conflict
|
||||
* @param itemsEquipped Items to check compatibilities with
|
||||
* @param tplToCheck Tpl of the item to check for incompatibilities
|
||||
* @param equipmentSlot Slot the item will be placed into
|
||||
* @returns false if no incompatibilities, also has incompatibility reason
|
||||
*/
|
||||
isItemIncompatibleWithCurrentItems(itemsEquipped: Item[], tplToCheck: string, equipmentSlot: string): IChooseRandomCompatibleModResult;
|
||||
/**
|
||||
* Convert a bots role to the equipment role used in config/bot.json
|
||||
* @param botRole Role to convert
|
||||
* @returns Equipment role (e.g. pmc / assault / bossTagilla)
|
||||
*/
|
||||
getBotEquipmentRole(botRole: string): string;
|
||||
/**
|
||||
* Adds an item with all its children into specified equipmentSlots, wherever it fits.
|
||||
* @param equipmentSlots Slot to add item+children into
|
||||
* @param rootItemId Root item id to use as mod items parentid
|
||||
* @param rootItemTplId Root itms tpl id
|
||||
* @param itemWithChildren Item to add
|
||||
* @param inventory Inventory to add item+children into
|
||||
* @returns ItemAddedResult result object
|
||||
*/
|
||||
addItemWithChildrenToEquipmentSlot(equipmentSlots: string[], rootItemId: string, rootItemTplId: string, itemWithChildren: Item[], inventory: Inventory, containersIdFull?: Set<string>): ItemAddedResult;
|
||||
/**
|
||||
* Is the provided item allowed inside a container
|
||||
* @param slotGrid Items sub-grid we want to place item inside
|
||||
* @param itemTpl Item tpl being placed
|
||||
* @returns True if allowed
|
||||
*/
|
||||
protected itemAllowedInContainer(slotGrid: Grid, itemTpl: string): boolean;
|
||||
}
|
||||
80
types/helpers/BotHelper.d.ts
vendored
Normal file
80
types/helpers/BotHelper.d.ts
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import { MinMax } from "@spt/models/common/MinMax";
|
||||
import { Difficulty, IBotType } from "@spt/models/eft/common/tables/IBotType";
|
||||
import { EquipmentFilters, IBotConfig, RandomisationDetails } from "@spt/models/spt/config/IBotConfig";
|
||||
import { IPmcConfig } from "@spt/models/spt/config/IPmcConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class BotHelper {
|
||||
protected logger: ILogger;
|
||||
protected databaseService: DatabaseService;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected configServer: ConfigServer;
|
||||
protected botConfig: IBotConfig;
|
||||
protected pmcConfig: IPmcConfig;
|
||||
constructor(logger: ILogger, databaseService: DatabaseService, randomUtil: RandomUtil, configServer: ConfigServer);
|
||||
/**
|
||||
* Get a template object for the specified botRole from bots.types db
|
||||
* @param role botRole to get template for
|
||||
* @returns IBotType object
|
||||
*/
|
||||
getBotTemplate(role: string): IBotType;
|
||||
/**
|
||||
* Is the passed in bot role a PMC (usec/bear/pmc)
|
||||
* @param botRole bot role to check
|
||||
* @returns true if is pmc
|
||||
*/
|
||||
isBotPmc(botRole: string): boolean;
|
||||
isBotBoss(botRole: string): boolean;
|
||||
isBotFollower(botRole: string): boolean;
|
||||
/**
|
||||
* Add a bot to the FRIENDLY_BOT_TYPES array
|
||||
* @param difficultySettings bot settings to alter
|
||||
* @param typeToAdd bot type to add to friendly list
|
||||
*/
|
||||
addBotToFriendlyList(difficultySettings: Difficulty, typeToAdd: string): void;
|
||||
/**
|
||||
* Add a bot to the REVENGE_BOT_TYPES array
|
||||
* @param difficultySettings bot settings to alter
|
||||
* @param typesToAdd bot type to add to revenge list
|
||||
*/
|
||||
addBotToRevengeList(difficultySettings: Difficulty, typesToAdd: string[]): void;
|
||||
/**
|
||||
* Choose if a bot should become a PMC by checking if bot type is allowed to become a Pmc in botConfig.convertFromChances and doing a random int check
|
||||
* @param botRole the bot role to check if should be a pmc
|
||||
* @returns true if should be a pmc
|
||||
*/
|
||||
shouldBotBePmc(botRole: string): boolean;
|
||||
rollChanceToBePmc(role: string, botConvertMinMax: MinMax): boolean;
|
||||
/**
|
||||
* is the provided role a PMC, case-agnostic
|
||||
* @param botRole Role to check
|
||||
* @returns True if role is PMC
|
||||
*/
|
||||
botRoleIsPmc(botRole: string): boolean;
|
||||
/**
|
||||
* Get randomization settings for bot from config/bot.json
|
||||
* @param botLevel level of bot
|
||||
* @param botEquipConfig bot equipment json
|
||||
* @returns RandomisationDetails
|
||||
*/
|
||||
getBotRandomizationDetails(botLevel: number, botEquipConfig: EquipmentFilters): RandomisationDetails | undefined;
|
||||
/**
|
||||
* Choose between pmcBEAR and pmcUSEC at random based on the % defined in pmcConfig.isUsec
|
||||
* @returns pmc role
|
||||
*/
|
||||
getRandomizedPmcRole(): string;
|
||||
/**
|
||||
* Get the corresponding side when pmcBEAR or pmcUSEC is passed in
|
||||
* @param botRole role to get side for
|
||||
* @returns side (usec/bear)
|
||||
*/
|
||||
getPmcSideByRole(botRole: string): string;
|
||||
/**
|
||||
* Get a randomized PMC side based on bot config value 'isUsec'
|
||||
* @returns pmc side as string
|
||||
*/
|
||||
protected getRandomizedPmcSide(): string;
|
||||
getPmcNicknameOfMaxLength(userId: string, maxLength: number): string;
|
||||
}
|
||||
65
types/helpers/BotWeaponGeneratorHelper.d.ts
vendored
Normal file
65
types/helpers/BotWeaponGeneratorHelper.d.ts
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { BotGeneratorHelper } from "@spt/helpers/BotGeneratorHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { WeightedRandomHelper } from "@spt/helpers/WeightedRandomHelper";
|
||||
import { Inventory } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { GenerationData } from "@spt/models/eft/common/tables/IBotType";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { EquipmentSlots } from "@spt/models/enums/EquipmentSlots";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class BotWeaponGeneratorHelper {
|
||||
protected logger: ILogger;
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected hashUtil: HashUtil;
|
||||
protected weightedRandomHelper: WeightedRandomHelper;
|
||||
protected botGeneratorHelper: BotGeneratorHelper;
|
||||
protected localisationService: LocalisationService;
|
||||
constructor(logger: ILogger, databaseServer: DatabaseServer, itemHelper: ItemHelper, randomUtil: RandomUtil, hashUtil: HashUtil, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, localisationService: LocalisationService);
|
||||
/**
|
||||
* Get a randomized number of bullets for a specific magazine
|
||||
* @param magCounts Weights of magazines
|
||||
* @param magTemplate magazine to generate bullet count for
|
||||
* @returns bullet count number
|
||||
*/
|
||||
getRandomizedBulletCount(magCounts: GenerationData, magTemplate: ITemplateItem): number;
|
||||
/**
|
||||
* Get a randomized count of magazines
|
||||
* @param magCounts min and max value returned value can be between
|
||||
* @returns numerical value of magazine count
|
||||
*/
|
||||
getRandomizedMagazineCount(magCounts: GenerationData): number;
|
||||
/**
|
||||
* Is this magazine cylinder related (revolvers and grenade launchers)
|
||||
* @param magazineParentName the name of the magazines parent
|
||||
* @returns true if it is cylinder related
|
||||
*/
|
||||
magazineIsCylinderRelated(magazineParentName: string): boolean;
|
||||
/**
|
||||
* Create a magazine using the parameters given
|
||||
* @param magazineTpl Tpl of the magazine to create
|
||||
* @param ammoTpl Ammo to add to magazine
|
||||
* @param magTemplate template object of magazine
|
||||
* @returns Item array
|
||||
*/
|
||||
createMagazineWithAmmo(magazineTpl: string, ammoTpl: string, magTemplate: ITemplateItem): Item[];
|
||||
/**
|
||||
* Add a specific number of cartridges to a bots inventory (defaults to vest and pockets)
|
||||
* @param ammoTpl Ammo tpl to add to vest/pockets
|
||||
* @param cartridgeCount number of cartridges to add to vest/pockets
|
||||
* @param inventory bot inventory to add cartridges to
|
||||
* @param equipmentSlotsToAddTo what equipment slots should bullets be added into
|
||||
*/
|
||||
addAmmoIntoEquipmentSlots(ammoTpl: string, cartridgeCount: number, inventory: Inventory, equipmentSlotsToAddTo?: EquipmentSlots[]): void;
|
||||
/**
|
||||
* Get a weapons default magazine template id
|
||||
* @param weaponTemplate weapon to get default magazine for
|
||||
* @returns tpl of magazine
|
||||
*/
|
||||
getWeaponsDefaultMagazineTpl(weaponTemplate: ITemplateItem): string;
|
||||
}
|
||||
39
types/helpers/ContainerHelper.d.ts
vendored
Normal file
39
types/helpers/ContainerHelper.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
export declare class FindSlotResult {
|
||||
success: boolean;
|
||||
x?: number;
|
||||
y?: number;
|
||||
rotation: boolean;
|
||||
constructor(success?: boolean, x?: number, y?: number, rotation?: boolean);
|
||||
}
|
||||
export declare class ContainerHelper {
|
||||
/**
|
||||
* Finds a slot for an item in a given 2D container map
|
||||
* @param container2D Array of container with slots filled/free
|
||||
* @param itemWidth Width of item
|
||||
* @param itemHeight Height of item
|
||||
* @returns Location to place item in container
|
||||
*/
|
||||
findSlotForItem(container2D: number[][], itemWidth: number, itemHeight: number): FindSlotResult;
|
||||
/**
|
||||
* Find a slot inside a container an item can be placed in
|
||||
* @param container2D Container to find space in
|
||||
* @param containerX Container x size
|
||||
* @param containerY Container y size
|
||||
* @param x ???
|
||||
* @param y ???
|
||||
* @param itemW Items width
|
||||
* @param itemH Items height
|
||||
* @returns True - slot found
|
||||
*/
|
||||
protected locateSlot(container2D: number[][], containerX: number, containerY: number, x: number, y: number, itemW: number, itemH: number): boolean;
|
||||
/**
|
||||
* Find a free slot for an item to be placed at
|
||||
* @param container2D Container to place item in
|
||||
* @param x Container x size
|
||||
* @param y Container y size
|
||||
* @param itemW Items width
|
||||
* @param itemH Items height
|
||||
* @param rotate is item rotated
|
||||
*/
|
||||
fillContainerMapWithItem(container2D: number[][], x: number, y: number, itemW: number, itemH: number, rotate: boolean): void;
|
||||
}
|
||||
16
types/helpers/Dialogue/AbstractDialogueChatBot.d.ts
vendored
Normal file
16
types/helpers/Dialogue/AbstractDialogueChatBot.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { IChatCommand } from "@spt/helpers/Dialogue/Commando/IChatCommand";
|
||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
export declare abstract class AbstractDialogueChatBot implements IDialogueChatBot {
|
||||
protected logger: ILogger;
|
||||
protected mailSendService: MailSendService;
|
||||
protected chatCommands: IChatCommand[];
|
||||
constructor(logger: ILogger, mailSendService: MailSendService, chatCommands: IChatCommand[]);
|
||||
registerChatCommand(chatCommand: IChatCommand): void;
|
||||
abstract getChatBot(): IUserDialogInfo;
|
||||
protected abstract getUnrecognizedCommandMessage(): string;
|
||||
handleMessage(sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
8
types/helpers/Dialogue/Commando/IChatCommand.d.ts
vendored
Normal file
8
types/helpers/Dialogue/Commando/IChatCommand.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
export interface IChatCommand {
|
||||
getCommandPrefix(): string;
|
||||
getCommandHelp(command: string): string;
|
||||
getCommands(): Set<string>;
|
||||
handle(command: string, commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
17
types/helpers/Dialogue/Commando/SptCommandoCommands.d.ts
vendored
Normal file
17
types/helpers/Dialogue/Commando/SptCommandoCommands.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { IChatCommand } from "@spt/helpers/Dialogue/Commando/IChatCommand";
|
||||
import { ISptCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/ISptCommand";
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
export declare class SptCommandoCommands implements IChatCommand {
|
||||
protected configServer: ConfigServer;
|
||||
protected localisationService: LocalisationService;
|
||||
protected sptCommands: ISptCommand[];
|
||||
constructor(configServer: ConfigServer, localisationService: LocalisationService, sptCommands: ISptCommand[]);
|
||||
registerSptCommandoCommand(command: ISptCommand): void;
|
||||
getCommandHelp(command: string): string;
|
||||
getCommandPrefix(): string;
|
||||
getCommands(): Set<string>;
|
||||
handle(command: string, commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
47
types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts
vendored
Normal file
47
types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { SavedCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/GiveCommand/SavedCommand";
|
||||
import { ISptCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/ISptCommand";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ItemFilterService } from "@spt/services/ItemFilterService";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
export declare class GiveSptCommand implements ISptCommand {
|
||||
protected logger: ILogger;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected hashUtil: HashUtil;
|
||||
protected presetHelper: PresetHelper;
|
||||
protected mailSendService: MailSendService;
|
||||
protected localeService: LocaleService;
|
||||
protected databaseService: DatabaseService;
|
||||
protected itemFilterService: ItemFilterService;
|
||||
protected cloner: ICloner;
|
||||
/**
|
||||
* Regex to account for all these cases:
|
||||
* spt give "item name" 5
|
||||
* spt give templateId 5
|
||||
* spt give en "item name in english" 5
|
||||
* spt give es "nombre en español" 5
|
||||
* spt give 5 <== this is the reply when the algo isn't sure about an item
|
||||
*/
|
||||
private static commandRegex;
|
||||
private static acceptableConfidence;
|
||||
private static excludedPresetItems;
|
||||
protected savedCommand: Map<string, SavedCommand>;
|
||||
constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseService: DatabaseService, itemFilterService: ItemFilterService, cloner: ICloner);
|
||||
getCommand(): string;
|
||||
getCommandHelp(): string;
|
||||
performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string;
|
||||
/**
|
||||
* A "simple" function that checks if an item is supposed to be given to a player or not
|
||||
* @param templateItem the template item to check
|
||||
* @returns true if its obtainable, false if its not
|
||||
*/
|
||||
protected isItemAllowed(templateItem: ITemplateItem): boolean;
|
||||
}
|
||||
6
types/helpers/Dialogue/Commando/SptCommands/GiveCommand/SavedCommand.d.ts
vendored
Normal file
6
types/helpers/Dialogue/Commando/SptCommands/GiveCommand/SavedCommand.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export declare class SavedCommand {
|
||||
quantity: number;
|
||||
potentialItemNames: string[];
|
||||
locale: string;
|
||||
constructor(quantity: number, potentialItemNames: string[], locale: string);
|
||||
}
|
||||
7
types/helpers/Dialogue/Commando/SptCommands/ISptCommand.d.ts
vendored
Normal file
7
types/helpers/Dialogue/Commando/SptCommands/ISptCommand.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
export interface ISptCommand {
|
||||
getCommand(): string;
|
||||
getCommandHelp(): string;
|
||||
performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
36
types/helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.d.ts
vendored
Normal file
36
types/helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { SavedCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/GiveCommand/SavedCommand";
|
||||
import { ISptCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/ISptCommand";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { IProfileChangeEvent } from "@spt/models/spt/dialog/ISendMessageDetails";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
export declare class ProfileSptCommand implements ISptCommand {
|
||||
protected logger: ILogger;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected hashUtil: HashUtil;
|
||||
protected presetHelper: PresetHelper;
|
||||
protected mailSendService: MailSendService;
|
||||
protected localeService: LocaleService;
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected profileHelper: ProfileHelper;
|
||||
/**
|
||||
* Regex to account for all these cases:
|
||||
* spt profile level 20
|
||||
* spt profile skill metabolism 10
|
||||
*/
|
||||
private static commandRegex;
|
||||
protected savedCommand: SavedCommand;
|
||||
constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, profileHelper: ProfileHelper);
|
||||
getCommand(): string;
|
||||
getCommandHelp(): string;
|
||||
performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string;
|
||||
protected handleSkillCommand(skill: string, level: number): IProfileChangeEvent;
|
||||
protected handleLevelCommand(level: number): IProfileChangeEvent;
|
||||
}
|
||||
31
types/helpers/Dialogue/Commando/SptCommands/TraderCommand/TraderSptCommand.d.ts
vendored
Normal file
31
types/helpers/Dialogue/Commando/SptCommands/TraderCommand/TraderSptCommand.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { SavedCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/GiveCommand/SavedCommand";
|
||||
import { ISptCommand } from "@spt/helpers/Dialogue/Commando/SptCommands/ISptCommand";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
export declare class TraderSptCommand implements ISptCommand {
|
||||
protected logger: ILogger;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected hashUtil: HashUtil;
|
||||
protected presetHelper: PresetHelper;
|
||||
protected mailSendService: MailSendService;
|
||||
protected localeService: LocaleService;
|
||||
protected databaseService: DatabaseService;
|
||||
/**
|
||||
* Regex to account for all these cases:
|
||||
* spt trader prapor rep 100
|
||||
* spt trader mechanic spend 1000000
|
||||
*/
|
||||
private static commandRegex;
|
||||
protected savedCommand: SavedCommand;
|
||||
constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseService: DatabaseService);
|
||||
getCommand(): string;
|
||||
getCommandHelp(): string;
|
||||
performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
10
types/helpers/Dialogue/CommandoDialogueChatBot.d.ts
vendored
Normal file
10
types/helpers/Dialogue/CommandoDialogueChatBot.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { AbstractDialogueChatBot } from "@spt/helpers/Dialogue/AbstractDialogueChatBot";
|
||||
import { IChatCommand } from "@spt/helpers/Dialogue/Commando/IChatCommand";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
export declare class CommandoDialogueChatBot extends AbstractDialogueChatBot {
|
||||
constructor(logger: ILogger, mailSendService: MailSendService, chatCommands: IChatCommand[]);
|
||||
getChatBot(): IUserDialogInfo;
|
||||
protected getUnrecognizedCommandMessage(): string;
|
||||
}
|
||||
6
types/helpers/Dialogue/IDialogueChatBot.d.ts
vendored
Normal file
6
types/helpers/Dialogue/IDialogueChatBot.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
export interface IDialogueChatBot {
|
||||
getChatBot(): IUserDialogInfo;
|
||||
handleMessage(sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
27
types/helpers/Dialogue/SptDialogueChatBot.d.ts
vendored
Normal file
27
types/helpers/Dialogue/SptDialogueChatBot.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { IDialogueChatBot } from "@spt/helpers/Dialogue/IDialogueChatBot";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { ISendMessageRequest } from "@spt/models/eft/dialog/ISendMessageRequest";
|
||||
import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||
import { IWeatherConfig } from "@spt/models/spt/config/IWeatherConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { GiftService } from "@spt/services/GiftService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class SptDialogueChatBot implements IDialogueChatBot {
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected mailSendService: MailSendService;
|
||||
protected giftService: GiftService;
|
||||
protected configServer: ConfigServer;
|
||||
protected coreConfig: ICoreConfig;
|
||||
protected weatherConfig: IWeatherConfig;
|
||||
constructor(profileHelper: ProfileHelper, randomUtil: RandomUtil, mailSendService: MailSendService, giftService: GiftService, configServer: ConfigServer);
|
||||
getChatBot(): IUserDialogInfo;
|
||||
/**
|
||||
* Send responses back to player when they communicate with SPT friend on friends list
|
||||
* @param sessionId Session Id
|
||||
* @param request send message request
|
||||
*/
|
||||
handleMessage(sessionId: string, request: ISendMessageRequest): string;
|
||||
}
|
||||
41
types/helpers/DialogueHelper.d.ts
vendored
Normal file
41
types/helpers/DialogueHelper.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { NotificationSendHelper } from "@spt/helpers/NotificationSendHelper";
|
||||
import { NotifierHelper } from "@spt/helpers/NotifierHelper";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { Dialogue, MessagePreview } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
export declare class DialogueHelper {
|
||||
protected logger: ILogger;
|
||||
protected hashUtil: HashUtil;
|
||||
protected saveServer: SaveServer;
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected notifierHelper: NotifierHelper;
|
||||
protected notificationSendHelper: NotificationSendHelper;
|
||||
protected localisationService: LocalisationService;
|
||||
protected itemHelper: ItemHelper;
|
||||
constructor(logger: ILogger, hashUtil: HashUtil, saveServer: SaveServer, databaseServer: DatabaseServer, notifierHelper: NotifierHelper, notificationSendHelper: NotificationSendHelper, localisationService: LocalisationService, itemHelper: ItemHelper);
|
||||
/**
|
||||
* Get the preview contents of the last message in a dialogue.
|
||||
* @param dialogue
|
||||
* @returns MessagePreview
|
||||
*/
|
||||
getMessagePreview(dialogue: Dialogue): MessagePreview;
|
||||
/**
|
||||
* Get the item contents for a particular message.
|
||||
* @param messageID
|
||||
* @param sessionID
|
||||
* @param itemId Item being moved to inventory
|
||||
* @returns
|
||||
*/
|
||||
getMessageItemContents(messageID: string, sessionID: string, itemId: string): Item[];
|
||||
/**
|
||||
* Get the dialogs dictionary for a profile, create if doesnt exist
|
||||
* @param sessionId Session/player id
|
||||
* @returns Dialog dictionary
|
||||
*/
|
||||
getDialogsForProfile(sessionId: string): Record<string, Dialogue>;
|
||||
}
|
||||
54
types/helpers/DurabilityLimitsHelper.d.ts
vendored
Normal file
54
types/helpers/DurabilityLimitsHelper.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { BotHelper } from "@spt/helpers/BotHelper";
|
||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { IBotConfig } from "@spt/models/spt/config/IBotConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class DurabilityLimitsHelper {
|
||||
protected randomUtil: RandomUtil;
|
||||
protected botHelper: BotHelper;
|
||||
protected configServer: ConfigServer;
|
||||
protected botConfig: IBotConfig;
|
||||
constructor(randomUtil: RandomUtil, botHelper: BotHelper, configServer: ConfigServer);
|
||||
/**
|
||||
* Get max durability for a weapon based on bot role
|
||||
* @param itemTemplate UNUSED - Item to get durability for
|
||||
* @param botRole Role of bot to get max durability for
|
||||
* @returns Max durability of weapon
|
||||
*/
|
||||
getRandomizedMaxWeaponDurability(itemTemplate: ITemplateItem, botRole?: string): number;
|
||||
/**
|
||||
* Get max durability value for armor based on bot role
|
||||
* @param itemTemplate Item to get max durability for
|
||||
* @param botRole Role of bot to get max durability for
|
||||
* @returns max durability
|
||||
*/
|
||||
getRandomizedMaxArmorDurability(itemTemplate: ITemplateItem, botRole?: string): number;
|
||||
/**
|
||||
* Get randomised current weapon durability by bot role
|
||||
* @param itemTemplate Unused - Item to get current durability of
|
||||
* @param botRole Role of bot to get current durability for
|
||||
* @param maxDurability Max durability of weapon
|
||||
* @returns Current weapon durability
|
||||
*/
|
||||
getRandomizedWeaponDurability(itemTemplate: ITemplateItem, botRole: string | undefined, maxDurability: number): number;
|
||||
/**
|
||||
* Get randomised current armor durability by bot role
|
||||
* @param itemTemplate Unused - Item to get current durability of
|
||||
* @param botRole Role of bot to get current durability for
|
||||
* @param maxDurability Max durability of armor
|
||||
* @returns Current armor durability
|
||||
*/
|
||||
getRandomizedArmorDurability(itemTemplate: ITemplateItem, botRole: string | undefined, maxDurability: number): number;
|
||||
protected generateMaxWeaponDurability(botRole?: string): number;
|
||||
protected generateMaxPmcArmorDurability(itemMaxDurability: number): number;
|
||||
protected getLowestMaxWeaponFromConfig(botRole?: string): number;
|
||||
protected getHighestMaxWeaponDurabilityFromConfig(botRole?: string): number;
|
||||
protected generateWeaponDurability(botRole: string | undefined, maxDurability: number): number;
|
||||
protected generateArmorDurability(botRole: string | undefined, maxDurability: number): number;
|
||||
protected getMinWeaponDeltaFromConfig(botRole?: string): number;
|
||||
protected getMaxWeaponDeltaFromConfig(botRole?: string): number;
|
||||
protected getMinArmorDeltaFromConfig(botRole?: string): number;
|
||||
protected getMaxArmorDeltaFromConfig(botRole?: string): number;
|
||||
protected getMinArmorLimitPercentFromConfig(botRole?: string): number;
|
||||
protected getMinWeaponLimitPercentFromConfig(botRole?: string): number;
|
||||
}
|
||||
9
types/helpers/GameEventHelper.d.ts
vendored
Normal file
9
types/helpers/GameEventHelper.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ISeasonalEventConfig } from "@spt/models/spt/config/ISeasonalEventConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
export declare class GameEventHelper {
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected configServer: ConfigServer;
|
||||
protected seasonalEventConfig: ISeasonalEventConfig;
|
||||
constructor(databaseServer: DatabaseServer, configServer: ConfigServer);
|
||||
}
|
||||
71
types/helpers/HandbookHelper.d.ts
vendored
Normal file
71
types/helpers/HandbookHelper.d.ts
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { Category } from "@spt/models/eft/common/tables/IHandbookBase";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { IItemConfig } from "@spt/models/spt/config/IItemConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
declare class LookupItem<T, I> {
|
||||
readonly byId: Map<string, T>;
|
||||
readonly byParent: Map<string, I[]>;
|
||||
constructor();
|
||||
}
|
||||
export declare class LookupCollection {
|
||||
readonly items: LookupItem<number, string>;
|
||||
readonly categories: LookupItem<string, string>;
|
||||
constructor();
|
||||
}
|
||||
export declare class HandbookHelper {
|
||||
protected databaseService: DatabaseService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected itemConfig: IItemConfig;
|
||||
protected lookupCacheGenerated: boolean;
|
||||
protected handbookPriceCache: LookupCollection;
|
||||
constructor(databaseService: DatabaseService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Create an in-memory cache of all items with associated handbook price in handbookPriceCache class
|
||||
*/
|
||||
hydrateLookup(): void;
|
||||
/**
|
||||
* Get price from internal cache, if cache empty look up price directly in handbook (expensive)
|
||||
* If no values found, return 0
|
||||
* @param tpl Item tpl to look up price for
|
||||
* @returns price in roubles
|
||||
*/
|
||||
getTemplatePrice(tpl: string): number;
|
||||
getTemplatePriceForItems(items: Item[]): number;
|
||||
/**
|
||||
* Get all items in template with the given parent category
|
||||
* @param parentId
|
||||
* @returns string array
|
||||
*/
|
||||
templatesWithParent(parentId: string): string[];
|
||||
/**
|
||||
* Does category exist in handbook cache
|
||||
* @param category
|
||||
* @returns true if exists in cache
|
||||
*/
|
||||
isCategory(category: string): boolean;
|
||||
/**
|
||||
* Get all items associated with a categories parent
|
||||
* @param categoryParent
|
||||
* @returns string array
|
||||
*/
|
||||
childrenCategories(categoryParent: string): string[];
|
||||
/**
|
||||
* Convert non-roubles into roubles
|
||||
* @param nonRoubleCurrencyCount Currency count to convert
|
||||
* @param currencyTypeFrom What current currency is
|
||||
* @returns Count in roubles
|
||||
*/
|
||||
inRUB(nonRoubleCurrencyCount: number, currencyTypeFrom: string): number;
|
||||
/**
|
||||
* Convert roubles into another currency
|
||||
* @param roubleCurrencyCount roubles to convert
|
||||
* @param currencyTypeTo Currency to convert roubles into
|
||||
* @returns currency count in desired type
|
||||
*/
|
||||
fromRUB(roubleCurrencyCount: number, currencyTypeTo: string): number;
|
||||
getCategoryById(handbookId: string): Category;
|
||||
}
|
||||
export {};
|
||||
60
types/helpers/HealthHelper.d.ts
vendored
Normal file
60
types/helpers/HealthHelper.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { ISyncHealthRequestData } from "@spt/models/eft/health/ISyncHealthRequestData";
|
||||
import { Effects, ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { IHealthConfig } from "@spt/models/spt/config/IHealthConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class HealthHelper {
|
||||
protected logger: ILogger;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected saveServer: SaveServer;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected healthConfig: IHealthConfig;
|
||||
constructor(logger: ILogger, timeUtil: TimeUtil, saveServer: SaveServer, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Resets the profiles vitality/health and vitality/effects properties to their defaults
|
||||
* @param sessionID Session Id
|
||||
* @returns updated profile
|
||||
*/
|
||||
resetVitality(sessionID: string): ISptProfile;
|
||||
/**
|
||||
* Update player profile vitality values with changes from client request object
|
||||
* @param pmcData Player profile
|
||||
* @param request Heal request
|
||||
* @param sessionID Session id
|
||||
* @param addEffects Should effects be added to profile (default - true)
|
||||
* @param deleteExistingEffects Should all prior effects be removed before apply new ones (default - true)
|
||||
*/
|
||||
saveVitality(pmcData: IPmcData, request: ISyncHealthRequestData, sessionID: string, addEffects?: boolean, deleteExistingEffects?: boolean): void;
|
||||
/**
|
||||
* Adjust hydration/energy/temperate and body part hp values in player profile to values in profile.vitality
|
||||
* @param pmcData Profile to update
|
||||
* @param sessionId Session id
|
||||
*/
|
||||
protected saveHealth(pmcData: IPmcData, sessionID: string): void;
|
||||
/**
|
||||
* Save effects to profile
|
||||
* Works by removing all effects and adding them back from profile
|
||||
* Removes empty 'Effects' objects if found
|
||||
* @param pmcData Player profile
|
||||
* @param sessionId Session id
|
||||
* @param bodyPartsWithEffects dict of body parts with effects that should be added to profile
|
||||
* @param addEffects Should effects be added back to profile
|
||||
*/
|
||||
protected saveEffects(pmcData: IPmcData, sessionId: string, bodyPartsWithEffects: Effects, deleteExistingEffects?: boolean): void;
|
||||
/**
|
||||
* Add effect to body part in profile
|
||||
* @param pmcData Player profile
|
||||
* @param effectBodyPart body part to edit
|
||||
* @param effectType Effect to add to body part
|
||||
* @param duration How long the effect has left in seconds (-1 by default, no duration).
|
||||
*/
|
||||
protected addEffect(pmcData: IPmcData, effectBodyPart: string, effectType: string, duration?: number): void;
|
||||
protected isEmpty(map: Record<string, {
|
||||
Time: number;
|
||||
}>): boolean;
|
||||
}
|
||||
290
types/helpers/HideoutHelper.d.ts
vendored
Normal file
290
types/helpers/HideoutHelper.d.ts
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { HideoutArea, IHideoutImprovement, Production, Productive } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { Item, Upd } from "@spt/models/eft/common/tables/IItem";
|
||||
import { StageBonus } from "@spt/models/eft/hideout/IHideoutArea";
|
||||
import { IHideoutContinuousProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutContinuousProductionStartRequestData";
|
||||
import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction";
|
||||
import { IHideoutSingleProductionStartRequestData } from "@spt/models/eft/hideout/IHideoutSingleProductionStartRequestData";
|
||||
import { IHideoutTakeProductionRequestData } from "@spt/models/eft/hideout/IHideoutTakeProductionRequestData";
|
||||
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { SkillTypes } from "@spt/models/enums/SkillTypes";
|
||||
import { IHideoutConfig } from "@spt/models/spt/config/IHideoutConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { PlayerService } from "@spt/services/PlayerService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class HideoutHelper {
|
||||
protected logger: ILogger;
|
||||
protected hashUtil: HashUtil;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected databaseService: DatabaseService;
|
||||
protected eventOutputHolder: EventOutputHolder;
|
||||
protected httpResponse: HttpResponseUtil;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected inventoryHelper: InventoryHelper;
|
||||
protected playerService: PlayerService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
static bitcoinFarm: string;
|
||||
static bitcoinProductionId: string;
|
||||
static waterCollector: string;
|
||||
static maxSkillPoint: number;
|
||||
protected hideoutConfig: IHideoutConfig;
|
||||
constructor(logger: ILogger, hashUtil: HashUtil, timeUtil: TimeUtil, databaseService: DatabaseService, eventOutputHolder: EventOutputHolder, httpResponse: HttpResponseUtil, profileHelper: ProfileHelper, inventoryHelper: InventoryHelper, playerService: PlayerService, localisationService: LocalisationService, itemHelper: ItemHelper, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Add production to profiles' Hideout.Production array
|
||||
* @param pmcData Profile to add production to
|
||||
* @param body Production request
|
||||
* @param sessionID Session id
|
||||
* @returns client response
|
||||
*/
|
||||
registerProduction(pmcData: IPmcData, body: IHideoutSingleProductionStartRequestData | IHideoutContinuousProductionStartRequestData, sessionID: string): IItemEventRouterResponse;
|
||||
/**
|
||||
* This convenience function initializes new Production Object
|
||||
* with all the constants.
|
||||
*/
|
||||
initProduction(recipeId: string, productionTime: number, needFuelForAllProductionTime: boolean): Production;
|
||||
/**
|
||||
* Is the provided object a Production type
|
||||
* @param productive
|
||||
* @returns
|
||||
*/
|
||||
isProductionType(productive: Productive): productive is Production;
|
||||
/**
|
||||
* Apply bonus to player profile given after completing hideout upgrades
|
||||
* @param pmcData Profile to add bonus to
|
||||
* @param bonus Bonus to add to profile
|
||||
*/
|
||||
applyPlayerUpgradesBonuses(pmcData: IPmcData, bonus: StageBonus): void;
|
||||
/**
|
||||
* Process a players hideout, update areas that use resources + increment production timers
|
||||
* @param sessionID Session id
|
||||
*/
|
||||
updatePlayerHideout(sessionID: string): void;
|
||||
/**
|
||||
* Get various properties that will be passed to hideout update-related functions
|
||||
* @param pmcData Player profile
|
||||
* @returns Properties
|
||||
*/
|
||||
protected getHideoutProperties(pmcData: IPmcData): {
|
||||
btcFarmCGs: number;
|
||||
isGeneratorOn: boolean;
|
||||
waterCollectorHasFilter: boolean;
|
||||
};
|
||||
protected doesWaterCollectorHaveFilter(waterCollector: HideoutArea): boolean;
|
||||
/**
|
||||
* Iterate over productions and update their progress timers
|
||||
* @param pmcData Profile to check for productions and update
|
||||
* @param hideoutProperties Hideout properties
|
||||
*/
|
||||
protected updateProductionTimers(pmcData: IPmcData, hideoutProperties: {
|
||||
btcFarmCGs: number;
|
||||
isGeneratorOn: boolean;
|
||||
waterCollectorHasFilter: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Update progress timer for water collector
|
||||
* @param pmcData profile to update
|
||||
* @param productionId id of water collection production to update
|
||||
* @param hideoutProperties Hideout properties
|
||||
*/
|
||||
protected updateWaterCollectorProductionTimer(pmcData: IPmcData, productionId: string, hideoutProperties: {
|
||||
btcFarmCGs?: number;
|
||||
isGeneratorOn: boolean;
|
||||
waterCollectorHasFilter: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Update a productions progress value based on the amount of time that has passed
|
||||
* @param pmcData Player profile
|
||||
* @param prodId Production id being crafted
|
||||
* @param recipe Recipe data being crafted
|
||||
* @param hideoutProperties
|
||||
*/
|
||||
protected updateProductionProgress(pmcData: IPmcData, prodId: string, recipe: IHideoutProduction, hideoutProperties: {
|
||||
btcFarmCGs?: number;
|
||||
isGeneratorOn: boolean;
|
||||
waterCollectorHasFilter?: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Check if a productions progress value matches its corresponding recipes production time value
|
||||
* @param pmcData Player profile
|
||||
* @param prodId Production id
|
||||
* @param recipe Recipe being crafted
|
||||
* @returns progress matches productionTime from recipe
|
||||
*/
|
||||
protected doesProgressMatchProductionTime(pmcData: IPmcData, prodId: string): boolean;
|
||||
/**
|
||||
* Update progress timer for scav case
|
||||
* @param pmcData Profile to update
|
||||
* @param productionId Id of scav case production to update
|
||||
*/
|
||||
protected updateScavCaseProductionTimer(pmcData: IPmcData, productionId: string): void;
|
||||
/**
|
||||
* Iterate over hideout areas that use resources (fuel/filters etc) and update associated values
|
||||
* @param sessionID Session id
|
||||
* @param pmcData Profile to update areas of
|
||||
* @param hideoutProperties hideout properties
|
||||
*/
|
||||
protected updateAreasWithResources(sessionID: string, pmcData: IPmcData, hideoutProperties: {
|
||||
btcFarmCGs: number;
|
||||
isGeneratorOn: boolean;
|
||||
waterCollectorHasFilter: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Decrease fuel from generator slots based on amount of time since last time this occured
|
||||
* @param generatorArea Hideout area
|
||||
* @param pmcData Player profile
|
||||
* @param isGeneratorOn Is the generator turned on since last update
|
||||
*/
|
||||
protected updateFuel(generatorArea: HideoutArea, pmcData: IPmcData, isGeneratorOn: boolean): void;
|
||||
protected updateWaterCollector(sessionId: string, pmcData: IPmcData, area: HideoutArea, hideoutProperties: {
|
||||
btcFarmCGs: number;
|
||||
isGeneratorOn: boolean;
|
||||
waterCollectorHasFilter: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Get craft time and make adjustments to account for dev profile + crafting skill level
|
||||
* @param pmcData Player profile making craft
|
||||
* @param recipeId Recipe being crafted
|
||||
* @param applyHideoutManagementBonus should the hideout mgmt bonus be appled to the calculation
|
||||
* @returns Items craft time with bonuses subtracted
|
||||
*/
|
||||
getAdjustedCraftTimeWithSkills(pmcData: IPmcData, recipeId: string, applyHideoutManagementBonus?: boolean): number;
|
||||
/**
|
||||
* Adjust water filter objects resourceValue or delete when they reach 0 resource
|
||||
* @param waterFilterArea water filter area to update
|
||||
* @param production production object
|
||||
* @param isGeneratorOn is generator enabled
|
||||
* @param pmcData Player profile
|
||||
*/
|
||||
protected updateWaterFilters(waterFilterArea: HideoutArea, production: Production, isGeneratorOn: boolean, pmcData: IPmcData): void;
|
||||
/**
|
||||
* Get an adjusted water filter drain rate based on time elapsed since last run,
|
||||
* handle edge case when craft time has gone on longer than total production time
|
||||
* @param secondsSinceServerTick Time passed
|
||||
* @param totalProductionTime Total time collecting water
|
||||
* @param productionProgress how far water collector has progressed
|
||||
* @param baseFilterDrainRate Base drain rate
|
||||
* @returns drain rate (adjusted)
|
||||
*/
|
||||
protected getTimeAdjustedWaterFilterDrainRate(secondsSinceServerTick: number, totalProductionTime: number, productionProgress: number, baseFilterDrainRate: number): number;
|
||||
/**
|
||||
* Get the water filter drain rate based on hideout bonues player has
|
||||
* @param pmcData Player profile
|
||||
* @returns Drain rate
|
||||
*/
|
||||
protected getWaterFilterDrainRate(pmcData: IPmcData): number;
|
||||
/**
|
||||
* Get the production time in seconds for the desired production
|
||||
* @param prodId Id, e.g. Water collector id
|
||||
* @returns seconds to produce item
|
||||
*/
|
||||
protected getTotalProductionTimeSeconds(prodId: string): number;
|
||||
/**
|
||||
* Create a upd object using passed in parameters
|
||||
* @param stackCount
|
||||
* @param resourceValue
|
||||
* @param resourceUnitsConsumed
|
||||
* @returns Upd
|
||||
*/
|
||||
protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number, isFoundInRaid: boolean): Upd;
|
||||
protected updateAirFilters(airFilterArea: HideoutArea, pmcData: IPmcData, isGeneratorOn: boolean): void;
|
||||
protected updateBitcoinFarm(pmcData: IPmcData, btcFarmCGs: number, isGeneratorOn: boolean): Production | undefined;
|
||||
/**
|
||||
* Add bitcoin object to btc production products array and set progress time
|
||||
* @param btcProd Bitcoin production object
|
||||
* @param coinCraftTimeSeconds Time to craft a bitcoin
|
||||
*/
|
||||
protected addBtcToProduction(btcProd: Production, coinCraftTimeSeconds: number): void;
|
||||
/**
|
||||
* Get number of ticks that have passed since hideout areas were last processed, reduced when generator is off
|
||||
* @param pmcData Player profile
|
||||
* @param isGeneratorOn Is the generator on for the duration of elapsed time
|
||||
* @param recipe Hideout production recipe being crafted we need the ticks for
|
||||
* @returns Amount of time elapsed in seconds
|
||||
*/
|
||||
protected getTimeElapsedSinceLastServerTick(pmcData: IPmcData, isGeneratorOn: boolean, recipe?: IHideoutProduction): number;
|
||||
/**
|
||||
* Get a count of how many possible BTC can be gathered by the profile
|
||||
* @param pmcData Profile to look up
|
||||
* @returns Coin slot count
|
||||
*/
|
||||
protected getBTCSlots(pmcData: IPmcData): number;
|
||||
/**
|
||||
* Get a count of how many additional bitcoins player hideout can hold with elite skill
|
||||
*/
|
||||
protected getEliteSkillAdditionalBitcoinSlotCount(): number;
|
||||
/**
|
||||
* HideoutManagement skill gives a consumption bonus the higher the level
|
||||
* 0.5% per level per 1-51, (25.5% at max)
|
||||
* @param pmcData Profile to get hideout consumption level level from
|
||||
* @returns consumption bonus
|
||||
*/
|
||||
protected getHideoutManagementConsumptionBonus(pmcData: IPmcData): number;
|
||||
/**
|
||||
* Get a multipler based on players skill level and value per level
|
||||
* @param pmcData Player profile
|
||||
* @param skill Player skill from profile
|
||||
* @param valuePerLevel Value from globals.config.SkillsSettings - `PerLevel`
|
||||
* @returns Multipler from 0 to 1
|
||||
*/
|
||||
protected getSkillBonusMultipliedBySkillLevel(pmcData: IPmcData, skill: SkillTypes, valuePerLevel: number): number;
|
||||
/**
|
||||
* @param pmcData Player profile
|
||||
* @param productionTime Time to complete hideout craft in seconds
|
||||
* @param skill Skill bonus to get reduction from
|
||||
* @param amountPerLevel Skill bonus amount to apply
|
||||
* @returns Seconds to reduce craft time by
|
||||
*/
|
||||
getSkillProductionTimeReduction(pmcData: IPmcData, productionTime: number, skill: SkillTypes, amountPerLevel: number): number;
|
||||
isProduction(productive: Productive): productive is Production;
|
||||
/**
|
||||
* Gather crafted BTC from hideout area and add to inventory
|
||||
* Reset production start timestamp if hideout area at full coin capacity
|
||||
* @param pmcData Player profile
|
||||
* @param request Take production request
|
||||
* @param sessionId Session id
|
||||
* @param output Output object to update
|
||||
*/
|
||||
getBTC(pmcData: IPmcData, request: IHideoutTakeProductionRequestData, sessionId: string, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Upgrade hideout wall from starting level to interactable level if necessary stations have been upgraded
|
||||
* @param pmcProfile Profile to upgrade wall in
|
||||
*/
|
||||
unlockHideoutWallInProfile(pmcProfile: IPmcData): void;
|
||||
/**
|
||||
* Hideout improvement is flagged as complete
|
||||
* @param improvement hideout improvement object
|
||||
* @returns true if complete
|
||||
*/
|
||||
protected hideoutImprovementIsComplete(improvement: IHideoutImprovement): boolean;
|
||||
/**
|
||||
* Iterate over hideout improvements not completed and check if they need to be adjusted
|
||||
* @param pmcProfile Profile to adjust
|
||||
*/
|
||||
setHideoutImprovementsToCompleted(pmcProfile: IPmcData): void;
|
||||
/**
|
||||
* Add/remove bonus combat skill based on number of dogtags in place of fame hideout area
|
||||
* @param pmcData Player profile
|
||||
*/
|
||||
applyPlaceOfFameDogtagBonus(pmcData: IPmcData): void;
|
||||
/**
|
||||
* Calculate the raw dogtag combat skill bonus for place of fame based on number of dogtags
|
||||
* Reverse engineered from client code
|
||||
* @param pmcData Player profile
|
||||
* @param activeDogtags Active dogtags in place of fame dogtag slots
|
||||
* @returns combat bonus
|
||||
*/
|
||||
protected getDogtagCombatSkillBonusPercent(pmcData: IPmcData, activeDogtags: Item[]): number;
|
||||
}
|
||||
32
types/helpers/HttpServerHelper.d.ts
vendored
Normal file
32
types/helpers/HttpServerHelper.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { IHttpConfig } from "@spt/models/spt/config/IHttpConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
export declare class HttpServerHelper {
|
||||
protected configServer: ConfigServer;
|
||||
protected httpConfig: IHttpConfig;
|
||||
protected mime: {
|
||||
css: string;
|
||||
bin: string;
|
||||
html: string;
|
||||
jpg: string;
|
||||
js: string;
|
||||
json: string;
|
||||
png: string;
|
||||
svg: string;
|
||||
txt: string;
|
||||
};
|
||||
constructor(configServer: ConfigServer);
|
||||
getMimeText(key: string): string;
|
||||
/**
|
||||
* Combine ip and port into address
|
||||
* @returns url
|
||||
*/
|
||||
buildUrl(): string;
|
||||
/**
|
||||
* Prepend http to the url:port
|
||||
* @returns URI
|
||||
*/
|
||||
getBackendUrl(): string;
|
||||
/** Get websocket url + port */
|
||||
getWebsocketUrl(): string;
|
||||
sendTextJson(resp: any, output: any): void;
|
||||
}
|
||||
162
types/helpers/InRaidHelper.d.ts
vendored
Normal file
162
types/helpers/InRaidHelper.d.ts
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { QuestHelper } from "@spt/helpers/QuestHelper";
|
||||
import { IPmcData, IPostRaidPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { IQuestStatus, TraderInfo } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ISaveProgressRequestData } from "@spt/models/eft/inRaid/ISaveProgressRequestData";
|
||||
import { IInRaidConfig } from "@spt/models/spt/config/IInRaidConfig";
|
||||
import { ILostOnDeathConfig } from "@spt/models/spt/config/ILostOnDeathConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { ProfileFixerService } from "@spt/services/ProfileFixerService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class InRaidHelper {
|
||||
protected logger: ILogger;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected saveServer: SaveServer;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected databaseService: DatabaseService;
|
||||
protected inventoryHelper: InventoryHelper;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected questHelper: QuestHelper;
|
||||
protected paymentHelper: PaymentHelper;
|
||||
protected localisationService: LocalisationService;
|
||||
protected profileFixerService: ProfileFixerService;
|
||||
protected configServer: ConfigServer;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected cloner: ICloner;
|
||||
protected lostOnDeathConfig: ILostOnDeathConfig;
|
||||
protected inRaidConfig: IInRaidConfig;
|
||||
constructor(logger: ILogger, timeUtil: TimeUtil, saveServer: SaveServer, itemHelper: ItemHelper, databaseService: DatabaseService, inventoryHelper: InventoryHelper, profileHelper: ProfileHelper, questHelper: QuestHelper, paymentHelper: PaymentHelper, localisationService: LocalisationService, profileFixerService: ProfileFixerService, configServer: ConfigServer, randomUtil: RandomUtil, cloner: ICloner);
|
||||
/**
|
||||
* Lookup quest item loss from lostOnDeath config
|
||||
* @returns True if items should be removed from inventory
|
||||
*/
|
||||
shouldQuestItemsBeRemovedOnDeath(): boolean;
|
||||
/**
|
||||
* Check items array and add an upd object to money with a stack count of 1
|
||||
* Single stack money items have no upd object and thus no StackObjectsCount, causing issues
|
||||
* @param items Items array to check
|
||||
*/
|
||||
addStackCountToMoneyFromRaid(items: Item[]): void;
|
||||
/**
|
||||
* Reset a profile to a baseline, used post-raid
|
||||
* Reset points earned during session property
|
||||
* Increment exp
|
||||
* @param profileData Profile to update
|
||||
* @param saveProgressRequest post raid save data request data
|
||||
* @param sessionID Session id
|
||||
* @returns Reset profile object
|
||||
*/
|
||||
updateProfileBaseStats(profileData: IPmcData, saveProgressRequest: ISaveProgressRequestData, sessionID: string): void;
|
||||
/**
|
||||
* Reset the skill points earned in a raid to 0, ready for next raid
|
||||
* @param profile Profile to update
|
||||
*/
|
||||
protected resetSkillPointsEarnedDuringRaid(profile: IPmcData): void;
|
||||
/** Check counters are correct in profile */
|
||||
protected validateTaskConditionCounters(saveProgressRequest: ISaveProgressRequestData, profileData: IPmcData): void;
|
||||
/**
|
||||
* Update various serverPMC profile values; quests/limb hp/trader standing with values post-raic
|
||||
* @param pmcData Server PMC profile
|
||||
* @param saveProgressRequest Post-raid request data
|
||||
* @param sessionId Session id
|
||||
*/
|
||||
updatePmcProfileDataPostRaid(pmcData: IPmcData, saveProgressRequest: ISaveProgressRequestData, sessionId: string): void;
|
||||
/**
|
||||
* Update scav quest values on server profile with updated values post-raid
|
||||
* @param scavData Server scav profile
|
||||
* @param saveProgressRequest Post-raid request data
|
||||
* @param sessionId Session id
|
||||
*/
|
||||
updateScavProfileDataPostRaid(scavData: IPmcData, saveProgressRequest: ISaveProgressRequestData, sessionId: string): void;
|
||||
/**
|
||||
* Look for quests with a status different from what it began the raid with
|
||||
* @param sessionId Player id
|
||||
* @param pmcData Player profile
|
||||
* @param preRaidQuests Quests prior to starting raid
|
||||
* @param postRaidProfile Profile sent by client with post-raid quests
|
||||
*/
|
||||
protected processAlteredQuests(sessionId: string, pmcData: IPmcData, preRaidQuests: IQuestStatus[], postRaidProfile: IPostRaidPmcData): void;
|
||||
protected handleFailRestartableQuestStatus(pmcData: IPmcData, postRaidProfile: IPostRaidPmcData, postRaidQuest: IQuestStatus): void;
|
||||
/**
|
||||
* Take body part effects from client profile and apply to server profile
|
||||
* @param saveProgressRequest post-raid request
|
||||
* @param profileData player profile on server
|
||||
*/
|
||||
protected transferPostRaidLimbEffectsToProfile(saveProgressRequest: ISaveProgressRequestData, profileData: IPmcData): void;
|
||||
/**
|
||||
* Adjust server trader settings if they differ from data sent by client
|
||||
* @param tradersServerProfile Server
|
||||
* @param tradersClientProfile Client
|
||||
*/
|
||||
protected applyTraderStandingAdjustments(tradersServerProfile: Record<string, TraderInfo>, tradersClientProfile: Record<string, TraderInfo>): void;
|
||||
/**
|
||||
* Transfer client achievements into profile
|
||||
* @param profile Player pmc profile
|
||||
* @param clientAchievements Achievements from client
|
||||
*/
|
||||
protected updateProfileAchievements(profile: IPmcData, clientAchievements: Record<string, number>): void;
|
||||
/**
|
||||
* Set the SPT inraid location Profile property to 'none'
|
||||
* @param sessionID Session id
|
||||
*/
|
||||
protected setPlayerInRaidLocationStatusToNone(sessionID: string): void;
|
||||
/**
|
||||
* Iterate over inventory items and remove the property that defines an item as Found in Raid
|
||||
* Only removes property if item had FiR when entering raid
|
||||
* @param postRaidProfile profile to update items for
|
||||
* @returns Updated profile with SpawnedInSession removed
|
||||
*/
|
||||
removeSpawnedInSessionPropertyFromItems(postRaidProfile: IPostRaidPmcData): IPostRaidPmcData;
|
||||
/**
|
||||
* Update a players inventory post-raid
|
||||
* Remove equipped items from pre-raid
|
||||
* Add new items found in raid to profile
|
||||
* Store insurance items in profile
|
||||
* @param sessionID Session id
|
||||
* @param serverProfile Profile to update
|
||||
* @param postRaidProfile Profile returned by client after a raid
|
||||
*/
|
||||
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): void;
|
||||
/**
|
||||
* Clear PMC inventory of all items except those that are exempt
|
||||
* Used post-raid to remove items after death
|
||||
* @param pmcData Player profile
|
||||
* @param sessionId Session id
|
||||
*/
|
||||
deleteInventory(pmcData: IPmcData, sessionId: string): void;
|
||||
/**
|
||||
* Get an array of items from a profile that will be lost on death
|
||||
* @param pmcProfile Profile to get items from
|
||||
* @returns Array of items lost on death
|
||||
*/
|
||||
protected getInventoryItemsLostOnDeath(pmcProfile: IPmcData): Item[];
|
||||
/**
|
||||
* Get items in vest/pocket/backpack inventory containers (excluding children)
|
||||
* @param pmcData Player profile
|
||||
* @returns Item array
|
||||
*/
|
||||
protected getBaseItemsInRigPocketAndBackpack(pmcData: IPmcData): Item[];
|
||||
/**
|
||||
* Does the provided items slotId mean its kept on the player after death
|
||||
* @pmcData Player profile
|
||||
* @itemToCheck Item to check should be kept
|
||||
* @returns true if item is kept after death
|
||||
*/
|
||||
protected isItemKeptAfterDeath(pmcData: IPmcData, itemToCheck: Item): boolean;
|
||||
/**
|
||||
* Return the equipped items from a players inventory
|
||||
* @param items Players inventory to search through
|
||||
* @returns an array of equipped items
|
||||
*/
|
||||
getPlayerGear(items: Item[]): Item[];
|
||||
}
|
||||
265
types/helpers/InventoryHelper.d.ts
vendored
Normal file
265
types/helpers/InventoryHelper.d.ts
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
import { ContainerHelper } from "@spt/helpers/ContainerHelper";
|
||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { TraderAssortHelper } from "@spt/helpers/TraderAssortHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { Inventory } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { Item, Upd } from "@spt/models/eft/common/tables/IItem";
|
||||
import { IAddItemDirectRequest } from "@spt/models/eft/inventory/IAddItemDirectRequest";
|
||||
import { IAddItemsDirectRequest } from "@spt/models/eft/inventory/IAddItemsDirectRequest";
|
||||
import { IInventoryMergeRequestData } from "@spt/models/eft/inventory/IInventoryMergeRequestData";
|
||||
import { IInventoryMoveRequestData } from "@spt/models/eft/inventory/IInventoryMoveRequestData";
|
||||
import { IInventoryRemoveRequestData } from "@spt/models/eft/inventory/IInventoryRemoveRequestData";
|
||||
import { IInventorySplitRequestData } from "@spt/models/eft/inventory/IInventorySplitRequestData";
|
||||
import { IInventoryTransferRequestData } from "@spt/models/eft/inventory/IInventoryTransferRequestData";
|
||||
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { IInventoryConfig, RewardDetails } from "@spt/models/spt/config/IInventoryConfig";
|
||||
import { IOwnerInventoryItems } from "@spt/models/spt/inventory/IOwnerInventoryItems";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { FenceService } from "@spt/services/FenceService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||
export declare class InventoryHelper {
|
||||
protected logger: ILogger;
|
||||
protected hashUtil: HashUtil;
|
||||
protected httpResponse: HttpResponseUtil;
|
||||
protected fenceService: FenceService;
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected paymentHelper: PaymentHelper;
|
||||
protected traderAssortHelper: TraderAssortHelper;
|
||||
protected dialogueHelper: DialogueHelper;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected containerHelper: ContainerHelper;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected presetHelper: PresetHelper;
|
||||
protected localisationService: LocalisationService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected inventoryConfig: IInventoryConfig;
|
||||
constructor(logger: ILogger, hashUtil: HashUtil, httpResponse: HttpResponseUtil, fenceService: FenceService, databaseServer: DatabaseServer, paymentHelper: PaymentHelper, traderAssortHelper: TraderAssortHelper, dialogueHelper: DialogueHelper, itemHelper: ItemHelper, containerHelper: ContainerHelper, profileHelper: ProfileHelper, presetHelper: PresetHelper, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Add multiple items to player stash (assuming they all fit)
|
||||
* @param sessionId Session id
|
||||
* @param request IAddItemsDirectRequest request
|
||||
* @param pmcData Player profile
|
||||
* @param output Client response object
|
||||
*/
|
||||
addItemsToStash(sessionId: string, request: IAddItemsDirectRequest, pmcData: IPmcData, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Add whatever is passed in `request.itemWithModsToAdd` into player inventory (if it fits)
|
||||
* @param sessionId Session id
|
||||
* @param request addItemDirect request
|
||||
* @param pmcData Player profile
|
||||
* @param output Client response object
|
||||
*/
|
||||
addItemToStash(sessionId: string, request: IAddItemDirectRequest, pmcData: IPmcData, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Set FiR status for an item + its children
|
||||
* @param itemWithChildren An item
|
||||
* @param foundInRaid Item was found in raid
|
||||
*/
|
||||
protected setFindInRaidStatusForItem(itemWithChildren: Item[], foundInRaid: boolean): void;
|
||||
/**
|
||||
* Remove properties from a Upd object used by a trader/ragfair that are unnecessary to a player
|
||||
* @param upd Object to update
|
||||
*/
|
||||
protected removeTraderRagfairRelatedUpdProperties(upd: Upd): void;
|
||||
/**
|
||||
* Can all probided items be added into player inventory
|
||||
* @param sessionId Player id
|
||||
* @param itemsWithChildren array of items with children to try and fit
|
||||
* @returns True all items fit
|
||||
*/
|
||||
canPlaceItemsInInventory(sessionId: string, itemsWithChildren: Item[][]): boolean;
|
||||
/**
|
||||
* Do the provided items all fit into the grid
|
||||
* @param containerFS2D Container grid to fit items into
|
||||
* @param itemsWithChildren items to try and fit into grid
|
||||
* @returns True all fit
|
||||
*/
|
||||
canPlaceItemsInContainer(containerFS2D: number[][], itemsWithChildren: Item[][]): boolean;
|
||||
/**
|
||||
* Does an item fit into a container grid
|
||||
* @param containerFS2D Container grid
|
||||
* @param itemWithChildren item to check fits
|
||||
* @returns True it fits
|
||||
*/
|
||||
canPlaceItemInContainer(containerFS2D: number[][], itemWithChildren: Item[]): boolean;
|
||||
/**
|
||||
* Find a free location inside a container to fit the item
|
||||
* @param containerFS2D Container grid to add item to
|
||||
* @param itemWithChildren Item to add to grid
|
||||
* @param containerId Id of the container we're fitting item into
|
||||
* @param desiredSlotId slot id value to use, default is "hideout"
|
||||
*/
|
||||
placeItemInContainer(containerFS2D: number[][], itemWithChildren: Item[], containerId: string, desiredSlotId?: string): void;
|
||||
/**
|
||||
* Find a location to place an item into inventory and place it
|
||||
* @param stashFS2D 2-dimensional representation of the container slots
|
||||
* @param sortingTableFS2D 2-dimensional representation of the sorting table slots
|
||||
* @param itemWithChildren Item to place with children
|
||||
* @param playerInventory Players inventory
|
||||
* @param useSortingTable Should sorting table to be used if main stash has no space
|
||||
* @param output output to send back to client
|
||||
*/
|
||||
protected placeItemInInventory(stashFS2D: number[][], sortingTableFS2D: number[][], itemWithChildren: Item[], playerInventory: Inventory, useSortingTable: boolean, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Handle Remove event
|
||||
* Remove item from player inventory + insured items array
|
||||
* Also deletes child items
|
||||
* @param profile Profile to remove item from (pmc or scav)
|
||||
* @param itemId Items id to remove
|
||||
* @param sessionID Session id
|
||||
* @param output OPTIONAL - IItemEventRouterResponse
|
||||
*/
|
||||
removeItem(profile: IPmcData, itemId: string, sessionID: string, output?: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Delete desired item from a player profiles mail
|
||||
* @param sessionId Session id
|
||||
* @param removeRequest Remove request
|
||||
* @param output OPTIONAL - IItemEventRouterResponse
|
||||
*/
|
||||
removeItemAndChildrenFromMailRewards(sessionId: string, removeRequest: IInventoryRemoveRequestData, output?: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Find item by id in player inventory and remove x of its count
|
||||
* @param pmcData player profile
|
||||
* @param itemId Item id to decrement StackObjectsCount of
|
||||
* @param countToRemove Number of item to remove
|
||||
* @param sessionID Session id
|
||||
* @param output IItemEventRouterResponse
|
||||
* @returns IItemEventRouterResponse
|
||||
*/
|
||||
removeItemByCount(pmcData: IPmcData, itemId: string, countToRemove: number, sessionID: string, output?: IItemEventRouterResponse): IItemEventRouterResponse;
|
||||
/**
|
||||
* Get the height and width of an item - can have children that alter size
|
||||
* @param itemTpl Item to get size of
|
||||
* @param itemID Items id to get size of
|
||||
* @param inventoryItems
|
||||
* @returns [width, height]
|
||||
*/
|
||||
getItemSize(itemTpl: string, itemID: string, inventoryItems: Item[]): number[];
|
||||
/**
|
||||
* Calculates the size of an item including attachements
|
||||
* takes into account if item is folded
|
||||
* @param itemTpl Items template id
|
||||
* @param itemID Items id
|
||||
* @param inventoryItemHash Hashmap of inventory items
|
||||
* @returns An array representing the [width, height] of the item
|
||||
*/
|
||||
protected getSizeByInventoryItemHash(itemTpl: string, itemID: string, inventoryItemHash: InventoryHelper.InventoryItemHash): number[];
|
||||
/**
|
||||
* Get a blank two-dimentional representation of a container
|
||||
* @param containerH Horizontal size of container
|
||||
* @param containerY Vertical size of container
|
||||
* @returns Two-dimensional representation of container
|
||||
*/
|
||||
protected getBlankContainerMap(containerH: number, containerY: number): number[][];
|
||||
/**
|
||||
* @param containerH Horizontal size of container
|
||||
* @param containerV Vertical size of container
|
||||
* @param itemList
|
||||
* @param containerId Id of the container
|
||||
* @returns Two-dimensional representation of container
|
||||
*/
|
||||
getContainerMap(containerH: number, containerV: number, itemList: Item[], containerId: string): number[][];
|
||||
protected getInventoryItemHash(inventoryItem: Item[]): InventoryHelper.InventoryItemHash;
|
||||
/**
|
||||
* Return the inventory that needs to be modified (scav/pmc etc)
|
||||
* Changes made to result apply to character inventory
|
||||
* Based on the item action, determine whose inventories we should be looking at for from and to.
|
||||
* @param request Item interaction request
|
||||
* @param sessionId Session id / playerid
|
||||
* @returns OwnerInventoryItems with inventory of player/scav to adjust
|
||||
*/
|
||||
getOwnerInventoryItems(request: IInventoryMoveRequestData | IInventorySplitRequestData | IInventoryMergeRequestData | IInventoryTransferRequestData, sessionId: string): IOwnerInventoryItems;
|
||||
/**
|
||||
* Get a two dimensional array to represent stash slots
|
||||
* 0 value = free, 1 = taken
|
||||
* @param pmcData Player profile
|
||||
* @param sessionID session id
|
||||
* @returns 2-dimensional array
|
||||
*/
|
||||
protected getStashSlotMap(pmcData: IPmcData, sessionID: string): number[][];
|
||||
/**
|
||||
* Get a blank two-dimensional array representation of a container
|
||||
* @param containerTpl Container to get data for
|
||||
* @returns blank two-dimensional array
|
||||
*/
|
||||
getContainerSlotMap(containerTpl: string): number[][];
|
||||
/**
|
||||
* Get a two-dimensional array representation of the players sorting table
|
||||
* @param pmcData Player profile
|
||||
* @returns two-dimensional array
|
||||
*/
|
||||
protected getSortingTableSlotMap(pmcData: IPmcData): number[][];
|
||||
/**
|
||||
* Get Players Stash Size
|
||||
* @param sessionID Players id
|
||||
* @returns Array of 2 values, horizontal and vertical stash size
|
||||
*/
|
||||
protected getPlayerStashSize(sessionID: string): Record<number, number>;
|
||||
/**
|
||||
* Get the players stash items tpl
|
||||
* @param sessionID Player id
|
||||
* @returns Stash tpl
|
||||
*/
|
||||
protected getStashType(sessionID: string): string;
|
||||
/**
|
||||
* Internal helper function to transfer an item + children from one profile to another.
|
||||
* @param sourceItems Inventory of the source (can be non-player)
|
||||
* @param toItems Inventory of the destination
|
||||
* @param request Move request
|
||||
*/
|
||||
moveItemToProfile(sourceItems: Item[], toItems: Item[], request: IInventoryMoveRequestData): void;
|
||||
/**
|
||||
* Internal helper function to move item within the same profile_f.
|
||||
* @param pmcData profile to edit
|
||||
* @param inventoryItems
|
||||
* @param moveRequest client move request
|
||||
* @returns True if move was successful
|
||||
*/
|
||||
moveItemInternal(pmcData: IPmcData, inventoryItems: Item[], moveRequest: IInventoryMoveRequestData): {
|
||||
success: boolean;
|
||||
errorMessage?: string;
|
||||
};
|
||||
/**
|
||||
* Update fast panel bindings when an item is moved into a container that doesnt allow quick slot access
|
||||
* @param pmcData Player profile
|
||||
* @param itemBeingMoved item being moved
|
||||
*/
|
||||
protected updateFastPanelBinding(pmcData: IPmcData, itemBeingMoved: Item): void;
|
||||
/**
|
||||
* Internal helper function to handle cartridges in inventory if any of them exist.
|
||||
*/
|
||||
protected handleCartridges(items: Item[], request: IInventoryMoveRequestData): void;
|
||||
/**
|
||||
* Get details for how a random loot container should be handled, max rewards, possible reward tpls
|
||||
* @param itemTpl Container being opened
|
||||
* @returns Reward details
|
||||
*/
|
||||
getRandomLootContainerRewardDetails(itemTpl: string): RewardDetails;
|
||||
getInventoryConfig(): IInventoryConfig;
|
||||
/**
|
||||
* Recursively checks if the given item is
|
||||
* inside the stash, that is it has the stash as
|
||||
* ancestor with slotId=hideout
|
||||
* @param pmcData Player profile
|
||||
* @param itemToCheck Item to look for
|
||||
* @returns True if item exists inside stash
|
||||
*/
|
||||
isItemInStash(pmcData: IPmcData, itemToCheck: Item): boolean;
|
||||
}
|
||||
declare namespace InventoryHelper {
|
||||
interface InventoryItemHash {
|
||||
byItemId: Record<string, Item>;
|
||||
byParentId: Record<string, Item[]>;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
520
types/helpers/ItemHelper.d.ts
vendored
Normal file
520
types/helpers/ItemHelper.d.ts
vendored
Normal file
@@ -0,0 +1,520 @@
|
||||
import { HandbookHelper } from "@spt/helpers/HandbookHelper";
|
||||
import { IStaticAmmoDetails } from "@spt/models/eft/common/ILocation";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { InsuredItem } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { Item, Repairable, Upd } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { ItemTpl } from "@spt/models/enums/ItemTpl";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ItemBaseClassService } from "@spt/services/ItemBaseClassService";
|
||||
import { ItemFilterService } from "@spt/services/ItemFilterService";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { CompareUtil } from "@spt/utils/CompareUtil";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { JsonUtil } from "@spt/utils/JsonUtil";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { ObjectId } from "@spt/utils/ObjectId";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class ItemHelper {
|
||||
protected logger: ILogger;
|
||||
protected hashUtil: HashUtil;
|
||||
protected jsonUtil: JsonUtil;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected objectId: ObjectId;
|
||||
protected mathUtil: MathUtil;
|
||||
protected databaseService: DatabaseService;
|
||||
protected handbookHelper: HandbookHelper;
|
||||
protected itemBaseClassService: ItemBaseClassService;
|
||||
protected itemFilterService: ItemFilterService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected localeService: LocaleService;
|
||||
protected compareUtil: CompareUtil;
|
||||
protected cloner: ICloner;
|
||||
protected readonly defaultInvalidBaseTypes: string[];
|
||||
constructor(logger: ILogger, hashUtil: HashUtil, jsonUtil: JsonUtil, randomUtil: RandomUtil, objectId: ObjectId, mathUtil: MathUtil, databaseService: DatabaseService, handbookHelper: HandbookHelper, itemBaseClassService: ItemBaseClassService, itemFilterService: ItemFilterService, localisationService: LocalisationService, localeService: LocaleService, compareUtil: CompareUtil, cloner: ICloner);
|
||||
/**
|
||||
* Does the provided pool of items contain the desired item
|
||||
* @param itemPool Item collection to check
|
||||
* @param item Item to look for
|
||||
* @param slotId OPTIONAL - slotid of desired item
|
||||
* @returns True if pool contains item
|
||||
*/
|
||||
hasItemWithTpl(itemPool: Item[], item: ItemTpl, slotId?: string): boolean;
|
||||
/**
|
||||
* Get the first item from provided pool with the desired tpl
|
||||
* @param itemPool Item collection to search
|
||||
* @param item Item to look for
|
||||
* @param slotId OPTIONAL - slotid of desired item
|
||||
* @returns Item or undefined
|
||||
*/
|
||||
getItemFromPoolByTpl(itemPool: Item[], item: ItemTpl, slotId?: string): Item | undefined;
|
||||
/**
|
||||
* This method will compare two items (with all its children) and see if the are equivalent.
|
||||
* This method will NOT compare IDs on the items
|
||||
* @param item1 first item with all its children to compare
|
||||
* @param item2 second item with all its children to compare
|
||||
* @param compareUpdProperties Upd properties to compare between the items
|
||||
* @returns true if they are the same, false if they arent
|
||||
*/
|
||||
isSameItems(item1: Item[], item2: Item[], compareUpdProperties?: Set<string>): boolean;
|
||||
/**
|
||||
* This method will compare two items and see if the are equivalent.
|
||||
* This method will NOT compare IDs on the items
|
||||
* @param item1 first item to compare
|
||||
* @param item2 second item to compare
|
||||
* @param compareUpdProperties Upd properties to compare between the items
|
||||
* @returns true if they are the same, false if they arent
|
||||
*/
|
||||
isSameItem(item1: Item, item2: Item, compareUpdProperties?: Set<string>): boolean;
|
||||
/**
|
||||
* Helper method to generate a Upd based on a template
|
||||
* @param itemTemplate the item template to generate a Upd for
|
||||
* @returns A Upd with all the default properties set
|
||||
*/
|
||||
generateUpdForItem(itemTemplate: ITemplateItem): Upd;
|
||||
/**
|
||||
* Checks if an id is a valid item. Valid meaning that it's an item that be stored in stash
|
||||
* @param {string} tpl the template id / tpl
|
||||
* @returns boolean; true for items that may be in player possession and not quest items
|
||||
*/
|
||||
isValidItem(tpl: string, invalidBaseTypes?: string[]): boolean;
|
||||
/**
|
||||
* Check if the tpl / template Id provided is a descendent of the baseclass
|
||||
*
|
||||
* @param {string} tpl the item template id to check
|
||||
* @param {string} baseClassTpl the baseclass to check for
|
||||
* @return {boolean} is the tpl a descendent?
|
||||
*/
|
||||
isOfBaseclass(tpl: string, baseClassTpl: string): boolean;
|
||||
/**
|
||||
* Check if item has any of the supplied base classes
|
||||
* @param tpl Item to check base classes of
|
||||
* @param baseClassTpls base classes to check for
|
||||
* @returns true if any supplied base classes match
|
||||
*/
|
||||
isOfBaseclasses(tpl: string, baseClassTpls: string[]): boolean;
|
||||
/**
|
||||
* Does the provided item have the chance to require soft armor inserts
|
||||
* Only applies to helmets/vest/armors.
|
||||
* Not all head gear needs them
|
||||
* @param itemTpl item to check
|
||||
* @returns Does item have the possibility ot need soft inserts
|
||||
*/
|
||||
armorItemCanHoldMods(itemTpl: string): boolean;
|
||||
/**
|
||||
* Does the provided item tpl need soft/removable inserts to function
|
||||
* @param itemTpl Armor item
|
||||
* @returns True if item needs some kind of insert
|
||||
*/
|
||||
armorItemHasRemovableOrSoftInsertSlots(itemTpl: string): boolean;
|
||||
/**
|
||||
* Does the pased in tpl have ability to hold removable plate items
|
||||
* @param itemTpl item tpl to check for plate support
|
||||
* @returns True when armor can hold plates
|
||||
*/
|
||||
armorItemHasRemovablePlateSlots(itemTpl: string): boolean;
|
||||
/**
|
||||
* Does the provided item tpl require soft inserts to become a valid armor item
|
||||
* @param itemTpl Item tpl to check
|
||||
* @returns True if it needs armor inserts
|
||||
*/
|
||||
itemRequiresSoftInserts(itemTpl: string): boolean;
|
||||
/**
|
||||
* Get all soft insert slot ids
|
||||
* @returns An array of soft insert ids (e.g. soft_armor_back, helmet_top)
|
||||
*/
|
||||
getSoftInsertSlotIds(): string[];
|
||||
/**
|
||||
* Returns the items total price based on the handbook or as a fallback from the prices.json if the item is not
|
||||
* found in the handbook. If the price can't be found at all return 0
|
||||
* @param tpls item tpls to look up the price of
|
||||
* @returns Total price in roubles
|
||||
*/
|
||||
getItemAndChildrenPrice(tpls: string[]): number;
|
||||
/**
|
||||
* Returns the item price based on the handbook or as a fallback from the prices.json if the item is not
|
||||
* found in the handbook. If the price can't be found at all return 0
|
||||
* @param tpl Item to look price up of
|
||||
* @returns Price in roubles
|
||||
*/
|
||||
getItemPrice(tpl: string): number;
|
||||
/**
|
||||
* Returns the item price based on the handbook or as a fallback from the prices.json if the item is not
|
||||
* found in the handbook. If the price can't be found at all return 0
|
||||
* @param tpl Item to look price up of
|
||||
* @returns Price in roubles
|
||||
*/
|
||||
getItemMaxPrice(tpl: string): number;
|
||||
/**
|
||||
* Get the static (handbook) price in roubles for an item by tpl
|
||||
* @param tpl Items tpl id to look up price
|
||||
* @returns Price in roubles (0 if not found)
|
||||
*/
|
||||
getStaticItemPrice(tpl: string): number;
|
||||
/**
|
||||
* Get the dynamic (flea) price in roubles for an item by tpl
|
||||
* @param tpl Items tpl id to look up price
|
||||
* @returns Price in roubles (undefined if not found)
|
||||
*/
|
||||
getDynamicItemPrice(tpl: string): number;
|
||||
/**
|
||||
* Update items upd.StackObjectsCount to be 1 if its upd is missing or StackObjectsCount is undefined
|
||||
* @param item Item to update
|
||||
* @returns Fixed item
|
||||
*/
|
||||
fixItemStackCount(item: Item): Item;
|
||||
/**
|
||||
* Get cloned copy of all item data from items.json
|
||||
* @returns array of ITemplateItem objects
|
||||
*/
|
||||
getItems(): ITemplateItem[];
|
||||
/**
|
||||
* Gets item data from items.json
|
||||
* @param tpl items template id to look up
|
||||
* @returns bool - is valid + template item object as array
|
||||
*/
|
||||
getItem(tpl: string): [boolean, ITemplateItem];
|
||||
itemHasSlots(itemTpl: string): boolean;
|
||||
isItemInDb(tpl: string): boolean;
|
||||
/**
|
||||
* Calcualte the average quality of an item and its children
|
||||
* @param items An offers item to process
|
||||
* @param skipArmorItemsWithoutDurability Skip over armor items without durability
|
||||
* @returns % quality modifer between 0 and 1
|
||||
*/
|
||||
getItemQualityModifierForItems(items: Item[], skipArmorItemsWithoutDurability?: boolean): number;
|
||||
/**
|
||||
* get normalized value (0-1) based on item condition
|
||||
* Will return -1 for base armor items with 0 durability
|
||||
* @param item
|
||||
* @param skipArmorItemsWithoutDurability return -1 for armor items that have maxdurability of 0
|
||||
* @returns Number between 0 and 1
|
||||
*/
|
||||
getItemQualityModifier(item: Item, skipArmorItemsWithoutDurability?: boolean): number;
|
||||
/**
|
||||
* Get a quality value based on a repairable items (weapon/armor) current state between current and max durability
|
||||
* @param itemDetails Db details for item we want quality value for
|
||||
* @param repairable Repairable properties
|
||||
* @param item Item quality value is for
|
||||
* @returns A number between 0 and 1
|
||||
*/
|
||||
protected getRepairableItemQualityValue(itemDetails: ITemplateItem, repairable: Repairable, item: Item): number;
|
||||
/**
|
||||
* Recursive function that looks at every item from parameter and gets their childrens Ids + includes parent item in results
|
||||
* @param items Array of items (item + possible children)
|
||||
* @param baseItemId Parent items id
|
||||
* @returns an array of strings
|
||||
*/
|
||||
findAndReturnChildrenByItems(items: Item[], baseItemId: string): string[];
|
||||
/**
|
||||
* A variant of findAndReturnChildren where the output is list of item objects instead of their ids.
|
||||
* @param items Array of items (item + possible children)
|
||||
* @param baseItemId Parent items id
|
||||
* @param modsOnly Include only mod items, exclude items stored inside root item
|
||||
* @returns An array of Item objects
|
||||
*/
|
||||
findAndReturnChildrenAsItems(items: Item[], baseItemId: string, modsOnly?: boolean): Item[];
|
||||
/**
|
||||
* Find children of the item in a given assort (weapons parts for example, need recursive loop function)
|
||||
* @param itemIdToFind Template id of item to check for
|
||||
* @param assort Array of items to check in
|
||||
* @returns Array of children of requested item
|
||||
*/
|
||||
findAndReturnChildrenByAssort(itemIdToFind: string, assort: Item[]): Item[];
|
||||
/**
|
||||
* Check if the passed in item has buy count restrictions
|
||||
* @param itemToCheck Item to check
|
||||
* @returns true if it has buy restrictions
|
||||
*/
|
||||
hasBuyRestrictions(itemToCheck: Item): boolean;
|
||||
/**
|
||||
* is the passed in template id a dog tag
|
||||
* @param tpl Template id to check
|
||||
* @returns true if it is a dogtag
|
||||
*/
|
||||
isDogtag(tpl: string): boolean;
|
||||
/**
|
||||
* Gets the identifier for a child using slotId, locationX and locationY.
|
||||
* @param item
|
||||
* @returns "slotId OR slotid,locationX,locationY"
|
||||
*/
|
||||
getChildId(item: Item): string;
|
||||
/**
|
||||
* Can the passed in item be stacked
|
||||
* @param tpl item to check
|
||||
* @returns true if it can be stacked
|
||||
*/
|
||||
isItemTplStackable(tpl: string): boolean;
|
||||
/**
|
||||
* Split item stack if it exceeds its items StackMaxSize property into child items of passed in parent
|
||||
* @param itemToSplit Item to split into smaller stacks
|
||||
* @returns Array of root item + children
|
||||
*/
|
||||
splitStack(itemToSplit: Item): Item[];
|
||||
/**
|
||||
* Turn items like money into separate stacks that adhere to max stack size
|
||||
* @param itemToSplit Item to split into smaller stacks
|
||||
* @returns
|
||||
*/
|
||||
splitStackIntoSeparateItems(itemToSplit: Item): Item[][];
|
||||
/**
|
||||
* Find Barter items from array of items
|
||||
* @param {string} by tpl or id
|
||||
* @param {Item[]} itemsToSearch Array of items to iterate over
|
||||
* @param {string} desiredBarterItemIds
|
||||
* @returns Array of Item objects
|
||||
*/
|
||||
findBarterItems(by: "tpl" | "id", itemsToSearch: Item[], desiredBarterItemIds: string | string[]): Item[];
|
||||
/**
|
||||
* Regenerate all GUIDs with new IDs, for the exception of special item types (e.g. quest, sorting table, etc.) This
|
||||
* function will not mutate the original items array, but will return a new array with new GUIDs.
|
||||
*
|
||||
* @param originalItems Items to adjust the IDs of
|
||||
* @param pmcData Player profile
|
||||
* @param insuredItems Insured items that should not have their IDs replaced
|
||||
* @param fastPanel Quick slot panel
|
||||
* @returns Item[]
|
||||
*/
|
||||
replaceIDs(originalItems: Item[], pmcData?: IPmcData, insuredItems?: InsuredItem[], fastPanel?: any): Item[];
|
||||
/**
|
||||
* Mark the passed in array of items as found in raid.
|
||||
* Modifies passed in items
|
||||
* @param items The list of items to mark as FiR
|
||||
*/
|
||||
setFoundInRaid(items: Item[]): void;
|
||||
/**
|
||||
* WARNING, SLOW. Recursively loop down through an items hierarchy to see if any of the ids match the supplied list, return true if any do
|
||||
* @param {string} tpl Items tpl to check parents of
|
||||
* @param {Array} tplsToCheck Tpl values to check if parents of item match
|
||||
* @returns boolean Match found
|
||||
*/
|
||||
doesItemOrParentsIdMatch(tpl: string, tplsToCheck: string[]): boolean;
|
||||
/**
|
||||
* Check if item is quest item
|
||||
* @param tpl Items tpl to check quest status of
|
||||
* @returns true if item is flagged as quest item
|
||||
*/
|
||||
isQuestItem(tpl: string): boolean;
|
||||
/**
|
||||
* Checks to see if the item is *actually* moddable in-raid. Checks include the items existence in the database, the
|
||||
* parent items existence in the database, the existence (and value) of the items RaidModdable property, and that
|
||||
* the parents slot-required property exists, matches that of the item, and it's value.
|
||||
*
|
||||
* Note: this function does not preform any checks to see if the item and parent are *actually* related.
|
||||
*
|
||||
* @param item The item to be checked
|
||||
* @param parent The parent of the item to be checked
|
||||
* @returns True if the item is actually moddable, false if it is not, and undefined if the check cannot be performed.
|
||||
*/
|
||||
isRaidModdable(item: Item, parent: Item): boolean | undefined;
|
||||
/**
|
||||
* Retrieves the main parent item for a given attachment item.
|
||||
*
|
||||
* This method traverses up the hierarchy of items starting from a given `itemId`, until it finds the main parent
|
||||
* item that is not an attached attachment itself. In other words, if you pass it an item id of a suppressor, it
|
||||
* will traverse up the muzzle brake, barrel, upper receiver, and return the gun that the suppressor is ultimately
|
||||
* attached to, even if that gun is located within multiple containers.
|
||||
*
|
||||
* It's important to note that traversal is expensive, so this method requires that you pass it a Map of the items
|
||||
* to traverse, where the keys are the item IDs and the values are the corresponding Item objects. This alleviates
|
||||
* some of the performance concerns, as it allows for quick lookups of items by ID.
|
||||
*
|
||||
* @param itemId - The unique identifier of the item for which to find the main parent.
|
||||
* @param itemsMap - A Map containing item IDs mapped to their corresponding Item objects for quick lookup.
|
||||
* @returns The Item object representing the top-most parent of the given item, or `undefined` if no such parent exists.
|
||||
*/
|
||||
getAttachmentMainParent(itemId: string, itemsMap: Map<string, Item>): Item | undefined;
|
||||
/**
|
||||
* Determines if an item is an attachment that is currently attached to it's parent item.
|
||||
*
|
||||
* @param item The item to check.
|
||||
* @returns true if the item is attached attachment, otherwise false.
|
||||
*/
|
||||
isAttachmentAttached(item: Item): boolean;
|
||||
/**
|
||||
* Retrieves the equipment parent item for a given item.
|
||||
*
|
||||
* This method traverses up the hierarchy of items starting from a given `itemId`, until it finds the equipment
|
||||
* parent item. In other words, if you pass it an item id of a suppressor, it will traverse up the muzzle brake,
|
||||
* barrel, upper receiver, gun, nested backpack, and finally return the backpack Item that is equipped.
|
||||
*
|
||||
* It's important to note that traversal is expensive, so this method requires that you pass it a Map of the items
|
||||
* to traverse, where the keys are the item IDs and the values are the corresponding Item objects. This alleviates
|
||||
* some of the performance concerns, as it allows for quick lookups of items by ID.
|
||||
*
|
||||
* @param itemId - The unique identifier of the item for which to find the equipment parent.
|
||||
* @param itemsMap - A Map containing item IDs mapped to their corresponding Item objects for quick lookup.
|
||||
* @returns The Item object representing the equipment parent of the given item, or `undefined` if no such parent exists.
|
||||
*/
|
||||
getEquipmentParent(itemId: string, itemsMap: Map<string, Item>): Item | undefined;
|
||||
/**
|
||||
* Get the inventory size of an item
|
||||
* @param items Item with children
|
||||
* @param rootItemId
|
||||
* @returns ItemSize object (width and height)
|
||||
*/
|
||||
getItemSize(items: Item[], rootItemId: string): ItemHelper.ItemSize;
|
||||
/**
|
||||
* Get a random cartridge from an items Filter property
|
||||
* @param item Db item template to look up Cartridge filter values from
|
||||
* @returns Caliber of cartridge
|
||||
*/
|
||||
getRandomCompatibleCaliberTemplateId(item: ITemplateItem): string | undefined;
|
||||
/**
|
||||
* Add cartridges to the ammo box with correct max stack sizes
|
||||
* @param ammoBox Box to add cartridges to
|
||||
* @param ammoBoxDetails Item template from items db
|
||||
*/
|
||||
addCartridgesToAmmoBox(ammoBox: Item[], ammoBoxDetails: ITemplateItem): void;
|
||||
/**
|
||||
* Add a single stack of cartridges to the ammo box
|
||||
* @param ammoBox Box to add cartridges to
|
||||
* @param ammoBoxDetails Item template from items db
|
||||
*/
|
||||
addSingleStackCartridgesToAmmoBox(ammoBox: Item[], ammoBoxDetails: ITemplateItem): void;
|
||||
/**
|
||||
* Check if item is stored inside of a container
|
||||
* @param item Item to check is inside of container
|
||||
* @param desiredContainerSlotId Name of slot to check item is in e.g. SecuredContainer/Backpack
|
||||
* @param items Inventory with child parent items to check
|
||||
* @returns True when item is in container
|
||||
*/
|
||||
itemIsInsideContainer(item: Item, desiredContainerSlotId: string, items: Item[]): boolean;
|
||||
/**
|
||||
* Add child items (cartridges) to a magazine
|
||||
* @param magazine Magazine to add child items to
|
||||
* @param magTemplate Db template of magazine
|
||||
* @param staticAmmoDist Cartridge distribution
|
||||
* @param caliber Caliber of cartridge to add to magazine
|
||||
* @param minSizePercent % the magazine must be filled to
|
||||
* @param defaultCartridgeTpl Cartridge to use when none found
|
||||
* @param weapon Weapon the magazine will be used for (if passed in uses Chamber as whitelist)
|
||||
*/
|
||||
fillMagazineWithRandomCartridge(magazine: Item[], magTemplate: ITemplateItem, staticAmmoDist: Record<string, IStaticAmmoDetails[]>, caliber?: string, minSizePercent?: number, defaultCartridgeTpl?: string, weapon?: ITemplateItem): void;
|
||||
/**
|
||||
* Add child items to a magazine of a specific cartridge
|
||||
* @param magazineWithChildCartridges Magazine to add child items to
|
||||
* @param magTemplate Db template of magazine
|
||||
* @param cartridgeTpl Cartridge to add to magazine
|
||||
* @param minSizePercent % the magazine must be filled to
|
||||
*/
|
||||
fillMagazineWithCartridge(magazineWithChildCartridges: Item[], magTemplate: ITemplateItem, cartridgeTpl: string, minSizePercent?: number): void;
|
||||
/**
|
||||
* Choose a random bullet type from the list of possible a magazine has
|
||||
* @param magTemplate Magazine template from Db
|
||||
* @returns Tpl of cartridge
|
||||
*/
|
||||
protected getRandomValidCaliber(magTemplate: ITemplateItem): string;
|
||||
/**
|
||||
* Chose a randomly weighted cartridge that fits
|
||||
* @param caliber Desired caliber
|
||||
* @param staticAmmoDist Cartridges and thier weights
|
||||
* @param fallbackCartridgeTpl If a cartridge cannot be found in the above staticAmmoDist param, use this instead
|
||||
* @param cartridgeWhitelist OPTIONAL whitelist for cartridges
|
||||
* @returns Tpl of cartridge
|
||||
*/
|
||||
protected drawAmmoTpl(caliber: string, staticAmmoDist: Record<string, IStaticAmmoDetails[]>, fallbackCartridgeTpl: string, cartridgeWhitelist?: string[]): string | undefined;
|
||||
/**
|
||||
* Create a basic cartrige object
|
||||
* @param parentId container cartridges will be placed in
|
||||
* @param ammoTpl Cartridge to insert
|
||||
* @param stackCount Count of cartridges inside parent
|
||||
* @param location Location inside parent (e.g. 0, 1)
|
||||
* @param foundInRaid OPTIONAL - Are cartridges found in raid (SpawnedInSession)
|
||||
* @returns Item
|
||||
*/
|
||||
createCartridges(parentId: string, ammoTpl: string, stackCount: number, location: number, foundInRaid?: boolean): Item;
|
||||
/**
|
||||
* Get the size of a stack, return 1 if no stack object count property found
|
||||
* @param item Item to get stack size of
|
||||
* @returns size of stack
|
||||
*/
|
||||
getItemStackSize(item: Item): number;
|
||||
/**
|
||||
* Get the name of an item from the locale file using the item tpl
|
||||
* @param itemTpl Tpl of item to get name of
|
||||
* @returns Full name, short name if not found
|
||||
*/
|
||||
getItemName(itemTpl: string): string;
|
||||
/**
|
||||
* Get all item tpls with a desired base type
|
||||
* @param desiredBaseType Item base type wanted
|
||||
* @returns Array of tpls
|
||||
*/
|
||||
getItemTplsOfBaseType(desiredBaseType: string): string[];
|
||||
/**
|
||||
* Add child slot items to an item, chooses random child item if multiple choices exist
|
||||
* @param itemToAdd array with single object (root item)
|
||||
* @param itemToAddTemplate Db tempalte for root item
|
||||
* @param modSpawnChanceDict Optional dictionary of mod name + % chance mod will be included in item (e.g. front_plate: 100)
|
||||
* @param requiredOnly Only add required mods
|
||||
* @returns Item with children
|
||||
*/
|
||||
addChildSlotItems(itemToAdd: Item[], itemToAddTemplate: ITemplateItem, modSpawnChanceDict?: Record<string, number>, requiredOnly?: boolean): Item[];
|
||||
/**
|
||||
* Get a compatible tpl from the array provided where it is not found in the provided incompatible mod tpls parameter
|
||||
* @param possibleTpls Tpls to randomly choose from
|
||||
* @param incompatibleModTpls Incompatible tpls to not allow
|
||||
* @returns Chosen tpl or undefined
|
||||
*/
|
||||
getCompatibleTplFromArray(possibleTpls: string[], incompatibleModTpls: Set<string>): string | undefined;
|
||||
/**
|
||||
* Is the provided item._props.Slots._name property a plate slot
|
||||
* @param slotName Name of slot (_name) of Items Slot array
|
||||
* @returns True if its a slot that holds a removable palte
|
||||
*/
|
||||
isRemovablePlateSlot(slotName: string): boolean;
|
||||
/**
|
||||
* Get a list of slot names that hold removable plates
|
||||
* @returns Array of slot ids (e.g. front_plate)
|
||||
*/
|
||||
getRemovablePlateSlotIds(): string[];
|
||||
/**
|
||||
* Generate new unique ids for child items while preserving hierarchy
|
||||
* @param rootItem Base/primary item
|
||||
* @param itemWithChildren Primary item + children of primary item
|
||||
* @returns Item array with updated IDs
|
||||
*/
|
||||
reparentItemAndChildren(rootItem: Item, itemWithChildren: Item[]): Item[];
|
||||
/**
|
||||
* Update a root items _id property value to be unique
|
||||
* @param itemWithChildren Item to update root items _id property
|
||||
* @param newId Optional: new id to use
|
||||
* @returns New root id
|
||||
*/
|
||||
remapRootItemId(itemWithChildren: Item[], newId?: string): string;
|
||||
/**
|
||||
* Adopts orphaned items by resetting them as root "hideout" items. Helpful in situations where a parent has been
|
||||
* deleted from a group of items and there are children still referencing the missing parent. This method will
|
||||
* remove the reference from the children to the parent and set item properties to root values.
|
||||
*
|
||||
* @param rootId The ID of the "root" of the container.
|
||||
* @param items Array of Items that should be adjusted.
|
||||
* @returns Array of Items that have been adopted.
|
||||
*/
|
||||
adoptOrphanedItems(rootId: string, items: Item[]): Item[];
|
||||
/**
|
||||
* Populate a Map object of items for quick lookup using their ID.
|
||||
*
|
||||
* @param items An array of Items that should be added to a Map.
|
||||
* @returns A Map where the keys are the item IDs and the values are the corresponding Item objects.
|
||||
*/
|
||||
generateItemsMap(items: Item[]): Map<string, Item>;
|
||||
/**
|
||||
* Add a blank upd object to passed in item if it does not exist already
|
||||
* @param item item to add upd to
|
||||
* @param warningMessageWhenMissing text to write to log when upd object was not found
|
||||
* @returns True when upd object was added
|
||||
*/
|
||||
addUpdObjectToItem(item: Item, warningMessageWhenMissing?: string): boolean;
|
||||
}
|
||||
declare namespace ItemHelper {
|
||||
interface ItemSize {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
36
types/helpers/NotificationSendHelper.d.ts
vendored
Normal file
36
types/helpers/NotificationSendHelper.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Dialogue, IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||
import { MessageType } from "@spt/models/enums/MessageType";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { SptWebSocketConnectionHandler } from "@spt/servers/ws/SptWebSocketConnectionHandler";
|
||||
import { NotificationService } from "@spt/services/NotificationService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
export declare class NotificationSendHelper {
|
||||
protected sptWebSocketConnection: SptWebSocketConnectionHandler;
|
||||
protected hashUtil: HashUtil;
|
||||
protected saveServer: SaveServer;
|
||||
protected notificationService: NotificationService;
|
||||
constructor(sptWebSocketConnection: SptWebSocketConnectionHandler, hashUtil: HashUtil, saveServer: SaveServer, notificationService: NotificationService);
|
||||
/**
|
||||
* Send notification message to the appropriate channel
|
||||
* @param sessionID
|
||||
* @param notificationMessage
|
||||
*/
|
||||
sendMessage(sessionID: string, notificationMessage: IWsNotificationEvent): void;
|
||||
/**
|
||||
* Send a message directly to the player
|
||||
* @param sessionId Session id
|
||||
* @param senderDetails Who is sendin the message to player
|
||||
* @param messageText Text to send player
|
||||
* @param messageType Underlying type of message being sent
|
||||
*/
|
||||
sendMessageToPlayer(sessionId: string, senderDetails: IUserDialogInfo, messageText: string, messageType: MessageType): void;
|
||||
/**
|
||||
* Helper function for sendMessageToPlayer(), get new dialog for storage in profile or find existing by sender id
|
||||
* @param sessionId Session id
|
||||
* @param messageType Type of message to generate
|
||||
* @param senderDetails Who is sending the message
|
||||
* @returns Dialogue
|
||||
*/
|
||||
protected getDialog(sessionId: string, messageType: MessageType, senderDetails: IUserDialogInfo): Dialogue;
|
||||
}
|
||||
28
types/helpers/NotifierHelper.d.ts
vendored
Normal file
28
types/helpers/NotifierHelper.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { HttpServerHelper } from "@spt/helpers/HttpServerHelper";
|
||||
import { Message, MessageContentRagfair } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { IWsChatMessageReceived } from "@spt/models/eft/ws/IWsChatMessageReceived";
|
||||
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
|
||||
import { IWsRagfairOfferSold } from "@spt/models/eft/ws/IWsRagfairOfferSold";
|
||||
export declare class NotifierHelper {
|
||||
protected httpServerHelper: HttpServerHelper;
|
||||
/**
|
||||
* The default notification sent when waiting times out.
|
||||
*/
|
||||
protected defaultNotification: IWsNotificationEvent;
|
||||
constructor(httpServerHelper: HttpServerHelper);
|
||||
getDefaultNotification(): IWsNotificationEvent;
|
||||
/**
|
||||
* Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside
|
||||
* @param dialogueMessage Message from dialog that was sent
|
||||
* @param ragfairData Ragfair data to attach to notification
|
||||
* @returns
|
||||
*/
|
||||
createRagfairOfferSoldNotification(dialogueMessage: Message, ragfairData: MessageContentRagfair): IWsRagfairOfferSold;
|
||||
/**
|
||||
* Create a new notification with the specified dialogueMessage object
|
||||
* @param dialogueMessage
|
||||
* @returns
|
||||
*/
|
||||
createNewMessageNotification(dialogueMessage: Message): IWsChatMessageReceived;
|
||||
getWebSocketServer(sessionID: string): string;
|
||||
}
|
||||
19
types/helpers/PaymentHelper.d.ts
vendored
Normal file
19
types/helpers/PaymentHelper.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { IInventoryConfig } from "@spt/models/spt/config/IInventoryConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
export declare class PaymentHelper {
|
||||
protected configServer: ConfigServer;
|
||||
protected inventoryConfig: IInventoryConfig;
|
||||
constructor(configServer: ConfigServer);
|
||||
/**
|
||||
* Is the passed in tpl money (also checks custom currencies in inventoryConfig.customMoneyTpls)
|
||||
* @param {string} tpl
|
||||
* @returns void
|
||||
*/
|
||||
isMoneyTpl(tpl: string): boolean;
|
||||
/**
|
||||
* Gets currency TPL from TAG
|
||||
* @param {string} currency
|
||||
* @returns string
|
||||
*/
|
||||
getCurrency(currency: string): string;
|
||||
}
|
||||
55
types/helpers/PresetHelper.d.ts
vendored
Normal file
55
types/helpers/PresetHelper.d.ts
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { IPreset } from "@spt/models/eft/common/IGlobals";
|
||||
import { BaseClasses } from "@spt/models/enums/BaseClasses";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
export declare class PresetHelper {
|
||||
protected databaseService: DatabaseService;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected cloner: ICloner;
|
||||
protected lookup: Record<string, string[]>;
|
||||
protected defaultEquipmentPresets: Record<string, IPreset>;
|
||||
protected defaultWeaponPresets: Record<string, IPreset>;
|
||||
constructor(databaseService: DatabaseService, itemHelper: ItemHelper, cloner: ICloner);
|
||||
hydratePresetStore(input: Record<string, string[]>): void;
|
||||
/**
|
||||
* Get default weapon and equipment presets
|
||||
* @returns Dictionary
|
||||
*/
|
||||
getDefaultPresets(): Record<string, IPreset>;
|
||||
/**
|
||||
* Get default weapon presets
|
||||
* @returns Dictionary
|
||||
*/
|
||||
getDefaultWeaponPresets(): Record<string, IPreset>;
|
||||
/**
|
||||
* Get default equipment presets
|
||||
* @returns Dictionary
|
||||
*/
|
||||
getDefaultEquipmentPresets(): Record<string, IPreset>;
|
||||
isPreset(id: string): boolean;
|
||||
/**
|
||||
* Checks to see if the preset is of the given base class.
|
||||
* @param id The id of the preset
|
||||
* @param baseClass The BaseClasses enum to check against
|
||||
* @returns True if the preset is of the given base class, false otherwise
|
||||
*/
|
||||
isPresetBaseClass(id: string, baseClass: BaseClasses): boolean;
|
||||
hasPreset(templateId: string): boolean;
|
||||
getPreset(id: string): IPreset;
|
||||
getAllPresets(): IPreset[];
|
||||
getPresets(templateId: string): IPreset[];
|
||||
/**
|
||||
* Get the default preset for passed in item id
|
||||
* @param templateId Item id to get preset for
|
||||
* @returns Null if no default preset, otherwise IPreset
|
||||
*/
|
||||
getDefaultPreset(templateId: string): IPreset | undefined;
|
||||
getBaseItemTpl(presetId: string): string;
|
||||
/**
|
||||
* Return the price of the preset for the given item tpl, or for the tpl itself if no preset exists
|
||||
* @param tpl The item template to get the price of
|
||||
* @returns The price of the given item preset, or base item if no preset exists
|
||||
*/
|
||||
getDefaultPresetOrItemPrice(tpl: string): number;
|
||||
}
|
||||
14
types/helpers/ProbabilityHelper.d.ts
vendored
Normal file
14
types/helpers/ProbabilityHelper.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class ProbabilityHelper {
|
||||
protected logger: ILogger;
|
||||
protected randomUtil: RandomUtil;
|
||||
constructor(logger: ILogger, randomUtil: RandomUtil);
|
||||
/**
|
||||
* Chance to roll a number out of 100
|
||||
* @param chance Percentage chance roll should success
|
||||
* @param scale scale of chance to allow support of numbers > 1-100
|
||||
* @returns true if success
|
||||
*/
|
||||
rollChance(chance: number, scale?: number): boolean;
|
||||
}
|
||||
201
types/helpers/ProfileHelper.d.ts
vendored
Normal file
201
types/helpers/ProfileHelper.d.ts
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { Common, CounterKeyValue, Stats } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { IValidateNicknameRequestData } from "@spt/models/eft/profile/IValidateNicknameRequestData";
|
||||
import { SkillTypes } from "@spt/models/enums/SkillTypes";
|
||||
import { IInventoryConfig } from "@spt/models/spt/config/IInventoryConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { ProfileSnapshotService } from "@spt/services/ProfileSnapshotService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
import { Watermark } from "@spt/utils/Watermark";
|
||||
export declare class ProfileHelper {
|
||||
protected logger: ILogger;
|
||||
protected hashUtil: HashUtil;
|
||||
protected watermark: Watermark;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected saveServer: SaveServer;
|
||||
protected databaseService: DatabaseService;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected profileSnapshotService: ProfileSnapshotService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected inventoryConfig: IInventoryConfig;
|
||||
constructor(logger: ILogger, hashUtil: HashUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseService: DatabaseService, itemHelper: ItemHelper, profileSnapshotService: ProfileSnapshotService, localisationService: LocalisationService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Remove/reset a completed quest condtion from players profile quest data
|
||||
* @param sessionID Session id
|
||||
* @param questConditionId Quest with condition to remove
|
||||
*/
|
||||
removeQuestConditionFromProfile(pmcData: IPmcData, questConditionId: Record<string, string>): void;
|
||||
/**
|
||||
* Get all profiles from server
|
||||
* @returns Dictionary of profiles
|
||||
*/
|
||||
getProfiles(): Record<string, ISptProfile>;
|
||||
/**
|
||||
* Get the pmc and scav profiles as an array by profile id
|
||||
* @param sessionId
|
||||
* @returns Array of IPmcData objects
|
||||
*/
|
||||
getCompleteProfile(sessionId: string): IPmcData[];
|
||||
/**
|
||||
* Fix xp doubling on post-raid xp reward screen by sending a 'dummy' profile to the post-raid screen
|
||||
* Server saves the post-raid changes prior to the xp screen getting the profile, this results in the xp screen using
|
||||
* the now updated profile values as a base, meaning it shows x2 xp gained
|
||||
* Instead, clone the post-raid profile (so we dont alter its values), apply the pre-raid xp values to the cloned objects and return
|
||||
* Delete snapshot of pre-raid profile prior to returning profile data
|
||||
* @param sessionId Session id
|
||||
* @param output pmc and scav profiles array
|
||||
* @param pmcProfile post-raid pmc profile
|
||||
* @param scavProfile post-raid scav profile
|
||||
* @returns Updated profile array
|
||||
*/
|
||||
protected postRaidXpWorkaroundFix(sessionId: string, pmcProfile: IPmcData, scavProfile: IPmcData, output: IPmcData[]): IPmcData[];
|
||||
/**
|
||||
* Check if a nickname is used by another profile loaded by the server
|
||||
* @param nicknameRequest nickname request object
|
||||
* @param sessionID Session id
|
||||
* @returns True if already in use
|
||||
*/
|
||||
isNicknameTaken(nicknameRequest: IValidateNicknameRequestData, sessionID: string): boolean;
|
||||
protected profileHasInfoProperty(profile: ISptProfile): boolean;
|
||||
protected stringsMatch(stringA: string, stringB: string): boolean;
|
||||
/**
|
||||
* Add experience to a PMC inside the players profile
|
||||
* @param sessionID Session id
|
||||
* @param experienceToAdd Experience to add to PMC character
|
||||
*/
|
||||
addExperienceToPmc(sessionID: string, experienceToAdd: number): void;
|
||||
/**
|
||||
* Iterate all profiles and find matching pmc profile by provided id
|
||||
* @param pmcId Profile id to find
|
||||
* @returns IPmcData
|
||||
*/
|
||||
getProfileByPmcId(pmcId: string): IPmcData | undefined;
|
||||
/**
|
||||
* Get experience value for given level
|
||||
* @param level Level to get xp for
|
||||
* @returns Number of xp points for level
|
||||
*/
|
||||
getExperience(level: number): number;
|
||||
/**
|
||||
* Get the max level a player can be
|
||||
* @returns Max level
|
||||
*/
|
||||
getMaxLevel(): number;
|
||||
getDefaultSptDataObject(): any;
|
||||
/**
|
||||
* Get full representation of a players profile json
|
||||
* @param sessionID Profile id to get
|
||||
* @returns ISptProfile object
|
||||
*/
|
||||
getFullProfile(sessionID: string): ISptProfile | undefined;
|
||||
/**
|
||||
* Get a PMC profile by its session id
|
||||
* @param sessionID Profile id to return
|
||||
* @returns IPmcData object
|
||||
*/
|
||||
getPmcProfile(sessionID: string): IPmcData | undefined;
|
||||
/**
|
||||
* Is given user id a player
|
||||
* @param userId Id to validate
|
||||
* @returns True is a player
|
||||
*/
|
||||
isPlayer(userId: string): boolean;
|
||||
/**
|
||||
* Get a full profiles scav-specific sub-profile
|
||||
* @param sessionID Profiles id
|
||||
* @returns IPmcData object
|
||||
*/
|
||||
getScavProfile(sessionID: string): IPmcData;
|
||||
/**
|
||||
* Get baseline counter values for a fresh profile
|
||||
* @returns Default profile Stats object
|
||||
*/
|
||||
getDefaultCounters(): Stats;
|
||||
/**
|
||||
* is this profile flagged for data removal
|
||||
* @param sessionID Profile id
|
||||
* @returns True if profile is to be wiped of data/progress
|
||||
*/
|
||||
protected isWiped(sessionID: string): boolean;
|
||||
/**
|
||||
* Iterate over player profile inventory items and find the secure container and remove it
|
||||
* @param profile Profile to remove secure container from
|
||||
* @returns profile without secure container
|
||||
*/
|
||||
removeSecureContainer(profile: IPmcData): IPmcData;
|
||||
/**
|
||||
* Flag a profile as having received a gift
|
||||
* Store giftid in profile spt object
|
||||
* @param playerId Player to add gift flag to
|
||||
* @param giftId Gift player received
|
||||
* @param maxCount Limit of how many of this gift a player can have
|
||||
*/
|
||||
flagGiftReceivedInProfile(playerId: string, giftId: string, maxCount: number): void;
|
||||
/**
|
||||
* Check if profile has recieved a gift by id
|
||||
* @param playerId Player profile to check for gift
|
||||
* @param giftId Gift to check for
|
||||
* @param maxGiftCount Max times gift can be given to player
|
||||
* @returns True if player has recieved gift previously
|
||||
*/
|
||||
playerHasRecievedMaxNumberOfGift(playerId: string, giftId: string, maxGiftCount: number): boolean;
|
||||
/**
|
||||
* Find Stat in profile counters and increment by one
|
||||
* @param counters Counters to search for key
|
||||
* @param keyToIncrement Key
|
||||
*/
|
||||
incrementStatCounter(counters: CounterKeyValue[], keyToIncrement: string): void;
|
||||
/**
|
||||
* Check if player has a skill at elite level
|
||||
* @param skillType Skill to check
|
||||
* @param pmcProfile Profile to find skill in
|
||||
* @returns True if player has skill at elite level
|
||||
*/
|
||||
hasEliteSkillLevel(skillType: SkillTypes, pmcProfile: IPmcData): boolean;
|
||||
/**
|
||||
* Add points to a specific skill in player profile
|
||||
* @param skill Skill to add points to
|
||||
* @param pointsToAdd Points to add
|
||||
* @param pmcProfile Player profile with skill
|
||||
* @param useSkillProgressRateMultipler Skills are multiplied by a value in globals, default is off to maintain compatibility with legacy code
|
||||
* @returns
|
||||
*/
|
||||
addSkillPointsToPlayer(pmcProfile: IPmcData, skill: SkillTypes, pointsToAdd: number, useSkillProgressRateMultipler?: boolean): void;
|
||||
/**
|
||||
* Get a speciic common skill from supplied profile
|
||||
* @param pmcData Player profile
|
||||
* @param skill Skill to look up and return value from
|
||||
* @returns Common skill object from desired profile
|
||||
*/
|
||||
getSkillFromProfile(pmcData: IPmcData, skill: SkillTypes): Common;
|
||||
/**
|
||||
* Is the provided session id for a developer account
|
||||
* @param sessionID Profile id ot check
|
||||
* @returns True if account is developer
|
||||
*/
|
||||
isDeveloperAccount(sessionID: string): boolean;
|
||||
/**
|
||||
* Add stash row bonus to profile or increments rows given count if it already exists
|
||||
* @param sessionId Profile id to give rows to
|
||||
* @param rowsToAdd How many rows to give profile
|
||||
*/
|
||||
addStashRowsBonusToProfile(sessionId: string, rowsToAdd: number): void;
|
||||
playerIsFleaBanned(pmcProfile: IPmcData): boolean;
|
||||
/**
|
||||
* Add an achievement to player profile
|
||||
* @param pmcProfile Profile to add achievement to
|
||||
* @param achievementId Id of achievement to add
|
||||
*/
|
||||
addAchievementToProfile(pmcProfile: IPmcData, achievementId: string): void;
|
||||
hasAccessToRepeatableFreeRefreshSystem(pmcProfile: IPmcData): boolean;
|
||||
}
|
||||
8
types/helpers/QuestConditionHelper.d.ts
vendored
Normal file
8
types/helpers/QuestConditionHelper.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { IQuestCondition } from "@spt/models/eft/common/tables/IQuest";
|
||||
export declare class QuestConditionHelper {
|
||||
getQuestConditions(q: IQuestCondition[], furtherFilter?: (a: IQuestCondition) => IQuestCondition[]): IQuestCondition[];
|
||||
getLevelConditions(q: IQuestCondition[], furtherFilter?: (a: IQuestCondition) => IQuestCondition[]): IQuestCondition[];
|
||||
getLoyaltyConditions(q: IQuestCondition[], furtherFilter?: (a: IQuestCondition) => IQuestCondition[]): IQuestCondition[];
|
||||
getStandingConditions(q: IQuestCondition[], furtherFilter?: (a: IQuestCondition) => IQuestCondition[]): IQuestCondition[];
|
||||
protected filterConditions(q: IQuestCondition[], questType: string, furtherFilter?: (a: IQuestCondition) => IQuestCondition[]): IQuestCondition[];
|
||||
}
|
||||
289
types/helpers/QuestHelper.d.ts
vendored
Normal file
289
types/helpers/QuestHelper.d.ts
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
import { DialogueHelper } from "@spt/helpers/DialogueHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { QuestConditionHelper } from "@spt/helpers/QuestConditionHelper";
|
||||
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
|
||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { Common, IQuestStatus } from "@spt/models/eft/common/tables/IBotBase";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { IQuest, IQuestCondition, IQuestReward } from "@spt/models/eft/common/tables/IQuest";
|
||||
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { IAcceptQuestRequestData } from "@spt/models/eft/quests/IAcceptQuestRequestData";
|
||||
import { IFailQuestRequestData } from "@spt/models/eft/quests/IFailQuestRequestData";
|
||||
import { QuestStatus } from "@spt/models/enums/QuestStatus";
|
||||
import { IQuestConfig } from "@spt/models/spt/config/IQuestConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class QuestHelper {
|
||||
protected logger: ILogger;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected hashUtil: HashUtil;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected databaseService: DatabaseService;
|
||||
protected questConditionHelper: QuestConditionHelper;
|
||||
protected eventOutputHolder: EventOutputHolder;
|
||||
protected localeService: LocaleService;
|
||||
protected ragfairServerHelper: RagfairServerHelper;
|
||||
protected dialogueHelper: DialogueHelper;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected paymentHelper: PaymentHelper;
|
||||
protected localisationService: LocalisationService;
|
||||
protected seasonalEventService: SeasonalEventService;
|
||||
protected traderHelper: TraderHelper;
|
||||
protected presetHelper: PresetHelper;
|
||||
protected mailSendService: MailSendService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected questConfig: IQuestConfig;
|
||||
constructor(logger: ILogger, timeUtil: TimeUtil, hashUtil: HashUtil, itemHelper: ItemHelper, databaseService: DatabaseService, questConditionHelper: QuestConditionHelper, eventOutputHolder: EventOutputHolder, localeService: LocaleService, ragfairServerHelper: RagfairServerHelper, dialogueHelper: DialogueHelper, profileHelper: ProfileHelper, paymentHelper: PaymentHelper, localisationService: LocalisationService, seasonalEventService: SeasonalEventService, traderHelper: TraderHelper, presetHelper: PresetHelper, mailSendService: MailSendService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Get status of a quest in player profile by its id
|
||||
* @param pmcData Profile to search
|
||||
* @param questId Quest id to look up
|
||||
* @returns QuestStatus enum
|
||||
*/
|
||||
getQuestStatus(pmcData: IPmcData, questId: string): QuestStatus;
|
||||
/**
|
||||
* returns true is the level condition is satisfied
|
||||
* @param playerLevel Players level
|
||||
* @param condition Quest condition
|
||||
* @returns true if player level is greater than or equal to quest
|
||||
*/
|
||||
doesPlayerLevelFulfilCondition(playerLevel: number, condition: IQuestCondition): boolean;
|
||||
/**
|
||||
* Get the quests found in both arrays (inner join)
|
||||
* @param before Array of quests #1
|
||||
* @param after Array of quests #2
|
||||
* @returns Reduction of cartesian product between two quest arrays
|
||||
*/
|
||||
getDeltaQuests(before: IQuest[], after: IQuest[]): IQuest[];
|
||||
/**
|
||||
* Adjust skill experience for low skill levels, mimicing the official client
|
||||
* @param profileSkill the skill experience is being added to
|
||||
* @param progressAmount the amount of experience being added to the skill
|
||||
* @returns the adjusted skill progress gain
|
||||
*/
|
||||
adjustSkillExpForLowLevels(profileSkill: Common, progressAmount: number): number;
|
||||
/**
|
||||
* Get quest name by quest id
|
||||
* @param questId id to get
|
||||
* @returns
|
||||
*/
|
||||
getQuestNameFromLocale(questId: string): string;
|
||||
/**
|
||||
* Check if trader has sufficient loyalty to fulfill quest requirement
|
||||
* @param questProperties Quest props
|
||||
* @param profile Player profile
|
||||
* @returns true if loyalty is high enough to fulfill quest requirement
|
||||
*/
|
||||
traderLoyaltyLevelRequirementCheck(questProperties: IQuestCondition, profile: IPmcData): boolean;
|
||||
/**
|
||||
* Check if trader has sufficient standing to fulfill quest requirement
|
||||
* @param questProperties Quest props
|
||||
* @param profile Player profile
|
||||
* @returns true if standing is high enough to fulfill quest requirement
|
||||
*/
|
||||
traderStandingRequirementCheck(questProperties: IQuestCondition, profile: IPmcData): boolean;
|
||||
protected compareAvailableForValues(current: number, required: number, compareMethod: string): boolean;
|
||||
/**
|
||||
* Take reward item from quest and set FiR status + fix stack sizes + fix mod Ids
|
||||
* @param questReward Reward item to fix
|
||||
* @returns Fixed rewards
|
||||
*/
|
||||
protected processReward(questReward: IQuestReward): Item[];
|
||||
/**
|
||||
* Add missing mod items to a quest armor reward
|
||||
* @param originalRewardRootItem Original armor reward item from IQuestReward.items object
|
||||
* @param questReward Armor reward from quest
|
||||
*/
|
||||
protected generateArmorRewardChildSlots(originalRewardRootItem: Item, questReward: IQuestReward): void;
|
||||
/**
|
||||
* Gets a flat list of reward items for the given quest at a specific state (e.g. Fail/Success)
|
||||
* @param quest quest to get rewards for
|
||||
* @param status Quest status that holds the items (Started, Success, Fail)
|
||||
* @returns array of items with the correct maxStack
|
||||
*/
|
||||
getQuestRewardItems(quest: IQuest, status: QuestStatus): Item[];
|
||||
/**
|
||||
* Look up quest in db by accepted quest id and construct a profile-ready object ready to store in profile
|
||||
* @param pmcData Player profile
|
||||
* @param newState State the new quest should be in when returned
|
||||
* @param acceptedQuest Details of accepted quest from client
|
||||
*/
|
||||
getQuestReadyForProfile(pmcData: IPmcData, newState: QuestStatus, acceptedQuest: IAcceptQuestRequestData): IQuestStatus;
|
||||
/**
|
||||
* Get quests that can be shown to player after starting a quest
|
||||
* @param startedQuestId Quest started by player
|
||||
* @param sessionID Session id
|
||||
* @returns Quests accessible to player incuding newly unlocked quests now quest (startedQuestId) was started
|
||||
*/
|
||||
getNewlyAccessibleQuestsWhenStartingQuest(startedQuestId: string, sessionID: string): IQuest[];
|
||||
/**
|
||||
* Should a seasonal/event quest be shown to the player
|
||||
* @param questId Quest to check
|
||||
* @returns true = show to player
|
||||
*/
|
||||
showEventQuestToPlayer(questId: string): boolean;
|
||||
/**
|
||||
* Is the quest for the opposite side the player is on
|
||||
* @param playerSide Player side (usec/bear)
|
||||
* @param questId QuestId to check
|
||||
*/
|
||||
questIsForOtherSide(playerSide: string, questId: string): boolean;
|
||||
/**
|
||||
* Get quests that can be shown to player after failing a quest
|
||||
* @param failedQuestId Id of the quest failed by player
|
||||
* @param sessionId Session id
|
||||
* @returns IQuest array
|
||||
*/
|
||||
failedUnlocked(failedQuestId: string, sessionId: string): IQuest[];
|
||||
/**
|
||||
* Adjust quest money rewards by passed in multiplier
|
||||
* @param quest Quest to multiple money rewards
|
||||
* @param bonusPercent Value to adjust money rewards by
|
||||
* @param questStatus Status of quest to apply money boost to rewards of
|
||||
* @returns Updated quest
|
||||
*/
|
||||
applyMoneyBoost(quest: IQuest, bonusPercent: number, questStatus: QuestStatus): IQuest;
|
||||
/**
|
||||
* Sets the item stack to new value, or delete the item if value <= 0
|
||||
* // TODO maybe merge this function and the one from customization
|
||||
* @param pmcData Profile
|
||||
* @param itemId id of item to adjust stack size of
|
||||
* @param newStackSize Stack size to adjust to
|
||||
* @param sessionID Session id
|
||||
* @param output ItemEvent router response
|
||||
*/
|
||||
changeItemStack(pmcData: IPmcData, itemId: string, newStackSize: number, sessionID: string, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Add item stack change object into output route event response
|
||||
* @param output Response to add item change event into
|
||||
* @param sessionId Session id
|
||||
* @param item Item that was adjusted
|
||||
*/
|
||||
protected addItemStackSizeChangeIntoEventResponse(output: IItemEventRouterResponse, sessionId: string, item: Item): void;
|
||||
/**
|
||||
* Get quests, strip all requirement conditions except level
|
||||
* @param quests quests to process
|
||||
* @returns quest array without conditions
|
||||
*/
|
||||
protected getQuestsWithOnlyLevelRequirementStartCondition(quests: IQuest[]): IQuest[];
|
||||
/**
|
||||
* Remove all quest conditions except for level requirement
|
||||
* @param quest quest to clean
|
||||
* @returns reset IQuest object
|
||||
*/
|
||||
getQuestWithOnlyLevelRequirementStartCondition(quest: IQuest): IQuest;
|
||||
/**
|
||||
* Fail a quest in a player profile
|
||||
* @param pmcData Player profile
|
||||
* @param failRequest Fail quest request data
|
||||
* @param sessionID Session id
|
||||
* @param output Client output
|
||||
*/
|
||||
failQuest(pmcData: IPmcData, failRequest: IFailQuestRequestData, sessionID: string, output?: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Get List of All Quests from db
|
||||
* NOT CLONED
|
||||
* @returns Array of IQuest objects
|
||||
*/
|
||||
getQuestsFromDb(): IQuest[];
|
||||
/**
|
||||
* Get quest by id from database (repeatables are stored in profile, check there if questId not found)
|
||||
* @param questId Id of quest to find
|
||||
* @param pmcData Player profile
|
||||
* @returns IQuest object
|
||||
*/
|
||||
getQuestFromDb(questId: string, pmcData: IPmcData): IQuest;
|
||||
/**
|
||||
* Get a quests startedMessageText key from db, if no startedMessageText key found, use description key instead
|
||||
* @param startedMessageTextId startedMessageText property from IQuest
|
||||
* @param questDescriptionId description property from IQuest
|
||||
* @returns message id
|
||||
*/
|
||||
getMessageIdForQuestStart(startedMessageTextId: string, questDescriptionId: string): string;
|
||||
/**
|
||||
* Get the locale Id from locale db for a quest message
|
||||
* @param questMessageId Quest message id to look up
|
||||
* @returns Locale Id from locale db
|
||||
*/
|
||||
getQuestLocaleIdFromDb(questMessageId: string): string;
|
||||
/**
|
||||
* Alter a quests state + Add a record to its status timers object
|
||||
* @param pmcData Profile to update
|
||||
* @param newQuestState New state the quest should be in
|
||||
* @param questId Id of the quest to alter the status of
|
||||
*/
|
||||
updateQuestState(pmcData: IPmcData, newQuestState: QuestStatus, questId: string): void;
|
||||
/**
|
||||
* Resets a quests values back to its chosen state
|
||||
* @param pmcData Profile to update
|
||||
* @param newQuestState New state the quest should be in
|
||||
* @param questId Id of the quest to alter the status of
|
||||
*/
|
||||
resetQuestState(pmcData: IPmcData, newQuestState: QuestStatus, questId: string): void;
|
||||
/**
|
||||
* Give player quest rewards - Skills/exp/trader standing/items/assort unlocks - Returns reward items player earned
|
||||
* @param profileData Player profile (scav or pmc)
|
||||
* @param questId questId of quest to get rewards for
|
||||
* @param state State of the quest to get rewards for
|
||||
* @param sessionId Session id
|
||||
* @param questResponse Response to send back to client
|
||||
* @returns Array of reward objects
|
||||
*/
|
||||
applyQuestReward(profileData: IPmcData, questId: string, state: QuestStatus, sessionId: string, questResponse: IItemEventRouterResponse): Item[];
|
||||
/**
|
||||
* WIP - Find hideout craft id and add to unlockedProductionRecipe array in player profile
|
||||
* also update client response recipeUnlocked array with craft id
|
||||
* @param pmcData Player profile
|
||||
* @param craftUnlockReward Reward item from quest with craft unlock details
|
||||
* @param questDetails Quest with craft unlock reward
|
||||
* @param sessionID Session id
|
||||
* @param response Response to send back to client
|
||||
*/
|
||||
protected findAndAddHideoutProductionIdToProfile(pmcData: IPmcData, craftUnlockReward: IQuestReward, questDetails: IQuest, sessionID: string, response: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Get players money reward bonus from profile
|
||||
* @param pmcData player profile
|
||||
* @returns bonus as a percent
|
||||
*/
|
||||
protected getQuestMoneyRewardBonus(pmcData: IPmcData): number;
|
||||
/**
|
||||
* Find quest with 'findItem' condition that needs the item tpl be handed in
|
||||
* @param itemTpl item tpl to look for
|
||||
* @param questIds Quests to search through for the findItem condition
|
||||
* @returns quest id with 'FindItem' condition id
|
||||
*/
|
||||
getFindItemConditionByQuestItem(itemTpl: string, questIds: string[], allQuests: IQuest[]): Record<string, string>;
|
||||
/**
|
||||
* Add all quests to a profile with the provided statuses
|
||||
* @param pmcProfile profile to update
|
||||
* @param statuses statuses quests should have
|
||||
*/
|
||||
addAllQuestsToProfile(pmcProfile: IPmcData, statuses: QuestStatus[]): void;
|
||||
findAndRemoveQuestFromArrayIfExists(questId: string, quests: IQuestStatus[]): void;
|
||||
/**
|
||||
* Return a list of quests that would fail when supplied quest is completed
|
||||
* @param completedQuestId quest completed id
|
||||
* @returns array of IQuest objects
|
||||
*/
|
||||
getQuestsFailedByCompletingQuest(completedQuestId: string): IQuest[];
|
||||
/**
|
||||
* Get the hours a mails items can be collected for by profile type
|
||||
* @param pmcData Profile to get hours for
|
||||
* @returns Hours item will be available for
|
||||
*/
|
||||
getMailItemRedeemTimeHoursForProfile(pmcData: IPmcData): number;
|
||||
}
|
||||
47
types/helpers/RagfairHelper.d.ts
vendored
Normal file
47
types/helpers/RagfairHelper.d.ts
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { HandbookHelper } from "@spt/helpers/HandbookHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { TraderAssortHelper } from "@spt/helpers/TraderAssortHelper";
|
||||
import { UtilityHelper } from "@spt/helpers/UtilityHelper";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITraderAssort } from "@spt/models/eft/common/tables/ITrader";
|
||||
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
|
||||
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { RagfairLinkedItemService } from "@spt/services/RagfairLinkedItemService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
export declare class RagfairHelper {
|
||||
protected logger: ILogger;
|
||||
protected traderAssortHelper: TraderAssortHelper;
|
||||
protected databaseService: DatabaseService;
|
||||
protected handbookHelper: HandbookHelper;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected ragfairLinkedItemService: RagfairLinkedItemService;
|
||||
protected utilityHelper: UtilityHelper;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected ragfairConfig: IRagfairConfig;
|
||||
constructor(logger: ILogger, traderAssortHelper: TraderAssortHelper, databaseService: DatabaseService, handbookHelper: HandbookHelper, itemHelper: ItemHelper, ragfairLinkedItemService: RagfairLinkedItemService, utilityHelper: UtilityHelper, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Gets currency TAG from TPL
|
||||
* @param {string} currency
|
||||
* @returns string
|
||||
*/
|
||||
getCurrencyTag(currency: string): string;
|
||||
filterCategories(sessionID: string, request: ISearchRequestData): string[];
|
||||
getDisplayableAssorts(sessionID: string): Record<string, ITraderAssort>;
|
||||
protected getCategoryList(handbookId: string): string[];
|
||||
/**
|
||||
* Iterate over array of identical items and merge stack count
|
||||
* Ragfair allows abnormally large stacks.
|
||||
*/
|
||||
mergeStackable(items: Item[]): Item[];
|
||||
/**
|
||||
* Return the symbol for a currency
|
||||
* e.g. 5449016a4bdc2d6f028b456f return ₽
|
||||
* @param currencyTpl currency to get symbol for
|
||||
* @returns symbol of currency
|
||||
*/
|
||||
getCurrencySymbol(currencyTpl: string): string;
|
||||
}
|
||||
202
types/helpers/RagfairOfferHelper.d.ts
vendored
Normal file
202
types/helpers/RagfairOfferHelper.d.ts
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
import { BotHelper } from "@spt/helpers/BotHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
|
||||
import { PresetHelper } from "@spt/helpers/PresetHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { QuestHelper } from "@spt/helpers/QuestHelper";
|
||||
import { RagfairHelper } from "@spt/helpers/RagfairHelper";
|
||||
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
|
||||
import { RagfairSortHelper } from "@spt/helpers/RagfairSortHelper";
|
||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITraderAssort } from "@spt/models/eft/common/tables/ITrader";
|
||||
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
|
||||
import { ISearchRequestData } from "@spt/models/eft/ragfair/ISearchRequestData";
|
||||
import { IQuestConfig } from "@spt/models/spt/config/IQuestConfig";
|
||||
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { RagfairOfferService } from "@spt/services/RagfairOfferService";
|
||||
import { RagfairRequiredItemsService } from "@spt/services/RagfairRequiredItemsService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class RagfairOfferHelper {
|
||||
protected logger: ILogger;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected hashUtil: HashUtil;
|
||||
protected eventOutputHolder: EventOutputHolder;
|
||||
protected databaseService: DatabaseService;
|
||||
protected traderHelper: TraderHelper;
|
||||
protected saveServer: SaveServer;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected botHelper: BotHelper;
|
||||
protected paymentHelper: PaymentHelper;
|
||||
protected presetHelper: PresetHelper;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected questHelper: QuestHelper;
|
||||
protected ragfairServerHelper: RagfairServerHelper;
|
||||
protected ragfairSortHelper: RagfairSortHelper;
|
||||
protected ragfairHelper: RagfairHelper;
|
||||
protected ragfairOfferService: RagfairOfferService;
|
||||
protected ragfairRequiredItemsService: RagfairRequiredItemsService;
|
||||
protected localeService: LocaleService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected mailSendService: MailSendService;
|
||||
protected configServer: ConfigServer;
|
||||
protected static goodSoldTemplate: string;
|
||||
protected ragfairConfig: IRagfairConfig;
|
||||
protected questConfig: IQuestConfig;
|
||||
constructor(logger: ILogger, timeUtil: TimeUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, databaseService: DatabaseService, traderHelper: TraderHelper, saveServer: SaveServer, itemHelper: ItemHelper, botHelper: BotHelper, paymentHelper: PaymentHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, questHelper: QuestHelper, ragfairServerHelper: RagfairServerHelper, ragfairSortHelper: RagfairSortHelper, ragfairHelper: RagfairHelper, ragfairOfferService: RagfairOfferService, ragfairRequiredItemsService: RagfairRequiredItemsService, localeService: LocaleService, localisationService: LocalisationService, mailSendService: MailSendService, configServer: ConfigServer);
|
||||
/**
|
||||
* Passthrough to ragfairOfferService.getOffers(), get flea offers a player should see
|
||||
* @param searchRequest Data from client
|
||||
* @param itemsToAdd ragfairHelper.filterCategories()
|
||||
* @param traderAssorts Trader assorts
|
||||
* @param pmcData Player profile
|
||||
* @returns Offers the player should see
|
||||
*/
|
||||
getValidOffers(searchRequest: ISearchRequestData, itemsToAdd: string[], traderAssorts: Record<string, ITraderAssort>, pmcData: IPmcData): IRagfairOffer[];
|
||||
/**
|
||||
* Get matching offers that require the desired item and filter out offers from non traders if player is below ragfair unlock level
|
||||
* @param searchRequest Search request from client
|
||||
* @param pmcDataPlayer profile
|
||||
* @returns Matching IRagfairOffer objects
|
||||
*/
|
||||
getOffersThatRequireItem(searchRequest: ISearchRequestData, pmcData: IPmcData): IRagfairOffer[];
|
||||
/**
|
||||
* Get offers from flea/traders specifically when building weapon preset
|
||||
* @param searchRequest Search request data
|
||||
* @param itemsToAdd string array of item tpls to search for
|
||||
* @param traderAssorts All trader assorts player can access/buy
|
||||
* @param pmcData Player profile
|
||||
* @returns IRagfairOffer array
|
||||
*/
|
||||
getOffersForBuild(searchRequest: ISearchRequestData, itemsToAdd: string[], traderAssorts: Record<string, ITraderAssort>, pmcData: IPmcData): IRagfairOffer[];
|
||||
/**
|
||||
* Check if offer is from trader standing the player does not have
|
||||
* @param offer Offer to check
|
||||
* @param pmcProfile Player profile
|
||||
* @returns True if item is locked, false if item is purchaseable
|
||||
*/
|
||||
protected traderOfferLockedBehindLoyaltyLevel(offer: IRagfairOffer, pmcProfile: IPmcData): boolean;
|
||||
/**
|
||||
* Check if offer item is quest locked for current player by looking at sptQuestLocked property in traders barter_scheme
|
||||
* @param offer Offer to check is quest locked
|
||||
* @param traderAssorts all trader assorts for player
|
||||
* @returns true if quest locked
|
||||
*/
|
||||
traderOfferItemQuestLocked(offer: IRagfairOffer, traderAssorts: Record<string, ITraderAssort>): boolean;
|
||||
/**
|
||||
* Has a traders offer ran out of stock to sell to player
|
||||
* @param offer Offer to check stock of
|
||||
* @returns true if out of stock
|
||||
*/
|
||||
protected traderOutOfStock(offer: IRagfairOffer): boolean;
|
||||
/**
|
||||
* Check if trader offers' BuyRestrictionMax value has been reached
|
||||
* @param offer offer to check restriction properties of
|
||||
* @returns true if restriction reached, false if no restrictions/not reached
|
||||
*/
|
||||
protected traderBuyRestrictionReached(offer: IRagfairOffer): boolean;
|
||||
/**
|
||||
* Get an array of flea offers that are inaccessible to player due to their inadequate loyalty level
|
||||
* @param offers Offers to check
|
||||
* @param pmcProfile Players profile with trader loyalty levels
|
||||
* @returns array of offer ids player cannot see
|
||||
*/
|
||||
protected getLoyaltyLockedOffers(offers: IRagfairOffer[], pmcProfile: IPmcData): string[];
|
||||
/**
|
||||
* Process all player-listed flea offers for a desired profile
|
||||
* @param sessionID Session id to process offers for
|
||||
* @returns true = complete
|
||||
*/
|
||||
processOffersOnProfile(sessionID: string): boolean;
|
||||
/**
|
||||
* Count up all rootitem StackObjectsCount properties of an array of items
|
||||
* @param itemsInInventoryToList items to sum up
|
||||
* @returns Total count
|
||||
*/
|
||||
getTotalStackCountSize(itemsInInventoryToList: Item[][]): number;
|
||||
/**
|
||||
* Add amount to players ragfair rating
|
||||
* @param sessionId Profile to update
|
||||
* @param amountToIncrementBy Raw amount to add to players ragfair rating (excluding the reputation gain multiplier)
|
||||
*/
|
||||
increaseProfileRagfairRating(profile: ISptProfile, amountToIncrementBy: number): void;
|
||||
/**
|
||||
* Return all offers a player has listed on a desired profile
|
||||
* @param sessionID Session id
|
||||
* @returns Array of ragfair offers
|
||||
*/
|
||||
protected getProfileOffers(sessionID: string): IRagfairOffer[];
|
||||
/**
|
||||
* Delete an offer from a desired profile and from ragfair offers
|
||||
* @param sessionID Session id of profile to delete offer from
|
||||
* @param offerId Id of offer to delete
|
||||
*/
|
||||
protected deleteOfferById(sessionID: string, offerId: string): void;
|
||||
/**
|
||||
* Complete the selling of players' offer
|
||||
* @param sessionID Session id
|
||||
* @param offer Sold offer details
|
||||
* @param boughtAmount Amount item was purchased for
|
||||
* @returns IItemEventRouterResponse
|
||||
*/
|
||||
protected completeOffer(sessionID: string, offer: IRagfairOffer, boughtAmount: number): IItemEventRouterResponse;
|
||||
/**
|
||||
* Get a localised message for when players offer has sold on flea
|
||||
* @param itemTpl Item sold
|
||||
* @param boughtAmount How many were purchased
|
||||
* @returns Localised message text
|
||||
*/
|
||||
protected getLocalisedOfferSoldMessage(itemTpl: string, boughtAmount: number): string;
|
||||
/**
|
||||
* Check an offer passes the various search criteria the player requested
|
||||
* @param searchRequest
|
||||
* @param offer
|
||||
* @param pmcData
|
||||
* @returns True
|
||||
*/
|
||||
protected passesSearchFilterCriteria(searchRequest: ISearchRequestData, offer: IRagfairOffer, pmcData: IPmcData): boolean;
|
||||
/**
|
||||
* Check that the passed in offer item is functional
|
||||
* @param offerRootItem The root item of the offer
|
||||
* @param offer The flea offer
|
||||
* @returns True if the given item is functional
|
||||
*/
|
||||
isItemFunctional(offerRootItem: Item, offer: IRagfairOffer): boolean;
|
||||
/**
|
||||
* Should a ragfair offer be visible to the player
|
||||
* @param searchRequest Search request
|
||||
* @param itemsToAdd ?
|
||||
* @param traderAssorts Trader assort items
|
||||
* @param offer The flea offer
|
||||
* @param pmcProfile Player profile
|
||||
* @returns True = should be shown to player
|
||||
*/
|
||||
isDisplayableOffer(searchRequest: ISearchRequestData, itemsToAdd: string[], traderAssorts: Record<string, ITraderAssort>, offer: IRagfairOffer, pmcProfile: IPmcData, playerIsFleaBanned?: boolean): boolean;
|
||||
isDisplayableOfferThatNeedsItem(searchRequest: ISearchRequestData, offer: IRagfairOffer): boolean;
|
||||
/**
|
||||
* Does the passed in item have a condition property
|
||||
* @param item Item to check
|
||||
* @returns True if has condition
|
||||
*/
|
||||
protected isConditionItem(item: Item): boolean;
|
||||
/**
|
||||
* Is items quality value within desired range
|
||||
* @param item Item to check quality of
|
||||
* @param min Desired minimum quality
|
||||
* @param max Desired maximum quality
|
||||
* @returns True if in range
|
||||
*/
|
||||
protected itemQualityInRange(item: Item, min: number, max: number): boolean;
|
||||
}
|
||||
32
types/helpers/RagfairSellHelper.d.ts
vendored
Normal file
32
types/helpers/RagfairSellHelper.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { SellResult } from "@spt/models/eft/ragfair/IRagfairOffer";
|
||||
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class RagfairSellHelper {
|
||||
protected logger: ILogger;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected databaseService: DatabaseService;
|
||||
protected configServer: ConfigServer;
|
||||
protected ragfairConfig: IRagfairConfig;
|
||||
constructor(logger: ILogger, randomUtil: RandomUtil, timeUtil: TimeUtil, databaseService: DatabaseService, configServer: ConfigServer);
|
||||
/**
|
||||
* Get the percent chance to sell an item based on its average listed price vs player chosen listing price
|
||||
* @param averageOfferPriceRub Price of average offer in roubles
|
||||
* @param playerListedPriceRub Price player listed item for in roubles
|
||||
* @param qualityMultiplier Quality multipler of item being sold
|
||||
* @returns percent value
|
||||
*/
|
||||
calculateSellChance(averageOfferPriceRub: number, playerListedPriceRub: number, qualityMultiplier: number): number;
|
||||
/**
|
||||
* Get array of item count and sell time (empty array = no sell)
|
||||
* @param sellChancePercent chance item will sell
|
||||
* @param itemSellCount count of items to sell
|
||||
* @param sellInOneGo All items listed get sold at once
|
||||
* @returns Array of purchases of item(s) listed
|
||||
*/
|
||||
rollForSale(sellChancePercent: number, itemSellCount: number, sellInOneGo?: boolean): SellResult[];
|
||||
}
|
||||
87
types/helpers/RagfairServerHelper.d.ts
vendored
Normal file
87
types/helpers/RagfairServerHelper.d.ts
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { IQuestConfig } from "@spt/models/spt/config/IQuestConfig";
|
||||
import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ItemFilterService } from "@spt/services/ItemFilterService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { MailSendService } from "@spt/services/MailSendService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
/**
|
||||
* Helper class for common ragfair server actions
|
||||
*/
|
||||
export declare class RagfairServerHelper {
|
||||
protected logger: ILogger;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected saveServer: SaveServer;
|
||||
protected databaseService: DatabaseService;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected traderHelper: TraderHelper;
|
||||
protected mailSendService: MailSendService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected itemFilterService: ItemFilterService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected ragfairConfig: IRagfairConfig;
|
||||
protected questConfig: IQuestConfig;
|
||||
protected static goodsReturnedTemplate: string;
|
||||
constructor(logger: ILogger, randomUtil: RandomUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseService: DatabaseService, profileHelper: ProfileHelper, itemHelper: ItemHelper, traderHelper: TraderHelper, mailSendService: MailSendService, localisationService: LocalisationService, itemFilterService: ItemFilterService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Is item valid / on blacklist / quest item
|
||||
* @param itemDetails
|
||||
* @returns boolean
|
||||
*/
|
||||
isItemValidRagfairItem(itemDetails: [boolean, ITemplateItem]): boolean;
|
||||
/**
|
||||
* Is supplied item tpl on the ragfair custom blacklist from configs/ragfair.json/dynamic
|
||||
* @param itemTemplateId Item tpl to check is blacklisted
|
||||
* @returns True if its blacklsited
|
||||
*/
|
||||
protected isItemOnCustomFleaBlacklist(itemTemplateId: string): boolean;
|
||||
/**
|
||||
* Is supplied parent id on the ragfair custom item category blacklist
|
||||
* @param parentId Parent Id to check is blacklisted
|
||||
* @returns true if blacklisted
|
||||
*/
|
||||
protected isItemCategoryOnCustomFleaBlacklist(itemParentId: string): boolean;
|
||||
/**
|
||||
* is supplied id a trader
|
||||
* @param traderId
|
||||
* @returns True if id was a trader
|
||||
*/
|
||||
isTrader(traderId: string): boolean;
|
||||
/**
|
||||
* Send items back to player
|
||||
* @param sessionID Player to send items to
|
||||
* @param returnedItems Items to send to player
|
||||
*/
|
||||
returnItems(sessionID: string, returnedItems: Item[]): void;
|
||||
calculateDynamicStackCount(tplId: string, isWeaponPreset: boolean): number;
|
||||
/**
|
||||
* Choose a currency at random with bias
|
||||
* @returns currency tpl
|
||||
*/
|
||||
getDynamicOfferCurrency(): string;
|
||||
/**
|
||||
* Given a preset id from globals.json, return an array of items[] with unique ids
|
||||
* @param item Preset item
|
||||
* @returns Array of weapon and its children
|
||||
*/
|
||||
getPresetItems(item: Item): Item[];
|
||||
/**
|
||||
* Possible bug, returns all items associated with an items tpl, could be multiple presets from globals.json
|
||||
* @param item Preset item
|
||||
* @returns
|
||||
*/
|
||||
getPresetItemsByTpl(item: Item): Item[];
|
||||
}
|
||||
29
types/helpers/RagfairSortHelper.d.ts
vendored
Normal file
29
types/helpers/RagfairSortHelper.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { IRagfairOffer } from "@spt/models/eft/ragfair/IRagfairOffer";
|
||||
import { RagfairSort } from "@spt/models/enums/RagfairSort";
|
||||
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
||||
import { LocaleService } from "@spt/services/LocaleService";
|
||||
export declare class RagfairSortHelper {
|
||||
protected databaseServer: DatabaseServer;
|
||||
protected localeService: LocaleService;
|
||||
constructor(databaseServer: DatabaseServer, localeService: LocaleService);
|
||||
/**
|
||||
* Sort a list of ragfair offers by something (id/rating/offer name/price/expiry time)
|
||||
* @param offers Offers to sort
|
||||
* @param type How to sort it
|
||||
* @param direction Ascending/descending
|
||||
* @returns Sorted offers
|
||||
*/
|
||||
sortOffers(offers: IRagfairOffer[], type: RagfairSort, direction?: number): IRagfairOffer[];
|
||||
protected sortOffersByID(a: IRagfairOffer, b: IRagfairOffer): number;
|
||||
protected sortOffersByBarter(a: IRagfairOffer, b: IRagfairOffer): number;
|
||||
protected sortOffersByRating(a: IRagfairOffer, b: IRagfairOffer): number;
|
||||
protected sortOffersByName(a: IRagfairOffer, b: IRagfairOffer): number;
|
||||
/**
|
||||
* Order two offers by rouble price value
|
||||
* @param a Offer a
|
||||
* @param b Offer b
|
||||
* @returns
|
||||
*/
|
||||
protected sortOffersByPrice(a: IRagfairOffer, b: IRagfairOffer): number;
|
||||
protected sortOffersByExpiry(a: IRagfairOffer, b: IRagfairOffer): number;
|
||||
}
|
||||
46
types/helpers/RepairHelper.d.ts
vendored
Normal file
46
types/helpers/RepairHelper.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem, Props } from "@spt/models/eft/common/tables/ITemplateItem";
|
||||
import { IRepairConfig } from "@spt/models/spt/config/IRepairConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
export declare class RepairHelper {
|
||||
protected logger: ILogger;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected databaseService: DatabaseService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected repairConfig: IRepairConfig;
|
||||
constructor(logger: ILogger, randomUtil: RandomUtil, databaseService: DatabaseService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Alter an items durability after a repair by trader/repair kit
|
||||
* @param itemToRepair item to update durability details
|
||||
* @param itemToRepairDetails db details of item to repair
|
||||
* @param isArmor Is item being repaired a piece of armor
|
||||
* @param amountToRepair how many unit of durability to repair
|
||||
* @param useRepairKit Is item being repaired with a repair kit
|
||||
* @param traderQualityMultipler Trader quality value from traders base json
|
||||
* @param applyMaxDurabilityDegradation should item have max durability reduced
|
||||
*/
|
||||
updateItemDurability(itemToRepair: Item, itemToRepairDetails: ITemplateItem, isArmor: boolean, amountToRepair: number, useRepairKit: boolean, traderQualityMultipler: number, applyMaxDurabilityDegradation?: boolean): void;
|
||||
/**
|
||||
* Repairing armor reduces the total durability value slightly, get a randomised (to 2dp) amount based on armor material
|
||||
* @param armorMaterial What material is the armor being repaired made of
|
||||
* @param isRepairKit Was a repair kit used
|
||||
* @param armorMax Max amount of durability item can have
|
||||
* @param traderQualityMultipler Different traders produce different loss values
|
||||
* @returns Amount to reduce max durability by
|
||||
*/
|
||||
protected getRandomisedArmorRepairDegradationValue(armorMaterial: string, isRepairKit: boolean, armorMax: number, traderQualityMultipler: number): number;
|
||||
/**
|
||||
* Repairing weapons reduces the total durability value slightly, get a randomised (to 2dp) amount
|
||||
* @param itemProps Weapon properties
|
||||
* @param isRepairKit Was a repair kit used
|
||||
* @param weaponMax ax amount of durability item can have
|
||||
* @param traderQualityMultipler Different traders produce different loss values
|
||||
* @returns Amount to reduce max durability by
|
||||
*/
|
||||
protected getRandomisedWeaponRepairDegradationValue(itemProps: Props, isRepairKit: boolean, weaponMax: number, traderQualityMultipler: number): number;
|
||||
}
|
||||
20
types/helpers/RepeatableQuestHelper.d.ts
vendored
Normal file
20
types/helpers/RepeatableQuestHelper.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "@spt/models/spt/config/IQuestConfig";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { ProbabilityObject, ProbabilityObjectArray } from "@spt/utils/RandomUtil";
|
||||
export declare class RepeatableQuestHelper {
|
||||
protected mathUtil: MathUtil;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected questConfig: IQuestConfig;
|
||||
constructor(mathUtil: MathUtil, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Get the relevant elimination config based on the current players PMC level
|
||||
* @param pmcLevel Level of PMC character
|
||||
* @param repeatableConfig Main repeatable config
|
||||
* @returns IEliminationConfig
|
||||
*/
|
||||
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
|
||||
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
|
||||
}
|
||||
18
types/helpers/SecureContainerHelper.d.ts
vendored
Normal file
18
types/helpers/SecureContainerHelper.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
export interface OwnerInventoryItems {
|
||||
from: Item[];
|
||||
to: Item[];
|
||||
sameInventory: boolean;
|
||||
isMail: boolean;
|
||||
}
|
||||
export declare class SecureContainerHelper {
|
||||
protected itemHelper: ItemHelper;
|
||||
constructor(itemHelper: ItemHelper);
|
||||
/**
|
||||
* Get an array of the item IDs (NOT tpls) inside a secure container
|
||||
* @param items Inventory items to look for secure container in
|
||||
* @returns Array of ids
|
||||
*/
|
||||
getSecureContainerItems(items: Item[]): string[];
|
||||
}
|
||||
69
types/helpers/TradeHelper.d.ts
vendored
Normal file
69
types/helpers/TradeHelper.d.ts
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { TraderAssortHelper } from "@spt/helpers/TraderAssortHelper";
|
||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { IProcessBuyTradeRequestData } from "@spt/models/eft/trade/IProcessBuyTradeRequestData";
|
||||
import { IProcessSellTradeRequestData } from "@spt/models/eft/trade/IProcessSellTradeRequestData";
|
||||
import { IInventoryConfig } from "@spt/models/spt/config/IInventoryConfig";
|
||||
import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { RagfairServer } from "@spt/servers/RagfairServer";
|
||||
import { FenceService } from "@spt/services/FenceService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { PaymentService } from "@spt/services/PaymentService";
|
||||
import { TraderPurchasePersisterService } from "@spt/services/TraderPurchasePersisterService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||
export declare class TradeHelper {
|
||||
protected logger: ILogger;
|
||||
protected eventOutputHolder: EventOutputHolder;
|
||||
protected traderHelper: TraderHelper;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected paymentService: PaymentService;
|
||||
protected fenceService: FenceService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected httpResponse: HttpResponseUtil;
|
||||
protected inventoryHelper: InventoryHelper;
|
||||
protected ragfairServer: RagfairServer;
|
||||
protected traderAssortHelper: TraderAssortHelper;
|
||||
protected traderPurchasePersisterService: TraderPurchasePersisterService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected traderConfig: ITraderConfig;
|
||||
protected inventoryConfig: IInventoryConfig;
|
||||
constructor(logger: ILogger, eventOutputHolder: EventOutputHolder, traderHelper: TraderHelper, itemHelper: ItemHelper, paymentService: PaymentService, fenceService: FenceService, localisationService: LocalisationService, httpResponse: HttpResponseUtil, inventoryHelper: InventoryHelper, ragfairServer: RagfairServer, traderAssortHelper: TraderAssortHelper, traderPurchasePersisterService: TraderPurchasePersisterService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Buy item from flea or trader
|
||||
* @param pmcData Player profile
|
||||
* @param buyRequestData data from client
|
||||
* @param sessionID Session id
|
||||
* @param foundInRaid Should item be found in raid
|
||||
* @param output IItemEventRouterResponse
|
||||
* @returns IItemEventRouterResponse
|
||||
*/
|
||||
buyItem(pmcData: IPmcData, buyRequestData: IProcessBuyTradeRequestData, sessionID: string, foundInRaid: boolean, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Sell item to trader
|
||||
* @param profileWithItemsToSell Profile to remove items from
|
||||
* @param profileToReceiveMoney Profile to accept the money for selling item
|
||||
* @param sellRequest Request data
|
||||
* @param sessionID Session id
|
||||
* @param output IItemEventRouterResponse
|
||||
*/
|
||||
sellItem(profileWithItemsToSell: IPmcData, profileToReceiveMoney: IPmcData, sellRequest: IProcessSellTradeRequestData, sessionID: string, output: IItemEventRouterResponse): void;
|
||||
/**
|
||||
* Traders allow a limited number of purchases per refresh cycle (default 60 mins)
|
||||
* @param sessionId Session id
|
||||
* @param pmcData Profile making the purchase
|
||||
* @param traderId Trader assort is purchased from
|
||||
* @param assortBeingPurchased the item from trader being bought
|
||||
* @param assortId Id of assort being purchased
|
||||
* @param count How many of the item are being bought
|
||||
*/
|
||||
protected checkPurchaseIsWithinTraderItemLimit(sessionId: string, pmcData: IPmcData, traderId: string, assortBeingPurchased: Item, assortId: string, count: number): void;
|
||||
}
|
||||
94
types/helpers/TraderAssortHelper.d.ts
vendored
Normal file
94
types/helpers/TraderAssortHelper.d.ts
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
import { RagfairAssortGenerator } from "@spt/generators/RagfairAssortGenerator";
|
||||
import { RagfairOfferGenerator } from "@spt/generators/RagfairOfferGenerator";
|
||||
import { AssortHelper } from "@spt/helpers/AssortHelper";
|
||||
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ITrader, ITraderAssort } from "@spt/models/eft/common/tables/ITrader";
|
||||
import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { FenceService } from "@spt/services/FenceService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { TraderAssortService } from "@spt/services/TraderAssortService";
|
||||
import { TraderPurchasePersisterService } from "@spt/services/TraderPurchasePersisterService";
|
||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||
import { MathUtil } from "@spt/utils/MathUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class TraderAssortHelper {
|
||||
protected logger: ILogger;
|
||||
protected mathUtil: MathUtil;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected databaseService: DatabaseService;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected assortHelper: AssortHelper;
|
||||
protected paymentHelper: PaymentHelper;
|
||||
protected ragfairAssortGenerator: RagfairAssortGenerator;
|
||||
protected ragfairOfferGenerator: RagfairOfferGenerator;
|
||||
protected traderAssortService: TraderAssortService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected traderPurchasePersisterService: TraderPurchasePersisterService;
|
||||
protected traderHelper: TraderHelper;
|
||||
protected fenceService: FenceService;
|
||||
protected configServer: ConfigServer;
|
||||
protected cloner: ICloner;
|
||||
protected traderConfig: ITraderConfig;
|
||||
protected mergedQuestAssorts: Record<string, Record<string, string>>;
|
||||
protected createdMergedQuestAssorts: boolean;
|
||||
constructor(logger: ILogger, mathUtil: MathUtil, timeUtil: TimeUtil, databaseService: DatabaseService, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, localisationService: LocalisationService, traderPurchasePersisterService: TraderPurchasePersisterService, traderHelper: TraderHelper, fenceService: FenceService, configServer: ConfigServer, cloner: ICloner);
|
||||
/**
|
||||
* Get a traders assorts
|
||||
* Can be used for returning ragfair / fence assorts
|
||||
* Filter out assorts not unlocked due to level OR quest completion
|
||||
* @param sessionId session id
|
||||
* @param traderId traders id
|
||||
* @param flea Should assorts player hasn't unlocked be returned - default false
|
||||
* @returns a traders' assorts
|
||||
*/
|
||||
getAssort(sessionId: string, traderId: string, flea?: boolean): ITraderAssort;
|
||||
/**
|
||||
* Given the blacklist provided, remove root items from assort
|
||||
* @param assortToFilter Trader assort to modify
|
||||
* @param itemsTplsToRemove Item TPLs the assort should not have
|
||||
*/
|
||||
protected removeItemsFromAssort(assortToFilter: ITraderAssort, itemsTplsToRemove: string[]): void;
|
||||
/**
|
||||
* Reset every traders root item `BuyRestrictionCurrent` property to 0
|
||||
* @param assortItems Items to adjust
|
||||
*/
|
||||
protected resetBuyRestrictionCurrentValue(assortItems: Item[]): void;
|
||||
/**
|
||||
* Create a dict of all assort id = quest id mappings used to work out what items should be shown to player based on the quests they've started/completed/failed
|
||||
*/
|
||||
protected hydrateMergedQuestAssorts(): void;
|
||||
/**
|
||||
* Reset a traders assorts and move nextResupply value to future
|
||||
* Flag trader as needing a flea offer reset to be picked up by flea update() function
|
||||
* @param trader trader details to alter
|
||||
*/
|
||||
resetExpiredTrader(trader: ITrader): void;
|
||||
/**
|
||||
* Does the supplied trader need its assorts refreshed
|
||||
* @param traderID Trader to check
|
||||
* @returns true they need refreshing
|
||||
*/
|
||||
traderAssortsHaveExpired(traderID: string): boolean;
|
||||
/**
|
||||
* Iterate over all assorts barter_scheme values, find barters selling for money and multiply by multipler in config
|
||||
* @param traderAssort Assorts to multiple price of
|
||||
*/
|
||||
protected multiplyItemPricesByConfigMultiplier(traderAssort: ITraderAssort): void;
|
||||
/**
|
||||
* Get an array of pristine trader items prior to any alteration by player (as they were on server start)
|
||||
* @param traderId trader id
|
||||
* @returns array of Items
|
||||
*/
|
||||
protected getPristineTraderAssorts(traderId: string): Item[];
|
||||
/**
|
||||
* Returns generated ragfair offers in a trader assort format
|
||||
* @returns Trader assort object
|
||||
*/
|
||||
protected getRagfairDataAsTraderAssort(): ITraderAssort;
|
||||
}
|
||||
187
types/helpers/TraderHelper.d.ts
vendored
Normal file
187
types/helpers/TraderHelper.d.ts
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
import { HandbookHelper } from "@spt/helpers/HandbookHelper";
|
||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||
import { ProfileTraderTemplate } from "@spt/models/eft/common/tables/IProfileTemplate";
|
||||
import { ITraderAssort, ITraderBase, LoyaltyLevel } from "@spt/models/eft/common/tables/ITrader";
|
||||
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { Traders } from "@spt/models/enums/Traders";
|
||||
import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { FenceService } from "@spt/services/FenceService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { PlayerService } from "@spt/services/PlayerService";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
export declare class TraderHelper {
|
||||
protected logger: ILogger;
|
||||
protected databaseService: DatabaseService;
|
||||
protected profileHelper: ProfileHelper;
|
||||
protected handbookHelper: HandbookHelper;
|
||||
protected itemHelper: ItemHelper;
|
||||
protected playerService: PlayerService;
|
||||
protected localisationService: LocalisationService;
|
||||
protected fenceService: FenceService;
|
||||
protected timeUtil: TimeUtil;
|
||||
protected randomUtil: RandomUtil;
|
||||
protected configServer: ConfigServer;
|
||||
protected traderConfig: ITraderConfig;
|
||||
/** Dictionary of item tpl and the highest trader sell rouble price */
|
||||
protected highestTraderPriceItems?: Record<string, number>;
|
||||
constructor(logger: ILogger, databaseService: DatabaseService, profileHelper: ProfileHelper, handbookHelper: HandbookHelper, itemHelper: ItemHelper, playerService: PlayerService, localisationService: LocalisationService, fenceService: FenceService, timeUtil: TimeUtil, randomUtil: RandomUtil, configServer: ConfigServer);
|
||||
/**
|
||||
* Get a trader base object, update profile to reflect players current standing in profile
|
||||
* when trader not found in profile
|
||||
* @param traderID Traders Id to get
|
||||
* @param sessionID Players id
|
||||
* @returns Trader base
|
||||
*/
|
||||
getTrader(traderID: string, sessionID: string): ITraderBase | undefined;
|
||||
/**
|
||||
* Get all assort data for a particular trader
|
||||
* @param traderId Trader to get assorts for
|
||||
* @returns ITraderAssort
|
||||
*/
|
||||
getTraderAssortsByTraderId(traderId: string): ITraderAssort;
|
||||
/**
|
||||
* Retrieve the Item from a traders assort data by its id
|
||||
* @param traderId Trader to get assorts for
|
||||
* @param assortId Id of assort to find
|
||||
* @returns Item object
|
||||
*/
|
||||
getTraderAssortItemByAssortId(traderId: string, assortId: string): Item | undefined;
|
||||
/**
|
||||
* Reset a profiles trader data back to its initial state as seen by a level 1 player
|
||||
* Does NOT take into account different profile levels
|
||||
* @param sessionID session id of player
|
||||
* @param traderID trader id to reset
|
||||
*/
|
||||
resetTrader(sessionID: string, traderID: string): void;
|
||||
/**
|
||||
* Get the starting standing of a trader based on the current profiles type (e.g. EoD, Standard etc)
|
||||
* @param traderId Trader id to get standing for
|
||||
* @param rawProfileTemplate Raw profile from profiles.json to look up standing from
|
||||
* @returns Standing value
|
||||
*/
|
||||
protected getStartingStanding(traderId: string, rawProfileTemplate: ProfileTraderTemplate): number;
|
||||
/**
|
||||
* Add an array of suit ids to a profiles suit array, no duplicates
|
||||
* @param fullProfile Profile to add to
|
||||
* @param suitIds Suit Ids to add
|
||||
*/
|
||||
protected addSuitsToProfile(fullProfile: ISptProfile, suitIds: string[]): void;
|
||||
/**
|
||||
* Alter a traders unlocked status
|
||||
* @param traderId Trader to alter
|
||||
* @param status New status to use
|
||||
* @param sessionId Session id of player
|
||||
*/
|
||||
setTraderUnlockedState(traderId: string, status: boolean, sessionId: string): void;
|
||||
/**
|
||||
* Add standing to a trader and level them up if exp goes over level threshold
|
||||
* @param sessionId Session id of player
|
||||
* @param traderId Traders id to add standing to
|
||||
* @param standingToAdd Standing value to add to trader
|
||||
*/
|
||||
addStandingToTrader(sessionId: string, traderId: string, standingToAdd: number): void;
|
||||
/**
|
||||
* Add standing to current standing and clamp value if it goes too low
|
||||
* @param currentStanding current trader standing
|
||||
* @param standingToAdd stansding to add to trader standing
|
||||
* @returns current standing + added standing (clamped if needed)
|
||||
*/
|
||||
protected addStandingValuesTogether(currentStanding: number, standingToAdd: number): number;
|
||||
/**
|
||||
* iterate over a profiles traders and ensure they have the correct loyaltyLevel for the player
|
||||
* @param sessionId Profile to check
|
||||
*/
|
||||
validateTraderStandingsAndPlayerLevelForProfile(sessionId: string): void;
|
||||
/**
|
||||
* Calculate traders level based on exp amount and increments level if over threshold
|
||||
* Also validates and updates player level if not correct based on XP value
|
||||
* @param traderID Trader to check standing of
|
||||
* @param pmcData Profile to update trader in
|
||||
*/
|
||||
lvlUp(traderID: string, pmcData: IPmcData): void;
|
||||
/**
|
||||
* Get the next update timestamp for a trader
|
||||
* @param traderID Trader to look up update value for
|
||||
* @returns future timestamp
|
||||
*/
|
||||
getNextUpdateTimestamp(traderID: string): number;
|
||||
/**
|
||||
* Get the reset time between trader assort refreshes in seconds
|
||||
* @param traderId Trader to look up
|
||||
* @returns Time in seconds
|
||||
*/
|
||||
getTraderUpdateSeconds(traderId: string): number | undefined;
|
||||
getLoyaltyLevel(traderID: string, pmcData: IPmcData): LoyaltyLevel;
|
||||
/**
|
||||
* Store the purchase of an assort from a trader in the player profile
|
||||
* @param sessionID Session id
|
||||
* @param newPurchaseDetails New item assort id + count
|
||||
*/
|
||||
addTraderPurchasesToPlayerProfile(sessionID: string, newPurchaseDetails: {
|
||||
items: {
|
||||
itemId: string;
|
||||
count: number;
|
||||
}[];
|
||||
traderId: string;
|
||||
}, itemPurchased: Item): void;
|
||||
/**
|
||||
* EoD and Unheard get a 20% bonus to personal trader limit purchases
|
||||
* @param buyRestrictionMax Existing value from trader item
|
||||
* @param gameVersion Profiles game version
|
||||
* @returns buyRestrictionMax value
|
||||
*/
|
||||
getAccountTypeAdjustedTraderPurchaseLimit(buyRestrictionMax: number, gameVersion: string): number;
|
||||
/**
|
||||
* Get the highest rouble price for an item from traders
|
||||
* UNUSED
|
||||
* @param tpl Item to look up highest pride for
|
||||
* @returns highest rouble cost for item
|
||||
*/
|
||||
getHighestTraderPriceRouble(tpl: string): number;
|
||||
/**
|
||||
* Get the highest price item can be sold to trader for (roubles)
|
||||
* @param tpl Item to look up best trader sell-to price
|
||||
* @returns Rouble price
|
||||
*/
|
||||
getHighestSellToTraderPrice(tpl: string): number;
|
||||
/**
|
||||
* Get a trader enum key by its value
|
||||
* @param traderId Traders id
|
||||
* @returns Traders key
|
||||
*/
|
||||
getTraderById(traderId: string): Traders | undefined;
|
||||
/**
|
||||
* Validates that the provided traderEnumValue exists in the Traders enum. If the value is valid, it returns the
|
||||
* same enum value, effectively serving as a trader ID; otherwise, it logs an error and returns an empty string.
|
||||
* This method provides a runtime check to prevent undefined behavior when using the enum as a dictionary key.
|
||||
*
|
||||
* For example, instead of this:
|
||||
* `const traderId = Traders[Traders.PRAPOR];`
|
||||
*
|
||||
* You can use safely use this:
|
||||
* `const traderId = this.traderHelper.getValidTraderIdByEnumValue(Traders.PRAPOR);`
|
||||
*
|
||||
* @param traderEnumValue The trader enum value to validate
|
||||
* @returns The validated trader enum value as a string, or an empty string if invalid
|
||||
*/
|
||||
getValidTraderIdByEnumValue(traderEnumValue: Traders): string;
|
||||
/**
|
||||
* Does the 'Traders' enum has a value that matches the passed in parameter
|
||||
* @param key Value to check for
|
||||
* @returns True, values exists in Traders enum as a value
|
||||
*/
|
||||
traderEnumHasKey(key: string): boolean;
|
||||
/**
|
||||
* Accepts a trader id
|
||||
* @param traderId Trader id
|
||||
* @returns Ttrue if Traders enum has the param as a value
|
||||
*/
|
||||
traderEnumHasValue(traderId: string): boolean;
|
||||
}
|
||||
3
types/helpers/UtilityHelper.d.ts
vendored
Normal file
3
types/helpers/UtilityHelper.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class UtilityHelper {
|
||||
arrayIntersect<T>(a: T[], b: T[]): T[];
|
||||
}
|
||||
44
types/helpers/WeightedRandomHelper.d.ts
vendored
Normal file
44
types/helpers/WeightedRandomHelper.d.ts
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
export declare class WeightedRandomHelper {
|
||||
/**
|
||||
* @deprecated USE getWeightedValue() WHERE POSSIBLE
|
||||
* Gets a tplId from a weighted dictionary
|
||||
* @param {tplId: weighting[]} itemArray
|
||||
* @returns tplId
|
||||
*/
|
||||
getWeightedInventoryItem(itemArray: {
|
||||
[tplId: string]: unknown;
|
||||
} | ArrayLike<unknown>): string;
|
||||
/**
|
||||
* Choos an item from the passed in array based on the weightings of each
|
||||
* @param itemArray Items and weights to use
|
||||
* @returns Chosen item from array
|
||||
*/
|
||||
getWeightedValue<T>(itemArray: {
|
||||
[key: string]: unknown;
|
||||
} | ArrayLike<unknown>): T;
|
||||
/**
|
||||
* Picks the random item based on its weight.
|
||||
* The items with higher weight will be picked more often (with a higher probability).
|
||||
*
|
||||
* For example:
|
||||
* - items = ['banana', 'orange', 'apple']
|
||||
* - weights = [0, 0.2, 0.8]
|
||||
* - weightedRandom(items, weights) in 80% of cases will return 'apple', in 20% of cases will return
|
||||
* 'orange' and it will never return 'banana' (because probability of picking the banana is 0%)
|
||||
*
|
||||
* @param {any[]} items
|
||||
* @param {number[]} weights
|
||||
* @returns {{item: any, index: number}}
|
||||
*/
|
||||
weightedRandom(items: any[], weights: any[]): {
|
||||
item: any;
|
||||
index: number;
|
||||
};
|
||||
/**
|
||||
* Find the greated common divisor of all weights and use it on the passed in dictionary
|
||||
* @param weightedDict values to reduce
|
||||
*/
|
||||
reduceWeightValues(weightedDict: Record<string, number>): void;
|
||||
protected commonDivisor(numbers: number[]): number;
|
||||
protected gcd(a: number, b: number): number;
|
||||
}
|
||||
Reference in New Issue
Block a user