From ac5103390cd7e78b7f06e93b66db5d2af51a8813 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 11 May 2024 16:21:39 +0100 Subject: [PATCH] Added nullguard check inside `generateLoot()` to prevent 380 mods killing bot generation --- project/src/generators/BotLootGenerator.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index c8a244e4..4b59f006 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -85,6 +85,24 @@ export class BotLootGenerator // Limits on item types to be added as loot const itemCounts = botJsonTemplate.generation.items; + if(!itemCounts.backpackLoot.weights + || !itemCounts.pocketLoot.weights + || !itemCounts.vestLoot.weights + || !itemCounts.specialItems.weights + || !itemCounts.healing.weights + || !itemCounts.drugs.weights + || !itemCounts.food.weights + || !itemCounts.drink.weights + || !itemCounts.currency.weights + || !itemCounts.stims.weights + || !itemCounts.grenades.weights + ) + { + this.logger.warning(`Unable to generate bot loot for ${botRole} as bot.generation.items lacks data, skipping`); + + return; + } + const backpackLootCount = Number( this.weightedRandomHelper.getWeightedValue(itemCounts.backpackLoot.weights), );