Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AlphaRunner extends Script implements Painting {
- private static final Font FONT = new Font("Arial", Font.PLAIN, 14);
- private static final int MINIMUM_HP_RATIO = 10;
- private final AtomicReference<String> status = new AtomicReference<>("");
- private final AgilityCourse course = AgilityCourse.AL_KHARID_ROOF;
- private final ABCUtil abcUtil = new ABCUtil();
- @Override
- public void run() {
- ThreadSettings.get().setClickingAPIUseDynamic(true);
- while (true) {
- //pick up marks
- if (course.isRoof()) {
- RSGroundItem[] marks = GroundItems.find(Filters.GroundItems.nameEquals("Mark of grace").combine(new Filter<RSGroundItem>() {
- @Override
- public boolean accept(RSGroundItem rsGroundItem) {
- return MyWalking.canReach(rsGroundItem.getPosition());
- }
- }, false));
- if (marks.length > 0) {
- if (!marks[0].isOnScreen()) {
- MyWalking.walk(marks[0]);
- continue;
- }
- final int count = Inventory.getCount("Mark of grace");
- if (!marks[0].click("Take") || !Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Game.getCrosshairState() == 2;
- }
- }, 500) || !Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Inventory.getCount("Mark of grace") > count;
- }
- }, 4000)) continue;
- }
- }
- //eat food
- if (course != AgilityCourse.GNOME_COURSE) {
- final RSItem[] food = Inventory.find(Filters.Items.actionsContains("Eat"));
- final int hpRatio = Combat.getHPRatio();
- if (food.length > 0 && hpRatio <= abcUtil.INT_TRACKER.NEXT_EAT_AT.next()) {
- if (!food[0].click("Eat") || !Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Combat.getHPRatio() > hpRatio;
- }
- }, 3000)) continue;
- abcUtil.INT_TRACKER.NEXT_EAT_AT.reset();
- } else if (hpRatio < MINIMUM_HP_RATIO) {
- System.out.println("Logging out: Out of food");
- Login.logout();
- return;
- }
- }
- //enable run
- if (Game.getRunEnergy() <= abcUtil.INT_TRACKER.NEXT_RUN_AT.next() && Options.setRunOn(true)) {
- abcUtil.INT_TRACKER.NEXT_RUN_AT.reset();
- }
- stepCourse(course);
- sleep(100);
- }
- }
- /**
- * Step over the next obstacle in the course.
- * @param course The course that you want to traverse
- */
- public void stepCourse(final AgilityCourse course) {
- final Obstacle obstacle = course.getNextObstacle();
- if (obstacle == null) {
- final Obstacle nearest = course.getNearestObstacle();
- MyWalking.walk(Utility.getCenterTile(nearest.area));
- return;
- }
- final Rectangle bounds = obstacle.area.polygon.getBounds();
- final RSObject[] object = Objects.findNearest(Math.max(bounds.width, bounds.height) + 1, obstacle.name);
- if (object.length > 0) {
- if (object[0].getPosition().distanceTo(Player.getPosition()) > 4) {
- status.set("Walking to " + obstacle.name + "...");
- MyWalking.walk(object[0].getPosition());
- return;
- }
- if (!object[0].isOnScreen()) {
- status.set("Turning camera to " + object[0].getPosition());
- Camera.turnToTile(object[0]);
- }
- RSObjectDefinition def = object[0].getDefinition();
- if (def == null) return;
- final String action = def.getActions()[0];
- status.set("Clicking " + obstacle.name + "...");
- if (object[0].click(action) && Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Game.getCrosshairState() == 2;
- }
- }, 500)) {
- status.set("Performing action " + action + "...");
- if (Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- Obstacle next = course.getNextObstacle();
- return next != null && next != obstacle;
- }
- }, 10000)) {
- status.set("Successfully " + action + " " + obstacle.name);
- }
- } else status.set("Failed to click " + obstacle.name);
- }
- }
- @Override
- public void onPaint(Graphics g) {
- g.setFont(FONT);
- g.setColor(Color.LIGHT_GRAY);
- g.drawString(status.get(), 10, 30);
- }
- }
- /**
- * Obstacle wrapper
- */
- class Obstacle {
- public final String name;
- public final RSArea area;
- Obstacle(String name, RSArea area) {
- this.name = name;
- this.area = area;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement