2024-07-04 14:11:11 +00:00
|
|
|
|
using SPT.Reflection.Patching;
|
2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Utils;
|
2023-07-27 21:00:26 +01:00
|
|
|
|
using EFT;
|
2023-10-10 10:58:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2023-07-27 21:00:26 +01:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2023-07-27 21:00:26 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2024-07-11 11:18:00 +01:00
|
|
|
|
/// On pmc heal action, remove all negative effects from limbs e.g. light/heavy bleeds
|
|
|
|
|
/// Solves PMCs spending multiple minutes healing every limb
|
2023-07-27 21:00:26 +01:00
|
|
|
|
/// </summary>
|
2024-07-11 11:18:00 +01:00
|
|
|
|
public class PmcTakesAgesToHealLimbsPatch : ModulePatch
|
2023-07-27 21:00:26 +01:00
|
|
|
|
{
|
2023-10-10 10:58:33 +00:00
|
|
|
|
private static Type _targetType;
|
2023-07-27 21:00:26 +01:00
|
|
|
|
private static readonly string methodName = "FirstAidApplied";
|
|
|
|
|
|
2024-07-11 11:18:00 +01:00
|
|
|
|
public PmcTakesAgesToHealLimbsPatch()
|
2023-10-10 10:58:33 +00:00
|
|
|
|
{
|
|
|
|
|
_targetType = PatchConstants.EftTypes.FirstOrDefault(IsTargetType);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 21:00:26 +01:00
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
return _targetType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public);
|
2023-10-10 10:58:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-07-11 11:18:00 +01:00
|
|
|
|
/// BotFirstAidClass
|
2023-10-10 10:58:33 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
private bool IsTargetType(Type type)
|
|
|
|
|
{
|
|
|
|
|
if (type.GetMethod("GetHpPercent") != null && type.GetMethod("TryApplyToCurrentPart") != null)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2023-07-27 21:00:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
|
|
|
|
private static bool PatchPrefix(BotOwner ___botOwner_0)
|
|
|
|
|
{
|
2024-07-09 10:33:42 +01:00
|
|
|
|
if (___botOwner_0.IsRole(WildSpawnType.pmcUSEC) || ___botOwner_0.IsRole(WildSpawnType.pmcBEAR))
|
2023-07-27 21:00:26 +01:00
|
|
|
|
{
|
|
|
|
|
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
|
2023-07-27 21:00:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|