Update
This commit is contained in:
parent
4e079cc794
commit
eb1fc985fb
@ -13,14 +13,19 @@ namespace Common.Models
|
||||
|
||||
public class Props
|
||||
{
|
||||
public string defMagType;
|
||||
|
||||
public string Name { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public List<Chamber> Chambers { get; set; }
|
||||
public List<Cartridge> Cartridges { get;set;}
|
||||
public List<Slot> Slots { get; set; }
|
||||
public string defAmmo { get; set; }
|
||||
public string weapClass { get; set; }
|
||||
public string weapUseType { get; set; }
|
||||
public string ammoCaliber { get; set; }
|
||||
public string Caliber { get; set; }
|
||||
}
|
||||
|
||||
public class Chamber
|
||||
@ -34,10 +39,21 @@ namespace Common.Models
|
||||
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 string _name { get; set; }
|
||||
public bool _required { get; set; }
|
||||
public ChamberProps _props { get;set;}
|
||||
}
|
||||
|
||||
public class ChamberProps
|
||||
|
@ -45,9 +45,12 @@ namespace Common.Models.Output
|
||||
equipment = new Equipment();
|
||||
items = new Items();
|
||||
mods = new Dictionary<string, Dictionary<string, List<string>>>();
|
||||
Ammo = new Dictionary<string, Dictionary<string, int>>();
|
||||
}
|
||||
|
||||
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 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": {
|
||||
"Equipment": {
|
||||
"FirstPrimaryWeapon": {
|
||||
"54491c4f4bdc2db1078b4568": 61,
|
||||
"5580223e4bdc2d1c128b457f": 4,
|
||||
@ -44,7 +45,23 @@
|
||||
"60a2828e8689911a226117f9": 1
|
||||
}
|
||||
},
|
||||
"Ammo": {
|
||||
"Caliber366TKM": {
|
||||
"5f0596629e22f464da6bbdd9": 1,
|
||||
"59e6542b86f77411dc52a77a": 1,
|
||||
"59e655cb86f77411dc52a77b": 1
|
||||
},
|
||||
"Caliber12g": {
|
||||
"5d6e67fba4b9361bc73bc779": 1,
|
||||
"5d6e689ca4b9361bc8618956": 1,
|
||||
"560d5e524bdc2d25448b4571": 1,
|
||||
"5d6e6806a4b936088465b17e": 1,
|
||||
"5d6e68dea4b9361bcc29e659": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"pmcBot": {
|
||||
"Equipment": {
|
||||
"FirstPrimaryWeapon": {
|
||||
"5447a9cd4bdc2dbd208b4567": 30,
|
||||
"54491c4f4bdc2db1078b4568": 50,
|
||||
@ -74,7 +91,10 @@
|
||||
"623063e994fc3f7b302a9696": 35
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
},
|
||||
"bossBully": {
|
||||
"Equipment": {
|
||||
"FirstPrimaryWeapon": {
|
||||
"576165642459773c7a400233": 15,
|
||||
"5926bb2186f7744b1c6c6e60": 11,
|
||||
@ -88,14 +108,20 @@
|
||||
"6193a720f8ee7e52e42109ed": 1
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
},
|
||||
"bossKilla": {
|
||||
"Equipment": {
|
||||
"FirstPrimaryWeapon": {
|
||||
"59984ab886f7743e98271174": 2,
|
||||
"59ff346386f77477562ff5e2": 3,
|
||||
"5beed0f50db834001c062b12": 17
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
},
|
||||
"bossKojaniy": {
|
||||
"Equipment": {
|
||||
"Backpack": {
|
||||
"56e335e4d2720b6c058b456d": 37,
|
||||
"5c0e805e86f774683f3dd637": 11,
|
||||
@ -109,7 +135,10 @@
|
||||
"6176aca650224f204c1da3fb": 1
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
},
|
||||
"bossTagilla": {
|
||||
"Equipment": {
|
||||
"FirstPrimaryWeapon": {
|
||||
"576165642459773c7a400233": 12,
|
||||
"583990e32459771419544dd2": 7,
|
||||
@ -117,7 +146,10 @@
|
||||
"606dae0ab0e443224b421bb7": 1
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
},
|
||||
"exUsec": {
|
||||
"Equipment": {
|
||||
"ArmorVest": {
|
||||
"5648a7494bdc2d9d488b4583": 32,
|
||||
"5b44cf1486f77431723e3d05": 7,
|
||||
@ -141,7 +173,10 @@
|
||||
"628a60ae6b1d481ff772e9c8": 7
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
},
|
||||
"marksman": {
|
||||
"Equipment": {
|
||||
"FirstPrimaryWeapon": {
|
||||
"55801eed4bdc2d89578b4588": 87,
|
||||
"5644bd2b4bdc2d3b4c8b4572": 58,
|
||||
@ -159,5 +194,7 @@
|
||||
"5929a2a086f7744f4b234d43": 4,
|
||||
"5ca20abf86f77418567a43f2": 1
|
||||
}
|
||||
},
|
||||
"Ammo": {}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ namespace Generator
|
||||
foreach (var rawParsedBot in rawParsedBotOfCurrentType)
|
||||
{
|
||||
GearHelpers.AddEquippedGear(botToUpdate, rawParsedBot);
|
||||
GearHelpers.AddAmmo(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.Output;
|
||||
using Generator.Weighting;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Generator.Helpers.Gear
|
||||
{
|
||||
@ -64,6 +62,28 @@ namespace Generator.Helpers.Gear
|
||||
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)
|
||||
{
|
||||
// add equipped gear
|
||||
|
@ -45,7 +45,7 @@ internal static class Program
|
||||
if (parsedBots.Count == 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -9,30 +9,60 @@ using System.Threading.Tasks;
|
||||
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
|
||||
{
|
||||
private readonly Dictionary<BotType, Dictionary<string, Dictionary<string, int>>> _weights;
|
||||
private readonly Dictionary<BotType, Weightings> _weights;
|
||||
public WeightingService()
|
||||
{
|
||||
|
||||
var itemsFilePath = $"{Directory.GetCurrentDirectory()}\\Assets\\weights.json";
|
||||
if (!File.Exists(itemsFilePath))
|
||||
var weightsFilePath = $"{Directory.GetCurrentDirectory()}\\Assets\\weights.json";
|
||||
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);
|
||||
_weights = JsonSerializer.Deserialize<Dictionary<BotType, Dictionary<string, Dictionary<string, int>>>>(itemsJson);
|
||||
var weightJson = File.ReadAllText(weightsFilePath);
|
||||
_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)
|
||||
{
|
||||
if (_weights.ContainsKey(botType))
|
||||
{
|
||||
var botWeights = _weights[botType];
|
||||
if (botWeights.Keys.Contains(slot, StringComparer.CurrentCultureIgnoreCase))
|
||||
var botItemList = _weights[botType];
|
||||
|
||||
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))
|
||||
{
|
||||
var itemWeight = slotWeights[tpl];
|
||||
|
Loading…
x
Reference in New Issue
Block a user