Skip to content

Commit

Permalink
Small changes to reach check, redid aimbot check, improved default co…
Browse files Browse the repository at this point in the history
…nfig

Prepared for release.
  • Loading branch information
Rammelkast committed Jan 1, 2022
1 parent 67e6f0d commit 5c85b87
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId>
<version>1.10.3-PRE</version>
<version>1.10.3</version>
<name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public static CheckResult checkReach(final Player player, final Entity target) {
// Velocity compensation
final double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier");
allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier;
final double reachedDistance = ((LivingEntity) target).getLocation().toVector()
.distance(player.getLocation().toVector());
if (reachedDistance > allowedReach) {
final double reachedDistance = Utilities.roundDouble(((LivingEntity) target).getLocation().toVector()
.distance(player.getLocation().toVector()), 2);
if (reachedDistance > Utilities.roundDouble(allowedReach, 2)) {
return new CheckResult(CheckResult.Result.FAILED, "Reach",
"reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")");
"reached too far (distance=" + reachedDistance + ", max=" + Utilities.roundDouble(allowedReach, 2) + ")");
}
return PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;

/*
* TODO redo (again)
* Just go for a basic GCD check and implement optifine detection
*/
public final class AimbotCheck {

private static final double EXPANDER = Math.pow(2, 24);
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);

public static CheckResult runCheck(final Player player, final EntityDamageByEntityEvent event) {
Expand All @@ -49,19 +46,18 @@ public static CheckResult runCheck(final Player player, final EntityDamageByEnti
final MovementManager movementManager = user.getMovementManager();
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
final float deltaPitch = movementManager.deltaPitch;
final float deltaYaw = movementManager.deltaYaw;
final float pitchAcceleration = Math.abs(deltaPitch - movementManager.lastDeltaPitch);

final double gcd = Utilities.computeGcd(deltaPitch, movementManager.lastDeltaPitch);
final double mod = Math.abs(player.getLocation().getPitch() % gcd);
final long gcd = Utilities.getGcd((long) (deltaPitch * EXPANDER),
(long) (movementManager.lastDeltaPitch * EXPANDER));
final double mod = Math.abs(player.getLocation().getPitch() % (gcd / EXPANDER));
final double minAcceleration = checksConfig.getDouble(CheckType.AIMBOT, "minAcceleration");
final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod");
if (mod < maxMod && pitchAcceleration > minAcceleration
&& (deltaPitch == 0.0f || (deltaPitch > 45.0f && deltaYaw > 45.0f))) {
if ((gcd > 0L && gcd < 131072L) && mod <= maxMod && pitchAcceleration > minAcceleration && deltaPitch > 5.0f) {
return new CheckResult(CheckResult.Result.FAILED,
"failed computational check (gcd=" + Utilities.roundDouble(gcd, 4) + ", mod="
+ Utilities.roundDouble(mod, 4) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 4)
+ ")");
"failed computational check (gcd=" + gcd + ", mod="
+ Utilities.roundDouble(mod, 5) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 3)
+ ", delta=" + Utilities.roundDouble(deltaPitch, 1) + ")");
}
return PASS;
}
Expand Down
21 changes: 7 additions & 14 deletions src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -766,22 +766,15 @@ public static float computeAngleDifference(final float a, final float b) {

/**
* Calculates the greatest common divider
* @param a value a
* @param b value b
* @return the greatest common divider of a and b
*
* @param current - The current value
* @param previous - The previous value
* @return - The GCD of those two values
*/
public static double computeGcd(final double a, final double b) {
if (a < b) {
return computeGcd(b, a);
}
public static long getGcd(final long current, final long previous) {
return (previous <= 16384L) ? current : getGcd(previous, current % previous);
}

if (Math.abs(b) < 0.001) {
return a;
} else {
return computeGcd(b, a - Math.floor(a / b) * b);
}
}

public static boolean isCollisionPoint(final Location location, final Predicate<Material> predicate) {
final ArrayList<Material> materials = new ArrayList<>();
for (double x = -0.3; x <= 0.3; x += 0.3) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ speed:
# Should this part of the check be enabled?
enabled: true
# Base unadjusted air speed limit
baseLimit: 0.03125
baseLimit: 0.0315
# Prediction multiplier for custom walk speeds
walkSpeedMultiplier: 1.4
# Checks movement acceleration in the air
Expand All @@ -67,7 +67,7 @@ speed:
# Should this part of the check be enabled?
enabled: true
# Base unadjusted air acceleration limit
baseLimit: 0.3725
baseLimit: 0.375
# Limit multiplier for custom walk speeds
walkSpeedMultiplier: 1.4
# Checks movement acceleration in the air
Expand Down Expand Up @@ -157,7 +157,7 @@ killaura:
# Maximum base reach distances
baseMaxValue:
# Maximum base reach value
normal: 3.6
normal: 3.5
# Maximum base reach value when a player has velocity
velocitized: 4.0
# Settings for lag compensation
Expand All @@ -167,7 +167,7 @@ killaura:
# Extra allowed reach distance per millisecond of ping
pingCompensation: 0.0025
# The multiplier of extra compensation for velocity
velocityMultiplier: 1.2
velocityMultiplier: 1.3
# Checks if the target it within a players viewing angle
# Debugs as 'tried to attack from an illegal angle'
angle:
Expand All @@ -194,9 +194,9 @@ aimbot:
# Should this check be enabled?
enabled: true
# Maximum pitch acceleration for check to consider aim illegal
minAcceleration: 0.5
minAcceleration: 5.5
# Maximum mod value for check to consider aim illegal
maxMod: 0.0001
maxMod: 0.001
# Criticals check settings
# Checks if the player tries to do a crit without needed conditions
criticals:
Expand Down

0 comments on commit 5c85b87

Please sign in to comment.