Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix Raid Exit Status so Missing in Action works" #228

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Source/AkiSupport/SITFixes/DisableEndByTimerPatch.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Source/AkiSupport/Singleplayer/AkiSingleplayerPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Awake()
new GetNewBotTemplatesPatch().Enable();
new DogtagPatch().Enable();
new PostRaidHealingPricePatch().Enable();
//new EndByTimerPatch().Enable();
new EndByTimerPatch().Enable();
new PostRaidHealScreenPatch().Enable();
new LighthouseBridgePatch().Enable();
new LighthouseTransmitterPatch().Enable();
Expand Down
100 changes: 50 additions & 50 deletions Source/AkiSupport/Singleplayer/Patches/Quests/EndByTimerPatch.cs
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
//using EFT;
//using System.Reflection;
//using HarmonyLib;
//using StayInTarkov.Networking;
using EFT;
using System.Reflection;
using HarmonyLib;
using StayInTarkov.Networking;

//namespace StayInTarkov.AkiSupport.Singleplayer.Patches.Quests
//{
// /// <summary>
// /// Credit SPT-Aki team
// /// Link: https://dev.sp-tarkov.com/SPT-AKI/Modules/src/branch/master/project/Aki.SinglePlayer/Patches/Quests/EndByTimerPatch.cs
// /// Modified by: KWJimWails. Converted to use AkiBackendCommunication
// /// Having the raid timer reach zero results in a successful extract,
// /// this patch makes it so letting the time reach zero results in a MIA result
// /// </summary>
// public class EndByTimerPatch : ModulePatch
// {
// protected override MethodBase GetTargetMethod()
// {
// return AccessTools.Method(typeof(BaseLocalGame<GamePlayerOwner>), nameof(BaseLocalGame<GamePlayerOwner>.Stop));
// }
namespace StayInTarkov.AkiSupport.Singleplayer.Patches.Quests
{
/// <summary>
/// Credit SPT-Aki team
/// Link: https://dev.sp-tarkov.com/SPT-AKI/Modules/src/branch/master/project/Aki.SinglePlayer/Patches/Quests/EndByTimerPatch.cs
/// Modified by: KWJimWails. Converted to use AkiBackendCommunication
/// Having the raid timer reach zero results in a successful extract,
/// this patch makes it so letting the time reach zero results in a MIA result
/// </summary>
public class EndByTimerPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BaseLocalGame<GamePlayerOwner>), nameof(BaseLocalGame<GamePlayerOwner>.Stop));
}

// // Unused, but left here in case patch breaks and finding the intended method is difficult
// private static bool IsStopRaidMethod(MethodInfo mi)
// {
// var parameters = mi.GetParameters();
// return (parameters.Length == 4
// && parameters[0].Name == "profileId"
// && parameters[1].Name == "exitStatus"
// && parameters[2].Name == "exitName"
// && parameters[3].Name == "delay"
// && parameters[0].ParameterType == typeof(string)
// && parameters[1].ParameterType == typeof(ExitStatus)
// && parameters[2].ParameterType == typeof(string)
// && parameters[3].ParameterType == typeof(float));
// }
// Unused, but left here in case patch breaks and finding the intended method is difficult
private static bool IsStopRaidMethod(MethodInfo mi)
{
var parameters = mi.GetParameters();
return (parameters.Length == 4
&& parameters[0].Name == "profileId"
&& parameters[1].Name == "exitStatus"
&& parameters[2].Name == "exitName"
&& parameters[3].Name == "delay"
&& parameters[0].ParameterType == typeof(string)
&& parameters[1].ParameterType == typeof(ExitStatus)
&& parameters[2].ParameterType == typeof(string)
&& parameters[3].ParameterType == typeof(float));
}

// [PatchPrefix]
// private static bool PrefixPatch(ref ExitStatus exitStatus, ref string exitName)
// {
// var isParsed = bool.TryParse(AkiBackendCommunication.Instance.GetJson("/singleplayer/settings/raid/endstate"), out bool MIAOnRaidEnd);
// if (isParsed)
// {
// // No extract name and successful, its a MIA
// if (MIAOnRaidEnd && string.IsNullOrEmpty(exitName?.Trim()) && exitStatus == ExitStatus.Survived)
// {
// exitStatus = ExitStatus.MissingInAction;
// exitName = null;
// }
// }
// return true; // Do original
// }
// }
//}
[PatchPrefix]
private static bool PrefixPatch(ref ExitStatus exitStatus, ref string exitName)
{
var isParsed = bool.TryParse(AkiBackendCommunication.Instance.GetJson("/singleplayer/settings/raid/endstate"), out bool MIAOnRaidEnd);
if (isParsed)
{
// No extract name and successful, its a MIA
if (MIAOnRaidEnd && string.IsNullOrEmpty(exitName?.Trim()) && exitStatus == ExitStatus.Survived)
{
exitStatus = ExitStatus.MissingInAction;
exitName = null;
}
}
return true; // Do original
}
}
}
Loading
Loading