Add CAgility script
This commit is contained in:
parent
a4737f548a
commit
bc6e82e409
9
.idea/artifacts/CAgility_jar.xml
generated
Normal file
9
.idea/artifacts/CAgility_jar.xml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" name="CAgility:jar">
|
||||||
|
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
|
||||||
|
<root id="archive" name="CAgility.jar">
|
||||||
|
<element id="module-output" name="CAgility" />
|
||||||
|
<element id="module-output" name="Util" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@ -2,6 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/CAgility/CAgility.iml" filepath="$PROJECT_DIR$/CAgility/CAgility.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/CBlackjack/CBlackjack.iml" filepath="$PROJECT_DIR$/CBlackjack/CBlackjack.iml" />
|
<module fileurl="file://$PROJECT_DIR$/CBlackjack/CBlackjack.iml" filepath="$PROJECT_DIR$/CBlackjack/CBlackjack.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/CDebug/CDebug.iml" filepath="$PROJECT_DIR$/CDebug/CDebug.iml" />
|
<module fileurl="file://$PROJECT_DIR$/CDebug/CDebug.iml" filepath="$PROJECT_DIR$/CDebug/CDebug.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/CFisher/CFisher.iml" filepath="$PROJECT_DIR$/CFisher/CFisher.iml" />
|
<module fileurl="file://$PROJECT_DIR$/CFisher/CFisher.iml" filepath="$PROJECT_DIR$/CFisher/CFisher.iml" />
|
||||||
|
13
CAgility/CAgility.iml
Normal file
13
CAgility/CAgility.iml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="client" level="project" />
|
||||||
|
<orderEntry type="module" module-name="Util" />
|
||||||
|
</component>
|
||||||
|
</module>
|
24
CAgility/src/io/reisub/dreambot/cagility/CAgility.java
Normal file
24
CAgility/src/io/reisub/dreambot/cagility/CAgility.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package io.reisub.dreambot.cagility;
|
||||||
|
|
||||||
|
import io.reisub.dreambot.cagility.tasks.HandleObstacle;
|
||||||
|
import io.reisub.dreambot.cagility.tasks.PickupMark;
|
||||||
|
import io.reisub.dreambot.util.Constants;
|
||||||
|
import io.reisub.dreambot.util.tasks.Eat;
|
||||||
|
import io.reisub.dreambot.util.tasks.kitten.KittenTask;
|
||||||
|
import org.dreambot.api.script.Category;
|
||||||
|
import org.dreambot.api.script.ScriptManifest;
|
||||||
|
import org.dreambot.api.script.impl.TaskScript;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@ScriptManifest(category = Category.AGILITY, name = "CAgility", description = "Runs laps for days", author = Constants.AUTHOR, version = 1.0)
|
||||||
|
public class CAgility extends TaskScript {
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
addNodes(
|
||||||
|
new Eat(),
|
||||||
|
KittenTask.createKittenTask(),
|
||||||
|
new HandleObstacle(HandleObstacle.Course.CANIFIS),
|
||||||
|
new PickupMark()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
39
CAgility/src/io/reisub/dreambot/cagility/Obstacle.java
Normal file
39
CAgility/src/io/reisub/dreambot/cagility/Obstacle.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package io.reisub.dreambot.cagility;
|
||||||
|
|
||||||
|
import org.dreambot.api.methods.interactive.GameObjects;
|
||||||
|
import org.dreambot.api.wrappers.interactive.GameObject;
|
||||||
|
|
||||||
|
public class Obstacle {
|
||||||
|
private final int id;
|
||||||
|
private final boolean retry;
|
||||||
|
private Obstacle next;
|
||||||
|
|
||||||
|
public Obstacle(int id, boolean canRetry) {
|
||||||
|
this.id = id;
|
||||||
|
this.retry = canRetry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Obstacle(int id) {
|
||||||
|
this(id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canRetry() {
|
||||||
|
return this.retry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameObject getGameObject() {
|
||||||
|
return GameObjects.closest(getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Obstacle getNext() {
|
||||||
|
return this.next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNext(Obstacle next) {
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
package io.reisub.dreambot.cagility.tasks;
|
||||||
|
|
||||||
|
import io.reisub.dreambot.cagility.Obstacle;
|
||||||
|
import io.reisub.dreambot.util.Constants;
|
||||||
|
import io.reisub.dreambot.util.Util;
|
||||||
|
import io.reisub.dreambot.util.event.ListenerManager;
|
||||||
|
import io.reisub.dreambot.util.event.health.HealthListener;
|
||||||
|
import org.dreambot.api.input.Mouse;
|
||||||
|
import org.dreambot.api.methods.Calculations;
|
||||||
|
import org.dreambot.api.methods.MethodContext;
|
||||||
|
import org.dreambot.api.methods.interactive.Players;
|
||||||
|
import org.dreambot.api.methods.item.GroundItems;
|
||||||
|
import org.dreambot.api.methods.skills.Skill;
|
||||||
|
import org.dreambot.api.methods.walking.impl.Walking;
|
||||||
|
import org.dreambot.api.script.ScriptManager;
|
||||||
|
import org.dreambot.api.script.TaskNode;
|
||||||
|
import org.dreambot.api.script.event.impl.ExperienceEvent;
|
||||||
|
import org.dreambot.api.script.listener.ExperienceListener;
|
||||||
|
import org.dreambot.api.wrappers.interactive.GameObject;
|
||||||
|
import org.dreambot.api.wrappers.items.GroundItem;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HandleObstacle extends TaskNode {
|
||||||
|
public enum Course {
|
||||||
|
CANIFIS(
|
||||||
|
new Obstacle(14843),
|
||||||
|
new Obstacle(14844),
|
||||||
|
new Obstacle(14845),
|
||||||
|
new Obstacle(14848),
|
||||||
|
new Obstacle(14846),
|
||||||
|
new Obstacle(14894),
|
||||||
|
new Obstacle(14847),
|
||||||
|
new Obstacle(14897)
|
||||||
|
);
|
||||||
|
|
||||||
|
private final Obstacle firstObstacle;
|
||||||
|
|
||||||
|
Course(Obstacle... obstacles) {
|
||||||
|
this.firstObstacle = obstacles[0];
|
||||||
|
|
||||||
|
for (int i = 0; i < obstacles.length; i++) {
|
||||||
|
if (i + 1 == obstacles.length) {
|
||||||
|
obstacles[i].setNext(obstacles[0]);
|
||||||
|
} else {
|
||||||
|
obstacles[i].setNext(obstacles[i+1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Course course;
|
||||||
|
private final Map<Integer, Rectangle> hoverMap;
|
||||||
|
private Obstacle lastObstacle = null;
|
||||||
|
private boolean failed, obstacleCompleted = false;
|
||||||
|
|
||||||
|
public HandleObstacle(Course course) {
|
||||||
|
this.course = course;
|
||||||
|
this.hoverMap = new HashMap<>();
|
||||||
|
|
||||||
|
ListenerManager.getInstance().addListener(new HealthListener() {
|
||||||
|
@Override
|
||||||
|
public void onHealthDecreased(int oldValue, int newValue) {
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ScriptManager.getScriptManager().addListener(new ExperienceListener() {
|
||||||
|
@Override
|
||||||
|
public void onGained(ExperienceEvent event) {
|
||||||
|
if (event.getSkill().equals(Skill.AGILITY)) {
|
||||||
|
obstacleCompleted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept() {
|
||||||
|
GroundItem mark = GroundItems.closest(Constants.MARK_OF_GRACE);
|
||||||
|
|
||||||
|
return Util.playerIsIdle() && (mark == null || !mark.canReach());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int execute() {
|
||||||
|
Obstacle current;
|
||||||
|
|
||||||
|
if (lastObstacle == null) {
|
||||||
|
current = course.firstObstacle;
|
||||||
|
} else {
|
||||||
|
if (failed) {
|
||||||
|
if (lastObstacle.canRetry()) {
|
||||||
|
current = lastObstacle;
|
||||||
|
} else {
|
||||||
|
current = course.firstObstacle;
|
||||||
|
}
|
||||||
|
failed = false;
|
||||||
|
} else {
|
||||||
|
current = lastObstacle.getNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final GameObject currentObject = current.getGameObject();
|
||||||
|
if (currentObject == null) return Calculations.random(300, 500);
|
||||||
|
|
||||||
|
if (!currentObject.isOnScreen()) {
|
||||||
|
Walking.clickTileOnMinimap(currentObject.getTile());
|
||||||
|
MethodContext.sleepUntil(() -> Players.localPlayer().distance(currentObject) < 3, Calculations.random(5000, 5500));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hoverMap.get(current.getID()) == null) {
|
||||||
|
hoverMap.put(current.getID(), currentObject.getBoundingBox());
|
||||||
|
}
|
||||||
|
|
||||||
|
currentObject.interact();
|
||||||
|
|
||||||
|
lastObstacle = current;
|
||||||
|
|
||||||
|
Rectangle hoverRect = hoverMap.get(current.getNext().getID());
|
||||||
|
if (hoverRect != null) {
|
||||||
|
Mouse.move(hoverRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodContext.sleepUntil(() -> failed || obstacleCompleted, Calculations.random(9000, 10000));
|
||||||
|
|
||||||
|
obstacleCompleted = false;
|
||||||
|
|
||||||
|
return Calculations.random(180, 350);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package io.reisub.dreambot.cagility.tasks;
|
||||||
|
|
||||||
|
import io.reisub.dreambot.util.Constants;
|
||||||
|
import org.dreambot.api.methods.Calculations;
|
||||||
|
import org.dreambot.api.methods.MethodContext;
|
||||||
|
import org.dreambot.api.methods.container.impl.Inventory;
|
||||||
|
import org.dreambot.api.methods.item.GroundItems;
|
||||||
|
import org.dreambot.api.script.TaskNode;
|
||||||
|
import org.dreambot.api.wrappers.items.GroundItem;
|
||||||
|
import org.dreambot.api.wrappers.items.Item;
|
||||||
|
|
||||||
|
public class PickupMark extends TaskNode {
|
||||||
|
@Override
|
||||||
|
public boolean accept() {
|
||||||
|
GroundItem mark = GroundItems.closest(Constants.MARK_OF_GRACE);
|
||||||
|
|
||||||
|
return mark != null && mark.canReach();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int execute() {
|
||||||
|
GroundItem mark = GroundItems.closest(Constants.MARK_OF_GRACE);
|
||||||
|
|
||||||
|
if (mark == null || !mark.canReach()) return 0;
|
||||||
|
|
||||||
|
Item marks = Inventory.get(Constants.MARK_OF_GRACE);
|
||||||
|
final int count = marks == null ? 0 : marks.getAmount();
|
||||||
|
|
||||||
|
mark.interact();
|
||||||
|
|
||||||
|
MethodContext.sleepUntil(() -> {
|
||||||
|
Item currentMarks = Inventory.get(Constants.MARK_OF_GRACE);
|
||||||
|
return currentMarks != null && currentMarks.getAmount() > count;
|
||||||
|
}, Calculations.random(5000, 5500));
|
||||||
|
|
||||||
|
return Calculations.random(250, 400);
|
||||||
|
}
|
||||||
|
}
|
@ -47,6 +47,7 @@ public class Constants {
|
|||||||
public static final String BRUMA_ROOTS = "Bruma roots";
|
public static final String BRUMA_ROOTS = "Bruma roots";
|
||||||
public static final String BRAZIER = "Brazier";
|
public static final String BRAZIER = "Brazier";
|
||||||
public static final String BURNING_BRAZIER = "Burning brazier";
|
public static final String BURNING_BRAZIER = "Burning brazier";
|
||||||
|
public static final String MARK_OF_GRACE = "Mark of grace";
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
public static final String USE = "Use";
|
public static final String USE = "Use";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user