0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 03:30:44 -05:00

Fix quest counters triggering while ending the HideoutGame (!78)

When exiting the hideout, the HideoutPlayer class ends up triggering a call in Player that calculates quest counter changes. This causes issues with quests that require not dying

The Player class however wraps these calls in a null check on the QuestController, so we can set it to null before ending the hideout session, and restore it afterwards to skip quest counter calculations

As Hideout Game end only triggers on start of a new raid, and not when you actually close the hideout, I can't think of any reason that quest counters should trigger in this scenario

Resolves: SPT-AKI/Issues#471

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#78
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
DrakiaXYZ 2024-02-10 08:31:18 +00:00 committed by Terkoiz
parent 2e11148618
commit 3853a413f6
2 changed files with 36 additions and 0 deletions

View File

@ -62,6 +62,7 @@ namespace Aki.SinglePlayer
new PurchaseTraderServicePatch().Enable();
new ScavSellAllPriceStorePatch().Enable();
new ScavSellAllRequestPatch().Enable();
new HideoutQuestIgnorePatch().Enable();
}
catch (Exception ex)
{

View File

@ -0,0 +1,35 @@
using Aki.Reflection.Patching;
using EFT;
using HarmonyLib;
using System.Reflection;
namespace Aki.SinglePlayer.Patches.Progression
{
/**
* There is no reason to update quest counters when exiting the hideout, so set the
* player's QuestController to null while calling HideoutPlayer.OnGameSessionEnd to
* avoid the quest controller counters from being triggered
*
* Note: Player.OnGameSessionEnd handles the player's quest controller not being set gracefully
*/
public class HideoutQuestIgnorePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(HideoutPlayer), nameof(HideoutPlayer.OnGameSessionEnd));
}
[PatchPrefix]
private static void PatchPrefix(AbstractQuestControllerClass __state, ref AbstractQuestControllerClass ____questController)
{
__state = ____questController;
____questController = null;
}
[PatchPostfix]
private static void PatchPostfix(AbstractQuestControllerClass __state, ref AbstractQuestControllerClass ____questController)
{
____questController = __state;
}
}
}