PageRenderTime 63ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/scripts/SS7AddyMiner.java

http://d-linked.googlecode.com/
Java | 2462 lines | 2218 code | 202 blank | 42 comment | 655 complexity | 66f1c96792c5d049ef2c2d70d638a293 MD5 | raw file
Possible License(s): GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.awt.event.KeyEvent;
  6. import java.io.BufferedReader;
  7. import java.io.File;
  8. import java.io.FileInputStream;
  9. import java.io.FileOutputStream;
  10. import java.io.IOException;
  11. import java.io.InputStreamReader;
  12. import java.lang.reflect.Method;
  13. import java.net.URL;
  14. import java.net.URLConnection;
  15. import java.util.ArrayList;
  16. import java.util.Map;
  17. import java.util.Properties;
  18. import java.util.logging.Level;
  19. import javax.swing.JOptionPane;
  20. import org.rsbot.bot.Bot;
  21. import org.rsbot.bot.input.Mouse;
  22. import org.rsbot.event.events.ServerMessageEvent;
  23. import org.rsbot.event.listeners.PaintListener;
  24. import org.rsbot.event.listeners.ServerMessageListener;
  25. import org.rsbot.gui.AccountManager;
  26. import org.rsbot.script.Calculations;
  27. import org.rsbot.script.Constants;
  28. import org.rsbot.script.GrandExchange;
  29. import org.rsbot.script.Script;
  30. import org.rsbot.script.ScriptManifest;
  31. import org.rsbot.script.randoms.WelcomeScreen;
  32. import org.rsbot.script.wrappers.RSInterface;
  33. import org.rsbot.script.wrappers.RSInterfaceComponent;
  34. import org.rsbot.script.wrappers.RSObject;
  35. import org.rsbot.script.wrappers.RSTile;
  36. import org.rsbot.util.GlobalConfiguration;
  37. @ScriptManifest(authors = { "SS7" }, category = "Mining", name = "SS7's Adamantite And Mithril Miner", version = 4.04, description = "<html><head><style type=\"text/css\"> hr {color: white} p {margin-left: 20px}</style></head><body><center><b><font size=\"4\" color=\"black\">All setting's can be configured in the GUI</font></b></table></center></body></html>")
  38. public class SS7AddyMiner extends Script implements PaintListener,
  39. ServerMessageListener {
  40. class SS7AddyMinerSettings {
  41. final File settingsFile = new File(new File(GlobalConfiguration.Paths
  42. .getSettingsDirectory()), SETTINGS_FILE_NAME);
  43. String oreToMine = "";
  44. String location = "";
  45. String miningMethod = "";
  46. String antibanSpeed = "";
  47. boolean allWorlds = false;
  48. int[] worlds = new int[50];
  49. boolean superheat = false;
  50. boolean mithBars = false;
  51. boolean addyBars = false;
  52. boolean alch = false;
  53. boolean alchGems = false;
  54. boolean alchBars = false;
  55. boolean alchOres = false;
  56. boolean alchCoal = false;
  57. boolean member = false;
  58. boolean showPaint = false;
  59. boolean useRest = false;
  60. boolean dropGems = false;
  61. boolean dropDiamonds = false;
  62. boolean dropRubies = false;
  63. boolean dropEmeralds = false;
  64. boolean dropSapphires = false;
  65. String reportSetting = "";
  66. public SS7AddyMinerSettings() {
  67. }
  68. public String booleanToString(final boolean a) {
  69. if (a) {
  70. return "true";
  71. } else {
  72. return "false";
  73. }
  74. }
  75. public boolean extractBoolean(final String text) {
  76. return text.equals("true");
  77. }
  78. public int[] extractIntegers(String text) {
  79. int[] ints = null;
  80. try {
  81. text = text.replaceAll(" ", "");
  82. final String[] strInts = text.split(",");
  83. ints = new int[strInts.length];
  84. for (int a = 0; a < strInts.length; a++) {
  85. ints[a] = Integer.parseInt(strInts[a]);
  86. }
  87. } catch (final Exception e) {
  88. log.log(Level.SEVERE, "extractIntegers(String) error: ", e);
  89. }
  90. return ints;
  91. }
  92. public String[] extractStrings(final String text) {
  93. return text.split(",");
  94. }
  95. public String getSetting(final String settingName) {
  96. try {
  97. final Properties p = new Properties();
  98. p.load(new FileInputStream(settingsFile));
  99. return p.getProperty(settingName);
  100. } catch (final IOException ioe) {
  101. log.log(Level.SEVERE, "loadSettings(String) error: ", ioe);
  102. return "";
  103. }
  104. }
  105. public String[][] getSettingsArray() {
  106. final ArrayList<String[]> settingsArray = new ArrayList<String[]>();
  107. settingsArray.add(new String[] { "ORETOMINE", oreToMine });
  108. settingsArray.add(new String[] { "MININGMETHOD", miningMethod });
  109. settingsArray.add(new String[] { "LOCATION", location });
  110. settingsArray.add(new String[] { "ANTIBANSPEED", antibanSpeed });
  111. settingsArray.add(new String[] { "ALLWORLDS",
  112. booleanToString(allWorlds) });
  113. if (!allWorlds) {
  114. settingsArray.add(new String[] { "WORLDS",
  115. intArrayToString(worlds) });
  116. }
  117. settingsArray.add(new String[] { "SUPERHEAT",
  118. booleanToString(superheat) });
  119. if (superheat) {
  120. settingsArray.add(new String[] { "MITHBARS",
  121. booleanToString(mithBars) });
  122. settingsArray.add(new String[] { "ADDYBARS",
  123. booleanToString(addyBars) });
  124. }
  125. settingsArray.add(new String[] { "ALCH", booleanToString(alch) });
  126. if (alch) {
  127. settingsArray.add(new String[] { "ALCHGEMS",
  128. booleanToString(alchGems) });
  129. settingsArray.add(new String[] { "ALCHBARS",
  130. booleanToString(alchBars) });
  131. settingsArray.add(new String[] { "ALCHORES",
  132. booleanToString(alchOres) });
  133. settingsArray.add(new String[] { "ALCHCOAL",
  134. booleanToString(alchCoal) });
  135. }
  136. settingsArray.add(new String[] { "DROPGEMS",
  137. booleanToString(dropGems) });
  138. if (dropGems) {
  139. settingsArray.add(new String[] { "DROPDIAMOND",
  140. booleanToString(dropDiamonds) });
  141. settingsArray.add(new String[] { "DROPRUBY",
  142. booleanToString(dropRubies) });
  143. settingsArray.add(new String[] { "DROPEMERALD",
  144. booleanToString(dropEmeralds) });
  145. settingsArray.add(new String[] { "DROPSAPPHIRE",
  146. booleanToString(dropSapphires) });
  147. }
  148. settingsArray.add(new String[] { "USEREST",
  149. booleanToString(useRest) });
  150. settingsArray.add(new String[] { "SHOWPAINT",
  151. booleanToString(showPaint) });
  152. settingsArray
  153. .add(new String[] { "MEMBER", booleanToString(member) });
  154. settingsArray.add(new String[] { "REPORTSETTING", reportSetting });
  155. final String[][] stringArray = new String[settingsArray.size()][2];
  156. for (int a = 0; a < settingsArray.size(); a++) {
  157. stringArray[a][0] = settingsArray.get(a)[0];
  158. stringArray[a][1] = settingsArray.get(a)[1];
  159. }
  160. return stringArray;
  161. }
  162. public String intArrayToString(final int[] array) {
  163. String intArray = null;
  164. try {
  165. if (array.length > 0) {
  166. intArray = "";
  167. for (int a = 0; a < array.length; a++) {
  168. if (array[a] != 0) {
  169. intArray += array[a];
  170. if (a != array.length - 1) {
  171. intArray += ",";
  172. }
  173. }
  174. }
  175. return intArray;
  176. }
  177. } catch (final Exception e) {
  178. }
  179. return "";
  180. }
  181. public void saveSettings(final String[][] settings) {
  182. try {
  183. final Properties p = new Properties();
  184. settingsFile.createNewFile();
  185. p.load(new FileInputStream(settingsFile));
  186. for (final String[] setting : settings) {
  187. p.setProperty(setting[0], setting[1]);
  188. }
  189. final FileOutputStream out = new FileOutputStream(settingsFile);
  190. p.store(out, "");
  191. } catch (final IOException ioe) {
  192. log.log(Level.SEVERE, "saveSettings(String[][]) error: ", ioe);
  193. }
  194. }
  195. public void setSettings() {
  196. try {
  197. oreToMine = getSetting("ORETOMINE");
  198. miningMethod = getSetting("MININGMETHOD");
  199. location = getSetting("LOCATION");
  200. antibanSpeed = getSetting("ANTIBANSPEED");
  201. allWorlds = extractBoolean(getSetting("ALLWORLDS"));
  202. if (!allWorlds) {
  203. worlds = extractIntegers(getSetting("WORLDS"));
  204. }
  205. superheat = extractBoolean(getSetting("SUPERHEAT"));
  206. if (superheat) {
  207. mithBars = extractBoolean(getSetting("MITHBARS"));
  208. addyBars = extractBoolean(getSetting("ADDYBARS"));
  209. }
  210. alch = extractBoolean(getSetting("ALCH"));
  211. if (alch) {
  212. alchGems = extractBoolean(getSetting("ALCHGEMS"));
  213. alchBars = extractBoolean(getSetting("ALCHBARS"));
  214. alchOres = extractBoolean(getSetting("ALCHORES"));
  215. alchCoal = extractBoolean(getSetting("ALCHCOAL"));
  216. }
  217. dropGems = extractBoolean(getSetting("DROPGEMS"));
  218. if (dropGems) {
  219. dropDiamonds = extractBoolean(getSetting("DROPDIAMOND"));
  220. dropRubies = extractBoolean(getSetting("DROPRUBY"));
  221. dropEmeralds = extractBoolean(getSetting("DROPEMERALD"));
  222. dropSapphires = extractBoolean(getSetting("DROPSAPPHIRE"));
  223. }
  224. useRest = extractBoolean(getSetting("USEREST"));
  225. showPaint = extractBoolean(getSetting("SHOWPAINT"));
  226. member = extractBoolean(getSetting("MEMBER"));
  227. } catch (final Exception e) {
  228. log.log(Level.SEVERE, "setSettings error: ", e);
  229. }
  230. }
  231. public boolean settingsExist() {
  232. return settingsFile.exists();
  233. }
  234. public String stringArrayToString(final String[] array) {
  235. String strArray = null;
  236. try {
  237. strArray = "";
  238. if (array.length <= 0) {
  239. return "";
  240. }
  241. for (int a = 0; a < array.length; a++) {
  242. if (!array[a].equals(null) && !array[a].equals("")) {
  243. strArray += array[a].trim();
  244. if (a != array.length - 1) {
  245. strArray += ",";
  246. }
  247. }
  248. }
  249. } catch (final Exception e) {
  250. }
  251. return strArray;
  252. }
  253. }
  254. private class getMarketPrice implements Runnable {
  255. public boolean stop;
  256. public void run() {
  257. while (!stop) {
  258. try {
  259. addyPrice = ge.loadItemInfo(449).getMarketPrice();
  260. mithPrice = ge.loadItemInfo(447).getMarketPrice();
  261. diamondPrice = ge.loadItemInfo(1617).getMarketPrice();
  262. rubyPrice = ge.loadItemInfo(1619).getMarketPrice();
  263. emeraldPrice = ge.loadItemInfo(1621).getMarketPrice();
  264. sapphirePrice = ge.loadItemInfo(1623).getMarketPrice();
  265. stop = true;
  266. } catch (Exception e) {
  267. e.printStackTrace();
  268. }
  269. }
  270. }
  271. }
  272. private class SS7AddyMinerAntiBan implements Runnable {
  273. public boolean stopThread;
  274. public void run() {
  275. while (!stopThread && isLoggedIn() && antiBanSpeed > 0) {
  276. try {
  277. if (random(0, 15) == 0) {
  278. final char[] LR = new char[] { KeyEvent.VK_LEFT,
  279. KeyEvent.VK_RIGHT };
  280. final char[] UD = new char[] { KeyEvent.VK_DOWN,
  281. KeyEvent.VK_UP };
  282. final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
  283. KeyEvent.VK_RIGHT, KeyEvent.VK_UP,
  284. KeyEvent.VK_UP };
  285. final int random2 = random(0, 2);
  286. final int random1 = random(0, 2);
  287. final int random4 = random(0, 4);
  288. if (random(0, 3) == 0) {
  289. Bot.getInputManager().pressKey(LR[random1]);
  290. Thread.sleep(random(100, 400));
  291. Bot.getInputManager().pressKey(UD[random2]);
  292. Thread.sleep(random(300, 600));
  293. Bot.getInputManager().releaseKey(UD[random2]);
  294. Thread.sleep(random(100, 400));
  295. Bot.getInputManager().releaseKey(LR[random1]);
  296. } else {
  297. Bot.getInputManager().pressKey(LRUD[random4]);
  298. if (random4 > 1) {
  299. Thread.sleep(random(300, 600));
  300. } else {
  301. Thread.sleep(random(500, 900));
  302. }
  303. Bot.getInputManager().releaseKey(LRUD[random4]);
  304. }
  305. } else {
  306. Thread.sleep(random(200, 2000));
  307. }
  308. } catch (final Exception e) {
  309. e.printStackTrace();
  310. }
  311. }
  312. }
  313. }
  314. SS7AddyMinerAntiBan antiban;
  315. Thread t;
  316. getMarketPrice price;
  317. Thread p;
  318. // ROCK ID'S
  319. int[] ironRock = { 37307, 37308, 37309, 31071, 31072, 31073 };
  320. int[] addyRock = { 11941, 11939, 31083, 31085, 31083, 31085 };
  321. int[] coalRock = { 11930, 11931, 11932 };
  322. int[] mithRock = { 11944, 11943, 11942, 31086, 31088 };
  323. int[] mithAndAddyRock = { 11941, 11939, 31083, 31085, 31083, 31085, 11944,
  324. 11943, 11942, 31086, 31088 };
  325. int[] oreToMine2;
  326. // MINING
  327. RSTile lastRock = new RSTile(0000, 0000);
  328. int rocksteal = 0;
  329. int xrocksteal = 0;
  330. int rrocksteal = 0;
  331. int superheatError = 0;
  332. int wieldStaff = 0;
  333. int scroll = 2;
  334. int[] gems = { 1617, 1619, 1621, 1623 };
  335. int[] bars = { 2361, 2359 };
  336. private final int PASSWORD_INTERFACE = 457, USERNAME_INTERFACE = 451,
  337. TEXT_INTERFACE = 445;
  338. private int failSafeCount = 0;
  339. boolean checkMining = false;
  340. boolean checkSmithing = false;
  341. boolean checkMagic = false;
  342. int[] dontBank = { 1387, 561, 1265, 1267, 1269, 1271, 1273, 1275, 1296, 995 };
  343. int total;
  344. boolean done = false;
  345. private final String SETTINGS_FILE_NAME = "SS7AddyMinerSettings.txt";
  346. private final SS7AddyMinerSettings settings = new SS7AddyMinerSettings();
  347. String accountName;
  348. private javax.swing.JCheckBox addyBars;
  349. private javax.swing.JCheckBox alch;
  350. private javax.swing.JCheckBox alchBars;
  351. private javax.swing.JCheckBox alchGOres;
  352. private javax.swing.JCheckBox alchGems;
  353. private javax.swing.JCheckBox alchSOres;
  354. private javax.swing.JComboBox antibanSpeed;
  355. private javax.swing.JButton cancelButton;
  356. private javax.swing.JCheckBox dropDia;
  357. private javax.swing.JCheckBox dropEme;
  358. private javax.swing.JCheckBox dropGems;
  359. private javax.swing.JCheckBox dropRub;
  360. private javax.swing.JCheckBox dropSapp;
  361. private javax.swing.JFrame jFrame1;
  362. private javax.swing.JLabel jLabel1;
  363. private javax.swing.JLabel jLabel10;
  364. private javax.swing.JLabel jLabel15;
  365. private javax.swing.JLabel jLabel2;
  366. private javax.swing.JLabel jLabel28;
  367. private javax.swing.JLabel jLabel3;
  368. private javax.swing.JLabel jLabel5;
  369. private javax.swing.JLabel jLabel6;
  370. private javax.swing.JLabel jLabel7;
  371. private javax.swing.JPanel jPanel2;
  372. private javax.swing.JPanel jPanel4;
  373. private javax.swing.JPanel jPanel5;
  374. private javax.swing.JPanel jPanel6;
  375. private javax.swing.JTabbedPane jTabbedPane2;
  376. private javax.swing.JTextField listOfWorlds;
  377. private javax.swing.JComboBox location;
  378. private javax.swing.JCheckBox member;
  379. private javax.swing.JCheckBox mithBars;
  380. private javax.swing.JComboBox oreToMine;
  381. private javax.swing.JCheckBox showPaint;
  382. private javax.swing.JButton startButton;
  383. private javax.swing.JCheckBox superheat;
  384. private javax.swing.JCheckBox useRest;
  385. private javax.swing.JButton visitThread;
  386. private javax.swing.JCheckBox worldCheck;
  387. private javax.swing.JComboBox worldhop;
  388. // WORLD HOP STRINGS
  389. String customWorlds[];
  390. // PATHS
  391. // ALKHARID
  392. RSTile[] bankToMine = new RSTile[] { new RSTile(3270, 3167),
  393. new RSTile(3276, 3174), new RSTile(3283, 3185),
  394. new RSTile(3282, 3196), new RSTile(3279, 3209),
  395. new RSTile(3277, 3220), new RSTile(3275, 3231),
  396. new RSTile(3278, 3242), new RSTile(3278, 3252),
  397. new RSTile(3282, 3262), new RSTile(3288, 3272),
  398. new RSTile(3296, 3279), new RSTile(3298, 3293),
  399. new RSTile(3300, 3304), new RSTile(3297, 3312) };
  400. RSTile[] mineToBank = reversePath(bankToMine);
  401. // DRAYNOR
  402. RSTile[] cabbageToStile = new RSTile[] { new RSTile(3054, 3289),
  403. new RSTile(3058, 3288), new RSTile(3063, 3284) };
  404. RSTile[] stileToBank = new RSTile[] { new RSTile(3071, 3277),
  405. new RSTile(3073, 3271), new RSTile(3074, 3264),
  406. new RSTile(3076, 3257), new RSTile(3081, 3253),
  407. new RSTile(3086, 3249), new RSTile(3091, 3248),
  408. new RSTile(3092, 3244) };
  409. RSTile[] draynorToBank = new RSTile[] { new RSTile(3146, 3148),
  410. new RSTile(3150, 3153), new RSTile(3145, 3163),
  411. new RSTile(3141, 3171), new RSTile(3140, 3179),
  412. new RSTile(3139, 3186), new RSTile(3138, 3194),
  413. new RSTile(3135, 3201), new RSTile(3131, 3209),
  414. new RSTile(3123, 3215), new RSTile(3116, 3219),
  415. new RSTile(3108, 3223), new RSTile(3096, 3234),
  416. new RSTile(3093, 3243) };
  417. RSTile[] bankToDraynor = reversePath(draynorToBank);
  418. // FALADOR
  419. RSTile[] bankToDoor = new RSTile[] { new RSTile(3013, 3356),
  420. new RSTile(3012, 3360), new RSTile(3016, 3362),
  421. new RSTile(3022, 3364), new RSTile(3028, 3366),
  422. new RSTile(3034, 3368), new RSTile(3040, 3370),
  423. new RSTile(3047, 3369), new RSTile(3052, 3369),
  424. new RSTile(3057, 3370), new RSTile(3061, 3374),
  425. new RSTile(3061, 3377) };
  426. RSTile[] stairsToMine = new RSTile[] { new RSTile(3058, 9776),
  427. new RSTile(3052, 9774), new RSTile(3046, 9772),
  428. new RSTile(3039, 9773) };
  429. RSTile[] doorToBank = reversePath(bankToDoor);
  430. RSTile[] mineToStairs = reversePath(stairsToMine);
  431. // DEATHWALK
  432. RSTile[] alkharidDeathwalk = new RSTile[] {};
  433. RSTile[] draynorDeathwalk = new RSTile[] {};
  434. // LOCATION BOOLEANS
  435. boolean draynor, alkharid, falador = false;
  436. // ITEMS
  437. int[] thingsToKeep = { 1275, 449, 1623, 1621, 1619, 1617, 447, 1387, 561,
  438. 2361, 2359, 995, 1265, 1267, 1269, 1271, 1273, 1275, 1296 };
  439. // BANK ITEMS
  440. int[] bankBoothID = { 35647, 35648, 11758, 2213 };
  441. // PAINT VARIABLES
  442. int startingXP, addyMined, mithMined, startingLevel, profit, levelsGained,
  443. moneyGained, currentXP, XPGained, currentLevel, nextLevel,
  444. XPTillNextLevel, oresTillNextLevel, avgXPHour, avgMoneyHour,
  445. avgOresHour, percentTillNextLevel, addyPrice, mithPrice,
  446. diamondPrice, rubyPrice, emeraldPrice, sapphirePrice, diamondMined,
  447. rubyMined, emeraldMined, sapphireMined = 0;
  448. long startTime;
  449. // ANTIBAN VARIABLES
  450. int antiBanSpeed;
  451. // STRINGS
  452. String status;
  453. // LONGS
  454. long stairsUpTime = System.currentTimeMillis();
  455. long stairsDownTime = System.currentTimeMillis();
  456. // OBJECTS
  457. RSObject rock;
  458. // OPTIONS
  459. boolean member2, rest, paint, addy, mith, both, worldHop, diamond, ruby,
  460. emerald, sapphire, superheat2, alch2, addyBar, mithBar, alchG,
  461. alchB, alchGO, alchSO, ring = false;
  462. // GUI
  463. boolean startScript = false;
  464. // GRAND EXCHANGE
  465. final GrandExchange ge = new GrandExchange();
  466. // STRING EXTRACTION
  467. public String[] extractStrings(final String text) {
  468. return text.split(", ");
  469. }
  470. // LOOP
  471. public boolean ableToCast() {
  472. if (superheat2) {
  473. if (addyBar) {
  474. if (getInventoryCount(449) >= 1 && getInventoryCount(453) >= 7) {
  475. return true;
  476. }
  477. } else if (mithBar) {
  478. if (getInventoryCount(447) >= 1 && getInventoryCount(453) >= 4) {
  479. return true;
  480. }
  481. } else {
  482. return false;
  483. }
  484. }
  485. return false;
  486. }
  487. public boolean ableToAlch() {
  488. if (alch2) {
  489. if (getInventoryCount() > random(22, 28)) {
  490. if (alchG) {
  491. if (getInventoryCount(gems) > 0) {
  492. return true;
  493. }
  494. }
  495. if (alchB) {
  496. if (getInventoryCount(bars) > 0) {
  497. return true;
  498. }
  499. }
  500. if (alchGO) {
  501. if (getInventoryCount(449, 447) > 0) {
  502. return true;
  503. }
  504. }
  505. if (alchSO) {
  506. if (getInventoryCount(453) > 0) {
  507. return true;
  508. }
  509. }
  510. } else {
  511. return false;
  512. }
  513. } else {
  514. return false;
  515. }
  516. return false;
  517. }
  518. boolean s = false;
  519. public int loop() {
  520. try {
  521. if (!t.isAlive()) {
  522. t.start();
  523. }
  524. } catch (Exception e) {
  525. }
  526. if (!s) {
  527. if (equipmentContains(13562)) {
  528. ring = true;
  529. }
  530. s = true;
  531. }
  532. antiBan();
  533. runCheck();
  534. dropGems();
  535. combat();
  536. if (getMyPlayer().getAnimation() == 624) {
  537. status = "Mining";
  538. }
  539. if ((checkMining) || (checkMagic) || (checkSmithing)) {
  540. if (random(-10, 10) > 0) {
  541. clickStat();
  542. checkMining = false;
  543. checkMagic = false;
  544. checkSmithing = false;
  545. } else {
  546. checkMining = false;
  547. checkMagic = false;
  548. checkSmithing = false;
  549. }
  550. }
  551. if (superheat2) {
  552. if (ableToCast()) {
  553. castSuperHeat();
  554. wait(random(200, 300));
  555. lastRock = new RSTile(0, 0);
  556. }
  557. }
  558. if (alch2) {
  559. if (ableToAlch()) {
  560. Highalch();
  561. wait(random(200, 300));
  562. lastRock = new RSTile(0, 0);
  563. }
  564. }
  565. if (isInventoryFull()) {
  566. if (worldHop) {
  567. if (atBank()) {
  568. handleBank();
  569. } else {
  570. status = "Walking To The Bank";
  571. walkToBank();
  572. }
  573. } else {
  574. if (getInventoryCount(thingsToKeep) >= 28) {
  575. if (atBank()) {
  576. handleBank();
  577. } else {
  578. status = "Walking To The Bank";
  579. walkToBank();
  580. }
  581. } else {
  582. status = "Dropping Ores";
  583. dropAllExcept(thingsToKeep);
  584. }
  585. }
  586. } else {
  587. if (atMine()) {
  588. rockMining();
  589. } else {
  590. status = "Walking To The Mine";
  591. walkToMine();
  592. }
  593. }
  594. return random(400, 800);
  595. }
  596. // ANTIBAN
  597. public void antiBan() {
  598. if (antiBanSpeed != 0) {
  599. switch (random(0, antiBanSpeed)) {
  600. case 1:
  601. case 2:
  602. case 3:
  603. case 4:
  604. case 5:
  605. case 6:
  606. case 7:
  607. moveMouse();
  608. break;
  609. case 8:
  610. case 9:
  611. case 10:
  612. case 11:
  613. case 12:
  614. case 13:
  615. turnCamera();
  616. break;
  617. case 14:
  618. case 15:
  619. openTab(Constants.TAB_STATS);
  620. wait(random(200, 400));
  621. if (random(-10, 10) > 0) {
  622. moveMouse(688, 246, 10, 10);
  623. }
  624. wait(random(800, 1200));
  625. break;
  626. case 16:
  627. openTab(Constants.TAB_FRIENDS);
  628. wait(random(800, 1220));
  629. break;
  630. case 17:
  631. openTab(Constants.TAB_INVENTORY);
  632. wait(random(1000, 2000));
  633. break;
  634. case 18:
  635. openTab(Constants.TAB_INVENTORY);
  636. wait(random(1000, 2000));
  637. openTab(Constants.TAB_STATS);
  638. wait(random(200, 400));
  639. moveMouse(688, 246, 5, 5);
  640. wait(random(800, 1200));
  641. break;
  642. case 19:
  643. moveMouse(random(0, 800), random(0, 800));
  644. wait(random(200, 400));
  645. moveMouse(random(0, 800), random(0, 800));
  646. wait(random(150, 300));
  647. break;
  648. case 20:
  649. int randomTab = random(1, 14);
  650. openTab(randomTab);
  651. break;
  652. case 22:
  653. if (alch2) {
  654. if (ableToCast()) {
  655. return;
  656. }
  657. Highalch();
  658. }
  659. case 23:
  660. if (superheat2) {
  661. castSuperHeat();
  662. }
  663. }
  664. }
  665. }
  666. public void clickStat() {
  667. openTab(TAB_STATS);
  668. if (checkMining) {
  669. moveMouse(688, 246, 10, 10);
  670. } else if (checkSmithing) {
  671. moveMouse(692, 278, 10, 10);
  672. } else {
  673. moveMouse(580, 408, 10, 10);
  674. }
  675. clickMouse(true);
  676. wait(random(200, 300));
  677. moveMouse(random(70, 400), random(40, 335));
  678. wait(random(4900, 6200));
  679. atInterface(741, 9);
  680. wait(random(50, 500));
  681. }
  682. public void clickMainMenu() {
  683. do {
  684. moveMouse(random(296, 472), random(410, 422), 5, 5);
  685. } while (!mouseInArea(472, 422, 296, 410));
  686. clickMouse(true);
  687. }
  688. public int Login() {
  689. while (!isLoggedIn()) {
  690. if (isLoggedIn()) {
  691. while (RSInterface.getChildInterface(
  692. WelcomeScreen.WELCOME_SCREEN_ID,
  693. WelcomeScreen.WELCOME_SCREEN_BUTTON_PLAY)
  694. .getAbsoluteY() < 2) {
  695. wait(random(1500, 2500));
  696. }
  697. return -1;
  698. }
  699. if (failSafeCount > 19) {
  700. log("Can't log in... Stopping script.");
  701. stopScript();
  702. return -1;
  703. }
  704. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  705. .getText().contains("update")) {
  706. log("There was a update. Stopping script.");
  707. stopScript();
  708. return -1;
  709. }
  710. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  711. .getText().contains("disable")) {
  712. log("Can't log in... stopping script");
  713. stopScript();
  714. return -1;
  715. }
  716. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  717. .getText().contains("members")) {
  718. member2 = false;
  719. clickMainMenu();
  720. worldHop();
  721. }
  722. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  723. .getText().contains("incorrect")) {
  724. log("Can't log in... stopping script.");
  725. stopScript();
  726. return -1;
  727. }
  728. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  729. .getText().contains("invalid")) {
  730. failSafeCount++;
  731. }
  732. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  733. .getText().contains("full")) {
  734. clickMainMenu();
  735. worldHop();
  736. }
  737. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  738. .getText().contains("Error connecting")) {
  739. boolean connected = false;
  740. log("Internet connection lost.. waiting for connection");
  741. while (!connected) {
  742. try {
  743. final URL rs = new URL(
  744. "http://www.runescape.com");
  745. final URLConnection connection = rs
  746. .openConnection();
  747. final BufferedReader reader = new BufferedReader(
  748. new InputStreamReader(connection
  749. .getInputStream()));
  750. String contents = "";
  751. String s = "";
  752. while ((s = reader.readLine()) != null) {
  753. contents = contents.concat(s);
  754. }
  755. if (contents != null) {
  756. log("Connection restored!");
  757. connected = true;
  758. }
  759. } catch (final Exception e) {
  760. log("Unable to connect, retrying connection");
  761. wait(random(5000, 10000));
  762. }
  763. }
  764. }
  765. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  766. .getText().contains("world")) {
  767. while (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  768. .getText().contains("world")) {
  769. wait(random(200, 500));
  770. }
  771. }
  772. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  773. .getText().contains("Performing login")) {
  774. wait(random(1500, 2500));
  775. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  776. .getText().contains("Performing login")) {
  777. done = true;
  778. return -1;
  779. } else {
  780. wait(random(100, 200));
  781. }
  782. }
  783. if (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  784. .getText().contains("transferred")) {
  785. while (RSInterface.getInterface(744).getChild(TEXT_INTERFACE)
  786. .getText().contains("transferred")) {
  787. wait(random(200, 500));
  788. }
  789. }
  790. int typingPropType = 0;
  791. if (isLoginScreen()) {
  792. int propTrys = 0;
  793. while (true) {
  794. propTrys++;
  795. if (RSInterface.getInterface(744).getChild(
  796. USERNAME_INTERFACE).getText().endsWith("|")) {
  797. typingPropType = 1;
  798. break;
  799. }
  800. if (RSInterface.getInterface(744).getChild(
  801. PASSWORD_INTERFACE).getText().endsWith("|")) {
  802. typingPropType = 2;
  803. break;
  804. }
  805. if (propTrys == 50) {
  806. break;
  807. }
  808. wait(random(10, 20));
  809. }
  810. if (typingPropType == 0) {
  811. moveMouse(299, 180, 166, 18);
  812. clickMouse(true);
  813. }
  814. if (typingPropType == 1) {
  815. sendUserProp(
  816. accountName.replaceAll("_", " ").toLowerCase(),
  817. USERNAME_INTERFACE);
  818. }
  819. if (typingPropType == 2) {
  820. sendUserProp(AccountManager.getPassword(accountName),
  821. PASSWORD_INTERFACE);
  822. }
  823. }
  824. return random(250, 500);
  825. }
  826. return random(250, 500);
  827. }
  828. private void sendUserProp(final String data, final int type) {
  829. String boxText = RSInterface.getInterface(744).getChild(type).getText();
  830. if (boxText.endsWith("|")) {
  831. boxText = boxText.substring(0, boxText.length() - 1);
  832. }
  833. final int boxTextLength = boxText.length();
  834. if (boxTextLength == data.length()) {
  835. sendText("", true);
  836. return;
  837. }
  838. if (boxTextLength > 0 && boxTextLength != data.length()) {
  839. for (int i = 0; i <= boxTextLength; i++) {
  840. sendText("\b", false);
  841. wait(random(5, 10));
  842. }
  843. }
  844. sendText(data, false);
  845. sendUserProp(data, type);
  846. }
  847. // GEM DROPPING METHOD
  848. public void dropGems() {
  849. if (diamond) {
  850. if (getInventoryCount(1617) > 0) {
  851. atInventoryItem(1623, "Drop");
  852. }
  853. }
  854. if (ruby) {
  855. if (getInventoryCount(1619) > 0) {
  856. atInventoryItem(1621, "Drop");
  857. }
  858. }
  859. if (emerald) {
  860. if (getInventoryCount(1621) > 0) {
  861. atInventoryItem(1619, "Drop");
  862. }
  863. }
  864. if (sapphire) {
  865. if (getInventoryCount(1623) > 0) {
  866. atInventoryItem(1617, "Drop");
  867. }
  868. }
  869. }
  870. public int getNumberOfAlchableItems() {
  871. int i = 0;
  872. if (alchG) {
  873. i = getInventoryCount(gems) + i;
  874. }
  875. if (alchB) {
  876. i = getInventoryCount(bars) + i;
  877. }
  878. if (alchGO) {
  879. if (mith) {
  880. i = getInventoryCount(447) + i;
  881. } else if (addy) {
  882. i = getInventoryCount(449) + i;
  883. } else {
  884. i = getInventoryCount(449) + i + getInventoryCount(447);
  885. }
  886. }
  887. if (alchSO) {
  888. i = getInventoryCount(453) + i;
  889. }
  890. return i;
  891. }
  892. // HIGH ALCH METHOD
  893. public int Highalch() {
  894. int abx = 0;
  895. int o = 0;
  896. while (getNumberOfAlchableItems() >= 1) {
  897. if (ableToCast()) {
  898. return -1;
  899. }
  900. if (getMyPlayer().getAnimation() == 624) {
  901. return -1;
  902. }
  903. if (!inventoryContains(561)) {
  904. log("Unable to complete task... shutting down");
  905. stopScript();
  906. }
  907. castSpell(SPELL_HIGH_LEVEL_ALCHEMY);
  908. while (getCurrentTab() != TAB_INVENTORY && o < 6) {
  909. wait(random(250, 750));
  910. o++;
  911. }
  912. o = 0;
  913. if (wieldStaff == 1) {
  914. if (!inventoryContains(1387)) {
  915. if (equipmentContains(1387)) {
  916. continue;
  917. }
  918. log("Unable to complete task... shutting down");
  919. stopScript();
  920. } else {
  921. atInventoryItem(1387, "ield");
  922. }
  923. }
  924. if (getNumberOfAlchableItems() == 0) {
  925. break;
  926. } else {
  927. if (alchSO) {
  928. if (getInventoryCount(453) > 0) {
  929. atInventoryItem(453, "Cast");
  930. while (getMyPlayer().getAnimation() == 9633) {
  931. wait(random(20, 30));
  932. }
  933. while (getCurrentTab() != TAB_MAGIC) {
  934. wait(random(20, 30));
  935. }
  936. continue;
  937. }
  938. }
  939. if (alchGO) {
  940. if (getInventoryCount(447) > 0) {
  941. atInventoryItem(447, "Cast");
  942. while (getMyPlayer().getAnimation() == 9633) {
  943. wait(random(20, 30));
  944. }
  945. while (getCurrentTab() != TAB_MAGIC) {
  946. wait(random(20, 30));
  947. }
  948. continue;
  949. }
  950. }
  951. if (alchGO) {
  952. if (getInventoryCount(449) > 0) {
  953. atInventoryItem(449, "Cast");
  954. while (getMyPlayer().getAnimation() == 9633) {
  955. wait(random(20, 30));
  956. }
  957. while (getCurrentTab() != TAB_MAGIC) {
  958. wait(random(20, 30));
  959. }
  960. continue;
  961. }
  962. }
  963. if (alchG) {
  964. if (getInventoryCount(1617) > 0) {
  965. atInventoryItem(1617, "Cast");
  966. while (getMyPlayer().getAnimation() == 9633) {
  967. wait(random(20, 30));
  968. }
  969. while (getCurrentTab() != TAB_MAGIC) {
  970. wait(random(20, 30));
  971. }
  972. continue;
  973. }
  974. if (getInventoryCount(1619) > 0) {
  975. atInventoryItem(1619, "Cast");
  976. while (getMyPlayer().getAnimation() == 9633) {
  977. wait(random(20, 30));
  978. }
  979. while (getCurrentTab() != TAB_MAGIC) {
  980. wait(random(20, 30));
  981. }
  982. continue;
  983. }
  984. if (getInventoryCount(1621) > 0) {
  985. atInventoryItem(1621, "Cast");
  986. while (getMyPlayer().getAnimation() == 9633) {
  987. wait(random(20, 30));
  988. }
  989. while (getCurrentTab() != TAB_MAGIC) {
  990. wait(random(20, 30));
  991. }
  992. continue;
  993. }
  994. if (getInventoryCount(1623) > 0) {
  995. atInventoryItem(1623, "Cast");
  996. while (getMyPlayer().getAnimation() == 9633) {
  997. wait(random(20, 30));
  998. }
  999. while (getCurrentTab() != TAB_MAGIC) {
  1000. wait(random(20, 30));
  1001. }
  1002. continue;
  1003. }
  1004. }
  1005. if (alchB) {
  1006. if (getInventoryCount(2359) > 0) {
  1007. atInventoryItem(2359, "Cast");
  1008. while (getMyPlayer().getAnimation() == 9633) {
  1009. wait(random(20, 30));
  1010. }
  1011. while (getCurrentTab() != TAB_MAGIC) {
  1012. wait(random(20, 30));
  1013. }
  1014. continue;
  1015. }
  1016. if (getInventoryCount(2361) > 0) {
  1017. atInventoryItem(0, "Cast");
  1018. while (getMyPlayer().getAnimation() == 9633) {
  1019. wait(random(20, 30));
  1020. }
  1021. while (getCurrentTab() != TAB_MAGIC) {
  1022. wait(random(20, 30));
  1023. }
  1024. continue;
  1025. }
  1026. }
  1027. }
  1028. }
  1029. if (abx >= 11) {
  1030. log("Unable to complete task... shutting down");
  1031. stopScript();
  1032. }
  1033. return random(500, 1000);
  1034. }
  1035. // SCROLLING METHOD
  1036. public void scroll() {
  1037. try {
  1038. Point point = null;
  1039. final RSInterfaceComponent[] click = RSInterface.getInterface(744)
  1040. .getChild(178).getComponents();
  1041. point = new Point(click[0].getPoint());
  1042. moveMouse(point, 0, 100);
  1043. wait(random(200, 500));
  1044. clickMouse(true);
  1045. } catch (final Exception e) {
  1046. return;
  1047. }
  1048. }
  1049. // REORDER WORLD LIST - TYPE
  1050. public void reorderTypeList() {
  1051. final Point point = new Point(RSInterface.getInterface(744).getChild(
  1052. 184).getAbsoluteX(), RSInterface.getInterface(744)
  1053. .getChild(184).getAbsoluteY());
  1054. moveMouse(point, 1, 1);
  1055. wait(random(100, 300));
  1056. clickMouse(true);
  1057. }
  1058. public void reorderTypeListMember() {
  1059. final Point point = new Point(RSInterface.getInterface(744).getChild(
  1060. 184).getAbsoluteX(), RSInterface.getInterface(744)
  1061. .getChild(183).getAbsoluteY());
  1062. moveMouse(point, 1, 1);
  1063. wait(random(100, 300));
  1064. clickMouse(true);
  1065. }
  1066. public int getNumberOfItems() {
  1067. int item = 0;
  1068. if (mithBar) {
  1069. item = item + getInventoryCount(447);
  1070. }
  1071. if (addyBar) {
  1072. item = item + getInventoryCount(449);
  1073. }
  1074. return item;
  1075. }
  1076. public int getNumberOfCoal() {
  1077. int coal = 0;
  1078. if (mithBar && getInventoryCount(447) > 0) {
  1079. coal = 4;
  1080. }
  1081. if (addyBar && getInventoryCount(449) > 0) {
  1082. coal = 7;
  1083. }
  1084. return coal;
  1085. }
  1086. // SUPER HEATING METHOD
  1087. public int castSuperHeat() {
  1088. int abx = 0;
  1089. int o = 0;
  1090. int item = 0;
  1091. while (getInventoryCount(453) >= getNumberOfCoal()
  1092. && getNumberOfItems() >= 1 && abx < 10) {
  1093. while (getMyPlayer().getAnimation() == 624) {
  1094. wait(random(100, 500));
  1095. }
  1096. if (!inventoryContains(561)) {
  1097. log("You are out of nature runes...Stopping script...");
  1098. logout();
  1099. stopScript();
  1100. }
  1101. status = "Superheating";
  1102. castSpell(SPELL_SUPERHEAT_ITEM);
  1103. while (getCurrentTab() != TAB_INVENTORY && o < 6) {
  1104. wait(random(250, 750));
  1105. o++;
  1106. }
  1107. o = 0;
  1108. if (getCurrentTab() != TAB_INVENTORY) {
  1109. openTab(TAB_INVENTORY);
  1110. }
  1111. if (mithBar) {
  1112. if (getInventoryCount(447) >= 1 && getInventoryCount(453) >= 4) {
  1113. item = 447;
  1114. }
  1115. }
  1116. if (addyBar) {
  1117. if (getInventoryCount(449) >= 1 && getInventoryCount(453) >= 7) {
  1118. item = 449;
  1119. }
  1120. }
  1121. if (!atInventoryItem(item, "Cast")) {
  1122. abx++;
  1123. }
  1124. wait(random(2000, 2500));
  1125. if (superheatError == 1) {
  1126. log("You do not have the smithing lvl required...Stopping script...");
  1127. logout();
  1128. stopScript();
  1129. }
  1130. if (wieldStaff == 1) {
  1131. if (!inventoryContains(1387)) {
  1132. if (equipmentContains(1387)) {
  1133. continue;
  1134. }
  1135. log("You do not have a fire staff...Stopping script...");
  1136. logout();
  1137. stopScript();
  1138. } else {
  1139. atInventoryItem(1387, "ield");
  1140. }
  1141. }
  1142. }
  1143. if (abx >= 11) {
  1144. log("Unable to cast superheat...Stopping script...");
  1145. logout();
  1146. stopScript();
  1147. }
  1148. return random(500, 1000);
  1149. }
  1150. // AREA METHODS
  1151. public boolean atBank() {
  1152. if (alkharid) {
  1153. if (isInArea(3271, 3162, 3269, 3173)) {
  1154. return true;
  1155. }
  1156. } else if (draynor) {
  1157. if (isInArea(3095, 3240, 3092, 3246)) {
  1158. return true;
  1159. }
  1160. } else if (falador) {
  1161. if (isInArea(3018, 3355, 3009, 3358)) {
  1162. return true;
  1163. }
  1164. }
  1165. return false;
  1166. }
  1167. public boolean atMine() {
  1168. if (alkharid) {
  1169. if (isInArea(3308, 3283, 3293, 3319)) {
  1170. return true;
  1171. }
  1172. } else if (draynor) {
  1173. if (isInArea(3150, 3144, 3143, 3154)) {
  1174. return true;
  1175. }
  1176. } else if (falador) {
  1177. if (isInArea(3046, 9759, 3033, 9780)) {
  1178. return true;
  1179. }
  1180. }
  1181. return false;
  1182. }
  1183. public boolean isInArea(final int maxX, final int minY, final int minX,
  1184. final int maxY) {
  1185. final int x = getMyPlayer().getLocation().getX();
  1186. final int y = getMyPlayer().getLocation().getY();
  1187. if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
  1188. return true;
  1189. }
  1190. return false;
  1191. }
  1192. public boolean inArea(final Point p, final int x, final int y, final int w,
  1193. final int h) {
  1194. if (p.x > x && p.x < x + w && p.y > y && p.y < y + h) {
  1195. return true;
  1196. } else {
  1197. return false;
  1198. }
  1199. }
  1200. public boolean mouseInArea(int x, int y, int xx, int yy) {
  1201. int x3 = input.getX();
  1202. int y3 = input.getY();
  1203. if (x3 < x && x3 > xx && y3 < y && y3 > yy) {
  1204. return true;
  1205. } else {
  1206. return false;
  1207. }
  1208. }
  1209. // WALKING METHODS
  1210. public boolean isResting() {
  1211. if (getMyPlayer().getAnimation() == 12108
  1212. || getMyPlayer().getAnimation() == 2033
  1213. || getMyPlayer().getAnimation() == 2716
  1214. || getMyPlayer().getAnimation() == 11786
  1215. || getMyPlayer().getAnimation() == 5713) {
  1216. return true;
  1217. }
  1218. return false;
  1219. }
  1220. public void runCheck() {
  1221. int tries = 0;
  1222. int replenishes = 0;
  1223. int currentEnergy = 0;
  1224. boolean rest = true;
  1225. if (getEnergy() > 21 + random(1, 29) || getEnergy() >= 51) {
  1226. setRun(true);
  1227. }
  1228. if (getEnergy() <= 1 && !atMine() && !atBank() && rest
  1229. && settings.useRest) {
  1230. if (ring && replenishes <= 3) {
  1231. do {
  1232. openTab(TAB_EQUIPMENT);
  1233. wait(random(200, 300));
  1234. tries++;
  1235. } while (getCurrentTab() != TAB_EQUIPMENT && tries < 10);
  1236. tries = 0;
  1237. currentEnergy = getEnergy();
  1238. atEquippedItem(13562, "un-replenish");
  1239. wait(random(250, 500));
  1240. if (getEnergy() > currentEnergy) {
  1241. replenishes++;
  1242. } else {
  1243. replenishes = 3;
  1244. }
  1245. } else {
  1246. if (random(-10, 10) > 0) {
  1247. rest(random(40 + random(5, 20), 80 + random(5, 19)));
  1248. }
  1249. }
  1250. rest = false;
  1251. }
  1252. if (getEnergy() > 1) {
  1253. rest = true;
  1254. }
  1255. if (getEnergy() == 100 && isResting()) {
  1256. walk();
  1257. }
  1258. }
  1259. public void walk() {
  1260. atTile(new RSTile(getMyPlayer().getLocation().getX() + random(-1, 1),
  1261. getMyPlayer().getLocation().getY() + random(-1, 1)), "alk Here");
  1262. }
  1263. public boolean nearTile(final RSTile tile) {
  1264. wait(random(700, 1000));
  1265. while (distanceTo(tile) >= 3 && getMyPlayer().isMoving()) {
  1266. return false;
  1267. }
  1268. return true;
  1269. }
  1270. public boolean nearTile2(final RSTile tile) {
  1271. wait(random(700, 1000));
  1272. while (distanceTo(tile) >= 1 && getMyPlayer().isMoving()) {
  1273. return false;
  1274. }
  1275. return true;
  1276. }
  1277. public RSTile getNextTile(final RSTile[] path, final int maxDist) {
  1278. for (int i = path.length - 1; i >= 0; i--) {
  1279. if (distanceTo(path[i]) <= maxDist) {
  1280. return path[i];
  1281. }
  1282. }
  1283. return null;
  1284. }
  1285. public boolean walkPath(final RSTile[] path, final int maxDist,
  1286. final int randomness) {
  1287. if (distanceTo(path[path.length - 1]) <= 4) {
  1288. return true;
  1289. } else {
  1290. final RSTile theTile = getNextTile(path, maxDist);
  1291. if (theTile != null) {
  1292. walkTile(theTile, randomness);
  1293. }
  1294. return false;
  1295. }
  1296. }
  1297. public boolean walkPath(final RSTile[] path) {
  1298. return walkPath(path, 15, 1);
  1299. }
  1300. public boolean WalkTileMM(final RSTile t, final int x, final int y) {
  1301. final Point p = tileToMinimap(t);
  1302. if (p.x == -1 || p.y == -1) {
  1303. return WalkTileMM(getClosestTileOnMap(t), x, y);
  1304. }
  1305. clickMouse(p, x, y, true);
  1306. return true;
  1307. }
  1308. public boolean WalkTileMM(final RSTile t) {
  1309. return WalkTileMM(t, 2, 2);
  1310. }
  1311. public boolean walkTile(final RSTile theTile) {
  1312. return walkTile(theTile, 1);
  1313. }
  1314. public boolean walkTile(final RSTile theTile, final int randomness) {
  1315. if (theTile == null) {
  1316. return false;
  1317. }
  1318. if (distanceTo(theTile) <= 17) {
  1319. RSTile newTile;
  1320. if (randomness == 0) {
  1321. newTile = new RSTile(theTile.getX(), theTile.getY());
  1322. } else {
  1323. newTile = new RSTile(theTile.getX()
  1324. + random(-randomness, randomness + 1), theTile.getY()
  1325. + random(-randomness, randomness + 1));
  1326. }
  1327. if (random(0, 30) == 0) {
  1328. turnToTile(newTile, 15);
  1329. }
  1330. if (tileOnScreen(newTile) && random(0, 10) == 0) {
  1331. if (!atTile(newTile, "Walk")) {
  1332. if (!WalkTileMM(newTile)) {
  1333. return false;
  1334. } else {
  1335. return true;
  1336. }
  1337. } else {
  1338. return true;
  1339. }
  1340. } else {
  1341. if (!WalkTileMM(newTile)) {
  1342. return false;
  1343. } else {
  1344. return true;
  1345. }
  1346. }
  1347. } else {
  1348. return false;
  1349. }
  1350. }
  1351. public boolean walkToBank() {
  1352. int tries = 0;
  1353. boolean jumped = false;
  1354. if (alkharid) {
  1355. walkPath(fixPath(generateProperPath(new RSTile(3270, 3166))));
  1356. } else if (draynor) {
  1357. if (ring) {
  1358. do {
  1359. openTab(TAB_EQUIPMENT);
  1360. wait(random(200, 300));
  1361. tries++;
  1362. } while (getCurrentTab() != TAB_EQUIPMENT && tries < 10);
  1363. tries = 0;
  1364. RSTile currentLocation = getMyPlayer().getLocation();
  1365. atEquippedItem(13562, "abbage-port");
  1366. wait(random(2500, 5000));
  1367. while (getMyPlayer().getLocation() == currentLocation
  1368. && tries <= 10) {
  1369. wait(random(300, 500));
  1370. tries++;
  1371. }
  1372. tries = 0;
  1373. while (distanceTo(new RSTile(3063, 3283)) > 4) {
  1374. walkPath(cabbageToStile);
  1375. wait(random(500, 600));
  1376. }
  1377. while (!jumped) {
  1378. jumpStile(new RSTile(3063, 3283), new RSTile(3063, 3282));
  1379. while (tries <= 20) {
  1380. wait(random(200, 300));
  1381. tries++;
  1382. if (getMyPlayer().getLocation().getX() == 3063
  1383. && getMyPlayer().getLocation().getY() == 3282) {
  1384. jumped = true;
  1385. break;
  1386. }
  1387. }
  1388. tries = 0;
  1389. }
  1390. while (!atBank()) {
  1391. walkPath(stileToBank);
  1392. wait(random(500, 1000));
  1393. }
  1394. jumped = false;
  1395. } else {
  1396. walkPath(draynorToBank);
  1397. }
  1398. } else if (falador) {
  1399. if (atBank()) {
  1400. return false;
  1401. } else if (isInArea(3065, 3359, 3005, 3374)) {
  1402. walkPath(doorToBank);
  1403. } else if (isInArea(3062, 3375, 3058, 3381)) {
  1404. try {
  1405. if (!isDoorOpen(new RSTile(3061, 3375), 11715)) {
  1406. openDoor(new RSTile(3061, 3374), new RSTile(3061, 3375));
  1407. } else {
  1408. walkPath(doorToBank);
  1409. }
  1410. } catch (Exception e) {
  1411. }
  1412. } else if (getMyPlayer().getLocation().getY() > 6000) {
  1413. if (isInArea(3059, 9774, 3056, 9779)) {
  1414. useStairs();
  1415. } else {
  1416. walkPath(mineToStairs);
  1417. }
  1418. }
  1419. }
  1420. return false;
  1421. }
  1422. public boolean walkToMine() {
  1423. if (alkharid) {
  1424. walkPath(fixPath(generateProperPath(new RSTile(3300, 3311))));
  1425. } else if (draynor) {
  1426. walkPath(bankToDraynor);
  1427. } else if (falador) {
  1428. if (!(atMine() && atBank() && isInArea(3062, 3375, 3058, 3381)
  1429. && isInArea(3064, 3371, 3058, 3374)
  1430. && isInArea(3065, 3359, 3005, 3374) && getMyPlayer()
  1431. .getLocation().getY() > 6000)) {
  1432. if (tileOnScreen(new RSTile(3061, 3373))) {
  1433. walkTo(new RSTile(3061, 3373));
  1434. while (!nearTile2(new RSTile(3061, 3373))) {
  1435. wait(random(10, 15));
  1436. }
  1437. } else {
  1438. walkPath(bankToDoor);
  1439. }
  1440. }
  1441. if (atMine()) {
  1442. return false;
  1443. } else if (getMyPlayer().getLocation().getY() > 6000) {
  1444. walkPath(stairsToMine);
  1445. } else if (isInArea(3062, 3375, 3058, 3381)) {
  1446. useStairs();
  1447. } else if (isInArea(3064, 3371, 3058, 3374)) {
  1448. try {
  1449. if (!isDoorOpen(new RSTile(3061, 3375), 11715)) {
  1450. openDoor(new RSTile(3061, 3374), new RSTile(3061, 3375));
  1451. } else {
  1452. walkPath(bankToDoor);
  1453. }
  1454. } catch (Exception e) {
  1455. }
  1456. } else if (isInArea(3065, 3359, 3005, 3374)) {
  1457. walkPath(bankToDoor);
  1458. } else if (atBank()) {
  1459. walkPath(bankToDoor);
  1460. }
  1461. }
  1462. return false;
  1463. }
  1464. // ANTICOMBAT METHOD
  1465. public void combat() {
  1466. RSTile runAwayTile = new RSTile(0, 0);
  1467. if (falador) {
  1468. runAwayTile = new RSTile(3051, 9774);
  1469. } else if (alkharid) {
  1470. runAwayTile = new RSTile(3299, 3298);
  1471. }
  1472. if (falador || alkharid) {
  1473. if (getMyPlayer().isInCombat()) {
  1474. if (tileOnMap(runAwayTile)) {
  1475. walkTile(runAwayTile);
  1476. } else {
  1477. walkPath(randomizePath(
  1478. fixPath(generateProperPath(runAwayTile)), 0, 0));
  1479. }
  1480. while (!nearTile(runAwayTile)) {
  1481. wait(random(10, 15));
  1482. }
  1483. wait(random(10000, 15000));
  1484. worldHop();
  1485. }
  1486. }
  1487. }
  1488. // DOOR AND STAIRS METHODS
  1489. public boolean isDoorOpen(RSTile location, int openDoor) {
  1490. RSObject o = getObjectAt(location);
  1491. int door = o.getID();
  1492. if (o != null && door == openDoor) {
  1493. return true;
  1494. } else {
  1495. return false;
  1496. }
  1497. }
  1498. public boolean useStairs() {
  1499. stairsUpTime = System.currentTimeMillis();
  1500. stairsDownTime = System.currentTimeMillis();
  1501. final RSObject object;
  1502. if (getMyPlayer().getLocation().getY() > 6000) {
  1503. object = getNearestObjectByID(16, 30943);
  1504. } else {
  1505. object = getNearestObjectByID(16, 30944);
  1506. }
  1507. if (object == null) {
  1508. return false;
  1509. }
  1510. if (!Calculations.onScreen(Calculations.tileToScreen(object
  1511. .getLocation()))) {
  1512. walkTile(object.getLocation());
  1513. wait(random(50, 600));
  1514. if (random(0, 4) < 3) {
  1515. moveMouse(random(100, 415), random(100, 237));
  1516. }
  1517. while (!nearTile(object.getLocation())) {
  1518. wait(random(10, 15));
  1519. }
  1520. }
  1521. if (getMyPlayer().getLocation().getY() > 6000) {
  1522. if (atObject(object, "Climb-up")) {
  1523. while (getMyPlayer().getLocation().getY() > 6000
  1524. && System.currentTimeMillis() - stairsUpTime < 6000) {
  1525. if (getMyPlayer().getLocation().getY() < 6000) {
  1526. return true;
  1527. }
  1528. if (System.currentTimeMillis() - stairsUpTime >= 6000) {
  1529. return false;
  1530. }
  1531. }
  1532. } else {
  1533. setCameraRotation(random(1, 359));
  1534. }
  1535. } else {
  1536. if (atObject(object, "Climb-down")) {
  1537. while (getMyPlayer().getLocation().getY() > 6000
  1538. && System.currentTimeMillis() - stairsDownTime < 6000) {
  1539. if (getMyPlayer().getLocation().getY() < 6000) {
  1540. return true;
  1541. }
  1542. if (System.currentTimeMillis() - stairsDownTime >= 6000) {
  1543. return false;
  1544. }
  1545. }
  1546. } else {
  1547. setCameraRotation(random(1, 359));
  1548. }
  1549. }
  1550. while (getMyPlayer().isMoving()) {
  1551. wait(random(200, 600));
  1552. }
  1553. return false;
  1554. }
  1555. public boolean jumpStile(RSTile a, RSTile b) {
  1556. long st = System.currentTimeMillis();
  1557. do {
  1558. if ((System.currentTimeMillis() - st) > 750) {
  1559. setCameraRotation(random(0, 360));
  1560. st = System.currentTimeMillis();
  1561. }
  1562. moveMouse(midPoint(Calculations.tileToScreen(a), Calculations
  1563. .tileToScreen(b)), 3, 3);
  1564. } while (!listContainsString(getMenuItems(), "limb-over"));
  1565. clickMouse(true);
  1566. wait(random(100, 200));
  1567. return true;
  1568. }
  1569. public boolean openDoor(RSTile a, RSTile b) {
  1570. long st = System.currentTimeMillis();
  1571. do {
  1572. if ((System.currentTimeMillis() - st) > 750) {
  1573. setCameraRotation(random(0, 360));
  1574. st = System.currentTimeMillis();
  1575. }
  1576. moveMouse(midPoint(Calculations.tileToScreen(a), Calculations
  1577. .tileToScreen(b)), 3, 3);
  1578. } while (!listContainsString(getMenuItems(), "pen"));
  1579. clickMouse(true);
  1580. wait(random(100, 200));
  1581. return true;
  1582. }
  1583. private boolean listContainsString(final java.util.List<String> list,
  1584. final String string) {
  1585. try {
  1586. int a;
  1587. for (a = list.size() - 1; a-- >= 0;) {
  1588. if (list.get(a).contains(string)) {
  1589. return true;
  1590. }
  1591. }
  1592. } catch (final Exception e) {
  1593. }
  1594. return false;
  1595. }
  1596. public Point midPoint(Point p1, Point p2) {
  1597. return (new Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2));
  1598. }
  1599. // BANKING METHODS
  1600. public void handleBank() {
  1601. int tries = 0;
  1602. if (!bank.isOpen()) {
  1603. RSObject bankObject = getNearestObjectByID(bankBoothID);
  1604. if (bank != null) {
  1605. if (!atTile(bankObject.getLocation(), "quickly")) {
  1606. atObject(bankObject, "quickly");
  1607. }
  1608. }
  1609. while (!bank.isOpen() && tries < 10) {
  1610. wait(random(200, 500));
  1611. tries++;
  1612. }
  1613. if (!bank.isOpen()) {
  1614. bank.open();
  1615. }
  1616. }
  1617. if (getInventoryCount(dontBank) > 0) {
  1618. bank.depositAllExcept(dontBank);
  1619. } else {
  1620. bank.depositAll();
  1621. }
  1622. if (random(-10, 10) > 0) {
  1623. bank.close();
  1624. }
  1625. }
  1626. // MINING METHODs
  1627. public boolean nextRock() {
  1628. final RSObject obj = getObjectAt(lastRock);
  1629. if (obj == null) {
  1630. return true;
  1631. }
  1632. for (final int element : oreToMine2) {
  1633. if (obj.getID() == element) {
  1634. return false;
  1635. }
  1636. }
  1637. for (final int element : ironRock) {
  1638. if (obj.getID() == element) {
  1639. return false;
  1640. }
  1641. }
  1642. for (final int element : coalRock) {
  1643. if (obj.getID() == element) {
  1644. return false;
  1645. }
  1646. }
  1647. return true;
  1648. }
  1649. public RSObject oreToMine() {
  1650. RSObject r;
  1651. if (both) {
  1652. r = getNearestObjectByID(addyRock);
  1653. if (r != null) {
  1654. return r;
  1655. } else {
  1656. r = getNearestObjectByID(mithRock);
  1657. if (r != null) {
  1658. return r;
  1659. }
  1660. }
  1661. } else if (addy) {
  1662. r = getNearestObjectByID(addyRock);
  1663. if (r != null) {
  1664. return r;
  1665. }
  1666. } else {
  1667. r = getNearestObjectByID(mithRock);
  1668. if (r != null) {
  1669. return r;
  1670. }
  1671. }
  1672. return null;
  1673. }
  1674. public void clickRock(RSObject o) {
  1675. if (!atMine() || isInventoryFull()) {
  1676. return;
  1677. }
  1678. if (distanceTo(o.getLocation()) >= 10) {
  1679. walkTile(new RSTile(o.getLocation().getX() + random(-1, 1), o
  1680. .getLocation().getY()
  1681. + random(-1, 1)));
  1682. while (!nearTile(new RSTile(o.getLocation().getX() + random(-1, 1),
  1683. o.getLocation().getY() + random(-1, 1)))) {
  1684. wait(random(15, 30));
  1685. }
  1686. }
  1687. if (!tileOnScreen(o.getLocation())) {
  1688. turnToObject(o);
  1689. }
  1690. lastRock = o.getLocation();
  1691. try {
  1692. if (Bot.getClient().isSpellSelected()) {
  1693. int randomTab = 0;
  1694. do {
  1695. randomTab = random(1, 6);
  1696. } while (randomTab == getCurrentTab());
  1697. do {
  1698. openTab(randomTab);
  1699. } while (Bot.getClient().isSpellSelected());
  1700. }
  1701. if (!atTile(o.getLocation(), "Mine")) {
  1702. atObject(o, "Mine");
  1703. }
  1704. int tries = 0;
  1705. while (getMyPlayer().getAnimation() != 624 && tries < 10) {
  1706. wait(random(100, 300));
  1707. tries++;
  1708. }
  1709. } catch (Exception e) {
  1710. }
  1711. }
  1712. public void rockMining() {
  1713. if (getObjectAt(lastRock) == null) {
  1714. lastRock = new RSTile(0000, 0000);
  1715. }
  1716. if (nextRock() || getMyPlayer().getAnimation() == -1
  1717. && !getMyPlayer().isMoving()) {
  1718. rock = null;
  1719. rock = oreToMine();
  1720. if (rock == null) {
  1721. if (worldHop) {
  1722. rock = getNearestObjectByID(oreToMine2);
  1723. if (falador) {
  1724. if (rock == null
  1725. || distanceTo(rock.getLocation()) >= 20) {
  1726. status = "World Hopping";
  1727. wait(random(1000, 2000));
  1728. worldHop();
  1729. }
  1730. } else if (draynor || alkharid) {
  1731. if (rock == null) {
  1732. status = "World Hopping";
  1733. wait(random(1000, 2000));
  1734. worldHop();
  1735. }
  1736. }
  1737. } else {
  1738. if (alkharid) {
  1739. RSObject iron = getNearestObjectByID(ironRock);
  1740. if (iron == null) {
  1741. antiBan();
  1742. wait(random(400, 800));
  1743. } else {
  1744. clickRock(iron);
  1745. }
  1746. } else if (draynor) {
  1747. RSObject rock = getNearestObjectByID(coalRock);
  1748. if (rock == null) {
  1749. antiBan();
  1750. wait(random(400, 800));
  1751. } else {
  1752. clickRock(rock);
  1753. }
  1754. } else if (falador) {
  1755. RSObject rock = getNearestObjectByID(ironRock);
  1756. if (rock == null) {
  1757. antiBan();
  1758. wait(random(400, 800));
  1759. } else {
  1760. clickRock(rock);
  1761. }
  1762. }
  1763. }
  1764. } else {
  1765. clickRock(rock);
  1766. }
  1767. }
  1768. }
  1769. // CAMERA AND MOUSE MOVEMENT METHODS
  1770. public void turnCamera() {
  1771. final char[] LR = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
  1772. final char[] UD = new char[] { KeyEvent.VK_DOWN, KeyEvent.VK_UP };
  1773. final char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
  1774. KeyEvent.VK_UP, KeyEvent.VK_DOWN };
  1775. final int random2 = random(0, 2);
  1776. final int random1 = random(0, 2);
  1777. final int random4 = random(0, 4);
  1778. if (random(0, 3) == 0) {
  1779. Bot.getInputManager().pressKey(LR[random1]);
  1780. wait(random(100, 400));
  1781. Bot.getInputManager().pressKey(UD[random2]);
  1782. wait(random(100, 200));
  1783. Bot.getInputManager().releaseKey(UD[random2]);
  1784. wait(random(100, 400));
  1785. Bot.getInputManager().releaseKey(LR[random1]);
  1786. } else {
  1787. Bot.getInputManager().pressKey(LRUD[random4]);
  1788. wait(random(500, 900));
  1789. Bot.getInputManager().releaseKey(LRUD[random4]);
  1790. }
  1791. }
  1792. public void moveMouse() {
  1793. moveMouse(random(0, 750), random(0, 750), 50, 50);
  1794. wait(random(200, 600));
  1795. }
  1796. // ON FINISH
  1797. public void onFinish() {
  1798. Bot.getEventManager().removeListener(PaintListener.class, this);
  1799. antiban.stopThread = true;
  1800. price.stop = true;
  1801. if (random(-10, 10) > 0) {
  1802. final int x = 0;
  1803. final int y = random(0, 500);
  1804. moveMouse(x, y);
  1805. } else {
  1806. final int x = ran

Large files files are truncated, but you can click here to view the full file