mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
[BLEEDING][INSTABLE] Attempt to know when the bloody bunny can't fly.
Technically, tracking actual speed / base speed seems promising, done here via using the liftOffEnvelope that is maintained anyway, adding a counter and sum value. [Base speed is something like the allowed speed, without accounting for specialties like bunny hopping.] Limits are checked for moving in ground+air or water+air and are currently hard-coded. This simplistic first-step-in may easily yield all sorts of false positives and other random issues, handle with care.
This commit is contained in:
parent
f1e5096912
commit
3d141f3125
@ -226,6 +226,11 @@ public class MovingData extends ACheckData {
|
||||
public LiftOffEnvelope liftOffEnvelope = defaultLiftOffEnvelope;
|
||||
/** Count how many moves have been made inside a medium (other than air). */
|
||||
public int insideMediumCount = 0;
|
||||
// TODO: Does combinedMedium stuff need resetting on join/teleport/special?
|
||||
/** Number of moves for horizontal moving within air + certain medium. */
|
||||
public int combinedMediumHCount = 0;
|
||||
/** Sum of actual speed / base speed for horizontal moving within air + certain medium. */
|
||||
public double combinedMediumHValue = 0.0;
|
||||
|
||||
// Locations shared between all checks.
|
||||
private Location setBack = null;
|
||||
|
@ -275,7 +275,6 @@ public class SurvivalFly extends Check {
|
||||
// Check allowed vs. taken horizontal distance.
|
||||
// Get the allowed distance.
|
||||
hAllowedDistance = setAllowedhDist(player, sprinting, thisMove, data, cc, false);
|
||||
|
||||
// Judge if horizontal speed is above limit.
|
||||
hDistanceAboveLimit = hDistance - hAllowedDistance;
|
||||
|
||||
@ -294,6 +293,39 @@ public class SurvivalFly extends Check {
|
||||
data.bunnyhopDelay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// hacc (if enabled, always update)
|
||||
final double fcmhv = Math.max(1.0, thisMove.hDistance / thisMove.hAllowedDistanceBase);
|
||||
data.combinedMediumHCount ++;
|
||||
data.combinedMediumHValue += fcmhv;
|
||||
// TODO: Balance, where to check / use (...).
|
||||
if (data.combinedMediumHCount > 30) { // TODO: Adjust whatever way.
|
||||
final double fcmh = data.combinedMediumHValue / (double) data.combinedMediumHCount;
|
||||
final double limitFCMH;
|
||||
// TODO: with buffer use, might want to skip.
|
||||
if (data.liftOffEnvelope == LiftOffEnvelope.NORMAL) {
|
||||
limitFCMH = 1.34;
|
||||
}
|
||||
else if (data.liftOffEnvelope == LiftOffEnvelope.LIMIT_LIQUID
|
||||
|| data.liftOffEnvelope == LiftOffEnvelope.LIMIT_NEAR_GROUND) {
|
||||
limitFCMH = 1.05;
|
||||
}
|
||||
else {
|
||||
limitFCMH = 1.0;
|
||||
}
|
||||
if (fcmh > limitFCMH && !data.isVelocityJumpPhase()) { // TODO: Configurable / adjust by medium type.
|
||||
hDistanceAboveLimit = hDistance * (fcmh - limitFCMH);
|
||||
tags.add("hacc");
|
||||
// Reset for now.
|
||||
data.combinedMediumHCount = 0;
|
||||
data.combinedMediumHValue = 0.0;
|
||||
}
|
||||
else {
|
||||
// TODO: Other cases (1.0, between, ...)?
|
||||
data.combinedMediumHCount = 1;
|
||||
data.combinedMediumHValue = fcmhv;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent players from walking on a liquid in a too simple way.
|
||||
// TODO: Find something more effective against more smart methods (limitjump helps already).
|
||||
@ -487,7 +519,12 @@ public class SurvivalFly extends Check {
|
||||
// TODO: Is above stairs ?
|
||||
}
|
||||
// Count how long one is moving inside of a medium.
|
||||
if (!resetFrom || !resetTo || oldLiftOffEnvelope != data.liftOffEnvelope) {
|
||||
if (oldLiftOffEnvelope != data.liftOffEnvelope) {
|
||||
data.insideMediumCount = 0;
|
||||
data.combinedMediumHCount = 0;
|
||||
data.combinedMediumHValue = 0.0;
|
||||
}
|
||||
else if (!resetFrom || !resetTo) {
|
||||
data.insideMediumCount = 0;
|
||||
} else {
|
||||
data.insideMediumCount ++;
|
||||
@ -1510,7 +1547,14 @@ public class SurvivalFly extends Check {
|
||||
tags.add("headbangbunny");
|
||||
allowHop = true;
|
||||
}
|
||||
|
||||
// ONLY WITH ALL ABOVE BEING ABOUT HEAD OBSTRUCTED:
|
||||
// TODO: Magic.
|
||||
if (allowHop && data.combinedMediumHValue / (double) data.combinedMediumHCount < 1.5) {
|
||||
// TODO: Reset to 1 and min(allowed, actual) rather.
|
||||
data.combinedMediumHCount = 0;
|
||||
data.combinedMediumHValue = 0.0;
|
||||
tags.add("bunny_no_hacc");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user