Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.RenderingHints;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.text.NumberFormat;
- import java.util.concurrent.TimeUnit;
- import javax.imageio.ImageIO;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.util.Timer;
- import com.rarebot.script.wrappers.RSArea;
- import com.rarebot.script.wrappers.RSComponent;
- import com.rarebot.script.wrappers.RSItem;
- import com.rarebot.script.wrappers.RSObject;
- import com.rarebot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "Robert G" }, name = "ApeAgility", version = 1.4)
- public class ApeAgility extends Script implements PaintListener {
- private static final int pineapplePlant = 4827;
- private static final int pineapple = 2114;
- private static final int pineappleRing = 2118;
- private static final int tropicalTree = 12570;
- private static final int monkeyBars = 12573;
- private static final int skullSlope = 12576;
- private static final int ropeSwing = 12578;
- private static final int upperTropicalTree = 12618;
- private static final RSArea steppingStoneArea = new RSArea(2755, 2742, 2779, 2754);
- private static final RSArea tropicalTreeArea = new RSArea(2752, 2742, 2753, 2742);
- private static final RSArea monkeyBarsArea = new RSArea(2752, 2741, 2754, 2742);
- private static final RSTile skullSlopeTile = new RSTile(2747, 2741, 0);
- private static final RSTile[] ropeSwingArea = { new RSTile(2741, 2740),
- new RSTile(2741, 2739), new RSTile(2741, 2738),
- new RSTile(2741, 2733), new RSTile(2741, 2732),
- new RSTile(2742, 2741), new RSTile(2742, 2740),
- new RSTile(2742, 2739), new RSTile(2742, 2738),
- new RSTile(2742, 2737), new RSTile(2742, 2736),
- new RSTile(2742, 2734), new RSTile(2742, 2732),
- new RSTile(2742, 2731), new RSTile(2743, 2741),
- new RSTile(2743, 2740), new RSTile(2743, 2739),
- new RSTile(2743, 2738), new RSTile(2743, 2737),
- new RSTile(2743, 2736), new RSTile(2743, 2735),
- new RSTile(2743, 2734), new RSTile(2743, 2732),
- new RSTile(2743, 2731), new RSTile(2743, 2730),
- new RSTile(2744, 2741), new RSTile(2744, 2740),
- new RSTile(2744, 2739), new RSTile(2744, 2738),
- new RSTile(2744, 2737), new RSTile(2744, 2736),
- new RSTile(2744, 2735), new RSTile(2744, 2734),
- new RSTile(2744, 2732), new RSTile(2744, 2731),
- new RSTile(2744, 2730), new RSTile(2745, 2741),
- new RSTile(2745, 2739), new RSTile(2745, 2737),
- new RSTile(2745, 2736), new RSTile(2745, 2735),
- new RSTile(2745, 2734), new RSTile(2745, 2733),
- new RSTile(2745, 2732), new RSTile(2745, 2731),
- new RSTile(2745, 2730), new RSTile(2745, 2729),
- new RSTile(2746, 2738), new RSTile(2746, 2737),
- new RSTile(2746, 2736), new RSTile(2746, 2735),
- new RSTile(2746, 2734), new RSTile(2746, 2733),
- new RSTile(2746, 2732), new RSTile(2746, 2731),
- new RSTile(2746, 2730), new RSTile(2746, 2729),
- new RSTile(2747, 2736), new RSTile(2747, 2735),
- new RSTile(2747, 2734), new RSTile(2747, 2733),
- new RSTile(2747, 2732), new RSTile(2747, 2729),
- new RSTile(2748, 2735), new RSTile(2748, 2734),
- new RSTile(2748, 2733), new RSTile(2748, 2732),
- new RSTile(2748, 2729), new RSTile(2748, 2728),
- new RSTile(2749, 2734), new RSTile(2749, 2733),
- new RSTile(2749, 2730), new RSTile(2749, 2729),
- new RSTile(2749, 2727), new RSTile(2750, 2734),
- new RSTile(2750, 2733), new RSTile(2750, 2730),
- new RSTile(2750, 2729), new RSTile(2750, 2728),
- new RSTile(2750, 2727), new RSTile(2750, 2726),
- new RSTile(2751, 2733), new RSTile(2751, 2732),
- new RSTile(2751, 2731), new RSTile(2751, 2730),
- new RSTile(2751, 2729), new RSTile(2751, 2728),
- new RSTile(2751, 2727), new RSTile(2751, 2726),
- new RSTile(2751, 2725), new RSTile(2752, 2730),
- new RSTile(2752, 2729) };
- private static final RSArea upperTropicalTreeArea = new RSArea(2756, 2731, 2760, 2736);
- private static int startLVL, curLVL, startXP, curXP;
- private static long startTime, runTime;;
- private static String status = "Loading...";
- private final Color color1 = new Color(0, 0, 0);
- private final Color color2 = new Color(51, 204, 0);
- private final Color color3 = new Color(255, 255, 255, 90);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Cambria", 1, 15);
- private Image img1;
- private Image img2;
- private boolean eat = false;
- private static final NumberFormat nf = NumberFormat.getInstance();
- private static final String versionUrl = "http://pastebin.com/raw.php?i=vGfspk34";
- private static final String scriptUrl = "http://pastebin.com/raw.php?i=WepLnaHm";
- ScriptManifest props = getClass().getAnnotation(ScriptManifest.class);
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private boolean checkVersion(double currentVersion, double latestVersion) {
- return (currentVersion >= latestVersion);
- }
- private double getCurrentVersion(String webUrl, String search) {
- try {
- URL url = new URL(webUrl);
- BufferedReader x = new BufferedReader(new InputStreamReader(url.openStream()));
- String inputLine;
- while ((inputLine = x.readLine()) != null) {
- if (inputLine.contains(search)) {
- return Double.parseDouble(x.readLine());
- }
- }
- x.close();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return -1D;
- }
- @Override
- public boolean onStart() {
- log("Welcome to ApeAgility by Robert G");
- log("Checking version...");
- if (checkVersion(props.version(), getCurrentVersion(versionUrl, props.name()))) {
- log("You have the lates version, starting up.");
- } else {
- log.severe("New version available!, please update.");
- log.severe("Download the new version from here: " + scriptUrl);
- return false;
- }
- if (getText().toLowerCase().contains("eat")) {
- log("Eating enabled.");
- eat = true;
- }
- new imageLoader();
- startLVL = skills.getRealLevel(Skills.AGILITY);
- if (startLVL < 48) {
- log.severe("This script requires 48 agility to run!");
- return false;
- }
- startXP = skills.getCurrentExp(Skills.AGILITY);
- startTime = System.currentTimeMillis();
- return true;
- }
- public class imageLoader extends Thread {
- private imageLoader() {
- Thread t = new Thread(this);
- t.start();
- }
- @Override
- public void run() {
- log("Downloading paint images...");
- img1 = getImage("http://desmond.imageshack.us/Himg821/scaled.php?server=821&filename=cooltext643981409.png&res=medium");
- img2 = getImage("http://img845.imageshack.us/img845/6471/cooltext643985568.png");
- log("Finished downloading paint images.");
- }
- }
- private RSComponent getComp() {
- return interfaces.getComponent(137, 55);
- }
- private String getText() {
- return getComp().getText().trim();
- }
- private boolean canPick() {
- final RSObject pine = objects.getNearest(pineapplePlant);
- return pine != null && steppingStoneArea.contains(pine.getLocation());
- }
- private boolean canCut() {
- return inventory.contains(pineapple);
- }
- private RSComponent getPInt() {
- return interfaces.getComponent(905, 14);
- }
- private boolean inArea(RSArea area) {
- return area.contains(myTile());
- }
- private boolean atSlope() {
- return myTile().equals(skullSlopeTile);
- }
- private boolean atSwing() {
- for (RSTile t : ropeSwingArea) {
- if (myTile().equals(t)) {
- return true;
- }
- }
- return false;
- }
- private boolean idle() {
- return getMyPlayer().isIdle();
- }
- private RSTile myTile() {
- return new RSTile(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- private boolean chop() {
- final RSItem p = inventory.getItem(pineapple);
- if (p != null) {
- if (p.interact("slice")) {
- waitFor();
- }
- if (getPInt().isValid()) {
- return getPInt().doClick();
- }
- }
- return false;
- }
- private boolean eat() {
- final RSItem p = inventory.getItem(pineappleRing);
- if (p != null) {
- return p.interact("eat");
- }
- return false;
- }
- private boolean hasFood() {
- return inventory.contains(pineappleRing);
- }
- private void waitFor() {
- final long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < 2000) {
- sleep(50);
- if (getPInt().isValid())break;
- }
- }
- private boolean walk(RSTile dest) {
- final Point p = calc.tileToMinimap(dest);
- if (eat) {
- return walking.walkTileMM(dest);
- } else {
- if (p.x != -1 && p.y != -1) {
- if (!mouse.getLocation().equals(p)) {
- mouse.hop(p);
- mouse.click(true);
- mouse.moveSlightly();
- return true;
- }
- }
- }
- return false;
- }
- private boolean doObstacle(int id, String action) {
- final RSObject obj = objects.getNearest(id);
- if (obj != null) {
- if (obj.isOnScreen()) {
- mouse.hop(obj.getPoint());
- return obj.interact(action);
- } else {
- if (walk(obj.getLocation())) {
- camera.turnTo(obj);
- return true;
- }
- }
- }
- return false;
- }
- private boolean steppingStone() {
- final RSTile tile = new RSTile(2754, 2742);
- final RSObject stone = objects.getTopAt(tile);
- if (stone != null) {
- if (stone.isOnScreen()) {
- return tiles.interact(tile, "Jump");
- } else {
- if (walk(new RSTile(2755, 2742))) {
- camera.turnTo(stone);
- }
- }
- }
- return false;
- }
- private boolean ropeSwing() {
- final RSObject swing = objects.getNearest(ropeSwing);
- if (swing != null) {
- if (swing.isOnScreen()) {
- mouse.hop(swing.getPoint());
- return swing.interact("Swing");
- } else {
- return walk(swing.getLocation());
- }
- }
- return false;
- }
- private enum State {
- SETRUN, STEPPING_STONE, TROPICAL_TREE, MONKEYBARS, SKULL_SLOPE, ROPE_SWING, UPPER_TROPICAL_TREE, SLEEP, CROSSING_OBSTACLE, EAT, GET_PINEAPPLE, SLICE
- }
- private boolean hasSpace() {
- return inventory.getCount() <= 20;
- }
- private State getState() {
- if (!game.isLoggedIn() || game.isWelcomeScreen()) {
- return State.SLEEP;
- } else {
- if (walking.getEnergy() > 20 && !walking.isRunEnabled()) {
- return State.SETRUN;
- }
- if (eat) {
- if (hasSpace() && inArea(steppingStoneArea)) {
- if (canPick()) {
- return State.GET_PINEAPPLE;
- }
- }
- if (combat.getHealth() < 50 && hasFood()) {
- return State.EAT;
- }
- if (canCut()) {
- return State.SLICE;
- }
- }
- if (idle()) {
- if (inArea(steppingStoneArea) && game.getPlane() == 0) {
- return State.STEPPING_STONE;
- } else if (inArea(tropicalTreeArea) && game.getPlane() == 0) {
- return State.TROPICAL_TREE;
- } else if (inArea(monkeyBarsArea) && game.getPlane() == 2) {
- return State.MONKEYBARS;
- } else if (atSlope() && game.getPlane() == 0) {
- return State.SKULL_SLOPE;
- } else if (atSwing() && game.getPlane() == 0) {
- return State.ROPE_SWING;
- } else if (inArea(upperTropicalTreeArea)
- && game.getPlane() == 0) {
- return State.UPPER_TROPICAL_TREE;
- } else {
- return State.CROSSING_OBSTACLE;
- }
- }
- }
- return State.CROSSING_OBSTACLE;
- }
- @Override
- public int loop() {
- mouse.setSpeed(random(3, 5));
- switch (getState()) {
- case SLEEP:
- status = ("Waiting for client.");
- return random(1000, 1200);
- case CROSSING_OBSTACLE:
- status = ("Moving.");
- return 400;
- case SETRUN:
- status = "Turning run on";
- walking.setRun(true);
- return random(1200, 1400);
- case GET_PINEAPPLE:
- status = ("Picking pineapple.");
- if (doObstacle(pineapplePlant, "Pick")) {
- return random(1000, 1200);
- }
- break;
- case SLICE:
- status = ("Slicing pineapple.");
- if (chop()) {
- return random(1000, 1200);
- }
- break;
- case EAT:
- status = ("Eating food.");
- if (eat()) {
- return random(1000, 1200);
- }
- break;
- case STEPPING_STONE:
- status = ("Stepping stone.");
- if (steppingStone()) {
- return random(1200, 1400);
- }
- break;
- case TROPICAL_TREE:
- status = ("Tropical tree.");
- if (doObstacle(tropicalTree, "Climb")) {
- return random(1200, 1400);
- }
- break;
- case MONKEYBARS:
- status = ("Monkey bars.");
- if (doObstacle(monkeyBars, "Swing")) {
- camera.setCompass('w');
- return random(1200, 1400);
- }
- break;
- case SKULL_SLOPE:
- status = ("Skull slope.");
- if (doObstacle(skullSlope, "Climb")) {
- camera.setCompass('e');
- camera.setPitch(false);
- return random(1200, 1400);
- }
- break;
- case ROPE_SWING:
- status = ("Rope swing.");
- if (ropeSwing()) {
- return random(1200, 1400);
- }
- break;
- case UPPER_TROPICAL_TREE:
- status = ("Tropical tree");
- if (doObstacle(upperTropicalTree, "Climb")) {
- camera.setPitch(true);
- return random(1200, 1400);
- }
- break;
- }
- return 0;
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- private int PH(int arg0) {
- int PH = (int) (3600000.0 / runTime * arg0);
- return PH;
- }
- private String nf(int number) {
- return nf.format(number);
- }
- private RSComponent get() {
- return interfaces.getComponent(261, 8);
- }
- private RSComponent getMain() {
- return interfaces.getComponent(548, 0);
- }
- private String ft(long duration) {
- String res = "";
- long days = TimeUnit.MILLISECONDS.toDays(duration);
- long hours = TimeUnit.MILLISECONDS.toHours(duration)
- - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
- long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
- .toHours(duration));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
- .toMinutes(duration));
- if (days == 0) {
- res = (hours + ":" + minutes + ":" + seconds);
- } else {
- res = (days + ":" + hours + ":" + minutes + ":" + seconds);
- }
- return res;
- }
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setRenderingHints(antialiasing);
- runTime = System.currentTimeMillis() - startTime;
- curLVL = skills.getRealLevel(Skills.AGILITY);
- curXP = skills.getCurrentExp(Skills.AGILITY);
- int x = get().getAbsoluteX();
- int y = get().getAbsoluteY();
- int mX = getMain().getAbsoluteX();
- int mY = getMain().getAbsoluteY();
- int gainedLVL = curLVL - startLVL;
- int gainedXP = curXP - startXP;
- int tnl = skills.getExpToNextLevel(Skills.AGILITY);
- int till99 = skills.getExpToMaxLevel(Skills.AGILITY);
- long timeTNL = (long) ((double) tnl / (double) PH(gainedXP) * 3600000);
- long timeTo99 = (long) ((double) till99 / (double) PH(gainedXP) * 3600000);
- g.drawImage(img1, mX + 60, mY - 15, null);
- g.drawImage(img2, x, y, null);
- x += 15;
- y += 30;
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Run Time: " + Timer.format(runTime), x, y);
- y += 20;
- g.drawString("Start Level: " + startLVL, x, y);
- y += 20;
- g.drawString("Current Level: " + curLVL, x, y);
- y += 20;
- g.drawString("Levels Gained: " + gainedLVL, x, y);
- y += 20;
- g.drawString("Xp Gained: " + nf(gainedXP), x, y);
- y += 20;
- g.drawString("Xp Ph: " + nf(PH(gainedXP)), x, y);
- y += 20;
- g.drawString("Xp Tnl: " + nf(tnl), x, y);
- y += 20;
- if (gainedXP > 0) {
- g.drawString("TTnl: " + ft(timeTNL), x, y);
- y += 20;
- g.drawString("TT 99: " + ft(timeTo99), x, y);
- y += 20;
- } else {
- g.drawString("TTnl: Calculating", x, y);
- y += 20;
- g.drawString("TT 99: Calculating", x, y);
- y += 20;
- }
- g.drawString("Status: " + status, x, y);
- y += 10;
- int percent = skills.getPercentToNextLevel(Skills.AGILITY);
- int length = percent * 156 / 100;
- g.setColor(color1);
- g.setStroke(stroke1);
- g.drawRect(x, y, 156, 25);
- g.setColor(color2);
- g.fillRect(x, y, length, 25);
- g.setColor(color1);
- g.setStroke(stroke1);
- g.drawRect(x, y, length, 25);
- g.setColor(color3);
- g.fillRect(x, y, length, 13);
- g.setColor(color1);
- y += 20;
- x += 70;
- g.drawString(percent + "%", x, y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement