public Position nextTile(Position path[], int skipDist) {
int dist = -1, closest = -1;
for (int i = path.length - 1; i >= 0; i--) {
Position tile = path[i];
int d = script.map.distance(tile);
if (d <= 16 && (d < dist || dist == -1)) { //<---- was edited
dist = d;
closest = i;
}
}
int feasibleTileIndex = -1;
for (int i = closest; i < path.length; i++) {
if (script.map.distance(path[i]) <= skipDist) {
feasibleTileIndex = i;
} else {
break;
}
}
return (feasibleTileIndex == -1) ? null : path[feasibleTileIndex];
}
i added in one line, because for the next tile method it will get the furthest tile in the path, but sometime it picks a tile that maybe like 3-5 time out of minimap rang and just get stuck there so i added a quick boolean that will help check to see if it can reach tile.