Generate mod chances into 2 separate dicts

This commit is contained in:
Dev 2024-01-09 15:29:22 +00:00
parent deb307fb6f
commit d54be35ae9
5 changed files with 307 additions and 30 deletions

View File

@ -36,8 +36,12 @@
bossboar = 34,
followerboar = 35,
bossboarsniper = 36,
followerboarclose1 = 37,
followerboarclose2 = 38,
crazyAssaultEvent = 37,
peacefullzryachiyevent = 38,
sectactpriestevent = 39,
ravangezryachiyevent = 40,
followerboarclose1 = 41,
followerboarclose2 = 42,
bosskolontay = 43,
followerkolontayassault = 44,
followerkolontaysecurity = 45,

View File

@ -133,7 +133,8 @@ public class Chances
}
public EquipmentChances equipment { get; set; }
public Dictionary<string, int> mods { get; set; }
public Dictionary<string, int> weaponMods { get; set; }
public Dictionary<string, int> equipmentMods { get; set; }
}
public class EquipmentChances

View File

@ -2179,5 +2179,206 @@
"64b9cf0ac12b9c38db26923a",
"5d3eb5eca4b9363b1f22f8e4"
]
},
"bosssanitar": {
"Backpack": [
"5d02778e86f774203e7dedbe",
"590c657e86f77412b013051d",
"5ed515e03a40a50460332579",
"5ed515f6915ec335206e4152",
"60098ad7c2240c0fe85c570a",
"5e54f6af86f7742199090bf3",
"637b6179104668754b72f8f5",
"544fb3364bdc2d34748b456a",
"5af0548586f7743a532b7e99",
"5eff09cd30a7dc22fd1ddfed",
"5ed515c8d380ab312177c0fa",
"5c10c8fd86f7743d7d706df3",
"5ed5160a87bb8443d10680b5",
"5ed5166ad380ab312177c100",
"5efde6b4f5448336730dbd61",
"5fca138c2a7b221b2852a5c6",
"5755356824597772cb798962",
"5ed515ece452db0eb56fc028",
"5e8488fa988a8701445df1e4",
"5ed51652f6c34d2cc26336a1",
"5751a25924597722c463c472",
"5c0e531286f7747fa54205c2",
"544fb45d4bdc2dee738b4568",
"544fb3f34bdc2d03748b456a",
"5c0e534186f7747fa1419867",
"60098af40accd37ef2175f27",
"544fb25a4bdc2dfb738b4567",
"5c0e531d86f7747fa23f4d42",
"637b612fb7afa97bfc3d7005",
"5c0e530286f7747fa1419862",
"590c661e86f7741e566b646a",
"544fb37f4bdc2dee738b4567",
"5755383e24597772cb798966",
"5e831507ea0a7c419c2f9bd9",
"5fca13ca637ee0341a484f46",
"57347baf24597738002c6178",
"5af0454c86f7746bf20992e8",
"637b620db7afa97bfc3d7009",
"637b6251104668754b72f8f9",
"5c0e533786f7747fa23f4d47",
"590c311186f77424d1667482",
"590c678286f77426c9660122",
"573475fb24597737fb1379e1",
"573476d324597737da2adc13",
"5d1b2ffd86f77425243e8d17",
"5d1b371186f774253763a656",
"590c695186f7741e566b64a2",
"5c06779c86f77426e00dd782",
"62a09ee4cf4a99369e262453",
"5672cb124bdc2d1a0f8b4568",
"56742c2e4bdc2d95058b456d",
"5bc9b9ecd4351e3bac122519",
"6389c6463485cf0eeb260715",
"5d02797c86f774203f38e30a",
"590a358486f77429692b2790",
"60391b0fb847c71012789415",
"5734795124597738002c6176",
"590c595c86f7747884343ad7",
"57347c93245977448d35f6e3",
"61bf7b6302b3924be92fa8c3",
"59e361e886f774176c10a2a5",
"5e2af2bc86f7746d3f3c33fc",
"59e35ef086f7741777737012",
"5d40419286f774318526545f",
"5751a89d24597722aa0e8db0",
"5c06782b86f77426df5407d2",
"57347c77245977448d35f6e2",
"59faf98186f774067b6be103",
"5909e99886f7740c983b9984",
"5e2af00086f7746d3f3c33f7",
"5e2af02c86f7746d420957d4",
"56742c284bdc2d98058b456d",
"5b43575a86f77424f443fe62",
"59faf7ca86f7740dbe19f6c2",
"62a0a098de7ac8199358053b",
"57347c1124597737fb1379e3",
"5d0379a886f77420407aa271",
"59e3556c86f7741776641ac2",
"590c5c9f86f77477c91c36e7",
"5d1b3a5d86f774252167ba22",
"590c346786f77423e50ed342",
"573477e124597737dd42e191",
"5c13cd2486f774072c757944",
"590a3c0a86f774385a33c450",
"5d1c774f86f7746d6620f8db",
"57347c5b245977448d35f6e1",
"573476f124597737e04bf328",
"5d1b317c86f7742523398392",
"5c13cef886f774072e618e82",
"577e1c9d2459773cd707c525",
"5672cb304bdc2dc2088b456a",
"5d6fc78386f77449d825f9dc",
"590c5bbd86f774785762df04",
"5d6fc87386f77449db3db94e",
"57347b8b24597737dd42e192",
"590c2b4386f77425357b6123",
"60391a8b3364dc22b04d0ce5",
"59e35abd86f7741778269d82",
"590a391c86f774385a33c404",
"5e2af4d286f7746d4159f07a",
"5c1265fc86f7743f896a21c2",
"590c2e1186f77425357b6124",
"5d1b3f2d86f774253763b735",
"5733279d245977289b77ec24",
"59e36c6f86f774176c10a2a7",
"590c5a7286f7747884343aea",
"5e2aef7986f7746d3f3c33f5",
"59fafb5d86f774067a6f2084",
"590a3b0486f7743954552bdb",
"637b60c3b7afa97bfc3d7001",
"590a3cd386f77436f20848cb",
"5d1c819a86f774771b0acd6c",
"5d1b392c86f77425243e98fe",
"5734770f24597738025ee254",
"5e2af51086f7746d3f3c3402",
"590c35a486f774273531c822",
"5e2aee0a86f774755a234b62",
"590a386e86f77429692b27ab",
"5af0534a86f7743b6f354284",
"62a08f4c4f842e1bd12d9d62",
"5c1d0d6d86f7744bb2683e1f",
"5c1d0c5f86f7744bb2683cf0",
"5c1e495a86f7743109743dfb",
"5c1d0dc586f7744baf2e7b79",
"5c1d0efb86f7744baf2e7b7b",
"5c1d0f4986f7744bb01837fa",
"5c94bbff86f7747ee735c08f",
"5e42c83786f7742a021fdf3c",
"5e42c81886f7742a01529f57",
"59136a4486f774447a1ed172",
"5780cf7f2459777de4559322",
"5d80c60f86f77440373c4ece",
"5d80c62a86f7744036212b3f",
"5ede7a8229445733cb4c18e2",
"5da743f586f7744014504f72",
"5d8e15b686f774445103b190",
"5a13f24186f77410e57c5626",
"5448ba0b4bdc2d02308b456c",
"5a1452ee86f7746f33111763",
"5a13f35286f77413ef1436b0",
"5a0eec9686f77402ac5c39f2",
"5a13ef7e86f7741290491063",
"5a0ee30786f774023b6ee08f",
"5a0ee76686f7743698200d5c",
"5913877a86f774432f15d444",
"5780d0652459777df90dcb74",
"5d80c88d86f77440556dbf07",
"5ede7b0c6d23e5473e6e8c66",
"5d8e0e0e86f774321140eb56",
"5d80cb3886f77440556dbf09",
"5d95d6fa86f77424484aa5e9",
"5d80cb5686f77440545d1286",
"5d80c6fc86f774403a401e3c",
"5d9f1fa686f774726974a992",
"5d947d3886f774447b415893",
"5e42c71586f7747f245e1343",
"5ad5d7d286f77450166e0a89",
"5addaffe86f77470b455f900",
"5ad5d64486f774079b080af8",
"591afe0186f77431bd616a11",
"5c1e2d1f86f77431e9280bee",
"5c1f79a086f7746ed066fb8f",
"5c1e2a1e86f77431ea0ea84c",
"5a144bdb86f7741d374bbde0",
"5a0ee4b586f7743698200d22",
"5a145d4786f7744cbb6f4a12",
"5a145d7b86f7744cbb6f4a13",
"5a0eecf686f7740350630097",
"5a0eee1486f77402aa773226"
],
"Pockets": [
"57838f9f2459774a150289a0",
"5a17fb03fcdbcbcae668728f",
"5710c24ad2720bc3458b45a3",
"57d1519e24597714373db79d",
"5ed515e03a40a50460332579",
"544fb3f34bdc2d03748b456a",
"5ed5166ad380ab312177c100",
"5d6e68a8a4b9360b6c0d54e2",
"5ed51652f6c34d2cc26336a1",
"5c0e534186f7747fa1419867",
"5c0e533786f7747fa23f4d47",
"5ed515ece452db0eb56fc028",
"5ed515c8d380ab312177c0fa",
"5c0e531d86f7747fa23f4d42",
"5ed5160a87bb8443d10680b5",
"587df583245977373c4f1129",
"637b612fb7afa97bfc3d7005",
"5c0e531286f7747fa54205c2",
"5fca13ca637ee0341a484f46",
"637b6179104668754b72f8f5",
"637b620db7afa97bfc3d7009",
"5c10c8fd86f7743d7d706df3",
"5ed515f6915ec335206e4152",
"5c0e530286f7747fa1419862",
"5fca138c2a7b221b2852a5c6"
],
"TacticalVest": []
}
}

View File

@ -42,6 +42,7 @@ namespace Generator
GearChanceHelpers.CalculateEquipmentChances(botToUpdate, rawBotsOfSameType);
GearChanceHelpers.AddGenerationChances(botToUpdate, weightHelper);
GearChanceHelpers.CalculateModChances(botToUpdate, rawBotsOfSameType);
GearChanceHelpers.CalculateEquipmentModChances(botToUpdate, rawBotsOfSameType);
GearChanceHelpers.ApplyModChanceOverrides(botToUpdate);
GearChanceHelpers.ApplyEquipmentChanceOverrides(botToUpdate);
}));

View File

@ -13,8 +13,83 @@ namespace Generator.Helpers.Gear
public static void CalculateModChances(Bot bot, List<Datum> baseBots)
{
// TODO: Further split these counts by equipment slot? (ex. "FirstPrimaryWeapon", "Holster", etc.)
var validSlots = new List<string> { "FirstPrimaryWeapon", "SecondPrimaryWeapon", "Holster" };
var validSlots = new List<string> { "FirstPrimaryWeapon", "SecondPrimaryWeapon", "Holster", "Headwear", "ArmorVest" };
var modCounts = new Dictionary<string, int>();
var slotCounts = new Dictionary<string, int>();
foreach (var baseBot in baseBots)
{
var validParents = new List<string>();
foreach (var inventoryItem in baseBot.Inventory.items)
{
if (validSlots.Contains(inventoryItem.slotId))
{
validParents.Add(inventoryItem._id);
}
else if (validParents.Contains(inventoryItem.parentId))
{
validParents.Add(inventoryItem._id);
}
else
{
continue;
}
var template = ItemTemplateHelper.GetTemplateById(inventoryItem._tpl);
var parentTemplate = ItemTemplateHelper.GetTemplateById(baseBot.Inventory.items.Single(i => i._id == inventoryItem.parentId)._tpl);
if (!(parentTemplate?._props?.Slots?.FirstOrDefault(slot => slot._name == inventoryItem.slotId)?._required ?? false))
{
if (modCounts.ContainsKey(inventoryItem.slotId.ToLower()))
{
modCounts[inventoryItem.slotId.ToLower()]++;
}
else
{
modCounts.Add(inventoryItem.slotId.ToLower(), 1);
}
}
if ((template?._props?.Slots?.Count ?? 0) < 1)
{
// Item has no slots, nothing to count here
continue;
}
foreach (var slot in template._props.Slots)
{
if (slot._required)
{
continue;
}
if (slot._name.StartsWith("camora"))
{
continue;
}
if (slotCounts.ContainsKey(slot._name.ToLower()))
{
slotCounts[slot._name.ToLower()]++;
}
else
{
slotCounts.Add(slot._name.ToLower(), 1);
}
}
}
}
bot.chances.weaponMods = slotCounts.ToDictionary(
kvp => kvp.Key,
kvp => GetPercent(kvp.Value, modCounts.GetValueOrDefault(kvp.Key)));
}
public static void CalculateEquipmentModChances(Bot bot, List<Datum> baseBots)
{
// TODO: Further split these counts by equipment slot? (ex. "FirstPrimaryWeapon", "Holster", etc.)
var validSlots = new List<string> { "Headwear", "ArmorVest", "TacticalVest" };
var modCounts = new Dictionary<string, int>();
var slotCounts = new Dictionary<string, int>();
@ -61,11 +136,6 @@ namespace Generator.Helpers.Gear
foreach (var slot in template._props.Slots)
{
if (slot._name == "Back_plate")
{
var x = 1;
}
if (slot._required)
{
continue;
@ -88,7 +158,7 @@ namespace Generator.Helpers.Gear
}
}
bot.chances.mods = slotCounts.ToDictionary(
bot.chances.equipmentMods = slotCounts.ToDictionary(
kvp => kvp.Key,
kvp => GetPercent(kvp.Value, modCounts.GetValueOrDefault(kvp.Key)));
}
@ -108,53 +178,53 @@ namespace Generator.Helpers.Gear
switch (botToUpdate.botType)
{
case BotType.bosskojaniy:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.mods["mod_scope"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_scope"] = 100;
break;
case BotType.bosstagilla:
botToUpdate.chances.mods["mod_tactical"] = 100; // force ultima thermal camera
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_tactical"] = 100; // force ultima thermal camera
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.bossbully:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.bosskilla:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.mods["mod_stock_001"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock_001"] = 100;
break;
case BotType.bosssanitar:
botToUpdate.chances.mods["mod_scope"] = 100;
botToUpdate.chances.weaponMods["mod_scope"] = 100;
break;
case BotType.pmcbot:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.followerbully:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.mods["mod_stock_000"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock_000"] = 100;
break;
case BotType.followergluharassault:
case BotType.followergluharscout:
case BotType.followergluharsecurity:
case BotType.followergluharsnipe:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.followerkojaniy:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.sectantpriest:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.sectantwarrior:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.marksman:
botToUpdate.chances.mods["mod_scope"] = 100;
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_scope"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
break;
case BotType.exusec:
botToUpdate.chances.mods["mod_stock"] = 100;
botToUpdate.chances.mods["mod_stock_000"] = 100;
botToUpdate.chances.mods["mod_stock_001"] = 100;
botToUpdate.chances.weaponMods["mod_stock"] = 100;
botToUpdate.chances.weaponMods["mod_stock_000"] = 100;
botToUpdate.chances.weaponMods["mod_stock_001"] = 100;
break;
}