merge into main #1

Merged
chomp merged 35 commits from WeightedSystem into master 2023-08-15 05:29:21 -04:00
8 changed files with 116935 additions and 116900 deletions
Showing only changes of commit eb1fc985fb - Show all commits

View File

@ -13,14 +13,19 @@ namespace Common.Models
public class Props public class Props
{ {
public string defMagType;
public string Name { get; set; } public string Name { get; set; }
public string ShortName { get; set; } public string ShortName { get; set; }
public string Description { get; set; } public string Description { get; set; }
public List<Chamber> Chambers { get; set; } public List<Chamber> Chambers { get; set; }
public List<Cartridge> Cartridges { get;set;}
public List<Slot> Slots { get; set; } public List<Slot> Slots { get; set; }
public string defAmmo { get; set; } public string defAmmo { get; set; }
public string weapClass { get; set; } public string weapClass { get; set; }
public string weapUseType { get; set; } public string weapUseType { get; set; }
public string ammoCaliber { get; set; }
public string Caliber { get; set; }
} }
public class Chamber public class Chamber
@ -34,10 +39,21 @@ namespace Common.Models
public string _proto { get; set; } public string _proto { get; set; }
} }
public class Cartridge
{
public string _name { get; set; }
public string _id { get; set; }
public string _parent { get; set; }
public int _max_count { get; set; }
public ChamberProps _props { get; set; }
public string _proto { get; set; }
}
public class Slot public class Slot
{ {
public string _name { get; set; } public string _name { get; set; }
public bool _required { get; set; } public bool _required { get; set; }
public ChamberProps _props { get;set;}
} }
public class ChamberProps public class ChamberProps

View File

