Jump to content

(Open Source) ELeetLumbyFrogs


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 killing frogs in lumby and burying the 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.GroundItem;
import com.epicbot.api.shared.entity.ItemWidget;
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.*;


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

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

    private final Timer runTimer = new Timer(0);
    private static String status = "Starting";
    private String[] pickupLoots = {"Big bones"};
    private double trainedSkillExperienceGained, trainedSkillStartingExperience = 0;
    private double prayerSkillExperienceGained, prayerSkillStartingExperience = 0;
    private Skill.Skills trainedSkill = Skill.Skills.RANGED;
    private Skill.Skills prayerSkill = Skill.Skills.PRAYER;

    public IGroundItemsAPI groundItems()  { return getAPIContext().groundItems(); }
    public ICameraAPI camera()  { return getAPIContext().camera(); }
    public INPCsAPI npcs()  { return getAPIContext().npcs(); }
    public IMouseAPI mouse()  { return getAPIContext().mouse(); }
    public IInventoryAPI inventory()  { return getAPIContext().inventory(); }
    public IScriptAPI script()  { return getAPIContext().script(); }
    public ILocalPlayerAPI player()  { return getAPIContext().localPlayer(); }
    public ITabsAPI tabs()  { return getAPIContext().tabs(); }
    public IEquipmentAPI equipment()  { return getAPIContext().equipment(); }
    public ISkillsAPI skills()  { return getAPIContext().skills(); }
    public IWebWalkingAPI webWalking()  { return getAPIContext().webWalking(); }


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

        if(!player().isAttacking() && !player().isMoving() && player().getInteracting() == null) {
            /*if(playerIsUsingRanged()) {
                equipArrows();
            }*/

            while(inventoryContainsBigBones()) {
                buryBones();
            }

            while(groundContainsLoot()) {
                pickupLoots();
            }

            rotateCamera();
            attackNpc();
            moveMouse();
        }

        return 3;
    }

    private void handleCalculations() {

        //Handle Trained Skill Calculation
        if (trainedSkillStartingExperience == 0) {
            trainedSkillStartingExperience = skills().get(trainedSkill).getExperience();
        } else {
            trainedSkillExperienceGained = skills().get(trainedSkill).getExperience() - trainedSkillStartingExperience;
        }

        //Handle Prayer Skill Calculation
        if (prayerSkillStartingExperience == 0) {
            prayerSkillStartingExperience = skills().get(prayerSkill).getExperience();
        } else {
            prayerSkillExperienceGained = skills().get(prayerSkill).getExperience() - prayerSkillStartingExperience;
        }
    }

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

    public static int getShortSleepTime() {
        int sleepMin = 733;
        int sleepMax = 1123;
        return Random.nextInt(sleepMin, sleepMax);
    }
    public static int getSleepTime() {
        int sleepMin = 3750;
        int sleepMax = 5530;
        return Random.nextInt(sleepMin, sleepMax);
    }
    public static int getAmountToTurnCamera() {
        return Random.nextInt(-322, 363);
    }

    private void walkToStartingSpot() {
        webWalking().walkTo(new Tile(3199, 3171, 0));
    }

    public void attackNpc() {
        if(player().getInteracting() != null || player().isMoving() || player().isAnimating()) {
            return;
        }

        String npc = "Giant frog";
        GameEntity entity = npcs().query().named(npc).distance(10.0).reachable().results().nearest();

        if(entity == null) {
            walkToStartingSpot();
            Time.sleep(getSleepTime());
            return;
        }

        status = "Attacking " + npc;
        entity.interact("Attack");
        Time.sleep(getShortSleepTime());
    }

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

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

    public void eatFood() {
        //Check Inventory For Food
        String food = "Swordfish";
        if(!inventory().contains(food)) {
            System.out.println("No food left to eat.");
            script().pause("No food found. Paused Script.");
        }

        //Click food if health is < 50%
        int currentHealth = player().getHealthPercent();
        if(currentHealth < 50) {
            status = "Eating Food";

            //Swap to Inventory Tab if it's not open
            if(!tabs().isOpen(ITabsAPI.Tabs.INVENTORY)) {
                tabs().open(ITabsAPI.Tabs.INVENTORY);
            }

            int foodX = inventory().getItem(food).getX();
            int foodY = inventory().getItem(food).getY();
            mouse().click(foodX, foodY);
        }
    }

    public boolean inventoryContainsBigBones() {
        return inventory().contains("Big bones");
    }

    public boolean playerIsUsingRanged() {
        boolean isUsingRanged;

        if(equipment().getItem(IEquipmentAPI.Slot.WEAPON).getName().contains("bow")) {
            isUsingRanged = true;
        } else {
            isUsingRanged = false;
        }

        return isUsingRanged;
    }

    public boolean groundContainsLoot() {
        boolean lootFound = false;

        for(int i = 0; i < pickupLoots.length; i++) {
            GroundItem loot = groundItems().query().named(pickupLoots[i]).distance(10.0).reachable().results().nearest();

            if(loot != null) {
                lootFound = true;
            }
        }

        return lootFound;
    }

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

        ItemWidget item = inventory().getItem(pickupLoots[0]);
        if(inventory().contains(pickupLoots[0])) {
            mouse().click(item);
        }
    }

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

        ItemWidget item = inventory().getItem(pickupLoots[0]);
        item.interact("Bury");
    }

    public void pickupLoots() {
        status = "Picking up loots";

        rotateCamera();

        for(int i = 0; i < pickupLoots.length; i++) {
            GroundItem item = groundItems().query().named(pickupLoots[i]).distance(10.0).reachable().results().nearest();

            if(item != null) {
                item.interact("Take");
                Time.sleep(getShortSleepTime());
            }
        }
    }

    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) {
        double xpPerKill = 92.0;

        PaintFrame frame = new PaintFrame("ELeetLumbyFrogs");
        frame.addLine("[Time running]:", runTimer.toElapsedString());
        frame.addLine("[Status]:", status);
        frame.addLine("", "");
        frame.addLine("[Kills]:", (int)(trainedSkillExperienceGained / xpPerKill));
        frame.addLine("[Bones Buried]:", (int)(prayerSkillExperienceGained / 15));
        frame.addLine("", "");
        frame.addLine("[Ranged Xp Gained]", trainedSkillExperienceGained);
        frame.addLine("[Ranged Xp Per Hr]", rsFormat(getHourlyRate((int)trainedSkillExperienceGained)));
        frame.addLine("", "");
        frame.addLine("[Prayer Xp Gained]", prayerSkillExperienceGained);
        frame.addLine("[Prayer Xp Per Hr]", rsFormat(getHourlyRate((int)prayerSkillExperienceGained)));
        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...