More grace to velocity handling, configurable.

Before full revert or recode: a moderate (smaller than
before) minimal grace amount for the counters is used now.
This commit is contained in:
asofold 2013-02-06 18:43:34 +01:00
parent 261fca021d
commit df005b4181
6 changed files with 41 additions and 13 deletions

View File

@ -110,6 +110,8 @@ public class MovingConfig extends ACheckConfig {
public final double sfHoverViolation; public final double sfHoverViolation;
// Special tolerance values: // Special tolerance values:
/** This is not strictly ticks, but packets, for now.*/
public final int velocityGraceTicks;
public final double noFallyOnGround; public final double noFallyOnGround;
public final double yOnGround; public final double yOnGround;
public final double yStep; public final double yStep;
@ -168,6 +170,7 @@ public class MovingConfig extends ACheckConfig {
sfHoverFallDamage = data.getBoolean(ConfPaths.MOVING_SURVIVALFLY_HOVER_FALLDAMAGE); sfHoverFallDamage = data.getBoolean(ConfPaths.MOVING_SURVIVALFLY_HOVER_FALLDAMAGE);
sfHoverViolation = data.getDouble(ConfPaths.MOVING_SURVIVALFLY_HOVER_SFVIOLATION); sfHoverViolation = data.getDouble(ConfPaths.MOVING_SURVIVALFLY_HOVER_SFVIOLATION);
velocityGraceTicks = data.getInt(ConfPaths.MOVING_VELOCITY_GRACETICKS);
yOnGround = data.getDouble(ConfPaths.MOVING_YONGROUND, 0.001, 2.0, 0.0626); // sqrt(1/256), see: NetServerHandler. yOnGround = data.getDouble(ConfPaths.MOVING_YONGROUND, 0.001, 2.0, 0.0626); // sqrt(1/256), see: NetServerHandler.
noFallyOnGround = data.getDouble(ConfPaths.MOVING_NOFALL_YONGROUND, 0.001, 2.0, 0.3); noFallyOnGround = data.getDouble(ConfPaths.MOVING_NOFALL_YONGROUND, 0.001, 2.0, 0.3);
// ystep is set to 0.45 by default, for stairs / steps. // ystep is set to 0.45 by default, for stairs / steps.

View File

@ -87,11 +87,13 @@ public class MovingData extends ACheckData {
// Velocity handling. // Velocity handling.
// TODO: consider resetting these with clearFlyData and onSetBack. // TODO: consider resetting these with clearFlyData and onSetBack.
public int verticalVelocityCounter;
public double verticalFreedom; public double verticalFreedom;
public double verticalVelocity; public double verticalVelocity;
public int verticalVelocityCounter; public int verticalVelocityUsed = 0;
public double horizontalVelocityCounter; public int horizontalVelocityCounter;
public double horizontalFreedom; public double horizontalFreedom;
public int horizontalVelocityUsed = 0;
// Coordinates. // Coordinates.
/** Last from coordinates. */ /** Last from coordinates. */

View File

@ -525,20 +525,28 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do // Just try to estimate velocities over time. Not very precise, but works good enough most of the time. Do
// general data modifications one for each event. // general data modifications one for each event.
if (data.horizontalVelocityCounter > 0D){ if (data.horizontalVelocityCounter > 0D){
data.horizontalVelocityUsed ++;
data.horizontalVelocityCounter--; data.horizontalVelocityCounter--;
data.horizontalFreedom = Math.max(0.0, data.horizontalFreedom - 0.09); data.horizontalFreedom = Math.max(0.0, data.horizontalFreedom - 0.09);
} }
else if (data.horizontalFreedom > 0.001D) else if (data.horizontalFreedom > 0.001D){
data.horizontalFreedom *= 0.90D; data.horizontalVelocityUsed ++;
data.horizontalFreedom *= 0.90D;
}
if (data.verticalVelocity <= 0.09D) if (data.verticalVelocity <= 0.09D){
data.verticalVelocityCounter--; data.verticalVelocityUsed ++;
data.verticalVelocityCounter--;
}
else if (data.verticalVelocityCounter > 0D) { else if (data.verticalVelocityCounter > 0D) {
data.verticalVelocityUsed ++;
data.verticalFreedom += data.verticalVelocity; data.verticalFreedom += data.verticalVelocity;
data.verticalVelocity = Math.max(0.0, data.verticalVelocity -0.09); data.verticalVelocity = Math.max(0.0, data.verticalVelocity -0.09);
} else if (data.verticalFreedom > 0.001D) } else if (data.verticalFreedom > 0.001D){
// Counter has run out, now reduce the vertical freedom over time. // Counter has run out, now reduce the vertical freedom over time.
data.verticalVelocityUsed ++;
data.verticalFreedom *= 0.93D; data.verticalFreedom *= 0.93D;
}
Location newTo = null; Location newTo = null;
@ -884,15 +892,20 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
double newVal = velocity.getY(); double newVal = velocity.getY();
if (newVal >= 0D) { if (newVal >= 0D) {
if (data.verticalFreedom <= 0.001 && data.verticalVelocityCounter >= 0){
data.verticalVelocity = 0;
}
data.verticalVelocity += newVal; data.verticalVelocity += newVal;
data.verticalFreedom += data.verticalVelocity; data.verticalFreedom += data.verticalVelocity;
data.verticalVelocityCounter = Math.min(100, Math.max(data.verticalVelocityCounter, 0) + 1 + (int) Math.round(newVal * 10.0)); // 50; data.verticalVelocityCounter = Math.min(100, Math.max(data.verticalVelocityCounter, cc.velocityGraceTicks ) + 1 + (int) Math.round(newVal * 10.0)); // 50;
data.verticalVelocityUsed = 0;
} }
newVal = Math.sqrt(velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ()); newVal = Math.sqrt(velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ());
if (newVal > 0D) { if (newVal > 0D) {
data.horizontalFreedom += newVal; data.horizontalFreedom += newVal;
data.horizontalVelocityCounter = Math.min(100, Math.max(data.horizontalVelocityCounter, 0) + 1 + (int) Math.round(newVal * 10.0)); // 30; data.horizontalVelocityCounter = Math.min(100, Math.max(data.horizontalVelocityCounter, cc.velocityGraceTicks ) + 1 + (int) Math.round(newVal * 10.0)); // 30;
data.horizontalVelocityUsed = 0;
} }
// Set dirty flag here. // Set dirty flag here.
@ -1106,9 +1119,11 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Experiment: add some velocity (fake). // Experiment: add some velocity (fake).
data.horizontalVelocityCounter = 1; data.horizontalVelocityCounter = 1;
data.horizontalFreedom = 0.75; data.horizontalFreedom = 0.75;
data.horizontalVelocityUsed = 0;
data.verticalVelocityCounter = 1; data.verticalVelocityCounter = 1;
data.verticalFreedom = 1.2; data.verticalFreedom = 1.2;
data.verticalVelocity = 0.1; data.verticalVelocity = 0.1;
data.verticalVelocityUsed = 0;
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

View File

@ -400,7 +400,7 @@ public class SurvivalFly extends Check {
// Apply reset conditions. // Apply reset conditions.
data.toWasReset = resetTo || data.noFallAssumeGround; data.toWasReset = resetTo || data.noFallAssumeGround;
data.fromWasReset = resetFrom || data.noFallAssumeGround; data.fromWasReset = resetFrom || data.noFallAssumeGround;
if (yDistance <= 0 && data.sfLastYDist > 0){ if (data.verticalVelocityUsed > cc.velocityGraceTicks && yDistance <= 0 && data.sfLastYDist > 0){
// data.verticalFreedom = 0; // data.verticalFreedom = 0;
data.verticalVelocityCounter = 0; data.verticalVelocityCounter = 0;
data.verticalVelocity = 0; data.verticalVelocity = 0;
@ -411,14 +411,16 @@ public class SurvivalFly extends Check {
data.sfJumpPhase = 0; data.sfJumpPhase = 0;
data.clearAccounting(); data.clearAccounting();
// TODO: Experimental: reset velocity. // TODO: Experimental: reset velocity.
if (toOnGround && yDistance < 0 || Math.abs(yDistance) < 0.09){ if (data.verticalVelocityUsed > cc.velocityGraceTicks && toOnGround && yDistance < 0){
data.verticalVelocityCounter = 0; data.verticalVelocityCounter = 0;
data.verticalFreedom = 0; data.verticalFreedom = 0;
data.verticalVelocity = 0; data.verticalVelocity = 0;
data.verticalVelocityUsed = 0;
} }
if (hDistance < sprintingSpeed){ if (data.horizontalVelocityUsed > cc.velocityGraceTicks && hDistance < sprintingSpeed){
data.horizontalFreedom = 0; data.horizontalFreedom = 0;
data.horizontalVelocityCounter = 0; data.horizontalVelocityCounter = 0;
data.horizontalVelocityUsed = 0;
} }
} }
else if (resetFrom){ else if (resetFrom){

View File

@ -508,6 +508,9 @@ public abstract class ConfPaths {
public static final String MOVING_SURVIVALFLY_HOVER_SFVIOLATION = MOVING_SURVIVALFLY_HOVER + "sfviolation"; public static final String MOVING_SURVIVALFLY_HOVER_SFVIOLATION = MOVING_SURVIVALFLY_HOVER + "sfviolation";
// Special (to be sorted in or factored out). // Special (to be sorted in or factored out).
private static final String MOVING_VELOCITY = MOVING + "velocity.";
public static final String MOVING_VELOCITY_GRACETICKS = MOVING_VELOCITY + "graceticks";
public static final String MOVING_NOFALL_YONGROUND = MOVING_NOFALL + "yonground"; public static final String MOVING_NOFALL_YONGROUND = MOVING_NOFALL + "yonground";
public static final String MOVING_YONGROUND = MOVING + "yonground"; public static final String MOVING_YONGROUND = MOVING + "yonground";
public static final String MOVING_SURVIVALFLY_YSTEP = MOVING_SURVIVALFLY + "ystep"; public static final String MOVING_SURVIVALFLY_YSTEP = MOVING_SURVIVALFLY + "ystep";
@ -534,5 +537,5 @@ public abstract class ConfPaths {
public static final String SUB_IGNOREPASSABLE = RootConfPaths.SUB_IGNOREPASSABLE; public static final String SUB_IGNOREPASSABLE = RootConfPaths.SUB_IGNOREPASSABLE;
public static final String SUB_ALLOWINSTANTBREAK = RootConfPaths.SUB_ALLOWINSTANTBREAK; public static final String SUB_ALLOWINSTANTBREAK = RootConfPaths.SUB_ALLOWINSTANTBREAK;
public static final String SUB_LAG = "lag"; public static final String SUB_LAG = "lag";
} }

View File

@ -400,6 +400,9 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.MOVING_SURVIVALFLY_HOVER_FALLDAMAGE, true); set(ConfPaths.MOVING_SURVIVALFLY_HOVER_FALLDAMAGE, true);
set(ConfPaths.MOVING_SURVIVALFLY_HOVER_SFVIOLATION, 500); set(ConfPaths.MOVING_SURVIVALFLY_HOVER_SFVIOLATION, 500);
// Special.
set(ConfPaths.MOVING_VELOCITY_GRACETICKS, 20);
/* /*
* dP"8 d8 ,e, * dP"8 d8 ,e,
* C8b Y d88 888,8, " 888 8e e88 888 dP"Y * C8b Y d88 888,8, " 888 8e e88 888 dP"Y