2018-11-05 22:01:29 -05:00
|
|
|
|
using IW4MAdmin.Plugins.Stats.Models;
|
2019-05-29 17:55:35 -04:00
|
|
|
|
using SharedLibraryCore.Database.Models;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
using SharedLibraryCore.Helpers;
|
2018-04-08 17:50:58 -04:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2018-04-08 17:50:58 -04:00
|
|
|
|
namespace IW4MAdmin.Plugins.Stats.Cheat
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
class Detection
|
|
|
|
|
{
|
2018-05-11 00:52:20 -04:00
|
|
|
|
public enum DetectionType
|
|
|
|
|
{
|
|
|
|
|
Bone,
|
|
|
|
|
Chest,
|
|
|
|
|
Offset,
|
2019-06-15 18:37:43 -04:00
|
|
|
|
Strain,
|
|
|
|
|
Recoil
|
2018-05-11 00:52:20 -04:00
|
|
|
|
};
|
|
|
|
|
|
2018-06-05 17:31:36 -04:00
|
|
|
|
public ChangeTracking<EFACSnapshot> Tracker { get; private set; }
|
2019-06-24 17:56:47 -04:00
|
|
|
|
public const int MAX_TRACKED_HIT_COUNT = 10;
|
2018-06-05 17:31:36 -04:00
|
|
|
|
|
2019-06-24 17:56:47 -04:00
|
|
|
|
public List<EFClientKill> TrackedHits { get; set; }
|
2018-03-18 22:24:06 -04:00
|
|
|
|
int Kills;
|
2018-05-10 01:34:29 -04:00
|
|
|
|
int HitCount;
|
2019-06-12 11:27:15 -04:00
|
|
|
|
Dictionary<IW4Info.HitLocation, HitInfo> HitLocationCount;
|
2018-05-08 00:58:46 -04:00
|
|
|
|
double AngleDifferenceAverage;
|
2018-03-27 20:27:01 -04:00
|
|
|
|
EFClientStatistics ClientStats;
|
2018-05-05 16:36:26 -04:00
|
|
|
|
long LastOffset;
|
2018-10-06 16:31:05 -04:00
|
|
|
|
IW4Info.WeaponName LastWeapon;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
ILogger Log;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
Strain Strain;
|
2018-08-03 22:11:58 -04:00
|
|
|
|
readonly DateTime ConnectionTime = DateTime.UtcNow;
|
2019-06-15 18:37:43 -04:00
|
|
|
|
private double sessionAverageRecoilAmount;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2019-06-12 11:27:15 -04:00
|
|
|
|
private class HitInfo
|
|
|
|
|
{
|
|
|
|
|
public int Count { get; set; }
|
|
|
|
|
public double Offset { get; set; }
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
public Detection(ILogger log, EFClientStatistics clientStats)
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
Log = log;
|
2019-06-12 11:27:15 -04:00
|
|
|
|
HitLocationCount = new Dictionary<IW4Info.HitLocation, HitInfo>();
|
2018-03-18 22:24:06 -04:00
|
|
|
|
foreach (var loc in Enum.GetValues(typeof(IW4Info.HitLocation)))
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2019-06-12 11:27:15 -04:00
|
|
|
|
HitLocationCount.Add((IW4Info.HitLocation)loc, new HitInfo());
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
ClientStats = clientStats;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
Strain = new Strain();
|
2018-06-05 17:31:36 -04:00
|
|
|
|
Tracker = new ChangeTracking<EFACSnapshot>();
|
2019-06-24 17:56:47 -04:00
|
|
|
|
TrackedHits = new List<EFClientKill>();
|
2018-03-18 22:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Analyze kill and see if performed by a cheater
|
|
|
|
|
/// </summary>
|
2018-10-28 21:47:56 -04:00
|
|
|
|
/// <param name="hit">kill performed by the player</param>
|
2018-03-18 22:24:06 -04:00
|
|
|
|
/// <returns>true if detection reached thresholds, false otherwise</returns>
|
2018-10-28 21:47:56 -04:00
|
|
|
|
public DetectionPenaltyResult ProcessHit(EFClientKill hit, bool isDamage)
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
var results = new List<DetectionPenaltyResult>();
|
|
|
|
|
|
2018-10-28 21:47:56 -04:00
|
|
|
|
if ((hit.DeathType != IW4Info.MeansOfDeath.MOD_PISTOL_BULLET &&
|
|
|
|
|
hit.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET &&
|
|
|
|
|
hit.DeathType != IW4Info.MeansOfDeath.MOD_HEAD_SHOT) ||
|
|
|
|
|
hit.HitLoc == IW4Info.HitLocation.none || hit.TimeOffset - LastOffset < 0 ||
|
2018-10-06 16:31:05 -04:00
|
|
|
|
// hack: prevents false positives
|
2018-10-28 21:47:56 -04:00
|
|
|
|
(LastWeapon != hit.Weapon && (hit.TimeOffset - LastOffset) == 50))
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-03-18 22:24:06 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Any,
|
2018-03-18 22:24:06 -04:00
|
|
|
|
};
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-10-28 21:47:56 -04:00
|
|
|
|
LastWeapon = hit.Weapon;
|
|
|
|
|
|
2019-06-12 11:27:15 -04:00
|
|
|
|
HitLocationCount[hit.HitLoc].Count++;
|
2018-10-28 21:47:56 -04:00
|
|
|
|
HitCount++;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
2019-06-15 18:37:43 -04:00
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
if (!isDamage)
|
|
|
|
|
{
|
|
|
|
|
Kills++;
|
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-05-04 00:22:10 -04:00
|
|
|
|
#region VIEWANGLES
|
2018-10-28 21:47:56 -04:00
|
|
|
|
if (hit.AnglesList.Count >= 2)
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
2018-10-28 21:47:56 -04:00
|
|
|
|
double realAgainstPredict = Vector3.ViewAngleDistance(hit.AnglesList[0], hit.AnglesList[1], hit.ViewAngles);
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
// LIFETIME
|
2018-03-27 20:27:01 -04:00
|
|
|
|
var hitLoc = ClientStats.HitLocations
|
2018-10-28 21:47:56 -04:00
|
|
|
|
.First(hl => hl.Location == hit.HitLoc);
|
2018-05-08 00:58:46 -04:00
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
float previousAverage = hitLoc.HitOffsetAverage;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
double newAverage = (previousAverage * (hitLoc.HitCount - 1) + realAgainstPredict) / hitLoc.HitCount;
|
2018-03-27 20:27:01 -04:00
|
|
|
|
hitLoc.HitOffsetAverage = (float)newAverage;
|
2018-04-11 18:24:21 -04:00
|
|
|
|
|
2019-06-12 11:27:15 -04:00
|
|
|
|
int totalHits = ClientStats.HitLocations.Sum(_hit => _hit.HitCount);
|
|
|
|
|
var weightedLifetimeAverage = ClientStats.HitLocations.Where(_hit => _hit.HitCount > 0)
|
|
|
|
|
.Sum(_hit => _hit.HitOffsetAverage * _hit.HitCount) / totalHits;
|
|
|
|
|
|
|
|
|
|
if (weightedLifetimeAverage > Thresholds.MaxOffset(totalHits) &&
|
2018-05-16 00:57:37 -04:00
|
|
|
|
hitLoc.HitCount > 100)
|
2018-04-11 18:24:21 -04:00
|
|
|
|
{
|
2019-06-12 11:27:15 -04:00
|
|
|
|
Log.WriteDebug("*** Reached Max Lifetime Average for Angle Difference ***");
|
|
|
|
|
Log.WriteDebug($"Lifetime Average = {newAverage}");
|
|
|
|
|
Log.WriteDebug($"Bone = {hitLoc.Location}");
|
|
|
|
|
Log.WriteDebug($"HitCount = {hitLoc.HitCount}");
|
|
|
|
|
Log.WriteDebug($"ID = {hit.AttackerId}");
|
2018-05-10 01:34:29 -04:00
|
|
|
|
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = hitLoc.HitOffsetAverage,
|
|
|
|
|
HitCount = hitLoc.HitCount,
|
2018-05-14 13:55:10 -04:00
|
|
|
|
Type = DetectionType.Offset
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-11 18:24:21 -04:00
|
|
|
|
}
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
// SESSION
|
2019-06-12 11:27:15 -04:00
|
|
|
|
var sessionHitLoc = HitLocationCount[hit.HitLoc];
|
|
|
|
|
sessionHitLoc.Offset = (sessionHitLoc.Offset * (sessionHitLoc.Count - 1) + realAgainstPredict) / sessionHitLoc.Count;
|
|
|
|
|
|
|
|
|
|
int totalSessionHits = HitLocationCount.Sum(_hit => _hit.Value.Count);
|
|
|
|
|
var weightedSessionAverage = HitLocationCount.Where(_hit => _hit.Value.Count > 0)
|
2019-06-13 20:10:08 -04:00
|
|
|
|
.Sum(_hit => _hit.Value.Offset * _hit.Value.Count) / totalSessionHits;
|
2018-05-04 00:22:10 -04:00
|
|
|
|
|
2019-06-24 12:01:34 -04:00
|
|
|
|
AngleDifferenceAverage = weightedSessionAverage;
|
|
|
|
|
|
2019-06-12 11:27:15 -04:00
|
|
|
|
if (weightedSessionAverage > Thresholds.MaxOffset(totalSessionHits) &&
|
2019-06-24 17:56:47 -04:00
|
|
|
|
totalSessionHits >= (Thresholds.MediumSampleMinKills * 2))
|
2018-05-04 00:22:10 -04:00
|
|
|
|
{
|
2019-06-12 11:27:15 -04:00
|
|
|
|
Log.WriteDebug("*** Reached Max Session Average for Angle Difference ***");
|
|
|
|
|
Log.WriteDebug($"Session Average = {weightedSessionAverage}");
|
|
|
|
|
Log.WriteDebug($"HitCount = {HitCount}");
|
|
|
|
|
Log.WriteDebug($"ID = {hit.AttackerId}");
|
2018-05-10 01:34:29 -04:00
|
|
|
|
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-05-04 00:22:10 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
2019-06-12 11:27:15 -04:00
|
|
|
|
Value = weightedSessionAverage,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Offset,
|
|
|
|
|
Location = hitLoc.Location
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-05-04 00:22:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-03 01:25:49 -04:00
|
|
|
|
#if DEBUG
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Log.WriteDebug($"PredictVsReal={realAgainstPredict}");
|
2018-05-03 01:25:49 -04:00
|
|
|
|
#endif
|
|
|
|
|
}
|
2019-06-24 17:56:47 -04:00
|
|
|
|
#endregion
|
|
|
|
|
|
2018-05-20 22:35:56 -04:00
|
|
|
|
|
2019-06-24 17:56:47 -04:00
|
|
|
|
#region STRAIN
|
|
|
|
|
double currentStrain = Strain.GetStrain(hit.Distance / 0.0254, hit.ViewAngles, Math.Max(50, hit.TimeOffset - LastOffset));
|
2018-10-28 21:47:56 -04:00
|
|
|
|
#if DEBUG == true
|
|
|
|
|
Log.WriteDebug($"Current Strain: {currentStrain}");
|
|
|
|
|
#endif
|
|
|
|
|
LastOffset = hit.TimeOffset;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
|
|
|
|
if (currentStrain > ClientStats.MaxStrain)
|
|
|
|
|
{
|
|
|
|
|
ClientStats.MaxStrain = currentStrain;
|
2018-05-05 16:36:26 -04:00
|
|
|
|
}
|
2018-05-04 00:22:10 -04:00
|
|
|
|
|
2018-05-16 00:57:37 -04:00
|
|
|
|
// flag
|
2018-10-28 21:47:56 -04:00
|
|
|
|
if (currentStrain > Thresholds.MaxStrainFlag)
|
2018-05-16 00:57:37 -04:00
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-05-16 00:57:37 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Flag,
|
2018-05-20 22:35:56 -04:00
|
|
|
|
Value = currentStrain,
|
2018-05-16 00:57:37 -04:00
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Strain
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-05-16 00:57:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ban
|
2018-07-05 22:04:34 -04:00
|
|
|
|
if (currentStrain > Thresholds.MaxStrainBan &&
|
2018-10-28 21:47:56 -04:00
|
|
|
|
HitCount >= 5)
|
2018-05-05 16:36:26 -04:00
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-05-04 00:22:10 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
2018-05-20 22:35:56 -04:00
|
|
|
|
Value = currentStrain,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Strain
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region RECOIL
|
|
|
|
|
var hitRecoilAverage = (hit.AnglesList.Sum(_angle => _angle.Z) + hit.ViewAngles.Z) / (hit.AnglesList.Count + 1);
|
|
|
|
|
sessionAverageRecoilAmount = (sessionAverageRecoilAmount * (HitCount - 1) + hitRecoilAverage) / HitCount;
|
|
|
|
|
|
|
|
|
|
var lifeTimeHits = ClientStats.HitLocations.Sum(_loc => _loc.HitCount);
|
|
|
|
|
ClientStats.AverageRecoilOffset = (ClientStats.AverageRecoilOffset * (lifeTimeHits - 1) + hitRecoilAverage) / lifeTimeHits;
|
|
|
|
|
|
2019-06-25 19:01:47 -04:00
|
|
|
|
if (sessionAverageRecoilAmount == 0 && HitCount >= Thresholds.LowSampleMinKills)
|
2019-06-15 18:37:43 -04:00
|
|
|
|
{
|
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
|
|
|
|
Value = sessionAverageRecoilAmount,
|
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Recoil
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-24 19:32:14 -04:00
|
|
|
|
if (ClientStats.AverageRecoilOffset == 0 && HitCount >= Thresholds.HighSampleMinKills)
|
2019-06-15 18:37:43 -04:00
|
|
|
|
{
|
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
|
|
|
|
Value = ClientStats.AverageRecoilOffset,
|
|
|
|
|
HitCount = lifeTimeHits,
|
|
|
|
|
Type = DetectionType.Recoil
|
|
|
|
|
});
|
2018-03-26 00:51:25 -04:00
|
|
|
|
}
|
2018-04-05 00:38:45 -04:00
|
|
|
|
#endregion
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
#region SESSION_RATIOS
|
|
|
|
|
if (Kills >= Thresholds.LowSampleMinKills)
|
|
|
|
|
{
|
2018-05-10 01:34:29 -04:00
|
|
|
|
double marginOfError = Thresholds.GetMarginOfError(HitCount);
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// determine what the max headshot percentage can be for current number of kills
|
2018-05-10 01:34:29 -04:00
|
|
|
|
double lerpAmount = Math.Min(1.0, (HitCount - Thresholds.LowSampleMinKills) / (double)(/*Thresholds.HighSampleMinKills*/ 60 - Thresholds.LowSampleMinKills));
|
2018-04-05 00:38:45 -04:00
|
|
|
|
double maxHeadshotLerpValueForFlag = Thresholds.Lerp(Thresholds.HeadshotRatioThresholdLowSample(2.0), Thresholds.HeadshotRatioThresholdHighSample(2.0), lerpAmount) + marginOfError;
|
2018-06-02 00:48:10 -04:00
|
|
|
|
double maxHeadshotLerpValueForBan = Thresholds.Lerp(Thresholds.HeadshotRatioThresholdLowSample(3.5), Thresholds.HeadshotRatioThresholdHighSample(3.5), lerpAmount) + marginOfError;
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// determine what the max bone percentage can be for current number of kills
|
|
|
|
|
double maxBoneRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.BoneRatioThresholdLowSample(2.25), Thresholds.BoneRatioThresholdHighSample(2.25), lerpAmount) + marginOfError;
|
|
|
|
|
double maxBoneRatioLerpValueForBan = Thresholds.Lerp(Thresholds.BoneRatioThresholdLowSample(3.25), Thresholds.BoneRatioThresholdHighSample(3.25), lerpAmount) + marginOfError;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// calculate headshot ratio
|
2019-06-12 11:27:15 -04:00
|
|
|
|
double currentHeadshotRatio = ((HitLocationCount[IW4Info.HitLocation.head].Count + HitLocationCount[IW4Info.HitLocation.helmet].Count + HitLocationCount[IW4Info.HitLocation.neck].Count) / (double)HitCount);
|
2018-04-09 23:33:42 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// calculate maximum bone
|
2019-06-12 11:27:15 -04:00
|
|
|
|
double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v.Count / (double)HitCount).Max());
|
2019-06-13 20:10:08 -04:00
|
|
|
|
var bone = HitLocationCount.FirstOrDefault(b => b.Value.Count == HitLocationCount.Values.Max(_hit => _hit.Count)).Key;
|
2018-04-09 23:33:42 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
#region HEADSHOT_RATIO
|
|
|
|
|
// flag on headshot
|
|
|
|
|
if (currentHeadshotRatio > maxHeadshotLerpValueForFlag)
|
|
|
|
|
{
|
|
|
|
|
// ban on headshot
|
2018-09-02 23:09:25 -04:00
|
|
|
|
if (currentHeadshotRatio > maxHeadshotLerpValueForBan)
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = currentHeadshotRatio,
|
|
|
|
|
Location = IW4Info.HitLocation.head,
|
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Bone
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-05 00:38:45 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Flag,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = currentHeadshotRatio,
|
|
|
|
|
Location = IW4Info.HitLocation.head,
|
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Bone
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-05 00:38:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2018-03-26 00:51:25 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
#region BONE_RATIO
|
|
|
|
|
// flag on bone ratio
|
|
|
|
|
else if (currentMaxBoneRatio > maxBoneRatioLerpValueForFlag)
|
|
|
|
|
{
|
|
|
|
|
// ban on bone ratio
|
|
|
|
|
if (currentMaxBoneRatio > maxBoneRatioLerpValueForBan)
|
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = currentMaxBoneRatio,
|
|
|
|
|
Location = bone,
|
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Bone
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-05 00:38:45 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Flag,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = currentMaxBoneRatio,
|
|
|
|
|
Location = bone,
|
|
|
|
|
HitCount = HitCount,
|
|
|
|
|
Type = DetectionType.Bone
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-05 00:38:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
#region CHEST_ABDOMEN_RATIO_SESSION
|
2019-06-12 11:27:15 -04:00
|
|
|
|
int chestHits = HitLocationCount[IW4Info.HitLocation.torso_upper].Count;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-05-11 00:52:20 -04:00
|
|
|
|
if (chestHits >= Thresholds.MediumSampleMinKills)
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2018-05-11 00:52:20 -04:00
|
|
|
|
double marginOfError = Thresholds.GetMarginOfError(chestHits);
|
|
|
|
|
double lerpAmount = Math.Min(1.0, (chestHits - Thresholds.MediumSampleMinKills) / (double)(Thresholds.HighSampleMinKills - Thresholds.LowSampleMinKills));
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// determine max acceptable ratio of chest to abdomen kills
|
|
|
|
|
double chestAbdomenRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdLowSample(3), Thresholds.ChestAbdomenRatioThresholdHighSample(3), lerpAmount) + marginOfError;
|
|
|
|
|
double chestAbdomenLerpValueForBan = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdLowSample(4), Thresholds.ChestAbdomenRatioThresholdHighSample(4), lerpAmount) + marginOfError;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2019-06-12 11:27:15 -04:00
|
|
|
|
double currentChestAbdomenRatio = HitLocationCount[IW4Info.HitLocation.torso_upper].Count / (double)HitLocationCount[IW4Info.HitLocation.torso_lower].Count;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag)
|
|
|
|
|
{
|
2018-03-26 00:51:25 -04:00
|
|
|
|
|
2019-06-16 13:19:23 -04:00
|
|
|
|
if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan && chestHits >= Thresholds.MediumSampleMinKills * 2)
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Ban,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = currentChestAbdomenRatio,
|
|
|
|
|
Location = IW4Info.HitLocation.torso_upper,
|
|
|
|
|
Type = DetectionType.Chest,
|
|
|
|
|
HitCount = chestHits
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-05 00:38:45 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-06-15 18:37:43 -04:00
|
|
|
|
results.Add(new DetectionPenaltyResult()
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
2019-05-29 17:55:35 -04:00
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Flag,
|
2018-05-11 00:52:20 -04:00
|
|
|
|
Value = currentChestAbdomenRatio,
|
|
|
|
|
Location = IW4Info.HitLocation.torso_upper,
|
|
|
|
|
Type = DetectionType.Chest,
|
|
|
|
|
HitCount = chestHits
|
2019-06-15 18:37:43 -04:00
|
|
|
|
});
|
2018-04-05 00:38:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
2018-05-20 22:35:56 -04:00
|
|
|
|
|
2018-06-05 17:31:36 -04:00
|
|
|
|
Tracker.OnChange(new EFACSnapshot()
|
2018-05-20 22:35:56 -04:00
|
|
|
|
{
|
2018-10-28 21:47:56 -04:00
|
|
|
|
When = hit.When,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
ClientId = ClientStats.ClientId,
|
|
|
|
|
SessionAngleOffset = AngleDifferenceAverage,
|
2019-06-15 18:37:43 -04:00
|
|
|
|
RecoilOffset = hitRecoilAverage,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
CurrentSessionLength = (int)(DateTime.UtcNow - ConnectionTime).TotalSeconds,
|
|
|
|
|
CurrentStrain = currentStrain,
|
2018-10-28 21:47:56 -04:00
|
|
|
|
CurrentViewAngle = hit.ViewAngles,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
Hits = HitCount,
|
|
|
|
|
Kills = Kills,
|
|
|
|
|
Deaths = ClientStats.SessionDeaths,
|
2018-10-28 21:47:56 -04:00
|
|
|
|
HitDestinationId = hit.DeathOrigin.Vector3Id,
|
|
|
|
|
HitDestination = hit.DeathOrigin,
|
|
|
|
|
HitOriginId = hit.KillOrigin.Vector3Id,
|
|
|
|
|
HitOrigin = hit.KillOrigin,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
EloRating = ClientStats.EloRating,
|
2018-10-28 21:47:56 -04:00
|
|
|
|
HitLocation = hit.HitLoc,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
LastStrainAngle = Strain.LastAngle,
|
2018-10-28 21:47:56 -04:00
|
|
|
|
PredictedViewAngles = hit.AnglesList,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
// this is in "meters"
|
2018-10-28 21:47:56 -04:00
|
|
|
|
Distance = hit.Distance,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
SessionScore = ClientStats.SessionScore,
|
2018-10-28 21:47:56 -04:00
|
|
|
|
HitType = hit.DeathType,
|
2018-06-05 17:31:36 -04:00
|
|
|
|
SessionSPM = ClientStats.SessionSPM,
|
|
|
|
|
StrainAngleBetween = Strain.LastDistance,
|
|
|
|
|
TimeSinceLastEvent = (int)Strain.LastDeltaTime,
|
2018-10-28 21:47:56 -04:00
|
|
|
|
WeaponId = hit.Weapon
|
2018-06-05 17:31:36 -04:00
|
|
|
|
});
|
2018-05-20 22:35:56 -04:00
|
|
|
|
|
2019-06-15 18:37:43 -04:00
|
|
|
|
return results.FirstOrDefault(_result => _result.ClientPenalty == EFPenalty.PenaltyType.Ban) ??
|
|
|
|
|
results.FirstOrDefault(_result => _result.ClientPenalty == EFPenalty.PenaltyType.Flag) ??
|
|
|
|
|
new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = EFPenalty.PenaltyType.Any,
|
|
|
|
|
};
|
2018-03-26 00:51:25 -04:00
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
}
|