1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-07 13:48:00 -05:00

Add shouldIgnoreDetection check for DetectionType.Bone

This commit updates the cheat detection logic to allow ignoring specific weapons for DetectionType.Bone.

- Modified Detection.cs to include the shouldIgnoreDetection check for DetectionType.Bone, similar to how it's handled for Recoil and Chest detection types.
- Updated AnticheatConfiguration.cs to add an entry for DetectionType.Bone under Game.IW4 in the IgnoredDetectionSpecification, allowing you to configure weapon regexes to ignore for this detection type.
This commit is contained in:
google-labs-jules[bot] 2025-05-26 02:13:46 +00:00 committed by RaidMax
parent 3e186ca07a
commit c2cce14ad3
2 changed files with 65 additions and 49 deletions

View File

@ -372,6 +372,18 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
#region SESSION_RATIOS #region SESSION_RATIOS
if (Kills >= Thresholds.LowSampleMinKills) if (Kills >= Thresholds.LowSampleMinKills)
{ {
shouldIgnoreDetection = false; // reset
try
{
shouldIgnoreDetection = _statsConfiguration.AnticheatConfiguration.IgnoredDetectionSpecification[(Server.Game)hit.GameName][DetectionType.Bone]
.Any(_weaponRegex => Regex.IsMatch(hit.WeaponReference, _weaponRegex));
}
catch (KeyNotFoundException)
{
// not configured, so we don't ignore
}
double marginOfError = Thresholds.GetMarginOfError(HitCount); double marginOfError = Thresholds.GetMarginOfError(HitCount);
// determine what the max headshot percentage can be for current number of kills // determine what the max headshot percentage can be for current number of kills
double lerpAmount = Math.Min(1.0, (HitCount - Thresholds.LowSampleMinKills) / (double)(/*Thresholds.HighSampleMinKills*/ 60 - Thresholds.LowSampleMinKills)); double lerpAmount = Math.Min(1.0, (HitCount - Thresholds.LowSampleMinKills) / (double)(/*Thresholds.HighSampleMinKills*/ 60 - Thresholds.LowSampleMinKills));
@ -388,65 +400,68 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v.Count / (double)HitCount).Max()); double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v.Count / (double)HitCount).Max());
var bone = HitLocationCount.FirstOrDefault(b => b.Value.Count == HitLocationCount.Values.Max(_hit => _hit.Count)).Key; var bone = HitLocationCount.FirstOrDefault(b => b.Value.Count == HitLocationCount.Values.Max(_hit => _hit.Count)).Key;
#region HEADSHOT_RATIO if (!shouldIgnoreDetection)
// flag on headshot
if (currentHeadshotRatio > maxHeadshotLerpValueForFlag)
{ {
// ban on headshot #region HEADSHOT_RATIO
if (currentHeadshotRatio > maxHeadshotLerpValueForBan) // flag on headshot
if (currentHeadshotRatio > maxHeadshotLerpValueForFlag)
{ {
results.Add(new DetectionPenaltyResult() // ban on headshot
if (currentHeadshotRatio > maxHeadshotLerpValueForBan)
{ {
ClientPenalty = EFPenalty.PenaltyType.Ban, results.Add(new DetectionPenaltyResult()
Value = currentHeadshotRatio, {
Location = IW4Info.HitLocation.head, ClientPenalty = EFPenalty.PenaltyType.Ban,
HitCount = HitCount, Value = currentHeadshotRatio,
Type = DetectionType.Bone Location = IW4Info.HitLocation.head,
}); HitCount = HitCount,
} Type = DetectionType.Bone
else });
{ }
results.Add(new DetectionPenaltyResult() else
{ {
ClientPenalty = EFPenalty.PenaltyType.Flag, results.Add(new DetectionPenaltyResult()
Value = currentHeadshotRatio, {
Location = IW4Info.HitLocation.head, ClientPenalty = EFPenalty.PenaltyType.Flag,
HitCount = HitCount, Value = currentHeadshotRatio,
Type = DetectionType.Bone Location = IW4Info.HitLocation.head,
}); HitCount = HitCount,
Type = DetectionType.Bone
});
}
} }
} #endregion
#endregion
#region BONE_RATIO #region BONE_RATIO
// flag on bone ratio // flag on bone ratio
else if (currentMaxBoneRatio > maxBoneRatioLerpValueForFlag) else if (currentMaxBoneRatio > maxBoneRatioLerpValueForFlag)
{
// ban on bone ratio
if (currentMaxBoneRatio > maxBoneRatioLerpValueForBan)
{ {
results.Add(new DetectionPenaltyResult() // ban on bone ratio
if (currentMaxBoneRatio > maxBoneRatioLerpValueForBan)
{ {
ClientPenalty = EFPenalty.PenaltyType.Ban, results.Add(new DetectionPenaltyResult()
Value = currentMaxBoneRatio, {
Location = bone, ClientPenalty = EFPenalty.PenaltyType.Ban,
HitCount = HitCount, Value = currentMaxBoneRatio,
Type = DetectionType.Bone Location = bone,
}); HitCount = HitCount,
} Type = DetectionType.Bone
else });
{ }
results.Add(new DetectionPenaltyResult() else
{ {
ClientPenalty = EFPenalty.PenaltyType.Flag, results.Add(new DetectionPenaltyResult()
Value = currentMaxBoneRatio, {
Location = bone, ClientPenalty = EFPenalty.PenaltyType.Flag,
HitCount = HitCount, Value = currentMaxBoneRatio,
Type = DetectionType.Bone Location = bone,
}); HitCount = HitCount,
Type = DetectionType.Bone
});
}
} }
#endregion
} }
#endregion
} }
#region CHEST_ABDOMEN_RATIO_SESSION #region CHEST_ABDOMEN_RATIO_SESSION

View File

@ -26,7 +26,8 @@ namespace Stats.Config
{ {
{ DetectionType.Chest, new[] { "m21.+" } }, { DetectionType.Chest, new[] { "m21.+" } },
{ DetectionType.Recoil, new[] { "ranger.*_mp", "model1887.*_mp", ".+shotgun.*_mp", "turret_minigun_mp" } }, { DetectionType.Recoil, new[] { "ranger.*_mp", "model1887.*_mp", ".+shotgun.*_mp", "turret_minigun_mp" } },
{ DetectionType.Button, new[] { ".*akimbo.*" } } { DetectionType.Button, new[] { ".*akimbo.*" } },
{ DetectionType.Bone, new string[0] }
} }
} }
}; };