Removed FilterBlacklistedGear, same functionality can be done via editing the equipment's weighting to 0

This commit is contained in:
Chomp
2025-07-14 17:57:32 +01:00
parent 4d1ef0d326
commit 0ec5aeab91
3 changed files with 10 additions and 70 deletions
@@ -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;
}
/// <summary>
/// Set weighting of flagged equipment to 0
/// </summary>
/// <param name="botJsonTemplate">Bot data to adjust</param>
/// <param name="botGenerationDetails">Generation details of bot</param>
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;
}
}
}
/// <summary>
/// Unheard PMCs need their pockets expanded
/// </summary>
@@ -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<string, HashSet<MongoId>>? Equipment { get; set; }
/// <summary>
/// Key: equipment slot name e.g. FirstPrimaryWeapon, value: item tpls
/// </summary>
[JsonPropertyName("gear")]
public Dictionary<EquipmentSlots, HashSet<MongoId>>? Gear { get; set; }
/// <summary>
/// Key: cartridge type e.g. Caliber23x75, value: item tpls
/// </summary>
@@ -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<string, double>)prop.GetValue(botDb.BotAppearance);
propValue[itemKey.Key] = weightAdjustments[itemKey.Key];