Jump to content

Simple Glassblower [Unpowered Orbs] WIP


Imthabawse

Recommended Posts

-Imthabawse's Unpowered Orbs-

 

 

 

Features

- Blows Unpowered Orbs at any bank

- Basic informative paint

 

How to run

- Client set to "Fixed mode" (Haven't tested re-sizable)

- Glassblowing pipe in inventory (Start with either just pipe in inventory or pipe and molten glass)

- Molten glass in bank (Have visible although probably not necessary)

- If you have a bank PIN make sure you unlock bank prior to running

 

Known Bug's

- If script is paused with Unpowered Orbs in inventory and Molten glass will sit idle (Working on this)

- This also goes for if you level up with molten glass still in inventory with unpowered orbs

 

Code

Spoiler

import org.osbot.rs07.api.ui.RS2Widget;
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.*;
import java.util.concurrent.TimeUnit;

@ScriptManifest(author = "Imthabawse", info = "Makes Un-powered Orbs and banks", logo = "", name = "GlassBlower - Un-powered Orbs", version = 1)

public class GlassBlower extends Script {

    private long timeBegan;
    private long timeRan;
    private int beginningXp;
    private int currentXp;
    private int xpGained;
    private int currentLevel;
    private int beginningLevel;
    private int levelsGained;


    @Override
    public void onStart() {
        timeBegan = System.currentTimeMillis();
        beginningXp = skills.getExperience(Skill.CRAFTING);
        beginningLevel = skills.getStatic(Skill.CRAFTING);
    }


    @Override
    public void onPaint(Graphics2D g) {
        g.setColor(Color.GREEN);
        timeRan = System.currentTimeMillis() - this.timeBegan;
        g.drawString(ft(timeRan), 12, 235);
        currentXp = skills.getExperience(Skill.CRAFTING);
        xpGained = currentXp - beginningXp;
        g.drawString("Exp Gained: " + xpGained, 12, 255);
        currentLevel = skills.getStatic(Skill.CRAFTING);
        levelsGained = currentLevel - beginningLevel;
        g.drawString("Start Level: " + beginningLevel, 12,275);
        g.drawString("Current Level: " + currentLevel, 12,295);
        g.drawString("Levels Gained: " + levelsGained, 12, 315);
    }


    private String ft(long duration)
    {
        String res = "";
        long days = TimeUnit.MILLISECONDS.toDays(duration);
        long hours = TimeUnit.MILLISECONDS.toHours(duration)
                - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
        long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
                - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
                .toHours(duration));
        long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
                .toMinutes(duration));
        if (days == 0) {
            res = (hours + ":" + minutes + ":" + seconds);
        } else {
            res = (days + ":" + hours + ":" + minutes + ":" + seconds);
        }
        return res;
    }




    @Override
    public int onLoop() throws InterruptedException {
        if(canBlowGlass()) {
            blowGlass();
            lvlUp();
        }else{
            bankOrbs();
        }
        return 500;
    }


    private void blowGlass() throws InterruptedException {
        RS2Widget orb = getWidgets().get(270,19,38);

        if(!myPlayer().isAnimating() && !myPlayer().isMoving() && orb == null && !getInventory().contains("Unpowered orb")) {
            sleep(random(550,750));
            log("Interacting with pipe..");
            getInventory().interact("Use","Glassblowing pipe");
            sleep(random(350,450));
            log("Interacting with glass..");
            getInventory().interact("Use","Molten glass");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    return isMenuVisable();
                }
            }.sleep();
        }else if(isMenuVisable() && orb != null) {
            log("Blowing glass.. sit back & relax...");
            orb.interact("Make");
            sleep(random(450,650));
            getMouse().moveOutsideScreen();
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    return myPlayer().isAnimating() || getInventory().getAmount("Unpowered orb") == 27;
                }
            }.sleep();
        }
    }

    private void bankOrbs() throws InterruptedException {
        if(!myPlayer().isAnimating() && getInventory().getAmount("Unpowered orb") == 27) {
            log("Banking orbs..");
            getBank().open();
            sleep(random(350,500));
            getBank().depositAllExcept("Glassblowing pipe");
            sleep(random(350,500));
            getBank().withdrawAll("Molten glass");
            sleep(random(350,500));
            getBank().close();
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    return getInventory().contains("Molten glass");
                }
            }.sleep();
        }else if(!getInventory().contains("Molten glass") && !getInventory().contains("Unpowered orb")) {
                log("Getting glass..");
                getBank().open();
                sleep(random(350,500));
                getBank().withdrawAll("Molten glass");
                sleep(random(350,500));
                getBank().close();
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() {
                        return getInventory().contains("Molten glass");
                    }
                }.sleep();
            }
        }

        private void lvlUp() throws InterruptedException {
        if(getDialogues().isPendingContinuation() && !myPlayer().isAnimating()) {
            sleep(random(550,750));
            getDialogues().clickContinue();
        }
        }



    private boolean canBlowGlass() {
        return getInventory().contains("Glassblowing pipe") && getInventory().contains("Molten glass");
    }

    private boolean isMenuVisable() {
        return getWidgets().getWidgetContainingText("How many do you wish to make?") != null;
    }
}

Download

-Re-working this project at a later time-

Edited by Imthabawse
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...