From 5e79f02cbfc2899bc2bd3455d6a73451ff9b53ba Mon Sep 17 00:00:00 2001 From: Chomp Date: Wed, 15 Jan 2025 00:04:44 +0000 Subject: [PATCH] Made use of EquipmentSlots enum --- Core/Generators/BotGenerator.cs | 4 +- Core/Generators/BotInventoryGenerator.cs | 280 +++++++++++++++++- Core/Helpers/BotGeneratorHelper.cs | 20 +- Core/Models/Eft/Common/Tables/BotType.cs | 3 +- Core/Models/Eft/Match/RaidSettings.cs | 6 +- Core/Models/Enums/EquipmentSlots.cs | 32 +- .../Spt/Bots/GenerateEquipmentProperties.cs | 7 +- Core/Models/Spt/Config/BotConfig.cs | 3 +- Core/Models/Spt/Config/PlayerScavConfig.cs | 3 +- Core/Services/BotEquipmentFilterService.cs | 20 +- Core/Services/SeasonalEventService.cs | 3 +- 11 files changed, 338 insertions(+), 43 deletions(-) diff --git a/Core/Generators/BotGenerator.cs b/Core/Generators/BotGenerator.cs index e9337162..78da8cf7 100644 --- a/Core/Generators/BotGenerator.cs +++ b/Core/Generators/BotGenerator.cs @@ -302,7 +302,7 @@ public class BotGenerator // Filter out blacklisted gear from the base template FilterBlacklistedGear(botJsonTemplate, botGenerationDetails); - bot.Inventory = _botInventoryGenerator.generateInventory( + bot.Inventory = _botInventoryGenerator.GenerateInventory( sessionId, botJsonTemplate, botRoleLowercase, @@ -407,7 +407,7 @@ public class BotGenerator { var blacklist = _botEquipmentFilterService.GetBotEquipmentBlacklist( _botGeneratorHelper.GetBotEquipmentRole(botGenerationDetails.Role), - botGenerationDetails.PlayerLevel.Value); + botGenerationDetails.PlayerLevel.GetValueOrDefault(1)); if (blacklist?.Gear is null) { diff --git a/Core/Generators/BotInventoryGenerator.cs b/Core/Generators/BotInventoryGenerator.cs index 00f387c3..257b8165 100644 --- a/Core/Generators/BotInventoryGenerator.cs +++ b/Core/Generators/BotInventoryGenerator.cs @@ -1,19 +1,55 @@ -using Core.Annotations; +using Core.Annotations; +using Core.Context; +using Core.Helpers; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Match; +using Core.Models.Enums; using Core.Models.Spt.Bots; using Core.Models.Spt.Config; +using Core.Servers; +using Core.Utils; using Equipment = Core.Models.Eft.Common.Tables.Equipment; +using ILogger = Core.Models.Utils.ILogger; namespace Core.Generators; [Injectable] public class BotInventoryGenerator { + private readonly ILogger _logger; + private readonly HashUtil _hashUtil; + private readonly BotLootGenerator _botLootGenerator; + private readonly BotHelper _botHelper; + private readonly BotGeneratorHelper _botGeneratorHelper; + private readonly WeatherHelper _weatherHelper; + private readonly ProfileHelper _profileHelper; + private readonly ConfigServer _configServer; + private readonly ApplicationContext _applicationContext; private BotConfig _botConfig; - public BotInventoryGenerator() + public BotInventoryGenerator( + ILogger logger, + HashUtil hashUtil, + BotLootGenerator botLootGenerator, + BotHelper botHelper, + BotGeneratorHelper botGeneratorHelper, + WeatherHelper weatherHelper, + ProfileHelper profileHelper, + ConfigServer configServer, + ApplicationContext applicationContext + ) { + _logger = logger; + _hashUtil = hashUtil; + _botLootGenerator = botLootGenerator; + _botHelper = botHelper; + _botGeneratorHelper = botGeneratorHelper; + _weatherHelper = weatherHelper; + _profileHelper = profileHelper; + _configServer = configServer; + _applicationContext = applicationContext; + + _botConfig = _configServer.GetConfig(ConfigTypes.BOT); } /// @@ -26,9 +62,45 @@ public class BotInventoryGenerator /// Level of bot being generated /// Game version for bot, only really applies for PMCs /// PmcInventory object with equipment/weapons/loot - public BotBaseInventory generateInventory(string sessionId, BotType botJsonTemplate, string botRole, bool isPmc, int botLevel, string chosenGameVersion) + public BotBaseInventory GenerateInventory(string sessionId, BotType botJsonTemplate, string botRole, bool isPmc, int botLevel, string chosenGameVersion) { - throw new NotImplementedException(); + var templateInventory = botJsonTemplate.BotInventory; + var wornItemChances = botJsonTemplate.BotChances; + var itemGenerationLimitsMinMax = botJsonTemplate.BotGeneration; + + // Generate base inventory with no items + var botInventory = GenerateInventoryBase(); + + // Get generated raid details bot will be spawned in + var raidConfig = _applicationContext + .GetLatestValue(ContextVariableType.RAID_CONFIGURATION) + ?.GetValue(); + + GenerateAndAddEquipmentToBot( + sessionId, + templateInventory, + wornItemChances, + botRole, + botInventory, + botLevel, + chosenGameVersion, + raidConfig); + + // Roll weapon spawns (primary/secondary/holster) and generate a weapon for each roll that passed + GenerateAndAddWeaponsToBot( + templateInventory, + wornItemChances, + sessionId, + botInventory, + botRole, + isPmc, + itemGenerationLimitsMinMax, + botLevel); + + // Pick loot and add to bots containers (rig/backpack/pockets/secure) + _botLootGenerator.GenerateLoot(sessionId, botJsonTemplate, isPmc, botRole, botInventory, botLevel); + + return botInventory; } /// @@ -37,7 +109,31 @@ public class BotInventoryGenerator /// PmcInventory object public BotBaseInventory GenerateInventoryBase() { - throw new NotImplementedException(); + var equipmentId = _hashUtil.Generate(); + var stashId = _hashUtil.Generate(); + var questRaidItemsId = _hashUtil.Generate(); + var questStashItemsId = _hashUtil.Generate(); + var sortingTableId = _hashUtil.Generate(); + + return new BotBaseInventory{ + Items = + [ + new() { Id = equipmentId, Template = ItemTpl.INVENTORY_DEFAULT }, + new() { Id = stashId, Template = ItemTpl.STASH_STANDARD_STASH_10X30 }, + new() { Id = questRaidItemsId, Template = ItemTpl.STASH_QUESTRAID }, + new() { Id = questStashItemsId, Template = ItemTpl.STASH_QUESTOFFLINE }, + new() { Id = sortingTableId, Template = ItemTpl.SORTINGTABLE_SORTING_TABLE } + ], + Equipment = equipmentId, + Stash = stashId, + QuestRaidItems = questRaidItemsId, + QuestStashItems = questStashItemsId, + SortingTable = sortingTableId, + HideoutAreaStashes = { }, + FastPanel = { }, + FavoriteItems = [], + HideoutCustomizationStashId = "", + }; } /// @@ -51,10 +147,168 @@ public class BotInventoryGenerator /// Level of bot /// Game version for bot, only really applies for PMCs /// RadiConfig - public void GenerateAndAddEquipmentToBot(string sessionId, BotBaseInventory templateInventory, Chances wornItemChances, string botRole, + public void GenerateAndAddEquipmentToBot(string sessionId, BotTypeInventory templateInventory, Chances wornItemChances, string botRole, BotBaseInventory botInventory, int botLevel, string chosenGameVersion, GetRaidConfigurationRequestData raidConfig) { - throw new NotImplementedException(); + // These will be handled later + var excludedSlots = new List(){ + EquipmentSlots.Pockets, + EquipmentSlots.FirstPrimaryWeapon, + EquipmentSlots.SecondPrimaryWeapon, + EquipmentSlots.Holster, + EquipmentSlots.ArmorVest, + EquipmentSlots.TacticalVest, + EquipmentSlots.FaceCover, + EquipmentSlots.Headwear, + EquipmentSlots.Earpiece + }; + + _botConfig.Equipment.TryGetValue(_botGeneratorHelper.GetBotEquipmentRole(botRole), out var botEquipConfig); + var randomistionDetails = _botHelper.GetBotRandomizationDetails(botLevel, botEquipConfig); + + // Apply nighttime changes if its nighttime + there's changes to make + if ( + randomistionDetails?.NighttimeChanges is not null && + raidConfig is not null && + _weatherHelper.IsNightTime(raidConfig.TimeVariant) + ) + { + foreach (var equipmentSlotKvP in (randomistionDetails.NighttimeChanges.EquipmentModsModifiers)) { + // Never let mod chance go outside of 0 - 100 + randomistionDetails.EquipmentMods[equipmentSlotKvP.Key] = Math.Min( + Math.Max( randomistionDetails.EquipmentMods[equipmentSlotKvP.Key] + equipmentSlotKvP.Value, 0), 100); + } + } + + // Get profile of player generating bots, we use their level later on + var pmcProfile = _profileHelper.GetPmcProfile(sessionId); + var botEquipmentRole = _botGeneratorHelper.GetBotEquipmentRole(botRole); + + + // Iterate over all equipment slots of bot, do it in specifc order to reduce conflicts + // e.g. ArmorVest should be generated after TactivalVest + // or FACE_COVER before HEADWEAR + foreach (var equipmentSlotKvP in templateInventory.Equipment) { + // Skip some slots as they need to be done in a specific order + with specific parameter values + // e.g. Weapons + if (excludedSlots.Contains(equipmentSlotKvP.Key)) { + continue; + } + + GenerateEquipment( new GenerateEquipmentProperties + { + RootEquipmentSlot = equipmentSlotKvP.Key, + RootEquipmentPool = equipmentSlotKvP.Value, + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData { Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); + } + + // Generate below in specific order + GenerateEquipment( new GenerateEquipmentProperties + { + RootEquipmentSlot = EquipmentSlots.Pockets, + // Unheard profiles have unique sized pockets, TODO - handle this somewhere else in a better way + RootEquipmentPool = + chosenGameVersion == GameEditions.UNHEARD + ? new Dictionary{ [ItemTpl.POCKETS_1X4_TUE] = 1 } + : templateInventory.Equipment[EquipmentSlots.Pockets], + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData{ Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GenerateModsBlacklist = [ItemTpl.POCKETS_1X4_TUE], + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); + + GenerateEquipment( new GenerateEquipmentProperties + { + RootEquipmentSlot = EquipmentSlots.FaceCover, + RootEquipmentPool = templateInventory.Equipment[EquipmentSlots.FaceCover], + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData { Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); + + GenerateEquipment( new GenerateEquipmentProperties + { + RootEquipmentSlot = EquipmentSlots.Headwear, + RootEquipmentPool = templateInventory.Equipment[EquipmentSlots.Headwear], + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData { Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); + + GenerateEquipment(new GenerateEquipmentProperties + { + RootEquipmentSlot = EquipmentSlots.Earpiece, + RootEquipmentPool = templateInventory.Equipment[EquipmentSlots.Earpiece], + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData { Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); + + var hasArmorVest = GenerateEquipment( new GenerateEquipmentProperties + { + RootEquipmentSlot = EquipmentSlots.ArmorVest, + RootEquipmentPool = templateInventory.Equipment[EquipmentSlots.ArmorVest], + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData { Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); + + // Bot has no armor vest and flagged to be forced to wear armored rig in this event + if (botEquipConfig.ForceOnlyArmoredRigWhenNoArmor.GetValueOrDefault(false) && !hasArmorVest) { + // Filter rigs down to only those with armor + FilterRigsToThoseWithProtection(templateInventory.Equipment, botRole); + } + + // Optimisation - Remove armored rigs from pool + if (hasArmorVest) { + // Filter rigs down to only those with armor + FilterRigsToThoseWithoutProtection(templateInventory.Equipment, botRole); + } + + // Bot is flagged as always needing a vest + if (botEquipConfig.ForceRigWhenNoVest.GetValueOrDefault(false) && !hasArmorVest) { + wornItemChances.EquipmentChances["TacticalVest"] = 100; + } + + GenerateEquipment( new GenerateEquipmentProperties + { + RootEquipmentSlot = EquipmentSlots.Earpiece, + RootEquipmentPool = templateInventory.Equipment[EquipmentSlots.Earpiece], + ModPool = templateInventory.Mods, + SpawnChances = wornItemChances, + BotData = new BotData { Role = botRole, Level = botLevel, EquipmentRole = botEquipmentRole }, + Inventory = botInventory, + BotEquipmentConfig = botEquipConfig, + RandomisationDetails = randomistionDetails, + GeneratingPlayerLevel = pmcProfile.Info.Level, + }); } /// @@ -62,7 +316,12 @@ public class BotInventoryGenerator /// /// Equpiment to filter TacticalVest of /// Role of bot vests are being filtered for - public void FilterRigsToThoseWithProtection(Equipment templateEquipment, string botRole) + public void FilterRigsToThoseWithProtection(Dictionary> templateEquipment, string botRole) + { + throw new NotImplementedException(); + } + + public void FilterRigsToThoseWithoutProtection(Dictionary> templateEquipment, string botRole, bool allowEmptyResult = true) { throw new NotImplementedException(); } @@ -85,7 +344,8 @@ public class BotInventoryGenerator /// true when item added public bool GenerateEquipment(GenerateEquipmentProperties settings) { - throw new NotImplementedException(); + _logger.Error("NOT IMPLEMENTED - GenerateEquipment"); + return true; } /// @@ -110,7 +370,7 @@ public class BotInventoryGenerator /// Is the bot being generated as a pmc /// Limits for items the bot can have /// level of bot having weapon generated - public void GenerateAndAddWeaponsToBot(BotBaseInventory templateInventory, Chances equipmentChances, string sessionId, BotBaseInventory botInventory, + public void GenerateAndAddWeaponsToBot(BotTypeInventory templateInventory, Chances equipmentChances, string sessionId, BotBaseInventory botInventory, string botRole, bool isPmc, Generation itemGenerationLimitsMinMax, int botLevel) { diff --git a/Core/Helpers/BotGeneratorHelper.cs b/Core/Helpers/BotGeneratorHelper.cs index 8f595563..5e73642d 100644 --- a/Core/Helpers/BotGeneratorHelper.cs +++ b/Core/Helpers/BotGeneratorHelper.cs @@ -1,13 +1,25 @@ -using Core.Annotations; +using Core.Annotations; using Core.Models.Eft.Common.Tables; using Core.Models.Enums; using Core.Models.Spt.Config; +using Core.Servers; namespace Core.Helpers; [Injectable] public class BotGeneratorHelper { + private readonly ConfigServer _configServer; + private readonly PmcConfig _pmcConfig; + + public BotGeneratorHelper( + ConfigServer configServer + ) + { + _configServer = configServer; + _pmcConfig = _configServer.GetConfig(ConfigTypes.PMC); + } + /// /// Adds properties to an item /// e.g. Repairable / HasHinge / Foldable / MaxDurability @@ -84,7 +96,11 @@ public class BotGeneratorHelper /// Equipment role (e.g. pmc / assault / bossTagilla) public string GetBotEquipmentRole(string botRole) { - throw new NotImplementedException(); + string[] pmcs = [_pmcConfig.UsecType.ToLower(), _pmcConfig.BearType.ToLower()]; + return pmcs.Contains( + botRole.ToLower()) + ? "pmc" + : botRole; } /// diff --git a/Core/Models/Eft/Common/Tables/BotType.cs b/Core/Models/Eft/Common/Tables/BotType.cs index 8bc1b3af..180b1487 100644 --- a/Core/Models/Eft/Common/Tables/BotType.cs +++ b/Core/Models/Eft/Common/Tables/BotType.cs @@ -1,5 +1,6 @@ using System.Text.Json.Serialization; using Core.Models.Common; +using Core.Models.Enums; using Core.Utils.Json.Converters; namespace Core.Models.Eft.Common.Tables; @@ -332,7 +333,7 @@ public class BodyPart public class BotTypeInventory { [JsonPropertyName("equipment")] - public Dictionary>? Equipment { get; set; } + public Dictionary>? Equipment { get; set; } public GlobalAmmo? Ammo { get; set; } diff --git a/Core/Models/Eft/Match/RaidSettings.cs b/Core/Models/Eft/Match/RaidSettings.cs index b5ef7e56..0498c075 100644 --- a/Core/Models/Eft/Match/RaidSettings.cs +++ b/Core/Models/Eft/Match/RaidSettings.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; using Core.Models.Enums; using Core.Models.Enums.RaidSettings; using Core.Models.Enums.RaidSettings.TimeAndWeather; @@ -17,7 +17,7 @@ public class RaidSettings public bool? IsLocationTransition { get; set; } [JsonPropertyName("timeVariant")] - public DateTime? TimeVariant { get; set; } + public DateTimeEnum TimeVariant { get; set; } [JsonPropertyName("metabolismDisabled")] public bool? MetabolismDisabled { get; set; } @@ -93,4 +93,4 @@ public class WavesSettings [JsonPropertyName("isTaggedAndCursed")] public bool? IsTaggedAndCursed { get; set; } -} \ No newline at end of file +} diff --git a/Core/Models/Enums/EquipmentSlots.cs b/Core/Models/Enums/EquipmentSlots.cs index 8d736c11..c8d5d33d 100644 --- a/Core/Models/Enums/EquipmentSlots.cs +++ b/Core/Models/Enums/EquipmentSlots.cs @@ -1,19 +1,19 @@ -namespace Core.Models.Enums; +namespace Core.Models.Enums; public enum EquipmentSlots { - HEADWEAR, - EARPIECE, - FACE_COVER, - ARMOR_VEST, - EYEWEAR, - ARM_BAND, - TACTICAL_VEST, - POCKETS, - BACKPACK, - SECURED_CONTAINER, - FIRST_PRIMARY_WEAPON, - SECOND_PRIMARY_WEAPON, - HOLSTER, - SCABBARD -} \ No newline at end of file + Headwear, + Earpiece, + FaceCover, + ArmorVest, + Eyewear, + ArmBand, + TacticalVest, + Pockets, + Backpack, + SecuredContainer, + FirstPrimaryWeapon, + SecondPrimaryWeapon, + Holster, + Scabbard +} diff --git a/Core/Models/Spt/Bots/GenerateEquipmentProperties.cs b/Core/Models/Spt/Bots/GenerateEquipmentProperties.cs index b1dc32b1..f558e841 100644 --- a/Core/Models/Spt/Bots/GenerateEquipmentProperties.cs +++ b/Core/Models/Spt/Bots/GenerateEquipmentProperties.cs @@ -1,5 +1,6 @@ using System.Text.Json.Serialization; using Core.Models.Eft.Common.Tables; +using Core.Models.Enums; using Core.Models.Spt.Config; namespace Core.Models.Spt.Bots; @@ -10,13 +11,13 @@ public class GenerateEquipmentProperties /// Root Slot being generated /// [JsonPropertyName("rootEquipmentSlot")] - public string? RootEquipmentSlot { get; set; } + public EquipmentSlots RootEquipmentSlot { get; set; } /// /// Equipment pool for root slot being generated /// [JsonPropertyName("rootEquipmentPool")] - public Dictionary? RootEquipmentPool { get; set; } + public Dictionary? RootEquipmentPool { get; set; } [JsonPropertyName("modPool")] public GlobalMods? ModPool { get; set; } @@ -53,4 +54,4 @@ public class GenerateEquipmentProperties [JsonPropertyName("generatingPlayerLevel")] public int? GeneratingPlayerLevel { get; set; } -} \ No newline at end of file +} diff --git a/Core/Models/Spt/Config/BotConfig.cs b/Core/Models/Spt/Config/BotConfig.cs index 1ccf7089..b9c15c59 100644 --- a/Core/Models/Spt/Config/BotConfig.cs +++ b/Core/Models/Spt/Config/BotConfig.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text.Json.Serialization; using Core.Models.Common; using Core.Models.Eft.Common.Tables; +using Core.Models.Enums; namespace Core.Models.Spt.Config; @@ -479,7 +480,7 @@ public class EquipmentFilterDetails /// Key: equipment slot name e.g. FirstPrimaryWeapon, value: item tpls /// [JsonPropertyName("gear")] - public Dictionary>? Gear { get; set; } + public Dictionary>? Gear { get; set; } /// /// Key: cartridge type e.g. Caliber23x75, value: item tpls diff --git a/Core/Models/Spt/Config/PlayerScavConfig.cs b/Core/Models/Spt/Config/PlayerScavConfig.cs index 7df449a9..a31fe71e 100644 --- a/Core/Models/Spt/Config/PlayerScavConfig.cs +++ b/Core/Models/Spt/Config/PlayerScavConfig.cs @@ -1,5 +1,6 @@ using System.Text.Json.Serialization; using Core.Models.Eft.Common.Tables; +using Core.Models.Enums; namespace Core.Models.Spt.Config; @@ -24,7 +25,7 @@ public class KarmaLevel public Dictionary ItemLimits { get; set; } [JsonPropertyName("equipmentBlacklist")] - public Dictionary EquipmentBlacklist { get; set; } + public Dictionary EquipmentBlacklist { get; set; } [JsonPropertyName("labsAccessCardChancePercent")] public double? LabsAccessCardChancePercent { get; set; } diff --git a/Core/Services/BotEquipmentFilterService.cs b/Core/Services/BotEquipmentFilterService.cs index 0ed34870..260d01ab 100644 --- a/Core/Services/BotEquipmentFilterService.cs +++ b/Core/Services/BotEquipmentFilterService.cs @@ -1,13 +1,26 @@ using Core.Annotations; using Core.Models.Eft.Common.Tables; +using Core.Models.Enums; using Core.Models.Spt.Bots; using Core.Models.Spt.Config; +using Core.Servers; namespace Core.Services; [Injectable(InjectionType.Singleton)] public class BotEquipmentFilterService { + private readonly ConfigServer _configServer; + private readonly BotConfig _botConfig; + + public BotEquipmentFilterService( + ConfigServer configServer) + { + _configServer = configServer; + + _botConfig = _configServer.GetConfig(ConfigTypes.BOT); + } + /// /// Filter a bots data to exclude equipment and cartridges defines in the botConfig /// @@ -74,9 +87,12 @@ public class BotEquipmentFilterService /// Role of the bot we want the blacklist for /// Level of the player /// EquipmentBlacklistDetails object - public EquipmentFilterDetails GetBotEquipmentBlacklist(string botRole, double playerLevel) + public EquipmentFilterDetails? GetBotEquipmentBlacklist(string botRole, double playerLevel) { - throw new NotImplementedException(); + var blacklistDetailsForBot = _botConfig.Equipment.GetValueOrDefault(botRole, null); + + return blacklistDetailsForBot?.Blacklist?.FirstOrDefault( + (equipmentFilter) => playerLevel >= equipmentFilter.LevelRange.Min && playerLevel <= equipmentFilter.LevelRange.Max); } /// diff --git a/Core/Services/SeasonalEventService.cs b/Core/Services/SeasonalEventService.cs index 4a3a674b..e2353709 100644 --- a/Core/Services/SeasonalEventService.cs +++ b/Core/Services/SeasonalEventService.cs @@ -5,7 +5,6 @@ using Core.Models.Eft.Common.Tables; using Core.Models.Enums; using Core.Models.Spt.Config; using Core.Servers; -using Core.Utils; using ILogger = Core.Models.Utils.ILogger; namespace Core.Services; @@ -363,7 +362,7 @@ public class SeasonalEventService public void RemoveChristmasItemsFromBotInventory(BotTypeInventory botInventory, string botRole) { var christmasItems = GetChristmasEventItems(); - List equipmentSlotsToFilter = ["FaceCover", "Headwear", "Backpack", "TacticalVest"]; + List equipmentSlotsToFilter = [EquipmentSlots.FaceCover, EquipmentSlots.Headwear, EquipmentSlots.Backpack, EquipmentSlots.TacticalVest]; List lootContainersToFilter = ["Backpack", "Pockets", "TacticalVest"]; // Remove christmas related equipment