@ -45,9 +45,12 @@ namespace Common.Models.Output
equipment = new Equipment(); equipment = new Equipment();
items = new Items(); items = new Items();
mods = new Dictionary<string, Dictionary<string, List<string>>>(); mods = new Dictionary<string, Dictionary<string, List<string>>>();
Ammo = new Dictionary<string, Dictionary<string, int>>();
} }
public Equipment equipment { get; set; } public Equipment equipment { get; set; }
public Dictionary<string, Dictionary<string, int>> Ammo { get;set;}
public Dictionary<string, Dictionary<string, List<string>>> mods { get; set; } public Dictionary<string, Dictionary<string, List<string>>> mods { get; set; }
public Items items { get; set; } public Items items { get; set; }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,163 +1,200 @@
{ {
"assault": { "assault": {
"FirstPrimaryWeapon": { "Equipment": {
"54491c4f4bdc2db1078b4568": 61, "FirstPrimaryWeapon": {
"5580223e4bdc2d1c128b457f": 4, "54491c4f4bdc2db1078b4568": 61,
"5644bd2b4bdc2d3b4c8b4572": 10, "5580223e4bdc2d1c128b457f": 4,
"56dee2bdd2720bc8328b4567": 80, "5644bd2b4bdc2d3b4c8b4572": 10,
"574d967124597745970e7c94": 56, "56dee2bdd2720bc8328b4567": 80,
"576165642459773c7a400233": 80, "574d967124597745970e7c94": 56,
"57d14d2524597714373db789": 16, "576165642459773c7a400233": 80,
"57dc2fa62459775949412633": 41, "57d14d2524597714373db789": 16,
"587e02ff24597743df3deaeb": 37, "57dc2fa62459775949412633": 41,
"59d6088586f774275f37482f": 22, "587e02ff24597743df3deaeb": 37,
"59e6152586f77473dc057aa1": 83, "59d6088586f774275f37482f": 22,
"59e6687d86f77411d949b251": 61, "59e6152586f77473dc057aa1": 83,
"59f9cabd86f7743a10721f46": 49, "59e6687d86f77411d949b251": 61,
"59ff346386f77477562ff5e2": 12, "59f9cabd86f7743a10721f46": 49,
"5a38e6bac4a2826c6e06d79b": 78, "59ff346386f77477562ff5e2": 12,
"5ab8e9fcd8ce870019439434": 4, "5a38e6bac4a2826c6e06d79b": 78,
"5ac4cd105acfc40016339859": 32, "5ab8e9fcd8ce870019439434": 4,
"5ac66d9b5acfc4001633997a": 9, "5ac4cd105acfc40016339859": 32,
"5ae08f0a5acfc408fb1398a1": 4, "5ac66d9b5acfc4001633997a": 9,
"5bf3e03b0db834001d2c4a9c": 4, "5ae08f0a5acfc408fb1398a1": 4,
"5bf3e0490db83400196199af": 7, "5bf3e03b0db834001d2c4a9c": 4,
"5bfd297f0db834001a669119": 5, "5bf3e0490db83400196199af": 7,
"5c07c60e0db834002330051f": 33, "5bfd297f0db834001a669119": 5,
"5c501a4d2e221602b412b540": 27, "5c07c60e0db834002330051f": 33,
"5de652c31b7e3716273428be": 17, "5c501a4d2e221602b412b540": 27,
"5e870397991fd70db46995c8": 29, "5de652c31b7e3716273428be": 17,
"5ea03f7400685063ec28bfa8": 11, "5e870397991fd70db46995c8": 29,
"606dae0ab0e443224b421bb7": 57, "5ea03f7400685063ec28bfa8": 11,
"60db29ce99594040e04c4a27": 4, "606dae0ab0e443224b421bb7": 57,
"61f7c9e189e6fb1a5e3ea78d": 32 "60db29ce99594040e04c4a27": 4,
"61f7c9e189e6fb1a5e3ea78d": 32
},
"Backpack": {
"544a5cde4bdc2d39388b456b": 9,
"56e335e4d2720b6c058b456d": 4,
"56e33634d2720bd8058b456b": 10,
"56e33680d2720be2748b4576": 12,
"59e763f286f7742ee57895da": 1,
"5ab8ee7786f7742d8f33f0b9": 1,
"5ab8f04f86f774585f4237d8": 12,
"5f5e45cc5021ce62144be7aa": 4,
"60a2828e8689911a226117f9": 1
}
}, },
"Backpack": { "Ammo": {
"544a5cde4bdc2d39388b456b": 9, "Caliber366TKM": {
"56e335e4d2720b6c058b456d": 4, "5f0596629e22f464da6bbdd9": 1,
"56e33634d2720bd8058b456b": 10, "59e6542b86f77411dc52a77a": 1,
"56e33680d2720be2748b4576": 12, "59e655cb86f77411dc52a77b": 1
"59e763f286f7742ee57895da": 1, },
"5ab8ee7786f7742d8f33f0b9": 1, "Caliber12g": {
"5ab8f04f86f774585f4237d8": 12, "5d6e67fba4b9361bc73bc779": 1,
"5f5e45cc5021ce62144be7aa": 4, "5d6e689ca4b9361bc8618956": 1,
"60a2828e8689911a226117f9": 1 "560d5e524bdc2d25448b4571": 1,
"5d6e6806a4b936088465b17e": 1,
"5d6e68dea4b9361bcc29e659": 1
}
} }
}, },
"pmcBot": { "pmcBot": {
"FirstPrimaryWeapon": { "Equipment": {
"5447a9cd4bdc2dbd208b4567": 30, "FirstPrimaryWeapon": {
"54491c4f4bdc2db1078b4568": 50, "5447a9cd4bdc2dbd208b4567": 30,
"574d967124597745970e7c94": 58, "54491c4f4bdc2db1078b4568": 50,
"576165642459773c7a400233": 36, "574d967124597745970e7c94": 58,
"57c44b372459772d2b39b8ce": 10, "576165642459773c7a400233": 36,
"57d14d2524597714373db789": 93, "57c44b372459772d2b39b8ce": 10,
"57dc2fa62459775949412633": 81, "57d14d2524597714373db789": 93,
"583990e32459771419544dd2": 103, "57dc2fa62459775949412633": 81,
"58948c8e86f77409493f7266": 12, "583990e32459771419544dd2": 103,
"5926bb2186f7744b1c6c6e60": 107, "58948c8e86f77409493f7266": 12,
"5a7828548dc32e5a9c28b516": 120, "5926bb2186f7744b1c6c6e60": 107,
"5ac4cd105acfc40016339859": 34, "5a7828548dc32e5a9c28b516": 120,
"5ac66d725acfc43b321d4b60": 41, "5ac4cd105acfc40016339859": 34,
"5ac66d9b5acfc4001633997a": 53, "5ac66d725acfc43b321d4b60": 41,
"5b0bbe4e5acfc40dc528a72d": 3, "5ac66d9b5acfc4001633997a": 53,
"5bb2475ed4351e00853264e3": 17, "5b0bbe4e5acfc40dc528a72d": 3,
"5bd70322209c4d00d7167b8f": 6, "5bb2475ed4351e00853264e3": 17,
"5c488a752e221602b412af63": 10, "5bd70322209c4d00d7167b8f": 6,
"5d43021ca4b9362eab4b5e25": 6, "5c488a752e221602b412af63": 10,
"5df8ce05b11454561e39243b": 4, "5d43021ca4b9362eab4b5e25": 6,
"5f2a9575926fd9352339381f": 27, "5df8ce05b11454561e39243b": 4,
"5fbcc1d9016cce60e8341ab3": 12, "5f2a9575926fd9352339381f": 27,
"5fc3f2d5900b1d5091531e57": 14, "5fbcc1d9016cce60e8341ab3": 12,
"60339954d62c9b14ed777c06": 18, "5fc3f2d5900b1d5091531e57": 14,
"606587252535c57a13424cfd": 4, "60339954d62c9b14ed777c06": 18,
"623063e994fc3f7b302a9696": 35 "606587252535c57a13424cfd": 4,
} "623063e994fc3f7b302a9696": 35
}
},
"Ammo": {}
}, },
"bossBully": { "bossBully": {
"FirstPrimaryWeapon": { "Equipment": {
"576165642459773c7a400233": 15, "FirstPrimaryWeapon": {
"5926bb2186f7744b1c6c6e60": 11, "576165642459773c7a400233": 15,
"5ac66cb05acfc40198510a10": 45, "5926bb2186f7744b1c6c6e60": 11,
"5ac66d015acfc400180ae6e4": 41, "5ac66cb05acfc40198510a10": 45,
"5dcbd56fdbd3d91b3e5468d5": 13 "5ac66d015acfc400180ae6e4": 41,
"5dcbd56fdbd3d91b3e5468d5": 13
},
"Holster": {
"5b3b713c5acfc4330140bd8d": 1,
"602a9740da11d6478d5a06dc": 5,
"6193a720f8ee7e52e42109ed": 1
}
}, },
"Holster": { "Ammo": {}
"5b3b713c5acfc4330140bd8d": 1,
"602a9740da11d6478d5a06dc": 5,
"6193a720f8ee7e52e42109ed": 1
}
}, },
"bossKilla": { "bossKilla": {
"FirstPrimaryWeapon": { "Equipment": {
"59984ab886f7743e98271174": 2, "FirstPrimaryWeapon": {
"59ff346386f77477562ff5e2": 3, "59984ab886f7743e98271174": 2,
"5beed0f50db834001c062b12": 17 "59ff346386f77477562ff5e2": 3,
} "5beed0f50db834001c062b12": 17
}
},
"Ammo": {}
}, },
"bossKojaniy": { "bossKojaniy": {
"Backpack": { "Equipment": {
"56e335e4d2720b6c058b456d": 37, "Backpack": {
"5c0e805e86f774683f3dd637": 11, "56e335e4d2720b6c058b456d": 37,
"5ca20d5986f774331e7c9602": 38, "5c0e805e86f774683f3dd637": 11,
"6034d103ca006d2dca39b3f0": 11, "5ca20d5986f774331e7c9602": 38,
"6038d614d10cbf667352dd44": 11, "6034d103ca006d2dca39b3f0": 11,
"618cfae774bb2d036a049e7c": 11 "6038d614d10cbf667352dd44": 11,
"618cfae774bb2d036a049e7c": 11
},
"FirstPrimaryWeapon": {
"5c46fbd72e2216398b5a8c9c": 4,
"6176aca650224f204c1da3fb": 1
}
}, },
"FirstPrimaryWeapon": { "Ammo": {}
"5c46fbd72e2216398b5a8c9c": 4,
"6176aca650224f204c1da3fb": 1
}
}, },
"bossTagilla": { "bossTagilla": {
"FirstPrimaryWeapon": { "Equipment": {
"576165642459773c7a400233": 12, "FirstPrimaryWeapon": {
"583990e32459771419544dd2": 7, "576165642459773c7a400233": 12,
"5beed0f50db834001c062b12": 2, "583990e32459771419544dd2": 7,
"606dae0ab0e443224b421bb7": 1 "5beed0f50db834001c062b12": 2,
} "606dae0ab0e443224b421bb7": 1
}
},
"Ammo": {}
}, },
"exUsec": { "exUsec": {
"ArmorVest": { "Equipment": {
"5648a7494bdc2d9d488b4583": 32, "ArmorVest": {
"5b44cf1486f77431723e3d05": 7, "5648a7494bdc2d9d488b4583": 32,
"5b44d0de86f774503d30cba8": 18, "5b44cf1486f77431723e3d05": 7,
"5c0e655586f774045612eeb2": 26, "5b44d0de86f774503d30cba8": 18,
"5fd4c474dd870108a754b241": 7, "5c0e655586f774045612eeb2": 26,
"609e8540d5c319764c2bc2e9": 18 "5fd4c474dd870108a754b241": 7,
"609e8540d5c319764c2bc2e9": 18
},
"FirstPrimaryWeapon": {
"5447a9cd4bdc2dbd208b4567": 31,
"59d6088586f774275f37482f": 22,
"5ac4cd105acfc40016339859": 10,
"5ac66d725acfc43b321d4b60": 7,
"5b0bbe4e5acfc40dc528a72d": 2,
"5bb2475ed4351e00853264e3": 4,
"5df8ce05b11454561e39243b": 1,
"5fbcc1d9016cce60e8341ab3": 1,
"606587252535c57a13424cfd": 2,
"6184055050224f204c1da540": 1,
"618428466ef05c2ce828f218": 19,
"628a60ae6b1d481ff772e9c8": 7
}
}, },
"FirstPrimaryWeapon": { "Ammo": {}
"5447a9cd4bdc2dbd208b4567": 31,
"59d6088586f774275f37482f": 22,
"5ac4cd105acfc40016339859": 10,
"5ac66d725acfc43b321d4b60": 7,
"5b0bbe4e5acfc40dc528a72d": 2,
"5bb2475ed4351e00853264e3": 4,
"5df8ce05b11454561e39243b": 1,
"5fbcc1d9016cce60e8341ab3": 1,
"606587252535c57a13424cfd": 2,
"6184055050224f204c1da540": 1,
"618428466ef05c2ce828f218": 19,
"628a60ae6b1d481ff772e9c8": 7
}
}, },
"marksman": { "marksman": {
"FirstPrimaryWeapon": { "Equipment": {
"55801eed4bdc2d89578b4588": 87, "FirstPrimaryWeapon": {
"5644bd2b4bdc2d3b4c8b4572": 58, "55801eed4bdc2d89578b4588": 87,
"574d967124597745970e7c94": 149, "5644bd2b4bdc2d3b4c8b4572": 58,
"57838ad32459774a17445cd2": 12, "574d967124597745970e7c94": 149,
"57dc2fa62459775949412633": 27, "57838ad32459774a17445cd2": 12,
"5839a40f24597726f856b511": 16, "57dc2fa62459775949412633": 27,
"587e02ff24597743df3deaeb": 292, "5839a40f24597726f856b511": 16,
"5ae08f0a5acfc408fb1398a1": 244, "587e02ff24597743df3deaeb": 292,
"5bfea6e90db834001b7347f3": 13, "5ae08f0a5acfc408fb1398a1": 244,
"5c46fbd72e2216398b5a8c9c": 97 "5bfea6e90db834001b7347f3": 13,
"5c46fbd72e2216398b5a8c9c": 97
},
"TacticalVest": {
"572b7adb24597762ae139821": 20,
"5929a2a086f7744f4b234d43": 4,
"5ca20abf86f77418567a43f2": 1
}
}, },
"TacticalVest": { "Ammo": {}
"572b7adb24597762ae139821": 20,
"5929a2a086f7744f4b234d43": 4,
"5ca20abf86f77418567a43f2": 1
}
} }
} }

