Jump to content

Sulphurous Fertiliser


Durky

Recommended Posts

I whipped this up tonight, start it in any bank with or without the compost or the saltpetre in your inventory.

i know other people have made this, i just don't run other peoples free scripts no offense to anyone. Heres my version.

 

import java.awt.Graphics2D;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "Durky", name = "Sulphurous Fertiliser", info = "Combines compost and Saltpetre", version = 1.0, logo = "")

public class main extends Script {
	private String Sulphurousfertiliser = "Sulphurous fertiliser";
	private String Compost = "Compost";
	private String Saltpetre = "Saltpetre";
	private boolean opened = false;
	private boolean lastInventory = false;
	private int leftOverAmount = 14;
	private long startTime;
	private int amountMade = 0;
	private String status;
	private State playerState = State.COMBINING;

	@Override
	public void onStart() {
		startTime = System.currentTimeMillis();
		status = "Starting up!";
	}

	public enum State {
		BANKING, COMBINING, SHUTTING_DOWN;
	}

	private int sleepDelay = 2500;
	private long iterations;

	@Override
	public int onLoop() throws InterruptedException {
		switch (playerState) {

		case BANKING:
			if (!opened) {
				log("attempting to open bank.");
				status = "Opening Bank, getting more!";
				opened = true;
				if (!getBank().isOpen()) {
					getBank().open();
					new ConditionalSleep(5000) {
						public boolean condition() {
							return getBank().isOpen();
						}
					}.sleep();
				}
			}
			if (getBank().isOpen()) {
				status = "Removing Items from the bank!";
				if (getInventory().contains(Sulphurousfertiliser)) {
					getBank().depositAll();
					amountMade += getInventory().getAmount(Sulphurousfertiliser);
				}
				sleep(random(500, 1000));
				if (getBank().getAmount(Saltpetre) > 13) {
					getBank().withdraw(Saltpetre, 14);
				} else {
					leftOverAmount = (int) getBank().getAmount(Saltpetre);
					getBank().withdraw(Saltpetre, leftOverAmount);
					lastInventory = true;
					log("down to the last " + leftOverAmount + " saltpetre");
					status = "Last Inventory! out of saltpetre";
				}
				sleep(random(500, 1000));
				if (getBank().getAmount(Compost) > 13) {
					getBank().withdraw(Compost, 14);
				} else {
					leftOverAmount = (int) getBank().getAmount(Compost);
					getBank().withdraw(Compost, leftOverAmount);
					lastInventory = true;
					log("down to the last " + leftOverAmount + " compost");
					status = "Last Inventory! out of compost";
				}
				getBank().close();
				opened = false;

				setPlayerState(State.COMBINING);
			}
			break;

		case COMBINING:
			if (!getInventory().isEmpty()) {
				if (getInventory().contains(Compost) && getInventory().contains(Saltpetre)) {
					getInventory().getItem(Compost).interact("Use");
					sleep(250);
					getInventory().getItem(Saltpetre).interact("Use");
					iterations = getInventory().getAmount(Compost) >= getInventory().getAmount(Saltpetre)
							? getInventory().getAmount(Compost)
							: getInventory().getAmount(Saltpetre);
					status = "Combining the materials!";
					amountMade += iterations;
					sleep((int) sleepDelay * iterations);
					setPlayerState(lastInventory ? State.SHUTTING_DOWN : State.BANKING);
				}
				else
					setPlayerState(State.BANKING);
			} else
				setPlayerState(State.BANKING);

			break;
		case SHUTTING_DOWN:
			log("Shutting down, thanks!");
			stop();
			break;
		}
		return 500;
	}

	public State getPlayerState() {
		return playerState;
	}

	public void setPlayerState(State playerState) {
		this.playerState = playerState;
	}

	@Override
	public void onPaint(Graphics2D g) {
		g.drawString("Run time: " + formatTime(System.currentTimeMillis() - startTime), 10, 304);
		g.drawString("Bot Status: " + status, 10, 320);
		g.drawString("You have currently made " + amountMade + " Sulphurous fertiliser!", 10, 334);
	}

	public final String formatTime(final long ms) {
		long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
		s %= 60;
		m %= 60;
		h %= 24;

		return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
				: h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s);
	}

}

 

SulphurousFertiliser.jar

Edited by Durky
  • Like 1
Link to comment
Share on other sites

  • 2 years later...

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...