Reworked botgen to store bot loot in containers with weights, similar to ammo

Updated to .net 8
This commit is contained in:
Dev 2024-02-21 17:06:08 +00:00
parent c9c61a34cf
commit 926dcd2213
14 changed files with 366665 additions and 275274 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -225,6 +225,18 @@ namespace Common.Models.Input
public int LastAccess { get; set; } public int LastAccess { get; set; }
} }
public class Stats
{
public EftStats Eft { get; set; }
}
public class EftStats
{
public SessionCounters SessionCounters { get; set; }
public OverallCounters OverallCounters { get; set; }
}
public class SessionCounters public class SessionCounters
{ {
public List<object> Items { get; set; } public List<object> Items { get; set; }
@ -235,15 +247,9 @@ namespace Common.Models.Input
public List<object> Items { get; set; } public List<object> Items { get; set; }
} }
public class Stats public class TaskConditionCounters
{ {
public SessionCounters SessionCounters { get; set; } public object Counters { get; set; }
public OverallCounters OverallCounters { get; set; }
}
public class ConditionCounters
{
public List<object> Counters { get; set; }
} }
public class BackendCounters public class BackendCounters
@ -284,8 +290,7 @@ namespace Common.Models.Input
public Skills Skills { get; set; } public Skills Skills { get; set; }
public Stats Stats { get; set; } public Stats Stats { get; set; }
public object Encyclopedia { get; set; } public object Encyclopedia { get; set; }
public ConditionCounters ConditionCounters { get; set; } public TaskConditionCounters TaskConditionCounters { get; set; }
public BackendCounters BackendCounters { get; set; }
public List<object> InsuredItems { get; set; } public List<object> InsuredItems { get; set; }
public Hideout Hideout { get; set; } public Hideout Hideout { get; set; }
public IEnumerable<object> Bonuses { get; set; } public IEnumerable<object> Bonuses { get; set; }

View File

@ -59,17 +59,17 @@ namespace Common.Models.Output
{ {
public Items() public Items()
{ {
TacticalVest = new List<string>(); TacticalVest = new Dictionary<string, int>();
Pockets = new List<string>(); Pockets = new Dictionary<string, int>();
Backpack = new List<string>(); Backpack = new Dictionary<string, int>();
SecuredContainer = new List<string>(); SecuredContainer = new Dictionary<string, int>();
SpecialLoot = new List<string>(); SpecialLoot = new Dictionary<string, int>();
} }
public List<string> TacticalVest { get; set; } public Dictionary<string, int> TacticalVest { get; set; }
public List<string> Pockets { get; set; } public Dictionary<string, int> Pockets { get; set; }
public List<string> Backpack { get; set; } public Dictionary<string, int> Backpack { get; set; }
public List<string> SecuredContainer { get; set; } public new Dictionary<string, int> SecuredContainer { get; set; }
public List<string> SpecialLoot { get; set; } public new Dictionary<string, int> SpecialLoot { get; set; }
} }
} }

View File

@ -49,16 +49,16 @@ public class Appearance
{ {
body = new Dictionary<string, int>(); body = new Dictionary<string, int>();
feet = new Dictionary<string, int>(); feet = new Dictionary<string, int>();
hands = new List<string>(); hands = new Dictionary<string, int>();
head = new List<string>(); head = new Dictionary<string, int>();
voice = new List<string>(); voice = new Dictionary<string, int>();
} }
public Dictionary<string, int> body { get; set; } public Dictionary<string, int> body { get; set; }
public Dictionary<string, int> feet { get; set; } public Dictionary<string, int> feet { get; set; }
public List<string> hands { get; set; } public Dictionary<string, int> hands { get; set; }
public List<string> head { get; set; } public Dictionary<string, int> head { get; set; }
public List<string> voice { get; set; } public Dictionary<string, int> voice { get; set; }
} }
public class Experience public class Experience

File diff suppressed because it is too large Load Diff

View File

@ -23,12 +23,12 @@ public static class BotParser
var botFiles = Directory.GetFiles(dumpPath, "*.json", SearchOption.TopDirectoryOnly).ToList(); var botFiles = Directory.GetFiles(dumpPath, "*.json", SearchOption.TopDirectoryOnly).ToList();
LoggingHelpers.LogToConsole($"{botFiles.Count} bot dump files found"); LoggingHelpers.LogToConsole($"{botFiles.Count} bot dump files found");
var parsedBotsDict = new HashSet<Datum>(); var parsedBotsDict = new Dictionary<string, Datum>();
var dictionaryLock = new object(); var dictionaryLock = new object();
int totalDupeCount = 0; int totalDupeCount = 0;
var tasks = new List<Task>(50); var tasks = new List<Task>(45);
foreach (var file in botFiles) foreach (var file in botFiles)
{ {
tasks.Add(Task.Factory.StartNew(() => tasks.Add(Task.Factory.StartNew(() =>
@ -72,26 +72,23 @@ public static class BotParser
lock (dictionaryLock) lock (dictionaryLock)
{ {
// Bot already exists in dictionary, skip
if (parsedBotsDict.Contains(bot))
{
//var existingBot = parsedBotsDict[bot._id];
dupeCount++;
continue;
}
if (!parsedBotsDict.Contains(bot))
{
// Null out data we don't need for generating bots to save RAM
bot.Stats = null; bot.Stats = null;
bot.Encyclopedia = null; bot.Encyclopedia = null;
bot.Hideout = null; bot.Hideout = null;
bot.ConditionCounters = null; bot.TaskConditionCounters = null;
bot.Bonuses = null; bot.Bonuses = null;
bot.BackendCounters = null;
bot.InsuredItems = null; bot.InsuredItems = null;
parsedBotsDict.Add(bot);
// Bot already exists in dictionary, skip
if (parsedBotsDict.TryAdd(bot._id, bot))
{
// Success - Null out data we don't need for generating bots to save RAM
}
else
{
//var existingBot = parsedBotsDict.FirstOrDefault(x => x._id == bot._id);
dupeCount++;
continue;
} }
} }
} }
@ -105,7 +102,7 @@ public static class BotParser
LoggingHelpers.LogToConsole($"Cleaned and Parsed: {parsedBotsDict.Count} bots. {totalDupeCount} dupes were ignored. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds"); LoggingHelpers.LogToConsole($"Cleaned and Parsed: {parsedBotsDict.Count} bots. {totalDupeCount} dupes were ignored. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
return parsedBotsDict.ToList(); return [.. parsedBotsDict.Values];
} }
private static string PruneMalformedBsgJson(string json, string fileName) private static string PruneMalformedBsgJson(string json, string fileName)

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1469,7 +1469,17 @@
"5c0696830db834001d23f5da", "5c0696830db834001d23f5da",
"5eeb2ff5ea4f8b73c827350b", "5eeb2ff5ea4f8b73c827350b",
"5d4406a8a4b9361e4f6eb8b7", "5d4406a8a4b9361e4f6eb8b7",
"5c6beec32e221601da3578f2" "5c6beec32e221601da3578f2",
"616554fe50224f204c1da2aa",
"5a34fbadc4a28200741e230a",
"5b30ac585acfc433000eb79c",
"5cf67cadd7f00c065a5abab7",
"5fb653962b1b027b1f50bd03",
"59e0bed186f774156f04ce84",
"5ba2657ed4351e0035628ff2",
"65169d5b30425317755f8e25",
"57cffce524597763b31685d8",
"65293c38fc460e50a509cb25"
], ],
"Pockets": [ "Pockets": [
"57347d5f245977448b40fa81", "57347d5f245977448b40fa81",
@ -6132,6 +6142,399 @@
"5ed515e03a40a50460332579", "5ed515e03a40a50460332579",
"637b6251104668754b72f8f9", "637b6251104668754b72f8f9",
"5ed5166ad380ab312177c100" "5ed5166ad380ab312177c100"
]
},
"gifter": {
"Backpack": [
"544fb6cc4bdc2d34748b456e",
"628a66b41d5e41750e314f34",
"5751496424597720a27126da",
"57513f07245977207e26a311",
"5df8a72c86f77412640e2e83",
"57347d692459774491567cf1",
"57513f9324597720a7128161",
"57347da92459774491567cf5",
"61962b617c6c7b169525f168",
"59e3577886f774176a362503",
"575146b724597720a27126d5",
"590c621186f774138d11ea29",
"57347d3d245977448f7b7f61",
"5751435d24597720a27126d1",
"5a0ee30786f774023b6ee08f",
"57347d5f245977448b40fa81",
"615d8e9867085e45ef1409c6",
"57c55f112459772d28133310",
"62987da96188c076bc0d8c51",
"5673de654bdc2d180f8b456d",
"5780cda02459777b272ede61",
"590c5f0d86f77413997acfab",
"5df8a6a186f77412640e2e80",
"5df8a77486f77412672a1e3f",
"57505f6224597709a92585a9",
"5a38ebd9c4a282000d722a5b",
"5d6e68b3a4b9361bca7e50b5",
"590c5d4b86f774784e1b9c45",
"60b0f93284c20f0feb453da7",
"5ed515e03a40a50460332579",
"5448fee04bdc2dbc018b4567",
"57514643245977207f2c2d09",
"56dff338d2720bbd668b4569",
"5d6e6a42a4b9364f07165f52",
"5751487e245977207e26a315",
"5c471c2d2e22164bef5d077f",
"618168dc8004cc50514c34fc",
"5900b89686f7744e704a8747",
"57347d90245977448f7b7f65",
"5c0695860db834001b735461",
"5f0c892565703e5c461894e9",
"5a26ac06c4a282000c5a90a8",
"5d6e6a5fa4b93614ec501745",
"59e77a2386f7742ee578960a",
"60098b1705871270cd5352a1",
"5d6e69b9a4b9361bc8618958",
"5649be884bdc2d79388b4577",
"5448ff904bdc2d6f028b456e",
"57a349b2245977762b199ec7",
"5734773724597737fd047c14",
"5c0e533786f7747fa23f4d47",
"5a145d7b86f7744cbb6f4a13",
"62389bc9423ed1685422dc57",
"5ba2678ad4351e44f824b344",
"5fc275cf85fd526b824a571a",
"59e4d24686f7741776641ac7",
"5913877a86f774432f15d444",
"544fb62a4bdc2dfb738b4568",
"5751a25924597722c463c472",
"544fb25a4bdc2dfb738b4567",
"5c0d5e4486f77478390952fe",
"57347d8724597744596b4e76",
"5f0596629e22f464da6bbdd9",
"5cc80f79e4a949033c7343b2",
"591afe0186f77431bd616a11",
"5d40407c86f774318526545a",
"5c503af12e221602b177ca02",
"5bb20e70d4351e0035629f8f",
"57347d9c245977448b40fa85",
"57513fcc24597720a31c09a6",
"5755356824597772cb798962",
"57371e4124597760ff7b25f1",
"5656d7c34bdc2d9d198b4587",
"59e6920f86f77411d82aa167",
"5d6e695fa4b936359b35d852",
"573718ba2459775a75491131",
"56dff4ecd2720b5f5a8b4568",
"57347d7224597744596b4e72",
"5b057b4f5acfc4771e1bd3e9",
"5ed515f6915ec335206e4152",
"573601b42459776410737435",
"5bc9c29cd4351e003562b8a3",
"5b2cfa535acfc432ff4db7a0",
"5947fa2486f77425b47c1a9b",
"57a0dfb82459774d3078b56c",
"5783c43d2459774bbe137486",
"635a758bfefc88a93f021b8a",
"5efb0d4f4bc50b58e81710f3",
"5efb0fc6aeb21837e749c801",
"558032614bdc2de7118b4585",
"5de6558e9f98ac2bc65950fc",
"6183fd9e8004cc50514c358f",
"544fb3364bdc2d34748b456a",
"59136a4486f774447a1ed172",
"59e6906286f7746c9f75e847",
"5cf508bfd7f00c056e24104e",
"5efb0e16aeb21837e749c7ff",
"5735ff5c245977640e39ba7e",
"5b7be1ca5acfc400170e2d2f",
"57616a9e2459773c7a400234",
"607d5a891246154cad35d6aa",
"588226dd24597767ad33f789",
"56dff061d2720bb5668b4567",
"6065880c132d4d12c81fd8da",
"603372f153a60014f970616d",
"5d403f9186f7743cac3f229b",
"575062b524597720a31c09a1",
"60098ad7c2240c0fe85c570a",
"5d6e6a53a4b9361bd473feec",
"5c78f26f2e221601da3581d1",
"5a38ef1fc4a282000b1521f6",
"5c0505e00db834001b735073",
"5d1c774f86f7746d6620f8db",
"573475fb24597737fb1379e1",
"590c346786f77423e50ed342",
"5cc70146e4a949000d73bf6b",
"62a09f32621468534a797acb",
"5b363dea5acfc4771e1c5e7e",
"5a0ee37f86f774023657a86f",
"5bc9b156d4351e00367fbce9",
"5cc80f67e4a949035e43bbba",
"5737207f24597760ff7b25f2",
"5a788169c5856700142fdd9e",
"5ede474b0c226a66f5402622",
"5cadf6eeae921500134b2799",
"60098af40accd37ef2175f27",
"5d6e69c7a4b9360b6c0d54e4",
"5a3c16fe86f77452b62de32a",
"62330bfadc5883093563729b",
"57372140245977611f70ee91",
"56dfef82d2720bbd668b4567",
"5bb20de5d4351e0035629e59",
"61816fcad92c473c770215cc",
"5d02797c86f774203f38e30a",
"5fc382a9d724d907e2077dab",
"5c10c8fd86f7743d7d706df3",
"5c0d56a986f774449d5de529",
"5c0fa877d174af02a012e1cf",
"5d02778e86f774203e7dedbe",
"5c010a700db834001d23ef5d",
"5a0eed4386f77405112912aa",
"590c661e86f7741e566b646a",
"56dff2ced2720bb4668b4567",
"5c3df7d588a4501f290594e5",
"5e85a9f4add9fe03027d9bf1",
"63a39f6e64283b5e9c56b289",
"5c7d55de2e221644f31bff68",
"5e8488fa988a8701445df1e4",
"5737218f245977612125ba51",
"5d25a7b88abbc3054f3e60bc",
"6272874a6c47bd74f92e2087",
"57d152ec245977144076ccdf",
"544fb37f4bdc2dee738b4567",
"573719df2459775a626ccbc2",
"5448c1d04bdc2dff2f8b4569",
"590c657e86f77412b013051d",
"5e8f3423fd7471236e6e3b64",
"637b620db7afa97bfc3d7009",
"5ba26835d4351e0035628ff5",
"5a26ac0ec4a28200741e1e18",
"593d493f86f7745e6b2ceb22",
"5a34fae7c4a2826c6e06d760",
"5b7d645e5acfc400170e2f90",
"5d6e689ca4b9361bc8618956",
"56dff3afd2720bba668b4567",
"56dff421d2720b5f5a8b4567",
"56dff026d2720bb8668b4567",
"59e6658b86f77411d949b250",
"5f647f31b6238e5dd066e196",
"59387a4986f77401cc236e62",
"5e831507ea0a7c419c2f9bd9",
"5efb0cabfb3e451d70735af5",
"59e5f5a486f7746c530b3ce2",
"59e898ee86f77427614bd225",
"5672cb304bdc2dc2088b456a",
"5c0e530286f7747fa1419862",
"5c06779c86f77426e00dd782",
"622f14e899892a7f9e08f6c5",
"56dff216d2720bbd668b4568",
"63a39df18a56922e82001f25",
"5672cb124bdc2d1a0f8b4568",
"590a386e86f77429692b27ab",
"59e3658a86f7741776641ac4",
"5d1b309586f77425227d1676",
"615d8da4d3a39d50044c10e8",
"5cadf6ddae9215051e1c23b2",
"5d6e6a05a4b93618084f58d0",
"5c0d5ae286f7741e46554302",
"5af0454c86f7746bf20992e8",
"6130c4d51cb55961fa0fd49f",
"55d45d3f4bdc2d972f8b456c",
"5cc86840d7f00c002412c56c",
"5e023e6e34d52a55c3304f71",
"591383f186f7744a4c5edcf3",
"5894a2c386f77427140b8342",
"5887431f2459777e1612938f",
"637b6251104668754b72f8f9",
"59d64fc686f774171b243fe2",
"5d235b4d86f7742e017bc88a",
"5780cf942459777df90dcb72",
"56dff0bed2720bb0668b4567",
"5af0548586f7743a532b7e99",
"590c695186f7741e566b64a2",
"62a09ec84f842e1bd12da3f2",
"5d6e68e6a4b9361c140bcfe0",
"63888bbd28e5cc32cc09d2b6",
"5cc80f38e4a949001152b560",
"5a27b3d0c4a282000d721ec1",
"58dd3ad986f77403051cba8f",
"62a0a043cf4a99369e2624a5",
"5d6e68dea4b9361bcc29e659",
"5c78f2882e22165df16b832e",
"5addc7db5acfc4001669f279",
"544fb3f34bdc2d03748b456a",
"5c0e534186f7747fa1419867",
"5656eb674bdc2d35148b457c",
"544fb45d4bdc2dee738b4568",
"5926f34786f77469195bfe92",
"57838f0b2459774a256959b2",
"5755383e24597772cb798966",
"58949edd86f77409483e16a9",
"5caf1109ae9215753c44119f",
"5cf656f2d7f00c06585fb6eb",
"5c1f79a086f7746ed066fb8f",
"5780d07a2459777de4559324",
"59e6918f86f7746c9f75e849",
"5938994586f774523a425196",
"637b6179104668754b72f8f5",
"59e4cf5286f7741778269d8a",
"5cc80f53e4a949000e1ea4f8",
"59e6927d86f77411da468256",
"5ede475b549eed7c6d5c18fb",
"5d6e68c4a4b9361b93413f79",
"5a269f97c4a282000b151807",
"5a80a29286f7742b25692012",
"59e68f6f86f7746c9f75e846",
"5ba26812d4351e003201fef1",
"59e690b686f7746c9f75e848",
"56dff4a2d2720bbd668b456a",
"54527a984bdc2d4e668b4567",
"5d1b376e86f774252519444e",
"61f8024263dc1250e26eb029",
"590c678286f77426c9660122",
"5de655be4a9f347bc92edb88",
"6194f3286db0f2477964e67d",
"5cc7012ae4a949001252b43e",
"5b1fb3e15acfc4001637f068",
"61702f1b67085e45ef140b26",
"5de8fbad2fbe23140d3ee9c4",
"59136e1e86f774432f15d133",
"56d59d3ad2720bdb418b4577",
"590a3b0486f7743954552bdb",
"5e023e53d4353e3302577c4c",
"5d6e6911a4b9361bd5780d52",
"637b60c3b7afa97bfc3d7001",
"5ae35b315acfc4001714e8b0",
"61825d06d92c473c770215de",
"62987cb98081af308d7558c8",
"6388c4478d895f557a0c6512",
"55d4ae6c4bdc2d8b2f8b456e",
"5e208b9842457a4a7a33d074",
"5a37cb10c4a282329a73b4e7",
"5cadc431ae921500113bb8d5",
"5ed51652f6c34d2cc26336a1",
"59e4d3d286f774176a36250a",
"573476d324597737da2adc13",
"5c06782b86f77426df5407d2",
"62a0a0bb621468534a797ad5",
"56742c284bdc2d98058b456d",
"57347c77245977448d35f6e2",
"5fbb978207e8a97d1f0902d3",
"590c5a7286f7747884343aea",
"5d1b39a386f774252339976f",
"59ccfdba86f7747f2109a587",
"5c0e531286f7747fa54205c2",
"61a6444b8c141d68246e2d2f",
"5938603e86f77435642354f4",
"59e655cb86f77411dc52a77b",
"5ac66bea5acfc43b321d4aec",
"5a8036fb86f77407252ddc02",
"5ed5160a87bb8443d10680b5",
"5a26abfac4a28232980eabff",
"5ac7655e5acfc40016339a19",
"5c07c5ed0db834001b73571c",
"5c7e8fab2e22165df16b889b",
"59e0d99486f7744a32234762",
"5fc3e4ee7283c4046c5814af",
"5c503d0a2e221602b542b7ef",
"57dbb57e2459774673234890",
"5cc86832d7f00c000d3a6e6c",
"62307b7b10d2321fa8741921",
"59985a8086f77414ec448d1a",
"5cc80f8fe4a949033b0224a2",
"5e85a9a6eacf8c039e4e2ac1",
"63a39cb1c9b3aa4b61683ee2",
"5938504186f7740991483f30",
"5913915886f774123603c392",
"62987dfc402c7f69bf010923",
"5d03794386f77420415576f5",
"5d1b3a5d86f774252167ba22",
"560d5e524bdc2d25448b4571",
"57a0e5022459774d1673f889",
"5ea2a8e200685063ec28c05a",
"590c5c9f86f77477c91c36e7",
"5e85aa1a988a8701445df1f5",
"5c0d688c86f77413ae3407b2",
"5a13ef7e86f7741290491063",
"578395e82459774a0e553c7b",
"5bfd4cd60db834001c38f095",
"57371aab2459775a77142f22",
"62330b3ed4dc74626d570b95",
"591ae8f986f77406f854be45",
"5c925fa22e221601da359b7b",
"5cadc2e0ae9215051e1c21e7",
"5c0faf68d174af02a96260b8",
"5c0e531d86f7747fa23f4d42",
"5c0548ae0db834001966a3c2",
"62811f461d5df4475f46a332",
"58d268fc86f774111273f8c2",
"59f99a7d86f7745b134aa97b",
"63a39667c9b3aa4b61683e98",
"5a0f075686f7745bcc42ee12",
"5913611c86f77479e0084092",
"5c1bc5612e221602b5429350",
"622f0ee47762f55aaa68ac87",
"573477e124597737dd42e191",
"5b3b99265acfc4704b4a1afb",
"61695095d92c473c7702147a"
],
"Pockets": [
"5a38ee51c4a282000c5a955c",
"5448c12b4bdc2d02308b456f",
"5aaa5e60e5b5b000140293d6",
"576a5ed62459771e9c2096cb",
"560d5e524bdc2d25448b4571",
"5a17fb03fcdbcbcae668728f",
"5656d7c34bdc2d9d198b4587",
"56d59948d2720bb7418b4582",
"57d14e1724597714010c3f4b",
"55d4837c4bdc2d1d4e8b456c",
"571a29dc2459771fb2755a6a",
"5449016a4bdc2d6f028b456f",
"5c503ad32e2216398b5aada2",
"5df8a6a186f77412640e2e80",
"5755383e24597772cb798966",
"5d6e6911a4b9361bd5780d52",
"5c0e533786f7747fa23f4d47",
"59e5d83b86f7745aed03d262",
"5ed515c8d380ab312177c0fa",
"5448be9a4bdc2dfd2f8b456a",
"5751a25924597722c463c472",
"5783c43d2459774bbe137486",
"5ed51652f6c34d2cc26336a1",
"5d6e68dea4b9361bcc29e659",
"60098af40accd37ef2175f27",
"5c0e531d86f7747fa23f4d42",
"57347d3d245977448f7b7f61",
"637b612fb7afa97bfc3d7005",
"544fb3f34bdc2d03748b456a",
"5df8a72c86f77412640e2e83",
"5df8a77486f77412672a1e3f",
"57505f6224597709a92585a9",
"57347d692459774491567cf1",
"5755356824597772cb798962",
"5ed515ece452db0eb56fc028",
"5751496424597720a27126da",
"5a38ed75c4a28232996e40c6",
"5d6e6806a4b936088465b17e",
"57347da92459774491567cf5",
"544fb25a4bdc2dfb738b4567",
"5751487e245977207e26a315",
"59e3577886f774176a362503",
"544fb37f4bdc2dee738b4567",
"544fb6cc4bdc2d34748b456e",
"590c695186f7741e566b64a2",
"57514643245977207f2c2d09",
"57347d8724597744596b4e76",
"544fb3364bdc2d34748b456a",
"5bc9c29cd4351e003562b8a3",
"575062b524597720a31c09a1",
"57347d9c245977448b40fa85",
"5673de654bdc2d180f8b456d",
"5e831507ea0a7c419c2f9bd9",
"5af0548586f7743a532b7e99",
"5af0454c86f7746bf20992e8",
"5e8488fa988a8701445df1e4",
"5448ff904bdc2d6f028b456e",
"5ed515e03a40a50460332579",
"60098b1705871270cd5352a1"
] ]
} }
} }