View File

@ -30,8 +30,9 @@ namespace Generator
foreach (var rawParsedBot in rawParsedBotOfCurrentType) foreach (var rawParsedBot in rawParsedBotOfCurrentType)
{ {
GearHelpers.AddEquippedGear(botToUpdate, rawParsedBot); GearHelpers.AddEquippedGear(botToUpdate, rawParsedBot);
GearHelpers.AddAmmo(botToUpdate, rawParsedBot);
GearHelpers.AddEquippedMods(botToUpdate, rawParsedBot); GearHelpers.AddEquippedMods(botToUpdate, rawParsedBot);
GearHelpers.AddCartridges(botToUpdate, rawParsedBot); //GearHelpers.AddCartridges(botToUpdate, rawParsedBot);
} }
} }

View File

@ -2,8 +2,6 @@
using Common.Models.Input; using Common.Models.Input;
using Common.Models.Output; using Common.Models.Output;
using Generator.Weighting; using Generator.Weighting;
using System.Collections.Generic;
using System.Linq;
namespace Generator.Helpers.Gear namespace Generator.Helpers.Gear
{ {
@ -64,6 +62,28 @@ namespace Generator.Helpers.Gear
botToUpdate.inventory.mods = itemsWithModsDictionary; botToUpdate.inventory.mods = itemsWithModsDictionary;
} }
internal static void AddAmmo(Bot botToUpdate, Datum bot)
{
var weightService = new WeightingService();
foreach (var inventoryItem in bot.Inventory.items.Where(x => x.slotId != null && (x.slotId == "patron_in_weapon" || x.slotId == "cartridges" || x.slotId.StartsWith("camora"))))
{
var caliber = ItemTemplateHelper.GetTemplateById(inventoryItem._tpl)._props.ammoCaliber;
if (caliber == null)
{
caliber = ItemTemplateHelper.GetTemplateById(inventoryItem._tpl)._props.Caliber;
}
// Create key if caliber doesnt exist
if (!botToUpdate.inventory.Ammo.ContainsKey(caliber))
{
botToUpdate.inventory.Ammo[caliber] = new Dictionary<string, int>();
}
botToUpdate.inventory.Ammo[caliber].AddUnique(inventoryItem._tpl, weightService.GetAmmoWeight(inventoryItem._tpl, botToUpdate.botType, caliber));
}
}
public static void AddEquippedGear(Bot botToUpdate, Datum bot) public static void AddEquippedGear(Bot botToUpdate, Datum bot)
{ {
// add equipped gear // add equipped gear

View File

@ -6,35 +6,35 @@ internal static class Program
{ {
// Create list of bots we want to process // Create list of bots we want to process
string[] botTypes = { string[] botTypes = {
"assault", "assault",
"marksman", "marksman",
"pmcBot", "pmcBot",
"exUsec", "exUsec",
"bossbully", "bossbully",
"bossgluhar", "bossgluhar",
"bosskilla", "bosskilla",
"bosskojaniy", "bosskojaniy",
"bosssanitar", "bosssanitar",
"bosstagilla", "bosstagilla",
"bossknight", "bossknight",
"followerbully", "followerbully",
"followergluharassault", "followergluharassault",
"followergluharscout", "followergluharscout",
"followergluharsecurity", "followergluharsecurity",
"followergluharsnipe", "followergluharsnipe",
"followerkojaniy", "followerkojaniy",
"followersanitar", "followersanitar",
"followerstormtrooper", "followerstormtrooper",
"followerbirdeye", "followerbirdeye",
"followerbigpipe", "followerbigpipe",
// //
"cursedassault", "cursedassault",
// //
"sectantpriest", "sectantpriest",
"sectantwarrior", "sectantwarrior",
"gifter" "gifter"
}; };
// Read raw bot dumps and turn into c# objects // Read raw bot dumps and turn into c# objects
@ -45,7 +45,7 @@ internal static class Program
if (parsedBots.Count == 0) if (parsedBots.Count == 0)
{ {
LoggingHelpers.LogToConsole("no bots found, unable to continue"); LoggingHelpers.LogToConsole("no bots found, unable to continue");
LoggingHelpers.LogToConsole("Check your dumps are in 'Generator\\bin\\Debug\\netcoreapp3.1\\dumps' and start with 'resp.' NOT 'req.'"); LoggingHelpers.LogToConsole("Check your dumps are in 'Generator\\bin\\Debug\\net6.0\\dumps' and start with 'resp.' NOT 'req.'");
return; return;
} }

View File

@ -8,31 +8,61 @@ using System.Threading.Tasks;
namespace Generator.Weighting namespace Generator.Weighting
{ {
public class Weightings
{
public Dictionary<string, Dictionary<string, int>> Equipment { get; set; }
// Ammo type + (dict of ammo + weight)
public Dictionary <string, Dictionary<string, int>> Ammo { get; set; }
}
public class WeightingService public class WeightingService
{ {
private readonly Dictionary<BotType, Dictionary<string, Dictionary<string, int>>> _weights; private readonly Dictionary<BotType, Weightings> _weights;
public WeightingService() public WeightingService()
{ {
var itemsFilePath = $"{Directory.GetCurrentDirectory()}\\Assets\\weights.json"; var weightsFilePath = $"{Directory.GetCurrentDirectory()}\\Assets\\weights.json";
if (!File.Exists(itemsFilePath)) if (!File.Exists(weightsFilePath))
{ {
throw new Exception($"Missing weights.json in /assets ({itemsFilePath})"); throw new Exception($"Missing weights.json in /assets ({weightsFilePath})");
} }
var itemsJson = File.ReadAllText(itemsFilePath); var weightJson = File.ReadAllText(weightsFilePath);
_weights = JsonSerializer.Deserialize<Dictionary<BotType, Dictionary<string, Dictionary<string, int>>>>(itemsJson); _weights = JsonSerializer.Deserialize<Dictionary<BotType, Weightings>>(weightJson);
}
public int GetAmmoWeight(string tpl, BotType botType, string caliber)
{
if (_weights.ContainsKey(botType))
{
var botWeights = _weights[botType];
if (botWeights.Ammo.ContainsKey(caliber))
{
var calibers = botWeights.Ammo[caliber];
if (calibers.ContainsKey(tpl))
{
return calibers[tpl];
}
}
}
return 1;
} }
public int GetItemWeight(string tpl, BotType botType, string slot) public int GetItemWeight(string tpl, BotType botType, string slot)
{ {
if (_weights.ContainsKey(botType)) if (_weights.ContainsKey(botType))
{ {
var botWeights = _weights[botType]; var botItemList = _weights[botType];
if (botWeights.Keys.Contains(slot, StringComparer.CurrentCultureIgnoreCase))
if (botItemList.Equipment.Keys.Contains(slot, StringComparer.CurrentCultureIgnoreCase))
{ {
var slotWeights = botWeights.FirstOrDefault(x => x.Key.ToLower() == slot).Value; var slotWeights = botItemList.Equipment.FirstOrDefault(x => x.Key.ToLower() == slot).Value;
if (slotWeights.Keys.Contains(tpl, StringComparer.CurrentCultureIgnoreCase)) if (slotWeights.Keys.Contains(tpl, StringComparer.CurrentCultureIgnoreCase))
{ {
var itemWeight = slotWeights[tpl]; var itemWeight = slotWeights[tpl];