e8dff01c41
less warns when using a disposed socket topstats added to tokens as {{TOPSTATS}} fixed topstats reporting for only a single server added fix to iw4 regex for negative score tokens now support multiple lines (using Environment.NewLine to separate) localization includes culture again
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
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;
|
|
|
|
public int TimesReachedMaxStrain { get; private set; }
|
|
|
|
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;
|
|
CurrentStrain += newStrain;
|
|
|
|
if (CurrentStrain > Thresholds.MaxStrain)
|
|
TimesReachedMaxStrain++;
|
|
|
|
LastAngle = newAngle;
|
|
return CurrentStrain;
|
|
}
|
|
|
|
private double GetDecay(double deltaTime) => Math.Pow(StrainDecayBase, deltaTime / 1000.0);
|
|
}
|
|
} |