Advertisement
TheBat

BatSmelterAIO for TriBot

Apr 11th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.00 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Container;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.GridBagConstraints;
  7. import java.awt.GridBagLayout;
  8. import java.awt.Insets;
  9. import java.awt.Point;
  10. import java.awt.Rectangle;
  11. import java.awt.event.ActionEvent;
  12. import java.awt.event.ActionListener;
  13. import java.awt.event.KeyEvent;
  14. import java.awt.event.MouseEvent;
  15. import java.awt.event.MouseListener;
  16. import java.awt.image.BufferedImage;
  17. import java.io.File;
  18. import java.io.FileNotFoundException;
  19. import java.io.IOException;
  20. import java.lang.reflect.InvocationTargetException;
  21. import java.net.URL;
  22. import java.util.LinkedList;
  23. import java.util.List;
  24.  
  25. import javax.imageio.ImageIO;
  26. import javax.swing.JButton;
  27. import javax.swing.JCheckBox;
  28. import javax.swing.JComboBox;
  29. import javax.swing.JFrame;
  30. import javax.swing.JLabel;
  31. import javax.swing.JPasswordField;
  32. import javax.swing.JTabbedPane;
  33. import javax.swing.JTextField;
  34. import javax.swing.SwingUtilities;
  35.  
  36. import org.tribot.bot.ClientContext;
  37. import org.tribot.interfaces.Paintable;
  38. import org.tribot.script.Script;
  39. import org.tribot.script.ScriptManifest;
  40. import org.tribot.script.methods.Banking;
  41. import org.tribot.script.methods.Colour;
  42. import org.tribot.script.methods.General;
  43. import org.tribot.script.methods.Timing;
  44.  
  45. @ScriptManifest(
  46. authors = { "TheBat"},
  47. name = "BatSmelterAIO",
  48. version = 1.0,
  49. description = "Smelts shit in edgeville or Al-Kharid.",
  50. category = "Smithing")
  51.  
  52. public class BatSmelterAIO extends Script implements MouseListener, Paintable{
  53. final private static Rectangle VIEWPORT = new Rectangle(4,4,513,335);
  54. final private static Rectangle VIEWPORTS = new Rectangle(4,35,513,304);
  55. final private static Rectangle VIEWPORTR = new Rectangle(234,4,279,335);
  56. final private static Rectangle MINIMAP = new Rectangle(548,6,156,156);
  57. final private static Rectangle MINIMAPL = new Rectangle(548,6,44,156);
  58. final private static Rectangle MINIMAPMR = new Rectangle(655,53,40,39);
  59. final private static Rectangle INVENTORY = new Rectangle(552,209,177,256);
  60.  
  61. //The dtm for the banker
  62. Point[] BANKER1_DTM_PTS = { new Point( 351, 227), new Point( 344, 243), new Point( 339, 248)};
  63. Color[] BANKER1_DTM_RGB = { new Color( 174, 123, 54), new Color( 23, 18, 33), new Color( 132, 106, 74)};
  64. DTM2 dtmBanker1 = new DTM2(BANKER1_DTM_PTS, BANKER1_DTM_RGB);
  65. Point[] BANKER2_DTM_PTS = { new Point( 351, 228), new Point( 346, 244)};
  66. Color[] BANKER2_DTM_RGB = { new Color( 176, 124, 54), new Color( 23, 18, 33)};
  67. DTM2 dtmBanker2 = new DTM2(BANKER2_DTM_PTS, BANKER2_DTM_RGB);
  68. Point[] BANKER3_DTM_PTS = { new Point( 263, 231), new Point( 258, 249)};
  69. Color[] BANKER3_DTM_RGB = { new Color( 164, 116, 51), new Color( 134, 107, 75)};
  70. DTM2 dtmBanker3 = new DTM2(BANKER3_DTM_PTS, BANKER3_DTM_RGB);
  71.  
  72. //The dtm for the Smithy Building
  73. Point[] SMITH1_DTM_PTS = { new Point( 659, 83), new Point( 680, 59), new Point( 683, 78)};
  74. Color[] SMITH1_DTM_RGB = { new Color( 232, 234, 250), new Color( 232, 234, 250), new Color( 232, 234, 250)};
  75. DTM2 dtmSmith1 = new DTM2(SMITH1_DTM_PTS, SMITH1_DTM_RGB);
  76. Point[] SMITH2_DTM_PTS = { new Point( 678, 83), new Point( 658, 60), new Point( 682, 63)};
  77. Color[] SMITH2_DTM_RGB = { new Color( 232, 234, 250), new Color( 232, 234, 250), new Color( 232, 234, 250)};
  78. DTM2 dtmSmith2 = new DTM2(SMITH2_DTM_PTS, SMITH2_DTM_RGB);
  79. Point[] SMITH3_DTM_PTS = { new Point( 670, 83), new Point( 662, 57), new Point( 682, 57)};
  80. Color[] SMITH3_DTM_RGB = { new Color( 231, 237, 235), new Color( 231, 237, 235), new Color( 231, 237, 235)};
  81. DTM2 dtmSmith3 = new DTM2(SMITH3_DTM_PTS, SMITH3_DTM_RGB);
  82. Point[] SMITH4_DTM_PTS = { new Point( 661, 83), new Point( 663, 57), new Point( 675, 57), new Point( 665, 83)};
  83. Color[] SMITH4_DTM_RGB = { new Color( 231, 237, 235), new Color( 231, 237, 235), new Color( 231, 237, 235), new Color( 231, 237, 235)};
  84. DTM2 dtmSmith4 = new DTM2(SMITH4_DTM_PTS, SMITH4_DTM_RGB);
  85. Point[] SMITH5_DTM_PTS = { new Point( 693, 75), new Point( 675, 49), new Point( 691, 49)};
  86. Color[] SMITH5_DTM_RGB = { new Color( 249, 249, 239), new Color( 249, 249, 239), new Color( 249, 249, 239)};
  87. DTM2 dtmSmith5 = new DTM2(SMITH5_DTM_PTS, SMITH5_DTM_RGB);
  88. Point[] SMITH6_DTM_PTS = { new Point( 687, 83), new Point( 662, 57), new Point( 687, 57)};
  89. Color[] SMITH6_DTM_RGB = { new Color( 249, 249, 239), new Color( 249, 249, 239), new Color( 249, 249, 239)};
  90. DTM2 dtmSmith6 = new DTM2(SMITH6_DTM_PTS, SMITH6_DTM_RGB);
  91. Point[] SMITH7_DTM_PTS = { new Point( 683, 82), new Point( 663, 56), new Point( 677, 55)};
  92. Color[] SMITH7_DTM_RGB = { new Color( 249, 249, 239), new Color( 249, 249, 239), new Color( 249, 249, 239)};
  93. DTM2 dtmSmith7 = new DTM2(SMITH7_DTM_PTS, SMITH7_DTM_RGB);
  94. Point[] SMITH8_DTM_PTS = { new Point( 660, 83), new Point( 661, 58), new Point( 685, 58), new Point( 685, 83)};
  95. Color[] SMITH8_DTM_RGB = { new Color( 236, 232, 237), new Color( 236, 232, 237), new Color( 236, 232, 237), new Color( 236, 232, 237)};
  96. DTM2 dtmSmith8 = new DTM2(SMITH8_DTM_PTS, SMITH8_DTM_RGB);
  97. Point[] SMITH9_DTM_PTS = { new Point( 661, 57), new Point( 685, 56), new Point( 685, 82)};
  98. Color[] SMITH9_DTM_RGB = { new Color( 231, 234, 240), new Color( 231, 234, 240), new Color( 231, 234, 240)};
  99. DTM2 dtmSmith9 = new DTM2(SMITH9_DTM_PTS, SMITH9_DTM_RGB);
  100.  
  101. //The dtm for the furnace symbol
  102. Point[] FURN_SYM_DTM_PTS = { new Point( 687, 81), new Point( 689, 79)};
  103. Color[] FURN_SYM_DTM_RGB = { new Color( 250, 254, 18), new Color( 233, 106, 24)};
  104. DTM2 dtmFurnSym = new DTM2(FURN_SYM_DTM_PTS, FURN_SYM_DTM_RGB);
  105.  
  106. //The dtm for the furnace
  107. Point[] FURN1_DTM_PTS = { new Point( 402, 83), new Point( 405, 83)};
  108. Color[] FURN1_DTM_RGB = { new Color( 162, 34, 24), new Color( 58, 58, 55)};
  109. DTM2 dtmFurn1 = new DTM2(FURN1_DTM_PTS, FURN1_DTM_RGB);
  110. Point[] FURN2_DTM_PTS = { new Point( 430, 103), new Point( 428, 103)};
  111. Color[] FURN2_DTM_RGB = { new Color( 137, 29, 20), new Color( 56, 55, 53)};
  112. DTM2 dtmFurn2 = new DTM2(FURN2_DTM_PTS, FURN2_DTM_RGB);
  113.  
  114. //The dtm for the bank
  115. Point[] BANK1_DTM_PTS = { new Point( 586, 82), new Point( 586, 90), new Point( 586, 92)};
  116. Color[] BANK1_DTM_RGB = { new Color( 53, 100, 20), new Color( 250, 252, 238), new Color( 75, 68, 54)};
  117. DTM2 dtmBank1 = new DTM2(BANK1_DTM_PTS, BANK1_DTM_RGB);
  118. Point[] BANK2_DTM_PTS = { new Point( 594, 92), new Point( 594, 102), new Point( 594, 93)};
  119. Color[] BANK2_DTM_RGB = { new Color( 49, 97, 26), new Color( 233, 250, 236), new Color( 49, 97, 26)};
  120. DTM2 dtmBank2 = new DTM2(BANK2_DTM_PTS, BANK2_DTM_RGB);
  121. Point[] BANK3_DTM_PTS = { new Point( 594, 92), new Point( 594, 103), new Point( 594, 93)};
  122. Color[] BANK3_DTM_RGB = { new Color( 49, 97, 26), new Color( 233, 250, 236), new Color( 49, 97, 26)};
  123. DTM2 dtmBank3 = new DTM2(BANK3_DTM_PTS, BANK3_DTM_RGB);
  124. Point[] BANK4_DTM_PTS = { new Point( 594, 92), new Point( 594, 101), new Point( 594, 93)};
  125. Color[] BANK4_DTM_RGB = { new Color( 49, 97, 26), new Color( 233, 250, 236), new Color( 49, 97, 26)};
  126. DTM2 dtmBank4 = new DTM2(BANK4_DTM_PTS, BANK4_DTM_RGB);
  127.  
  128. //The dtm for the Al-Kharid banker
  129. Point[] AL_BANKER_DTM_PTS = { new Point( 149, 90), new Point( 144, 84)};
  130. Color[] AL_BANKER_DTM_RGB = { new Color( 226, 217, 227), new Color( 107, 103, 102)};
  131. DTM2 dtmAlBanker = new DTM2(AL_BANKER_DTM_PTS, AL_BANKER_DTM_RGB);
  132.  
  133. //The dtm for the Al-Kharid Smithy Building
  134. Point[] CACTUS1_DTM_PTS = { new Point( 665, 90), new Point( 665, 87), new Point( 661, 89), new Point( 666, 94), new Point( 669, 88), new Point( 671, 90)};
  135. Color[] CACTUS1_DTM_RGB = { new Color( 73, 115, 57), new Color( 73, 115, 57), new Color( 73, 115, 57), new Color( 73, 115, 57), new Color( 73, 115, 57), new Color( 58, 57, 11)};
  136. DTM2 dtmCactus1 = new DTM2(CACTUS1_DTM_PTS, CACTUS1_DTM_RGB);
  137. Point[] CACTUS2_DTM_PTS = { new Point( 656, 86), new Point( 669, 86), new Point( 669, 88)};
  138. Color[] CACTUS2_DTM_RGB = { new Color( 73, 115, 57), new Color( 48, 99, 25), new Color( 58, 57, 11)};
  139. DTM2 dtmCactus2 = new DTM2(CACTUS2_DTM_PTS, CACTUS2_DTM_RGB);
  140.  
  141. //The dtm for the Al-Kharid furnace
  142. Point[] ALFURN_DTM_PTS = { new Point( 137, 175), new Point( 112, 139), new Point( 178, 139), new Point( 166, 224), new Point( 103, 219)};
  143. Color[] ALFURN_DTM_RGB = { new Color( 54, 52, 52), new Color( 62, 60, 59), new Color( 43, 41, 41), new Color( 49, 47, 47), new Color( 65, 62, 62)};
  144. DTM2 dtmAlFurn1 = new DTM2(ALFURN_DTM_PTS, ALFURN_DTM_RGB);
  145.  
  146. //The dtm for the Al-Kharid bank
  147. Point[] BCACACTUS1_DTM_PTS = { new Point( 593, 99), new Point( 590, 96), new Point( 596, 98), new Point( 593, 104), new Point( 600, 103)};
  148. Color[] BCACACTUS1_DTM_RGB = { new Color( 72, 116, 56), new Color( 63, 100, 30), new Color( 63, 100, 30), new Color( 72, 116, 56), new Color( 63, 100, 30)};
  149. DTM2 dtmBCactus1 = new DTM2(BCACACTUS1_DTM_PTS, BCACACTUS1_DTM_RGB);
  150. Point[] AL_HEDGE_DTM_PTS = { new Point( 619, 136), new Point( 652, 136), new Point( 652, 148), new Point( 619, 148)};
  151. Color[] AL_HEDGE_DTM_RGB = { new Color( 251, 251, 245), new Color( 67, 99, 28), new Color( 51, 99, 22), new Color( 251, 251, 245)};
  152. DTM2 dtmAlHedge1 = new DTM2(AL_HEDGE_DTM_PTS, AL_HEDGE_DTM_RGB);
  153. Point[] ALDOOR_DTM_PTS = { new Point( 583, 91), new Point( 583, 94)};
  154. Color[] ALDOOR_DTM_RGB = { new Color( 243, 6, 3), new Color( 243, 6, 3)};
  155. DTM2 dtmAlDoor1 = new DTM2(ALDOOR_DTM_PTS, ALDOOR_DTM_RGB);
  156. Point[] AL_BANK1_DTM_PTS = { new Point( 588, 139), new Point( 602, 150), new Point( 597, 137)};
  157. Color[] AL_BANK1_DTM_RGB = { new Color( 242, 238, 244), new Color( 238, 229, 253), new Color( 238, 229, 253)};
  158. DTM2 dtmAlBank1 = new DTM2(AL_BANK1_DTM_PTS, AL_BANK1_DTM_RGB);
  159.  
  160. //dtm for a selected object
  161. Point[] SELECTED_DTM_PTS = { new Point( 572, 255)};
  162. Color[] SELECTED_DTM_RGB = { new Color( 255, 255, 255)};
  163. DTM2 dtmSelected = new DTM2(SELECTED_DTM_PTS, SELECTED_DTM_RGB);
  164.  
  165. //dtm for casting gui
  166. Point[] CAST_DTM_PTS = { new Point( 20, 30), new Point( 499, 30), new Point( 499, 321), new Point( 21, 321)};
  167. Color[] CAST_DTM_RGB = { new Color( 180, 178, 170), new Color( 175, 171, 164), new Color( 175, 171, 164), new Color( 175, 171, 164)};
  168. DTM2 dtmCast = new DTM2(CAST_DTM_PTS, CAST_DTM_RGB);
  169.  
  170. /**
  171. * New bank finding dtms
  172. * Point[] DTM_PTS = { new Point( 581, 91), new Point( 586, 93), new Point( 582, 96)};
  173. * Color[] DTM_RGB = { new Color( 245, 247, 230), new Color( 245, 247, 230), new Color( 245, 247, 230)};
  174. * DTM2 dtm1 = new DTM2(DTM_PTS, DTM_RGB);
  175. *
  176. */
  177.  
  178. //dtm for an iron bar
  179. Point[] BAR_DTM_PTS = { new Point( 579, 218), new Point( 570, 237), new Point( 584, 227)};
  180. Color[] BAR_DTM_RGB = { new Color( 0, 0, 2), new Color( 0, 0, 2), new Color( 84, 81, 81)};
  181. DTM2 dtmBar = new DTM2(BAR_DTM_PTS, BAR_DTM_RGB);
  182.  
  183. Point[] ORE_DTM_PTS = { new Point( 54, 107)};
  184. Color[] ORE_DTM_RGB = new Color [1];
  185. DTM2 oredtm;
  186.  
  187. private static BufferedImage back = null;
  188. private static long TIME = 0, smeltTO = 0;
  189. private boolean showPaint = true, first = true;
  190. private Color temp0 = null, temp1 = null, temp2 = null, ore = new Color(0,0,0);
  191. private int row = 0, col = 0, smelted = 0;
  192. private static String status = "Setup";
  193. private boolean getCol = true;
  194. private GUI gui;
  195. private StaminaChecker stamStam = new StaminaChecker();
  196. protected int smelting = 0;
  197. private Point chkPt = new Point (54,107);
  198. private double exp = 25.2;
  199. protected boolean goldsmith = false;
  200. private String type = "Cannonballs";
  201. private long reTry = 0;
  202. private int smeltedT;
  203. private int trys = 0;
  204. private long TO = 21600000;
  205. private boolean login = false;
  206. private String userName = "";
  207. private String password = "";
  208. public static boolean staminaFull;
  209. private String version = "1.5";
  210. private Rectangle drawR = new Rectangle();
  211. private boolean firstS = true;
  212. private Color[] IRON_DTM_RGB = { Colour.getColour(582, 219), Colour.getColour(580, 228), Colour.getColour(587, 234)};
  213. private int barsTemp = 0;
  214. private boolean logout = false;
  215. private char location = 'A';
  216. private int profit = 0;
  217. private String tStat = "Finding banker";
  218. private boolean showD = false;
  219. private boolean makeJewl = false;
  220. private int jewel = 0;
  221. private int S = 7;
  222. private String typeJ = "";
  223. private OCR ocr = new OCR();
  224.  
  225. private static int walkmod = 1;
  226.  
  227. public boolean onStart(){
  228. ORE_DTM_RGB [0] = new Color(0,0,0);
  229. oredtm = new DTM2(ORE_DTM_PTS, ORE_DTM_RGB);
  230. try {
  231. back = ImageIO.read(new File("./Storage/BatScripts/backPick.png"));
  232. }catch (FileNotFoundException e) {
  233. }catch (IOException e) {
  234. try {
  235. println("Images not found, retrieving from internet.");
  236. back = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/underPaint.png"));
  237. File file = new File("./Storage/BatScripts/backPick.png");
  238. file.getParentFile().mkdirs();
  239. ImageIO.write(back, "png",file);
  240. } catch (IOException ex) {
  241. }
  242. }
  243.  
  244. try {
  245. SwingUtilities.invokeAndWait(new Runnable() {
  246. @Override
  247. public void run() {
  248. gui = new GUI();
  249. gui.setVisible(true);
  250. }
  251. });
  252. } catch (InterruptedException ex) {
  253. } catch (InvocationTargetException ex) {
  254. }
  255. while(gui.OPEN){
  256. sleep(100);
  257. }
  258. switch(smelting){
  259. case 0:
  260. exp = 25.2;
  261. profit = 4*GE.getGuidePrice(2)-GE.getGuidePrice(2353);
  262. break;
  263. case 1:
  264. exp = 6.2;
  265. profit = GE.getGuidePrice(2349)-(GE.getGuidePrice(438) + GE.getGuidePrice(436));
  266. break;
  267. case 2:
  268. exp = 12.5;
  269. profit = GE.getGuidePrice(2351)-GE.getGuidePrice(440);
  270. break;
  271. case 3:
  272. exp = 13.7;
  273. profit = GE.getGuidePrice(2355)-GE.getGuidePrice(442);
  274. break;
  275. case 4:
  276. exp = 17.5;
  277. profit = GE.getGuidePrice(2353)-(GE.getGuidePrice(440)+ 2*GE.getGuidePrice(453));
  278. break;
  279. case 5:
  280. exp = 22.5;
  281. if(goldsmith) exp = 56.2;
  282. profit = GE.getGuidePrice(2357)-GE.getGuidePrice(444);
  283. break;
  284. case 6:
  285. exp = 30 ;
  286. profit = GE.getGuidePrice(2359)-(GE.getGuidePrice(447)+ 4*GE.getGuidePrice(453));
  287. break;
  288. case 7:
  289. exp = 37.5;
  290. profit = GE.getGuidePrice(2361)-(GE.getGuidePrice(449)+ 6*GE.getGuidePrice(453));
  291. break;
  292. case 8:
  293. exp = 50;
  294. profit = GE.getGuidePrice(2363)-(GE.getGuidePrice(451)+ 8*GE.getGuidePrice(453));
  295. break;
  296. }
  297. status = "Finding banker";
  298. TIME = System.currentTimeMillis();
  299. General.clickMouse(new Point(543,26),1);
  300. sleep(200);
  301. ClientContext.get().client.getKeyboardHandler().sendPressEvent((char)KeyEvent.VK_UP);
  302. sleep(300);
  303. ClientContext.get().client.getKeyboardHandler().sendReleaseEvent((char)KeyEvent.VK_UP);
  304. return true;
  305. }
  306. public void onStop(){
  307. if(stamStam.isAlive()){
  308. stamStam.interrupt();
  309. }
  310. if(logout){
  311. println("Logging out.");
  312. General.clickMouse(new Point(General.random(748,760),General.random(4,15)), 1);
  313. sleep(General.random(400,600));
  314. General.clickMouse(new Point(General.random(576,708),General.random(394,418)),1);
  315. }
  316. println("You managed to smelt " + smelted + " items!");
  317. println("Total runtime: " + Timing.msToString(System.currentTimeMillis() - TIME));
  318. println("Thanks for using BatSmelterAIO");
  319. }
  320. @Override
  321. public void run() {
  322. if(onStart())while(!Thread.interrupted()&&(loop() > 0));
  323. onStop();
  324. }
  325. /*****************************************************/
  326. /*** LOOP ***/
  327. /*****************************************************/
  328. public int loop(){
  329. if(!isLoggedIn()){
  330. println("You have been logged out, you are probably Client token errored, Shutting down.");
  331. return -1;
  332. }
  333. General.setMouseSpeed(General.random(3,5));
  334. if(!Banking.isBankScreenOpen()) if(!getOpenTab().equals(Tab.INVENTORY))openTab(Tab.INVENTORY);
  335. if(location == 'A'){
  336. return loopA();
  337. }else if(location == 'B'){
  338. return loopB();
  339. }else{
  340. println("ERROR WITH LOCATION! SOMETHING VERY BAD HAPPEND!");
  341. return -1;
  342. }
  343. }
  344. ///////////////////////
  345. // Loop for Edgeville//
  346. ///////////////////////
  347. public int loopA() {
  348. if(status.equals("Finding banker")){
  349. if(Banking.isBankScreenOpen()){
  350. status = "Banking";
  351. return 100;
  352. }
  353. if(dtmBanker2.findDTMS(20, VIEWPORTR) || dtmBanker1.findDTMS(20, VIEWPORTR) || dtmBanker3.findDTMS(20, VIEWPORTR)){
  354. int i = General.random(0,DTM2.dtmLocations.size()-1);
  355. Point bankerPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  356. General.clickMouse(bankerPt,-1);
  357. sleep(100);
  358. String lol = ocr.findString(new Rectangle(bankerPt.x-65,bankerPt.y+30, 130,25), null,true,false);
  359. if(lol.contains("Bank") || lol.contains("ank") || lol.contains("nk") || lol.contains("Ba")|| lol.contains("Ban")){
  360. General.clickMouse(new Point(bankerPt.x,bankerPt.y+46),1);
  361. trys = 0;
  362. int k = 0;
  363. while(!Banking.isBankScreenOpen() && k <= 30){
  364. sleep(100);
  365. k++;
  366. }
  367. }else {if(trys++ == 8){
  368. trys = 0;
  369. status = "Lost";
  370. tStat = "Finding banker";
  371. }
  372. General.moveMouse(new Point(General.random(0,517),General.random(0,339)));
  373.  
  374. }
  375. }else{
  376. if(trys++ >= 3){
  377. if(dtmBanker2.findDTMS(30, VIEWPORT) || dtmBanker1.findDTMS(30, VIEWPORT) || dtmBanker3.findDTMS(30, VIEWPORT)){
  378. int i = General.random(0,DTM2.dtmLocations.size()-1);
  379. Point bankerPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  380. General.clickMouse(bankerPt,2);
  381. sleep(100);
  382. String lol = ocr.findString(new Rectangle(bankerPt.x-65,bankerPt.y+30, 130,25), null,true,false);
  383. if(lol.contains("Bank") || lol.contains("ank") || lol.contains("nk") || lol.contains("Ba")|| lol.contains("Ban")){
  384. General.clickMouse(new Point(bankerPt.x,bankerPt.y+46),1);
  385. int k = 0;
  386. while(!Banking.isBankScreenOpen() && k <= 50){
  387. sleep(100);
  388. k++;
  389. }
  390. }else trys++;
  391. }else if(trys++ >= 8){
  392. trys= 0;
  393. tStat = "Finding banker";
  394. status = "Lost";
  395. return 100;
  396. }
  397. General.moveMouse(new Point(General.random(0,517),General.random(0,339)));
  398.  
  399. }
  400. return 100;
  401. }
  402. if(Banking.isBankScreenOpen()){
  403. status = "Banking";
  404. return 100;
  405. }
  406. return 100;
  407. }
  408. //Lost!
  409. if(status.equals("Lost")){
  410. if(dtmFurnSym.findDTMS(20, MINIMAP)){
  411. int i = General.random(0,DTM2.dtmLocations.size()-1);
  412. Point symPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  413. General.clickMouse(new Point(symPt.x+General.random(-7,7),symPt.y+General.random(-7,7)),1);
  414. sleep(6500);
  415. if(tStat.equals("Finding banker")){
  416. if(dtmBank1.findDTMS(20, MINIMAP) || dtmBank2.findDTMS(20, MINIMAP) || dtmBank3.findDTMS(20, MINIMAP)){
  417. int j = General.random(0,DTM2.dtmLocations.size()-1);
  418. Point bankPt = new Point((int)DTM2.dtmLocations.get(j).getCenterX(),(int)DTM2.dtmLocations.get(j).getCenterY());
  419. bankPt.y = bankPt.y + 30;
  420. General.clickMouse(bankPt,1);
  421. sleep(6500);
  422. }
  423. }
  424. status = tStat;
  425. return 100;
  426. }
  427. if(trys++ == 6){
  428. println("Completely lost. Might be a random.");
  429. return -1;
  430. }
  431. }
  432. //Banking
  433. if(status.equals("Banking")){
  434. return bank();
  435. }
  436. //Walking to Furnace
  437. if(status.equals("Walking to furnace")){
  438. if(!checkColor(ore,new Point(579,228), 20) /*&&*/){
  439. status = "Finding banker";
  440. return 100;
  441. }
  442. if(dtmSmith1.findDTMS(20, MINIMAPMR) || dtmSmith2.findDTMS(20, MINIMAPMR)|| dtmSmith3.findDTMS(20, MINIMAPMR)|| dtmSmith4.findDTMS(20, MINIMAPMR)|| dtmSmith6.findDTMS(20, MINIMAPMR)|| dtmSmith7.findDTMS(20, MINIMAPMR)|| dtmSmith8.findDTMS(20, MINIMAPMR) || dtmSmith9.findDTMS(20, MINIMAPMR)|| dtmSmith5.findDTMS(20, MINIMAPMR)){
  443. int i = General.random(0,DTM2.dtmLocations.size()-1);
  444. drawR = DTM2.dtmLocations.get(i);
  445. Point smithPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  446. if(smithPt.y <= 55){
  447. showD = true;
  448. sleep(100);
  449. }
  450. General.clickMouse(smithPt,1);
  451. sleep(1000);
  452. showD = false;
  453. drawR = new Rectangle();
  454. sleep(4100);
  455. status = "Finding furnace";
  456. return 100;
  457. }else if(dtmFurnSym.findDTMS(20, MINIMAP)){
  458. int i = General.random(0,DTM2.dtmLocations.size()-1);
  459. drawR = DTM2.dtmLocations.get(i);
  460. Point symPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  461. General.clickMouse(new Point(symPt.x+General.random(-2,2),symPt.y+General.random(-2,2)),1);
  462. sleep(1000);
  463. drawR = new Rectangle();
  464. sleep(4100);
  465. status = "Finding furnace";
  466. return 100;
  467. }
  468. }
  469. //Finding Furnace
  470. if(status.equals("Finding furnace")){
  471. if(makeJewl && S==2){
  472. S = 0;
  473. status = "Walking back";
  474. return 100;
  475. }
  476. if(dtmFurn1.findDTMS(20, VIEWPORT) || dtmFurn2.findDTMS(20, VIEWPORT)){
  477. int i = General.random(0,DTM2.dtmLocations.size()-1);
  478. Point FurnPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  479. if(S==1 && (smelting == 3 || smelting == 5) && !dtmSelected.findDTMS(10,new Rectangle(561, 212, 36, 32).getBounds()))General.clickMouse(new Point(General.random(567,587),General.random(219,240)),1);
  480. General.clickMouse(FurnPt,2);
  481. sleep(300);
  482. String lol = ocr.findString(new Rectangle(FurnPt.x-100,FurnPt.y+15, 200,25), null,true,false);
  483. if((lol.contains("Use") || lol.contains("Smelt"))&& lol.contains("Furnace")){
  484. General.clickMouse(new Point(FurnPt.x,FurnPt.y+33),1);
  485. }else{
  486. General.moveMouse(new Point(General.random(0,765), General.random(0,502)));
  487. if(S==1 && (smelting == 3 || smelting == 5) && dtmSelected.findDTMS(10,new Rectangle(561, 212, 36, 32).getBounds()))General.clickMouse(new Point(General.random(567,587),General.random(219,240)),1);
  488. if(trys++ >= 5){
  489. trys= 0;
  490. tStat = "Finding furnace";
  491. status = "Lost";
  492. return 100;
  493. }
  494. }
  495. int k = 0;
  496. while((!Colour.getColour(319,360).equals(new Color(90,82,69)) || dtmCast.findDTMS(20))&& k <= 30){
  497. sleep(100);
  498. k++;
  499. }
  500. }else{
  501. if(trys++ >= 5){
  502. trys = 0;
  503. tStat = "Finding furnace";
  504. status = "Lost";
  505. }
  506. return 100;
  507. }
  508. if(Colour.getColour(319,360).equals(new Color(90,82,69))){
  509. first = true;
  510. row = 0;
  511. col = 0;
  512. reTry = System.currentTimeMillis();
  513. smeltedT = smelted;
  514. firstS = true;
  515. status = "Smelting";
  516. General.moveMouse(new Point(General.random(233,273),General.random(405,452)));
  517.  
  518. }else if(dtmCast.findDTMS(20)){
  519. switch(jewel){
  520. case 0:
  521. General.clickMouse(new Point(85,90),2);
  522. break;
  523. case 1:
  524. General.clickMouse(new Point(170,90),2);
  525. break;
  526. case 2:
  527. General.clickMouse(new Point(255,100),2);
  528. break;
  529. case 3:
  530. General.clickMouse(new Point(78,205),2);
  531. break;
  532. case 4:
  533. General.clickMouse(new Point(335,210),2);
  534. break;
  535. case 5:
  536. General.clickMouse(new Point(115,105),2);
  537. break;
  538. case 6:
  539. General.clickMouse(new Point(130,165),2);
  540. break;
  541. case 7:
  542. General.clickMouse(new Point(130,228),2);
  543. break;
  544. case 8:
  545. General.clickMouse(new Point(130,290),2);
  546. break;
  547. }
  548. sleep(300);
  549. General.clickMouse(new Point(General.getMousePos().x, General.getMousePos().y + 60),1);
  550. first = true;
  551. row = 0;
  552. col = 0;
  553. reTry = System.currentTimeMillis();
  554. smeltedT = smelted;
  555. firstS = true;
  556. status = "Smelting";
  557. sleep(1000);
  558. }
  559. return 100;
  560. }
  561.  
  562. //Smelting
  563. if(status.equals("Smelting")){
  564. return smelt();
  565. }
  566. if(status.equals("Walking back")){
  567. if(dtmBank1.findDTMS(20, MINIMAPL) || dtmBank2.findDTMS(20, MINIMAPL)){
  568. int i = 0;
  569. Point bankPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  570. bankPt.y = bankPt.y + 20;
  571. General.clickMouse(bankPt,1);
  572. sleep(1000);
  573. sleep(5000);
  574. trys = 0;
  575. status = "Finding banker";
  576. return 100;
  577. }else if(trys++ == 6){
  578. trys = 0;
  579. tStat = "Finding banker";
  580. status = "Lost";
  581. }
  582. return 100;
  583. }
  584. return 100;
  585. }
  586. ///////////////////////
  587. // Loop for Al-Kharid//
  588. ///////////////////////
  589. private int loopB() {
  590. if(!stamStam.isAlive()){
  591. stamStam = new StaminaChecker();
  592. stamStam.start();
  593. }
  594. if(StaminaChecker.staminaOff() && !status.equals("Banking") && !status.equals("Finding banker")){
  595. int x = 0;
  596. int y = 0;
  597. Point pfullStam = new Point(721,96);
  598. General.clickMouse(new Point((x = pfullStam.x+General.random(-3,5)),(y = pfullStam.y+General.random(3,25))),1);
  599. sleep(400,500);
  600. General.clickMouse(new Point(x, (y + General.random(21,32))),1);
  601. sleep(400,500);
  602. walkmod = 1;
  603. }
  604. if(status.equals("Finding banker")){
  605. if(Banking.isBankScreenOpen()){
  606. status = "Banking";
  607. return 100;
  608. }
  609. if(dtmAlBanker.findDTMS(20, VIEWPORTS)){
  610. int i = General.random(0,DTM2.dtmLocations.size()-1);
  611. Point bankerPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  612. General.clickMouse(bankerPt,2);
  613. sleep(100);
  614. String lol = ocr.findString(new Rectangle(bankerPt.x-65,bankerPt.y+30, 130,25), null,true,false);
  615. if((lol.contains("Bank") || lol.contains("ank") || lol.contains("nk") || lol.contains("Ba")|| lol.contains("Ban")) && !lol.contains("Booth")){
  616. General.clickMouse(new Point(bankerPt.x,bankerPt.y+46),1);
  617. trys = 0;
  618. int k = 0;
  619. while(!Banking.isBankScreenOpen() && k <= 30){
  620. sleep(100);
  621. k++;
  622. }
  623. }else {
  624. if(trys++ == 8){
  625. trys = 0;
  626. tStat = "Finding banker";
  627. status = "Lost";
  628. }
  629. General.moveMouse(new Point(General.random(0,517),General.random(0,339)));
  630. }
  631. }
  632. return 100;
  633. }
  634. //Lost!
  635. if(status.equals("Lost")){
  636. if(dtmFurnSym.findDTMS(20, MINIMAP)){
  637. int i = General.random(0,DTM2.dtmLocations.size()-1);
  638. Point symPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  639. General.clickMouse(symPt,1);
  640. for(int j = 0; j <= 65; j++)sleep(100*walkmod);
  641.  
  642. if(tStat.equals("Finding banker")){
  643. if(dtmAlDoor1.findDTMS(20, MINIMAP)){
  644. int j = General.random(0,DTM2.dtmLocations.size()-1);
  645. Point bankPt = new Point((int)DTM2.dtmLocations.get(j).getCenterX(),(int)DTM2.dtmLocations.get(j).getCenterY());
  646. General.clickMouse(bankPt,1);
  647. for(int k = 0; k <= 65; k++)sleep(100*walkmod);
  648. }
  649. }
  650. status = tStat;
  651. return 100;
  652. }
  653. if(trys++ == 6){
  654. println("Completely lost. Might be a random.");
  655. return -1;
  656. }
  657. }
  658. //Banking
  659. if(status.equals("Banking")){
  660. return bank();
  661. }
  662.  
  663. //Walking to Furnace
  664. if(status.equals("Walking to furnace")){
  665. if(dtmCactus1.findDTMS(20, MINIMAP) || dtmCactus2.findDTMS(20, MINIMAP) ){
  666. int i = General.random(0,DTM2.dtmLocations.size()-1);
  667. Point cactPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  668. cactPt.y -=60;
  669. General.clickMouse(cactPt,1);
  670. for(int j = 0; j <= 34; j++){
  671. sleep(100*walkmod);
  672. }
  673. if(dtmCactus1.findDTMS(20, MINIMAP) || dtmCactus2.findDTMS(20, MINIMAP) ){
  674. i = General.random(0,DTM2.dtmLocations.size()-1);
  675. cactPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  676. cactPt.x -= General.random(10, 15);
  677. cactPt.y -= 76;
  678. General.clickMouse(cactPt,1);
  679. for(int j = 0; j <= 65; j++){
  680. sleep(100*walkmod);
  681. }
  682. status = "Finding furnace";
  683. }
  684. }
  685. return 100;
  686. }
  687. //Finding Furnace
  688. if(status.equals("Finding furnace")){
  689. if(makeJewl && S==2){
  690. S = 0;
  691. status = "Walking back";
  692. return 100;
  693. }
  694. if(dtmAlFurn1.findDTMS(20, VIEWPORT)){
  695. int i = General.random(0,DTM2.dtmLocations.size()-1);
  696. Point FurnPt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  697. if(S++==1 && (smelting == 3 || smelting == 5) && !dtmSelected.findDTMS(10,new Rectangle(561, 212, 36, 32).getBounds()))General.clickMouse(new Point(General.random(567,587),General.random(219,240)),1);
  698. General.clickMouse(new Point(FurnPt),2);
  699. sleep(300);
  700. String lol = ocr.findString(new Rectangle(FurnPt.x-100,FurnPt.y+15, 200,25), null,true,false);
  701. if((lol.contains("Smelt") || lol.contains("Use"))&& lol.contains("Furnace")){
  702. General.clickMouse(new Point(FurnPt.x,FurnPt.y+33),1);
  703. }else{
  704. General.moveMouse(new Point(General.random(0,765), General.random(0,502)));
  705. if(S==1 && (smelting == 3 || smelting == 5) && dtmSelected.findDTMS(10,new Rectangle(561, 212, 36, 32).getBounds()))General.clickMouse(new Point(General.random(567,587),General.random(219,240)),1);
  706. // if(trys == 3){
  707. // General.clickMouse(236,171);
  708. // return 100;
  709. // }
  710. if(trys++ >= 5){
  711. General.clickMouse(new Point(236,171),1);
  712. // trys= 0;
  713. // tStat = "Finding furnace";
  714. // status = "Lost";
  715. return 100;
  716. }
  717. }
  718. int k = 0;
  719. while((!Colour.getColour(319,360).equals(new Color(90,82,69)) || dtmCast.findDTMS(20))&& k <= 30){
  720. sleep(100);
  721. k++;
  722. }
  723. }else{
  724. if(trys++ >= 5){
  725. trys = 0;
  726. tStat = "Finding furnace";
  727. status = "Lost";
  728. }
  729. return 100;
  730. }
  731. if(Colour.getColour(319,360).equals(new Color(90,82,69))){
  732. first = true;
  733. row = 0;
  734. col = 0;
  735. reTry = System.currentTimeMillis();
  736. smeltedT = smelted;
  737. firstS = true;
  738. status = "Smelting";
  739. General.moveMouse(new Point(General.random(233,273),General.random(405,452)));
  740.  
  741. }else if(dtmCast.findDTMS(20)){
  742. switch(jewel){
  743. case 0:
  744. General.clickMouse(new Point(85,90),2);
  745. break;
  746. case 1:
  747. General.clickMouse(new Point(170,90),2);
  748. break;
  749. case 2:
  750. General.clickMouse(new Point(255,100),2);
  751. break;
  752. case 3:
  753. General.clickMouse(new Point(78,205),2);
  754. break;
  755. case 4:
  756. General.clickMouse(new Point(335,210),2);
  757. break;
  758. case 5:
  759. General.clickMouse(new Point(115,105),2);
  760. break;
  761. case 6:
  762. General.clickMouse(new Point(130,165),2);
  763. break;
  764. case 7:
  765. General.clickMouse(new Point(130,228),2);
  766. break;
  767. case 8:
  768. General.clickMouse(new Point(130,290),2);
  769. break;
  770. }
  771. sleep(300);
  772. General.clickMouse(new Point(General.getMousePos().x, General.getMousePos().y + 60),1);
  773. first = true;
  774. row = 0;
  775. col = 0;
  776. reTry = System.currentTimeMillis();
  777. smeltedT = smelted;
  778. firstS = true;
  779. status = "Smelting";
  780. sleep(1000);
  781. }
  782. return 100;
  783. }
  784.  
  785. //Smelting
  786. if(status.equals("Smelting")){
  787. return smelt();
  788. }
  789. if(status.equals("Walking back")){
  790. // if(dtmAlHedge1.findDTMS(20, MINIMAP)){
  791. // int i = General.random(0,DTM2.dtmLocations.size()-1);
  792. // Point hedgePt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  793. // General.clickMouse(hedgePt);
  794. // Environment.saveScreenshot();
  795. // for(int j = 0; j <= 70; j++){
  796. // sleep(100*walkmod);
  797. // }
  798. // if(dtmAlHedge1.findDTMS(20, MINIMAP)){
  799. // i = General.random(0,DTM2.dtmLocations.size()-1);
  800. // hedgePt = new Point((int)DTM2.dtmLocations.get(i).getCenterX(),(int)DTM2.dtmLocations.get(i).getCenterY());
  801. // hedgePt.x -= 30;
  802. // General.clickMouse(hedgePt);
  803. // Environment.saveScreenshot();
  804. // for(int j = 0; j <= 30; j++){
  805. // sleep(100*walkmod);
  806. // }
  807. General.clickMouse(new Point(609, 158),1);
  808. for(int j = 0; j <= 100; j++){
  809. sleep(100*walkmod);
  810. }
  811. status = "Finding banker";
  812. return 100;
  813. // }
  814. // }
  815. }
  816. return 100;
  817. }
  818. /**********************************************************************************/
  819. /*************************** END LOOP *********************************************/
  820. /**********************************************************************************/
  821. /**
  822. * Opens a given tab.
  823. * @param tab The tab to open.
  824. */
  825. public void openTab(final Tab tab) {
  826. tab.open();
  827. }
  828. /**
  829. * Gets the open tab.
  830. * @return The open tab.
  831. */
  832. public Tab getOpenTab() {
  833. for (final Tab tab : Tab.values()) {
  834. if (tab.isOpen()) {
  835. return tab;
  836. }
  837. }
  838. return null;
  839. }
  840. private int smelt(){
  841. if(System.currentTimeMillis() - reTry > 20000 && smeltedT == smelted){
  842. status = "Finding furnace";
  843. }
  844. if(first){
  845. if(!makeJewl && !Colour.getColour(319,360).equals(new Color(90,82,69))){
  846. status = "Finding furnace";
  847. }
  848. if(smelting == 4){
  849. General.clickMouse(new Point(General.random(272,315),General.random(405,450)),1);
  850. }else{
  851. if(!makeJewl || S == 0){
  852. General.clickMouse(new Point(General.random(233,273),General.random(405,450)),1);
  853. }
  854. }
  855. temp0 = Colour.getColour(583,221);
  856. temp1 = Colour.getColour(591,225);
  857. temp2 = Colour.getColour(569,231);
  858. first = false;
  859. smeltTO = System.currentTimeMillis();
  860. }
  861. if(System.currentTimeMillis()- smeltTO > 1200000){
  862. status = "Walking back";
  863. return 100;
  864. }
  865. if(!checkColor(temp0,new Point(583 + (col*42),221 + (row*36)),15)
  866. || !checkColor(temp1,new Point(591 + (col*42),225 + (row*36)),15)
  867. || !checkColor(temp2,new Point(569 + (col*42),231 + (row*36)),15)){
  868. if(smelting != 2){
  869. smelted ++;
  870. smeltedT = smelted;
  871. reTry = System.currentTimeMillis();
  872. col++;
  873. }
  874. switch(smelting){
  875. case 1:
  876. if(col == 4){
  877. col = 0;
  878. row++;
  879. }
  880. if(row == 3){
  881. if(col == 2){
  882. status = "Walking back";
  883. return 100;
  884. }
  885. }
  886.  
  887. break;
  888. case 2:
  889. dtmBar.findDTMS(1, INVENTORY);
  890. if(DTM2.dtmLocations.size()/2 != barsTemp ){
  891. smelted ++;
  892. smeltedT = smelted;
  893. reTry = System.currentTimeMillis();
  894. barsTemp = DTM2.dtmLocations.size()/2;
  895. }
  896. Point[] IRON_DTM_PTS = { new Point( 582, 219), new Point( 580, 228), new Point( 587, 234)};
  897. if(firstS){
  898. IRON_DTM_RGB = new Color [] { Colour.getColour(582, 219), Colour.getColour(582, 219), Colour.getColour(582, 219), Colour.getColour(582, 219)};
  899. firstS = false;
  900. }
  901. DTM2 dtmIron = new DTM2(IRON_DTM_PTS, IRON_DTM_RGB);
  902. if(!dtmIron.findDTMS(1, INVENTORY)){
  903. status = "Walking back";
  904. return 100;
  905. }
  906. break;
  907. case 4:
  908. if(col == 4){
  909. col = 0;
  910. row++;
  911. }
  912. if(row == 2){
  913. if(col == 1){
  914. status = "Walking back";
  915. return 100;
  916. }
  917. }
  918.  
  919. break;
  920. case 6:
  921. if(col == 4){
  922. col = 0;
  923. row++;
  924. }
  925. if(row == 1){
  926. if(col == 1){
  927. status = "Walking back";
  928. return 100;
  929. }
  930. }
  931.  
  932. break;
  933. case 7:
  934. if(col == 4){
  935. col = 0;
  936. status = "Walking back";
  937. return 100;
  938. }
  939. break;
  940. case 8:
  941. if(col == 3){
  942. col = 0;
  943. status = "Walking back";
  944. return 100;
  945. }
  946. default:
  947. if(col == 4){
  948. col = 0;
  949. row++;
  950. if(row == 7){
  951. if((smelting == 3 || smelting == 5) && makeJewl){
  952. col = 0;
  953. row = 0;
  954. if(S == 1)S = 2;
  955. if(S == 0)S = 1;
  956. status = "Finding furnace";
  957. return 100;
  958. }
  959. status = "Walking back";
  960. return 100;
  961. }
  962. }
  963. return 100;
  964. }
  965.  
  966. }
  967. return 100;
  968. }
  969. private int bank(){
  970. if(Banking.isBankScreenOpen()){
  971. if(!checkColor(ore, new Point(54, 107), 20) && !getCol){
  972. println("May be out of raw materials, rechecking bank just in case.");
  973. sleep(600,1000);
  974. if(!checkColor(ore, new Point(54, 107), 20) && !getCol){
  975. println("Out of raw material!");
  976. General.clickMouse(new Point(489,30), 1);
  977. sleep(100,200);
  978. return -1;
  979. }else{
  980. println("Second check came back positive, continuing!");
  981. }
  982. }
  983. ore = Colour.getColour(54, 107);
  984. ORE_DTM_RGB [0] = Colour.getColour(54, 107);
  985. oredtm = new DTM2(ORE_DTM_PTS, ORE_DTM_RGB);
  986. getCol = false;
  987. Banking.depositAll();
  988. sleep(500,700);
  989.  
  990. switch(smelting){
  991. case 1:
  992. General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  993. sleep(500,700);
  994. withdrawX(14);
  995. sleep(2000);
  996. if(!checkColor(ore, chkPt, 30)) General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  997. else General.moveMouse(new Point(General.random(87, 108),General.random(96, 120)));
  998. sleep(500,700);
  999. withdrawX(14);
  1000. break;
  1001. case 4:
  1002. General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1003. sleep(500,700);
  1004. withdrawX(9);
  1005. sleep(2000);
  1006. if(!checkColor(ore, chkPt, 30)) General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1007. else General.moveMouse(new Point(General.random(87, 108),General.random(96, 120)));
  1008. sleep(500,700);
  1009. withdrawAll();
  1010. break;
  1011. case 6:
  1012. General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1013. sleep(500,700);
  1014. withdrawX(5);
  1015. sleep(2000);
  1016. if(!checkColor(ore, chkPt, 30)) General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1017. else General.moveMouse(new Point(General.random(87, 108),General.random(96, 120)));
  1018. sleep(500,700);
  1019. withdrawAll();
  1020. break;
  1021. case 7:
  1022. General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1023. sleep(500,700);
  1024. withdrawX(4);
  1025. sleep(2000);
  1026. if(!checkColor(ore, chkPt, 30)) General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1027. else General.moveMouse(new Point(General.random(87, 108),General.random(96, 120)));
  1028. sleep(500,700);
  1029. withdrawAll();
  1030. break;
  1031. case 8:
  1032. General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1033. sleep(500,700);
  1034. withdrawX(3);
  1035. sleep(2000);
  1036. if(!checkColor(ore, chkPt, 30)) General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1037. else General.moveMouse(new Point(General.random(87, 108),General.random(96, 120)));
  1038. sleep(500,700);
  1039. withdrawAll();
  1040. break;
  1041. default:
  1042. General.moveMouse(new Point(General.random(41, 66),General.random(96, 120)));
  1043. sleep(500,700);
  1044. withdrawAll();
  1045. break;
  1046. }
  1047. sleep(500,700);
  1048. //Close the window.
  1049. General.clickMouse(new Point(489,30),1);
  1050. sleep(100,200);
  1051. General.moveMouse(new Point(General.random(0,765), General.random(0,502)));
  1052. sleep(400,500);
  1053. }
  1054. if(makeJewl)S = 0;
  1055. status = "Walking to furnace";
  1056. return 100;
  1057. }
  1058. /**
  1059. * Checks if the player is logged in
  1060. * @return boolean
  1061. * - true if logged in.
  1062. * - false if logged out.
  1063. */
  1064. private static boolean isLoggedIn() {
  1065. Point[] DTM_PTS = { new Point( 754, 10), new Point( 758, 6), new Point( 750, 6), new Point( 750, 14), new Point( 758, 14)};
  1066. Color[] DTM_RGB = { new Color( 115, 98, 55), new Color( 153, 131, 84), new Color( 162, 146, 104), new Color( 115, 98, 55), new Color( 104, 88, 46)};
  1067. DTM2 dtmlog = new DTM2(DTM_PTS, DTM_RGB);
  1068. if(!dtmlog.findDTMS(30,new Rectangle(740,6,14,14)))
  1069. return Banking.isBankScreenOpen();
  1070. else return true;
  1071. }
  1072. private void withdrawX(int i){
  1073. General.clickMouse(General.getMousePos(),2);
  1074. sleep(500,700);
  1075. String lol = ocr.findString(new Rectangle(General.getMousePos().x-30,General.getMousePos().y+65, 140,21), null,true,false);
  1076. if(lol.contains(" "+i+" ")){
  1077. General.clickMouse(new Point(General.getMousePos().x, (General.getMousePos().y + General.random(73,83))),1);
  1078. }else{
  1079. General.clickMouse(new Point(General.getMousePos().x, (General.getMousePos().y + General.random(86,100))),1);
  1080. sleep(1200);
  1081. ClientContext.get().client.getKeyboardHandler().typeSend(""+i);
  1082. }
  1083. }
  1084. private void withdrawAll(){
  1085. General.clickMouse(General.getMousePos(),2);
  1086. sleep(500,700);
  1087. General.clickMouse(new Point(General.getMousePos().x, (General.getMousePos().y + General.random(102,114))),1);
  1088. }
  1089. @SuppressWarnings("unused")
  1090. private void withdrawAllB1(){
  1091. General.clickMouse(General.getMousePos(),-1);
  1092. sleep(500,700);
  1093. General.clickMouse(new Point(General.getMousePos().x, (General.getMousePos().y + General.random(119,131))),1);
  1094. }
  1095. public void paint(Graphics g){
  1096. if(showD)g.drawString("Time Running: " + Timing.msToString(System.currentTimeMillis() - TIME), 11, 358);
  1097.  
  1098. if(showPaint){
  1099. g.drawImage(back, 5, 343, null);
  1100. g.setColor(Color.BLACK);
  1101. g.setFont(new Font("Salaryman", 1, 14));
  1102. g.drawString("Time Running: " + Timing.msToString(System.currentTimeMillis() - TIME), 11, 358);
  1103. g.drawString("Total Smelted: " + smelted ,11,373);
  1104. try{
  1105. g.drawString("Smelted/Hour: " + (3600000*(long)smelted)/(int)(System.currentTimeMillis() - TIME),11,388);
  1106. g.drawString("Exp./Hour: " + (int)(exp *(3600000*(long)smelted)/(int)(System.currentTimeMillis() - TIME)),11,403);
  1107. g.drawString("Profit/Hour: " + (int)(profit *(3600000*(long)(smelted))/(int)(System.currentTimeMillis() - TIME)),11,418);
  1108. }catch(ArithmeticException e){}
  1109. g.drawString("Status: " + status ,11,433);
  1110. if(makeJewl)g.drawString("Current Setting: " + type + " (" + typeJ + ")",11,448);
  1111. else g.drawString("Current Setting: " + type ,11,448);
  1112. switch(location){
  1113. case 'A':
  1114. g.drawString("Location: Edgeville",11,463);
  1115. break;
  1116. case 'B':
  1117. g.drawString("Location: Al-Kharid" ,11,463);
  1118. break;
  1119. }
  1120. g.setFont(new Font("Salaryman", 1, 25));
  1121. g.drawString("BatSmelterAIO",270,390);
  1122. g.drawString("Version " + version,265,420);
  1123. g.setColor(Color.RED);
  1124. g.drawString("x",500,360);
  1125. }else{
  1126. g.setColor(Color.GREEN);
  1127. g.setFont(new Font("Salaryman", 1, 25));
  1128. g.drawString("o",500,360);
  1129. }
  1130. g.setColor(Color.ORANGE);
  1131. g.drawLine(General.getMousePos().x,0,General.getMousePos().x,2100);
  1132. g.drawLine(0,General.getMousePos().y,2100,General.getMousePos().y);
  1133. g.setColor(Color.GREEN);
  1134. g.drawRect(drawR.x,drawR.y,drawR.width,drawR.height);
  1135. }
  1136.  
  1137. /**
  1138. * Returns whether the given point is a certain color.
  1139. * Accounts for the variable colors that runescape produces whenever you log in.
  1140. * @param col
  1141. * - Color to check for.
  1142. * @param p
  1143. * - Point to check at.
  1144. * @return
  1145. */
  1146. private static boolean checkColor(Color col, Point p, int tol){
  1147. if(Math.abs(col.getRed() - Colour.getColour(p).getRed()) < tol)
  1148. if(Math.abs(col.getGreen() - Colour.getColour(p).getGreen()) < tol)
  1149. if(Math.abs(col.getBlue() - Colour.getColour(p).getBlue()) < tol)
  1150. return true;
  1151. return false;
  1152. }
  1153. public void mouseClicked(MouseEvent e) {
  1154. Point pt = e.getPoint();
  1155. if (pt.x >= 499 && pt.x <= 512 && pt.y >= 345 && pt.y <= 360) {
  1156. showPaint = !showPaint;
  1157. }
  1158. }
  1159. public void mouseEntered(MouseEvent arg0) {}
  1160. public void mouseExited(MouseEvent arg0) {}
  1161. public void mousePressed(MouseEvent arg0) {}
  1162. public void mouseReleased(MouseEvent arg0) {}
  1163.  
  1164. @SuppressWarnings("serial")
  1165. class GUI extends JFrame implements ActionListener{
  1166. GridBagConstraints c;
  1167. Container pane1;
  1168. Container pane2;
  1169. Container pane3;
  1170. JTabbedPane tabbedPane = new JTabbedPane();
  1171. public boolean OPEN = true;
  1172. private JButton startB1 = new JButton("Start");
  1173. private JButton startB2 = new JButton("Start");
  1174. private JButton startB3 = new JButton("Start");
  1175. private JLabel smeltL = new JLabel("Smelting Type:", JLabel.LEFT);
  1176. private JLabel goldL = new JLabel("Gold Jewlery:", JLabel.LEFT);
  1177. private JLabel silverL = new JLabel("Silver Jewlery:", JLabel.LEFT);
  1178. private JLabel unL = new JLabel("Username:", JLabel.LEFT);
  1179. private JLabel passL = new JLabel("Password:", JLabel.LEFT);
  1180. private JTextField unT = new JTextField();
  1181. private JPasswordField pT = new JPasswordField();
  1182. private JComboBox smeltCB;
  1183. private JComboBox silverCB;
  1184. private JComboBox goldCB;
  1185. private JComboBox locationCB;
  1186. private JLabel locL = new JLabel("Location:", JLabel.LEFT);
  1187. private JCheckBox goldSmithChkB = new JCheckBox("Use goldsmithing gauntlets", false);
  1188. private JCheckBox JewlChkB = new JCheckBox("Make Jewelry", false);
  1189. private JCheckBox logInChkB = new JCheckBox("Login after Client Token Error", false);
  1190. private JCheckBox logOutChkB = new JCheckBox("Log out on shutdown", false);
  1191. private String [] smelt;
  1192. private String [] locs;
  1193. private String [] gold;
  1194. private String [] silver;
  1195.  
  1196. public GUI(){
  1197. super("BatSmelter " + version);
  1198. tabbedPane = new JTabbedPane();
  1199. pane1 = new Container();
  1200. pane1.setLayout(new GridBagLayout());
  1201. pane2 = new Container();
  1202. pane2.setLayout(new GridBagLayout());
  1203. pane3 = new Container();
  1204. pane3.setLayout(new GridBagLayout());
  1205. c = new GridBagConstraints();
  1206. c.fill = GridBagConstraints.HORIZONTAL;
  1207. c.ipady = c.ipadx = 3;
  1208. c.insets = new Insets(5, 5, 5, 5);
  1209. init();
  1210. build();
  1211. this.setLocationRelativeTo(getParent());
  1212. }
  1213. private void build(){
  1214. addToGrid(locL,0,0,1,.25, pane1);
  1215. addToGrid(locationCB,1,0,1,.75, pane1);
  1216. addToGrid(smeltL,0,1,1,.25, pane1);
  1217. addToGrid(smeltCB,1,1,1,.75, pane1);
  1218. addToGrid(goldSmithChkB,0,2,1,.5, pane1);
  1219. addToGrid(JewlChkB,1,2,1,.5, pane1);
  1220. addToGrid(startB1,1,3,1,.5, pane1);
  1221.  
  1222.  
  1223. addToGrid(goldL,0,0,1,.25, pane2);
  1224. addToGrid(goldCB,1,0,1,.75, pane2);
  1225. addToGrid(silverL,0,1,1,.25, pane2);
  1226. addToGrid(silverCB,1,1,1,.75, pane2);
  1227. addToGrid(startB2,1,5,1,.5, pane2);
  1228.  
  1229.  
  1230. addToGrid(logInChkB,1,2,1,.5, pane3);
  1231. addToGrid(unL,0,3,1,.25, pane3);
  1232. addToGrid(unT,1,3,1,.75, pane3);
  1233. addToGrid(passL,0,4,1,.25, pane3);
  1234. addToGrid(pT,1,4,2,.75, pane3);
  1235. addToGrid(logOutChkB,0,5,1,.5, pane3);
  1236. addToGrid(startB3,1,5,1,.5, pane3);
  1237.  
  1238.  
  1239. tabbedPane.addTab("Smelting", pane1);
  1240. tabbedPane.addTab("Jewelry", pane2);
  1241. tabbedPane.addTab("Login", pane3);
  1242. getContentPane().add(tabbedPane);
  1243. pack();
  1244. setVisible(true);
  1245. }
  1246. private void init(){
  1247. startB1.addActionListener(this);
  1248. startB2.addActionListener(this);
  1249. // startB3.addActionListener(this);
  1250. smelt = new String []{"Cannonballs", "Bronze", "Iron", "Silver", "Steel", "Gold", "Mithril", "Adamant", "Runite"};
  1251. smeltCB = new JComboBox(smelt);
  1252. smeltCB.setSelectedIndex(0);
  1253. locs = new String []{"Edgeville", "Al-Kharid"};
  1254. locationCB = new JComboBox(locs);
  1255. locationCB.setSelectedIndex(0);
  1256. gold = new String []{"Rings", "Necklaces", "Amulets", "Bracelets"};
  1257. goldCB = new JComboBox(gold);
  1258. goldCB.setSelectedIndex(0);
  1259. silver = new String []{"Holy Symbol", "Sickles", "Tiara", "Unholy Symbol", "Bolts"};
  1260. silverCB = new JComboBox(silver);
  1261. silverCB.setSelectedIndex(0);
  1262. }
  1263. private void addToGrid(Component comp, int gridx, int gridy, int gridwidth,
  1264. double weightx, Container pane) {
  1265. c.gridx = gridx;
  1266. c.gridy = gridy;
  1267. c.gridwidth = gridwidth;
  1268. c.weightx = weightx;
  1269. pane.add(comp, c);
  1270. }
  1271.  
  1272. public void actionPerformed(ActionEvent e) {
  1273. if(locationCB.getSelectedIndex() == 0)location = 'A';
  1274. else location = 'B';
  1275.  
  1276. if(logInChkB.isSelected()){
  1277. userName = unT.getText();
  1278. password = "";
  1279. for(int i = 0; i < pT.getPassword().length; i++){
  1280. password += pT.getPassword()[i];
  1281. pT.getPassword()[i] = '0';
  1282. }
  1283. login = true;
  1284. }
  1285. smelting = smeltCB.getSelectedIndex();
  1286. switch(smelting){
  1287. case 0:
  1288. type = "Cannonballs";
  1289. break;
  1290. case 1:
  1291. type = "Bronze bars";
  1292. break;
  1293. case 2:
  1294. type = "Iron bars";
  1295. break;
  1296. case 3:
  1297. type = "Silver bars";
  1298. break;
  1299. case 4:
  1300. type = "Steel bars";
  1301. break;
  1302. case 5:
  1303. type = "Gold bars";
  1304. break;
  1305. case 6:
  1306. type = "Mithril bars";
  1307. break;
  1308. case 7:
  1309. type = "Adamant bars";
  1310. break;
  1311. case 8:
  1312. type = "Rune bars";
  1313. break;
  1314. }
  1315. if(JewlChkB.isSelected()){
  1316. makeJewl = true;
  1317. S = 0;
  1318. if(smelting == 3){
  1319. jewel = silverCB.getSelectedIndex();
  1320. typeJ = silver[silverCB.getSelectedIndex()];
  1321. }else if(smelting == 5){
  1322. jewel = goldCB.getSelectedIndex() + 5;
  1323. typeJ = gold[goldCB.getSelectedIndex()];
  1324. }
  1325. }
  1326. logout = logOutChkB.isSelected();
  1327. goldsmith = goldSmithChkB.isSelected();
  1328. OPEN = false;
  1329. dispose();
  1330. }
  1331. }
  1332. static class StaminaChecker extends Thread implements Runnable {
  1333. private Point p = new Point(722,104);
  1334. private Color cOn = new Color (235,217,102);
  1335. private Color cOff = new Color (142,97,55);
  1336. private Point pfullStam = new Point(721,96);
  1337. private Color fullStam = new Color (94,86,71);
  1338. private static boolean staminaOff;
  1339. public static boolean staminaOff() {
  1340. return staminaOff;
  1341. }
  1342. public StaminaChecker() {
  1343. this.setPriority(MIN_PRIORITY);
  1344. }
  1345.  
  1346. @Override
  1347. public void run() {
  1348. try{
  1349. while (!Thread.interrupted()) {
  1350. if (!checkColor(cOn, p, 20)){
  1351. staminaOff = true;
  1352. walkmod = 2;
  1353. if(checkColor(fullStam, pfullStam, 20)){
  1354. staminaFull = true;
  1355. }
  1356. }else if (!checkColor(cOff, p, 20)){
  1357. staminaOff = false;
  1358. staminaFull = false;
  1359. walkmod = 1;
  1360. }
  1361. if(Thread.interrupted()) return;
  1362. }
  1363. } finally{}
  1364. }
  1365. }
  1366.  
  1367. /**
  1368. * Game tab enumeration.
  1369. */
  1370. public enum Tab {
  1371. COMBAT(0, new Rectangle(522, 170, 30, 33)),
  1372. TASKS(1, new Rectangle(552, 170, 30, 33)),
  1373. SKILLS(2, new Rectangle(582, 170, 30, 33)),
  1374. QUESTS(3, new Rectangle(612, 170, 30, 33)),
  1375. INVENTORY(4, new Rectangle(642, 170, 30, 33)),
  1376. EQUIPMENT(5, new Rectangle(672, 170, 30, 33)),
  1377. PRAYER(6, new Rectangle(702, 170, 30, 33)),
  1378. MAGIC(7, new Rectangle(732, 170, 30, 33)),
  1379. FRIEND_LIST(8, new Rectangle(552, 468, 30, 33)),
  1380. FRIENDS_CHAT(9, new Rectangle(582, 468, 30, 33)),
  1381. CLAN_CHAT(10, new Rectangle(612, 468, 30, 33)),
  1382. OPTIONS(11, new Rectangle(642, 467, 30, 33)),
  1383. EMOTES(12, new Rectangle(672, 468, 30, 33)),
  1384. MUSIC(13, new Rectangle(702, 467, 30, 33)),
  1385. NOTES(14, new Rectangle(732, 467, 30, 33));
  1386.  
  1387. private final int index;
  1388. private final Rectangle bounds;
  1389. public static final Color TAB_OPEN = new Color(254, 239, 114);
  1390.  
  1391. private Tab(final int index, final Rectangle bounds) {
  1392. this.index = index;
  1393. this.bounds = bounds;
  1394. }
  1395.  
  1396. /**
  1397. * Gets the tab index.
  1398. * @return The tab's index.
  1399. */
  1400. public int getIndex() {
  1401. return index;
  1402. }
  1403.  
  1404. /**
  1405. * Gets the tab bounds.
  1406. * @return The tab's bounds.
  1407. */
  1408. public Rectangle getBounds() {
  1409. return bounds;
  1410. }
  1411.  
  1412. /**
  1413. * Gets the tab's center point.
  1414. * @return The tab's center.
  1415. */
  1416. public Point getCenter() {
  1417. return new Point(bounds.x + (int) (bounds.width / 2), bounds.y + (int) (bounds.height / 2));
  1418. }
  1419.  
  1420. /**
  1421. * Gets the tab's color array.
  1422. * @return The colors of the tab.
  1423. */
  1424. public Color[] getColors() {
  1425. final List<Color> colors = new LinkedList<Color>();
  1426. for (int x = bounds.x; x < bounds.x + bounds.width; x++) {
  1427. for (int y = bounds.y; y < bounds.y + bounds.height; y++) {
  1428. final Point p = new Point(x, y);
  1429. colors.add(Colour.getColour(p));
  1430. }
  1431. }
  1432. return colors.toArray(new Color[colors.size()]);
  1433. }
  1434.  
  1435. /**
  1436. * Checks if the tab is open.
  1437. * @return <tt>true</tt> if open; otherwise <tt>false</tt>.
  1438. */
  1439. public boolean isOpen() {
  1440. for (final Color color : getColors()) {
  1441. if (color.equals(TAB_OPEN)) {
  1442. return true;
  1443. }
  1444. }
  1445. return false;
  1446. }
  1447.  
  1448. /**
  1449. * Opens the tab.
  1450. */
  1451. public void open() {
  1452. if (!isOpen()) {
  1453. General.clickMouse(getCenter(), 1, 6, 6);
  1454. }
  1455. }
  1456.  
  1457. }
  1458. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement