I wrote this primarily to experiment with dialogue, banking, conditional sleeps, using multiple classes, etc.
v .03 - Added Mind bombs/ Stouts/ Asgarnian ales due to request. Not going to bother updating source. Going to work on other projects now.
The script will do the following:
- Now can also buy Wizard Bombs / Stouts/ Asgarnian Ale in Falador.
- Buys beers at the Port Sarim bar.
- Deposits using the deposit box near the Entrana boat.
- If you reach 0 or 1 gp, the script will check the bank for more and log out if you are out of GP or only have 1 coin left. Same logic for Falador, only 2 GP rather than 1.
- Can walk from most areas to either bar.
- Averages about 20k/hr based on a 50gp sell price. The current guide price is 56, but I understand that is a stretch to sell at this price.
Progress report from my test on the script:
The source for the old script is below, if anything is conventionally incorrect or redundant, please let me know. I am more of a C/C++ person and this is my first OSBOT script.
Script should run fine, but if any issues arise I will fix them and update the JAR.
JAR is attached to the post.
Old script shell is below:
Main.java
package src;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
@ScriptManifest(author = "Aftermath", name = "Beer Purchaser", info = "Buys beer at Port Sarim", version = 0.2, logo = "")
public final class Main extends Script {
private Tasks check;
private Action action;
int beers = 0;
private long startedTime;
public final Area Bar = new Area(3045, 3256, 3044, 3258);
public final Area DepositBox = new Area(3047, 3236, 3043, 3236);
public void onStart() {
startedTime = System.currentTimeMillis();
check = new Tasks(this);
action = new Action(this);
}
@Override
public final int onLoop() throws InterruptedException {
if (check.hasCoins() & (!check.needsDeposit())) {
action.barWalk();
} else if (!check.hasCoins()) {
action.coinCheck();
}
if (!check.needsDeposit()) {
action.talkToBartender();
action.buy();
} else if (check.needsDeposit()) {
action.deposit();
}
return random(150, 200);
}
public void onPaint(Graphics2D g) {
Font font = new Font("Roman_Baseline", Font.ROMAN_BASELINE, 20);
g.setColor(Color.RED);
g.setFont(font);
g.setFont(g.getFont().deriveFont(18.0f));
g.drawString("Beer Buyer", 20, 360);
g.drawString("Beers purchased: " + (beers), 20, 375);
g.drawString("Profit earned: " + (beers * 50), 20, 390);
final long runTime = System.currentTimeMillis() - startedTime;
g.drawString("Run time: " + (formatTime(runTime)), 20, 405);
}
public final String formatTime(final long ms) {
long s = ms / 1000, m = s / 60, h = m / 60;
s %= 60;
m %= 60;
h %= 24;
return String.format("%02d:%02d:%02d", h, m, s);
}
}
Tasks.java
package src;
import org.osbot.rs07.script.MethodProvider;
public class Tasks extends MethodProvider {
Main main;
public Tasks(Main mainReference) {
this.main = mainReference;
}
public boolean needsDeposit() {
return (main.getInventory().isFull());
}
public boolean hasCoins() {
return (main.inventory.getAmount("Coins") > 1);
}
}
Action.java
package src;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;
public class Action extends MethodProvider {
Main main;
public Action(Main mainReference) {
this.main = mainReference;
}
public void barWalk() {
if (!main.Bar.contains(main.myPosition())) {
main.getWalking().webWalk(main.Bar);
}
}
public void coinCheck() throws InterruptedException {
if (!Banks.DRAYNOR.contains(main.myPosition())) {
main.getWalking().webWalk(Banks.DRAYNOR);
} else if (!main.getBank().isOpen()) {
main.getBank().open();
} else if (main.inventory.getAmount("Coins") <= 1) {
main.getBank().withdrawAll("Coins");
if (!main.getBank().contains("Coins") & (main.inventory.getAmount("Coins")) <= 1) {
sleep(random(200, 400));
this.main.stop();
}
}
}
public void deposit() throws InterruptedException {
if (!main.DepositBox.contains(main.myPosition())) {
main.getWalking().webWalk(main.DepositBox);
}
else if (main.DepositBox.contains(main.myPosition())) {
main.objects.closest("Bank deposit box").interact("Deposit");
main.sleep(random(1000,2000));
new ConditionalSleep(5000) {
public boolean condition() {
return (!main.getDepositBox().isOpen());
}
}.sleep();
} if (main.getDepositBox().isOpen()) {
main.getDepositBox().depositAllExcept("Coins");
}
}
public void talkToBartender() throws InterruptedException {
NPC bartender = main.npcs.closest("Bartender");
if (bartender != null) {
bartender.interact("Talk-to");
new ConditionalSleep(10000) {
public boolean condition() {
return (main.getDialogues().inDialogue());
}
}.sleep();
}
}
public void buy() throws InterruptedException {
if (main.dialogues.inDialogue()) {
main.dialogues.selectOption("Could I buy a beer please?");
sleep(random(400, 500));
if (main.dialogues.isPendingContinuation()) {
sleep(random(400, 600));
main.dialogues.completeDialogue();
sleep(random(400, 500));
this.main.beers++;
}
}
}
}
BeerPurchaser.jar