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

33 lines
985 B
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.Debugging.Patches.Stats
{
public class ArmorDamagePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(Player), nameof(Player.ApplyDamageInfo));
}
[PatchPostfix]
private static void PatchPostfix(DamageInfo damageInfo)
{
if (!damageInfo.Player.iPlayer.IsYourPlayer)
{
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
}
}
}
}