Recent Posts
None | 8 sec ago
None | 15 sec ago
None | 27 sec ago
None | 28 sec ago
ASM (NASM) | 36 sec ago
MySQL | 37 sec ago
HTML | 37 sec ago
C# | 48 sec ago
None | 49 sec ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By bradleyw123 on the 10th of Feb 2010 01:17:02 AM Download | Raw | Embed | Report
  1. import org.rsbot.bot.Bot;
  2. import org.rsbot.bot.input.Mouse;
  3. import org.rsbot.event.events.ServerMessageEvent;
  4. import org.rsbot.event.listeners.PaintListener;
  5. import org.rsbot.event.listeners.ServerMessageListener;
  6. import org.rsbot.script.*;
  7. import org.rsbot.script.wrappers.*;
  8.  
  9. import java.awt.*;
  10. import java.util.ArrayList;
  11. import java.util.Map;
  12. @ScriptManifest(authors = {"Zenzie"}, category = "Combat", name = "AIOSoulwars", version = 1.5, description =
  13.         "<html><head>" +
  14.                 "<style type=\"text/css\"> body {background-color: #333333; color: #FFFFFF; padding: 5px; font-family: Arial; text-align: center;}" +
  15.                 "h1 {font-weight: bold; color: #FFFFFF; font-size: 14px; padding: 0px; margin: 0px; margin-top: 4px; }" +
  16.                 "h2 {color: #FF0000; padding: 0px; margin: 0px; margin-top: 1px; margin-bottom: 5px; font-weight: normal; font-size: 10px;}" +
  17.                 "td {font-weight: bold; width: 50%;}</style>" +
  18.                 "</head><body>" +
  19.                 "<div style=\"width: 100%, height: 80px; background-color: #111111; text-align: center; padding: 5px;\">" +
  20.                 "<h1>AIOSoulwars 1.5</h1>" +
  21.                 "<h2>Zenzie</h2></div><br />" +
  22.                 "Make sure that you are already using the combat style that you want to train." +
  23.                 "Thread: http://www.rsbot.org/vb/showthread.php?t=170805" +
  24.                 "<br /><br /><br /><table style=\"border: 0px; width: 200px; margin: auto;\"><tr>" +
  25.                 "</select><tr><td>Play Style:</td>" +
  26.                 "<td><select name=\"playStyle\">" +
  27.                 "<option>Attack Players</option>" +
  28.                 "<option>Bandage</option>" +
  29.                 "<option>Attack NPCs</option>" +
  30.                 "</select><tr><td>Turn on Quick-Prayer at:</td>" +
  31.                 "<td><select name=\"quickPrayAt\">" +
  32.                 "<option>Nowhere</option>" +
  33.                 "<option>Obelisk</option>" +
  34.                 "<option>Bandages</option>" +
  35.                 "<option>Jellies</option>" +
  36.                 "<option>Pyres</option>" +
  37.                 "</select><tr><td>Join team:</td><td><select name=\"joinTeam\">" +
  38.                 "<option>Red</option>" +
  39.                 "<option>Blue</option>" +
  40.                 "<option>Last won</option>" +
  41.                 "<option>Last lost</option>" +
  42.                 "<option>Clan chat</option>" +
  43.                 "</select><tr><td>Pick Bandages One-by-one:</td>" +
  44.                 "<td><select name=\"oneByOne\">" +
  45.                 "<option>Yes</option>" +
  46.                 "<option>No</option>" +
  47.                 "</select></table>" +
  48.                 "</body></html>")
  49.  
  50. public class AIOSoulwars extends Script implements PaintListener, ServerMessageListener {
  51.  
  52.     public enum actions {
  53.         CHOOSING_TEAM, JOINING_BLUE, JOINING_RED, WAITING_FOR_GAME, LEAVING_SPAWN, WALKING_TO_BANDAGES,
  54.         GETTING_BANDAGES, USING_BANDAGES, ATTACKING_PLAYERS,LEAVING_GRAVEYARD,
  55.         ATTACKING_MONSTER, SUICIDE, WAIT
  56.     }
  57.    
  58.     public enum Box {
  59.         BLUE_BARRIER(32,48,-57,57,13,153),
  60.         RED_BARRIER(110,89,-57,57,13,153),
  61.         BLUE_SPAWN_BARRIER(19,37,-57,57,13,153),
  62.         RED_SPAWN_BARRIER(-19,-37,-57,57,13,153),
  63.         BLUE_GRAVE_BARRIER(-57,55,86,102,-3,153),
  64.         RED_GRAVE_BARRIER(57,-55,-78,-55,-3,153);
  65.  
  66.  
  67.         public int xstart, xstop, ystart, ystop, zstart, zstop;
  68.  
  69.         Box(int xstart, int xstop, int ystart, int ystop, int zstart, int zstop) {
  70.             this.xstart = xstart;
  71.             this.xstop = xstop;
  72.             this.ystart = ystart;
  73.             this.ystop = ystop;
  74.             this.zstart = zstart;
  75.             this.zstop = zstop;
  76.         }
  77.  
  78.         public Polygon getPolygon(RSTile tile) {
  79.             try {
  80.                 int x = (tile.getX() - Bot.getClient().getBaseX()) * 128 + 64;
  81.                 int y = (tile.getY() - Bot.getClient().getBaseY()) * 128 + 64;
  82.                 Point p = Calculations
  83.                     .worldToScreen(x + xstart, y + ystart, zstart);
  84.                 Point p1 = Calculations
  85.                     .worldToScreen(x + xstart, y + ystop, zstart);
  86.                 Point p2 = Calculations
  87.                     .worldToScreen(x + xstop, y + ystart, zstart);
  88.                 Point p3 = Calculations.worldToScreen(x + xstop, y + ystop, zstart);
  89.  
  90.                 Point p4 = Calculations
  91.                     .worldToScreen(x + xstart, y + ystart, zstop);
  92.                 Point p5 = Calculations.worldToScreen(x + xstart, y + ystop, zstop);
  93.                 Point p6 = Calculations.worldToScreen(x + xstop, y + ystart, zstop);
  94.                 Point p7 = Calculations.worldToScreen(x + xstop, y + ystop, zstop);
  95.                 if (p.x == -1 || p1.x == -1 || p2.x == -1 || p3.x == -1
  96.                     || p4.x == -1 || p5.x == -1 || p6.x == -1 || p7.x == -1) {
  97.                 return null;
  98.                 }
  99.                 int xp[] = { p.x, p1.x, p3.x, p2.x, p.x, p4.x, p5.x, p1.x, p5.x,
  100.                     p7.x, p3.x, p7.x, p6.x, p2.x, p6.x, p4.x };
  101.                 int yp[] = { p.y, p1.y, p3.y, p2.y, p.y, p4.y, p5.y, p1.y, p5.y,
  102.                     p7.y, p3.y, p7.y, p6.y, p2.y, p6.y, p4.y };
  103.                 return new Polygon(xp, yp, xp.length);
  104.             } catch(Exception ignored) {
  105.                 return null;
  106.             }
  107.         }
  108.     }
  109.  
  110.     int selectedTab = 0;
  111.     long startTime = System.currentTimeMillis();
  112.  
  113.     String onTeam = "None";
  114.  
  115.     int won = 0;
  116.     int tie = 0;
  117.     int lost = 0;
  118.     int zeals = 0;
  119.     int kickedGames = 0;
  120.     int playedGames = 0;
  121.  
  122.     String whatToJoin = "Nothing";
  123.     String lastWon = "Dunno";
  124.  
  125.     String howToPlayInGame = "";
  126.     String turnOnQuickPrayAt = "";
  127.     boolean inGame = false;
  128.     int cantAttack = 0;
  129.     int antiBanTimer = 0;
  130.  
  131.     String actionName = "";
  132.  
  133.     int callBlue = 0;
  134.     int callRed = 0;
  135.     public String lastCCMessage = "";
  136.         public boolean continueChat = true;
  137.  
  138.     int startXPSTR = skills.getCurrentSkillExp(STAT_STRENGTH);
  139.     int startXPDEF = skills.getCurrentSkillExp(STAT_DEFENSE);
  140.     int startXMAGE = skills.getCurrentSkillExp(STAT_MAGIC);
  141.     int startXRANGE = skills.getCurrentSkillExp(STAT_RANGE);
  142.     int startXPATT = skills.getCurrentSkillExp(STAT_ATTACK);
  143.     int startHPXP = skills.getCurrentSkillExp(STAT_HITPOINTS);
  144.  
  145.     int[] dropTheseItems = {229,14643,14644,14638,14640};
  146.     String BandagesClickByClick;
  147.  
  148.     public void serverMessageRecieved(ServerMessageEvent e) {
  149.         String message = e.getMessage();
  150.         if (message.contains("You receive 1 Zeal")) {
  151.             inGame = false;
  152.             zeals += 1;
  153.             lost += 1;
  154.             playedGames += 1;
  155.             if (onTeam.equals("Blue")) {
  156.                 lastWon = "Red";
  157.             } else if (onTeam.equals("Red")) {
  158.                 lastWon = "Blue";
  159.             }
  160.             actionName = "Choosing Team";
  161.         }
  162.         if (message.contains("You receive 2 Zeal")) {
  163.             inGame = false;
  164.             zeals += 2;
  165.             playedGames += 1;
  166.             tie += 1;
  167.             lastWon = "Dunno";
  168.             actionName = "Choosing Team";
  169.         }
  170.         if (message.contains("You receive 3 Zeal")) {
  171.             inGame = false;
  172.             zeals += 3;
  173.             won += 1;
  174.             playedGames += 1;
  175.             if (onTeam.equals("Blue")) {
  176.                 lastWon = "Blue";
  177.             } else if (onTeam.equals("Red")) {
  178.                 lastWon = "Red";
  179.             }
  180.             actionName = "Choosing Team";
  181.         }
  182.         if (message.contains(("You receive 0 Zeal"))) {
  183.             inGame = false;
  184.             playedGames += 1;
  185.             if (onTeam.equals("Blue")) {
  186.                 lastWon = "Red";
  187.             } else if (onTeam.equals("Red")) {
  188.                 lastWon = "Blue";
  189.             }
  190.         }
  191.     }
  192.  
  193.     public void onRepaint(Graphics g) {
  194.  
  195.         int x = Bot.getInputManager().getX();
  196.         int y = Bot.getInputManager().getY();
  197.  
  198.         g.setColor(Color.BLUE);
  199.         if(x != -1 && y != -1) {
  200.             Graphics2D g2 = (Graphics2D) g;
  201.             g2.setStroke(new BasicStroke(3));
  202.             g2.drawLine(x - 5, y, x + 5, y);
  203.             g2.drawLine(x, y - 5, x, y + 5);
  204.             g2.setStroke(new BasicStroke(1));
  205.         }
  206.  
  207.         g.setColor(Color.WHITE);
  208.         int attXP = skills.getCurrentSkillExp(STAT_ATTACK) - startXPATT;
  209.         int strXP = skills.getCurrentSkillExp(STAT_STRENGTH) - startXPSTR;
  210.         int defXP = skills.getCurrentSkillExp(STAT_DEFENSE) - startXPDEF;
  211.         int mageXP = skills.getCurrentSkillExp(STAT_MAGIC) - startXMAGE;
  212.         int rangeXP = skills.getCurrentSkillExp(STAT_RANGE) - startXRANGE;
  213.         int gainedHPXP = skills.getCurrentSkillExp(STAT_HITPOINTS) - startHPXP;
  214.         int barsize = 100;
  215.         int barheight = 15;
  216.         int transparancy = 170;
  217.         int xBar = 560;
  218.         int yBar = 360;
  219.  
  220.         long millis = System.currentTimeMillis() - startTime;
  221.         long hours = millis / (1000 * 60 * 60);
  222.         millis -= hours * 1000 * 60 * 60;
  223.         long minutes = millis / (1000 * 60);
  224.         millis -= minutes * 1000 * 60;
  225.         long seconds = millis / 1000;
  226.  
  227.         selectedTab = getMouseTab();
  228.  
  229.                 Polygon box1 = Box.BLUE_BARRIER.getPolygon(new RSTile(1879, 3162));
  230.         Polygon box2 = Box.RED_BARRIER.getPolygon(new RSTile(1899, 3162));
  231.         Polygon box3 = Box.BLUE_SPAWN_BARRIER.getPolygon(new RSTile(1815,3225));
  232.         Polygon box4 = Box.RED_SPAWN_BARRIER.getPolygon(new RSTile(1959, 3239));
  233.         Polygon box5 = Box.BLUE_GRAVE_BARRIER.getPolygon(new RSTile(1842,3219));
  234.         Polygon box6 = Box.RED_GRAVE_BARRIER.getPolygon(new RSTile(1933,3244));
  235.         if(box1 != null) g.drawPolygon(box1);
  236.         if(box2 != null) g.drawPolygon(box2);
  237.         if(box3 != null) g.drawPolygon(box3);
  238.         if(box4 != null) g.drawPolygon(box4);
  239.         if(box5 != null) g.drawPolygon(box5);
  240.         if(box6 != null) g.drawPolygon(box6);
  241.  
  242.         g.setColor(new Color(0, 0, 0, 90));
  243.         g.fillRect(550, 205, 184, 30);
  244.         g.fill3DRect(550, 234, 185, 233, true);
  245.         g.setColor(Color.BLACK);
  246.         g.drawRect(550, 205, 184, 30);
  247.         g.drawLine(610, 205, 610, 235);
  248.         g.drawLine(680, 205, 680, 235);
  249.  
  250.         g.setColor(Color.LIGHT_GRAY);
  251.         g.drawString("Game", 564, 225);
  252.         g.drawString("Gained", 624, 225);
  253.         g.drawString("Info", 695, 225);
  254.  
  255.         g.setColor(Color.WHITE);
  256.         switch (selectedTab) {
  257.             case 0:
  258.                 g.drawString("Game", 564, 225);
  259.                 g.drawString("Games completed: " + playedGames, 560, 255);
  260.                 g.drawString("Games kicked: " + kickedGames, 560, 270);
  261.                 g.drawString("Won " + won + " games", 560, 300);
  262.                 g.drawString("Tied " + tie + " games", 560, 315);
  263.                 g.drawString("Lost " + lost + " games", 560, 330);
  264.  
  265.                 if(getActivityBarPercent() != -1 && inGame) {
  266.                     g.drawString("Activity Bar " + getActivityBarPercent() + "%", 565, 372);
  267.                     g.setColor(new Color(255, 0, 0, transparancy));
  268.                     g.fillRect(xBar, yBar, barsize, barheight);
  269.                     g.setColor(new Color(0, 255, 0, transparancy));
  270.                     g.fillRect(xBar, yBar, barsize/100* getActivityBarPercent(), barheight);
  271.                     g.setColor(new Color(255, 255, 255, transparancy));
  272.                     g.drawRect(xBar, yBar, barsize, barheight);
  273.                     g.setColor(Color.WHITE);
  274.                 }
  275.  
  276.                 break;
  277.             case 1:
  278.                 g.drawString("Gained", 624, 225);
  279.                 g.drawString("Gained " + zeals + " zeals", 560, 255);
  280.                 g.drawString("Hitpoints XP gained : " + gainedHPXP, 560, 285);
  281.                 g.drawString("Attack XP gained: " + attXP, 560, 300);
  282.                 g.drawString("Strength XP gained: " + strXP, 560, 315);
  283.                 g.drawString("Defense XP gained: " + defXP, 560, 330);
  284.                 g.drawString("Ranged XP gained: " + rangeXP, 560, 345);
  285.                 g.drawString("Magic XP gained: " + mageXP, 560, 360);
  286.                 break;
  287.             case 2:
  288.                 g.drawString("Info", 695, 225);
  289.                 g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds, 560, 255);
  290.                 g.drawString("State: " + actionName, 560, 270);
  291.                 g.drawString("Blue calls: " + callBlue, 560, 300);
  292.                 g.drawString("Red calls: " + callRed, 560, 315);
  293.                 g.drawString("Joining: " + whatToJoin, 560, 345);
  294.                 g.drawString("In-Game Style: " + howToPlayInGame, 560, 360);
  295.                 g.drawString("In-Game: " + String.valueOf(inGame), 560,375);
  296.                 g.drawString("AIOSoulwars", 560, 435);
  297.                 g.drawString("By Zenzie", 560, 450);
  298.                 break;
  299.         }
  300.     }
  301.  
  302.     private int getMouseTab() {
  303.         final Mouse mouse = Bot.getClient().getMouse();
  304.         if (mouse.x > 550 && mouse.x < 610 && mouse.y > 205 && mouse.y < 230) {
  305.             selectedTab = 0;
  306.         }
  307.         if (mouse.x > 610 && mouse.x < 680 && mouse.y > 205 && mouse.y < 230) {
  308.             selectedTab = 1;
  309.         }
  310.         if (mouse.x > 680 && mouse.x < 735 && mouse.y > 205 && mouse.y < 230) {
  311.             selectedTab = 2;
  312.         }
  313.         return selectedTab;
  314.     }
  315.  
  316.     @Override
  317.     public boolean onStart(final Map<String, String> args) {
  318.         setCameraAltitude(true);
  319.         turnOnQuickPrayAt = args.get("quickPrayAt");
  320.         howToPlayInGame = args.get("playStyle");
  321.         whatToJoin = args.get("joinTeam");
  322.         BandagesClickByClick = args.get("oneByOne");
  323.         actionName = "Choosing Team";
  324.         if(whatToJoin.equals("Clan chat")) {
  325.                 log("Started reading clan chat");
  326.                 new clanChat().start();
  327.         }
  328.         return true;
  329.     }
  330.  
  331.     public void onFinish() {
  332.                 continueChat = false;
  333.                 Bot.getEventManager().removeListener(PaintListener.class, this);
  334.                 Bot.getEventManager().removeListener(ServerMessageListener.class, this);
  335.         }
  336.  
  337.     public actions getAction() {
  338.  
  339.         if (actionName.equals("Choosing Team") && !actionName.equals("Waiting for game") && !inGame) {
  340.             return actions.CHOOSING_TEAM;
  341.         }
  342.         if (actionName.contains("Joining") && !actionName.equals("Choosing Team") && !inArea(1870,1879,3158,3166) &&
  343.                 !inArea(1900,1909,3157,3166) && !inArea(1816,1823,3220,3230) && !inArea(1951,1958,3234,3244) && !inGame) {
  344.             if (actionName.equals("Joining blue team")) {
  345.                 return actions.JOINING_BLUE;
  346.             }
  347.             if (actionName.equals("Joining red team")) {
  348.                 return actions.JOINING_RED;
  349.             }
  350.         }
  351.         if (inArea(1870,1879,3158,3166) || inArea(1900,1909,3157,3166)) {
  352.             return actions.WAITING_FOR_GAME;
  353.         }
  354.         if (inArea(1816,1823,3220,3230) || inArea(1951,1958,3234,3244)) {
  355.             return actions.LEAVING_SPAWN;
  356.         }
  357.         if((inArea(1798,1811,3250,3260) || inArea(1963,1974,3200,3212)) && howToPlayInGame.equals("Bandage") && inGame ) {
  358.             if (inventoryContains(14640)) {
  359.                 return actions.USING_BANDAGES;
  360.             } else {
  361.                 return actions.GETTING_BANDAGES;
  362.             }
  363.         }
  364.         if (!inArea(1816,1823,3220,3230) && !inArea(1951,1958,3234,3244) && !inArea(1798,1811,3250,3260)
  365.                 && !inArea(1963, 1974, 3200, 3212) && howToPlayInGame.equals("Bandage") && inGame) {
  366.             return actions.WALKING_TO_BANDAGES;
  367.         }
  368.         if (howToPlayInGame.equals("Attack Players") && !actionName.equals("Suicide") && inGame) {
  369.             if(!inArea(1841, 1843, 3217, 3219) && !inArea(1932, 1934, 3244, 3246) && !inArea(1816,1823,3220,3230) && !inArea(1951,1958,3234,3244)) {
  370.                 return actions.ATTACKING_PLAYERS;
  371.             }
  372.         }
  373.         if ((inArea(1841, 1843, 3217, 3219) || inArea(1932, 1934, 3244, 3246)) && inGame) {
  374.             return actions.LEAVING_GRAVEYARD;
  375.         }
  376.         if(!inArea(1816,1823,3220,3230) && !inArea(1951,1958,3234,3244) && !inArea(1841, 1843, 3217, 3219) &&
  377.                 !inArea(1932, 1934, 3244, 3246) && howToPlayInGame.equals("Attack NPCs") && inGame) {
  378.             return actions.ATTACKING_MONSTER;
  379.         }
  380.  
  381.         return actions.WAIT;
  382.     }
  383.  
  384.     public int loop() {
  385.  
  386.         if(!actionName.equals("Choosing Team") && !inArea(1770,2000,3180,3610) &&
  387.                 !actionName.contains("Joining") && !inArea(1870,1879,3158,3166) && !inArea(1900,1909,3157,3166)) {
  388.             inGame = false;
  389.             actionName = "Choosing Team";
  390.         }
  391.  
  392.         if(!inGame && inventoryContains(dropTheseItems)) {
  393.             for (final int id : dropTheseItems) {
  394.                                 if (getInventoryCount(id) > 0) {
  395.                                         clickInventoryItem(dropTheseItems, "Drop");
  396.                                 }
  397.             }
  398.         }
  399.  
  400.  
  401.         actions act = getAction();
  402.  
  403.         if (!isRunning() && getEnergy() >= random(45, 60)) {
  404.             setRun(true);
  405.             wait(random(250,500));
  406.         }
  407.  
  408.         if (RSInterface.getChildInterface(243, 4).isValid() &&
  409.                 RSInterface.getChildInterface(243, 4).containsText("You were removed from the game due")) {
  410.             kickedGames += 1;
  411.             actionName = "Choosing Team";
  412.             inGame = false;
  413.  
  414.         }
  415.  
  416.             String time = RSInterface.getInterface(836).getChild(27).getText();
  417.             if (time.equals("2 mins") || time.equals(" 1 min") || time.equals("3 mins")) {
  418.                 if (whatToJoin.equals("Clan chat")) {
  419.                     continueChat = true;
  420.                 }
  421.             }
  422.  
  423.         if(inGame) {
  424.             if(random(0,30) == 20) {
  425.                 antiBan(0,6);
  426.             }
  427.         }
  428.  
  429.         switch (act) {
  430.  
  431.             case CHOOSING_TEAM:
  432.                 if (whatToJoin.equals("Red")) {
  433.                     actionName = "Joining red team";
  434.                 } else if (whatToJoin.equals("Blue")) {
  435.                     actionName = "Joining blue team";
  436.                 } else if (whatToJoin.equals("Last won")) {
  437.                     if (lastWon.equals("Blue")) {
  438.                         actionName = "Joining blue team";
  439.                     } else if (lastWon.equals("Red")) {
  440.                         actionName = "Joining red team";
  441.                     } else if (lastWon.equals("Dunno")) {
  442.                         actionName = "Joining blue team";
  443.                     }
  444.                 } else if (whatToJoin.equals("Last lost")) {
  445.                     if (lastWon.equals("Blue")) {
  446.                         actionName = "Joining red team";
  447.                     } else if (lastWon.equals("Red")) {
  448.                         actionName = "Joining blue team";
  449.                     } else if (lastWon.equals("Dunno")) {
  450.                         actionName = "Joining blue team";
  451.                     }
  452.                 } else if (whatToJoin.equals("Clan chat") && callBlue == 0 && callRed == 0) {
  453.                     continueChat = true;
  454.                 } else if(callBlue > callRed && whatToJoin.equals("Clan chat")) {
  455.                     actionName = "Joining blue team";
  456.                 } else if(callRed > callBlue && whatToJoin.equals("Clan chat")) {
  457.                      actionName = "Joining red team";
  458.                 }
  459.                 break;
  460.  
  461.             case JOINING_BLUE:
  462.                 onTeam = "Blue";
  463.                 if(distanceTo(new RSTile(1882, 3162)) > 3) {
  464.                     walkTo2(randomizeTile(new RSTile(1882, 3162),2,2));
  465.                 }
  466.                 Polygon box1 = Box.BLUE_BARRIER.getPolygon(new RSTile(1879, 3162));
  467.                 if (box1 != null) {
  468.                     if (distanceTo(new RSTile(1879, 3162)) <= 4 && !getMyPlayer().isMoving()) {
  469.                         if(box1 == null) {
  470.                             walkTile(randomizeTile(new RSTile(1879,3162), 2, 2));
  471.                         }
  472.                         if (box1 != null) {
  473.                             if(onPoly(box1, "barrier")) {
  474.                                 wait(random(1200,1800));
  475.                             }
  476.                         }
  477.                         if (waitTime() >= 2) {
  478.                             wait(random(20000, 40000));
  479.                         } else if(waitTime() == 1) {
  480.                             wait(random(10000,20000));
  481.                         }
  482.                         if (atInterface(RSInterface.getInterface(211).getChild(3))) {
  483.                             wait(random(2000, 3000));
  484.                         }
  485.                         if (atInterface(RSInterface.getInterface(228).getChild(2))) {
  486.                             wait(random(2000, 3000));
  487.                         }
  488.                 } else {
  489.                     walkTile(randomizeTile(new RSTile(1879, 3162), 2, 2));
  490.                 }
  491.              }
  492.             break;
  493.  
  494.             case JOINING_RED:
  495.                 onTeam = "Red";
  496.                 if(distanceTo(new RSTile(1899, 3162)) > 3) {
  497.                     walkTo2(randomizeTile(new RSTile(1899, 3162),2,2));
  498.                 }
  499.                 Polygon box2 = Box.RED_BARRIER.getPolygon(new RSTile(1899, 3162));
  500.                     if (!getMyPlayer().isMoving()) {
  501.                         if(box2 == null) {
  502.                             walkTile(randomizeTile(new RSTile(1899, 3162), 2, 2));
  503.                         }
  504.                         if (box2 != null) {
  505.                             if(onPoly(box2, "barrier")) {
  506.                                 wait(random(1200,1800));
  507.                             }
  508.                         }
  509.                     }
  510.                     if (waitTime() >= 2) {
  511.                         wait(random(20000, 40000));
  512.                     } else if(waitTime() == 1) {
  513.                             wait(random(10000,20000));
  514.                     }
  515.                     if (atInterface(RSInterface.getInterface(211).getChild(3))) {
  516.                         wait(random(1500, 1800));
  517.                     }
  518.                     if (atInterface(RSInterface.getInterface(228).getChild(2))) {
  519.                         wait(random(1200, 1500));
  520.                     }
  521.                 break;
  522.  
  523.             case WAITING_FOR_GAME:
  524.                 callBlue = 0;
  525.                 callRed = 0;
  526.                 inGame = true;
  527.                 continueChat = false;
  528.                 actionName = "Waiting for game";
  529.                 if (actionName.equals("Waiting for game")) {
  530.                     if (random(1, 30) == 2) {
  531.                         if (onTeam.equals("Blue")) {
  532.                             int blueX = random(1870, 1879);
  533.                             int blueY = random(3159, 3165);
  534.                             walkTile(new RSTile(blueX, blueY));
  535.                         }
  536.                         if (onTeam.equals("Red")) {
  537.                             int redX = random(1900, 1909);
  538.                             int redY = random(3157, 3165);
  539.                             walkTile(new RSTile(redX, redY));
  540.                         }
  541.                     }
  542.                     wait(random(1666, 5000));
  543.                     antiBanTimer += 1;
  544.                     if (antiBanTimer >= 4) {
  545.                         antiBan(0, 6);
  546.                         antiBanTimer = 0;
  547.                     }
  548.                 }
  549.                 break;
  550.  
  551.             case LEAVING_SPAWN:
  552.                 setCameraAltitude(true);
  553.                 actionName = "Leaving spawn";
  554.                 if (onTeam.equals("Blue")) {
  555.                     Polygon box3 = Box.BLUE_SPAWN_BARRIER.getPolygon(new RSTile(1815,3225));
  556.                     if (!getMyPlayer().isMoving()) {
  557.                         if(box3 == null) {
  558.                             walkTileMM(randomizeTile(new RSTile(1815,3225),2,2));
  559.                         }
  560.                         if (box3 != null) {
  561.                             if(onPoly(box3, "barrier")) {
  562.                                 wait(random(1500, 2500));
  563.                             }
  564.                         }
  565.                     }
  566.                 } else if (onTeam.equals("Red")) {
  567.                     Polygon box4 = Box.RED_SPAWN_BARRIER.getPolygon(new RSTile(1959, 3239));
  568.                     if (!getMyPlayer().isMoving()) {
  569.                         if (box4 != null) {
  570.                             if(onPoly(box4, "barrier")) {
  571.                                 wait(random(1500, 2500));
  572.                             }
  573.                         }
  574.                         if(box4 == null) {
  575.                             walkTile(randomizeTile(new RSTile(1959, 3239), 2, 2));
  576.                         }
  577.                     }
  578.                 }
  579.                 break;
  580.  
  581.             case WALKING_TO_BANDAGES:
  582.                 actionName = "Walking to bandages";
  583.                 if (onTeam.equals("Blue")) {
  584.                     walkTo2(randomizeTile(new RSTile(1810, 3254),2 ,2));
  585.                 }
  586.                 if (onTeam.equals("Red")) {
  587.                     walkTo2(randomizeTile(new RSTile(1963,3207),2 ,2));
  588.                 }
  589.                 break;
  590.  
  591.             case GETTING_BANDAGES:
  592.                 if(!isInCameraAngleForBandages()) {
  593.                     int randomCom = random(1,3);
  594.                     if(randomCom == 2) {
  595.                         setCameraRotation(random(240,280));
  596.                     } else {
  597.                         setCameraRotation(random(60,100));
  598.                     }
  599.                 }
  600.                 actionName = "Getting bandages";
  601.                 setCameraAltitude(true);
  602.                 if (onTeam.equals("Blue")) {
  603.                     RSTile bandageTableBlue = new RSTile(1810, 3254);
  604.                     if (bandageTableBlue != null) {
  605.                         if (distanceTo(new RSTile(1810, 3254)) > 2 && !getMyPlayer().isMoving()) {
  606.                             walkTileMM(randomizeTile(new RSTile(1810, 3254), 2, 2));
  607.                         }
  608.                         if (distanceTo(bandageTableBlue) <= 2 && !getMyPlayer().isMoving()) {
  609.                             if(BandagesClickByClick.equals("No")) {
  610.                                 atTile(bandageTableBlue, "Take-x");
  611.                                 wait(random(2000, 5000));
  612.                                 if (RSInterface.getInterface(752).getChild(4).isValid() && RSInterface.getInterface(752).getChild(4).containsText("How many bandages would")
  613.                                     && !getMyPlayer().isInCombat()) {
  614.                                     if(distanceTo(bandageTableBlue) <= 2) {
  615.                                         sendText(Integer.toString(random(28, 100)), true);
  616.                                     }
  617.                                     wait(random(600, 950));
  618.                                 }
  619.                             } else {
  620.                                 atTile(bandageTableBlue, "Take-from");
  621.                                 wait(random(1000,1500));
  622.                             }
  623.                         } else if (!getMyPlayer().isMoving()) {
  624.                             walkTile(randomizeTile(new RSTile(1810, 3254), 2, 2));
  625.                         }
  626.                     }
  627.                 } else {
  628.                     RSTile bandageTableRed = new RSTile(1963, 3207);
  629.                     if (bandageTableRed != null) {
  630.                         if (distanceTo(new RSTile(1963, 3207)) > 2 && !getMyPlayer().isMoving()) {
  631.                             walkTileMM(randomizeTile(new RSTile(1962,3207), 2, 2));
  632.                         }
  633.                         if (distanceTo(bandageTableRed) <= 2 && !getMyPlayer().isMoving()) {
  634.                             if(BandagesClickByClick.equals("No")) {
  635.                                 wait(random(1000, 1500));
  636.                                 atTile(bandageTableRed, "Take-x");
  637.                                 wait(random(1500, 3000));
  638.                                 if (RSInterface.getInterface(752).getChild(4).isValid() && RSInterface.getInterface(752).getChild(4).containsText("How many bandages would")
  639.                                         && !getMyPlayer().isInCombat()) {
  640.                                     if(distanceTo(bandageTableRed) <= 2) {
  641.                                         sendText(Integer.toString(random(28, 100)), true);
  642.                                     }
  643.                                     wait(random(600, 950));
  644.                                 }
  645.                             } else {
  646.                                 atTile(bandageTableRed, "Take-from");
  647.                                 wait(random(1000,1500));
  648.                             }
  649.                         } else if (!getMyPlayer().isMoving()) {
  650.                             walkTile(randomizeTile(new RSTile(1963, 3207), 2, 2));
  651.                         }
  652.                     }
  653.                 }
  654.                 break;
  655.  
  656.             case USING_BANDAGES:
  657.                     if(turnOnQuickPrayAt.equals("Bandages")) {
  658.                         if(getSetting(1396) == 0 && skills.getCurrentSkillLevel(Constants.STAT_PRAYER) > 0) {
  659.                             atInterface(749, 4, "Turn quick prayers on");
  660.                         }
  661.                     }
  662.                     useBandagesOnOtherPlayer();
  663.                 break;
  664.  
  665.             case ATTACKING_PLAYERS:
  666.                 if(!inArea(1872,1901,3218,3245) && !inArea(1798,1811,3250,3260) && !inArea(1963, 1974, 3212, 3200)) {
  667.                     actionName = "Walking to obelisk";
  668.                     if (onTeam.equals("Blue")) {
  669.                         if(getMyPlayer().getLocation().getX() < 1816
  670.                                 && getMyPlayer().getLocation().getY() < 3235) {
  671.                             walkTo2(randomizeTile(new RSTile(1810,3245),2,2));
  672.                         } else if (getMyPlayer().getLocation().getX() > 1816
  673.                                 && getMyPlayer().getLocation().getX() < 1843) {
  674.                             walkTo2(randomizeTile(new RSTile(1853, 3234),2 , 2));
  675.                         } else {
  676.                             walkTo2(randomizeTile(new RSTile(1885,3232),2,2));
  677.                         }
  678.                     }
  679.                     if (onTeam.equals("Red")) {
  680.                         if(getMyPlayer().getLocation().getX() >= 1959) {
  681.                             walkTo2(randomizeTile(new RSTile(1955,3212),2,2));
  682.                         } else if(getMyPlayer().getLocation().getX() > 1929
  683.                                 && getMyPlayer().getLocation().getX() < 1950) {
  684.                             walkTo2(randomizeTile(new RSTile(1920,3231),2,2));
  685.                         } else {
  686.                             walkTo2(randomizeTile(new RSTile(1885,3232),2,2));
  687.                         }
  688.                     }
  689.                 }
  690.                 if(inArea(1872,1901,3218,3245)) {
  691.                     actionName = "Killing players";
  692.                     setCameraAltitude(true);
  693.                     if(turnOnQuickPrayAt.equals("Obelisk")) {
  694.                         if(getSetting(1396) == 0 && skills.getCurrentSkillLevel(Constants.STAT_PRAYER) > 0) {
  695.                             atInterface(749, 4, "Turn quick prayers on");
  696.                         }
  697.                     }
  698.                     if(!getMyPlayer().isMoving() && !getMyPlayer().isInCombat()) {
  699.                         getAttackAblePlayer();
  700.                     }
  701.                 }
  702.                 break;
  703.  
  704.             case LEAVING_GRAVEYARD:
  705.                 actionName = "Leaving graveyard";
  706.                 cantAttack = 0;
  707.                 if(!isInCameraAngleForGraveYard()) {
  708.                     int randomCom = random(1,3);
  709.                     if(randomCom == 2) {
  710.                         setCameraRotation(random(330,380));
  711.                     } else {
  712.                         setCameraRotation(random(150,200));
  713.                     }
  714.                 }
  715.  
  716.                 if (actionName.equals("Leaving graveyard")) {
  717.                     if (inArea(1841,1843,3217,3219)) {
  718.                         Polygon box5 = Box.BLUE_GRAVE_BARRIER.getPolygon(new RSTile(1842,3219));
  719.                         if (box5 != null && !getMyPlayer().isMoving()) {
  720.                             onPoly(box5, "barrier");
  721.                         }
  722.                     }
  723.                     if (inArea(1932,1934,3244,3246)) {
  724.                         Polygon box6 = Box.RED_GRAVE_BARRIER.getPolygon(new RSTile(1933,3244));
  725.                         if (box6 != null && !getMyPlayer().isMoving()) {
  726.                             onPoly(box6, "barrier");
  727.                         }
  728.                     }
  729.                 }
  730.                 break;
  731.  
  732.             case ATTACKING_MONSTER:
  733.                 int slayerLevel = skills.getRealSkillLevel(STAT_SLAYER);
  734.  
  735.                 if(slayerLevel < 30) {
  736.                     howToPlayInGame = "Attack Players";
  737.                 }
  738.  
  739.                 if(slayerLevel >= 29 && slayerLevel <= 59 && !inArea(1835,1855,3241,3256) && !inArea(1920,1935,3206,3218)) {
  740.                     actionName = "Walking to pyres";
  741.                 }
  742.                 if(slayerLevel >= 60 && !inArea(1874,1893,3203,3216) && !inArea(1887,1908,3248,3255)) {
  743.                     actionName = "Walking to jellies";
  744.                 }
  745.  
  746.                 if(actionName.equals("Walking to pyres")) {
  747.                     if(onTeam.equals("Blue")) {
  748.                         if(getMyPlayer().getLocation().getX() < 1816
  749.                                 && getMyPlayer().getLocation().getY() < 3235) {
  750.                             walkTo2(randomizeTile(new RSTile(1810,3245),2,2));
  751.                         }
  752.                     }
  753.                     if(onTeam.equals("Red")) {
  754.                         if(getMyPlayer().getLocation().getX() >= 1959) {
  755.                             walkTo2(randomizeTile(new RSTile(1955,3212),2,2));
  756.                         } else {
  757.                             walkTo2(randomizeTile(new RSTile(1927,3214),2,2));
  758.                         }
  759.                     }
  760.                 }
  761.                 if(actionName.equals("Walking to jellies")) {
  762.                     if(onTeam.equals("Blue")) {
  763.                         if(getMyPlayer().getLocation().getX() < 1816
  764.                                 && getMyPlayer().getLocation().getY() < 3235) {
  765.                             walkTo2(randomizeTile(new RSTile(1810,3245),2,2));
  766.                         } else {
  767.                             walkTo2(randomizeTile(new RSTile(1881,3206),2,2));
  768.                        }
  769.                     }
  770.                     if(onTeam.equals("Red")) {
  771.                         if(getMyPlayer().getLocation().getX() >= 1959) {
  772.                             walkTo2(randomizeTile(new RSTile(1955,3212),2,2));
  773.                         } else {
  774.                             walkTo2(randomizeTile(new RSTile(1897,3252),2,2));
  775.                         }
  776.                     }
  777.                 }
  778.                 if(inArea(1835,1855,3241,3256) || inArea(1920,1935,3206,3218)) {
  779.                     actionName = "Killing pyrefiens";
  780.                     if(getMyPlayer().getInteracting() == null && getMyPlayer().getInteracting() instanceof RSNPC) {
  781.                         RSNPC pyre = getNearestNPCByID(8598);
  782.                         if(pyre != null) {
  783.                             attackNPC(pyre);
  784.                         }
  785.                     }
  786.                 }
  787.                 if(inArea(1874,1893,3203,3216) || inArea(1887,1908,3248,3255)) {
  788.                     actionName = "Killing jellies";
  789.                     if(getMyPlayer().getInteracting() == null && getMyPlayer().getInteracting() instanceof RSNPC) {
  790.                         RSNPC jelly = getNearestNPCByID(8599);
  791.                         if(jelly != null) {
  792.                             attackNPC(jelly);
  793.                         }
  794.                     }
  795.                 }
  796.                 break;
  797.  
  798.  
  799.             case WAIT:
  800.                 wait(random(500,900));
  801.                 break;
  802.         }
  803.         return random(500, 900);
  804.     }
  805.  
  806.     public boolean onPoly(Polygon p, final String action) {
  807.         try{
  808.         getMenuItems();
  809.         if (p == null) {
  810.             return false;
  811.         }
  812.         if(p != null && !getMyPlayer().isMoving()) {
  813.             for(int i = 0; i < getMenuItems().size(); i++) {
  814.                 if(!getMenuItems().get(i).contains(action)) {
  815.                     moveMouse(p);
  816.                     wait(random(150,200));
  817.                 }
  818.                 final int idx = getMenuIndex(action);
  819.                         if (!isMenuOpen()) {
  820.                                 if (idx == -1) {
  821.                                         return false;
  822.                                 }
  823.                                 if (idx == 0) {
  824.                                         clickMouse(true);
  825.                                 } else {
  826.                                         clickMouse(false);
  827.                                         atMenuItem(idx);
  828.                                 }
  829.                                 return true;
  830.                         } else {
  831.                                 if (idx == -1) {
  832.                                         while (isMenuOpen()) {
  833.                                                 moveMouseRandomly(750);
  834.                                                 wait(random(750, 1200));
  835.                                         }
  836.                                     return false;
  837.                                 } else {
  838.                                         atMenuItem(idx);
  839.                                             return true;
  840.                                 }
  841.                         }
  842.             }
  843.         }
  844.        } catch(NullPointerException ignored) {}
  845.        return false;
  846.         }
  847.  
  848.     public boolean walkTo2(RSTile dest) {
  849.         if(isRandDest(3, dest)) {
  850.             return false;
  851.         }
  852.         if(!getMyPlayer().isMoving() || distanceTo(getDestination()) < random(5,10)
  853.                 && !isRandDest(3, dest)) {
  854.             if(getMyPlayer().getInteracting() == null) {
  855.                 return walkTo(dest);
  856.             }
  857.         }
  858.         return false;
  859.     }
  860.  
  861.     public boolean isRandDest(final int range, final RSTile dest) {
  862.                 final int minX = getMyPlayer().getLocation().getX() - range;
  863.                 final int minY = getMyPlayer().getLocation().getY() - range;
  864.                 final int maxX = getMyPlayer().getLocation().getX() + range;
  865.                 final int maxY = getMyPlayer().getLocation().getY() + range;
  866.                 for (int x = minX; x < maxX; x++) {
  867.                         for (int y = minY; y < maxY; y++) {
  868.                 if(getDestination() == dest) {
  869.                     log("Walking to random dest");
  870.                     return true;
  871.                 }
  872.                         }
  873.                 }
  874.                 return false;
  875.         }
  876.  
  877.     private int antiBan(int minC, int maxC) {
  878.  
  879.         final int randomAction = random(minC, maxC);
  880.         switch (randomAction) {
  881.             case 0:
  882.                 return random(1250,2500);
  883.             case 1:
  884.                 Point randomMouse;
  885.                 final int rndMovement = random(1, 5);
  886.                 for (int a = 0; a < rndMovement; a++) {
  887.                     randomMouse = new Point(random(15, 730), random(15, 465));
  888.                     moveMouse(randomMouse);
  889.                     wait(random(50, 800));
  890.                 }
  891.                 return random(130, 810);
  892.             case 2:
  893.                 final int currentAngle = getCameraAngle();
  894.                 switch (random(0, 1)) {
  895.                     case 0:
  896.                         setCameraRotation(currentAngle + random(0, 650));
  897.                         return random(710, 1700);
  898.                     case 1:
  899.                         setCameraRotation(currentAngle - random(0, 650));
  900.                         return random(710, 1700);
  901.                 }
  902.             case 3:
  903.                 final int currentAlt = Bot.getClient().getCamPosZ();
  904.                 final int random = random(0, 10);
  905.                 if (random <= 7) {
  906.                     setCameraAltitude(currentAlt - random(0, 100));
  907.                     return random(410, 2130);
  908.                 } else {
  909.                     setCameraAltitude(currentAlt + random(0, 100));
  910.                     return random(410, 2130);
  911.                 }
  912.             case 4:
  913.                 final int currentAngle2 = getCameraAngle();
  914.                 Bot.getClient().getCamPosZ();
  915.                 switch (random(0, 1)) {
  916.                     case 0:
  917.                         setCameraRotation(currentAngle2 + random(0, 650));
  918.                         setCameraAltitude(random(80, 100));
  919.                         return random(410, 2130);
  920.                     case 1:
  921.                         setCameraRotation(currentAngle2 - random(0, 650));
  922.                         setCameraAltitude(random(40, 80));
  923.                         return random(410, 2130);
  924.                 }
  925.             case 5:
  926.                 return random(310, 2400);
  927.  
  928.             case 6:
  929.                 final int currentAlt2 = Bot.getClient().getCamPosZ();
  930.                 final int random2 = random(0, 2);
  931.                 if (random2 <= 2) {
  932.                     setCameraAltitude(currentAlt2 - random(-100, +100));
  933.                     return random(410, 2130);
  934.                 } else {
  935.                     setCameraAltitude(currentAlt2 + random(-100, +100));
  936.                     return random(410, 2130);
  937.                 }
  938.         }
  939.         return random(100, 200);
  940.     }
  941.  
  942.     public boolean clickInventoryItem(int itemID, String option) {
  943.         if (getCurrentTab() != TAB_INVENTORY) {
  944.             openTab(TAB_INVENTORY);
  945.         }
  946.         int[] items = getInventoryArray();
  947.         java.util.List<Integer> possible = new ArrayList<Integer>();
  948.         for (int i = 0; i < items.length; i++) {
  949.             if (items[i] == itemID) {
  950.                 possible.add(i);
  951.             }
  952.         }
  953.         if (possible.size() == 0) {
  954.             return false;
  955.         }
  956.         int idx = possible.get(random(0, possible.size()));
  957.         Point t = getInventoryItemPoint(idx);
  958.         moveMouse(t, 5, 5);
  959.         long waitTime = System.currentTimeMillis() + random(50, 250);
  960.         boolean found = false;
  961.         while (!found && System.currentTimeMillis() < waitTime) {
  962.             wait(15);
  963.                 if ((getMenuItems()).get(0).toLowerCase().equals(
  964.                         option.toLowerCase())) {
  965.                     found = true;
  966.                 }
  967.             }
  968.         if (found) {
  969.             clickMouse(true);
  970.             wait(random(150, 250));
  971.             return true;
  972.         }
  973.         clickMouse(false);
  974.         wait(random(150, 250));
  975.         return atMenu(option);
  976.     }
  977.  
  978.     public boolean onSpot(int x, int y) {
  979.         int myX = getMyPlayer().getLocation().getX();
  980.         int myY = getMyPlayer().getLocation().getY();
  981.         return myX == x && myY == y;
  982.     }
  983.  
  984.     public boolean isInCameraAngleForGraveYard() {
  985.         int angle = getCameraAngle();
  986.         return angle < 380 && angle > 330 || angle < 200 && angle > 150;
  987.     }
  988.  
  989.     public boolean isInCameraAngleForBandages() {
  990.         int angle = getCameraAngle();
  991.         return angle < 240 && angle > 280 || angle < 60 && angle > 100;
  992.     }
  993.  
  994.     public int waitTime() {
  995.         if (RSInterface.getChildInterface(211, 1).isValid() &&
  996.                 RSInterface.getChildInterface(211, 1).containsText("You left a game of Soul Wars early")) {
  997.             String getLine = RSInterface.getChildInterface(211, 1).getText();
  998.             String subLine = getLine.substring(getLine.indexOf("wait ") + 5,
  999.                     getLine.indexOf(" minutes"));
  1000.             return Integer.parseInt(subLine);
  1001.         }
  1002.         return 0;
  1003.     }
  1004.  
  1005.     public void walkTile(RSTile walkTo) {
  1006.         if (!getMyPlayer().isMoving() && distanceTo(walkTo) > 5) {
  1007.                 walkTileMM(walkTo);
  1008.         }
  1009.     }
  1010.  
  1011.     public boolean useBandagesOnOtherPlayer() {
  1012.         RSPlayer player = null;
  1013.         int[] validPlayers = Bot.getClient().getRSPlayerIndexArray();
  1014.         org.rsbot.accessors.RSPlayer[] players = Bot.getClient().getRSPlayerArray();
  1015.  
  1016.         for (int element : validPlayers) {
  1017.             if (players[element] == null) {
  1018.                 continue;
  1019.             }
  1020.  
  1021.             setCameraAltitude(true);
  1022.             player = new RSPlayer(players[element]);
  1023.             try {
  1024.                 RSTile bandaging = player.getLocation();
  1025.                 Point checkPlayer = Calculations.tileToScreen(bandaging);
  1026.                 String targName = player.getName();
  1027.                 if (distanceTo(bandaging) > 10 || !pointOnScreen(checkPlayer) || player.getTeam() != getMyPlayer().getTeam()) {
  1028.                     continue;
  1029.                 }
  1030.                 if (actionName.equals("Choosing team") || !inventoryContains(14640)) {
  1031.                     break;
  1032.                 }
  1033.                 if (onTeam.equals("Blue")) {
  1034.                     RSObject bandageTableBlue = findObject(42023);
  1035.                     if (bandageTableBlue != null) {
  1036.                         if (distanceTo(bandageTableBlue.getLocation()) >= 8 && !getMyPlayer().isMoving()) {
  1037.                         walkTo(randomizeTile(new RSTile(1810, 3254),2 ,2));
  1038.                         }
  1039.                     } else {
  1040.                         walkTo(randomizeTile(new RSTile(1810, 3254),2 ,2));
  1041.                     }
  1042.                 } else {
  1043.                     RSObject bandageTableRed = findObject(42024);
  1044.                     if (bandageTableRed != null) {
  1045.                         if (distanceTo(bandageTableRed.getLocation()) >= 8 && !getMyPlayer().isMoving()) {
  1046.                             walkTo(randomizeTile(new RSTile(1963,3207),2 ,2));
  1047.                         }
  1048.                     } else {
  1049.                         walkTo(randomizeTile(new RSTile(1963,3207),2 ,2));
  1050.                     }
  1051.                 }
  1052.                 if (inventoryContains(14640) && getActivityBarPercent() <= random(40,80)
  1053.                         && player.getTeam() == getMyPlayer().getTeam()) {
  1054.                     if(!isItemSelected()) {
  1055.                         clickInventoryItem(14640, "use");
  1056.                     }
  1057.                     wait(random(700, 900));
  1058.                     actionName = "Bandaging People";
  1059.                     log("Using bandages on " + targName);
  1060.                     moveMouse(checkPlayer, 2, 2);
  1061.                     wait(random(500, 750));
  1062.                     clickMouse(false);
  1063.                     atMenu("use bandages -> ");
  1064.                 }
  1065.                 return true;
  1066.             } catch (Exception ignored) {
  1067.             }
  1068.         }
  1069.         return player != null;
  1070.     }
  1071.  
  1072.     public boolean atMenuBandages(final String optionContains) {
  1073.                 final int idx = getMenuIndex(optionContains);
  1074.                 if (!isMenuOpen()) {
  1075.                         if (idx == -1) {
  1076.                                 return false;
  1077.                         }
  1078.                         if (idx == 0) {
  1079.                                 clickMouse(true);
  1080.                         } else {
  1081.                                 clickMouse(false);
  1082.                                 atMenuItem(idx);
  1083.                         }
  1084.                         return true;
  1085.                 } else {
  1086.                         if (idx == -1) {
  1087.                                 while (isMenuOpen()) {
  1088.                                         moveMouseRandomly(750);
  1089.                                         wait(random(100, 500));
  1090.                                 }
  1091.                                 return false;
  1092.                         } else {
  1093.                                 atMenuThingBandages(idx);
  1094.                                 return true;
  1095.                         }
  1096.                 }
  1097.         }
  1098.  
  1099.     public boolean atMenuThingBandages(int i) {
  1100.                 if (!isMenuOpen()) {
  1101.                         return false;
  1102.                 }
  1103.                 try {
  1104.                         if (getMenuItems().size() < i) {
  1105.                                 return false;
  1106.                         }
  1107.                         final RSTile menu = getMenuLocation();
  1108.             final int randomIdx = random(1, getMenuItems().size());
  1109.                         final int xOff = random(4, getMenuItems().get(randomIdx).length() * 4);
  1110.                         final int yOff = 21 + 15 * i + random(3, 12);
  1111.                         moveMouse(menu.getX() + xOff, menu.getY() + yOff, 2, 2);
  1112.                         if (!isMenuOpen()) {
  1113.                                 return false;
  1114.                         }
  1115.                         clickMouse(true);
  1116.                         return true;
  1117.                 } catch (final Exception e) {
  1118.                         e.printStackTrace();
  1119.                         return false;
  1120.                 }
  1121.         }
  1122.  
  1123.     public int getActivityBarPercent() {
  1124.       RSInterfaceChild c = RSInterface.getInterface(836).getChild(56);
  1125.       if (c != null && c.isValid() && c.getAbsoluteX() > -1) {
  1126.             return ((c.getArea().height * 100) / 141) - 2;
  1127.         }
  1128.         return -1;
  1129.     }
  1130.  
  1131.     public boolean isItemSelected(){
  1132.       for(RSInterfaceComponent com : getInventoryInterface().getComponents()){
  1133.         if(com.getBorderThickness() == 2)
  1134.           return true;
  1135.       }
  1136.       return false;
  1137.     }
  1138.  
  1139.     public boolean getAttackAblePlayer() {
  1140.         RSPlayer player;
  1141.         int[] validPlayers = Bot.getClient().getRSPlayerIndexArray();
  1142.         org.rsbot.accessors.RSPlayer[] players = Bot.getClient().getRSPlayerArray();
  1143.  
  1144.         for (int element : validPlayers) {
  1145.             player = new RSPlayer(players[element]);
  1146.             if (players[element] == null) {
  1147.                 continue;
  1148.             }
  1149.             RSTile targetLocation = player.getLocation();
  1150.             Point targetLoc = Calculations.tileToScreen(targetLocation);
  1151.             String targName = player.getName();
  1152.             if (!pointOnScreen(targetLoc)) {
  1153.                 continue;
  1154.             }
  1155.             if (getMyPlayer().getInteracting() == null && player.getHPPercent() > 10) {
  1156.                 if(player.getTeam() != getMyPlayer().getTeam()) {
  1157.                     moveMouse(targetLoc, 5, 5);
  1158.                     cantAttack = 0;
  1159.                     atMenu("Attack " + targName);
  1160.                     log("Attacking " + targName);
  1161.                     wait(random(1500,2000));
  1162.                 } else {
  1163.                     cantAttack += 1;
  1164.                 }
  1165.             }
  1166.  
  1167.             if (!inGame || getMyPlayer().isMoving()) {
  1168.                 break;
  1169.             }
  1170.         }
  1171.         return true;
  1172.     }
  1173.  
  1174.     public boolean attackNPC(final RSNPC npc) {
  1175.         final RSTile tile = npc.getLocation();
  1176.         tile.randomizeTile(1, 1);
  1177.         try {
  1178.             final int hoverRand = random(8, 13);
  1179.             for (int i = 0; i < hoverRand; i++) {
  1180.                 if (distanceTo(tile) <= 1) {
  1181.                     return false;
  1182.                 }
  1183.                 final Point screenLoc = npc.getScreenLocation();
  1184.                 if (!pointOnScreen(screenLoc)) {
  1185.                     turnToTile(npc.getLocation());
  1186.                     return true;
  1187.                 }
  1188.  
  1189.                 moveMouse(screenLoc, 15, 15);
  1190.  
  1191.                 final java.util.List<String> menuItems = getMenuItems();
  1192.                 if (menuItems.isEmpty() || menuItems.size() <= 1) {
  1193.                     continue;
  1194.                 }
  1195.                 if (menuItems.get(0).toLowerCase().contains(
  1196.                         npc.getName().toLowerCase())
  1197.                         && getMyPlayer().getInteracting() == null) {
  1198.                     clickMouse(true);
  1199.                     return true;
  1200.                 } else {
  1201.                     for (int a = 1; a < menuItems.size(); a++) {
  1202.                         if (menuItems.get(a).toLowerCase().contains(
  1203.                                 npc.getName().toLowerCase())
  1204.                                 && getMyPlayer().getInteracting() == null) {
  1205.                             clickMouse(false);
  1206.                             return atMenu("Attack " + npc.getName());
  1207.                         }
  1208.                     }
  1209.                 }
  1210.             }
  1211.         } catch (final Exception E) {
  1212.             return false;
  1213.         }
  1214.         return false;
  1215.     }
  1216.  
  1217.     public void moveMouse(Polygon p){
  1218.         try {
  1219.             moveMouse(p.getBounds());
  1220.         } catch(Exception E) {
  1221.             log(E.getMessage());
  1222.         }
  1223.     }
  1224.  
  1225.     public void moveMouse(Rectangle r) {
  1226.         try {
  1227.             int x = r.x + random(0, r.width);
  1228.             int y = r.y + random(0, r.height);
  1229.             moveMouse(x, y);
  1230.         } catch(Exception E) {
  1231.             log(E.getMessage());
  1232.         }
  1233.     }
  1234.  
  1235.     public boolean inArea(int lowX, int hiX, int lowY, int hiY) {
  1236.         int x = getMyPlayer().getLocation().getX();
  1237.         int y = getMyPlayer().getLocation().getY();
  1238.     return x >= lowX && x <= hiX && y >= lowY && y <= hiY;
  1239.     }
  1240.  
  1241.         private boolean clickInventoryItem(final int[] ids, final String command) {
  1242.                 try {
  1243.                         if (getCurrentTab() != Constants.TAB_INVENTORY
  1244.                                         && !RSInterface.getInterface(Constants.INTERFACE_BANK)
  1245.                                                         .isValid()
  1246.                                         && !RSInterface.getInterface(Constants.INTERFACE_STORE)
  1247.                                                         .isValid()) {
  1248.                                 openTab(Constants.TAB_INVENTORY);
  1249.                         }
  1250.                         final int[] items = getInventoryArray();
  1251.                         final java.util.List<Integer> possible = new ArrayList<Integer>();
  1252.                         for (int i = 0; i < items.length; i++) {
  1253.                                 for (final int item : ids) {
  1254.                                         if (items[i] == item) {
  1255.                                                 possible.add(i);
  1256.                                         }
  1257.                                 }
  1258.                         }
  1259.                         if (possible.size() == 0) {
  1260.                                 return false;
  1261.                         }
  1262.                         final int idx = possible.get(random(0, possible.size()));
  1263.                         final Point t = getInventoryItemPoint(idx);
  1264.                         moveMouse(t, 5, 5);
  1265.                         wait(random(100, 290));
  1266.                         if (getMenuActions().get(0).equals(command)) {
  1267.                                 clickMouse(true);
  1268.                                 return true;
  1269.                         } else {
  1270.                                 return atMenu(command);
  1271.                         }
  1272.                 } catch (final Exception e) {
  1273.                         log("error clicking inventory");
  1274.                         return false;
  1275.                 }
  1276.         }
  1277.  
  1278.     public class clanChat extends Thread {
  1279.  
  1280.         @Override
  1281.                 public void run() {
  1282.             if(continueChat) {
  1283.                     String ccmessage = getLastClanChatMessage();
  1284.                 String[] chars = {"=", "-","_","*","@","#"};
  1285.                 for (String aChar : chars) {
  1286.                     ccmessage.replace(aChar, "");
  1287.                 }
  1288.                         if(!ccmessage.equals(lastCCMessage)) {
  1289.                     log(ccmessage);
  1290.                                 parseInComingData(ccmessage);
  1291.                                 lastCCMessage = ccmessage;
  1292.                         }
  1293.                 if(!inGame) {
  1294.                     if(random(0,30) == 20) {
  1295.                         antiBan(0,6);
  1296.                     }
  1297.                 }
  1298.             }
  1299.                 }
  1300.  
  1301.         private String getLastClanChatMessage() {
  1302.                 for(int i = 155; i >= 56; i --) {
  1303.                         final String text = RSInterface.getInterface(INTERFACE_CHAT_BOX).getChild(i).getText();
  1304.                         if (text.contains("<col=800000>")) {
  1305.                                 return text.substring(text.indexOf("<col=800000>") + 12);
  1306.                         }
  1307.                 }
  1308.                 return "";
  1309.         }
  1310.  
  1311.         public void parseInComingData(String text) {
  1312.             String lower = text.toLowerCase();
  1313.             if (lower.contains("blue") || lower.contains("b l u e")) {
  1314.                 callBlue += 1;
  1315.             } else if (lower.contains("red") || lower.contains("r e d")) {
  1316.                 callRed += 1;
  1317.             }
  1318.         }
  1319.         }
  1320. }
Submit a correction or amendment below. [ previous version ] | [ difference ] | Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: