mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:10:44 -05:00
54 lines
2.1 KiB
C#
54 lines
2.1 KiB
C#
using System;
|
|
using SPT.Reflection.Patching;
|
|
using EFT;
|
|
using EFT.Counters;
|
|
using EFT.UI.SessionEnd;
|
|
using System.Reflection;
|
|
using HarmonyLib;
|
|
|
|
namespace SPT.SinglePlayer.Patches.Progression
|
|
{
|
|
/// <summary>
|
|
/// Fix XP gained value being 0 after a scav raid
|
|
/// </summary>
|
|
public class FixPostScavRaidXpShowingZeroPatch : ModulePatch
|
|
{
|
|
/// <summary>
|
|
/// Looking for SessionResultExitStatus Show() (private)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return AccessTools.Method(
|
|
typeof(SessionResultExitStatus),
|
|
nameof(SessionResultExitStatus.Show),
|
|
[typeof(Profile), typeof(PlayerVisualRepresentation), typeof(ESideType), typeof(ExitStatus), typeof(TimeSpan), typeof(ISession), typeof(bool)
|
|
]);
|
|
}
|
|
|
|
// Unused, but left here in case patch breaks and finding the intended method is difficult
|
|
private static bool IsTargetMethod(MethodInfo mi)
|
|
{
|
|
var parameters = mi.GetParameters();
|
|
return (parameters.Length == 7
|
|
&& parameters[0].Name == "activeProfile"
|
|
&& parameters[1].Name == "lastPlayerState"
|
|
&& parameters[2].Name == "side"
|
|
&& parameters[3].Name == "exitStatus"
|
|
&& parameters[4].Name == "raidTime");
|
|
}
|
|
|
|
[PatchPrefix]
|
|
public static bool PatchPrefix(ref Profile activeProfile, ref EPlayerSide side)
|
|
{
|
|
if (activeProfile.Side == EPlayerSide.Savage)
|
|
{
|
|
side = EPlayerSide.Savage; // Also set side to correct value (defaults to USEC/BEAR when playing as scav)
|
|
int xpGainedInSession = activeProfile.Stats.Eft.SessionCounters.GetAllInt(new object[] { CounterTag.Exp });
|
|
activeProfile.Stats.Eft.TotalSessionExperience = (int)(xpGainedInSession * activeProfile.Stats.Eft.SessionExperienceMult * activeProfile.Stats.Eft.ExperienceBonusMult);
|
|
}
|
|
|
|
return true; // Do original method
|
|
}
|
|
}
|
|
} |