Jump to content

Glass make Caster.


zwaffel

Recommended Posts

This program is designed to cast glass make in order to create molten glass.

Been using this on my ironman without any trouble.

Requirements:

  • Plenty of astral and fire runes.
  • Buckets of sand.
  • Be on the lunar spell book.

Features:

  • The bot will take the extra dropped glass from the floor once it contains enough.
  • The bot will keep going until it runs out of supply.
  • Should work at any bank.
  • Gets an air staff out of the bank and equips it.
  • simple gui with quit options and the option to use seaweed instead of giant seaweed

 

 

FmP63pw.png.d9fa6a9516af380d2d43b68ed2e6a2f6.png

 

 

If you encounter a bug please let me know, be as precise as you can be so i can recreate the bug and fix it.

Uploading to the forums didn't work so uploaded it elsewhere.

https://mega.nz/#!H8pzzCLK!xGVMASw1KNpYCvqG1W9ZkS1vMrLUu-PCzlccDTuMKDM

To use go to your Osbot folder (usually in c/users/*username*/osbot/  navigate to the Scripts folder and drag it in there. Reload your scripts and it should appear.

 

 

Currently v2.

Changelog:

 

v2.

Gui added with the options to stop at X amount of glass made, buckets used, sand used or stop when out of supply.

option added in the gui to use normal seaweed instead of giant seaweed.

 

v1.1

While loop has been made more safe, the bot will now check if the user has paused the bot or not.

Upcoming update:

 

Will be making a gui for this which will give you the options, to exit the script after X amount or glass made.

Exit on X amount of buckets or seaweed used.

Grabbing a staff from the bank and equipping it.

General updates to the code will also come as i made this quickly for myself to use and wasn't actually planning on releasing to the public.

 

 

 

Edited by zwaffel
updated for v2, added new link (forgot previously)
Link to comment
Share on other sites

Jar upload keeps failing so here is source code.

 

source outdated, wont be uploading the new source since it has been split in multiple classes for the gui etc.

 

import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.event.InteractionEvent;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;
import java.util.ArrayList;

@ScriptManifest(info = "makes glass have air staff equiped", name = "Glass make", logo = "", author = "Zwaffel", version = 1)
public class Main extends Script {

    private int sand_in_invetory, seaweed_in_invetory, astrals_in_inventory, fire_runes_in_invetory, glass_made, glass_before_cast;
    private final String SEAWEED = "Giant seaweed";
    private final String SAND = "Bucket of sand";
    private final String GLASS = "Molten glass";
    private final int REQUIRED_SEAWEED = 3;
    private final int REQUIRED_SAND = 18;


    @Override
    public void onStart() throws InterruptedException
    {
        super.onStart();
        getExperienceTracker().start(Skill.MAGIC);
        getExperienceTracker().start(Skill.CRAFTING);
    }

    @Override
    public int onLoop() throws InterruptedException
    {

        // kijken of er meer dan 20 glas op de grond ligt
        if (getAmountOfGlassOnTheFloor() > 20)
        {
            // glas blijven oprapen tot er geen meer op de grond ligt
            pickupGlassFromGround();
        }
        else if (!getBank().isOpen())
        {
            getBank().open();
        }

        if (hasEnoughAstralRunes() && hasEnoughFireRunes() && hasEnoughSandInInvetory() && hasEnoughSeaweedInInventory())
        {
            makeGlass();
        }
        if (inventory.contains(GLASS))
        {
            bankGlass();
        }


        return 700;
    }

    private void pickupGlassFromGround() throws InterruptedException
    {

        while (floorContainsGlass() && !getBot().getScriptExecutor().isPaused())
        {

            ArrayList<GroundItem> grounditems = new ArrayList<>(getGroundItems().get(myPlayer().getX(), myPlayer().getY()));
            for (GroundItem glass : grounditems)
            {

                if (glass.getName().equals(GLASS))
                {
                    int glass_on_floor = getAmountOfGlassOnTheFloor();

                    InteractionEvent take = new InteractionEvent(glass, "Take");
                    take.setOperateCamera(false);
                    take.setWalkingDistanceThreshold(1);
                    take.setWalkTo(true);
                    if (!getBot().getScriptExecutor().isPaused())
                    {

                        if (!getInventory().isFull())
                        {
                            execute(take);
                            new ConditionalSleep(1000, 250) {
                                @Override
                                public boolean condition() throws InterruptedException
                                {
                                    return glass_on_floor > getAmountOfGlassOnTheFloor();
                                }
                            }.sleep();
                        }
                        else
                            bankGlass();
                    }
                    else
                        break;

                }
            }
        }
    }

    private void evaluateGlassMade()
    {
        //tellen hoeveel glass er in de inventory zit.
        if (inventory.contains(GLASS))
        {
            glass_made += getInventory().getAmount(GLASS) - glass_before_cast;
        }
    }

    private int getAmountOfGlassOnTheFloor()
    {
        ArrayList<GroundItem> grounditems = new ArrayList<>(getGroundItems().get(myPlayer().getX(), myPlayer().getY()));
        int count = 0;
        for (GroundItem glass : grounditems)
        {
            if (glass.getName().equals(GLASS))
            {
                count++;
            }
        }

        return count;
    }


    private boolean floorContainsGlass()
    {
        ArrayList<GroundItem> grounditems = new ArrayList<>(getGroundItems().get(myPlayer().getX(), myPlayer().getY()));


        for (GroundItem glass : grounditems)
        {
            if (glass.getName().equals(GLASS))
            {
                return true;
            }
        }
        return false;
    }

    private void makeGlass() throws InterruptedException
    {
        Item seaweed = getInventory().getItem(SEAWEED);
        Item sand = getInventory().getItem(SAND);
        glass_before_cast = (int) getInventory().getAmount(GLASS);
        if (sand != null && seaweed != null)
        {

            // if bank is open, close bank.
            if (getBank().isOpen())
            {
                getBank().close();
                new ConditionalSleep(1000, 250) {
                    @Override
                    public boolean condition() throws InterruptedException
                    {
                        return !getBank().isOpen();
                    }
                }.sleep();
            }
            magic.castSpell(Spells.LunarSpells.SUPERGLASS_MAKE);
            sleep(1000);
            new ConditionalSleep(5000, 1000) {
                @Override
                public boolean condition() throws InterruptedException
                {
                    return !myPlayer().isAnimating();
                }
            }.sleep();

            evaluateGlassMade();

        }
    }

    private boolean withdrawFromBank(int amount, String itemName)
    {

        if (bank.isOpen())
        {
            if (getBank().contains(itemName) && getBank().getAmount(itemName) >= amount)
            {
                log("Bank contains " + itemName);
                getBank().withdraw(itemName, amount);
                new ConditionalSleep(2000, 500) {
                    @Override
                    public boolean condition() throws InterruptedException
                    {
                        return getInventory().contains(itemName);
                    }
                }.sleep();
                return true;


            }
            else
            {
                log("Bank does not contain required item + " + itemName);
                stop();
                return false;
            }
        }
        return false;
    }


    private boolean hasEnoughAstralRunes()
    {
        if (getInventory().contains("Astral rune"))
        {
            astrals_in_inventory = getInventory().getItem("Astral Rune").getAmount();
            if (astrals_in_inventory > 100)
            {
                return true;
            }
        }
        else
            return withdrawFromBank(500, "Astral rune");

        return false;
    }

    private boolean hasEnoughFireRunes()
    {
        if (getInventory().contains("Fire rune"))
        {
            fire_runes_in_invetory = getInventory().getItem("Fire rune").getAmount();
            if (fire_runes_in_invetory > 500)
            {
                return true;
            }

        }
        else
            return withdrawFromBank(1000, "Fire rune");

        return true;

    }


    /*
    kijkt of er genoeg seaweed in de invtoroy is.
     */
    private boolean hasEnoughSeaweedInInventory()
    {
        if (getInventory().contains(SEAWEED))
        {
            Item seaweed = getInventory().getItem(SEAWEED);
            seaweed_in_invetory = seaweed.getAmount();

            if (seaweed_in_invetory == REQUIRED_SEAWEED)
            {
                return true;
            }
            else return withdrawFromBank(REQUIRED_SEAWEED - seaweed_in_invetory, SEAWEED);
        }
        else
            return withdrawFromBank(REQUIRED_SEAWEED, SEAWEED);


    }

    /*
    kijkt of er genoeg buckets in de inventory zijn.
     */
    private boolean hasEnoughSandInInvetory()
    {
        if (getInventory().contains(SAND))
        {
            log("inv contains sand");
            Item bucket = getInventory().getItem(SAND);
            sand_in_invetory = bucket.getAmount();
            if (sand_in_invetory == REQUIRED_SAND)
            {
                log("no more sand needed");
                return true;
            }
            else
                log("getting sand from the bank.");
            return withdrawFromBank(REQUIRED_SAND - sand_in_invetory, SAND);

        }
        else
            log("No sand in inv withdrawing");
        return withdrawFromBank(REQUIRED_SAND, SAND);

    }

    private void bankGlass() throws InterruptedException
    {
        if (bank.isOpen())
        {
            bank.deposit(GLASS, Bank.STORE_ALL);
            glass_before_cast = 0;
        }
        else
        {
            getBank().open();
            new ConditionalSleep(1000, 100) {
                @Override
                public boolean condition() throws InterruptedException
                {
                    return bank.isOpen();
                }
            }.sleep();
            bankGlass();
        }

    }

    @Override
    public void onExit() throws InterruptedException
    {
        super.onExit();
    }


    @Override
    public void onPaint(Graphics2D e)
    {
        super.onPaint(e);

        e.drawString("Glass made = " + glass_made, 15, 295);
        e.drawString("magic exp gained = " + getExperienceTracker().getGainedXP(Skill.MAGIC), 15, 310);
        e.drawString("Crafting exp gained = " + getExperienceTracker().getGainedXP(Skill.CRAFTING), 15, 325);
        e.drawString("magic exp/h =  " + getExperienceTracker().getGainedXPPerHour(Skill.MAGIC), 200, 310);
        e.drawString("crafting exp/h =  " + getExperienceTracker().getGainedXPPerHour(Skill.CRAFTING), 200, 325);
    }


}

 

Edited by zwaffel
Link to comment
Share on other sites

20 hours ago, Czar said:

Cool release, I highly recommend making that while statement more safe, add a few breaks to check if the script is running/paused otherwise you may need to ALT + F4 out of the bot

Aside from that, should be super useful to the community, good job on sharing :)

 

Hi, thanks for the feedback ill make some changes and push an update later on :)

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