I don't know why you used a 2d array instead of an array of positions..
public boolean WalkAlongPath(Position[] path, boolean forward, int distanceFromEnd) {
if (distanceToPoint(forward ? path[path.length - 1].getX() : path[0].getX(),
forward ? path[path.length - 1].getY() : path[0].getY()) <= distanceFromEnd)
return true;
else {
walkPath(path, forward);
return false;
}
}
public void walkPath(Position[] path, boolean forward) {
int destination = 0;
for (int i = 0; i < path.length; i++)
if (distanceToPoint(path[i].getX(), path[i].getY()) < distanceToPoint(path[destination].getX(), path[destination].getY()))
destination = i;
if (script.client.getMyPlayer().isMoving() && distanceToPoint(path[destination].getX(), path[destination].getY()) > (script.isRunning() ? 3 : 2))
return;
if (forward && destination != path.length - 1 || !forward && destination != 0)
destination += (forward ? 1 : -1);
try {
script.walk(new Position(path[destination].getX(), path[destination].getY(), 0));
script.sleep(600);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private int distanceToPoint(int pointX, int pointY) {
return (int) Math.sqrt(Math.pow(script.client.getMyPlayer().getX() - pointX, 2)
+ Math.pow(script.client.getMyPlayer().getY() - pointY, 2));
}
Also, not trying to hijack or anything.. but is there a position.isReachable() or position.canReach() ?