0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 01:50:45 -05:00

fixed questing and achievements controller, removed un-needed patches for midraid changes

This commit is contained in:
CWX 2024-07-12 11:17:56 +01:00
parent b1b0c9d151
commit 338a8c015f
4 changed files with 37 additions and 70 deletions

View File

@ -1,25 +0,0 @@
using System.Reflection;
using SPT.Reflection.Patching;
namespace SPT.SinglePlayer.Patches.Progression
{
/// <summary>
/// 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
/// </summary>
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
}
}
}

View File

@ -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
{
/// <summary>
/// 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)
/// </summary>
public class MidRaidQuestChangePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(Profile), nameof(Profile.AddToCarriedQuestItems));
}
[PatchPostfix]
private static void PatchPostfix()
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
Logger.LogDebug("[MidRaidQuestChangePatch] gameWorld instance was null");
return;
}
var player = gameWorld.MainPlayer;
var questController = Traverse.Create(player).Field<AbstractQuestControllerClass>("_questController").Value;
if (questController != null)
{
foreach (var quest in questController.Quests.ToList())
{
quest.CheckForStatusChange(true, true);
}
}
}
}
}

View File

@ -0,0 +1,35 @@
using System.Reflection;
using EFT;
using HarmonyLib;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
namespace SPT.SinglePlayer.Patches.RaidFix
{
/// <summary>
/// this patch aims to allow achievements and quests to activate/change and finish whilst inraid
/// </summary>
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;
}
}
}

View File

@ -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)
{