Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

OSBot Gilded Altar

Featured Replies

  • Developer

OSBot Gilded Altar

 

I wrote this for myself and wanted to share it as I wrote to be ready enough to be shared with others. Usually I don't make paints and add several variations to a script picked by a GUI, but I did it this time as I might be using it more often.

 

I'm releasing this script open source, some of you might find it interesting to look through it and learn from it. For anyone else, hopefully you put it to good use and grind some bones with it.

 

Features:

  • Use a host or your own house
  • Walking from Yanille bank to Yanille house and vica versa
  • Instead of walking, use House teleport tabs or House teleport combined with a mounted Amulet of Glory in your house
  • Choice between offering Dragon bones, Big Bones and normal bones
  • Never ever offers bones when there are no 2 lit Incense burners
  • Automatic door support, will work with every house setup
  • Begin anywhere in your house, near a bank or near your portal (depending on setup) without supplies

GUI:

 

MTd1XNw.png

 

Progress report:

 

ZgKDc8g.png

 

Download JAR:

 

 
Code:

package osbot.maxi.script.gildedaltar;
 
import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.model.Item;
import org.osbot.script.rs2.model.RS2Object;
import org.osbot.script.rs2.skill.Skill;
import org.osbot.script.rs2.ui.Spell;
import org.osbot.script.rs2.utility.Area;
import org.osbot.script.rs2.utility.ConditionalSleep;
 
import java.awt.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
 
/**
 * Created with IntelliJ IDEA.
 * User: Maxi
 */
@ScriptManifest(name = "GildedAltar", author = "Maxi", version = 1.0D,
        info = "Offers Dragon bones, Big bones and normal bones on a Gilded Altar located in your or a friend's " +
                "with various transportation options.")
public class GildedAltar extends Script {
 
    private DoorHandler doorHandler = null;
    private long startTime = 0;
    private int startXp = 0;
    private GildedAltarGUI gui = new GildedAltarGUI();
    private boolean configured = false;
 
    private State state;
    private String host = null;
    private ToHouseMethod toHouseMethod;
    private ToBankMethod toBankMethod;
    private String bonesName;
 
    private static final Area WALK_AREA = new Area(2586, 3096, 2589, 3098);
 
    private static enum State {
        ENTER_HOUSE,
        TO_ALTAR,
        LIGHT_BURNERS,
        OFFER_BONES,
        TO_BANK,
        RESTOCK,
        TO_HOUSE,
        QUIT
    }
 
    private static enum ToHouseMethod {
        WALK(0, new String[] { "Tinderbox", "Marrentill" }, 25, 15),
        TELEPORT(1, new String[] { "Law rune", "Earth rune", "Tinderbox", "Marrentill" }, 23, 60),
        TELETAB(2, new String[] { "Teleport to house", "Tinderbox", "Marrentill" }, 24, 252);
 
        public int index;
        public String[] validItems;
        public int noBones;
        public int xp;
 
        private ToHouseMethod(int index, String[] validItems, int noBones, int xp) {
            this.index = index;
            this.validItems = validItems;
            this.noBones = noBones;
            this.xp = xp;
        }
 
        public static ToHouseMethod forIndex(int index) {
            for (ToHouseMethod method : ToHouseMethod.values()) {
                if (index == method.index)
                    return method;
            }
            return null;
        }
    }
 
    private static enum ToBankMethod {
        WALK(0),
        GLORY(1);
 
        public int index;
 
        private ToBankMethod(int index) {
            this.index = index;
        }
 
        public static ToBankMethod forIndex(int index) {
            for (ToBankMethod method : ToBankMethod.values()) {
                if (index == method.index)
                    return method;
            }
            return null;
        }
    }
 
    @Override
    public void onStart() {
        doorHandler = new DoorHandler();
        doorHandler.provideBot(bot);
        gui.setVisible(true);
    }
 
    @Override
    public int onLoop() throws InterruptedException {
        if (!gui.started)
            return 10;
        if (!configured) {
            configure();
        }
        scan();
        log("State = " + state.toString());
        switch (state) {
            case ENTER_HOUSE:
                return enterHouse();
            case TO_ALTAR:
                return toAltar();
            case LIGHT_BURNERS:
                return lightBurners();
            case OFFER_BONES:
                return offerBones();
            case TO_BANK:
                return toBank();
            case RESTOCK:
                return restock();
            case TO_HOUSE:
                return toHouse();
            case QUIT:
                log("Something went wrong, shutting down script");
                return -1;
 
        }
        return -1;
    }
 
    private void configure() {
        if (gui.useHostCheckbox.isSelected()) {
            host = gui.hostNameTextField.getText();
        } else {
            host = null;
        }
        toHouseMethod = ToHouseMethod.forIndex(gui.toHouseMethodComboBox.getSelectedIndex());
        toBankMethod = ToBankMethod.forIndex(gui.toBankMethodComboBox.getSelectedIndex());
        bonesName = (String) gui.boneTypeComboBox.getSelectedItem();
        startTime = System.currentTimeMillis();
        startXp = client.getSkills().getExperience(Skill.PRAYER);
        configured = true;
    }
 
    private int toHouse() throws InterruptedException {
        switch (toHouseMethod) {
            case WALK:
                return enterHouse();
            case TELEPORT:
                return teleportToHouse();
            case TELETAB:
                return teleportToHouseTab();
            default:
                log("No proper to house method found, shutting down...");
                return -1;
        }
    }
 
    private int toBank() throws InterruptedException {
        switch (toBankMethod) {
            case WALK:
                return exitHouse();
            case GLORY:
                return useMountedGlory();
            default:
                log("No proper to bank method found, shutting down...");
                return -1;
        }
    }
 
    private int exitHouse() throws InterruptedException {
        setRunning(true);
        if (isInHouse()) {
            RS2Object portal = closestObjectForName("portal");
            if (portal != null) {
                if (!doorHandler.handleNextObstacle(portal)) {
                    portal.interact("enter");
                }
            } else {
                warn("Could not find entry portal!");
            }
        } else {
            return 10 + gRandom(10, 10);
        }
        return 10 + gRandom(10, 10);
    }
 
    private int teleportToHouse() throws InterruptedException {
        closeOpenInterface();
        if (magicTab.castSpell(Spell.HOUSE_TELEPORT)) {
            waitForHouse();
            return 10 + gRandom(10, 10);
        } else {
            return 10 + gRandom(10, 10);
        }
    }
 
    private int teleportToHouseTab() throws InterruptedException {
        closeOpenInterface();
        if (client.getInventory().interactWithName("Teleport to house", "Break")) {
            waitForHouse();
            return 10 + gRandom(10, 10);
        } else {
            return 10 + gRandom(10, 10);
        }
    }
 
    private void waitForHouse() throws InterruptedException {
        new ConditionalSleep(5000) {
            @Override
            public boolean condition() {
                return client.getValidInterfaces()[399];
            }
        }.sleep();
        new ConditionalSleep(10000) {
            @Override
            public boolean condition() {
                return !client.getValidInterfaces()[399];
            }
        }.sleep();
    }
 
    private boolean restockLawRunes() throws InterruptedException {
        Item lawRune = client.getBank().getItemForName("Law rune");
        if (lawRune != null) {
            return client.getBank().withdrawX(lawRune.getId(), 100);
        } else {
            log("You have no law runes left in your bank or inventory, shutting down...");
            return false;
        }
    }
 
    private boolean restockEarthRunes() throws InterruptedException {
        Item earthRune = client.getBank().getItemForName("Earth rune");
        if (earthRune != null) {
            return client.getBank().withdrawX(earthRune.getId(), 100);
        } else {
            log("You have no earth runes left in your bank or inventory, shutting down...");
            return false;
        }
    }
 
    private boolean restockTabs() throws InterruptedException {
        Item tab = client.getBank().getItemForName("Teleport to house");
        if (tab != null) {
            return client.getBank().withdrawX(tab.getId(), 100);
        } else {
            log("You have no law runes left in your bank or inventory, shutting down...");
            return false;
        }
    }
 
    private boolean restockTeleportSupplies() throws InterruptedException {
        switch (toHouseMethod) {
            case TELEPORT:
                if (!client.getInventory().contains("Law rune") && !restockLawRunes()) {
                    return false;
                }
                if (!client.getInventory().contains("Earth rune") && !restockEarthRunes()) {
                    return false;
                }
                break;
            case TELETAB:
                if (!client.getInventory().contains("Teleport to house") && !restockTabs()) {
                    return false;
                }
                break;
        }
        return true;
    }
 
    private boolean hashAllRequiredSupplies() {
        if (client.getInventory().getAmount("Tinderbox") != 1) {
            log("Too little or too many tinderboxes in inventory...");
            return false;
        }
        switch (toHouseMethod) {
            case TELEPORT:
                if (!client.getInventory().contains("Law rune"))
                    return false;
                if (!client.getInventory().contains("Earth rune"))
                    return false;
                break;
            case TELETAB:
                if (!client.getInventory().contains("Teleport to house"))
                    return false;
                break;
        }
        if (client.getInventory().getAmount("Marrentill") != 2) {
            return false;
        }
        if (client.getInventory().getAmount(bonesName) < toHouseMethod.noBones) {
            return false;
        }
        return true;
    }
 
    private boolean restockMarrentills() throws InterruptedException {
        int curAmount = (int) client.getInventory().getAmount("Marrentill");
        int needed = 2 - curAmount;
        if (needed < 0) {
            int toStore = curAmount - 2;
            for (; toStore > 0; ) {
                client.getBank().deposit1(client.getInventory().getItemForName("Marrentill").getId());
                sleep(5 + gRandom(10, 5));
            }
        } else {
            Item marrentil = client.getBank().getItemForName("Marrentill");
            if (marrentil != null) {
                for (; needed > 0;) {
                    if (client.getBank().withdraw1(marrentil.getId())) {
                        needed--;
                        sleep(5 + gRandom(10, 5));
                    }
                }
            } else {
                log ("We ran out of marrentills, shutting down...");
                return false;
            }
        }
        return true;
    }
 
    private boolean restockTinderbox() throws InterruptedException {
        if (!client.getInventory().contains("Tinderbox")) {
            Item tinderBox = client.getBank().getItemForName("Tinderbox");
            if (tinderBox != null) {
                client.getBank().withdraw1(tinderBox.getId());
            } else {
                log("You have no tinderbox in your bank or inventory, shutting down...");
                return false;
            }
        } else if (client.getInventory().getAmount("Tinderbox") > 1) {
            Item tinderBox = client.getInventory().getItemForName("Tinderbox");
            int toStore = (int) client.getInventory().getAmount("Tinderbox") - 1;
            if (tinderBox != null) {
                client.getBank().depositX(tinderBox.getId(), toStore);
            }
        }
        return true;
    }
 
    private boolean restockBones() throws InterruptedException {
        if (client.getInventory().getAmount(bonesName) < toHouseMethod.noBones) {
            Item bones = client.getBank().getItemForName(bonesName);
            if (bones != null) {
                client.getBank().withdrawAll(bones.getId());
            } else {
                log("We ran out of " + bonesName + ", shutting down...");
                return false;
            }
        }
        return true;
    }
 
    private int restock() throws InterruptedException {
        if (client.getBank().isOpen()) {
            client.getBank().depositAllExcept(toHouseMethod.validItems);
            if (hashAllRequiredSupplies())
                return 10 + gRandom(10, 10);
            if (!restockTeleportSupplies())
                return -1;
            if (!restockTinderbox())
                return -1;
            if (!restockMarrentills())
                return -1;
            if (!restockBones())
                return -1;
            if (client.getInventory().contains(toHouseMethod.validItems))
                return 10 + gRandom(10, 10);
            else
                return 10 + gRandom(10, 10);
        } else {
            if (hashAllRequiredSupplies())
                return 10 + gRandom(10, 10);
            else {
                RS2Object bank = closestObjectForName("Bank booth");
                if (bank != null) {
                    if (bank.interact("Bank")) {
                        new ConditionalSleep(2000) {
                            @Override
                            public boolean condition() {
                                return client.getBank().isOpen();
                            }
                        }.sleep();
                    }
                    return 100 + gRandom(20, 50);
                } else {
                    walk(WALK_AREA, 1);
                    return 10 + gRandom(10, 10);
                }
            }
        }
    }
 
