Jump to content

[F2P & P2P] Zammy wines


Shaft

Recommended Posts

Zammy wines

I found this script i wrote quite some time ago and decided to add paint an release it here.

Keep in mind the price checker isn't always right because it uses the osrs's api not osbuddy's api.

I've thrown in the source even tho it's not the cleanest code ever and shouldn't be used as an example for your scripts.

What does it do:

    -Grabs wines of zamorak

    -Banks

How to use:

    -Start anywhere with law, water and air runes or staves.

Source:

Spoiler

package WineGrabber;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Spells.NormalSpells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "Shaft", info = "Grabs wines of zamy", logo = "", name = "WineGrabber", version = 1.0)
public class main extends Script {

	private Area bank = new Area(2945, 3370, 2948, 3368);
	private Area standArea = new Area(2933, 3514, 2933, 3514);
	private Position wineTile = new Position(2930, 3515, 0);
	private int statusInt;
	private RS2Object booth;
	private Point mousePos;

	private int count;
	private boolean shouldRefresh, shouldGrab;
	private long count2, count3;
	private int price;
	private long startTime;

	public void onStart() {
		price = Calculations.getPrice(245);
		statusInt = 0;
		startTime = System.currentTimeMillis();
		shouldRefresh = true;
	}

	public int onLoop() throws InterruptedException {
		if (shouldGrab) {
			grab();
		} else if (shouldRefresh) {
			count2 = getInventory().getAmount(245);
			shouldRefresh = false;
		} else if (!getInventory().isFull()) {
			prepare();
			log("count3: " + count3);
			log("count2: " + count2);
			if (count3 > count2) {
				log(true);
				count++;
				shouldRefresh = true;
			}
		} else {
			bank();
		}
		if (!getInventory().contains(563))
			stop();
		return Calculations.Random(1, 3);
	}

	public void bank() throws InterruptedException {
		if (bank.contains(myPlayer())) {
			if (getBank().isOpen()) {
				log(true);
				getBank().depositAll(245);
				getBank().close();
				statusInt = 0;
			} else {
				booth = getObjects().closest(g -> g != null && g.getName().equalsIgnoreCase("Bank booth") && g.hasAction("Bank") && g.getX() <= 2948);
				booth.interact("Bank");
				new ConditionalSleep(4500, Calculations.Random(100, 200)) {
					public boolean condition() throws InterruptedException {
						return getBank().isOpen();
					}
				}.sleep();
			}
		} else {
			if (getMagic().canCast(NormalSpells.FALADOR_TELEPORT) && statusInt == 0) {
				getMagic().castSpell(NormalSpells.FALADOR_TELEPORT);
				sleep(Calculations.Random(424, 623));
				statusInt = 1;
			} else {
				getWalking().webWalk(bank);
			}
		}
	}

	public void prepare() throws InterruptedException {
		if (standArea.contains(myPlayer())) {
			getMagic().castSpell(NormalSpells.TELEKINETIC_GRAB);
			if(mousePos != null) getMouse().move((int)mousePos.getX() + Calculations.Random(-5, 5), (int)mousePos.getY() + Calculations.Random(-5, 5));
			else wineTile.hover(getBot());
			
			shouldGrab = true;
			sleep(Calculations.Random(500, 800));
			count3 = getInventory().getAmount(245);
		} else {
			getWalking().webWalk(standArea);
		}
	}

	public void grab() throws InterruptedException {
		GroundItem wine = getGroundItems().closest(i -> i != null && i.getId() == 245 && i.getName().equalsIgnoreCase("Wine of Zamorak")&& i.getPosition().getX() == wineTile.getX() && i.getPosition().getY() == wineTile.getY());
		if (wine == null)
			return;
		if (getMouse().getEntitiesOnCursor().contains(wine)) {
			if (getMouse().getEntitiesOnCursor().contains(getGroundItems().closest(i -> i != wine && i.getPosition().getX() == wineTile.getX() && i.getPosition().getY() == wineTile.getY())) || getMouse().getEntitiesOnCursor().contains(getNpcs().getAll())) {
				getMagic().castSpellOnEntity(NormalSpells.TELEKINETIC_GRAB, wine);
				log("grabbed with secondarry");
			}
			getMouse().click(false);
		} else {
			wine.hover();
			return;
		}
		mousePos = getMouse().getPosition();
		new ConditionalSleep(2000, Calculations.Random(50, 150)) {
			public boolean condition() throws InterruptedException {
				return !wine.exists();
			}
		}.sleep();
		shouldGrab = false;
	}

	public void onPaint(Graphics2D g) {
		g.setStroke(new BasicStroke(3));
		g.setColor(new Color(50, 50, 50, 150));
		g.fillRect(-5, 236, 150, 100);
		
		g.setColor(new Color(31, 221, 223));
		g.drawRect(-5, 236, 150, 100);
		long Runtime = System.currentTimeMillis() - startTime;

		long runtime = (int) (Runtime / 1000);
		long collectph = 3600 / runtime * count;
		long profitph = collectph * price;
		long profit = count * price;

		g.setColor(new Color(255, 255, 255));
		g.drawString("Shaft's wines", 20, 250);
		g.drawString("Wines grabbed: " + count, 5, 270);
		g.drawString("Wines p/h: " + collectph, 5, 290);
		g.drawString("profit made: " + profit, 5, 310);
		g.drawString("profit p/h: " + profitph, 5, 330);

	}
}

 

Download:

https://mega.nz/#!JpwVBCZR!KOHqeJ3pkVHSmKZe-kEg4U2YaPidSyqobQJqNvgcXHw

Link to comment
Share on other sites

  • 2 months later...
  • 7 months 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...