From 3c8634edd76f6c35b32012487be0bee51d941bb4 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 16 Aug 2025 14:38:02 +0100 Subject: [PATCH] Improved saftey of adjusting values when using `randomistionDetails.NighttimeChanges.EquipmentModsModifiers` --- .../Generators/BotInventoryGenerator.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotInventoryGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotInventoryGenerator.cs index 76a954c1..a153a184 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotInventoryGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotInventoryGenerator.cs @@ -210,10 +210,13 @@ public class BotInventoryGenerator( ) { foreach (var (equipment, weight) in randomistionDetails.NighttimeChanges.EquipmentModsModifiers) - // Never let mod chance go outside 0 - 100 { - var newWeight = weight + randomistionDetails.EquipmentMods[equipment]; - randomistionDetails.EquipmentMods[equipment] = Math.Clamp(newWeight, 0, 100); + if (randomistionDetails.EquipmentMods.TryGetValue(equipment, out var value)) + { + // Never let mod chance go outside 0 - 100 + var newWeight = weight + value; + randomistionDetails.EquipmentMods[equipment] = Math.Clamp(newWeight, 0, 100); + } } }