Jump to content

(Open Source) ELeetBoneBurier


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 banking/burying bones.

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.GameEntity;
import com.epicbot.api.shared.entity.ItemWidget;
import com.epicbot.api.shared.entity.WidgetChild;
import com.epicbot.api.shared.methods.*;
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.util.time.Timer;

import java.awt.*;

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

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

    private int bonesBuried = 0;
    private double xpGained = 0.0;
    private static String status = "STARTING";
    private final Timer runTimer = new Timer(0);
    private String boneType = "Big bones";
    private Skill.Skills skill = Skill.Skills.PRAYER;

    private double experienceGained, startExperience = 0;
    private double xpPerBone = 15.0;

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

    @Override
    protected int loop() {
        handleCalculations();

       if(!playerInventoryContainsBones()) {
           openBank();
           withdrawBones();
       } else {
            buryBones();
       }

        return 60;
    }

    public static int getSleepTime() {
        int sleepMin = 1000;
        int sleepMax = 2250;
        return Random.nextInt(sleepMin, sleepMax);
    }
    public static int getShortSleepTime() {
        int sleepMin = 445;
        int sleepMax = 887;
        return Random.nextInt(sleepMin, sleepMax);
    }
    public static int getAmountToTurnCamera() {
        return Random.nextInt(-224, 779);
    }

    public void buryBones() {
        if(bank().isOpen()) {
            bank().close();
            Time.sleep(getShortSleepTime());
        }

        status = "Burying Bones";

        rotateCamera();

        ItemWidget bone = inventory().getItem(boneType);

        if(bone.isValid()) {
            bone.interact("Bury");
        }
        Time.sleep(getShortSleepTime());
        moveMouse();
    }

    public void openBank() {
        if(player().isMoving()) {
            Time.sleep(getShortSleepTime());
            return;
        }

        status = "Opening bank";

        GameEntity bank = objects().query().named("Bank booth").results().nearest();
        if(bank.isValid()) {
            bank.interact("Bank");
        }
        Time.sleep(getShortSleepTime());
    }

    private void withdrawBones() {
        bank().withdraw(28, boneType);
        Time.sleep(getShortSleepTime());
        bank().close();
    }

    public void clickBankAll() {
        status = "Clicking Bank all";

        bank().open();
        Time.sleep(getShortSleepTime());

        WidgetChild bankAllButton = widgets().get(12).getChild(42);
        mouse().click(bankAllButton);
    }

    private boolean playerInventoryContainsBones() {
        boolean bool = false;
        if(inventory().contains(boneType)) {
            bool = true;
        }

        return bool;
    }

    public void rotateCamera() {
        if(Random.nextInt(1, 50) < 3) {
            int currentYaw = camera().getY();
            camera().setYaw(currentYaw + getAmountToTurnCamera());
        }
    }

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

    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 + "";
    }

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

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

        bonesBuried = (int)(experienceGained / xpPerBone);
    }

    @Override
    protected void onPaint(Graphics2D g, APIContext ctx) {
        PaintFrame scriptDetails = new PaintFrame("ELeetBoneBurier");
        scriptDetails.addLine("[Timer]:", runTimer.toElapsedString());
        scriptDetails.addLine("[Status]:", status);
        scriptDetails.addLine("", "");
        scriptDetails.addLine("[Bones Buried]", bonesBuried);
        scriptDetails.addLine("[Xp Per Hour]", rsFormat(getHourlyRate((int)experienceGained)));

        scriptDetails.draw(g, 0, 0, ctx);
    }
}

 

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