From 6d75f99d7a0cf6d2a4b50db979ff418942f7e506 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 24 Jul 2022 21:22:02 +0100 Subject: [PATCH] Update types folders --- .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../13AddTrader/types/helpers/GameHelper.d.ts | 11 ---- .../13AddTrader/types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../7OnLoadHook/types/helpers/GameHelper.d.ts | 11 ---- .../7OnLoadHook/types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ .../types/controllers/GameController.d.ts | 22 ++----- .../types/controllers/MatchController.d.ts | 4 +- .../types/controllers/ProfileController.d.ts | 10 +++- .../RepeatableQuestController.d.ts | 6 +- .../types/generators/BotLootGenerator.d.ts | 14 ++--- .../types/generators/BotWeaponGenerator.d.ts | 31 +++++++++- .../generators/RagfairOfferGenerator.d.ts | 2 +- .../types/helpers/ExtendedProfileHelper.d.ts | 7 ++- .../types/helpers/GameHelper.d.ts | 11 ---- .../types/helpers/ItemHelper.d.ts | 6 +- .../types/helpers/TraderAssortHelper.d.ts | 17 +++++- .../types/helpers/TraderHelper.d.ts | 2 +- .../eft/common/tables/IProfileTemplate.d.ts | 2 + .../types/models/spt/bots/BotLootCache.d.ts | 23 ++++++++ .../models/spt/config/ITraderConfig.d.ts | 12 ++-- .../types/services/BotLootCacheService.d.ts | 59 +++++++++++++++++++ .../types/services/PaymentService.d.ts | 17 ++++++ .../types/services/ProfileFixerService.d.ts | 40 +++++++++++++ 252 files changed, 3220 insertions(+), 770 deletions(-) delete mode 100644 TypeScript/10ScopesAndTypes/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/10ScopesAndTypes/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/10ScopesAndTypes/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/10ScopesAndTypes/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/11BundleLoadingSample/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/11BundleLoadingSample/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/11BundleLoadingSample/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/11BundleLoadingSample/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/12ClassExtensionOverride/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/12ClassExtensionOverride/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/12ClassExtensionOverride/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/12ClassExtensionOverride/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/13AddTrader/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/13AddTrader/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/13AddTrader/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/13AddTrader/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/14AfterDBLoadHook/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/14AfterDBLoadHook/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/14AfterDBLoadHook/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/14AfterDBLoadHook/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/1LogToConsole/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/1LogToConsole/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/1LogToConsole/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/1LogToConsole/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/2EditDatabase/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/2EditDatabase/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/2EditDatabase/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/2EditDatabase/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/3GetSptConfigFile/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/3GetSptConfigFile/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/3GetSptConfigFile/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/3GetSptConfigFile/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/4UseACustomConfigFile/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/4UseACustomConfigFile/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/4UseACustomConfigFile/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/4UseACustomConfigFile/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/5ReplaceMethod/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/5ReplaceMethod/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/5ReplaceMethod/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/5ReplaceMethod/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/6ReferenceAnotherClass/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/6ReferenceAnotherClass/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/6ReferenceAnotherClass/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/6ReferenceAnotherClass/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/7OnLoadHook/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/7OnLoadHook/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/7OnLoadHook/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/7OnLoadHook/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/8OnUpdateHook/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/8OnUpdateHook/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/8OnUpdateHook/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/8OnUpdateHook/types/services/ProfileFixerService.d.ts delete mode 100644 TypeScript/9RouterHooks/types/helpers/GameHelper.d.ts create mode 100644 TypeScript/9RouterHooks/types/models/spt/bots/BotLootCache.d.ts create mode 100644 TypeScript/9RouterHooks/types/services/BotLootCacheService.d.ts create mode 100644 TypeScript/9RouterHooks/types/services/ProfileFixerService.d.ts diff --git a/TypeScript/10ScopesAndTypes/types/controllers/GameController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/GameController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/10ScopesAndTypes/types/controllers/MatchController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/MatchController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/10ScopesAndTypes/types/controllers/ProfileController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/ProfileController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/10ScopesAndTypes/types/controllers/RepeatableQuestController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/10ScopesAndTypes/types/generators/BotLootGenerator.d.ts b/TypeScript/10ScopesAndTypes/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/10ScopesAndTypes/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/10ScopesAndTypes/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/10ScopesAndTypes/types/generators/BotWeaponGenerator.d.ts b/TypeScript/10ScopesAndTypes/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/10ScopesAndTypes/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/10ScopesAndTypes/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/10ScopesAndTypes/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/10ScopesAndTypes/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/10ScopesAndTypes/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/10ScopesAndTypes/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/10ScopesAndTypes/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/10ScopesAndTypes/types/helpers/GameHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/10ScopesAndTypes/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/10ScopesAndTypes/types/helpers/ItemHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/ItemHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/10ScopesAndTypes/types/helpers/TraderAssortHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/10ScopesAndTypes/types/helpers/TraderHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/TraderHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/10ScopesAndTypes/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/10ScopesAndTypes/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/10ScopesAndTypes/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/10ScopesAndTypes/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/10ScopesAndTypes/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/10ScopesAndTypes/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/10ScopesAndTypes/types/services/BotLootCacheService.d.ts b/TypeScript/10ScopesAndTypes/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/10ScopesAndTypes/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/10ScopesAndTypes/types/services/PaymentService.d.ts b/TypeScript/10ScopesAndTypes/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/10ScopesAndTypes/types/services/PaymentService.d.ts +++ b/TypeScript/10ScopesAndTypes/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/10ScopesAndTypes/types/services/ProfileFixerService.d.ts b/TypeScript/10ScopesAndTypes/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/10ScopesAndTypes/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/11BundleLoadingSample/types/controllers/GameController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/GameController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/11BundleLoadingSample/types/controllers/MatchController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/MatchController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/11BundleLoadingSample/types/controllers/ProfileController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/ProfileController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/11BundleLoadingSample/types/controllers/RepeatableQuestController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/11BundleLoadingSample/types/generators/BotLootGenerator.d.ts b/TypeScript/11BundleLoadingSample/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/11BundleLoadingSample/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/11BundleLoadingSample/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/11BundleLoadingSample/types/generators/BotWeaponGenerator.d.ts b/TypeScript/11BundleLoadingSample/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/11BundleLoadingSample/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/11BundleLoadingSample/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/11BundleLoadingSample/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/11BundleLoadingSample/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/11BundleLoadingSample/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/11BundleLoadingSample/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/11BundleLoadingSample/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/11BundleLoadingSample/types/helpers/GameHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/11BundleLoadingSample/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/11BundleLoadingSample/types/helpers/ItemHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/ItemHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/11BundleLoadingSample/types/helpers/TraderAssortHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/11BundleLoadingSample/types/helpers/TraderHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/TraderHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/11BundleLoadingSample/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/11BundleLoadingSample/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/11BundleLoadingSample/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/11BundleLoadingSample/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/11BundleLoadingSample/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/11BundleLoadingSample/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/11BundleLoadingSample/types/services/BotLootCacheService.d.ts b/TypeScript/11BundleLoadingSample/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/11BundleLoadingSample/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/11BundleLoadingSample/types/services/PaymentService.d.ts b/TypeScript/11BundleLoadingSample/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/11BundleLoadingSample/types/services/PaymentService.d.ts +++ b/TypeScript/11BundleLoadingSample/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/11BundleLoadingSample/types/services/ProfileFixerService.d.ts b/TypeScript/11BundleLoadingSample/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/11BundleLoadingSample/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/GameController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/GameController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/MatchController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/MatchController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/ProfileController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/ProfileController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/RepeatableQuestController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/12ClassExtensionOverride/types/generators/BotLootGenerator.d.ts b/TypeScript/12ClassExtensionOverride/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/12ClassExtensionOverride/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/12ClassExtensionOverride/types/generators/BotWeaponGenerator.d.ts b/TypeScript/12ClassExtensionOverride/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/12ClassExtensionOverride/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/12ClassExtensionOverride/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/12ClassExtensionOverride/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/12ClassExtensionOverride/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/GameHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/12ClassExtensionOverride/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/ItemHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/ItemHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/TraderAssortHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/TraderHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/TraderHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/12ClassExtensionOverride/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/12ClassExtensionOverride/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/12ClassExtensionOverride/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/12ClassExtensionOverride/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/12ClassExtensionOverride/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/12ClassExtensionOverride/types/services/BotLootCacheService.d.ts b/TypeScript/12ClassExtensionOverride/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/12ClassExtensionOverride/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/12ClassExtensionOverride/types/services/PaymentService.d.ts b/TypeScript/12ClassExtensionOverride/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/12ClassExtensionOverride/types/services/PaymentService.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/12ClassExtensionOverride/types/services/ProfileFixerService.d.ts b/TypeScript/12ClassExtensionOverride/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/12ClassExtensionOverride/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/13AddTrader/types/controllers/GameController.d.ts b/TypeScript/13AddTrader/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/13AddTrader/types/controllers/GameController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/13AddTrader/types/controllers/MatchController.d.ts b/TypeScript/13AddTrader/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/13AddTrader/types/controllers/MatchController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/13AddTrader/types/controllers/ProfileController.d.ts b/TypeScript/13AddTrader/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/13AddTrader/types/controllers/ProfileController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/13AddTrader/types/controllers/RepeatableQuestController.d.ts b/TypeScript/13AddTrader/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/13AddTrader/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/13AddTrader/types/generators/BotLootGenerator.d.ts b/TypeScript/13AddTrader/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/13AddTrader/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/13AddTrader/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/13AddTrader/types/generators/BotWeaponGenerator.d.ts b/TypeScript/13AddTrader/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/13AddTrader/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/13AddTrader/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/13AddTrader/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/13AddTrader/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/13AddTrader/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/13AddTrader/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/13AddTrader/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/13AddTrader/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/13AddTrader/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/13AddTrader/types/helpers/GameHelper.d.ts b/TypeScript/13AddTrader/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/13AddTrader/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/13AddTrader/types/helpers/ItemHelper.d.ts b/TypeScript/13AddTrader/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/13AddTrader/types/helpers/ItemHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/13AddTrader/types/helpers/TraderAssortHelper.d.ts b/TypeScript/13AddTrader/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/13AddTrader/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/13AddTrader/types/helpers/TraderHelper.d.ts b/TypeScript/13AddTrader/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/13AddTrader/types/helpers/TraderHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/13AddTrader/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/13AddTrader/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/13AddTrader/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/13AddTrader/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/13AddTrader/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/13AddTrader/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/13AddTrader/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/13AddTrader/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/13AddTrader/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/13AddTrader/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/13AddTrader/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/13AddTrader/types/services/BotLootCacheService.d.ts b/TypeScript/13AddTrader/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/13AddTrader/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/13AddTrader/types/services/PaymentService.d.ts b/TypeScript/13AddTrader/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/13AddTrader/types/services/PaymentService.d.ts +++ b/TypeScript/13AddTrader/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/13AddTrader/types/services/ProfileFixerService.d.ts b/TypeScript/13AddTrader/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/13AddTrader/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/GameController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/GameController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/MatchController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/MatchController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/ProfileController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/ProfileController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/RepeatableQuestController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/14AfterDBLoadHook/types/generators/BotLootGenerator.d.ts b/TypeScript/14AfterDBLoadHook/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/14AfterDBLoadHook/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/14AfterDBLoadHook/types/generators/BotWeaponGenerator.d.ts b/TypeScript/14AfterDBLoadHook/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/14AfterDBLoadHook/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/14AfterDBLoadHook/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/14AfterDBLoadHook/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/14AfterDBLoadHook/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/GameHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/14AfterDBLoadHook/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/ItemHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/ItemHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/TraderAssortHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/TraderHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/TraderHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/14AfterDBLoadHook/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/14AfterDBLoadHook/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/14AfterDBLoadHook/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/14AfterDBLoadHook/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/14AfterDBLoadHook/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/14AfterDBLoadHook/types/services/BotLootCacheService.d.ts b/TypeScript/14AfterDBLoadHook/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/14AfterDBLoadHook/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/14AfterDBLoadHook/types/services/PaymentService.d.ts b/TypeScript/14AfterDBLoadHook/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/14AfterDBLoadHook/types/services/PaymentService.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/14AfterDBLoadHook/types/services/ProfileFixerService.d.ts b/TypeScript/14AfterDBLoadHook/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/14AfterDBLoadHook/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/1LogToConsole/types/controllers/GameController.d.ts b/TypeScript/1LogToConsole/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/1LogToConsole/types/controllers/GameController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/1LogToConsole/types/controllers/MatchController.d.ts b/TypeScript/1LogToConsole/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/1LogToConsole/types/controllers/MatchController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/1LogToConsole/types/controllers/ProfileController.d.ts b/TypeScript/1LogToConsole/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/1LogToConsole/types/controllers/ProfileController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/1LogToConsole/types/controllers/RepeatableQuestController.d.ts b/TypeScript/1LogToConsole/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/1LogToConsole/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/1LogToConsole/types/generators/BotLootGenerator.d.ts b/TypeScript/1LogToConsole/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/1LogToConsole/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/1LogToConsole/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/1LogToConsole/types/generators/BotWeaponGenerator.d.ts b/TypeScript/1LogToConsole/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/1LogToConsole/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/1LogToConsole/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/1LogToConsole/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/1LogToConsole/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/1LogToConsole/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/1LogToConsole/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/1LogToConsole/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/1LogToConsole/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/1LogToConsole/types/helpers/GameHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/1LogToConsole/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/1LogToConsole/types/helpers/ItemHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/1LogToConsole/types/helpers/ItemHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/1LogToConsole/types/helpers/TraderAssortHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/1LogToConsole/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/1LogToConsole/types/helpers/TraderHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/1LogToConsole/types/helpers/TraderHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/1LogToConsole/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/1LogToConsole/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/1LogToConsole/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/1LogToConsole/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/1LogToConsole/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/1LogToConsole/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/1LogToConsole/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/1LogToConsole/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/1LogToConsole/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/1LogToConsole/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/1LogToConsole/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/1LogToConsole/types/services/BotLootCacheService.d.ts b/TypeScript/1LogToConsole/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/1LogToConsole/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/1LogToConsole/types/services/PaymentService.d.ts b/TypeScript/1LogToConsole/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/1LogToConsole/types/services/PaymentService.d.ts +++ b/TypeScript/1LogToConsole/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/1LogToConsole/types/services/ProfileFixerService.d.ts b/TypeScript/1LogToConsole/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/1LogToConsole/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/2EditDatabase/types/controllers/GameController.d.ts b/TypeScript/2EditDatabase/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/2EditDatabase/types/controllers/GameController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/2EditDatabase/types/controllers/MatchController.d.ts b/TypeScript/2EditDatabase/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/2EditDatabase/types/controllers/MatchController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/2EditDatabase/types/controllers/ProfileController.d.ts b/TypeScript/2EditDatabase/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/2EditDatabase/types/controllers/ProfileController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/2EditDatabase/types/controllers/RepeatableQuestController.d.ts b/TypeScript/2EditDatabase/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/2EditDatabase/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/2EditDatabase/types/generators/BotLootGenerator.d.ts b/TypeScript/2EditDatabase/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/2EditDatabase/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/2EditDatabase/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/2EditDatabase/types/generators/BotWeaponGenerator.d.ts b/TypeScript/2EditDatabase/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/2EditDatabase/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/2EditDatabase/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/2EditDatabase/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/2EditDatabase/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/2EditDatabase/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/2EditDatabase/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/2EditDatabase/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/2EditDatabase/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/2EditDatabase/types/helpers/GameHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/2EditDatabase/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/2EditDatabase/types/helpers/ItemHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/2EditDatabase/types/helpers/ItemHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/2EditDatabase/types/helpers/TraderAssortHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/2EditDatabase/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/2EditDatabase/types/helpers/TraderHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/2EditDatabase/types/helpers/TraderHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/2EditDatabase/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/2EditDatabase/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/2EditDatabase/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/2EditDatabase/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/2EditDatabase/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/2EditDatabase/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/2EditDatabase/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/2EditDatabase/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/2EditDatabase/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/2EditDatabase/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/2EditDatabase/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/2EditDatabase/types/services/BotLootCacheService.d.ts b/TypeScript/2EditDatabase/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/2EditDatabase/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/2EditDatabase/types/services/PaymentService.d.ts b/TypeScript/2EditDatabase/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/2EditDatabase/types/services/PaymentService.d.ts +++ b/TypeScript/2EditDatabase/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/2EditDatabase/types/services/ProfileFixerService.d.ts b/TypeScript/2EditDatabase/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/2EditDatabase/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/3GetSptConfigFile/types/controllers/GameController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/GameController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/3GetSptConfigFile/types/controllers/MatchController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/MatchController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/3GetSptConfigFile/types/controllers/ProfileController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/ProfileController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/3GetSptConfigFile/types/controllers/RepeatableQuestController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/3GetSptConfigFile/types/generators/BotLootGenerator.d.ts b/TypeScript/3GetSptConfigFile/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/3GetSptConfigFile/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/3GetSptConfigFile/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/3GetSptConfigFile/types/generators/BotWeaponGenerator.d.ts b/TypeScript/3GetSptConfigFile/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/3GetSptConfigFile/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/3GetSptConfigFile/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/3GetSptConfigFile/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/3GetSptConfigFile/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/3GetSptConfigFile/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/3GetSptConfigFile/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/3GetSptConfigFile/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/3GetSptConfigFile/types/helpers/GameHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/3GetSptConfigFile/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/3GetSptConfigFile/types/helpers/ItemHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/ItemHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/3GetSptConfigFile/types/helpers/TraderAssortHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/3GetSptConfigFile/types/helpers/TraderHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/TraderHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/3GetSptConfigFile/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/3GetSptConfigFile/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/3GetSptConfigFile/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/3GetSptConfigFile/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/3GetSptConfigFile/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/3GetSptConfigFile/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/3GetSptConfigFile/types/services/BotLootCacheService.d.ts b/TypeScript/3GetSptConfigFile/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/3GetSptConfigFile/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/3GetSptConfigFile/types/services/PaymentService.d.ts b/TypeScript/3GetSptConfigFile/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/3GetSptConfigFile/types/services/PaymentService.d.ts +++ b/TypeScript/3GetSptConfigFile/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/3GetSptConfigFile/types/services/ProfileFixerService.d.ts b/TypeScript/3GetSptConfigFile/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/3GetSptConfigFile/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/GameController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/GameController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/MatchController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/MatchController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/ProfileController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/ProfileController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/RepeatableQuestController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/4UseACustomConfigFile/types/generators/BotLootGenerator.d.ts b/TypeScript/4UseACustomConfigFile/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/4UseACustomConfigFile/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/4UseACustomConfigFile/types/generators/BotWeaponGenerator.d.ts b/TypeScript/4UseACustomConfigFile/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/4UseACustomConfigFile/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/4UseACustomConfigFile/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/4UseACustomConfigFile/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/4UseACustomConfigFile/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/GameHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/4UseACustomConfigFile/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/ItemHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/ItemHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/TraderAssortHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/TraderHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/TraderHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/4UseACustomConfigFile/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/4UseACustomConfigFile/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/4UseACustomConfigFile/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/4UseACustomConfigFile/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/4UseACustomConfigFile/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/4UseACustomConfigFile/types/services/BotLootCacheService.d.ts b/TypeScript/4UseACustomConfigFile/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/4UseACustomConfigFile/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/4UseACustomConfigFile/types/services/PaymentService.d.ts b/TypeScript/4UseACustomConfigFile/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/4UseACustomConfigFile/types/services/PaymentService.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/4UseACustomConfigFile/types/services/ProfileFixerService.d.ts b/TypeScript/4UseACustomConfigFile/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/4UseACustomConfigFile/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/5ReplaceMethod/types/controllers/GameController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/GameController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/5ReplaceMethod/types/controllers/MatchController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/MatchController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/5ReplaceMethod/types/controllers/ProfileController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/ProfileController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/5ReplaceMethod/types/controllers/RepeatableQuestController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/5ReplaceMethod/types/generators/BotLootGenerator.d.ts b/TypeScript/5ReplaceMethod/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/5ReplaceMethod/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/5ReplaceMethod/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/5ReplaceMethod/types/generators/BotWeaponGenerator.d.ts b/TypeScript/5ReplaceMethod/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/5ReplaceMethod/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/5ReplaceMethod/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/5ReplaceMethod/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/5ReplaceMethod/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/5ReplaceMethod/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/5ReplaceMethod/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/5ReplaceMethod/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/5ReplaceMethod/types/helpers/GameHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/5ReplaceMethod/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/5ReplaceMethod/types/helpers/ItemHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/ItemHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/5ReplaceMethod/types/helpers/TraderAssortHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/5ReplaceMethod/types/helpers/TraderHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/TraderHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/5ReplaceMethod/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/5ReplaceMethod/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/5ReplaceMethod/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/5ReplaceMethod/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/5ReplaceMethod/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/5ReplaceMethod/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/5ReplaceMethod/types/services/BotLootCacheService.d.ts b/TypeScript/5ReplaceMethod/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/5ReplaceMethod/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/5ReplaceMethod/types/services/PaymentService.d.ts b/TypeScript/5ReplaceMethod/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/5ReplaceMethod/types/services/PaymentService.d.ts +++ b/TypeScript/5ReplaceMethod/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/5ReplaceMethod/types/services/ProfileFixerService.d.ts b/TypeScript/5ReplaceMethod/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/5ReplaceMethod/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/GameController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/GameController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/MatchController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/MatchController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/ProfileController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/ProfileController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/RepeatableQuestController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/6ReferenceAnotherClass/types/generators/BotLootGenerator.d.ts b/TypeScript/6ReferenceAnotherClass/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/6ReferenceAnotherClass/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/6ReferenceAnotherClass/types/generators/BotWeaponGenerator.d.ts b/TypeScript/6ReferenceAnotherClass/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/6ReferenceAnotherClass/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/6ReferenceAnotherClass/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/6ReferenceAnotherClass/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/6ReferenceAnotherClass/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/GameHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/ItemHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/ItemHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/TraderAssortHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/TraderHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/TraderHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/6ReferenceAnotherClass/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/6ReferenceAnotherClass/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/6ReferenceAnotherClass/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/6ReferenceAnotherClass/types/services/BotLootCacheService.d.ts b/TypeScript/6ReferenceAnotherClass/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/6ReferenceAnotherClass/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/6ReferenceAnotherClass/types/services/PaymentService.d.ts b/TypeScript/6ReferenceAnotherClass/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/6ReferenceAnotherClass/types/services/PaymentService.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/6ReferenceAnotherClass/types/services/ProfileFixerService.d.ts b/TypeScript/6ReferenceAnotherClass/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/6ReferenceAnotherClass/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/7OnLoadHook/types/controllers/GameController.d.ts b/TypeScript/7OnLoadHook/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/7OnLoadHook/types/controllers/GameController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/7OnLoadHook/types/controllers/MatchController.d.ts b/TypeScript/7OnLoadHook/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/7OnLoadHook/types/controllers/MatchController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/7OnLoadHook/types/controllers/ProfileController.d.ts b/TypeScript/7OnLoadHook/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/7OnLoadHook/types/controllers/ProfileController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/7OnLoadHook/types/controllers/RepeatableQuestController.d.ts b/TypeScript/7OnLoadHook/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/7OnLoadHook/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/7OnLoadHook/types/generators/BotLootGenerator.d.ts b/TypeScript/7OnLoadHook/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/7OnLoadHook/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/7OnLoadHook/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/7OnLoadHook/types/generators/BotWeaponGenerator.d.ts b/TypeScript/7OnLoadHook/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/7OnLoadHook/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/7OnLoadHook/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/7OnLoadHook/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/7OnLoadHook/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/7OnLoadHook/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/7OnLoadHook/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/7OnLoadHook/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/7OnLoadHook/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/7OnLoadHook/types/helpers/GameHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/7OnLoadHook/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/7OnLoadHook/types/helpers/ItemHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/7OnLoadHook/types/helpers/ItemHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/7OnLoadHook/types/helpers/TraderAssortHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/7OnLoadHook/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/7OnLoadHook/types/helpers/TraderHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/7OnLoadHook/types/helpers/TraderHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/7OnLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/7OnLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/7OnLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/7OnLoadHook/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/7OnLoadHook/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/7OnLoadHook/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/7OnLoadHook/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/7OnLoadHook/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/7OnLoadHook/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/7OnLoadHook/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/7OnLoadHook/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/7OnLoadHook/types/services/BotLootCacheService.d.ts b/TypeScript/7OnLoadHook/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/7OnLoadHook/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/7OnLoadHook/types/services/PaymentService.d.ts b/TypeScript/7OnLoadHook/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/7OnLoadHook/types/services/PaymentService.d.ts +++ b/TypeScript/7OnLoadHook/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/7OnLoadHook/types/services/ProfileFixerService.d.ts b/TypeScript/7OnLoadHook/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/7OnLoadHook/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/8OnUpdateHook/types/controllers/GameController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/GameController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/8OnUpdateHook/types/controllers/MatchController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/MatchController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/8OnUpdateHook/types/controllers/ProfileController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/ProfileController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/8OnUpdateHook/types/controllers/RepeatableQuestController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/8OnUpdateHook/types/generators/BotLootGenerator.d.ts b/TypeScript/8OnUpdateHook/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/8OnUpdateHook/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/8OnUpdateHook/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/8OnUpdateHook/types/generators/BotWeaponGenerator.d.ts b/TypeScript/8OnUpdateHook/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/8OnUpdateHook/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/8OnUpdateHook/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/8OnUpdateHook/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/8OnUpdateHook/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/8OnUpdateHook/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/8OnUpdateHook/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/8OnUpdateHook/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/8OnUpdateHook/types/helpers/GameHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/8OnUpdateHook/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/8OnUpdateHook/types/helpers/ItemHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/ItemHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/8OnUpdateHook/types/helpers/TraderAssortHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/8OnUpdateHook/types/helpers/TraderHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/TraderHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/8OnUpdateHook/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/8OnUpdateHook/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/8OnUpdateHook/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/8OnUpdateHook/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/8OnUpdateHook/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/8OnUpdateHook/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/8OnUpdateHook/types/services/BotLootCacheService.d.ts b/TypeScript/8OnUpdateHook/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/8OnUpdateHook/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/8OnUpdateHook/types/services/PaymentService.d.ts b/TypeScript/8OnUpdateHook/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/8OnUpdateHook/types/services/PaymentService.d.ts +++ b/TypeScript/8OnUpdateHook/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/8OnUpdateHook/types/services/ProfileFixerService.d.ts b/TypeScript/8OnUpdateHook/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/8OnUpdateHook/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +} diff --git a/TypeScript/9RouterHooks/types/controllers/GameController.d.ts b/TypeScript/9RouterHooks/types/controllers/GameController.d.ts index f4c3d2c..85ec418 100644 --- a/TypeScript/9RouterHooks/types/controllers/GameController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/GameController.d.ts @@ -1,9 +1,6 @@ -import { GameHelper } from "../helpers/GameHelper"; import { HttpServerHelper } from "../helpers/HttpServerHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData"; -import { IPmcData } from "../models/eft/common/IPmcData"; -import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; import { IGameConfigResponse } from "../models/eft/game/IGameConfigResponse"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; import { ICoreConfig } from "../models/spt/config/ICoreConfig"; @@ -11,6 +8,7 @@ import { IHttpConfig } from "../models/spt/config/IHttpConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { LocaleService } from "../services/LocaleService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { Watermark } from "../utils/Watermark"; export declare class GameController { protected logger: ILogger; @@ -18,25 +16,13 @@ export declare class GameController { protected httpServerHelper: HttpServerHelper; protected localeService: LocaleService; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected configServer: ConfigServer; protected httpConfig: IHttpConfig; protected coreConfig: ICoreConfig; - constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, gameHelper: GameHelper, configServer: ConfigServer); + constructor(logger: ILogger, watermark: Watermark, httpServerHelper: HttpServerHelper, localeService: LocaleService, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, configServer: ConfigServer); gameStart(_url: string, _info: IEmptyRequestData, sessionID: string): void; - protected addMissingBonusesProperty(pmcProfile: IPmcData): void; - protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; - protected addMissingWeaponRepairSkill(pmcProfile: IPmcData): void; - protected addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; - /** - * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots - * @param pmcProfile - */ - protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; - protected addMissingArmorRepairSkill(pmcProfile: IPmcData): void; - protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; - protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected logProfileDetails(fullProfile: IAkiProfile): void; getGameConfig(sessionID: string): IGameConfigResponse; getServer(): any[]; - protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; } diff --git a/TypeScript/9RouterHooks/types/controllers/MatchController.d.ts b/TypeScript/9RouterHooks/types/controllers/MatchController.d.ts index 87a070c..0851ab0 100644 --- a/TypeScript/9RouterHooks/types/controllers/MatchController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/MatchController.d.ts @@ -12,16 +12,18 @@ import { IInRaidConfig } from "../models/spt/config/IInRaidConfig"; import { IMatchConfig } from "../models/spt/config/IMatchConfig"; import { ConfigServer } from "../servers/ConfigServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { MatchLocationService } from "../services/MatchLocationService"; export declare class MatchController { protected saveServer: SaveServer; protected profileHelper: ProfileHelper; protected matchLocationService: MatchLocationService; protected traderHelper: TraderHelper; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected matchConfig: IMatchConfig; protected inraidConfig: IInRaidConfig; - constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, configServer: ConfigServer); + constructor(saveServer: SaveServer, profileHelper: ProfileHelper, matchLocationService: MatchLocationService, traderHelper: TraderHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); getEnabled(): boolean; getProfile(info: IGetProfileRequestData): IPmcData[]; createGroup(sessionID: string, info: ICreateGroupRequestData): any; diff --git a/TypeScript/9RouterHooks/types/controllers/ProfileController.d.ts b/TypeScript/9RouterHooks/types/controllers/ProfileController.d.ts index 9b7a6d5..b40bb7d 100644 --- a/TypeScript/9RouterHooks/types/controllers/ProfileController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/ProfileController.d.ts @@ -11,6 +11,7 @@ import { ISearchFriendResponse } from "../models/eft/profile/ISearchFriendRespon import { IValidateNicknameRequestData } from "../models/eft/profile/IValidateNicknameRequestData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { HashUtil } from "../utils/HashUtil"; import { TimeUtil } from "../utils/TimeUtil"; export declare class ProfileController { @@ -19,13 +20,20 @@ export declare class ProfileController { protected saveServer: SaveServer; protected databaseServer: DatabaseServer; protected itemHelper: ItemHelper; + protected profileFixerService: ProfileFixerService; protected traderHelper: TraderHelper; protected extendedProfileHelper: ExtendedProfileHelper; - constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); + constructor(hashUtil: HashUtil, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileFixerService: ProfileFixerService, traderHelper: TraderHelper, extendedProfileHelper: ExtendedProfileHelper); getMiniProfiles(): IMiniProfile[]; getMiniProfile(sessionID: string): any; getCompleteProfile(sessionID: string): IPmcData[]; createProfile(info: IProfileCreateRequestData, sessionID: string): void; + /** + * Generate a player scav object + * pmc profile MUST exist first before pscav can be generated + * @param sessionID + * @returns IPmcData object + */ generatePlayerScav(sessionID: string): IPmcData; validateNickname(info: IValidateNicknameRequestData, sessionID: string): string; changeNickname(info: IProfileChangeNicknameRequestData, sessionID: string): string; diff --git a/TypeScript/9RouterHooks/types/controllers/RepeatableQuestController.d.ts b/TypeScript/9RouterHooks/types/controllers/RepeatableQuestController.d.ts index 9aa9590..2bb2aa9 100644 --- a/TypeScript/9RouterHooks/types/controllers/RepeatableQuestController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/RepeatableQuestController.d.ts @@ -1,4 +1,3 @@ -import { GameHelper } from "../helpers/GameHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { PresetHelper } from "../helpers/PresetHelper"; import { ProfileHelper } from "../helpers/ProfileHelper"; @@ -16,6 +15,7 @@ import { ItemEventRouter } from "../routers/ItemEventRouter"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { PaymentService } from "../services/PaymentService"; +import { ProfileFixerService } from "../services/ProfileFixerService"; import { JsonUtil } from "../utils/JsonUtil"; import { MathUtil } from "../utils/MathUtil"; import { ObjectId } from "../utils/ObjectId"; @@ -58,14 +58,14 @@ export declare class RepeatableQuestController { protected itemHelper: ItemHelper; protected presetHelper: PresetHelper; protected profileHelper: ProfileHelper; - protected gameHelper: GameHelper; + protected profileFixerService: ProfileFixerService; protected ragfairServerHelper: RagfairServerHelper; protected itemEventRouter: ItemEventRouter; protected paymentService: PaymentService; protected objectId: ObjectId; protected configServer: ConfigServer; protected questConfig: IQuestConfig; - constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, gameHelper: GameHelper, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); + constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, itemEventRouter: ItemEventRouter, paymentService: PaymentService, objectId: ObjectId, configServer: ConfigServer); /** * This is the method reached by the /client/repeatalbeQuests/activityPeriods endpoint * Returns an array of objects in the format of repeatable quests to the client. diff --git a/TypeScript/9RouterHooks/types/generators/BotLootGenerator.d.ts b/TypeScript/9RouterHooks/types/generators/BotLootGenerator.d.ts index 1d91836..2295f51 100644 --- a/TypeScript/9RouterHooks/types/generators/BotLootGenerator.d.ts +++ b/TypeScript/9RouterHooks/types/generators/BotLootGenerator.d.ts @@ -1,29 +1,27 @@ -import { PMCLootGenerator } from "../generators/PMCLootGenerator"; import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { HandbookHelper } from "../helpers/HandbookHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; import { ItemMinMax, Items } from "../models/eft/common/tables/IBotType"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { IBotConfig } from "../models/spt/config/IBotConfig"; +import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { HashUtil } from "../utils/HashUtil"; -import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; export declare class BotLootGenerator { - protected jsonUtil: JsonUtil; + protected logger: ILogger; protected hashUtil: HashUtil; protected randomUtil: RandomUtil; protected databaseServer: DatabaseServer; protected handbookHelper: HandbookHelper; protected botGeneratorHelper: BotGeneratorHelper; - protected pmcLootGenerator: PMCLootGenerator; + protected botLootCacheService: BotLootCacheService; protected configServer: ConfigServer; protected botConfig: IBotConfig; - constructor(jsonUtil: JsonUtil, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, pmcLootGenerator: PMCLootGenerator, configServer: ConfigServer); - generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, inventory: PmcInventory): void; + constructor(logger: ILogger, hashUtil: HashUtil, randomUtil: RandomUtil, databaseServer: DatabaseServer, handbookHelper: HandbookHelper, botGeneratorHelper: BotGeneratorHelper, botLootCacheService: BotLootCacheService, configServer: ConfigServer); + generateLoot(lootPool: Items, itemCounts: ItemMinMax, isPmc: boolean, botRole: string, inventory: PmcInventory): void; protected getRandomisedCount(min: number, max: number, nValue: number): number; protected addLootFromPool(pool: ITemplateItem[], equipmentSlots: string[], count: number, inventory: PmcInventory, totalValueLimit?: number, useLimits?: boolean): void; - /** Compares two item templates by their price to spawn chance ratio */ - protected compareByValue(a: ITemplateItem, b: ITemplateItem): number; } diff --git a/TypeScript/9RouterHooks/types/generators/BotWeaponGenerator.d.ts b/TypeScript/9RouterHooks/types/generators/BotWeaponGenerator.d.ts index 80dc37c..f118872 100644 --- a/TypeScript/9RouterHooks/types/generators/BotWeaponGenerator.d.ts +++ b/TypeScript/9RouterHooks/types/generators/BotWeaponGenerator.d.ts @@ -2,7 +2,7 @@ import { BotGeneratorHelper } from "../helpers/BotGeneratorHelper"; import { ItemHelper } from "../helpers/ItemHelper"; import { WeightedRandomHelper } from "../helpers/WeightedRandomHelper"; import { Inventory as PmcInventory } from "../models/eft/common/IPmcData"; -import { Inventory, MinMax, ModsChances } from "../models/eft/common/tables/IBotType"; +import { Inventory, MinMax, Mods, ModsChances } from "../models/eft/common/tables/IBotType"; import { Item } from "../models/eft/common/tables/IItem"; import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -22,6 +22,35 @@ export declare class BotWeaponGenerator { private readonly modMagazineSlotId; constructor(jsonUtil: JsonUtil, logger: ILogger, hashUtil: HashUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, weightedRandomHelper: WeightedRandomHelper, botGeneratorHelper: BotGeneratorHelper, randomUtil: RandomUtil); generateWeapon(equipmentSlot: string, templateInventory: Inventory, modChances: ModsChances, magCounts: MinMax, botRole: string, isPmc: boolean, inventory: PmcInventory): void; + /** + * Create a list of mods for a weapon defined by the weaponTpl parameter + * @param weaponTpl Weapon to generate mods for + */ + protected getWeaponMods(weaponTpl: string): Mods; + /** + * Get a dictionary of items and their attachments + * @param itemTpl item to look up attachments for + * @param weaponModsResult Mods array to add to + */ + protected getItemAttachmentsRecursive(itemTpl: string, weaponModsResult: Mods): void; + protected isTplAnOptic(tplToCheck: string): boolean; + /** + * Get a weapon tpl from a bot jsons inventory + * @param weaponSlot slot to get randomised tpl for + * @param templateInventory + * @returns + */ + protected getRandomisedWeaponTplForSlot(weaponSlot: string, templateInventory: Inventory): string; + /** + * Get an array with a single object being the the weapon as defined by the weaponTpl parameter + * @param weaponTpl weapon to generate array around + * @param equipmentId + * @param weaponSlot + * @param itemTemplate + * @param botRole bot we're generating for + * @returns Item array + */ + protected getWeaponBase(weaponTpl: string, equipmentId: string, weaponSlot: string, itemTemplate: ITemplateItem, botRole: string): Item[]; /** * Get the mods necessary to kit out a weapon to its preset level * @param weaponTpl weapon to find preset for diff --git a/TypeScript/9RouterHooks/types/generators/RagfairOfferGenerator.d.ts b/TypeScript/9RouterHooks/types/generators/RagfairOfferGenerator.d.ts index 6645c8d..3e7f4cc 100644 --- a/TypeScript/9RouterHooks/types/generators/RagfairOfferGenerator.d.ts +++ b/TypeScript/9RouterHooks/types/generators/RagfairOfferGenerator.d.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; import { FenceService } from "../services/FenceService"; +import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; import { RagfairOfferService } from "../services/RagfairOfferService"; import { RagfairPriceService } from "../services/RagfairPriceService"; import { HashUtil } from "../utils/HashUtil"; @@ -18,7 +19,6 @@ import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { RagfairAssortGenerator } from "./RagfairAssortGenerator"; -import { RagfairCategoriesService } from "../services/RagfairCategoriesService"; export declare class RagfairOfferGenerator { protected logger: ILogger; protected jsonUtil: JsonUtil; diff --git a/TypeScript/9RouterHooks/types/helpers/ExtendedProfileHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/ExtendedProfileHelper.d.ts index d8b754d..c05d88e 100644 --- a/TypeScript/9RouterHooks/types/helpers/ExtendedProfileHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/ExtendedProfileHelper.d.ts @@ -2,15 +2,20 @@ import { BotGenerator } from "../generators/BotGenerator"; import { IPmcData, Skills, Stats } from "../models/eft/common/IPmcData"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { BotLootCacheService } from "../services/BotLootCacheService"; import { FenceService } from "../services/FenceService"; import { JsonUtil } from "../utils/JsonUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; import { ItemHelper } from "./ItemHelper"; import { ProfileHelper } from "./ProfileHelper"; +/** + * This class needs to exist outside of ProfileHelper to ensure cyclic deps don't cause the server to fail on load + */ export declare class ExtendedProfileHelper extends ProfileHelper { + protected botLootCacheService: BotLootCacheService; protected botGenerator: BotGenerator; - constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, fenceService: FenceService, botGenerator: BotGenerator); + constructor(jsonUtil: JsonUtil, watermark: Watermark, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, botLootCacheService: BotLootCacheService, fenceService: FenceService, botGenerator: BotGenerator); generatePlayerScav(sessionID: string): IPmcData; protected getScavSkills(sessionID: string): Skills; protected removeSecureContainer(profile: IPmcData): IPmcData; diff --git a/TypeScript/9RouterHooks/types/helpers/GameHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/GameHelper.d.ts deleted file mode 100644 index fd49e84..0000000 --- a/TypeScript/9RouterHooks/types/helpers/GameHelper.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IPmcData } from "../models/eft/common/IPmcData"; -import { ILogger } from "../models/spt/utils/ILogger"; -export declare class GameHelper { - protected logger: ILogger; - constructor(logger: ILogger); - /** - * Remove condition conters no longer used - * @param pmcProfile profile to remove old counters from - */ - removeDanglingConditionCounters(pmcProfile: IPmcData): void; -} diff --git a/TypeScript/9RouterHooks/types/helpers/ItemHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/ItemHelper.d.ts index a6b61d0..4e0eba4 100644 --- a/TypeScript/9RouterHooks/types/helpers/ItemHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/ItemHelper.d.ts @@ -162,10 +162,10 @@ declare class ItemHelper { * Find Barter items in the inventory * @param {string} by * @param {Object} pmcData - * @param {string} barter_itemID - * @returns Array + * @param {string} barterItemId + * @returns Array of Item objects */ - findBarterItems(by: string, pmcData: IPmcData, barter_itemID: string): any[]; + findBarterItems(by: string, pmcData: IPmcData, barterItemId: string): Item[]; /** * * @param pmcData diff --git a/TypeScript/9RouterHooks/types/helpers/TraderAssortHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/TraderAssortHelper.d.ts index 4f41ac2..91ba6b9 100644 --- a/TypeScript/9RouterHooks/types/helpers/TraderAssortHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/TraderAssortHelper.d.ts @@ -2,24 +2,32 @@ import { RagfairAssortGenerator } from "../generators/RagfairAssortGenerator"; import { RagfairOfferGenerator } from "../generators/RagfairOfferGenerator"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; +import { ITraderConfig } from "../models/spt/config/ITraderConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { FenceService } from "../services/FenceService"; import { TraderAssortService } from "../services/TraderAssortService"; import { JsonUtil } from "../utils/JsonUtil"; +import { MathUtil } from "../utils/MathUtil"; import { AssortHelper } from "./AssortHelper"; +import { PaymentHelper } from "./PaymentHelper"; import { ProfileHelper } from "./ProfileHelper"; export declare class TraderAssortHelper { protected logger: ILogger; protected jsonUtil: JsonUtil; + protected mathUtil: MathUtil; protected databaseServer: DatabaseServer; protected profileHelper: ProfileHelper; protected assortHelper: AssortHelper; + protected paymentHelper: PaymentHelper; protected ragfairAssortGenerator: RagfairAssortGenerator; protected ragfairOfferGenerator: RagfairOfferGenerator; protected traderAssortService: TraderAssortService; protected fenceService: FenceService; - constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService); + protected configServer: ConfigServer; + protected traderConfig: ITraderConfig; + constructor(logger: ILogger, jsonUtil: JsonUtil, mathUtil: MathUtil, databaseServer: DatabaseServer, profileHelper: ProfileHelper, assortHelper: AssortHelper, paymentHelper: PaymentHelper, ragfairAssortGenerator: RagfairAssortGenerator, ragfairOfferGenerator: RagfairOfferGenerator, traderAssortService: TraderAssortService, fenceService: FenceService, configServer: ConfigServer); /** * Get a traders assorts * Can be used for returning ragfair / fence assorts @@ -29,7 +37,12 @@ export declare class TraderAssortHelper { */ getAssort(sessionId: string, traderId: string): ITraderAssort; /** - * Get an array of pristine trader items prior to any alteration by player + * 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 multiplyItemPricesByConfigMultipler(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 */ diff --git a/TypeScript/9RouterHooks/types/helpers/TraderHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/TraderHelper.d.ts index ba0c564..b2e9d38 100644 --- a/TypeScript/9RouterHooks/types/helpers/TraderHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/TraderHelper.d.ts @@ -29,7 +29,7 @@ export declare class TraderHelper { getTrader(traderID: string, sessionID: string): ITraderBase; getTraderAssortsById(traderId: string): ITraderAssort; /** - * Reset a trader back to its initial state as seen by a level 1 player + * 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 * @param traderID trader id to reset diff --git a/TypeScript/9RouterHooks/types/models/eft/common/tables/IProfileTemplate.d.ts b/TypeScript/9RouterHooks/types/models/eft/common/tables/IProfileTemplate.d.ts index c445e92..fbcd81a 100644 --- a/TypeScript/9RouterHooks/types/models/eft/common/tables/IProfileTemplate.d.ts +++ b/TypeScript/9RouterHooks/types/models/eft/common/tables/IProfileTemplate.d.ts @@ -18,6 +18,8 @@ export interface TemplateSide { trader: ProfileTraderTemplate; } export interface ProfileTraderTemplate { + initialLoyaltyLevel: number; initialStanding: number; initialSalesSum: number; + jaegerUnlocked: boolean; } diff --git a/TypeScript/9RouterHooks/types/models/spt/bots/BotLootCache.d.ts b/TypeScript/9RouterHooks/types/models/spt/bots/BotLootCache.d.ts new file mode 100644 index 0000000..e185315 --- /dev/null +++ b/TypeScript/9RouterHooks/types/models/spt/bots/BotLootCache.d.ts @@ -0,0 +1,23 @@ +import { ITemplateItem } from "../../eft/common/tables/ITemplateItem"; +export declare class BotLootCache { + backpackLoot: ITemplateItem[]; + pocketLoot: ITemplateItem[]; + vestLoot: ITemplateItem[]; + combinedPoolLoot: ITemplateItem[]; + specialItems: ITemplateItem[]; + healingItems: ITemplateItem[]; + drugItems: ITemplateItem[]; + stimItems: ITemplateItem[]; + grenadeItems: ITemplateItem[]; +} +export declare enum LootCacheType { + Special = "Special", + Backpack = "Backpack", + Pocket = "Pocket", + Vest = "Vest", + Combined = "Combined", + HealingItems = "HealingItems", + DrugItems = "DrugItems", + StimItems = "StimItems", + GrenadeItems = "GrenadeItems" +} diff --git a/TypeScript/9RouterHooks/types/models/spt/config/ITraderConfig.d.ts b/TypeScript/9RouterHooks/types/models/spt/config/ITraderConfig.d.ts index dab73e3..c8e8044 100644 --- a/TypeScript/9RouterHooks/types/models/spt/config/ITraderConfig.d.ts +++ b/TypeScript/9RouterHooks/types/models/spt/config/ITraderConfig.d.ts @@ -3,13 +3,17 @@ export interface ITraderConfig extends IBaseConfig { kind: "aki-trader"; updateTime: UpdateTime[]; updateTimeDefault: number; - fenceAssortSize: number; - fenceMaxPresetsCount: number; - fencePresetPriceMult: number; + traderPriceMultipler: number; minDurabilityForSale: number; - fenceItemIgnoreList: string[]; + fence: FenceConfig; } export interface UpdateTime { traderId: string; seconds: number; } +export interface FenceConfig { + assortSize: number; + maxPresetsCount: number; + presetPriceMult: number; + blacklist: string[]; +} diff --git a/TypeScript/9RouterHooks/types/services/BotLootCacheService.d.ts b/TypeScript/9RouterHooks/types/services/BotLootCacheService.d.ts new file mode 100644 index 0000000..72eb332 --- /dev/null +++ b/TypeScript/9RouterHooks/types/services/BotLootCacheService.d.ts @@ -0,0 +1,59 @@ +import { PMCLootGenerator } from "../generators/PMCLootGenerator"; +import { Items } from "../models/eft/common/tables/IBotType"; +import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem"; +import { BotLootCache, LootCacheType } from "../models/spt/bots/BotLootCache"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { JsonUtil } from "../utils/JsonUtil"; +import { RagfairPriceService } from "./RagfairPriceService"; +export declare class BotLootCacheService { + protected logger: ILogger; + protected jsonUtil: JsonUtil; + protected databaseServer: DatabaseServer; + protected pmcLootGenerator: PMCLootGenerator; + protected ragfairPriceService: RagfairPriceService; + protected lootCache: Record; + constructor(logger: ILogger, jsonUtil: JsonUtil, databaseServer: DatabaseServer, pmcLootGenerator: PMCLootGenerator, ragfairPriceService: RagfairPriceService); + /** + * Remove all cached bot loot data + */ + clearCache(): void; + /** + * Get the fully created loot array, ordered by price low to high + * @param botRole bot to get loot for + * @param isPmc is the bot a pmc + * @param lootType what type of loot is needed + * @param lootPool the full pool of loot (needed when cache is empty) + * @returns ITemplateItem array + */ + getLootFromCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): ITemplateItem[]; + /** + * Generate loot for a bot and store inside a private class property + * @param botRole + * @param lootType + * @param lootPool the full pool of loot we use to create the various sub-categories with + * @param isPmc + */ + protected addLootToCache(botRole: string, isPmc: boolean, lootType: LootCacheType, lootPool: Items): void; + /** + * Check if a bot type exists inside the loot cache + * @param botRole role to check for + * @returns true if they exist + */ + protected botRoleExistsInCache(botRole: string): boolean; + /** + * If lootcache is null, init with empty property arrays + * @param botRole Bot role to hydrate + */ + protected initCacheForBotRole(botRole: string): void; + /** + * Compares two item prices by their flea (or handbook if that doesnt exist) price + * -1 when a < b + * 0 when a === b + * 1 when a > b + * @param itemAPrice + * @param itemBPrice + * @returns + */ + protected compareByValue(itemAPrice: number, itemBPrice: number): number; +} diff --git a/TypeScript/9RouterHooks/types/services/PaymentService.d.ts b/TypeScript/9RouterHooks/types/services/PaymentService.d.ts index 5834750..a5e538f 100644 --- a/TypeScript/9RouterHooks/types/services/PaymentService.d.ts +++ b/TypeScript/9RouterHooks/types/services/PaymentService.d.ts @@ -45,5 +45,22 @@ export declare class PaymentService { * ancestor with slotId=hideout */ protected isItemInStash(pmcData: IPmcData, item: Item): boolean; + /** + * Remove currency from player stash/inventory + * @param pmcData Player profile to find and remove currency from + * @param currencyTpl Type of currency to pay + * @param amountToPay money value to pay + * @param sessionID Sessino id + * @param output output object to send to client + * @returns IItemEventRouterResponse + */ addPaymentToOutput(pmcData: IPmcData, currencyTpl: string, amountToPay: number, sessionID: string, output: IItemEventRouterResponse): IItemEventRouterResponse; + /** + * Prioritise player stash first over player inventory + * Post-raid healing would often take money out of the players pockets/secure container + * @param a Firsat money stack item + * @param b Second money stack item + * @returns sorted item + */ + protected moneySort(a: Item, b: Item): number; } diff --git a/TypeScript/9RouterHooks/types/services/ProfileFixerService.d.ts b/TypeScript/9RouterHooks/types/services/ProfileFixerService.d.ts new file mode 100644 index 0000000..313a907 --- /dev/null +++ b/TypeScript/9RouterHooks/types/services/ProfileFixerService.d.ts @@ -0,0 +1,40 @@ +import { IPmcData } from "../models/eft/common/IPmcData"; +import { IPmcDataRepeatableQuest, IRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests"; +import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ILogger } from "../models/spt/utils/ILogger"; +import { DatabaseServer } from "../servers/DatabaseServer"; +import { Watermark } from "../utils/Watermark"; +export declare class ProfileFixerService { + protected logger: ILogger; + protected watermark: Watermark; + protected databaseServer: DatabaseServer; + constructor(logger: ILogger, watermark: Watermark, databaseServer: DatabaseServer); + /** + * Find issues in the pmc profile data that may cause issues and fix them + * @param pmcProfile profile to check and fix + */ + checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void; + /** + * Add tag to profile to indicate when it was made + * @param fullProfile + */ + addMissingAkiVersionTagToProfile(fullProfile: IAkiProfile): void; + /** + * TODO - make this non-public - currently used by RepeatableQuestController + * Remove unused condition counters + * @param pmcProfile profile to remove old counters from + */ + removeDanglingConditionCounters(pmcProfile: IPmcData): void; + protected removeDanglingBackendCounters(pmcProfile: IPmcData): void; + protected getActiveRepeatableQuests(repeatableQuests: IPmcDataRepeatableQuest[]): IRepeatableQuest[]; + protected fixNullTraderSalesSums(pmcProfile: IPmcData): void; + protected addMissingBonusesProperty(pmcProfile: IPmcData): void; + protected addMissingRepeatableQuestsProperty(pmcProfile: IPmcData): void; + protected addMissingWorkbenchWeaponSkills(pmcProfile: IPmcData): void; + /** + * In 18876 bsg changed the pockets tplid to be one that has 3 additional special slots + * @param pmcProfile + */ + protected updateProfilePocketsToNewId(pmcProfile: IPmcData): void; + addMissingArmorRepairSkill(pmcProfile: IPmcData): void; +}