Skip fall damage penalty, if no damage would have resulted previously.

To avoid cheaters accumulating velocity dealt by damage, we skip dealing
fall damage, if they would not have received any, without taking the
current move into account. This is only for the case a player causes a
violation for which NoFall would usually have dealt fall damage.
This commit is contained in:
asofold 2015-03-08 21:17:31 +01:00
parent 84d47e52b9
commit e0f7e53c57
2 changed files with 19 additions and 4 deletions

View File

@ -563,7 +563,11 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
}
else{
if (checkNf && cc.sfFallDamage) {
if (mightSkipNoFall) {
if (noFall.estimateDamage(player, from.getY(), data) < 1.0) {
// TODO: Consider making this / damage amount configurable.
mightSkipNoFall = true;
}
else if (mightSkipNoFall) {
// Check if to really skip.
if (!pFrom.isOnGround() && !pFrom.isResetCond()) {
mightSkipNoFall = false;

View File

@ -51,7 +51,7 @@ public class NoFall extends Check {
// final int nfD = getDamage(data.noFallFallDistance);
// final int yD = getDamage((float) (data.noFallMaxY - y));
// final int maxD = Math.max(Math.max(pD, nfD), yD);
final double maxD = getDamage(Math.max((float) (data.noFallMaxY - y), Math.max(data.noFallFallDistance, player.getFallDistance())));
final double maxD = estimateDamage(player, y, data);
if (maxD >= 1.0){
// Damage to be dealt.
// TODO: more effects like sounds, maybe use custom event with violation added.
@ -65,6 +65,17 @@ public class NoFall extends Check {
else data.clearNoFallData();
}
/**
* Convenience method to estimate fall damage at a certain y-level, checking data and mc-fall-distance.
* @param player
* @param y
* @param data
* @return
*/
public double estimateDamage(final Player player, final double y, final MovingData data) {
return getDamage(Math.max((float) (data.noFallMaxY - y), Math.max(data.noFallFallDistance, player.getFallDistance())));
}
private final void adjustFallDistance(final Player player, final double minY, final boolean reallyOnGround, final MovingData data, final MovingConfig cc) {
final float noFallFallDistance = Math.max(data.noFallFallDistance, (float) (data.noFallMaxY - minY));
if (noFallFallDistance >= 3.0){
@ -91,7 +102,7 @@ public class NoFall extends Check {
mcAccess.dealFallDamage(player, BridgeHealth.getDamage(event));
}
}
// TODO: let this be done by the damage event (!).
// data.clearNoFallData(); // -> currently done in the damage eventhandling method.
player.setFallDistance(0);
@ -249,7 +260,7 @@ public class NoFall extends Check {
// Deal damage.
handleOnGround(player, y, false, data, cc);
}
/**
* Convenience method bypassing the factories.
* @param player