diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs index a2891a41..3a21f79c 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs @@ -214,7 +214,12 @@ public class BotWeaponGenerator( { var ubglTemplate = _itemHelper.GetItem(ubglMod.Template).Value; ubglAmmoTpl = GetWeightedCompatibleAmmo(botTemplateInventory.Ammo, ubglTemplate); - FillUbgl(weaponWithModsArray, ubglMod, ubglAmmoTpl); + // this can be null - example - FollowerBoarClose2 can have an UBGL but doesnt have the ammo caliber defined in its json + // the default ammo passed from GetWeightCompatibleAmmo can be null + if (ubglAmmoTpl is not null) + { + FillUbgl(weaponWithModsArray, ubglMod, ubglAmmoTpl); + } } return new GenerateWeaponResult @@ -576,7 +581,7 @@ public class BotWeaponGenerator( /// Dictionary of all cartridges keyed by type e.g. Caliber556x45NATO /// Weapon details from database we want to pick ammo for /// Ammo template that works with the desired gun - protected string GetWeightedCompatibleAmmo(Dictionary> cartridgePool, TemplateItem weaponTemplate) + protected string? GetWeightedCompatibleAmmo(Dictionary> cartridgePool, TemplateItem weaponTemplate) { var desiredCaliber = GetWeaponCaliber(weaponTemplate); if (!cartridgePool.TryGetValue(desiredCaliber, out var cartridgePoolForWeapon) || cartridgePoolForWeapon?.Count == 0) @@ -597,6 +602,7 @@ public class BotWeaponGenerator( } // Immediately returns, default ammo is guaranteed to be compatible + // it is not guaranteed to even have a default ammo return weaponTemplate.Properties.DefAmmo; }