don't count bots on master list

don't save every ac snapshot oops..
This commit is contained in:
RaidMax 2019-06-16 12:19:23 -05:00
parent 495197c19d
commit e669d0be82
3 changed files with 20 additions and 14 deletions

View File

@ -371,7 +371,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag) if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag)
{ {
if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan && chestHits >= Thresholds.MediumSampleMinKills + 30) if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan && chestHits >= Thresholds.MediumSampleMinKills * 2)
{ {
//Log.WriteDebug("**Maximum Chest/Abdomen Ratio Reached For Ban**"); //Log.WriteDebug("**Maximum Chest/Abdomen Ratio Reached For Ban**");
//Log.WriteDebug($"ClientId: {hit.AttackerId}"); //Log.WriteDebug($"ClientId: {hit.AttackerId}");
@ -459,8 +459,9 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
public DetectionPenaltyResult ProcessTotalRatio(EFClientStatistics stats) public DetectionPenaltyResult ProcessTotalRatio(EFClientStatistics stats)
{ {
int totalChestHits = stats.HitLocations.Single(c => c.Location == IW4Info.HitLocation.torso_upper).HitCount; int totalChestHits = stats.HitLocations.Single(c => c.Location == IW4Info.HitLocation.torso_upper).HitCount;
var results = new List<DetectionPenaltyResult>();
if (totalChestHits >= 60) if (totalChestHits >= Thresholds.MediumSampleMinKills * 2)
{ {
double marginOfError = Thresholds.GetMarginOfError(totalChestHits); double marginOfError = Thresholds.GetMarginOfError(totalChestHits);
double lerpAmount = Math.Min(1.0, (totalChestHits - 60) / 250.0); double lerpAmount = Math.Min(1.0, (totalChestHits - 60) / 250.0);
@ -486,14 +487,14 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
// sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n"); // sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n");
//Log.WriteDebug(sb.ToString()); //Log.WriteDebug(sb.ToString());
return new DetectionPenaltyResult() results.Add(new DetectionPenaltyResult()
{ {
ClientPenalty = EFPenalty.PenaltyType.Ban, ClientPenalty = EFPenalty.PenaltyType.Ban,
Value = currentChestAbdomenRatio, Value = currentChestAbdomenRatio,
Location = IW4Info.HitLocation.torso_upper, Location = IW4Info.HitLocation.torso_upper,
HitCount = totalChestHits, HitCount = totalChestHits,
Type = DetectionType.Chest Type = DetectionType.Chest
}; });
} }
else else
{ {
@ -507,22 +508,24 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
// sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n"); // sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n");
//Log.WriteDebug(sb.ToString()); //Log.WriteDebug(sb.ToString());
return new DetectionPenaltyResult() results.Add(new DetectionPenaltyResult()
{ {
ClientPenalty = EFPenalty.PenaltyType.Flag, ClientPenalty = EFPenalty.PenaltyType.Flag,
Value = currentChestAbdomenRatio, Value = currentChestAbdomenRatio,
Location = IW4Info.HitLocation.torso_upper, Location = IW4Info.HitLocation.torso_upper,
HitCount = totalChestHits, HitCount = totalChestHits,
Type = DetectionType.Chest Type = DetectionType.Chest
}; });
} }
} }
} }
return new DetectionPenaltyResult() return results.FirstOrDefault(_result => _result.ClientPenalty == EFPenalty.PenaltyType.Ban) ??
{ results.FirstOrDefault(_result => _result.ClientPenalty == EFPenalty.PenaltyType.Flag) ??
ClientPenalty = EFPenalty.PenaltyType.Any new DetectionPenaltyResult()
}; {
ClientPenalty = EFPenalty.PenaltyType.Any,
};
} }
} }
} }

View File

@ -569,6 +569,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
if (Plugin.Config.Configuration().EnableAntiCheat && !attacker.IsBot && attacker.ClientId != victim.ClientId) if (Plugin.Config.Configuration().EnableAntiCheat && !attacker.IsBot && attacker.ClientId != victim.ClientId)
{ {
DetectionPenaltyResult result = new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Any };
#if DEBUG #if DEBUG
if (clientDetection.QueuedHits.Count > 0) if (clientDetection.QueuedHits.Count > 0)
#else #else
@ -580,10 +581,12 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
clientDetection.QueuedHits = clientDetection.QueuedHits.OrderBy(_hits => _hits.TimeOffset).ToList(); clientDetection.QueuedHits = clientDetection.QueuedHits.OrderBy(_hits => _hits.TimeOffset).ToList();
var oldestHit = clientDetection.QueuedHits.First(); var oldestHit = clientDetection.QueuedHits.First();
clientDetection.QueuedHits.RemoveAt(0); clientDetection.QueuedHits.RemoveAt(0);
await ApplyPenalty(clientDetection.ProcessHit(oldestHit, isDamage), attacker, ctx); result = clientDetection.ProcessHit(oldestHit, isDamage);
await ApplyPenalty(result, attacker, ctx);
} }
await ApplyPenalty(clientDetection.ProcessTotalRatio(clientStats), attacker, ctx); result = clientDetection.ProcessTotalRatio(clientStats);
await ApplyPenalty(result , attacker, ctx);
} }
else else
@ -591,7 +594,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
clientDetection.QueuedHits.Add(hit); clientDetection.QueuedHits.Add(hit);
} }
if (clientDetection.Tracker.HasChanges) if (clientDetection.Tracker.HasChanges && result.ClientPenalty != EFPenalty.PenaltyType.Any)
{ {
SaveTrackedSnapshots(clientDetection, ctx); SaveTrackedSnapshots(clientDetection, ctx);
} }

View File

@ -295,7 +295,7 @@ namespace SharedLibraryCore
{ {
get get
{ {
return Clients.Where(p => p != null).Count(); return Clients.Where(p => p != null && !p.IsBot).Count();
} }
} }
public int MaxClients { get; protected set; } public int MaxClients { get; protected set; }