It's starting to really annoy me, I have to walk through an area where there's aggressive monsters and the walker sometimes just stands still, meaning I get to half health...
I don't see where the problem is, sometimes it works perfectly fine but sometimes it stands still for no reason.
public void walkPath(Position[] path, int startIndex, boolean reverse)
throws InterruptedException {
if (script.myPlayer().getPosition()
.distance(path[reverse ? 0 : path.length - 1]) <= 3
|| script.myPlayer().getPosition().distance(path[startIndex]) > 100)
return;
if (!reverse) {
for (int i = startIndex; i < path.length; i++) {
if (!walkTile(path[i], 3))
i--;
}
} else {
for (int i = startIndex; i >= 0; i--) {
if (!walkTile(path[i], 3))
i++;
}
}
}
public int getPathStartIndex(Position[] path, boolean reverse) {
int closestIndex;
int closest;
if (!reverse) {
closest = script.myPlayer().getPosition().distance(path[0]);
closestIndex = 0;
for (int i = 1; i < path.length; i++) {
if (script.myPlayer().getPosition().distance(path[i]) <= closest) {
closest = script.myPlayer().getPosition().distance(path[i]);
closestIndex = i;
}
}
} else {
closest = script.myPlayer().getPosition()
.distance(path[path.length - 1]);
closestIndex = path.length - 1;
for (int i = path.length - 1; i >= 0; i--) {
if (script.myPlayer().getPosition().distance(path[i]) <= closest) {
closest = script.myPlayer().getPosition().distance(path[i]);
closestIndex = i;
}
}
}
return closestIndex;
}
public boolean walkTile(Position p, int margin) throws InterruptedException {
if (script.myPlayer().getPosition().distance(p) <= margin)
return true;
else if (script.myPlayer().getPosition().distance(p) > margin)
script.client.moveMouseTo(
new MinimapTileDestination(script.bot, p), false, true,
false);
int failsafe = 0;
while (failsafe < 10
&& script.myPlayer().getPosition().distance(p) > margin) {
if ((script.client.getRunEnergy() > MethodProvider.random(25, 40) || script.myPlayer().isUnderAttack())
&& !script.isRunning()) {
script.client.getInterface(548).getChild(93).interact();
script.sleep(MethodProvider.random(500, 700));
}
script.sleep(100);
failsafe++;
if (script.myPlayer().isMoving())
failsafe = 0;
}
return script.myPlayer().getPosition().distance(p) <= margin;
}