Optimize Seers agility course

This commit is contained in:
Yuri Moens 2021-10-28 00:00:55 +02:00
parent 7f44187e6b
commit 1aa793b4bf
Signed by: ymo
GPG Key ID: F6D51D6FE15BE924
2 changed files with 22 additions and 4 deletions

View File

@ -44,5 +44,9 @@ public class CAgility extends CTaskScript {
int marks = PickupMark.marksPickedUp; int marks = PickupMark.marksPickedUp;
getUI().drawString("Marks picked up: " + marks + " (" + getUI().getHourlyRate(marks) + " per hour)"); 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);
}
} }
} }

View File

@ -4,6 +4,9 @@ import io.reisub.dreambot.cagility.Obstacle;
import io.reisub.dreambot.util.Constants; import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.Util; import io.reisub.dreambot.util.Util;
import org.dreambot.api.input.Mouse; 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.input.mouse.destination.impl.MiniMapTileDestination;
import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext; import org.dreambot.api.methods.MethodContext;
@ -84,7 +87,8 @@ public class HandleObstacle extends TaskNode {
new Tile(2721, 3489, 3), new Tile(2721, 3489, 3),
new Tile(2730, 3489, 3), new Tile(2730, 3489, 3),
new Tile(2730, 3497, 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 Obstacle(14932, new Area(
new Tile(2715, 3487, 2), new Tile(2715, 3487, 2),
new Tile(2715, 3498, 2), new Tile(2715, 3498, 2),
@ -145,7 +149,7 @@ 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 Obstacle current; public static Obstacle current;
private int retries = 0; private int retries = 0;
public HandleObstacle(Course course) { public HandleObstacle(Course course) {
@ -196,6 +200,7 @@ public class HandleObstacle extends TaskNode {
} }
Tile finalTarget = target; 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)); 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); Mouse.move(hoverRect);
} }
if (!Util.sleepUntilMoving(Calculations.random(1200, 1500))) {
return Calculations.random(180, 350);
}
if (isWalking) { if (isWalking) {
Util.sleepUntilMovingAndAnimating(Calculations.random(12000, 13000)); Util.sleepUntilMovingAndAnimating(Calculations.random(12000, 13000));
} else { } else {
@ -232,7 +241,10 @@ public class HandleObstacle extends TaskNode {
public void interact(GameObject currentObject, boolean shouldHop) { public void interact(GameObject currentObject, boolean shouldHop) {
Mouse.setAlwaysHop(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); Mouse.setAlwaysHop(false);
Tile dest = null; Tile dest = null;
@ -244,6 +256,8 @@ public class HandleObstacle extends TaskNode {
dest = Walking.getDestination(); dest = Walking.getDestination();
} }
if (dest == null) return;
if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) { if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) {
MethodProvider.log("Misclick, trying again "); MethodProvider.log("Misclick, trying again ");
interact(currentObject, true); interact(currentObject, true);