2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2024-04-01 14:03:10 +01:00
|
|
|
|
using EFT.Interactive;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2024-04-01 14:03:10 +01:00
|
|
|
|
{
|
2024-06-28 11:12:51 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// On death some bots have a habit of flying upwards. We have found this occurs when the velocity y and magnitude match
|
|
|
|
|
/// </summary>
|
2024-04-01 14:03:10 +01:00
|
|
|
|
public class ClampRagdollPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return AccessTools.Method(typeof(Corpse), nameof(Corpse.method_16));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
|
|
|
|
private static void PatchPreFix(ref Vector3 velocity)
|
|
|
|
|
{
|
2024-06-28 11:12:51 +01:00
|
|
|
|
if (velocity.magnitude == velocity.y && velocity.y > 5)
|
|
|
|
|
{
|
|
|
|
|
// Probably flying upwards
|
|
|
|
|
velocity.y = 1;
|
|
|
|
|
}
|
2024-04-01 14:03:10 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|