From 3846363758b2a07c32e49704da40434c3e6015ec Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 5 Mar 2024 12:24:09 +0000 Subject: [PATCH] Added system to weight stack size of money in bot inventories Removed `dynamicLoot` system from pmc config as its been replaced with this one #546 --- project/assets/configs/bot.json | 42 +++++++++++++++++++++ project/assets/configs/pmc.json | 7 ---- project/src/generators/BotLootGenerator.ts | 27 +++++++------ project/src/models/spt/config/IBotConfig.ts | 2 + project/src/models/spt/config/IPmcConfig.ts | 6 --- 5 files changed, 59 insertions(+), 25 deletions(-) diff --git a/project/assets/configs/bot.json b/project/assets/configs/bot.json index e272f4fe..15da889f 100644 --- a/project/assets/configs/bot.json +++ b/project/assets/configs/bot.json @@ -2506,5 +2506,47 @@ "5696686a4bdc2da3298b456a": 0 }, "walletTplPool": ["5783c43d2459774bbe137486", "60b0f6c058e0b0481a09ad11"] + }, + "currencyStackSize": { + "default": { + "5449016a4bdc2d6f028b456f": { + "25000": 2, + "20000": 4, + "15000": 8, + "10000": 14, + "5000": 20 + }, + "5696686a4bdc2da3298b456a": { + "50": 10, + "100": 5, + "250": 1 + }, + "569668774bdc2da2298b4568": { + "50": 10, + "100": 5, + "250": 1 + } + }, + "assault": { + "5449016a4bdc2d6f028b456f": { + "30000": 2, + "25000": 4, + "20000": 8, + "15000": 16, + "10000": 28, + "5000": 40, + "350000": 1 + }, + "5696686a4bdc2da3298b456a": { + "50": 10, + "100": 5, + "250": 1 + }, + "569668774bdc2da2298b4568": { + "50": 10, + "100": 5, + "250": 1 + } + } } } diff --git a/project/assets/configs/pmc.json b/project/assets/configs/pmc.json index 404a1063..58f0149e 100644 --- a/project/assets/configs/pmc.json +++ b/project/assets/configs/pmc.json @@ -165,13 +165,6 @@ "6540d2162ae6d96b540afcaf" ] }, - "dynamicLoot": { - "moneyStackLimits": { - "5449016a4bdc2d6f028b456f": 12000, - "5696686a4bdc2da3298b456a": 120, - "569668774bdc2da2298b4568": 120 - } - }, "useDifficultyOverride": false, "difficulty": "AsOnline", "botRelativeLevelDeltaMax": 10, diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 342ab6ba..b0e45964 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -437,7 +437,7 @@ export class BotLootGenerator } } - this.addRequiredChildItemsToParent(itemToAddTemplate, itemWithChildrenToAdd, isPmc); + this.addRequiredChildItemsToParent(itemToAddTemplate, itemWithChildrenToAdd, isPmc, botRole); // Attempt to add item to container(s) const itemAddedResult = this.botGeneratorHelper.addItemWithChildrenToEquipmentSlot( @@ -525,11 +525,13 @@ export class BotLootGenerator * @param itemToAddTemplate Db template of item to check * @param itemToAddChildrenTo Item to add children to * @param isPmc Is the item being generated for a pmc (affects money/ammo stack sizes) + * @param botRole role bot has that owns item */ protected addRequiredChildItemsToParent( itemToAddTemplate: ITemplateItem, itemToAddChildrenTo: Item[], isPmc: boolean, + botRole: string, ): void { // Fill ammo box @@ -540,7 +542,7 @@ export class BotLootGenerator // Make money a stack else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.MONEY)) { - this.randomiseMoneyStackSize(isPmc, itemToAddTemplate, itemToAddChildrenTo[0]); + this.randomiseMoneyStackSize(botRole, itemToAddTemplate, itemToAddChildrenTo[0]); } // Make ammo a stack else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.AMMO)) @@ -695,25 +697,26 @@ export class BotLootGenerator /** * Randomise the stack size of a money object, uses different values for pmc or scavs - * @param isPmc Is money on a PMC bot + * @param botRole Role bot has that has money stack * @param itemTemplate item details from db * @param moneyItem Money item to randomise */ - protected randomiseMoneyStackSize(isPmc: boolean, itemTemplate: ITemplateItem, moneyItem: Item): void + protected randomiseMoneyStackSize(botRole: string, itemTemplate: ITemplateItem, moneyItem: Item): void { - // PMCs have a different stack max size - const minStackSize = itemTemplate._props.StackMinRandom; - const maxStackSize = isPmc - ? this.pmcConfig.dynamicLoot.moneyStackLimits[itemTemplate._id] - : itemTemplate._props.StackMaxRandom; - const randomSize = this.randomUtil.getInt(minStackSize, maxStackSize); + // Get all currency weights for this bot type + let currencyWeights = this.botConfig.currencyStackSize[botRole]; + if (!currencyWeights) + { + currencyWeights = this.botConfig.currencyStackSize.default; + } + + const currencyWeight = currencyWeights[moneyItem._tpl]; if (!moneyItem.upd) { moneyItem.upd = {}; } - - moneyItem.upd.StackObjectsCount = randomSize; + moneyItem.upd.StackObjectsCount = Number.parseInt(this.weightedRandomHelper.getWeightedValue(currencyWeight)); } /** diff --git a/project/src/models/spt/config/IBotConfig.ts b/project/src/models/spt/config/IBotConfig.ts index a6220ae2..fd71175c 100644 --- a/project/src/models/spt/config/IBotConfig.ts +++ b/project/src/models/spt/config/IBotConfig.ts @@ -39,6 +39,8 @@ export interface IBotConfig extends IBaseConfig botRolesWithDogTags: string[]; /** Settings to control the items that get added into wallets on bots */ walletLoot: IWalletLootSettings; + /** Currency weights, Keyed by botrole / currency */ + currencyStackSize: Record>>; } /** Number of bots to generate and store in cache on raid start per bot type */ diff --git a/project/src/models/spt/config/IPmcConfig.ts b/project/src/models/spt/config/IPmcConfig.ts index f785c77c..55d42ae4 100644 --- a/project/src/models/spt/config/IPmcConfig.ts +++ b/project/src/models/spt/config/IPmcConfig.ts @@ -15,7 +15,6 @@ export interface IPmcConfig extends IBaseConfig pocketLoot: SlotLootSettings; /** Global whitelist/blacklist of backpack loot for PMCs */ backpackLoot: SlotLootSettings; - dynamicLoot: DynamicLoot; /** Use difficulty defined in config/bot.json/difficulty instead of chosen difficulty dropdown value */ useDifficultyOverride: boolean; /** Difficulty override e.g. "AsOnline/Hard" */ @@ -63,8 +62,3 @@ export interface SlotLootSettings blacklist: string[]; moneyStackLimits: Record; } - -export interface DynamicLoot -{ - moneyStackLimits: Record; -}