From bb741f681dc95e4c9db44dbc648ff8900c0f7c2a Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 18 Jan 2024 12:07:32 +0000 Subject: [PATCH] Store and process secure container loot items for bots Give gifter more items --- .../assets/database/bots/types/gifter.json | 28 +++++++++---------- project/src/generators/BotLootGenerator.ts | 12 ++++++++ project/src/models/spt/bots/IBotLootCache.ts | 2 ++ project/src/services/BotLootCacheService.ts | 12 ++++++-- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/project/assets/database/bots/types/gifter.json b/project/assets/database/bots/types/gifter.json index 60b2d91d..d77911fd 100644 --- a/project/assets/database/bots/types/gifter.json +++ b/project/assets/database/bots/types/gifter.json @@ -2051,14 +2051,15 @@ "items": { "backpackLoot": { "weights": { - "0": 1, - "1": 1, - "2": 2, - "3": 1, - "4": 1, - "5": 1, - "6": 1, - "7": 0 + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 8, + "5": 5, + "6": 2, + "7": 1, + "10": 1 }, "whitelist": [] }, @@ -2074,10 +2075,7 @@ "weights": { "0": 1, "1": 2, - "2": 1, - "3": 1, - "4": 0, - "5": 0 + "2": 1 }, "whitelist": [] }, @@ -2095,15 +2093,15 @@ "1": 0, "2": 1, "3": 3, - "4": 1 + "4": 0 }, "whitelist": [] }, "pocketLoot": { "weights": { "0": 1, - "1": 6, - "2": 3, + "1": 3, + "2": 6, "3": 1, "4": 1 }, diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 7c73d131..be823976 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -205,6 +205,18 @@ export class BotLootGenerator this.pmcConfig.maxPocketLootTotalRub, isPmc, ); + + // Secure + this.addLootFromPool( + this.botLootCacheService.getLootFromCache(botRole, isPmc, LootCacheType.SECURE, botJsonTemplate), + [EquipmentSlots.SECURED_CONTAINER], + 100, + botInventory, + botRole, + false, + -1, + isPmc, + ); } /** diff --git a/project/src/models/spt/bots/IBotLootCache.ts b/project/src/models/spt/bots/IBotLootCache.ts index 83735fca..3e50104c 100644 --- a/project/src/models/spt/bots/IBotLootCache.ts +++ b/project/src/models/spt/bots/IBotLootCache.ts @@ -5,6 +5,7 @@ export interface IBotLootCache backpackLoot: ITemplateItem[]; pocketLoot: ITemplateItem[]; vestLoot: ITemplateItem[]; + secureLoot: ITemplateItem[]; combinedPoolLoot: ITemplateItem[]; specialItems: ITemplateItem[]; @@ -20,6 +21,7 @@ export enum LootCacheType BACKPACK = "Backpack", POCKET = "Pocket", VEST = "Vest", + SECURE = "SecuredContainer", COMBINED = "Combined", HEALING_ITEMS = "HealingItems", DRUG_ITEMS = "DrugItems", diff --git a/project/src/services/BotLootCacheService.ts b/project/src/services/BotLootCacheService.ts index f24ba9ff..5b22cf6f 100644 --- a/project/src/services/BotLootCacheService.ts +++ b/project/src/services/BotLootCacheService.ts @@ -69,6 +69,8 @@ export class BotLootCacheService return this.lootCache[botRole].pocketLoot; case LootCacheType.VEST: return this.lootCache[botRole].vestLoot; + case LootCacheType.SECURE: + return this.lootCache[botRole].secureLoot; case LootCacheType.COMBINED: return this.lootCache[botRole].combinedPoolLoot; case LootCacheType.HEALING_ITEMS: @@ -107,6 +109,7 @@ export class BotLootCacheService const backpackLootTemplates: ITemplateItem[] = []; const pocketLootTemplates: ITemplateItem[] = []; const vestLootTemplates: ITemplateItem[] = []; + const secureLootTemplates: ITemplateItem[] = []; const combinedPoolTemplates: ITemplateItem[] = []; if (isPmc) @@ -143,15 +146,16 @@ export class BotLootCacheService this.addUniqueItemsToPool(vestLootTemplates, itemsToAdd); break; case "securedcontainer": - // Don't add these items to loot pool + itemsToAdd = pool.map((lootTpl: string) => items[lootTpl]); + this.addUniqueItemsToPool(secureLootTemplates, itemsToAdd); break; default: itemsToAdd = pool.map((lootTpl: string) => items[lootTpl]); this.addUniqueItemsToPool(backpackLootTemplates, itemsToAdd); } - // Add items to combined pool if any exist - if (Object.keys(itemsToAdd).length > 0) + // Add items to combined pool if any exist (excluding secured) + if (Object.keys(itemsToAdd).length > 0 && slot.toLowerCase() !== "securedcontainer") { this.addUniqueItemsToPool(combinedPoolTemplates, itemsToAdd); } @@ -231,6 +235,7 @@ export class BotLootCacheService this.lootCache[botRole].backpackLoot = backpackLootItems; this.lootCache[botRole].pocketLoot = pocketLootItems; this.lootCache[botRole].vestLoot = vestLootItems; + this.lootCache[botRole].secureLoot = secureLootTemplates; } /** @@ -328,6 +333,7 @@ export class BotLootCacheService backpackLoot: [], pocketLoot: [], vestLoot: [], + secureLoot: [], combinedPoolLoot: [], specialItems: [],