Jump to content

T3 Pizza-baser


Tw3nty

Recommended Posts

Start with buckets of water and pots of flour in either your bank/inventory.

 

No idea on GP/hour. Bases currently sell for much higher than market price but flour buys for much higher as well.

 

Made as a request and so I could learn OSBot API and re-familiarize myself with Java. May add shit later.

 

Download link: http://upx.nz/9fXovk

 

Download the .ZIP, extract it to your scripts folder. User -> [Your PC Name] -> OSBot -> Scripts.

 

Source code:

 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.text.DecimalFormat;
import org.osbot.rs07.api.ui.RS2Widget;

import java.awt.*;
import java.util.concurrent.TimeUnit;

@ScriptManifest(author = "Tw3nty", info = "Makes pizza bases.", name = "T3 Pizza-baser", version = 0.2, logo = "")
public class T3Pizzabaser extends Script {

    private long timeBegan;
    private long timeRan;
    private int itemsMade;
    private int itemsMadehr;

    @Override
    public void onStart() {
        log("Let's make some motherfucking pizzas!");
        timeBegan = System.currentTimeMillis();
        itemsMade = 0;
    }

    private enum State {
        MAKE, BANK, IDLE, STOP;
    }

    private State getState() throws InterruptedException {
        if (inventory.contains("Bucket of water") && inventory.contains("Pot of flour")) {
            return State.MAKE;
        }
        else if (bank.open()) {
            if (bank.contains("Bucket of water") && bank.contains("Pot of flour")) {
                return State.BANK;
            }
            else {
                return State.STOP;
            }
        }
        else {
            return State.IDLE;
        }
    }

    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()) {
            case MAKE:
                if (bank.isOpen()) {
                    bank.close();
                    sleep(random(110, 320));
                }
                log("Case == MAKE");
                inventory.interact("Use", "Bucket of water");
                log("Interacting BoW...");
                sleep(random(110, 320));
                if (inventory.isItemSelected()) {
                    inventory.interact("Use", "Pot of flour");
                    log("Interacting PoF...");
                    sleep(random(970, 1975));
                }
                if (getDialogues().isPendingOption()) {
                    getDialogues().selectOption("Pizza dough");
                    log("Interacting Pizza dough...");
                    sleep(random(1020, 2050));
                    RS2Widget pizzaBase = widgets.get(309,2);
                    if (pizzaBase != null) {
                        pizzaBase.interact("Make All");
                        log("Interacting widget...");
                        sleep(random(10600, 12320));
                        itemsMade += 9;
                    }
                }
                break;
            case BANK:
                log("Case == BANK");
                if (inventory.contains("Bucket of water", "Pot of flour")) {
                    bank.depositAllExcept("Bucket of water","Pot of flour");
                    sleep(random(110, 320));
                }
                else if (!inventory.isEmpty()) {
                    bank.depositAll();
                    sleep(random(110, 320));
                }
                if (!inventory.contains("Bucket of water")) {
                    bank.withdraw("Bucket of water", 9);
                    sleep(random(110, 320));
                }
                if (!inventory.contains("Pot of flour")) {
                    bank.withdraw("Pot of flour", 9);
                    sleep(random(110, 320));
                }
                break;
            case IDLE:
                sleep (random(9100,11320));
                break;
            case STOP:
                stop();
                break;
        }
        return random(200, 300);
    }

    @Override
    public void onExit() {
        log("ENJOY YOUR PIZZAS!");
    }

    @Override
    public void onPaint(Graphics2D g) {
        timeRan = System.currentTimeMillis() - this.timeBegan;
        itemsMadehr = (int)(itemsMade / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
        g.drawString("Time ran: " + ft(timeRan), 10, 35);
        DecimalFormat df = new DecimalFormat("#");
        g.drawString("Pizza bases made: " + df.format(itemsMade), 10,50);
        g.drawString("Pizza bases per hour: " + df.format(itemsMadehr), 10,65);
    }

    private String ft(long duration)
    {
        String res = "";
        long days = TimeUnit.MILLISECONDS.toDays(duration);
        long hours = TimeUnit.MILLISECONDS.toHours(duration)
                - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
        long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
                - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
                .toHours(duration));
        long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
                .toMinutes(duration));
        if (days == 0) {
            res = (hours + ":" + minutes + ":" + seconds);
        } else {
            res = (days + ":" + hours + ":" + minutes + ":" + seconds);
        }
        return res;
    }
} 
Edited by Tw3nty
Link to comment
Share on other sites

You should do a conditional sleep method instead of a static reference of such high random numbers. Just think if you only have 7 pizzas left to make, you're going to be sleeping that entire time still.  


You should do a conditional sleep method instead of a static reference of such high random numbers. Just think if you only have 7 pizzas left to make, you're going to be sleeping that entire time still.  

Link to comment
Share on other sites

You should do a conditional sleep method instead of a static reference of such high random numbers. Just think if you only have 7 pizzas left to make, you're going to be sleeping that entire time still.  

You should do a conditional sleep method instead of a static reference of such high random numbers. Just think if you only have 7 pizzas left to make, you're going to be sleeping that entire time still.  

 

Normally I would do this but since there's no animation involved with making pizzas I didn't really put much effort into thinking about it :3  

 

A simple "while inventory still contains flour/water" is open to bugs if the player somehow gets interrupted mid pizza making, no? A static "oversleep" only happens at most once per script. If I ever feel like making this properly I'll probably look over it but this was just made to familiarize myself with Java and the API.

  • Like 1
Link to comment
Share on other sites

Normally I would do this but since there's no animation involved with making pizzas I didn't really put much effort into thinking about it :3  

 

A simple "while inventory still contains flour/water" is open to bugs if the player somehow gets interrupted mid pizza making, no? A static "oversleep" only happens at most once per script. If I ever feel like making this properly I'll probably look over it but this was just made to familiarize myself with Java and the API.

 

 

I created a custom method which involved inventory changes. Maybe that's enough of a hint for you to write something similar. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...