mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Changed the way we count shot ammo. Fixed NRE when player is null when trying to calculate armor damage
This commit is contained in:
parent
c29589768d
commit
a77fc7f036
@ -2,7 +2,6 @@
|
||||
using EFT;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using Comfort.Common;
|
||||
|
||||
namespace Aki.SinglePlayer.Patches.MainMenu
|
||||
{
|
||||
@ -12,20 +11,16 @@ namespace Aki.SinglePlayer.Patches.MainMenu
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
|
||||
return AccessTools.Method(typeof(Player), nameof(Player.OnMakingShot));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
private static void PatchPostfix()
|
||||
private static void PatchPostfix(Player __instance)
|
||||
{
|
||||
player = Singleton<GameWorld>.Instance.MainPlayer;
|
||||
var firearmsController = player.HandsController as Player.FirearmController;
|
||||
firearmsController.OnShot += Hook;
|
||||
}
|
||||
|
||||
private static void Hook()
|
||||
if (__instance.IsYourPlayer)
|
||||
{
|
||||
player.Profile.EftStats.SessionCounters.AddLong(1L, SessionCounterTypesAbstractClass.AmmoUsed);
|
||||
__instance.Profile.EftStats.SessionCounters.AddLong(1L, SessionCounterTypesAbstractClass.AmmoUsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace Aki.SinglePlayer.Patches.MainMenu
|
||||
[PatchPostfix]
|
||||
private static void PatchPostfix(DamageInfo damageInfo)
|
||||
{
|
||||
if (!damageInfo.Player.iPlayer.IsYourPlayer)
|
||||
if (damageInfo.Player == null || damageInfo.Player.iPlayer == null || !damageInfo.Player.iPlayer.IsYourPlayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user