diff --git a/Libraries/Core/Generators/BotLootGenerator.cs b/Libraries/Core/Generators/BotLootGenerator.cs
index f88f4b0d..6ede13e6 100644
--- a/Libraries/Core/Generators/BotLootGenerator.cs
+++ b/Libraries/Core/Generators/BotLootGenerator.cs
@@ -43,11 +43,21 @@ public class BotLootGenerator(
///
private ItemSpawnLimitSettings GetItemSpawnLimitsForBot(string botRole)
{
- // Init item limits
- Dictionary limitsForBotDict = new();
- InitItemLimitArray(botRole, limitsForBotDict);
+ var limits = GetItemSpawnLimitsForBotType(botRole);
- return new ItemSpawnLimitSettings { CurrentLimits = limitsForBotDict, GlobalLimits = GetItemSpawnLimitsForBotType(botRole) };
+ // Clone limits and set all values to 0 to use as a running total
+ var limitsForBotDict = _cloner.Clone(limits);
+ // Init current count of items we want to limit
+ foreach (var limit in limitsForBotDict)
+ {
+ limitsForBotDict[limit.Key] = 0;
+ }
+
+ return new ItemSpawnLimitSettings
+ {
+ CurrentLimits = limitsForBotDict,
+ GlobalLimits = GetItemSpawnLimitsForBotType(botRole)
+ };
}
///
@@ -706,22 +716,6 @@ public class BotLootGenerator(
}
}
- ///
- /// Hydrate item limit array to contain items that have a limit for a specific bot type
- /// All values are set to 0
- ///
- /// Role the bot has
- ///
- public void InitItemLimitArray(string botRole, Dictionary limitCount)
- {
- // Init current count of items we want to limit
- var spawnLimits = GetItemSpawnLimitsForBotType(botRole);
- foreach (var limit in spawnLimits)
- {
- spawnLimits[limit.Key] = 0;
- }
- }
-
///
/// Check if an item has reached its bot-specific spawn limit
///
@@ -762,10 +756,11 @@ public class BotLootGenerator(
// Check if over limit
+ var currentLimitCount = itemSpawnLimits.CurrentLimits[idToCheckFor];
if (itemSpawnLimits.CurrentLimits[idToCheckFor] > itemSpawnLimits.GlobalLimits[idToCheckFor])
{
// Prevent edge-case of small loot pools + code trying to add limited item over and over infinitely
- if (itemSpawnLimits.CurrentLimits[idToCheckFor] > itemSpawnLimits.CurrentLimits[idToCheckFor] * 10)
+ if (currentLimitCount > currentLimitCount * 10)
{
if(_logger.IsLogEnabled(LogLevel.Debug))
_logger.Debug(
@@ -775,7 +770,7 @@ public class BotLootGenerator(
{
botRole = botRole,
itemName = itemTemplate.Name,
- attempts = itemSpawnLimits.CurrentLimits[idToCheckFor]
+ attempts = currentLimitCount
}
)
);
@@ -837,7 +832,7 @@ public class BotLootGenerator(
return _botConfig.ItemSpawnLimits["pmc"];
}
- if (_botConfig.ItemSpawnLimits[botRole.ToLower()] is not null)
+ if (_botConfig.ItemSpawnLimits.ContainsKey(botRole.ToLower()))
{
return _botConfig.ItemSpawnLimits[botRole.ToLower()];
}