2018-05-03 01:25:49 -04:00
|
|
|
|
using SharedLibraryCore.Helpers;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Plugins.Stats.Cheat
|
|
|
|
|
{
|
|
|
|
|
class Strain
|
|
|
|
|
{
|
|
|
|
|
private static double StrainDecayBase = 0.15;
|
|
|
|
|
private double CurrentStrain;
|
|
|
|
|
private Vector3 LastAngle;
|
|
|
|
|
|
2018-05-05 16:36:26 -04:00
|
|
|
|
public int TimesReachedMaxStrain { get; private set; }
|
|
|
|
|
|
2018-05-03 01:25:49 -04:00
|
|
|
|
public double GetStrain(Vector3 newAngle, double deltaTime)
|
|
|
|
|
{
|
|
|
|
|
if (LastAngle == null)
|
|
|
|
|
LastAngle = newAngle;
|
|
|
|
|
|
|
|
|
|
double decayFactor = GetDecay(deltaTime);
|
|
|
|
|
CurrentStrain *= decayFactor;
|
|
|
|
|
|
|
|
|
|
double[] distance = Helpers.Extensions.AngleStuff(newAngle, LastAngle);
|
|
|
|
|
|
|
|
|
|
// this happens on first kill
|
|
|
|
|
if ((distance[0] == 0 && distance[1] == 0) ||
|
|
|
|
|
deltaTime == 0 ||
|
|
|
|
|
double.IsNaN(CurrentStrain))
|
|
|
|
|
{
|
|
|
|
|
return CurrentStrain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double newStrain = Math.Pow(distance[0] + distance[1], 0.99) / deltaTime;
|
2018-05-05 16:36:26 -04:00
|
|
|
|
CurrentStrain += newStrain;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
2018-05-05 16:36:26 -04:00
|
|
|
|
if (CurrentStrain > Thresholds.MaxStrain)
|
|
|
|
|
TimesReachedMaxStrain++;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
|
|
|
|
LastAngle = newAngle;
|
|
|
|
|
return CurrentStrain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private double GetDecay(double deltaTime) => Math.Pow(StrainDecayBase, deltaTime / 1000.0);
|
|
|
|
|
}
|
|
|
|
|
}
|