From 5bad769a440c5b23022bd4199992d3990c9e22c6 Mon Sep 17 00:00:00 2001 From: CWX Date: Thu, 11 Jul 2024 21:09:38 +0100 Subject: [PATCH] mid raid achievement patch no longer needed as we assign our own, added patch to fix achievements --- .../MidRaidAchievementChangePatch.cs | 25 ------------------ .../Patches/RaidFix/FixAchievementsPatch.cs | 26 +++++++++++++++++++ .../SPT.SinglePlayer/SPTSingleplayerPlugin.cs | 2 +- 3 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 project/SPT.SinglePlayer/Patches/Progression/MidRaidAchievementChangePatch.cs create mode 100644 project/SPT.SinglePlayer/Patches/RaidFix/FixAchievementsPatch.cs diff --git a/project/SPT.SinglePlayer/Patches/Progression/MidRaidAchievementChangePatch.cs b/project/SPT.SinglePlayer/Patches/Progression/MidRaidAchievementChangePatch.cs deleted file mode 100644 index 2cf0170..0000000 --- a/project/SPT.SinglePlayer/Patches/Progression/MidRaidAchievementChangePatch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Reflection; -using SPT.Reflection.Patching; - -namespace SPT.SinglePlayer.Patches.Progression -{ - /// - /// BSG have disabled notifications for local raids, set updateAchievements in the achievement controller to always be true - /// This enables the achievement notifications and the client to save completed achievement data into profile.Achievements - /// - public class MidRaidAchievementChangePatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return typeof(AchievementControllerClass).GetConstructors()[0]; - } - - [PatchPrefix] - private static bool PatchPrefix(ref bool updateAchievements) - { - updateAchievements = true; - - return true; // Do original method - } - } -} \ No newline at end of file diff --git a/project/SPT.SinglePlayer/Patches/RaidFix/FixAchievementsPatch.cs b/project/SPT.SinglePlayer/Patches/RaidFix/FixAchievementsPatch.cs new file mode 100644 index 0000000..cc96a9c --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/RaidFix/FixAchievementsPatch.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using EFT; +using HarmonyLib; +using SPT.Reflection.Patching; +using SPT.Reflection.Utils; + +namespace SPT.SinglePlayer.Patches.RaidFix +{ + public class FixAchievementsPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(Player), nameof(Player.Init)); + } + + [PatchPostfix] + public static void PatchPostfix(Profile profile, InventoryControllerClass inventoryController, ref AbstractAchievementControllerClass ____achievementsController, ref AbstractQuestControllerClass ____questController) + { + var achievementController = new GClass3233(profile, inventoryController, PatchConstants.BackEndSession, true); + achievementController.Init(); + achievementController.Run(); + + ____achievementsController = achievementController; + } + } +} \ No newline at end of file diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index 468dbd9..7002839 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -58,7 +58,6 @@ namespace SPT.SinglePlayer new MapReadyButtonPatch().Enable(); new LabsKeycardRemovalPatch().Enable(); new ScavLateStartPatch().Enable(); - new MidRaidAchievementChangePatch().Enable(); new GetTraderServicesPatch().Enable(); new PurchaseTraderServicePatch().Enable(); new ScavSellAllPriceStorePatch().Enable(); @@ -69,6 +68,7 @@ namespace SPT.SinglePlayer new ScavRepAdjustmentPatch().Enable(); new AmmoUsedCounterPatch().Enable(); new ArmorDamageCounterPatch().Enable(); + new FixAchievementsPatch().Enable(); } catch (Exception ex) {