From 4830f1e2b2e8c82b662f529e7570cf82b34b046f Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 8 Sep 2025 15:52:36 +0100 Subject: [PATCH] Removed `filledContainerIds` system as its handled by `botInventoryContainerService` --- .../Generators/BotLootGenerator.cs | 75 +++++++------------ .../Helpers/BotGeneratorHelper.cs | 10 +-- 2 files changed, 27 insertions(+), 58 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs index 451722ff..52290ee0 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs @@ -36,22 +36,22 @@ public class BotLootGenerator( protected readonly PmcConfig PMCConfig = configServer.GetConfig(); /// + /// Get a dictionary of item tpls and the number of times they can be spawned on a single bot + /// Keyed by bot type /// - /// - /// + /// Role of bot to get limits for + /// Item spawn limits protected ItemSpawnLimitSettings GetItemSpawnLimitsForBot(string botRole) { - var limits = GetItemSpawnLimitsForBotType(botRole); - // Clone limits and set all values to 0 to use as a running total - var limitsForBotDict = cloner.Clone(limits); + var limitsForBotDictClone = cloner.Clone(GetItemSpawnLimitsForBotType(botRole)); // Init current count of items we want to limit - foreach (var limit in limitsForBotDict) + foreach (var limit in limitsForBotDictClone) { - limitsForBotDict[limit.Key] = 0; + limitsForBotDictClone[limit.Key] = 0; } - return new ItemSpawnLimitSettings { CurrentLimits = limitsForBotDict, GlobalLimits = GetItemSpawnLimitsForBotType(botRole) }; + return new ItemSpawnLimitSettings { CurrentLimits = limitsForBotDictClone, GlobalLimits = GetItemSpawnLimitsForBotType(botRole) }; } /// @@ -128,10 +128,6 @@ public class BotLootGenerator( var containersBotHasAvailable = GetAvailableContainersBotCanStoreItemsIn(botInventory); - // This set is passed as a reference to fill up the containers that are already full, this alleviates - // generation of the bots by avoiding checking the slots of containers we already know are full - HashSet filledContainerIds = []; - // Special items AddLootFromPool( botId, @@ -140,8 +136,7 @@ public class BotLootGenerator( specialLootItemCount, botInventory, botRole, - botItemLimits, - containersIdFull: filledContainerIds + botItemLimits ); // Healing items / Meds @@ -154,8 +149,7 @@ public class BotLootGenerator( botRole, null, 0, - isPmc, - filledContainerIds + isPmc ); // Drugs @@ -168,8 +162,7 @@ public class BotLootGenerator( botRole, null, 0, - isPmc, - filledContainerIds + isPmc ); // Food @@ -182,8 +175,7 @@ public class BotLootGenerator( botRole, null, 0, - isPmc, - filledContainerIds + isPmc ); // Drink @@ -196,8 +188,7 @@ public class BotLootGenerator( botRole, null, 0, - isPmc, - filledContainerIds + isPmc ); // Currency @@ -210,8 +201,7 @@ public class BotLootGenerator( botRole, null, 0, - isPmc, - filledContainerIds + isPmc ); // Stims @@ -224,8 +214,7 @@ public class BotLootGenerator( botRole, botItemLimits, 0, - isPmc, - filledContainerIds + isPmc ); // Grenades @@ -238,8 +227,7 @@ public class BotLootGenerator( botRole, null, 0, - isPmc, - filledContainerIds + isPmc ); var itemPriceLimits = GetSingleItemLootPriceLimits(botLevel, isPmc); @@ -259,8 +247,7 @@ public class BotLootGenerator( botJsonTemplate.BotChances?.WeaponModsChances, botRole, isPmc, - botLevel, - filledContainerIds + botLevel ); } @@ -277,8 +264,7 @@ public class BotLootGenerator( botRole, botItemLimits, backpackLootRoubleTotal, - isPmc, - filledContainerIds + isPmc ); } @@ -297,8 +283,7 @@ public class BotLootGenerator( botRole, botItemLimits, vestLootRoubleTotal, - isPmc, - filledContainerIds + isPmc ); } @@ -314,8 +299,7 @@ public class BotLootGenerator( botRole, botItemLimits, pocketLootRoubleTotal, - isPmc, - filledContainerIds + isPmc ); // Secure @@ -332,8 +316,7 @@ public class BotLootGenerator( botRole, null, -1, - isPmc, - filledContainerIds + isPmc ); } } @@ -411,7 +394,6 @@ public class BotLootGenerator( /// Bot inventory loot will be added to /// Role of the bot loot is being generated for (assault/pmcbot) /// Item spawn limits the bot must adhere to - /// /// Total value of loot allowed in roubles /// Is bot being generated for a pmc protected internal void AddLootFromPool( @@ -423,8 +405,7 @@ public class BotLootGenerator( string botRole, ItemSpawnLimitSettings? itemSpawnLimits, double totalValueLimitRub = 0, - bool isPmc = false, - HashSet? containersIdFull = null + bool isPmc = false ) { // Loot pool has items @@ -514,8 +495,7 @@ public class BotLootGenerator( newRootItemId, itemToAddTemplate.Id, itemWithChildrenToAdd, - inventoryToAddItemsTo, - containersIdFull + inventoryToAddItemsTo ); // Handle when item cannot be added @@ -639,8 +619,7 @@ public class BotLootGenerator( /// Chances for mods to spawn on weapon /// bots role .e.g. pmcBot /// are we generating for a pmc - /// - /// + /// Level of bot having loose weapon generated public void AddLooseWeaponsToInventorySlot( MongoId botId, MongoId sessionId, @@ -650,8 +629,7 @@ public class BotLootGenerator( Dictionary modChances, string botRole, bool isPmc, - int botLevel, - HashSet? containersIdFull + int botLevel ) { var chosenWeaponType = randomUtil.GetArrayValue( @@ -698,8 +676,7 @@ public class BotLootGenerator( weaponRootItem.Id, weaponRootItem.Template, generatedWeapon.Weapon, - botInventory, - containersIdFull + botInventory ); if (result != ItemAddedResult.SUCCESS) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs index b15e2a27..d14809fc 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs @@ -436,7 +436,6 @@ public class BotGeneratorHelper( /// Root items tpl id /// Item to add /// Inventory to add item+children into - /// Container Ids with no space for more items /// ItemAddedResult result object public ItemAddedResult AddItemWithChildrenToEquipmentSlot( MongoId botId, @@ -444,8 +443,7 @@ public class BotGeneratorHelper( MongoId rootItemId, MongoId rootItemTplId, IEnumerable itemWithChildren, - BotBaseInventory inventory, - HashSet? containersIdFull = null + BotBaseInventory inventory ) { var itemWithChildrenList = itemWithChildren.ToList(); @@ -454,12 +452,6 @@ public class BotGeneratorHelper( var missingContainerCount = 0; foreach (var equipmentSlotId in equipmentSlots) { - if (containersIdFull is not null && containersIdFull.Contains(equipmentSlotId.ToString())) - { - // Container has been flagged as full already, skip trying to add item into it - continue; - } - // Get container from inventory to put item into var container = inventory.Items?.FirstOrDefault(item => item.SlotId == equipmentSlotId.ToString()); if (container is null)