Advertisement
TheBat

BatFireRunes

Feb 7th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.08 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Image;
  5. import java.awt.Point;
  6. import java.awt.event.MouseEvent;
  7. import java.awt.event.MouseListener;
  8. import java.io.IOException;
  9. import java.net.URL;
  10. import java.util.List;
  11. import javax.imageio.ImageIO;
  12. import org.runedream.api.Script;
  13. import org.runedream.api.ScriptManifest;
  14. import org.runedream.api.methods.Bank;
  15. import org.runedream.api.methods.Camera;
  16. import org.runedream.api.methods.Game;
  17. import org.runedream.api.methods.ImageUtil;
  18. import org.runedream.api.methods.Mouse;
  19. import org.runedream.api.util.Log;
  20. import org.runedream.api.util.Random;
  21.  
  22. @ScriptManifest(
  23. authors = { "TheBat"},
  24. name = "BatFireRunes",
  25. version = 0.9,
  26. description = "Crafts Fire Runes.",
  27. keywords = {},
  28. language = { true, true, true, true })
  29.  
  30. public class BatFireRunes extends Script implements MouseListener{
  31.  
  32. //color points for the runecrafting alter symbol
  33. private static final Color RCSA = new Color(246,183,1);
  34. private static final Color RCSB = new Color(89,84,84);
  35. private static final Point distRCS = new Point(2,-5);
  36.  
  37. //color points for the mysterious ruins
  38. private static final Color ChestA = new Color(108,104,104);
  39. private static final Color ChestB = new Color(98,94,94);
  40. private static final Color ChestC = new Color(89,86,85);
  41. private static final Point ChestAB = new Point(-21,-13);
  42. private static final Point ChestAC = new Point(-18,-35);
  43.  
  44. //color points for the bank symbol
  45. private static final Color tourchesA = new Color(215,121,50);
  46. private static final Color tourchesB = new Color(212,119,54);
  47. private static final Point tourchesAB = new Point(-282,-3);
  48.  
  49. //color points for the first walking spot
  50. private static final Color WS1A = new Color(70,53,17);
  51. private static final Color WS1B = new Color(234,243,243);
  52. private static final Point distWS1 = new Point(12,0);
  53.  
  54. //color points for the second walking spot
  55. private static final Color WS3A = new Color(74,109,58);
  56. private static final Color WS3B = new Color(71,53,22);
  57. private static final Point distWS3 = new Point(-9,3);
  58.  
  59. //color points for the mysterious ruins
  60. private static final Color MystRuinA = new Color(253,126,76);
  61. private static final Color MystRuinB = new Color(248,124,75);
  62. private static final Color MystRuinC = new Color(253,126,76);
  63. private static final Point MystRuinAB = new Point(-30,15);
  64. private static final Point MystRuinAC = new Point(-8,30);
  65.  
  66. //color points for the swords by the banker
  67. private static final Color SwordsA = new Color(185,183,27);
  68. private static final Color SwordsB = new Color(178,154,26);
  69. private static final Color SwordsC = new Color(186,184,27);
  70. private static final Point SwordsAB = new Point(8,-10);
  71. private static final Point SwordsAC = new Point(-1,-7);
  72.  
  73. //color points for the exit portal
  74. private static final Color portA = new Color(170,49,28);
  75. private static final Color portB = new Color(196,49,29);
  76. private static final Color portC = new Color(175,49,29);
  77. private static final Point portAB = new Point(-12,-22);
  78. private static final Point portAC = new Point(-26,-5);
  79.  
  80.  
  81. //Class variables
  82. private static int RUNS = 0;
  83. private static double TIME = 0;
  84. private static Image pic = null;
  85. private static String status = "";
  86. private StaminaChecker staminaCheck = new StaminaChecker();
  87. public static int walkmod = 1;
  88. public static int levelGained = 0;
  89. private boolean showPaint = true;
  90.  
  91. private Point pt3 = new Point();
  92. private Point pt4 = new Point();
  93.  
  94. private int templvls = levelGained;
  95. private boolean first = false;
  96. private LevelUpCheck levelUpCheck = new LevelUpCheck();
  97. /**
  98. * Actions to be performed when the script starts up.
  99. */
  100. public boolean onStart(){
  101. try {
  102. pic = ImageIO.read(new URL("http://i1024.photobucket.com/albums/y308/dudebrosick/Fire_rune_detail.png"));
  103. } catch (IOException e) {
  104. }
  105. Mouse.setSpeed(Random.random(8, 11));
  106. TIME = System.currentTimeMillis();
  107. Game.clickCompass();
  108. Camera.pitchUp(1000);
  109. if (!Game.getOpenTab().equals("Inventory")) {
  110. Mouse.click(Random.random(642, 670), Random.random(170, 200)); //returns to inventory tab
  111. }
  112. staminaCheck.start();
  113. status = "Finding bank";
  114. return true;
  115. }
  116. /**
  117. * The main loop
  118. */
  119. public int loop() {
  120. Mouse.setSpeed(Random.random(6, 9));
  121. if(status.equals("Crafting runes")){
  122. levelUpCheck = new LevelUpCheck();
  123. }
  124. double timeOut = 0;
  125. double timeOut1 = 0;
  126. if(status.equals("Finding bank")){
  127. timeOut = System.currentTimeMillis();
  128. while(!bankIsOpen()){
  129. if(first){
  130. if(Random.random(0, 10) <= 1){
  131. status = "Antiban";
  132. antiban();
  133. first = false;
  134. return 1000;
  135. }
  136. }
  137. int trys = 0;
  138. while((pt3 = findItemThreePoint(SwordsA, SwordsB, SwordsC, SwordsAB, SwordsAC, 20, new Point(3,3), new Point(512,332))).equals(new Point(-1,-1))){
  139. sleep(600,700);
  140. if(trys==3){
  141. int x = Random.random(256,270);
  142. int y = Random.random(136,150);
  143. Mouse.click(x,y);
  144. sleep(500,600);
  145. if(checkColor(new Color (28,28,28), new Point(x,y), 10)){
  146. Mouse.click(x,y+ Random.random(21,32));
  147. }
  148. trys = 3;
  149. return 1000;
  150. }
  151. trys++;
  152. if(System.currentTimeMillis() - timeOut > 9000)return 1000;
  153. }
  154. timeOut = System.currentTimeMillis();
  155. while((pt4 = findItemThreePoint(ChestA, ChestB, ChestC, ChestAB, ChestAC, 20, new Point(pt3.x-15,pt3.y), new Point(pt3.x+35,pt3.y+70))).equals(new Point(-1,-1))){
  156. sleep(walkmod * 800,walkmod * 1000);
  157. if(System.currentTimeMillis() - timeOut > 9000)return 1000;
  158. }
  159. timeOut1 = System.currentTimeMillis();
  160. if(!bankIsOpen()){
  161. Mouse.click(pt4.x+10,pt4.y+10);
  162. sleep(400,500);
  163. }else
  164. break;
  165. if(!bankIsOpen()){
  166. Mouse.click(pt4.x+10, (pt4.y+10 + Random.random(21,32)));
  167. sleep(100,200);
  168. Mouse.move(Random.random(0,765), Random.random(0,502));
  169. sleep(walkmod * 900,walkmod * 1000);
  170. }else
  171. break;
  172. sleep(2000);
  173. if(System.currentTimeMillis() - timeOut1 > 9000)return 1000;
  174. }
  175. first = true;
  176. status = "Banking";
  177. return 1000;
  178. }
  179. if(status.equals("Banking")){
  180. if(bankIsOpen()){
  181. int x = Random.random(50, 60);
  182. int y = Random.random(100, 110);
  183. Bank.depositAll();
  184. sleep(500,700);
  185. Mouse.click(x,y);
  186. sleep(500,700);
  187. Mouse.click(x, (y + Random.random(103,126)));
  188. sleep(500,700);
  189. Mouse.move(489,30);
  190. if(Mouse.getLocation()!= new Point(489,30)) Mouse.move(489,30);
  191. sleep(200,300);
  192. Mouse.click();
  193. sleep(100,200);
  194. Mouse.move(Random.random(0,765), Random.random(0,502));
  195. sleep(400,500);
  196. }
  197. status = "Walking to ruins";
  198. return 1000;
  199. }
  200. if(status.equals("Walking to ruins")){
  201. // walks until it finds the RC symbol
  202. Point pt4 = new Point();
  203. timeOut = System.currentTimeMillis();
  204. while((pt4 = findItemTwoPoint(RCSA, RCSB, distRCS, 4, new Point(522,3), new Point(705,164))).equals(new Point(-1,-1))){
  205. Mouse.click(Random.random(560,590),Random.random(81,88));
  206. sleep(walkmod * 1000, walkmod * 1200);
  207. if(System.currentTimeMillis() - timeOut > walkmod * 36000)return 1000;
  208. }
  209. Mouse.click(pt4);
  210. sleep(100,200);
  211. Mouse.move(Random.random(0,765), Random.random(0,502));
  212. sleep(walkmod * 2000);
  213. Mouse.move(Random.random(0,765), Random.random(0,502));
  214. //AntiBan
  215. if(Random.random(0, 10) <= 5)
  216. Camera.rotateLeft(Random.random(500,1200));
  217. else
  218. Camera.rotateRight(Random.random(500,1200));
  219. Mouse.move(Random.random(0,765), Random.random(0,502));
  220. sleep(walkmod * 5000);
  221. Mouse.move(Random.random(0,765), Random.random(0,502));
  222. sleep(walkmod * 3000);
  223. Mouse.move(Random.random(0,765), Random.random(0,502));
  224. sleep(walkmod * 4000);
  225. Mouse.move(Random.random(0,765), Random.random(0,502));
  226. status = "Entering ruins";
  227. return 1000;
  228. }
  229. if(status.equals("Entering ruins")){
  230. //Enters ruins
  231. int trys = 0;
  232. Point pt1 = new Point();
  233. timeOut = System.currentTimeMillis();
  234. timeOut1 = System.currentTimeMillis();
  235.  
  236. while((pt1 = findItemThreePoint(MystRuinA, MystRuinB, MystRuinC, MystRuinAB, MystRuinAC, 4)).equals(new Point(-1,-1))){
  237. sleep(200,300);
  238. if(trys == 3){
  239. Point pn = findItemTwoPoint(RCSA, RCSB, distRCS, 4, new Point(522,3), new Point(705,164));
  240. Mouse.click(pn.x +2, pn.y);
  241. if(Random.random(0, 10) <= 5)
  242. Camera.rotateLeft(Random.random(500,1200));
  243. else
  244. Camera.rotateRight(Random.random(500,1200));
  245. }
  246. trys++;
  247. if(System.currentTimeMillis() - timeOut > 9000)return 1000;
  248. }
  249. sleep(200,300);
  250. Mouse.click(pt1);
  251. sleep(400,500);
  252. Mouse.click(pt1.x, (pt1.y + Random.random(21,32)));
  253. sleep(100,200);
  254. Mouse.move(Random.random(0,765), Random.random(0,502));
  255. sleep(3000,4000);
  256. boolean portFound = false;
  257.  
  258. for(int i = 0;i < 25;i++){
  259. if(!(findItemTwoPoint(portA, portB, portAB, 10, new Point(3,3), new Point(512,332)).equals(new Point(-1,-1)))) {
  260. portFound = true;
  261. break;
  262. }
  263. sleep(2);
  264. }
  265.  
  266. if(portFound)status = "Crafting runes";
  267. return 1000;
  268. }
  269.  
  270. if(status.equals("Crafting runes")){
  271. Game.clickCompass();
  272. Camera.pitchUp(700);
  273. Mouse.click(658,117);
  274. //Mouse.click(653, 114);
  275. sleep(100,200);
  276. Mouse.move(Random.random(0,765), Random.random(0,502));
  277. sleep(walkmod * 4000,walkmod * 4200);
  278. Point pt = new Point (336,199);
  279. timeOut = System.currentTimeMillis();
  280. while((pt = findItemTwoPoint(tourchesA, tourchesB, tourchesAB, 20, new Point(3,3), new Point(512,332))).equals(new Point(-1,-1))){
  281. if(System.currentTimeMillis() - timeOut > walkmod * 36000)return 1000;
  282. }
  283. pt = new Point (pt.x,pt.y+20);
  284. Mouse.click(pt);
  285. sleep(400,500);
  286. levelUpCheck.start();
  287. Mouse.click(pt.x,pt.y + Random.random(21,32));
  288. sleep(100,200);
  289. Mouse.move(Random.random(0,765), Random.random(0,502));
  290. sleep(3000);
  291. status = "Exiting ruins";
  292. return 1000;
  293. }
  294.  
  295. if(status.equals("Exiting ruins")){
  296. Mouse.click(Random.random(587,609), Random.random(55,72));
  297. sleep(walkmod * 4500);
  298. Point pt2 = new Point();
  299. while((pt2 = findItemThreePoint(portA, portB, portC, portAB, portAC, 4)).equals(new Point(-1,-1))){
  300. }
  301. sleep(200,300);
  302. Mouse.click(pt2);
  303. sleep(400,500);
  304. Mouse.click(pt2.x, (pt2.y + Random.random(21,32)));
  305. sleep(100,200);
  306. Mouse.move(Random.random(0,765), Random.random(0,502));
  307. sleep(4000);
  308. try{
  309. levelUpCheck.interrupt();
  310. }catch(IllegalThreadStateException e){}
  311. //Antiban => checks levels if you get a lvl up.
  312. if(templvls < levelGained){
  313. status = "Checking new Abilities";
  314. Mouse.click(Random.random(590, 604),Random.random(177, 196));
  315. sleep(300,500);
  316. int x = Random.random(560, 600);
  317. int y = Random.random(385, 397);
  318. Mouse.click(x,y);
  319. sleep(300,500);
  320. Mouse.click(x,y + Random.random(21,32));
  321. sleep(400,500);
  322. Mouse.click(Random.random(216, 715),Random.random(128, 435));
  323. sleep(600,1000);
  324. Mouse.scroll(Random.random(7,12), false);
  325. sleep(100,200);
  326. Mouse.move(Random.random(0,765), Random.random(0,502));
  327. sleep(1000,2000);
  328. Mouse.move(Random.random(0,765), Random.random(0,502));
  329. sleep(100,200);
  330. Mouse.move(Random.random(0,765), Random.random(0,502));
  331. sleep(3000,5000);
  332. Mouse.click(Random.random(740, 743),Random.random(20, 24));
  333. sleep(300,500);
  334. Mouse.click(Random.random(642, 670), Random.random(170, 200)); //returns to inventory tab
  335. }
  336.  
  337. boolean ruins = false;
  338. for(int i = 0;i < 25;i++){
  339. if(!(findItemTwoPoint(MystRuinA, MystRuinB, MystRuinAB, 4, new Point(3,3), new Point(512,332)).equals(new Point(-1,-1)))) {
  340. ruins = true;
  341. break;
  342. }
  343. sleep(2);
  344. }
  345. if(ruins)status = "Walking back";
  346. return 1000;
  347. }
  348.  
  349. if(status.equals("Walking back")){
  350. Point lp = findItemTwoPoint(WS1A, WS1B, distWS1, 5, new Point(522,3), new Point(705,164));
  351. Mouse.click(lp.x+2,lp.y);
  352. sleep(100,200);
  353. Mouse.move(Random.random(0,765), Random.random(0,502));
  354. sleep(walkmod * 3000);
  355. sleep(100,200);
  356. Mouse.move(Random.random(0,765), Random.random(0,502));
  357. sleep(walkmod * 2000);
  358. sleep(100,200);
  359. Mouse.move(Random.random(0,765), Random.random(0,502));
  360. sleep(walkmod * 5000);
  361. sleep(100,200);
  362. Mouse.move(Random.random(0,765), Random.random(0,502));
  363. sleep(walkmod * 3000);
  364. Point pt5 = findItemTwoPoint(WS3A, WS3B, distWS3, 5, new Point(522,3), new Point(705,164));
  365. Mouse.click(pt5.x+Random.random(10, 35),pt5.y-Random.random(5, 7));
  366. sleep(300,400);
  367. Mouse.move(Random.random(0,765), Random.random(0,502));
  368. sleep(walkmod * 6500);
  369. int i = 0;
  370. while(i<13){
  371. Mouse.click(670,87);
  372. sleep(walkmod * 1000, walkmod * 1100);
  373. i++;
  374. }
  375. sleep(3000);
  376. RUNS++;
  377. status = "Finding bank";
  378. }
  379. return 1000;
  380. }
  381.  
  382. /**
  383. * Performs actions that are "human-like"
  384. */
  385. private void antiban() {
  386. if(!bankIsOpen()){
  387. if(Random.random(0, 10) <= 5){
  388. status = "Checking stats";
  389. if(!bankIsOpen()){
  390. Mouse.click(Random.random(590, 604),Random.random(177, 196));
  391. sleep(300,500);
  392. }
  393. int x = Random.random(556, 729);
  394. int y = Random.random(214, 428);
  395. if(!bankIsOpen()){
  396. Mouse.click(x,y);
  397. sleep(300,500);
  398. }
  399. if(!bankIsOpen()){
  400. Mouse.click(x,y + Random.random(21,32));
  401. sleep(400,500);
  402. }
  403. if(!bankIsOpen()){
  404. Mouse.click(Random.random(216, 715),Random.random(128, 435));
  405. sleep(600,1000);
  406. }
  407. if(!bankIsOpen()){
  408. Mouse.scroll(Random.random(7,12), false);
  409. sleep(3000,5000);
  410. }
  411. if(!bankIsOpen()){
  412. Mouse.click(Random.random(740, 743),Random.random(20, 24));
  413. sleep(300,500);
  414. }
  415. }else if(Random.random(0, 10) > 5){
  416. status = "Checking Friends";
  417. if(!bankIsOpen()){
  418. Mouse.click(Random.random(558, 575),Random.random(473, 498));
  419. sleep(300,500);
  420. }
  421. int x = Random.random(556, 729);
  422. int y = Random.random(214, 428);
  423. if(!bankIsOpen()){
  424. Mouse.move(x,y);
  425. sleep(1000,1500);
  426. }
  427.  
  428. }
  429. Mouse.click(Random.random(642, 670), Random.random(170, 200));
  430. }
  431. status = "Finding bank";
  432. }
  433. /**
  434. * The actions performed when the script stops.
  435. */
  436. public void onStop(){
  437. staminaCheck.interrupt();
  438. Log.log("Thanks for using BatFireRunes!");
  439. Log.log("Total runtime of: " + getTime(System.currentTimeMillis() - TIME));
  440. Log.log("You completed " + RUNS + " runs.");
  441. }
  442.  
  443. /**
  444. * The paint.
  445. */
  446. public void onRepaint(Graphics g){
  447. if(showPaint){
  448. g.setColor(new Color(203,186,153));
  449. g.fillRect(7,345,505,128);
  450. g.setColor(Color.BLACK);
  451. g.drawString("Time Running : " + getTime(System.currentTimeMillis() - TIME), 11, 360);
  452. g.drawString("Total Runs: " + RUNS ,11,380);
  453. g.drawString("Runs/Hour: " + (int)((double)(RUNS*3600000)/(System.currentTimeMillis() - TIME)),11,400);
  454. g.drawString("Levels Gained: " + levelGained ,11,420);
  455. g.drawString("Status: " + status ,11,440);
  456. if(!staminaCheck.staminaOff()){
  457. g.setColor(Color.GREEN);
  458. g.drawString("Running", 11,460);
  459. }else {
  460. g.setColor(Color.RED);
  461. g.drawString("Walking", 11,460);
  462. walkmod = 2;
  463. }
  464. g.setColor(Color.BLACK);
  465. g.setFont(new Font("Salaryman", 1, 25));
  466. g.drawImage(pic, 270, 370, null, null);
  467. g.drawString("Version Beta 0.9",220,380);
  468. g.drawString("BatFireRunes",230,440);
  469. g.setColor(Color.RED);
  470. g.drawString("x",500,360);
  471. }else{
  472. g.setColor(Color.GREEN);
  473. g.setFont(new Font("Salaryman", 1, 25));
  474. g.drawString("o",500,360);
  475. }
  476. g.setColor(Color.RED);
  477. g.drawLine(Mouse.getLocation().x,0,Mouse.getLocation().x,2100);
  478. g.drawLine(0,Mouse.getLocation().y,2100,Mouse.getLocation().y);
  479. }
  480.  
  481. /**
  482. * This is a time display method from jaanu22
  483. *
  484. * @param millis
  485. * - Give it the current counter time in milliseconds.
  486. * @return
  487. * - Returns the time in a more readable format
  488. */
  489. private static String getTime(double millis){
  490. double time = millis / 1000;
  491. String seconds = Integer.toString((int) (time % 60));
  492. String minutes = Integer.toString((int) ((time % 3600) / 60));
  493. String hours = Integer.toString((int) (time / 3600));
  494. for (int i = 0; i < 2; i++)
  495. {
  496. if (seconds.length() < 2)
  497. {
  498. seconds = "0" + seconds;
  499. }
  500. if (minutes.length() < 2)
  501. {
  502. minutes = "0" + minutes;
  503. }
  504. if (hours.length() < 2)
  505. {
  506. hours = "0" + hours;
  507. }
  508. }
  509. return hours + ":" + minutes + ":" + seconds;
  510. }
  511. /**
  512. * Checks if the bank is open.
  513. *
  514. * @return boolean
  515. * - true if the bank is open
  516. * - false if the bank is open
  517. */
  518. private boolean bankIsOpen() {
  519. sleep(200,300);
  520. if(checkColor(new Color(242,170,62), new Point(198,30), 20) && checkColor(new Color(130,77,30), new Point(374,313), 20))return true;
  521. else return false;
  522. }
  523. /**
  524. * Logs you out.
  525. */
  526. private void logOut(){
  527. Mouse.click(Random.random(758,784),Random.random(4,15));
  528. sleep(Random.random(500,700));
  529. Mouse.click(Random.random(576,708),Random.random(355,372));
  530. sleep(Random.random(500,700));
  531. }
  532. /**
  533. * Return the center point between two points of color, indicating where the desire object is.
  534. * Returns (-1,-1) if the point is not found.
  535. *
  536. * @param col1
  537. * - The color value of a point on object.
  538. * @param col2
  539. * - The color value of a point on object.
  540. * @param p
  541. * - the distance x and y between the two points of color.
  542. * @return
  543. */
  544. private Point findItemTwoPoint(Color col1, Color col2, Point p, int tolerance){
  545. Point out = new Point(0,0);
  546. List<Point> test1 = ImageUtil.getPointsWithColor(Game.getImage(), col1,.05);
  547. List<Point> test2 = ImageUtil.getPointsWithColor(Game.getImage(), col2,.05);
  548. boolean breakable = false;
  549. boolean pointFound = false;
  550. for(int i = 0;i < test1.size();i++){
  551. for(int j = 0;j < test2.size();j++){
  552. if(Math.abs(test1.get(i).x - test2.get(j).x - p.x) < tolerance){
  553. if(Math.abs(test1.get(i).y - test2.get(j).y - p.y) < tolerance){
  554. out = new Point((int)((test1.get(i).x + test2.get(j).x)/2),
  555. (int)((test1.get(i).y + test2.get(j).y)/2));
  556. pointFound = true;
  557. breakable = true;
  558. break;
  559.  
  560. }
  561. }
  562. }
  563. if(breakable)break;
  564. }
  565. if(pointFound)return out;
  566. else return new Point(-1,-1);
  567. }
  568.  
  569. /**
  570. * This works with bounds
  571. * Return the center point between two points of color, indicating where the desire object is.
  572. * Returns (-1,-1) if the point is not found.
  573. *
  574. *
  575. * @param col1
  576. * - The color value of a point on object.
  577. * @param col2
  578. * - The color value of a point on object.
  579. * @param p
  580. * - the distance x and y between the two points of color.
  581. * @param TL
  582. * - The top left bound
  583. * @param BR
  584. * - The bottom right bound
  585. * @return
  586. */
  587.  
  588. private Point findItemTwoPoint(Color col1, Color col2, Point p, int tolerance, Point TL, Point BR){
  589. Point out = new Point(0,0);
  590. List<Point> test1 = ImageUtil.getPointsWithColor(Game.getImage(), col1,.05);
  591. List<Point> test2 = ImageUtil.getPointsWithColor(Game.getImage(), col2,.05);
  592. boolean breakable = false;
  593. boolean pointFound = false;
  594. for(int i = 0;i < test1.size();i++){
  595. if((test1.get(i).x > TL.x) && (test1.get(i).y > TL.y)){
  596. if((test1.get(i).x < BR.x) && (test1.get(i).y < BR.y)){
  597. for(int j = 0;j < test2.size();j++){
  598. if((test2.get(j).x > TL.x) && (test2.get(j).y > TL.y)){
  599. if((test2.get(j).x < BR.x) && (test2.get(j).y < BR.y)){
  600. if(Math.abs(test1.get(i).x - test2.get(j).x - p.x) < tolerance){
  601. if(Math.abs(test1.get(i).y - test2.get(j).y - p.y) < tolerance){
  602. out = new Point((int)((test1.get(i).x + test2.get(j).x)/2),
  603. (int)((test1.get(i).y + test2.get(j).y)/2));
  604. pointFound = true;
  605. breakable = true;
  606. break;
  607. }
  608. }
  609. }
  610. }
  611. }
  612. }
  613. }
  614. if(breakable)break;
  615. }
  616. if(pointFound)return out;
  617. else return new Point(-1,-1);
  618. }
  619.  
  620.  
  621. /**
  622. * This works with bounds
  623. * Return the center point of a triangle, indicating where the desire object is.
  624. * Returns (-1,-1) if the point is not found.
  625. *
  626. * @param col1
  627. * - The color of the first point
  628. * @param col2
  629. * - The color of the second point
  630. * @param col3
  631. * - The color of the third point
  632. * @param p1
  633. * - The distance between point 1 and point 2
  634. * @param p2
  635. * - The distance between point 1 and point 3
  636. * @param tolerance
  637. * - The distance tolerance in pixels
  638. *
  639. * @return Point the point
  640. */
  641. private Point findItemThreePoint(Color col1, Color col2, Color col3, Point p1, Point p2, int tolerance){
  642. Point out = new Point();
  643. Point pt2 = new Point();
  644. Point pt1 = findItemTwoPoint(col1,col2, p1, tolerance);
  645. if(!pt1.equals(new Point (-1,-1))){
  646. pt2 = findItemTwoPoint(col1,col3, p2, tolerance);
  647. if(!pt2.equals(new Point (-1,-1))){
  648. out = new Point((int)((pt1.x + pt2.x)/2),
  649. (int)((pt1.y + pt2.y)/2));
  650. }else return new Point (-1,-1);
  651. }else return new Point (-1,-1);
  652. return out;
  653. }
  654. /**
  655. * This works with bounds
  656. * Return the center point of a triangle, indicating where the desire object is.
  657. * Returns (-1,-1) if the point is not found.
  658. *
  659. * @param col1
  660. * - The color of the first point
  661. * @param col2
  662. * - The color of the second point
  663. * @param col3
  664. * - The color of the third point
  665. * @param p1
  666. * - The distance between point 1 and point 2
  667. * @param p2
  668. * - The distance between point 1 and point 3
  669. * @param tolerance
  670. * - The distance tolerance in pixels
  671. * @param TL
  672. * - The top left corner of the bounds
  673. * @param BR
  674. * - The bottom right corner of the bounds
  675. *
  676. * @return Point the point
  677. */
  678. private Point findItemThreePoint(Color col1, Color col2, Color col3, Point p1, Point p2, int tolerance, Point TL, Point BR){
  679. Point out = new Point();
  680. Point pt2 = new Point();
  681. Point pt1 = findItemTwoPoint(col1,col2, p1, tolerance, TL, BR);
  682. if(!pt1.equals(new Point (-1,-1))){
  683. pt2 = findItemTwoPoint(col1,col3, p2, tolerance,TL, BR);
  684. if(!pt2.equals(new Point (-1,-1))){
  685. out = new Point((int)((pt1.x + pt2.x)/2),
  686. (int)((pt1.y + pt2.y)/2));
  687. }else return new Point (-1,-1);
  688. }else return new Point (-1,-1);
  689. return out;
  690. }
  691.  
  692. /**
  693. * Returns whether the given point is a certain color.
  694. * Accounts for the variable colors that runescape produces whenever you log in.
  695. * @param col
  696. * - Color to check for.
  697. * @param p
  698. * - Point to check at.
  699. * @return
  700. */
  701. private boolean checkColor(Color col, Point p, int tol){
  702. if(Math.abs(col.getRed() - Game.getColorAt(p).getRed()) < tol)
  703. if(Math.abs(col.getGreen() - Game.getColorAt(p).getGreen()) < tol)
  704. if(Math.abs(col.getBlue() - Game.getColorAt(p).getBlue()) < tol)
  705. return true;
  706. return false;
  707. }
  708.  
  709.  
  710.  
  711. /**
  712. * Mouse listener
  713. */
  714. public void mouseClicked(MouseEvent e) {
  715. Point pt = e.getPoint();
  716. if (pt.x >= 499 && pt.x <= 512 && pt.y >= 345 && pt.y <= 360) {
  717. showPaint = !showPaint;
  718. }
  719.  
  720. }
  721. public void mouseEntered(MouseEvent arg0) {}
  722. public void mouseExited(MouseEvent arg0) {}
  723. public void mousePressed(MouseEvent arg0) {}
  724. public void mouseReleased(MouseEvent arg0) {}
  725. }//Ends BatFireRune class.
  726.  
  727.  
  728. class StaminaChecker extends Thread implements Runnable {
  729. private Point p = new Point(722,104);
  730. private Color cOn = new Color (235,217,102);
  731. private Color cOff = new Color (142,97,55);
  732. private Point pfullStam = new Point(721,96);
  733. private Color fullStam = new Color (94,86,71);
  734. private boolean staminaOff;
  735. public boolean staminaOff() {
  736. return this.staminaOff;
  737. }
  738. public StaminaChecker() {
  739. this.setPriority(MIN_PRIORITY);
  740. }
  741.  
  742. @Override
  743. public void run() {
  744. try{
  745. while (!Thread.interrupted()) {
  746. if (!checkColor(cOn, p, 20)){
  747. staminaOff = true;
  748. BatFireRunes.walkmod = 2;
  749. if(checkColor(fullStam, pfullStam, 20)){
  750. int x = 0;
  751. int y = 0;
  752. BatFireRunes.sleep(600);
  753. Mouse.click((x = pfullStam.x+Random.random(-3,5)),(y = pfullStam.y+Random.random(3,25)));
  754. try {
  755. sleep(400,500);
  756. } catch (InterruptedException e) {
  757. }
  758. Mouse.click(x, (y + Random.random(21,32)));
  759. BatFireRunes.walkmod = 1;
  760. }
  761. }else if (!checkColor(cOff, p, 20)){
  762. staminaOff = false;
  763. BatFireRunes.walkmod = 1;
  764. }
  765. if(Thread.interrupted()) return;
  766. }
  767. } finally{}
  768. }
  769.  
  770. /**
  771. * Returns whether the given point is a certain color.
  772. * Accounts for the variable colors that runescape produces whenever you log in.
  773. * @param col
  774. * - Color to check for.
  775. * @param p
  776. * - Point to check at.
  777. * @return
  778. */
  779. private boolean checkColor(Color col, Point p, int tol){
  780. if(Math.abs(col.getRed() - Game.getColorAt(p).getRed()) < tol)
  781. if(Math.abs(col.getGreen() - Game.getColorAt(p).getGreen()) < tol)
  782. if(Math.abs(col.getBlue() - Game.getColorAt(p).getBlue()) < tol)
  783. return true;
  784. return false;
  785. }
  786. }
  787.  
  788. class LevelUpCheck extends Thread implements Runnable {
  789. private Point ptB = new Point(271,92);
  790. private Color ptBC = new Color (5,4,4);
  791.  
  792. public LevelUpCheck() {
  793. this.setPriority(MIN_PRIORITY);
  794. }
  795.  
  796. @Override
  797. public void run() {
  798. try{
  799. while (!Thread.interrupted()) {
  800. if(checkColor(ptBC, ptB, 10)){
  801. BatFireRunes.levelGained++;
  802. return;
  803. }
  804. if(Thread.interrupted()) return;
  805. }
  806. } finally{}
  807. }
  808.  
  809. /**
  810. * Returns whether the given point is a certain color.
  811. * Accounts for the variable colors that runescape produces whenever you log in.
  812. * @param col
  813. * - Color to check for.
  814. * @param p
  815. * - Point to check at.
  816. * @return
  817. */
  818. private boolean checkColor(Color col, Point p, int tol){
  819. if(Math.abs(col.getRed() - Game.getColorAt(p).getRed()) < tol)
  820. if(Math.abs(col.getGreen() - Game.getColorAt(p).getGreen()) < tol)
  821. if(Math.abs(col.getBlue() - Game.getColorAt(p).getBlue()) < tol)
  822. return true;
  823. return false;
  824. }
  825. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement