import java.awt.Color; import java.awt.Graphics; import java.awt.Point; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.imageio.ImageIO; import org.rsbot.script.Script; import org.rsbot.script.ScriptManifest; import org.rsbot.event.listeners.PaintListener; import org.rsbot.script.wrappers.RSObject; import org.rsbot.script.wrappers.RSTile; import org.rsbot.script.wrappers.RSArea; import org.rsbot.script.wrappers.RSItem; import java.io.BufferedReader; import java.io.InputStreamReader; import java.text.DecimalFormat; import java.net.URLConnection; import java.awt.Insets; import java.awt.Rectangle; import java.awt.Dimension; import java.awt.Font; import java.awt.Container; import java.awt.Polygon; import java.awt.event.*; import javax.swing.*; import org.rsbot.script.methods.Skills; @ScriptManifest(authors = "Kirby", name = "Barbarianrappistcourse", keywords = "Agility", version = 1.9, description = "funks up that anil") public class Barbarianrappistcourse extends Script implements PaintListener { private long scriptStartTime = 0; private int runEnergy = random(40, 95); private int health; private boolean setAltitude = true; private int startXP = 0; private int antibanca = 0; private int startLvl = 0; public String status = ""; private enum State { rope, log, net, ledge, ladder, wall, error }; private int[] food = { 1895, 1893, 1891, 4293, 2142, 291, 2140, 3228, 9980, 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343, 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329, 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369, 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180, 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897, 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942, 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978, 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745, 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048, 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255, 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074, 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883, 1971, 4608, 1883, 1885, 15272 }; BufferedImage normal = null; BufferedImage clicked = null; int [] rope = {43526}; int [] net = {20211}; int [] ladderrope = {32015}; int [] loger = {43595}; private RSObject currentObject; private RSArea logArea = new RSArea(new RSTile(2549, 3543), new RSTile( 2554, 3549)); private void dorope2() { RSObject swing = objects.getNearest(43526); if (swing != null && getMyPlayer().getAnimation() != 751 && !logArea.contains(getMyPlayer().getLocation())){ currentObject = swing; if(swing.isOnScreen()){ swing.doHover(); sleep(40, 60); if(swing.doAction("Swing-on")){ sleep(600, 700); }else{ sleep(500, 700); } } } } private void doladderr() { RSObject climbu = objects.getNearest(ladderrope); if (climbu != null) { climbu.doAction("Climb-up"); } } private void dolog2(boolean mm) { if (getMyPlayer().getAnimation() == 9908) { int r = random(0, 34); if(r==0){ RSObject wall = objects.getNearest(43533); if(wall != null && wall.isOnScreen()){ wall.doHover(); try{ if(calc.distanceTo(wall.getLocation()) <= 7){ wall.doAction("Run-up"); sleep(500, 700); } }catch(Exception e){ } } } return; } RSObject log = objects.getNearest(43595); if (log != null){ currentObject = log; if(log.isOnScreen()){ log.doHover(); sleep(40, 60); if(log.doAction("Walk-across")){ sleep(500, 600); }else{ sleep(400, 600); } }else{ if (!mm) { walking.walkTileOnScreen(new RSTile(2551, 3547)); } else { walking.walkTileMM(new RSTile(2551, 3547)); } } } else { walking.walkTileOnScreen(new RSTile(2551, 3547)); sleep(500, 600); } } private void donet2() { RSObject climb = objects.getNearest(net); if (climb != null) { climb.doAction("Climb-over"); } } private State getState() { if (!inventory.containsOneOf(food) && getCurrentLifePoints() < health) { log.info("Health is too low and out of food..."); return State.error; } if (playerInArea(2555, 3559, 2543, 3550)) return State.rope; if (playerInArea(2553, 3549, 2544, 3542)) return State.log; if (playerInArea(2542, 3547, 2533, 3545) && game.getPlane() == 0) return State.net; if (playerInArea(2538, 3547, 2536, 3545) && game.getPlane() == 1) return State.ledge; if (playerInArea(2532, 3547, 2532, 3546) && game.getPlane() == 1) return State.ladder; if (playerInArea(2537, 3551, 2532, 3548) || (playerInArea(2532, 3549, 2532, 3546) && game.getPlane() == 0) || playerInArea(2542, 3556, 2532, 3550)) return State.wall; return State.rope; } public int getCurrentLifePoints() { return Integer.parseInt(interfaces.getComponent(748, 8).getText()); } //*******************************************************// // ON START //*******************************************************// public boolean onStart() { try { final URL cursorURL = new URL("http://imgur.com/i7nMG.png"); final URL cursor80URL = new URL("http://imgur.com/8k9op.png"); normal = ImageIO.read(cursorURL); clicked = ImageIO.read(cursor80URL); } catch (MalformedURLException e) { log.info("Unable to buffer cursor."); } catch (IOException e) { log.info("Unable to open cursor image."); } scriptStartTime = System.currentTimeMillis(); camera.setPitch(true); return true; } //*******************************************************// // MAIN LOOP //*******************************************************// public int loop() { if (!game.isLoggedIn()) return 50; if (startLvl == 0) { startXP = skills.getCurrentExp(Skills.AGILITY); startLvl = skills.getCurrentLevel(Skills.AGILITY); return 50; } if (setAltitude) { camera.setPitch(true); sleep(random(250, 500)); setAltitude = false; return 50; } eat(); startRunning(runEnergy); switch(getState()) { case rope: doRope(); return 50; case log: doLog(); return 50; case net: doNet(); return 50; case ledge: doLedge(); return 50; case ladder: doLadder(); return 50; case wall: doWall(); return 50; case error: return -1; } return 50; } //*******************************************************// // OTHER METHODS //*******************************************************// public void antiban() { antibanca = random(0,5); if (antibanca == 1) { int angle = camera.getAngle() + random(-90, 90); if (angle < 0) { angle = random(0, 10); } if (angle > 359) { angle = random(0, 10); } camera.setAngle(angle); return; } if (antibanca == 2) { status = "AntiBan(2)"; camera.setCompass('n'); sleep(200,300); return; } if (antibanca == 3) { status = "AntiBan(3)"; camera.setCompass('s'); sleep(200,400); return; } if (antibanca == 4) { status = "AntiBan(4)"; mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(200,300); return; } if (antibanca == 5) { status = "AntiBan(5)"; mouse.moveSlightly(); sleep(50,100); return; } } private void doRope() { status = "Swinging on rope..."; final RSTile rope = new RSTile(2551 + random(0, 2), 3554); final RSTile ladder = new RSTile(2547, 9951); final RSTile walkHere = new RSTile(2551, 3554); if (playerInArea(2555, 9955, 2546, 9948)) { if (camera.getAngle() < 75 || camera.getAngle() > 110) { camera.setAngle(random(75, 110)); sleep(random(100, 200)); return; } doladderr(); log.info("Fell off of the rope."); sleep(random(700, 800)); return; } if (!playerInArea(2554, 3555, 2549, 3554)) { walkTile(walkHere); sleep(random(50, 1500)); camera.setAngle(random(200, 500)); sleep(random(100, 200)); return; } dorope2(); mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(random(1600, 1800)); while(players.getMyPlayer().getAnimation() == 751 || players.getMyPlayer().isMoving()) sleep(100); return; } private void doLog() { status = "Crossing log..."; final RSTile log = new RSTile(2550, 3546); dolog2(true); sleep(random(100, 200)); camera.setAngle(random(1, 360)); sleep(random(100, 300)); mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(random(200, 700)); mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(random(1300, 1600)); while(players.getMyPlayer().isMoving() || playerInArea(2550, 3546, 2542, 3546)) sleep(100); return; } private void doNet() { status = "Climbing up net..."; final RSTile net = new RSTile(2538, 3546); final RSTile walkHere = new RSTile(2539, 3545); if (game.getPlane() == 0 && calc.distanceTo(new RSTile(2535, 3546)) <= 3) { camera.setCompass('w'); walkTile(walkHere); sleep(random(500, 750)); while(players.getMyPlayer().isMoving()) sleep(100); return; } donet2(); sleep(random(2000, 2700)); antiban(); while(players.getMyPlayer().getAnimation() == 828 || players.getMyPlayer().isMoving()) sleep(100); return;} private void doLedge() { status = "Walking on ledge..."; final RSTile ledge = new RSTile(2535, 3547); if (onTile(ledge, "Balancing ledge", "Walk-across", 0.5, 0.75, 0)) sleep(random(200, 700)); mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(random(1400, 2000)); while(players.getMyPlayer().isMoving() || (playerInArea(2535, 3547, 2532, 3547) && game.getPlane() == 1)) sleep(100); return; } private void doLadder() { status = "Climbing ladder..."; final RSTile ladder = new RSTile(2532, 3545); if (onTile(ladder, "Ladder", "Climb-down", 0.5, 0.6, 0)) sleep(random(50, 200)); camera.setAngle(random(1, 50)); mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(random(1000, 1400)); while(players.getMyPlayer().isMoving() || players.getMyPlayer().getAnimation() == 827) sleep(100); return; } private void doWall() { status = "Climbing over wall..."; if (players.getMyPlayer().isMoving()) return; final RSTile wall1 = new RSTile(2537, 3553); final RSTile wall2 = new RSTile(2542, 3553); final RSTile walkHere = new RSTile(2536, 3553); if (!calc.tileOnScreen(wall1)) { walking.walkTileOnScreen(wall1); //walkTile(walkHere); sleep(random(200, 300)); return; } if (playerInArea(2542, 3554, 2538, 3553)) { if (onTile(wall2, "Crumbling wall", "Climb-over", 0.9, 0.5, 5)) sleep(random(500, 1500)); while(players.getMyPlayer().isMoving() || players.getMyPlayer().getAnimation() == 4853) sleep(100); return; } if (onTile(wall1, "Crumbling wall", "Climb-over", 0.9, 0.5, 5)) sleep(random(200, 600)); mouse.move(random(50, 700), random(50, 450), 2, 2); sleep(random(1000, 1100)); while(players.getMyPlayer().isMoving() || players.getMyPlayer().getAnimation() == 4853) sleep(100); return; } private void startRunning(final int energy) { if (walking.getEnergy() >= energy && !walking.isRunEnabled()) { runEnergy = random(40, 95); walking.setRun(true); sleep(random(500, 750)); } } private boolean playerInArea(int maxX, int maxY, int minX, int minY) { int x = players.getMyPlayer().getLocation().getX(); int y = players.getMyPlayer().getLocation().getY(); if (x >= minX && x <= maxX && y >= minY && y <= maxY) { return true; } return false; } public boolean eat() { status = "Eating..."; int getHP = combat.getLifePoints(); int RealHP = skills.getRealLevel(3) * 10; if (inventory.containsOneOf(food)) { if (getHP <= random(RealHP / 2.0, RealHP / 2.5)) { inventory.getItem(food).doAction("Eat"); sleep(500, 600); } } return false; } public boolean onTile(RSTile tile, String search, String action, double dx, double dy, int height) { if (!(tile !=null)) { return false; } Point checkScreen = null; checkScreen = calc.tileToScreen(tile, dx, dy, height); if (!calc.pointOnScreen(checkScreen)) { walkTile(tile); sleep(random(340, 1310)); } try { Point screenLoc = null; for (int i = 0; i < 30; i++) { screenLoc = calc.tileToScreen(tile, dx, dy, height); if (!calc.pointOnScreen(screenLoc)) { return false; } if(menu.getItems().toString().toLowerCase().contains(search.toLowerCase())) { break; } if (mouse.getLocation().equals(screenLoc)) { break; } mouse.move(screenLoc); } screenLoc = calc.tileToScreen(tile, height); if (menu.getItems().length <= 1) { return false; } sleep(random(100, 200)); if (menu.getItems().toString().toLowerCase().contains(action.toLowerCase())) { mouse.click(true); return true; } else { return menu.doAction(action); } } catch (Exception e) { e.printStackTrace(); return false; } } private void walkTile(final RSTile tile) { if (!(calc.distanceTo(walking.getDestination()) <= random(4, 7))) { if (players.getMyPlayer().isMoving()) return; } Point screen = calc.tileToScreen(tile); if (calc.pointOnScreen(screen)) { if (players.getMyPlayer().isMoving()) return; mouse.move(screen, random(-3, 4), random(-3, 4)); walking.walkTileOnScreen(tile); sleep(random(500, 750)); return; } else { walking.walkTileMM(tile); sleep(random(500, 750)); return; } } //*******************************************************// // ON FINISH //*******************************************************// public void onFinish() { } //*******************************************************// // PAINT SCREEN //*******************************************************// public void drawMouse(final Graphics g) { if (normal != null) { final double mouseX = mouse.getLocation().getX() - 8, mouseY = mouse.getLocation().getY() - 8; final double mousePressX = mouse.getPressLocation().getX() - 8, mousePressY = mouse.getPressLocation().getY() - 8; if (System.currentTimeMillis() - mouse.getPressTime() < 400) { g.drawImage(clicked, (int) mousePressX, (int) mousePressY, null); } g.drawImage(normal, (int) mouseX, (int) mouseY, null); } } public void drawStringShadow(final String text, final int x, final int y, final Graphics g) { g.setColor(Color.BLACK); g.drawString(text, x + 1, y + 1); g.setColor(Color.WHITE); g.drawString(text, x, y); } public void onRepaint(Graphics g) { long runTime = 0; long seconds = 0; long minutes = 0; long hours = 0; int laps = 0; int percent = 0; int currentXP = 0; int currentLVL = 0; int gainedXP = 0; int gainedLVL = 0; int lapsPerHour = 0; int expPerHour = 0; final double courseXP = 139.5; runTime = System.currentTimeMillis() - scriptStartTime; seconds = runTime / 1000; if ( seconds >= 60 ) { minutes = seconds / 60; seconds -= (minutes * 60); } if ( minutes >= 60 ) { hours = minutes / 60; minutes -= (hours * 60); } percent = skills.getPercentToNextLevel(Skills.AGILITY); currentXP = skills.getCurrentExp(Skills.AGILITY); currentLVL = skills.getCurrentLevel(Skills.AGILITY); gainedXP = currentXP - startXP; gainedLVL = currentLVL - startLvl; laps = (int) (gainedXP / courseXP); lapsPerHour = (int) ((3600000.0 / (double) runTime) * laps); expPerHour = (int) (3600000.0 / (double) runTime * gainedXP); drawMouse(g); drawStringShadow("Run Time: " + hours + ":" + minutes + ":" + seconds, 10, 40, g); drawStringShadow("Status: " + status, 10, 60, g); drawStringShadow("Total Laps: " + laps + " ( " + lapsPerHour + "/hr )", 10, 80, g); drawStringShadow("Current Lvl: " + currentLVL + " ( + " + gainedLVL + " )", 10, 100, g); drawStringShadow("Exp Gained: " + gainedXP + " ( " + expPerHour + "/hr )", 10, 120, g); drawStringShadow("Exp To Next Level: " + skills.getExpToNextLevel(Skills.AGILITY), 10, 140, g); try { if (expPerHour > 0) { long sTNL = (skills.getExpToNextLevel(Skills.AGILITY)) / (expPerHour / 3600); long hTNL = sTNL / (60 * 60); sTNL -= hTNL * (60 * 60); long mTNL = sTNL / 60; sTNL -= mTNL * 60; drawStringShadow("Level in: " + hTNL + ":" + mTNL + ":" + sTNL + " ( " + percent + "% )", 10, 160, g); } else { drawStringShadow("Level in: 0:0:0 ( " + percent + "% )", 10, 160, g); } } catch(Exception e) { drawStringShadow("Level in: -1:-1:-1 ( " + percent + "% )", 10, 160, g); } } }