Jump to content

(Open Source) ELeetFireMaking


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/firemaking (It sometimes bugs out a bit so you'll need to baby-sit this one)
 

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.methods.*;
import com.epicbot.api.shared.util.time.Time;
import com.epicbot.api.shared.util.time.Timer;
import javafx.scene.Scene;

import java.awt.*;

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

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

    private final Timer runTimer = new Timer(0);
    private String status = "Starting";
    private double experienceGained, startExperience = 0;
    private Skill.Skills trainedSkill = Skill.Skills.FIREMAKING;

    private Tile fireArea = new Tile(3208,3428);
    private Tile fireArea2 = new Tile(3208,3429);
    private Tile bankArea = new Tile(3185,3436);
    private String logType = "Willow logs";
    private String fireType = "Fire";

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

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

        if(playerOutOfBounds()) {
            walkToFiremakingSpot();
        }

        if(groundContainsFire()) {
            walkWest();
            rotateCamera();
        }

        if(!inventoryContainsLogs()) {
            moveMouseRandomly();
            walkToBank();
            rotateCamera();
            openBank();
            withdrawLogs();
        }

        if(inventoryIsFull() && inventoryContainsTinderbox()) {
            walkToFiremakingSpot();
            rotateCamera();
        }

        if(!groundContainsFire()) {
            moveMouseRandomly();
            lightFire();
            rotateCamera2();
        }

        return 3;
    }

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

    public static int getSleepTime() {
        int sleepMin = 1222;
        int sleepMax = 2662;
        return Random.nextInt(sleepMin, sleepMax);
    }
    public static int getShortSleepTime() {
        int sleepMin = 650;
        int sleepMax = 1448;
        return Random.nextInt(sleepMin, sleepMax);
    }
    public static int getAmountToTurnCamera() {
        return Random.nextInt(-1000, 1000);
    }

    public boolean groundContainsFire() {
        SceneObject fire = objects().query().named(fireType).located(player().getLocation()).results().nearest();
        if(fire != null) {
            return true;
        }
        return false;
    }

    public boolean inventoryIsFull() {
        return inventory().isFull();
    }

    public boolean inventoryContainsLogs() {
        boolean bool = false;

        for(ItemWidget item : inventory().getItems()) {
            if(item.getName().equals(logType)) {
                bool = true;
            }
        }

        return bool;
    }

    public boolean playerOutOfBounds() {
        boolean bool = false;

        if(player().getLocation().getY() <= 3427) {
            bool = true;
        }

        return bool;
    }

    public void walkWest() {
        SceneObject fire = objects().query().named("Fire").located(player().getLocation()).results().first();
        if(!fire.isValid()) {
            return;
        }

        status = "Walking west";

        Tile tileSouth = new Tile(player().getX() - 1, player().getY());
        webWalking().walkTo(tileSouth);
    }

    public boolean inventoryContainsTinderbox() {
        return inventory().contains("Tinderbox");
    }

    public void walkToFiremakingSpot() {
        status = "Walking to firemaking location";
        webWalking().walkTo(getFireTile());

        if(!walking().isRunEnabled() && walking().getRunEnergy() > 50) {
            walking().setRun(true);
        }
    }

    public void walkToBank() {
        status = "Walking to bank";
        webWalking().walkTo(getBankTile());

        if(!walking().isRunEnabled() && walking().getRunEnergy() > 50) {
            walking().setRun(true);
        }
        Time.sleep(getShortSleepTime());
    }

    public Tile getFireTile() {
        int x;
        int y;
        int randomness = 0;

        if(Random.nextInt(1,2) == 1) {
            x = fireArea.getX();
            y = fireArea.getY();
        } else {
            x = fireArea2.getX();
            y = fireArea2.getY();
        }

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

        return new Tile(randomX, randomY);
    }

    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);
    }

    public void rotateCamera() {
        if(Random.nextInt(1, 10) != 1) {
            return;
        }

        Time.sleep(getShortSleepTime());

        int currentYaw = camera().getYaw();
        camera().setYaw(currentYaw + getAmountToTurnCamera());
    }
    public void rotateCamera2() {
        if(Random.nextInt(1, 25) != 1) {
            return;
        }

        Time.sleep(getShortSleepTime());

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


    public void lightFire() {

        status = "Lighting fire";

        ItemWidget tinderbox = inventory().getItem("Tinderbox");
        mouse().click(tinderbox);
        Time.sleep(getShortSleepTime());

        ItemWidget log = inventory().getItem(logType);
        mouse().click(log);
        Time.sleep(getShortSleepTime());

        while(player().isAnimating() && !groundContainsFire()) {
            Time.sleep();
        }
    }

    public void openBank() {
        status = "Opening bank";
        GameEntity bank = objects().query().named("Bank booth").distance(5.0).results().nearest();
        bank.interact("Bank");
        Time.sleep(getSleepTime());
    }

    public void withdrawLogs() {
        status = "Withdrawing logs";
        bank().withdraw(27, logType);

        Time.sleep(getShortSleepTime());

        if(!inventoryContainsTinderbox()) {
            bank().withdraw(1, "Tinderbox");
            Time.sleep(getShortSleepTime());
        }
    }

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

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

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

    public void moveMouseRandomly() {
        if(Random.nextInt(1, 500) == 2) {
            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));
    }

    @Override
    protected void onPaint(Graphics2D g, APIContext ctx) {
        PaintFrame frame = new PaintFrame("ELeetFiremaking");
        frame.addLine("[Time running]:", runTimer.toElapsedString());
        frame.addLine("[Status]:", status);
        frame.addLine("", "");
        frame.addLine("[Xp Gained]:", experienceGained);
        frame.addLine("[Xp Per Hour]:", rsFormat(getHourlyRate((int)experienceGained)));
        frame.draw(g, 0, 155, 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...