merge into main #1
@ -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
|
||||||
|
@ -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; }
|
||||||
}
|
}
|
||||||
|
233346
Common/Assets/items.json
233346
Common/Assets/items.json
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"assault": {
|
"assault": {
|
||||||
|
"Equipment": {
|
||||||
"FirstPrimaryWeapon": {
|
"FirstPrimaryWeapon": {
|
||||||
"54491c4f4bdc2db1078b4568": 61,
|
"54491c4f4bdc2db1078b4568": 61,
|
||||||
"5580223e4bdc2d1c128b457f": 4,
|
"5580223e4bdc2d1c128b457f": 4,
|
||||||
@ -44,7 +45,23 @@
|
|||||||
"60a2828e8689911a226117f9": 1
|
"60a2828e8689911a226117f9": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {
|
||||||
|
"Caliber366TKM": {
|
||||||
|
"5f0596629e22f464da6bbdd9": 1,
|
||||||
|
"59e6542b86f77411dc52a77a": 1,
|
||||||
|
"59e655cb86f77411dc52a77b": 1
|
||||||
|
},
|
||||||
|
"Caliber12g": {
|
||||||
|
"5d6e67fba4b9361bc73bc779": 1,
|
||||||
|
"5d6e689ca4b9361bc8618956": 1,
|
||||||
|
"560d5e524bdc2d25448b4571": 1,
|
||||||
|
"5d6e6806a4b936088465b17e": 1,
|
||||||
|
"5d6e68dea4b9361bcc29e659": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"pmcBot": {
|
"pmcBot": {
|
||||||
|
"Equipment": {
|
||||||
"FirstPrimaryWeapon": {
|
"FirstPrimaryWeapon": {
|
||||||
"5447a9cd4bdc2dbd208b4567": 30,
|
"5447a9cd4bdc2dbd208b4567": 30,
|
||||||
"54491c4f4bdc2db1078b4568": 50,
|
"54491c4f4bdc2db1078b4568": 50,
|
||||||
@ -74,7 +91,10 @@
|
|||||||
"623063e994fc3f7b302a9696": 35
|
"623063e994fc3f7b302a9696": 35
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {}
|
||||||
|
},
|
||||||
"bossBully": {
|
"bossBully": {
|
||||||
|
"Equipment": {
|
||||||
"FirstPrimaryWeapon": {
|
"FirstPrimaryWeapon": {
|
||||||
"576165642459773c7a400233": 15,
|
"576165642459773c7a400233": 15,
|
||||||
"5926bb2186f7744b1c6c6e60": 11,
|
"5926bb2186f7744b1c6c6e60": 11,
|
||||||
@ -88,14 +108,20 @@
|
|||||||
"6193a720f8ee7e52e42109ed": 1
|
"6193a720f8ee7e52e42109ed": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {}
|
||||||
|
},
|
||||||
"bossKilla": {
|
"bossKilla": {
|
||||||
|
"Equipment": {
|
||||||
"FirstPrimaryWeapon": {
|
"FirstPrimaryWeapon": {
|
||||||
"59984ab886f7743e98271174": 2,
|
"59984ab886f7743e98271174": 2,
|
||||||
"59ff346386f77477562ff5e2": 3,
|
"59ff346386f77477562ff5e2": 3,
|
||||||
"5beed0f50db834001c062b12": 17
|
"5beed0f50db834001c062b12": 17
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {}
|
||||||
|
},
|
||||||
"bossKojaniy": {
|
"bossKojaniy": {
|
||||||
|
"Equipment": {
|
||||||
"Backpack": {
|
"Backpack": {
|
||||||
"56e335e4d2720b6c058b456d": 37,
|
"56e335e4d2720b6c058b456d": 37,
|
||||||
"5c0e805e86f774683f3dd637": 11,
|
"5c0e805e86f774683f3dd637": 11,
|
||||||
@ -109,7 +135,10 @@
|
|||||||
"6176aca650224f204c1da3fb": 1
|
"6176aca650224f204c1da3fb": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {}
|
||||||
|
},
|
||||||
"bossTagilla": {
|
"bossTagilla": {
|
||||||
|
"Equipment": {
|
||||||
"FirstPrimaryWeapon": {
|
"FirstPrimaryWeapon": {
|
||||||
"576165642459773c7a400233": 12,
|
"576165642459773c7a400233": 12,
|
||||||
"583990e32459771419544dd2": 7,
|
"583990e32459771419544dd2": 7,
|
||||||
@ -117,7 +146,10 @@
|
|||||||
"606dae0ab0e443224b421bb7": 1
|
"606dae0ab0e443224b421bb7": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {}
|
||||||
|
},
|
||||||
"exUsec": {
|
"exUsec": {
|
||||||
|
"Equipment": {
|
||||||
"ArmorVest": {
|
"ArmorVest": {
|
||||||
"5648a7494bdc2d9d488b4583": 32,
|
"5648a7494bdc2d9d488b4583": 32,
|
||||||
"5b44cf1486f77431723e3d05": 7,
|
"5b44cf1486f77431723e3d05": 7,
|
||||||
@ -141,7 +173,10 @@
|
|||||||
"628a60ae6b1d481ff772e9c8": 7
|
"628a60ae6b1d481ff772e9c8": 7
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Ammo": {}
|
||||||
|
},
|
||||||
"marksman": {
|
"marksman": {
|
||||||
|
"Equipment": {
|
||||||
"FirstPrimaryWeapon": {
|
"FirstPrimaryWeapon": {
|
||||||
"55801eed4bdc2d89578b4588": 87,
|
"55801eed4bdc2d89578b4588": 87,
|
||||||
"5644bd2b4bdc2d3b4c8b4572": 58,
|
"5644bd2b4bdc2d3b4c8b4572": 58,
|
||||||
@ -159,5 +194,7 @@
|
|||||||
"5929a2a086f7744f4b234d43": 4,
|
"5929a2a086f7744f4b234d43": 4,
|
||||||
"5ca20abf86f77418567a43f2": 1
|
"5ca20abf86f77418567a43f2": 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Ammo": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,30 +9,60 @@ 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];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user