Jump to content

Alora Fatty Cooker


fattyscripts
 Share

Recommended Posts

After noticing that there were no working cooking bots on alora I decided to make on of my own. 

How to use

  1. Teleport to fishing guild and go to the bank
  2. Run script
  3. Choose fish type

Huge shout outs to @Jakefor helping me setup my intellij and @IR0Nfor helping me with basic questions and the ingame paint.

ybybfhC.png

n3nyA7z.png

Source (loop logic && GUI Selector)

Spoiler

import xobot.client.callback.listeners.PaintListener;
import xobot.script.ActiveScript;
import xobot.script.Manifest;
import xobot.script.methods.Bank;
import xobot.script.methods.GameObjects;
import xobot.script.methods.Players;
import xobot.script.methods.tabs.Inventory;
import xobot.script.util.Time;
import xobot.script.methods.Widgets;
import xobot.script.wrappers.WidgetChild;
import xobot.script.wrappers.interactive.GameObject;
import xobot.script.wrappers.interactive.Item;
import xobot.script.wrappers.Tile;
import xobot.script.wrappers.interactive.Player;
import xobot.script.util.Timer;
import xobot.script.methods.tabs.Skills;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;

@Manifest(authors = { "Fatty Scripts" }, name = "Fatty Cooker", description = "Cooks fish in fishing guild")
public class fattyCooker extends ActiveScript implements PaintListener {
    private static Boolean cooking = false;

    private Timer t = null;
    private int startXP = 0;

    public int rawType;
    public int burntType;

    fattyCookerGUI gui = new fattyCookerGUI();

    public boolean onStart() {
        gui.setVisible(true);

        startXP = Skills.COOKING.getCurrentExp();
        t = new Timer(System.currentTimeMillis());
        return true;
    }

    @Override
    public int loop() {

        if (gui.startScript == false) {
            return 1000;
        }

        System.out.println(gui.rawType);
        System.out.println(gui.burntType);

        if(Inventory.isFull()) { //Check if inventory is full
            if (Inventory.Contains(gui.rawType) && !cooking){
                int posx = Player.getMyPlayer().getX();
                int posy = Player.getMyPlayer().getY();
                if (posx != 2593 && posy != 3422) {
                    new Tile(2593, 3422).walk();
                    Time.sleep(6000);
                }
                GameObject stove = GameObjects.getNearest(21302);
                Item fish = Inventory.getItem(gui.rawType);
                    if(stove != null){
                        fish.interact("use");
                        Time.sleep(1000);
                        stove.interact("use-with");
                        Time.sleep(1000);
                        WidgetChild cookScreen = Widgets.get(307, 4);
                        Time.sleep(1000);
                        cookScreen.click("Cook All");
                        Time.sleep(500);
                        if (Players.getMyPlayer().getAnimation() != -1){
                            cooking = true;
                        }
                    }
                return 650;
            }else if ((!Inventory.Contains(gui.rawType))){
                cooking = false;
                int posx = Player.getMyPlayer().getX();
                int posy = Player.getMyPlayer().getY();
                if (posx != 2586 && posy != 3418) {
                    new Tile(2586,3418).walk();
                    Time.sleep(6000);
                }
                GameObject bank = GameObjects.getNearest(6943);
                if(bank != null){

                    Item fish = Bank.getItem(gui.rawType);

                    bank.interact("bank");
                    Time.sleep(1000);
                    Bank.depositAll();
                    Time.sleep(1000);
                    if(fish != null) {
                        Bank.withdraw(gui.rawType, 28);
                    }else{
                        System.out.println("No food left");
                    }
                }
                return 1000;
            }else{
                return 1000;
            }
        }else{
            GameObject bank = GameObjects.getNearest(6943);
            if(bank != null){
                bank.interact("bank");
                Time.sleep(200);
                if (Inventory.getCount() > 0) {
                    Bank.depositAll();
                }
                Time.sleep(200);
                Bank.withdraw(gui.rawType, 28);
            }
        }
        return 1000;
    }
    private final Color color1 = new Color(102, 102, 102, 218);
    private final Color color2 = new Color(0, 0, 0);
    private final Color color3 = new Color(0, 255, 255);
    private final Color color4 = new Color(255, 255, 255);

