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

Untitled

By: a guest on Mar 11th, 2012  |  syntax: None  |  size: 441.36 KB  |  hits: 34  |  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.*;
  2. import java.awt.Color;
  3. import java.awt.Desktop;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Image;
  8. import java.awt.Point;
  9. import java.awt.Polygon;
  10. import java.awt.RenderingHints;
  11. import java.awt.Rectangle;
  12. import java.awt.event.KeyEvent;
  13. import java.awt.event.KeyListener;
  14. import java.awt.event.MouseEvent;
  15. import java.awt.event.MouseMotionListener;
  16. import java.awt.event.MouseListener;
  17. import java.io.BufferedReader;
  18. import java.io.BufferedWriter;
  19. import java.io.DataInputStream;
  20. import java.io.File;
  21. import java.io.FileInputStream;
  22. import java.io.FileWriter;
  23. import java.io.IOException;
  24. import java.io.InputStreamReader;
  25. import java.net.URI;
  26. import java.net.URL;
  27. import java.net.URLConnection;
  28. import java.util.ArrayList;
  29. import java.util.Arrays;
  30. import java.util.LinkedHashSet;
  31. import java.util.Set;
  32.  
  33. import javax.imageio.ImageIO;
  34.  
  35. //import com.rarebot.Configuration;
  36. import com.rarebot.event.events.MessageEvent;
  37. import com.rarebot.event.listeners.MessageListener;
  38. import com.rarebot.event.listeners.PaintListener;
  39. import com.rarebot.script.Script;
  40. import com.rarebot.script.ScriptManifest;
  41. import com.rarebot.script.methods.Environment;
  42. import com.rarebot.script.methods.Equipment;
  43. import com.rarebot.script.methods.Game;
  44. import com.rarebot.script.methods.Prayer.Book;
  45. import com.rarebot.script.methods.Prayer.Curses;
  46. import com.rarebot.script.methods.Prayer.Normal;
  47. import com.rarebot.script.methods.Skills;
  48. import com.rarebot.script.util.Filter;
  49. import com.rarebot.script.util.Timer;
  50. import com.rarebot.script.wrappers.RSArea;
  51. import com.rarebot.script.wrappers.RSCharacter;
  52. import com.rarebot.script.wrappers.RSComponent;
  53. import com.rarebot.script.wrappers.RSGroundItem;
  54. import com.rarebot.script.wrappers.RSInterface;
  55. import com.rarebot.script.wrappers.RSItem;
  56. import com.rarebot.script.wrappers.RSModel;
  57. import com.rarebot.script.wrappers.RSNPC;
  58. import com.rarebot.script.wrappers.RSObject;
  59. import com.rarebot.script.wrappers.RSObject.Type;
  60. import com.rarebot.script.wrappers.RSObjectDef;
  61. import com.rarebot.script.wrappers.RSPlayer;
  62. import com.rarebot.script.wrappers.RSTile;
  63.  
  64. @ScriptManifest(name = "iDungeon Pro",
  65.                 authors = "Kiko",
  66.                 description = "C6, 30 Bosses, 39 Puzzles, 60 Floors, Flawless Dungeoneering!",
  67.                 version = 1.0)
  68.  
  69. public class iDungeonPro extends Script implements KeyListener, MouseListener, MouseMotionListener, MessageListener, PaintListener {
  70.         private static final String VERSION = "1.44";
  71.         private final int SMUGGLER = 11226, SKINWEAVER = 10058, HEIM_CRAB = 18159, RED_EYE = 18161, DUSK_EEL = 18163, FLAT_FISH =
  72.  
  73. 18165, SHORT_FIN = 18167, WEB_SNIPPER = 18169, BOULDABASS = 18171, SALVE_EEL = 18173, BLUE_CRAB = 18175, CAVE_MORAY = 18177;
  74.         private final int ANTIPOISON = 17566, GATESTONE = 17489, GGS = 18829, TOOLKIT = 19650, COINS = 18201, CHISEL = 17444, PICKAXE
  75.  
  76. = 16295, TINDERBOX = 17678, GUARD_KEY = 17363, END_STAIRS = 50552, ENTRANCE = 48496;
  77.         private final int[] BLOCK_ANIMS = { 733, 7660, 13085, 13573, 13711 };
  78.         private final int[] BONES = { 17670, 17672, 17674, 17676, 17671, 18830, 18831, 18833, 18834 }, RINGS = { 15707, 18817, 18818,
  79.  
  80. 18819, 18820, 18821, 18822, 18823, 18824, 18825, 18826, 18827, 18828 };
  81.         private final int[] EQUIP_SLOTS = { Equipment.HELMET, Equipment.BODY, Equipment.SHIELD, Equipment.LEGS, Equipment.HANDS,
  82.  
  83. Equipment.FEET };
  84.         private final int[] EXIT_LADDERS = { 50604, 51156, 51704, 54675, 56149 }, FINISHED_LADDERS = { 49696, 49698, 49700, 53748,
  85.  
  86. 55484 };
  87.         private final int[] FOOD_ARRAY = { HEIM_CRAB, RED_EYE, DUSK_EEL, FLAT_FISH, SHORT_FIN, WEB_SNIPPER, BOULDABASS, SALVE_EEL,
  88.  
  89. BLUE_CRAB, CAVE_MORAY };
  90.         private final int[] FIRES = { 49940, 49941, 49942, 49943, 49944, 49945, 49946, 49947, 49948, 49949 };
  91.         private final int[] FRIENDLIES = { SKINWEAVER, 11086, 11087, 11088, 11089, 11090, 11091, 11092, 11093, 11094, 11095, SMUGGLER,
  92.  
  93. 11002, 11003, 11004 };
  94.         private final int[] GROUP_PORTAL = { 53124, 53125, 53126, 7528, 56146 };
  95.         private final int[] TOOLS = { PICKAXE, 16361, 17490, TINDERBOX, 17754, 17794, 17796, 17883 };
  96.         private final int[] COSMIC_RUNES = { 16100, 17789 };
  97.         private final int[] LAW_RUNES = { 16103, 17792 };
  98.         private final int[] FIRE_RUNES = { 16094, 17783 };
  99.         private final int[] NATURE_RUNES = { 16102, 17791 };
  100.         private final int[] UNLIT = { 17682, 17684, 17686, 17688, 17690, 17692, 17694, 17696, 17698, 17700 };
  101.  
  102.         private final int[] CHAIN_WARRIORS = { 10250, 10251, 10252, 10256, 10258, 10259, 10262, 10263, 10265, 10266, 10270, 10271,
  103.  
  104. 10272, 10273, 10277, 10284, 10286, 10292, 10293, 10298, 10299, 10300, 10307, 10402, 10403, 10409, 10416, 10417, 10430, 10445, 10450,
  105.  
  106. 10451, 10452, 10457, 10458, 10517, 10526, 10546, 10548, 10847, 10848, 10849, 10854, 10855, 10856, 10860, 10861, 10868, 10877, 10881,
  107.  
  108. 10883, 10884, 10888, 10889, 10897 };
  109.         private final int[] PLATE_WARRIORS = { 10246, 10247, 10248, 10253, 10254, 10255, 10260, 10261, 10267, 10274, 10289, 10295,
  110.  
  111. 10296, 10297, 10302, 10303, 10397, 10398, 10399, 10401, 10404, 10405, 10411, 10412, 10413, 10419, 10426, 10439, 10448, 10455, 10509,
  112.  
  113. 10542, 10845, 10851, 10858, 10866, 10873, 10885, 10886, 10899, 10893 };
  114.  
  115.         private final int[] BASIC_DOORS = { 50342, 50343, 50344, 53948, 55762 }, GUARDIAN_DOORS = { 50346, 50347, 50348, 53949, 55763
  116.  
  117. }, STANDARD_DOORS = { 50342, 50343, 50344, 53948, 55762, 50346, 50347, 50348, 53949, 55763 };
  118.         private final int[] BACK_DOORS = { 49462, 50342, 50343, 50344, 53948, 55762, 50350, 50351, 50352, 53950, 55764 }, BOSS_DOORS =
  119.  
  120. { 50350, 50351, 50352, 53950, 55764 };
  121.         private final int[] FREE_BLOCK_DOORS = { 50278, 50279, 50280, 50305, 50306, 50307, 50314, 50315, 50316, 50329, 50330, 50331,
  122.  
  123. 53953, 53962, 53965, 53970 };
  124.         private final int[] FREE_SKILL_DOORS = { 50272, 50273, 50274, 50287, 50288, 50289, 50299, 50300, 50301, 50308, 50309, 50310,
  125.  
  126. 50317, 50318, 50319, 53951, 53960, 53963, 53966 };
  127.         private final int[] MEMBER_BLOCK_DOORS = { 50323, 50324, 50325, 53968, 55741, 55750, 55753, 55756, 55757, 55758 };
  128.         private final int[] MEMBER_SKILL_DOORS = { 50281, 50282, 50283, 50293, 50294, 50295, 50335, 50336, 50337, 53954, 53956, 53958,
  129.  
  130. 53972, 55739, 55742, 55744, 55745, 55746, 55748, 55751, 55754, 55760 };
  131.         private final int[] PRAYER_DOORS = { 50332, 50333, 50334, 53971, 55759 };
  132.         private final int[] SUMMON_DOORS = { 50326, 50327, 50328, 53969, 55757 };
  133.         private final int[] PUZZLE_DOORS = { 49306, 49335, 49336, 49337, 49338, 49375, 49376, 49377, 49378, 49379, 49380, 49387,
  134.  
  135. 49388, 49389, 49462, 49463, 49464, 49504, 49505, 49506, 49516, 49517, 49518, 49564, 49565, 49566, 49574, 49575, 49576, 49577, 49578,
  136.  
  137. 49579, 49603, 49604, 49605, 49606, 49607, 49608, 49625, 49626, 49627, 49644, 49645, 49646, 49650, 49651, 49652, 49677, 49678, 49679,
  138.  
  139. 53987, 53988, 53989, 53990, 53992, 54000, 54001, 54006, 54067, 54070, 54071, 54072, 54073, 54106, 54107, 54108, 54109, 54236, 54274,
  140.  
  141. 54284, 54299, 54300, 54315, 54316, 54317, 54318, 54319, 54320, 54335, 54360, 54361, 54362, 54363, 54404, 54417, 54418, 54620, 55478,
  142.  
  143. 55479, 55480, 55481, 56079, 56081, 56526, 56527, 56528, 56529 };
  144.         private final int[] WARPED_PUZZLE_DOORS = { 32370, 32406, 33607, 33634, 33637, 33654, 33712, 34269, 34865, 35273, 35348,
  145.  
  146. 35863, 35907, 37199, 37201, 39522, 39854, 39856, 39863, 39901, 39965, 55482, 56082, 56530 };
  147.  
  148.         private final int[] ORANGE_KEYS = { 18202, 18204, 18206, 18208, 18210, 18212, 18214, 18216 };
  149.         private final int[] SILVER_KEYS = { 18218, 18220, 18222, 18224, 18226, 18228, 18230, 18232 };
  150.         private final int[] YELLOW_KEYS = { 18234, 18236, 18238, 18240, 18242, 18244, 18246, 18248 };
  151.         private final int[] GREEN_KEYS = { 18250, 18252, 18254, 18256, 18258, 18260, 18262, 18264 };
  152.         private final int[] BLUE_KEYS = { 18266, 18268, 18270, 18272, 18274, 18276, 18278, 18280 };
  153.         private final int[] PURPLE_KEYS = { 18282, 18284, 18286, 18288, 18290, 18292, 18294, 18296 };
  154.         private final int[] CRIMSON_KEYS = { 18298, 18300, 18302, 18304, 18306, 18308, 18310, 18312 };
  155.         private final int[] GOLD_KEYS = { 18314, 18316, 18318, 18320, 18322, 18324, 18326, 18328 };
  156.         private final int[][] KEYS = { ORANGE_KEYS, SILVER_KEYS, YELLOW_KEYS, GREEN_KEYS, BLUE_KEYS, PURPLE_KEYS, CRIMSON_KEYS,
  157.  
  158. GOLD_KEYS };
  159.  
  160.         private final int[] ORANGE_DOORS = { 50208, 50209, 50210, 50211, 50212, 50213, 50214, 50215 };
  161.         private final int[] SILVER_DOORS = { 50216, 50217, 50218, 50219, 50220, 50221, 50222, 50223 };
  162.         private final int[] YELLOW_DOORS = { 50224, 50225, 50226, 50227, 50228, 50229, 50230, 50231 };
  163.         private final int[] GREEN_DOORS = { 50232, 50233, 50234, 50235, 50236, 50237, 50238, 50239 };
  164.         private final int[] BLUE_DOORS = { 50240, 50241, 50242, 50243, 50244, 50245, 50246, 50247 };
  165.         private final int[] PURPLE_DOORS = { 50248, 50249, 50250, 50251, 50252, 50253, 50254, 50255 };
  166.         private final int[] CRIMSON_DOORS = { 50256, 50257, 50258, 50259, 50260, 50261, 50262, 50263 };
  167.         private final int[] GOLD_DOORS = { 50264, 50265, 50266, 50267, 50268, 50269, 50270, 50271 };
  168.         private final int[][] KEY_DOORS = { ORANGE_DOORS, SILVER_DOORS, YELLOW_DOORS, GREEN_DOORS, BLUE_DOORS, PURPLE_DOORS,
  169.  
  170. CRIMSON_DOORS, GOLD_DOORS };
  171.  
  172.         private final Monster[] HOODED_MONSTERS = { Monster.FORGOTTEN_WARRIOR, Monster.FORGOTTEN_WARRIOR0CHAIN,
  173.  
  174. Monster.FORGOTTEN_WARRIOR0PLATE, Monster.FORGOTTEN_RANGER, Monster.ZOMBIE0MELEE, Monster.ZOMBIE0RANGE, Monster.SKELETON0MELEE,
  175.  
  176. Monster.SKELETON0RANGE, Monster.HILL_GIANT };
  177.  
  178.         private final String[] PRIORITY_MONSTERS = { "Necromancer", "Reborn mage", "dragon" };
  179.         private final String[] SECONDARY_MONSTERS = { "shade", "mage" };
  180.         private final String[] DISTANCE_MONSTER = { "Forgotten ranger", "Forgotten mage", "Mysterious shade", "Zombie", "Hydra",
  181.  
  182. "Icefiend", "Animated book", "Skeleton", "Thrower troll", "Ice elemental", "Lesser demon", "Greater demon", "Necromancer", "Ghost" };
  183.         private final String[] POISON_MONSTER = { "Dungeon spider", "Cave crawler", "Night spider" };
  184.         private final String[] METAL_TIERS = { "Novite", "Bathus", "Marmaros", "Kratonite", "Fractite", "Zephyrium", "Argonite",
  185.  
  186. "Katagon", "Gorgonite", "Promethium", "Primal" };
  187.         private final String[] LEATHER_TIERS = { "Protoleather", "Subleather", "Paraleather", "Archleather", "Dromoleather",
  188.  
  189. "Spinoleather", "Gallileather", "Stegoleather", "Megaleather", "Tyrannoleather", "Sagittarian" };
  190.         private final String[] CLOTH_TIERS = { "Salve", "Wildercress", "Blightleaf", "Roseblood", "Bryll", "Duskweed", "Soulbell",
  191.  
  192. "Ectograss", "Runic", "Spiritbloom", "Celestial" };
  193.         private final String[] WOOD_TIERS = { "Tangle gum", "Seeping elm", "Blood spindle", "Utuku", "Spinebeam", "Bovistrangler",
  194.  
  195. "Thigat", "Corpsethorn", "Entgallow", "Grave creeper", "Sagittarian" };
  196.         private final String[] FREE_WORLDS = { "1", "3", "4", "5", "7", "8", "10", "11", "13", "14", "16", "17", "19", "20", "25",
  197.  
  198. "29", "30", "33", "34", "35", "37", "38", "41", "43", "47", "49", "50", "55", "57", "61", "62", "73", "74", "75", "80", "81", "87",
  199.  
  200. "90", "93", "102", "105", "106", "108", "113", "118", "120", "123", "134", "135", "136", "141", "149", "152", "153", "154", "155",
  201.  
  202. "161", "167", "169" };
  203.         private final String[] MELEE_SLOTS = { "full helm", "body", "kiteshield", "plate", "gauntlets", "boots" };
  204.         private final String[] RANGE_SLOTS = { "coif", "body", "", "chaps", "vambraces", "boots" };
  205.         private final String[] MAGIC_SLOTS = { "hood", "robe top", "", "robe bottom", "gloves", "boots" };
  206.  
  207.         private final String LOGO = "";//"http://img526.imageshack.us/img526/6892/iconacv.png";
  208.         private final String HIDE = "";//"http://img807.imageshack.us/img807/5183/hide.png";
  209.         private final String HIDE_S = "";//"http://img807.imageshack.us/img807/5183/hide.png";
  210.         private final String UPARROW = "";//"http://www2.hawaii.edu/~mbutler/ButlerLab.data/SmartObjects/up_arrow_green_sm.gif";
  211.         private final String UPARROW_S = "";//"http://www2.hawaii.edu/~mbutler/ButlerLab.data/SmartObjects/up_arrow_green_sm.gif";
  212.         private final String DOWNARROW = "";//"http://www2.hawaii.edu/~mbutler/ButlerLab.data/SmartObjects/down_arrow_green_sm.gif";
  213.         private final String DOWNARROW_S = "";//"http://www2.hawaii.edu/~mbutler/ButlerLab.data/SmartObjects/down_arrow_green_sm.gif";
  214.         private final String PLAY = "";//"http://files.softicons.com/download/toolbar-icons/gaming-toolbar-icons-by-natalie-nash/png/32x32/Play%20Symbol.png";
  215.         private final String PLAY_S = "";//"http://img42.imageshack.us/img42/9383/playsi.png";
  216.         private final String PAUSE = "";//"https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/Gnome-media-playback-pause.svg/48px-Gnome-media-playback-pause.svg.png";
  217.         private final String PAUSE_S = "";//"https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/Gnome-media-playback-pause.svg/48px-Gnome-media-playback-pause.svg.png";
  218.         private final String INFO = "";//"http://cdn1.iconfinder.com/data/icons/lullacons/large-info.png";
  219.         private final String INFO_S = "";//"http://cdn1.iconfinder.com/data/icons/lullacons/large-info.png";
  220.         private final String HELP = "";//"http://www.webhelpdesk.com/images/icon_question-mark.png";
  221.         private final String HELP_S = "";//"http://www.webhelpdesk.com/images/icon_question-mark.png";
  222.         private final String STOP = "";//"http://fedoraproject.org/w/uploads/thumb/6/61/Stop_(medium_size).png/35px-Stop_(medium_size).png";
  223.         private final String STOP_S = "";//"http://fedoraproject.org/w/uploads/thumb/6/61/Stop_(medium_size).png/35px-Stop_(medium_size).png";
  224.         private final String MINIS = "";//"http://images4.wikia.nocookie.net/__cb20111118163341/runescape/images/f/f6/Bronze_arrow_5.png";
  225.         private final String MINIS_S = "";//"http://www.go-runescape.com/img/woodcutting_fletching_firemaking/arrow_bronze1.gif";
  226.  
  227.         private static final int[] SLAYER_MONSTERS = { 10694, 10695, 10696, 10697, 10698, 10699, 10700, 10701, 10702, 10704, 10705 };
  228.        
  229.         private static final String CACHE = "C:/Documents and Settings/Daniel/My Documents/RareBot";
  230.         private static final String DIRECTORY = CACHE + File.separator + "iDungeonLoader" + File.separator;
  231.         private static final RSTile ORIGIN = new RSTile(0, 0), DAEMONHEIM = new RSTile(3450, 3720);
  232.         private static final String LOGIN_FILE = DIRECTORY + File.separator + "iDPLogin.ini";
  233.  
  234.         private static final String EMPTY_TIMER = "00:00:00";
  235.  
  236.         private static Floor floor = Floor.OUTSIDE;
  237.         private static int dungLevel, prayerLevel, slayerLevel = 85;
  238.         private static Point mp = new Point(0, 0), cp = new Point(0, 0);
  239.  
  240.         private int[] foods = FOOD_ARRAY, goodFoods, topFoods;
  241.         private int[] equipmentTiers = { 0, 0, 0, 0, 0, 0 }, initialEquipmentTiers = { 0, 0, 0, 0, 0, 0 }, tempTiers = { 0, 0, 0, 0,
  242.  
  243. 0, 0 };
  244.         private String[] improvements, armorTiers = METAL_TIERS, weaponTiers, slotNames = MELEE_SLOTS;
  245.  
  246.         private ArrayList<Integer> bounds = new ArrayList<Integer>(), lockIDs = new ArrayList<Integer>();
  247.         private ArrayList<RSArea> rooms = new ArrayList<RSArea>(), clearedRooms = new ArrayList<RSArea>(), finishedRooms = new
  248.  
  249. ArrayList<RSArea>(), skipRooms = new ArrayList<RSArea>();
  250.         private ArrayList<RSArea> unBacktrackable = new ArrayList<RSArea>();
  251.         private ArrayList<RSArea> puzzleRooms = new ArrayList<RSArea>(), finishedPuzzles = new ArrayList<RSArea>(), chasmRooms = new
  252.  
  253. ArrayList<RSArea>();
  254.         private ArrayList<RSObject> newObjects = new ArrayList<RSObject>();
  255.         private ArrayList<RSTile> allDoors = new ArrayList<RSTile>(), goodDoors = new ArrayList<RSTile>(), openedDoors = new
  256.  
  257. ArrayList<RSTile>();
  258.         private ArrayList<RSTile> newDoors = new ArrayList<RSTile>(), backDoors = new ArrayList<RSTile>(), drawDoors = new
  259.  
  260. ArrayList<RSTile>();
  261.         private ArrayList<RSTile> guardianDoors = new ArrayList<RSTile>(), lockedDoors = new ArrayList<RSTile>(), blockedDoors = new
  262.  
  263. ArrayList<RSTile>(), skillDoors = new ArrayList<RSTile>(), finishedDoors = new ArrayList<RSTile>();
  264.         private ArrayList<RSTile> bossPath = new ArrayList<RSTile>(), deathPath = new ArrayList<RSTile>();
  265.         private ArrayList<RSTile> badTiles = new ArrayList<RSTile>();
  266.         private ArrayList<RSTile> oldObjectTiles = new ArrayList<RSTile>(), newObjectTiles = new ArrayList<RSTile>();
  267.         private ArrayList<RSTile> roomFlags = new ArrayList<RSTile>();
  268.         private ArrayList<RSTile> puzzlePoints = new ArrayList<RSTile>();
  269.  
  270.         private boolean authCheck, verified, developer, memberWorld = true, newDungeon = true, inDungeon, levelRequirement = true,
  271.  
  272. temporarySecondary, welcomeBack;
  273.         private boolean isDead, isCursing, unreachable, outOfAmmo, lockDown, skipRoom, isRushing, shadowHooded, roomHooded,
  274.  
  275. itemReceived, skipDoorFound, showSecondary = true;
  276.         private boolean explore, open, bossFight, retrace, finish, exit, settingsFinished, forcePrestige, aborted, twoHanded,
  277.  
  278. disrobed, cookReady, spawnRoom;
  279.         private boolean puzzleSolved, puzzleRepeat, roomSwitch, disableBossPath;
  280.         private double tpf = 0, fph = 0;
  281.         private int degrees, pitch;
  282.         private int attackMode = -1, defaultMode = -1, defenseMode = 3, weaponTier = 11, attackTier, defenseTier, newWeapon,
  283.  
  284. startArmor, armorSlot = -1, attempts;
  285.         private int roomNumber, primaryWep, secondaryWep, arrows, blastBox, complexity = 6, rushTo = 18, aComplexity = 6, rComplexity
  286.  
  287. = 1, fNumber = 0, maxFloor = 47, dungStartLevel;
  288.         private int abortedCount, dungeonCount = 0, prestigeCount, puzzleCount, reportedPrestige, userCount = 0, userOffset = 114,
  289.  
  290. userRank = 0, rankOffset = 144;
  291.         private int dungStart, dungGain, strStart, strGain, attStart, attGain, defStart, defGain, rngStart, rngGain, mgcStart,
  292.  
  293. mgcGain, hitStart, hitGain, prayStart, prayGain;
  294.         private int runeStart, runeGain, mineStart, mineGain, fireStart, fireGain, woodStart, woodGain, smthStart, smthGain,
  295.  
  296. crftStart, crftGain, agilStart, agilGain, thevStart, thevGain, summStart, summGain, herbStart, herbGain, cnstStart, cnstGain,
  297.  
  298. cookStart, cookGain, fishStart, fishGain, slayStart, slayGain;
  299.         private int tokens, restarts, restartCount, deaths, bossStage, bossID, cProg, ceph, deph, seph, bossHp = 100, levelGoal;
  300.         private long fastestMillis = 999999, slowestMillis = 0;
  301.  
  302.         private Combat tempMode = Melee.NONE;
  303.         private Food fish;
  304.         private Logs logs;
  305.         private RSArea newRoom, currentRoom, oldRoom, startRoom, groupRoom, bossRoom, targetRoom, gateRoom;
  306.         private RSGroundItem nearItem;
  307.         private RSNPC nearMonster;
  308.         private RSTile nearDoor, nearDoor2, bossDoor, destDoor, entryDoor, oldDoor, safeTile;
  309.         private Spell combatSpell;
  310.         private String controlStatus = "", fastestTime = EMPTY_TIMER, secondaryStatus = "", slowestTime = EMPTY_TIMER, status =
  311.  
  312. "Loading images...", statusSettings = "Hover over an option to find out more";
  313.         private String armorType, bossName = "", failReason = "", lastMessage = "", strongestMonster = "", userSettings, weaponType =
  314.  
  315. "Unknown";
  316.         private Style combatStyle = Style.MELEE, primaryStyle = Style.MELEE, protection;
  317.         private Timer bossTimer, doorTimer, dungTimer, failTimer = new Timer(random(360000, 480000)), idleTimer = new Timer(0),
  318.  
  319. itemTimer = new Timer(random(800, 1100)), logoutTimer = new Timer(0), prayTimer, puzzleTimer, runTimer = new Timer(0);
  320.  
  321.         @Override
  322.         public boolean onStart() {
  323.                 userSettings = DIRECTORY + "iDPSettings141-" + account.getName() + ".ini";
  324.                 //loadSettings();
  325.                 dungStartLevel = skills.getRealLevel(Skills.DUNGEONEERING);
  326.                 dungLevel = skills.getRealLevel(Skills.DUNGEONEERING);
  327.                 levelGoal = dungLevel + 1;
  328.                 return retrieveCredentials();
  329.         }
  330.  
  331.         public boolean retrieveCredentials() {
  332.                 /*try {
  333.                 FileInputStream fstream = new FileInputStream(LOGIN_FILE);
  334.                 DataInputStream in = new DataInputStream(fstream);
  335.                 BufferedReader br = new BufferedReader(new InputStreamReader(in));
  336.                 username = br.readLine().replaceAll("_", "");
  337.                 password = br.readLine().replaceAll("_", "");
  338.                 in.close();
  339.                 try {
  340.                         String[] tmp = { username, "" };
  341.                         BufferedWriter out = new BufferedWriter(new FileWriter(LOGIN_FILE));
  342.                         for (String s : tmp) {
  343.                                 out.write(s);
  344.                                 out.newLine();
  345.                         }
  346.                         if (out != null)
  347.                                 out.close();
  348.                 } catch (Exception e) {
  349.                         log(RED, "Unable to clear the password data");
  350.                         return false;
  351.                 }
  352.                 authCheck = true;
  353.                 } catch (Exception e) {
  354.                 log.severe("Error checking credentials!");
  355.                 }*/
  356.                 authCheck = true;
  357.                 verified = false;
  358.                 return authCheck;
  359.         }
  360.        
  361.         @Override
  362.         public void onFinish() {
  363.                 authCheck = false;
  364.                 hidePaint = false;
  365.                 Option.DEBUG.set(true);
  366.                 if (dungeonCount > 1 && verified) {
  367.                         verified = false;
  368.                         log(PRP, "Thanks for using iDungeon Pro v" + VERSION + " by kiko & ShadowMoose");
  369.                         env.saveScreenshot(true);
  370.                         log("We completed " + dungeonCount + " dungeons for " + tokens + " tokens!");
  371.                         env.enableRandoms();
  372.                 }
  373.         }
  374.  
  375.         private void enterDungeon() {
  376.                 int selComplexity = valueOf(complexity);
  377.                 RSObject entrance;
  378.                 aborted = false;
  379.                 exit = false;
  380.                 lastMessage = "";
  381.                 status = "Entering Daemonheim...";
  382.                 while ((entrance = objects.getNearest(ENTRANCE)) != null) {
  383.                         if (failSafe())
  384.                                 return;
  385.                         updateProgress();
  386.                         selComplexity = valueOf(Option.RUSH.enabled() && cProg < rushTo ? rComplexity : complexity);
  387.                         if (lastMessage.contains("carrying items")) {
  388.                                 log.severe("Please bank all items besides your Ring and restart the script!");
  389.                                 authCheck = false;
  390.                                 return;
  391.                         }
  392.                         RSInterface floorWindow = interfaces.get(947);
  393.                         RSInterface cWindow = interfaces.get(938);
  394.                         if (interfaces.getComponent(210, 2).isValid()) {
  395.                                 interfaces.getComponent(210, 2).doClick();
  396.                         } else if (interfaces.get(236).isValid()) {
  397.                                 interfaces.getComponent(236, !isRushing && Option.MEDIUM.enabled() && interfaces.getComponent(236,
  398.  
  399. 0).containsText("size") && (!Option.RUSH.enabled() || fNumber > rushTo) ? 2 : 1).doClick();
  400.                         } else if (floorWindow.getComponent(608).isValid()) {
  401.                                 if (updateProgress() && fNumber > 1 && maxFloor > 0 && (fNumber + (forcePrestige ? 1 : 0) > maxFloor
  402.  
  403. || (username.isEmpty() && dungeonCount > 6))) {
  404.                                         if (!resetPrestige())
  405.                                                 return;
  406.                                 }
  407.                                 boolean skipScrolling = fNumber == maxFloor;
  408.                                 if (skipScrolling || scrollToFloor()) {
  409.                                         for (int d = 0; d < 10; d++) {
  410.                                                 if (!floorWindow.getComponent(608).isValid())
  411.                                                         break;
  412.                                                 if (skipScrolling || floorWindow.getComponent(765).getText().contains("" + fNumber)) {
  413.                                                         floorWindow.getComponent(761).interact("Confirm");
  414.                                                 } else floorWindow.getComponent(608 + cProg).interact("Select-floor");
  415.                                                 sleep(700, 1000);
  416.                                         }
  417.                                 } else mouse.moveRandomly(200);
  418.                         } else if (cWindow.getComponent(42).isValid()) {
  419.                                 lastMessage = "";
  420.                                 while (cWindow.getComponent(42).isValid()) {
  421.                                         if (lastMessage.contains("access complexity")) {
  422.                                                 selComplexity--;
  423.                                                 lastMessage = "";
  424.                                         }
  425.                                         if (!cWindow.getComponent(42).getText().contains("" + selComplexity)) {
  426.                                                 cWindow.getComponent(55 + 5 * selComplexity).interact("Select-complexity");
  427.                                         } else if (cWindow.getComponent(37).interact("Confirm")) {
  428.                                                 sleep(400);
  429.                                         }
  430.                                         sleep(600, 800);
  431.                                 }
  432.                         } else if (updateProgress() && fNumber > 1 && maxFloor > 0 && (fNumber + (forcePrestige ? 1 : 0) > maxFloor ||
  433.  
  434. (username.isEmpty() && dungeonCount > 6))) {
  435.                                 if (!resetPrestige())
  436.                                         return;
  437.                         } else if (doObjAction(entrance, "Climb-down")) {
  438.                                 waitToStop(false);
  439.                         }
  440.                         sleep(600, 1000);
  441.                 }
  442.                 newDungeon = true;
  443.                 inDungeon = true;
  444.                 aComplexity = selComplexity;
  445.         }
  446.  
  447.         private void exitDungeon() {
  448.                 status = "Exiting dungeon...";
  449.                 selectTab(Game.TAB_INVENTORY, 3);
  450.                 exit = true;
  451.                 idleTimer = new Timer(0);
  452.                 while (inDungeon()) {
  453.                         if (failBasic())
  454.                                 return;
  455.                         if (player().isInCombat()) {
  456.                                 getCurrentRoom();
  457.                                 setTargetRoom(currentRoom);
  458.                                 if (bossRoom == null && npcs.getNearest(guardians) != null)
  459.                                         intentionallyBacktrack();
  460.                         } else if (interfaces.get(236).isValid()) {
  461.                                 interfaces.getComponent(236, 1).interact("Continue");
  462.                         } else if (interfaces.get(211).isValid()) {
  463.                                 interfaces.getComponent(211, 3).interact("Continue");
  464.                         } else if (openPartyTab()) {
  465.                                 interfaces.getComponent(939, 34).interact("Leave-party");
  466.                         }
  467.                         sleep(700, 1100);
  468.                 }
  469.                 floor = Floor.OUTSIDE;
  470.                 inDungeon = false;
  471.                 newDungeon = false;
  472.         }
  473.  
  474.         private void exploreRoom() {
  475.                 if (roomNumber == 1) {
  476.                         pickUpAll();
  477.                         open = true;
  478.                         roomHooded = false;
  479.                         return;
  480.                 }
  481.                 if (areaContains(bossRoom, myLoc())) {
  482.                         retrace = false;
  483.                         bossFight = true;
  484.                         return;
  485.                 }
  486.                 boolean unexplored = newRoom != null;
  487.                 if (unexplored)
  488.                         protection = null;
  489.                 roomHooded = shadowHooded && !roomContains(targetRoom, guardianDoors);
  490.                 if (floor == Floor.OCCULT) {
  491.                         spawnRoom = getNpcInRoom("Necromancer") != null;
  492.                 } else if (floor == Floor.WARPED) {
  493.                         spawnRoom = getNpcInRoom("Reborn mage") != null;
  494.                 } else spawnRoom = false;
  495.                 if (rooms.size() > 1)
  496.                         status = "Exploring a " + (unexplored ? "new" : "old") + " room";
  497.                 newRoom = null;
  498.                 boolean toCheck = false;
  499.                 int puzzleCheck = 0;
  500.                 getCurrentRoom();
  501.                 if (aComplexity > 4 && (unexplored || (!finishedPuzzles.contains(targetRoom) && !finishedRooms.contains(targetRoom))))
  502.  
  503. {
  504.                         for (RSTile door : drawDoors) {
  505.                                 if (areaContains(targetRoom, door) && !finishedDoors.contains(door)) {
  506.                                         toCheck = true;
  507.                                         break;
  508.                                 }
  509.                         }
  510.                 }
  511.                 if (developer && unexplored) {
  512.                         for (RSNPC warrior : getNpcsInRoom("Forgotten warrior")) {
  513.                                 if (!intMatch(warrior.getID(), CHAIN_WARRIORS) && !intMatch(warrior.getID(), PLATE_WARRIORS))
  514.                                         log(BLK, "Unknown warrior ID: " + warrior.getID());
  515.                         }
  516.                 }
  517.                 if (toCheck) {
  518.                         puzzleSolved = false;
  519.                         puzzleRepeat = false;
  520.                         roomSwitch = false;
  521.                         entryDoor = null;
  522.                         if (!unexplored) {
  523.                                 for (RSTile oD : openedDoors) {
  524.                                         if (calc.distanceTo(oD) < 4) {
  525.                                                 entryDoor = oD;
  526.                                                 break;
  527.                                         }
  528.                                 }
  529.                         }
  530.                         puzzleCheck = checkPuzzles();
  531.                         puzzlePoints.clear();
  532.                         if (puzzleCheck != 2 && failSafe())
  533.                                 puzzleCheck = 2;
  534.                         if (puzzleCheck == 2 && secondaryStatus.startsWith("Attempting to"))
  535.                                 puzzleCheck = -1;
  536.                         nearItem = null;
  537.                         nearMonster = null;
  538.                         String puzzleName = status.contains("Puzzle room: ") ? status.substring(status.indexOf(":") + 2) : "Unknown puzzle";
  539.                         if (puzzleCheck == 1 || puzzleSolved) {
  540.                                 if (puzzleTimer != null && puzzleTimer.getElapsed() > 1000) {
  541.                                         log(GN5, "Puzzle room: " + puzzleName + " completed successfully in " + puzzleTimer.toElapsedString() + "!");
  542.                                         puzzleCount++;
  543.                                 }
  544.                                 safeTile = null;
  545.                                 puzzleRooms.remove(targetRoom);
  546.                                 clearedRooms.add(targetRoom);
  547.                                 failTimer = new Timer(random(360000, 480000));
  548.                                 idleTimer = new Timer(0);
  549.                                 finishedRooms.remove(targetRoom);
  550.                                 deathPath.clear();
  551.                         } else if (puzzleCheck == 2) {
  552.                                 if (exit)
  553.                                         return;
  554.                                 if (puzzleTimer != null && (!puzzleTimer.isRunning() || status.contains("reengage"))) {
  555.                                         log.severe("Took too long to solve Puzzle: " + puzzleName + " (" + (puzzleTimer != null ?
  556.  
  557. puzzleTimer.toElapsedString() : "unknown time") + ")");
  558.                                         if (developer)
  559.                                                 env.saveScreenshot(false);
  560.                                         retrace = true;
  561.                                         tempMode = Melee.NONE;
  562.                                         finishedDoors.addAll(newDoors);
  563.                                         finishedRooms.add(targetRoom);
  564.                                         goodDoors.removeAll(finishedDoors);
  565.                                         allDoors.removeAll(finishedDoors);
  566.                                         skipRoom = true;
  567.                                         puzzleTimer = null;
  568.                                         deathPath.clear();
  569.                                         teleHome(false);
  570.                                         secondaryStatus = "";
  571.                                 } else open = true;
  572.                                 safeTile = null;
  573.                                 failTimer = new Timer(random(360000, 480000));
  574.                                 idleTimer = new Timer(0);
  575.                                 return;
  576.                         } else if (puzzleCheck == -1) {
  577.                                 if (failReason.contains("requirements") || failReason.contains("Members") || failReason.contains
  578.  
  579. ("Prayer")) {
  580.                                         log("Unable to complete Puzzle: " + puzzleName + "; Reason: " + failReason + ".");
  581.                                 } else {
  582.                                         log(RED, "Unable to complete Puzzle: " + puzzleName + "; Reason: " + failReason + ".");
  583.                                         if (developer)
  584.                                                 env.saveScreenshot(false);
  585.                                 }
  586.                                 safeTile = null;
  587.                                 retrace = true;
  588.                                 tempMode = Melee.NONE;
  589.                                 finishedDoors.addAll(newDoors);
  590.                                 finishedRooms.add(targetRoom);
  591.                                 goodDoors.removeAll(finishedDoors);
  592.                                 allDoors.removeAll(finishedDoors);
  593.                                 skipRoom = true;
  594.                                 failTimer = new Timer(random(360000, 480000));
  595.                                 idleTimer = new Timer(0);
  596.                                 deathPath.clear();
  597.                         }
  598.                         if (!puzzleRepeat)
  599.                                 finishedPuzzles.add(targetRoom);
  600.                         puzzleTimer = null;
  601.                 }
  602.                 if (puzzleCheck != -1) {
  603.                         if (unexplored && !slayerCheck()) {
  604.                                 for (RSTile door : guardianDoors) {
  605.                                         if (areaContains(targetRoom, door)) {
  606.                                                 log(RED, "Unkillable slayer monster in this room, removing Guardian door");
  607.                                                 finishedDoors.add(door);
  608.                                                 allDoors.remove(door);
  609.                                                 goodDoors.remove(door);
  610.                                         }
  611.                                 }
  612.                         }
  613.                         guardianDoors.removeAll(finishedDoors);
  614.                         if (skipRooms.contains(targetRoom)) {
  615.                                 skipRoom = true;
  616.                         } else if (unexplored) {
  617.                                 if (roomContains(targetRoom, guardianDoors)) {
  618.                                         if (skipRoom) {
  619.                                                 if (npcs.getNearest(monster) != null) {
  620.                                                         if (developer)
  621.                                                                 log("We can't skip through this room!");
  622.                                                         skipRoom = false;
  623.                                                 } else skipRooms.add(targetRoom);
  624.                                         }
  625.                                 } else if (isRushing && !skipRoom && newRoom != null) {
  626.                                         skipRoom = true;
  627.                                         if (npcs.getNearest(monster) != null)
  628.                                                 log("No guardian doors, skipping through this room!");
  629.                                         skipRooms.add(targetRoom);
  630.                                 }
  631.                         }
  632.                         if (skipRoom) {
  633.                                 if (!pickUpAll())
  634.                                         return;
  635.                         } else {
  636.                                 setRetaliate(true);
  637.                                 if (!fightMonsters())
  638.                                         return;
  639.                                 if (!pickUpAll())
  640.                                         return;
  641.                                 eatFood(foods, 45, 50);
  642.                                 buryBones();
  643.                                 if (Option.RANGE.enabled() && invCount(true, arrows) > (random(10, 40)))
  644.                                         doItemAction(inventory.getItem(arrows), "Wield");
  645.                                 if (!pickUpAll())
  646.                                         return;
  647.                                 getCurrentRoom();
  648.                         }
  649.                 }
  650.                 if (failSafe())
  651.                         return;
  652.                 allDoors.removeAll(backDoors);
  653.                 goodDoors.removeAll(backDoors);
  654.                 goodDoors.removeAll(openedDoors);
  655.                 goodDoors.removeAll(finishedDoors);
  656.                 if (puzzleCheck < 1) {
  657.                         if (puzzleCheck == -1 || (!roomContains(targetRoom, allDoors) && !roomContains(targetRoom, goodDoors) && !
  658.  
  659. roomContains(targetRoom, openedDoors))) {
  660.                                 finishedRooms.add(targetRoom);
  661.                                 for (RSTile door : drawDoors) {
  662.                                         if (calc.distanceBetween(door, targetRoom.getNearestTile(door)) < 3)
  663.                                                 finishedDoors.add(door);
  664.                                 }
  665.                         } else if (!clearedRooms.contains(targetRoom)) {
  666.                                 clearedRooms.add(targetRoom);
  667.                         }
  668.                 }
  669.                 allDoors.removeAll(finishedDoors);
  670.                 goodDoors.removeAll(finishedDoors);
  671.                 guardianDoors.removeAll(finishedDoors);
  672.                 openedDoors.removeAll(finishedDoors);
  673.                 secondaryStatus = "";
  674.                 if (finishedRooms.contains(targetRoom)) {
  675.                         retrace = true;
  676.                 } else open = true;
  677.                 newRoom = null;
  678.                 roomHooded = false;
  679.         }
  680.  
  681.         private void finishDungeon() {
  682.                 status = "Completing the dungeon...";
  683.                 RSObject finishedLadder = objects.getNearest(FINISHED_LADDERS);
  684.                 if (finishedLadder != null) {
  685.                         safeTile = finishedLadder.getLocation();
  686.                         log(BLK, "Exit found" + (dungTimer != null ? " in " + dungTimer.toElapsedString() : "") + ", completing the dungeon.");
  687.                         bossTimer = null;
  688.                         failTimer.reset();
  689.                         if (bossRoom == null)
  690.                                 bossRoom = targetRoom;
  691.                         o:while (!interfaces.get(933).isValid()) {
  692.                                 if (failSafe())
  693.                                         return;
  694.                                 if (lastMessage.startsWith("You have already") && idleTimer.getElapsed() > random(45000, 60000)) {
  695.                                         log(RED, "The exit ladder is glitched, unable to finish this dungeon");
  696.                                         exit = true;
  697.                                         return;
  698.                                 }
  699.                                 if (itemReceived) {
  700.                                         if (developer && inventory.containsOneOf(16905, 16909))
  701.                                                 waitForResponse();
  702.                                         improveBossWeapon();
  703.                                         improveWeaponBinding();
  704.                                         itemReceived = false;
  705.                                 } else if (interfaces.get(236).isValid()) {
  706.                                         if (interfaces.getComponent(236, 1).doClick()) {
  707.                                                 for (int i = 0; i < 10; i++) {
  708.                                                         if (interfaces.get(933).isValid())
  709.                                                                 break o;
  710.                                                         sleep(200, 300);
  711.                                                 }
  712.                                         }
  713.                                 } else if ((finishedLadder = objects.getTopAt(safeTile)) != null) {
  714.                                         if (calc.distanceTo(finishedLadder) < 3 && !adjacentTo(finishedLadder))
  715.                                                 walkTo(finishedLadder.getLocation(), 0);
  716.                                         if (smartSleep(doObjAction(finishedLadder, "End-dungeon"), true)) {
  717.                                                 for (int c = 0; c < 10; c++) {
  718.                                                         if (interfaces.get(236).isValid())
  719.                                                                 continue o;
  720.                                                         sleep(100, 200);
  721.                                                 }
  722.                                         }
  723.                                 }
  724.                                 sleep(200, 300);
  725.                         }
  726.                         status = "Waiting for the next dungeon...";
  727.                         dungeonCount++;
  728.                         fNumber++;
  729.                         cProg++;
  730.                         long dungeonTime = dungTimer.getElapsed();
  731.                         if (dungeonTime < fastestMillis) {
  732.                                 if (slowestMillis == 0 && fastestMillis != 999999) {
  733.                                         long millis = fastestMillis;
  734.                                         String time = fastestTime;
  735.                                         slowestMillis = millis;
  736.                                         slowestTime = time;
  737.                                 } else if (password.isEmpty() && dungeonCount > random(5, 20)) {
  738.                                         exit = true;
  739.                                 }
  740.                                 fastestMillis = dungeonTime;
  741.                                 fastestTime = dungTimer.toElapsedString();
  742.                         } else if (dungeonTime > slowestMillis) {
  743.                                 slowestMillis = dungeonTime;
  744.                                 slowestTime = dungTimer.toElapsedString();
  745.                         }
  746.                         tpf = Math.rint(runTimer.getElapsed() * 10 / dungeonCount / 60000) / 10;
  747.                         int trueTime = (int) (dungeonTime / 1000);
  748.                         int truePrestige = prestigeCount - reportedPrestige;
  749.                         reportedPrestige = prestigeCount;
  750.                         clearAll();
  751.                         updateProgress();
  752.                         RSInterface notice = interfaces.get(519);
  753.                         if ((notice.isValid() && fNumber + 1 > maxFloor && notice.getText().toLowerCase().contains("not available at")) || fNumber > maxFloor) {
  754.                                 log(BLU, "Last floor reached, prestiging!");
  755.                                 if (fNumber > maxFloor)
  756.                                         forcePrestige = true;
  757.                                 exit = true;
  758.                         }
  759.                         boolean clicked = false;
  760.                         int tokensGained = 0, expGained = 0;
  761.                         RSInterface finishWindow;
  762.                         o:while ((finishWindow = interfaces.get(933)).isValid()) {
  763.                                 if (failBasic())
  764.                                         break;
  765.                                 if (!clicked && clickComponent(finishWindow.getComponent(13), "")) {
  766.                                         sleep(200, 300);
  767.                                 }
  768.                                 if (clickComponent(finishWindow.getComponent(322), "")) {
  769.                                         sleep(300, 500);
  770.                                         if (!clicked) {
  771.                                                 String tokenString = finishWindow.getComponent(41).getText().replace("%", "").trim();
  772.                                                 String expString = finishWindow.getComponent(39).getText().replace("%", "").trim();
  773.                                                 if (!tokenString.isEmpty())
  774.                                                         tokensGained = Integer.parseInt(tokenString);
  775.                                                 if (!expString.isEmpty())
  776.                                                         expGained = Integer.parseInt(expString);
  777.                                                 tokens += tokensGained;
  778.                                                 if (tokensGained > 0) {
  779.                                                         clicked = true;
  780.                                                         updateSiggy(trueTime, expGained, tokensGained, truePrestige);
  781.                                                 } else log(RED, "Stat uploading failed!");
  782.                                         }
  783.                                         for (int i = 0; i < 40; i++) {
  784.                                                 if (!finishWindow.isValid())
  785.                                                         break o;
  786.                                                 sleep(200, 300);
  787.                                         }
  788.                                 } else
  789.  
  790.                                         sleep(100, 200);
  791.                         }
  792.                         updateProgress();
  793.                         if (failSafe())
  794.                                 return;
  795.                 }
  796.         }
  797.  
  798.         private boolean openNextDoor() {
  799.                 if (roomNumber == 1 && areaContains(startRoom, myLoc()) && (memberWorld || cookReady) && getSaleCount() < 28) {
  800.                         if (memberWorld && bossRoom == null && floor != Floor.FROZEN && !invContains(ANTIPOISON)) {
  801.                                 int coinCount = inventory.getCount(true, COINS);
  802.                                 int poisonCount = coinCount / 200;
  803.                                 if (poisonCount > random(1, 3))
  804.                                         poisonCount = floor == Floor.ABANDONED && rooms.size() == 1 ? random(2, 4) : 2;
  805.                                         if (poisonCount > 0 && inventory.getCount() < random(20, 24))
  806.                                                 shop(464, poisonCount);
  807.                         }
  808.                         unPoison();
  809.                         if ((cookReady || readyToCook()) && getSaleCount() < 24) {
  810.                                 cookReady = false;
  811.                                 failTimer = new Timer(random(360000, 480000));
  812.                                 if (fish != null && logs != null && inventory.contains(TINDERBOX)) {
  813.                                         status = "Cook: " + fish.getName(true) + " on " + logs.getName(true);
  814.                                         log(BLU, status);
  815.                                         idleTimer.reset();
  816.                                         lastMessage = "";
  817.                                         o:for (int c = 0; c < 2; c++) {
  818.                                                 omNomNom();
  819.                                                 if (!inventory.contains(fish.rawID())) {
  820.                                                         RSObject fire = getObjInRoom(FIRES);
  821.                                                         if (getSaleCount() > random(25, 27) || inventory.getCount(true, COINS) < (fire
  822.  
  823. != null ? logs.price() : 0) + fish.price(random(1, 3)))
  824.                                                                 break;
  825.                                                 }
  826.                                                 while (!inventory.isFull() && !lastMessage.contains("inventory space") && !
  827.  
  828. lastMessage.contains("afford") && !lastMessage.contains("enough money")) {
  829.                                                         if (failCheck())
  830.                                                                 break o;
  831.                                                         failInterfaces();
  832.                                                         if (!inventory.contains(TINDERBOX)) {
  833.                                                                 RSGroundItem tinder = getItemInRoom(targetRoom, TINDERBOX);
  834.                                                                 if (tinder != null) {
  835.                                                                         smartSleep(pickUpItem(tinder), false);
  836.                                                                         continue;
  837.                                                                 }
  838.                                                                 break o;
  839.                                                         }
  840.                                                         if (!shop(fish, logs))
  841.                                                                 sleep(400, 800);
  842.                                                 }
  843.                                                 idleTimer.reset();
  844.                                                 boolean textReady = false;
  845.                                                 i:while (inventory.contains(fish.rawID())) {
  846.                                                         if (failCheck())
  847.                                                                 break o;
  848.                                                         failInterfaces();
  849.                                                         boolean toWait = false;
  850.                                                         RSObject fire = getObjInRoom(FIRES);
  851.                                                         if (interfaces.get(740).isValid()) {
  852.                                                                 clickComponent(interfaces.getComponent(740, 3), "Continue");
  853.                                                         } else if (fire == null) {
  854.                                                                 if (!inventory.contains(TINDERBOX))
  855.                                                                         break i;
  856.                                                                 int logID = logs.getID();
  857.                                                                 if (!inventory.contains(logID))
  858.                                                                         logID = getItemID("branches");
  859.                                                                 if (logID == -1) {
  860.                                                                         getItemInRoom(startRoom, UNLIT);
  861.                                                                         if (nearItem != null) {
  862.                                                                                 toWait = pickUpItem(nearItem);
  863.                                                                         } else if (!shop(fish, logs)) {
  864.                                                                                 break o;
  865.                                                                         }
  866.                                                                 } else if (lastMessage.contains("can't light")) {
  867.                                                                         walkAdjacentTo(myLoc(), 2);
  868.                                                                         lastMessage = "";
  869.                                                                 }
  870.                                                                 RSObject obelisk = getObjInRoom("Summoning obelisk");
  871.                                                                 if (calc.distanceTo(startRoom.getCentralTile()) == 1 && (obelisk ==
  872.  
  873. null || calc.distanceBetween(myLoc(), obelisk.getLocation()) == 2)) {
  874.                                                                         walkAdjacentTo(myLoc(), random(1, 3));
  875.                                                                 } else if (logID != -1 && inventory.useItem(TINDERBOX, logID)) {
  876.                                                                         for (int i = 0; i < 10; i++) {
  877.                                                                                 if (getObjInRoom(FIRES) != null)
  878.                                                                                         continue i;
  879.                                                                                 if (player().getAnimation() != -1)
  880.                                                                                         i = 0;
  881.                                                                                 sleep(200, 300);
  882.                                                                         }
  883.                                                                 }
  884.                                                         } else if (player().getAnimation() != 897) {
  885.                                                                 if (textReady && interfaces.getComponent(752, 5).getText().isEmpty())
  886.  
  887. {
  888.                                                                         keyboard.sendText("" + random(22, 99), true);
  889.                                                                         toWait = true;
  890.                                                                         textReady = false;
  891.                                                                 } else if (interfaces.getComponent(944, 78).isValid()) {
  892.                                                                         String amount = inventory.getCount(fish.rawID()) > 10 ? "X" :
  893.  
  894. "10";
  895.                                                                         if (clickComponent(interfaces.getComponent(944, 78), "Make " +
  896.  
  897. amount)) {
  898.                                                                                 if (amount.equals("X")) {
  899.                                                                                         textReady = true;
  900.                                                                                 } else toWait = true;
  901.                                                                         }
  902.                                                                 } else toWait = useItem(fish.rawID(), fire);
  903.                                                         }
  904.                                                         smartSleep(toWait, false);
  905.                                                 }
  906.                                         }
  907.                                 }
  908.                         }
  909.                         makeSpace(true);
  910.                 }
  911.                 if (roomNumber != 1 && !rechargePrayer())
  912.                         return false;
  913.                 nearDoor = null;
  914.                 nearDoor2 = null;
  915.                 newRoom = null;
  916.                 allDoors.removeAll(finishedDoors);
  917.                 allDoors.removeAll(backDoors);
  918.                 goodDoors.removeAll(finishedDoors);
  919.                 goodDoors.removeAll(backDoors);
  920.                 goodDoors.removeAll(openedDoors);
  921.                 openedDoors.removeAll(finishedDoors);
  922.                 for (int i = clearedRooms.size() - 1; i >= 0; i--) {
  923.                         RSArea cRoom = clearedRooms.get(i);
  924.                         if (cRoom != null && !finishedRooms.contains(cRoom)) {
  925.                                 if (!roomContains(cRoom, allDoors) && !roomContains(cRoom, goodDoors) && !roomContains(cRoom,
  926.  
  927. openedDoors)) {
  928.                                         finishedRooms.add(cRoom);
  929.                                         for (RSTile door : drawDoors) {
  930.                                                 if (door != null && calc.distanceBetween(door, cRoom.getNearestTile(door)) < 4)
  931.                                                         finishedDoors.add(door);
  932.                                         }
  933.                                 }
  934.                         }
  935.                 }
  936.                 clearedRooms.removeAll(finishedRooms);
  937.                 openedDoors.removeAll(finishedDoors);
  938.                 allDoors.removeAll(finishedDoors);
  939.                 allDoors.removeAll(backDoors);
  940.                 goodDoors.removeAll(finishedDoors);
  941.                 goodDoors.removeAll(backDoors);
  942.                 goodDoors.removeAll(openedDoors);
  943.                 updateLocks();
  944.                 getCurrentRoom();
  945.                 if (currentRoom != null) {
  946.                         lastMessage = "";
  947.                         oldRoom = getCurrentRoom();
  948.                         if (roomNumber == 1 && aComplexity > 4 && !inventory.contains(GGS) && rooms.size() > 1) {
  949.                                 status = "Teleporting back to where we died";
  950.                                 boolean blockedDest = false;
  951.                                 while (!inventory.contains(GGS) && getItemInRoom(currentRoom, GGS) == null) {
  952.                                         if (failSafe())
  953.                                                 return false;
  954.                                         if (lastMessage.contains("destination") || lastMessage.contains("blocking you")) {
  955.                                                 blockedDest = true;
  956.                                                 break;
  957.                                         }
  958.                                         if (player().getAnimation() == -1) {
  959.                                                 if (!areaContains(startRoom, myLoc()) && !areaContains(groupRoom, myLoc())) {
  960.                                                         unBacktrack(true);
  961.                                                 } else if (telePortal()) {
  962.                                                         waitToStop(false);
  963.                                                 }
  964.                                         }
  965.                                         sleep(300, 400);
  966.                                         getCurrentRoom();
  967.                                 }
  968.                                 if (!blockedDest) {
  969.                                         setTargetRoom(groupRoom != null ? groupRoom : currentRoom);
  970.                                         groupRoom = null;
  971.                                         if (!areaEquals(targetRoom, startRoom)) {
  972.                                                 deathPath.clear();
  973.                                                 if (puzzleRooms.contains(targetRoom) || (bossRoom != null && (bossName.equals
  974.  
  975. ("Sagittare") || bossName.equals("Stomp") || bossName.startsWith("Kal'Ger")))) {
  976.                                                         for (int c = 0; c < 5; c++) {
  977.                                                                 if (inventory.contains(GGS) || inventory.isFull())
  978.                                                                         break;
  979.                                                                 smartSleep(pickUpItem(getItemInRoom(targetRoom, GGS)), false);
  980.                                                         }
  981.                                                 }
  982.                                                 explore = true;
  983.                                                 return true;
  984.                                         }
  985.                                 }
  986.                         }
  987.                         if (disableBossPath && goodDoors.isEmpty()) {
  988.                                 log(BLU, "Remaining openable rooms explored, returning to the boss!");
  989.                                 disableBossPath = false;
  990.                                 if (teleTo(GATESTONE))
  991.                                         return true;
  992.                         }
  993.                         if (!disableBossPath && bossRoom != null && !bossPath.isEmpty()) {
  994.                                 for (RSTile door : bossPath) {
  995.                                         if (areaContains(currentRoom, door)) {
  996.                                                 nearDoor = door;
  997.                                                 doorTimer = new Timer(0);
  998.                                                 idleTimer = new Timer(0);
  999.                                                 crossTheChasm(nearDoor);
  1000.                                                 status = "Opening a door back to the Boss";
  1001.                                                 if (bossDoor != null && nearDoor.equals(bossDoor)) {
  1002.                                                         walkToDoor(1);
  1003.                                                         waitToEat(false);
  1004.                                                         if (floor != Floor.ABANDONED || getNpcInRoom(SKINWEAVER) == null)
  1005.                                                                 omNomNom();
  1006.                                                         setTargetRoom(bossRoom);
  1007.                                                         if (!prepareForBoss())
  1008.                                                                 return false;
  1009.                                                         setTargetRoom(getCurrentRoom());
  1010.                                                 }
  1011.                                                 return openOldDoor();
  1012.                                         }
  1013.                                 }
  1014.                         }
  1015.                         if (groupRoom != null && !deathPath.isEmpty()) {
  1016.                                 if (!areaEquals(currentRoom, groupRoom)) {
  1017.                                         for (RSTile door : deathPath) {
  1018.                                                 if (areaContains(currentRoom, door)) {
  1019.                                                         nearDoor = door;
  1020.                                                         doorTimer = new Timer(0);
  1021.                                                         idleTimer = new Timer(0);
  1022.                                                         crossTheChasm(nearDoor);
  1023.                                                         status = "Opening a door back to where we died";
  1024.                                                         return openOldDoor();
  1025.                                                 }
  1026.                                         }
  1027.                                 }
  1028.                                 deathPath.clear();
  1029.                         }
  1030.                         setTargetRoom(currentRoom);
  1031.                         int doorType = getBestDoor();
  1032.                         if (nearDoor != null) {
  1033.                                 doorTimer = new Timer(0);
  1034.                                 idleTimer = new Timer(0);
  1035.                                 crossTheChasm(destDoor);
  1036.                                 lastMessage = "";
  1037.                                 if (!calc.tileOnScreen(nearDoor))
  1038.                                         walkToDoor(1);
  1039.                                 threadPitch(100);
  1040.                                 switch (doorType) {
  1041.                                 case 1:
  1042.                                         return openBasicDoor();
  1043.                                 case 2:
  1044.                                         return openBlockedDoor();
  1045.                                 case 3:
  1046.                                         return openLockedDoor();
  1047.                                 case 4:
  1048.                                         return openSkillDoor();
  1049.                                 case 5:
  1050.                                         return openOldDoor();
  1051.                                 }
  1052.                         }
  1053.                 }
  1054.                 return false;
  1055.         }
  1056.  
  1057.         private void retraceDungeon() {
  1058.                 if (areaContains(bossRoom, myLoc())) {
  1059.                         bossFight = true;
  1060.                         return;
  1061.                 }
  1062.                 boolean teleBack = false;
  1063.                 restarts++;
  1064.                 restartCount++;
  1065.                 allDoors.removeAll(finishedDoors);
  1066.                 allDoors.removeAll(backDoors);
  1067.                 goodDoors.removeAll(finishedDoors);
  1068.                 goodDoors.removeAll(backDoors);
  1069.                 if (bossRoom != null && getObjInRoom(FINISHED_LADDERS) != null) {
  1070.                         finish = true;
  1071.                         return;
  1072.                 }
  1073.                 if (npcs.getNearest(guardians) == null && !pickUpAll())
  1074.                         return;
  1075.                 if (gateRoom != null) {
  1076.                         updateLocks();
  1077.                         for (RSTile t : goodDoors) {
  1078.                                 if (areaContains(gateRoom, t)) {
  1079.                                         log(PRP, "Gatestone teleporting to the next good door");
  1080.                                         setTargetRoom(gateRoom);
  1081.                                         while (!areaEquals(getCurrentRoom(), targetRoom)) {
  1082.                                                 teleTo(GATESTONE);
  1083.                                         }
  1084.                                         gateRoom = null;
  1085.                                         open = true;
  1086.                                         return;
  1087.                                 }
  1088.                         }
  1089.                 }
  1090.                 if (restartCount > 2) {
  1091.                         if (failSafe())
  1092.                                 return;
  1093.                         if (roomNumber == 1 && !deathPath.isEmpty())
  1094.                                 deathPath.clear();
  1095.                         updateLocks();
  1096.                         if (goodDoors.isEmpty()) {
  1097.                                 if (bossRoom == null) {
  1098.                                         if (skipDoorFound) {
  1099.                                                 log(RED, "An unopenable door is preventing us from solving this dungeon");
  1100.                                         } else {
  1101.                                                 log.severe("No good doors remain.. Aborting dungeon");
  1102.                                                 if (floor == Floor.WARPED)
  1103.                                                         waitForResponse();
  1104.                                                 abortedCount++;
  1105.                                         }
  1106.                                         exit = true;
  1107.                                 } else {
  1108.                                         disableBossPath = false;
  1109.                                         oldDoor = null;
  1110.                                         oldRoom = null;
  1111.                                         open = true;
  1112.                                 }
  1113.                                 return;
  1114.                         } else if (rooms.size() == 1) {
  1115.                                 walkTo(currentRoom.getCentralTile(), 3);
  1116.                         }
  1117.                         if (areaContains(startRoom, myLoc())) {
  1118.                                 oldDoor = null;
  1119.                                 oldRoom = null;
  1120.                                 open = true;
  1121.                                 return;
  1122.                         }
  1123.                         if (disableBossPath)
  1124.                                 disableBossPath = false;
  1125.                         if (restarts > random(aComplexity + 5, aComplexity + 8)) {
  1126.                                 log.severe("Restarted too many times.. Aborting dungeon");
  1127.                                 abortedCount++;
  1128.                                 exitDungeon();
  1129.                                 return;
  1130.                         }
  1131.                         if (!monsterBacktrack())
  1132.                                 return;
  1133.                         restartCount = 0;
  1134.                         teleBack = true;
  1135.                 } else if (unBacktrackable.contains(currentRoom)) {
  1136.                         teleBack = true;
  1137.                 }
  1138.                 if (rooms.size() == 1)
  1139.                         return;
  1140.                 status = "Backtracking through the dungeon";
  1141.                 getCurrentRoom();
  1142.                 if (areaContains(targetRoom, myLoc()) && !finishedRooms.contains(currentRoom) && roomNumber != 1) {
  1143.                         if (castable(Spell.MAKE_GATESTONE)) {
  1144.                                 for (RSTile t : allDoors) {
  1145.                                         if (areaContains(targetRoom, t) && calc.distanceTo(t) > 4) {
  1146.                                                 walkFast(t, 1);
  1147.                                                 break;
  1148.                                         }
  1149.                                 }
  1150.                                 makeGatestone();
  1151.                         }
  1152.                 }
  1153.                 goodDoors.removeAll(backDoors);
  1154.                 goodDoors.removeAll(openedDoors);
  1155.                 nearDoor = null;
  1156.                 nearDoor2 = null;
  1157.                 RSTile backDoor = null;
  1158.                 boolean cantTele = false;
  1159.                 if (npcs.getNearest(guardians) != null) {
  1160.                         if (unBacktrackable.contains(targetRoom)) {
  1161.                                 if (!fightMonsters() || !pickUpAll())
  1162.                                         return;
  1163.                         } else {
  1164.                                 cantTele = true;
  1165.                                 teleBack = false;
  1166.                         }
  1167.                 }
  1168.                 if (targetRoom != null && !teleBack) {
  1169.                         boolean autoSkip = cantTele || (skipRoom && npcs.getNearest(monster) != null);
  1170.                         for (RSTile d : backDoors) {
  1171.                                 if (areaContains(targetRoom, d)) {
  1172.                                         if (autoSkip) {
  1173.                                                 backDoor = d;
  1174.                                         } else {
  1175.                                                 RSArea room = getNextRoom(d);
  1176.                                                 if (room != null && areaEquals(room, startRoom) || roomContains(room, goodDoors))
  1177.                                                         backDoor = d;
  1178.                                         }
  1179.                                         break;
  1180.                                 }
  1181.                         }
  1182.                 }
  1183.                 getCurrentRoom();
  1184.                 if (currentRoom != null && roomNumber != 1) {
  1185.                         crossTheChasm(backDoor);
  1186.                         o:while (areaEquals(currentRoom, targetRoom) && roomNumber != 1) {
  1187.                                 if (failSafe())
  1188.                                         break;
  1189.                                 if (backDoor == null) {
  1190.                                         if (npcs.getNearest(monster) != null) {
  1191.                                                 log("Finishing off monsters before teleporting home");
  1192.                                                 if (!fightMonsters() || !pickUpAll())
  1193.                                                         return;
  1194.                                         } else if (npcs.getNearest(guardians) != null) {
  1195.                                                 log("Bad monster found, backtracking.");
  1196.                                                 backDoor = getBackDoor();
  1197.                                         } else teleHome(false);
  1198.                                 } else {
  1199.                                         RSObject door = objects.getTopAt(backDoor);
  1200.                                         if (door != null) {
  1201.                                                 if (doObjAction(door, "Enter")) {
  1202.                                                         if (combat.isAutoRetaliateEnabled() || !selectTab(Game.TAB_ATTACK, 3))
  1203.                                                                 sleep(600, 800);
  1204.                                                         while (isMoving() && areaContains(targetRoom, myLoc())) {
  1205.                                                                 if (player().getInteracting() != null)
  1206.                                                                         continue o;
  1207.                                                                 sleep(100, 200);
  1208.                                                         }
  1209.                                                         sleep(300, 500);
  1210.                                                 }
  1211.                                         } else backDoor = null;
  1212.                                 }
  1213.                                 sleep(100, 200);
  1214.                                 getCurrentRoom();
  1215.                         }
  1216.                 }
  1217.                 if (bossRoom == null && roomNumber == 1) {
  1218.                         updateLocks();
  1219.                         if (!roomContains(startRoom, goodDoors) && !roomContains(startRoom, openedDoors)) {
  1220.                                 log.severe("No good doors remain at the start room.. Aborting dungeon");
  1221.                                 abortedCount++;
  1222.                                 if (floor == Floor.WARPED)
  1223.                                         waitForResponse();
  1224.                                 exit = true;
  1225.                                 return;
  1226.                         }
  1227.                 }
  1228.                 if (npcs.getNearest(monster) == null)
  1229.                         setRetaliate(true);
  1230.                 oldRoom = targetRoom;
  1231.                 setTargetRoom(currentRoom);
  1232.                 explore = true;
  1233.                 skipRoom = false;
  1234.         }
  1235.  
  1236.         private void startDungeon() {
  1237.                 int c = 0;
  1238.                 status = "Beginning a new dungeon!";
  1239.                 idleTimer = new Timer(0);
  1240.                 log("");
  1241.                 RSObject exitLadder;
  1242.                 if (Option.LOGOUT.enabled() && logoutTimer.getElapsed() > random(14400000, 21000000)) {
  1243.                         status = "Logging out to reset the timer";
  1244.                         log(PRP, "Voluntarily logging out to avoid the 6-hour timer");
  1245.                         while (!game.logout(true)) {
  1246.                                 sleep(100, 300);
  1247.                         }
  1248.                         while (game.getClientState() != 10) {
  1249.                                 if (!authCheck)
  1250.                                         return;
  1251.                                 failLoginScreen();
  1252.                                 sleep(1000, 2000);
  1253.                         }
  1254.                         welcomeBack = false;
  1255.                         logoutTimer = new Timer(0);
  1256.                 }
  1257.                 newDungeon = false;
  1258.                 while ((exitLadder = objects.getNearest(EXIT_LADDERS)) == null || !inDungeon()) {
  1259.                         if (failBasic())
  1260.                                 return;
  1261.                         c++;
  1262.                         if (inDungeon()) {
  1263.                                 if (!authCheck || !goodDungeon())
  1264.                                         return;
  1265.                                 if (c == 11)
  1266.                                         log(RED, "Exit ladder is null!");
  1267.                         }
  1268.                         if (c > 10) {
  1269.                                 inDungeon = false;
  1270.                                 return;
  1271.                         }
  1272.                         sleep(300, 600);
  1273.                 }
  1274.                 if (Option.RUSH.enabled()) {
  1275.                         if (cProg < rushTo) {
  1276.                                 isRushing = true;
  1277.                                 if (aComplexity != rComplexity) {
  1278.                                         log(BLU, "Rushing enabled, exiting to update to your rush Complexity.");
  1279.                                         exit = true;
  1280.                                 }
  1281.                         } else {
  1282.                                 isRushing = false;
  1283.                                 if (!Option.PRESTIGE.enabled()) {
  1284.                                         log(PRP, "Last rush floor reached with Prestiging disabled! Shutting down script..");
  1285.                                         authCheck = false;
  1286.                                 }
  1287.                                 if (aComplexity != complexity) {
  1288.                                         log(BLU, "Last rush floor reached, exiting to change to your main Complexity.");
  1289.                                         exit = true;
  1290.                                 }
  1291.                         }
  1292.                 }
  1293.                 if (exit || !authCheck || !goodDungeon())
  1294.                         return;
  1295.                 log(BLK, "Starting a new dungeon");
  1296.                 clearAll();
  1297.                 walking.setRun(true);
  1298.                 ridItem(primaryWep, "Wield");
  1299.                 while (!getNewRoomArea()) {
  1300.                         if (failSafe())
  1301.                                 return;
  1302.                         if (developer)
  1303.                                 log.severe("Reattempting to define the startroom area.");
  1304.                         sleep(500, 700);
  1305.                 }
  1306.                 getCurrentRoom();
  1307.                 startRoom = currentRoom;
  1308.                 RSComponent complexityMenu = interfaces.getComponent(519, 1);
  1309.                 if (complexityMenu.isValid() && complexityMenu.getText().indexOf(":") > 0) {
  1310.                         String menuText = complexityMenu.getText();
  1311.                         String complexityText = "" + menuText.charAt(menuText.indexOf(":") - 1);
  1312.                         if (Integer.parseInt(complexityText) < 7)
  1313.                                 aComplexity = Integer.parseInt(complexityText);
  1314.                 } else if (inventory.contains(GGS) || groundItems.getNearest(GGS) != null) {
  1315.                         aComplexity = 6;
  1316.                 } else if (getObjInRoom("Summoning obelisk") != null) {
  1317.                         aComplexity = 6;
  1318.                 } else if (getObjInRoom("Spinning wheel") != null) {
  1319.                         aComplexity = 4;
  1320.                 } else if (getObjInRoom("Runecrafting altar") != null) {
  1321.                         aComplexity = 3;
  1322.                 } else if (getNpcInRoom(SMUGGLER) != null) {
  1323.                         aComplexity = 1;
  1324.                 }
  1325.                 if (!Option.RUSH.enabled())
  1326.                         complexity = aComplexity;
  1327.                 switch (exitLadder.getID()) {
  1328.                 case 51156:
  1329.                         floor = Floor.FROZEN;
  1330.                         if (Option.STYLE_SWAP.enabled()) {
  1331.                                 if (Melee.CRUSH.enabled()) {
  1332.                                         attackMode = Melee.CRUSH.index();
  1333.                                 } else attackMode = valueOf(defaultMode);
  1334.                         }
  1335.                         break;
  1336.                 case 50604:
  1337.                         floor = Floor.ABANDONED;
  1338.                         if (Option.STYLE_SWAP.enabled()) {
  1339.                                 if (Melee.SLASH.enabled()) {
  1340.                                         attackMode = Melee.SLASH.index();
  1341.                                 } else if (Melee.STAB.enabled()) {
  1342.                                         attackMode = Melee.STAB.index();
  1343.                                 } else attackMode = valueOf(defaultMode);
  1344.                         }
  1345.                         break;
  1346.                 case 51704:
  1347.                         floor = Floor.FURNISHED;
  1348.                         if (Option.STYLE_SWAP.enabled()) {
  1349.                                 if (Melee.SLASH.enabled()) {
  1350.                                         attackMode = Melee.SLASH.index();
  1351.                                 } else if (Melee.CRUSH.enabled()) {
  1352.                                         attackMode = Melee.CRUSH.index();
  1353.                                 } else attackMode = valueOf(defaultMode);
  1354.                         }
  1355.                         break;
  1356.                 case 54675:
  1357.                         floor = Floor.OCCULT;
  1358.                         if (Option.STYLE_SWAP.enabled()) {
  1359.                                 if (Melee.SLASH.enabled()) {
  1360.                                         attackMode = Melee.SLASH.index();
  1361.                                 } else if (Melee.STAB.enabled()) {
  1362.                                         attackMode = Melee.STAB.index();
  1363.                                 } else attackMode = valueOf(defaultMode);
  1364.                         }
  1365.                         break;
  1366.                 case 56149:
  1367.                         floor = Floor.WARPED;
  1368.                         if (Option.STYLE_SWAP.enabled()) {
  1369.                                 if (Melee.SLASH.enabled()) {
  1370.                                         attackMode = Melee.SLASH.index();
  1371.                                 } else attackMode = valueOf(defaultMode);
  1372.                         }
  1373.                         break;
  1374.                 default:
  1375.                         log(RED, "Unable to detect the floor type, returning to a lower floor.");
  1376.                         exit = true;
  1377.                         return;
  1378.                 }
  1379.                 runSettings();
  1380.                 if (!authCheck)
  1381.                         return;
  1382.                 getNewDoorTiles();
  1383.                 if (skipDoorFound) {
  1384.                         log(RED, "A skipped door type is in the start room, trying another dungeon.");
  1385.                         exit = true;
  1386.                         return;
  1387.                 }
  1388.                 idleTimer = new Timer(0);
  1389.                 if (failSafe())
  1390.                         return;
  1391.                 if (!Option.RUSH.enabled() && complexity != aComplexity)
  1392.                         log(RED, "Complexity mismatch - selected: " + complexity + ", actual: " + aComplexity);
  1393.                 if (!Option.STYLE_SWAP.enabled())
  1394.                         attackMode = valueOf(defaultMode);
  1395.                 dungTimer = new Timer(0);
  1396.                 threadPitch(100);
  1397.                 if (aComplexity < 5)
  1398.                         dropAllExceptSaves();
  1399.                 setRetaliate(true);
  1400.                 selectTab(Game.TAB_INVENTORY, 3);
  1401.                 exploreRoom();
  1402.                 if (Option.SECONDARY_RANGE.enabled() && secondaryWep < 1 && arrows > 0 && floor == Floor.OCCULT) {
  1403.                         int bowId = getItemID("longbow") > 0 ? getItemID("longbow") : getItemID("shortbow");
  1404.                         if (bowId > 0) {
  1405.                                 log(BLU, "Enabling secondary range with bow ID: " + bowId + " for this Occult floor.");
  1406.                                 secondaryWep = bowId;
  1407.                                 bounds.add((Integer) bowId);
  1408.                                 Style.RANGE.set(true);
  1409.                         }
  1410.                 }
  1411.                 if (aComplexity > 4) {
  1412.                         if (!inventory.containsAll(TOOLS)) {
  1413.                                 secondaryStatus = "Purchasing a toolkit";
  1414.                                 o:while (!inventory.containsAll(TOOLS)) {
  1415.                                         if (failSafe())
  1416.                                                 return;
  1417.                                         if (inventory.contains(TOOLKIT)) {
  1418.                                                 makeSpace(true);
  1419.                                                 inventory.getItem(TOOLKIT).doClick(true);
  1420.                                                 for (int i = 0; i < 10; i++) {
  1421.                                                         if (inventory.containsAll(TOOLS))
  1422.                                                                 break o;
  1423.                                                         sleep(100, 130);
  1424.                                                 }
  1425.                                         } else if (!shopToolkit()) {
  1426.                                                 if (exit)
  1427.                                                         return;
  1428.                                                 sleep(200, 400);
  1429.                                         }
  1430.                                 }
  1431.                         }
  1432.                         secondaryStatus = "";
  1433.                         ridItem(primaryWep, "Wield");
  1434.                 }
  1435.         }
  1436.  
  1437.         final static int[] RUNEBOUND_ACTIVES = { 53977, 53979, 53978 };
  1438.         final static int[] GRAVE_PADS = { 54444, 54450, 54458 };
  1439.         final static int[] BLINK_PILLARS = { 32184, 32196, 32202, 32195, 32201, 32231 };
  1440.  
  1441.         final static int BEHEMOTH_CARCASS = 49283;
  1442.         final int[] ACTIVE_STONES = { 49278, 49279, 49276, 49277, 49274, 49275 };
  1443.         final int[] BLUE_STONES = { 49278, 49279 }, GREEN_STONES = { 49276, 49277 }, RED_STONES = { 49274, 49275 };
  1444.         final int[][] ALL_STONES = { BLUE_STONES, GREEN_STONES, RED_STONES };
  1445.         final int[] K_SPEC_ANIMS = { 13426, 13427, 13428, 13429 }, K_START_ANIMS = { 13427, 13429 };
  1446.         final int BEHEMOTH_WALL = 51180, BLOCK_ROCKS = 49268, FALLING_ROCKS = 49269;
  1447.  
  1448.         final int[] RAISED_PILLARS = { 32184, 32196, 32202 };
  1449.         final int[] SUNKEN_PILLARS = { 32195, 32201, 32231 };
  1450.  
  1451.         private void frozenBoss() {
  1452.                 RSObject carcass = getObjInRoom(BEHEMOTH_CARCASS);
  1453.                 if (carcass != null) {
  1454.                         RSNPC behemoth = getNpcInRoom("Gluttonous behemoth");
  1455.                         setBoss("Gluttonous Behemoth", true);
  1456.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  1457.                         setRetaliate(true);
  1458.                         safeTile = carcass.getLocation();
  1459.                         RSTile wall = getNearestObjTo(safeTile, BEHEMOTH_WALL);
  1460.                         if (wall != null) {
  1461.                                 for (RSTile t : getAdjacentTo(safeTile)) {
  1462.                                         int wDist = (int) calc.distanceBetween(t, wall);
  1463.                                         if (wDist == 3) {
  1464.                                                 safeTile = t;
  1465.                                                 break;
  1466.                                         }
  1467.                                 }
  1468.                         }
  1469.                         walkToMap(safeTile, 0);
  1470.                         setPrayer(true, Style.RANGE, true);
  1471.                         updateFightMode();
  1472.                         while (getObjInRoom(FINISHED_LADDERS) == null) {
  1473.                                 if (failSafe())
  1474.                                         return;
  1475.                                 if (behemoth != null && behemoth.getAnimation() == 13720) {
  1476.                                         secondaryStatus = "Waiting for the behemoth to eat";
  1477.                                         while (behemoth != null && behemoth.getAnimation() == 13720) {
  1478.                                                 topUp(true);
  1479.                                                 sleep(300, 500);
  1480.                                         }
  1481.                                         secondaryStatus = "";
  1482.                                 }
  1483.                                 if (calc.distanceTo(safeTile) > 1) {
  1484.                                         secondaryStatus = "Repositioning to guard the food";
  1485.                                         if (!isMoving())
  1486.                                                 walkTo(safeTile, 0);
  1487.                                         waitToStop(false);
  1488.                                         attackBoss(behemoth, true);
  1489.                                         secondaryStatus = "";
  1490.                                 }
  1491.                                 eatFood(topFoods, 50, 60);
  1492.                                 sleep(200, 300);
  1493.                         }
  1494.                 } else if (bossName.equals("Astea Frostweb") || getNpcInRoom("Frostweb") != null) {
  1495.                         RSNPC frostWeb;
  1496.                         setBoss("Astea Frostweb", false);
  1497.                         boolean invincible = false;
  1498.                         setPrayer(true, Style.MAGIC, true);
  1499.                         swapStyle(Style.RANGE);
  1500.                         tempMode = Melee.SLASH;
  1501.                         while (getObjInRoom(FINISHED_LADDERS) == null) {
  1502.                                 if (failSafe())
  1503.                                         return;
  1504.                                 if ((frostWeb = getNpcInRoom("Frostweb")) != null) {
  1505.                                         int style = combatStyle == Style.MELEE ? 0 : combatStyle == Style.RANGE ? 2 : 1;
  1506.                                         invincible = isProtecting(frostWeb, 9964, style);
  1507.                                         secondaryStatus = invincible ? "Astea is protecting against us!" : "";
  1508.                                         if (lastMessage.contains("A magical force")) {
  1509.                                                 lastMessage = "";
  1510.                                                 topUp(true);
  1511.                                         } else if (unreachable) {
  1512.                                                 if (combatStyle == Style.MELEE && !isEdgeTile(frostWeb.getLocation())) {
  1513.                                                         RSNPC spider = getNpcInRoom("spider");
  1514.                                                         if (spider != null) {
  1515.                                                                 if (attackNpc(spider))
  1516.                                                                         sleep(500, 900);
  1517.                                                         } else topUp(true);
  1518.                                                 } else topUp(true);
  1519.                                                 unreachable = false;
  1520.                                         } else if (invincible) {
  1521.                                                 if (!swapStyle(true, Style.RANGE, Style.MELEE)) {
  1522.                                                         RSNPC spider = getNpcInRoom("spider");
  1523.                                                         if (spider != null) {
  1524.                                                                 if (attackNpc(spider))
  1525.                                                                         sleep(500, 800);
  1526.                                                         } else if (!topUp(false) && combatStyle == Style.MELEE && calc.distanceTo
  1527.  
  1528. (frostWeb) > 1) {
  1529.                                                                 attackBoss(frostWeb, false);
  1530.                                                         }
  1531.                                                 }
  1532.                                                 unreachable = false;
  1533.                                         } else attackBoss(frostWeb, false);
  1534.                                         eatFood(topFoods, 50, 55);
  1535.                                 }
  1536.                                 sleep(200, 300);
  1537.                         }
  1538.                 } else if (bossName.equals("Icy Bones") || getNpcInRoom("Bones") != null) {
  1539.                         setBoss("Icy Bones", false);
  1540.                         setPrayer(true, Style.MELEE, true);
  1541.                         tempMode = Melee.CRUSH;
  1542.                         if (!genericBossFight())
  1543.                                 return;
  1544.                 } else if (bossName.equals("Luminescent Icefiend") || getNpcInRoom("Luminescent") != null) {
  1545.                         RSNPC iceFiend;
  1546.                         setBoss("Luminescent Icefiend", true);
  1547.                         RSTile oldCorner = null;
  1548.                         setPrayer(false, Style.RANGE, true);
  1549.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  1550.                         while (getObjInRoom(FINISHED_LADDERS) == null) {
  1551.                                 if (failSafe())
  1552.                                         return;
  1553.                                 if ((iceFiend = getNpcInRoom("Luminescent")) != null) {
  1554.                                         if (iceFiend.getAnimation() == 13338) {
  1555.                                                 RSObject corner = getObjInRoom(51300);
  1556.                                                 if (corner == null || walking.getEnergy() < random(8, 13)) {
  1557.                                                         secondaryStatus = corner != null ? "Out of run.. Eating after the attack" :
  1558.  
  1559. "Eating after the attack";
  1560.                                                         while (iceFiend.getAnimation() == 13338) {
  1561.                                                                 sleep(100, 200);
  1562.                                                         }
  1563.                                                 } else {
  1564.                                                         secondaryStatus = "Dodging the icicles!";
  1565.                                                         RSObject next = getNextObj(corner, 51300);
  1566.                                                         if (next != null)
  1567.                                                                 oldCorner = next.getLocation();
  1568.                                                         if (!walking.isRunEnabled()) {
  1569.                                                                 walking.setRun(true);
  1570.                                                         } else sleep(400, 600);
  1571.                                                         safeTile = corner.getLocation();
  1572.                                                         sleep(300, 400);
  1573.                                                         walkTo(safeTile, 1);
  1574.                                                         int dist = calc.distanceTo(safeTile);
  1575.                                                         sleep(dist * 100, dist * 150);
  1576.                                                         while (iceFiend != null && iceFiend.getAnimation() == 13338 && areaContains
  1577.  
  1578. (bossRoom, myLoc())) {
  1579.                                                                 if (failSafe())
  1580.                                                                         return;
  1581.                                                                 if (safeTile != null) {
  1582.                                                                         walkToMap(safeTile, 1);
  1583.                                                                         waitToStart(true);
  1584.                                                                         idleTimer = new Timer(0);
  1585.                                                                         while (calc.distanceBetween(myLoc(), safeTile) > 8.5) {
  1586.                                                                                 if (failCheck())
  1587.                                                                                         break;
  1588.                                                                                 if (!isMoving() || player().getAnimation() != -1) {
  1589.                                                                                         walkToMap(safeTile, 1);
  1590.                                                                                         if (!isMoving())
  1591.                                                                                                 sleep(400, 600);
  1592.                                                                                         sleep(500, 800);
  1593.                                                                                 }
  1594.                                                                                 sleep(30, 50);
  1595.                                                                         }
  1596.                                                                 }
  1597.                                                                 if (iceFiend.getAnimation() != 13338)
  1598.                                                                         break;
  1599.                                                                 for (RSObject o : getObjsInRoom(51300)) {
  1600.                                                                         if (o != null) {
  1601.                                                                                 RSTile oTile = o.getLocation();
  1602.                                                                                 if (oldCorner != null && oTile.equals(oldCorner))
  1603.                                                                                         continue;
  1604.                                                                                 if (safeTile == null || (!oTile.equals(safeTile) &&
  1605.  
  1606. (oTile.getX() == safeTile.getX() || oTile.getY() == safeTile.getY()))) {
  1607.                                                                                         oldCorner = safeTile;
  1608.                                                                                         safeTile = oTile;
  1609.                                                                                         break;
  1610.                                                                                 }
  1611.                                                                         }
  1612.                                                                 }
  1613.                                                         }
  1614.                                                         eatFood(topFoods, 15, 15);
  1615.                                                         if (iceFiend != null)
  1616.                                                                 walkTo(iceFiend.getLocation(), 1);
  1617.                                                         safeTile = null;
  1618.                                                 }
  1619.                                                 secondaryStatus = "";
  1620.                                         }
  1621.                                         attackBoss(iceFiend, false);
  1622.                                         eatFood(topFoods, 40, 40);
  1623.                                 }
  1624.                                 sleep(200, 300);
  1625.                         }
  1626.                 } else if (bossName.equals("Plane-Freezer Lakhrahnaz") || getNpcInRoom("Lakhrahnaz") != null) {
  1627.                         RSNPC planeFreezer;
  1628.                         setBoss("Plane-Freezer Lakhrahnaz", false);
  1629.                         swapStyle(Style.RANGE);
  1630.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  1631.                         setPrayer(false, Style.RANGE, true);
  1632.                         while (getObjInRoom(FINISHED_LADDERS) == null) {
  1633.                                 if (failSafe())
  1634.                                         return;
  1635.                                 if ((planeFreezer = getNpcInRoom("Lakhrahnaz")) != null) {
  1636.                                         if (unreachable || (combatStyle == Style.MELEE && calc.distanceTo(planeFreezer) > 2)) {
  1637.                                                 if (!isMoving()) {
  1638.                                                         walkTo(planeFreezer.getLocation(), 0);
  1639.                                                         unreachable = false;
  1640.                                                 }
  1641.                                         }
  1642.                                         RSObject corner = getObjInRoom(SNOWY_CORNER);
  1643.                                         if (!isAttacking(planeFreezer) && calc.distanceTo(planeFreezer) < 3 && !isMoving() && corner
  1644.  
  1645. != null && calc.distanceTo(corner) < 3) {
  1646.                                                 walkTo(myLoc(), 2);
  1647.                                                 waitToStart(false);
  1648.                                         }
  1649.                                         attackBoss(planeFreezer, true);
  1650.                                         eatFood(topFoods, 45, 55);
  1651.                                 }
  1652.                                 sleep(100, 200);
  1653.                         }
  1654.                         RSObject finishedLadder = objects.getNearest(FINISHED_LADDERS);
  1655.                         if (finishedLadder != null) {
  1656.                                 RSObject corner;
  1657.                                 RSTile finishTile = finishedLadder.getLocation();
  1658.                                 walkToMap(finishTile, 1);
  1659.                                 waitToEat(false);
  1660.                                 secondaryStatus = "Navigating to the nearest corner";
  1661.                                 while ((corner = getObjInRoom(SNOWY_STOPS)) != null && !myLoc().equals(safeTile = corner.getLocation
  1662.  
  1663. ()) && calc.distanceTo(finishTile) > 1) {
  1664.                                         if (failSafe())
  1665.                                                 return;
  1666.                                         if (!isMoving())
  1667.                                                 walkTo(safeTile, 0);
  1668.                                         if (!isMoving())
  1669.                                                 walkTo(myLoc(), 5);
  1670.                                         sleep(300, 400);
  1671.                                 }
  1672.                                 walkToMap(safeTile = finishTile, 0);
  1673.                         }
  1674.                 } else if (bossName.equals("Blood Chiller") || getNpcInRoom("Bloodchiller") != null) {
  1675.                         setBoss("Blood Chiller", true);
  1676.                         setPrayer(true, Style.MAGIC, true);
  1677.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.CRUSH;
  1678.                         if (!genericBossFight())
  1679.                                 return;
  1680.                 } else if (!unknownBossFight()) {
  1681.                         return;
  1682.                 }
  1683.                 finish = true;
  1684.         }
  1685.  
  1686.         private void abandonedBoss() {
  1687.                 if (bossName.equals("Skeletal Hoarde") || getNpcInRoom(SKINWEAVER) != null) {
  1688.                         RSNPC skinweaver = getNpcInRoom(SKINWEAVER);
  1689.                         setBoss("Skeletal Hoarde", true);
  1690.                         boolean tunnelReady = false;
  1691.                         RSObject tunnel = null;
  1692.                         setRetaliate(combatStyle !=Style.MELEE);
  1693.                         setPrayer(false, Style.RANGE, true);
  1694.                         tempMode = Melee.CRUSH;
  1695.                         updateFightMode();
  1696.                         selectTab(Game.TAB_INVENTORY, 3);
  1697.                         while (getObjInRoom(FINISHED_LADDERS) == null) {
  1698.                                 if (failSafe())
  1699.                                         return;
  1700.                                 if (skinweaver != null) {
  1701.                                         String skinMsg = skinweaver.getMessage();
  1702.                                         if (skinMsg != null && !skinMsg.contains("Chat later"))
  1703.                                                 tunnelReady = true;
  1704.                                         tunnel = getObjInRoom("Tunnel");
  1705.                                         if (tunnelReady && tunnel != null) {
  1706.                                                 secondaryStatus = "Blocking the next tunnel!";
  1707.                                                 safeTile = tunnel.getLocation();
  1708.                                                 lastMessage = "";
  1709.                                                 doObjAction(tunnel, "Block");
  1710.                                                 waitToStart(false);
  1711.                                                 while (tunnel != null) {
  1712.                                                         if (failSafe())
  1713.                                                                 return;
  1714.                                                         if (lastMessage.contains("fully powered"))
  1715.                                                                 break;
  1716.                                                         if (calc.distanceTo(safeTile) > 4)
  1717.                                                                 walkTo(safeTile, 1);
  1718.                                                         if (doObjAction(tunnel, "Block"))
  1719.                                                                 waitToObject(false);
  1720.                                                         eatFood(topFoods, 20, 20);
  1721.                                                         sleep(50, 100);
  1722.                                                         if (!getName(tunnel = objects.getTopAt(safeTile)).equals("Tunnel"))
  1723.                                                                 break;
  1724.                                                 }
  1725.                                                 secondaryStatus = "";
  1726.                                                 if (!lastMessage.contains("fully powered")) {
  1727.                                                         if (bossStage < 5)
  1728.                                                                 bossStage++;
  1729.                                                         status = "Skeletal Hoarde: " + bossStage + " of 5 blocked";
  1730.                                                 }
  1731.                                                 lastMessage = "";
  1732.                                                 safeTile = null;
  1733.                                                 if (combat.getHealth() > 40)
  1734.                                                         doNpcAction(npcs.getNearest(monster), "Attack");
  1735.                                                 tunnelReady = false;
  1736.                                         }
  1737.                                         if (tunnel == null && npcs.getNearest(guardians) == null) {
  1738.                                                 doNpcAction(skinweaver, "Talk-To");
  1739.                                                 sleep(700, 1100);
  1740.                                         } else if (combat.getHealth() < 30 + npcs.getAll(guardians).length * 3 + aComplexity +
  1741.  
  1742. (calc.distanceTo(skinweaver) / 3)) {
  1743.                                                 safeTile = skinweaver.getLocation();
  1744.                                                 while (combat.getHealth() < 95 && getHpPercent(player()) < 95) {
  1745.                                                         if (failSafe())
  1746.                                                                 return;
  1747.                                                         skinMsg = skinweaver.getMessage();
  1748.                                                         if (skinMsg != null && !skinMsg.contains("Chat later"))
  1749.                                                                 tunnelReady = true;
  1750.                                                         nearMonster = npcs.getNearest(monster);
  1751.                                                         eatFood(topFoods, 20, 20);
  1752.                                                         if (calc.distanceTo(skinweaver) > 3 || myLoc().equals(safeTile)) {
  1753.                                                                 walkAdjacentTo(safeTile, 2);
  1754.                                                         } else if (nearMonster != null && calc.distanceBetween(safeTile,
  1755.  
  1756. nearMonster.getLocation()) < 5) {
  1757.                                                                 attackBoss(nearMonster, false);
  1758.                                                         }
  1759.                                                         sleep(300, 600);
  1760.                                                 }
  1761.                                                 sleep(1400, 1800);
  1762.                                                 safeTile = null;
  1763.                                         }
  1764.                                 } else skinweaver = getNpcInRoom(SKINWEAVER);
  1765.                                 attackBoss(npcs.getNearest(monster), false);
  1766.                                 eatFood(topFoods, 20, 20);
  1767.                                 sleep(200, 400);
  1768.                         }
  1769.                 } else if (bossName.equals("Hobgoblin Geomancer") || getNpcInRoom("Geomancer") != null) {
  1770.                         setBoss("Hobgoblin Geomancer", true);
  1771.                         setPrayer(true, null, false);
  1772.                         tempMode = Melee.SLASH;
  1773.                         if (!genericBossFight())
  1774.                                 return;
  1775.                 } else if (bossName.equals("Bulwark Beast") || getNpcInRoom("Bulwark beast") != null) {
  1776.                         boolean pickWielded = false;
  1777.                         setBoss("Bulwark Beast", true);
  1778.                         RSNPC bulwark = getNpcInRoom("Bulwark beast");
  1779.                         if (bulwark != null) {
  1780.                                 if (bossID < 1)
  1781.                                         bossID = bulwark.getID();
  1782.                                 status = "Killing the Bulwark Beast" + (bulwark.getID() == bossID ? " (armored)" : "!");
  1783.                         }
  1784.                         setPrayer(combatStyle == Style.MAGIC, Style.MAGIC, true);
  1785.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.CRUSH;
  1786.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  1787.                                 if (failSafe())
  1788.                                         return;
  1789.                                 if ((bulwark = getNpcInRoom("Bulwark beast")) != null && combatStyle != Style.MAGIC) {
  1790.                                         RSItem pWeapon = inventory.getItem(primaryWep);
  1791.                                         if (bulwark.getID() == bossID) {
  1792.                                                 RSItem pickAxe = inventory.getItem(PICKAXE);
  1793.                                                 if (!pickWielded && pickAxe == null) {
  1794.                                                         if (equipment.containsAll(PICKAXE)) {
  1795.                                                                 pickWielded = true;
  1796.                                                         } else {
  1797.                                                                 secondaryStatus = "Pulling a pickaxe from the stone";
  1798.                                                                 setRetaliate(false);
  1799.                                                                 RSObject pickRock = getObjInRoom(49295);
  1800.                                                                 while (pickRock != null && !inventory.contains(PICKAXE)) {
  1801.                                                                         if (isDead())
  1802.                                                                                 break;
  1803.                                                                         doObjAction(pickRock, "Take-pickaxe");
  1804.                                                                         sleep(500, 800);
  1805.                                                                 }
  1806.                                                                 secondaryStatus = "";
  1807.                                                         }
  1808.                                                 }
  1809.                                                 if (pickAxe != null && pWeapon == null) {
  1810.                                                         if (ridItem(PICKAXE, "Wield") || inventory.contains(primaryWep))
  1811.                                                                 pickWielded = true;
  1812.                                                 }
  1813.                                         } else if (pWeapon != null) {
  1814.                                                 status = "Killing the Bulwark Beast!";
  1815.                                                 ridItem(primaryWep, "Wield");
  1816.                                         }
  1817.                                 }
  1818.                                 if (attackBoss(bulwark, true))
  1819.                                         setRetaliate(true);
  1820.                                 eatFood(topFoods, 50, 60);
  1821.                                 sleep(200, 300);
  1822.                         }
  1823.                 } else if (bossName.equals("Unholy Cursebearer") || getNpcInRoom("cursebearer") != null) {
  1824.                         setBoss("Unholy Cursebearer", true);
  1825.                         setPrayer(true, Style.MELEE, true);
  1826.                         tempMode = Melee.CRUSH;
  1827.                         if (!genericBossFight())
  1828.                                 return;
  1829.                 } else if (bossName.equals("Shadow-Forger Ihlakhizan") || getNpcInRoom("Ihlakhizan") != null) {
  1830.                         RSNPC ihlakhizan = getNpcInRoom("Ihlakhizan");
  1831.                         setBoss("Shadow-Forger", true);
  1832.                         setPrayer(true, combatStyle == Style.MELEE ? Style.MELEE : Style.MAGIC, true);
  1833.                         tempMode = Melee.STAB;
  1834.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  1835.                                 if (failSafe())
  1836.                                         return;
  1837.                                 if (ihlakhizan != null) {
  1838.                                         if (ihlakhizan.getAnimation() == 13030) {
  1839.                                                 if (safeTile == null || calc.distanceTo(safeTile) > 3) {
  1840.                                                         RSObject pillar = getObjInRoom(51110), corner = getObjInRoom(50749);
  1841.                                                         if (pillar != null && corner != null) {
  1842.                                                                 int pX = pillar.getLocation().getX(), pY = pillar.getLocation().getY
  1843.  
  1844. ();
  1845.                                                                 int cX = corner.getLocation().getX(), cY = corner.getLocation().getY
  1846.  
  1847. ();
  1848.                                                                 safeTile = new RSTile(pX + (cX - pX) / 4, pY + (cY - pY) / 4);
  1849.                                                         }
  1850.                                                 }
  1851.                                                 walkTo(safeTile, random(0, 2));
  1852.                                                 sleep(100, 600);
  1853.                                                 while (ihlakhizan.getAnimation() == 13030 && !isDead()) {
  1854.                                                         sleep(200, 400);
  1855.                                                         if (calc.distanceTo(safeTile) > 1 && walkTo(safeTile, 1))
  1856.                                                                 sleep(600, 800);
  1857.                                                 }
  1858.                                         } else {
  1859.                                                 attackBoss(ihlakhizan, true);
  1860.                                                 if (!roomSwitch && ihlakhizan.getAnimation() != 13030)
  1861.                                                         eatFood(topFoods, 50, 0);
  1862.                                         }
  1863.                                 }
  1864.                                 sleep(100, 300);
  1865.                         }
  1866.                 } else if (bossName.equals("Bal'lak the Pummeller") || getNpcInRoom("Pummeller") != null) {
  1867.                         RSNPC pummeller = getNpcInRoom("Pummeller");
  1868.                         setBoss("Bal'lak the Pummeller", false);
  1869.                         int maxDef = random(80, 120);
  1870.                         setPrayer(true, Style.MELEE, true);
  1871.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  1872.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  1873.                                 if (failSafe())
  1874.                                         return;
  1875.                                 if (pummeller != null) {
  1876.                                         RSObject slime = getObjInRoom(49298);
  1877.                                         if (slime != null && calc.distanceTo(slime) < 3) {
  1878.                                                 if (!isMoving())
  1879.                                                         walkToMap(pummeller.getLocation(), 1);
  1880.                                                 waitToStart(false);
  1881.                                         } else if (interfaces.getComponent(945, 17).getRelativeX() < maxDef) {
  1882.                                                 eatFood(topFoods, 50, 60);
  1883.                                         } else if (!inventory.contains(GGS) && getItemInRoom(bossRoom, GGS) == null) {
  1884.                                                 secondaryStatus = "Teleporting out, degenerating defense";
  1885.                                                 if (teleTo(GGS)) {
  1886.                                                         omNomNom();
  1887.                                                         if (readyToCook()) {
  1888.                                                                 teleHome(true);
  1889.                                                                 return;
  1890.                                                         }
  1891.                                                         defenseDegenerate();
  1892.                                                         unBacktrack(true);
  1893.                                                 }
  1894.                                                 secondaryStatus = "";
  1895.                                         }
  1896.                                         attackBoss(pummeller, true);
  1897.                                 }
  1898.                                 sleep(100, 200);
  1899.                         }
  1900.                 } else if (!unknownBossFight()) {
  1901.                         return;
  1902.                 }
  1903.                 finish = true;
  1904.         }
  1905.  
  1906.         private void furnishedBoss() {
  1907.                 if (bossName.equals("Rammernaut") || getNpcInRoom("Rammernaut") != null) {
  1908.                         RSNPC rammernaut = getNpcInRoom("Rammernaut");
  1909.                         setBoss("Rammernaut", false);
  1910.                         swapStyle(Style.MAGIC);
  1911.                         tempMode = Melee.STAB;
  1912.                         prayTimer = new Timer(random(4000, 6000));
  1913.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  1914.                                 if (failSafe())
  1915.                                         return;
  1916.                                 if (rammernaut != null) {
  1917.                                         String shout = rammernaut.getMessage();
  1918.                                         if (shout != null && shout.contains("CHAA")) {
  1919.                                                 secondaryStatus = "Running for cover!";
  1920.                                                 safeTile = safeCorner(rammernaut.getLocation());
  1921.                                                 if (safeTile != null) {
  1922.                                                         walkToMap(safeTile, 0);
  1923.                                                         for (int i = 0; i < 7 && !isDead(); i++) {
  1924.                                                                 if (rammernaut != null && rammernaut.getMessage() == null)
  1925.                                                                         break;
  1926.                                                                 if (!isMoving() && calc.distanceTo(safeTile) < 3 && calc.distanceTo
  1927.  
  1928. (rammernaut) < 3)
  1929.                                                                         break;
  1930.                                                                 if (!topUp(true))
  1931.                                                                         sleep(400, 600);
  1932.                                                         }
  1933.                                                         for (int i = 0; i < 20 && !isDead(); i++) {
  1934.                                                                 if (rammernaut != null) {
  1935.                                                                         String msg = rammernaut.getMessage();
  1936.                                                                         if (msg != null && msg.contains("Oo"))
  1937.                                                                                 break;
  1938.                                                                 }
  1939.                                                                 if (calc.distanceTo(safeTile) < 3 && calc.distanceTo(rammernaut) < 4)
  1940.                                                                         break;
  1941.                                                                 sleep(200, 300);
  1942.                                                         }
  1943.                                                         if (failSafe())
  1944.                                                                 return;
  1945.                                                         if (rammernaut != null && rammernaut.getMessage() == null) {
  1946.                                                                 walkToScreen(currentRoom.getCentralTile());
  1947.                                                                 sleep(600, 1000);
  1948.                                                         }
  1949.                                                 }
  1950.                                                 secondaryStatus = "";
  1951.                                         } else if (rammernaut.getAnimation() == 13705) {
  1952.                                                 topUp(true);
  1953.                                         } else {
  1954.                                                 RSObject corner = getObjInRoom(51762);
  1955.                                                 if (rammernaut.getMessage() == null && (isEdgeTile(myLoc()) || (corner != null &&
  1956.  
  1957. calc.distanceTo(corner) < 4))) {
  1958.                                                         walkToScreen(currentRoom.getCentralTile());
  1959.                                                         sleep(400, 800);
  1960.                                                 }
  1961.                                                 setPrayer(true, Style.MELEE, true);
  1962.                                                 attackBoss(rammernaut, true);
  1963.                                                 if (rammernaut.getMessage() != null)
  1964.                                                         continue;
  1965.                                                 eatFood(topFoods, 50, 20);
  1966.                                         }
  1967.                                 }
  1968.                                 sleep(100, 200);
  1969.                         }
  1970.                 } else if (bossName.equals("Stomp") || getNpcInRoom("Stomp") != null) {
  1971.                         RSNPC stomp = getNpcInRoom("Stomp");
  1972.                         ArrayList<RSTile> stoneChecks = new ArrayList<RSTile>();
  1973.                         int dX = 0, dY = 0, stoneCount = random(10, 16);
  1974.                         if (setBoss("Stomp", false)) {
  1975.                                 bounds.add((Integer) 15750);
  1976.                                 bounds.add((Integer) 15751);
  1977.                                 bounds.add((Integer) 15752);
  1978.                         }
  1979.                         tempMode = Melee.STAB;
  1980.                         if (stomp != null) {
  1981.                                 RSTile backDoor = getBackDoor(), bossTile = stomp.getLocation();
  1982.                                 walkFast(bossTile, 2);
  1983.                                 setPrayer(true, null, false);
  1984.                                 if (backDoor != null) {
  1985.                                         if (backDoor.getX() - bossTile.getX() > 3) {
  1986.                                                 dX = 1;
  1987.                                         } else if (backDoor.getX() - bossTile.getX() < -3) {
  1988.                                                 dX = -1;
  1989.                                         }
  1990.                                         if (backDoor.getY() - bossTile.getY() > 3) {
  1991.                                                 dY = 1;
  1992.                                         } else if (backDoor.getY() - bossTile.getY() < -3) {
  1993.                                                 dY = -1;
  1994.                                         }
  1995.                                 }
  1996.                                 for (RSObject o : getObjsInRoom("lodestone")) {
  1997.                                         if (o != null) {
  1998.                                                 RSTile oT = o.getLocation();
  1999.                                                 stoneChecks.add(new RSTile(oT.getX() + dX, oT.getY() + dY));
  2000.                                         }
  2001.                                 }
  2002.                         }
  2003.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2004.                                 if (failSafe())
  2005.                                         return;
  2006.                                 if (getObjInRoom(ACTIVE_STONES) != null) {
  2007.                                         boolean pickup = true;
  2008.                                         int reachCount = 0;
  2009.                                         Timer stoneTimer = new Timer(random(14000, 15000));
  2010.                                         badTiles.clear();
  2011.                                         stoneCount = random(10, 15);
  2012.                                         sleep(500, 1000);
  2013.                                         for (int I = 0; I < ALL_STONES.length; I++) {
  2014.                                                 if (objects.getNearest(ALL_STONES[I]) != null) {
  2015.                                                         bossStage = 1 + I;
  2016.                                                         break;
  2017.                                                 }
  2018.                                         }
  2019.                                         if (bossStage == 0)
  2020.                                                 bossStage = 1;
  2021.                                         final int CRYSTAL_ID = 15749 + bossStage;
  2022.                                         status = "Killing Stomp (stage " + bossStage + " of 3)";
  2023.                                         int newCount = 0, oldCount = 0;
  2024.                                         for (RSTile t : stoneChecks) {
  2025.                                                 RSObject blockObj = objects.getTopAt(t);
  2026.                                                 if (blockObj != null) {
  2027.                                                         if (blockObj.getID() == FALLING_ROCKS) {
  2028.                                                                 newCount++;
  2029.                                                         } else if (blockObj.getID() == BLOCK_ROCKS) {
  2030.                                                                 oldCount++;
  2031.                                                         }
  2032.                                                 }
  2033.                                         }
  2034.                                         if (newCount == 1 && oldCount == 0) {
  2035.                                                 for (RSTile t : stoneChecks) {
  2036.                                                         if (calc.distanceTo(t) < 5) {
  2037.                                                                 RSObject blockObj = objects.getTopAt(t);
  2038.                                                                 if (blockObj != null && blockObj.getID() == FALLING_ROCKS) {
  2039.                                                                         walkTo(t, 0);
  2040.                                                                         break;
  2041.                                                                 }
  2042.                                                         }
  2043.                                                 }
  2044.                                         }
  2045.                                         setPrayersOff();
  2046.                                         lastMessage = "";
  2047.                                         for (RSTile t : stoneChecks) {
  2048.                                                 if (myLoc().equals(t) || objects.getTopAt(t) == null)
  2049.                                                         reachCount++;
  2050.                                         }
  2051.                                         while (getObjInRoom(ACTIVE_STONES) != null) {
  2052.                                                 if (failSafe())
  2053.                                                         return;
  2054.                                                 int crystalsNeeded = 2;
  2055.                                                 unreachable = false;
  2056.                                                 if (reachCount == 2) {
  2057.                                                         RSObject[] actives = getObjsInRoom(ACTIVE_STONES);
  2058.                                                         crystalsNeeded = actives != null ? actives.length : 0;
  2059.                                                 }
  2060.                                                 if (inventory.getCount(CRYSTAL_ID) < crystalsNeeded) {
  2061.                                                         RSGroundItem crystal = getRoomItem(stompCrystal);
  2062.                                                         if (crystal != null) {
  2063.                                                                 if (pickup && pickUpItem(crystal))
  2064.                                                                         waitToStop(false);
  2065.                                                                 if (unreachable)
  2066.                                                                         badTiles.add(crystal.getLocation());
  2067.                                                         } else if (!topUp(true) && (stoneTimer == null || !stoneTimer.isRunning()) &&
  2068.  
  2069. !lastMessage.contains("currently invulnerable")) {
  2070.                                                                 if (doNpcAction(stomp, "Attack"))
  2071.                                                                         waitToStop(false);
  2072.                                                         }
  2073.                                                 } else if (reachCount == 2 && stoneTimer != null && stoneTimer.isRunning()) {
  2074.                                                         for (RSTile t : stoneChecks) {
  2075.                                                                 if (!myLoc().equals(t) && objects.getTopAt(t) != null) {
  2076.                                                                         stoneTimer = null;
  2077.                                                                         break;
  2078.                                                                 }
  2079.                                                         }
  2080.                                                         if (stoneTimer != null) {
  2081.                                                                 RSObject nextStone = getObjInRoom(ACTIVE_STONES);
  2082.                                                                 if (nextStone != null) {
  2083.                                                                         safeTile = nextStone.getLocation();
  2084.                                                                         if (doObjAction(nextStone, "Charge")) {
  2085.                                                                                 waitToStop(false);
  2086.                                                                                 if (unreachable) {
  2087.                                                                                         reachCount--;
  2088.                                                                                         safeTile = null;
  2089.                                                                                 } else if (stoneTimer != null) {
  2090.                                                                                         stoneTimer.reset();
  2091.                                                                                 }
  2092.                                                                         }
  2093.                                                                 }
  2094.                                                         }
  2095.                                                 } else if (!topUp(true) && (stoneTimer == null || !stoneTimer.isRunning()) && !
  2096.  
  2097. lastMessage.contains("currently invulnerable")) {
  2098.                                                         if (doNpcAction(stomp, "Attack"))
  2099.                                                                 waitToStop(true);
  2100.                                                 }
  2101.                                                 sleep(200, 300);
  2102.                                         }
  2103.                                         safeTile = null;
  2104.                                         badTiles.clear();
  2105.                                         setPrayer(true, null, false);
  2106.                                 } else if (stomp != null && bossStage == 3 && stomp.getAnimation() == 13449) {
  2107.                                         for (RSTile t : stoneChecks) {
  2108.                                                 if (calc.distanceTo(t) > 2) {
  2109.                                                         walkTo(t, 1);
  2110.                                                         topUp(true);
  2111.                                                         sleep(600, 900);
  2112.                                                         break;
  2113.                                                 }
  2114.                                         }
  2115.                                 } else {
  2116.                                         boolean blocked = false;
  2117.                                         for (RSTile t : stoneChecks) {
  2118.                                                 if (objects.getTopAt(t) != null) {
  2119.                                                         blocked = true;
  2120.                                                         break;
  2121.                                                 }
  2122.                                         }
  2123.                                         if (blocked || getObjsInRoom(BLOCK_ROCKS).length > stoneCount) {
  2124.                                                 lastMessage = "";
  2125.                                                 setRetaliate(combatStyle == Style.MELEE);
  2126.                                                 RSObject block = getObjInRoom(BLOCK_ROCKS);
  2127.                                                 if (block != null) {
  2128.                                                         safeTile = block.getLocation();
  2129.                                                         if (!isMoving() && (calc.distanceTo(safeTile) > 1 || isAttacking(stomp))) {
  2130.                                                                 walkTo(safeTile, 1);
  2131.                                                         } else topUp(true);
  2132.                                                 }
  2133.                                         } else {
  2134.                                                 eatFood(topFoods, 50, 50);
  2135.                                                 setRetaliate(true);
  2136.                                                 if (!lastMessage.contains("currently invulnerable")) {
  2137.                                                         attackBoss(stomp, false);
  2138.                                                         safeTile = null;
  2139.                                                 } else topUp(true);
  2140.                                         }
  2141.                                 }
  2142.                                 sleep(200, 300);
  2143.                         }
  2144.                 } else if (bossName.equals("Har'laak the Riftsplitter") || getNpcInRoom("Riftsplitter") != null) {
  2145.                         RSNPC riftsplitter = getNpcInRoom("Riftsplitter");
  2146.                         boolean newShout = false;
  2147.                         String shout = null;
  2148.                         ArrayList<RSArea> portals = new ArrayList<RSArea>();
  2149.                         ArrayList<RSTile> corners = new ArrayList<RSTile>();
  2150.                         setBoss("Riftsplitter", true);
  2151.                         setPrayer(true, Style.MAGIC, true);
  2152.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  2153.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2154.                                 if (failSafe())
  2155.                                         return;
  2156.                                 if (riftsplitter != null) {
  2157.                                         if (riftsplitter.getMessage() != null && shout != null && shout.equals
  2158.  
  2159. (riftsplitter.getMessage())) {
  2160.                                                 newShout = false;
  2161.                                         } else {
  2162.                                                 shout = riftsplitter.getMessage();
  2163.                                                 newShout = true;
  2164.                                         }
  2165.                                         if (shout != null && newShout) {
  2166.                                                 secondaryStatus = "Look out for that portal!";
  2167.                                                 RSTile mT = myLoc();
  2168.                                                 if (corners.isEmpty()) {
  2169.                                                         portals.clear();
  2170.                                                         portals.add(new RSArea(new RSTile(mT.getX() - 1, mT.getY() - 1), new RSTile
  2171.  
  2172. (mT.getX() + 1, mT.getY() + 1)));
  2173.                                                         o:for (RSObject obj : getObjsInRoom(51866)) {
  2174.                                                                 RSTile oTile = obj.getLocation();
  2175.                                                                 for (RSArea portal : portals) {
  2176.                                                                         if (areaContains(portal, oTile))
  2177.                                                                                 continue o;
  2178.                                                                 }
  2179.                                                                 corners.add(obj.getLocation());
  2180.                                                         }
  2181.                                                 } else portals.add(new RSArea(new RSTile(mT.getX() - 1, mT.getY() - 1), new RSTile
  2182.  
  2183. (mT.getX() + 1, mT.getY() + 1)));
  2184.                                                 int dist = 20;
  2185.                                                 if (safeTile == null) {
  2186.                                                         for (RSTile corner : corners) {
  2187.                                                                 if (calc.distanceTo(corner) > 2 && calc.distanceTo(corner) < dist) {
  2188.                                                                         safeTile = corner;
  2189.                                                                         dist = calc.distanceTo(corner);
  2190.                                                                 }
  2191.                                                         }
  2192.                                                 }
  2193.                                                 if (safeTile != null) {
  2194.                                                         walkFast(safeTile, 0);
  2195.                                                         corners.remove(safeTile);
  2196.                                                         topUp(true);
  2197.                                                         for (int c = 0; c < 10; c++) {
  2198.                                                                 if (isDead() || calc.distanceTo(safeTile) < 4)
  2199.                                                                         break;
  2200.                                                                 if (!isMoving()) {
  2201.                                                                         walkTo(safeTile, 0);
  2202.                                                                 } else if (!topUp(true)) {
  2203.                                                                         sleep(300, 500);
  2204.                                                                 }
  2205.                                                         }
  2206.                                                         safeTile = null;
  2207.                                                 }
  2208.                                                 secondaryStatus = "";
  2209.                                         } else {
  2210.                                                 attackBoss(riftsplitter, true);
  2211.                                                 eatFood(topFoods, 50, 20);
  2212.                                                 if (calc.distanceTo(riftsplitter) < 3 && !player().isInCombat() && !
  2213.  
  2214. riftsplitter.isInCombat())
  2215.                                                         walkToMap(currentRoom.getCentralTile(), 1);
  2216.                                         }
  2217.                                 }
  2218.                                 sleep(100, 200);
  2219.                         }
  2220.                 } else if (bossName.equals("Lexicus Runewright") || getNpcInRoom("Lexicus") != null) {
  2221.                         RSNPC lexicus = getNpcInRoom("Lexicus");
  2222.                         setBoss("Lexicus Runewright", false);
  2223.                         String shout = "";
  2224.                         setPrayer(false, Style.MAGIC, true);
  2225.                         swapStyle(Style.RANGE);
  2226.                         tempMode = Melee.SLASH;
  2227.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2228.                                 if (failSafe())
  2229.                                         return;
  2230.                                 if (lexicus != null) {
  2231.                                         shout = lexicus.getMessage();
  2232.                                         if (shout != null && shout.contains("barrage")) {
  2233.                                                 RSObject corner = objects.getNearest(bookCorner);
  2234.                                                 if (corner != null) {
  2235.                                                         safeTile = corner.getLocation();
  2236.                                                         walkToMap(safeTile, 1);
  2237.                                                         if (!topUp(true))
  2238.                                                                 sleep(500, 700);
  2239.                                                         sleep(600, 800);
  2240.                                                         doNpcAction(lexicus, "Attack");
  2241.                                                         safeTile = null;
  2242.                                                 }
  2243.                                                 secondaryStatus = "";
  2244.                                         } else if (getNpcInRoom("Tome") != null) {
  2245.                                                 if (smartSleep(attackNpc(getNpcInRoom("Tome")), false))
  2246.                                                         eatFood(topFoods, 40, 20);
  2247.                                         } else if (lexicus.getAnimation() == 13499) {
  2248.                                                 for (int i = 0; i < 15 && !isDead(); i++) {
  2249.                                                         if (getNpcInRoom("Tome") != null)
  2250.                                                                 break;
  2251.                                                         topUp(false);
  2252.                                                         sleep(100, 200);
  2253.                                                 }
  2254.                                         } else attackBoss(lexicus, false);
  2255.                                 }
  2256.                                 eatFood(topFoods, 40, 20);
  2257.                                 sleep(100, 200);
  2258.                         }
  2259.                 } else if (bossName.equals("Sagittare") || getObjInRoom(51887) != null) {
  2260.                         RSNPC sagittare;
  2261.                         setBoss("Sagittare", false);
  2262.                         if (combatStyle == Style.RANGE) {
  2263.                                 if (swapAlternative()) {
  2264.                                         log("Swapped our attack style for Sagittare");
  2265.                                 } else {
  2266.                                         log.severe("We don't have a way to kill Sagittare, aborting dungeon!");
  2267.                                         exit = true;
  2268.                                         return;
  2269.                                 }
  2270.                         }
  2271.                         setPrayer(true, Style.MAGIC, true);
  2272.                         tempMode = Melee.SLASH;
  2273.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2274.                                 if (failSafe())
  2275.                                         return;
  2276.                                 if ((sagittare = getNpcInRoom("Sagittare")) != null) {
  2277.                                         if (lastMessage.contains("stops you") || lastMessage.contains("bound"))
  2278.                                                 topUp(true);
  2279.                                         if (sagittare.getAnimation() == 13270 || sagittare.getMessage() != null) {
  2280.                                                 if (calc.distanceTo(currentRoom.getCentralTile()) > 2) {
  2281.                                                         safeTile = currentRoom.getCentralTile();
  2282.                                                 } else {
  2283.                                                         RSObject door = objects.getNearest(50352);
  2284.                                                         safeTile = door != null ? door.getLocation() : sagittare.getLocation();
  2285.                                                 }
  2286.                                                 walkToMap(safeTile, 1);
  2287.                                                 sleep(2500, 4000);
  2288.                                                 safeTile = null;
  2289.                                         } else if (combatStyle != Style.MAGIC && calc.distanceTo(sagittare) > 1) {
  2290.                                                 if (isMoving()) {
  2291.                                                         topUp(false);
  2292.                                                 } else walkToMap(sagittare.getLocation(), 1);
  2293.                                                 RSTile dest = walking.getDestination();
  2294.                                                 if (dest != null && calc.distanceBetween(dest, sagittare.getLocation()) > 1) {
  2295.                                                         walkToMap(sagittare.getLocation(), 0);
  2296.                                                         waitToStart(false);
  2297.                                                 }
  2298.                                         }
  2299.                                         eatFood(topFoods, 50, 50);
  2300.                                         if (sagittare.getAnimation() != 8939 /*&& sagittare.getGraphic() != 1576*/)
  2301.                                                 attackBoss(sagittare, false);
  2302.                                 }
  2303.                                 sleep(100, 200);
  2304.                         }
  2305.                 } else if (bossName.equals("Night-gazer Khighorahk") || getNpcInRoom("Khighorahk") != null) {
  2306.                         RSNPC khighorahk = getNpcInRoom("Khighorahk");
  2307.                         setBoss("Night-gazer", true);
  2308.                         if (khighorahk != null && bossID < 1) {
  2309.                                 bossID = khighorahk.getID();
  2310.                                 bossStage = 1;
  2311.                         }
  2312.                         setPrayer(false, Style.MAGIC, true);
  2313.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  2314.                         status = "Killing the Night-gazer (stage " + bossStage + " of 2)";
  2315.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2316.                                 if (failSafe())
  2317.                                         return;
  2318.                                 if ((khighorahk = getNpcInRoom("Khighorahk")) != null) {
  2319.                                         if (intMatch(khighorahk.getAnimation(), K_SPEC_ANIMS) && (isMoving() || calc.distanceTo
  2320.  
  2321. (khighorahk.getLocation()) < 6)) {
  2322.                                                 safeTile = safePillar(khighorahk.getLocation());
  2323.                                                 RSObject pillar = getObjInRoom(49265);
  2324.                                                 if (safeTile != null) {
  2325.                                                         walkToMap(safeTile, 1);
  2326.                                                         waitToStart(false);
  2327.                                                         RSTile bossTile = khighorahk.getLocation();
  2328.                                                         for (int i = 0; i < 7 && !isDead(); i++) {
  2329.                                                                 if (pillar != null && calc.distanceTo(pillar) < 4) {
  2330.                                                                         if (doObjAction(pillar, "Light")) {
  2331.                                                                                 waitToObject(false);
  2332.                                                                                 if (player().getAnimation() != 13355 || player
  2333.  
  2334. ().getAnimation() != 13354)
  2335.                                                                                         doObjAction(pillar, "Light");
  2336.                                                                                 break;
  2337.                                                                         }
  2338.                                                                 }
  2339.                                                                 if (player().getAnimation() == 10070) {
  2340.                                                                         topUp(true);
  2341.                                                                         break;
  2342.                                                                 }
  2343.                                                                 if (walking.isRunEnabled()) {
  2344.                                                                         sleep(200, 300);
  2345.                                                                 } else if (calc.distanceTo(safeTile) < 3 || calc.distanceTo(bossTile)
  2346.  
  2347. > 7) {
  2348.                                                                         break;
  2349.                                                                 }
  2350.                                                                 if (calc.distanceBetween(myLoc(), bossTile) > 4 && !intMatch
  2351.  
  2352. (khighorahk.getAnimation(), K_START_ANIMS))
  2353.                                                                         break;
  2354.                                                                 sleep(200, 250);
  2355.                                                                 if (!intMatch(khighorahk.getAnimation(), K_SPEC_ANIMS))
  2356.                                                                         break;
  2357.                                                         }
  2358.                                                         for (int c = 0; c < 5 && !isDead(); c++) {
  2359.                                                                 if (intMatch(khighorahk.getAnimation(), K_START_ANIMS))
  2360.                                                                         break;
  2361.                                                                 if (attackBoss(khighorahk, true)) {
  2362.                                                                         waitToAnimate();
  2363.                                                                         break;
  2364.                                                                 }
  2365.                                                                 sleep(400, 600);
  2366.                                                         }
  2367.                                                         safeTile = null;
  2368.                                                 }
  2369.                                         } else {
  2370.                                                 RSObject[] litPillars = getObjsInRoom(49266, 49267);
  2371.                                                 if (litPillars != null && litPillars.length < 2) {
  2372.                                                         if (doObjAction(objects.getNearest(49265), "Light"))
  2373.                                                                 waitToObject(false);
  2374.                                                 } else if (!intMatch(khighorahk.getAnimation(), K_START_ANIMS)) {
  2375.                                                         eatFood(topFoods, 50, 20);
  2376.                                                         if (!intMatch(khighorahk.getAnimation(), K_START_ANIMS))
  2377.                                                                 attackBoss(khighorahk, true);
  2378.                                                         if (khighorahk.getID() != bossID) {
  2379.                                                                 bossID = khighorahk.getID();
  2380.                                                                 bossStage = 2;
  2381.                                                                 status = "Killing the Night-gazer (stage 2 of 2)";
  2382.                                                         }
  2383.                                                 }
  2384.                                         }
  2385.                                 }
  2386.                                 sleep(100, 200);
  2387.                         }
  2388.                 } else if (!unknownBossFight()) {
  2389.                         return;
  2390.                 }
  2391.                 finish = true;
  2392.         }
  2393.  
  2394.         private void occultBoss() {
  2395.                 if (bossName.equals("Skeletal Trio") || getNpcInRoom("Skeletal warrior") != null || getNpcInRoom("Skeletal sorcerer")
  2396.  
  2397. != null || getNpcInRoom("Skeletal archer") != null) {
  2398.                         RSNPC meleer, archer, sorcerer, targ = null;
  2399.                         status = "Killing the Skeletal Trio!";
  2400.                         setBoss("Skeletal Trio", true);
  2401.                         tempMode = Melee.CRUSH.enabled() ? Melee.CRUSH : Melee.SLASH;
  2402.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2403.                                 if (failSafe())
  2404.                                         return;
  2405.                                 boolean mInvincible = true, aInvincible = true, sInvincible = true;
  2406.                                 int remaining = 0;
  2407.                                 if ((meleer = getNpcInRoom("Skeletal warrior")) != null) {
  2408.                                         mInvincible = isProtecting(meleer, 11939, combatStyle.index());
  2409.                                         remaining++;
  2410.                                 }
  2411.                                 if ((archer = getNpcInRoom("Skeletal archer")) != null) {
  2412.                                         aInvincible = isProtecting(archer, 12043, combatStyle.index());
  2413.                                         remaining++;
  2414.                                 }
  2415.                                 if ((sorcerer = getNpcInRoom("Skeletal sorcerer")) != null) {
  2416.                                         sInvincible = isProtecting(sorcerer, 11998, combatStyle.index());
  2417.                                         remaining++;
  2418.                                 }
  2419.                                 switch (combatStyle) {
  2420.                                 case MELEE:
  2421.                                         protection = sorcerer != null ? Style.MAGIC : archer != null ? Style.RANGE : Style.MELEE;
  2422.                                         targ = !aInvincible ? archer : !sInvincible ? sorcerer : !mInvincible ? meleer : null;
  2423.                                         break;
  2424.                                 case RANGE:
  2425.                                         protection = meleer != null? Style.MELEE : sorcerer != null ? Style.MAGIC : Style.RANGE;
  2426.                                         targ = !sInvincible ? sorcerer : !mInvincible ? meleer : !aInvincible ? archer : null;
  2427.                                         break;
  2428.                                 case MAGIC:
  2429.                                         protection = archer != null ? Style.RANGE : meleer != null ? Style.MELEE : Style.MAGIC;
  2430.                                         targ = !mInvincible ? meleer : !aInvincible ? archer : !sInvincible ? sorcerer : null;
  2431.                                         break;
  2432.                                 }
  2433.                                 setPrayer(true, protection, true);
  2434.                                 if (targ != null) {
  2435.                                         attackNpc(targ);
  2436.                                         if (!eatFood(topFoods, 50, 50))
  2437.                                                 sleep(400, 600);
  2438.                                 } else if (remaining == 3 || !swapAlternative()) {
  2439.                                         topUp(true);
  2440.                                 }
  2441.                                 sleep(200, 300);
  2442.                         }
  2443.                 } else if (bossName.equals("Runebound Behemoth") || getObjInRoom(RUNEBOUND_ACTIVES) != null) {
  2444.                         RSNPC runebound = getNpcInRoom("Runebound behemoth");
  2445.                         setBoss("Runebound Behemoth", true);
  2446.                         tempMode = Melee.CRUSH;
  2447.                         if (bossID < 1 && runebound != null)
  2448.                                 bossID = runebound.getID();
  2449.                         setPrayer(true, Style.MAGIC, true);
  2450.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2451.                                 if (failSafe())
  2452.                                         return;
  2453.                                 if (runebound != null) {
  2454.                                         if (runebound.getAnimation() == 14440 || runebound.getMessage() != null) {
  2455.                                                 secondaryStatus = "Dodging the lightning!";
  2456.                                                 RSObject corner = getObjInRoom(54786);
  2457.                                                 walkToScreen(calc.distanceTo(corner) > 2 && !isEdgeTile(myLoc()) ? reflect
  2458.  
  2459. (runebound.getLocation(), myLoc(), .5) : bossRoom.getCentralTile());
  2460.                                                 if (!topUp(true))
  2461.                                                         sleep(400, 600);
  2462.                                                 secondaryStatus = "";
  2463.                                         } else {
  2464.                                                 int differential = bossID - runebound.getID();
  2465.                                                 boolean meleeI = true, rangeI = true, magicI = true;
  2466.                                                 if (differential == 15) {
  2467.                                                         meleeI = false;
  2468.                                                 } else if (differential == 30) {
  2469.                                                         rangeI = false;
  2470.                                                 } else if (differential == 60) {
  2471.                                                         magicI = false;
  2472.                                                 } else if (differential == -15) {
  2473.                                                         meleeI = false;
  2474.                                                         magicI = false;
  2475.                                                 } else if (differential == -30) {
  2476.                                                         rangeI = false;
  2477.                                                         meleeI = false;
  2478.                                                 } else if (differential == -45) {
  2479.                                                         rangeI = false;
  2480.                                                         magicI = false;
  2481.                                                 }
  2482.                                                 boolean[] invin = { meleeI, rangeI, magicI };
  2483.                                                 if (!invin[combatStyle.index()]) {
  2484.                                                         attackBoss(runebound, true);
  2485.                                                         eatFood(topFoods, 30, 15);
  2486.                                                 } else {
  2487.                                                         eatFood(topFoods, 50, 20);
  2488.                                                         RSObject styleActive = getObjInRoom(RUNEBOUND_ACTIVES[combatStyle.index()]);
  2489.                                                         if (styleActive != null) {
  2490.                                                                 if (combat.getHealth() > random(8, 15) && doObjAction(styleActive,
  2491.  
  2492. "Deactivate"))
  2493.                                                                         waitToStop(false);
  2494.                                                         } else {
  2495.                                                                 for (int I = 0; I < 3; I++) {
  2496.                                                                         Style test = styleOf(I);
  2497.                                                                         if (combatStyle != test && test.enabled() && (!invin[I] ||
  2498.  
  2499. getObjInRoom(RUNEBOUND_ACTIVES[I]) != null)) {
  2500.                                                                                 RSObject active = getObjInRoom(RUNEBOUND_ACTIVES[I]);
  2501.                                                                                 if (active != null)
  2502.                                                                                         walkFast(active.getLocation(), 1);
  2503.                                                                                 swapStyle(test);
  2504.                                                                                 break;
  2505.                                                                         }
  2506.                                                                         if (I == 2)
  2507.                                                                                 topUp(true);
  2508.                                                                 }
  2509.                                                         }
  2510.                                                 }
  2511.                                         }
  2512.                                 }
  2513.                                 sleep(100, 200);
  2514.                         }
  2515.                 } else if (bossName.equals("Gravecreeper") || getObjInRoom(54447) != null) {
  2516.                         RSNPC gravecreeper;
  2517.                         setBoss("Gravecreeper", true);
  2518.                         if (combatStyle == Style.RANGE)
  2519.                                 swapStyle(Style.MELEE);
  2520.                         tempMode = Melee.SLASH.enabled() ? Melee.SLASH : Melee.CRUSH;
  2521.                         setPrayer(true, combatStyle == Style.MELEE ? Style.MELEE : Style.RANGE, true);
  2522.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2523.                                 if (failSafe())
  2524.                                         return;
  2525.                                 if ((gravecreeper = getNpcInRoom(bossName)) != null) {
  2526.                                         RSObject aGrave = getObjInRoom(GRAVE_PADS);
  2527.                                         String graveMessage = gravecreeper.getMessage();
  2528.                                         if (graveMessage != null) {
  2529.                                                 if (graveMessage.equals("Burrrn")) {
  2530.                                                         secondaryStatus = "Dodging the burn spots!";
  2531.                                                         RSTile badTile = gravecreeper.getLocation();
  2532.                                                         safeTile = safeGrave(badTile);
  2533.                                                         if (safeTile != null && badTile != null) {
  2534.                                                                 for (int c = 0; c < 10; c++) {
  2535.                                                                         if (calc.distanceTo(badTile) < 2) {
  2536.                                                                                 walkTo(safeTile, 1);
  2537.                                                                                 c++;
  2538.                                                                         } else if (topUp(false)) {
  2539.                                                                                 c++;
  2540.                                                                         }
  2541.                                                                         sleep(400, 500);
  2542.                                                                 }
  2543.                                                         }
  2544.                                                         secondaryStatus = "";
  2545.                                                 } else if (graveMessage.contains("Buuu")) {
  2546.                                                         omNomNom();
  2547.                                                 } else if (graveMessage.contains("Diii")) {
  2548.                                                         omNomNom();
  2549.                                                 } else if (graveMessage.contains("Braa")) {
  2550.                                                         omNomNom();
  2551.                                                 }
  2552.                                         } else if (aGrave != null && calc.distanceTo(aGrave) < 2) {
  2553.                                                 safeTile = safeGrave(gravecreeper.getLocation());
  2554.                                                 if (safeTile != null) {
  2555.                                                         walkTo(safeTile, 1);
  2556.                                                 } else walkToScreen(bossRoom.getCentralTile());
  2557.                                                 sleep(600, 1000);
  2558.                                         } else {
  2559.                                                 attackBoss(gravecreeper, false);
  2560.                                                 eatFood(topFoods, 50, 20);
  2561.                                         }
  2562.                                 } else topUp(true);
  2563.                                 sleep(100, 200);
  2564.                         }
  2565.                 } else if (bossName.equals("Necrolord") || getObjInRoom(54475) != null) {
  2566.                         RSNPC necrolord = getNpcInRoom("Necrolord");
  2567.                         setBoss("Necrolord", true);
  2568.                         if (combatStyle == Style.MELEE && !swapAlternative()) {
  2569.                                 log.severe("We can't kill this boss with melee, aborting dungeon");
  2570.                                 abortedCount++;
  2571.                                 exit = true;
  2572.                                 return;
  2573.                         }
  2574.                         if (necrolord != null && calc.distanceTo(necrolord) > 3)
  2575.                                 walkToMap(necrolord.getLocation(), 1);
  2576.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2577.                                 if (failSafe())
  2578.                                         return;
  2579.                                 RSNPC minion = getNpcInRoom("Skeletal minion");
  2580.                                 setPrayer(true, minion != null && calc.distanceTo(minion) < 4 ? Style.MELEE : Style.MAGIC, true);
  2581.                                 if (combatStyle == Style.MELEE) {
  2582.                                         log.severe("We can't kill this boss with melee, aborting dungeon");
  2583.                                         exit = true;
  2584.                                         return;
  2585.                                 }
  2586.                                 if (unreachable) {
  2587.                                         if (!isAttacking(necrolord))
  2588.                                                 topUp(true);
  2589.                                         unreachable = false;
  2590.                                 }
  2591.                                 attackBoss(necrolord, false);
  2592.                                 eatFood(topFoods, 50, 60);
  2593.                                 sleep(200, 400);
  2594.                         }
  2595.                 } else if (bossName.equals("Flesh-Spoiler Haasghenahk") || getNpcInRoom("Flesh-Spoiler") != null) {
  2596.                         RSNPC fleshSpoiler = getNpcInRoom("Flesh-Spoiler");
  2597.                         if (setBoss("Flesh-Spoiler", true)) {
  2598.                                 if (fleshSpoiler != null)
  2599.                                         bossID = fleshSpoiler.getID();
  2600.                                 bossStage = 1;
  2601.                         }
  2602.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  2603.                         setPrayer(true, null, false);
  2604.                         status = "Killing the Flesh-Spoiler (Stage " + bossStage + " of 2)";
  2605.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2606.                                 if (failSafe())
  2607.                                         return;
  2608.                                 if ((fleshSpoiler = getNpcInRoom(bossName)) != null) {
  2609.                                         if (Option.PRAY.enabled() && getNpcInRoom("spawn") != null)
  2610.                                                 setPrayer(true, Style.MELEE, true);
  2611.                                         attackBoss(fleshSpoiler, true);
  2612.                                         eatFood(topFoods, 50, 40);
  2613.                                         if (fleshSpoiler.getID() != bossID) {
  2614.                                                 status = "Killing the Flesh-Spoiler (Stage 2 of 2)";
  2615.                                                 bossID = fleshSpoiler.getID();
  2616.                                                 bossStage = 2;
  2617.                                         }
  2618.                                 }
  2619.                                 sleep(200, 300);
  2620.                         }
  2621.                 } else if (bossName.equals("Yk'Lagor the Thunderous") || getNpcInRoom("Yk'Lagor the Thunderous") != null) {
  2622.                         RSNPC thunderous;
  2623.                         setBoss("Yk'Lagor the Thunderous", false);
  2624.                         roomSwitch = false;
  2625.                         swapStyle(Style.MAGIC);
  2626.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.SLASH;
  2627.                         ArrayList<RSTile> spots = new ArrayList<RSTile>();
  2628.                         for (RSObject p : getObjsInRoom(55057)) {
  2629.                                 for (RSTile t : getAdjacentTo(p.getLocation())) {
  2630.                                         if (isEdgeTile(t)) {
  2631.                                                 spots.add(t);
  2632.                                                 break;
  2633.                                         }
  2634.                                 }
  2635.                         }
  2636.                         if (getNpcInRoom("Mysterious mage") != null) {
  2637.                                 secondaryStatus = "Freeing Yk'Lagor from the mages";
  2638.                                 walkFast(bossRoom.getCentralTile(), 2);
  2639.                                 setRetaliate(false);
  2640.                                 setPrayer(false, Style.MAGIC, true);
  2641.                                 while (getNpcInRoom("Mysterious mage") != null) {
  2642.                                         if (failSafe())
  2643.                                                 return;
  2644.                                         if (npcs.getAll(unInteracting).length <= 4) {
  2645.                                                 safeTile = getNearestTileTo(myLoc(), spots);
  2646.                                                 walkTo(safeTile, 0);
  2647.                                                 waitToEat(false);
  2648.                                         } else {
  2649.                                                 if (attackNpc(npcs.getNearest(unInteracting)))
  2650.                                                         sleep(600, 800);
  2651.                                                 eatFood(topFoods, 50, 50);
  2652.                                         }
  2653.                                 }
  2654.                                 secondaryStatus = "";
  2655.                                 if (myLoc().equals(safeTile))
  2656.                                         omNomNom();
  2657.                                 setRetaliate(true);
  2658.                                 selectTab(Game.TAB_INVENTORY, 3);
  2659.                         }
  2660.                         setPrayer(true, combatStyle == Style.MELEE ? Style.MELEE : Style.MAGIC, true);
  2661.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2662.                                 if (failSafe())
  2663.                                         return;
  2664.                                 if ((thunderous = getNpcInRoom(bossName)) != null) {
  2665.                                         String shout = thunderous.getMessage();
  2666.                                         if (shout != null) {
  2667.                                                 if (shout.startsWith("This is")) {
  2668.                                                         secondaryStatus = "Taking cover from the quake!";
  2669.                                                         safeTile = getNearestTileTo(myLoc(), spots);
  2670.                                                         Timer quakeTimer = new Timer(random(3000, 3500));
  2671.                                                         if (safeTile != null) {
  2672.                                                                 while (!myLoc().equals(safeTile) && quakeTimer.isRunning()) {
  2673.                                                                         if (failSafe())
  2674.                                                                                 return;
  2675.                                                                         if (thunderous != null && thunderous.getAnimation() == -1)
  2676.                                                                                 break;
  2677.                                                                         if (myLoc().equals(safeTile)) {
  2678.                                                                                 topUp(true);
  2679.                                                                         } else if (!isMoving()) {
  2680.                                                                                 walkTo(safeTile, 0);
  2681.                                                                         }
  2682.                                                                         sleep(100, 200);
  2683.                                                                 }
  2684.                                                         }
  2685.                                                 } else if (shout.startsWith("Come")) {
  2686.                                                         secondaryStatus = "Dodging his grasp!";
  2687.                                                         safeTile = getNearestTileTo(myLoc(), spots);
  2688.                                                         Timer graspTimer = new Timer(random(4000, 5000));
  2689.                                                         if (safeTile != null) {
  2690.                                                                 while (!roomSwitch && graspTimer.isRunning()) {
  2691.                                                                         if (failSafe())
  2692.                                                                                 return;
  2693.                                                                         if (roomSwitch) {
  2694.                                                                                 if (lastMessage.contains("stunned")) {
  2695.                                                                                         log("Damn it.. Got sucked in.");
  2696.                                                                                         sleep(4000, 6000);
  2697.                                                                                 }
  2698.                                                                                 break;
  2699.                                                                         }
  2700.                                                                         if (myLoc().equals(safeTile)) {
  2701.                                                                                 topUp(true);
  2702.                                                                         } else if (walkTo(safeTile, 0)) {
  2703.                                                                                 waitToEat(false);
  2704.                                                                         }
  2705.                                                                         sleep(100, 200);
  2706.                                                                 }
  2707.                                                                 roomSwitch = false;
  2708.                                                         }
  2709.                                                 }
  2710.                                                 secondaryStatus = "";
  2711.                                         } else {
  2712.                                                 if (!isMoving()) {
  2713.                                                         RSTile safety = getNearestTileTo(myLoc(), spots);
  2714.                                                         if (calc.distanceTo(safety) > (combatStyle == Style.MELEE ? 4 : 3)) {
  2715.                                                                 walkToScreen(safety);
  2716.                                                                 if (thunderous != null && thunderous.getMessage() == null)
  2717.                                                                         waitToStart(false);
  2718.                                                         } else attackBoss(thunderous, true);
  2719.                                                 } else attackBoss(thunderous, true);
  2720.                                                 eatFood(topFoods, 50, 0);
  2721.                                         }
  2722.                                 }
  2723.                                 sleep(200, 400);
  2724.                         }
  2725.                 } else if (!unknownBossFight()) {
  2726.                         return;
  2727.                 }
  2728.                 finish = true;
  2729.         }
  2730.  
  2731.         private void warpedBoss() {
  2732.                 if (bossName.equals("Blink") || getObjInRoom(BLINK_PILLARS) != null) {
  2733.                         RSNPC blink;
  2734.                         setBoss("Blink", false);
  2735.                         boolean respawn = true;
  2736.                         RSTile center = bossRoom.getCentralTile();
  2737.                         tempMode = Melee.STAB;
  2738.                         if (combatStyle == Style.MAGIC)
  2739.                                 swapAlternative();
  2740.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2741.                                 if (failSafe())
  2742.                                         return;
  2743.                                 if ((blink = getNpcInRoom(bossName)) == null) {
  2744.                                         RSObject pillar = getObjInRoom(RAISED_PILLARS);
  2745.                                         secondaryStatus = "";
  2746.                                         respawn = true;
  2747.                                         if (pillar == null) {
  2748.                                                 if (doObjAction(getCloseObjTo(center, SUNKEN_PILLARS), "Raise"))
  2749.                                                         waitToStop(false);
  2750.                                         } else {
  2751.                                                 puzzlePoints.clear();
  2752.                                                 topUp(false);
  2753.                                         }
  2754.                                 } else if (respawn || blink.isMoving() || !stringMatch("Attack", blink.getActions())) {
  2755.                                         if (respawn) {
  2756.                                                 RSObject pillar = getObjInRoom(RAISED_PILLARS);
  2757.                                                 boolean aligned = false;
  2758.                                                 safeTile = blink.getLocation();
  2759.                                                 if (pillar != null) {
  2760.                                                         RSTile pTile = pillar.getLocation();
  2761.                                                         aligned = safeTile.getX() == pTile.getX() || safeTile.getY() == pTile.getY();
  2762.                                                 }
  2763.                                                 puzzlePoints.clear();
  2764.                                                 if (aligned) {
  2765.                                                         secondaryStatus = "Got him! Time to dish the pain";
  2766.                                                         for (int c = 0; c < 10; c++) {
  2767.                                                                 if (blink == null || !blink.isMoving() || isDead())
  2768.                                                                         break;
  2769.                                                                 sleep(200, 400);
  2770.                                                         }
  2771.                                                 } else blinkPath(blink);
  2772.                                                 respawn = false;
  2773.                                         }
  2774.                                         if (!puzzlePoints.isEmpty()) {
  2775.                                                 RSTile near = getNearestTileTo(myLoc(), puzzlePoints);
  2776.                                                 if (near != null && calc.distanceTo(near) < 5 && walkToMap(reflect(near, myLoc(), 1),
  2777.  
  2778. 1)) {
  2779.                                                         puzzlePoints.clear();
  2780.                                                         topUp(false);
  2781.                                                 }
  2782.                                         } else topUp(true);
  2783.                                 } else {
  2784.                                         attackBoss(blink, false);
  2785.                                         eatFood(topFoods, 40, 0);
  2786.                                 }
  2787.                                 sleep(100, 300);
  2788.                         }
  2789.                         puzzlePoints.clear();
  2790.                 } else if (bossName.equals("Warped gulega") || getNpcInRoom("Warped gulega") != null) {
  2791.                         RSNPC gulega = getNpcInRoom("Warped gulega");
  2792.                         setBoss("Warped Gulega", true);
  2793.                         setPrayer(true, Style.MAGIC, true);
  2794.                         tempMode = Melee.SLASH;
  2795.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2796.                                 if (failSafe())
  2797.                                         return;
  2798.                                 if (gulega != null) {
  2799.                                         int gAnim = gulega.getAnimation();
  2800.                                         if (gAnim != -1) {
  2801.                                                 if (gAnim == 15004) {
  2802.                                                         RSTile start = myLoc();
  2803.                                                         Timer graphicTimer = new Timer(random(2000, 2500));
  2804.                                                         secondaryStatus = "Analyzing Boss attack data...";
  2805.                                                         while (gulega.getAnimation() == 15004 && calc.distanceTo(start) < 1) {
  2806.                                                                 if (/*gulega.getGraphic() == 2877 &&*/ !graphicTimer.isRunning()) {
  2807.                                                                         secondaryStatus = "Special attack detected - Ruuun!";
  2808.                                                                         if (walkToMap(start, 2))
  2809.                                                                                 waitToStart(false);
  2810.                                                                         walkAdjacentTo(start, 2);
  2811.                                                                         while (gulega != null && !failBasic() && gulega.getAnimation()
  2812.  
  2813. == 15004) {
  2814.                                                                                 attackBoss(gulega, true);
  2815.                                                                                 sleep(300, 600);
  2816.                                                                         }
  2817.                                                                         secondaryStatus = "";
  2818.                                                                         break;
  2819.                                                                 }
  2820.                                                                 sleep(50, 100);
  2821.                                                         }
  2822.                                                         secondaryStatus = "";
  2823.                                                 } else if (developer) {
  2824.                                                         if (gAnim == 15001) {
  2825.                                                         } else if (gAnim == 15007) {
  2826.                                                         }
  2827.                                                 }
  2828.                                         } else {
  2829.                                                 eatFood(topFoods, 50, 0);
  2830.                                                 if (gulega != null && gulega.getAnimation() == -1)
  2831.                                                         attackBoss(gulega, true);
  2832.                                         }
  2833.                                 }
  2834.                                 sleep(100, 200);
  2835.                         }
  2836.                 } else if (bossName.equals("Dreadnaut") || getNpcInRoom("Dreadnaut") != null) {
  2837.                         RSNPC dreadnaut = getNpcInRoom("Dreadnaut");
  2838.                         setBoss("Dreadnaut", false);
  2839.                         swapStyle(Style.MAGIC);
  2840.                         setPrayer(true, Style.MELEE, true);
  2841.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2842.                                 if (failSafe())
  2843.                                         return;
  2844.                                 eatFood(topFoods, 50, 60);
  2845.                                 attackBoss(dreadnaut, true);
  2846.                                 setPrayer(true, Style.MELEE, true);
  2847.                                 sleep(200, 400);
  2848.                         }
  2849.                 } else if (bossName.equals("Hope Devourer") || getNpcInRoom("Hope devourer") != null) {
  2850.                         RSNPC devourer = getNpcInRoom("Hope devourer");
  2851.                         setBoss("Hope Devourer", true);
  2852.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.CRUSH;
  2853.                         prayTimer = new Timer(random(4000, 6000));
  2854.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2855.                                 if (failSafe())
  2856.                                         return;
  2857.                                 if (devourer != null) {
  2858.                                         if (devourer.getMessage() != null) {
  2859.                                                 if (setPrayersOff()) {
  2860.                                                         attackBoss(devourer, true);
  2861.                                                         sleep(600, 1200);
  2862.                                                 }
  2863.                                         } else if (prayTimer != null && devourer.getAnimation() == 14460) {
  2864.                                                 prayTimer = null;
  2865.                                                 if (!eatFood(topFoods, 50, 40))
  2866.                                                         sleep(500, 800);
  2867.                                         } else {
  2868.                                                 setPrayer(true, Style.MELEE, true);
  2869.                                                 eatFood(topFoods, 50, 0);
  2870.                                                 attackBoss(devourer, true);
  2871.                                         }
  2872.                                 }
  2873.                                 sleep(200, 400);
  2874.                         }
  2875.                 } else if (bossName.equals("World-gorger Shukarhazh") || getNpcInRoom("World-gorger shukarhazh") != null) {
  2876.                         RSNPC worldGorger = getNpcInRoom("World-gorger shukarhazh");
  2877.                         setBoss("World-gorger", true);
  2878.                         String[] eyeNames = { "warrior-eye", "ranger-eye", "mage-eye" };
  2879.                         eyeNames[primaryStyle.index()] = null;
  2880.                         tempMode = Melee.STAB;
  2881.                         setPrayer(true, Style.MAGIC, true);
  2882.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2883.                                 if (failSafe())
  2884.                                         return;
  2885.                                 if (worldGorger != null) {
  2886.                                         boolean noneDown = getNpcsInRoom(eyeNames).length == 2;
  2887.                                         int hp = combat.getHealth();
  2888.                                         RSNPC eye = null;
  2889.                                         if (noneDown || hp > 40) {
  2890.                                                 for (int I = 0; I < eyeNames.length; I++) {
  2891.                                                         if (eyeNames[I] == null)
  2892.                                                                 continue;
  2893.                                                         if ((eye = getGoodNpc(eyeNames[I])) == null)
  2894.                                                                 continue;
  2895.                                                         Style style = styleOf(I);
  2896.                                                         if ((style.enabled() && swapStyle(style)) || noneDown || hp > 65)
  2897.                                                                 break;
  2898.                                                         eye = null;
  2899.                                                 }
  2900.                                         }
  2901.                                         if (eye == null)
  2902.                                                 swapStyle(primaryStyle);
  2903.                                         attackBoss(eye != null ? eye : worldGorger, eye == null);
  2904.                                         eatFood(topFoods, 55, 70);
  2905.                                 }
  2906.                                 sleep(200, 400);
  2907.                         }
  2908.                 } else if (bossName.equals("Kal'Ger the Warmonger") || getObjInRoom(56038) != null) {
  2909.                         RSNPC kalger = getNpcInRoom("Kal'Ger the Warmonger");
  2910.                         setBoss("Kal'Ger the Warmonger",false);
  2911.                         Style kStyle = kalgerStyle();
  2912.                         kalgerState(kStyle);
  2913.                         tempMode = Melee.STAB.enabled() ? Melee.STAB : Melee.CRUSH;
  2914.                         if (bossStage == 0) {
  2915.                                 status = "Waiting for the cutscene to finish...";
  2916.                                 setRetaliate(false);
  2917.                                 while ((kalger = getNpcInRoom(bossName)) != null && !reachable(kalger.getLocation(), true)) {
  2918.                                         if (failSafe())
  2919.                                                 return;
  2920.                                         unBacktrack(true);
  2921.                                         sleep(300, 600);
  2922.                                 }
  2923.                                 bossStage = 1;
  2924.                         }
  2925.                         status = "Killing the Warmonger! (Stage " + bossStage + " of 6)";
  2926.                         if (kalger != null && bossID < 1)
  2927.                                 bossID = kalger.getID();
  2928.                         while (objects.getNearest(FINISHED_LADDERS) == null) {
  2929.                                 if (failSafe())
  2930.                                         return;
  2931.                                 if ((kalger = getNpcInRoom(bossName)) != null) {
  2932.                                         String shout = kalger.getMessage();
  2933.                                         if (shout != null && shout.startsWith("GRRR") && combat.getHealth() > random(15, 20)) {
  2934.                                                 secondaryStatus = "Disabling prayers too cool him off";
  2935.                                                 setPrayersOff();
  2936.                                                 prayTimer = new Timer(random(15000, 25000));
  2937.                                         } else if (kalger.getAnimation() == 14968 || calc.distanceBetween(myLoc(), kalger.getLocation
  2938.  
  2939. ()) < 3) {
  2940.                                                 walkTo(reflect(kalger.getLocation(), myLoc(), 1), 1);
  2941.                                         }
  2942.                                         int currStage = bossStage;
  2943.                                         bossStage = (kalger.getID() - bossID + 15) / 15;
  2944.                                         if (bossStage != currStage) {
  2945.                                                 status = "Killing the Warmonger! (Stage " + bossStage + " of 6)";
  2946.                                                 kalgerState(kStyle = kalgerStyle());
  2947.                                         } else if (kalger.getAnimation() == 1) {
  2948.                                                 protection = null;
  2949.                                                 setPrayersOff();
  2950.                                         }
  2951.                                         if (protection != null) {
  2952.                                                 if (prayTimer != null && combat.getHealth() < random(15, 25))
  2953.                                                         prayTimer = null;
  2954.                                                 if (prayTimer == null || !prayTimer.isRunning()) {
  2955.                                                         secondaryStatus = "";
  2956.                                                         setPrayer(true, protection, true);
  2957.                                                 } else setPrayer(true, protection, false);
  2958.                                         }
  2959.                                         if ((combatStyle == Style.MELEE || kStyle == Style.MELEE) && !reachable(kalger.getLocation(),
  2960.  
  2961. true)) {
  2962.                                                 if (player().getAnimation() != 13493) {
  2963.                                                         RSNPC orb = getNpcInRoom(12842);
  2964.                                                         if (orb != null && !myLoc().equals(orb.getLocation())) {
  2965.                                                                 walkTo(orb.getLocation(), 0);
  2966.                                                         } else topUp(true);
  2967.                                                 }
  2968.                                         } else {
  2969.                                                 setPrayer(true, protection, true);
  2970.                                                 eatFood(topFoods, 50, 0);
  2971.                                                 attackBoss(kalger, true);
  2972.                                         }
  2973.                                 }
  2974.                                 sleep(200, 400);
  2975.                         }
  2976.                 } else if (!unknownBossFight()) {
  2977.                         return;
  2978.                 }
  2979.                 finish = true;
  2980.         }
  2981.  
  2982.         @Override
  2983.         public int loop() {
  2984.                 if (!authCheck)
  2985.                         return -1;
  2986.                 if (!verified) {
  2987.                         threadPitch(100);
  2988.                 } else if (game.isLoggedIn()) {
  2989.                         mouse.setSpeed(random(5, 8));
  2990.                         if (inDungeon) {
  2991.                                 getCurrentRoom();
  2992.                                 if (exit) {
  2993.                                         exitDungeon();
  2994.                                         exit = false;
  2995.                                 } else if (finish) {
  2996.                                         finishDungeon();
  2997.                                         finish = false;
  2998.                                 } else if (newDungeon) {
  2999.                                         startDungeon();
  3000.                                         newDungeon = false;
  3001.                                 } else if (settingsFinished) {
  3002.                                         if (bossFight) {
  3003.                                                 safeTile = null;
  3004.                                                 if (getObjInRoom(FINISHED_LADDERS) != null) {
  3005.                                                         finish = true;
  3006.                                                 } else if (floor == Floor.FROZEN) {
  3007.                                                         frozenBoss();
  3008.                                                 } else if (floor == Floor.ABANDONED) {
  3009.                                                         abandonedBoss();
  3010.                                                 } else if (floor == Floor.FURNISHED) {
  3011.                                                         furnishedBoss();
  3012.                                                 } else if (floor == Floor.OCCULT) {
  3013.                                                         occultBoss();
  3014.                                                 } else if (floor == Floor.WARPED) {
  3015.                                                         warpedBoss();
  3016.                                                 }
  3017.                                                 bossFight = false;
  3018.                                                 retrace = false;
  3019.                                         } else if (explore) {
  3020.                                                 exploreRoom();
  3021.                                                 explore = false;
  3022.                                         } else if (open) {
  3023.                                                 if (openNextDoor()) {
  3024.                                                         explore = true;
  3025.                                                 } else retrace = true;
  3026.                                                 nearDoor = null;
  3027.                                                 nearDoor2 = null;
  3028.                                                 doorTimer = null;
  3029.                                                 open = false;
  3030.                                         } else if (retrace) {
  3031.                                                 retraceDungeon();
  3032.                                                 retrace = false;
  3033.                                         } else {
  3034.                                                 if (failSafe())
  3035.                                                         return 100;
  3036.                                                 if (developer)
  3037.                                                         secondaryStatus = "We don't know what to do :(";
  3038.                                                 return random(500, 1000);
  3039.                                         }
  3040.                                 }
  3041.                         } else {
  3042.                                 if (newDungeon && inDungeon()) {
  3043.                                         status = "Starting a new dungeon!";
  3044.                                         inDungeon = true;
  3045.                                 } else if (objects.getNearest(END_STAIRS) != null) {
  3046.                                         status = "Jumping down the stairs...";
  3047.                                         if (doObjAction(objects.getNearest(END_STAIRS), "Jump-down")) {
  3048.                                                 if (waitToStop(true))
  3049.                                                         waitToStop(true);
  3050.                                         }
  3051.                                 } else if (objects.getNearest(ENTRANCE) != null) {
  3052.                                         enterDungeon();
  3053.                                 } else {
  3054.                                         // Failsafe
  3055.                                 }
  3056.                         }
  3057.                 }
  3058.                 secondaryStatus = "";
  3059.                 unreachable = false;
  3060.                 return random(0, 20);
  3061.         }
  3062.  
  3063.         private boolean checkRoom() {
  3064.                 skipRoom = false;
  3065.                 getNewDoorTiles();
  3066.                 doorTimer = null;
  3067.                 if (newRoom == null)
  3068.                         newRoom = targetRoom;
  3069.                 if (newDoors.size() == 0) {
  3070.                         RSObject finishedLadder = getObjInRoom(FINISHED_LADDERS);
  3071.                         RSObject bDoor = getObjInRoom(BOSS_DOORS);
  3072.                         if (finishedLadder != null) {
  3073.                                 log("Dungeon exit ahead!");
  3074.                                 finishDungeon();
  3075.                                 return false;
  3076.                         }
  3077.                         if (bDoor != null) {
  3078.                                 if (bossRoom == null) {
  3079.                                         bossRoom = newRoom;
  3080.                                         bossDoor = nearDoor;
  3081.                                         backDoors.add(bDoor.getLocation());
  3082.                                         openedDoors.add(bossDoor);
  3083.                                         bossPath = generatePath(bossRoom);
  3084.                                         restartCount = 0;
  3085.                                 }
  3086.                                 if (!areaContains(bossRoom, myLoc())) {
  3087.                                         boolean exploreCheck = Option.EXPLORER.enabled() && !goodDoors.isEmpty() && !bossPath.isEmpty
  3088.  
  3089. ();
  3090.                                         secondaryStatus = "Preparing for the boss battle";
  3091.                                         if ((floor != Floor.ABANDONED || getNpcInRoom(SKINWEAVER) == null) && !inTrueCombat())
  3092.                                                 omNomNom();
  3093.                                         if (!skipRoom && !isRushing && (exploreCheck || Option.MAKE_FOOD.enabled()) && !areaContains
  3094.  
  3095. (bossRoom, myLoc())) {
  3096.                                                 if (exploreCheck) {
  3097.                                                         log(BLU, "Boss room found.. Looks like we've got some more exploring to do first!");
  3098.                                                         makeGatestone();
  3099.                                                         setTargetRoom(currentRoom);
  3100.                                                         disableBossPath = true;
  3101.                                                         return true;
  3102.                                                 }
  3103.                                                 if (inventory.contains(GGS) && readyToCook()) {
  3104.                                                         log(BLU, "Boss room found.. Returning home to prepare food before taking them on!");
  3105.                                                         setTargetRoom(currentRoom);
  3106.                                                         teleHome(true);
  3107.                                                         return true;
  3108.                                                 }
  3109.                                         }
  3110.                                 }
  3111.                                 if (!prepareForBoss())
  3112.                                         return true;
  3113.                                 finishedRooms.remove(newRoom);
  3114.                                 open = false;
  3115.                                 explore = false;
  3116.                                 bossFight = true;
  3117.                                 return retrace = false;
  3118.                         }
  3119.                         RSTile kTile = getKey();
  3120.                         if (kTile != null) {
  3121.                                 secondaryStatus = "Grabbing a key from the dead end";
  3122.                                 if (areaContains(targetRoom, myLoc()))
  3123.                                         walkToMap(kTile, 1);
  3124.                                 selectTab(Game.TAB_INVENTORY, 3);
  3125.                                 walking.setRun(true);
  3126.                                 skipRoom = true;
  3127.                         } else {
  3128.                                 secondaryStatus = "Skipping the dead end";
  3129.                                 finishedDoors.add(nearDoor);
  3130.                                 openedDoors.removeAll(finishedDoors);
  3131.                                 goodDoors.removeAll(finishedDoors);
  3132.                                 allDoors.removeAll(finishedDoors);
  3133.                                 skipRoom = true;
  3134.                                 skipRooms.add(targetRoom);
  3135.                                 setTargetRoom(currentRoom);
  3136.                                 newRoom = null;
  3137.                                 return true;
  3138.                         }
  3139.                 }
  3140.                 return false;
  3141.         }
  3142.  
  3143.         private void clearAll() {
  3144.                 newObjects = new ArrayList<RSObject>();
  3145.                 blockedDoors.clear();
  3146.                 allDoors.clear();
  3147.                 goodDoors.clear();
  3148.                 newDoors.clear();
  3149.                 openedDoors.clear();
  3150.                 lockedDoors.clear();
  3151.                 backDoors.clear();
  3152.                 finishedDoors.clear();
  3153.                 drawDoors.clear();
  3154.                 deathPath.clear();
  3155.                 bossPath.clear();
  3156.                 oldObjectTiles.clear();
  3157.                 newObjectTiles.clear();
  3158.                 rooms.clear();
  3159.                 finishedRooms.clear();
  3160.                 puzzleRooms.clear();
  3161.                 clearedRooms.clear();
  3162.                 chasmRooms.clear();
  3163.                 skipRooms.clear();
  3164.                 finishedPuzzles.clear();
  3165.                 unBacktrackable.clear();
  3166.                 badTiles.clear();
  3167.                 lockIDs.clear();
  3168.                 startRoom = null;
  3169.                 currentRoom = null;
  3170.                 targetRoom = null;
  3171.                 groupRoom = null;
  3172.                 oldRoom = null;
  3173.                 bossRoom = null;
  3174.                 nearMonster = null;
  3175.                 nearDoor = null;
  3176.                 nearDoor2 = null;
  3177.                 safeTile = null;
  3178.                 nearItem = null;
  3179.                 bossDoor = null;
  3180.                 oldDoor = null;
  3181.                 puzzleTimer = null;
  3182.                 bossHp = 100;
  3183.                 roomNumber = 0;
  3184.                 bossID = 0;
  3185.                 restarts = 0;
  3186.                 restartCount = 0;
  3187.                 bossStage = 0;
  3188.                 tempMode = Melee.NONE;
  3189.                 if (temporarySecondary)
  3190.                         secondaryWep = -1;
  3191.                 bossName = "";
  3192.                 secondaryStatus = "";
  3193.                 aborted = false;
  3194.                 retrace = false;
  3195.                 explore = false;
  3196.                 open = false;
  3197.                 bossFight = false;
  3198.                 finish = false;
  3199.                 exit = false;
  3200.                 skipRoom = false;
  3201.                 skipDoorFound = false;
  3202.                 isDead = false;
  3203.                 outOfAmmo = false;
  3204.                 disrobed = false;
  3205.                 newDungeon = true;
  3206.                 cookReady = false;
  3207.                 roomSwitch = false;
  3208.                 spawnRoom = false;
  3209.                 disableBossPath = false;
  3210.                 failTimer = new Timer(random(360000, 480000));
  3211.                 idleTimer = new Timer(0);
  3212.                 prayTimer = null;
  3213.                 combatStyle = styleOf(primaryStyle.index());
  3214.         }
  3215.  
  3216.         private boolean fightMonsters() {
  3217.                 boolean activated = false, primariesCleared = false, secondariesCleared = false;
  3218.                 if (finishedRooms.contains(targetRoom))
  3219.                         return true;
  3220.                 nearMonster = npcs.getNearest(monster);
  3221.                 unreachable = false;
  3222.                 if (nearMonster != null) {
  3223.                         crossTheChasm(nearMonster.getLocation());
  3224.                         secondaryStatus = "Clearing the room of monsters";
  3225.                         while (npcs.getNearest(monster) != null) {
  3226.                                 if (failSafe())
  3227.                                         return false;
  3228.                                 if (!isGoodMonster(nearMonster)) {
  3229.                                         if (!secondariesCleared) {
  3230.                                                 RSNPC primary = !primariesCleared ? npcs.getNearest(primaryMonster) : null;
  3231.                                                 if (primary == null) {
  3232.                                                         RSNPC secondary = npcs.getNearest(secondaryMonster);
  3233.                                                         primariesCleared = true;
  3234.                                                         if (secondary == null) {
  3235.                                                                 secondariesCleared = true;
  3236.                                                                 nearMonster = npcs.getNearest(monster);
  3237.                                                         } else nearMonster = secondary;
  3238.                                                 } else nearMonster = primary;
  3239.                                         } else nearMonster = npcs.getNearest(monster);
  3240.                                 }
  3241.                                 if (unreachable) {
  3242.                                         topUp(true);
  3243.                                         unreachable = false;
  3244.                                 } else if (attackNpc(nearMonster)) {
  3245.                                         getBestStyle(nearMonster);
  3246.                                         if (!updateFightMode())
  3247.                                                 sleep(900, 1400);
  3248.                                 }
  3249.                                 if (Option.PRAY.enabled()) {
  3250.                                         monsterPrayer();
  3251.                                         if (protection != null) {
  3252.                                                 if (setPrayer(false, protection, getGoodNpc(strongestMonster) != null))
  3253.                                                         activated = true;
  3254.                                         } else if (activated) {
  3255.                                                 activated = setPrayersOff();
  3256.                                         }
  3257.                                 }
  3258.                                 if (status.startsWith("Puzzle room: Follow")) {
  3259.                                         RSObject obj = objects.getTopAt(myLoc());
  3260.                                         if (obj != null && intMatch(obj.getID(), ACTIVE_PADS))
  3261.                                                 walkAdjacentTo(myLoc(), 2);
  3262.                                 }
  3263.                                 eatFood(goodFoods, 45, 55);
  3264.                                 sleep(200, 400);
  3265.                         }
  3266.                         if (activated)
  3267.                                 setPrayersOff();
  3268.                         nearMonster = null;
  3269.                         double mDist = random(3, 7);
  3270.                         while (npcs.getNearest(dying) != null) {
  3271.                                 if (failSafe())
  3272.                                         return false;
  3273.                                 if (inventory.getCount() < 27 || !topUp(false)) {
  3274.                                         getGoodItem();
  3275.                                         if (nearItem != null && calc.distanceTo(nearItem.getLocation()) < mDist) {
  3276.                                                 if (pickUpItem(nearItem))
  3277.                                                         waitToStop(false);
  3278.                                         } else if (!topUp(false) || getGoodItem() == null) {
  3279.                                                 sleep(300, 600);
  3280.                                         }
  3281.                                 } else sleep(300, 600);
  3282.                         }
  3283.  
  3284.                         secondaryStatus = "";
  3285.                 }
  3286.                 return true;
  3287.         }
  3288.  
  3289.         private boolean unknownBossFight() {
  3290.                 setBoss("an unknown boss...", false);
  3291.                 setPrayer(true, null, false);
  3292.                 return genericBossFight();
  3293.         }
  3294.  
  3295.         private boolean genericBossFight() {
  3296.                 RSNPC boss = npcs.getNearest(bossMonster);
  3297.                 while (objects.getNearest(FINISHED_LADDERS) == null) {
  3298.                         if (failSafe())
  3299.                                 return false;
  3300.                         if (unreachable) {
  3301.                                 if (!topUp(true))
  3302.                                         sleep(500, 1000);
  3303.                                 unreachable = false;
  3304.                         }
  3305.                         attackBoss(boss, true);
  3306.                         eatFood(goodFoods, 50, 60);
  3307.                         sleep(400, 800);
  3308.                 }
  3309.                 return finish = true;
  3310.         }
  3311.  
  3312.         private int getBestDoor() {
  3313.                 int[] puzzleDoors = floor != Floor.WARPED ? PUZZLE_DOORS : WARPED_PUZZLE_DOORS;
  3314.                 double dist = 99.99;
  3315.                 int doorID = -1;
  3316.                 RSTile nextDoor = null, start = myLoc();
  3317.                 destDoor = null;
  3318.                 nearDoor = null;
  3319.                 nearDoor2 = null;
  3320.                 ArrayList<RSTile> goodRoomDoors = new ArrayList<RSTile>();
  3321.                 for (RSTile gDoor : goodDoors) {
  3322.                         if (areaContains(targetRoom, gDoor))
  3323.                                 goodRoomDoors.add(gDoor);
  3324.                 }
  3325.                 if (!goodRoomDoors.isEmpty()) {
  3326.                         for (RSTile door : goodRoomDoors) {
  3327.                                 double dDist = calc.distanceBetween(start, door);
  3328.                                 if (dDist < dist) {
  3329.                                         RSObject doorObj = objects.getTopAt(door);
  3330.                                         if (doorObj != null) {
  3331.                                                 dist = dDist;
  3332.                                                 doorID = doorObj.getID();
  3333.                                                 nextDoor = door;
  3334.                                         }
  3335.                                 }
  3336.                         }
  3337.                         if (nextDoor != null && doorID > 0) {
  3338.                                 for (RSTile bDoor : blockedDoors) {
  3339.                                         if (calc.distanceBetween(nextDoor, bDoor) < 3) {
  3340.                                                 nearDoor = nextDoor;
  3341.                                                 nearDoor2 = bDoor;
  3342.                                                 destDoor = nearDoor2;
  3343.                                                 return 2;
  3344.                                         }
  3345.                                 }
  3346.                                 for (RSTile lDoor : lockedDoors) {
  3347.                                         if (calc.distanceBetween(nextDoor, lDoor) < 3) {
  3348.                                                 nearDoor = nextDoor;
  3349.                                                 nearDoor2 = lDoor;
  3350.                                                 destDoor = nearDoor2;
  3351.                                                 return 3;
  3352.                                         }
  3353.                                 }
  3354.                                 if (intMatch(doorID, STANDARD_DOORS)) {
  3355.                                         nearDoor = nextDoor;
  3356.                                         destDoor = nearDoor;
  3357.                                         return 1;
  3358.                                 }
  3359.                                 if (skillDoors.contains(nextDoor)) {
  3360.                                         nearDoor = nextDoor;
  3361.                                         destDoor = nearDoor;
  3362.                                         return 4;
  3363.                                 }
  3364.                                 if (intMatch(doorID, puzzleDoors)) {
  3365.                                         nearDoor = nextDoor;
  3366.                                         destDoor = nearDoor;
  3367.                                         return 1;
  3368.                                 }
  3369.                         }
  3370.                 }
  3371.                 boolean verifyBoss = disableBossPath && bossDoor != null;
  3372.                 for (RSTile door : openedDoors) {
  3373.                         if ((!verifyBoss || !bossDoor.equals(door)) && (oldDoor == null || !door.equals(oldDoor)) && areaContains
  3374.  
  3375. (targetRoom, door)) {
  3376.                                 RSArea room = getNextRoom(door);
  3377.                                 if (room != null && (roomContains(room, goodDoors) || roomContains(room, openedDoors))) {
  3378.                                         nearDoor = door;
  3379.                                         destDoor = nearDoor;
  3380.                                         return 5;
  3381.                                 }
  3382.                         }
  3383.                 }
  3384.                 return 0;
  3385.         }
  3386.  
  3387.         private void getNewDoorTiles() {
  3388.                 int[] puzzleDoors = floor != Floor.WARPED ? PUZZLE_DOORS : WARPED_PUZZLE_DOORS;
  3389.                 newDoors.clear();
  3390.                 nextObj:for (RSObject obj : newObjects) {
  3391.                         int objID = obj.getID();
  3392.                         RSTile objTile = obj.getLocation();
  3393.                         if (intMatch(objID, BASIC_DOORS)) {
  3394.                                 if (nearDoor != null && calc.distanceBetween(nearDoor, objTile) < 4) {
  3395.                                         backDoors.add(objTile);
  3396.                                         continue nextObj;
  3397.                                 }
  3398.                                 newDoors.add(objTile);
  3399.                                 goodDoors.add(objTile);
  3400.                                 continue nextObj;
  3401.                         }
  3402.                         if (intMatch(objID, GUARDIAN_DOORS)) {
  3403.                                 guardianDoors.add(objTile);
  3404.                                 newDoors.add(objTile);
  3405.                                 goodDoors.add(objTile);
  3406.                                 continue nextObj;
  3407.                         }
  3408.                         for (int[] color : KEY_DOORS) {
  3409.                                 if (intMatch(objID - floor.diff(), color)) {
  3410.                                         newDoors.add(objTile);
  3411.                                         continue nextObj;
  3412.                                 }
  3413.                                 if (intMatch(objID, color)) {
  3414.                                         lockIDs.add(objID);
  3415.                                         lockedDoors.add(objTile);
  3416.                                         continue nextObj;
  3417.                                 }
  3418.                         }
  3419.                         if (aComplexity > 4) {
  3420.                                 if (intMatch(objID, FREE_BLOCK_DOORS)) {
  3421.                                         blockedDoors.add(objTile);
  3422.                                 } else if (intMatch(objID, MEMBER_BLOCK_DOORS)) {
  3423.                                         if (memberWorld) {
  3424.                                                 blockedDoors.add(objTile);
  3425.                                         } else finishedDoors.add(objTile);
  3426.                                 } else if (intMatch(objID, PRAYER_DOORS)) {
  3427.                                         if (!Option.PRAY_DOORS.enabled()) {
  3428.                                                 finishedDoors.add(objTile);
  3429.                                                 skipDoorFound = true;
  3430.                                         } else blockedDoors.add(objTile);
  3431.                                 } else if (intMatch(objID, SUMMON_DOORS)) {
  3432.                                         if (!Option.SUMMON.enabled()) {
  3433.                                                 finishedDoors.add(objTile);
  3434.                                                 skipDoorFound = true;
  3435.                                         } else blockedDoors.add(objTile);
  3436.                                 } else if (intMatch(objID, FREE_SKILL_DOORS)) {
  3437.                                         skillDoors.add(objTile);
  3438.                                         newDoors.add(objTile);
  3439.                                         goodDoors.add(objTile);
  3440.                                 } else if (intMatch(objID, MEMBER_SKILL_DOORS)) {
  3441.                                         if (memberWorld) {
  3442.                                                 skillDoors.add(objTile);
  3443.                                                 newDoors.add(objTile);
  3444.                                                 goodDoors.add(objTile);
  3445.                                         } else finishedDoors.add(objTile);
  3446.                                 } else if (intMatch(objID, puzzleDoors)) {
  3447.                                         newDoors.add(objTile);
  3448.                                         goodDoors.add(objTile);
  3449.                                 }
  3450.                         }
  3451.                 }
  3452.                 newObjectTiles.clear();
  3453.                 newObjects.clear();
  3454.                 ArrayList<RSTile> removals = new ArrayList<RSTile>();
  3455.                 for (RSTile fDoor : finishedDoors) {
  3456.                         if (areaContains(newRoom, fDoor)) {
  3457.                                 for (RSTile nDoor : newDoors) {
  3458.                                         if (calc.distanceBetween(nDoor, fDoor) < 4)
  3459.                                                 removals.add(nDoor);
  3460.                                 }
  3461.                         }
  3462.                 }
  3463.                 finishedDoors.addAll(removals);
  3464.                 drawDoors.addAll(removals);
  3465.                 newDoors.removeAll(finishedDoors);
  3466.                 goodDoors.removeAll(finishedDoors);
  3467.                 drawDoors.addAll(blockedDoors);
  3468.                 drawDoors.addAll(lockedDoors);
  3469.                 drawDoors.addAll(newDoors);
  3470.                 allDoors.addAll(newDoors);
  3471.                 if (nearDoor != null) {
  3472.                         openedDoors.add(nearDoor);
  3473.                         goodDoors.remove(nearDoor);
  3474.                         oldDoor = nearDoor;
  3475.                 }
  3476.                 return;
  3477.         }
  3478.  
  3479.         private boolean getNewRoomArea() {
  3480.                 boolean newDoor = false;
  3481.                 if (currentRoom != null && nearDoor != null) {
  3482.                         for (RSObject o : objects.getAll()) {
  3483.                                 if (o != null && intMatch(o.getID(), BACK_DOORS) && calc.distanceBetween(o.getLocation(), nearDoor) <
  3484.  
  3485. 3 && !areaContains(currentRoom, o.getLocation())) {
  3486.                                         newDoor = true;
  3487.                                         break;
  3488.                                 }
  3489.                         }
  3490.                 }
  3491.                 if (!newDoor && rooms.size() > 0)
  3492.                         return false;
  3493.                 if (game.getClientState() == 11) {
  3494.                         while (game.getClientState() == 11) {
  3495.                                 sleep(200, 300);
  3496.                         }
  3497.                         sleep(300);
  3498.                 }
  3499.                 sleep(400);
  3500.                 for (RSObject obj : objects.getAll(roomObjects)) {
  3501.                         RSTile objTile = obj.getLocation();
  3502.                         if (!oldObjectTiles.contains(objTile)) {
  3503.                                 newObjectTiles.add(objTile);
  3504.                                 newObjects.add(obj);
  3505.                         }
  3506.                 }
  3507.                 if (newObjectTiles.size() > 60) {
  3508.                         int swX = 20000, swY = 20000;
  3509.                         for (RSTile t : newObjectTiles) {
  3510.                                 if (t.getX() <= swX && t.getY() <= swY) {
  3511.                                         swX = t.getX();
  3512.                                         swY = t.getY();
  3513.                                 }
  3514.                         }
  3515.                         newRoom = new RSArea(swX, swY, swX + 15, swY + 15);
  3516.                         rooms.add(newRoom);
  3517.                         if (dropItem(GUARD_KEY) && bounds.contains((Integer) GUARD_KEY))
  3518.                                 bounds.remove((Integer) GUARD_KEY);
  3519.                         setTargetRoom(newRoom);
  3520.                         oldObjectTiles.addAll(newObjectTiles);
  3521.                         restartCount = 0;
  3522.                         restarts = 0;
  3523.                         failTimer.reset();
  3524.                         doorTimer = null;
  3525.                         return true;
  3526.                 }
  3527.                 return false;
  3528.         }
  3529.  
  3530.         private boolean openBasicDoor() {
  3531.                 status = "Opening a standard door";
  3532.                 while (!areaContains(newRoom, myLoc())) {
  3533.                         if (failSafe() || nearDoor == null)
  3534.                                 return false;
  3535.                         if (areaContains(getCurrentRoom(), nearDoor)) {
  3536.                                 if (calc.distanceTo(nearDoor) > 4) {
  3537.                                         lastMessage = "";
  3538.                                 } else if (lastMessage.contains("guardians")) {
  3539.                                         if (npcs.getNearest(monster) != null) {
  3540.                                                 if (!fightMonsters() || !pickUpAll())
  3541.                                                         return false;
  3542.                                                 doorTimer = new Timer(0);
  3543.                                         } else {
  3544.                                                 log("Unkillable Guardians, removing door.");
  3545.                                                 finishedDoors.add(nearDoor);
  3546.                                                 allDoors.remove(nearDoor);
  3547.                                                 openedDoors.remove(nearDoor);
  3548.                                                 goodDoors.remove(nearDoor);
  3549.                                                 return true;
  3550.                                         }
  3551.                                         lastMessage = "";
  3552.                                 } else if (unreachable && calc.tileOnScreen(nearDoor)) {
  3553.                                         if (calc.distanceTo(nearDoor) < 4) {
  3554.                                                 camera.moveRandomly(random(800, 1400));
  3555.                                                 clickTile(nearDoor, "");
  3556.                                         } else walkToMap(nearDoor, 1);
  3557.                                         unreachable = false;
  3558.                                 } else if (lastMessage.contains("not open") || lastMessage.contains("won't open")) {
  3559.                                         log("Undetected puzzle door, removing!");
  3560.                                         if (developer)
  3561.                                                 env.saveScreenshot(false);
  3562.                                         finishedDoors.add(nearDoor);
  3563.                                         allDoors.remove(nearDoor);
  3564.                                         goodDoors.remove(nearDoor);
  3565.                                         waitForResponse();
  3566.                                         return true;
  3567.                                 } else if (lastMessage.contains("don't have the correct")) {
  3568.                                         log.severe("Hmm.. we got tricked, we don't have the right key!");
  3569.                                         finishedDoors.add(nearDoor);
  3570.                                         finishedDoors.add(nearDoor2);
  3571.                                         goodDoors.remove(nearDoor);
  3572.                                         return true;
  3573.                                 }
  3574.                                 if (doObjAction(objects.getTopAt(nearDoor))) {
  3575.                                         waitToObject(false);
  3576.                                         if (waitForRoom(false))
  3577.                                                 return true;
  3578.                                 } else while (isMoving() && !calc.tileOnScreen(nearDoor)) {
  3579.                                         sleep(100, 200);
  3580.                                 }
  3581.                         }
  3582.                         sleep(100, 200);
  3583.                 }
  3584.                 return true;
  3585.         }
  3586.  
  3587.         private boolean openBlockedDoor() {
  3588.                 RSObject block;
  3589.                 status = "Opening a blocked door";
  3590.                 while ((block = objects.getTopAt(nearDoor2)) != null) {
  3591.                         if (failSafe())
  3592.                                 return false;
  3593.                         if (intMatch(player().getAnimation(), BLOCK_ANIMS))
  3594.                                 break;
  3595.                         if (calc.distanceTo(nearDoor2) < 4 && (getName(block).isEmpty() || block.getArea().getTileArray().length !=
  3596.  
  3597. 2))
  3598.                                 break;
  3599.                         if (!doorCheck()) {
  3600.                                 finishedDoors.add(nearDoor2);
  3601.                                 allDoors.remove(nearDoor2);
  3602.                                 openedDoors.remove(nearDoor2);
  3603.                                 goodDoors.remove(nearDoor2);
  3604.                                 drawDoors.remove(nearDoor);
  3605.                                 return true;
  3606.                         }
  3607.                         if (doObjAction(block)) {
  3608.                                 if (!waitToObject(false))
  3609.                                         continue;
  3610.                                 eatFood(foods, 50, 50);
  3611.                         } else {
  3612.                                 while (block != null && isMoving() && !block.isOnScreen()) {
  3613.                                         sleep(100, 200);
  3614.                                 }
  3615.                         }
  3616.                         waitForDamage();
  3617.                         sleep(100, 200);
  3618.                 }
  3619.                 drawDoors.remove(nearDoor2);
  3620.                 allDoors.remove(nearDoor2);
  3621.                 blockedDoors.remove(nearDoor2);
  3622.                 goodDoors.remove(nearDoor2);
  3623.                 openedDoors.remove(nearDoor2);
  3624.                 doorTimer = new Timer(0);
  3625.                 int attempts = 0;
  3626.                 while (!areaContains(newRoom, myLoc())) {
  3627.                         if (failSafe())
  3628.                                 return false;
  3629.                         if (areaContains(getCurrentRoom(), nearDoor)) {
  3630.                                 RSObject door = objects.getTopAt(nearDoor);
  3631.                                 if (door != null) {
  3632.                                         if (doorTimer != null && attempts < 10 && doorTimer.getElapsed() > 30000) {
  3633.                                                 door = getObjInRoom(FREE_BLOCK_DOORS);
  3634.                                                 if (door == null || calc.distanceTo(door) > 2) {
  3635.                                                         door = getObjInRoom(MEMBER_BLOCK_DOORS);
  3636.                                                         if (door != null && calc.distanceTo(door) > 2)
  3637.                                                                 door = null;
  3638.                                                 }
  3639.                                                 attempts ++;
  3640.                                                 unreachable = false;
  3641.                                         }
  3642.                                         if (doObjAction(door)) {
  3643.                                                 waitToObject(false);
  3644.                                                 if (waitForRoom(false))
  3645.                                                         return true;
  3646.                                         } else while (isMoving() && !calc.tileOnScreen(nearDoor)) {
  3647.                                                 sleep(100, 200);
  3648.                                         }
  3649.                                 }
  3650.                         }
  3651.                         sleep(100, 200);
  3652.                 }
  3653.                 return true;
  3654.         }
  3655.  
  3656.         private boolean openLockedDoor() {
  3657.                 status = "Opening a locked door";
  3658.                 lockDown = false;
  3659.                 while (!lockDown) {
  3660.                         if (failSafe())
  3661.                                 return false;
  3662.                         if (player().getAnimation() == 13798)
  3663.                                 break;
  3664.                         RSObject lock = objects.getTopAt(nearDoor2);
  3665.                         if (calc.distanceTo(nearDoor2) < 4 && (getName(lock).isEmpty() || lock.getArea().getTileArray().length != 2))
  3666.                                 break;
  3667.                         if (lastMessage.contains("don't have the correct")) {
  3668.                                 log.severe("Hmm.. we got tricked, we don't have the right key!");
  3669.                                 goodDoors.remove(nearDoor);
  3670.                                 goodDoors.remove(nearDoor2);
  3671.                                 return true;
  3672.                         }
  3673.                         if (doObjAction(lock)) {
  3674.                                 waitToAnimate();
  3675.                                 if (player().getAnimation() == 13798)
  3676.                                         break;
  3677.                                 waitToObject(false);
  3678.                         } else while (lock != null && isMoving() && !lock.isOnScreen()) {
  3679.                                 sleep(100, 200);
  3680.                         }
  3681.                         sleep(200, 400);
  3682.                 }
  3683.                 int attempts = 0;
  3684.                 lockDown = false;
  3685.                 drawDoors.remove(nearDoor2);
  3686.                 allDoors.remove(nearDoor2);
  3687.                 goodDoors.remove(nearDoor2);
  3688.                 lockedDoors.remove(nearDoor2);
  3689.                 doorTimer = new Timer(0);
  3690.                 while (!areaContains(newRoom, myLoc())) {
  3691.                         if (failSafe())
  3692.                                 return false;
  3693.                         RSObject door = objects.getTopAt(nearDoor);
  3694.                         if (door != null) {
  3695.                                 if (unreachable || (doorTimer != null && attempts < 10 && doorTimer.getElapsed() > 30000)) {
  3696.                                         door = getObjInRoom(door.getID() - floor.diff());
  3697.                                         if (door == null)
  3698.                                                 door = objects.getTopAt(nearDoor2);
  3699.                                         unreachable = false;
  3700.                                         attempts++;
  3701.                                 }
  3702.                                 if (doObjAction(door)) {
  3703.                                         waitToObject(false);
  3704.                                         if (waitForRoom(false))
  3705.                                                 return true;
  3706.                                 }
  3707.                         }
  3708.                         sleep(200, 400);
  3709.                         getCurrentRoom();
  3710.                 }
  3711.                 return true;
  3712.         }
  3713.  
  3714.         private boolean openSkillDoor() {
  3715.                 status = "Opening a skill door";
  3716.                 while (!areaContains(newRoom, myLoc())) {
  3717.                         if (failSafe())
  3718.                                 return false;
  3719.                         if (!doorCheck())
  3720.                                 return true;
  3721.                         if (lastMessage.contains("need an empty vial")) {
  3722.                                 if (inventory.contains(ANTIPOISON)) {
  3723.                                         ridItem(ANTIPOISON, "Drink");
  3724.                                 } else {
  3725.                                         finishedDoors.add(nearDoor);
  3726.                                         allDoors.remove(nearDoor);
  3727.                                         openedDoors.remove(nearDoor);
  3728.                                         goodDoors.remove(nearDoor);
  3729.                                         return true;
  3730.                                 }
  3731.                         }
  3732.                         if (areaContains(getCurrentRoom(), nearDoor)) {
  3733.                                 RSObject door = objects.getTopAt(nearDoor);
  3734.                                 if (door != null) {
  3735.                                         if (doObjAction(door)) {
  3736.                                                 waitToObject(true);
  3737.                                                 if (newRoom == null && staticDamage() && (intMatch(door.getID(), FREE_SKILL_DOORS) ||
  3738.  
  3739. intMatch(door.getID(), MEMBER_SKILL_DOORS)))
  3740.                                                         topUp(true);
  3741.                                                 if (waitForRoom(true))
  3742.                                                         return true;
  3743.                                         } else while (door != null && isMoving() && !door.isOnScreen()) {
  3744.                                                 sleep(100, 200);
  3745.                                         }
  3746.                                         if (!doorCheck())
  3747.                                                 return true;
  3748.                                 }
  3749.                         }
  3750.                         eatFood(foods, 40, 50);
  3751.                         sleep(200, 400);
  3752.                 }
  3753.                 oldDoor = nearDoor;
  3754.                 return true;
  3755.         }
  3756.  
  3757.         private boolean openOldDoor() {
  3758.                 if (!status.contains("Opening"))
  3759.                         status = "Opening an old door";
  3760.                 for (RSArea room : rooms) {
  3761.                         if (!areaEquals(room, oldRoom) && calc.distanceBetween(nearDoor, room.getNearestTile(nearDoor)) < 3) {
  3762.                                 newRoom = room;
  3763.                                 break;
  3764.                         }
  3765.                 }
  3766.                 if (newRoom == null)
  3767.                         return false;
  3768.                 doorTimer = new Timer(0);
  3769.                 o:while (!areaContains(newRoom, myLoc())) {
  3770.                         if (failSafe())
  3771.                                 return false;
  3772.                         if (areaContains(getCurrentRoom(), nearDoor)) {
  3773.                                 if (doObjAction(objects.getTopAt(nearDoor))) {
  3774.                                         waitToObject(false);
  3775.                                         for (int i = 0; i < 4; i++) {
  3776.                                                 if (areaContains(newRoom, myLoc()))
  3777.                                                         break o;
  3778.                                                 sleep(200, 250);
  3779.                                         }
  3780.                                 } else {
  3781.                                         while (isMoving() && !calc.tileOnScreen(nearDoor)) {
  3782.                                                 topUp(false);
  3783.                                                 sleep(100, 200);
  3784.                                         }
  3785.                                 }
  3786.                         }
  3787.                         sleep(200, 400);
  3788.                 }
  3789.                 setTargetRoom(getCurrentRoom());
  3790.                 newRoom = null;
  3791.                 openedDoors.remove(nearDoor);
  3792.                 openedDoors.add(nearDoor);
  3793.                 oldDoor = nearDoor;
  3794.                 return true;
  3795.         }
  3796.  
  3797.         private boolean pickUpAll() {
  3798.                 if (getGoodItem() == null || (finishedRooms.contains(targetRoom) && (puzzleRooms.contains(targetRoom) || !reachable
  3799.  
  3800. (nearItem.getLocation(), true))))
  3801.                         return true;
  3802.                 boolean guardian = npcs.getNearest(guardians) != null;
  3803.                 int invCheck = inventory.getCount(true);
  3804.                 RSTile iTile = nearItem.getLocation();
  3805.                 improveEquipment();
  3806.                 crossTheChasm(iTile);
  3807.                 if (secondaryStatus.isEmpty()) {
  3808.                         secondaryStatus = "Picking up food & keys";
  3809.                         if (Option.BONES.enabled())
  3810.                                 secondaryStatus += " & bones";
  3811.                         if (Option.ARROWS.enabled())
  3812.                                 secondaryStatus += " & arrows";
  3813.                 }
  3814.                 Timer pickupTimer = new Timer(0);
  3815.                 unreachable = false;
  3816.                 o:while (getGoodItem() != null) {
  3817.                         if (failSafe())
  3818.                                 return false;
  3819.                         if (pickupTimer.getElapsed() > random(30000, 90000) || secondaryStatus.contains("reengage"))
  3820.                                 return true;
  3821.                         iTile = nearItem.getLocation();
  3822.                         makeSpace(!skipRoom);
  3823.                         if (pickUpItem(nearItem)) {
  3824.                                 if (calc.distanceTo(iTile) > 2 && !waitToStart(false))
  3825.                                         unStick();
  3826.                                 while (isMoving() && calc.distanceTo(iTile) > 2) {
  3827.                                         if (guardian && player().getInteracting() != null)
  3828.                                                 continue o;
  3829.                                         sleep(100, 200);
  3830.                                 }
  3831.                                 sleep(0, 300);
  3832.                                 if (unreachable) {
  3833.                                         walkToMap(iTile, 1);
  3834.                                         waitToStart(false);
  3835.                                         unreachable = false;
  3836.                                 } else {
  3837.                                         for (int c = 0; c < (!isMoving() && myLoc().equals(iTile) ? 4 : 8); c++) {
  3838.                                                 if (inventory.getCount(true) > invCheck) {
  3839.                                                         improveEquipment();
  3840.                                                         break;
  3841.                                                 }
  3842.                                                 sleep(200, 300);
  3843.                                                 if (!isMoving()) {
  3844.                                                         if (roomNumber != 1 && !myLoc().equals(iTile))
  3845.                                                                 break;
  3846.                                                         c++;
  3847.                                                 } else if (guardian && player().getInteracting() != null) {
  3848.                                                         continue o;
  3849.                                                 }
  3850.                                         }
  3851.                                 }
  3852.                         } else {
  3853.                                 if (roomNumber == 1)
  3854.                                         threadDefault();
  3855.                                 unStick();
  3856.                         }
  3857.                         if (!isMoving() && calc.distanceTo(iTile) > 2 && reachable(iTile, true) && pickupTimer.getElapsed() > random
  3858.  
  3859. (3000, 6000))
  3860.                                 walkTo(iTile, 2);
  3861.                         if (inventory.getCount(true) > invCheck || isMoving()) {
  3862.                                 invCheck = inventory.getCount(true);
  3863.                                 pickupTimer = new Timer(0);
  3864.                         } else if (pickupTimer.getElapsed() > random(14000, 20000)) {
  3865.                                 getCurrentRoom();
  3866.                                 unStick();
  3867.                                 if (calc.distanceTo(iTile) > 1 && reachable(iTile, true)) {
  3868.                                         walkBlockedTile(iTile, 2);
  3869.                                 } else if (!badTiles.contains(iTile)) {
  3870.                                         pickupTimer = new Timer(0);
  3871.                                         badTiles.add(iTile);
  3872.                                 }
  3873.                         }
  3874.                         sleep(200, 300);
  3875.                 }
  3876.                 if (skipRoom)
  3877.                         eatFood(foods, 30, 30);
  3878.                 improveArmorWielding();
  3879.                 improveWeaponBinding();
  3880.                 secondaryStatus = "";
  3881.                 return true;
  3882.         }
  3883.  
  3884.         private boolean resetPrestige() {
  3885.                 if (Option.PRESTIGE.enabled()) {
  3886.                         secondaryStatus = "Resetting prestige";
  3887.                         while (cProg != 0) {
  3888.                                 if (failBasic())
  3889.                                         return false;
  3890.                                 if (dungeonCount > 5 && password.isEmpty()) {
  3891.                                         walkTo(ORIGIN, 1000);
  3892.                                 } else if (interfaces.get(213).isValid()) {
  3893.                                         interfaces.getComponent(213, 5).interact("Continue");
  3894.                                 } else if (interfaces.get(228).isValid()) {
  3895.                                         interfaces.getComponent(228, 2).interact("Continue");
  3896.                                 } else if (openPartyTab()) {
  3897.                                         clickComponent(interfaces.getComponent(939, 87), "Reset");
  3898.                                 }
  3899.                                 sleep(600, 1000);
  3900.                                 updateProgress();
  3901.                         }
  3902.                         prestigeCount++;
  3903.                         forcePrestige = false;
  3904.                         secondaryStatus = "";
  3905.                         return true;
  3906.                 } else {
  3907.                         log(RED, "Last floor reached, but prestiging is disabled! Shutting down script.");
  3908.                         authCheck = false;
  3909.                 }
  3910.                 return false;
  3911.         }
  3912.  
  3913.         private void runSettings() {
  3914.                 threadDefault();
  3915.                 bounds.clear();
  3916.                 prayerLevel = skills.getRealLevel(Skills.PRAYER);
  3917.                 slayerLevel = skills.getRealLevel(Skills.SLAYER);
  3918.                 if (!settingsFinished) {
  3919.                         if (!authCheck)
  3920.                                 return;
  3921.                         attStart = skills.getCurrentExp(Skills.ATTACK);
  3922.                         strStart = skills.getCurrentExp(Skills.STRENGTH);
  3923.                         defStart = skills.getCurrentExp(Skills.DEFENSE);
  3924.                         hitStart = skills.getCurrentExp(Skills.CONSTITUTION);
  3925.                         rngStart = skills.getCurrentExp(Skills.RANGE);
  3926.                         mgcStart = skills.getCurrentExp(Skills.MAGIC);
  3927.                         prayStart = skills.getCurrentExp(Skills.PRAYER);
  3928.                         dungStart = skills.getCurrentExp(Skills.DUNGEONEERING);
  3929.                         runeStart = skills.getCurrentExp(Skills.RUNECRAFTING);
  3930.                         mineStart = skills.getCurrentExp(Skills.MINING);
  3931.                         fireStart = skills.getCurrentExp(Skills.FIREMAKING);
  3932.                         woodStart = skills.getCurrentExp(Skills.WOODCUTTING);
  3933.                         smthStart = skills.getCurrentExp(Skills.SMITHING);
  3934.                         crftStart = skills.getCurrentExp(Skills.CRAFTING);
  3935.                         agilStart = skills.getCurrentExp(Skills.AGILITY);
  3936.                         thevStart = skills.getCurrentExp(Skills.THIEVING);
  3937.                         summStart = skills.getCurrentExp(Skills.SUMMONING);
  3938.                         herbStart = skills.getCurrentExp(Skills.HERBLORE);
  3939.                         cnstStart = skills.getCurrentExp(Skills.CONSTRUCTION);
  3940.                         cookStart = skills.getCurrentExp(Skills.COOKING);
  3941.                         fishStart = skills.getCurrentExp(Skills.FISHING);
  3942.                         slayStart = skills.getCurrentExp(Skills.SLAYER);
  3943.                         dungStartLevel = skills.getRealLevel(Skills.DUNGEONEERING);
  3944.                         dungLevel = skills.getRealLevel(Skills.DUNGEONEERING);
  3945.                         isCursing = prayer.isCursing();
  3946.                         if (levelGoal <= dungLevel)
  3947.                                 levelGoal = dungLevel + 1;
  3948.                         //if (!loadSettings()) {
  3949.                                 if (prayerLevel > 11) {
  3950.                                         Option.PRAY_DOORS.set(true);
  3951.                                         if (prayerLevel > 36)
  3952.                                                 Option.PRAY.set(true);
  3953.                                 }
  3954.                                 if (skills.getRealLevel(Skills.CONSTITUTION) < 60)
  3955.                                         Option.CRABS.set(true);
  3956.                                 if (skills.getRealLevel(Skills.DEFENSE) < 20) {
  3957.                                         Option.PURE.set(true);
  3958.                                 } else Option.STYLE_SWAP.set(true);
  3959.                         //}
  3960.                         if (groundItems.getNearest(CAVE_MORAY, BLUE_CRAB, SALVE_EEL, BOULDABASS, WEB_SNIPPER) == null) {
  3961.                                 game.open(Game.TAB_FRIENDS, false);
  3962.                                 String world = interfaces.getComponent(550, 18).getText();
  3963.                                 selectTab(Game.TAB_INVENTORY, 3);
  3964.                                 if (!world.isEmpty()) {
  3965.                                         world = world.concat(".");
  3966.                                         for (String w : FREE_WORLDS) {
  3967.                                                 if (world.contains(" " + w + ".")) {
  3968.                                                         memberWorld = false;
  3969.                                                         break;
  3970.                                                 }
  3971.                                         }
  3972.                                 }
  3973.                         }
  3974.                         oTab = 0;
  3975.                         hidePaint = false;
  3976.                         showStats = false;
  3977.                         showOptions = false;
  3978.                         showSettings = true;
  3979.                         game.setChatOption(Game.ChatButton.GAME, Game.ChatMode.VIEW);
  3980.                         env.setUserInput(Environment.INPUT_MOUSE | Environment.INPUT_KEYBOARD);
  3981.                         while (showSettings) {
  3982.                                 if (!authCheck)
  3983.                                         return;
  3984.                                 sleep(300, 600);
  3985.                         }
  3986.                         env.setUserInput(Environment.INPUT_KEYBOARD);
  3987.                         game.setChatOption(Game.ChatButton.ASSIST, Game.ChatMode.OFF);
  3988.                         defaultMode = combat.getFightMode();
  3989.                         if (Option.MAGIC.enabled()) {
  3990.                                 defaultMode = 4;
  3991.                         } else if (defaultMode == 4) {
  3992.                                 defaultMode = 1;
  3993.                         }
  3994.                         attackMode = valueOf(defaultMode);
  3995.                         selectTab(Game.TAB_EQUIPMENT, 5);
  3996.                         int attackLevel = skills.getRealLevel(Skills.ATTACK), defenseLevel = skills.getRealLevel(Skills.DEFENSE);
  3997.                         defenseTier = defenseLevel == 99 ? 11 : defenseLevel / 10 + 1;
  3998.                         attackTier = attackLevel == 99 ? 11 : attackLevel / 10 + 1;
  3999.                         if (Option.RANGE.enabled()) {
  4000.                                 int rangeLevel = skills.getRealLevel(Skills.RANGE);
  4001.                                 attackTier = rangeLevel == 99 ? 11 : rangeLevel / 10 + 1;
  4002.                                 primaryStyle = Style.RANGE;
  4003.                                 armorTiers = LEATHER_TIERS;
  4004.                                 slotNames = RANGE_SLOTS;
  4005.                                 weaponTiers = WOOD_TIERS;
  4006.                         } else if (Option.MAGIC.enabled()) {
  4007.                                 primaryStyle = Style.MAGIC;
  4008.                                 armorTiers = CLOTH_TIERS;
  4009.                                 slotNames = MAGIC_SLOTS;
  4010.                                 weaponTiers = null;
  4011.                         }
  4012.                         RSItem weaponSlot = equipment.getItem(Equipment.WEAPON);
  4013.                         if (weaponSlot != null && weaponSlot.getID() > 0) {
  4014.                                 primaryWep = weaponSlot.getID();
  4015.                                 String wName = equipmentName(weaponSlot);
  4016.                                 String wMetal = equipmentMaterial(wName);
  4017.                                 weaponTier = equipmentTier(wName);
  4018.                                 weaponType = equipmentType(wName);
  4019.                                 Weapon weapon = enumOf(Weapon.class, weaponType);
  4020.                                 if (weapon == null) {
  4021.                                         log.severe("Unknown weapon type. Please try restarting the script for best results");
  4022.                                 } else {
  4023.                                         int level = skills.getRealLevel(weapon.skill());
  4024.                                         Melee.STAB.set(weapon.stab());
  4025.                                         Melee.SLASH.set(weapon.slash());
  4026.                                         Melee.CRUSH.set(weapon.crush());
  4027.                                         if (combatStyle == Style.MELEE)
  4028.                                                 Melee.DEFENSE.set(weapon.defensive());
  4029.                                         attackTier = level == 99 ? 11 : level / 10 + 1;
  4030.                                         twoHanded = weapon.isTwoHanded();
  4031.                                         if (weaponTier == 0)
  4032.                                                 weaponTier = 11;
  4033.                                         log(BLU, "Weapon: " + wMetal + " " + weaponType + " - Tier: " + weaponTier + "; Max tier: " +
  4034.  
  4035. attackTier + "; Two-handed: " + (twoHanded ? "Yes" : "No") + "; Upgrading: " + (weaponTier < attackTier ? "Yes" : "No"));
  4036.                                         if (Option.STYLE_SWAP.enabled && weapon.slash() == -1)
  4037.                                                 Option.STYLE_SWAP.set(false);
  4038.                                 }
  4039.                         }
  4040.                         if (Option.PURE.enabled() && (defaultMode == defenseMode || defaultMode == 3))
  4041.                                 defaultMode = 1;
  4042.                         RSItem ammo = equipment.getItem(Equipment.AMMO);
  4043.                         if (ammo != null && ammo.getID() > 0)
  4044.                                 arrows = ammo.getID();
  4045.                         for (int I = 0; I < EQUIP_SLOTS.length; I++) {
  4046.                                 RSItem eq = equipment.getItem(EQUIP_SLOTS[I]);
  4047.                                 if (eq != null && eq.getID() > 0) {
  4048.                                         String eqName = equipmentName(eq);
  4049.                                         int tier = equipmentTier(eqName);
  4050.                                         if (eq.getName().contains("(b)")) {
  4051.                                                 if (I == 0 && eqName.contains("silk hood")) {
  4052.                                                         initialEquipmentTiers[I] = 11;
  4053.                                                         shadowHooded = true;
  4054.                                                 } else if (I == 2 && (eqName.contains("blastbox") || eqName.contains("surgebox"))) {
  4055.                                                         blastBox = eq.getID();
  4056.                                                         initialEquipmentTiers[I] = 11;
  4057.                                                         twoHanded = true;
  4058.                                                 } else if (I == 4 && eqName.contains("precision")) {
  4059.                                                         initialEquipmentTiers[I] = 11;
  4060.                                                 } else initialEquipmentTiers[I] = tier;
  4061.                                                 if (initialEquipmentTiers[I] == 0)
  4062.                                                         initialEquipmentTiers[I] = 11;
  4063.                                                 if (initialEquipmentTiers[I] < defenseTier) {
  4064.                                                         startArmor = eq.getID();
  4065.                                                         armorSlot = I;
  4066.                                                         armorType = equipmentType(eqName);
  4067.                                                 }
  4068.                                                 equipmentTiers[I] = valueOf(initialEquipmentTiers[I]);
  4069.                                                 tempTiers[I] = valueOf(initialEquipmentTiers[I]);
  4070.                                                 log(BLU, "Armor: " + eqName + " - Tier: " + equipmentTiers[I] + "; Max tier: " +
  4071.  
  4072. defenseTier + "; Upgrading: " + (equipmentTiers[I] < defenseTier ? "Yes" : "No"));
  4073.                                         } else {
  4074.                                                 equipmentTiers[I] = tier;
  4075.                                                 tempTiers[I] = tier;
  4076.                                         }
  4077.                                 }
  4078.                         }
  4079.                         if (combatSpell != null) {
  4080.                                 Magic spellType = combatSpell.type();
  4081.                                 if (spellType != null && spellType != Magic.NONE)
  4082.                                         spellType.set(4);
  4083.                         }
  4084.                 }
  4085.                 for (RSItem item : inventory.getItems()) {
  4086.                         if (item == null)
  4087.                                 continue;
  4088.                         int itemId = item.getID();
  4089.                         if (itemId < 1)
  4090.                                 continue;
  4091.                         String iName = equipmentName(item);
  4092.                         int tier = equipmentTier(iName);
  4093.                         if (tier > 0) {
  4094.                                 String iType = equipmentType(iName);
  4095.                                 for (int I = 0; I < slotNames.length; I++) {
  4096.                                         if (iType.contains(slotNames[I])) {
  4097.                                                 if (tier > equipmentTiers[I] && ridItem(itemId, "Wear"))
  4098.                                                         equipmentTiers[I] = tier;
  4099.                                                 break;
  4100.                                         }
  4101.                                 }
  4102.                         }
  4103.                 }
  4104.                 Style.MELEE.set(Option.MELEE.enabled() || (Option.SECONDARY_MELEE.enabled() && secondaryWep > 0));
  4105.                 Style.RANGE.set(Option.RANGE.enabled() || (Option.SECONDARY_RANGE.enabled() && arrows > 0 && secondaryWep > 0));
  4106.                 Style.MAGIC.set(Option.MAGIC.enabled() || (Option.SECONDARY_MAGIC.enabled() && (secondaryWep > 0 || blastBox > 0)));
  4107.                 temporarySecondary = secondaryWep < 1;
  4108.                 int goodOffset = skills.getRealLevel(Skills.CONSTITUTION) / (memberWorld ? 34 : 46);
  4109.                 foods = FOOD_ARRAY;
  4110.                 goodFoods = new int[foods.length - goodOffset];
  4111.                 int[] newTop = new int[foods.length - goodOffset - 1];
  4112.                 topFoods = new int[newTop.length];
  4113.                 if (skills.getRealLevel(Skills.DEFENSE) < random(5, 20) && username.isEmpty())
  4114.                         Option.PURE.set(true);
  4115.                 System.arraycopy(foods, goodOffset, goodFoods, 0, goodFoods.length);
  4116.                 System.arraycopy(goodFoods, 1, newTop, 0, newTop.length);
  4117.                 for (int I = 0; I < newTop.length; I++) {
  4118.                         topFoods[I] = newTop[newTop.length - 1 - I];
  4119.                 }
  4120.                 if (!Option.CRABS.enabled()) {
  4121.                         foods = new int[FOOD_ARRAY.length - 1];
  4122.                         System.arraycopy(FOOD_ARRAY, 1, foods, 0, foods.length);
  4123.                 }
  4124.                 for (int food : foods) {
  4125.                         bounds.add((Integer) food);
  4126.                 }
  4127.                 if (Option.BONES.enabled()) {
  4128.                         for (int bone : BONES) {
  4129.                                 bounds.add((Integer) bone);
  4130.                         }
  4131.                 }
  4132.                 if (Option.MAKE_FOOD.enabled())
  4133.                         bounds.add((Integer) COINS);
  4134.                 if (primaryWep > 0)
  4135.                         bounds.add((Integer) primaryWep);
  4136.                 if (secondaryWep > 0)
  4137.                         bounds.add((Integer) secondaryWep);
  4138.                 if (blastBox > 0)
  4139.                         bounds.add((Integer) blastBox);
  4140.                 if (arrows > 0)
  4141.                         bounds.add((Integer) arrows);
  4142.                 for (int[] color : KEYS) {
  4143.                         for (int key : color) {
  4144.                                 bounds.add((Integer) key);
  4145.                         }
  4146.                 }
  4147.                 if (aComplexity > 4) {
  4148.                         for (Integer tool : TOOLS) {
  4149.                                 bounds.add(tool);
  4150.                         }
  4151.                         int magicLevel = skills.getRealLevel(Skills.MAGIC);
  4152.                         if (magicLevel > 31) {
  4153.                                 bounds.add((Integer) GGS);
  4154.                                 for (Integer rune : COSMIC_RUNES) {
  4155.                                         bounds.add(rune);
  4156.                                 }
  4157.                                 if (magicLevel > 63 && floor != Floor.FROZEN) {
  4158.                                         for (Integer rune : LAW_RUNES) {
  4159.                                                 bounds.add(rune);
  4160.                                         }
  4161.                                 }
  4162.                         }
  4163.                         if (!memberWorld) {
  4164.                                 bounds.remove((Integer) 17490);
  4165.                                 bounds.remove((Integer) 17754);
  4166.                         } else bounds.add((Integer) ANTIPOISON);
  4167.                 } else if (floor == Floor.ABANDONED) {
  4168.                         bounds.add((Integer) PICKAXE);
  4169.                 }
  4170.                 if (Option.RUSH.enabled() && cProg < 1)
  4171.                         openPartyTab();
  4172.                 for (RSItem item : inventory.getItems()) {
  4173.                         if (item != null && item.getName().contains("(b)"))
  4174.                                 bounds.add((Integer) item.getID());
  4175.                 }
  4176.                 if (Option.RANGE.enabled()) {
  4177.                         ridItem(arrows, "Wield");
  4178.                 } else if (Option.MAGIC.enabled() && ridItem(blastBox, "Wield")) {
  4179.                         while (!isAutoCasting()) {
  4180.                                 if (failCheck())
  4181.                                         return;
  4182.                                 if (castDungeonSpell(combatSpell, "Autocast"))
  4183.                                         sleep(300, 600);
  4184.                                 sleep(100, 200);
  4185.                         }
  4186.                 }
  4187.                 combatStyle = styleOf(primaryStyle.index());
  4188.                 if (!settingsFinished) {
  4189.                         settingsFinished = true;
  4190.                         saveSettings();
  4191.                         runTimer = new Timer(0);
  4192.                         log(PRP, "Settings complete!");
  4193.                 }
  4194.                 failTimer = new Timer(random(360000, 480000));
  4195.         }
  4196.  
  4197.         private class threadAngle extends Thread {
  4198.                 public void run() {
  4199.                         try {
  4200.                                 while (Math.abs(camera.getAngleTo(degrees)) > 5) {
  4201.                                         camera.setAngle(degrees);
  4202.                                         sleep(0, 20);
  4203.                                 }
  4204.                         } catch (Exception e) { }
  4205.                 }
  4206.         }
  4207.  
  4208.         private class threadPitch extends Thread {
  4209.                 public void run() {
  4210.                         try {
  4211.                                 while (camera.getPitch() != pitch) {
  4212.                                         camera.setPitch(pitch);
  4213.                                         sleep(0, 20);
  4214.                                 }
  4215.                         } catch (Exception e) { }
  4216.                 }
  4217.         }
  4218.  
  4219.         private boolean shop(final Food fish, final Logs logs) {
  4220.                 boolean sold = false;
  4221.                 int toScroll = random(175, 200);
  4222.                 lastMessage = "";
  4223.                 while ((!sold || !inventory.isFull()) && !lastMessage.contains("afford") && !lastMessage.contains("enough money")) {
  4224.                         if (failCheck())
  4225.                                 return false;
  4226.                         RSInterface shop = interfaces.get(956);
  4227.                         if (!shop.isValid()) {
  4228.                                 smartSleep(doNpcAction(getNpcInRoom(SMUGGLER), "Trade"), false);
  4229.                         } else if (!sellToShop()) {
  4230.                                 RSComponent logItem = shop.getComponent(24).getComponent((memberWorld ? 197 : 97) + logs.tier() * 5);
  4231.                                 RSComponent scrollBar = shop.getComponent(25);
  4232.                                 while (scrollBar.isValid() && logItem.getAbsoluteY() > toScroll) {
  4233.                                         clickComponent(scrollBar.getComponent(5), "");
  4234.                                         sleep(0, 50);
  4235.                                 }
  4236.                                 if (logs != null && getObjInRoom(FIRES) == null && !inventory.contains(logs.getID())) {
  4237.                                         if (clickComponent(logItem, "Buy 1")) {
  4238.                                                 for (int c = 0; c < 10; c++) {
  4239.                                                         if (inventory.contains(logs.getID()))
  4240.                                                                 break;
  4241.                                                         sleep(150, 250);
  4242.                                                 }
  4243.                                         }
  4244.                                 } else if (fish != null) {
  4245.                                         RSComponent foodItem = shop.getComponent(24).getComponent((memberWorld ? 147 : 72) +
  4246.  
  4247. fish.tier() * 5);
  4248.                                         int startCount = inventory.getCount();
  4249.                                         if (clickComponent(foodItem, "Buy 50")) {
  4250.                                                 for (int c = 0; c < 10; c++) {
  4251.                                                         if (inventory.getCount() > startCount)
  4252.                                                                 break;
  4253.                                                         sleep(150, 250);
  4254.                                                 }
  4255.                                         }
  4256.                                 }
  4257.                                 sold = true;
  4258.                         }
  4259.                         sleep(50, 200);
  4260.                 }
  4261.                 while (interfaces.get(956).isValid()) {
  4262.                         interfaces.getComponent(956, 18).interact("Close");
  4263.                         sleep(700, 1000);
  4264.                 }
  4265.                 return true;
  4266.         }
  4267.  
  4268.         private boolean shop(final int idx, final int amount) {
  4269.                 lastMessage = "";
  4270.                 while (!interfaces.get(956).isValid()) {
  4271.                         if (failCheck())
  4272.                                 return false;
  4273.                         if (doNpcAction(getNpcInRoom(SMUGGLER), "Trade"))
  4274.                                 waitToStop(false);
  4275.                         sleep(600, 800);
  4276.                 }
  4277.                 sellToShop();
  4278.                 RSComponent scrollBar = interfaces.getComponent(956, 25);
  4279.                 Point sP = scrollBar.getComponent(5).getCenter();
  4280.                 while (scrollBar.isValid() && scrollBar.getComponent(3).getRelativeY() < 225) {
  4281.                         mouse.click(sP.x, sP.y - 25, 5, 17, true);
  4282.                         sleep(200, 600);
  4283.                 }
  4284.                 RSComponent item = interfaces.getComponent(956, 24).getComponent(idx);
  4285.                 for (int c = 0; c < amount; c++) {
  4286.                         if (lastMessage.contains("don't have enough"))
  4287.                                 break;
  4288.                         if (!clickComponent(item, "Buy 1")) {
  4289.                                 if (!interfaces.get(956).isValid())
  4290.                                         break;
  4291.                                 c--;
  4292.                         }
  4293.                 }
  4294.                 while (interfaces.get(956).isValid()) {
  4295.                         interfaces.getComponent(956, 18).interact("Close");
  4296.                         sleep(700, 1000);
  4297.                 }
  4298.                 return true;
  4299.         }
  4300.  
  4301.         private boolean shopToolkit() {
  4302.                 boolean ret = true;
  4303.                 int failCount = 0, sellCount = 0, sellFood = -1;
  4304.                 lastMessage = "";
  4305.                 while (!inventory.contains(TOOLKIT) && !inventory.containsAll(TOOLS)) {
  4306.                         if (failCheck()) {
  4307.                                 ret = false;
  4308.                                 break;
  4309.                         }
  4310.                         if (!interfaces.get(956).isValid()) {
  4311.                                 smartSleep(doNpcAction(getNpcInRoom(SMUGGLER), "Trade"), false);
  4312.                                 sleep(200, 400);
  4313.                                 continue;
  4314.                         }
  4315.                         boolean sold = false;
  4316.                         if (sellCount < 3) {
  4317.                                 for (RSItem item : inventory.getItems()) {
  4318.                                         int testID = item.getID();
  4319.                                         if (testID == -1)
  4320.                                                 continue;
  4321.                                         if (testID != sellFood && !intMatch(testID, TOOLS) && (intMatch(testID, COINS, TOOLKIT) ||
  4322.  
  4323. bounds.contains((Integer) testID)))
  4324.                                                 continue;
  4325.                                         for (int c = 0; c < random(3, 5); c++) {
  4326.                                                 if (item.interact("Sell 50")) {
  4327.                                                         sleep(100, 300);
  4328.                                                         if (item.getStackSize() > 50 && item.interact("Sell 50"))
  4329.                                                                 sleep(30, 300);
  4330.                                                         if (!sold) {
  4331.                                                                 sellCount++;
  4332.                                                                 sold = true;
  4333.                                                         }
  4334.                                                         break;
  4335.                                                 }
  4336.                                                 sleep(10, 100);
  4337.                                         }
  4338.                                 }
  4339.                                 if (sold)
  4340.                                         continue;
  4341.                         }
  4342.                         sellFood = -1;
  4343.                         if (lastMessage.contains("enough money")) {
  4344.                                 failCount++;
  4345.                                 sleep(300, 500);
  4346.                                 if (failCount > 1) {
  4347.                                         sellFood = foodLowest();
  4348.                                         if (sellFood == -1 && failCount > 2) {
  4349.                                                 log(RED, "Unable to purchase a toolkit, trying a new floor.");
  4350.                                                 if (developer)
  4351.                                                         env.saveScreenshot(false);
  4352.                                                 exit = true;
  4353.                                                 ret = false;
  4354.                                                 break;
  4355.                                         }
  4356.                                 }
  4357.                                 lastMessage = "";
  4358.                         } else {
  4359.                                 RSComponent scrollBar = interfaces.getComponent(956, 25);
  4360.                                 Point sP = scrollBar.getComponent(5).getCenter();
  4361.                                 while (scrollBar.isValid() && scrollBar.getComponent(3).getRelativeY() < 225) {
  4362.                                         mouse.click(sP.x, sP.y - 25, 5, 17, true);
  4363.                                         sleep(200, 600);
  4364.                                 }
  4365.                                 if (memberWorld && dungeonCount == 0)
  4366.                                         memberWorld = interfaces.getComponent(956, 24).getComponents().length > 400;
  4367.                                         if (clickComponent(interfaces.getComponent(956, 24).getComponent(memberWorld ? 469 : 254),
  4368.  
  4369. "Buy 1")) {
  4370.                                                 for (int c = 0; c < 10; c++) {
  4371.                                                         if (inventory.contains(TOOLKIT))
  4372.                                                                 break;
  4373.                                                         sleep(100, 200);
  4374.                                                 }
  4375.                                         }
  4376.                         }
  4377.                 }
  4378.                 while (interfaces.get(956).isValid()) {
  4379.                         interfaces.getComponent(956, 18).interact("Close");
  4380.                         sleep(700, 1000);
  4381.                 }
  4382.                 return ret;
  4383.         }
  4384.  
  4385.         private boolean hidePaint = false, backPage = false, pauseiDungeon = false, confirmToStop = false;
  4386.         private boolean showStats = true, showOptions = false, showSettings = false, showChat = false;
  4387.  
  4388.         private final Option[] opTab1 = { Option.MELEE, Option.RANGE, Option.MAGIC, Option.SECONDARY_MELEE, Option.SECONDARY_RANGE,
  4389.  
  4390. Option.SECONDARY_MAGIC, Option.LOAD_SETTINGS, Option.SAVE_SETTINGS };
  4391.         private final Option[] opTab2 = { Option.BONES, Option.ARROWS, Option.CRABS, Option.PRAY, Option.QUICK_PRAY,
  4392.  
  4393. Option.PRAY_DOORS, Option.PURE, Option.STYLE_SWAP, Option.SUMMON, Option.MAKE_FOOD, Option.EXPLORER, Option.LOGOUT };
  4394.         private final Option[] opTab3 = { Option.PRESTIGE, Option.MEDIUM, Option.DEBUG, Option.VIDEO, Option.RUSH, Option.RUSH_FOOD };
  4395.         private final Option[][] options = { opTab1, opTab2, opTab3 };
  4396.  
  4397.         private static final Color GN1 = new Color(0, 255, 0, 130);
  4398.         private static final Color GN2 = new Color(0, 180, 0, 80);
  4399.         private static final Color RD1 = new Color(255, 0, 0, 130);
  4400.         private static final Color RD2 = new Color(180, 0, 0, 100);
  4401.  
  4402.         private final Color BLU = new Color(0, 0, 255);
  4403.         private final Color BL1 = new Color(0, 0, 255, 150);
  4404.         private final Color BLK = new Color(0, 0, 0);
  4405.         private final Color BT1 = new Color(0, 0, 0, 225);
  4406.         private final Color BT2 = new Color(0, 0, 0, 180);
  4407.         private final Color BT3 = new Color(0, 0, 0, 110);
  4408.         private final Color BT4 = new Color(0, 0, 0, 200);
  4409.         private final Color DPL = new Color(255, 0, 255);
  4410.         private final Color GLD = new Color(255, 215, 0, 140);
  4411.         private final Color GRN = new Color(0, 240, 0);
  4412.         private final Color GN3 = new Color(0, 255, 0, 100);
  4413.         private final Color GN5 = new Color(0, 150, 0);
  4414.         private final Color RED = new Color(255, 0, 0);
  4415.         private final Color PRP = new Color(160, 0, 160);
  4416.         private final Color PT1 = new Color(160, 0, 160, 100);
  4417.         private final Color PT2 = new Color(160, 0, 160, 160);
  4418.         private final Color PT3 = new Color(160, 0, 160, 40);
  4419.         private final Color SKY = new Color(0, 190, 255, 140);
  4420.         private final Color WHT = new Color(255, 255, 255);
  4421.         private final Color WT1 = new Color(255, 255, 255, 100);
  4422.         private final Color WT2 = new Color(255, 255, 255, 150);
  4423.         private final Color WT3 = new Color(255, 255, 255, 220);
  4424.         private final Color YLW = new Color(240, 240, 0);
  4425.  
  4426.         private final Font FONT_1 = new Font("Arial", Font.BOLD, 13);
  4427.         private final Font FONT_2 = new Font("Trebuchet MS", 0, 15);
  4428.         private final Font FONT_3 = new Font("Trebuchet MS", 0, 11);
  4429.         private final Font FONT_4 = new Font("Arial", Font.BOLD, 12);
  4430.  
  4431.         private final Rectangle RECT_STATS = new Rectangle(7, 344, 80, 17);
  4432.         private final Rectangle RECT_OPTIONS = new Rectangle(7 + 84, 344, 80, 17);
  4433.         private final Rectangle RECT_STATUS = new Rectangle(7 + 168, 344, 222, 17);
  4434.         private final Rectangle RECT_CONTROL = new Rectangle(7 + 394, 344, 112, 19);
  4435.         private final Rectangle RECT_CHAT = new Rectangle(7, 458, 506, 16);
  4436.         private final Rectangle RECT_TAB_1 = new Rectangle(6, 363, 81, 32);
  4437.         private final Rectangle RECT_TAB_2 = new Rectangle(6, 395, 81, 32);
  4438.         private final Rectangle RECT_TAB_3 = new Rectangle(6, 427, 81, 31);
  4439.  
  4440.         private final Rectangle RECT_C_UP = new Rectangle(121, 389, 20, 15);
  4441.         private final Rectangle RECT_C_DOWN = new Rectangle(121, 420, 20, 15);
  4442.         private final Rectangle RECT_RC_UP = new Rectangle(310, 389, 20, 15);
  4443.         private final Rectangle RECT_RC_DOWN = new Rectangle(310, 420, 20, 15);
  4444.         private final Rectangle RECT_F_UP = new Rectangle(380, 389, 20, 15);
  4445.         private final Rectangle RECT_F_DOWN = new Rectangle(380, 420, 20, 15);
  4446.         private final Rectangle RECT_MINI_UP = new Rectangle(285, 367, 9, 8);
  4447.         private final Rectangle RECT_MINI_DOWN = new Rectangle(285, 375, 9, 7);
  4448.         private final Rectangle RECT_PLAY = new Rectangle(405, 346, 18, 18);
  4449.         private final Rectangle RECT_INFO = new Rectangle(425, 346, 18, 18);
  4450.         private final Rectangle RECT_HELP = new Rectangle(445, 346, 18, 18);
  4451.         private final Rectangle RECT_STOP = new Rectangle(465, 346, 18, 18);
  4452.         private final Rectangle RECT_HIDE = new Rectangle(495, 346, 18, 18);
  4453.         private final Rectangle RECT_CONTINUE = new Rectangle(438, 437, 69, 16);
  4454.         private final Rectangle RECT_BACK = new Rectangle(12, 437, 69, 16);
  4455.         private final Rectangle RECT_BLOCK_1 = new Rectangle(7, 458, 100, 16);
  4456.         private final Rectangle RECT_BLOCK_2 = new Rectangle(570, 235, 133, 12);
  4457.         private final Rectangle RECT_BLOCK_3 = new Rectangle(367, 56, 100, 15);
  4458.         private final Rectangle RECT_PICKUP = new Rectangle(97, 387, 197, 18);
  4459.         private final Rectangle RECT_DESTROY = new Rectangle(305, 387, 197, 18);
  4460.  
  4461.         final Point o = new Point(7, 344);
  4462.         private int page = 0, sTab = 1, oTab = 1, typeTo = -1;
  4463.         private String username = "", password = "", pickupName = "", destroyName = "";
  4464.  
  4465.         private void drawBevel(final Graphics g, final Rectangle r) {
  4466.                 g.draw3DRect(r.x, r.y, r.width, r.height, true);
  4467.         }
  4468.  
  4469.         private void drawRect(final Graphics g, final Rectangle r) {
  4470.                 g.fillRect(r.x, r.y, r.width, r.height);
  4471.         }
  4472.  
  4473.         private void drawTile(final Graphics g, final RSTile t, double m) {
  4474.                 if (t == null)
  4475.                         return;
  4476.                 final int tX = t.getX(), tY = t.getY();
  4477.                 Point p1 = calc.worldToMinimap(tX - m, tY - m), p2 = calc.worldToMinimap(tX - m, tY + m);
  4478.                 Point p3 = calc.worldToMinimap(tX + m, tY + m), p4 = calc.worldToMinimap(tX + m, tY - m);
  4479.                 if (p1.x != -1 && p2.x != -1 && p3.x != -1 && p4.x != -1) {
  4480.                         int[] allX = new int[] { p1.x, p2.x, p3.x, p4.x };
  4481.                         int[] allY = new int[] { p1.y, p2.y, p3.y, p4.y };
  4482.                         g.fillPolygon(allX, allY, 4);
  4483.                 }
  4484.         }
  4485.  
  4486.         public void onRepaint(final Graphics g) {
  4487.                 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  4488.                 if (!authCheck || game.isLoggedIn()) {
  4489.                         g.setFont(FONT_2);
  4490.                         if (Option.DEBUG.enabled() && inDungeon && currentRoom != null && targetRoom != null) {
  4491.                                 if (skipRooms.contains(targetRoom)) {
  4492.                                         g.setColor(GLD);
  4493.                                 } else if (startRoom != null && areaEquals(targetRoom, startRoom)) {
  4494.                                         g.setColor(SKY);
  4495.                                 } else if ((puzzleRooms.contains(targetRoom)) || (bossRoom != null && areaEquals(targetRoom,
  4496.  
  4497. bossRoom))) {
  4498.                                         g.setColor(RD1);
  4499.                                 } else if (finishedRooms.contains(targetRoom)) {
  4500.                                         g.setColor(PT2);
  4501.                                 } else if (finish || clearedRooms.contains(targetRoom)) {
  4502.                                         g.setColor(GN3);
  4503.                                 } else g.setColor(BL1);
  4504.                                 for (RSTile f : roomFlags) {
  4505.                                         if (!f.equals(safeTile))
  4506.                                                 drawTile(g, f, 0.5);
  4507.                                 }
  4508.                                 if (safeTile != null) {
  4509.                                         g.setColor(GRN);
  4510.                                         drawTile(g, safeTile, 0.5);
  4511.                                 }
  4512.                                 for (RSTile dT : drawDoors) {
  4513.                                         if (calc.distanceBetween(myLoc(), dT) < 17) {
  4514.                                                 RSObject dObj = objects.getTopAt(dT);
  4515.                                                 if (dObj != null) {
  4516.                                                         if (finishedDoors.contains(dT)) {
  4517.                                                                 g.setColor(DPL);
  4518.                                                         } else if (lockedDoors.contains(dT) || blockedDoors.contains(dT)) {
  4519.                                                                 g.setColor(RED);
  4520.                                                         } else if (openedDoors.contains(dT)) {
  4521.                                                                 g.setColor(GRN);
  4522.                                                         } else g.setColor(YLW);
  4523.                                                         for (RSTile t : dObj.getArea().getTileArray()) {
  4524.                                                                 drawTile(g, t, 0.5);
  4525.                                                         }
  4526.                                                 }
  4527.                                         }
  4528.                                 }
  4529.                                 g.setColor(BL1);
  4530.                                 for (RSTile t : puzzlePoints) {
  4531.                                         if (!t.equals(safeTile)) {
  4532.                                                 drawTile(g, t, 0.3);
  4533.                                         }
  4534.                                 }
  4535.                         }
  4536.                         if (Option.VIDEO.enabled()) {
  4537.                                 g.setColor(BLK);
  4538.                                 drawRect(g, RECT_BLOCK_1);
  4539.                                 if ((exit || status.contains("Entering D")) && game.getCurrentTab() != Game.TAB_INVENTORY)
  4540.                                         drawRect(g, RECT_BLOCK_2);
  4541.                                 if (status.contains("next dungeon...") || (newDungeon && dungeonCount != 0 && startRoom == null))
  4542.                                         drawRect(g, RECT_BLOCK_3);
  4543.                         }
  4544.                         if (!hidePaint) {
  4545.                                 if (RECT_CHAT.contains(mp)) {
  4546.                                         g.setColor(BLK);
  4547.                                         g.drawString((userRank != 0 ? "Highscores rank: " + userRank + " || " : "") + (userCount != 0
  4548.  
  4549. ? userCount + " users online || " : "") + "by kiko & ShadowMoose", 92 + rankOffset + userOffset, 472);
  4550.                                 }
  4551.                                 g.setColor(BT1);
  4552.                                 if (showSettings && page != 1)
  4553.                                         g.fillRect(7, 363, 80, 95);
  4554.                                 g.fillRect(87, 363, 426, 95);
  4555.                                 g.setColor(BLK);
  4556.                                 if (showChat) {
  4557.                                         g.setColor(BT3);
  4558.                                 } else if (RECT_CHAT.contains(mp)) {
  4559.                                         g.setColor(BT4);
  4560.                                 }
  4561.                                 drawRect(g, RECT_CHAT);
  4562.                                 g.setColor(WT2);
  4563.                                 g.drawLine(6, 458, 512, 458);
  4564.                                 if (showStats || showOptions || (showSettings && page == 1)) {
  4565.                                         g.drawLine(87, 363, 87, 457);
  4566.                                         g.drawLine(87, RECT_TAB_1.y, 511, RECT_TAB_1.y);
  4567.                                 }
  4568.                                 if (showStats && !showSettings) {
  4569.                                         double runTime = runTimer.getElapsed();
  4570.                                         if (settingsFinished && runTime != 0) {
  4571.                                                 attGain = skills.getCurrentExp(Skills.ATTACK) - attStart;
  4572.                                                 strGain = skills.getCurrentExp(Skills.STRENGTH) - strStart;
  4573.                                                 defGain = skills.getCurrentExp(Skills.DEFENSE) - defStart;
  4574.                                                 hitGain = skills.getCurrentExp(Skills.CONSTITUTION) - hitStart;
  4575.                                                 rngGain = skills.getCurrentExp(Skills.RANGE) - rngStart;
  4576.                                                 mgcGain = skills.getCurrentExp(Skills.MAGIC) - mgcStart;
  4577.                                                 prayGain = skills.getCurrentExp(Skills.PRAYER) - prayStart;
  4578.                                                 runeGain = skills.getCurrentExp(Skills.RUNECRAFTING) - runeStart;
  4579.                                                 mineGain = skills.getCurrentExp(Skills.MINING) - mineStart;
  4580.                                                 fireGain = skills.getCurrentExp(Skills.FIREMAKING) - fireStart;
  4581.                                                 woodGain = skills.getCurrentExp(Skills.WOODCUTTING) - woodStart;
  4582.                                                 crftGain = skills.getCurrentExp(Skills.CRAFTING) - crftStart;
  4583.                                                 smthGain = skills.getCurrentExp(Skills.SMITHING) - smthStart;
  4584.                                                 agilGain = skills.getCurrentExp(Skills.AGILITY) - agilStart;
  4585.                                                 thevGain = skills.getCurrentExp(Skills.THIEVING) - thevStart;
  4586.                                                 summGain = skills.getCurrentExp(Skills.SUMMONING) - summStart;
  4587.                                                 herbGain = skills.getCurrentExp(Skills.HERBLORE) - herbStart;
  4588.                                                 cnstGain = skills.getCurrentExp(Skills.CONSTRUCTION) - cnstStart;
  4589.                                                 cookGain = skills.getCurrentExp(Skills.COOKING) - cookStart;
  4590.                                                 fishGain = skills.getCurrentExp(Skills.FISHING) - fishStart;
  4591.                                                 slayGain = skills.getCurrentExp(Skills.SLAYER) - slayStart;
  4592.                                                 dungGain = skills.getCurrentExp(Skills.DUNGEONEERING) - dungStart;
  4593.                                                 ceph = (int) (3600000 / runTime * (attGain + defGain + strGain + rngGain + mgcGain +
  4594.  
  4595. hitGain + prayGain));
  4596.                                                 deph = (int) (3600000 / runTime * dungGain);
  4597.                                                 seph = (int) (3600000 / runTime * (runeGain + mineGain + fireGain + woodGain +
  4598.  
  4599. smthGain + crftGain + agilGain + thevGain + summGain + herbGain + cnstGain + cookGain + fishGain + slayGain));
  4600.                                                 fph = Math.rint((3600000 / runTime * dungeonCount) * 10) / 10;
  4601.                                         }
  4602.                                         if (sTab == 1) {
  4603.                                                 g.setColor(BT1);
  4604.                                                 drawRect(g, RECT_TAB_1);
  4605.                                                 g.setColor(RECT_TAB_2.contains(mp) ? BT2 : BT4);
  4606.                                                 drawRect(g, RECT_TAB_2);
  4607.                                                 g.setColor(RECT_TAB_3.contains(mp) ? BT2 : BT4);
  4608.                                                 drawRect(g, RECT_TAB_3);
  4609.                                                 g.setColor(WT3);
  4610.                                                 drawBevel(g, RECT_TAB_1);
  4611.                                                 g.clearRect(RECT_TAB_1.x + RECT_TAB_1.width, RECT_TAB_1.y + 1, 1, RECT_TAB_1.height -
  4612.  
  4613. 1);
  4614.                                                 g.drawString("Total Time: " + timeFormat(runTimer.getElapsed()), 93, 380);
  4615.                                                 g.drawString("Dung. Level: " + dungLevel + " (+" + (dungLevel - dungStartLevel) + ")",
  4616.  
  4617. 93, 398);
  4618.                                                 g.drawString("Exp per Hour: " + deph, 93, 416);
  4619.                                                 g.drawString("Exp Gained: " + dungGain, 93, 434);
  4620.                                                 g.drawString("Tokens Gained: " + tokens, 93, 452);
  4621.                                                 g.drawString("Time to Level " + levelGoal + ": " + (deph > 0 ? timeFormat
  4622.  
  4623. (getDungExpToLevel() * 360 / deph * 10000) : EMPTY_TIMER), 295, 380);
  4624.                                                 g.drawString("Dungeons Completed: " + dungeonCount + " (" + abortedCount + ")", 295,
  4625.  
  4626. 398);
  4627.                                                 g.drawString("Floors per Hour: " + fph, 295, 416);
  4628.                                                 g.drawString("Deaths: " + deaths + " (" + perFloor(deaths) + " per floor)", 295, 434);
  4629.                                                 g.drawString("Puzzles: " + puzzleCount + " (" + perFloor(puzzleCount) + " per floor)",
  4630.  
  4631. 295, 452);
  4632.                                                 g.drawString(RECT_MINI_UP.contains(mp) || RECT_MINI_DOWN.contains(mp) ? MINIS_S :
  4633.  
  4634. MINIS, RECT_MINI_UP.x + 1, RECT_MINI_UP.y + 1);
  4635.                                         } else if (sTab == 2) {
  4636.                                                 String roomString = "" + roomNumber;
  4637.                                                 if (roomNumber == 1) {
  4638.                                                         roomString = "Start";
  4639.                                                 } else if (bossFight) {
  4640.                                                         roomString = "Boss";
  4641.                                                 }
  4642.                                                 g.setColor(RECT_TAB_1.contains(mp) ? BT2 : BT4);
  4643.                                                 drawRect(g, RECT_TAB_1);
  4644.                                                 g.setColor(BT1);
  4645.                                                 drawRect(g, RECT_TAB_2);
  4646.                                                 g.setColor(RECT_TAB_3.contains(mp) ? BT2 : BT4);
  4647.                                                 drawRect(g, RECT_TAB_3);
  4648.                                                 g.setColor(WT3);
  4649.                                                 drawBevel(g, RECT_TAB_2);
  4650.                                                 g.clearRect(RECT_TAB_2.x + RECT_TAB_2.width, RECT_TAB_2.y + 1, 1, RECT_TAB_2.height -
  4651.  
  4652. 1);
  4653.                                                 g.drawString("Floor Time: " + (dungTimer != null ? dungTimer.toElapsedString() :
  4654.  
  4655. EMPTY_TIMER), 93, 380);
  4656.                                                 g.drawString("Floor Type: " + floor.getName(), 93, 398);
  4657.                                                 g.drawString("Floor Number: " + (fNumber > 0 ? fNumber : "??") + " (C" + aComplexity +
  4658.  
  4659. ")", 93, 416);
  4660.                                                 g.drawString("Current Room: " + roomString + " (of " + rooms.size() + ")", 93, 434);
  4661.                                                 g.drawString("Prestige Count: " + prestigeCount, 93, 452);
  4662.                                                 g.drawString("Progress: " + (maxFloor > 0 ? cProg + " of " + maxFloor + " floors" :
  4663.  
  4664. "Unknown"), 295, 380);
  4665.                                                 g.drawString("Avg. Floor Time: " + tpf + " mins", 295, 398);
  4666.                                                 g.drawString("Fastest Dungeon: " + fastestTime, 295, 416);
  4667.                                                 g.drawString("Slowest Dungeon: " + slowestTime, 295, 434);
  4668.                                                 g.drawString("Floor Success Rate: " + (dungeonCount + abortedCount != 0 ? dungeonCount
  4669.  
  4670. * 100 / (dungeonCount + abortedCount) : 100) + "%" , 295, 452);
  4671.                                         } else if (sTab == 3) {
  4672.                                                 g.setColor(RECT_TAB_1.contains(mp) ? BT2 : BT4);
  4673.                                                 drawRect(g, RECT_TAB_1);
  4674.                                                 g.setColor(RECT_TAB_2.contains(mp) ? BT2 : BT4);
  4675.                                                 drawRect(g, RECT_TAB_2);
  4676.                                                 g.setColor(BT1);
  4677.                                                 drawRect(g, RECT_TAB_3);
  4678.                                                 String cbName = "Melee";
  4679.                                                 String cbStyle = "";
  4680.                                                 if (primaryStyle == Style.MELEE) {
  4681.                                                         if (attGain > 0) {
  4682.                                                                 cbStyle = defGain > 0 ? "Controlled" : "Accurate";
  4683.                                                         } else if (defGain > 0) {
  4684.                                                                 cbStyle = "Defensive";
  4685.                                                         } else if (strGain > 0) {
  4686.                                                                 cbStyle = "Aggressive";
  4687.                                                         } else cbStyle = "Unknown";
  4688.                                                 } else if (primaryStyle == Style.RANGE) {
  4689.                                                         cbName = "Range";
  4690.                                                         cbStyle = defGain > 0 ? "Longrange" : "Rapid";
  4691.                                                 } else if (primaryStyle == Style.MAGIC) {
  4692.                                                         cbStyle = "Magic";
  4693.                                                         cbStyle = defGain > 0 ? "Defensive casting" : "Autocasting";
  4694.                                                 }
  4695.                                                 g.setColor(WT3);
  4696.                                                 drawBevel(g, RECT_TAB_3);
  4697.                                                 g.clearRect(RECT_TAB_3.x + RECT_TAB_3.width, RECT_TAB_3.y + 1, 1, RECT_TAB_3.height -
  4698.  
  4699. 1);
  4700.                                                 g.drawString(cbName + " Style: " + cbStyle, 93, 380);
  4701.                                                 g.drawString("Pray gain: " + prayGain + ", Def gain: " + defGain, 93, 398);
  4702.                                                 g.drawString("Combat Exp per Hour: " + ceph, 93, 416);
  4703.                                                 g.drawString("Skills Exp per Hour: " + seph, 93, 434);
  4704.                                                 g.drawString("Total Exp per Hour: " + (ceph + deph + seph), 93, 452);
  4705.                                         }
  4706.                                         g.setFont(FONT_1);
  4707.                                         g.setColor(WT3);
  4708.                                         g.drawString("Overview", 18, 384);
  4709.                                         g.drawString("Dungeons", 16, 415);
  4710.                                         g.drawString("Misc.", 32, 446);
  4711.                                         g.setColor(BT4);
  4712.                                         g.fillRect(7, 361, 80, 2);
  4713.                                 } else if (RECT_STATS.contains(mp)) {
  4714.                                         g.setColor(BLK);
  4715.                                         g.setFont(FONT_1);
  4716.                                         g.drawString("Statistics", 19, 358);
  4717.                                         g.setFont(FONT_2);
  4718.                                         g.setColor(BT2);
  4719.                                 } else g.setColor(BT4);
  4720.                                 drawRect(g, RECT_STATS);
  4721.                                 if (showOptions) {
  4722.                                         g.setColor(BT4);
  4723.                                         g.fillRect(91, 361, 80, 2);
  4724.                                 } else if (RECT_OPTIONS.contains(mp)) {
  4725.                                         g.setColor(BLK);
  4726.                                         g.setFont(FONT_1);
  4727.                                         g.drawString("Options", 108, 358);
  4728.                                         g.setFont(FONT_2);
  4729.                                         g.setColor(BT2);
  4730.                                 } else g.setColor(BT4);
  4731.                                 drawRect(g, RECT_OPTIONS);
  4732.                                 if ((showOptions || (showSettings && page < 2)) && oTab != 3) {
  4733.                                         for (Option o : options[oTab]) {
  4734.                                                 g.setColor(o.color());
  4735.                                                 drawRect(g, o.button());
  4736.                                                 g.setColor(WT3);
  4737.                                                 drawBevel(g, o.button());
  4738.                                                 g.setColor(WT3);
  4739.                                                 g.drawString(o.getName(), o.p().x, o.p().y);
  4740.                                         }
  4741.                                 }
  4742.                                 if (showOptions || page == 1) {
  4743.                                         if (oTab == 1) {
  4744.                                                 g.setColor(BT1);
  4745.                                                 drawRect(g, RECT_TAB_1);
  4746.                                                 g.setColor(RECT_TAB_2.contains(mp) ? BT2 : BT4);
  4747.                                                 drawRect(g, RECT_TAB_2);
  4748.                                                 g.setColor(!showSettings && RECT_TAB_3.contains(mp) ? BT2 : BT4);
  4749.                                                 drawRect(g, RECT_TAB_3);
  4750.                                                 g.setColor(WT3);
  4751.                                                 drawBevel(g, RECT_TAB_1);
  4752.                                                 g.clearRect(RECT_TAB_1.x + RECT_TAB_1.width, RECT_TAB_1.y + 1, 1, RECT_TAB_1.height -
  4753.  
  4754. 1);
  4755.                                                 g.setColor(WHT);
  4756.                                                 g.drawString("Pickup:", 100, 383);
  4757.                                                 g.drawString("Prayer:", 100, 405);
  4758.                                                 g.drawString("Exp:", 115, 427);
  4759.                                                 g.drawString("Other:", 105, 449);
  4760.                                         } else if (oTab == 2) {
  4761.                                                 g.setColor(RECT_TAB_1.contains(mp) ? BT2 : BT4);
  4762.                                                 drawRect(g, RECT_TAB_1);
  4763.                                                 g.setColor(BT1);
  4764.                                                 drawRect(g, RECT_TAB_2);
  4765.                                                 g.setColor(!showSettings && RECT_TAB_3.contains(mp) ? BT2 : BT4);
  4766.                                                 drawRect(g, RECT_TAB_3);
  4767.                                                 g.setColor(WT3);
  4768.                                                 drawBevel(g, RECT_TAB_2);
  4769.                                                 g.clearRect(RECT_TAB_2.x + RECT_TAB_2.width, RECT_TAB_2.y + 1, 1, RECT_TAB_2.height -
  4770.  
  4771. 1);
  4772.                                                 g.setColor(PT3);
  4773.                                                 g.fillRect(124, 403, 19, 19);
  4774.                                                 g.fillRect(310, 403, 19, 19);
  4775.                                                 g.fillRect(380, 403, 22, 19);
  4776.                                                 g.setColor(WT2);
  4777.                                                 g.draw3DRect(124, 403, 19, 19, true);
  4778.                                                 g.draw3DRect(310, 403, 19, 19, true);
  4779.                                                 g.draw3DRect(380, 403, 22, 19, true);
  4780.                                                 g.setColor(WHT);
  4781.                                                 g.drawString("Complexity:", 93, 382);
  4782.                                                 g.drawString("Rush Settings:", 270, 382);
  4783.                                                 g.drawString("" + complexity, 130, 418);
  4784.                                                 g.drawString("" + rComplexity, 316, 418);
  4785.                                                 g.drawString("" + rushTo, rushTo < 10 ? 387 : 383, 418);
  4786.                                                 g.setColor(WT3);
  4787.                                                 g.drawString("Complexity", 280, 452);
  4788.                                                 g.drawString("To floor", 365, 452);
  4789.                                                 g.drawString(RECT_C_UP.contains(mp) ? UPARROW_S : UPARROW, 124, 387);
  4790.                                                 g.drawString(RECT_C_DOWN.contains(mp) ? DOWNARROW_S : DOWNARROW, 124, 422);
  4791.                                                 g.drawString(RECT_RC_UP.contains(mp) ? UPARROW_S : UPARROW, 310, 387);
  4792.                                                 g.drawString(RECT_RC_DOWN.contains(mp) ? DOWNARROW_S : DOWNARROW, 310, 422);
  4793.                                                 g.drawString(RECT_F_UP.contains(mp) ? UPARROW_S : UPARROW, 381, 387);
  4794.                                                 g.drawString(RECT_F_DOWN.contains(mp) ? DOWNARROW_S : DOWNARROW, 381, 422);
  4795.                                         } else if (oTab == 3 && !showSettings) {
  4796.                                                 g.setColor(RECT_TAB_1.contains(mp) ? BT2 : BT4);
  4797.                                                 drawRect(g, RECT_TAB_1);
  4798.                                                 g.setColor(RECT_TAB_2.contains(mp) ? BT2 : BT4);
  4799.                                                 drawRect(g, RECT_TAB_2);
  4800.                                                 g.setColor(BT1);
  4801.                                                 drawRect(g, RECT_TAB_3);
  4802.                                                 g.setColor(WHT);
  4803.                                                 g.drawString("Loot Item:", RECT_PICKUP.x, RECT_PICKUP.y - 5);
  4804.                                                 g.drawString("Destroy Item:", RECT_DESTROY.x, RECT_DESTROY.y - 5);
  4805.                                                 g.setColor(PT3);
  4806.                                                 drawRect(g, RECT_PICKUP);
  4807.                                                 drawRect(g, RECT_DESTROY);
  4808.                                                 g.setColor(WT3);
  4809.                                                 drawBevel(g, RECT_TAB_3);
  4810.                                                 g.clearRect(RECT_TAB_3.x + RECT_TAB_3.width, RECT_TAB_3.y + 1, 1, RECT_TAB_3.height -
  4811.  
  4812. 1);
  4813.                                                 g.drawString("Type in the exact item names (case-insensitive).", RECT_PICKUP.x + 1,
  4814.  
  4815. RECT_PICKUP.y + 37);
  4816.                                                 g.drawString("Enter an item to destroy if you don't have an extra bind slot.",
  4817.  
  4818. RECT_PICKUP.x + 1, RECT_PICKUP.y + 53);
  4819.                                                 drawBevel(g, RECT_PICKUP);
  4820.                                                 drawBevel(g, RECT_DESTROY);
  4821.                                                 if (pickupName.isEmpty() && typeTo != 0) {
  4822.                                                         g.setColor(WT1);
  4823.                                                         g.drawString("Item to Look For", RECT_PICKUP.x + 4, RECT_PICKUP.y + 15);
  4824.                                                 } else g.drawString(pickupName + (typeTo == 0 ? "_" : ""), RECT_PICKUP.x + 4,
  4825.  
  4826. RECT_PICKUP.y + 15);
  4827.                                                 if (destroyName.isEmpty() && typeTo != 1) {
  4828.                                                         g.setColor(WT1);
  4829.                                                         g.drawString("Optional Item to Destroy", RECT_DESTROY.x + 4, RECT_DESTROY.y +
  4830.  
  4831. 15);
  4832.                                                 } else {
  4833.                                                         g.setColor(WT3);
  4834.                                                         g.drawString(destroyName + (typeTo == 1 ? "_" : ""), RECT_DESTROY.x + 4,
  4835.  
  4836. RECT_DESTROY.y + 15);
  4837.                                                 }
  4838.                                         }
  4839.                                         g.setFont(FONT_1);
  4840.                                         g.setColor(WT3);
  4841.                                         g.drawString("General", 22, 383);
  4842.                                         g.drawString("Complexity", 12, 415);
  4843.                                         if (!showSettings)
  4844.                                                 g.drawString("Binding", 22, 447);
  4845.                                 }
  4846.                                 if (showSettings) {
  4847.                                         g.setFont(FONT_2);
  4848.                                         if (page > 0) {
  4849.                                                 if (RECT_BACK.contains(mp)) {
  4850.                                                         g.setColor(BT1);
  4851.                                                         g.drawString("Back", 31, 450);
  4852.                                                         g.setColor(PT2);
  4853.                                                 } else g.setColor(PT1);
  4854.                                                 drawRect(g, RECT_BACK);
  4855.                                                 g.setColor(WT3);
  4856.                                                 drawBevel(g, RECT_BACK);
  4857.                                                 g.setColor(WHT);
  4858.                                                 g.drawString("Back", 32, 451);
  4859.                                         }
  4860.                                         if (RECT_CONTINUE.contains(mp)) {
  4861.                                                 g.setColor(BT1);
  4862.                                                 g.drawString("Continue", 442, 450);
  4863.                                                 g.setColor(PT2);
  4864.                                         } else g.setColor(PT1);
  4865.                                         drawRect(g, RECT_CONTINUE);
  4866.                                         g.setColor(WT3);
  4867.                                         drawBevel(g, RECT_CONTINUE);
  4868.                                         g.setColor(WHT);
  4869.                                         g.drawString("Continue", 443, 451);
  4870.                                         if (page == 0) {
  4871.                                                 g.drawString("Choose your primary combat style", 15, 382);
  4872.                                                 g.drawString("Choose your secondary combat style", 15, 422);
  4873.                                                 g.drawString("Settings options:", 300, 382);
  4874.                                         } else if (page == 2) {
  4875.                                                 if (Option.MELEE.enabled()) {
  4876.                                                         page = backPage ? --page : ++page;
  4877.                                                 } else if (Option.MAGIC.enabled()) {
  4878.                                                         g.drawString("Wield your staff and blastbox (optional) to use.", 15, 380);
  4879.                                                         g.drawString("Then turn the spell you want to use to autocast.", 15, 395);
  4880.                                                         if (isAutoCasting()) {
  4881.                                                                 Spell spell = getSpell(getSelectedSpell());
  4882.                                                                 if (spell != null)
  4883.                                                                         combatSpell = spell;
  4884.                                                                 g.setColor(WT3);
  4885.                                                         }
  4886.                                                         g.drawString("Spell selected: " + (combatSpell != null ? combatSpell.getName()
  4887.  
  4888. : "None"), 15, 415);
  4889.                                                 } else if (Option.RANGE.enabled()) {
  4890.                                                         g.drawString("Bind and wield the arrows you would like to use.", 15, 380);
  4891.                                                 }
  4892.                                         } else if (page == 3) {
  4893.                                                 if (Option.SECONDARY_MELEE.enabled()) {
  4894.                                                         RSItem selected = null;
  4895.                                                         String name = null;
  4896.                                                         g.drawString("Bind your backup melee weapon.", 15, 395);
  4897.                                                         g.drawString("Right click the item and select 'Use'.", 15, 410);
  4898.                                                         if (game.getCurrentTab() == Game.TAB_INVENTORY)
  4899.                                                                 selected = inventory.getSelectedItem();
  4900.                                                         if (selected != null) {
  4901.                                                                 secondaryWep = selected.getID();
  4902.                                                                 name = equipmentName(selected);
  4903.                                                         }
  4904.                                                         g.drawString("Secondary Weapon: " + (name != null ? name : "None"), 15, 425);
  4905.                                                 } else if (Option.SECONDARY_RANGE.enabled()) {
  4906.                                                         RSItem selected = null;
  4907.                                                         String name = null;
  4908.                                                         g.drawString("Bind the bow and arrows you would like to use.", 15, 380);
  4909.                                                         g.drawString("Equip the arrows and leave the bow in your inventory.", 15,
  4910.  
  4911. 395);
  4912.                                                         g.drawString("Right click the bow and select 'Use'.", 15, 410);
  4913.                                                         if (game.getCurrentTab() == Game.TAB_INVENTORY)
  4914.                                                                 selected = inventory.getSelectedItem();
  4915.                                                         if (selected != null) {
  4916.                                                                 secondaryWep = selected.getID();
  4917.                                                                 name = equipmentName(selected);
  4918.                                                         }
  4919.                                                         g.drawString("Secondary Weapon: " + (name != null ? name : "None"), 15, 425);
  4920.                                                 } else if (Option.SECONDARY_MAGIC.enabled()) {
  4921.                                                         g.drawString("You'll need a filled blastbox or combat runes to use secondary magic.", 15, 380);
  4922.                                                         g.drawString("Autocast the spell to use, then return the items to your inventory.", 15, 395);
  4923.                                                         if (isAutoCasting()) {
  4924.                                                                 Spell spell = getSpell(getSelectedSpell());
  4925.                                                                 if (spell != null)
  4926.                                                                         combatSpell = spell;
  4927.                                                                 if (game.getCurrentTab() == Game.TAB_INVENTORY) {
  4928.                                                                         int staff = getItemID("staff (b)");
  4929.                                                                         int bBox = getItemID("blastbox (b)");
  4930.                                                                         if (bBox == -1)
  4931.                                                                                 bBox = getItemID("surgebox (b)");
  4932.                                                                         if (bBox != -1)
  4933.                                                                                 blastBox = bBox;
  4934.                                                                         if (staff != -1)
  4935.                                                                                 secondaryWep = staff;
  4936.                                                                 }
  4937.                                                                 g.setColor(WT3);
  4938.                                                         }
  4939.                                                         g.drawString("Spell: " + (combatSpell != null ? combatSpell.getName() :
  4940.  
  4941. "None") + ", Staff: " + (secondaryWep > 0 ? game.getCurrentTab() == Game.TAB_INVENTORY ? equipmentName(inventory.getItem
  4942.  
  4943. (secondaryWep)).replace(" staff", "") : secondaryWep : "None") + ", Blastbox: " + (blastBox > 0 ? "Yes" : "No"), 15, 415);
  4944.                                                 } else page = backPage ? --page : ++page;
  4945.                                         } else if (page == 4) {
  4946.                                                 g.drawString("Be sure to bind and wield the primary weapon you would like to use.",
  4947.  
  4948. 15, 380);
  4949.                                                 g.drawString("Then select the combat style you would like to use.", 15, 395);
  4950.                                                 g.drawString("Press continue to complete the settings.", 15, 421);
  4951.                                         }
  4952.                                         g.setColor(BT1);
  4953.                                         g.fillRect(175, 361, 222, 2);
  4954.                                 }
  4955.                                 g.setColor(RECT_STATUS.contains(mp) ? BT4 : BT1);
  4956.                                 drawRect(g, RECT_STATUS);
  4957.                                 if (RECT_STATUS.contains(mp)) {
  4958.                                         g.setColor(BLK);
  4959.                                         g.setFont(FONT_4);
  4960.                                         if (!showSettings) {
  4961.                                                 if (!RECT_CONTROL.contains(mp) || controlStatus.isEmpty()) {
  4962.                                                         if (secondaryStatus.isEmpty() || !showSecondary) {
  4963.                                                                 g.drawString(status, 181, 358);
  4964.                                                         } else g.drawString("+ " + secondaryStatus, 181, 358);
  4965.                                                 } else g.drawString(controlStatus, 181, 358);
  4966.                                         } else g.drawString(statusSettings, 181, 358);
  4967.                                 }
  4968.                                 g.setColor(PRP);
  4969.                                 g.setFont(FONT_1);
  4970.                                 g.drawString("Statistics", 18, 357);
  4971.                                 g.drawString("Options", 107, 357);
  4972.                                 g.setFont(FONT_4);
  4973.                                 if (!showSettings) {
  4974.                                         if (controlStatus.isEmpty() || !RECT_CONTROL.contains(mp)) {
  4975.                                                 g.setColor(GN1);
  4976.                                                 g.drawString(secondaryStatus.isEmpty() || !showSecondary ? status : "+ " +
  4977.  
  4978. secondaryStatus, 180, 357);
  4979.                                         } else {
  4980.                                                 g.setColor(RED);
  4981.                                                 g.drawString(controlStatus, 180, 357);
  4982.                                         }
  4983.                                 } else g.drawString(statusSettings, 180, 357);
  4984.                                 g.setColor(PRP);
  4985.                                 if (settingsFinished) {
  4986.                                         g.setFont(FONT_3);
  4987.                                         g.drawString("v" + VERSION, 484, 455);
  4988.                                 }
  4989.                                 g.setFont(FONT_2);
  4990.                                 g.drawString((userRank != 0 ? "Highscores rank: " + userRank + " || " : "") + (userCount != 0 ?
  4991.  
  4992. userCount + " users online || " : "") + "by kiko & ShadowMoose", 91 + rankOffset + userOffset, 471);
  4993.                         }
  4994.                         g.setColor(BT1);
  4995.                         drawRect(g, RECT_CONTROL);
  4996.                         if (RECT_CONTROL.contains(mp)) {
  4997.                                 if (!pauseiDungeon) {
  4998.                                         g.drawString(RECT_PLAY.contains(mp) ? PLAY_S : PLAY, RECT_PLAY.x, RECT_PLAY.y);
  4999.                                 } else g.drawString(RECT_PLAY.contains(mp) ? PAUSE_S : PAUSE, RECT_PLAY.x, RECT_PLAY.y);
  5000.                                 g.drawString(RECT_INFO.contains(mp) ? INFO_S : INFO, RECT_INFO.x, RECT_INFO.y);
  5001.                                 g.drawString(RECT_HELP.contains(mp) ? HELP_S : HELP, RECT_HELP.x, RECT_HELP.y);
  5002.                                 g.drawString(RECT_STOP.contains(mp) ? STOP_S : STOP, RECT_STOP.x, RECT_STOP.y);
  5003.                         } else g.drawString(LOGO, RECT_CONTROL.x, RECT_CONTROL.y);
  5004.                         g.drawString(RECT_HIDE.contains(mp) ? HIDE_S : HIDE, RECT_HIDE.x, RECT_HIDE.y);
  5005.                 }
  5006.         }
  5007.  
  5008.         public void keyPressed(KeyEvent e) { }
  5009.  
  5010.         public void keyReleased(KeyEvent e) { }
  5011.  
  5012.         public void keyTyped(KeyEvent e) {
  5013.                 if (!hidePaint && showOptions && oTab == 3) {
  5014.                         char key = e.getKeyChar();
  5015.                         if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB) {
  5016.                                 typeTo = typeTo < 1 ? ++typeTo : -1;
  5017.                                 env.setUserInput(typeTo != -1 ? 0 : Environment.INPUT_KEYBOARD);
  5018.                         } else if (typeTo == 0) {
  5019.                                 if (key == KeyEvent.VK_BACK_SPACE && pickupName.length() > 0) {
  5020.                                         pickupName = pickupName.substring(0, pickupName.length() - 1);
  5021.                                 } else if (key != KeyEvent.VK_BACK_SPACE && pickupName.length() < 25) {
  5022.                                         pickupName += key;
  5023.                                 }
  5024.                         } else if (typeTo == 1) {
  5025.                                 if (key == KeyEvent.VK_BACK_SPACE && destroyName.length() > 0) {
  5026.                                         destroyName = destroyName.substring(0, destroyName.length() - 1);
  5027.                                 } else if (key != KeyEvent.VK_BACK_SPACE && destroyName.length() < 25) {
  5028.                                         destroyName += key;
  5029.                                 }
  5030.                         }
  5031.                 }
  5032.         }
  5033.  
  5034.         public void messageReceived(MessageEvent e) {
  5035.                 int id = e.getID();
  5036.                 String msg = e.getMessage();
  5037.                 if (id == MessageEvent.MESSAGE_SERVER) {
  5038.                         if (msg.equals("Welcome to RuneScape.")) {
  5039.                                 welcomeBack = true;
  5040.                         } else if (msg.startsWith("Oh dear")) {
  5041.                                 isDead = true;
  5042.                         } else if (msg.startsWith("Floor <")) {
  5043.                                 int idx = msg.indexOf(">") + 1;
  5044.                                 if (idx != 0) {
  5045.                                         fNumber = Integer.parseInt(msg.substring(idx, idx + 2).trim());
  5046.                                         cProg = fNumber - 1;
  5047.                                 }
  5048.                         } else if (msg.startsWith("You unlock the door")) {
  5049.                                 lockDown = true;
  5050.                         } else if (msg.contains("been frozen") || msg.contains("force prevents") || msg.contains("force stops") ||
  5051.  
  5052. msg.contains("You're stunned")) {
  5053.                                 unreachable = true;
  5054.                         } else if (msg.contains("cannot teleport")) {
  5055.                                 finish = true;
  5056.                         } else if ((msg.startsWith("You need a") || msg.contains("require a")) && msg.contains("level of")) {
  5057.                                 levelRequirement = false;
  5058.                         } else if (msg.contains("need at least ") && msg.contains("to do that")) {
  5059.                                 levelRequirement = false;
  5060.                         } else if (combatStyle == Style.RANGE && msg.contains("ammo left in") && !secondaryStatus.startsWith
  5061.  
  5062. ("Swapping")) {
  5063.                                 outOfAmmo = true;
  5064.                         } else if (combatStyle == Style.MAGIC && msg.contains("runes to cast") && !secondaryStatus.startsWith
  5065.  
  5066. ("Swapping") && (msg.contains("air") || msg.contains("chaos") || msg.contains("death") || msg.contains("blood"))) {
  5067.                                 outOfAmmo = true;
  5068.                         } else if (msg.contains("advanced a Dung")) {
  5069.                                 dungLevel++;
  5070.                                 if (levelGoal <= dungLevel)
  5071.                                         levelGoal = dungLevel + 1;
  5072.                         } else if (puzzleTimer != null) {
  5073.                                 if (msg.contains("toggle back off") || msg.contains("both the chest in")) {
  5074.                                         roomSwitch = true;
  5075.                                 } else if (msg.contains("hear a click") || msg.contains("now unlocked") || msg.contains("challenge room has already")) {
  5076.                                         puzzleSolved = true;
  5077.                                 } else if (msg.contains("sever the plant") || msg.contains("monolith reaches")) {
  5078.                                         puzzleSolved = true;
  5079.                                 }
  5080.                         } else if (bossFight) {
  5081.                                 if (msg.contains("got caught")) {
  5082.                                         roomSwitch = true;
  5083.                                 }
  5084.                                 if (msg.contains(" pull")) {
  5085.                                         roomSwitch = true;
  5086.                                 } else if (msg.contains("received item: ")) {
  5087.                                         itemReceived = true;
  5088.                                 } else if (msg.contains("prayer") && (msg.contains("deactivated") || msg.contains("injured"))) {
  5089.                                         prayTimer = new Timer(random(10000, 20000));
  5090.                                 } else if (floor == Floor.WARPED) {
  5091.                                         if (msg.contains("consumes your prayers"))
  5092.                                                 prayTimer = new Timer(random(25000, 35000));
  5093.                                 }
  5094.                         }
  5095.                 } else if (id == 4 && msg.contains("can't reach")) {
  5096.                         unreachable = true;
  5097.                 }
  5098.                 if (id == MessageEvent.MESSAGE_SERVER || id == MessageEvent.MESSAGE_EXAMINE_NPC || id == MessageEvent.MESSAGE_ACTION)
  5099.                         lastMessage = msg;
  5100.         }
  5101.  
  5102.         public void mouseMoved(MouseEvent e) {
  5103.                 mp = e.getPoint();
  5104.                 if (RECT_CONTROL.contains(mp)) {
  5105.                         if (RECT_PLAY.contains(mp)) {
  5106.                                 controlStatus = (!pauseiDungeon ? "Pause" : "Resume") + " iDungeon";
  5107.                         } else if (RECT_STOP.contains(mp)) {
  5108.                                 controlStatus = "Terminate iDungeon";
  5109.                         } else if (RECT_INFO.contains(mp)) {
  5110.                                 controlStatus = "Visit the iDungeon forums";
  5111.                         } else if (RECT_HELP.contains(mp)) {
  5112.                                 controlStatus = "iDungeon help guide";
  5113.                         } else if (RECT_HIDE.contains(mp)) {
  5114.                                 controlStatus = "Hide paint";
  5115.                         } else controlStatus = "";
  5116.                 } else if (showSettings) {
  5117.                         statusSettings = statusSettings.isEmpty() || statusSettings.startsWith("Hover") ? "Hover over an option to find out more" : "Please choose your settings";
  5118.                         if (page > 0 && RECT_BACK.contains(mp)) {
  5119.                                 statusSettings = "<<< Previous page";
  5120.                         } else if (RECT_CONTINUE.contains(mp)) {
  5121.                                 statusSettings = page < 5 ? statusSettings = "Next page >>>" : "Finish the settings";
  5122.                         } else if (RECT_CHAT.contains(mp)) {
  5123.                                 statusSettings = "These guys kick ass!";
  5124.                         } else if (page == 0 && oTab == 0) {
  5125.                                 if (Option.MELEE.contains(mp)) {
  5126.                                         statusSettings = "Set your primary combat to melee";
  5127.                                 } else if (Option.RANGE.contains(mp)) {
  5128.                                         statusSettings = "Set your primary combat to range";
  5129.                                 } else if (Option.MAGIC.contains(mp)) {
  5130.                                         statusSettings = "Set your primary combat to range";
  5131.                                 } else if (Option.SECONDARY_MELEE.contains(mp)) {
  5132.                                         statusSettings = "Set your secondary combat to melee";
  5133.                                 } else if (Option.SECONDARY_RANGE.contains(mp)) {
  5134.                                         statusSettings = "Set your secondary combat to range";
  5135.                                 } else if (Option.SECONDARY_MAGIC.contains(mp)) {
  5136.                                         statusSettings = "Set your secondary combat to mage";
  5137.                                 } else if (Option.LOAD_SETTINGS.contains(mp)) {
  5138.                                         statusSettings = "Load your settings on startup";
  5139.                                 } else if (Option.SAVE_SETTINGS.contains(mp)) {
  5140.                                         statusSettings = "Save your settings for next time";
  5141.                                 }
  5142.                         } else if (page == 1) {
  5143.                                 if (RECT_TAB_1.contains(mp)) {
  5144.                                         statusSettings = "General script settings";
  5145.                                 } else if (RECT_TAB_2.contains(mp)) {
  5146.                                         statusSettings = "Advanced floor settings & complexity";
  5147.                                 } else if (!showSettings && RECT_TAB_3.contains(mp)) {
  5148.                                         statusSettings = "Search and bind an item";
  5149.                                 } else if (oTab == 1) {
  5150.                                         if (Option.BONES.contains(mp)) {
  5151.                                                 statusSettings = "Pick up and bury bones";
  5152.                                         } else if (Option.ARROWS.contains(mp)) {
  5153.                                                 statusSettings = "Collect the arrows you use up";
  5154.                                         } else if (Option.CRABS.contains(mp)) {
  5155.                                                 statusSettings = "Loot heim crabs, for extra hp";
  5156.                                         } else if (Option.PRAY.contains(mp)) {
  5157.                                                 statusSettings = "Use protection prayers for monsters";
  5158.                                         } else if (Option.QUICK_PRAY.contains(mp)) {
  5159.                                                 statusSettings = "Use quick prayers in addition";
  5160.                                         } else if (Option.PRAY_DOORS.contains(mp)) {
  5161.                                                 statusSettings = "Enable this to open prayer doors";
  5162.                                         } else if (Option.PURE.contains(mp)) {
  5163.                                                 statusSettings = "Prevents defense training";
  5164.                                         } else if (Option.STYLE_SWAP.contains(mp)) {
  5165.                                                 statusSettings = "Switch attack styles by weakness";
  5166.                                         } else if (Option.SUMMON.contains(mp)) {
  5167.                                                 statusSettings = "Gain summoning experience";
  5168.                                         } else if (Option.MAKE_FOOD.contains(mp)) {
  5169.                                                 statusSettings = "Make food when you're running low";
  5170.                                         } else if (Option.EXPLORER.contains(mp)) {
  5171.                                                 statusSettings = "Open all explorable rooms on the floor";
  5172.                                         } else if (Option.LOGOUT.contains(mp)) {
  5173.                                                 statusSettings = "Avoid the 6-hour logout timer";
  5174.                                         }
  5175.                                 } else if (oTab == 2) {
  5176.                                         if (RECT_C_UP.contains(mp) || RECT_C_DOWN.contains(mp)) {
  5177.                                                 statusSettings = "Cycle the Dungeon's Complexity level";
  5178.                                         } else if (RECT_RC_UP.contains(mp) || RECT_RC_DOWN.contains(mp)) {
  5179.                                                 statusSettings = "Select the complexity to rush at";
  5180.                                         } else if (RECT_F_UP.contains(mp) || RECT_F_DOWN.contains(mp)) {
  5181.                                                 statusSettings = "Select the floor to rush to";
  5182.                                         } else if (Option.PRESTIGE.contains(mp)) {
  5183.                                                 statusSettings = "Intelligently reset your progress";
  5184.                                         } else if (Option.MEDIUM.contains(mp)) {
  5185.                                                 statusSettings = "Explore Medium dungeons";
  5186.                                         } else if (Option.DEBUG.contains(mp)) {
  5187.                                                 statusSettings = "Paint doors and rooms on the map";
  5188.                                         } else if (Option.VIDEO.contains(mp)) {
  5189.                                                 statusSettings = "Blacks out all usernames - BETA";
  5190.                                         } else if (Option.RUSH.contains(mp)) {
  5191.                                                 statusSettings = "Enable rushing of certain floors";
  5192.                                         } else if (Option.RUSH_FOOD.contains(mp)) {
  5193.                                                 statusSettings = "Enable food pickup when rushing";
  5194.                                         }
  5195.                                 }
  5196.                         }
  5197.                 }
  5198.         }
  5199.  
  5200.         public void mouseClicked(MouseEvent e) {
  5201.                 Point p = e.getPoint();
  5202.                 cp = e.getPoint();
  5203.                 if (RECT_STATUS.contains(p)) {
  5204.                         if (confirmToStop) {
  5205.                                 authCheck = true;
  5206.                                 status = "Shutting down iDungeon Pro";
  5207.                                 secondaryStatus = "";
  5208.                         } else if (secondaryStatus.isEmpty()) {
  5209.                                 showSecondary = true;
  5210.                         } else showSecondary = !showSecondary;
  5211.                 } else if (RECT_PLAY.contains(p)) {
  5212.                         pauseiDungeon = !pauseiDungeon;
  5213.                 } else if (RECT_STOP.contains(p)) {
  5214.                         confirmToStop = !confirmToStop;
  5215.                         showSecondary = true;
  5216.                         secondaryStatus = confirmToStop ? "Click here to confirm shutdown" : "";
  5217.                 } else if (RECT_INFO.contains(p)) {
  5218.                         try {
  5219.                                 Desktop.getDesktop().browse(new URI("http://shadowscripting.org/forums/viewforum.php?f=2"));
  5220.                         } catch (Exception ex) {
  5221.                                 log(RED, "Unable to load the forums :(");
  5222.                         }
  5223.                 } else if (RECT_HELP.contains(p)) {
  5224.                         try {
  5225.                                 Desktop.getDesktop().browse(new URI("http://shadowscripting.wordpress.com/idungeon-users-guide/"));
  5226.                         } catch (Exception ex) {
  5227.                                 log(RED, "Unable to load the help manual :(");
  5228.                         }
  5229.                 } else if (RECT_HIDE.contains(p)) {
  5230.                         hidePaint = !hidePaint;
  5231.                 } else if (!hidePaint) {
  5232.                         if (RECT_CHAT.contains(p)) {
  5233.                                 showChat = !showChat;
  5234.                         } else if (RECT_STATS.contains(p) && !showSettings) {
  5235.                                 showStats = true;
  5236.                                 showOptions = false;
  5237.                         } else if (RECT_OPTIONS.contains(p) && !showSettings) {
  5238.                                 showStats = false;
  5239.                                 showOptions = true;
  5240.                         } else if (showSettings && page == 0) {
  5241.                                 if (Option.MELEE.contains(p)) {
  5242.                                         if (!Option.SECONDARY_RANGE.enabled())
  5243.                                                 Option.ARROWS.set(false);
  5244.                                         Option.MELEE.set(true);
  5245.                                         Option.RANGE.set(false);
  5246.                                         Option.MAGIC.set(false);
  5247.                                         Option.SECONDARY_MELEE.set(false);
  5248.                                 } else if (Option.RANGE.contains(p)) {
  5249.                                         if (!Option.SECONDARY_MAGIC.enabled())
  5250.                                                 Option.SECONDARY_MELEE.set(true);
  5251.                                         Option.MELEE.set(false);
  5252.                                         Option.RANGE.set(true);
  5253.                                         Option.MAGIC.set(false);
  5254.                                         Option.SECONDARY_RANGE.set(false);
  5255.                                         Option.ARROWS.set(true);
  5256.                                 } else if (Option.MAGIC.contains(p)) {
  5257.                                         if (!Option.SECONDARY_RANGE.enabled()) {
  5258.                                                 Option.ARROWS.set(true);
  5259.                                                 Option.SECONDARY_MELEE.set(true);
  5260.                                         }
  5261.                                         Option.MELEE.set(false);
  5262.                                         Option.RANGE.set(false);
  5263.                                         Option.MAGIC.set(true);
  5264.                                         Option.SECONDARY_MAGIC.set(false);
  5265.                                 } else if (Option.SECONDARY_MELEE.contains(p)) {
  5266.                                         if (!Option.MELEE.enabled()) {
  5267.                                                 Option.SECONDARY_MELEE.toggle();
  5268.                                                 if (Option.SECONDARY_MELEE.enabled()) {
  5269.                                                         Option.SECONDARY_RANGE.set(false);
  5270.                                                         Option.SECONDARY_MAGIC.set(false);
  5271.                                                 }
  5272.                                                 if (!Option.RANGE.enabled())
  5273.                                                         Option.ARROWS.set(true);
  5274.                                         }
  5275.                                 } else if (Option.SECONDARY_RANGE.contains(p)) {
  5276.                                         if (!Option.RANGE.enabled()) {
  5277.                                                 Option.SECONDARY_RANGE.toggle();
  5278.                                                 if (Option.SECONDARY_RANGE.enabled()) {
  5279.                                                         Option.SECONDARY_MELEE.set(false);
  5280.                                                         Option.SECONDARY_MAGIC.set(false);
  5281.                                                 }
  5282.                                                 Option.ARROWS.set(true);
  5283.                                         }
  5284.                                 } else if (Option.SECONDARY_MAGIC.contains(p)) {
  5285.                                         if (!Option.MAGIC.enabled()) {
  5286.                                                 Option.SECONDARY_MAGIC.toggle();
  5287.                                                 if (Option.SECONDARY_MAGIC.enabled()) {
  5288.                                                         Option.SECONDARY_MELEE.set(false);
  5289.                                                         Option.SECONDARY_RANGE.set(false);
  5290.                                                 }
  5291.                                                 if (!Option.RANGE.enabled())
  5292.                                                         Option.ARROWS.set(false);
  5293.                                         }
  5294.                                 } else if (Option.LOAD_SETTINGS.contains(p)) {
  5295.                                         Option.LOAD_SETTINGS.toggle();
  5296.                                 } else if (Option.SAVE_SETTINGS.contains(p)) {
  5297.                                         Option.SAVE_SETTINGS.toggle();
  5298.                                 }
  5299.                         } else if (showStats && sTab == 1) {
  5300.                                 if (RECT_MINI_UP.contains(p)) {
  5301.                                         levelGoal = levelGoal == 120 ? dungLevel + 1 : ++levelGoal;
  5302.                                 } else if (RECT_MINI_DOWN.contains(p)) {
  5303.                                         levelGoal = levelGoal == dungLevel + 1 ? 120 : --levelGoal;
  5304.                                 }
  5305.                         } else if ((showSettings && page == 1) || showOptions) {
  5306.                                 if (RECT_TAB_1.contains(p)) {
  5307.                                         oTab = 1;
  5308.                                 } else if (RECT_TAB_2.contains(p)) {
  5309.                                         oTab = 2;
  5310.                                 } else if (!showSettings && RECT_TAB_3.contains(p)) {
  5311.                                         oTab = 3;
  5312.                                 } else if (oTab == 1) {
  5313.                                         if (Option.BONES.contains(p)) {
  5314.                                                 Option.BONES.toggle();
  5315.                                         } else if (Option.ARROWS.contains(p)) {
  5316.                                                 if (Option.RANGE.enabled() || Option.SECONDARY_RANGE.enabled())
  5317.                                                         Option.ARROWS.toggle();
  5318.                                         } else if (Option.CRABS.contains(p)) {
  5319.                                                 Option.CRABS.toggle();
  5320.                                         } else if (Option.PRAY.contains(p)) {
  5321.                                                 Option.PRAY.toggle();
  5322.                                         } else if (Option.QUICK_PRAY.contains(p)) {
  5323.                                                 Option.QUICK_PRAY.toggle();
  5324.                                         } else if (Option.PRAY_DOORS.contains(p)) {
  5325.                                                 Option.PRAY_DOORS.toggle();
  5326.                                                 if (!Option.PRAY_DOORS.enabled())
  5327.                                                         log(RED, "Warning! Disabling prayer doors & puzzles will force the bot to abort dungeons");
  5328.                                         } else if (Option.PURE.contains(p)) {
  5329.                                                 Option.PURE.toggle();
  5330.                                         } else if (Option.STYLE_SWAP.contains(p)) {
  5331.                                                 if (!settingsFinished || Melee.SLASH.index() != -1)
  5332.                                                         Option.STYLE_SWAP.toggle();
  5333.                                         } else if (Option.SUMMON.contains(p)) {
  5334.                                                 Option.SUMMON.toggle();
  5335.                                                 if (!Option.SUMMON.enabled())
  5336.                                                         log(RED, "Warning! Disabling summoning doors & puzzles will force the bot to abort dungeons");
  5337.                                         } else if (Option.MAKE_FOOD.contains(p)) {
  5338.                                                 Option.MAKE_FOOD.toggle();
  5339.                                         } else if (Option.EXPLORER.contains(p)) {
  5340.                                                 Option.EXPLORER.toggle();
  5341.                                         } else if (Option.LOGOUT.contains(p)) {
  5342.                                                 Option.LOGOUT.toggle();
  5343.                                         }
  5344.                                 } else if (oTab == 2) {
  5345.                                         if (RECT_C_UP.contains(p)) {
  5346.                                                 if (complexity < 6) {
  5347.                                                         complexity++;
  5348.                                                 } else complexity = 1;
  5349.                                         } else if (RECT_C_DOWN.contains(p)) {
  5350.                                                 if (complexity > 1) {
  5351.                                                         complexity--;
  5352.                                                 } else complexity = 6;
  5353.                                         } else if (RECT_RC_UP.contains(p)) {
  5354.                                                 if (rComplexity != 6) {
  5355.                                                         rComplexity++;
  5356.                                                 } else rComplexity = 1;
  5357.                                         } else if (RECT_RC_DOWN.contains(p)) {
  5358.                                                 if (rComplexity != 1) {
  5359.                                                         rComplexity--;
  5360.                                                 } else rComplexity = 6;
  5361.                                         } else if (RECT_F_UP.contains(p)) {
  5362.                                                 if (maxFloor > 0) {
  5363.                                                         rushTo = rushTo < maxFloor ? ++rushTo : 1;
  5364.                                                 } else if (rushTo < 35) {
  5365.                                                         rushTo++;
  5366.                                                 } else rushTo = 1;
  5367.                                         } else if (RECT_F_DOWN.contains(p)) {
  5368.                                                 if (rushTo > 1) {
  5369.                                                         rushTo--;
  5370.                                                 } else if (maxFloor > 0) {
  5371.                                                         rushTo = valueOf(maxFloor);
  5372.                                                 } else rushTo = 35;
  5373.                                         } else if (Option.RUSH.contains(p)) {
  5374.                                                 Option.RUSH.toggle();
  5375.                                         } else if (Option.PRESTIGE.contains(p)) {
  5376.                                                 Option.PRESTIGE.toggle();
  5377.                                         } else if (Option.MEDIUM.contains(p)) {
  5378.                                                 Option.MEDIUM.toggle();
  5379.                                         } else if (Option.DEBUG.contains(p)) {
  5380.                                                 Option.DEBUG.toggle();
  5381.                                         } else if (Option.RUSH_FOOD.contains(p)) {
  5382.                                                 Option.RUSH_FOOD.toggle();
  5383.                                         } else if (Option.VIDEO.contains(p)) {
  5384.                                                 Option.VIDEO.toggle();
  5385.                                         }
  5386.                                 } else if (!showSettings && oTab == 3) {
  5387.                                         if (RECT_PICKUP.contains(p)) {
  5388.                                                 env.setUserInput(0);
  5389.                                                 typeTo = 0;
  5390.                                         } else if (RECT_DESTROY.contains(p)) {
  5391.                                                 env.setUserInput(0);
  5392.                                                 typeTo = 1;
  5393.                                         } else {
  5394.                                                 env.setUserInput(Environment.INPUT_KEYBOARD);
  5395.                                                 typeTo = -1;
  5396.                                         }
  5397.                                 }
  5398.                         }
  5399.                         if (showSettings) {
  5400.                                 if (RECT_CONTINUE.contains(p)) {
  5401.                                         if (page == 0)
  5402.                                                 oTab = 1;
  5403.                                         backPage = false;
  5404.                                         page++;
  5405.                                         if (page > 4) {
  5406.                                                 showSettings = false;
  5407.                                                 showStats = true;
  5408.                                           &nbs