Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.awt.Color;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- import com.rarebot.event.events.MessageEvent;
- import com.rarebot.event.listeners.MessageListener;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.wrappers.RSComponent;
- import com.rarebot.script.wrappers.RSItem;
- import com.rarebot.script.wrappers.RSObject;
- import com.rarebot.script.wrappers.RSTile;
- import com.rarebot.script.wrappers.RSWeb;
- @ScriptManifest(
- authors = {"Rudie"},
- version = 1.0,
- keywords = ("cooker, cooking, aio, rudie"),
- description = "Cooks all types of food!",
- name = "MultiCooker"
- )
- public class MultiCooker extends Script implements PaintListener, MessageListener, MouseListener {
- public int foodID;
- public int rangeID = 25730;
- public int[] boothID = {};
- RSTile Banktile = new RSTile(3270, 3167, 0);
- RSTile Rangetile = new RSTile(3273, 3180, 0);
- long startTime;
- private String status = "Loading...";
- int expGained = 0;
- int startExp = 0;
- int foodCooked = 0;
- int foodBurnt = 0;
- int gainedLvl = 0;
- private static boolean hide = false;
- public boolean showPaint = true ;
- public boolean clicked = false;
- MultiCookerGUI g;
- private boolean guiWait = true;
- public boolean onStart() {
- log(Color.RED, "Welcome to MultiCooker.");
- startTime = System.currentTimeMillis();
- mouse.setSpeed(random(5, 7));
- startExp = skills.getCurrentExp(Skills.COOKING);
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- g = new MultiCookerGUI();
- g.setVisible(true);
- }
- });
- } catch (Throwable e) {
- log("Fail.");
- }
- while(guiWait) sleep(500);
- return true;
- }
- @Override
- public int loop() {
- RSObject r = objects.getNearest(rangeID);
- if(inventory.contains(foodID) && r.isOnScreen()) {
- cook();
- AntiBan();
- AntiBanCamera();
- } else {
- if(!inventory.contains(foodID)) {
- walktoBank();
- }
- }
- if(!inventory.contains(foodID)) {
- doBank();
- } else {
- walktoRange();
- }
- return random(500, 800);
- }
- private void walktoBank() {
- RSWeb walkWeb = web.getWeb(Banktile);
- if (walkWeb != null && !walkWeb.finished()) {
- walkWeb.step();
- sleep(200, 300);
- clicked = false;
- } else if (walkWeb == null) {
- walkWeb = web.getWeb(Banktile);
- clicked = false;
- }}
- private void walktoRange() {
- RSWeb walkWeb = web.getWeb(Rangetile);
- if (walkWeb != null && !walkWeb.finished()) {
- walkWeb.step();
- sleep(200, 300);
- } else if (walkWeb == null) {
- walkWeb = web.getWeb(Rangetile);
- }}
- private void cook() {
- RSItem f = inventory.getItem(foodID);
- RSObject r = objects.getNearest(rangeID);
- if(r != null && getMyPlayer().getAnimation() == -1 && !cookingInterface().isValid() && clicked == false) {
- camera.turnTo(r);
- status = "Cooking";
- sleep(1500, 2000);
- f.interact("Use");
- sleep(500, 1000);
- r.doClick();
- sleep(2000, 2250);
- } else {
- if (cookingInterface().isValid()) {
- interfaces.getComponent(905, 14).doClick();
- clicked = true;
- status = "Cooking";
- sleep(1200, 1400);
- }
- }
- }
- private void doBank() {
- if (bank.isOpen()) {
- if (inventory.getCountExcept(foodID) > 0) {
- if (bank.depositAll()) {
- status = "Banking";
- sleep(400, 450);
- }
- }
- if (!inventory.contains(foodID)) {
- if (bank.getCount(foodID) > 0) {
- if (bank.withdraw(foodID, 0)) {
- status = "Banking";
- sleep(250, 300);
- }}}
- } else {
- bank.open();
- status = "Banking";
- sleep(1000, 1200);
- }
- }
- private RSComponent cookingInterface() {
- return interfaces.getComponent(905, 14);
- }
- @Override
- public void messageReceived(MessageEvent e) {
- String txt = e.getMessage().toLowerCase();
- if(txt.contains("successfully")) {
- foodCooked++;
- }
- if(txt.contains("burn")) {
- foodBurnt++;
- }
- if(txt.contains("cooking level")) {
- gainedLvl++;
- }
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Color color2 = new Color(255, 255, 255, 0);
- private final Color color3 = new Color(178, 34, 34);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 14);
- private final Image img1 = getImage("http://epicscape668.org/images/cook.png");
- public void onRepaint(Graphics g) {
- expGained = skills.getCurrentExp(Skills.COOKING) - startExp;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- float xpsec = 0;
- if((minutes > 0 || hours > 0 || seconds > 0)&& expGained > 0) {
- xpsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- float foodsec = 0;
- if((minutes > 0 || hours > 0 || seconds > 0)&& foodCooked > 0) {
- foodsec = ((float) foodCooked)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- float foodmin = foodsec * 60;
- float foodhour = foodmin * 60;
- Graphics2D g1 = (Graphics2D)g;
- g1.setColor(color2);
- g1.fillRect(336, 346, 75, 17);
- g1.setColor(color3);
- g1.setStroke(stroke1);
- g1.drawRect(336, 346, 75, 17);
- g1.drawString("Show", 357, 360);
- g.setColor(Color.WHITE);
- g.drawLine(0, (int)(mouse.getLocation().getY()), 800, (int)(mouse.getLocation().getY()));
- g.drawLine((int)(mouse.getLocation().getX()), 0, (int)(mouse.getLocation().getX()), 800);
- if(!hide) {
- g1.drawImage(img1, -7, -30, null);
- g1.setFont(font1);
- g1.setColor(color1);
- g1.drawString("" + hours + ":" + minutes + ":" + seconds, 120, 391);
- g1.drawString("" + expGained, 139, 416);
- g1.drawString("" + (int) xphour, 96, 444);
- g1.drawString("" + foodBurnt, 146, 470);
- g1.drawString("" + foodCooked, 409, 391);
- g1.drawString("" + (int) foodhour, 355, 415);
- g1.drawString("" + status, 345, 443);
- g1.drawString("" + gainedLvl + " (C:"+skills.getCurrentLevel(Skills.COOKING)+")", 407, 471);
- g1.setColor(color2);
- g1.fillRect(336, 346, 75, 17);
- g1.setColor(color1);
- g1.setStroke(stroke1);
- g1.drawRect(336, 346, 75, 17);
- g1.drawString("Hide", 357, 360);
- g.setColor(Color.WHITE);
- g.drawLine(0, (int)(mouse.getLocation().getY()), 800, (int)(mouse.getLocation().getY()));
- g.drawLine((int)(mouse.getLocation().getX()), 0, (int)(mouse.getLocation().getX()), 800);
- }
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- final Rectangle rect = new Rectangle(336, 346, 75, 17);
- final Point p = e.getPoint();
- if (rect.contains(p) && !hide) {
- hide = true;
- } else if (rect.contains(p) && hide) {
- hide = false;
- }
- }
- private void AntiBanCamera() {
- int randomNum = random(1, 160);
- if (randomNum == 1 || randomNum == 2 || randomNum == 3) {
- camera.moveRandomly(random(2000, 5500));
- }
- if (randomNum == 4 || randomNum == 5) {
- camera.setAngle(random(10, 40));
- }
- if (randomNum == 6) {
- camera.setPitch(random(40, 68));
- }
- if (randomNum == 7) {
- camera.setPitch(random(20, 45));
- }
- if (randomNum == 8) {
- camera.setPitch(random(68, 90));
- } else
- sleep(50, 70);
- }
- @SuppressWarnings("deprecation")
- private void AntiBan() {
- int randomProd = random(1, 60);
- if (randomProd == 1) {
- int randomMore = random(1, 5);
- if (randomMore == 1) {
- if (game.getCurrentTab() != 2) {
- game.openTab(2);
- sleep(350, 500);
- skills.doHover(Skills.COOKING);
- sleep(2000, 3500);
- } else {
- mouse.move(random(678, 728), random(213, 232));
- sleep(2000, 3500);
- }
- } else {
- sleep(1200, 2500);
- }
- }
- if (randomProd == 2 || randomProd == 3 || randomProd == 4) {
- sleep(1000, 2500);
- }
- if (randomProd >= 52) {
- mouse.moveRandomly(65, 350);
- } else
- sleep(10, 30);
- }
- public void onFinish() {
- log(Color.RED, "Thanks for using: MultiCooker!");
- env.saveScreenshot(true);
- }
- class MultiCookerGUI extends JFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public MultiCookerGUI() {
- initComponents();
- }
- private void startActionPerformed(ActionEvent e) {
- foodID = Integer.parseInt(foodfield.getText());
- guiWait = false;
- g.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Rudie Visser
- label1 = new JLabel();
- start = new JButton();
- label2 = new JLabel();
- label3 = new JLabel();
- foodfield = new JTextField();
- //======== this ========
- setTitle("MultiCooker GUI");
- Container contentPane = getContentPane();
- //---- label1 ----
- label1.setText("MultiCooker GUI");
- label1.setForeground(Color.red);
- label1.setFont(new Font("Tahoma", Font.PLAIN, 48));
- //---- start ----
- start.setText("Start Cooking!");
- start.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- startActionPerformed(e);
- }
- });
- //---- label2 ----
- label2.setText("To start cooking simply fill in your food id what you want to cook:");
- //---- label3 ----
- label3.setText("And then press: \"Start Cooking\".");
- GroupLayout contentPaneLayout = new GroupLayout(contentPane);
- contentPane.setLayout(contentPaneLayout);
- contentPaneLayout.setHorizontalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label1)
- .addContainerGap(14, Short.MAX_VALUE))
- .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
- .addContainerGap(31, Short.MAX_VALUE)
- .addComponent(label2)
- .addGap(27, 27, 27))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(95, 95, 95)
- .addComponent(label3)
- .addContainerGap(117, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(123, 123, 123)
- .addComponent(start, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(123, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(43, 43, 43)
- .addComponent(foodfield, GroupLayout.PREFERRED_SIZE, 283, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(43, Short.MAX_VALUE))
- );
- contentPaneLayout.setVerticalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label1)
- .addGap(41, 41, 41)
- .addComponent(label2)
- .addGap(2, 2, 2)
- .addComponent(label3)
- .addGap(18, 18, 18)
- .addComponent(foodfield, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addGap(27, 27, 27)
- .addComponent(start, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Rudie Visser
- private JLabel label1;
- private JButton start;
- private JLabel label2;
- private JLabel label3;
- private JTextField foodfield;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement