Retry area localisation and fix walking
This commit is contained in:
parent
34586a83f6
commit
d094033e6c
@ -97,6 +97,8 @@ public class HandleObstacle extends TaskNode {
|
||||
private final Course course;
|
||||
private final Map<Integer, Rectangle> hoverMap;
|
||||
|
||||
private int retries = 0;
|
||||
|
||||
public HandleObstacle(Course course) {
|
||||
this.course = course;
|
||||
this.hoverMap = new HashMap<>();
|
||||
@ -113,16 +115,22 @@ public class HandleObstacle extends TaskNode {
|
||||
public int execute() {
|
||||
Obstacle current = course.getCurrentObstacle();
|
||||
if (current == null) {
|
||||
if (retries >= 10) {
|
||||
MethodContext.logError("Player is in an unsupported area: " + Players.localPlayer().getTile().toString() + ". Stopping.");
|
||||
ScriptManager.getScriptManager().stop();
|
||||
return 0;
|
||||
} else {
|
||||
retries++;
|
||||
}
|
||||
|
||||
return Calculations.random(300, 400);
|
||||
}
|
||||
retries = 0;
|
||||
|
||||
final GameObject currentObject = current.getGameObject();
|
||||
if (currentObject == null) return Calculations.random(300, 500);
|
||||
|
||||
if (!currentObject.isOnScreen()) {
|
||||
Walking.clickTileOnMinimap(currentObject.getTile());
|
||||
Walking.walk(currentObject);
|
||||
MethodContext.sleepUntil(() -> Players.localPlayer().distance(currentObject) < 3, Calculations.random(5000, 5500));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user