View File

@ -107,7 +107,8 @@ namespace Generator
private static void AddVoice(Bot bot, Datum rawBot) private static void AddVoice(Bot bot, Datum rawBot)
{ {
bot.appearance.voice.AddUnique(rawBot.Info.Voice); GearHelpers.IncrementDictionaryValue(bot.appearance.voice, rawBot.Info.Voice);
GearHelpers.ReduceWeightValues(bot.appearance.voice);
} }
private static void AddDifficulties(Bot bot, string workingPath) private static void AddDifficulties(Bot bot, string workingPath)
@ -156,14 +157,16 @@ namespace Generator
private static void AddVisualAppearanceItems(Bot botToUpdate, Datum rawBot) private static void AddVisualAppearanceItems(Bot botToUpdate, Datum rawBot)
{ {
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.feet, rawBot.Customization.Feet); GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.feet, rawBot.Customization.Feet);
//botToUpdate.appearance.feet.AddUnique(rawBot.Customization.Feet, 1);
GearHelpers.ReduceWeightValues(botToUpdate.appearance.feet); GearHelpers.ReduceWeightValues(botToUpdate.appearance.feet);
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.body, rawBot.Customization.Body); GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.body, rawBot.Customization.Body);
GearHelpers.ReduceWeightValues(botToUpdate.appearance.body); GearHelpers.ReduceWeightValues(botToUpdate.appearance.body);
botToUpdate.appearance.head.AddUnique(rawBot.Customization.Head); GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.head, rawBot.Customization.Head);
botToUpdate.appearance.hands.AddUnique(rawBot.Customization.Hands); GearHelpers.ReduceWeightValues(botToUpdate.appearance.head);
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.hands, rawBot.Customization.Hands);
GearHelpers.ReduceWeightValues(botToUpdate.appearance.hands);
} }
private static void AddName(Bot botToUpdate, Datum rawBot) private static void AddName(Bot botToUpdate, Datum rawBot)

