Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Players;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSObject.Type;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "Speed" }, name = "SpeedIvy", version = 1.01, keywords = { "Woodcutting", "Ivy" }, description = "Cuts ivy in any location.")
- public class SpeedIvy extends Script implements PaintListener, ServerMessageListener {
- private RSTile currentIvy;
- private int ivyChopped;
- private char direction = 'f';
- private long startTime, minutes, hours, seconds, runTime;
- private int startXP;
- private static final int[] NESTS = { 5070, 5071, 5072, 5073, 5074, 5075, 5076, 7413, 11966 };
- private static final int[] IVY_ID = { 46318, 46320, 46322, 46324 };
- public boolean onStart() {
- mouse.setSpeed(random(3, 6));
- return true;
- }
- private boolean isBusy() {
- int timesBusy = 0;
- int timesNotBusy = 0;
- for (int i = 0; i < 10; i++) {
- if (players.getMyPlayer().getAnimation() != -1 || getMyPlayer().isInCombat() || getMyPlayer().isMoving()
- || !getMyPlayer().isIdle())
- timesBusy++;
- else
- timesNotBusy++;
- sleep(random(150, 200));
- }
- return timesBusy >= timesNotBusy;
- }
- private int canChop() {
- while (getMyPlayer().isMoving())
- sleep(random(300, 500));
- return random(300, 500);
- }
- public int loop() {
- if (startTime == 0 && skills.getRealLevel(Skills.CONSTITUTION) > 1) {
- startTime = System.currentTimeMillis();
- startXP = skills.getCurrentExp(Skills.WOODCUTTING);
- }
- if (groundItems.getNearest(NESTS) != null) {
- groundItems.getNearest(NESTS).doAction("Take");
- return canChop();
- }
- if (isBusy()) {
- if (random(0, 5) > 3) {
- switch (random(1, 9)) {
- case 1:
- camera.setAngle((int) (((camera.getAngle() + random(0, 180)) * 3) / 2));
- break;
- case 2:
- mouse.move((int) ((mouse.getLocation().x * 3.5) / 2.5) + random(10, 30),
- ((int) ((mouse.getLocation().y * 3.5) / 2.5) + random(10, 30)));
- break;
- case 3:
- mouse.move((int) ((mouse.getLocation().x * 3.5) / 2.5) + random(10, 30),
- ((int) ((mouse.getLocation().y * 3.5) / 2.5) + random(10, 30)));
- camera.setAngle((int) (((camera.getAngle() + random(0, 180)) * 3) / 2));
- break;
- case 5:
- camera.setAngle((int) (((camera.getAngle() + random(0, 180)) * 3) / 2));
- break;
- case 6:
- final RSObject[] obj = objects.getAll(new Filter<RSObject>() {
- public boolean accept(RSObject t) {
- return t.isOnScreen();
- }
- });
- if (obj.length == 0) {
- break;
- }
- final RSObject ran = obj[random(0, obj.length - 1)];
- if (ran.getType().equals(RSObject.Type.INTERACTABLE)) {
- ran.doAction("Examine");
- }
- break;
- case 7:
- RSPlayer play = players.getNearest(Players.ALL_FILTER);
- if (play.isOnScreen()) {
- mouse.move(play.getScreenLocation());
- sleep(random(300, 800));
- }
- break;
- case 8:
- final RSObject ivy = objects.getNearest(new Filter<RSObject>() {
- public boolean accept(final RSObject t) {
- for (final int i : IVY_ID) {
- if (t.getType().equals(Type.WALL_DECORATION) && !t.getLocation().equals(currentIvy)
- && t.getID() == i) {
- return true;
- }
- }
- return false;
- }
- });
- ivy.doHover();
- sleep(random(900, 1800));
- break;
- default:
- break;
- }
- }
- } else {
- final RSObject ivy = objects.getNearest(new Filter<RSObject>() {
- public boolean accept(final RSObject t) {
- for (final int i : IVY_ID) {
- if (t.getType().equals(Type.WALL_DECORATION) && t.getID() == i) {
- return true;
- }
- }
- return false;
- }
- });
- if (ivy != null) {
- final RSTile ivyTile = ivy.getLocation();
- currentIvy = ivyTile;
- if (direction == 'f') {
- ivyFail(ivy, 0);
- } else {
- camera.setCompass(direction);
- if (!ivy.doAction("Chop"))
- ivyFail(ivy, 0);
- }
- return canChop();
- }
- }
- return random(500, 700);
- }
- private boolean ivyFail(final RSObject ivy, int i) {
- if (i > 3) {
- return ivy.doAction("Chop");
- }
- switch (i) {
- case 0:
- direction = 'n';
- camera.setCompass('n');
- break;
- case 1:
- direction = 'e';
- camera.setCompass('e');
- break;
- case 2:
- direction = 's';
- camera.setCompass('s');
- break;
- case 3:
- direction = 'w';
- camera.setCompass('w');
- break;
- }
- ivy.doAction("Chop");
- canChop();
- return isBusy() ? true : ivyFail(ivy, ++i);
- }
- public void serverMessageRecieved(final ServerMessageEvent e) {
- if (e.getMessage().contains("some")) {
- ivyChopped++;
- }
- }
- public void onRepaint(final Graphics g) {
- runTime = System.currentTimeMillis() - startTime;
- seconds = runTime / 1000;
- if (seconds >= 60) {
- minutes = seconds / 60;
- seconds -= (minutes * 60);
- }
- if (minutes >= 60) {
- hours = minutes / 60;
- minutes -= (hours * 60);
- }
- final int xpGained = skills.getCurrentExp(Skills.WOODCUTTING) - startXP;
- g.drawString("SpeedIvy by Speed.", 15, 30);
- g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds + ".", 15, 45);
- g.drawString("Ivy Chopped: " + ivyChopped + ".", 15, 60);
- g.drawString("XP Gained: " + xpGained + ".", 15, 75);
- }
- }
Add Comment
Please, Sign In to add comment