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