From 42d2ac37dd56c4f8970043c2e586bbc99e591ca6 Mon Sep 17 00:00:00 2001 From: Kaeno Date: Fri, 5 Apr 2024 00:43:38 +0100 Subject: [PATCH 1/5] increase the ragdoll limits to hopefully prevent bodys falling into themselves --- project/Aki.Custom/Patches/ClampRagdollPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Aki.Custom/Patches/ClampRagdollPatch.cs b/project/Aki.Custom/Patches/ClampRagdollPatch.cs index 266eb40..2eea7ff 100644 --- a/project/Aki.Custom/Patches/ClampRagdollPatch.cs +++ b/project/Aki.Custom/Patches/ClampRagdollPatch.cs @@ -16,7 +16,7 @@ namespace Aki.Custom.Patches [PatchPrefix] private static void PatchPreFix(ref Vector3 velocity) { - velocity.y = Mathf.Clamp(velocity.y, -1f, 1f); + velocity.y = Mathf.Clamp(velocity.y, -2f, 2f); } } } From 558d5a3f6e2cad88780a5a326711e730a55608d9 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 8 Apr 2024 10:07:11 +0100 Subject: [PATCH 2/5] Added money to non-FiR list for PMCs --- project/Aki.Custom/CustomAI/PmcFoundInRaidEquipment.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/Aki.Custom/CustomAI/PmcFoundInRaidEquipment.cs b/project/Aki.Custom/CustomAI/PmcFoundInRaidEquipment.cs index cdf7df4..9399460 100644 --- a/project/Aki.Custom/CustomAI/PmcFoundInRaidEquipment.cs +++ b/project/Aki.Custom/CustomAI/PmcFoundInRaidEquipment.cs @@ -16,6 +16,7 @@ namespace Aki.Custom.CustomAI private static readonly string throwableItemId = "543be6564bdc2df4348b4568"; private static readonly string ammoItemId = "5485a8684bdc2da71d8b4567"; private static readonly string weaponId = "5422acb9af1c889c16000029"; + private static readonly string moneyId = "543be5dd4bdc2deb348b4569"; private static readonly string armorPlate = "644120aa86ffbe10ee032b6f"; private static readonly string builtInInserts = "65649eb40bf0ed77b8044453"; private static readonly List nonFiRItems = new List() { magazineId, drugId, mediKitItem, medicalItemId, injectorItemId, throwableItemId, ammoItemId, armorPlate, builtInInserts }; @@ -32,7 +33,7 @@ namespace Aki.Custom.CustomAI private static readonly string knifeId = "5447e1d04bdc2dff2f8b4567"; private static readonly List weaponTypeIds = new List() { pistolId, smgId, assaultRifleId, assaultCarbineId, shotgunId, marksmanRifleId, sniperRifleId, machinegunId, grenadeLauncherId, knifeId }; - private static readonly List nonFiRPocketLoot = new List{ throwableItemId, ammoItemId, magazineId, medicalItemId, mediKitItem, injectorItemId, drugId }; + private static readonly List nonFiRPocketLoot = new List{ moneyId, throwableItemId, ammoItemId, magazineId, medicalItemId, mediKitItem, injectorItemId, drugId }; private readonly ManualLogSource logger; public PmcFoundInRaidEquipment(ManualLogSource logger) From 6041bea712fd10f442c9576e902227e54011e7dd Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 11 Apr 2024 16:20:15 +0100 Subject: [PATCH 3/5] made `AddLoot()` `async Task` so it can be awaited --- project/Aki.Custom/Airdrops/Utils/ItemFactoryUtil.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/Aki.Custom/Airdrops/Utils/ItemFactoryUtil.cs b/project/Aki.Custom/Airdrops/Utils/ItemFactoryUtil.cs index 1ea01da..031413f 100644 --- a/project/Aki.Custom/Airdrops/Utils/ItemFactoryUtil.cs +++ b/project/Aki.Custom/Airdrops/Utils/ItemFactoryUtil.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; using System.Collections.Generic; using Aki.Custom.Airdrops.Models; using System.Linq; +using System.Threading.Tasks; namespace Aki.Custom.Airdrops.Utils { @@ -34,7 +35,7 @@ namespace Aki.Custom.Airdrops.Utils } } - public async void AddLoot(LootableContainer container, AirdropLootResultModel lootToAdd) + public async Task AddLoot(LootableContainer container, AirdropLootResultModel lootToAdd) { Item actualItem; foreach (var item in lootToAdd.Loot) From 84cc152e17d68c24d061ff489b7c558e8b65a06d Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Wed, 17 Apr 2024 07:49:49 +0000 Subject: [PATCH 4/5] Exit if the user has deleted the `BepInEx/plugins/spt` folder (!109) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added as a check in the PrePatch, because while users delete `BepInEx/plugins/spt` often, it would be uncommon for them to also delete the prepatcher No idea why there's a second commit in this PR, it doesn't actually change anything. Just Git Things™ Co-authored-by: Terkoiz Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/109 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/Aki.Core/Utils/ValidationUtil.cs | 4 +- project/Aki.PrePatch/AkiBotsPrePatcher.cs | 44 ++++++++++++++++++ project/Aki.PrePatch/MessageBoxHelper.cs | 56 +++++++++++++++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 project/Aki.PrePatch/MessageBoxHelper.cs diff --git a/project/Aki.Core/Utils/ValidationUtil.cs b/project/Aki.Core/Utils/ValidationUtil.cs index ab0b24b..b51dfee 100644 --- a/project/Aki.Core/Utils/ValidationUtil.cs +++ b/project/Aki.Core/Utils/ValidationUtil.cs @@ -16,7 +16,7 @@ namespace Aki.Core.Utils var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("InstallLocation"); var v2 = (v1 != null) ? v1.ToString() : string.Empty; var v3 = new DirectoryInfo(v2); - + var v4 = new FileSystemInfo[] { v3, @@ -55,4 +55,4 @@ namespace Aki.Core.Utils return File.Exists(a) ? new FileInfo(a) : null; } } -} +} \ No newline at end of file diff --git a/project/Aki.PrePatch/AkiBotsPrePatcher.cs b/project/Aki.PrePatch/AkiBotsPrePatcher.cs index d96d32a..2f7b599 100644 --- a/project/Aki.PrePatch/AkiBotsPrePatcher.cs +++ b/project/Aki.PrePatch/AkiBotsPrePatcher.cs @@ -1,4 +1,8 @@ +using System; using System.Collections.Generic; +using System.IO; +using System.Linq; +using BepInEx.Logging; using Mono.Cecil; namespace Aki.PrePatch @@ -10,8 +14,22 @@ namespace Aki.PrePatch public static int sptUsecValue = 47; public static int sptBearValue = 48; + private static string _sptPluginFolder = "plugins/spt"; + public static void Patch(ref AssemblyDefinition assembly) { + // Make sure the user hasn't deleted the SPT plugins folder + string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string sptPluginPath = Path.GetFullPath(Path.Combine(assemblyFolder, "..", _sptPluginFolder)); + if (!ValidateSpt(sptPluginPath)) + { + string message = $"'{sptPluginPath}' or required plugin files not found.\n\n" + + "Please re-install SPT. Exiting."; + MessageBoxHelper.Show(message, "[SPT-AKI] Missing Core Files", MessageBoxHelper.MessageBoxType.OK); + Environment.Exit(0); + return; + } + var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType"); var sptUsec = new FieldDefinition("sptUsec", @@ -27,5 +45,31 @@ namespace Aki.PrePatch botEnums.Fields.Add(sptUsec); botEnums.Fields.Add(sptBear); } + + private static bool ValidateSpt(string sptPluginPath) + { + ManualLogSource logger = Logger.CreateLogSource(nameof(AkiBotsPrePatcher)); + + // Validate that the SPT plugin path exists + if (!Directory.Exists(sptPluginPath)) + { + logger.LogError($"'{sptPluginPath}' directory not found"); + return false; + } + + // Validate that the folder exists, and contains our plugins + string[] sptPlugins = new string[] { "aki-core.dll", "aki-custom.dll", "aki-singleplayer.dll" }; + string[] foundPlugins = Directory.GetFiles(sptPluginPath).Select(x => Path.GetFileName(x)).ToArray(); + + foreach (string plugin in sptPlugins) + { + if (!foundPlugins.Contains(plugin)) + { + return false; + } + } + + return true; + } } } \ No newline at end of file diff --git a/project/Aki.PrePatch/MessageBoxHelper.cs b/project/Aki.PrePatch/MessageBoxHelper.cs new file mode 100644 index 0000000..837880f --- /dev/null +++ b/project/Aki.PrePatch/MessageBoxHelper.cs @@ -0,0 +1,56 @@ +using System; +using System.Runtime.InteropServices; + +namespace Aki.PrePatch +{ + internal class MessageBoxHelper + { + public enum MessageBoxType : uint + { + ABORTRETRYIGNORE = (uint)(0x00000002L | 0x00000010L), + CANCELTRYCONTINUE = (uint)(0x00000006L | 0x00000030L), + HELP = (uint)(0x00004000L | 0x00000040L), + OK = (uint)(0x00000000L | 0x00000040L), + OKCANCEL = (uint)(0x00000001L | 0x00000040L), + RETRYCANCEL = (uint)0x00000005L, + YESNO = (uint)(0x00000004L | 0x00000040L), + YESNOCANCEL = (uint)(0x00000003L | 0x00000040L), + DEFAULT = (uint)(0x00000000L | 0x00000010L) + } + + public enum MessageBoxResult + { + ERROR = -1, + OK = 1, + CANCEL = 2, + ABORT = 3, + RETRY = 4, + IGNORE = 5, + YES = 6, + NO = 7, + TRY_AGAIN = 10 + } + + [DllImport("user32.dll")] + private static extern IntPtr GetActiveWindow(); + [DllImport("user32.dll", SetLastError = true)] + static extern int MessageBox(IntPtr hwnd, String lpText, String lpCaption, uint uType); + + public static IntPtr GetWindowHandle() + { + return GetActiveWindow(); + } + + public static MessageBoxResult Show(string text, string caption, MessageBoxType type = MessageBoxType.DEFAULT) + { + try + { + return (MessageBoxResult)MessageBox(GetWindowHandle(), text, caption, (uint)type); ; + } + catch (Exception) + { + return MessageBoxResult.ERROR; + } + } + } +} From d6845c4337d616cd17d6d2e1eed746c25779b35b Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Mon, 29 Apr 2024 07:00:32 +0000 Subject: [PATCH 5/5] If SPT is started by directly running EscapeFromTarkov.exe, exit (!116) Inform user via messagebox that they need to run Aki.Launcher.exe Refactored a bit of the validation code in Aki.Prepatch Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/116 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- project/Aki.PrePatch/AkiBotsPrePatcher.cs | 57 +++++++++++++++++------ 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/project/Aki.PrePatch/AkiBotsPrePatcher.cs b/project/Aki.PrePatch/AkiBotsPrePatcher.cs index 2f7b599..f2ab1dc 100644 --- a/project/Aki.PrePatch/AkiBotsPrePatcher.cs +++ b/project/Aki.PrePatch/AkiBotsPrePatcher.cs @@ -18,17 +18,7 @@ namespace Aki.PrePatch public static void Patch(ref AssemblyDefinition assembly) { - // Make sure the user hasn't deleted the SPT plugins folder - string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - string sptPluginPath = Path.GetFullPath(Path.Combine(assemblyFolder, "..", _sptPluginFolder)); - if (!ValidateSpt(sptPluginPath)) - { - string message = $"'{sptPluginPath}' or required plugin files not found.\n\n" + - "Please re-install SPT. Exiting."; - MessageBoxHelper.Show(message, "[SPT-AKI] Missing Core Files", MessageBoxHelper.MessageBoxType.OK); - Environment.Exit(0); - return; - } + PerformPreValidation(); var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType"); @@ -46,14 +36,52 @@ namespace Aki.PrePatch botEnums.Fields.Add(sptBear); } - private static bool ValidateSpt(string sptPluginPath) + private static void PerformPreValidation() { + // Check if the launcher was used + bool launcherUsed = ValidateLauncherUse(out string launcherError); + + // Check that all the expected plugins are in the BepInEx/Plugins/spt/ folder + string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string sptPluginPath = Path.GetFullPath(Path.Combine(assemblyFolder, "..", _sptPluginFolder)); + bool pluginsValidated = ValidateSptPlugins(sptPluginPath, out string pluginErrorMessage); + + // If either the launcher wasn't used, or the plugins weren't found, exit + if (!launcherUsed || !pluginsValidated) + { + string errorTitle = (!launcherUsed) ? "Startup Error" : "Missing Core Files"; + string errorMessage = (!launcherUsed) ? launcherError : pluginErrorMessage; + MessageBoxHelper.Show(errorMessage, $"[SPT-AKI] {errorTitle}", MessageBoxHelper.MessageBoxType.OK); + Environment.Exit(0); + return; + } + } + + private static bool ValidateLauncherUse(out string message) + { + // Validate that parameters were passed to EscapeFromTarkov.exe, to verify the + // player used the SPT Launcher to start the process + string[] args = Environment.GetCommandLineArgs(); + if (args.Length > 1) + { + message = ""; + return true; + } + + message = "Please start SPT-AKI using Aki.Launcher.exe. Exiting."; + return false; + } + + private static bool ValidateSptPlugins(string sptPluginPath, out string message) + { + string exitMessage = "\n\nPlease re-install SPT. Exiting."; ManualLogSource logger = Logger.CreateLogSource(nameof(AkiBotsPrePatcher)); // Validate that the SPT plugin path exists if (!Directory.Exists(sptPluginPath)) { - logger.LogError($"'{sptPluginPath}' directory not found"); + message = $"'{sptPluginPath}' directory not found{exitMessage}"; + logger.LogError(message); return false; } @@ -65,10 +93,13 @@ namespace Aki.PrePatch { if (!foundPlugins.Contains(plugin)) { + message = $"Required SPT plugins missing from '{sptPluginPath}'{exitMessage}"; + logger.LogError(message); return false; } } + message = ""; return true; } }