View File

@ -38,6 +38,10 @@ namespace Generator
} }
AddLootToContainers(botType, botToUpdate, rawBotsOfSameType); AddLootToContainers(botType, botToUpdate, rawBotsOfSameType);
GearHelpers.ReduceWeightValues(botToUpdate.inventory.equipment.Backpack);
GearHelpers.ReduceWeightValues(botToUpdate.inventory.equipment.Pockets);
GearHelpers.ReduceWeightValues(botToUpdate.inventory.equipment.TacticalVest);
GearHelpers.ReduceWeightValues(botToUpdate.inventory.equipment.SecuredContainer);
//foreach (var rawParsedBot in rawBotsOfSameType) //foreach (var rawParsedBot in rawBotsOfSameType)
//{ //{
@ -61,123 +65,86 @@ namespace Generator
private static void AddLootToContainers(string botType, Bot botToUpdate, List<Datum> rawBotsOfSameType) private static void AddLootToContainers(string botType, Bot botToUpdate, List<Datum> rawBotsOfSameType)
{ {
var containerDict = new Dictionary<string, List<string>>(); // Process each bot
foreach (var bot in rawBotsOfSameType) foreach (var rawBot in rawBotsOfSameType)
{ {
var backpack = bot.Inventory.items.FirstOrDefault(x => x.slotId == "Backpack"); // Filter out base inventory items and equipment mod items
if (backpack != null) var rawBotItems = rawBot.Inventory.items.Where(x => x.parentId != null || x.location != null).ToList();
var botBackpack = rawBotItems.FirstOrDefault(item => item.slotId == "Backpack");
if (botBackpack != null)
{ {
containerDict.Add(backpack._id, new List<string>()); AddLootItemsToContainerDictionary(rawBotItems, botBackpack._id, botToUpdate.inventory.items.Backpack);
}
var pocket = bot.Inventory.items.FirstOrDefault(x => x.slotId == "Pockets");
if (pocket != null)
{
containerDict.Add(pocket._id, new List<string>());
}
var secure = bot.Inventory.items.FirstOrDefault(x => x.slotId == "SecuredContainer");
if (secure != null)
{
containerDict.Add(secure._id, new List<string>());
} }
var tacVest = bot.Inventory.items.FirstOrDefault(x => x.slotId == "TacticalVest"); var botPockets = rawBotItems.FirstOrDefault(item => item.slotId == "Pockets");
if (tacVest != null) if (botPockets != null)
{ {
containerDict.Add(tacVest._id, new List<string>()); AddLootItemsToContainerDictionary(rawBotItems, botPockets._id, botToUpdate.inventory.items.Pockets);
} }
foreach (var item in bot.Inventory.items) var botVest = rawBotItems.FirstOrDefault(item => item.slotId == "TacticalVest");
if (botVest != null)
{ {
// Filter out root items and equipment mod items AddLootItemsToContainerDictionary(rawBotItems, botVest._id, botToUpdate.inventory.items.TacticalVest);
if (item.parentId == null || item.location == null)
{
continue;
} }
// Container (backpack etc) exists in dict var botSecure = rawBotItems.FirstOrDefault(item => item.slotId == "SecuredContainer");
if (containerDict.ContainsKey(item.parentId)) if (botSecure != null)
{ {
containerDict[item.parentId].AddUnique(item._tpl); AddLootItemsToContainerDictionary(rawBotItems, botSecure._id, botToUpdate.inventory.items.SecuredContainer);
}
}
var forcedLoot = ForcedLootHelper.GetForcedLoot();
forcedLoot.TryGetValue(botType, out var lootToAdd);
if (backpack != null)
{
if (lootToAdd?.Backpack != null)
{
botToUpdate.inventory.items.Backpack.AddUniqueRange(lootToAdd.Backpack);
}
botToUpdate.inventory.items.Backpack.AddUniqueRange(containerDict[backpack._id]);
}
if (pocket != null)
{
if (lootToAdd?.Pockets != null)
{
botToUpdate.inventory.items.Pockets.AddUniqueRange(lootToAdd.Pockets);
}
botToUpdate.inventory.items.Pockets.AddUniqueRange(containerDict[pocket._id]);
}
if (secure != null)
{
botToUpdate.inventory.items.SecuredContainer.AddUniqueRange(containerDict[secure._id]);
}
if (tacVest != null)
{
if (lootToAdd?.TacticalVest != null)
{
botToUpdate.inventory.items.TacticalVest.AddUniqueRange(lootToAdd.TacticalVest);
}
botToUpdate.inventory.items.TacticalVest.AddUniqueRange(containerDict[tacVest._id]);
}
containerDict.Clear();
} }
// Add generic keys to bosses // Add generic keys to bosses
if (botToUpdate.botType.IsBoss()) if (botToUpdate.botType.IsBoss())
{ {
var keys = SpecialLootHelper.GetGenericBossKeys().ToList(); var keys = SpecialLootHelper.GetGenericBossKeysDictionary();
botToUpdate.inventory.items.Backpack.AddUniqueRange(keys); foreach (var bosskey in keys)
{
if (!botToUpdate.inventory.items.Backpack.ContainsKey(bosskey.Key))
{
botToUpdate.inventory.items.Backpack.Add(bosskey.Key, bosskey.Value);
}
}
} }
AddSpecialLoot(botToUpdate); AddSpecialLoot(botToUpdate);
} }
}
/// <summary>
/// Look for items inside itemsToFilter that have the parentid of `containerId` and add them to dictToAddTo
/// Keep track of how many items are added in the dictToAddTo value
/// </summary>
/// <param name="itemsToFilter">Bots inventory items</param>
/// <param name="containerId"></param>
/// <param name="dictToAddTo"></param>
private static void AddLootItemsToContainerDictionary(List<Item> itemsToFilter, string containerId, Dictionary<string, int> dictToAddTo)
{
var backpackLootItems = itemsToFilter.Where(item => item.parentId == containerId);
foreach (var backpackItem in backpackLootItems)
{
if (!dictToAddTo.ContainsKey(backpackItem._tpl))
{
dictToAddTo[backpackItem._tpl] = 1;
return;
}
dictToAddTo[backpackItem._tpl]++;
}
}
private static void AddSpecialLoot(Bot botToUpdate) private static void AddSpecialLoot(Bot botToUpdate)
{ {
botToUpdate.inventory.items.SpecialLoot.AddRange(SpecialLootHelper.GetSpecialLootForBotType(botToUpdate.botType)); var itemsToAdd = SpecialLootHelper.GetSpecialLootForBotType(botToUpdate.botType);
} foreach (var item in itemsToAdd)
private static IEnumerable<string> GetItemsStoredInEquipmentItem(IEnumerable<Datum> rawBots, string containerName)
{ {
var itemsStoredInContainer = new List<string>(); if (!botToUpdate.inventory.items.SpecialLoot.ContainsKey(item.Key))
var containers = new List<string>();
foreach (var bot in rawBots)
{ {
// find the container type we want on this bot (backpack etc) botToUpdate.inventory.items.SpecialLoot.Add(item.Key, item.Value);
// Add to list
var botContainers = bot.Inventory.items.Where(x => x.slotId == containerName);
foreach (var container in botContainers)
{
containers.AddUnique(container._id);
}
foreach (var item in bot.Inventory.items)
{
if (containers.Contains(item.parentId))
{
itemsStoredInContainer.AddUnique(item._tpl);
} }
} }
} }
return itemsStoredInContainer;
}
} }
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>true</ServerGarbageCollection> <ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection> <ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
@ -158,6 +158,9 @@
</Content> </Content>
<Content Include="Assets\normal_test_BotGlobalSettings.txt"> <Content Include="Assets\normal_test_BotGlobalSettings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Assets\forcedLoot.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Assets\weights.json"> <Content Include="Assets\weights.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@ -19,7 +19,10 @@ namespace Generator.Helpers
foreach (var path in pathsWithBotType) foreach (var path in pathsWithBotType)
{ {
var difficultyJson = File.ReadAllText(path); var difficultyJson = File.ReadAllText(path);
var serialisedDifficultySettings = JsonConvert.DeserializeObject<DifficultySettings>(difficultyJson); var serialisedDifficultySettings = JsonConvert.DeserializeObject<DifficultySettings>(difficultyJson, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Ignore
});
serialisedDifficultySettings = ApplyCustomDifficultyValues(botType, serialisedDifficultySettings); serialisedDifficultySettings = ApplyCustomDifficultyValues(botType, serialisedDifficultySettings);

View File

@ -1,5 +1,6 @@
using Common.Models; using Common.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Generator.Helpers.Gear namespace Generator.Helpers.Gear
{ {
@ -63,9 +64,14 @@ namespace Generator.Helpers.Gear
return _genericBossKeys; return _genericBossKeys;
} }
public static IEnumerable<string> GetSpecialLootForBotType(BotType botType) public static Dictionary<string, int> GetGenericBossKeysDictionary()
{ {
var results = new List<string>(); return _genericBossKeys.ToDictionary(x => x, y => 1);
}
public static Dictionary<string, int> GetSpecialLootForBotType(BotType botType)
{
var results = new Dictionary<string, int>();
switch (botType) switch (botType)
{ {
case BotType.assault: case BotType.assault:
@ -81,11 +87,11 @@ namespace Generator.Helpers.Gear
case BotType.bosskilla: case BotType.bosskilla:
break; break;
case BotType.bosskojaniy: case BotType.bosskojaniy:
results.Add("5d08d21286f774736e7c94c3"); // Shturman's stash key results.Add("5d08d21286f774736e7c94c3", 1); // Shturman's stash key
results.Add("5c94bbff86f7747ee735c08f"); // labs keycard results.Add("5c94bbff86f7747ee735c08f", 1); // labs keycard
break; break;
case BotType.bosssanitar: case BotType.bosssanitar:
results.Add("5efde6b4f5448336730dbd61"); // Keycard with a blue marking results.Add("5efde6b4f5448336730dbd61", 1); // Keycard with a blue marking
break; break;
case BotType.bossstormtrooper: case BotType.bossstormtrooper:
break; break;

View File

@ -43,6 +43,8 @@ internal static class Program
"followerkolontayassault", "followerkolontayassault",
"followerkolontaysecurity", "followerkolontaysecurity",
"ravangezryachiyevent",
"peacefullzryachiyevent",
"cursedassault", "cursedassault",
"sectantpriest", "sectantpriest",
"sectantwarrior", "sectantwarrior",
@ -59,7 +61,7 @@ internal static class Program
var parsedBots = BotParser.ParseAsync(dumpPath, botTypes.ToHashSet()); var parsedBots = BotParser.ParseAsync(dumpPath, botTypes.ToHashSet());
// Put in dictionary for better use later on // Put in dictionary for better use later on
var rawBotsCache = new Dictionary<string, List<Datum>>(40); var rawBotsCache = new Dictionary<string, List<Datum>>(45);
foreach (var rawBot in parsedBots) foreach (var rawBot in parsedBots)
{ {
if (rawBotsCache.TryGetValue(rawBot.Info.Settings.Role.ToLower(), out var botList)) if (rawBotsCache.TryGetValue(rawBot.Info.Settings.Role.ToLower(), out var botList))