From 2c5a2d1c193bb0ae828aa3692fc5a5e3081e6770 Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 12 Jul 2023 17:36:10 +0100 Subject: [PATCH] unified logging removed code that breaks bot spawns fixed dogtag error showing when player dies --- project/Aki.Custom/Patches/CustomAiPatch.cs | 10 +++++----- project/Aki.SinglePlayer/Patches/Quests/DogtagPatch.cs | 5 +++-- .../Patches/RaidFix/GetNewBotTemplatesPatch.cs | 8 +------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/project/Aki.Custom/Patches/CustomAiPatch.cs b/project/Aki.Custom/Patches/CustomAiPatch.cs index 2d52ca7..2a3456a 100644 --- a/project/Aki.Custom/Patches/CustomAiPatch.cs +++ b/project/Aki.Custom/Patches/CustomAiPatch.cs @@ -1,6 +1,5 @@ using Aki.Common.Http; using Aki.Reflection.Patching; -using Comfort.Common; using EFT; using Newtonsoft.Json; using System; @@ -56,12 +55,12 @@ namespace Aki.Custom.Patches var randomType = WeightedRandom(mapSettings.Keys.ToArray(), mapSettings.Values.ToArray()); if (Enum.TryParse(randomType, out WildSpawnType newAiType)) { - Console.WriteLine($"Updated spt bot {___botOwner_0.Profile.Info.Nickname}: {___botOwner_0.Profile.Info.Settings.Role} to use: {newAiType} brain"); + Logger.LogWarning($"Updated spt bot {___botOwner_0.Profile.Info.Nickname}: {___botOwner_0.Profile.Info.Settings.Role} to use: {newAiType} brain"); ___botOwner_0.Profile.Info.Settings.Role = newAiType; } else { - Console.WriteLine($"Couldnt not update spt bot {___botOwner_0.Profile.Info.Nickname} to the new type, random type {randomType} does not exist for WildSpawnType"); + Logger.LogError($"Couldnt not update spt bot {___botOwner_0.Profile.Info.Nickname} to random type {randomType}, does not exist for WildSpawnType enum"); } } } @@ -118,7 +117,7 @@ namespace Aki.Custom.Patches // Get weightings for PMCs from server and store in dict var result = RequestHandler.GetJson($"/singleplayer/settings/bot/getBotBehaviours/"); botTypeCache = JsonConvert.DeserializeObject>>>(result); - Console.WriteLine($"Added {botTypeCache.Count} bots to client cache"); + Logger.LogWarning($"Cached bot.json/pmcType PMC brain weights in client"); } private static string WeightedRandom(string[] botTypes, int[] weights) @@ -141,7 +140,8 @@ namespace Aki.Custom.Patches } } - Console.WriteLine("failed to get random bot weighting, returned assault"); + Logger.LogError("failed to get random bot weighting, returned assault"); + return "assault"; } } diff --git a/project/Aki.SinglePlayer/Patches/Quests/DogtagPatch.cs b/project/Aki.SinglePlayer/Patches/Quests/DogtagPatch.cs index a1fd042..fe05a34 100644 --- a/project/Aki.SinglePlayer/Patches/Quests/DogtagPatch.cs +++ b/project/Aki.SinglePlayer/Patches/Quests/DogtagPatch.cs @@ -37,9 +37,10 @@ namespace Aki.SinglePlayer.Patches.Quests var dogtagSlot = equipment.GetSlot(EquipmentSlot.Dogtag); var dogtagItem = dogtagSlot.ContainedItem; - if (dogtagItem == null) + // no dogtag item + its not on the player + if (dogtagItem == null && !__instance.IsYourPlayer) { - Logger.LogError($"DogtagPatch error > DogTag slot item on {__instance.Profile?.Info?.Nickname} is null somehow."); + Logger.LogError($"DogtagPatch error > DogTag slot item on: {__instance.Profile?.Info?.Nickname} is null somehow."); return; } diff --git a/project/Aki.SinglePlayer/Patches/RaidFix/GetNewBotTemplatesPatch.cs b/project/Aki.SinglePlayer/Patches/RaidFix/GetNewBotTemplatesPatch.cs index 2bb094e..a73bf4e 100644 --- a/project/Aki.SinglePlayer/Patches/RaidFix/GetNewBotTemplatesPatch.cs +++ b/project/Aki.SinglePlayer/Patches/RaidFix/GetNewBotTemplatesPatch.cs @@ -66,12 +66,6 @@ namespace Aki.SinglePlayer.Patches.RaidFix then perform request to server and get only first value of resulting single element collection */ - if (___list_0?.Count > 0) - { - // List of profiles already has data, do original function - return true; // Do original function - } - try { // Force true to ensure bot profile is deleted after use @@ -79,7 +73,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix } catch (Exception e) { - Logger.LogDebug($"getnewbot failed: {e.Message} {e.InnerException}"); + Logger.LogDebug($"GetNewBotTemplatesPatch() getNewProfile() failed: {e.Message} {e.InnerException}"); throw; }