From 89ab3a99a8d7e85ecd87211abc111ebceb62662b Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 23 Jul 2023 11:27:04 +0100 Subject: [PATCH] sealedWeaponContainer - Get random weapon preset if default preset not found --- project/src/generators/LootGenerator.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/project/src/generators/LootGenerator.ts b/project/src/generators/LootGenerator.ts index 8b4b763c..e5b7f3f7 100644 --- a/project/src/generators/LootGenerator.ts +++ b/project/src/generators/LootGenerator.ts @@ -279,10 +279,16 @@ export class LootGenerator } // Get weapon preset - default or choose a random one from all possible - const chosenWeaponPreset = containerSettings.defaultPresetsOnly + let chosenWeaponPreset = containerSettings.defaultPresetsOnly ? this.presetHelper.getDefaultPreset(chosenWeaponTpl) : this.randomUtil.getArrayValue(this.presetHelper.getPresets(chosenWeaponTpl)); + if (!chosenWeaponPreset) + { + this.logger.warning(`Default preset for weapon ${chosenWeaponTpl} not found, choosing random instead`); + chosenWeaponPreset = this.randomUtil.getArrayValue(this.presetHelper.getPresets(chosenWeaponTpl)); + } + // Add preset to return object itemsToReturn.push({ count: 1,