From 0ec5aeab915a9d12752df7d8b8701e96ee230d15 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 14 Jul 2025 17:57:32 +0100 Subject: [PATCH] Removed `FilterBlacklistedGear`, same functionality can be done via editing the equipment's weighting to 0 --- .../Generators/BotGenerator.cs | 50 ------------------- .../Models/Spt/Config/BotConfig.cs | 7 --- .../Services/SeasonalEventService.cs | 23 ++++----- 3 files changed, 10 insertions(+), 70 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs index 401fb6aa..0db5efed 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs @@ -301,9 +301,6 @@ public class BotGenerator( // Add drip SetBotAppearance(bot, botJsonTemplate.BotAppearance, botGenerationDetails); - // Filter out blacklisted gear from the base template - FilterBlacklistedGear(botJsonTemplate, botGenerationDetails); - bot.Inventory = botInventoryGenerator.GenerateInventory( sessionId, botJsonTemplate, @@ -429,53 +426,6 @@ public class BotGenerator( return result; } - /// - /// Set weighting of flagged equipment to 0 - /// - /// Bot data to adjust - /// Generation details of bot - public void FilterBlacklistedGear( - BotType botJsonTemplate, - BotGenerationDetails botGenerationDetails - ) - { - var blacklist = botEquipmentFilterService.GetBotEquipmentBlacklist( - botGeneratorHelper.GetBotEquipmentRole(botGenerationDetails.Role), - botGenerationDetails.PlayerLevel.GetValueOrDefault(1) - ); - - if (blacklist?.Gear is { Count: < 1 }) - // Nothing to filter by - { - return; - } - - foreach (var (equipmentSlot, blacklistedTpls) in blacklist.Gear) - { - if ( - !botJsonTemplate.BotInventory.Equipment.TryGetValue( - equipmentSlot, - out var equipmentTplWeights - ) - ) - { - // Bot doesn't have this equipment slot, skip - continue; - } - - // Inner join between equipment tpls and blacklist tpls - var tplsToZeroOut = equipmentTplWeights - .Keys.Where(tpl => blacklistedTpls.Contains(tpl)) - .ToList(); - - foreach (var tpl in tplsToZeroOut) - { - // Set weighting to 0, will never be picked - equipmentTplWeights[tpl] = 0; - } - } - } - /// /// Unheard PMCs need their pockets expanded /// diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/BotConfig.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/BotConfig.cs index c97a710e..e97cf024 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/BotConfig.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/BotConfig.cs @@ -2,7 +2,6 @@ using System.Text.Json.Serialization; using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; -using SPTarkov.Server.Core.Models.Enums; namespace SPTarkov.Server.Core.Models.Spt.Config; @@ -398,12 +397,6 @@ public record EquipmentFilterDetails [JsonPropertyName("equipment")] public Dictionary>? Equipment { get; set; } - /// - /// Key: equipment slot name e.g. FirstPrimaryWeapon, value: item tpls - /// - [JsonPropertyName("gear")] - public Dictionary>? Gear { get; set; } - /// /// Key: cartridge type e.g. Caliber23x75, value: item tpls /// diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 3d9f6b27..a4be9fee 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -568,33 +568,30 @@ public class SeasonalEventService( private void AdjustBotAppearanceValues(SeasonalEventType season) { - var adjustments = _seasonalEventConfig.BotAppearanceChanges[season]; - if (adjustments is null) + if ( + !_seasonalEventConfig.BotAppearanceChanges.TryGetValue( + season, + out var appearanceAdjustments + ) + ) { return; } - foreach (var botTypeKey in adjustments) + foreach (var (botType, botAppearanceAdjustments) in appearanceAdjustments) { - var botDb = databaseService.GetBots().Types[botTypeKey.Key]; - if (botDb is null) + if (!databaseService.GetBots().Types.TryGetValue(botType, out var botDb)) { continue; } - var botAppearanceAdjustments = botTypeKey.Value; - foreach (var appearanceKey in botAppearanceAdjustments) + foreach (var (key, weightAdjustments) in botAppearanceAdjustments) { - var weightAdjustments = appearanceKey.Value; var props = botDb.BotAppearance.GetType().GetProperties(); foreach (var itemKey in weightAdjustments) { var prop = props.FirstOrDefault(x => - string.Equals( - x.Name, - appearanceKey.Key, - StringComparison.CurrentCultureIgnoreCase - ) + string.Equals(x.Name, key, StringComparison.CurrentCultureIgnoreCase) ); var propValue = (Dictionary)prop.GetValue(botDb.BotAppearance); propValue[itemKey.Key] = weightAdjustments[itemKey.Key];