Jump to content

(Open Source) ELeetSmelter


LeetyPoo

Recommended Posts

Hello everyone. I am releasing all of the custom scripts that I've made. They are probably not super great but they worked for me just messing around. Might be able to find some useful stuff I suppose. I am a java game developer and just took these on for fun. I don't really play anymore though so I thought I'd release it all for everyone else to hopefully get some use out of. If you want a custom script feel free to message me. I don't mind helping out where I can. This is just a basic script for smelting bars. Hope you can find it useful.

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.*;
import com.epicbot.api.shared.methods.IInventoryAPI;
import com.epicbot.api.shared.model.Skill;
import com.epicbot.api.shared.model.Tile;
import com.epicbot.api.shared.script.LoopScript;
import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.util.Random;
import com.epicbot.api.shared.util.paint.frame.PaintFrame;
import com.epicbot.api.shared.util.time.Time;

import com.epicbot.api.shared.methods.*;
import com.epicbot.api.shared.util.time.Timer;
import misc.Misc;

import java.awt.*;

import static java.awt.event.KeyEvent.VK_3;
import static java.awt.event.KeyEvent.VK_4;

@ScriptManifest(name = "ELeetSmelter", gameType = GameType.OS)
public class ELeetSmelter extends LoopScript {

    @Override
    public boolean onStart(String... strings) {
        return true;
    }

    private final Timer runTimer = new Timer(0);
    private String status = "Starting";
    private Tile furnaceArea = new Tile(3274, 3186);
    private Tile bankArea = new Tile(3269, 3168);
    private boolean scriptBankFish = true;
    private String[] oreType = {"Iron ore", "Coal"};
    private String barType = "Steel bar";
    private int barsMade = 0;
    private double xpPerBar = 17.5;
    private double experienceGained, startExperience = 0;
    private Skill.Skills trainedSkill = Skill.Skills.SMITHING;

    public IInventoryAPI   inventory() { return getAPIContext().inventory(); }
    public ILocalPlayerAPI player()  { return getAPIContext().localPlayer(); }
    public IBankAPI bank()  { return getAPIContext().bank(); }
    public IMouseAPI mouse()  { return getAPIContext().mouse(); }
    public IWidgetsAPI widgets()  { return getAPIContext().widgets(); }
    public IObjectsAPI objects()  { return getAPIContext().objects(); }
    public IWebWalkingAPI webWalking()  { return getAPIContext().webWalking(); }
    public IKeyboardAPI keyboard()  { return getAPIContext().keyboard(); }
    public ICameraAPI camera()  { return getAPIContext().camera(); }
    public ISkillsAPI skills()  { return getAPIContext().skills(); }

    @Override
    protected int loop() {

        handleCalculations();

        rotateCamera();

        if(levelUpInterfacePresent()) {
            if(playerStillHasOresToSmelt()) {
                clickFurnace();
                rotateCamera();
                moveMouse();
                if (smeltingInterfaceOpen()) {
                    sendNumberForOreSelection();
                    moveMouse();
                    rotateCamera();
                }
            }

            if(!playerStillHasOresToSmelt()) {
                rotateCamera();
                walkToBank();
                rotateCamera();
                openBank();
            }
        }

        if(shouldWalkToFurnace()) {
            walkToFurnace();
            moveMouse();
            rotateCamera();
            if (isReadyToSmelt()) {
                clickFurnace();
                rotateCamera();
                moveMouse();
                if (smeltingInterfaceOpen()) {
                    sendNumberForOreSelection();
                    moveMouse();
                    rotateCamera();
                }
            }
        } else {
            walkToBank();
            rotateCamera();
            moveMouse();
            openBank();
            moveMouse();
            rotateCamera();
        }

        return 60;
    }

    private boolean levelUpInterfacePresent() {
        boolean bool = false;

        if(widgets().get(233).isVisible()) {
            System.out.println("Found Level Up Interface");
            bool = true;
        }

        return bool;
    }

    private void handleCalculations() {
        if (startExperience == 0) {
            startExperience = skills().get(trainedSkill).getExperience();
        } else {
            experienceGained = skills().get(trainedSkill).getExperience() - startExperience;
        }
    }

