Jump to content

(Open Source) ELeetOgressWarriors


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 Ogress Warriors. *NOTE* I cannot remember if I ever finished this script or not but should be pretty close.

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.*;
import com.epicbot.api.shared.model.Area;
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 = "ELeetOgressWarriors", gameType = GameType.OS)
public class ELeetOgressWarriors extends LoopScript {

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

    private final Timer runTimer = new Timer(0);
    private static String status = "Starting";
    private double experienceGained, startExperience = 0;
    private Skill.Skills trainedSkill = Skill.Skills.ATTACK;
    private int bigBonesInBank = 0;
    private int totalKills = 0;
    private int totalBones = 0;
    private double xpPerKill = 144.0;
    private Tile ogressArea = new Tile(2018,8997,1);
    private Tile safeArea = new Tile(2015,9005,1);

    private Tile holeAreaTop = new Tile(2524,2861,0);
    private Tile holeAreaBottom = new Tile(2012,9004,1);

    private Area killArea = new Area(2015, 8996, 2016, 9002);
    private Tile bankArea = new Tile(2569,2864);
    private String[] pickupItems = {"Law rune", "Nature rune",
                                    "Death rune", "Air rune",
                                    "Chaos rune", "Cosmic rune",
                                    "Earth rune","Fire rune",
                                    "Mind rune", "Water rune",
                                    "Steel arrow", "Iron arrow",
                                    "Uncut sapphire", "Uncut emerald",
                                    "Uncut ruby", "Rune med helm",
                                    "Rune full helm", "Mithril kiteshield",
                                    "Big bones"};

    private ILocalPlayerAPI player()       { return getAPIContext().localPlayer(); }
    private IInventoryAPI   inventory()    { return getAPIContext().inventory();   }
    private IMouseAPI       mouse()        { return getAPIContext().mouse();       }
    private ICameraAPI      camera()       { return getAPIContext().camera();      }
    private ITabsAPI        tabs()         { return getAPIContext().tabs();        }
    private IWebWalkingAPI  webWalking()   { return getAPIContext().webWalking();  }
    private IWalkingAPI     walking()      { return getAPIContext().walking();     }
    private IGroundItemsAPI groundItems()  { return getAPIContext().groundItems(); }
    private INPCsAPI        npcs()         { return getAPIContext().npcs();        }
    private IObjectsAPI     objects()      { return getAPIContext().objects();     }
    private IBankAPI        bank()         { return getAPIContext().bank();        }
    private ISkillsAPI      skills()       { return getAPIContext().skills();      }
    private IEquipmentAPI   equipment()    { return getAPIContext().equipment();   }
    private IWidgetsAPI     widgets()      { return getAPIContext().widgets();     }

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

        eatFood();

        if(beingAttackedByShaman()) {
            walkToSafeArea();
        }

        if(inventory().isFull()) {
            rotateCamera();
            moveMouse();
            rotateCamera();
            walkToBank();
            takeABreak();
            rotateCamera();
            bankLootItems();
        }

        if(groundContainsLoot()) {
            rotateCamera();
            pickupLoot();
        }

        if(!player().isInCombat() && !playerIsInKillArea()) {
            webWalking().walkTo(getHillTile());
        }

        if(!player().isAttacking() && !player().isMoving() && player().getInteracting() == null) {

            rotateCamera();

            if(player().getLocation().getY() > 8996 && !inventory().isFull()) {
                equipSword();
                walkToHillGiantArea();
            }

            attackNpc();

            moveMouse();
        } else {
            rotateCamera();
            moveMouse();
            Time.sleep(getSleepTime());
        }

