From e22af4ef1594848d72794c1f8a0aa34c0e074845 Mon Sep 17 00:00:00 2001 From: CWX Date: Wed, 21 Aug 2024 22:01:38 +0100 Subject: [PATCH] Remove need for Iteration count, should fix being kicked for AFK --- DumpLib/DumpyTool.cs | 157 ++++++++++++++++------------------ DumpLib/Helpers/DataHelper.cs | 1 - 2 files changed, 74 insertions(+), 84 deletions(-) diff --git a/DumpLib/DumpyTool.cs b/DumpLib/DumpyTool.cs index 8ec38a1..94700c4 100644 --- a/DumpLib/DumpyTool.cs +++ b/DumpLib/DumpyTool.cs @@ -16,6 +16,7 @@ namespace DumpLib { return; } + Utils.LogInfo("[Dumpy] Starting Dumpy"); await Task.Factory.StartNew(async delegate @@ -49,94 +50,83 @@ namespace DumpLib { try { - // Although there are now no map iterations, use the iterations to "reset" the afk montior - if (DataHelper.Iteration > 6) + foreach (var map in DataHelper.ConfigSettings.MapNames) { - DataHelper.Iteration = 1; + // Set location in the RaidSettings object + Utils.LogInfo($"[Dumpy] Setting LocalRaidSettings location to: {map}"); + DataHelper.LocalRaidSettings.GetType().GetField("location") + .SetValue(DataHelper.LocalRaidSettings, map); - var controller = DataHelper.MainMenuController.GetValue(DataHelper.TarkovApp); - if (controller != null) - { - controller.GetType().GetMethod("StopAfkMonitor").Invoke(controller, null); - } + // Set location in the RaidConfig object + Utils.LogInfo($"[Dumpy] Setting RaidSettings location to: {map}"); + DataHelper.RaidSettings.GetType().GetProperty("SelectedLocation") + .SetValue(DataHelper.RaidSettings, ReflectionHelper.CheckLocationID(map)); - Utils.LogInfo($"[Dumpy] Restarting Loop in {DataHelper.ConfigSettings.SptTimings.AllIterationDelayMs}ms"); - await Task.Delay(DataHelper.ConfigSettings.SptTimings.AllIterationDelayMs); + // "/client/raid/configuration" + // Call server with new map name in RaidSettings + Utils.LogInfo($"[Dumpy] Sending RaidConfig"); + await (Task)DataHelper.Session.GetType().GetMethod("SendRaidSettings") + .Invoke(DataHelper.Session, new[] { DataHelper.RaidSettings }); + + // Artificial wait to hopefully keep BSG off our toes + Utils.LogInfo("Waiting 10s"); + await Task.Delay(10000); + + // "/client/match/local/start" + // Call server with new map name in LocalRaidSettings + Utils.LogInfo($"[Dumpy] Getting loot for {map}"); + var localRaidSettings = DataHelper.Session.GetType().GetMethod("LocalRaidStarted") + .Invoke(DataHelper.Session, new[] { DataHelper.LocalRaidSettings }); + // Await the task + await (Task)localRaidSettings; + // Get the result + var result = localRaidSettings.GetType().GetProperty("Result").GetValue(localRaidSettings); + // get the string from the result + var result2 = (string)result.GetType().GetField("serverId").GetValue(result); + // set that to our LocalRaidSettings object + DataHelper.LocalRaidSettings.GetType().GetField("serverId").SetValue(DataHelper.LocalRaidSettings, result2); + + // Artificial wait to hopefully keep BSG off our toes + Utils.LogInfo("Waiting 10s"); + await Task.Delay(10000); + + // "/client/game/bot/generate" + // Call server with bot wave data + Utils.LogInfo($"[Dumpy] Getting Bot Data"); + await (Task)DataHelper.Session.GetType().GetMethod("LoadBots") + .Invoke(DataHelper.Session, new[] { DataHelper.WaveSettings }); + + // Artificial wait to hopefully keep BSG off our toes + Utils.LogInfo("Waiting 10s"); + await Task.Delay(10000); + + var emptyArray = ReflectionHelper.CreateGenericMethod(typeof(Array).GetMethod("Empty"), TypeHelper.GetJsonTokenCreateType()) + .Invoke(null, null); + Utils.LogInfo($"[Dumpy] Sending local raid ended"); + await (Task)DataHelper.Session.GetType().GetMethod("LocalRaidEnded") + .Invoke(DataHelper.Session, new object[] + { + DataHelper.LocalRaidSettings, + DataHelper.EndRaidClass, + emptyArray, + Activator.CreateInstance(ReflectionHelper.CreateGenericType(TypeHelper.GetDictionaryType(), typeof(string), + emptyArray.GetType())) + }); + + // after, reset LocalRaidSettings.serverId to null; + DataHelper.LocalRaidSettings.GetType().GetField("serverId").SetValue(DataHelper.LocalRaidSettings, null); + + await Task.Delay(DataHelper.ConfigSettings.SptTimings.SingleIterationDelayMs); } - else + + var controller = DataHelper.MainMenuController.GetValue(DataHelper.TarkovApp); + if (controller != null) { - Utils.LogInfo($"Dumpy iteration number: {DataHelper.Iteration}"); - foreach (var map in DataHelper.ConfigSettings.MapNames) - { - // Set location in the RaidSettings object - Utils.LogInfo($"[Dumpy] Setting LocalRaidSettings location to: {map}"); - DataHelper.LocalRaidSettings.GetType().GetField("location") - .SetValue(DataHelper.LocalRaidSettings, map); - - // Set location in the RaidConfig object - Utils.LogInfo($"[Dumpy] Setting RaidSettings location to: {map}"); - DataHelper.RaidSettings.GetType().GetProperty("SelectedLocation") - .SetValue(DataHelper.RaidSettings, ReflectionHelper.CheckLocationID(map)); - - // "/client/raid/configuration" - // Call server with new map name in RaidSettings - Utils.LogInfo($"[Dumpy] Sending RaidConfig"); - await (Task)DataHelper.Session.GetType().GetMethod("SendRaidSettings") - .Invoke(DataHelper.Session, new[] { DataHelper.RaidSettings }); - - // Artificial wait to hopefully keep BSG off our toes - Utils.LogInfo("Waiting 10s"); - await Task.Delay(10000); - - // "/client/match/local/start" - // Call server with new map name in LocalRaidSettings - Utils.LogInfo($"[Dumpy] Getting loot for {map}"); - var localRaidSettings = DataHelper.Session.GetType().GetMethod("LocalRaidStarted") - .Invoke(DataHelper.Session, new[] { DataHelper.LocalRaidSettings }); - // Await the task - await (Task)localRaidSettings; - // Get the result - var result = localRaidSettings.GetType().GetProperty("Result").GetValue(localRaidSettings); - // get the string from the result - var result2 = (string)result.GetType().GetField("serverId").GetValue(result); - // set that to our LocalRaidSettings object - DataHelper.LocalRaidSettings.GetType().GetField("serverId").SetValue(DataHelper.LocalRaidSettings, result2); - - // Artificial wait to hopefully keep BSG off our toes - Utils.LogInfo("Waiting 10s"); - await Task.Delay(10000); - - // "/client/game/bot/generate" - // Call server with bot wave data - Utils.LogInfo($"[Dumpy] Getting Bot Data"); - await (Task)DataHelper.Session.GetType().GetMethod("LoadBots") - .Invoke(DataHelper.Session, new[] { DataHelper.WaveSettings }); - - // Artificial wait to hopefully keep BSG off our toes - Utils.LogInfo("Waiting 10s"); - await Task.Delay(10000); - - var emptyArray = ReflectionHelper.CreateGenericMethod(typeof(Array).GetMethod("Empty"), TypeHelper.GetJsonTokenCreateType()) - .Invoke(null, null); - Utils.LogInfo($"[Dumpy] Sending local raid ended"); - await (Task)DataHelper.Session.GetType().GetMethod("LocalRaidEnded") - .Invoke(DataHelper.Session, new object[] - { - DataHelper.LocalRaidSettings, - DataHelper.EndRaidClass, - emptyArray, - Activator.CreateInstance(ReflectionHelper.CreateGenericType(TypeHelper.GetDictionaryType(), typeof(string), - emptyArray.GetType())) - }); - - // after, reset LocalRaidSettings.serverId to null; - DataHelper.LocalRaidSettings.GetType().GetField("serverId").SetValue(DataHelper.LocalRaidSettings, null); - - await Task.Delay(DataHelper.ConfigSettings.SptTimings.SingleIterationDelayMs); - } - - DataHelper.Iteration++; + controller.GetType().GetMethod("StopAfkMonitor").Invoke(controller, null); } + + Utils.LogInfo($"[Dumpy] Restarting Loop in {DataHelper.ConfigSettings.SptTimings.AllIterationDelayMs}ms"); + await Task.Delay(DataHelper.ConfigSettings.SptTimings.AllIterationDelayMs); } catch (Exception e) { @@ -208,7 +198,8 @@ namespace DumpLib { if (reqParams != null) { - File.WriteAllText($@"{path}req.{file}\\req.{file}_{time}_{DataHelper.ConfigSettings.Name}.json", JsonConvert.SerializeObject(reqParams)); + File.WriteAllText($@"{path}req.{file}\\req.{file}_{time}_{DataHelper.ConfigSettings.Name}.json", + JsonConvert.SerializeObject(reqParams)); } } diff --git a/DumpLib/Helpers/DataHelper.cs b/DumpLib/Helpers/DataHelper.cs index e8273f2..28d3ab0 100644 --- a/DumpLib/Helpers/DataHelper.cs +++ b/DumpLib/Helpers/DataHelper.cs @@ -22,7 +22,6 @@ public static class DataHelper public static SptConfigClass ConfigSettings = GetSptConfig(); - public static int Iteration = 1; public static bool GotBackend = false; public static object WaveSettings = null; public static object LocalRaidSettings = null;