From 4bd5124cf034a8111b5d0adade1324307a29d91c Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 7 May 2024 12:10:15 +0100 Subject: [PATCH] Update types --- README.md | 2 +- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- .../controllers/InsuranceController.d.ts | 47 +++++-------------- .../types/generators/PMCLootGenerator.d.ts | 12 ++--- .../GiveCommand/GiveSptCommand.d.ts | 9 +++- .../types/helpers/WeightedRandomHelper.d.ts | 7 +++ .../types/models/enums/BaseClasses.d.ts | 3 +- .../models/spt/config/IInsuranceConfig.d.ts | 2 + .../types/services/RagfairPriceService.d.ts | 6 +-- 169 files changed, 937 insertions(+), 1129 deletions(-) diff --git a/README.md b/README.md index 0e2ce0e..8c071d9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Mod examples for v3.8.1 +# Mod examples for v3.8.2 A collection of example mods that perform typical actions in SPT diff --git a/TypeScript/10ScopesAndTypes/types/controllers/InsuranceController.d.ts b/TypeScript/10ScopesAndTypes/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/10ScopesAndTypes/types/controllers/InsuranceController.d.ts +++ b/TypeScript/10ScopesAndTypes/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/10ScopesAndTypes/types/generators/PMCLootGenerator.d.ts b/TypeScript/10ScopesAndTypes/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/10ScopesAndTypes/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/10ScopesAndTypes/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/10ScopesAndTypes/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/10ScopesAndTypes/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/10ScopesAndTypes/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/10ScopesAndTypes/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/10ScopesAndTypes/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/10ScopesAndTypes/types/models/enums/BaseClasses.d.ts b/TypeScript/10ScopesAndTypes/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/10ScopesAndTypes/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/10ScopesAndTypes/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/10ScopesAndTypes/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/10ScopesAndTypes/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/10ScopesAndTypes/types/services/RagfairPriceService.d.ts b/TypeScript/10ScopesAndTypes/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/10ScopesAndTypes/types/services/RagfairPriceService.d.ts +++ b/TypeScript/10ScopesAndTypes/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/11BundleLoadingSample/types/controllers/InsuranceController.d.ts b/TypeScript/11BundleLoadingSample/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/11BundleLoadingSample/types/controllers/InsuranceController.d.ts +++ b/TypeScript/11BundleLoadingSample/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/11BundleLoadingSample/types/generators/PMCLootGenerator.d.ts b/TypeScript/11BundleLoadingSample/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/11BundleLoadingSample/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/11BundleLoadingSample/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/11BundleLoadingSample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/11BundleLoadingSample/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/11BundleLoadingSample/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/11BundleLoadingSample/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/11BundleLoadingSample/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/11BundleLoadingSample/types/models/enums/BaseClasses.d.ts b/TypeScript/11BundleLoadingSample/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/11BundleLoadingSample/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/11BundleLoadingSample/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/11BundleLoadingSample/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/11BundleLoadingSample/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/11BundleLoadingSample/types/services/RagfairPriceService.d.ts b/TypeScript/11BundleLoadingSample/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/11BundleLoadingSample/types/services/RagfairPriceService.d.ts +++ b/TypeScript/11BundleLoadingSample/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/12ClassExtensionOverride/types/controllers/InsuranceController.d.ts b/TypeScript/12ClassExtensionOverride/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/12ClassExtensionOverride/types/controllers/InsuranceController.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/12ClassExtensionOverride/types/generators/PMCLootGenerator.d.ts b/TypeScript/12ClassExtensionOverride/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/12ClassExtensionOverride/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/12ClassExtensionOverride/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/12ClassExtensionOverride/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/12ClassExtensionOverride/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/12ClassExtensionOverride/types/models/enums/BaseClasses.d.ts b/TypeScript/12ClassExtensionOverride/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/12ClassExtensionOverride/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/12ClassExtensionOverride/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/12ClassExtensionOverride/types/services/RagfairPriceService.d.ts b/TypeScript/12ClassExtensionOverride/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/12ClassExtensionOverride/types/services/RagfairPriceService.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/13AddTrader/types/controllers/InsuranceController.d.ts b/TypeScript/13AddTrader/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/13AddTrader/types/controllers/InsuranceController.d.ts +++ b/TypeScript/13AddTrader/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/13AddTrader/types/generators/PMCLootGenerator.d.ts b/TypeScript/13AddTrader/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/13AddTrader/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/13AddTrader/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/13AddTrader/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/13AddTrader/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/13AddTrader/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/13AddTrader/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/13AddTrader/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/13AddTrader/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/13AddTrader/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/13AddTrader/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/13AddTrader/types/models/enums/BaseClasses.d.ts b/TypeScript/13AddTrader/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/13AddTrader/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/13AddTrader/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/13AddTrader/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/13AddTrader/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/13AddTrader/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/13AddTrader/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/13AddTrader/types/services/RagfairPriceService.d.ts b/TypeScript/13AddTrader/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/13AddTrader/types/services/RagfairPriceService.d.ts +++ b/TypeScript/13AddTrader/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/14AfterDBLoadHook/types/controllers/InsuranceController.d.ts b/TypeScript/14AfterDBLoadHook/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/14AfterDBLoadHook/types/controllers/InsuranceController.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/14AfterDBLoadHook/types/generators/PMCLootGenerator.d.ts b/TypeScript/14AfterDBLoadHook/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/14AfterDBLoadHook/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/14AfterDBLoadHook/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/14AfterDBLoadHook/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/14AfterDBLoadHook/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/14AfterDBLoadHook/types/models/enums/BaseClasses.d.ts b/TypeScript/14AfterDBLoadHook/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/14AfterDBLoadHook/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/14AfterDBLoadHook/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/14AfterDBLoadHook/types/services/RagfairPriceService.d.ts b/TypeScript/14AfterDBLoadHook/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/14AfterDBLoadHook/types/services/RagfairPriceService.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/15HttpListenerExample/types/controllers/InsuranceController.d.ts b/TypeScript/15HttpListenerExample/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/15HttpListenerExample/types/controllers/InsuranceController.d.ts +++ b/TypeScript/15HttpListenerExample/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/15HttpListenerExample/types/generators/PMCLootGenerator.d.ts b/TypeScript/15HttpListenerExample/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/15HttpListenerExample/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/15HttpListenerExample/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/15HttpListenerExample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/15HttpListenerExample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/15HttpListenerExample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/15HttpListenerExample/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/15HttpListenerExample/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/15HttpListenerExample/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/15HttpListenerExample/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/15HttpListenerExample/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/15HttpListenerExample/types/models/enums/BaseClasses.d.ts b/TypeScript/15HttpListenerExample/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/15HttpListenerExample/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/15HttpListenerExample/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/15HttpListenerExample/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/15HttpListenerExample/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/15HttpListenerExample/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/15HttpListenerExample/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/15HttpListenerExample/types/services/RagfairPriceService.d.ts b/TypeScript/15HttpListenerExample/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/15HttpListenerExample/types/services/RagfairPriceService.d.ts +++ b/TypeScript/15HttpListenerExample/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/16ImporterUtil/types/controllers/InsuranceController.d.ts b/TypeScript/16ImporterUtil/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/16ImporterUtil/types/controllers/InsuranceController.d.ts +++ b/TypeScript/16ImporterUtil/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/16ImporterUtil/types/generators/PMCLootGenerator.d.ts b/TypeScript/16ImporterUtil/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/16ImporterUtil/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/16ImporterUtil/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/16ImporterUtil/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/16ImporterUtil/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/16ImporterUtil/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/16ImporterUtil/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/16ImporterUtil/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/16ImporterUtil/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/16ImporterUtil/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/16ImporterUtil/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/16ImporterUtil/types/models/enums/BaseClasses.d.ts b/TypeScript/16ImporterUtil/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/16ImporterUtil/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/16ImporterUtil/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/16ImporterUtil/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/16ImporterUtil/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/16ImporterUtil/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/16ImporterUtil/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/16ImporterUtil/types/services/RagfairPriceService.d.ts b/TypeScript/16ImporterUtil/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/16ImporterUtil/types/services/RagfairPriceService.d.ts +++ b/TypeScript/16ImporterUtil/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/17AsyncImporterWithDependency1/types/controllers/InsuranceController.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/controllers/InsuranceController.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/17AsyncImporterWithDependency1/types/generators/PMCLootGenerator.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/enums/BaseClasses.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairPriceService.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairPriceService.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/17AsyncImporterWithDependency2/types/controllers/InsuranceController.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/controllers/InsuranceController.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/17AsyncImporterWithDependency2/types/generators/PMCLootGenerator.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/enums/BaseClasses.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairPriceService.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairPriceService.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/18CustomItemService/types/controllers/InsuranceController.d.ts b/TypeScript/18CustomItemService/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/18CustomItemService/types/controllers/InsuranceController.d.ts +++ b/TypeScript/18CustomItemService/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/18CustomItemService/types/generators/PMCLootGenerator.d.ts b/TypeScript/18CustomItemService/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/18CustomItemService/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/18CustomItemService/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/18CustomItemService/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/18CustomItemService/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/18CustomItemService/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/18CustomItemService/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/18CustomItemService/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/18CustomItemService/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/18CustomItemService/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/18CustomItemService/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/18CustomItemService/types/models/enums/BaseClasses.d.ts b/TypeScript/18CustomItemService/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/18CustomItemService/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/18CustomItemService/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/18CustomItemService/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/18CustomItemService/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/18CustomItemService/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/18CustomItemService/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/18CustomItemService/types/services/RagfairPriceService.d.ts b/TypeScript/18CustomItemService/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/18CustomItemService/types/services/RagfairPriceService.d.ts +++ b/TypeScript/18CustomItemService/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/19UseExternalLibraries/types/controllers/InsuranceController.d.ts b/TypeScript/19UseExternalLibraries/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/19UseExternalLibraries/types/controllers/InsuranceController.d.ts +++ b/TypeScript/19UseExternalLibraries/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/19UseExternalLibraries/types/generators/PMCLootGenerator.d.ts b/TypeScript/19UseExternalLibraries/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/19UseExternalLibraries/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/19UseExternalLibraries/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/19UseExternalLibraries/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/19UseExternalLibraries/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/19UseExternalLibraries/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/19UseExternalLibraries/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/19UseExternalLibraries/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/19UseExternalLibraries/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/19UseExternalLibraries/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/19UseExternalLibraries/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/19UseExternalLibraries/types/models/enums/BaseClasses.d.ts b/TypeScript/19UseExternalLibraries/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/19UseExternalLibraries/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/19UseExternalLibraries/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/19UseExternalLibraries/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/19UseExternalLibraries/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/19UseExternalLibraries/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/19UseExternalLibraries/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/19UseExternalLibraries/types/services/RagfairPriceService.d.ts b/TypeScript/19UseExternalLibraries/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/19UseExternalLibraries/types/services/RagfairPriceService.d.ts +++ b/TypeScript/19UseExternalLibraries/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/1LogToConsole/types/controllers/InsuranceController.d.ts b/TypeScript/1LogToConsole/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/1LogToConsole/types/controllers/InsuranceController.d.ts +++ b/TypeScript/1LogToConsole/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/1LogToConsole/types/generators/PMCLootGenerator.d.ts b/TypeScript/1LogToConsole/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/1LogToConsole/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/1LogToConsole/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/1LogToConsole/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/1LogToConsole/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/1LogToConsole/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/1LogToConsole/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/1LogToConsole/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/1LogToConsole/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/1LogToConsole/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/1LogToConsole/types/models/enums/BaseClasses.d.ts b/TypeScript/1LogToConsole/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/1LogToConsole/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/1LogToConsole/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/1LogToConsole/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/1LogToConsole/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/1LogToConsole/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/1LogToConsole/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/1LogToConsole/types/services/RagfairPriceService.d.ts b/TypeScript/1LogToConsole/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/1LogToConsole/types/services/RagfairPriceService.d.ts +++ b/TypeScript/1LogToConsole/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/20CustomChatBot/types/controllers/InsuranceController.d.ts b/TypeScript/20CustomChatBot/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/20CustomChatBot/types/controllers/InsuranceController.d.ts +++ b/TypeScript/20CustomChatBot/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/20CustomChatBot/types/generators/PMCLootGenerator.d.ts b/TypeScript/20CustomChatBot/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/20CustomChatBot/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/20CustomChatBot/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/20CustomChatBot/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/20CustomChatBot/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/20CustomChatBot/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/20CustomChatBot/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/20CustomChatBot/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/20CustomChatBot/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/20CustomChatBot/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/20CustomChatBot/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/20CustomChatBot/types/models/enums/BaseClasses.d.ts b/TypeScript/20CustomChatBot/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/20CustomChatBot/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/20CustomChatBot/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/20CustomChatBot/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/20CustomChatBot/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/20CustomChatBot/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/20CustomChatBot/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/20CustomChatBot/types/services/RagfairPriceService.d.ts b/TypeScript/20CustomChatBot/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/20CustomChatBot/types/services/RagfairPriceService.d.ts +++ b/TypeScript/20CustomChatBot/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/21CustomCommandoCommand/types/controllers/InsuranceController.d.ts b/TypeScript/21CustomCommandoCommand/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/21CustomCommandoCommand/types/controllers/InsuranceController.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/21CustomCommandoCommand/types/generators/PMCLootGenerator.d.ts b/TypeScript/21CustomCommandoCommand/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/21CustomCommandoCommand/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/21CustomCommandoCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/21CustomCommandoCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/21CustomCommandoCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/21CustomCommandoCommand/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/21CustomCommandoCommand/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/21CustomCommandoCommand/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/21CustomCommandoCommand/types/models/enums/BaseClasses.d.ts b/TypeScript/21CustomCommandoCommand/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/21CustomCommandoCommand/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/21CustomCommandoCommand/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/21CustomCommandoCommand/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/21CustomCommandoCommand/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/21CustomCommandoCommand/types/services/RagfairPriceService.d.ts b/TypeScript/21CustomCommandoCommand/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/21CustomCommandoCommand/types/services/RagfairPriceService.d.ts +++ b/TypeScript/21CustomCommandoCommand/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/22CustomAkiCommand/types/controllers/InsuranceController.d.ts b/TypeScript/22CustomAkiCommand/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/22CustomAkiCommand/types/controllers/InsuranceController.d.ts +++ b/TypeScript/22CustomAkiCommand/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/22CustomAkiCommand/types/generators/PMCLootGenerator.d.ts b/TypeScript/22CustomAkiCommand/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/22CustomAkiCommand/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/22CustomAkiCommand/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/22CustomAkiCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/22CustomAkiCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/22CustomAkiCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/22CustomAkiCommand/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/22CustomAkiCommand/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/22CustomAkiCommand/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/22CustomAkiCommand/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/22CustomAkiCommand/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/22CustomAkiCommand/types/models/enums/BaseClasses.d.ts b/TypeScript/22CustomAkiCommand/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/22CustomAkiCommand/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/22CustomAkiCommand/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/22CustomAkiCommand/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/22CustomAkiCommand/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/22CustomAkiCommand/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/22CustomAkiCommand/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/22CustomAkiCommand/types/services/RagfairPriceService.d.ts b/TypeScript/22CustomAkiCommand/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/22CustomAkiCommand/types/services/RagfairPriceService.d.ts +++ b/TypeScript/22CustomAkiCommand/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/2EditDatabase/types/controllers/InsuranceController.d.ts b/TypeScript/2EditDatabase/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/2EditDatabase/types/controllers/InsuranceController.d.ts +++ b/TypeScript/2EditDatabase/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/2EditDatabase/types/generators/PMCLootGenerator.d.ts b/TypeScript/2EditDatabase/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/2EditDatabase/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/2EditDatabase/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/2EditDatabase/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/2EditDatabase/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/2EditDatabase/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/2EditDatabase/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/2EditDatabase/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/2EditDatabase/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/2EditDatabase/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/2EditDatabase/types/models/enums/BaseClasses.d.ts b/TypeScript/2EditDatabase/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/2EditDatabase/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/2EditDatabase/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/2EditDatabase/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/2EditDatabase/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/2EditDatabase/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/2EditDatabase/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/2EditDatabase/types/services/RagfairPriceService.d.ts b/TypeScript/2EditDatabase/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/2EditDatabase/types/services/RagfairPriceService.d.ts +++ b/TypeScript/2EditDatabase/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/3GetSptConfigFile/types/controllers/InsuranceController.d.ts b/TypeScript/3GetSptConfigFile/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/3GetSptConfigFile/types/controllers/InsuranceController.d.ts +++ b/TypeScript/3GetSptConfigFile/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/3GetSptConfigFile/types/generators/PMCLootGenerator.d.ts b/TypeScript/3GetSptConfigFile/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/3GetSptConfigFile/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/3GetSptConfigFile/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/3GetSptConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/3GetSptConfigFile/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/3GetSptConfigFile/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/3GetSptConfigFile/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/3GetSptConfigFile/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/3GetSptConfigFile/types/models/enums/BaseClasses.d.ts b/TypeScript/3GetSptConfigFile/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/3GetSptConfigFile/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/3GetSptConfigFile/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/3GetSptConfigFile/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/3GetSptConfigFile/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/3GetSptConfigFile/types/services/RagfairPriceService.d.ts b/TypeScript/3GetSptConfigFile/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/3GetSptConfigFile/types/services/RagfairPriceService.d.ts +++ b/TypeScript/3GetSptConfigFile/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/InsuranceController.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/InsuranceController.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/generators/PMCLootGenerator.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/BaseClasses.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairPriceService.d.ts b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairPriceService.d.ts +++ b/TypeScript/4.1UseACustomJson5OrJsonCConfigFile/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/4UseACustomConfigFile/types/controllers/InsuranceController.d.ts b/TypeScript/4UseACustomConfigFile/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/4UseACustomConfigFile/types/controllers/InsuranceController.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/4UseACustomConfigFile/types/generators/PMCLootGenerator.d.ts b/TypeScript/4UseACustomConfigFile/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/4UseACustomConfigFile/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/4UseACustomConfigFile/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/4UseACustomConfigFile/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/4UseACustomConfigFile/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/4UseACustomConfigFile/types/models/enums/BaseClasses.d.ts b/TypeScript/4UseACustomConfigFile/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/4UseACustomConfigFile/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/4UseACustomConfigFile/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/4UseACustomConfigFile/types/services/RagfairPriceService.d.ts b/TypeScript/4UseACustomConfigFile/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/4UseACustomConfigFile/types/services/RagfairPriceService.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/5ReplaceMethod/types/controllers/InsuranceController.d.ts b/TypeScript/5ReplaceMethod/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/5ReplaceMethod/types/controllers/InsuranceController.d.ts +++ b/TypeScript/5ReplaceMethod/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/5ReplaceMethod/types/generators/PMCLootGenerator.d.ts b/TypeScript/5ReplaceMethod/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/5ReplaceMethod/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/5ReplaceMethod/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/5ReplaceMethod/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/5ReplaceMethod/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/5ReplaceMethod/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/5ReplaceMethod/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/5ReplaceMethod/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/5ReplaceMethod/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/5ReplaceMethod/types/models/enums/BaseClasses.d.ts b/TypeScript/5ReplaceMethod/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/5ReplaceMethod/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/5ReplaceMethod/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/5ReplaceMethod/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/5ReplaceMethod/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/5ReplaceMethod/types/services/RagfairPriceService.d.ts b/TypeScript/5ReplaceMethod/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/5ReplaceMethod/types/services/RagfairPriceService.d.ts +++ b/TypeScript/5ReplaceMethod/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/6ReferenceAnotherClass/types/controllers/InsuranceController.d.ts b/TypeScript/6ReferenceAnotherClass/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/6ReferenceAnotherClass/types/controllers/InsuranceController.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/6ReferenceAnotherClass/types/generators/PMCLootGenerator.d.ts b/TypeScript/6ReferenceAnotherClass/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/6ReferenceAnotherClass/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/6ReferenceAnotherClass/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/6ReferenceAnotherClass/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/6ReferenceAnotherClass/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/6ReferenceAnotherClass/types/models/enums/BaseClasses.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/6ReferenceAnotherClass/types/services/RagfairPriceService.d.ts b/TypeScript/6ReferenceAnotherClass/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/6ReferenceAnotherClass/types/services/RagfairPriceService.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/7OnLoadHook/types/controllers/InsuranceController.d.ts b/TypeScript/7OnLoadHook/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/7OnLoadHook/types/controllers/InsuranceController.d.ts +++ b/TypeScript/7OnLoadHook/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/7OnLoadHook/types/generators/PMCLootGenerator.d.ts b/TypeScript/7OnLoadHook/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/7OnLoadHook/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/7OnLoadHook/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/7OnLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/7OnLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/7OnLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/7OnLoadHook/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/7OnLoadHook/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/7OnLoadHook/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/7OnLoadHook/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/7OnLoadHook/types/models/enums/BaseClasses.d.ts b/TypeScript/7OnLoadHook/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/7OnLoadHook/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/7OnLoadHook/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/7OnLoadHook/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/7OnLoadHook/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/7OnLoadHook/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/7OnLoadHook/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/7OnLoadHook/types/services/RagfairPriceService.d.ts b/TypeScript/7OnLoadHook/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/7OnLoadHook/types/services/RagfairPriceService.d.ts +++ b/TypeScript/7OnLoadHook/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/8OnUpdateHook/types/controllers/InsuranceController.d.ts b/TypeScript/8OnUpdateHook/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/8OnUpdateHook/types/controllers/InsuranceController.d.ts +++ b/TypeScript/8OnUpdateHook/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/8OnUpdateHook/types/generators/PMCLootGenerator.d.ts b/TypeScript/8OnUpdateHook/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/8OnUpdateHook/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/8OnUpdateHook/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/8OnUpdateHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/8OnUpdateHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/8OnUpdateHook/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/8OnUpdateHook/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/8OnUpdateHook/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/8OnUpdateHook/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/8OnUpdateHook/types/models/enums/BaseClasses.d.ts b/TypeScript/8OnUpdateHook/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/8OnUpdateHook/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/8OnUpdateHook/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/8OnUpdateHook/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/8OnUpdateHook/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/8OnUpdateHook/types/services/RagfairPriceService.d.ts b/TypeScript/8OnUpdateHook/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/8OnUpdateHook/types/services/RagfairPriceService.d.ts +++ b/TypeScript/8OnUpdateHook/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns diff --git a/TypeScript/9RouterHooks/types/controllers/InsuranceController.d.ts b/TypeScript/9RouterHooks/types/controllers/InsuranceController.d.ts index b3d7079..b08f2ef 100644 --- a/TypeScript/9RouterHooks/types/controllers/InsuranceController.d.ts +++ b/TypeScript/9RouterHooks/types/controllers/InsuranceController.d.ts @@ -2,6 +2,7 @@ import { DialogueHelper } from "@spt-aki/helpers/DialogueHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostRequestData"; @@ -20,6 +21,7 @@ import { MailSendService } from "@spt-aki/services/MailSendService"; import { PaymentService } from "@spt-aki/services/PaymentService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { HashUtil } from "@spt-aki/utils/HashUtil"; +import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { MathUtil } from "@spt-aki/utils/MathUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @@ -27,6 +29,7 @@ export declare class InsuranceController { protected logger: ILogger; protected randomUtil: RandomUtil; protected mathUtil: MathUtil; + protected jsonUtil: JsonUtil; protected hashUtil: HashUtil; protected eventOutputHolder: EventOutputHolder; protected timeUtil: TimeUtil; @@ -35,6 +38,7 @@ export declare class InsuranceController { protected itemHelper: ItemHelper; protected profileHelper: ProfileHelper; protected dialogueHelper: DialogueHelper; + protected weightedRandomHelper: WeightedRandomHelper; protected traderHelper: TraderHelper; protected paymentService: PaymentService; protected insuranceService: InsuranceService; @@ -43,7 +47,7 @@ export declare class InsuranceController { protected configServer: ConfigServer; protected insuranceConfig: IInsuranceConfig; protected roubleTpl: string; - constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); + constructor(logger: ILogger, randomUtil: RandomUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, hashUtil: HashUtil, eventOutputHolder: EventOutputHolder, timeUtil: TimeUtil, saveServer: SaveServer, databaseServer: DatabaseServer, itemHelper: ItemHelper, profileHelper: ProfileHelper, dialogueHelper: DialogueHelper, weightedRandomHelper: WeightedRandomHelper, traderHelper: TraderHelper, paymentService: PaymentService, insuranceService: InsuranceService, mailSendService: MailSendService, ragfairPriceService: RagfairPriceService, configServer: ConfigServer); /** * Process insurance items of all profiles prior to being given back to the player through the mail service. * @@ -146,35 +150,15 @@ export declare class InsuranceController { * @returns void */ protected processAttachmentByParent(attachments: Item[], traderId: string, toDelete: Set): void; + protected logAttachmentsBeingRemoved(attachmentIdsToRemove: string[], attachments: Item[], attachmentPrices: Record): void; + protected weightAttachmentsByPrice(attachments: Item[]): Record; /** - * Sorts the attachment items by their dynamic price in descending order. - * - * @param attachments The array of attachments items. - * @returns An array of items enriched with their max price and common locale-name. + * Get count of items to remove from weapon (take into account trader + price of attachment) + * @param weightedAttachmentByPrice Dict of item Tpls and thier rouble price + * @param traderId Trader attachment insured against + * @returns Attachment count to remove */ - protected sortAttachmentsByPrice(attachments: Item[]): EnrichedItem[]; - /** - * Logs the details of each attachment item. - * - * @param attachments The array of attachment items. - */ - protected logAttachmentsDetails(attachments: EnrichedItem[]): void; - /** - * Counts the number of successful rolls for the attachment items. - * - * @param attachments The array of attachment items. - * @param traderId The ID of the trader that has insured these attachments. - * @returns The number of successful rolls. - */ - protected countSuccessfulRolls(attachments: Item[], traderId: string): number; - /** - * Marks the most valuable attachments for deletion based on the number of successful rolls made. - * - * @param attachments The array of attachment items. - * @param successfulRolls The number of successful rolls. - * @param toDelete The array that accumulates the IDs of the items to be deleted. - */ - protected attachmentDeletionByValue(attachments: EnrichedItem[], successfulRolls: number, toDelete: Set): void; + protected getAttachmentCountToRemove(weightedAttachmentByPrice: Record, traderId: string): number; /** * Remove items from the insured items that should not be returned to the player. * @@ -192,7 +176,7 @@ export declare class InsuranceController { */ protected sendMail(sessionID: string, insurance: Insurance): void; /** - * Determines whether a insured item should be removed from the player's inventory based on a random roll and + * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance. * * @param traderId The ID of the trader who insured the item. @@ -220,8 +204,3 @@ export declare class InsuranceController { */ cost(request: IGetInsuranceCostRequestData, sessionID: string): IGetInsuranceCostResponseData; } -interface EnrichedItem extends Item { - name: string; - dynamicPrice: number; -} -export {}; diff --git a/TypeScript/9RouterHooks/types/generators/PMCLootGenerator.d.ts b/TypeScript/9RouterHooks/types/generators/PMCLootGenerator.d.ts index 4f487be..a7a36e9 100644 --- a/TypeScript/9RouterHooks/types/generators/PMCLootGenerator.d.ts +++ b/TypeScript/9RouterHooks/types/generators/PMCLootGenerator.d.ts @@ -1,4 +1,5 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; +import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -17,11 +18,13 @@ export declare class PMCLootGenerator { protected itemFilterService: ItemFilterService; protected ragfairPriceService: RagfairPriceService; protected seasonalEventService: SeasonalEventService; + protected weightedRandomHelper: WeightedRandomHelper; protected pocketLootPool: Record; protected vestLootPool: Record; protected backpackLootPool: Record; protected pmcConfig: IPmcConfig; - constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService); + protected roubleTpl: string; + constructor(itemHelper: ItemHelper, databaseServer: DatabaseServer, configServer: ConfigServer, itemFilterService: ItemFilterService, ragfairPriceService: RagfairPriceService, seasonalEventService: SeasonalEventService, weightedRandomHelper: WeightedRandomHelper); /** * Create an array of loot items a PMC can have in their pockets * @returns string array of tpls @@ -44,11 +47,4 @@ export declare class PMCLootGenerator { * @returns string array of tpls */ generatePMCBackpackLootPool(botRole: string): Record; - /** - * Find the greated common divisor of all weights and use it on the passed in dictionary - * @param weightedDict - */ - protected reduceWeightValues(weightedDict: Record): void; - protected commonDivisor(numbers: number[]): number; - protected gcd(a: number, b: number): number; } diff --git a/TypeScript/9RouterHooks/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts b/TypeScript/9RouterHooks/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts index 26958ca..d53189c 100644 --- a/TypeScript/9RouterHooks/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.d.ts @@ -2,6 +2,7 @@ import { SavedCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/Giv import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; +import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; @@ -30,10 +31,16 @@ export declare class GiveSptCommand implements ISptCommand { * spt give 5 <== this is the reply when the algo isn't sure about an item */ private static commandRegex; - private static maxAllowedDistance; + private static acceptableConfidence; protected savedCommand: Map; constructor(logger: ILogger, itemHelper: ItemHelper, hashUtil: HashUtil, jsonUtil: JsonUtil, presetHelper: PresetHelper, mailSendService: MailSendService, localeService: LocaleService, databaseServer: DatabaseServer, itemFilterService: ItemFilterService); getCommand(): string; getCommandHelp(): string; performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string; + /** + * A "simple" function that checks if an item is supposed to be given to a player or not + * @param templateItem the template item to check + * @returns true if its obtainable, false if its not + */ + protected isItemAllowed(templateItem: ITemplateItem): boolean; } diff --git a/TypeScript/9RouterHooks/types/helpers/WeightedRandomHelper.d.ts b/TypeScript/9RouterHooks/types/helpers/WeightedRandomHelper.d.ts index ab42805..f3a34f3 100644 --- a/TypeScript/9RouterHooks/types/helpers/WeightedRandomHelper.d.ts +++ b/TypeScript/9RouterHooks/types/helpers/WeightedRandomHelper.d.ts @@ -34,4 +34,11 @@ export declare class WeightedRandomHelper { item: any; index: number; }; + /** + * Find the greated common divisor of all weights and use it on the passed in dictionary + * @param weightedDict values to reduce + */ + reduceWeightValues(weightedDict: Record): void; + protected commonDivisor(numbers: number[]): number; + protected gcd(a: number, b: number): number; } diff --git a/TypeScript/9RouterHooks/types/models/enums/BaseClasses.d.ts b/TypeScript/9RouterHooks/types/models/enums/BaseClasses.d.ts index 6d2106b..d98a58f 100644 --- a/TypeScript/9RouterHooks/types/models/enums/BaseClasses.d.ts +++ b/TypeScript/9RouterHooks/types/models/enums/BaseClasses.d.ts @@ -109,5 +109,6 @@ export declare enum BaseClasses { RECEIVER = "55818a304bdc2db5418b457d", BARREL = "555ef6e44bdc2de9068b457e", CHARGING_HANDLE = "55818a6f4bdc2db9688b456b", - COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 " + COMB_MUZZLE_DEVICE = "550aa4dd4bdc2dc9348b4569 ", + HIDEOUT_AREA_CONTAINER = "63da6da4784a55176c018dba" } diff --git a/TypeScript/9RouterHooks/types/models/spt/config/IInsuranceConfig.d.ts b/TypeScript/9RouterHooks/types/models/spt/config/IInsuranceConfig.d.ts index 794abb7..86200f6 100644 --- a/TypeScript/9RouterHooks/types/models/spt/config/IInsuranceConfig.d.ts +++ b/TypeScript/9RouterHooks/types/models/spt/config/IInsuranceConfig.d.ts @@ -13,4 +13,6 @@ export interface IInsuranceConfig extends IBaseConfig { returnTimeOverrideSeconds: number; /** How often server should process insurance in seconds */ runIntervalSeconds: number; + minAttachmentRoublePriceToBeTaken: number; + chanceNoAttachmentsTakenPercent: number; } diff --git a/TypeScript/9RouterHooks/types/services/RagfairPriceService.d.ts b/TypeScript/9RouterHooks/types/services/RagfairPriceService.d.ts index 0fefdd8..f89967c 100644 --- a/TypeScript/9RouterHooks/types/services/RagfairPriceService.d.ts +++ b/TypeScript/9RouterHooks/types/services/RagfairPriceService.d.ts @@ -100,9 +100,9 @@ export declare class RagfairPriceService implements OnLoad { */ getDynamicOfferPriceForOffer(offerItems: Item[], desiredCurrency: string, isPackOffer: boolean): number; /** - * @param itemTemplateId - * @param desiredCurrency - * @param item + * @param itemTemplateId items tpl value + * @param desiredCurrency Currency to return result in + * @param item Item object (used for weapon presets) * @param offerItems * @param isPackOffer * @returns