Advertisement
TheBat

1.11

Feb 26th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.17 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.Rectangle;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.MouseListener;
  9. import java.io.IOException;
  10. import java.net.URL;
  11. import java.util.List;
  12.  
  13. import javax.imageio.ImageIO;
  14.  
  15. import org.runedream.api.Script;
  16. import org.runedream.api.ScriptManifest;
  17. import org.runedream.api.methods.Bank;
  18. import org.runedream.api.methods.Camera;
  19. import org.runedream.api.methods.Game;
  20. import org.runedream.api.methods.ImageUtil;
  21. import org.runedream.api.methods.Mouse;
  22. import org.runedream.api.methods.OCR;
  23. import org.runedream.api.util.Log;
  24. import org.runedream.api.util.Random;
  25. import org.runedream.api.util.Timer;
  26. @ScriptManifest(
  27. authors = { "TheBat"},
  28. name = "BatCooker",
  29. version = 1.11,
  30. description = "Cooks shit at the rogues den.",
  31. keywords = {},
  32. language = { true, true, true, true })
  33.  
  34. public class BatCooker extends Script implements MouseListener{
  35.  
  36. final private static Color fire = new Color(203,125,35);
  37. final private static Color bankerF = new Color(108,124,55);
  38. final private static Color bankerB = new Color(30,41,23);
  39. final private static Rectangle viewPort = new Rectangle(4,4,513,335);
  40. private static String status = "";
  41. private static Image pic = null;
  42. private static Image back = null;
  43. private static long TIME = 0;
  44. private boolean showPaint = true;
  45. private int cooked = 0;
  46. private int row = 0;
  47. private int col = 0;
  48. private boolean first;
  49. Color temp = null;
  50. Color raw = null;
  51. private boolean getColor = true;
  52. private long cookTO = 0;
  53.  
  54. public boolean onStart(){
  55. TIME = System.currentTimeMillis();
  56. try {
  57. back = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/underPaint.png"));
  58. } catch (IOException e) {
  59. }
  60. try {
  61. pic = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/fire.png"));
  62. } catch (IOException e) {
  63. }
  64. status = "Finding banker";
  65. return true;
  66. }
  67.  
  68. public int loop() {
  69. if(System.currentTimeMillis() - TIME > 22320000){
  70. Log.log("Over 6 hours, you are probably Client token errored.", Color.RED);
  71. return 1;
  72. }
  73. Mouse.setSpeed(Random.random(6,12));
  74. if(status.equals("Finding banker")){
  75. Mouse.setSpeed(2);
  76. Point bankerPt = findBanker();
  77. if(bankerPt.x == -1){
  78. Mouse.move(Random.random(0,517),Random.random(0,339));
  79. if(Bank.isOpen()){
  80. status = "Banking";
  81. return 100;
  82. }
  83. Camera.rotateLeft(300);
  84. Camera.pitchDown(300);
  85. return 100;
  86. }
  87. Mouse.click(bankerPt, false);
  88. Script.sleep(100);
  89. String lol = OCR.findString(new Rectangle(bankerPt.x-200,bankerPt.y+30, 200,25), null);
  90. if(lol.contains("Bank") || lol.contains("ank") || lol.contains("nk") || lol.contains("Ba")
  91. || lol.contains("Ban") || lol.contains("an"))Mouse.click(bankerPt.x,bankerPt.y+46);
  92. else{
  93. Mouse.move(Random.random(0,517),Random.random(0,339));
  94. Camera.rotateLeft(300);
  95. Camera.pitchDown(300);
  96. return 100;
  97. }
  98. int i = 0;
  99. while(!Bank.isOpen() && i <= 40){
  100. Script.sleep(100);
  101. i++;
  102. }
  103. if(Bank.isOpen()){
  104. status = "Banking";
  105. }
  106. return 100;
  107. }
  108. if(status.equals("Banking")){
  109. if(Bank.isOpen()){
  110. if(getColor ){
  111. raw = Game.getColorAt(51,111);
  112. getColor = false;
  113. }
  114. int x = Random.random(50, 60);
  115. int y = Random.random(100, 110);
  116. Bank.depositAll();
  117. sleep(500,700);
  118. Mouse.click(x,y,false);
  119. sleep(500,700);
  120. Mouse.click(x, (y + Random.random(103,126)));
  121. sleep(500,700);
  122. Mouse.move(489,30);
  123. if(Mouse.getLocation()!= new Point(489,30)) Mouse.move(489,30);
  124. sleep(200,300);
  125. Mouse.click();
  126. sleep(100,200);
  127. Mouse.move(Random.random(0,765), Random.random(0,502));
  128. sleep(400,500);
  129. }
  130. status = "Finding banker";
  131. return 100;
  132. }
  133. if(status.equals("Finding fire")){
  134. if(Game.getColorAt(343,427).equals(new Color(89,81,68))){
  135. status = "Cooking";
  136. return 100;
  137. }
  138. if(Bank.isOpen()){
  139. status = "Banking";
  140. return 100;
  141. }
  142. Camera.pitchUp(300);
  143. sleep(100);
  144. Camera.rotateRight(300);
  145. Mouse.click(Random.random(567,587),Random.random(219,240));
  146. Mouse.setSpeed(2);
  147. Point firePt = findFire();
  148. sleep(300);
  149. if(firePt.x == -1)return 100;
  150. Mouse.click(firePt,false);
  151. sleep(200);
  152. boolean found = false;
  153. int k = 0;
  154. if(checkColor(Color.WHITE,new Point(firePt.x,firePt.y+72),4)){
  155. k = 1;
  156. found = true;
  157. }else{
  158. for(; k <= 12; k++){
  159. if(Game.getColorAt(343,427).equals(new Color(89,81,68))){
  160. status = "Cooking";
  161. return 100;
  162. }
  163. String lol = OCR.findString(new Rectangle(firePt.x-60,firePt.y+(17*k),350,21), null);
  164. Mouse.move(firePt.x,firePt.y+(17*k)+11);
  165. if(lol.contains("Fire")){
  166. found = true;
  167. break;
  168. }
  169. if(checkColor(Color.WHITE,new Point(firePt.x,firePt.y+((k + 1)*17)),4)){
  170. found = true;
  171. break;
  172. }
  173.  
  174. }
  175. }
  176. if(found)Mouse.click(firePt.x,firePt.y+(17*k)+11);
  177. else Mouse.click(Random.random(567,587),Random.random(219,240));
  178. sleep(1000);
  179. if(Game.getColorAt(343,427).equals(new Color(89,81,68)))status = "Cooking";
  180. row = 0;
  181. col = 0;
  182. first = true;
  183. return 100;
  184. }
  185.  
  186. if(status.equals("Cooking")){
  187. if(first){
  188. temp = Game.getColorAt(576+84 ,232);
  189. Mouse.click(Random.random(240,282),Random.random(405,455));
  190. first = false;
  191. cookTO = System.currentTimeMillis();
  192. }
  193. if(System.currentTimeMillis()- cookTO > 120000){
  194. status = "Finding banker";
  195. return 100;
  196. }
  197. if(!temp.equals(Game.getColorAt(576 + (col*42),232 + (row*36)))){
  198. col++;
  199. cooked++;
  200. if(col == 4){
  201. col = 0;
  202. row++;
  203. if(row == 7){
  204. status = "Finding banker";
  205. return 100;
  206. }
  207. }
  208. return 100;
  209. }
  210. return 100;
  211. }
  212.  
  213. return 100;
  214. }
  215. public void onRepaint(Graphics g){
  216. if(showPaint){
  217. g.drawImage(back, 5, 343, null);
  218. g.setColor(Color.BLACK);
  219. g.setFont(new Font("Salaryman", 1, 18));
  220. g.drawString("Time Running: " + Timer.getTime(System.currentTimeMillis() - TIME), 11, 365);
  221. g.drawString("Total Cooked: " + cooked ,11,390);
  222. g.drawString("Cooks/Hour: " + (3600000*(long)cooked)/(int)(System.currentTimeMillis() - TIME),11,415);
  223. g.drawString("Status: " + status ,11,440);
  224. g.drawImage(pic, 240, 300, null, null);
  225.  
  226. g.setFont(new Font("Salaryman", 1, 25));
  227. g.drawString("BatCooker",270,390);
  228. g.drawString("Version 1.11",265,420);
  229. g.setColor(Color.ORANGE);
  230. g.drawString("Ve",265,420);
  231.  
  232. g.setColor(Color.RED);
  233. g.drawString("x",500,360);
  234. }else{
  235. g.setColor(Color.GREEN);
  236. g.setFont(new Font("Salaryman", 1, 25));
  237. g.drawString("o",500,360);
  238. }
  239.  
  240. g.setColor(Color.CYAN);
  241. g.drawLine(Mouse.getLocation().x,0,Mouse.getLocation().x,2100);
  242. g.drawLine(0,Mouse.getLocation().y,2100,Mouse.getLocation().y);
  243. }
  244.  
  245. private static Point findBanker(){
  246. Point thePoint = new Point();
  247. List<Point> test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, bankerF,.05);
  248. try{
  249. if(test.size() < 1)throw new IllegalArgumentException();
  250. thePoint = test.get(Random.random(0,test.size()-1));
  251. }catch(IllegalArgumentException e){
  252. try{
  253. test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, bankerB,.02);
  254. if(test.size() < 1)throw new IllegalArgumentException();
  255. thePoint = test.get(Random.random(0,test.size()-1));
  256. }catch(IllegalArgumentException e2){
  257. thePoint = new Point(-1,-1);
  258. }
  259. }
  260. return thePoint;
  261. }
  262. private static Point findFire(){
  263. Point thePoint = new Point();
  264. List<Point> test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, fire,.05);
  265. try{
  266. if(test.size() < 1)throw new IllegalArgumentException();
  267. thePoint = test.get(Random.random(0,test.size()-1));
  268. }catch(IllegalArgumentException e){
  269. // try{
  270. // test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, bankerB,.02);
  271. // if(test.size() < 1)throw new IllegalArgumentException();
  272. // thePoint = test.get(Random.random(0,test.size()-1));
  273. // }catch(IllegalArgumentException e2){
  274. thePoint = new Point(-1,-1);
  275. // }
  276. }
  277. return thePoint;
  278. }
  279. /**
  280. * Returns whether the given point is a certain color.
  281. * Accounts for the variable colors that runescape produces whenever you log in.
  282. * @param col
  283. * - Color to check for.
  284. * @param p
  285. * - Point to check at.
  286. * @return
  287. */
  288. private boolean checkColor(Color col, Point p, int tol){
  289. if(Math.abs(col.getRed() - Game.getColorAt(p).getRed()) < tol)
  290. if(Math.abs(col.getGreen() - Game.getColorAt(p).getGreen()) < tol)
  291. if(Math.abs(col.getBlue() - Game.getColorAt(p).getBlue()) < tol)
  292. return true;
  293. return false;
  294. }
  295. /**
  296. * Mouse listener
  297. */
  298. public void mouseClicked(MouseEvent e) {
  299. Point pt = e.getPoint();
  300. if (pt.x >= 499 && pt.x <= 512 && pt.y >= 345 && pt.y <= 360) {
  301. showPaint = !showPaint;
  302. }
  303. }
  304. public void mouseEntered(MouseEvent arg0) {}
  305. public void mouseExited(MouseEvent arg0) {}
  306. public void mousePressed(MouseEvent arg0) {}
  307. public void mouseReleased(MouseEvent arg0) {}
  308. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement