Jump to content

Al-Kharid Gold amulet (u) bot


0x7CB

Recommended Posts

I searched through the SDN but the free ones weren't working, so I made one myself. Make sure you have an Amulet mould in your inventory. I've ran it for an hour twice but didn't take a picture, I might add a progress report later (you are free to post yours as well of course).

 

Download link

http://s000.tinyupload.com/index.php?file_id=42385377592917125400

 

Source

Spoiler

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
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;

import java.awt.*;

@ScriptManifest(name = "HexAmulets", version = 1.0, author = "0x7BC", logo = "", info = "Makes Gold amulets (u) in Al-Kharid")
public class HexAmulets extends Script {

    private Area furnaceArea = new Area(3274, 3184, 3279, 3188);

    private long startTime;

    @Override
    public void onStart()  {
        startTime = System.currentTimeMillis();

        getExperienceTracker().start(Skill.CRAFTING);
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (hasGoldBars()) {
            if (atFurnace()) {
                smelt();
            } else {
                walkToFurnace();
            }
        } else {
            if (atBank()) {
                bank();
            } else {
                walkToBank();
            }
        }
        return random(650, 950);
    }

    private boolean hasGoldBars() {
        return getInventory().contains("Gold bar");
    }

    private boolean atFurnace() {
        return furnaceArea.contains(myPosition());
    }

    private boolean atBank() {
        return Banks.AL_KHARID.contains(myPosition());
    }

    private void smelt() {
        if (getWidgets().get(446, 34) == null) {
            getObjects().closest("Furnace").interact("Smelt");
            new ConditionalSleep(1000, 400) {
                @Override
                public boolean condition() {
                    return getWidgets().get(446, 34) != null;
                }
            }.sleep();
        } else {
            getWidgets().get(446, 34).interact("Make-All");
            new ConditionalSleep(50_000, 600) {
                @Override
                public boolean condition() {
                    return !hasGoldBars() || getDialogues().isPendingContinuation();
                }
            }.sleep();
        }
    }

    private void bank() throws InterruptedException {
        if (getBank().isOpen()) {
            if (getInventory().contains("Gold amulet (u)")) {
                getBank().depositAll("Gold amulet (u)");
            } else {
                getBank().withdrawAll("Gold bar");
            }
        } else {
            getBank().open();
        }
    }

    private void walkToFurnace() {
        getWalking().webWalk(furnaceArea);
    }

    private void walkToBank() {
        getWalking().webWalk(Banks.AL_KHARID);
    }

    @Override
    public void onPaint(Graphics2D g) {
        Font font = new Font("Arial", Font.PLAIN, 18);
        g.setFont(font);
        g.drawString("Running: " + formatTime(System.currentTimeMillis() - startTime), 10, 40);
        g.drawString("Levels: + " + getExperienceTracker().getGainedLevels(Skill.CRAFTING), 10, 70);
        g.drawString("Exp Gained: + " + format(getExperienceTracker().getGainedXP(Skill.CRAFTING)), 10, 100);
    }

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

    private String format(long l) {
        return (l > 1_000_000) ? String.format("%.2fM", ((double) l / 1_000_000)) : (1 > 1000) ? String.format("%0.1K", ((double) l / 1000)) : l + "";
    }
}

 

 

Link to comment
Share on other sites

  • 1 year 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...