Jump to content

FTP Beer Buyer/Mind Bomb/Dwarf Stouts


Veni

Recommended Posts

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:

proggy.png.f3b6a7265654f483d9503d9f8c6d21ee.png

 

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

Edited by Aftermath
Link to comment
Share on other sites

17 hours ago, Aftermath said:

I wrote this primarily to experiment with dialogue, banking, conditional sleeps, using multiple classes, etc. 

 

The script will do the following:

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

- Can walk from most areas to the 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:

proggy.png.f3b6a7265654f483d9503d9f8c6d21ee.png

 

The source for the 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 source. Hoping to get some feedback.  I didn't go very heavy on paint as this script is simple.

JAR is attached to the post. 

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

 

screenshot_25_12_2018-07_04_31.png

Link to comment
Share on other sites

1 hour ago, Aftermath said:

@doge24865

Thanks for running the script and posting a prog.

np personally the price for beer now a days is so bad its not even worth doing I maybe got 40 gp per beer so really might be worth it to make a bot for the wizard mind bombs in falador. 88gp each in the ge for them.

Edited by doge24865
Link to comment
Share on other sites

1 hour ago, doge24865 said:

np personally the price for beer now a days is so bad its not even worth doing I maybe got 40 gp per beer so really might be worth it to make a bot for the wizard mind bombs in falador. 88gp each in the ge for them.

6

I did notice they are definitely sinking in price. I will add mind bombs into the script soon. 

Probably in a day or two.

Edited by Aftermath
Link to comment
Share on other sites

I was selling them by the tens of thousands with another script because I was having such a low banrate. Maybe we dropped the price together. <3 They were going for 88gp before I started. Mind bombs are decent but the Dwarven Stouts sell slow even at a dramatic price decrease. I'll give this script a try it has a better profit/beer counter. Will post you a proggy tomorrow hopefully.  If you could add mind bombs that'd be dope. 

Edited by fennecer
Link to comment
Share on other sites

On ‎12‎/‎31‎/‎2018 at 4:40 PM, fennecer said:

I was selling them by the tens of thousands with another script because I was having such a low banrate. Maybe we dropped the price together. <3 They were going for 88gp before I started. Mind bombs are decent but the Dwarven Stouts sell slow even at a dramatic price decrease. I'll give this script a try it has a better profit/beer counter. Will post you a proggy tomorrow hopefully.  If you could add mind bombs that'd be dope. 

3
3

I wrote an update with a GUI that can do Mind Bombs/Stout/Asg. ale a few days ago. Thanks for reminding me. 

added the new jar file.

Edited by Aftermath
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...