Jump to content

(Open Source) ELeetCooker


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

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 java.awt.*;

import static java.awt.event.KeyEvent.VK_SPACE;

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

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

    private final Timer runTimer = new Timer(0);
    private String status = "Starting";
    private Tile rangeArea = new Tile(3211, 3215, 0);
    private Tile bankArea = new Tile(3208, 3220, 2);
    private String uncookedType = "Raw tuna";
    private String cookedType = "Tuna";
    private double experienceGained, startExperience = 0;
    private Skill.Skills skill = Skill.Skills.COOKING;

    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 IObjectsAPI objects()  { return getAPIContext().objects(); }
    public INPCsAPI npcs()  { return getAPIContext().npcs(); }
    public IWidgetsAPI widgets()  { return getAPIContext().widgets(); }
    public IKeyboardAPI keyboard()  { return getAPIContext().keyboard(); }
    public ISkillsAPI skills()  { return getAPIContext().skills(); }
    public IWebWalkingAPI webWalking()  { return getAPIContext().webWalking(); }
    public ICameraAPI camera()  { return getAPIContext().camera(); }


    @Override
    protected int loop() {

        handleCalculations();
        rotateCamera();

        if(levelUpInterfacePresent()) {
            rotateCamera();
            walkToBank();
            rotateCamera();
            openBank();
        }

        if(shouldWalkToFurnace()) {
            walkToRange();
            moveMouse();
            rotateCamera();
            if (isReadyToCook()) {
                clickRange();
                rotateCamera();
                moveMouse();
                if (cookingInterfaceOpen()) {
                    sendSpaceForFishSelection();
                    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(skill).getExperience();
        } else {
            experienceGained = skills().get(skill).getExperience() - startExperience;
        }
    }

    private void walkToBank() {
        status = "Walking to bank";
        webWalking().walkTo(getBankTile());
    }
    private void walkToRange() {
        if(player().getY() > 2310 && player().getPlane() == 0) {
            return;
        }
        status = "Walking to range";
        webWalking().walkTo(getFurnaceTile());
    }
    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().withdrawAll(uncookedType);
        Time.sleep(getShortSleepTime());
        bank().close();
    }
    private void clickRange() {
        if(cookingInterfaceOpen()) {
            return;
        }

        status = "Clicking range";
        GameEntity furnace = objects().query().named("Cooking range").results().nearest();
        furnace.interact("Cook");
    }
    private void sendSpaceForFishSelection() {
        if(!inventory().isFull()) {
            return;
        }
        keyboard().holdKey(VK_SPACE, getShortSleepTime());
        while(inventory().contains(uncookedType) && !levelUpInterfacePresent()) {
            Time.sleep();
        }
    }

    private boolean playerHasFoodToCook() {
        return inventory().contains(uncookedType);
    }
    public boolean shouldWalkToFurnace() {
        return inventory().contains(uncookedType) && inventory().isFull() && !inventory().contains(cookedType);
    }
    public boolean isReadyToCook() {
        return inventory().isFull() && inventory().contains(uncookedType) && player().getLocation().equals(rangeArea);
    }

    public boolean cookingInterfaceOpen() {
        boolean bool = false;

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

        return bool;
    }

    public Tile getBankTile() {
        int x = bankArea.getX();
        int y = bankArea.getY();
        int randomness = 0;

        int randomX = Random.nextInt(x - randomness, x + randomness);
        int randomY = Random.nextInt(y - randomness, y + randomness);

        return new Tile(x, y, 2);
    }

    public Tile getFurnaceTile() {
        int x = rangeArea.getX();
        int y = rangeArea.getY();
        int randomness = 0;

        int randomX = Random.nextInt(x - randomness, x + randomness);
        int randomY = Random.nextInt(y - randomness, y + randomness);

        return new Tile(x, y);
    }

    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, 10) < 3) {
            mouse().moveRandomly();
        }
    }

    public void rotateCamera() {
        if(Random.nextInt(1, 10) > 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("ELeetCooker");
        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.draw(g, 0, 220, ctx);
    }
}

 

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