0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.SinglePlayer/Patches/MainMenu/ArmorDamageCounterPatch.cs

33 lines
1.0 KiB
C#
Raw Normal View History

2024-03-21 11:04:53 +00:00
using Aki.Reflection.Patching;
using EFT;
using EFT.InventoryLogic;
using HarmonyLib;
using System;
using System.Reflection;
namespace Aki.SinglePlayer.Patches.MainMenu
2024-03-21 11:04:53 +00:00
{
public class ArmorDamageCounterPatch : ModulePatch
2024-03-21 11:04:53 +00:00
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(Player), nameof(Player.ApplyDamageInfo));
}
[PatchPostfix]
private static void PatchPostfix(DamageInfo damageInfo)
{
if (damageInfo.Player == null || damageInfo.Player.iPlayer == null || !damageInfo.Player.iPlayer.IsYourPlayer)
2024-03-21 11:04:53 +00:00
{
return;
}
if (damageInfo.Weapon is Weapon weapon && weapon.Chambers[0].ContainedItem is BulletClass bullet)
{
float newDamage = (float)Math.Round(bullet.Damage - damageInfo.Damage);
2024-03-21 11:09:00 +00:00
damageInfo.Player.iPlayer.Profile.EftStats.SessionCounters.AddFloat(newDamage, SessionCounterTypesAbstractClass.CauseArmorDamage);
2024-03-21 11:04:53 +00:00
}
}
}
}