Compare commits
6 Commits
97d34e4415
...
7b94322749
Author | SHA1 | Date | |
---|---|---|---|
7b94322749
|
|||
992f3ed17e
|
|||
1d8aaabdaa
|
|||
a7a172525c
|
|||
d094033e6c
|
|||
34586a83f6
|
@ -3,6 +3,7 @@ package io.reisub.dreambot.cagility;
|
|||||||
import io.reisub.dreambot.cagility.tasks.HandleObstacle;
|
import io.reisub.dreambot.cagility.tasks.HandleObstacle;
|
||||||
import io.reisub.dreambot.cagility.tasks.PickupMark;
|
import io.reisub.dreambot.cagility.tasks.PickupMark;
|
||||||
import io.reisub.dreambot.util.Constants;
|
import io.reisub.dreambot.util.Constants;
|
||||||
|
import io.reisub.dreambot.util.randomevents.GenieSolver;
|
||||||
import io.reisub.dreambot.util.tasks.Eat;
|
import io.reisub.dreambot.util.tasks.Eat;
|
||||||
import io.reisub.dreambot.util.tasks.kitten.KittenTask;
|
import io.reisub.dreambot.util.tasks.kitten.KittenTask;
|
||||||
import org.dreambot.api.script.Category;
|
import org.dreambot.api.script.Category;
|
||||||
@ -14,6 +15,8 @@ import org.dreambot.api.script.impl.TaskScript;
|
|||||||
public class CAgility extends TaskScript {
|
public class CAgility extends TaskScript {
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
|
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
|
||||||
|
|
||||||
addNodes(
|
addNodes(
|
||||||
new Eat(),
|
new Eat(),
|
||||||
KittenTask.createKittenTask(),
|
KittenTask.createKittenTask(),
|
||||||
|
@ -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) {
|
||||||
MethodContext.logError("Player is in an unsupported area: " + Players.localPlayer().getTile().toString() + ". Stopping.");
|
if (retries >= 10) {
|
||||||
ScriptManager.getScriptManager().stop();
|
MethodContext.logError("Player is in an unsupported area: " + Players.localPlayer().getTile().toString() + ". Stopping.");
|
||||||
return 0;
|
ScriptManager.getScriptManager().stop();
|
||||||
|
} 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +145,11 @@ public class HandleObstacle extends TaskNode {
|
|||||||
Mouse.move(hoverRect);
|
Mouse.move(hoverRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.sleepUntilMovingAndAnimating(Calculations.random(9000, 10000));
|
if (!Util.sleepUntilMoving(Calculations.random(1200, 1800))) {
|
||||||
|
return Calculations.random( 180, 350);
|
||||||
|
}
|
||||||
|
|
||||||
|
Util.sleepUntilMovingAndAnimating(Calculations.random(6000, 7000));
|
||||||
|
|
||||||
return Calculations.random(180, 350);
|
return Calculations.random(180, 350);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class CNPC {
|
|||||||
for (NPC npc : npcs) {
|
for (NPC npc : npcs) {
|
||||||
Character c = npc.getInteractingCharacter();
|
Character c = npc.getInteractingCharacter();
|
||||||
|
|
||||||
if (c != null && c.getName().equals(Players.localPlayer().getName())) {
|
if (c != null && c.getName() != null && c.getName().equals(Players.localPlayer().getName())) {
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ public class Constants {
|
|||||||
|
|
||||||
// Items/GameObjects/NPCs
|
// Items/GameObjects/NPCs
|
||||||
public static final String KITTEN = "Kitten";
|
public static final String KITTEN = "Kitten";
|
||||||
|
public static final String KITTEN_INVENTORY = "Pet kitten";
|
||||||
public static final String CAT = "Cat";
|
public static final String CAT = "Cat";
|
||||||
public static final String[] KITTEN_FISH_NAMES = new String[]{
|
public static final String[] KITTEN_FISH_NAMES = new String[]{
|
||||||
"Shrimp",
|
"Shrimp",
|
||||||
|
@ -21,69 +21,55 @@ public class Util {
|
|||||||
return !player.isMoving() && !player.isAnimating();
|
return !player.isMoving() && !player.isAnimating();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMoving() {
|
public static boolean sleepUntilMoving() {
|
||||||
return sleepUntilMoving(Calculations.random(3000, 3500));
|
return sleepUntilMoving(Calculations.random(3000, 3500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMoving(long timeout) {
|
public static boolean sleepUntilMoving(long timeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Player player = Players.localPlayer();
|
Player player = Players.localPlayer();
|
||||||
|
|
||||||
MethodContext.sleepUntil(() -> player.isMoving(), timeout);
|
return MethodContext.sleepUntil(player::isMoving, timeout);
|
||||||
|
|
||||||
return (int) (System.currentTimeMillis() - start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilAnimating() {
|
public static boolean sleepUntilAnimating() {
|
||||||
return sleepUntilAnimating(Calculations.random(3000, 3500));
|
return sleepUntilAnimating(Calculations.random(3000, 3500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilAnimating(long timeout) {
|
public static boolean sleepUntilAnimating(long timeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Player player = Players.localPlayer();
|
Player player = Players.localPlayer();
|
||||||
|
|
||||||
MethodContext.sleepUntil(() -> player.isAnimating(), timeout);
|
return MethodContext.sleepUntil(player::isAnimating, timeout);
|
||||||
|
|
||||||
return (int) (System.currentTimeMillis() - start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingOrAnimating() {
|
public static boolean sleepUntilMovingOrAnimating() {
|
||||||
return sleepUntilMovingOrAnimating(Calculations.random(3000, 3500));
|
return sleepUntilMovingOrAnimating(Calculations.random(3000, 3500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingOrAnimating(long timeout) {
|
public static boolean sleepUntilMovingOrAnimating(long timeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Player player = Players.localPlayer();
|
Player player = Players.localPlayer();
|
||||||
|
|
||||||
MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
return MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
||||||
|
|
||||||
return (int) (System.currentTimeMillis() - start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingAndAnimating() {
|
public static boolean sleepUntilMovingAndAnimating() {
|
||||||
return sleepUntilMovingAndAnimating(Calculations.random(5000, 5500));
|
return sleepUntilMovingAndAnimating(Calculations.random(5000, 5500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int sleepUntilMovingAndAnimating(long timeout) {
|
public static boolean sleepUntilMovingAndAnimating(long timeout) {
|
||||||
int elapsed = sleepUntilMovingOrAnimating(timeout);
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if (timeout - elapsed < 0) {
|
if (!sleepUntilMoving(timeout)) {
|
||||||
return elapsed;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - elapsed);
|
if (!MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - (System.currentTimeMillis() - start))) {
|
||||||
|
return false;
|
||||||
elapsed += (System.currentTimeMillis() - start);
|
|
||||||
|
|
||||||
if (timeout - elapsed < 0) {
|
|
||||||
return elapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsed += sleepUntilAnimating(timeout - elapsed);
|
return sleepUntilAnimating(timeout - (System.currentTimeMillis() - start));
|
||||||
|
|
||||||
return elapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCurrentHP() {
|
public static int getCurrentHP() {
|
||||||
|
@ -33,8 +33,8 @@ public class KittenTask extends TaskNodeParent {
|
|||||||
public static KittenTask createKittenTask() {
|
public static KittenTask createKittenTask() {
|
||||||
KittenTask task = null;
|
KittenTask task = null;
|
||||||
|
|
||||||
if (Inventory.contains(Constants.KITTEN)) {
|
if (Inventory.contains(Constants.KITTEN_INVENTORY)) {
|
||||||
Inventory.drop(Constants.KITTEN);
|
Inventory.drop(Constants.KITTEN_INVENTORY);
|
||||||
|
|
||||||
task = new KittenTask();
|
task = new KittenTask();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user