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

Actually add a patch this time. Removed more redundant patches

This commit is contained in:
Kaeno 2024-07-08 15:44:45 +01:00
parent 7a26e9028a
commit 01631c6060
5 changed files with 39 additions and 113 deletions

View File

@ -1,40 +0,0 @@
using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using System.Reflection;
using HarmonyLib;
namespace SPT.Custom.Patches
{
/// <summary>
/// Fix a bsg bug that causes the game to soft-lock when you have a container opened when extracting
/// </summary>
public class ExitWhileLootingPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BaseLocalGame<EftGamePlayerOwner>), nameof(BaseLocalGame<EftGamePlayerOwner>.Stop));
}
// Look at BaseLocalGame<TPlayerOwner> and find a method named "Stop"
// once you find it, there should be a StartBlackScreenShow method with
// a callback method (on dnspy will be called @class.method_0)
// Go into that method. This will be part of the code:
// if (GClass2505.CheckCurrentScreen(EScreenType.Reconnect))
// {
// GClass2505.CloseAllScreensForced();
// }
// The code INSIDE the if needs to run
[PatchPrefix]
private static bool PatchPrefix(string profileId)
{
var player = Singleton<GameWorld>.Instance.MainPlayer;
if (profileId == player?.Profile.Id)
{
CurrentScreenSingleton.Instance.CloseAllScreensForced();
}
return true;
}
}
}

View File

@ -1,46 +0,0 @@
using SPT.Common.Http;
using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using HarmonyLib;
using Newtonsoft.Json;
using System.Linq;
using System.Reflection;
namespace SPT.Custom.Patches
{
/// <summary>
/// Fixes the map sandbox from only spawning 1 bot at start of game as well as fixing no spawns till all bots are dead.
/// Remove once BSG decides to fix their map
/// </summary>
public class FixBrokenSpawnOnSandboxPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
}
[PatchPrefix]
private static void PatchPrefix()
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
return;
}
var playerLocation = gameWorld.MainPlayer.Location;
if (playerLocation == "Sandbox" || playerLocation == "Sandbox_high")
{
LocationScene.GetAll<BotZone>().ToList().First(zone => zone.name == "ZoneSandbox").MaxPersonsOnPatrol = GetMaxPatrolValueFromServer();
}
}
public static int GetMaxPatrolValueFromServer()
{
string json = RequestHandler.GetJson("/singleplayer/sandbox/maxpatrol");
return JsonConvert.DeserializeObject<int>(json);
}
}
}

View File

@ -23,8 +23,6 @@ namespace SPT.Custom
new EasyBundlePatch().Enable();
// TODO: check if these patches are needed
new QTEPatch().Enable();
new IsEnemyPatch().Enable();
new BotCalledDataTryCallPatch().Enable();
new BotCallForHelpCallBotPatch().Enable();
new BotOwnerDisposePatch().Enable();
@ -32,19 +30,21 @@ namespace SPT.Custom
new AddEnemyToAllGroupsInBotZonePatch().Enable();
new CustomAiPatch().Enable();
new AddTraitorScavsPatch().Enable();
new ExitWhileLootingPatch().Enable();
new PmcFirstAidPatch().Enable();
new SettingsLocationPatch().Enable();
new SetLocationIdOnRaidStartPatch().Enable();
new RagfairFeePatch().Enable();
new ScavQuestPatch().Enable();
new FixBrokenSpawnOnSandboxPatch().Enable();
new ResetTraderServicesPatch().Enable();
new ScavItemCheckmarkPatch().Enable();
new CultistAmuletRemovalPatch().Enable();
new HalloweenExtractPatch().Enable();
// Needed but needs editing
new IsEnemyPatch().Enable();
// Still need
new QTEPatch().Enable();
new FileCachePatch().Enable();
new BotSelfEnemyPatch().Enable();
new DisablePvEPatch().Enable();

View File

@ -5,40 +5,21 @@ using System.Reflection;
namespace SPT.SinglePlayer.Patches.ScavMode
{
internal class EnablePlayerScavPatch : ModulePatch
public 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
/// Change Raid Mode to local and ForceOnlineRaidInPVE to true to allow loading in as a scav
/// </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)
{
// 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)
{
___raidSettings_0.RaidMode = storedRaidMode;
___raidSettings_0.Side = storedSide;
___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = storedOnlineRaidInPVE;
___raidSettings_0.RaidMode = ERaidMode.Local;
___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = true;
}
}
}

View File

@ -0,0 +1,31 @@
using EFT;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Reflection;
namespace SPT.SinglePlayer.Patches.ScavMode
{
public class ScavFoundInRaidPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
}
[PatchPrefix]
private static void PatchPrefix(GameWorld __instance)
{
var player = __instance.MainPlayer;
if (player == null || player.Profile.Side != EPlayerSide.Savage)
{
return;
}
foreach (var item in player.Profile.Inventory.AllRealPlayerItems)
{
item.SpawnedInSession = true;
}
}
}
}