        return 3;
    }

    private void clickDownHole() {
        GameEntity hole = objects().query().named("Hole").distance(3.0).results().nearest();
        hole.interact("Enter");
        Time.sleep(getSleepTime());
    }
    private void climbUpHole() {
        GameEntity hole = objects().query().named("Vine ladder").distance(3.0).results().nearest();
        hole.interact("Climb");
        Time.sleep(getSleepTime());
    }

    private boolean playerIsToDeep() {
        return player().getY() <= 8996;
    }

    private boolean playerIsInKillArea() {
       return killArea.contains(player().getLocation());
    }

    public void walkToSafeArea() {
        status = "Walking to safe area";

        webWalking().walkTo(getSafeAreaTile());
        walking().setRun(true);
        Time.sleep(getLongSleepTime());
    }

    private void takeABreak() {
        status = "Taking a break";

        if(Random.nextInt(1, 10) == 1) {
            Time.sleep(210000);
        }
    }

    private boolean beingAttackedByShaman() {
        if(player().getInteracting() == null) {
            return false;
        }
        boolean bool = false;

        if(player().getInteracting().getName().equals("Ogress Shaman")) {
            bool = true;
        }

        return bool;
    }

    private void bankLootItems() {
        status = "Banking loot items";

        GameEntity bank = objects().query().named("Bank booth").results().nearest();
        bank.interact("Bank");
        Time.sleep(getSleepTime());

        for(int i = 0; i < pickupItems.length; i++) {
            bank().depositAll(pickupItems[i]);
            Time.sleep(getShortSleepTime());
        }

        bigBonesInBank = bank().getCount("Big bones");

        //restock food
        String foodType = "Swordfish";
        if(inventory().getCount(foodType) < 20) {
            int amountInInvy = inventory().getCount(foodType);
            bank().withdraw((20 - amountInInvy), foodType);
        }

        bank().close();
        Time.sleep(getSleepTime());
    }

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

        totalKills = (int)(experienceGained / xpPerKill);
    }

    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 getLongSleepTime() {
        int sleepMin = 10000;
        int sleepMax = 15000;
        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);
    }
    public void attackNpc() {
        if(player().getInteracting() != null || player().isMoving() || player().isAnimating()) {
            return;
        }

        String npc = "Ogress Warrior";
        NPC entity = npcs().query().named(npc).id(7989).distance(6.0).reachable().results().nearest();
        status = "Attacking " + npc;

        if(!entity.isAttacking() && !entity.isInCombat()) {
            entity.interact("Attack");
            Time.sleep(getShortSleepTime());
        }
    }

    public void rotateCamera() {
        if(Random.nextInt(1, 25) == 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.");
            walkToBank();
        }

        //Click food if health is < 50%
        int currentHealth = player().getHealthPercent();
        if(currentHealth < 75) {
            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 void walkToBank() {
        status = "Walking to bank";

        webWalking().walkTo(holeAreaBottom);
        climbUpHole();
        webWalking().walkTo(getBankTile());

        if(!walking().isRunEnabled() && walking().getRunEnergy() > 50) {
            walking().setRun(true);
        }
        Time.sleep(getShortSleepTime());
    }
    public void walkToHoleAreaTop() {
        status = "Walking to hole area top";

        webWalking().walkTo(holeAreaTop);
        if(!walking().isRunEnabled() && walking().getRunEnergy() > 50) {
            walking().setRun(true);
        }
        Time.sleep(getShortSleepTime());
    }
    public void walkToHoleAreaBottom() {
        status = "Walking to hole area bottom";

        webWalking().walkTo(holeAreaBottom);
        if(!walking().isRunEnabled() && walking().getRunEnergy() > 50) {
            walking().setRun(true);
        }
        Time.sleep(getShortSleepTime());
    }
    public void walkToHillGiantArea() {
        status = "Walking to Ogress Warriors";

        webWalking().walkTo(holeAreaTop);
        clickDownHole();
        webWalking().walkTo(getHillTile());
        if(!walking().isRunEnabled() && walking().getRunEnergy() > 50) {
            walking().setRun(true);
        }
        Time.sleep(getShortSleepTime());
    }

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

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

        return new Tile(randomX, randomY);
    }
    public Tile getSafeAreaTile() {
        int x = safeArea.getX();
        int y = safeArea.getY();
        int randomness = 1;

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

        return new Tile(randomX, randomY);
    }

    public Tile getHillTile() {
        int x = ogressArea.getX();
        int y = ogressArea.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, 1);
    }

    public boolean groundContainsLoot() {
        boolean loot = false;

        for(int i = 0; i < pickupItems.length; i++) {
            GroundItem item = groundItems().query().named(pickupItems[i]).distance(1.0).reachable().results().nearest();
            if(item != null || !inventory().isFull()) {
                loot = true;
            }
        }

        return loot;
    }

    public void equipSword() {
        status = "Equipping sword";

        String sword = "Rune scimitar";
        if(equipment().getItem(IEquipmentAPI.Slot.WEAPON).getName().equals(sword)) {
            return;
        }

        ItemWidget item = inventory().getItem(sword);
        if(!equipment().getItem(IEquipmentAPI.Slot.WEAPON).getName().equals(sword)) {
            mouse().click(item);
        }
    }

    public void pickupLoot() {
        status = "Picking up loot";

        for(int i = 0; i < pickupItems.length; i++) {
            GameEntity loot = groundItems().query().named(pickupItems[i]).distance(5.0).reachable().results().nearest();
            if(loot != null) {

                if(loot.getId() == 532) {
                    totalBones++;
                }

                loot.interact("Take");
                Time.sleep(getShortSleepTime());
            }
        }

        rotateCamera();
    }

    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("ELeetOgressWarriors");
        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.addLine("", "");

        frame.addLine("[Kills]:", (int)(experienceGained / xpPerKill));
        frame.addLine("[Kills Per Hour]:", rsFormat(getHourlyRate(totalKills)));
        frame.addLine("", "");

        frame.addLine("[Bones Collected]:", totalBones);
        frame.addLine("[Bones Per Hour]:", rsFormat(getHourlyRate(totalBones)));
        frame.addLine("", "");

        frame.addLine("[Big Bones Banked]:", bigBonesInBank);
        frame.addLine("[Big Bones Evaluation]:", bigBonesInBank * 235);
        frame.draw(g, 0, 130, 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...