    private void walkToBank() {
        status = "Walking to bank";
        webWalking().walkTo(Misc.getRandomTile(bankArea, 1));
    }
    private void walkToFurnace() {
        status = "Walking to furnace";
        webWalking().walkTo(Misc.getRandomTile(furnaceArea, 0));
    }
    private void openBank() {
        status = "Opening bank";
        GameEntity bank = objects().query().named("Bank Booth").results().nearest();
        bank.interact("Bank");

        doBanking();
    }
    private void doBanking() {
        status = "Doing banking";
        Time.sleep(getSleepTime());
        WidgetChild bankAllButton = widgets().get(12).getChild(42);
        mouse().click(bankAllButton);
        Time.sleep(getShortSleepTime());

        bank().withdraw(9, oreType[0]);
        Time.sleep(getShortSleepTime());

        bank().withdrawAll(oreType[1]);
        Time.sleep(getShortSleepTime());

        bank().close();
    }
    private void clickFurnace() {
        if(smeltingInterfaceOpen()) {
            return;
        }

       status = "Clicking furnace";
       GameEntity furnace = objects().query().named("Furnace").results().nearest();
       furnace.interact("Smelt");
    }
    private void sendNumberForOreSelection() {
        if(!inventory().isFull()) {
            return;
        }
        keyboard().holdKey(VK_4, getShortSleepTime());
        while(inventory().contains(oreType[0]) && inventory().contains(oreType[1]) && !levelUpInterfacePresent()) {
            Time.sleep();
        }
    }

    public boolean shouldWalkToFurnace() {
        return inventory().contains(oreType[0]) && inventory().contains(oreType[1]) && inventory().isFull() && !inventory().contains(barType);
    }
    public boolean isReadyToSmelt() {
        return inventory().isFull() && inventory().contains(oreType[0]) && inventory().contains(oreType[1]) && player().getLocation().equals(furnaceArea);
    }
    public boolean playerStillHasOresToSmelt() {
        return inventory().getCount(oreType[0]) >= 1 && inventory().getCount(oreType[1]) >= 2;
    }

    public boolean smeltingInterfaceOpen() {
        boolean bool = false;

        if(widgets().get(270).getChild(1).isVisible()) {
            System.out.println("Found smelting interface open");
            bool = true;
        }

        return bool;
    }

    public static int getSleepTime() {
        int SLEEP_MIN = 1750;
        int SLEEP_MAX = 3211;
        return Random.nextInt(SLEEP_MIN, SLEEP_MAX);
    }
    public static int getShortSleepTime() {
        int SLEEP_MIN = 250;
        int SLEEP_MAX = 400;
        return Random.nextInt(SLEEP_MIN, SLEEP_MAX);
    }
    public static int getAmountToTurnCamera() {
        return Random.nextInt(-1000, 1000);
    }


    private int getHourlyRate(int i) {
        return (int) (i / (runTimer.getElapsed() / 3600000.0D));
    }

    public void moveMouse() {
        if(Random.nextInt(1, 22) < 3) {
            mouse().moveRandomly();
        }
    }

    public void rotateCamera() {
        if(Random.nextInt(1, 15) < 2) {
            return;
        }

        int currentYaw = camera().getYaw();
        camera().setYaw(currentYaw + getAmountToTurnCamera());
    }

    private String rsFormat(Integer number) {
        String[] suffix = new String[]{"K", "M", "B", "T"};
        int size = (number != 0) ? (int) Math.log10(number) : 0;
        if (size >= 3) {
            while (size % 3 != 0) {
                size = size - 1;
            }
        }
        return (size >= 3) ? +(Math.round((number / Math.pow(10, size)) * 10) / 10d)
                + suffix[(size / 3) - 1]
                : +number + "";
    }

    @Override
    protected void onPaint(Graphics2D g, APIContext ctx) {
        PaintFrame frame = new PaintFrame("ELeetSmelter");
        frame.addLine("[Timer]:", runTimer.toElapsedString());
        frame.addLine("[Status]:", status);
        frame.addLine("", "");

        frame.addLine("[Xp Gained]:", rsFormat((int)experienceGained));
        frame.addLine("[Xp Per Hour]:", rsFormat(getHourlyRate((int)experienceGained)));
        frame.addLine("","");

        frame.addLine("[Bars Made]:", rsFormat((int)(experienceGained/xpPerBar)));
        frame.addLine("[Bars Per Hour]:", rsFormat(getHourlyRate((int)(experienceGained/xpPerBar))));
        frame.addLine("","");
        frame.draw(g, 0, 220, ctx);
    }
}

 

Link to comment
Share on other sites

  • 4 weeks later...
On 11/4/2023 at 9:37 PM, tdubcity said:

can you do a smithing one like for mith bars making dart tips or any mith item and adamant platebodies

Yes I can help you out with this. I sent you a private message. Would like to know more details about this script.

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.

×
×
  • Create New...