ed83c4c011
fix bug with unbanned players still showing as banned via lock icon move player based stuff into client class finally renamed Player to EFClient via partial class don't try to run this build because it's in between stages
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using SharedLibraryCore.Helpers;
|
|
using SharedLibraryCore.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace IW4MAdmin.Plugins.Stats.Cheat
|
|
{
|
|
class Strain
|
|
{
|
|
private const double StrainDecayBase = 0.9;
|
|
private double CurrentStrain;
|
|
public double LastDistance { get; private set; }
|
|
public Vector3 LastAngle { get; private set; }
|
|
public double LastDeltaTime { get; private set; }
|
|
|
|
public double GetStrain(bool isDamage, int damage, double killDistance, Vector3 newAngle, double deltaTime)
|
|
{
|
|
if (LastAngle == null)
|
|
LastAngle = newAngle;
|
|
|
|
LastDeltaTime = deltaTime;
|
|
|
|
double decayFactor = GetDecay(deltaTime);
|
|
CurrentStrain *= decayFactor;
|
|
double[] distance = Helpers.Extensions.AngleStuff(newAngle, LastAngle);
|
|
LastDistance = distance[0] + distance[1];
|
|
|
|
#if DEBUG == true
|
|
Console.WriteLine($"Angle Between = {LastDistance}");
|
|
Console.WriteLine($"Distance From Target = {killDistance}");
|
|
Console.WriteLine($"Time Offset = {deltaTime}");
|
|
Console.WriteLine($"Decay Factor = {decayFactor} ");
|
|
#endif
|
|
// this happens on first kill
|
|
if ((distance[0] == 0 && distance[1] == 0) ||
|
|
deltaTime == 0 ||
|
|
double.IsNaN(CurrentStrain))
|
|
{
|
|
return CurrentStrain;
|
|
}
|
|
|
|
double newStrain = Math.Pow(LastDistance, 0.99) / deltaTime;
|
|
newStrain *= killDistance / 1000.0;
|
|
|
|
CurrentStrain += newStrain;
|
|
|
|
LastAngle = newAngle;
|
|
return CurrentStrain;
|
|
}
|
|
|
|
private double GetDecay(double deltaTime) => Math.Pow(StrainDecayBase, Math.Pow(2.0, deltaTime / 250.0) / 1000.0);
|
|
}
|
|
} |