Jump to content

Jugs to jugs of water


Recommended Posts

Posted (edited)

Here you go.

[SPOILER]

package core;

import java.awt.Graphics2D;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Jug Filler", version = 1.1, author = "Marcus", logo = "", info = "Fills jugs in falador")

public class Main extends Script {

    private final Area waterPump = new Area(2949, 3382, 2950, 3383);
    private long startTime = System.currentTimeMillis();

    @Override
    public void onStart() throws InterruptedException {
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (hasJugs()) {
            walkPump();
            if (hasPump()) {
                fillJugs();
            }
        } else {
            if (!hasJugs())
                ;
            {
                bank();
            }
        }
        return 700;
    }

    public boolean hasJugs() {
        return (getInventory().contains("Jug") && (getInventory().isFull()));
    }

    public boolean hasPump() {
        RS2Object pump = getObjects().closest("Waterpump");
        return (pump != null && pump.isVisible());

    }

    private void bank() throws InterruptedException {
        if (!Banks.FALADOR_WEST.contains(myPosition())) {
            getWalking().webWalk(Banks.FALADOR_WEST);
        } else if (Banks.FALADOR_WEST != null && (!getBank().isOpen())) {
            getBank().open();
        } else if (!getInventory().isEmptyExcept("Jug")) {
            getBank().depositAllExcept("Jug");
        } else if (getBank().contains("Jug")) {
            getBank().withdrawAll("Jug");
            sleep(random(50, 150));
            getBank().close();
            sleep(random(50, 150));
            new ConditionalSleep(2000, 600) {
                @Override
                public boolean condition() {
                    return ((!getBank().isOpen()) && (inventory.getAmount("Jug") == 28));
                }
            }.sleep();
        } else {
            stop(false);
        }
    }

    public void fillJugs() throws InterruptedException {

        RS2Object waterPump = getObjects().closest("Waterpump");

        if ((!myPlayer().isAnimating()) && waterPump != null) {
            if (!getInventory().isItemSelected()) {
                getInventory().getItem("Jug").interact("Use");
                sleep(random(100, 250));
                waterPump.interact("Use");
                sleep(random(100, 200));
                getMouse().moveOutsideScreen();
                sleep(random(1000, 1500));
            }
            new ConditionalSleep(20000, 600) {
                @Override
                public boolean condition() {
                    return ((!myPlayer().isAnimating()) && (waterPump != null));
                }
            }.sleep();
        }
    }

    private void walkPump() throws InterruptedException {

        if (getInventory().isFull() && getInventory().contains("Jug")) {
            getWalking().walk(waterPump);
            sleep(random(50, 105));
            new ConditionalSleep(20000, 600) {
                @Override
                public boolean condition() {
                    return (waterPump.contains(myPosition()));
                }
            }.sleep();
        } else {
            stop(false);
        }
    }

    @Override
    public void onPaint(Graphics2D g) {

        super.onPaint(g);

        g.drawString("Jug Filler", 65, 255);
        g.drawString("Run time: " + String.valueOf(formatTime(System.currentTimeMillis() - startTime)), 15, 275);
    }

    private 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);
    }
}

 

[/SPOILER]

Edited by Lol_marcus
  • 2 weeks later...
Posted
On 10/26/2020 at 11:49 AM, Lol_marcus said:

Here you go.

[SPOILER]


package core;

import java.awt.Graphics2D;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Jug Filler", version = 1.1, author = "Marcus", logo = "", info = "Fills jugs in falador")

public class Main extends Script {

    private final Area waterPump = new Area(2949, 3382, 2950, 3383);
    private long startTime = System.currentTimeMillis();

    @Override
    public void onStart() throws InterruptedException {
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (hasJugs()) {
            walkPump();
            if (hasPump()) {
                fillJugs();
            }
        } else {
            if (!hasJugs())
                ;
            {
                bank();
            }
        }
        return 700;
    }

    public boolean hasJugs() {
        return (getInventory().contains("Jug") && (getInventory().isFull()));
    }

    public boolean hasPump() {
        RS2Object pump = getObjects().closest("Waterpump");
        return (pump != null && pump.isVisible());

    }

    private void bank() throws InterruptedException {
        if (!Banks.FALADOR_WEST.contains(myPosition())) {
            getWalking().webWalk(Banks.FALADOR_WEST);
        } else if (Banks.FALADOR_WEST != null && (!getBank().isOpen())) {
            getBank().open();
        } else if (!getInventory().isEmptyExcept("Jug")) {
            getBank().depositAllExcept("Jug");
        } else if (getBank().contains("Jug")) {
            getBank().withdrawAll("Jug");
            sleep(random(50, 150));
            getBank().close();
            sleep(random(50, 150));
            new ConditionalSleep(2000, 600) {
                @Override
                public boolean condition() {
                    return ((!getBank().isOpen()) && (inventory.getAmount("Jug") == 28));
                }
            }.sleep();
        } else {
            stop(false);
        }
    }

    public void fillJugs() throws InterruptedException {

        RS2Object waterPump = getObjects().closest("Waterpump");

        if ((!myPlayer().isAnimating()) && waterPump != null) {
            if (!getInventory().isItemSelected()) {
                getInventory().getItem("Jug").interact("Use");
                sleep(random(100, 250));
                waterPump.interact("Use");
                sleep(random(100, 200));
                getMouse().moveOutsideScreen();
                sleep(random(1000, 1500));
            }
            new ConditionalSleep(20000, 600) {
                @Override
                public boolean condition() {
                    return ((!myPlayer().isAnimating()) && (waterPump != null));
                }
            }.sleep();
        }
    }

    private void walkPump() throws InterruptedException {

        if (getInventory().isFull() && getInventory().contains("Jug")) {
            getWalking().walk(waterPump);
            sleep(random(50, 105));
            new ConditionalSleep(20000, 600) {
                @Override
                public boolean condition() {
                    return (waterPump.contains(myPosition()));
                }
            }.sleep();
        } else {
            stop(false);
        }
    }

    @Override
    public void onPaint(Graphics2D g) {

        super.onPaint(g);

        g.drawString("Jug Filler", 65, 255);
        g.drawString("Run time: " + String.valueOf(formatTime(System.currentTimeMillis() - startTime)), 15, 275);
    }

    private 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);
    }
}

 

[/SPOILER]

how to load it in osbot?i copy paste the txt and put it in the osbot folder but i cant see it in my scripts list.

  • Sad 1
Posted (edited)

i succeeded to compile it into a script and test it.it has a major flaw.it starts filling the jugs in the water pump and halfway clicks again a jug and then the water pump. and some times a third time. all that start again and again in a single row takes seconds away. resulting in less jugs to be filled per hour. can you repair it?

 

edit: script is broken.in the 15 minute running the player just sit doing nothing few meters away of the water pump. when i manually click him to go to the pump, he continue.

edit2: i manage to fix the player sitting and doing nothing if he is away from the water. but he keeps re-clicking the jug to fill every 7-8 even thought he has already start doing it. and losing many seconds do it so. i played with the sleep times but nothing changed.

edit3: i found the bot again idling. probably cause he hadn't a visual of the water pump. i had to turn manually a bit the camera so he can continue.

edit4: i see in the chat many times while he has start filling the text nothing interested happens...if that helps.

edit5: it got iddling again,even thought he had a clear view of the water but he was a little far of the pump.

that's it i cant change anything else. Can someone post a good script? the place there is full of bots doing it fast. thanks.

Edited by journey

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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