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/Progression/MidRaidQuestChangePatch.cs b/project/SPT.SinglePlayer/Patches/Progression/MidRaidQuestChangePatch.cs deleted file mode 100644 index d84147f..0000000 --- a/project/SPT.SinglePlayer/Patches/Progression/MidRaidQuestChangePatch.cs +++ /dev/null @@ -1,42 +0,0 @@ -using SPT.Reflection.Patching; -using Comfort.Common; -using EFT; -using HarmonyLib; -using System.Linq; -using System.Reflection; - -namespace SPT.SinglePlayer.Patches.Progression -{ - /// - /// After picking up a quest item, trigger CheckForStatusChange() from the questController to fully update a quest sub-tasks to show (e.g. `survive and extract item from raid` task) - /// - public class MidRaidQuestChangePatch : ModulePatch - { - protected override MethodBase GetTargetMethod() - { - return AccessTools.Method(typeof(Profile), nameof(Profile.AddToCarriedQuestItems)); - } - - [PatchPostfix] - private static void PatchPostfix() - { - var gameWorld = Singleton.Instance; - if (gameWorld == null) - { - Logger.LogDebug("[MidRaidQuestChangePatch] gameWorld instance was null"); - - return; - } - - var player = gameWorld.MainPlayer; - var questController = Traverse.Create(player).Field("_questController").Value; - if (questController != null) - { - foreach (var quest in questController.Quests.ToList()) - { - quest.CheckForStatusChange(true, true); - } - } - } - } -} \ No newline at end of file diff --git a/project/SPT.SinglePlayer/Patches/RaidFix/FixQuestAchieveControllersPatch.cs b/project/SPT.SinglePlayer/Patches/RaidFix/FixQuestAchieveControllersPatch.cs new file mode 100644 index 0000000..d5a3785 --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/RaidFix/FixQuestAchieveControllersPatch.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using EFT; +using HarmonyLib; +using SPT.Reflection.Patching; +using SPT.Reflection.Utils; + +namespace SPT.SinglePlayer.Patches.RaidFix +{ + /// + /// this patch aims to allow achievements and quests to activate/change and finish whilst inraid + /// + public class FixQuestAchieveControllersPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(Player), nameof(Player.Init)); + } + + [PatchPostfix] + public static void PatchPostfix(Profile profile, InventoryControllerClass inventoryController, ref AbstractQuestControllerClass ____questController, ref AbstractAchievementControllerClass ____achievementsController) + { + var questController = new LocalQuestControllerClass(profile, inventoryController, PatchConstants.BackEndSession, true); + questController.Init(); + questController.Run(); + + var achievementController = + new AchievementControllerClass(profile, inventoryController, PatchConstants.BackEndSession, true); + achievementController.Init(); + achievementController.Run(); + + ____questController = questController; + ____achievementsController = achievementController; + } + } +} \ No newline at end of file diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index 83526c9..cf31a69 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -20,8 +20,7 @@ namespace SPT.SinglePlayer try { // TODO: check if these patches are needed - new MidRaidQuestChangePatch().Enable(); - new MidRaidAchievementChangePatch().Enable(); + new InRaidQuestAvailablePatch().Enable(); new TinnitusFixPatch().Enable(); new SmokeGrenadeFuseSoundFixPatch().Enable(); new EmptyInfilFixPatch().Enable(); @@ -30,7 +29,6 @@ namespace SPT.SinglePlayer new PlayerPatch().Enable(); new MaxBotPatch().Enable(); new PostRaidHealingPricePatch().Enable(); - new InRaidQuestAvailablePatch().Enable(); new ExfilPointManagerPatch().Enable(); new HideoutQuestIgnorePatch().Enable(); new SpawnProcessNegativeValuePatch().Enable(); @@ -67,6 +65,7 @@ namespace SPT.SinglePlayer new FixSavageInventoryScreenPatch().Enable(); new InsuranceScreenPatch().Enable(); new ApplyRaidSettingsPatch().Enable(); + new FixQuestAchieveControllersPatch().Enable(); } catch (Exception ex) {