0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Custom/Patches/PmcFirstAidPatch.cs

62 lines
2.1 KiB
C#
Raw Normal View History

using SPT.Reflection.Patching;
2024-05-21 19:10:17 +01:00
using SPT.Reflection.Utils;
using EFT;
using System;
using System.Linq;
using System.Reflection;
2024-05-21 19:10:17 +01:00
namespace SPT.Custom.Patches
{
/// <summary>
/// SPT PMC enum value is high enough in wildspawntype it means the first aid class that gets init doesnt have an implementation
/// On heal event, remove all negative effects from limbs e.g. light/heavy bleeds
/// </summary>
public class PmcFirstAidPatch : ModulePatch
{
private static Type _targetType;
private static readonly string methodName = "FirstAidApplied";
public PmcFirstAidPatch()
{
_targetType = PatchConstants.EftTypes.FirstOrDefault(IsTargetType);
}
protected override MethodBase GetTargetMethod()
{
return _targetType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public);
}
/// <summary>
/// GCLass350 for client version 25782
/// </summary>
private bool IsTargetType(Type type)
{
if (type.GetMethod("GetHpPercent") != null && type.GetMethod("TryApplyToCurrentPart") != null)
{
return true;
}
return false;
}
[PatchPrefix]
private static bool PatchPrefix(BotOwner ___botOwner_0)
{
if (___botOwner_0.IsRole((WildSpawnType.pmcUSEC)) || ___botOwner_0.IsRole(WildSpawnType.pmcBEAR))
{
var healthController = ___botOwner_0.GetPlayer.ActiveHealthController;
healthController.RemoveNegativeEffects(EBodyPart.Head);
healthController.RemoveNegativeEffects(EBodyPart.Chest);
healthController.RemoveNegativeEffects(EBodyPart.Stomach);
healthController.RemoveNegativeEffects(EBodyPart.LeftLeg);
healthController.RemoveNegativeEffects(EBodyPart.RightLeg);
healthController.RemoveNegativeEffects(EBodyPart.LeftArm);
healthController.RemoveNegativeEffects(EBodyPart.RightArm);
}
2023-07-27 21:42:46 +01:00
return true; // Do original
}
}
}