Calculate weights for all bot equipment/ammo/appearance
This commit is contained in:
parent
2df1523ca5
commit
7c2d455b7b
@ -4,13 +4,14 @@ using System.Collections.Generic;
|
|||||||
namespace Common.Extensions;
|
namespace Common.Extensions;
|
||||||
public static class EnumExtensions
|
public static class EnumExtensions
|
||||||
{
|
{
|
||||||
private static readonly List<BotType> bossTypes = new List<BotType>(){
|
private static readonly List<BotType> bossTypes = new(){
|
||||||
BotType.bossbully,
|
BotType.bossbully,
|
||||||
BotType.bossgluhar,
|
BotType.bossgluhar,
|
||||||
BotType.bosskilla,
|
BotType.bosskilla,
|
||||||
BotType.bosskojaniy,
|
BotType.bosskojaniy,
|
||||||
BotType.bosssanitar,
|
BotType.bosssanitar,
|
||||||
BotType.bosstagilla
|
BotType.bosstagilla,
|
||||||
|
BotType.bossboar
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool IsBoss(this BotType self)
|
public static bool IsBoss(this BotType self)
|
||||||
|
@ -3,6 +3,7 @@ using Common.Models;
|
|||||||
using Common.Models.Input;
|
using Common.Models.Input;
|
||||||
using Common.Models.Output;
|
using Common.Models.Output;
|
||||||
using Generator.Helpers;
|
using Generator.Helpers;
|
||||||
|
using Generator.Helpers.Gear;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Generator
|
namespace Generator
|
||||||
@ -53,7 +54,6 @@ namespace Generator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
LoggingHelpers.LogToConsole($"Finished processing bot base. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
LoggingHelpers.LogToConsole($"Finished processing bot base. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
||||||
|
|
||||||
@ -155,10 +155,15 @@ 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);
|
||||||
|
//botToUpdate.appearance.feet.AddUnique(rawBot.Customization.Feet, 1);
|
||||||
|
GearHelpers.ReduceWeightValues(botToUpdate.appearance.feet);
|
||||||
|
|
||||||
|
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.body, rawBot.Customization.Body);
|
||||||
|
GearHelpers.ReduceWeightValues(botToUpdate.appearance.body);
|
||||||
|
|
||||||
botToUpdate.appearance.head.AddUnique(rawBot.Customization.Head);
|
botToUpdate.appearance.head.AddUnique(rawBot.Customization.Head);
|
||||||
botToUpdate.appearance.body.AddUnique(rawBot.Customization.Body, 1);
|
|
||||||
botToUpdate.appearance.hands.AddUnique(rawBot.Customization.Hands);
|
botToUpdate.appearance.hands.AddUnique(rawBot.Customization.Hands);
|
||||||
botToUpdate.appearance.feet.AddUnique(rawBot.Customization.Feet, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddName(Bot botToUpdate, Datum rawBot)
|
private static void AddName(Bot botToUpdate, Datum rawBot)
|
||||||
|
@ -42,6 +42,9 @@ namespace Generator
|
|||||||
GearHelpers.AddEquippedMods(botToUpdate, rawParsedBot);
|
GearHelpers.AddEquippedMods(botToUpdate, rawParsedBot);
|
||||||
//GearHelpers.AddCartridges(botToUpdate, rawParsedBot);
|
//GearHelpers.AddCartridges(botToUpdate, rawParsedBot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GearHelpers.ReduceAmmoWeightValues(botToUpdate);
|
||||||
|
GearHelpers.ReduceEquipmentWeightValues(botToUpdate.inventory.equipment);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,12 +136,6 @@ namespace Generator
|
|||||||
if (backpack != null)
|
if (backpack != null)
|
||||||
{
|
{
|
||||||
botToUpdate.inventory.items.Backpack.AddUniqueRange(containerDict[backpack._id]);
|
botToUpdate.inventory.items.Backpack.AddUniqueRange(containerDict[backpack._id]);
|
||||||
|
|
||||||
// Add generic keys to bosses
|
|
||||||
if (botToUpdate.botType.IsBoss())
|
|
||||||
{
|
|
||||||
botToUpdate.inventory.items.Backpack.AddUniqueRange(SpecialLootHelper.GetGenericBossKeys().ToList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pocket != null)
|
if (pocket != null)
|
||||||
@ -161,6 +155,15 @@ namespace Generator
|
|||||||
|
|
||||||
containerDict.Clear();
|
containerDict.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add generic keys to bosses
|
||||||
|
if (botToUpdate.botType.IsBoss())
|
||||||
|
{
|
||||||
|
var keys = SpecialLootHelper.GetGenericBossKeys().ToList();
|
||||||
|
botToUpdate.inventory.items.Backpack.AddUniqueRange(keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSpecialLoot(botToUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddSpecialLoot(Bot botToUpdate)
|
private static void AddSpecialLoot(Bot botToUpdate)
|
||||||
|
@ -180,18 +180,63 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Update="Assets\easy_assaultGroup_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Assets\generationWeights.json">
|
<None Update="Assets\generationWeights.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Assets\hard_assaultGroup_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\impossible_assaultGroup_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_arenaFighter_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_assaultGroup_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Assets\normal_bossBoarSniper_BotGlobalSettings.txt">
|
<None Update="Assets\normal_bossBoarSniper_BotGlobalSettings.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Assets\normal_bossBoar_BotGlobalSettings.txt">
|
<None Update="Assets\normal_bossBoar_BotGlobalSettings.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Assets\normal_bossKnight_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_bossZryachiy_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_crazyAssaultEvent_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_followerBigPipe_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_followerBirdEye_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Assets\normal_followerBoar_BotGlobalSettings.txt">
|
<None Update="Assets\normal_followerBoar_BotGlobalSettings.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Assets\normal_followerZryachiy_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_peacefullZryachiyEvent_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_ravangeZryachiyEvent_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\normal_sectactPriestEvent_BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Assets\__BotGlobalSettings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -12,30 +12,10 @@ namespace Generator.Helpers.Gear
|
|||||||
var modItemsInRawBot = new List<Item>();
|
var modItemsInRawBot = new List<Item>();
|
||||||
var itemsWithModsInRawBot = new List<Item>();
|
var itemsWithModsInRawBot = new List<Item>();
|
||||||
|
|
||||||
|
|
||||||
//foreach (var inv in rawParsedBot.Inventory.items.Where(x => x.slotId == "mod_magazine"))
|
|
||||||
//{
|
|
||||||
//var count = rawParsedBot.Inventory.items.Where(x => x.slotId == "mod_magazine").Count();
|
|
||||||
// if (inv._tpl == "60dc519adf4c47305f6d410d")
|
|
||||||
// {
|
|
||||||
// var y = 1;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
modItemsInRawBot = rawParsedBot.Inventory.items
|
modItemsInRawBot = rawParsedBot.Inventory.items
|
||||||
.Where(x => x.slotId != null && (x.slotId.StartsWith("mod_") || x.slotId.StartsWith("patron_in_weapon"))).ToList();
|
.Where(x => x.slotId != null && (x.slotId.StartsWith("mod_") || x.slotId.StartsWith("patron_in_weapon"))).ToList();
|
||||||
|
|
||||||
//var x = new List<Item>();
|
// Get items with Mods by iterating over mod items and getting the parent item
|
||||||
//foreach (var item in rawParsedBot.Inventory.items.Where(x=>x.slotId == "mod_magazine"))
|
|
||||||
//{
|
|
||||||
// if (item._tpl == "60dc519adf4c47305f6d410d")
|
|
||||||
// {
|
|
||||||
// var wow = 1;
|
|
||||||
// }
|
|
||||||
// x.Add(item);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// get items with Mods by iterating over mod items and getting the parent item
|
|
||||||
itemsWithModsInRawBot.AddRange(modItemsInRawBot
|
itemsWithModsInRawBot.AddRange(modItemsInRawBot
|
||||||
.Select(modItem => rawParsedBot.Inventory.items
|
.Select(modItem => rawParsedBot.Inventory.items
|
||||||
.Find(x => x._id == modItem.parentId)));
|
.Find(x => x._id == modItem.parentId)));
|
||||||
@ -45,6 +25,16 @@ namespace Generator.Helpers.Gear
|
|||||||
{
|
{
|
||||||
var modsToAdd = modItemsInRawBot.Where(x => x.parentId == itemToAdd._id).ToList();
|
var modsToAdd = modItemsInRawBot.Where(x => x.parentId == itemToAdd._id).ToList();
|
||||||
|
|
||||||
|
// fix pistolgrip that changes slot id name
|
||||||
|
if (itemToAdd._tpl == "56e0598dd2720bb5668b45a6")
|
||||||
|
{
|
||||||
|
var badMod = modsToAdd.FirstOrDefault(x => x.slotId == "mod_pistol_grip" && x._tpl == "56e05a6ed2720bd0748b4567");
|
||||||
|
if (badMod != null)
|
||||||
|
{
|
||||||
|
badMod.slotId = "mod_pistolgrip";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AddItemToDictionary(itemToAdd, modsToAdd, itemsWithModsDictionary);
|
AddItemToDictionary(itemToAdd, modsToAdd, itemsWithModsDictionary);
|
||||||
|
|
||||||
// check if these mods have sub-mods and add those
|
// check if these mods have sub-mods and add those
|
||||||
@ -64,14 +54,17 @@ namespace Generator.Helpers.Gear
|
|||||||
|
|
||||||
internal static void AddAmmo(Bot botToUpdate, Datum bot)
|
internal static void AddAmmo(Bot botToUpdate, Datum bot)
|
||||||
{
|
{
|
||||||
var weightService = new WeightingService();
|
//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"))))
|
foreach (var ammo in bot.Inventory.items.Where(
|
||||||
|
x => x.slotId != null
|
||||||
|
&& (x.slotId == "patron_in_weapon"
|
||||||
|
|| (x.slotId == "cartridges" && bot.Inventory.items.FirstOrDefault(parent => parent._id == x.parentId)?.slotId != "main") // Ignore cartridges in ammo boxes for ammo usage calc
|
||||||
|
|| x.slotId.StartsWith("camora"))))
|
||||||
{
|
{
|
||||||
var caliber = ItemTemplateHelper.GetTemplateById(inventoryItem._tpl)._props.ammoCaliber;
|
var caliber = ItemTemplateHelper.GetTemplateById(ammo._tpl)._props.ammoCaliber;
|
||||||
|
|
||||||
if (caliber == null)
|
if (caliber == null)
|
||||||
{
|
{
|
||||||
caliber = ItemTemplateHelper.GetTemplateById(inventoryItem._tpl)._props.Caliber;
|
caliber = ItemTemplateHelper.GetTemplateById(ammo._tpl)._props.Caliber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create key if caliber doesnt exist
|
// Create key if caliber doesnt exist
|
||||||
@ -80,10 +73,36 @@ namespace Generator.Helpers.Gear
|
|||||||
botToUpdate.inventory.Ammo[caliber] = new Dictionary<string, int>();
|
botToUpdate.inventory.Ammo[caliber] = new Dictionary<string, int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
botToUpdate.inventory.Ammo[caliber].AddUnique(inventoryItem._tpl, weightService.GetAmmoWeight(inventoryItem._tpl, botToUpdate.botType, caliber));
|
if (!botToUpdate.inventory.Ammo[caliber].ContainsKey(ammo._tpl))
|
||||||
|
{
|
||||||
|
botToUpdate.inventory.Ammo[caliber][ammo._tpl] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
botToUpdate.inventory.Ammo[caliber][ammo._tpl] ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int CommonDivisor(List<int> numbers)
|
||||||
|
{
|
||||||
|
int result = numbers[0];
|
||||||
|
for (int i = 1; i < numbers.Count; i++)
|
||||||
|
{
|
||||||
|
result = GCD(result, numbers[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GCD(int a, int b)
|
||||||
|
{
|
||||||
|
while (b != 0)
|
||||||
|
{
|
||||||
|
int temp = b;
|
||||||
|
b = a % b;
|
||||||
|
a = temp;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddEquippedGear(Bot botToUpdate, Datum bot)
|
public static void AddEquippedGear(Bot botToUpdate, Datum bot)
|
||||||
{
|
{
|
||||||
// add equipped gear
|
// add equipped gear
|
||||||
@ -93,46 +112,46 @@ namespace Generator.Helpers.Gear
|
|||||||
switch (inventoryItem.slotId?.ToLower())
|
switch (inventoryItem.slotId?.ToLower())
|
||||||
{
|
{
|
||||||
case "headwear":
|
case "headwear":
|
||||||
botToUpdate.inventory.equipment.Headwear.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "headwear"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Headwear, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "earpiece":
|
case "earpiece":
|
||||||
botToUpdate.inventory.equipment.Earpiece.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "earpiece"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Earpiece, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "facecover":
|
case "facecover":
|
||||||
botToUpdate.inventory.equipment.FaceCover.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "facecover"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.FaceCover, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "armorvest":
|
case "armorvest":
|
||||||
botToUpdate.inventory.equipment.ArmorVest.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "armorvest"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.ArmorVest, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "eyewear":
|
case "eyewear":
|
||||||
botToUpdate.inventory.equipment.Eyewear.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "eyewear"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Eyewear, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "armband":
|
case "armband":
|
||||||
botToUpdate.inventory.equipment.ArmBand.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "armband"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.ArmBand, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "tacticalvest":
|
case "tacticalvest":
|
||||||
botToUpdate.inventory.equipment.TacticalVest.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "tacticalvest"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.TacticalVest, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "backpack":
|
case "backpack":
|
||||||
botToUpdate.inventory.equipment.Backpack.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "backpack"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Backpack, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "firstprimaryweapon":
|
case "firstprimaryweapon":
|
||||||
botToUpdate.inventory.equipment.FirstPrimaryWeapon.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "firstprimaryweapon"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.FirstPrimaryWeapon, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "secondprimaryweapon":
|
case "secondprimaryweapon":
|
||||||
botToUpdate.inventory.equipment.SecondPrimaryWeapon.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "secondprimaryweapon"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.SecondPrimaryWeapon, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "holster":
|
case "holster":
|
||||||
botToUpdate.inventory.equipment.Holster.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "holster"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Holster, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "scabbard":
|
case "scabbard":
|
||||||
botToUpdate.inventory.equipment.Scabbard.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "scabbard"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Scabbard, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "pockets":
|
case "pockets":
|
||||||
botToUpdate.inventory.equipment.Pockets.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "pockets"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.Pockets, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
case "securedcontainer":
|
case "securedcontainer":
|
||||||
botToUpdate.inventory.equipment.SecuredContainer.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "securedcontainer"));
|
IncrementDictionaryValue(botToUpdate.inventory.equipment.SecuredContainer, inventoryItem._tpl);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -140,6 +159,16 @@ namespace Generator.Helpers.Gear
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void IncrementDictionaryValue(Dictionary<string, int> dictToIncrement, string key)
|
||||||
|
{
|
||||||
|
if (!dictToIncrement.ContainsKey(key))
|
||||||
|
{
|
||||||
|
dictToIncrement[key] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dictToIncrement[key]++;
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddCartridges(Bot botToUpdate, Datum rawParsedBot)
|
public static void AddCartridges(Bot botToUpdate, Datum rawParsedBot)
|
||||||
{
|
{
|
||||||
var cartridgesInRawBot = rawParsedBot.Inventory.items
|
var cartridgesInRawBot = rawParsedBot.Inventory.items
|
||||||
@ -250,5 +279,72 @@ namespace Generator.Helpers.Gear
|
|||||||
|
|
||||||
return itemsThatTakeCartridgesDict;
|
return itemsThatTakeCartridgesDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void ReduceAmmoWeightValues(Bot botToUpdate)
|
||||||
|
{
|
||||||
|
foreach (var caliber in botToUpdate.inventory.Ammo)
|
||||||
|
{
|
||||||
|
foreach (var cartridge in botToUpdate.inventory.Ammo.Keys)
|
||||||
|
{
|
||||||
|
var cartridgeWithWeights = botToUpdate.inventory.Ammo[cartridge];
|
||||||
|
var weights = cartridgeWithWeights.Values.Select(x => x).ToList();
|
||||||
|
var commonAmmoDivisor = CommonDivisor(weights);
|
||||||
|
|
||||||
|
foreach (var cartridgeWeightKvP in cartridgeWithWeights)
|
||||||
|
{
|
||||||
|
botToUpdate.inventory.Ammo[cartridge][cartridgeWeightKvP.Key] /= commonAmmoDivisor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ReduceEquipmentWeightValues(Equipment equipment)
|
||||||
|
{
|
||||||
|
ReduceWeightValues(equipment.Headwear);
|
||||||
|
ReduceWeightValues(equipment.Earpiece);
|
||||||
|
ReduceWeightValues(equipment.FaceCover);
|
||||||
|
ReduceWeightValues(equipment.ArmorVest);
|
||||||
|
ReduceWeightValues(equipment.Eyewear);
|
||||||
|
ReduceWeightValues(equipment.ArmBand);
|
||||||
|
ReduceWeightValues(equipment.TacticalVest);
|
||||||
|
ReduceWeightValues(equipment.Backpack);
|
||||||
|
ReduceWeightValues(equipment.FirstPrimaryWeapon);
|
||||||
|
ReduceWeightValues(equipment.SecondPrimaryWeapon);
|
||||||
|
ReduceWeightValues(equipment.Scabbard);
|
||||||
|
ReduceWeightValues(equipment.Holster);
|
||||||
|
ReduceWeightValues(equipment.Pockets);
|
||||||
|
ReduceWeightValues(equipment.SecuredContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ReduceWeightValues(Dictionary<string, int> equipmentDict)
|
||||||
|
{
|
||||||
|
// No values, nothing to reduce
|
||||||
|
if (equipmentDict.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only one value, quickly set to 1 and exit
|
||||||
|
if (equipmentDict.Count == 1)
|
||||||
|
{
|
||||||
|
equipmentDict[equipmentDict.First().Key] = 1;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var weights = equipmentDict.Values.Select(x => x).ToList();
|
||||||
|
var commonAmmoDivisor = CommonDivisor(weights);
|
||||||
|
|
||||||
|
// No point in dividing by 1
|
||||||
|
if (commonAmmoDivisor == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var itemTplWithWeight in equipmentDict)
|
||||||
|
{
|
||||||
|
equipmentDict[itemTplWithWeight.Key] /= commonAmmoDivisor;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,7 @@ internal static class Program
|
|||||||
"bosszryachiy",
|
"bosszryachiy",
|
||||||
"bossboar",
|
"bossboar",
|
||||||
"bossboarsniper",
|
"bossboarsniper",
|
||||||
|
|
||||||
|
|
||||||
"followerbully",
|
"followerbully",
|
||||||
"followergluharassault",
|
"followergluharassault",
|
||||||
"followergluharscout",
|
"followergluharscout",
|
||||||
@ -38,43 +37,47 @@ internal static class Program
|
|||||||
"followerbigpipe",
|
"followerbigpipe",
|
||||||
"followerzryachiy",
|
"followerzryachiy",
|
||||||
"followerboar",
|
"followerboar",
|
||||||
// //
|
|
||||||
"cursedassault",
|
"cursedassault",
|
||||||
// //
|
|
||||||
"sectantpriest",
|
"sectantpriest",
|
||||||
"sectantwarrior",
|
"sectantwarrior",
|
||||||
"gifter",
|
"gifter",
|
||||||
"arenafighterevent",
|
"arenafighterevent",
|
||||||
"crazyassaultevent"
|
"crazyassaultevent"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read raw bot dumps and turn into c# objects
|
// Read raw bot dumps and turn into c# objects
|
||||||
var workingPath = Directory.GetCurrentDirectory();
|
var workingPath = Directory.GetCurrentDirectory();
|
||||||
var dumpPath = $"{workingPath}//dumps";
|
var dumpPath = $"{workingPath}//dumps";
|
||||||
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>>(40);
|
||||||
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))
|
||||||
|
{
|
||||||
botList.Add(rawBot);
|
botList.Add(rawBot);
|
||||||
else
|
|
||||||
rawBotsCache.Add(rawBot.Info.Settings.Role.ToLower(), new List<Datum> {rawBot});
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Doesnt exist, add key and bot
|
||||||
|
rawBotsCache.Add(rawBot.Info.Settings.Role.ToLower(), new List<Datum> { rawBot });
|
||||||
}
|
}
|
||||||
|
|
||||||
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\\net6.0\\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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the base bot class with basic details (health/body part hp etc) and then append everything else
|
// Generate the base bot class with basic details (health/body part hp etc) and then append everything else
|
||||||
var bots = BaseBotGenerator.GenerateBaseDetails(parsedBots, workingPath, botTypes)
|
var bots = BaseBotGenerator.GenerateBaseDetails(parsedBots, workingPath, botTypes)
|
||||||
.AddGear(rawBotsCache) // Add weapons/armor
|
.AddGear(rawBotsCache) // Add weapons/armor
|
||||||
.AddLoot(rawBotsCache)
|
.AddLoot(rawBotsCache)
|
||||||
.AddChances(rawBotsCache); // Add mod/equipment chances
|
.AddChances(rawBotsCache); // Add mod/equipment chances
|
||||||
|
|
||||||
// Output bot to json file
|
// Output bot to json file
|
||||||
var jsonWriter = new JsonWriter(workingPath, "output");
|
var jsonWriter = new JsonWriter(workingPath, "output");
|
||||||
|
@ -15,8 +15,8 @@ namespace Generator.Weighting
|
|||||||
public class WeightingService
|
public class WeightingService
|
||||||
{
|
{
|
||||||
private readonly Dictionary<BotType, Weightings> _weights;
|
private readonly Dictionary<BotType, Weightings> _weights;
|
||||||
|
|
||||||
private readonly Dictionary<string, Dictionary<string, GenerationWeightData>> _generationWeights;
|
private readonly Dictionary<string, Dictionary<string, GenerationWeightData>> _generationWeights;
|
||||||
|
|
||||||
public WeightingService()
|
public WeightingService()
|
||||||
{
|
{
|
||||||
var assetsPath = $"{Directory.GetCurrentDirectory()}\\Assets";
|
var assetsPath = $"{Directory.GetCurrentDirectory()}\\Assets";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user