Created
April 17, 2012 00:32
-
-
Save TheBatScripts/2402551 to your computer and use it in GitHub Desktop.
BatCooker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.Color; | |
| import java.awt.Font; | |
| import java.awt.Graphics; | |
| import java.awt.Image; | |
| import java.awt.Point; | |
| import java.awt.Rectangle; | |
| import java.awt.event.MouseEvent; | |
| import java.awt.event.MouseListener; | |
| import java.io.IOException; | |
| import java.net.URL; | |
| import java.util.List; | |
| import javax.imageio.ImageIO; | |
| import org.runedream.api.Script; | |
| import org.runedream.api.ScriptManifest; | |
| import org.runedream.api.methods.Bank; | |
| import org.runedream.api.methods.Camera; | |
| import org.runedream.api.methods.Game; | |
| import org.runedream.api.methods.ImageUtil; | |
| import org.runedream.api.methods.Mouse; | |
| import org.runedream.api.methods.OCR; | |
| import org.runedream.api.util.Log; | |
| import org.runedream.api.util.Random; | |
| import org.runedream.api.util.Time; | |
| import org.runedream.api.wrappers.Menu; | |
| @ScriptManifest( | |
| authors = { "TheBat"}, | |
| name = "BatCooker", | |
| version = 1.31, | |
| description = "Cooks shit at the rogues den.", | |
| keywords = {}, | |
| language = { true, true, true, true }) | |
| public class BatCooker extends Script implements MouseListener{ | |
| final private static Color fire = new Color(203,125,35); | |
| final private static Color bankerF = new Color(108,124,55); | |
| final private static Color bankerB = new Color(30,41,23); | |
| final private static Rectangle viewPort = new Rectangle(4,4,513,335); | |
| private static String status = ""; | |
| private static Image pic = null; | |
| private static Image back = null; | |
| private static long TIME = 0; | |
| private boolean showPaint = true; | |
| private int cooked = 0; | |
| private int burned = 0; | |
| private int row = 0; | |
| private int col = 0; | |
| private boolean first; | |
| Menu menu; | |
| private Color temp0 = null; | |
| private Color temp1 = null; | |
| private Color temp2 = null; | |
| private Color raw = null; | |
| private long cookTO = 0; | |
| private boolean checkCooked = true; | |
| private Color notB0 = null; | |
| private Color notB1 = null; | |
| private Color notB2 = null; | |
| public boolean onStart(){ | |
| TIME = System.currentTimeMillis(); | |
| try { | |
| back = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/underPaint.png")); | |
| } catch (IOException e) { | |
| } | |
| try { | |
| pic = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/fire.png")); | |
| } catch (IOException e) { | |
| } | |
| status = "Finding banker"; | |
| return true; | |
| } | |
| public int loop() { | |
| if(System.currentTimeMillis() - TIME > 22320000){ | |
| Log.log("Over 6 hours, you are probably Client token errored.", Color.RED); | |
| return -1; | |
| } | |
| Mouse.setSpeed(Random.random(6,12)); | |
| if(status.equals("Finding banker")){ | |
| Mouse.setSpeed(2); | |
| Point bankerPt = findBanker(); | |
| if(bankerPt.x == -1){ | |
| Mouse.move(Random.random(0,517),Random.random(0,339)); | |
| if(Bank.isOpen()){ | |
| status = "Banking"; | |
| return 100; | |
| } | |
| Camera.rotateLeft(300); | |
| Camera.pitchDown(300); | |
| return 100; | |
| } | |
| Mouse.click(bankerPt, false); | |
| Time.sleep(100); | |
| try{ | |
| String lol = OCR.findString(new Rectangle(bankerPt.x-200,bankerPt.y+30, 200,25), null, true); | |
| if(lol.contains("Bank") || lol.contains("ank") || lol.contains("nk") || lol.contains("Ba") | |
| || lol.contains("Ban") || lol.contains("an"))Mouse.click(bankerPt.x,bankerPt.y+46); | |
| else{ | |
| Mouse.move(Random.random(0,517),Random.random(0,339)); | |
| Camera.rotateLeft(300); | |
| Camera.pitchDown(300); | |
| return 100; | |
| } | |
| }catch(NullPointerException e){ | |
| e.printStackTrace(); | |
| Mouse.move(Random.random(0,517),Random.random(0,339)); | |
| Camera.rotateLeft(300); | |
| Camera.pitchDown(300); | |
| return 100; | |
| } | |
| int i = 0; | |
| while(!Bank.isOpen() && i <= 40){ | |
| Time.sleep(100); | |
| i++; | |
| } | |
| if(Bank.isOpen()){ | |
| status = "Banking"; | |
| } | |
| return 100; | |
| } | |
| if(status.equals("Banking")){ | |
| if(Bank.isOpen()){ | |
| raw = Game.getColorAt(45,111); | |
| int x = Random.random(50, 60); | |
| int y = Random.random(100, 110); | |
| Bank.depositAll(); | |
| Time.sleep(500,700); | |
| Mouse.click(x,y,false); | |
| Time.sleep(500,700); | |
| Mouse.click(x, (y + Random.random(103,126))); | |
| Time.sleep(500,700); | |
| Mouse.move(489,30); | |
| if(Mouse.getLocation()!= new Point(489,30)) Mouse.move(489,30); | |
| Time.sleep(200,300); | |
| Mouse.click(); | |
| Time.sleep(100,200); | |
| Mouse.move(Random.random(0,765), Random.random(0,502)); | |
| Time.sleep(400,500); | |
| } | |
| status = "Finding fire"; | |
| return 100; | |
| } | |
| if(status.equals("Finding fire")){ | |
| if(Game.getColorAt(343,427).equals(new Color(89,81,68))){ | |
| status = "Cooking"; | |
| return 100; | |
| } | |
| if(Bank.isOpen()){ | |
| status = "Banking"; | |
| return 100; | |
| } | |
| if(!checkColor(raw,new Point(570,232), 20)){ | |
| status = "Finding banker"; | |
| return 100; | |
| } | |
| Camera.pitchUp(300); | |
| Time.sleep(100); | |
| Camera.rotateRight(300); | |
| Mouse.click(Random.random(567,587),Random.random(219,240)); | |
| Mouse.setSpeed(2); | |
| Point firePt = findFire(); | |
| Time.sleep(300); | |
| if(firePt.x == -1)return 100; | |
| Mouse.click(firePt,false); | |
| Time.sleep(200); | |
| boolean found = false; | |
| int k = 0; | |
| if(checkColor(Color.WHITE,new Point(firePt.x,firePt.y+72),4)){ | |
| k = 1; | |
| found = true; | |
| }else{ | |
| for(; k <= 12; k++){ | |
| if(Game.getColorAt(343,427).equals(new Color(89,81,68))){ | |
| status = "Cooking"; | |
| return 100; | |
| } | |
| String lol = OCR.findString(new Rectangle(firePt.x-60,firePt.y+(17*k),350,21), null, true); | |
| Mouse.move(firePt.x,firePt.y+(17*k)+11); | |
| if(lol.contains("Fire")){ | |
| found = true; | |
| break; | |
| } | |
| if(checkColor(Color.WHITE,new Point(firePt.x,firePt.y+((k + 1)*17)),8)){ | |
| found = true; | |
| break; | |
| } | |
| } | |
| } | |
| if(found)Mouse.click(firePt.x,firePt.y+(17*k)+11); | |
| else Mouse.click(Random.random(567,587),Random.random(219,240)); | |
| Time.sleep(1000); | |
| if(Game.getColorAt(343,427).equals(new Color(89,81,68)))status = "Cooking"; | |
| row = 0; | |
| col = 0; | |
| first = true; | |
| return 100; | |
| } | |
| if(status.equals("Cooking")){ | |
| if(first){ | |
| temp0 = Game.getColorAt(570 ,229); | |
| temp1 = Game.getColorAt(586 ,222); | |
| temp2 = Game.getColorAt(574 ,231); | |
| Mouse.click(Random.random(240,282),Random.random(405,455)); | |
| first = false; | |
| cookTO = System.currentTimeMillis(); | |
| } | |
| if(System.currentTimeMillis()- cookTO > 120000){ | |
| status = "Finding banker"; | |
| return 100; | |
| } | |
| if(!checkColor(temp0,new Point(570 + (col*42),229 + (row*36)),15) | |
| || !checkColor(temp1,new Point(586 + (col*42),222 + (row*36)),15) | |
| || !checkColor(temp2,new Point(574 + (col*42),231 + (row*36)),15)){ | |
| if(checkCooked){ | |
| Mouse.move(Random.random(567,587),Random.random(219,240)); | |
| String type = OCR.findString(new Rectangle(29,10,100,15), null); | |
| if(!type.contains("Burned") || !type.contains("Burn")){ | |
| notB0 = Game.getColorAt(570 + (col*42),229 + (row*36)); | |
| notB1 = Game.getColorAt(586 + (col*42),222 + (row*36)); | |
| notB2 = Game.getColorAt(574 + (col*42),231 + (row*36)); | |
| checkCooked = false; | |
| cooked++; | |
| } | |
| }else{ | |
| if(!isDarker(Game.getColorAt(570 + (col*42),229 + (row*36)),notB0) | |
| || !isDarker(Game.getColorAt(586 + (col*42),222 + (row*36)),notB1) | |
| || !isDarker(Game.getColorAt(574 + (col*42),231 + (row*36)),notB2)){ | |
| cooked++; | |
| }else{ | |
| burned++; | |
| } | |
| } | |
| col++; | |
| if(col == 4){ | |
| col = 0; | |
| row++; | |
| if(row == 7){ | |
| status = "Finding banker"; | |
| return 100; | |
| } | |
| } | |
| return 100; | |
| } | |
| return 100; | |
| } | |
| return 100; | |
| } | |
| public void onRepaint(Graphics g){ | |
| int percent = 0; | |
| try{ | |
| percent = (int) (100*((double)burned/(double)(cooked+burned))); | |
| }catch(ArithmeticException e){ | |
| } | |
| if(showPaint){ | |
| g.drawImage(back, 5, 343, null); | |
| g.setColor(Color.BLACK); | |
| int starty = 343; | |
| g.setFont(new Font("Salaryman", 1, 14)); | |
| g.drawString("Time Running: " + Time.toElapsedString(System.currentTimeMillis() - TIME), 11, starty+=17); | |
| g.drawString("Total Cooked: " + cooked ,11,starty+=17); | |
| g.drawString("Cooks/Hour: " + (3600000*(long)cooked)/(int)(System.currentTimeMillis() - TIME),11,starty+=17); | |
| g.drawString("Burn Percentage: " + percent + "%",11,starty+=17); | |
| g.drawString("Status: " + status ,11,starty+=17); | |
| g.drawString("Exp/Hour: " + 100*(3600000*(long)cooked)/(int)(System.currentTimeMillis() - TIME),11,starty+=17); | |
| g.drawImage(pic, 240, 300, null, null); | |
| g.setFont(new Font("Salaryman", 1, 25)); | |
| g.drawString("BatCooker",270,390); | |
| g.drawString("Version 1.31",265,420); | |
| g.setColor(Color.ORANGE); | |
| g.drawString("Ve",265,420); | |
| g.setColor(Color.RED); | |
| g.drawString("x",500,360); | |
| }else{ | |
| g.setColor(Color.GREEN); | |
| g.setFont(new Font("Salaryman", 1, 25)); | |
| g.drawString("o",500,360); | |
| } | |
| g.setColor(Color.CYAN); | |
| g.drawLine(Mouse.getLocation().x,0,Mouse.getLocation().x,2100); | |
| g.drawLine(0,Mouse.getLocation().y,2100,Mouse.getLocation().y); | |
| } | |
| public void onStop(){ | |
| //anti.interrupt(); | |
| Log.log("Thanks for using BatCooker!"); | |
| Log.log("Total runtime of: " + Time.toElapsedString(System.currentTimeMillis() - TIME)); | |
| Log.log("You cooked " + cooked + " food."); | |
| } | |
| private static Point findBanker(){ | |
| Point thePoint = new Point(); | |
| List<Point> test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, bankerF,3); | |
| try{ | |
| if(test.size() < 1)throw new IllegalArgumentException(); | |
| thePoint = test.get(Random.random(0,test.size()-1)); | |
| }catch(IllegalArgumentException e){ | |
| try{ | |
| test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, bankerB,5); | |
| if(test.size() < 1)throw new IllegalArgumentException(); | |
| thePoint = test.get(Random.random(0,test.size()-1)); | |
| }catch(IllegalArgumentException e2){ | |
| thePoint = new Point(-1,-1); | |
| } | |
| } | |
| return thePoint; | |
| } | |
| private static Point findFire(){ | |
| Point thePoint = new Point(); | |
| List<Point> test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, fire,3); | |
| try{ | |
| if(test.size() < 1)throw new IllegalArgumentException(); | |
| thePoint = test.get(Random.random(0,test.size()-1)); | |
| }catch(IllegalArgumentException e){ | |
| // try{ | |
| // test = ImageUtil.getPointsWithColor(Game.getImage(), viewPort, bankerB,.02); | |
| // if(test.size() < 1)throw new IllegalArgumentException(); | |
| // thePoint = test.get(Random.random(0,test.size()-1)); | |
| // }catch(IllegalArgumentException e2){ | |
| thePoint = new Point(-1,-1); | |
| // } | |
| } | |
| return thePoint; | |
| } | |
| /** | |
| * Returns whether the given point is a certain color. | |
| * Accounts for the variable colors that runescape produces whenever you log in. | |
| * @param col | |
| * - Color to check for. | |
| * @param p | |
| * - Point to check at. | |
| * @return | |
| */ | |
| private boolean checkColor(Color col, Point p, int tol){ | |
| if(Math.abs(col.getRed() - Game.getColorAt(p).getRed()) < tol) | |
| if(Math.abs(col.getGreen() - Game.getColorAt(p).getGreen()) < tol) | |
| if(Math.abs(col.getBlue() - Game.getColorAt(p).getBlue()) < tol) | |
| return true; | |
| return false; | |
| } | |
| public boolean isDarker(final Color c1, final Color c2) { | |
| int col1 = c1.getRed() + c1.getGreen() + c1.getBlue(); | |
| int col2 = c2.getRed() + c2.getGreen() + c2.getBlue(); | |
| return col1 < col2 ? true : false; | |
| } | |
| /** | |
| * Mouse listener | |
| */ | |
| public void mouseClicked(MouseEvent e) { | |
| Point pt = e.getPoint(); | |
| if (pt.x >= 499 && pt.x <= 512 && pt.y >= 345 && pt.y <= 360) { | |
| showPaint = !showPaint; | |
| } | |
| } | |
| public void mouseEntered(MouseEvent arg0) {} | |
| public void mouseExited(MouseEvent arg0) {} | |
| public void mousePressed(MouseEvent arg0) {} | |
| public void mouseReleased(MouseEvent arg0) {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment