Handle misclicks

This commit is contained in:
Yuri Moens 2021-10-20 11:21:55 +02:00
parent 3fce3be950
commit 8e72c90252
Signed by: ymo
GPG Key ID: F6D51D6FE15BE924

View File

@ -16,7 +16,6 @@ import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.methods.walking.path.impl.LocalPath;
import org.dreambot.api.script.ScriptManager;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.utilities.impl.Condition;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.items.GroundItem;
@ -214,13 +213,7 @@ public class HandleObstacle extends TaskNode {
MethodContext.sleepUntil(Util::playerIsIdle, Calculations.random(3000, 3500));
}
if (isWalking) {
Mouse.setAlwaysHop(true);
currentObject.interactForceLeft(currentObject.getActions()[0]);
Mouse.setAlwaysHop(false);
} else {
currentObject.interactForceLeft(currentObject.getActions()[0]);
}
interact(currentObject, isWalking);
Rectangle hoverRect = hoverMap.get(current.getNext().getID());
if (hoverRect != null) {
@ -235,4 +228,24 @@ public class HandleObstacle extends TaskNode {
return Calculations.random(180, 350);
}
public void interact(GameObject currentObject, boolean shouldHop) {
Mouse.setAlwaysHop(shouldHop);
currentObject.interactForceLeft(currentObject.getActions()[0]);
Mouse.setAlwaysHop(false);
Tile dest = null;
if (MethodProvider.sleepUntil(() -> {
Tile t = Walking.getDestination();
return t != null;
}, Calculations.random(1000, 1100))) {
dest = Walking.getDestination();
}
if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) {
MethodProvider.log("Misclick, trying again");
interact(currentObject, true);
}
}
}