m6P9aRdAb4Z0 Posted March 23, 2016 Share Posted March 23, 2016 Source: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Spells.NormalSpells; import org.osbot.rs07.input.mouse.PointDestination; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; // Requires Kandarin Hard Diary Completed (Seers Bank Teleport), Law Runes, Air Staff, Normal Magic Spellbook. // High Enough Agility/Weight Reduction to NOT fail obstacles (~75+?). @ScriptManifest(name = "SeersAgility", author = "Anonymous", version = 1.0, info = "", logo = "") public class SeersAgility extends Script { private static final Area Stage_1 = new Area(2718, 3479, 2732, 3499), Stage_2 = new Area(2721, 3490, 2730, 3497), Stage_3 = new Area(2704, 3487, 2714, 3498), Stage_4 = new Area(2709, 3476, 2716, 3482), Stage_5 = new Area(2699, 3469, 2716, 3476), Stage_6 = new Area(2690, 3459, 2703, 3466), Stage_7 = new Area(2704, 3464, 2704, 3464); private static final int MARK = 11849; private static Instant start; private static int hopTime; private static PointDestination s1, s2, s3, s4, s5, s6, s7; private static RS2Object obstacle; @Override public void onStart() { Stage_2.setPlane(3); Stage_3.setPlane(2); Stage_4.setPlane(2); Stage_5.setPlane(3); Stage_6.setPlane(2); camera.toTop(); camera.moveYaw(random(0, 7)); hopTime = random(1800, 3600); start = Instant.now(); getExperienceTracker().start(Skill.AGILITY); } private enum State { MARK, WAIT, HOP, CAMERA, STAGE_1, STAGE_2, STAGE_3, STAGE_4, STAGE_5, STAGE_6, STAGE_7 }; private State getState() { if (isGroundItemValid(groundItems.closest(MARK))) return State.MARK; if (Duration.between(start, Instant.now()).getSeconds() > hopTime) return State.HOP; if (Stage_1.contains(myPlayer())) return State.STAGE_1; if (Stage_2.contains(myPlayer())) return State.STAGE_2; if (Stage_3.contains(myPlayer())) return State.STAGE_3; if (Stage_4.contains(myPlayer())) return State.STAGE_4; if (Stage_5.contains(myPlayer())) return State.STAGE_5; if (camera.getPitchAngle() != 67 || camera.getYawAngle() >= 8) return State.CAMERA; if (Stage_6.contains(myPlayer())) return State.STAGE_6; if (Stage_7.contains(myPlayer())) return State.STAGE_7; if (myPlayer().getZ() == 0) System.exit(0); return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case CAMERA: camera.toTop(); camera.moveYaw(random(0, 7)); break; case MARK: if (groundItems.closest(MARK).interact("Take")) { long c = getInventory().getAmount(MARK); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return (getInventory().getAmount(MARK) > c); } }.sleep(); } break; case HOP: if (!myPlayer().isMoving() && !myPlayer().isAnimating() && worlds.hopToP2PWorld()) { start = Instant.now(); hopTime = random(1800, 3600); } break; case STAGE_1: obstacle = objects.closest(11373); if (isObjectValid(obstacle)) { if (obstacle.isVisible()) { if (mouse.isOnCursor(obstacle)) { mouse.click(false); } else { obstacle.interact("Climb-up"); } s1 = new PointDestination(getBot(), mouse.getPosition()); new ConditionalSleep(1000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isMoving() || myPlayer().isAnimating()); } }.sleep(); if (myPlayer().isMoving() || myPlayer().isAnimating()) { mouse.move(s2); mouse.moveVerySlightly(); new ConditionalSleep(4000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().getZ() != 0); } }.sleep(); } } else if (!myPlayer().isMoving() && !myPlayer().isAnimating()) { camera.toEntity(obstacle); } } break; case STAGE_2: obstacle = objects.closest(11374); if (isObjectValid(obstacle)) { if (obstacle.isVisible()) { if (mouse.isOnCursor(obstacle)) { mouse.click(false); } else { obstacle.interact("Jump"); } s2 = new PointDestination(getBot(), mouse.getPosition()); new ConditionalSleep(1000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isMoving() || myPlayer().isAnimating()); } }.sleep(); if (myPlayer().isMoving() || myPlayer().isAnimating()) { mouse.move(s3); mouse.moveVerySlightly(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().getZ() != 3); } }.sleep(); } } else if (!myPlayer().isMoving() && !myPlayer().isAnimating()) { camera.toTop(); camera.moveYaw(random(0, 7)); } } break; case STAGE_3: obstacle = objects.closest(11378); if (isObjectValid(obstacle)) { if (obstacle.isVisible()) { sleep(random(400, 500)); if (mouse.isOnCursor(obstacle)) { mouse.click(false); } else { obstacle.interact("Cross"); } s3 = new PointDestination(getBot(), mouse.getPosition()); new ConditionalSleep(1000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isMoving() || myPlayer().isAnimating()); } }.sleep(); if (myPlayer().isMoving() || myPlayer().isAnimating()) { mouse.move(s4); mouse.moveVerySlightly(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return (Stage_4.contains(myPlayer())); } }.sleep(); } } else if (!myPlayer().isMoving() && !myPlayer().isAnimating()) { camera.toEntity(obstacle); } } break; case STAGE_4: obstacle = objects.closest(11375); if (isObjectValid(obstacle)) { if (obstacle.isVisible()) { if (mouse.isOnCursor(obstacle)) { mouse.click(false); } else { obstacle.interact("Jump"); } s4 = new PointDestination(getBot(), mouse.getPosition()); new ConditionalSleep(1000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isMoving() || myPlayer().isAnimating()); } }.sleep(); if (myPlayer().isMoving() || myPlayer().isAnimating()) { mouse.move(s5); mouse.moveVerySlightly(); new ConditionalSleep(4000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().getZ() != 2); } }.sleep(); } } else if (!myPlayer().isMoving() && !myPlayer().isAnimating()) { camera.toEntity(obstacle); } } break; case STAGE_5: obstacle = objects.closest(11376); if (isObjectValid(obstacle)) { if (obstacle.isVisible()) { sleep(random(400, 500)); if (mouse.isOnCursor(obstacle)) { mouse.click(false); } else { obstacle.interact("Jump"); } s5 = new PointDestination(getBot(), mouse.getPosition()); new ConditionalSleep(1000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isMoving() || myPlayer().isAnimating()); } }.sleep(); if (myPlayer().isMoving() || myPlayer().isAnimating()) { mouse.move(s6); mouse.moveVerySlightly(); if (camera.getYawAngle() >= 8) { camera.moveYaw(random(0, 7)); } new ConditionalSleep(6000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().getZ() != 3); } }.sleep(); } } else if (myPlayer().getX() == 2712 && myPlayer().getY() == 3472) { camera.moveYaw(random(25, 46)); } else if (!myPlayer().isMoving() && !myPlayer().isAnimating()) { camera.toEntity(obstacle); } } break; case STAGE_6: obstacle = objects.closest(11377); if (isObjectValid(obstacle)) { if (obstacle.isVisible()) { sleep(random(400, 500)); if (mouse.isOnCursor(obstacle)) { mouse.click(false); } else { obstacle.interact("Jump"); } s6 = new PointDestination(getBot(), mouse.getPosition()); new ConditionalSleep(1000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isMoving() || myPlayer().isAnimating()); } }.sleep(); if (myPlayer().isMoving() || myPlayer().isAnimating()) { mouse.move(s7); mouse.moveVerySlightly(); new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().getZ() != 2); } }.sleep(); } } else if (!myPlayer().isMoving() && !myPlayer().isAnimating()) { camera.toEntity(obstacle); } } break; case STAGE_7: sleep(random(300, 400)); if (magic.castSpell(NormalSpells.CAMELOT_TELEPORT)) { s7 = new PointDestination(getBot(), mouse.getPosition()); mouse.move(s1); mouse.moveVerySlightly(); new ConditionalSleep(4000) { @Override public boolean condition() throws InterruptedException { return (Stage_1.contains(myPlayer())); } }.sleep(); } break; case WAIT: break; } return gRandom(215, 80); } public void onPaint(Graphics2D g) { g.setColor(Color.WHITE); g.setFont(new Font("Arial", 0, 14)); g.drawString("Duration: " + formatTime(getExperienceTracker().getElapsed(Skill.AGILITY)), 25, 265); g.drawString("", 25, 280); g.drawString("XP/hr: " + getExperienceTracker().getGainedXPPerHour(Skill.AGILITY), 25, 295); g.drawString("", 25, 310); g.drawString("TTL: " + formatTime(getExperienceTracker().getTimeToLevel(Skill.AGILITY)), 25, 325); } private String formatTime(long ms) { long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } private boolean isObjectValid(RS2Object object) { return object != null && object.exists() && map.canReach(object); } private boolean isGroundItemValid(GroundItem item) { return item != null && map.canReach(item) && item.isVisible() && item.getPosition().distance(myPlayer().getPosition()) <= 7; } } Longest prog: Requires Kandarin Hard Diary completed (Seers Teleport). Also there is no obstacle-fail handling, so have high enough agility (+L75). Quote Link to comment Share on other sites More sharing options...
Vilius Posted March 23, 2016 Share Posted March 23, 2016 Oh wow, this code repetition Quote Link to comment Share on other sites More sharing options...
pernicova Posted January 2, 2017 Share Posted January 2, 2017 cant had it, any trick? Quote Link to comment Share on other sites More sharing options...