0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 06:10:45 -05:00

unified logging

removed code that breaks bot spawns
fixed dogtag error showing when player dies
This commit is contained in:
Dev 2023-07-12 17:36:10 +01:00
parent 0c125bbd10
commit 2c5a2d1c19
3 changed files with 9 additions and 14 deletions

View File

@ -1,6 +1,5 @@
using Aki.Common.Http; using Aki.Common.Http;
using Aki.Reflection.Patching; using Aki.Reflection.Patching;
using Comfort.Common;
using EFT; using EFT;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
@ -56,12 +55,12 @@ namespace Aki.Custom.Patches
var randomType = WeightedRandom(mapSettings.Keys.ToArray(), mapSettings.Values.ToArray()); var randomType = WeightedRandom(mapSettings.Keys.ToArray(), mapSettings.Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType)) 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; ___botOwner_0.Profile.Info.Settings.Role = newAiType;
} }
else 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 // Get weightings for PMCs from server and store in dict
var result = RequestHandler.GetJson($"/singleplayer/settings/bot/getBotBehaviours/"); var result = RequestHandler.GetJson($"/singleplayer/settings/bot/getBotBehaviours/");
botTypeCache = JsonConvert.DeserializeObject<Dictionary<WildSpawnType, Dictionary<string, Dictionary<string, int>>>>(result); botTypeCache = JsonConvert.DeserializeObject<Dictionary<WildSpawnType, Dictionary<string, Dictionary<string, int>>>>(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) 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"; return "assault";
} }
} }

View File

@ -37,9 +37,10 @@ namespace Aki.SinglePlayer.Patches.Quests
var dogtagSlot = equipment.GetSlot(EquipmentSlot.Dogtag); var dogtagSlot = equipment.GetSlot(EquipmentSlot.Dogtag);
var dogtagItem = dogtagSlot.ContainedItem; 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; return;
} }

View File

@ -66,12 +66,6 @@ namespace Aki.SinglePlayer.Patches.RaidFix
then perform request to server and get only first value of resulting single element collection 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 try
{ {
// Force true to ensure bot profile is deleted after use // Force true to ensure bot profile is deleted after use
@ -79,7 +73,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix
} }
catch (Exception e) catch (Exception e)
{ {
Logger.LogDebug($"getnewbot failed: {e.Message} {e.InnerException}"); Logger.LogDebug($"GetNewBotTemplatesPatch() getNewProfile() failed: {e.Message} {e.InnerException}");
throw; throw;
} }