Cheaply prevent distanced action from executing when the mob is within the required distance but on the wrong side.

This commit is contained in:
Major-
2014-08-08 03:43:44 +01:00
parent 8f669f059b
commit 9bc9ddd0ce
@@ -58,8 +58,9 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
if (reached) { if (reached) {
// some actions (e.g. agility) will cause the player to move away again // some actions (e.g. agility) will cause the player to move away again
// so we don't check once the player got close enough once // so we don't check once the player got close enough once
executeAction(); executeAction(); // TODO checking the walking queue size is a really cheap fix, and relies on the client not
} else if (mob.getPosition().getDistance(position) <= distance) { // being edited... this class needs to be completely re-written.
} else if (mob.getPosition().getDistance(position) <= distance && mob.getWalkingQueue().size() == 0) {
reached = true; reached = true;
setDelay(delay); setDelay(delay);
if (immediate) { if (immediate) {
@@ -71,6 +72,6 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
/** /**
* Executes the actual action. Called when the distance requirement is met. * Executes the actual action. Called when the distance requirement is met.
*/ */
public abstract void executeAction(); protected abstract void executeAction();
} }