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

bdk

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 64.88 KB  |  hits: 29  |  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.Graphics;
  3. import java.awt.Image;
  4. import java.awt.Point;
  5. import java.io.IOException;
  6. import java.net.MalformedURLException;
  7. import java.net.URL;
  8. import org.powerbot.event.events.ServerMessageEvent;
  9. import org.powerbot.event.listeners.PaintListener;
  10. import org.powerbot.event.listeners.ServerMessageListener;
  11. import org.powerbot.script.Script;
  12. import org.powerbot.script.ScriptManifest;
  13. import org.powerbot.script.methods.Skills;
  14. import org.powerbot.script.util.Filter;
  15. import org.powerbot.script.util.Timer;
  16. import org.powerbot.script.util.WindowUtil;
  17. import org.powerbot.script.wrappers.RSCharacter;
  18. import org.powerbot.script.wrappers.RSGroundItem;
  19. import org.powerbot.script.wrappers.RSNPC;
  20. import org.powerbot.script.wrappers.RSObject;
  21. import org.powerbot.script.wrappers.RSTile;
  22. import java.awt.*;
  23. import org.rsbot.script.*;
  24. import org.rsbot.script.methods.*;
  25. import org.rsbot.script.wrappers.*;
  26.  
  27. public class Liamsresponder extends Random {
  28.  
  29.     public int dyingAnimation = 836;
  30.     String reply = "NO REPLY";
  31.     String textSent;
  32.     String[] oldQ = {""};
  33.     long nextTalk = System.currentTimeMillis() + random(160000, 170000 * random(2, 4));
  34.     long lastCheck = -1; //lets make it do a check at the start
  35.     String[] attackNames = {"Attack", "attack", "ATT", "Att", "att", "atk"};
  36.     String[] defenseNames = {"Defence", "defence", "Defense", "defense", "Def", "def"};
  37.     String[] strengthNames = {"Strength", "strength", "STR", "Str", "str"};
  38.     String[] hitpointsNames = {"Hitpoints", "hitpoints", "Hp", "hp"};
  39.     String[] rangeNames = {"Range", "range", "Ranged", "ranged"};
  40.     String[] prayerNames = {"Prayer", "prayer", "Pray", "prayr"};
  41.     String[] magicNames = {"Magic", "magic", "Mage", "mage"};
  42.     String[] cookingNames = {"Cooking", "cooking", "Cook", "cook", "Cookn", "cookn"};
  43.     String[] woodcuttingNames = {"Woodcutting", "woodcutting", "Wc", "wc", "Woodcuttn", "woodcuttn"};
  44.     String[] fletchingNames = {"Fletching", "fletching", "Fletch", "fletch", "Flechn", "flechn"};
  45.     String[] fishingNames = {"Fishing", "fishing", "Fish", "fish"};
  46.     String[] firemakingNames = {"Firemaking", "firemaking", "Firemake", "firemake", "Fm", "fm"};
  47.     String[] craftingNames = {"Crafting", "crafting", "Craft", "craft"};
  48.     String[] smithingNames = {"Smithing", "smithing", "Smith", "smith"};
  49.     String[] miningNames = {"Mining", "mining", "Mine", "mine"};
  50.     String[] herbloreNames = {"Herblore", "herblore", "Herb", "herb"};
  51.     String[] agilityNames = {"Agility", "agility", "Agil", "agil"};
  52.     String[] thievingNames = {"Thieving", "thieving", "Theif", "thief"};
  53.     String[] slayerNames = {"Slayer", "slayer", "Slay", "slay"};
  54.     String[] runecraftingNames = {"Runecrafting", "runecrafting", "Runecraft", "runecraft", "RC", "Rc", "rc"};
  55.     String[] farmingNames = {"Farming", "farming", "Farm", "farm"};
  56.     String[] hunterNames = {"Hunting", "hunting", "Hunter", "hunter"};
  57.     String[] constructionNames = {"Construction", "construction", "constructing", "constructing"};
  58.     String[] summoningNames = {"Summoning", "summoning", "Summon", "summon", "Summonin", "summonin"};
  59.     public int dist;
  60.  
  61.     public String statName(int stat) {
  62.         if (stat == Skills.ATTACK) {
  63.             return pickRandomName(attackNames);
  64.         }
  65.         if (stat == Skills.DEFENSE) {
  66.             return pickRandomName(defenseNames);
  67.         }
  68.         if (stat == Skills.STRENGTH) {
  69.             return pickRandomName(strengthNames);
  70.         }
  71.         if (stat == Skills.CONSTITUTION) {
  72.             return pickRandomName(hitpointsNames);
  73.         }
  74.         if (stat == Skills.RANGE) {
  75.             return pickRandomName(rangeNames);
  76.         }
  77.         if (stat == Skills.PRAYER) {
  78.             return pickRandomName(prayerNames);
  79.         }
  80.         if (stat == Skills.MAGIC) {
  81.             return pickRandomName(magicNames);
  82.         }
  83.         if (stat == Skills.COOKING) {
  84.             return pickRandomName(cookingNames);
  85.         }
  86.         if (stat == Skills.WOODCUTTING) {
  87.             return pickRandomName(woodcuttingNames);
  88.         }
  89.         if (stat == Skills.FLETCHING) {
  90.             return pickRandomName(fletchingNames);
  91.         }
  92.         if (stat == Skills.FISHING) {
  93.             return pickRandomName(fishingNames);
  94.         }
  95.         if (stat == Skills.FIREMAKING) {
  96.             return pickRandomName(firemakingNames);
  97.         }
  98.         if (stat == Skills.CRAFTING) {
  99.             return pickRandomName(craftingNames);
  100.         }
  101.         if (stat == Skills.SMITHING) {
  102.             return pickRandomName(smithingNames);
  103.         }
  104.         if (stat == Skills.MINING) {
  105.             return pickRandomName(miningNames);
  106.         }
  107.         if (stat == Skills.HERBLORE) {
  108.             return pickRandomName(herbloreNames);
  109.         }
  110.         if (stat == Skills.AGILITY) {
  111.             return pickRandomName(agilityNames);
  112.         }
  113.         if (stat == Skills.THIEVING) {
  114.             return pickRandomName(thievingNames);
  115.         }
  116.         if (stat == Skills.SLAYER) {
  117.             return pickRandomName(slayerNames);
  118.         }
  119.         if (stat == Skills.RUNECRAFTING) {
  120.             return pickRandomName(runecraftingNames);
  121.         }
  122.         if (stat == Skills.FARMING) {
  123.             return pickRandomName(farmingNames);
  124.         }
  125.         if (stat == Skills.HUNTER) {
  126.             return pickRandomName(hunterNames);
  127.         }
  128.         if (stat == Skills.CONSTRUCTION) {
  129.             return pickRandomName(constructionNames);
  130.         }
  131.         if (stat == Skills.SUMMONING) {
  132.             return pickRandomName(summoningNames);
  133.         }
  134.         return null;
  135.     }
  136.  
  137.     public void talk() {
  138.         long currentTime = System.currentTimeMillis();
  139.         long minutes = (currentTime - lastCheck) / (60000);
  140.         if (lastCheck == -1) {
  141.             for (int i = 0; i < training.length; i++) {
  142.                 oldXP[i] = skills.getCurrentExp(i);
  143.             }
  144.         }
  145.         if (minutes >= 1) {
  146.             lastCheck = System.currentTimeMillis();
  147.             for (int i = 0; i < training.length; i++) {
  148.                 if (oldXP[i] != skills.getCurrentExp(i)) {
  149.                     if (training[i] <= 5) {
  150.                         training[i]++;
  151.                     }
  152.                 } else {
  153.                     training[i] = 0;
  154.                 }
  155.             }
  156.             for (int i = 0; i < training.length; i++) {
  157.                 oldXP[i] = skills.getCurrentExp(i);
  158.             }
  159.         }
  160.         int biggest = -1;
  161.         int biggestNum = -1;
  162.         for (int i = 0; i < training.length; i++) {
  163.             if (training[i] > biggest && training[i] > 0) {
  164.                 biggest = training[i];
  165.                 biggestNum = i;
  166.             }
  167.         }
  168.         if (biggest > 0) {
  169.             talk2(biggestNum);
  170.         }
  171.     }
  172.  
  173.     public String xpToString(int level) {
  174.         String[] extraArray = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  175.             "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  176.             "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  177.             "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  178.             ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  179.             ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  180.             ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  181.             ". :\\", ".:\\", " :\\", ":\\", ". :O", ".:O", " :O", "O.O",
  182.             ". :)", ".;]]", " :)", ":)", ". :[]", ".:]", " :]", ":]",
  183.             ". :P", ".:P", " :P", ":D", ". :D", ".:O", " :O", ":L",};
  184.         int percent = skills.getPercentToNextLevel(level);
  185.         int xpTo = skills.getExpToNextLevel(level);
  186.         int skillLevel = skills.getCurrentLevel(level);
  187.         String only = "";
  188.         String temp = "";
  189.         String[] toArray = {"to", "to", "to", "2", "till", "till", "until", "until"};
  190.         String to = toArray[random(0, toArray.length)];
  191.         String[] onlyArray = {"only", "just"};
  192.         if (percent < 20 && random(1, 5) == 3) {
  193.             only = onlyArray[random(0, 1)] + " ";
  194.         }
  195.         String k = "k";
  196.         String m = "m";
  197.         if (random(0, 2) == 0) {
  198.             k = "K";
  199.             m = "M";
  200.         }
  201.         if (xpTo > 1000000) {
  202.             temp = xpTo / 1000000 + m;
  203.         } else if (xpTo > 1000) {
  204.             temp = xpTo / 1000 + k;
  205.         } else {
  206.             temp = "" + xpTo;
  207.         }
  208.         String[] moreArray = {"to go", "more", "left", "To Go", "More", "Left"};
  209.         String more = moreArray[random(0, moreArray.length)];
  210.         String[] xpArray = {"xp", "XP", "Xp", "EXP", "Exp", "exp", "Experience", "experience"};
  211.         String xp = xpArray[random(0, xpArray.length)];
  212.         String[] levelArray = {"Lvl", "LVL", "lvl",
  213.             "Lev", "lev", "LV", "lv", "Lv", "Level", "level"};
  214.         String lvl = levelArray[random(0, levelArray.length)];
  215.         String[] talkArray = {only + temp + xp + " " + more + " " + to + " " + lvl + " " + (skillLevel + 1), only + temp + " " + statName(level) + " " + xp + " " + more + " " + to + " " + lvl + " " + (skillLevel + 1),
  216.             "i " + only + "need " + temp + " " + xp + " " + more + " " + to + " " + lvl + " " + skillLevel, "i " + only + "need " + temp + " " + statName(level) + " " + xp + " " + more + " " + to + " " + lvl + " " + (skillLevel + 1)};
  217.         return talkArray[random(0, talkArray.length)] + extraArray[random(0, extraArray.length)];
  218.     }
  219.  
  220.     public void hoverInterface(int iface, int child) {
  221.         hoverInterface(interfaces.getComponent(iface, child));
  222.     }
  223.  
  224.     public void hoverInterface(RSComponent i) {
  225.         if (!i.isValid()) {
  226.             return;
  227.         }
  228.         Rectangle pos = i.getArea();
  229.         mouse.move((int) random(pos.getMinX(), pos.getMaxX()), (int) random(pos.getMinY(), pos.getMaxY()));
  230.     }
  231.  
  232.     public void talk2(int skill) {
  233.         if (nextTalk > System.currentTimeMillis()) {
  234.             return;
  235.         }
  236.         nextTalk = System.currentTimeMillis() + random(140000, 160000 * random(2, 4));
  237.         getNearestPlayerDistance();
  238.         if (dist >= 5) //nobodys close enough to talk to.
  239.         {
  240.             return;
  241.         }
  242.         String[] extraArray = {"", "", "", "?", "?", "?", "."};
  243.         String extra = extraArray[random(0, extraArray.length)];
  244.         int gamble = random(1, 3);
  245.         String stat = statName(skill);
  246.         int level = skills.getCurrentLevel(skill);
  247.         String only = "";
  248.         String[] onlyArray = {"only", "just"};
  249.         if (level < 30 && random(1, 5) == 3) {
  250.             only = onlyArray[random(0, 1)] + " ";
  251.         }
  252.         String[] extraArray2 = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  253.             "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  254.             "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  255.             "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  256.             ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  257.             ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  258.             ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  259.             ". =\\", ".x[)", " =\\", " lol", ". =O", ".=O", " =O", "=O",
  260.             ". =)", ".=)", " =)", "=)", ". =]", ".=]", " =]", "=]",
  261.             ". =P", ".=P", " =P", "=P", ". =D", ".=D", " =D", "=D",};
  262.         String extra2 = extraArray2[random(0, extraArray2.length)];
  263.         String[] levelArray = {"", "", "", "", "", "Lvl ", "LVL ", "lvl ",
  264.             "Lev ", "lev ", "LV ", "lv ", "Lv ", "Level ", "level "};
  265.         String lvl = levelArray[random(0, levelArray.length)];
  266.         String[] misc1 = {"what's your", "wuts ur", "whats your", "what's your", "whuts yur"};
  267.         String[] echoMineArray = {"mine is " + only + lvl + level, "mine is " + only + lvl + level, "mine is " + only + lvl + level, only + lvl + level + " here",
  268.             only + lvl + level + " over here"};
  269.         String echoMine = echoMineArray[random(0, echoMineArray.length)];
  270.         if (gamble == 1) {
  271.             textSent = misc1[random(0, misc1.length)] + " " + stat + " level" + extra;
  272.             keyboard.sendText(textSent, true);
  273.             sleep(random(100, 300));
  274.             if (random(0, 21) != 20) //one in 20 chance it wont say your level back.
  275.             {
  276.                 sleep(random(6000, 7000));
  277.             }
  278.             keyboard.sendText(echoMine + extra2, true);
  279.         } else if (gamble == 2) {
  280.             int oldTab = game.getCurrentTab();
  281.             game.openTab(Game.TAB_STATS);
  282.             sleep(random(100, 200));
  283.             hoverInterface(320, 125 + random(0, 5));
  284.             sleep(random(500, 2000));
  285.             String text = xpToString(skill);
  286.             System.out.println("\n\n\n" + text + "\n\n\n");
  287.             keyboard.sendText(text, true);
  288.             game.openTab(oldTab);
  289.         }
  290.     }
  291.  
  292.     public String getName() {  //Name of the Script
  293.         return "KaiChatResponder";   //between "" what will show up in RSBot script selector
  294.     }
  295.  
  296.     public double getVersion() {   //Version of the Script
  297.         return 1.0;       //what will show up in RSBot script selector
  298.     }
  299.  
  300.     public String getAuthor() { //Author of the Script
  301.         return "Kai Bliss";   //what will show up in RSBot script selector
  302.     }
  303.  
  304.     public boolean onStart(String[] args) {  //First thing run, when a Script is started (holds an array called "args" which contain the arguments put in by user in Script Selector
  305.         return true;   //return true = Start Script; return false = Don't Start Script
  306.     }
  307.  
  308.     public String getChildText(int iface, int child) {
  309.         return interfaces.get(iface).getComponent(child).getText();
  310.     }
  311.  
  312.     public String[] getChatMessages(boolean stripName) {
  313.         String[] temp = new String[100];
  314.         int tempi = 0;
  315.         for (int i = 155; i >= 56; i--) {
  316.             if (getChildText(137, i).contains("<col=0000ff>")) {
  317.                 if (stripName) {
  318.                     temp[tempi] = getChildText(137, i).substring(getChildText(137, i).indexOf("<col=0000ff>") + 12);
  319.                     tempi++;
  320.                 } else {
  321.                     temp[tempi] = getChildText(137, i).replaceAll("<col=0000ff>", "");
  322.                     tempi++;
  323.                 }
  324.             }
  325.         }
  326.         return temp;
  327.     }
  328.     String oldChat = "";
  329.     String[] chat = new String[100];
  330.     String[] chat2 = new String[100];
  331.     int[] training = new int[Skills.SUMMONING];
  332.     int[] oldXP = new int[Skills.SUMMONING];
  333.  
  334.     public boolean activateCondition() {  //Main function of the Script
  335.         reply();
  336.         talk();
  337.         return false;
  338.     }
  339.  
  340.     public void reply() {
  341.         chat = getChatMessages(true);
  342.         chat2 = getChatMessages(false);
  343.         if (chat[0] == null || oldChat.equalsIgnoreCase(chat2[0])) {
  344.             return;
  345.         }
  346.         if (oldQ[0].equalsIgnoreCase(chat2[0])) {
  347.             return;
  348.         }
  349.         String temp = chat2[0];
  350.         String name = temp.substring(0, temp.indexOf(":"));
  351.         if (name.equalsIgnoreCase(getMyPlayer().getName())) {
  352.             return;
  353.         }
  354.         if (replyToPlayer(chat[0])) {
  355.             log("KaiChatResponder is replying to: ");
  356.             log(chat2[0]);
  357.             log("Successfully talked with:");
  358.             log(reply);
  359.             oldQ[0] = chat2[0];
  360.         }
  361.     }
  362.  
  363.     public int loop() {
  364.         return -1; //wtf? this shouldn't be called.
  365.     }
  366.  
  367.     public String pickRandomName(String[] possible) { //it needs to USUALLY pick the first two.
  368.         if (random(0, 5) == 3) {
  369.             return possible[random(0, possible.length)];
  370.         } else {
  371.             return possible[random(0, 1)];
  372.         }
  373.     }
  374.  
  375.     public boolean replyToPlayer(String text) {
  376.         text = text.toLowerCase();
  377.         reply = "NO REPLY";
  378.         Boolean doPrefix = true;
  379.         int oldTab = -1;
  380.  
  381.         if (getMyPlayer().getAnimation() == dyingAnimation) {
  382.             String[] deathArray = {"aww thats nooby", "well that sucks dunt it", "oh man", "dang it", "..."};
  383.             String death = deathArray[random(0, deathArray.length)];
  384.             keyboard.sendText(death, true);
  385.             reply = death;
  386.             return true;
  387.         }
  388.  
  389.         if (text.contains("hey") || text.contains("hi") || text.contains("hello") || text.contains("hai der") || text.contains("yo") || text.contains("sappnin") || text.contains("hai")) {
  390.             String[] AccountArray = {"Hello", "Hey!", "shut up please i cba talking", "uhh hey", "Hai der", "Sup kid", "Can't be botherd talking no offence", "What you want? I'm not in a good mood.."};
  391.             String Account = AccountArray[random(0, AccountArray.length)];
  392.             keyboard.sendText(Account, true);
  393.             reply = Account;
  394.             return true;
  395.         }
  396.         if (text.contains("botting?") || text.contains("ur a bot") || text.contains("bot?") || text.contains("macro?") || text.contains("bot..")) {
  397.             String[] bottingArray = {"Don't Think So Kid.", "Nope Just don't Like talking Much", "Wouldn't Risk My account Kiddo", ":L Botting Fails", "Nope i'm all Legit mate", "Nooo Don't be mad", "I've never Botted never Will", "So now that i don't talk i get accused of botting?"};
  398.             String botting = bottingArray[random(0, bottingArray.length)];
  399.             keyboard.sendText(botting, true);
  400.             reply = botting;
  401.             return true;
  402.         }
  403.         if (text.contains("im bored") || text.contains("i'm bored") || text.contains("i am bored") || text.contains("i ma bored")) {
  404.             String[] boredArray = {"Same hard work this.", "I am a lil", "*sleeps* me too", "so am i", "i am also", "I could sleep on my Keyboard ATM", "LOLATYOU", "i'm not", "Neeh im not", "Rs is too call to be board, im just tired"};
  405.             String bored = boredArray[random(0, boredArray.length)];
  406.             keyboard.sendText(bored, true);
  407.             reply = bored;
  408.             return true;
  409.         }
  410.  
  411.         if (text.contains("leveld") || text.contains("yes finally level up") || text.contains("w00t level up") || text.contains("yipee") || text.contains("yay! level up")) {
  412.             String[] wootArray = {"Gratz", "Nice", "congratulations", "Congratz mate"};
  413.             String woot = wootArray[random(0, wootArray.length)];
  414.             keyboard.sendText(woot, true);
  415.             reply = woot;
  416.             return true;
  417.         }
  418.  
  419.  
  420.         if (text.contains("k till") || text.contains("k untill")) {
  421.             String[] ktillArray = {"oooo", "Lol nice, good luck bro", "good luck mate", "nice", "that's nice", "sweet", "wow", "gratz"};
  422.             String ktill = ktillArray[random(0, ktillArray.length)];
  423.             keyboard.sendText(ktill, true);
  424.             reply = ktill;
  425.             return true;
  426.         }
  427.  
  428.         if (text.contains("m till") || text.contains("m untill")) {
  429.             String[] mtillArray = {"OMG GL", "LOL", "dang man!", "dang", "holy cow", "w0w", "good luck!", "going to take you forever"};
  430.             String mtill = mtillArray[random(0, mtillArray.length)];
  431.             keyboard.sendText(mtill, true);
  432.             reply = mtill;
  433.             return true;
  434.         }
  435.  
  436.         if (text.contains("why are you doing that") || text.contains("why are you doin that") || text.contains("y r u doing that")) {
  437.             String[] looperrorArray = {"Who said i cant?", "because i want to got a problem?", "LOLATYOU", "why aren't you?!", "Because i'm cool"};
  438.             String looperror = looperrorArray[random(0, looperrorArray.length)];
  439.             keyboard.sendText(looperror, true);
  440.             reply = looperror;
  441.             return true;
  442.         }
  443.  
  444.         if (text.contains("goodbye") || text.contains("bye") || text.contains("cya") || text.contains("later") || text.contains("seeya")) {
  445.             String[] cyaArray = {"later man nice speaking to you", "bye bro", "bai!", "cya", "ok bye then"};
  446.             String cya = cyaArray[random(0, cyaArray.length)];
  447.             keyboard.sendText(cya, true);
  448.             reply = cya;
  449.             return true;
  450.         }
  451.  
  452.         if (text.endsWith("how are you") || text.contains("You ok") || text.contains("You ok?") || text.contains("you ok mate?") || text.contains("you alright") || text.startsWith("you alright?") && text.indexOf("fish") == -1 && text.indexOf("smithing") == -1 && text.indexOf("hitp") == -1 && text.indexOf("which") == -1 && text.indexOf("the") == -1 && text.indexOf("not") == -1 && text.indexOf("high") == -1 && text.indexOf("this") == -1) {
  453.             String[] greetingArray = {"i'm great", "yea man", "obv couldnt be better", "ye", "mhmm", "great", "Nahh :( Don't wana talk about it."};
  454.             String greeting = greetingArray[random(0, greetingArray.length)];
  455.             keyboard.sendText(greeting, true);
  456.             reply = greeting;
  457.             return true;
  458.         }
  459.  
  460.         if ((text.contains("level") || text.contains("lv")) && (text.indexOf(" ") == text.lastIndexOf(" ") || text.startsWith("what") || text.endsWith("?") || text.endsWith("lv") || text.endsWith("lvl") || text.endsWith("lev") || text.endsWith("level"))) { //asking for a level
  461.             int whichSkill = -1;
  462.             String statName;
  463.             if (text.contains("att")) {
  464.                 whichSkill = Skills.ATTACK;
  465.                 statName = pickRandomName(attackNames);
  466.             } else if (text.contains("def")) {
  467.                 whichSkill = Skills.DEFENSE;
  468.                 statName = pickRandomName(defenseNames);
  469.             } else if (text.contains("str")) {
  470.                 whichSkill = Skills.STRENGTH;
  471.                 statName = pickRandomName(strengthNames);
  472.             } else if (text.contains("hp") || text.contains("hit")) {
  473.                 whichSkill = Skills.CONSTITUTION;
  474.                 statName = pickRandomName(hitpointsNames);
  475.             } else if (text.contains("range")) {
  476.                 whichSkill = Skills.RANGE;
  477.                 statName = pickRandomName(rangeNames);
  478.             } else if (text.contains("pray")) {
  479.                 whichSkill = Skills.PRAYER;
  480.                 statName = pickRandomName(prayerNames);
  481.             } else if (text.contains("mag")) {
  482.                 whichSkill = Skills.MAGIC;
  483.                 statName = pickRandomName(magicNames);
  484.             } else if (text.contains("cook")) {
  485.                 whichSkill = Skills.COOKING;
  486.                 statName = pickRandomName(cookingNames);
  487.             } else if (text.contains("wc") || text.contains("woodcut")) {
  488.                 whichSkill = Skills.WOODCUTTING;
  489.                 statName = pickRandomName(woodcuttingNames);
  490.             } else if (text.contains("fletch")) {
  491.                 whichSkill = Skills.FLETCHING;
  492.                 statName = pickRandomName(fletchingNames);
  493.             } else if (text.contains("fish")) {
  494.                 whichSkill = Skills.FISHING;
  495.                 statName = pickRandomName(fishingNames);
  496.             } else if (text.contains("fm") || text.contains("fire")) {
  497.                 whichSkill = Skills.FIREMAKING;
  498.                 statName = pickRandomName(firemakingNames);
  499.             } else if (text.contains("craft")) {
  500.                 whichSkill = Skills.CRAFTING;
  501.                 statName = pickRandomName(craftingNames);
  502.             } else if (text.contains("smith")) {
  503.                 whichSkill = Skills.SMITHING;
  504.                 statName = pickRandomName(smithingNames);
  505.             } else if (text.contains("mining") || text.contains("mine")) {
  506.                 whichSkill = Skills.MINING;
  507.                 statName = pickRandomName(miningNames);
  508.             } else if (text.contains("herb")) {
  509.                 whichSkill = Skills.HERBLORE;
  510.                 statName = pickRandomName(herbloreNames);
  511.             } else if (text.contains("agil")) {
  512.                 whichSkill = Skills.AGILITY;
  513.                 statName = pickRandomName(agilityNames);
  514.             } else if (text.contains("thiev") || text.contains("theiv")) {
  515.                 whichSkill = Skills.THIEVING;
  516.                 statName = pickRandomName(thievingNames);
  517.             } else if (text.contains("slay")) {
  518.                 whichSkill = Skills.SLAYER;
  519.                 statName = pickRandomName(slayerNames);
  520.             } else if (text.contains("farm")) {
  521.                 whichSkill = Skills.FARMING;
  522.                 statName = pickRandomName(farmingNames);
  523.             } else if (text.contains("runecraft") || text.contains("rc")) {
  524.                 whichSkill = Skills.RUNECRAFTING;
  525.                 statName = pickRandomName(runecraftingNames);
  526.             } else if (text.contains("hunt")) {
  527.                 whichSkill = Skills.HUNTER;
  528.                 statName = pickRandomName(hunterNames);
  529.             } else if (text.contains("construct")) {
  530.                 whichSkill = Skills.CONSTRUCTION;
  531.                 statName = pickRandomName(constructionNames);
  532.             } else if (text.contains("summon")) {
  533.                 whichSkill = Skills.SUMMONING;
  534.                 statName = pickRandomName(summoningNames);
  535.             } else {
  536.                 statName = "NO STAT!";
  537.             }
  538.  
  539.  
  540.             if (whichSkill != -1) {
  541.                 oldTab = game.getCurrentTab();
  542.                 game.openTab(Game.TAB_STATS);
  543.                 int gambleInt = random(1, 4);
  544.                 String[] extraArray = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  545.                     "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  546.                     "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  547.                     "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
  548.                     ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  549.                     ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  550.                     ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".",
  551.                     ". =\\", ".=\\", " =\\", "=\\", ". =O", ".=O", " =O", "=O",
  552.                     ". =)", ".=)", " =)", "=)", ". =]", ".=]", " =]", "=]",
  553.                     ". =P", ".=P", " =P", "=P", ". =D", ".=D", " =D", "=D",};
  554.                 String extra = extraArray[random(0, extraArray.length)];
  555.                 if (extra.contains("=") && random(1, 3) == 1) {
  556.                     extra = extra.replaceAll("=", ":"); //transforms some happyfaces :D =D
  557.                 }
  558.                 String[] onlyArray = {"only", "just"};
  559.                 String[] levelArray = {"Lvl", "LVL", "lvl", "Lev", "lev", "LV", "lv", "Lv", "Level", "level"};
  560.                 String[] haveArray = {"have", "have", "have", "have", "got", "Have", "Got"};
  561.                 String misc = "";
  562.                 String only = "";
  563.                 String have = haveArray[random(0, haveArray.length)];
  564.                 if (random(0, 2) == 1 && statName.endsWith("ing")) {
  565.                     statName = statName.substring(0, statName.length() - 1); //will sometimes remove g at end (e.g mining to minin)
  566.                 }
  567.                 int skillLevel = skills.getCurrentLevel(whichSkill);
  568.                 if (skillLevel < 30 && random(1, 5) == 3) {
  569.                     only = onlyArray[random(0, 1)] + " ";
  570.                 }
  571.                 misc += levelArray[random(0, levelArray.length)];
  572.                 if (misc.length() > 0) {
  573.                     misc = " " + misc;
  574.                 }
  575.                 if (gambleInt == 1) {
  576.                     reply = "" + skillLevel + extra;
  577.                 } else if (gambleInt == 2) {
  578.                     reply = "My " + statName + misc + " is " + only + skillLevel + extra;
  579.                 } else if (gambleInt == 3) {
  580.                     reply = "I " + only + "have " + skillLevel + " " + statName + extra;
  581.                 }
  582.             }
  583.         }
  584.         if (reply.equals("NO REPLY")) {
  585.             return false;
  586.         } else {
  587.             String prefix = "";
  588.             sleep(random(2000, 3000));
  589.             if (random(1, 6) == 2) {
  590.                 reply = reply.toLowerCase();
  591.             }
  592.             keyboard.sendText(reply, true);
  593.             if (oldTab != -1) {
  594.                 sleep(random(10, 100));
  595.                 game.openTab(oldTab);
  596.             }
  597.             return true;
  598.         }
  599.     }
  600.  
  601.     public String getScriptCategory() {
  602.         return "Antiban";
  603.     }
  604.  
  605.     public void getNearestPlayerDistance() {
  606.         RSPlayer[] p = players.getAll();
  607.         for (int i = 0; i < p.length - 1; i++) {
  608.             try {
  609.                 RSPlayer cP = p[i];
  610.                 String nameP = cP.getName();
  611.                 String nameMe = getMyPlayer().getName();
  612.                 if (cP != null
  613.                         && (nameP != null && nameMe != null && !nameP.equals(nameMe)) && cP.isOnScreen()) {
  614.                     dist = calc.distanceTo(cP.getLocation());
  615.                 } else if (cP == null) {
  616.                     dist = 999;
  617.                 }
  618.             } catch (NullPointerException e) {
  619.             }
  620.         }
  621.  
  622.     }
  623. }
  624.  
  625. import java.awt.BasicStroke;
  626. import java.awt.Color;
  627. import java.awt.Font;
  628. import java.awt.Graphics;
  629. import java.awt.Graphics2D;
  630. import java.awt.Image;
  631. import java.awt.Point;
  632. import java.awt.Rectangle;
  633. import java.awt.RenderingHints;
  634. import java.awt.event.MouseEvent;
  635. import java.awt.event.MouseListener;
  636. import java.io.IOException;
  637. import java.net.URL;
  638. import java.text.NumberFormat;
  639. import java.util.ArrayList;
  640.  
  641. import com.rarebot.event.listeners.PaintListener;
  642. import com.rarebot.script.Script;
  643. import com.rarebot.script.ScriptManifest;
  644. import com.rarebot.script.methods.Game.Tab;
  645. import com.rarebot.script.methods.Skills;
  646. import com.rarebot.script.util.Filter;
  647. import com.rarebot.script.util.Timer;
  648. import com.rarebot.script.wrappers.RSArea;
  649. import com.rarebot.script.wrappers.RSComponent;
  650. import com.rarebot.script.wrappers.RSGroundItem;
  651. import com.rarebot.script.wrappers.RSItem;
  652. import com.rarebot.script.wrappers.RSNPC;
  653. import com.rarebot.script.wrappers.RSObject;
  654. import com.rarebot.script.wrappers.RSTile;
  655. import com.rarebot.script.wrappers.RSTilePath;
  656. import com.rarebot.script.wrappers.RSWeb;
  657.  
  658. @ScriptManifest(authors ={ "chuma" }, name = "chumasblueDragons", version = 1.0, description = "1.0")
  659. public class chumasblueDragons extends Script implements PaintListener {
  660. {
  661.     private Conditional conditional;}
  662.     private ArrayList<State> states = new ArrayList<State>();
  663.     private ScriptSettings scriptSettings;
  664.     private int tab;
  665.  
  666.     public boolean onStart() {
  667.         conditional = new Conditional();
  668.         scriptSettings = new ScriptSettings();
  669.         scriptSettings.antifirePotions = equipment.containsOneOf(new int[]{11284, 1540});
  670.         if (scriptSettings.antifirePotions) {
  671.             log.severe("Script currently doesn't support antifire potions.");
  672.             log.severe("Please equip a Dragonfire sheild and restart");
  673.             log("Don't worry it will be included soon");
  674.             return false;
  675.         }
  676.         if (isModernSetActive()) {
  677.             if (Modern.PROTECT_FROM_MAGIC.getRequiredLevel() < skills.getCurrentLevel(Skills.PRAYER)) {
  678.                 log("Unable to use prayers?");
  679.                 stopScript(false);
  680.             }
  681.         } else {
  682.             if (Ancient.DEFLECT_MAGIC.getRequiredLevel() < skills.getCurrentLevel(Skills.PRAYER)) {
  683.                 log("Unable to use prayers?");
  684.                 stopScript(false);
  685.             }
  686.         }
  687.         init();
  688.         return true;
  689.     }
  690.  
  691.     @Override
  692.     public int loop() {
  693.         if (ScriptSettings.optionsOpen) {
  694.             return 1;
  695.         }
  696.         return getStateLoop();
  697.     }
  698.  
  699.     private void init() {
  700.         states.add(new Fight());
  701.         states.add(new Bank());
  702.         states.add(new WalkToBank());
  703.         states.add(new WalkToDragons());
  704.     }
  705.  
  706.     private int getStateLoop() {
  707.         for (State state : states) {
  708.             if (state.activeCondition()) {
  709.                 return state.loop();
  710.             }
  711.         }
  712.         return 1;
  713.     }
  714.  
  715.         private static class ScriptSettings {
  716.         static boolean optionsOpen;
  717.         static boolean antifirePotions;
  718.         boolean weaponSpecial;
  719.         boolean useCannon;
  720.         boolean useFamiliar;
  721.         boolean rangeMode;
  722.         Familiar farmiliar;
  723.  
  724.         ScriptSettings() {
  725.             optionsOpen = true;
  726.         }
  727.     }
  728.  
  729.     private enum Familiar; {
  730.         PACKYAK("Pack yak", 12093, 12435, true, true),
  731.         WARTORTOISE("Wartortoise", 12031, 12439, true, false),
  732.         SPIRITTERRORBIRD("Spirit terrorbird", 12007, 12441, true, false);
  733.         String name;
  734.         int pouchID;
  735.         int scrollID;
  736.         boolean canStore;
  737.         boolean useSpecial;
  738.  
  739.         Familiar(String name, int pouchID, int scrollID, boolean canStore, boolean useSpecial) {
  740.             this.name = name;
  741.             this.pouchID = pouchID;
  742.             this.scrollID = scrollID;
  743.             this.canStore = canStore;
  744.             this.useSpecial = useSpecial;
  745.         }
  746.     }
  747.  
  748.     private interface Items {
  749.         final static int dragonBone = 18832;
  750.         final static int visage = 11286;
  751.         final static int houseTab = 8013;
  752.         final static int faladorTab = 8009;
  753.         final static int crimsonCharm = 0;
  754.         final static int blueCharm = 0;
  755.         final static int shark = 385;
  756.         final static int vial = 229;
  757.         final int[] prayerPots = {143, 141, 139, 2434};
  758.     }
  759.  
  760.     private interface Objects; {
  761.         final static int housePortal = 13405;
  762.         final static int obelisk = 29953;
  763.         final static int trapDoor = 9472;
  764.         final static int dungeon = 52859;
  765.         final static int door = 39978;
  766.         final static int alter = 39842;
  767.     }
  768.  
  769.     private interface Areas; {
  770.         final static RSArea bank = new RSArea(new RSTile(2820, 3486), new RSTile(2814, 3474));
  771.         final static RSArea dragon = new RSArea(new RSTile(0, 0), new RSTile(0, 0));
  772.     }
  773.  
  774.     private interface Paths {
  775.         final static RSTile[] houseToTrap = {
  776.                 new RSTile(2954, 3223), new RSTile(2959, 3224),
  777.                 new RSTile(2965, 3223), new RSTile(2970, 3222),
  778.                 new RSTile(2972, 3217), new RSTile(2974, 3212),
  779.                 new RSTile(2977, 3208), new RSTile(2980, 3204),
  780.                 new RSTile(2983, 3200), new RSTile(2985, 3195),
  781.                 new RSTile(2987, 3190), new RSTile(2989, 3185),
  782.                 new RSTile(2991, 3179), new RSTile(2993, 3174),
  783.                 new RSTile(2993, 3169), new RSTile(2995, 3164),
  784.                 new RSTile(2999, 3161), new RSTile(3004, 3160),
  785.                 new RSTile(3006, 3155), new RSTile(3007, 3150)
  786.         };
  787.  
  788.         final static RSTile[] houseToAlter = {
  789.                 new RSTile(2951, 3223), new RSTile(2959, 3222),
  790.                 new RSTile(2964, 3222), new RSTile(2969, 3222),
  791.                 new RSTile(2972, 3218), new RSTile(2974, 3213),
  792.                 new RSTile(2977, 3209), new RSTile(2980, 3205),
  793.                 new RSTile(2984, 3202), new RSTile(2988, 3194),
  794.                 new RSTile(2991, 3189), new RSTile(2994, 3185),
  795.                 new RSTile(2999, 3183), new RSTile(3002, 3179)
  796.         };
  797.  
  798.         final static RSTile[] houseToObelisk = {
  799.                 new RSTile(2952, 3223), new RSTile(2957, 3223),
  800.                 new RSTile(2963, 3223), new RSTile(2968, 3223),
  801.                 new RSTile(2973, 3223), new RSTile(2978, 3222),
  802.                 new RSTile(2983, 3222), new RSTile(2988, 3220),
  803.                 new RSTile(2991, 3214), new RSTile(2995, 3210),
  804.                 new RSTile(2999, 3206), new RSTile(3001, 3200),
  805.                 new RSTile(3000, 3195)
  806.         };
  807.  
  808.         public final RSTile[] obeliskToAlter = {
  809.                 new RSTile(3001, 3191), new RSTile(3001, 3186),
  810.                 new RSTile(3002, 3181), new RSTile(3001, 3177)
  811.         };
  812.  
  813.         final static RSTile[] alterToTrap = {
  814.                 new RSTile(3000, 3178), new RSTile(3004, 3175),
  815.                 new RSTile(3005, 3170), new RSTile(3007, 3162),
  816.                 new RSTile(3008, 3157), new RSTile(3008, 3151)
  817.         };
  818.  
  819.         final static RSTile[] faladorToBank = {
  820.                 new RSTile(2964, 3381), new RSTile(2959, 3380),
  821.                 new RSTile(2954, 3380), new RSTile(2949, 3378),
  822.                 new RSTile(2944, 3376), new RSTile(2943, 3370),
  823.                 new RSTile(2947, 3366)
  824.         };
  825.  
  826.         final static RSTile[] trapToDungeon = {
  827.                 new RSTile(3007, 9550), new RSTile(3006, 9550),
  828.                 new RSTile(3003, 9549), new RSTile(3002, 9549),
  829.                 new RSTile(2999, 9549), new RSTile(2998, 9549),
  830.                 new RSTile(2995, 9551), new RSTile(2995, 9552),
  831.                 new RSTile(2995, 9553), new RSTile(2995, 9554),
  832.                 new RSTile(2995, 9557), new RSTile(2995, 9558),
  833.                 new RSTile(2995, 9559), new RSTile(2995, 9560),
  834.                 new RSTile(2995, 9563), new RSTile(2995, 9564),
  835.                 new RSTile(2995, 9565), new RSTile(2995, 9566),
  836.                 new RSTile(2995, 9569), new RSTile(2995, 9570),
  837.                 new RSTile(2996, 9571), new RSTile(2997, 9571),
  838.                 new RSTile(2998, 9574), new RSTile(2998, 9575),
  839.                 new RSTile(2998, 9576), new RSTile(2999, 9577),
  840.                 new RSTile(3002, 9579), new RSTile(3003, 9579),
  841.                 new RSTile(3004, 9579), new RSTile(3005, 9579),
  842.                 new RSTile(3008, 9579), new RSTile(3009, 9579),
  843.                 new RSTile(3010, 9579), new RSTile(3011, 9579),
  844.                 new RSTile(3014, 9579), new RSTile(3015, 9579),
  845.                 new RSTile(3016, 9579), new RSTile(3017, 9579),
  846.                 new RSTile(3020, 9580), new RSTile(3021, 9580),
  847.                 new RSTile(3022, 9580), new RSTile(3023, 9580),
  848.                 new RSTile(3026, 9581), new RSTile(3027, 9581),
  849.                 new RSTile(3028, 9582), new RSTile(3029, 9582),
  850.                 new RSTile(3032, 9583), new RSTile(3033, 9584),
  851.                 new RSTile(3034, 9585), new RSTile(3034, 9586),
  852.                 new RSTile(3034, 9589), new RSTile(3034, 9590),
  853.                 new RSTile(3035, 9591), new RSTile(3035, 9592),
  854.                 new RSTile(3035, 9595), new RSTile(3034, 9596),
  855.                 new RSTile(3034, 9597), new RSTile(3033, 9598),
  856.         };
  857.  
  858.     }
  859.  
  860.     private class Conditional; {
  861.         boolean isInventReady() {
  862.             return (!inventory.contains(Items.shark) && combat.getLifePoints() < 400) &&
  863.                     (!inventory.containsOneOf(Items.prayerPots) && combat.getLifePoints() < 20);
  864.             //TODO: add checks for antidragons;
  865.         }
  866.  
  867.         boolean inHouse() {
  868.             return objects.getNearest(Objects.housePortal) != null;
  869.         }
  870.  
  871.         boolean cannonNeedsReseting() {
  872.             return false;
  873.         }
  874.  
  875.         boolean cannonNeedsReloading() {
  876.             return false;
  877.         }
  878.  
  879.         boolean isTeleporting() {
  880.             return true;
  881.         }
  882.  
  883.         boolean runFromFight() {
  884.             return (!inventory.contains(Items.shark) && combat.getLifePoints() < 400) &&
  885.                     (!inventory.containsOneOf(Items.prayerPots) && combat.getLifePoints() < 20);
  886.             //TODO: add checks for antidragons;
  887.         }
  888.  
  889.         boolean isReadyToEnter() {
  890.             return !runFromFight() && inventory.contains(Items.faladorTab);
  891.         }
  892.     }
  893.  
  894.     //States
  895.     private abstract class State; {
  896.         abstract int loop();
  897.  
  898.         abstract boolean activeCondition();
  899.     }
  900.  
  901.     private class Bank extends State; {
  902.  
  903.         @Override
  904.         int loop() {
  905.             if (Areas.bank.contains(getMyPlayer().getLocation())) {
  906.                 if (!bank.isOpen()) {
  907.                     if (inventory.contains(Items.shark) && combat.getLifePoints() < 500) {
  908.                         RSItem shark = inventory.getItem(Items.shark);
  909.                         if (shark != null) {
  910.                             shark.doAction("Eat");
  911.                         }
  912.                     } else{
  913.                         bank.open();
  914.                     }
  915.                 } else {
  916.                     if (!inventory.contains(Items.shark) || combat.getLifePoints() < 500) {
  917.                         if(!inventory.contains(Items.shark)){
  918.                             bank.withdraw(Items.shark, 2);
  919.                         }
  920.                         bank.close();
  921.                     } else {
  922.                         if (inventory.contains(Items.dragonBone)) {
  923.                             bank.deposit(Items.dragonBone, 0);
  924.                         }
  925.                         if (inventory.contains(Items.visage)) {
  926.                             bank.deposit(Items.visage, 0);
  927.                         }
  928.                         if (!inventory.contains(Items.houseTab)) {
  929.                             if (bank.getCount(Items.houseTab) >= 1) {
  930.                                 bank.withdraw(Items.houseTab, 1);
  931.                             } else {
  932.                                 try {
  933.                                     throw new BankingException("Out of house tablets");
  934.                                 } catch (Exception ignore) {
  935.                                 }
  936.                             }
  937.                         }
  938.                         if (!inventory.contains(Items.faladorTab)) {
  939.                             if (bank.getCount(Items.faladorTab) >= 1) {
  940.                                 bank.withdraw(Items.faladorTab, 1);
  941.                             } else {
  942.                                 try {
  943.                                     throw new BankingException("Out of Falador tablets");
  944.                                 } catch (Exception ignore) {
  945.                                 }
  946.                             }
  947.                         }
  948.                         if(inventory.getCount(Items.shark) < 4){
  949.                             if(bank.getCount(Items.shark) >= 4){
  950.                                 bank.withdraw(Items.shark, (4 - inventory.getCount(Items.shark)));
  951.                             } else {
  952.                                 try {
  953.                                     throw new BankingException("Out of sharks");
  954.                                 } catch (Exception ignore) {
  955.                                 }
  956.                             }
  957.                         }else if (inventory.getCount(Items.shark) > 4){
  958.                              bank.deposit(Items.shark, (inventory.getCount(Items.shark) - 4));
  959.                         }
  960.                     }
  961.                 }
  962.             } else {
  963.                 RSTilePath path = walking.newTilePath(Paths.faladorToBank);
  964.                 if (path != null && path.getNext() != null) {
  965.                     path.traverse();
  966.                 }
  967.             }
  968.             return 100;
  969.         }
  970.  
  971.         @Override
  972.         boolean activeCondition() {
  973.             return Areas.bank.contains(getMyPlayer().getLocation()) && !conditional.isInventReady();
  974.         }
  975.     }
  976.  
  977.     private class WalkToDragons extends State; {
  978.         @Override
  979.         int loop() {
  980.             if (conditional.inHouse()) {
  981.                 RSObject exit = objects.getNearest(Objects.housePortal);
  982.                 if (exit != null) {
  983.                     exit.doAction("Enter");
  984.                 }
  985.             } else if (game.getPlane() == 0) {
  986.                 if (summoning.getSummoningPoints() < 10 && scriptSettings.useFamiliar) {
  987.                     RSObject obelisk = objects.getNearest(Objects.obelisk);
  988.                     if (obelisk != null) {
  989.                         if (obelisk.isOnScreen()) {
  990.                             obelisk.doAction("Renew");
  991.                         } else {
  992.                             if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) <= 5) {
  993.                                 walking.walkTileMM(walking.getClosestTileOnMap(obelisk.getLocation()));
  994.                             }
  995.                         }
  996.                     } else {
  997.                         RSTilePath path = walking.newTilePath(Paths.houseToObelisk);
  998.                         if (path != null && path.getNext() != null) {
  999.                             path.traverse();
  1000.                         }
  1001.                     }
  1002.                 } else if (prayer.getPrayerPercentLeft() < 85) {
  1003.                     RSObject door = objects.getNearest(Objects.door);
  1004.                     RSObject alter = objects.getNearest(Objects.alter);
  1005.                     if (alter != null) {
  1006.                         if (door != null) {
  1007.                             if (door.isOnScreen()) {
  1008.                                 door.doAction("Open");
  1009.                             } else {
  1010.                                 if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) <= 5) {
  1011.                                     walking.walkTileMM(walking.getClosestTileOnMap(door.getLocation()));
  1012.                                 }
  1013.                             }
  1014.                         } else {
  1015.                             if (alter.isOnScreen() && calc.canReach(alter.getLocation(), true)) {
  1016.                                 alter.doAction("Pray");
  1017.                             } else {
  1018.                                 if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) <= 5) {
  1019.                                     walking.walkTileMM(walking.getClosestTileOnMap(alter.getLocation()));
  1020.                                 }
  1021.                             }
  1022.                         }
  1023.                     } else {
  1024.                         if (objects.getNearest(Objects.obelisk) != null) {
  1025.                             RSTilePath path = walking.newTilePath(Paths.obeliskToAlter);
  1026.                             if (path != null && path.getNext() != null) {
  1027.                                 path.traverse();
  1028.                             }
  1029.                         } else {
  1030.                             RSTilePath path = walking.newTilePath(Paths.houseToAlter);
  1031.                             if (path != null && path.getNext() != null) {
  1032.                                 path.traverse();
  1033.                             }
  1034.                         }
  1035.                     }
  1036.                 } else {
  1037.                     RSObject trapDoor = objects.getNearest(Objects.trapDoor);
  1038.                     if (trapDoor != null) {
  1039.                         if (trapDoor.isOnScreen() && calc.canReach(trapDoor.getLocation(), true)) {
  1040.                             trapDoor.doAction("Climb"); //TODO: check.
  1041.                         } else {
  1042.                             if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) <= 5) {
  1043.                                 walking.walkTileMM(walking.getClosestTileOnMap(trapDoor.getLocation()));
  1044.                             }
  1045.                         }
  1046.                     } else {
  1047.                         if (objects.getNearest(Objects.alter) != null) {
  1048.                             RSTilePath path = walking.newTilePath(Paths.alterToTrap);
  1049.                             if (path != null && path.getNext() != null) {
  1050.                                 path.traverse();
  1051.                             }
  1052.                         } else {
  1053.                             RSTilePath path = walking.newTilePath(Paths.houseToTrap);
  1054.                             if (path != null && path.getNext() != null) {
  1055.                                 path.traverse();
  1056.                             }
  1057.                         }
  1058.                     }
  1059.                 }
  1060.             } else if (game.getPlane() == -1) {
  1061.                 RSObject dungeon = objects.getNearest(Objects.dungeon);
  1062.                 if (dungeon != null) {
  1063.                     if (dungeon.isOnScreen() && calc.canReach(dungeon.getLocation(), true)) {
  1064.                         if (conditional.isReadyToEnter()) {
  1065.                             dungeon.doAction("Enter");
  1066.                         } else {
  1067.                             log.severe("Stopping script inventory not ready?");
  1068.                             game.logout(false);
  1069.                             return -1;
  1070.                         }
  1071.                     } else {
  1072.                         if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) <= 5) {
  1073.                             walking.walkTileMM(walking.getClosestTileOnMap(dungeon.getLocation()));
  1074.                         }
  1075.                     }
  1076.                 } else {
  1077.                     RSTilePath path = walking.newTilePath(Paths.alterToTrap);
  1078.                     if (path != null && path.getNext() != null) {
  1079.                         path.traverse();
  1080.                     }
  1081.                 }
  1082.             }
  1083.             return 100;
  1084.         }
  1085.  
  1086.         @Override
  1087.         boolean activeCondition() {
  1088.             return conditional.isInventReady() && !Areas.dragon.contains(getMyPlayer().getLocation());
  1089.         }
  1090.     }
  1091.  
  1092.     private class WalkToBank extends State; {
  1093.         @Override
  1094.         int loop() {
  1095.             if (getActivePrayers().length > 0) {
  1096.                 for (Prayers prayer : getActivePrayers()) {
  1097.                     setActivated(prayer, false);
  1098.                 }
  1099.             }
  1100.             if (Areas.dragon.contains(getMyPlayer().getLocation())) {
  1101.                 if (!conditional.isTeleporting()) {
  1102.                     if (inventory.getCount(Items.faladorTab) >= 1) {
  1103.                         RSItem faladorTab = inventory.getItem(Items.faladorTab);
  1104.                         if (faladorTab != null) {
  1105.                             faladorTab.doAction("Break");
  1106.                         }
  1107.                     } else {
  1108.                         //Walk to dungeon
  1109.                         //logout..
  1110.                     }
  1111.                 }
  1112.             } else {
  1113.                 RSTilePath path = walking.newTilePath(Paths.faladorToBank);
  1114.                 if (path != null && path.getNext() != null) {
  1115.                     path.traverse();
  1116.                 }
  1117.             }
  1118.             return 100;
  1119.         }
  1120.  
  1121.         @Override
  1122.         boolean activeCondition() {
  1123.             return !Areas.bank.contains(getMyPlayer().getLocation()) && !conditional.isInventReady() && conditional.runFromFight();
  1124.         }
  1125.     }
  1126.  
  1127.     private class Fight extends State; {
  1128.         private int weaponSpecial;
  1129.         private PotionMethods potionMethods;
  1130.  
  1131.         private Fight() {
  1132.             weaponSpecial = specialUsage();
  1133.             potionMethods = new PotionMethods();
  1134.         }
  1135.  
  1136.         private class Potion {
  1137.             private int[] ids;
  1138.             private int[] boostedSkills;
  1139.  
  1140.             private Potion(int[] ids, int[] boostedSkills) {
  1141.                 this.ids = ids;
  1142.                 this.boostedSkills = boostedSkills;
  1143.             }
  1144.  
  1145.             private Potion(int[] ids, int boostedSkill) {
  1146.                 this(ids, new int[boostedSkill]);
  1147.             }
  1148.  
  1149.             private int getAmount() {
  1150.                 return inventory.getCount(true, ids);
  1151.             }
  1152.         }
  1153.  
  1154.         private class PotionMethods {
  1155.             private LinkedList<Potion> getPotions() {
  1156.                 LinkedList<Potion> potions = new LinkedList<Potion>();
  1157.                 potions.add(new Potion(new int[]{3040, 3042, 3044, 3046,
  1158.                         11513, 11515, 13520, 13521, 13522, 13523},
  1159.                         Skills.MAGIC)); // Magic pots
  1160.                 potions.add(new Potion(new int[]{2444, 169, 171, 173, 11509,
  1161.                         11511, 13524, 13525, 15326, 15327}, Skills.RANGE)); // Range
  1162.                 // pots
  1163.                 potions.add(new Potion(new int[]{9739, 9741, 9743, 9745,
  1164.                         11445, 11447}, new int[]{Skills.ATTACK,
  1165.                         Skills.STRENGTH})); // Combat pots
  1166.                 potions.add(new Potion(new int[]{2428, 121, 123, 125, 2436,
  1167.                         145, 147, 149, 11429, 11431, 11429, 11431, 11429,
  1168.                         11431, 11469, 11471, 15308, 15309, 15310, 15311},
  1169.                         Skills.ATTACK)); // Attack pots
  1170.                 potions.add(new Potion(new int[]{113, 115, 117, 119, 2440,
  1171.                         157, 159, 161, 11443, 11441, 11485, 11487, 15312,
  1172.                         15313, 15314, 15315}, Skills.STRENGTH)); // Strength
  1173.                 // pots
  1174.                 potions.add(new Potion(new int[]{2432, 133, 135, 137, 2442,
  1175.                         163, 165, 167, 11457, 11459, 11497, 11499, 15316,
  1176.                         15317, 15318, 15319}, Skills.DEFENSE)); // Defense pots
  1177.                 potions.add(new Potion(
  1178.                         new int[]{15332, 15333, 15334, 15335}, new int[]{
  1179.                                 Skills.STRENGTH, Skills.ATTACK, Skills.DEFENSE,
  1180.                                 Skills.MAGIC, Skills.RANGE})); // Overloads
  1181.                 return potions;
  1182.             }
  1183.  
  1184.             private Potion needToPot() {
  1185.                 for (Potion p : getPotions()) {
  1186.                     if (p.getAmount() > 1 && areSkillsBoosted(p.boostedSkills)) {
  1187.                         return p;
  1188.                     }
  1189.                 }
  1190.                 return null;
  1191.             }
  1192.  
  1193.             public boolean usePotions() {
  1194.                 if (inventory.containsOneOf(Items.vial)) {
  1195.                     RSItem[] vials = inventory.getItems(Items.vial);
  1196.                     for (RSItem item : vials) {
  1197.                         item.doAction("Drop");
  1198.                     }
  1199.                 }
  1200.                 Potion pot = needToPot();
  1201.                 if (pot != null) {
  1202.                     RSItem item = inventory.getItem(pot.ids);
  1203.                     if (item != null) {
  1204.                         return item.doClick(true);
  1205.                     }
  1206.                 }
  1207.                 return false;
  1208.             }
  1209.  
  1210.             private boolean areSkillsBoosted(int[] skillsArray) {
  1211.                 for (int skill : skillsArray) {
  1212.                     if (skills.getCurrentLevel(skill) <= skills
  1213.                             .getRealLevel(skill)) {
  1214.                         return true;
  1215.                     }
  1216.                 }
  1217.                 return false;
  1218.             }
  1219.         }
  1220.  
  1221.         private void weaponSpecial() {
  1222.             if (scriptSettings.weaponSpecial && weaponSpecial != -1) {
  1223.                 if (getMyPlayer().getInteracting() != null) {
  1224.                     if (!combat.isSpecialEnabled() && settings.getSetting(300) >= weaponSpecial * 10) {
  1225.                         if (game.getCurrentTab() != Game.TAB_ATTACK) {
  1226.                             switch (random(1, 3)) {
  1227.                                 case 1:
  1228.                                     game.openTab(Game.TAB_ATTACK);
  1229.                                     break;
  1230.                                 case 2:
  1231.                                     game.openTab(Game.TAB_ATTACK, true);
  1232.                                     break;
  1233.                             }
  1234.                             sleep(random(300, 900));
  1235.                         }
  1236.                         mouse.click(645 + random(0, 4), 425 + random(0, 4), true);
  1237.                         sleep(3000, 5000);
  1238.                     }
  1239.                 }
  1240.             }
  1241.         }
  1242.  
  1243.         private void loot() {
  1244.             RSGroundItem loot = groundItems.getNearest(Items.visage);
  1245.             if (loot != null) {
  1246.                 if (inventory.isFull()) {
  1247.                     if (inventory.contains(Items.vial)) {
  1248.                         inventory.dropAllExcept(Items.vial);
  1249.                     } else if (inventory.contains(Items.shark)) {
  1250.                         RSItem shark = inventory.getItem(Items.shark);
  1251.                         if (shark != null) {
  1252.                             shark.doAction("Eat");
  1253.                         }
  1254.                     } else if (inventory.contains(Items.dragonBone)) {
  1255.                         RSItem dragonBone = inventory.getItem(Items.dragonBone);
  1256.                         if (dragonBone != null) {
  1257.                             dragonBone.doAction("Bury");
  1258.                         }
  1259.                     }
  1260.                     sleep(100, 200);
  1261.                 }
  1262.                 if (!loot.isOnScreen()) {
  1263.                     camera.turnTo(loot.getLocation());
  1264.                     if (!loot.isOnScreen()) {
  1265.                         walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
  1266.                         sleep(300, 400);
  1267.                     }
  1268.                 }
  1269.                 if (!inventory.isFull()) {
  1270.                     if (loot.isOnScreen()) {
  1271.                         loot.doAction("Take");
  1272.                     }
  1273.                 }
  1274.             }
  1275.             //TODO: add effiges
  1276.             loot = groundItems.getNearest(Items.dragonBone);
  1277.             if (loot != null) {
  1278.                 if (inventory.isFull()) {
  1279.                     if (inventory.contains(Items.vial)) {
  1280.                         inventory.dropAllExcept(Items.vial);
  1281.                     } else if (inventory.contains(Items.shark)) {
  1282.                         RSItem shark = inventory.getItem(Items.shark);
  1283.                         if (shark != null) {
  1284.                             shark.doAction("Eat");
  1285.                         }
  1286.                     }
  1287.                     sleep(100, 200);
  1288.                 }
  1289.                 if (!loot.isOnScreen()) {
  1290.                     camera.turnTo(loot.getLocation());
  1291.                     if (!loot.isOnScreen()) {
  1292.                         walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
  1293.                         sleep(300, 400);
  1294.                     }
  1295.                 }
  1296.                 if (!inventory.isFull()) {
  1297.                     if (loot.isOnScreen()) {
  1298.                         loot.doAction("Take");
  1299.                     }
  1300.                 }
  1301.             }
  1302.             loot = groundItems.getNearest(Items.blueCharm);
  1303.             if (loot != null) {
  1304.                 if (inventory.isFull() && inventory.getCount(Items.blueCharm) >= 1) {
  1305.                     if (inventory.contains(Items.vial)) {
  1306.                         inventory.dropAllExcept(Items.vial);
  1307.                     }
  1308.                     sleep(100, 200);
  1309.                 }
  1310.                 if (!loot.isOnScreen()) {
  1311.                     camera.turnTo(loot.getLocation());
  1312.                     if (!loot.isOnScreen()) {
  1313.                         walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
  1314.                         sleep(300, 400);
  1315.                     }
  1316.                 }
  1317.                 if (!inventory.isFull()) {
  1318.                     if (loot.isOnScreen()) {
  1319.                         loot.doAction("Take");
  1320.                     }
  1321.                 }
  1322.             }
  1323.             loot = groundItems.getNearest(Items.crimsonCharm);
  1324.             if (loot != null) {
  1325.                 if (inventory.isFull() && inventory.getCount(Items.crimsonCharm) >= 1) {
  1326.                     if (inventory.contains(Items.vial)) {
  1327.                         inventory.dropAllExcept(Items.vial);
  1328.                     }
  1329.                     sleep(100, 200);
  1330.                 }
  1331.                 if (!loot.isOnScreen()) {
  1332.                     camera.turnTo(loot.getLocation());
  1333.                     if (!loot.isOnScreen()) {
  1334.                         walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
  1335.                         sleep(300, 400);
  1336.                     }
  1337.                 }
  1338.                 if (!inventory.isFull()) {
  1339.                     if (loot.isOnScreen()) {
  1340.                         loot.doAction("Take");
  1341.                     }
  1342.                 }
  1343.             }
  1344.         }
  1345.  
  1346.         private void restore() {
  1347.             if (combat.getLifePoints() < 700) {
  1348.                 if (inventory.contains(Items.shark)) {
  1349.                     RSItem shark = inventory.getItem(Items.shark);
  1350.                     if (shark != null) {
  1351.                         shark.doAction("Eat");
  1352.                     }
  1353.                 }
  1354.             }
  1355.             if (combat.getPrayerPoints() < 30) {
  1356.                 for (int pot : Items.prayerPots) {
  1357.                     if (inventory.contains(pot)) {
  1358.                         inventory.getItem(pot).doAction("Drink");
  1359.                         sleep(1200, 1500);
  1360.                     }
  1361.                 }
  1362.  
  1363.             }
  1364.         }
  1365.  
  1366.         @Override
  1367.         int loop() {
  1368.             weaponSpecial();
  1369.             potionMethods.usePotions();
  1370.             loot();
  1371.             restore();
  1372.             return 100;
  1373.         }
  1374.  
  1375.         @Override
  1376.         boolean activeCondition() {
  1377.             return Areas.dragon.contains(getMyPlayer().getLocation()) && !conditional.runFromFight();
  1378.         }
  1379.  
  1380.         private int specialUsage() {
  1381.             int[] amountUsage = {10, 25, 33, 35, 45, 50, 55, 60, 80, 85, 100};
  1382.             String[][] weapons = {
  1383.                     {"Rune thrownaxe", "Rod of ivandis"},
  1384.                     {"Dragon Dagger", "Dragon dagger (p)", "Dragon dagger (p+)",
  1385.                             "Dragon dagger (p++)", "Dragon Mace", "Dragon Spear",
  1386.                             "Dragon longsword", "Rune claws"},
  1387.                     {"Dragon Halberd"},
  1388.                     {"Magic Longbow"},
  1389.                     {"Magic Composite Bow"},
  1390.                     {"Dragon Claws", "Abyssal Whip", "Granite Maul", "Darklight",
  1391.                             "Barrelchest Anchor", "Armadyl Godsword"},
  1392.                     {"Magic Shortbow"},
  1393.                     {"Dragon Scimitar", "Dragon 2H Sword", "Zamorak Godsword",
  1394.                             "Korasi's sword"},
  1395.                     {"Dorgeshuun Crossbow", "Bone Dagger", "Bone Dagger (p+)",
  1396.                             "Bone Dagger (p++)"},
  1397.                     {"Brine Sabre"},
  1398.                     {"Bandos Godsword", "Dragon Battleaxe", "Dragon Hatchet",
  1399.                             "Seercull Bow", "Excalibur", "Enhanced excalibur",
  1400.                             "Ancient Mace", "Saradomin sword"}};
  1401.             String str = equipment.getItem(
  1402.                     org.rsbot.script.methods.Equipment.WEAPON).getName();
  1403.             str = str.substring(str.indexOf(">") + 1);
  1404.             for (int i = 0; i < weapons.length; i++) {
  1405.                 for (int j = 0; j < weapons[i].length; j++) {
  1406.                     if (weapons[i][j].equalsIgnoreCase(str)) {
  1407.                         return amountUsage[i];
  1408.                     }
  1409.                 }
  1410.             }
  1411.             return -1;
  1412.         }
  1413.     }
  1414.  
  1415.     //Exceptions
  1416.     private class BankingException extends Exception; {
  1417.         BankingException(String cause) {
  1418.             log.severe("Banking exception: " + cause);
  1419.             stopScript(true);
  1420.         }
  1421.     }
  1422.  
  1423.     private class CannonException extends Exception; {
  1424.         CannonException(String cause) {
  1425.             log.severe("Cannon exception: " + cause);
  1426.             //Stop using cannon?
  1427.         }
  1428.     }
  1429.  
  1430.     //Paint
  1431.     private Image getImage(String url); {
  1432.         try {
  1433.             return ImageIO.read(new URL(url));
  1434.         } catch (IOException e) {
  1435.             return null;
  1436.         }
  1437.     }
  1438.  
  1439.     private enum Skill; {
  1440.         ATTACK(Skills.ATTACK, "Attack", 0),
  1441.         STRENGTH(Skills.STRENGTH, "Strength", 1),
  1442.         DEFENCE(Skills.DEFENSE, "Defence", 2),
  1443.         CONSTITUTION(Skills.CONSTITUTION, "Constitution", 3),
  1444.         RANGE(Skills.RANGE, "Range", 4);
  1445.  
  1446.         int skillID;
  1447.         String skillName;
  1448.         int index;
  1449.  
  1450.         private Skill(int skillID, String skillName, int index) {
  1451.             this.skillID = skillID;
  1452.             this.skillName = skillName;
  1453.             this.index = index;
  1454.         }
  1455.     }
  1456.  
  1457.     private final Image closed = getImage("http://i52.tinypic.com/i1i1wi.png");
  1458.     private final Image tabOne = getImage("http://i56.tinypic.com/mo3zl.png");
  1459.     private final Image tabOptions = getImage("http://i52.tinypic.com/2la8mpt.png");
  1460.     private final Rectangle hideRect = new Rectangle(477, 336, 34, 37);
  1461.     private final Rectangle tabOneRect = new Rectangle(177, 335, 147, 37);
  1462.     private final Rectangle tabTwoRect = new Rectangle(327, 336, 148, 37);
  1463.  
  1464.     public void onRepaint(Graphics g1); {
  1465.         Graphics2D g = (Graphics2D) g1;
  1466.         if (!scriptSettings.optionsOpen) {
  1467.             if (tab == 1) {
  1468.                 g.drawImage(tabOne, -1, 287, null);
  1469.                 drawSkillBars(g);
  1470.             } else {
  1471.                 g.drawImage(closed, 162, 287, null);
  1472.             }
  1473.         } else {
  1474.             g.drawImage(tabOptions, -1, 287, null);
  1475.         }
  1476.     }
  1477.  
  1478.     private void drawSkillBars(Graphics g) {
  1479.         for (Skill s : Skill.values()) {
  1480.             int x = s.index <= 3 ? 20 : 180;
  1481.             int y = s.index <= 3 ? 390 + (s.index * 20) : 390 + ((s.index - 3) * 20);
  1482.             g.setColor(new Color(153, 153, 153));
  1483.             g.drawRect(x, y, 150, 15);
  1484.             g.setColor(new Color(0, 0, 0, 80));
  1485.             g.fillRect(x, y, (int) (skills.getPercentToNextLevel(s.skillID) * 1.5), 15);
  1486.             g.setColor(new Color(90, 15, 15));
  1487.             g.setFont(new Font("Serif", 0, 12));
  1488.             g.drawString(s.skillName + ": " + skills.getPercentToNextLevel(s.skillID)
  1489.                     + "% to level " + (skills.getRealLevel(s.skillID) + 1), x + 4, y + 12);
  1490.             g.setColor(new Color(255, 255, 255, 90));
  1491.             g.drawString(s.skillName + ": " + skills.getPercentToNextLevel(s.skillID)
  1492.                     + "% to level " + (skills.getRealLevel(s.skillID) + 1), x + 5, y + 13);
  1493.         }
  1494.     }