    private int useMountedGlory() throws InterruptedException {
        RS2Object glory = closestObjectForName("Amulet of Glory");
        if (glory != null && !doorHandler.handleNextObstacle(glory)) {
            this.walk(glory, false, 6, true, false);
            client.moveCameraToEntity(glory);
            client.rotateCameraPitch(20);
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    return !myPlayer().isMoving();
                }
            }.sleep();
            if (glory.interact("Rub")) {
                if (!new ConditionalSleep(7000) {
                    @Override
                    public boolean condition() {
                        return client.getValidInterfaces()[234];
                    }
                }.sleep()) {
                    log("Glory interface did not show up within 7 seconds.. retrying");
                    return 5 + gRandom(5, 5);
                } else {
                    if (client.getInterface(234).getChild(1).interact()) {
                        new ConditionalSleep(5000) {
                            @Override
                            public boolean condition() {
                                return !isInHouse();
                            }
                        }.sleep();
                        return 5 + gRandom(5, 5);
                    } else {
                        return 50 + gRandom(50, 50);
                    }
                }
            } else {
                if (client.getValidInterfaces()[234]) {
                    if (client.getInterface(234).getChild(1).interact()) {
                        new ConditionalSleep(5000) {
                            @Override
                            public boolean condition() {
                                return !isInHouse();
                            }
                        }.sleep();
                        return 5 + gRandom(5, 5);
                    } else {
                        return 50 + gRandom(50, 50);
                    }
                }
                return 50 + gRandom(50, 50);
            }
        } else {
            log("Error with finding/walking glory");
            return 100 + gRandom(100, 100);
        }
    }
 
    private int offerBones() throws InterruptedException {
        client.rotateCameraPitch(67);
        new ConditionalSleep(5000) {
            @Override
            public boolean condition() {
                return !myPlayer().isMoving();
            }
        }.sleep();
        RS2Object altar = closestObjectForName("Altar");
        if (altar != null) {
            final int slot = client.getInventory().getSlotForName(bonesName);
            if (slot < 0)
                return 10 + gRandom(10, 10);
            client.getInventory().interactWithName(bonesName, "Use");
            sleep(30 + gRandom(20, 20));
            altar.interact("Use", true);
            new ConditionalSleep(1200) {
                @Override
                public boolean condition() {
                    return client.getInventory().getItems()[slot] == null;
                }
            }.sleep();
            return 10 + gRandom(20, 20);
        } else {
            log("Couldn't find altar, shutting down...");
            return -1;
        }
    }
 
    private int lightBurners() throws InterruptedException {
        client.rotateCameraPitch(67);
        List<RS2Object> burners = closestObjectListForName("Incense burner");
        for (final RS2Object burner : burners) {
            for (String s : burner.getDefinition().getActions()) {
                if (s != null && s.toLowerCase().contains("light")) {
                    if (burner.interact("Light", 9, false)) {
                        new ConditionalSleep(1000) {
                            @Override
                            public boolean condition() {
                                return !burner.exists();
                            }
                        }.sleep();
                        return 100 + gRandom(100, 100);
                    } else
                        return 10 + gRandom(10, 10);
                }
            }
        }
        return 10 + gRandom(10, 10);
    }
 
    private int toAltar() throws InterruptedException {
        final RS2Object altar = closestObjectForName("Altar");
        if (altar != null && distance(altar) > 2) {
            if (!doorHandler.handleNextObstacle(altar)) {
                this.walk(altar, false, 2, true, false);
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() {
                        return distance(altar) <= 2;
                    }
                }.sleep();
            } else {
                return 400 + gRandom(100, 100);
            }
        }
        return 100 + gRandom(100, 100);
    }
 
    private int enterHouse() throws InterruptedException {
        if (client.getInterface(232) != null && client.getInterface(232).getChild(1).isVisible()
                && client.getInterface(232).getChild(1).getMessage().equalsIgnoreCase("go to your house")) {
            if (host == null) {
                if (client.getInterface(232).getChild(1).interact()) {
                    waitForHouse();
                }
            } else {
                client.getInterface(232).getChild(3).interact();
                if (new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() {
                        return client.getInterface(137) == null || !client.getInterface(137).isVisible();
                    }
                }.sleep()) {
                    type(host);
                    waitForHouse();
                } else {
                    return 200 + gRandom(50, 50);
                }
            }
            return 3000 + gRandom(600, 200);
        }
        setRunning(true);
        RS2Object portal = closestObjectForName("portal");
        if (portal != null) {
            if (!doorHandler.handleNextObstacle(portal)) {
                portal.interact("enter");
            }
        } else {
            warn("Could not find entry portal!");
        }
        return 600 + gRandom(300, 100);
    }
 
    private void scan() {
        if (state == State.OFFER_BONES) {
            if (client.getInventory().contains(bonesName) && isInHouse()) {
                List<RS2Object> burners = closestObjectListForName("Incense burner");
                if (!burners.isEmpty()) {
                    for (RS2Object burner : burners) {
                        for (String s : burner.getDefinition().getActions()) {
                            if (s != null && s.toLowerCase().contains("light")) {
                                if (client.getInventory().getAmount("Marrentill") >= 0) {
                                    state = State.LIGHT_BURNERS;
                                    return;
                                } else {
                                    state = State.TO_BANK;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (isInHouse()) {
            if (!client.getInventory().contains(bonesName)) {
                state = State.TO_BANK;
                return;
            }
            RS2Object altar = closestObjectForName("Altar");
            if (altar != null && distance(altar) > 3) {
                state = State.TO_ALTAR;
                return;
            } else {
                List<RS2Object> burners = closestObjectListForName("Incense burner");
                if (!burners.isEmpty()) {
                    for (RS2Object burner : burners) {
                        for (String s : burner.getDefinition().getActions()) {
                            if (s != null && s.toLowerCase().contains("light")) {
                                if (client.getInventory().getAmount("Marrentill") >= 0) {
                                    state = State.LIGHT_BURNERS;
                                    return;
                                } else {
                                    state = State.TO_BANK;
                                    return;
                                }
                            }
                        }
                    }
                }
                if (client.getInventory().contains(bonesName)) {
                    state = State.OFFER_BONES;
                    return;
                }
            }
        } else {
            if (hashAllRequiredSupplies()) {
                RS2Object portal = closestObjectForName("Portal");
                if (portal != null && distance(portal) < 10) {
                    state = State.ENTER_HOUSE;
                    return;
                }
                state = State.TO_HOUSE;
                return;
            } else {
                state = State.RESTOCK;
                return;
            }
 
        }
    }
 
    private int getBonesPerHour() {
        if (gui.started && configured) {
            int exp = client.getSkills().getExperience(Skill.PRAYER) - startXp;
            int noBones = exp / toHouseMethod.xp;
            long time = System.currentTimeMillis() - startTime;
            if (time == 0)
                return 0;
            return (int) (((double) noBones / (double) time) * 3600000D);
        }
        return 0;
    }
 
    @Override
    public void onPaint(Graphics g) {
        g.setColor(new Color(0, 0, 0, 120));
        g.fillRect(10, 300, 500, 35);
        g.setColor(Color.green);
        if (gui.started && configured) {
            long time = System.currentTimeMillis() - startTime;
            g.drawString("Bones/hour : " + getBonesPerHour(), 15, 315);
            int exp = client.getSkills().getExperience(Skill.PRAYER) - startXp;
            g.drawString("Exp/hour : " + (int) (exp == 0 ? 0 : (3600000D / (((double) time) / ((double) exp)))), 15, 330);
            g.drawString("Bones: " + exp / toHouseMethod.xp, 190, 315);
            g.drawString("Exp: " + exp, 190, 330);
            g.drawString("State : " + state, 352, 315);
            g.drawString("Time running : " + formatTime(time), 352, 330);
        } else {
            g.drawString("Bones/hour : 0", 15, 315);
            g.drawString("Exp/hour : 0", 15, 330);
            g.drawString("Bones: 0", 190, 315);
            g.drawString("Exp: 0", 190, 330);
            g.drawString("State : Unstarted" + state, 352, 315);
            g.drawString("Time running : 00:00:00:00", 352, 330);
        }
    }
 
    private String formatTime(final long l) {
        final long day = TimeUnit.MILLISECONDS.toDays(l);
        final long hr = TimeUnit.MILLISECONDS.toHours(l - TimeUnit.DAYS.toMillis(day));
        final long min = TimeUnit.MILLISECONDS.toMinutes(l - TimeUnit.DAYS.toMillis(day)
                - TimeUnit.HOURS.toMillis(hr));
        final long sec = TimeUnit.MILLISECONDS.toSeconds(l - TimeUnit.DAYS.toMillis(day)
                - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min));
        final long ms = TimeUnit.MILLISECONDS.toMillis(l - TimeUnit.DAYS.toMillis(day)
                - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min) - TimeUnit.SECONDS.toMillis(sec));
        return String.format("%02d:%02d:%02d:%02d", day, hr, min, sec);
    }
 
}
 
Enjoy!

cool release

nice that you made the code public aswell so that coders can learn from the best :)

fml... if only you had released this 5 days ago before my main got banned botting 84-99 prayer :( i even looked for a script that would tele or use my own house so i wouldnt look suspicious since im ranked in 07 altar cc :( Now i can only hope my main gets unbanned tomorrow with the help of a jagex connection *fingers crossed* Great script though, wish i had a chance to use it...

I am getting this error:

 

Too little or too many tinderboxes in inventory...

I am getting this error:

 

Too little or too many tinderboxes in inventory...

Same...

and when you start it in the house, it clicks on the bone but doesn't click on the altar. 

Wow this script  looks great. Good work.

I am getting this error:

 

Too little or too many tinderboxes in inventory...

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.