Created
May 19, 2012 06:43
-
-
Save TheBatScripts/2729757 to your computer and use it in GitHub Desktop.
Batcooker 1.1 for tribot
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
| package scripts; | |
| import java.awt.Color; | |
| import java.awt.Font; | |
| import java.awt.Graphics; | |
| import java.awt.Point; | |
| import java.awt.Rectangle; | |
| import java.awt.event.KeyEvent; | |
| import java.awt.image.BufferedImage; | |
| import java.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.net.URL; | |
| import javax.imageio.ImageIO; | |
| import org.tribot.api.General; | |
| import org.tribot.api.Timing; | |
| import org.tribot.api.colour.Screen; | |
| import org.tribot.api.colour.types.Tolerance; | |
| import org.tribot.api.input.Keyboard; | |
| import org.tribot.api.input.Mouse; | |
| import org.tribot.api.togl.Game; | |
| import org.tribot.api.togl.Inventory; | |
| import org.tribot.api.togl.ScreenModels; | |
| import org.tribot.api.togl.types.InventoryItem; | |
| import org.tribot.api.togl.types.ScreenModel; | |
| import org.tribot.script.Script; | |
| import org.tribot.script.ScriptManifest; | |
| import org.tribot.script.interfaces.Painting; | |
| @ScriptManifest (authors = { "TheBat" }, category = "Cooking", name = "BatCooker", | |
| description="<html>"+ | |
| "<head>"+ | |
| "<title>BatCooker</title>"+ | |
| "</head>"+ | |
| "<body bgcolor=\"#b4ada1\">"+ | |
| "<h1 align=\"center\"><img style=\"WIDTH: 188px; HEIGHT: 94px\" "+ | |
| "border=0 hspace=0 src=\"http://i.imgur.com/OjzsS.png\" width=250 height=100></h1>"+ | |
| "<p align=\"left\"><font size=\"6\">Cooks raw "+ | |
| "food on the rogues' den infinite fire.</font></p>"+ | |
| "<p align=\"left\"><font size=\"6\">Start with the raw food in the "+ | |
| "first slot of your bank.</font></p>"+ | |
| "</body>"+ | |
| "</html>") | |
| public class BatCooker extends Script implements Painting { | |
| final long banker = 3984442403L, fire = 2764560156L; | |
| final Rectangle viewPort = new Rectangle(0, 0, 765, 495); | |
| String status = "Finding banker"; | |
| private static BufferedImage pic = null; | |
| private static BufferedImage back = null; | |
| private long cooked = 0; | |
| private long burned = 0; | |
| boolean firstCook = true; | |
| private long TIME; | |
| int row = 0; | |
| int spot = 0; | |
| Color rawColor = new Color(0,0,0); | |
| private Point pt = new Point(); | |
| public boolean onStart(){ | |
| TIME = System.currentTimeMillis(); | |
| try { | |
| back = ImageIO.read(new File("./Storage/BatScripts/backPick.png")); | |
| }catch (FileNotFoundException e) { | |
| }catch (IOException e) { | |
| try { | |
| println("Image not found, retrieving from internet."); | |
| back = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/underPaint.png")); | |
| File file = new File("./Storage/BatScripts/backPick.png"); | |
| file.getParentFile().mkdirs(); | |
| ImageIO.write(back, "png",file); | |
| } catch (IOException ex) { | |
| } | |
| } | |
| try { | |
| pic = ImageIO.read(new File("./Storage/BatScripts/fire.png")); | |
| }catch (FileNotFoundException e) { | |
| }catch (IOException e) { | |
| try { | |
| println("Image not found, retrieving from internet."); | |
| pic = ImageIO.read(new URL("http://i1066.photobucket.com/albums/u406/bootsncats/fire.png")); | |
| File file = new File("./Storage/BatScripts/fire.png"); | |
| file.getParentFile().mkdirs(); | |
| ImageIO.write(pic, "png",file); | |
| } catch (IOException ex) { | |
| } | |
| } | |
| status = "Finding banker"; | |
| return true; | |
| } | |
| private int loop(){ | |
| Mouse.setSpeed(General.random(130, 150)); | |
| if(isCookingOpen()){ | |
| status = "Cooking"; | |
| } | |
| if(isBankOpen()){ | |
| status = "Banking"; | |
| } | |
| if(status.equals("Finding banker")){ | |
| ScreenModel [] banker; | |
| try{ | |
| banker = ScreenModels.find(this.banker); | |
| }catch(NullPointerException e){ | |
| banker = new ScreenModel [0]; | |
| } | |
| if(banker.length > 0 && banker[0].points.length > 0 && viewPort.contains(banker[0].points[0])){ | |
| Mouse.setSpeed(300); | |
| Mouse.move(banker[0].points[0]); | |
| sleep(200); | |
| try{ | |
| if(Game.getUptext().contains("Emerald")){ | |
| Mouse.click(Mouse.getPos(), 3); | |
| Mouse.setSpeed(General.random(130, 150)); | |
| sleep(100); | |
| Mouse.click(new Point(Mouse.getPos().x,Mouse.getPos().y+46), 1); | |
| int i = 0; | |
| while(!isBankOpen() && i <= 40){ | |
| sleep(100); | |
| i++; | |
| } | |
| if(isBankOpen()){ | |
| status = "Banking"; | |
| } | |
| return 100; | |
| } | |
| }catch(NullPointerException e){} | |
| } | |
| Keyboard.pressKey((char) KeyEvent.VK_LEFT); | |
| sleep(300); | |
| Keyboard.pressKey((char) KeyEvent.VK_DOWN); | |
| sleep(300); | |
| Keyboard.releaseKey((char) KeyEvent.VK_LEFT); | |
| sleep(300); | |
| Keyboard.releaseKey((char) KeyEvent.VK_DOWN); | |
| return 100; | |
| } | |
| if(status.equals("Banking")){ | |
| if(isBankOpen()){ | |
| int x = General.random(50, 60); | |
| int y = General.random(100, 110); | |
| Mouse.click(new Point(371,310),1); | |
| sleep(500,700); | |
| Mouse.click(new Point(x,y),3); | |
| sleep(500,700); | |
| Mouse.click(new Point(x, (y + General.random(103,126))),1); | |
| sleep(500,700); | |
| Mouse.click(new Point(489,30),1); | |
| sleep(100,200); | |
| Mouse.move(new Point(General.random(0,765), General.random(0,502))); | |
| sleep(400,500); | |
| }else{ | |
| status = "Finding Banker"; | |
| return 100; | |
| } | |
| status = "Finding fire"; | |
| return 100; | |
| } | |
| if(status.equals("Finding fire")){ | |
| if(firstCook){ | |
| sleep(300); | |
| rawColor = new Color(Inventory.getAll()[0].avg_r,Inventory.getAll()[0].avg_g,Inventory.getAll()[0].avg_b); | |
| firstCook = false; | |
| } | |
| Mouse.click(new Point(577,229),1); | |
| ScreenModel [] fire; | |
| try{ | |
| fire = ScreenModels.find(this.fire); | |
| }catch(NullPointerException e){ | |
| fire = new ScreenModel [0]; | |
| Mouse.click(new Point(577,229),1); | |
| } | |
| if(fire.length > 0 && fire[0].points.length > 0 && viewPort.contains(fire[0].points[0])){ | |
| Mouse.click(fire[0].points[0],3); | |
| sleep(200); | |
| int k = 0; | |
| while(!Game.isMenuOpen() && k++ <= 40){ | |
| sleep(100); | |
| } | |
| if(Game.isMenuOpen()){ | |
| String [] options = Game.getMenuOptions(); | |
| for(int i = 0; i < options.length; i++){ | |
| if(options[i].contains("Raw")&&options[i].contains("Fire")){ | |
| Mouse.click(new Point(Mouse.getPos().x,Mouse.getPos().y + 21 + (i * 16)),1); | |
| k = 0; | |
| while(!isCookingOpen() && k++ <= 40){ | |
| sleep(100); | |
| } | |
| if(isCookingOpen()){ | |
| Mouse.click(new Point(254,428),1); | |
| sleep(500); | |
| status = "Cooking"; | |
| firstCook = true; | |
| return 100; | |
| } | |
| } | |
| } | |
| } | |
| }else{ | |
| Keyboard.pressKey((char) KeyEvent.VK_RIGHT); | |
| sleep(300); | |
| Keyboard.pressKey((char) KeyEvent.VK_UP); | |
| sleep(300); | |
| Keyboard.releaseKey((char) KeyEvent.VK_RIGHT); | |
| sleep(300); | |
| Keyboard.releaseKey((char) KeyEvent.VK_UP); | |
| return 100; | |
| } | |
| return 100; | |
| } | |
| if(status.equals("Cooking")){ | |
| if(firstCook){ | |
| spot = 0; | |
| firstCook = false; | |
| } | |
| try{ | |
| InventoryItem iI = Inventory.getAll()[spot]; | |
| Color test = new Color(iI.avg_r,iI.avg_g,iI.avg_g); | |
| pt = new Point(iI.x1,iI.y1); | |
| if(!Screen.coloursMatch(test, rawColor, new Tolerance(12))){ | |
| spot++; | |
| cooked++; | |
| } | |
| }catch(Exception e){} | |
| if(spot == 28){ | |
| status = "Finding banker"; | |
| return 100; | |
| } | |
| return 100; | |
| } | |
| return 100; | |
| } | |
| private boolean isBankOpen() { | |
| if(Screen.getColourAt(new Point(197,34)).equals(new Color(242,170,62))){ | |
| if(Screen.getColourAt(new Point(371,310)).equals(new Color(95,51,19))){ | |
| if(Screen.getColourAt(new Point(33,325)).equals(new Color(78,72,54))){ | |
| return true; | |
| } | |
| } | |
| } | |
| return false; | |
| } | |
| private boolean isCookingOpen() { | |
| if(Screen.getColourAt(new Point(17,350)).equals(new Color(90,82,69))){ | |
| if(Screen.getColourAt(new Point(499,470)).equals(new Color(67,61,52))){ | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| public void onStop(){ | |
| } | |
| public void onPaint(Graphics g) { | |
| int percent = 0; | |
| try{ | |
| percent = (int) (100*((double)burned/(double)(cooked+burned))); | |
| }catch(ArithmeticException e){ | |
| } | |
| g.drawImage(back, 5, 343, null); | |
| g.setColor(Color.BLACK); | |
| int starty = 343; | |
| g.setFont(new Font("Salaryman", 1, 14)); | |
| g.drawString("Time Running: " + Timing.msToString(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.1",265,420); | |
| g.setColor(Color.ORANGE); | |
| g.drawString("Ve",265,420); | |
| g.fillOval(pt.x-2, pt.y-2, 4, 4); | |
| g.setColor(Color.RED); | |
| g.drawString("x",500,360); | |
| } | |
| public void run() { | |
| if(onStart()){ | |
| while(!Thread.interrupted() && loop()>=0){} | |
| onStop(); | |
| }else println("Script failed to start!"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment