From 1aa793b4bfb33f78cf9b61341d64e5067c57d4ad Mon Sep 17 00:00:00 2001 From: Yuri Moens Date: Thu, 28 Oct 2021 00:00:55 +0200 Subject: [PATCH] Optimize Seers agility course --- .../io/reisub/dreambot/cagility/CAgility.java | 4 ++++ .../cagility/tasks/HandleObstacle.java | 22 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CAgility/src/io/reisub/dreambot/cagility/CAgility.java b/CAgility/src/io/reisub/dreambot/cagility/CAgility.java index 5bd227b..74d073a 100644 --- a/CAgility/src/io/reisub/dreambot/cagility/CAgility.java +++ b/CAgility/src/io/reisub/dreambot/cagility/CAgility.java @@ -44,5 +44,9 @@ public class CAgility extends CTaskScript { int marks = PickupMark.marksPickedUp; getUI().drawString("Marks picked up: " + marks + " (" + getUI().getHourlyRate(marks) + " per hour)"); + + if (HandleObstacle.current != null && HandleObstacle.current.getGameObject() != null && HandleObstacle.current.getGameObject().getModel() != null) { + HandleObstacle.current.getGameObject().getModel().drawWireFrame(g); + } } } diff --git a/CAgility/src/io/reisub/dreambot/cagility/tasks/HandleObstacle.java b/CAgility/src/io/reisub/dreambot/cagility/tasks/HandleObstacle.java index 3901f70..62d574d 100644 --- a/CAgility/src/io/reisub/dreambot/cagility/tasks/HandleObstacle.java +++ b/CAgility/src/io/reisub/dreambot/cagility/tasks/HandleObstacle.java @@ -4,6 +4,9 @@ import io.reisub.dreambot.cagility.Obstacle; import io.reisub.dreambot.util.Constants; import io.reisub.dreambot.util.Util; import org.dreambot.api.input.Mouse; +import org.dreambot.api.input.event.impl.InteractionEvent; +import org.dreambot.api.input.event.impl.InteractionSetting; +import org.dreambot.api.input.mouse.destination.impl.EntityDestination; import org.dreambot.api.input.mouse.destination.impl.MiniMapTileDestination; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.MethodContext; @@ -84,7 +87,8 @@ public class HandleObstacle extends TaskNode { new Tile(2721, 3489, 3), new Tile(2730, 3489, 3), new Tile(2730, 3497, 3), - new Tile(2721, 3497, 3))), + new Tile(2721, 3497, 3)), + () -> Players.localPlayer().getTile().equals(new Tile(2729, 3491, 3))), new Obstacle(14932, new Area( new Tile(2715, 3487, 2), new Tile(2715, 3498, 2), @@ -145,7 +149,7 @@ public class HandleObstacle extends TaskNode { private final Course course; private final Map hoverMap; - private Obstacle current; + public static Obstacle current; private int retries = 0; public HandleObstacle(Course course) { @@ -196,6 +200,7 @@ public class HandleObstacle extends TaskNode { } Tile finalTarget = target; + if (!MethodProvider.sleepUntil(() -> Players.localPlayer().isMoving(), Calculations.random(1200, 1500))) continue; MethodContext.sleepUntil(() -> finalTarget.distance(Players.localPlayer()) < Calculations.random(4, 7), Calculations.random(14000, 15000)); } } @@ -221,6 +226,10 @@ public class HandleObstacle extends TaskNode { Mouse.move(hoverRect); } + if (!Util.sleepUntilMoving(Calculations.random(1200, 1500))) { + return Calculations.random(180, 350); + } + if (isWalking) { Util.sleepUntilMovingAndAnimating(Calculations.random(12000, 13000)); } else { @@ -232,7 +241,10 @@ public class HandleObstacle extends TaskNode { public void interact(GameObject currentObject, boolean shouldHop) { Mouse.setAlwaysHop(shouldHop); - currentObject.interactForceLeft(currentObject.getActions()[0]); + EntityDestination ed = new EntityDestination(currentObject); + InteractionEvent ie = new InteractionEvent(ed); + ie.interact(currentObject.getActions()[0], InteractionSetting.EMPTY_SETTING, InteractionSetting.FORCE_LEFT_CLICK); + //currentObject.interactForceLeft(currentObject.getActions()[0]); Mouse.setAlwaysHop(false); Tile dest = null; @@ -244,8 +256,10 @@ public class HandleObstacle extends TaskNode { dest = Walking.getDestination(); } + if (dest == null) return; + if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) { - MethodProvider.log("Misclick, trying again"); + MethodProvider.log("Misclick, trying again "); interact(currentObject, true); } }