Jump to content

(Open Source) ELeetFisher


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

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

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

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

    private final Timer runTimer = new Timer(0);
    private int fishDropped = 0;
    private int fishBanked = 0;
    private String status = "Starting";
    private Tile fishArea = new Tile(2459, 2891);
    private Tile bankArea = new Tile(2569, 2864);
    private Tile fishArea2 = new Tile(2457, 2892);
    private boolean scriptBankFish = true;
    private String[] fishType = {"Raw tuna", "Raw swordfish"};
    private double experienceGained, startExperience = 0;
    private Skill.Skills trainedSkill = Skill.Skills.FISHING;

    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 IBankAPI bank()  { return getAPIContext().bank(); }
    public ITabsAPI tabs()  { return getAPIContext().tabs(); }
    public IObjectsAPI objects()  { return getAPIContext().objects(); }
    public INPCsAPI npcs()  { return getAPIContext().npcs(); }
    public ISkillsAPI skills()  { return getAPIContext().skills(); }

    @Override
    protected int loop() {

        handleCalculations();

        if(!playerHasFishingSupplies()) {
            walkToBank();
            bankFish();
        }

        if(!player().isAnimating()) {
            if (inventory().isFull()) {

                if(!scriptBankFish) {
                    rotateCamera();
                    shiftDropFish();
                } else {
                    walkToBank();
                    bankFish();
                }

                rotateCamera();
                moveMouse();
            }

            for(int i = 0; i < fishType.length; i++) {
                if(!inventory().contains(fishType[i]) && playerHasFishingSupplies()) {
                    walkToFishLocation();
                }
            }

            rotateCamera();

            if(!inventory().isFull() && playerHasFishingSupplies()) {
                takeABreak();
                clickFishingSpot();
            }

            moveMouse();
            Time.sleep(getSleepTime());
            moveMouse();
            rotateCamera();

        }

        return 3;
    }

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

    private void takeABreak() {
        if(Random.nextInt(1, 66) == 1) {
            status = "Taking a break";
            Time.sleep(getLongSleepTime());
        }
    }
    public static int getLongSleepTime() {
        int SLEEP_MIN = 175000;
        int SLEEP_MAX = 210000;
        return Random.nextInt(SLEEP_MIN, SLEEP_MAX);
    }
    public static int getSleepTime() {
        int SLEEP_MIN = 4222;
        int SLEEP_MAX = 7500;
        return Random.nextInt(SLEEP_MIN, SLEEP_MAX);
    }
    public static int getShortSleepTime() {
        int SLEEP_MIN = 460;
        int SLEEP_MAX = 950;
        return Random.nextInt(SLEEP_MIN, SLEEP_MAX);
    }
    public static int getAmountToTurnCamera() {
        return Random.nextInt(-1000, 1000);
    }

    public void bankFish() {
        status = "Banking Fish";
        int amountInInventory = 0;

        for(int i = 0; i < fishType.length; i++) {
           amountInInventory += inventory().getCount(fishType[i]);
        }

        rotateCamera();
        GameEntity bankBooth = objects().query().named("Bank booth").results().nearest();
        bankBooth.interact("Bank");

        Time.sleep(getShortSleepTime());
        WidgetChild bankAllButton = widgets().get(12).getChild(42);
        mouse().click(bankAllButton);

        withdrawFishingSupplies();

        fishBanked += amountInInventory;
    }

    public void withdrawFishingSupplies() {
        status = "Withdrawing fishing supplies";
        Time.sleep(getShortSleepTime());

        if(!bank().isOpen()) {
           bank().open();
        }

        bank().withdraw(1, "Harpoon");
        Time.sleep(getShortSleepTime());
        APIContext.get().bank().close();
    }

    public void dropFish() {
        status = "Dropping Fish";

        int amount = 0;

        for(int i = 0; i < fishType.length; i++) {
            amount = inventory().getCount(fishType[i]);
            inventory().dropAll(fishType[i]);
        }

        fishDropped += amount;
    }


    public void clickFishingSpot() {
        status = "Fishing";

        int fishSpotId2 = 7946;
        GameEntity entity = npcs().query().id(fishSpotId2).results().nearest();
        entity.interact("Harpoon");

        if(!tabs().isOpen(ITabsAPI.Tabs.INVENTORY)) {
            tabs().open(ITabsAPI.Tabs.INVENTORY);
        }

        Time.sleep(getShortSleepTime());

    }

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

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

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

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

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

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

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

        return new Tile(randomX, randomY);
    }

    /*public void toggleRunEnergy() {
        if(APIContext.get().walking().getRunEnergy() > 50 && !APIContext.get().walking().isRunEnabled()) {
            APIContext.get().walking().setRun(true);
        }
    }*/

    public void walkToFishLocation() {
        status = "Walking to Fish Location";
        /*toggleRunEnergy();*/
        APIContext.get().webWalking().walkTo(getFishAreaTile());
        Time.sleep(getShortSleepTime());
    }

    public void shiftDropFish() {
        int counter = 0;

        status = "Shift Dropping Items";
        APIContext.get().keyboard().pressKey(VK_SHIFT);

        for(ItemWidget item : APIContext.get().inventory().getItems()) {
            if(!item.getName().contains("Raw")) {
                continue;
            }

            counter++;
            mouse().click(item);
            Time.sleep(137);
        }

        APIContext.get().keyboard().releaseKey(VK_SHIFT);
        moveMouse();
        fishDropped += counter;
    }

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

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

    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(randomX, randomY);
    }

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

    public boolean playerHasFishingSupplies() {
        return inventory().contains("Harpoon");
    }

    @Override
    protected void onPaint(Graphics2D g, APIContext ctx) {
        PaintFrame frame = new PaintFrame("ELeetFisher");
        frame.addLine("[Timer]:", runTimer.toElapsedString());
        frame.addLine("[Status]:", status);
        frame.addLine("[Xp Gained]:", rsFormat((int)experienceGained));
        frame.addLine("[Fish Per Hour]:", getHourlyRate(fishBanked));
        frame.addLine("[Xp Per Hour]:", rsFormat(getHourlyRate((int)experienceGained)));
        if(!scriptBankFish) {
            frame.addLine("[Fish Dropped]:", fishDropped);
        } else {
            frame.addLine("[Fish Banked]:", fishBanked);
        }
        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...