2018-04-08 17:50:58 -04:00
|
|
|
|
using SharedLibraryCore.Helpers;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
|
|
|
|
using IW4MAdmin.Plugins.Stats.Models;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
using System.Text.RegularExpressions;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-08 17:50:58 -04:00
|
|
|
|
namespace IW4MAdmin.Plugins.Stats.Cheat
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
class Detection
|
|
|
|
|
{
|
|
|
|
|
int Kills;
|
|
|
|
|
int AboveThresholdCount;
|
|
|
|
|
double AverageKillTime;
|
|
|
|
|
Dictionary<IW4Info.HitLocation, int> HitLocationCount;
|
2018-03-27 20:27:01 -04:00
|
|
|
|
EFClientStatistics ClientStats;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
DateTime LastKill;
|
|
|
|
|
ILogger Log;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
Strain Strain;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
public Detection(ILogger log, EFClientStatistics clientStats)
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
Log = log;
|
|
|
|
|
HitLocationCount = new Dictionary<IW4Info.HitLocation, int>();
|
|
|
|
|
foreach (var loc in Enum.GetValues(typeof(IW4Info.HitLocation)))
|
|
|
|
|
HitLocationCount.Add((IW4Info.HitLocation)loc, 0);
|
2018-03-27 20:27:01 -04:00
|
|
|
|
ClientStats = clientStats;
|
2018-05-03 01:25:49 -04:00
|
|
|
|
Strain = new Strain();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ProcessDamage(string damageLine)
|
|
|
|
|
{
|
|
|
|
|
string regex = @"^(D);((?:bot[0-9]+)|(?:[A-Z]|[0-9])+);([0-9]+);(axis|allies);(.+);((?:[A-Z]|[0-9])+);([0-9]+);(axis|allies);(.+);((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$";
|
|
|
|
|
|
|
|
|
|
var match = Regex.Match(damageLine, regex, RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
|
|
|
|
var meansOfDeath = ParseEnum<IW4Info.MeansOfDeath>.Get(match.Groups[12].Value, typeof(IW4Info.MeansOfDeath));
|
|
|
|
|
var hitLocation = ParseEnum<IW4Info.HitLocation>.Get(match.Groups[13].Value, typeof(IW4Info.HitLocation));
|
|
|
|
|
|
|
|
|
|
if (meansOfDeath == IW4Info.MeansOfDeath.MOD_PISTOL_BULLET ||
|
|
|
|
|
meansOfDeath == IW4Info.MeansOfDeath.MOD_RIFLE_BULLET ||
|
|
|
|
|
meansOfDeath == IW4Info.MeansOfDeath.MOD_HEAD_SHOT)
|
|
|
|
|
{
|
|
|
|
|
ClientStats.HitLocations.First(hl => hl.Location == hitLocation).HitCount += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Analyze kill and see if performed by a cheater
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="kill">kill performed by the player</param>
|
|
|
|
|
/// <returns>true if detection reached thresholds, false otherwise</returns>
|
|
|
|
|
public DetectionPenaltyResult ProcessKill(EFClientKill kill)
|
|
|
|
|
{
|
|
|
|
|
if ((kill.DeathType != IW4Info.MeansOfDeath.MOD_PISTOL_BULLET &&
|
2018-03-22 14:50:09 -04:00
|
|
|
|
kill.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET &&
|
|
|
|
|
kill.DeathType != IW4Info.MeansOfDeath.MOD_HEAD_SHOT) ||
|
2018-03-18 22:24:06 -04:00
|
|
|
|
kill.HitLoc == IW4Info.HitLocation.none)
|
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Any,
|
|
|
|
|
RatioAmount = 0
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-03 01:25:49 -04:00
|
|
|
|
if (LastKill == DateTime.MinValue)
|
|
|
|
|
LastKill = DateTime.UtcNow;
|
|
|
|
|
|
2018-03-18 22:24:06 -04:00
|
|
|
|
HitLocationCount[kill.HitLoc]++;
|
|
|
|
|
Kills++;
|
|
|
|
|
AverageKillTime = (AverageKillTime + (DateTime.UtcNow - LastKill).TotalSeconds) / Kills;
|
|
|
|
|
|
2018-05-04 00:22:10 -04:00
|
|
|
|
#region VIEWANGLES
|
2018-05-03 01:25:49 -04:00
|
|
|
|
// make sure it's divisible by 2
|
|
|
|
|
if (kill.AnglesList.Count % 2 == 0)
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
2018-05-03 01:25:49 -04:00
|
|
|
|
double maxDistance = 0;
|
|
|
|
|
for (int i = 0; i < kill.AnglesList.Count - 1; i += 1)
|
|
|
|
|
{
|
|
|
|
|
// Log.WriteDebug($"Fixed 1 {kill.AnglesList[i]}");
|
|
|
|
|
// Log.WriteDebug($"Fixed 2 {kill.AnglesList[i + 1]}");
|
|
|
|
|
|
|
|
|
|
// fix max distance
|
|
|
|
|
double currDistance = Vector3.AbsoluteDistance(kill.AnglesList[i], kill.AnglesList[i + 1]);
|
|
|
|
|
//Log.WriteDebug($"Distance {currDistance}");
|
|
|
|
|
if (currDistance > maxDistance)
|
|
|
|
|
{
|
|
|
|
|
maxDistance = currDistance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double realAgainstPredict = Vector3.AbsoluteDistance(kill.ViewAngles, kill.AnglesList[10]);
|
|
|
|
|
|
2018-03-27 20:27:01 -04:00
|
|
|
|
var hitLoc = ClientStats.HitLocations
|
|
|
|
|
.First(hl => hl.Location == kill.HitLoc);
|
|
|
|
|
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
|
|
|
|
|
2018-05-03 01:25:49 -04:00
|
|
|
|
if (maxDistance > hitLoc.MaxAngleDistance)
|
|
|
|
|
hitLoc.MaxAngleDistance = (float)maxDistance;
|
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
if (double.IsNaN(hitLoc.HitOffsetAverage))
|
2018-04-11 18:24:21 -04:00
|
|
|
|
{
|
|
|
|
|
Log.WriteWarning("[Detection::ProcessKill] HitOffsetAvgerage NaN");
|
|
|
|
|
Log.WriteDebug($"{previousAverage}-{hitLoc.HitCount}-{hitLoc}-{newAverage}");
|
|
|
|
|
hitLoc.HitOffsetAverage = 0f;
|
|
|
|
|
}
|
2018-05-03 01:25:49 -04:00
|
|
|
|
|
2018-05-04 00:22:10 -04:00
|
|
|
|
var hitlocations = ClientStats.HitLocations
|
|
|
|
|
.Where(hl => new List<int>() { 4, 5, 2, 3, }.Contains((int)hl.Location))
|
|
|
|
|
.Where(hl => ClientStats.SessionKills > Thresholds.MediumSampleMinKills + 30);
|
|
|
|
|
|
|
|
|
|
double banAverage = hitlocations.Count() > 0 ? hitlocations.Average(c =>c.HitOffsetAverage) : 0;
|
|
|
|
|
|
|
|
|
|
if (banAverage > Thresholds.MaxOffset)
|
|
|
|
|
{
|
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Ban,
|
|
|
|
|
RatioAmount = banAverage,
|
|
|
|
|
KillCount = ClientStats.SessionKills,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-03 01:25:49 -04:00
|
|
|
|
#if DEBUG
|
|
|
|
|
Log.WriteDebug($"MaxDistance={maxDistance}, PredictVsReal={realAgainstPredict}");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentStrain = Strain.GetStrain(kill.ViewAngles, (kill.When - LastKill).TotalMilliseconds);
|
|
|
|
|
|
|
|
|
|
if (currentStrain > ClientStats.MaxStrain)
|
|
|
|
|
{
|
|
|
|
|
ClientStats.MaxStrain = currentStrain;
|
2018-05-04 00:22:10 -04:00
|
|
|
|
|
|
|
|
|
if (ClientStats.MaxStrain > Thresholds.MaxStrain)
|
|
|
|
|
{
|
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Ban,
|
|
|
|
|
RatioAmount = ClientStats.MaxStrain,
|
|
|
|
|
KillCount = ClientStats.SessionKills,
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-03-26 00:51:25 -04:00
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-05-03 01:25:49 -04:00
|
|
|
|
#if DEBUG
|
|
|
|
|
Log.WriteDebug($"Current Strain: {currentStrain}");
|
|
|
|
|
#endif
|
|
|
|
|
LastKill = kill.When;
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
double marginOfError = Thresholds.GetMarginOfError(Kills);
|
|
|
|
|
// determine what the max headshot percentage can be for current number of kills
|
2018-04-28 21:11:13 -04:00
|
|
|
|
double lerpAmount = Math.Min(1.0, (Kills - 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;
|
|
|
|
|
double maxHeadshotLerpValueForBan = Thresholds.Lerp(Thresholds.HeadshotRatioThresholdLowSample(3.0), Thresholds.HeadshotRatioThresholdHighSample(3.0), lerpAmount) + marginOfError;
|
|
|
|
|
// 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
|
2018-04-28 21:11:13 -04:00
|
|
|
|
double currentHeadshotRatio = ((HitLocationCount[IW4Info.HitLocation.head] + HitLocationCount[IW4Info.HitLocation.helmet] + HitLocationCount[IW4Info.HitLocation.neck]) / (double)Kills);
|
2018-04-09 23:33:42 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// calculate maximum bone
|
|
|
|
|
double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v / (double)Kills).Max());
|
|
|
|
|
var bone = HitLocationCount.FirstOrDefault(b => b.Value == HitLocationCount.Values.Max()).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
|
|
|
|
|
if (currentHeadshotRatio > maxHeadshotLerpValueForFlag)
|
|
|
|
|
{
|
|
|
|
|
AboveThresholdCount++;
|
|
|
|
|
Log.WriteDebug("**Maximum Headshot Ratio Reached For Ban**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {kill.AttackerId}");
|
|
|
|
|
Log.WriteDebug($"**Kills: {Kills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentHeadshotRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {maxHeadshotLerpValueForFlag}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var kvp in HitLocationCount)
|
|
|
|
|
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
|
|
|
|
Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Ban,
|
|
|
|
|
RatioAmount = currentHeadshotRatio,
|
|
|
|
|
Bone = IW4Info.HitLocation.head,
|
|
|
|
|
KillCount = Kills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AboveThresholdCount++;
|
|
|
|
|
Log.WriteDebug("**Maximum Headshot Ratio Reached For Flag**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {kill.AttackerId}");
|
|
|
|
|
Log.WriteDebug($"**Kills: {Kills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentHeadshotRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {maxHeadshotLerpValueForFlag}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var kvp in HitLocationCount)
|
|
|
|
|
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
|
|
|
|
Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Flag,
|
|
|
|
|
RatioAmount = currentHeadshotRatio,
|
|
|
|
|
Bone = IW4Info.HitLocation.head,
|
|
|
|
|
KillCount = Kills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#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)
|
|
|
|
|
{
|
|
|
|
|
Log.WriteDebug("**Maximum Bone Ratio Reached For Ban**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {kill.AttackerId}");
|
|
|
|
|
Log.WriteDebug($"**Kills: {Kills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentMaxBoneRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {maxBoneRatioLerpValueForBan}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var kvp in HitLocationCount)
|
|
|
|
|
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Ban,
|
|
|
|
|
RatioAmount = currentMaxBoneRatio,
|
|
|
|
|
Bone = bone,
|
|
|
|
|
KillCount = Kills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log.WriteDebug("**Maximum Bone Ratio Reached For Flag**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {kill.AttackerId}");
|
|
|
|
|
Log.WriteDebug($"**Kills: {Kills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentMaxBoneRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {maxBoneRatioLerpValueForFlag}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var kvp in HitLocationCount)
|
|
|
|
|
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Flag,
|
|
|
|
|
RatioAmount = currentMaxBoneRatio,
|
|
|
|
|
Bone = bone,
|
|
|
|
|
KillCount = Kills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
#region CHEST_ABDOMEN_RATIO_SESSION
|
|
|
|
|
int chestKills = HitLocationCount[IW4Info.HitLocation.torso_upper];
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if (chestKills >= Thresholds.MediumSampleMinKills)
|
|
|
|
|
{
|
|
|
|
|
double marginOfError = Thresholds.GetMarginOfError(chestKills);
|
2018-04-09 23:33:42 -04:00
|
|
|
|
double lerpAmount = Math.Min(1.0, (chestKills - 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
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
double currentChestAbdomenRatio = HitLocationCount[IW4Info.HitLocation.torso_upper] / (double)HitLocationCount[IW4Info.HitLocation.torso_lower];
|
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
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan && chestKills >= Thresholds.MediumSampleMinKills + 30)
|
|
|
|
|
{
|
|
|
|
|
Log.WriteDebug("**Maximum Chest/Abdomen Ratio Reached For Ban**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {kill.AttackerId}");
|
|
|
|
|
Log.WriteDebug($"**Chest Kills: {chestKills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {chestAbdomenLerpValueForBan}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var kvp in HitLocationCount)
|
|
|
|
|
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
|
|
|
|
// Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Ban,
|
|
|
|
|
RatioAmount = currentChestAbdomenRatio,
|
|
|
|
|
Bone = 0,
|
|
|
|
|
KillCount = chestKills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log.WriteDebug("**Maximum Chest/Abdomen Ratio Reached For Flag**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {kill.AttackerId}");
|
|
|
|
|
Log.WriteDebug($"**Chest Kills: {chestKills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {chestAbdomenRatioLerpValueForFlag}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var kvp in HitLocationCount)
|
|
|
|
|
sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
|
|
|
|
// Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Flag,
|
|
|
|
|
RatioAmount = currentChestAbdomenRatio,
|
|
|
|
|
Bone = 0,
|
|
|
|
|
KillCount = chestKills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
2018-03-26 00:51:25 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
2018-03-18 22:24:06 -04:00
|
|
|
|
{
|
2018-04-05 00:38:45 -04:00
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Any,
|
|
|
|
|
RatioAmount = 0
|
2018-03-26 00:51:25 -04:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
public DetectionPenaltyResult ProcessTotalRatio(EFClientStatistics stats)
|
|
|
|
|
{
|
2018-04-13 02:32:30 -04:00
|
|
|
|
int totalChestKills = stats.HitLocations.Single(c => c.Location == IW4Info.HitLocation.torso_upper).HitCount;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-09 23:33:42 -04:00
|
|
|
|
if (totalChestKills >= 60)
|
2018-04-05 00:38:45 -04:00
|
|
|
|
{
|
|
|
|
|
double marginOfError = Thresholds.GetMarginOfError(totalChestKills);
|
2018-04-09 23:33:42 -04:00
|
|
|
|
double lerpAmount = Math.Min(1.0, (totalChestKills - 60) / 250.0);
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// determine max acceptable ratio of chest to abdomen kills
|
2018-04-28 21:11:13 -04:00
|
|
|
|
double chestAbdomenRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), Thresholds.ChestAbdomenRatioThresholdHighSample(2.0), lerpAmount) + marginOfError;
|
|
|
|
|
double chestAbdomenLerpValueForBan = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdHighSample(4.0), Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), lerpAmount) + marginOfError;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
double currentChestAbdomenRatio = totalChestKills /
|
2018-03-28 23:01:09 -04:00
|
|
|
|
stats.HitLocations.Single(hl => hl.Location == IW4Info.HitLocation.torso_lower).HitCount;
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag)
|
|
|
|
|
{
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan)
|
|
|
|
|
{
|
|
|
|
|
Log.WriteDebug("**Maximum Lifetime Chest/Abdomen Ratio Reached For Ban**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {stats.ClientId}");
|
|
|
|
|
Log.WriteDebug($"**Total Chest Kills: {totalChestKills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {chestAbdomenLerpValueForBan}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var location in stats.HitLocations)
|
|
|
|
|
sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
|
|
|
|
// Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
|
2018-03-26 00:51:25 -04:00
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Ban,
|
|
|
|
|
RatioAmount = currentChestAbdomenRatio,
|
|
|
|
|
Bone = IW4Info.HitLocation.torso_upper,
|
|
|
|
|
KillCount = totalChestKills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Log.WriteDebug("**Maximum Lifetime Chest/Abdomen Ratio Reached For Flag**");
|
|
|
|
|
Log.WriteDebug($"ClientId: {stats.ClientId}");
|
|
|
|
|
Log.WriteDebug($"**Total Chest Kills: {totalChestKills}");
|
|
|
|
|
Log.WriteDebug($"**Ratio {currentChestAbdomenRatio}");
|
|
|
|
|
Log.WriteDebug($"**MaxRatio {chestAbdomenRatioLerpValueForFlag}");
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
foreach (var location in stats.HitLocations)
|
|
|
|
|
sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n");
|
|
|
|
|
Log.WriteDebug(sb.ToString());
|
|
|
|
|
// Log.WriteDebug($"ThresholdReached: {AboveThresholdCount}");
|
|
|
|
|
|
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Flag,
|
|
|
|
|
RatioAmount = currentChestAbdomenRatio,
|
|
|
|
|
Bone = IW4Info.HitLocation.torso_upper,
|
|
|
|
|
KillCount = totalChestKills
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-18 22:24:06 -04:00
|
|
|
|
|
|
|
|
|
return new DetectionPenaltyResult()
|
|
|
|
|
{
|
2018-04-05 00:38:45 -04:00
|
|
|
|
Bone = IW4Info.HitLocation.none,
|
|
|
|
|
ClientPenalty = Penalty.PenaltyType.Any
|
2018-03-18 22:24:06 -04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|