From 63d5da4c185673c613ffffa234494833af3c6df3 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 4 Mar 2024 20:18:53 +0000 Subject: [PATCH] Wallet loot improvements: Added % chance to have loot to config Added currency added weigfht system to config (only roubles by default) Added allowed wallet types array to config Added WZ wallet to pool of wallets to add money to Fixed bug where itemCount type was incorrect --- project/assets/configs/bot.json | 9 ++++++++- project/src/generators/BotLootGenerator.ts | 15 +++++++++------ project/src/models/spt/config/IBotConfig.ts | 7 ++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/project/assets/configs/bot.json b/project/assets/configs/bot.json index 2657c9e8..cdfee815 100644 --- a/project/assets/configs/bot.json +++ b/project/assets/configs/bot.json @@ -2486,6 +2486,7 @@ "default": 16 }, "walletLoot": { + "chancePercent": 35, "itemCount": { "min": 1, "max": 3 @@ -2496,6 +2497,12 @@ "15000": 4, "10000": 7, "5000": 10 - } + }, + "currencyWeight": { + "5449016a4bdc2d6f028b456f": 1, + "569668774bdc2da2298b4568": 0, + "5696686a4bdc2da3298b456a": 0 + }, + "walletTplPool": ["5783c43d2459774bbe137486", "60b0f6c058e0b0481a09ad11"] } } diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index bc5bab51..342ab6ba 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -404,10 +404,10 @@ export class BotLootGenerator }]; // Is Simple-Wallet - if (weightedItemTpl === "5783c43d2459774bbe137486") + if (this.botConfig.walletLoot.walletTplPool.includes(weightedItemTpl)) { - const addCurrency = this.randomUtil.getChance100(25); - if (addCurrency) + const addCurrencyToWallet = this.randomUtil.getChance100(this.botConfig.walletLoot.chancePercent); + if (addCurrencyToWallet) { // Create the currency items we want to add to wallet const itemsToAdd = this.createWalletLoot(newRootItemId); @@ -499,16 +499,19 @@ export class BotLootGenerator const result: Item[][] = []; // Choose how many stacks of currency will be added to wallet - const itemCount = this.randomUtil.getInt(1, this.botConfig.walletLoot.itemCount); + const itemCount = this.randomUtil.getInt( + this.botConfig.walletLoot.itemCount.min, + this.botConfig.walletLoot.itemCount.max, + ); for (let index = 0; index < itemCount; index++) { - // Choose the size of the currency stack + // Choose the size of the currency stack - default is 5k, 10k, 15k, 20k, 25k const chosenStackCount = Number( this.weightedRandomHelper.getWeightedValue(this.botConfig.walletLoot.stackSizeWeight), ); result.push([{ _id: this.hashUtil.generate(), - _tpl: "5449016a4bdc2d6f028b456f", // TODO - extend to be more than just roubles + _tpl: this.weightedRandomHelper.getWeightedValue(this.botConfig.walletLoot.currencyWeight), parentId: walletId, upd: { StackObjectsCount: chosenStackCount }, }]); diff --git a/project/src/models/spt/config/IBotConfig.ts b/project/src/models/spt/config/IBotConfig.ts index 3a787827..a6220ae2 100644 --- a/project/src/models/spt/config/IBotConfig.ts +++ b/project/src/models/spt/config/IBotConfig.ts @@ -84,8 +84,13 @@ export interface PresetBatch export interface IWalletLootSettings { - itemCount: number; + /** Chance wallets have loot in them */ + chancePercent: number; + itemCount: MinMax; stackSizeWeight: Record; + currencyWeight: Record; + /** What wallets will have money in them */ + walletTplPool: string[]; } export interface EquipmentFilters