Jump to content

Jugs to jugs of water


Oboyabot

Recommended Posts

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
Link to comment
Share on other sites

Like @ProjectPactsaid, this can really easily be made with Script Factory.

 

Not sure what you're going to use it for, but do know that jug of water is one of the items that are restricted. So the money is alright, but you'll have to get around the restriction first before being able to sell 😉

  • Heart 1
Link to comment
Share on other sites

  • 2 weeks later...
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
Link to comment
Share on other sites

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