mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 20:50:44 -05:00
add patches to enable Ref trader in PVE mode
This commit is contained in:
parent
fdc21fe688
commit
7fff0596a8
@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
using System.Reflection.Emit;
|
||||
using SPT.Reflection.CodeWrapper;
|
||||
using SPT.Reflection.Patching;
|
||||
|
||||
namespace SPT.SinglePlayer.Patches.MainMenu
|
||||
{
|
||||
/// <summary>
|
||||
/// All we want to do with this TranspilePatch is to replace the Ref ID they check for to something different
|
||||
/// so this allows the Ref trader to be shown on the TraderScreensGroup
|
||||
/// </summary>
|
||||
public class EnableRefForPVEPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(TraderScreensGroup), nameof(TraderScreensGroup.method_4));
|
||||
}
|
||||
|
||||
[PatchTranspiler]
|
||||
private static IEnumerable<CodeInstruction> PatchTranspile(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var codes = new List<CodeInstruction>(instructions);
|
||||
var searchCode = new CodeInstruction(OpCodes.Ldstr, "6617beeaa9cfa777ca915b7c");
|
||||
var searchIndex = -1;
|
||||
|
||||
for (var i = 0; i < codes.Count; i++)
|
||||
{
|
||||
if (codes[i].opcode == searchCode.opcode && codes[i]?.operand == searchCode?.operand)
|
||||
{
|
||||
searchIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (searchIndex == -1)
|
||||
{
|
||||
Logger.LogError($"{nameof(EnableRefForPVEPatch)} failed: Could not find reference code.");
|
||||
return instructions;
|
||||
}
|
||||
|
||||
// this doesnt have to be anything perticular for the string - just cant be a trader ID
|
||||
var newCode = new CodeInstruction(OpCodes.Ldstr, "SPT-PVE");
|
||||
|
||||
codes.RemoveAt(searchIndex);
|
||||
searchIndex -= 1;
|
||||
codes.Insert(searchIndex, newCode);
|
||||
|
||||
return codes.AsEnumerable();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System.Reflection;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
using SPT.Reflection.Patching;
|
||||
|
||||
namespace SPT.SinglePlayer.Patches.MainMenu
|
||||
{
|
||||
/// <summary>
|
||||
/// Remove BSG's check for Ref as the TraderID so we get Ref on the interm screen
|
||||
/// </summary>
|
||||
public class EnableRefIntermScreenPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(MerchantsList.Class2713), nameof(MerchantsList.Class2713.method_0));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(ref bool __result)
|
||||
{
|
||||
__result = false;
|
||||
return false; // Do not run original method
|
||||
}
|
||||
}
|
||||
}
|
@ -74,6 +74,8 @@ namespace SPT.SinglePlayer
|
||||
new ArmorDamageCounterPatch().Enable();
|
||||
new PVEModeWelcomeMessagePatch().Enable();
|
||||
new DisableMatchmakerPlayerPreviewButtonsPatch().Enable();
|
||||
new EnableRefForPVEPatch().Enable();
|
||||
new EnableRefIntermScreenPatch().Enable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user