diff --git a/Libraries/Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs b/Libraries/Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs index 044c498e..021bd94b 100644 --- a/Libraries/Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs +++ b/Libraries/Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs @@ -82,13 +82,19 @@ public class ExternalInventoryMagGen( if (magazineTpl == defaultMagazineTpl) { - // We were already on default - stop here to prevent infinite looping + // We were already on default - stop here to prevent infinite loop break; } // Add failed magazine tpl to blacklist attemptedMagBlacklist.Add(magazineTpl); + if (defaultMagazineTpl is null) + { + // No default to fall back to, stop trying to add mags + break; + } + // Set chosen magazine tpl to the weapons default magazine tpl and try to fit into inventory next loop magazineTpl = defaultMagazineTpl; magTemplate = _itemHelper.GetItem(magazineTpl).Value; diff --git a/Libraries/Core/Helpers/BotWeaponGeneratorHelper.cs b/Libraries/Core/Helpers/BotWeaponGeneratorHelper.cs index c283f697..64adc54c 100644 --- a/Libraries/Core/Helpers/BotWeaponGeneratorHelper.cs +++ b/Libraries/Core/Helpers/BotWeaponGeneratorHelper.cs @@ -149,7 +149,7 @@ public class BotWeaponGeneratorHelper( /// /// Weapon to get default magazine for /// Tpl of magazine - public string GetWeaponsDefaultMagazineTpl(TemplateItem weaponTemplate) + public string? GetWeaponsDefaultMagazineTpl(TemplateItem weaponTemplate) { return weaponTemplate.Properties.DefMagType; } diff --git a/Libraries/Core/Helpers/DurabilityLimitsHelper.cs b/Libraries/Core/Helpers/DurabilityLimitsHelper.cs index 74205031..69545ac8 100644 --- a/Libraries/Core/Helpers/DurabilityLimitsHelper.cs +++ b/Libraries/Core/Helpers/DurabilityLimitsHelper.cs @@ -42,9 +42,13 @@ public class DurabilityLimitsHelper( return GenerateMaxWeaponDurability("follower"); } } - - return GenerateMaxWeaponDurability(botRole); + var roleExistsInConfig = _botConfig.Durability.BotDurabilities.ContainsKey(botRole); + if (!roleExistsInConfig) + { + _logger.Warning($"{botRole} doesn't exist in bot config durability values, using default fallback"); + } + return GenerateMaxWeaponDurability(roleExistsInConfig ? botRole : "default"); } /// @@ -105,7 +109,12 @@ public class DurabilityLimitsHelper( } } - return GenerateWeaponDurability(botRole, maxDurability); + var roleExistsInConfig = _botConfig.Durability.BotDurabilities.ContainsKey(botRole); + if (!roleExistsInConfig) + { + _logger.Warning($"{botRole} doesn't exist in bot config durability values, using default fallback"); + } + return GenerateWeaponDurability(roleExistsInConfig ? botRole : "default", maxDurability); } /// diff --git a/Server/Assets/configs/bot.json b/Server/Assets/configs/bot.json index 671ec148..603e9c67 100644 --- a/Server/Assets/configs/bot.json +++ b/Server/Assets/configs/bot.json @@ -274,7 +274,21 @@ "minDelta": 0, "minLimitPercent": 15 } - } + }, + "gifter": { + "armor": { + "maxDelta": 10, + "minDelta": 0, + "minLimitPercent": 15 + }, + "weapon": { + "lowestMax": 90, + "highestMax": 100, + "maxDelta": 10, + "minDelta": 0, + "minLimitPercent": 15 + } + } } }, "lootItemResourceRandomization": {