Fixed issues with ScavGenerator not processing as expected
This commit is contained in:
@@ -251,43 +251,44 @@ public class PlayerScavGenerator
|
||||
protected void AdjustBotTemplateWithKarmaSpecificSettings(KarmaLevel karmaSettings, BotType baseBotNode)
|
||||
{
|
||||
// Adjust equipment chance values
|
||||
foreach (var equipment in karmaSettings.Modifiers.Equipment)
|
||||
{
|
||||
if (equipment.Value == 0)
|
||||
continue;
|
||||
foreach (var equipmentKvP in karmaSettings.Modifiers.Equipment) {
|
||||
|
||||
var prop = typeof(EquipmentChances).GetProperties().FirstOrDefault(p => p.Name == equipment.Key);
|
||||
var value = (int)prop.GetValue(baseBotNode.BotChances.EquipmentChances);
|
||||
var newValue = (int)value + karmaSettings.Modifiers.Equipment[equipment.Key];
|
||||
prop.SetValue(baseBotNode.BotChances.EquipmentChances, newValue);
|
||||
// Adjustment value zero, nothing to do
|
||||
if (equipmentKvP.Value == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try add new key with value
|
||||
if (!baseBotNode.BotChances.EquipmentChances.TryAdd(equipmentKvP.Key, equipmentKvP.Value))
|
||||
{
|
||||
// Unable to add new, update existing
|
||||
baseBotNode.BotChances.EquipmentChances[equipmentKvP.Key] += equipmentKvP.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust mod chance values
|
||||
foreach (var mod in karmaSettings.Modifiers.Mod)
|
||||
foreach (var modKvP in karmaSettings.Modifiers.Mod)
|
||||
{
|
||||
if (mod.Value == 0)
|
||||
// Adjustment value zero, nothing to do
|
||||
if (modKvP.Value == 0)
|
||||
continue;
|
||||
|
||||
baseBotNode.BotChances.WeaponModsChances[mod.Key] += karmaSettings.Modifiers.Mod[mod.Key];
|
||||
baseBotNode.BotChances.WeaponModsChances[modKvP.Key] += karmaSettings.Modifiers.Mod[modKvP.Key];
|
||||
}
|
||||
|
||||
// Adjust item spawn quantity values
|
||||
var props = karmaSettings.ItemLimits.GetType().GetProperties();
|
||||
var botGenProps = baseBotNode.BotGeneration.Items.GetType().GetProperties();
|
||||
foreach (var prop in props)
|
||||
foreach (var itemLimitKvP in karmaSettings.ItemLimits)
|
||||
{
|
||||
botGenProps.FirstOrDefault(p => p.Name == prop.Name).SetValue(baseBotNode.BotGeneration.Items, prop.GetValue(karmaSettings.ItemLimits));
|
||||
baseBotNode.BotGeneration.Items[itemLimitKvP.Key] = itemLimitKvP.Value;
|
||||
}
|
||||
|
||||
// Blacklist equipment
|
||||
props = baseBotNode.BotInventory.Equipment.GetType().GetProperties();
|
||||
foreach (var equipment in karmaSettings.EquipmentBlacklist)
|
||||
{
|
||||
var blacklistedItemTpls = equipment.Value;
|
||||
foreach (var itemToRemove in blacklistedItemTpls)
|
||||
// Blacklist equipment, keyed by equipment slot
|
||||
foreach (var equipmentBlacklistKvP in karmaSettings.EquipmentBlacklist) {
|
||||
baseBotNode.BotInventory.Equipment.TryGetValue(equipmentBlacklistKvP.Key, out var equipmentDict);
|
||||
foreach (var itemToRemove in equipmentBlacklistKvP.Value)
|
||||
{
|
||||
var dict = (Dictionary<string, double>?)props.FirstOrDefault(p => p.Name == equipment.Key).GetValue(baseBotNode.BotInventory.Equipment);
|
||||
dict.Remove(itemToRemove);
|
||||
equipmentDict.Remove(itemToRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
using Core.Annotations;
|
||||
using Core.Annotations;
|
||||
using Core.Models.Common;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
using Core.Models.Spt.Config;
|
||||
using Core.Services;
|
||||
using ILogger = Core.Models.Utils.ILogger;
|
||||
|
||||
namespace Core.Helpers;
|
||||
|
||||
[Injectable]
|
||||
public class BotHelper
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly DatabaseService _databaseService;
|
||||
|
||||
public BotHelper(
|
||||
ILogger logger,
|
||||
DatabaseService databaseService)
|
||||
{
|
||||
_logger = logger;
|
||||
_databaseService = databaseService;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get a template object for the specified botRole from bots.types db
|
||||
/// </summary>
|
||||
@@ -15,7 +27,14 @@ public class BotHelper
|
||||
/// <returns>BotType object</returns>
|
||||
public BotType GetBotTemplate(string role)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (!_databaseService.GetBots().Types.TryGetValue(role.ToLower(), out var bot))
|
||||
{
|
||||
_logger.Error($"Unable to get bot of type: {role} from DB");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return bot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Common;
|
||||
using Core.Utils.Json.Converters;
|
||||
|
||||
@@ -61,7 +62,7 @@ public class Appearance
|
||||
public class Chances
|
||||
{
|
||||
[JsonPropertyName("equipment")]
|
||||
public EquipmentChances? EquipmentChances { get; set; }
|
||||
public Dictionary<string, double>? EquipmentChances { get; set; }
|
||||
|
||||
[JsonPropertyName("weaponMods")]
|
||||
public Dictionary<string, double>? WeaponModsChances { get; set; }
|
||||
@@ -73,50 +74,6 @@ public class Chances
|
||||
public Dictionary<string, double>? Mods { get; set; }
|
||||
}
|
||||
|
||||
public class EquipmentChances
|
||||
{
|
||||
[JsonPropertyName("ArmBand")]
|
||||
public int? ArmBand { get; set; }
|
||||
|
||||
[JsonPropertyName("ArmorVest")]
|
||||
public int? ArmorVest { get; set; }
|
||||
|
||||
[JsonPropertyName("Backpack")]
|
||||
public int? Backpack { get; set; }
|
||||
|
||||
[JsonPropertyName("Earpiece")]
|
||||
public int? Earpiece { get; set; }
|
||||
|
||||
[JsonPropertyName("Eyewear")]
|
||||
public int? Eyewear { get; set; }
|
||||
|
||||
[JsonPropertyName("FaceCover")]
|
||||
public int? FaceCover { get; set; }
|
||||
|
||||
[JsonPropertyName("FirstPrimaryWeapon")]
|
||||
public int? FirstPrimaryWeapon { get; set; }
|
||||
|
||||
[JsonPropertyName("Headwear")]
|
||||
public int? Headwear { get; set; }
|
||||
|
||||
[JsonPropertyName("Holster")]
|
||||
public int? Holster { get; set; }
|
||||
|
||||
[JsonPropertyName("Pockets")]
|
||||
public int? Pockets { get; set; }
|
||||
|
||||
[JsonPropertyName("Scabbard")]
|
||||
public int? Scabbard { get; set; }
|
||||
|
||||
[JsonPropertyName("SecondPrimaryWeapon")]
|
||||
public int? SecondPrimaryWeapon { get; set; }
|
||||
|
||||
[JsonPropertyName("SecuredContainer")]
|
||||
public int? SecuredContainer { get; set; }
|
||||
|
||||
[JsonPropertyName("TacticalVest")]
|
||||
public int? TacticalVest { get; set; }
|
||||
}
|
||||
/* class removed in favor of Dictionary<string, double>
|
||||
used to be used in:
|
||||
Chances.WeaponModsChances
|
||||
@@ -339,46 +296,7 @@ public class Experience
|
||||
public class Generation
|
||||
{
|
||||
[JsonPropertyName("items")]
|
||||
public GenerationWeightingItems? Items { get; set; }
|
||||
}
|
||||
|
||||
public class GenerationWeightingItems
|
||||
{
|
||||
[JsonPropertyName("grenades")]
|
||||
public GenerationData? Grenades { get; set; }
|
||||
|
||||
[JsonPropertyName("healing")]
|
||||
public GenerationData? Healing { get; set; }
|
||||
|
||||
[JsonPropertyName("drugs")]
|
||||
public GenerationData? Drugs { get; set; }
|
||||
|
||||
[JsonPropertyName("food")]
|
||||
public GenerationData? Food { get; set; }
|
||||
|
||||
[JsonPropertyName("drink")]
|
||||
public GenerationData? Drink { get; set; }
|
||||
|
||||
[JsonPropertyName("currency")]
|
||||
public GenerationData? Currency { get; set; }
|
||||
|
||||
[JsonPropertyName("stims")]
|
||||
public GenerationData? Stims { get; set; }
|
||||
|
||||
[JsonPropertyName("backpackLoot")]
|
||||
public GenerationData? BackpackLoot { get; set; }
|
||||
|
||||
[JsonPropertyName("pocketLoot")]
|
||||
public GenerationData? PocketLoot { get; set; }
|
||||
|
||||
[JsonPropertyName("vestLoot")]
|
||||
public GenerationData? VestLoot { get; set; }
|
||||
|
||||
[JsonPropertyName("magazines")]
|
||||
public GenerationData? Magazines { get; set; }
|
||||
|
||||
[JsonPropertyName("specialItems")]
|
||||
public GenerationData? SpecialItems { get; set; }
|
||||
public Dictionary<string, GenerationData>? Items { get; set; }
|
||||
}
|
||||
|
||||
public class GenerationData
|
||||
@@ -415,7 +333,7 @@ public class BodyPart
|
||||
public class BotTypeInventory
|
||||
{
|
||||
[JsonPropertyName("equipment")]
|
||||
public Equipment? Equipment { get; set; }
|
||||
public Dictionary<string, Dictionary<string, double>>? Equipment { get; set; }
|
||||
|
||||
public GlobalAmmo? Ammo { get; set; }
|
||||
|
||||
@@ -451,4 +369,4 @@ public class ItemPools
|
||||
public Dictionary<string, double>? SecuredContainer { get; set; }
|
||||
public Dictionary<string, double>? SpecialLoot { get; set; }
|
||||
public Dictionary<string, double>? TacticalVest { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
|
||||
namespace Core.Models.Spt.Config;
|
||||
@@ -21,7 +21,7 @@ public class KarmaLevel
|
||||
public Modifiers Modifiers { get; set; }
|
||||
|
||||
[JsonPropertyName("itemLimits")]
|
||||
public ItemLimits ItemLimits { get; set; }
|
||||
public Dictionary<string, GenerationData> ItemLimits { get; set; }
|
||||
|
||||
[JsonPropertyName("equipmentBlacklist")]
|
||||
public Dictionary<string, string[]> EquipmentBlacklist { get; set; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Core.Annotations;
|
||||
using Core.Annotations;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
using Core.Models.Spt.Bots;
|
||||
using Core.Models.Spt.Config;
|
||||
@@ -31,7 +31,7 @@ public class BotEquipmentFilterService
|
||||
/// <param name="baseValues">data to update</param>
|
||||
protected void AdjustChances(
|
||||
Dictionary<string, int> equipmentChanges,
|
||||
EquipmentChances baseValues)
|
||||
object baseValues)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user