Jump to content
JioMy

[WIP] Jio's - Enchanter [Currently only Burning Amulets ] [Open Source]

Recommended Posts

Hello

Here's a Jewellery Enchanter i have been working.

Features:

  • Makes Burning Amulets
  • Equips Required Staff if not already
  • Gui & Paint will be added once it's an AIO
  • Tested it by making 5k amulets. 

Current Bugs: 

  • Breaks if started with bank open
  • Doesnt check if bank has items ( Didn't add it yet.)

 

How to use:

make sure you have required items in bank & hit start.

 

Here's the Source if you are looking for it:

Enchanter.java

Spoiler

package Magic;

import Utils.Sleep;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.ui.EquipmentSlot;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;

import static org.osbot.rs07.script.MethodProvider.random;

public class Enchanter {
    private final Script ctx;


    public Enchanter(Script ctx) {
        this.ctx = ctx;
    }

    public void doTask() throws InterruptedException {

        if (!staffIsOn() && !needStaff() && !ctx.getBank().isOpen()) {
            equipStaff();
        } else {
            if (hasItems() && staffIsOn()) {
                cast();
            } else {
                if (!ctx.getBank().isOpen()) {
                    openBank();
                    if (needToDepositBurnings()) {
                        depositAllBurnings();
                    }
                    if (needRunes()) {
                        getRunes();
                    }
                    if (needStaff() && !staffIsOn()) {
                        getStaff();
                    }
                    if (needAmulets() && !needToDepositBurnings()) {
                        withdrawAmulets();
                    }
                    closeBank();
                }
            }
        }
    }

    private void getRunes() {
        ctx.log("Getting runes");
        if (ctx.getBank().withdrawAll("Cosmic rune")) {
            Sleep.sleepUntil(() -> ctx.getInventory().contains("Cosmic rune"), random(1200, 2050));
        }
    }

    private void getStaff() {

        ctx.log("Getting Staff");
        if (ctx.getBank().withdraw("Staff of fire", 1)) {
            Sleep.sleepUntil(() -> !needStaff(), random(1200, 1550));
        }

    }

    private void equipStaff() {
        ctx.log("Equipping staff");
        if (ctx.getEquipment().equipForNameThatContains(EquipmentSlot.WEAPON, "Staff of fire")) {
            Sleep.sleepUntil(this::staffIsOn, random(1500, 2500));
        }
    }

    private void withdrawAmulets() {
        ctx.log("Withdrawing Topaz amulets");

        if (!ctx.getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of fire")) {
            if (ctx.getBank().withdraw("Topaz amulet", 26)) {
                Sleep.sleepUntil(()->!needAmulets(), random(1000, 1250));
            }
        } else {
            if (ctx.getBank().withdraw("Topaz amulet", 27))
                Sleep.sleepUntil(() -> !needAmulets(), random(1000, 1250));
        }
    }

    private void openBank() throws InterruptedException {

        if (ctx.getMagic().isSpellSelected()) {
            ctx.getMagic().deselectSpell();
        }
        ctx.log("Opening Bank");
        if (ctx.getBank().open()) {
            Sleep.sleepUntil(() -> ctx.getBank().isOpen(), random(1000, 2500));
        }
    }


    private void cast() {
        Item sr = ctx.getInventory().getItem("Topaz amulet");
        if (sr != null) {
            if (ctx.getMagic().castSpell(Spells.NormalSpells.LVL_3_ENCHANT)) {
                ctx.log("Casting Spell");
                if (ctx.getTabs().getOpen().equals(Tab.INVENTORY)) {
                    if (sr.interact("Cast")) {
                        Sleep.sleepUntil(() -> ctx.getTabs().getOpen().equals(Tab.MAGIC), random(1500, 2500));
                    }
                }
            }
        }
    }

    private void closeBank() {

        ctx.log("Closing Bank");
        if (ctx.getBank().close()) {
            Sleep.sleepUntil(() -> !ctx.getBank().isOpen(), random(1000, 2500));
        }
    }

    private void depositAllBurnings() {

        ctx.log("Deposting Burning amulets ");
        if (ctx.getBank().depositAllExcept("Cosmic rune")) {
            Sleep.sleepUntil(() -> !ctx.getInventory().onlyContains("Cosmic rune"), random(1000, 1250));
        }
    }

    private boolean staffIsOn() {
        return ctx.getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of fire");
    }

    private boolean needToDepositBurnings() {
        return (ctx.getInventory().contains("Burning amulet(5)") && !ctx.getInventory().contains("Topaz amulet"));

    }

    private boolean hasItems() {
        return (ctx.getInventory().contains("Topaz amulet") && ctx.getInventory().contains("Cosmic rune"));
    }

    private boolean needStaff() {
        return !ctx.getInventory().contains("Staff of fire");
    }

    private boolean needRunes() {
        return !ctx.getInventory().contains("Cosmic rune");
    }

    private boolean needAmulets() {
        return !ctx.getInventory().contains("Topaz amulet");
    }

}

 

 

Main.java

Spoiler

package Magic;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;


@ScriptManifest(name = "WIP Magic", version = 0.1, author = "Jio", logo = "", info = "Enchants")
public class Main extends Script {

   private Enchanter enchantTask;

    @Override
    public int onLoop() throws InterruptedException {
        enchantTask.doTask();
        return random(250, 350);
    }


    public void onStart() {
        this.enchantTask = new Enchanter(this);
        log("Running");
    }

    public void onExit() {

        System.gc();
    }

}

 

 

 

  • Like 2
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.

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