From b4c699bd40185488f41f2da907024bc83c395e10 Mon Sep 17 00:00:00 2001 From: Kaeno Date: Thu, 11 Jul 2024 09:12:44 +0100 Subject: [PATCH] Fixes for Raidsettings not applying correctly. (Needs revisitng) Restore InsurancePatch. Remove CultistAmuletRemovalpatch --- .../Patches/CultistAmuletRemovalPatch.cs | 36 ----------------- project/SPT.Custom/SPTCustomPlugin.cs | 1 - .../MainMenu/ApplyRaidSettingsPatch.cs | 33 ++++++++++++++++ .../Patches/MainMenu/InsuranceScreenPatch.cs | 39 +++++++++++++++++++ .../SPT.SinglePlayer/SPTSingleplayerPlugin.cs | 2 + 5 files changed, 74 insertions(+), 37 deletions(-) delete mode 100644 project/SPT.Custom/Patches/CultistAmuletRemovalPatch.cs create mode 100644 project/SPT.SinglePlayer/Patches/MainMenu/ApplyRaidSettingsPatch.cs create mode 100644 project/SPT.SinglePlayer/Patches/MainMenu/InsuranceScreenPatch.cs diff --git a/project/SPT.Custom/Patches/CultistAmuletRemovalPatch.cs b/project/SPT.Custom/Patches/CultistAmuletRemovalPatch.cs deleted file mode 100644 index 1521dc8..0000000 --- a/project/SPT.Custom/Patches/CultistAmuletRemovalPatch.cs +++ /dev/null @@ -1,36 +0,0 @@ -using SPT.Reflection.Patching; -using EFT; -using EFT.InventoryLogic; -using EFT.UI.DragAndDrop; -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace SPT.Custom.Patches -{ - public class CultistAmuletRemovalPatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(CultistEventsClass), nameof(CultistEventsClass.method_4)); - } - - [PatchPostfix] - private static void PatchPostfix(DamageInfo damageInfo, Player victim) - { - var player = damageInfo.Player.iPlayer; - var amulet = player.FindCultistAmulet(); - if (victim.Profile.Info.Settings.Role.IsSectant() && amulet != null) - { - var list = (player.Profile.Inventory.Equipment.GetSlot(EquipmentSlot.Pockets).ContainedItem as SearchableItemClass).Slots; - var amuletslot = list.Single(x => x.ContainedItem == amulet); - amuletslot.RemoveItem(); - } - } - - } -} diff --git a/project/SPT.Custom/SPTCustomPlugin.cs b/project/SPT.Custom/SPTCustomPlugin.cs index 65ccf5c..5075700 100644 --- a/project/SPT.Custom/SPTCustomPlugin.cs +++ b/project/SPT.Custom/SPTCustomPlugin.cs @@ -36,7 +36,6 @@ namespace SPT.Custom new RagfairFeePatch().Enable(); new ScavQuestPatch().Enable(); new ScavItemCheckmarkPatch().Enable(); - new CultistAmuletRemovalPatch().Enable(); new HalloweenExtractPatch().Enable(); // Needed but needs editing diff --git a/project/SPT.SinglePlayer/Patches/MainMenu/ApplyRaidSettingsPatch.cs b/project/SPT.SinglePlayer/Patches/MainMenu/ApplyRaidSettingsPatch.cs new file mode 100644 index 0000000..16215e9 --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/MainMenu/ApplyRaidSettingsPatch.cs @@ -0,0 +1,33 @@ +using EFT; +using EFT.UI; +using EFT.UI.Matchmaker; +using HarmonyLib; +using SPT.Reflection.Patching; +using System.Reflection; + +namespace SPT.SinglePlayer.Patches.MainMenu +{ + public class ApplyRaidSettingsPatch : ModulePatch + { + /// + /// Since Scav is never meant to have the RaidSettingsWindow If you choose scav first and modify options then go to PMC you will remain Scav until you restart the game (Same other way around). + /// This Patch Basically overwrites the original settings so they dont get set back original settings from scav page + /// + /// + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(RaidSettingsWindow), nameof(RaidSettingsWindow.RestoreOriginalOfflineSettings)); + } + + [PatchPrefix] + private static void PatchPrefix(ref RaidSettings ___raidSettings_0, ref RaidSettings ___raidSettings_1) + { + // If Raidsettingswindow is never opened it will soft lock game + if (___raidSettings_0 == null) + { + return; + } + ___raidSettings_1.Apply(___raidSettings_0); + } + } +} diff --git a/project/SPT.SinglePlayer/Patches/MainMenu/InsuranceScreenPatch.cs b/project/SPT.SinglePlayer/Patches/MainMenu/InsuranceScreenPatch.cs new file mode 100644 index 0000000..8b76fdc --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/MainMenu/InsuranceScreenPatch.cs @@ -0,0 +1,39 @@ +using SPT.Reflection.Patching; +using EFT; +using System.Reflection; +using HarmonyLib; + +namespace SPT.SinglePlayer.Patches.MainMenu +{ + /// + /// Force ERaidMode to online to make interface show insurance page + /// + public class InsuranceScreenPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + //[CompilerGenerated] + //private void method_XX() + //{ + // if (this.raidSettings_0.SelectedLocation.Id == "laboratory") + // { + // this.raidSettings_0.WavesSettings.IsBosses = true; + // } + // if (this.raidSettings_0.RaidMode == ERaidMode.Online) + // { + // this.method_40(); + // return; + // } + // this.method_41(); + //} + + return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_76)); + } + + [PatchPrefix] + private static void PrefixPatch(RaidSettings ___raidSettings_0) + { + ___raidSettings_0.RaidMode = ERaidMode.Online; + } + } +} diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index ccc652b..83526c9 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -65,6 +65,8 @@ namespace SPT.SinglePlayer new ScavFoundInRaidPatch().Enable(); new GetProfileAtEndOfRaidPatch().Enable(); new FixSavageInventoryScreenPatch().Enable(); + new InsuranceScreenPatch().Enable(); + new ApplyRaidSettingsPatch().Enable(); } catch (Exception ex) {