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

Revert Loadofflineraidscreenpatch back to its original state. Add patch to allow loading in as a scav.

This commit is contained in:
Kaeno 2024-07-05 22:41:13 +01:00
parent bfff4108f4
commit 00a2a3a984
3 changed files with 55 additions and 3 deletions

View File

@ -0,0 +1,54 @@
using EFT;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Reflection;
namespace SPT.SinglePlayer.Patches.ScavMode
{
internal class EnablePlayerScavPatch : ModulePatch
{
public static ERaidMode storedRaidMode;
public static ESideType storedSide;
public static bool storedOnlineRaidInPVE;
/// <summary>
/// Temporarily trick client into thinking we are PMC and in offline mode to allow loading of scavs in PVE mode
/// </summary>
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_22));
}
[PatchPrefix]
private static void PatchPrefix(ref MainMenuController __instance, ref RaidSettings ___raidSettings_0, ref ISession ___iSession)
{
if (!___raidSettings_0.IsScav)
{
return;
}
// Store old settings to restore them later in postfix
storedRaidMode = ___raidSettings_0.RaidMode;
storedSide = ___raidSettings_0.Side;
storedOnlineRaidInPVE = ___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE;
___raidSettings_0.RaidMode = ERaidMode.Online;
___raidSettings_0.Side = ESideType.Pmc;
___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = false;
}
[PatchPostfix]
private static void PatchPostfix(ref MainMenuController __instance, ref RaidSettings ___raidSettings_0, ref ISession ___iSession)
{
if (!___raidSettings_0.IsScav)
{
return;
}
___raidSettings_0.RaidMode = storedRaidMode;
___raidSettings_0.Side = storedSide;
___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = storedOnlineRaidInPVE;
}
}
}

View File

@ -117,7 +117,6 @@ namespace SPT.SinglePlayer.Patches.ScavMode
// Get fields from MainMenuController.cs
var raidSettings = Traverse.Create(menuController).Field("raidSettings_0").GetValue<RaidSettings>();
raidSettings.RaidMode = ERaidMode.Local;
// Find the private field of type `MatchmakerPlayerControllerClass`
var matchmakerPlayersController = menuController.GetType()
@ -144,8 +143,6 @@ namespace SPT.SinglePlayer.Patches.ScavMode
raidSettings.WavesSettings.IsBosses = true;
}
raidSettings.RaidMode = ERaidMode.Local;
// Set offline raid values
_isLocalField.SetValue(menuController, raidSettings.Local);

View File

@ -76,6 +76,7 @@ namespace SPT.SinglePlayer
new DisableMatchmakerPlayerPreviewButtonsPatch().Enable();
new EnableRefForPVEPatch().Enable();
new EnableRefIntermScreenPatch().Enable();
new EnablePlayerScavPatch().Enable();
}
catch (Exception ex)
{