Let fight.direction use the location trace (simplified version @Iceee).

Allow 15 ticks total latency (2 x attacker + 1 x damaged) for the
looping, decrease tolerance for direction by a lot.
This commit is contained in:
asofold 2015-03-26 23:29:42 +01:00
parent dc1f5eced5
commit 4180d3b20b
5 changed files with 11 additions and 6 deletions

View File

@ -134,11 +134,11 @@ public class Direction extends Check {
final double off;
if (cc.directionStrict){
off = TrigUtil.combinedDirectionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_PRECISION, 80.0);
off = TrigUtil.combinedDirectionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_LOOP_PRECISION, 80.0);
}
else{
// Also take into account the angle.
off = TrigUtil.directionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_PRECISION);
off = TrigUtil.directionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_LOOP_PRECISION);
}
if (off > 0.1) {

View File

@ -115,6 +115,9 @@ public class FightConfig extends ACheckConfig {
public final boolean yawRateCheck;
public final boolean cancelDead;
public final boolean knockBackVelocityPvP;
/** Maximum latency counted in ticks for the loop checks (reach, direction). */
public final long loopMaxLatencyTicks = 15; // TODO: Configurable, sections for players and entities.
/**
* Instantiates a new fight configuration.

View File

@ -339,7 +339,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final ReachContext reachContext = reachEnabled ? reach.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
final DirectionContext directionContext = directionEnabled ? direction.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
final long traceOldest = tick; // - damagedTrace.getMaxSize(); // TODO: Set by window.
final long traceOldest = tick - cc.loopMaxLatencyTicks; // TODO: Set by latency-window.
// TODO: Iterating direction, which, static/dynamic choice.
final Iterator<TraceEntry> traceIt = damagedTrace.maxAgeIterator(traceOldest);

View File

@ -798,9 +798,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
if (player.isInsideVehicle()) {
// TODO: refine (!).
final Location ref = player.getVehicle().getLocation(useLoc);
mData.resetPositions(ref);
mData.resetPositions(ref); // TODO: Consider using to and intercept cheat attempts in another way.
useLoc.setWorld(null);
mData.updateTrace(player, ref, time);
mData.updateTrace(player, to, time); // TODO: Can you become invincible by sending special moves?
}
else if (!fromWorldName.equals(toWorldName)) {
mData.resetPositions(to);

View File

@ -18,8 +18,10 @@ public class TrigUtil {
private static final Vector vec2 = new Vector();
/** Multiply to get grad from rad. */
public static final double fRadToGrad = 360.0 / (2.0 * Math.PI);
/** Some default precision value for the directionCheck method. */
/** Some default precision value for the classic fight.direction check. */
public static final double DIRECTION_PRECISION = 2.6;
/** Precision for the fight.direction check within the LocationTrace loop. */
public static final double DIRECTION_LOOP_PRECISION = 0.5;
private static final Location useLoc = new Location(null, 0, 0, 0);