    private final BasicStroke stroke1 = new BasicStroke(1);

    private final Font font1 = new Font("Arial", 0, 22);
    private final Font font2 = new Font("Arial", 0, 16);

    public void repaint(Graphics g1) {
        int xp = Skills.COOKING.getCurrentExp() - startXP;
        int xph = (int) ((xp) * 3600000D / (t.getElapsed()));

        Graphics2D g = (Graphics2D)g1;
        g.setColor(color1);
        g.fillRect(2, 0, 175, 100);
        g.setColor(color2);
        g.setStroke(stroke1);
        g.drawRect(2, 0, 175, 100);
        g.setFont(font1);
        g.setColor(color3);
        g.drawString("Fatty Cooker", 20, 25);
        g.setFont(font2);
        g.setColor(color4);
        g.drawString("XP: " + xp, 25, 65);
        g.drawString("XP(h): " + xph, 25, 80);
        g.drawString(t.toElapsedString(), 25, 50); //Time Elapsed
    }
}

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class fattyCookerGUI extends JFrame {

    private JButton buttonSelect = new JButton("Select");
    public String fishType = new String();
    public boolean startScript = false;
    public int rawType;
    public int burntType;

    public fattyCookerGUI() {
        super("Select a fish");

        setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));

        String[] fishTypes = new String[] { "Shrimp",
                "Trout",
                "Salmon",
                "Tuna",
                "Lobster",
                "Swordfish",
                "Monkfish",
                "Karambwan",
                "Shark",
                "Manta Ray"
        };

        // create a combo box with items specified in the String array:
        final JComboBox<String> fishList = new JComboBox<>(fishTypes);

        // customize some appearance:
        //fishList.setForeground(Color.BLUE);
        fishList.setFont(new Font("Arial", Font.BOLD, 14));
        fishList.setMaximumRowCount(10);

        // add event listener for the button Select
        buttonSelect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                fishType = (String) fishList.getSelectedItem();
                switch(fishType){
                    case "Shrimp":
                        rawType = 317; burntType = 7954; break;
                    case "Trout":
                        rawType = 335; burntType = 343; break;
                    case "Salmon":
                        rawType = 331; burntType = 343; break;
                    case "Tuna":
                        rawType = 359; burntType = 367; break;
                    case "Lobster":
                        rawType = 377; burntType = 381; break;
                    case "Swordfish":
                        rawType = 371; burntType = 375; break;
                    case "Monkfish":
                        rawType = 7944; burntType = 7948; break;
                    case "Karambwan":
                        rawType = 3142; burntType = 3148; break;
                    case "Shark":
                        rawType = 383; burntType = 387; break;
                    case "Manta Ray":
                        rawType = 389; burntType = 393; break;
                }
                startScript = true;
                dispose();
            }
        });

        // add components to this frame
        add(fishList);
        add(buttonSelect);

        pack();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
    }

}

 

 

Edited by fattyscripts
fixing the @'s
Link to comment
Share on other sites

Love the script, but I found it afking at excess amounts which seemed to mess the loop up. I modified:

 

 }else if ((!Inventory.Contains(gui.rawType))){
                cooking = false;
                int posx = Player.getMyPlayer().getX();
                int posy = Player.getMyPlayer().getY();
                if (posx != 2586 && posy != 3418) {
                    new Tile(2586,3418).walk();
                    Time.sleep(6000);

WITH
 

 }else if ((!Inventory.Contains(gui.rawType))){
                cooking = false;
                int posx = Player.getMyPlayer().getX();
                int posy = Player.getMyPlayer().getY();
                if (posx != 2586 && posy != 3418) {
                    new Tile(2586,3418).walk();
                    Time.sleep(3000);

and it seems to be looping better. Let me know what you think. I'm still learning to code and just tweaking minor user end modifications. 

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 weeks later...

Used this from the SDN today, worked brilliantly.

Only think I noticed is that it sometimes fails to click the cooker, but the mouse still moves as if it's right clicking > Cook all. Then it pauses for a while and tries again, successfully.

Also, perhaps going to Withdraw [x] and entering the number every time isn't the best option? Idk about that though :P

 

Thanks for this.

Link to comment
Share on other sites

  • Neo locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...