Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 26.41 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.Point;
  6. import java.awt.RenderingHints;
  7. import java.util.ArrayList;
  8. import java.util.Map;
  9.  
  10. import org.rsbot.bot.Bot;
  11. import org.rsbot.bot.input.Mouse;
  12. import org.rsbot.event.listeners.PaintListener;
  13. import org.rsbot.script.Calculations;
  14. import org.rsbot.script.Constants;
  15. import org.rsbot.script.Script;
  16. import org.rsbot.script.ScriptManifest;
  17. import org.rsbot.script.Skills;
  18. import org.rsbot.script.wrappers.RSInterface;
  19. import org.rsbot.script.wrappers.RSInterfaceChild;
  20. import org.rsbot.script.wrappers.RSPlayer;
  21. import org.rsbot.script.wrappers.RSTile;
  22.  
  23. @ScriptManifest(authors = { "Jacmob/Montonago" }, category = "Agility", name = "Monty's Barbarian Agility", version = 1.1, description = "<html>\n<body style=\"font-family: Arial; background-color: #DDFFDD;\">\n<div style=\"width: 100%; height: 35px; background-color: #BBEEBB; text-align: center;\"\n<h2 style=\"color: #118811;\">Barbarian Course</h2>\n</div>\n<div style=\"width:100%; background-color: #007700; text-align:center; color: #FFFFFF; height: 15px;\">Created by: Jacmob; Fixed by: Montonago"
  24.         + "<p>Version 1.1</p></div>\n<div style=\"width: 100%; padding: 10px; padding-bottom: 12px; background-color: #EEFFEE;\">Start in the Barbarian Agility Course.<br><br>Food and energy potions are supported.</div>\n<div style=\"width: 100%; padding: 10px;\">\n<h3>Auto Stop (Enter Runtime to Enable)</h3><input type=\"text\" name=\"hours\" id=\"hrs\" size=3 /><label for=\"hrs\" > : </label><input type=\"text\" name=\"mins\" id=\"mins\" size=3 /><label for=\"mins\"> : </label><input type=\"text\" name=\"secs\" id=\"secs\" size=3 /><label for=\"secs\"> (hrs:mins:secs)</label><br /><br /><input type=\"checkbox\" name=\"chkXP\" id=\"chkXP\" value=\"true\" /><label for=\"debug\">Check XP (Extra AntiBan)</label></div>\n</body>\n</html")
  25.         public class BarbarianAgilityMonty extends Script implements PaintListener {
  26.         public long currentExp, startExp, st, startLevel;
  27.         public boolean setpainton = true;
  28.         boolean showEXP = false;
  29.         boolean showMisc = true;
  30.         final int percentToLevel = 0;
  31.         int positionOfLap = 0;
  32.         public static final int[] Food = new int[] {
  33.                 315, //Shrimp
  34.                 325, //Sardine
  35.                 319, //Anchovies
  36.                 347, //Herring
  37.                 355, //Mackerel
  38.                 333, //Trout
  39.                 339, //Cod
  40.                 351, //Pike
  41.                 329, //Salmon
  42.                 361, //Tuna
  43.                 10135, //Rainbow Fish
  44.                 5003, //Cave Eel
  45.                 379, //Lobster
  46.                 361, //Bass
  47.                 373, //Swordfish
  48.                 7946, //Monkfish
  49.                 385, //Shark
  50.                 397, //Sea Turtle
  51.                 391, //Manta Ray
  52.                 2309, //Bread
  53.                 2003, //Stew
  54.                 2011, //Curry
  55.                 7068, //Tuna and Corn
  56.                 6701, //Baked Potato
  57.                 6703, //Potato with Butter
  58.                 7054, //Chilli Potato
  59.                 6705, //Potato with Cheese
  60.                 7060, //Tuna Potato
  61.                 1971, //Kebab
  62.                 4608, //Super Kebab
  63.                 1883, //Ugthanki Kebab
  64.                 7218, //Summer Pie
  65.                 7220, //Half-Summer Pie
  66.         };
  67.         public static final int[] energyPot = new int[] { 3014, 3012, 3010, 3008,
  68.                 3022, 3020, 3018, 3016 };
  69.         public int LapsDone = 0;
  70.         public static final String[] SKILL_NAMES = {"attack", "defence", "strength", "constitution", "range", "prayer", "magic", "cooking", "woodcutting", "fletching", "fishing", "firemaking", "crafting", "smithing", "mining", "herblore", "agility", "thieving", "slayer", "farming", "runecrafting", "hunter", "construction", "summoning", "dungeoneering", "-unused-"};
  71.  
  72.         public static final int[] XP_TABLE = {0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431, 14391160, 15889109, 17542976, 19368992, 21385073, 23611006, 26068632, 28782069, 31777943, 35085654, 38737661, 42769801, 47221641, 52136869, 57563718, 63555443, 70170840, 77474828, 85539082, 94442737, 104273167};
  73.  
  74.         public static final int ATTACK = 0;
  75.         public static final int DEFENSE = 1;
  76.         public static final int STRENGTH = 2;
  77.         public static final int CONSTITUTION = 3;
  78.         public static final int RANGE = 4;
  79.         public static final int PRAYER = 5;
  80.         public static final int MAGIC = 6;
  81.         public static final int COOKING = 7;
  82.         public static final int WOODCUTTING = 8;
  83.         public static final int FLETCHING = 9;
  84.         public static final int FISHING = 10;
  85.         public static final int FIREMAKING = 11;
  86.         public static final int CRAFTING = 12;
  87.         public static final int SMITHING = 13;
  88.         public static final int MINING = 14;
  89.         public static final int HERBLORE = 15;
  90.         public static final int AGILITY = 16;
  91.         public static final int THIEVING = 17;
  92.         public static final int SLAYER = 18;
  93.         public static final int FARMING = 19;
  94.         public static final int RUNECRAFTING = 20;
  95.         public static final int HUNTER = 21;
  96.         public static final int CONSTRUCTION = 22;
  97.         public static final int SUMMONING = 23;
  98.         public static final int DUNGEONEERING = 24;
  99.  
  100.         private boolean lapJustDone = false;
  101.         private boolean lapBegun = false;
  102.         private boolean checkXP = false;
  103.         private int RunningEnergy = random(15, 30);
  104.         private int DrinkingEnergy = -1;
  105.         private int currentFails = 0;
  106.         private int startingxp = -1;
  107.         private long startTime = -1;
  108.         private long stopTime = -1;
  109.  
  110.  
  111.         private boolean atTile3(final RSTile tile, final String action) {
  112.                 return atTile3(tile, action, 0, 0, 10);
  113.         }
  114.  
  115.         private boolean atTile3(final RSTile tile, final String action,
  116.                         final int xOffset, final int yOffset) {
  117.                 return atTile3(tile, action, xOffset, yOffset, 10);
  118.         }
  119.  
  120.         // atTile3 -Jacmob
  121.         private boolean atTile3(final RSTile tile, final String action,
  122.                         final int xOffset, final int yOffset, final int variation) {
  123.                 try {
  124.                         final Point location = Calculations.tileToScreen(tile);
  125.                         if (location.x == -1 || location.y == -1) {
  126.                                 return false;
  127.                         }
  128.                         moveMouse(location.x + xOffset, location.y + yOffset, variation,
  129.                                         variation);
  130.                         wait(random(30, 60));
  131.                         getMenuItems();
  132.                         final ArrayList<String> mis = getMenuItems();
  133.                         if (mis.get(0).contains(action)) {
  134.                                 clickMouse(true);
  135.                         } else {
  136.                                 for (int i = 1; i < mis.size(); i++) {
  137.                                         if (mis.get(i).contains(action)) {
  138.                                                 clickMouse(false);
  139.                                                 if (atMenu(action)) {
  140.                                                         return true;
  141.                                                 }
  142.                                         }
  143.                                 }
  144.                                 return false;
  145.                         }
  146.                         return true;
  147.                 } catch (final Exception e) {
  148.                         return false;
  149.                 }
  150.         }
  151.  
  152.         private RSTile checkTile(final RSTile tile) { // most credits to Fusion89k
  153.                 if (distanceTo(tile) < 15) {
  154.                         return tile;
  155.                 }
  156.                 final RSTile loc = getMyPlayer().getLocation();
  157.                 final RSTile walk = new RSTile((loc.getX() + tile.getX()) / 2, (loc
  158.                                 .getY() + tile.getY()) / 2);
  159.                 return tileOnMap(walk) ? walk : checkTile(walk);
  160.         }
  161.  
  162.         private void Drink() {
  163.                 while (getInventoryCount(BarbarianAgilityMonty.energyPot) >= 1
  164.                                 && getEnergy() <= DrinkingEnergy) {
  165.                         DrinkingEnergy = random(10, 40);
  166.                         for (final int element : BarbarianAgilityMonty.energyPot) {
  167.                                 if (getInventoryCount(element) == 0) {
  168.                                         continue;
  169.                                 }
  170.                                 log("Drinking energy potion.");
  171.                                 atInventoryItem(element, "Drink");
  172.                                 wait(random(500, 800));
  173.                                 break;
  174.                         }
  175.                 }
  176.         }
  177.  
  178.         private boolean Eat() {
  179.                 for (final int element : BarbarianAgilityMonty.Food) {
  180.                         if (getInventoryCount(element) >= 1) {
  181.                                 atInventoryItem(element, "Eat");
  182.                                 return true;
  183.                         }
  184.                 }
  185.                 return false;
  186.         }
  187.  
  188.         private RSTile[] generatePath(int startX, int startY,
  189.                         final int destinationX, final int destinationY) { // most credits to
  190.                 // aftermath
  191.                 double dx, dy;
  192.                 final ArrayList<RSTile> list = new ArrayList<RSTile>();
  193.  
  194.                 list.add(new RSTile(startX, startY));
  195.                 while (Math.hypot(destinationY - startY, destinationX - startX) > 8) {
  196.                         dx = destinationX - startX;
  197.                         dy = destinationY - startY;
  198.                         final int gamble = random(14, 17);
  199.                         while (Math.hypot(dx, dy) > gamble) {
  200.                                 dx *= .95;
  201.                                 dy *= .95;
  202.                         }
  203.                         startX += (int) dx;
  204.                         startY += (int) dy;
  205.                         list.add(new RSTile(startX, startY));
  206.                 }
  207.                 list.add(new RSTile(destinationX, destinationY));
  208.                 return list.toArray(new RSTile[list.size()]);
  209.  
  210.         }
  211.  
  212.         private RSTile[] generatePath(final RSTile tile) {
  213.                 return generatePath(getMyPlayer().getLocation().getX(), getMyPlayer()
  214.                                 .getLocation().getY(), tile.getX(), tile.getY());
  215.         }
  216.  
  217.         private String getFormattedTime(final long timeMillis) {
  218.                 long millis = timeMillis;
  219.                 final long seconds2 = millis / 1000;
  220.                 final long hours = millis / (1000 * 60 * 60);
  221.                 millis -= hours * 1000 * 60 * 60;
  222.                 final long minutes = millis / (1000 * 60);
  223.                 millis -= minutes * 1000 * 60;
  224.                 final long seconds = millis / 1000;
  225.                 String hoursString = "";
  226.                 String minutesString = "";
  227.                 String secondsString = seconds + "";
  228.                 String type = "seconds";
  229.  
  230.                 if (minutes > 0) {
  231.                         minutesString = minutes + ":";
  232.                         type = "minutes";
  233.                 } else if (hours > 0 && seconds2 > 0) {
  234.                         minutesString = "0:";
  235.                 }
  236.                 if (hours > 0) {
  237.                         hoursString = hours + ":";
  238.                         type = "hours";
  239.                 }
  240.                 if (minutes < 10 && type != "seconds") {
  241.                         minutesString = "0" + minutesString;
  242.                 }
  243.                 if (hours < 10 && type == "hours") {
  244.                         hoursString = "0" + hoursString;
  245.                 }
  246.                 if (seconds < 10 && type != "seconds") {
  247.                         secondsString = "0" + secondsString;
  248.                 }
  249.  
  250.                 return hoursString + minutesString + secondsString + " " + type;
  251.         }
  252.  
  253.         private int getState() {
  254.  
  255.                 final RSTile StartCoord = new RSTile(2552, 3554);
  256.                 final RSTile FailCoord = new RSTile(2548, 9951);
  257.                 final RSTile Fail2Coord = new RSTile(2548, 3551);
  258.                 final RSTile LogCoord = new RSTile(2552, 3549);
  259.                 final RSTile Log2Coord = new RSTile(2551, 3546);
  260.                 final RSTile LogFailCoord = new RSTile(2545, 3542);
  261.                 final RSTile NetCoord = new RSTile(2541, 3546);
  262.                 final RSTile BalanceCoord = new RSTile(2537, 3546);
  263.                 final RSTile BalanceFailCoord = new RSTile(2534, 3545);
  264.                 final RSTile LadderCoord = new RSTile(2532, 3546);
  265.                 final RSTile WallCoord = new RSTile(2532, 3546);
  266.                 final RSTile Wall2Coord = new RSTile(2536, 3553);
  267.                 final RSTile Wall3Coord = new RSTile(2538, 3553);
  268.                 final RSTile EndCoord = new RSTile(2543, 3553);
  269.  
  270.                 if (distanceTo(StartCoord) < 3) {
  271.                         return 1;
  272.                 }
  273.                 if (distanceTo(Fail2Coord) < 2 && getPlane() == 0) {
  274.                         return 10;
  275.                 }
  276.                 if ((distanceTo(LogCoord) < 3 || distanceTo(Log2Coord) < 2)
  277.                                 && getPlane() == 0) {
  278.                         return 2;
  279.                 }
  280.                 if (distanceTo(LogFailCoord) < 4 && getPlane() == 0) {
  281.                         return 3;
  282.                 }
  283.                 if (distanceTo(NetCoord) < 4 && getPlane() == 0) {
  284.                         return 4;
  285.                 }
  286.                 if (distanceTo(BalanceCoord) < 4 && getPlane() == 1) {
  287.                         return 5;
  288.                 }
  289.                 if (distanceTo(LadderCoord) < 3 && getPlane() == 1) {
  290.                         return 6;
  291.                 }
  292.                 if (distanceTo(WallCoord) < 4 && getMyPlayer().getLocation().getY() == 3546 && getPlane() == 0) {
  293.                         return 7;
  294.                 }
  295.                 if (distanceTo(Wall2Coord) < 4
  296.                                 && getMyPlayer().getLocation().getX() < 2538 && getPlane() == 0) {
  297.                         return 8;
  298.                 }
  299.                 if (distanceTo(Wall3Coord) < 6
  300.                                 && getMyPlayer().getLocation().getX() < 2543 && getPlane() == 0) {
  301.                         return 9;
  302.                 }
  303.                 if (distanceTo(EndCoord) < 5 && getPlane() == 0) {
  304.                         return 10;
  305.                 }
  306.                 if (distanceTo(FailCoord) < 20) {
  307.                         return 11;
  308.                 }
  309.                 if (distanceTo (BalanceFailCoord) <2 && getMyPlayer().getLocation().getX() == 2534 && getMyPlayer().getLocation().getY() == 3545) {
  310.                         return 12;
  311.                 }
  312.  
  313.                 return -1;
  314.         }
  315.  
  316.         public double getVersion() {
  317.                 return 1.1;
  318.         }
  319.  
  320.         public int getMouseSpeed(){
  321.                 return 6;
  322.         }
  323.  
  324.         public int LevelBar(final int index) {
  325.                  final int lvl = skills.getRealSkillLevel(index);
  326.                  if (lvl == 99)
  327.                          return 0;
  328.                  final int xpTotal = XP_TABLE[lvl + 1] - XP_TABLE[lvl];
  329.                  if (xpTotal == 0)
  330.                          return 0;
  331.                  final int xpDone = skills.getCurrentSkillExp(index) - XP_TABLE[lvl];
  332.                  return 246 * xpDone / xpTotal;
  333.          }
  334.          
  335.         private void hoverAgility() {
  336.                 final RSInterfaceChild agitab = RSInterface.getInterface(320).getChild(
  337.                                 134);
  338.                 openTab(Constants.TAB_STATS);
  339.                 moveMouse(new Point(agitab.getAbsoluteX()
  340.                                 + random(2, agitab.getWidth() - 1), agitab.getAbsoluteY()
  341.                                 + random(2, agitab.getHeight() - 1)));
  342.                 wait(random(900, 2000));
  343.                 openTab(Constants.TAB_INVENTORY);
  344.         }
  345.  
  346.         @Override
  347.         public int loop() {
  348.                 try {
  349.                         if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  350.                         } else {
  351.                                 wait(200);
  352.                         }
  353.  
  354.                         if (stopTime != -1 && startTime != -1
  355.                                         && System.currentTimeMillis() - startTime > stopTime) {
  356.                                 log("Stop Time Reached. Logging off in 10 seconds.");
  357.                                 wait(random(10000, 12000));
  358.                                 stopScript();
  359.                         }
  360.  
  361.                         if (checkXP && random(1, 1000) == 1) {
  362.                                 hoverAgility();
  363.                         }
  364.  
  365.                         if (getEnergy() >= RunningEnergy && !isRunning()) {
  366.                                 setRun(true);
  367.                                 RunningEnergy = random(15, 30);
  368.                                 wait(random(400, 500));
  369.                         }
  370.  
  371.                         if (getEnergy() != 0 && getEnergy() <= DrinkingEnergy) {
  372.                                 Drink();
  373.                         }
  374.  
  375.                         if (getInventoryCount(2313) > 0) {
  376.                                 atInventoryItem(2313, "Drop");
  377.                                 wait (300);
  378.                         }
  379.  
  380.                         if (getMyPlayer().getHPPercent() < (50 + random(0, 10))) {
  381.                                 log("Health is below 50%. Eating food...");
  382.                                 if (!Eat()) {
  383.                                         log("No food to eat. Waiting 10 seconds.");
  384.                                         wait(random(10000, 12000));
  385.                                         if (getMyPlayer().getHPPercent() >= (60 + random(0, 10))) {
  386.                                                 log("Failure correction activated. Logout cancelled.");
  387.                                                 return random(100, 200);
  388.                                         }
  389.                                         logout();
  390.                                         log("No food to eat. Logged out.");
  391.                                         Bot.getScriptHandler().stopScript(ID);
  392.                                 } else {
  393.                                         if (getMyPlayer().getHPPercent() < (50 + random(0, 10))) {
  394.                                                 wait(random(800, 1000));
  395.                                                 Eat();
  396.                                         } else {
  397.                                                 return random (400, 500);
  398.                                         }
  399.                                         return random(400, 500);
  400.                                 }
  401.                         }
  402.  
  403.                         final RSPlayer me = getMyPlayer();
  404.                         final int state = getState();
  405.  
  406.                         if (me.getAnimation() != -1 || me.isMoving()) {
  407.                                 if (lapJustDone) {
  408.                                         setCameraRotation(random(175, 185));
  409.                                         LapsDone++;
  410.                                         positionOfLap = 8;
  411.                                         lapJustDone = false;
  412.                                 }
  413.                                 return random(50, 200);
  414.                         }
  415.  
  416.                         switch (state) {
  417.                         case 0:
  418.                                 break;
  419.                         case -1: // Failure!
  420.                                 if (currentFails > 30 && getPlane() == 0) {
  421.                                         log("Unknown Location - Returning To Start");
  422.                                         walkPathMM(randomizePath(
  423.                                                         generatePath(new RSTile(2552, 3554)), 0, 1), 16);
  424.                                 }
  425.                                 currentFails += 1;
  426.                                 wait(1000);
  427.                                 break;
  428.                         case 1: // Rope
  429.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  430.                                         positionOfLap = 1;
  431.                                         if (distanceTo(new RSTile(2552, 3554)) > 1) {
  432.                                                 walkTo(new RSTile(2552, 3554));
  433.                                                 wait(random(50, 100));
  434.                                         } else if (atTile3(new RSTile(2552, 3552), "Swing-on")) {
  435.                                                 wait(random(650, 800));
  436.                                         } else {
  437.                                                 setCameraRotation(random(175, 185));
  438.                                                 currentFails += 1;
  439.                                                 wait(1000);
  440.                                         }
  441.                                         lapBegun = true;
  442.                                         return random(50, 100);
  443.                                 } else {
  444.                                         wait(200);
  445.                                 }
  446.                         case 2: // Log
  447.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  448.                                         positionOfLap = 2;
  449.                                         if (atTile3(new RSTile(2550, 3546), "Walk-across", 0, 5)) {
  450.                                                 setCameraRotation(random(5, 10));
  451.                                                 wait(random(400, 500));
  452.                                         } else {
  453.                                                 currentFails += 1;
  454.                                                 wait(1000);
  455.                                         }
  456.                                         break;
  457.                                 } else {
  458.                                         wait(200);
  459.                                 }
  460.                         case 3: // Log Failed
  461.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  462.                                         walkTo(new RSTile(2551, 3546));
  463.                                         wait(random(700, 900));
  464.                                         break;
  465.                                 } else {
  466.                                         wait(200);
  467.                                 }
  468.                         case 4: // Net
  469.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  470.                                         positionOfLap = 3;
  471.                                         if (atTile3(new RSTile(2538, 3546), "Climb-over", 0, -10)) {
  472.                                                 setCameraRotation(random(85, 95));
  473.                                                 wait(random(300, 500));
  474.                                         } else {
  475.                                                 currentFails += 1;
  476.                                                 wait(1000);
  477.                                         }
  478.                                         wait(random(300, 500));
  479.                                         break;
  480.                                 } else {
  481.                                         wait(200);
  482.                                 }
  483.                         case 5: // Ledge
  484.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  485.                                         positionOfLap = 3;
  486.                                         if (atTile3(new RSTile(2535, 3547), "Walk-across", 7, 0)) {
  487.                                                 setCameraRotation(random(185, 175));
  488.                                                 wait(random(1000, 1100));
  489.                                         } else if (currentFails > 0 && currentFails % 20 == 0) {
  490.                                                 turnToTile(new RSTile(2535, 3547));
  491.                                         } else {
  492.                                                 currentFails += 1;
  493.                                                 wait(1000);
  494.                                         }
  495.                                         break;
  496.                                 } else {
  497.                                         wait(200);
  498.                                 }
  499.                         case 6: // Ladder
  500.                                 if (atTile3(new RSTile(2532, 3545), "Climb-down")) {
  501.                                         positionOfLap = 4;
  502.                                         wait(random(500, 700));
  503.                                 } else if (currentFails > 0 && currentFails % 20 == 0) {
  504.                                         turnToTile(new RSTile(2532, 3545));
  505.                                 } else {
  506.                                         currentFails += 1;
  507.                                         wait(1000);
  508.                                 }
  509.                                 break;
  510.                         case 7: // Walk To Crumbling Wall
  511.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  512.                                         positionOfLap = 5;
  513.                                         walkTo(new RSTile(2536, 3553));
  514.                                         wait(random(50, 100));
  515.                                         setCameraRotation(random(265, 285));
  516.                                         wait(random(100, 200));
  517.                                         break;
  518.                                 } else {
  519.                                         wait(200);
  520.                                 }
  521.                         case 8: // First Crumbling Wall
  522.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  523.                                         positionOfLap = 6;
  524.                                         if (atTile3(new RSTile(2538, 3553), "Climb-over", -4, 15)) {
  525.                                                 wait(random(300, 400));
  526.                                         } else if (currentFails > 0 && currentFails % 20 == 0) {
  527.                                                 turnToTile(new RSTile(2538, 3553));
  528.                                         } else {
  529.                                                 currentFails += 1;
  530.                                                 wait(1000);
  531.                                         }
  532.                                         break;
  533.                                 } else {
  534.                                         wait(200);
  535.                                 }
  536.                         case 9: // Second Crumbling Wall
  537.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  538.                                         if (atTile3(new RSTile(2543, 3553), "Climb-over", 0, 15)) {
  539.                                                 positionOfLap = 7;
  540.                                                 wait(random(200, 300));
  541.                                                 if (lapBegun) {
  542.                                                         lapJustDone = true;
  543.                                                 }
  544.                                                 lapBegun = false;
  545.                                         } else if (currentFails > 0 && currentFails % 20 == 0) {
  546.                                                 turnToTile(new RSTile(2543, 3553));
  547.                                         } else {
  548.                                                 currentFails += 1;
  549.                                                 wait(1000);
  550.                                         }
  551.                                         break;
  552.                                 } else {
  553.                                         wait(200);
  554.                                 }
  555.                         case 10: // Return To Start
  556.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  557.                                         currentFails = 0;
  558.                                         walkTo(checkTile(new RSTile(2552, 3554)));
  559.                                         setCameraRotation(random(175, 185));
  560.                                         wait(random(400, 750));
  561.                                         break;
  562.                                 } else {
  563.                                         wait(200);
  564.                                 }
  565.                         case 11:
  566.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  567.                                         if (distanceTo(new RSTile(2547, 9951)) > 5) {
  568.                                                 walkTo(new RSTile(2548, 9951));
  569.                                         }
  570.                                         if (atTile3(new RSTile(2547, 9951), "Climb-up")) {
  571.                                                 wait(random(300, 400));
  572.                                         } else if (currentFails > 0 && currentFails % 20 == 0) {
  573.                                                 turnToTile(new RSTile(2547, 9951));
  574.                                         } else {
  575.                                                 currentFails += 1;
  576.                                                 wait(1000);
  577.                                         }
  578.                                         break;
  579.                                 } else {
  580.                                         wait(200);
  581.                                 }
  582.                         case 12:
  583.                                 //failed ledge
  584.                                 if (!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  585.                                         positionOfLap -= 1;
  586.                                         if (distanceTo(new RSTile(2540, 3546)) <8) {
  587.                                                 walkTo (new RSTile(2540, 3546));
  588.                                                 setCameraRotation(random(5, 10));
  589.                                                 wait(random(3000,2900));
  590.                                                 break;
  591.                                         }
  592.                                 } else {
  593.                                         wait (200);
  594.                                 }
  595.                         default: // Stop Script
  596.                                 return -1;
  597.                         }
  598.  
  599.                 } catch (final Exception e) {
  600.                         log.severe("SCRIPT ERROR");
  601.                         return 0;
  602.                 }
  603.                 return random(100, 200);
  604.         }
  605.  
  606.         @Override
  607.         public void onFinish() {
  608.                 log("Gained "
  609.                                 + (skills.getCurrentSkillExp(Constants.STAT_AGILITY) - startingxp)
  610.                                 + " XP ("
  611.                                 + (skills.getRealSkillLevel(Constants.STAT_AGILITY) - skills
  612.                                                 .getLvlByExp(startingxp)) + " levels) in "
  613.                                                 + getFormattedTime(System.currentTimeMillis() - startTime)
  614.                                                 + ".");
  615.         }
  616.  
  617.         @Override
  618.         public boolean onStart(final Map<String, String> args) {
  619.                 if (args.get("chkXP") == null) {
  620.                         checkXP = false;
  621.                 }
  622.                 showEXP = false;
  623.                 showMisc = true;
  624.                 if (!(args.get("hours").equals("") && args.get("mins").equals("") && args
  625.                                 .get("secs").equals(""))) {
  626.                         int sHours = 0, sMins = 0, sSecs = 0;
  627.                         if (!args.get("hours").equals("")) {
  628.                                 sHours = Integer.parseInt(args.get("hours"));
  629.                         }
  630.                         if (!args.get("mins").equals("")) {
  631.                                 sMins = Integer.parseInt(args.get("mins"));
  632.                         }
  633.                         if (!args.get("secs").equals("")) {
  634.                                 sSecs = Integer.parseInt(args.get("secs"));
  635.                         }
  636.                         stopTime = sHours * 3600000 + sMins * 60000 + sSecs * 1000;
  637.                         log("Script will stop after " + getFormattedTime(stopTime));
  638.                 }
  639.                 return true;
  640.         }
  641.  
  642.  
  643.         //This variable is used for Antialiasing. DO NOT DELETE!
  644.         private final RenderingHints rh = new RenderingHints(
  645.                         RenderingHints.KEY_TEXT_ANTIALIASING,
  646.                         RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  647.  
  648.         public void onRepaint(Graphics g) {
  649.                 if (isLoggedIn() && skills.getRealSkillLevel(Constants.STAT_AGILITY) > 1) {
  650.                         if (startingxp == -1) {
  651.                                 startingxp = skills.getCurrentSkillExp(Constants.STAT_AGILITY);
  652.                                 startTime = System.currentTimeMillis();
  653.                                 DrinkingEnergy = random(10, 40);
  654.                                 if (getState() == -1) {
  655.                                         walkPathMM(randomizePath(
  656.                                                         generatePath(new RSTile(2474, 3436)), 2, 2), 16);
  657.                                 }
  658.                         }
  659.                         int lapPercentage = (246 * positionOfLap / 8);
  660.                         final int levelsGained = skills
  661.                         .getRealSkillLevel(Constants.STAT_AGILITY)
  662.                         - skills.getLvlByExp(startingxp);
  663.                         final long runSeconds = (System.currentTimeMillis() - startTime) / 1000;
  664.                         if (levelsGained < 0) {
  665.                                 startingxp = skills.getCurrentSkillExp(Constants.STAT_AGILITY);
  666.                         }
  667.                         final int xpDone = skills.getCurrentSkillExp(STAT_AGILITY) - XP_TABLE[(skills.getRealSkillLevel(STAT_AGILITY))];
  668.                         ((Graphics2D)g).setRenderingHints(rh);
  669.  
  670.                         Mouse m = Bot.getClient().getMouse();
  671.                         //Below is formula for getting where the real mouse is on the screen.
  672.                         //if(m.x >= <X> && m.x < <X> + <WIDTH> && m.y >= <Y> && m.y < <Y> + <HEIGHT>)
  673.                         //<Graphics reference>.fillRect(<X>, <Y>, <WIDTH>, <HEIGHT>);
  674.                         if(m.x >= 368 && m.x < 368 + 140 && m.y >= 304 && m.y < 304 + 30) {
  675.                                 setpainton = (false);
  676.                         } else {
  677.                                 setpainton = (true);
  678.                         }
  679.                         int pctolevel = skills.getPercentToNextLevel(STAT_AGILITY);
  680.                         int pclevelbar = LevelBar(STAT_AGILITY);
  681.                         if (setpainton) {
  682.                                 //Background
  683.                                 g.setColor(new Color(0, 0, 0, 160));
  684.                                 g.fillRoundRect(4, 228, 512, 112, 10, 10);
  685.                                 g.setColor(new Color(255, 0, 51));
  686.                                 g.drawRoundRect(4, 228, 512, 112, 10, 10);
  687.                                 g.setColor(new Color(0, 0, 0, 105));
  688.                                 g.fillRoundRect(8, 232, 504, 104, 10, 10);
  689.                                 g.setColor(new Color(255, 255, 255));
  690.                                 g.drawRoundRect(8, 232, 504, 104, 10, 10);
  691.                                 //ShowExpButton
  692.                                 if(m.x >= 368 && m.x < 368 + 140 && m.y >= 236 && m.y < 236 + 30) {
  693.                                         showEXP = (true);
  694.                                         showMisc = (false);
  695.                                 }
  696.                                 g.setColor(new Color(255, 255, 255, 121));
  697.                                 g.fillRoundRect(368, 236, 140, 30, 10, 10);
  698.                                 g.setColor(new Color(255, 255, 255));
  699.                                 g.drawRoundRect(368, 236, 140, 30, 10, 10);
  700.                                 g.setFont(new Font("Aharoni", 0, 17));
  701.                                 g.setColor(new Color(255, 255, 255));
  702.                                 if (!showEXP) {
  703.                                         g.drawString("Show Exp", 396, 258);
  704.                                 } else {
  705.                                         g.drawString("EXP Open", 396, 258);
  706.                                 }
  707.                                 //ShowMiscButton
  708.                                 if(m.x >= 368 && m.x < 368 + 140 && m.y >= 270 && m.y < 270 + 30) {
  709.                                         showEXP = (false);
  710.                                         showMisc = (true);
  711.                                 }
  712.                                 g.setColor(new Color(255, 255, 255, 121));
  713.                                 g.fillRoundRect(368, 270, 140, 30, 10, 10);
  714.                                 g.setColor(new Color(255, 255, 255));
  715.                                 g.drawRoundRect(368, 270, 140, 30, 10, 10);
  716.                                 g.setFont(new Font("Aharoni", 0, 17));
  717.                                 g.setColor(new Color(255, 255, 255));
  718.                                 if (!showMisc) {
  719.                                         g.drawString("Show Misc", 394, 292);
  720.                                 } else {
  721.                                         g.drawString("Misc Open", 394, 292);
  722.                                 }
  723.                                 //HeadLine
  724.                                 g.setFont(new Font("Aharoni", 0, 17));
  725.                                 g.setColor(new Color(255, 255, 255));
  726.                                 g.drawString("Jacmobs's Standard Barbarian Agility v1.1", 12, 250);
  727.                                 g.setColor(new Color(255, 0, 51));
  728.                                 g.drawLine(10, 252, 354, 252);
  729.                                 g.setFont(new Font("Aharoni", 0, 15));
  730.                                 g.setColor(new Color(255, 255, 255));
  731.                                 g.drawString("Runtime: " + getFormattedTime(System.currentTimeMillis() - startTime), 12, 268);
  732.                                 //MiscStuff
  733.                                 if (showMisc == (true)) {
  734.                                 g.setFont(new Font("Aharoni", 0, 15));
  735.                                 g.setColor(new Color(255, 255, 255));
  736.                                 g.drawString("Laps Done: " + LapsDone, 12, 284);
  737.                                 if (LapsDone == 0) {
  738.                                         g.drawString("Laps per Hour: Estimating", 12, 300);
  739.                                 } else if (LapsDone > 0) {
  740.                                         g.drawString("Laps per Hour: " + LapsDone * 3600 / runSeconds, 12, 300);
  741.                                 }
  742.                                 g.drawString("Times Failed: " + "In the works", 12, 316);
  743.                                 g.drawString("Lap Progress: Bar", 12, 332);
  744.                                 //ProgressBarLaps
  745.                                 g.setColor(new Color(255, 0, 0));
  746.                                 g.fillRoundRect(110, 320, 246, 12, 10, 10);
  747.                                 g.setColor(new Color(0, 255, 0));
  748.                                 g.fillRoundRect(110, 320, lapPercentage, 12, 10, 10);
  749.                                 g.setColor(new Color(0, 0, 255));
  750.                                 g.drawRoundRect(110, 320, 246, 12, 10, 10);
  751.                                 g.drawRoundRect(110, 320, lapPercentage, 12, 10, 10);
  752.                                 }
  753.                                 //EXPStuff
  754.                                 if (showEXP == (true)) {
  755.                                         g.setFont(new Font("Aharoni", 0, 15));
  756.                                         g.setColor(new Color(255, 255, 255));
  757.                                         g.drawString("Exp Gained: " + (skills.getCurrentSkillExp(Constants.STAT_AGILITY) - startingxp)+ "XP", 12, 284);
  758.                                         if ((skills.getCurrentSkillExp(Constants.STAT_AGILITY) - startingxp) <1 ) {
  759.                                                 g.drawString("Exp per Hour: Estimating", 12, 300);
  760.                                         } else {
  761.                                                 g.drawString("Exp per Hour: "+ (skills.getCurrentSkillExp(Constants.STAT_AGILITY) - startingxp)* 3600 / runSeconds +"XP/h", 12, 300);
  762.                                         }
  763.                                         g.drawString("Exp to Level: " + skills.getXPToNextLevel(Constants.STAT_AGILITY)+ "XP", 12, 316);
  764.                                         g.drawString("Levels Gained: "+ levelsGained, 242, 284);
  765.                                         g.drawString("Exp Progress: ", 12, 332);
  766.                                         g.drawString("% to Level: " + (pctolevel) + "%", 260, 316);
  767.                                         //ProgressBarEXP
  768.                                         g.setColor(new Color(255, 0, 0));
  769.                                         g.fillRoundRect(110, 320, 246, 12, 10, 10);
  770.                                         g.setColor(new Color(0, 255, 0));
  771.                                         g.fillRoundRect(110, 320, pclevelbar, 12, 10, 10);
  772.                                         g.setColor(new Color(0, 0, 255));
  773.                                         g.drawRoundRect(110, 320, 246, 12, 10, 10);
  774.                                         g.drawRoundRect(110, 320, pclevelbar, 12, 10, 10);
  775.                                 }
  776.                         }
  777.                         //HidePaintButton
  778.                         g.setColor(new Color(255, 255, 255, 121));
  779.                         g.fillRoundRect(368, 304, 140, 30, 10, 10);
  780.                         g.setColor(new Color(255, 255, 255));
  781.                         g.drawRoundRect(368, 304, 140, 30, 10, 10);
  782.                         g.setFont(new Font("Aharoni", 0, 17));
  783.                         g.setColor(new Color(255, 255, 255));
  784.                         if (setpainton) {
  785.                                 g.drawString("Hide Paint", 394, 326);
  786.                         } else if (!setpainton) {
  787.                                 g.drawString("Paint Hidden", 390, 326);
  788.                         }
  789.                 }
  790.         }
  791. }