2023-08-15 12:05:31 +01:00
|
|
|
|
using Common.Extensions;
|
2021-08-31 18:39:30 +01:00
|
|
|
|
using Common.Models;
|
2021-09-18 22:36:59 +01:00
|
|
|
|
using Common.Models.Input;
|
|
|
|
|
using Common.Models.Output;
|
2021-08-24 12:08:30 +01:00
|
|
|
|
using Generator.Helpers;
|
2023-10-31 19:35:32 +00:00
|
|
|
|
using Generator.Helpers.Gear;
|
2021-08-12 16:52:06 +01:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace Generator
|
|
|
|
|
{
|
2021-09-01 19:19:44 +03:00
|
|
|
|
public static class BaseBotGenerator
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
public static void UpdateBaseDetails(Bot botData, Datum rawBotData)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
UpdateBodyPartHealth(botData, rawBotData);
|
|
|
|
|
AddExperience(botData, rawBotData);
|
|
|
|
|
AddStandingForKill(botData, rawBotData);
|
|
|
|
|
AddSkills(botData, rawBotData);
|
|
|
|
|
botData.experience.useSimpleAnimator = rawBotData.Info.Settings.UseSimpleAnimator;
|
|
|
|
|
|
|
|
|
|
AddVisualAppearanceItems(botData, rawBotData);
|
|
|
|
|
AddName(botData, rawBotData);
|
|
|
|
|
AddVoice(botData, rawBotData);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 23:29:50 -08:00
|
|
|
|
private static void AddSkills(Bot botToUpdate, Datum rawBotData)
|
2021-08-17 16:21:27 +01:00
|
|
|
|
{
|
2023-08-15 09:29:16 +00:00
|
|
|
|
// Find the smallest and biggest value for each skill
|
2024-11-03 23:29:50 -08:00
|
|
|
|
foreach (var skill in rawBotData.Skills.Common)
|
2021-08-17 16:21:27 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
if (botToUpdate.skills.Common.TryGetValue(skill.Id, out var existingSkill))
|
2023-08-15 09:29:16 +00:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
existingSkill.min = Math.Min(existingSkill.min, skill.Progress);
|
|
|
|
|
existingSkill.max = Math.Max(existingSkill.max, skill.Progress);
|
2023-08-15 09:29:16 +00:00
|
|
|
|
}
|
2024-11-03 23:29:50 -08:00
|
|
|
|
else
|
2023-08-15 09:29:16 +00:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
botToUpdate.skills.Common.Add(skill.Id, new MinMax(skill.Progress, skill.Progress));
|
2023-08-15 09:29:16 +00:00
|
|
|
|
}
|
2021-08-17 16:21:27 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 23:29:50 -08:00
|
|
|
|
private static void AddStandingForKill(Bot botToUpdate, Datum rawBotData)
|
2021-08-17 16:21:27 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
botToUpdate.experience.standingForKill = rawBotData.Info.Settings.StandingForKill;
|
|
|
|
|
botToUpdate.experience.aggressorBonus = rawBotData.Info.Settings.AggressorBonus;
|
2021-08-17 16:21:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 23:29:50 -08:00
|
|
|
|
private static void AddExperience(Bot botToUpdate, Datum rawBotData)
|
2021-08-17 16:21:27 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
botToUpdate.experience.reward.min = rawBotData.Info.Settings.Experience;
|
|
|
|
|
botToUpdate.experience.reward.max = rawBotData.Info.Settings.Experience;
|
2021-08-17 16:21:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 12:27:17 +01:00
|
|
|
|
private static void AddVoice(Bot bot, Datum rawBot)
|
2021-08-12 21:40:41 +01:00
|
|
|
|
{
|
2024-02-21 17:06:08 +00:00
|
|
|
|
GearHelpers.IncrementDictionaryValue(bot.appearance.voice, rawBot.Info.Voice);
|
2021-08-12 21:40:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 23:29:50 -08:00
|
|
|
|
public static void AddDifficulties(Bot bot)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
string workingPath = Directory.GetCurrentDirectory();
|
2023-08-15 09:29:16 +00:00
|
|
|
|
string botType = bot.botType.ToString();
|
|
|
|
|
var botDifficultyFiles = Directory
|
2021-08-14 09:53:00 +01:00
|
|
|
|
.GetFiles($"{workingPath}//Assets", "*.txt", SearchOption.TopDirectoryOnly)
|
2023-08-15 09:29:16 +00:00
|
|
|
|
.Where(x => x.Contains(botType, StringComparison.InvariantCultureIgnoreCase))
|
2021-08-14 09:53:00 +01:00
|
|
|
|
.ToList();
|
|
|
|
|
|
2023-08-15 09:29:16 +00:00
|
|
|
|
DifficultyHelper.AddDifficultySettings(bot, botDifficultyFiles);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 23:29:50 -08:00
|
|
|
|
private static void UpdateBodyPartHealth(Bot botToUpdate, Datum rawBot)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
var bodyPartHpToAdd = new Common.Models.Output.BodyParts()
|
2021-08-12 22:17:40 +01:00
|
|
|
|
{
|
2024-11-03 23:29:50 -08:00
|
|
|
|
Head = new MinMax(rawBot.Health.BodyParts.Head.Health.Current, rawBot.Health.BodyParts.Head.Health.Maximum),
|
|
|
|
|
Chest = new MinMax(rawBot.Health.BodyParts.Chest.Health.Current, rawBot.Health.BodyParts.Chest.Health.Maximum),
|
|
|
|
|
Stomach = new MinMax(rawBot.Health.BodyParts.Stomach.Health.Current, rawBot.Health.BodyParts.Stomach.Health.Maximum),
|
|
|
|
|
LeftArm = new MinMax(rawBot.Health.BodyParts.LeftArm.Health.Current, rawBot.Health.BodyParts.LeftArm.Health.Maximum),
|
|
|
|
|
RightArm = new MinMax(rawBot.Health.BodyParts.RightArm.Health.Current, rawBot.Health.BodyParts.RightArm.Health.Maximum),
|
|
|
|
|
LeftLeg = new MinMax(rawBot.Health.BodyParts.LeftLeg.Health.Current, rawBot.Health.BodyParts.LeftLeg.Health.Maximum),
|
|
|
|
|
RightLeg = new MinMax(rawBot.Health.BodyParts.RightLeg.Health.Current, rawBot.Health.BodyParts.RightLeg.Health.Maximum)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!botToUpdate.health.BodyParts.Contains(bodyPartHpToAdd))
|
|
|
|
|
{
|
|
|
|
|
botToUpdate.health.BodyParts.Add(bodyPartHpToAdd);
|
2021-08-12 22:17:40 +01:00
|
|
|
|
}
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 19:19:44 +03:00
|
|
|
|
private static void AddVisualAppearanceItems(Bot botToUpdate, Datum rawBot)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2023-10-31 19:35:32 +00:00
|
|
|
|
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.feet, rawBot.Customization.Feet);
|
|
|
|
|
|
|
|
|
|
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.body, rawBot.Customization.Body);
|
|
|
|
|
|
2024-02-21 17:06:08 +00:00
|
|
|
|
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.head, rawBot.Customization.Head);
|
|
|
|
|
|
|
|
|
|
GearHelpers.IncrementDictionaryValue(botToUpdate.appearance.hands, rawBot.Customization.Hands);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 19:19:44 +03:00
|
|
|
|
private static void AddName(Bot botToUpdate, Datum rawBot)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2021-08-13 16:23:00 +01:00
|
|
|
|
var name = rawBot.Info.Nickname.Split();
|
2021-08-12 21:40:41 +01:00
|
|
|
|
botToUpdate.firstName.AddUnique(name[0]);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
if (name.Length > 1)
|
2022-01-07 09:17:41 +00:00
|
|
|
|
{
|
|
|
|
|
// Add lastnames to all bots except raiders
|
2023-08-15 09:29:16 +00:00
|
|
|
|
if (botToUpdate.botType != BotType.pmcbot)
|
|
|
|
|
{
|
|
|
|
|
botToUpdate.lastName.AddUnique(name[1]);
|
|
|
|
|
}
|
2022-01-07 09:17:41 +00:00
|
|
|
|
}
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|