Jump to content

Frog Killer w/ Teleport support


Imthabawse

Recommended Posts

Made an updated version of my first Frog killing script. 

Whats new?

- Teleport to Lumbridge Castle if you have the proper runes in you're inventory, walks to bank and withdraws more Tuna.

- If you don't have the level to cast Teleport have no fear. I've added an option for walking as well :)

 

Id like to add:

- @Explv's sleep curious how I can add it to the API to use in all my scripts

- Moving of camera to NPC when im attacking it and it's not visible on screen

- Logging out (Stopping script) if out of Tuna in the bank

Feedback appreciated! :D

CODE:

 

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;


@ScriptManifest(name = "Frog killer", logo = "", version = 1, author = "Imthabawse", info = "Kills frogs for gains")

public final class FrogKiller extends Script {

    private final Area killArea = new Area(3208, 3168, 3194, 3181);
    private final Area teleArea = new Area(3226, 3227, 3217, 3212);

    @Override
    public void onStart() {
        log("Welcome to Frog Killer.. let's get to it!");
    }

    @Override
    public int onLoop() throws InterruptedException {
        killFrog();
        bank();
        eat();
        return 2500;
    }





    private void eat() {
        if (myPlayer().getHealthPercent() < 55 && getInventory().contains("Tuna")) {
            log("I got an owie, let's eat!");
            getInventory().interact("Eat", "Tuna");
        }
    }


    private void bank() throws InterruptedException {
        if (!getInventory().contains("Tuna") && !myPlayer().isAnimating() && !myPlayer().isMoving() && getInventory().contains("Air rune", "Earth rune", "Law rune")) {
            log("Teleportings for cool kids!");
            getMagic().castSpell(Spells.NormalSpells.LUMBRIDGE_TELEPORT);
            new ConditionalSleep(10000) {
                @Override
                public boolean condition() {
                    return teleArea.contains(myPosition());
                }
            }.sleep();
            log("Walking to bank.. please wait patiently.");
            getWalking().webWalk(Banks.LUMBRIDGE_UPPER);
            log("Opening bank..");
            getBank().open();
            log("Withdrawling Tuna's..");
            getBank().withdrawAll("Tuna");
            getTabs().open(Tab.INVENTORY);
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    return getInventory().contains("Tuna");
                }
            }.sleep();
        } else if (!getInventory().contains("Tuna") && !myPlayer().isAnimating() && !myPlayer().isMoving()) {
            log("Welp can't tele.. let's walk...");
            getWalking().webWalk(Banks.LUMBRIDGE_UPPER);
            log("Opening bank..");
            getBank().open();
            log("Withdrawlings Tuna's..");
            getBank().withdrawAll("Tuna");
            getTabs().open(Tab.INVENTORY);
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    return getInventory().contains("Tuna");
                }
            }.sleep();
        }
    }


    private void killFrog() {
        if (!killArea.contains(myPosition()) && getInventory().contains("Tuna")) {
            log("Let's get to killing!");
            getWalking().webWalk(killArea);
        } else if (killArea.contains(myPosition()) && !myPlayer().isAnimating() && !myPlayer().isMoving() && getInventory().contains("Tuna")) {
            NPC frog = getNpcs().closest(killArea,"Giant frog","Big frog");
            if (!frog.isUnderAttack() && !frog.isHitBarVisible() && frog.isOnScreen()) {
                    log("DIE! FROG! DIE!");
                    frog.interact("Attack");
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() {
                            return myPlayer().isAnimating();
                        }
                    }.sleep();
                }
            }
        }
    }
Link to comment
Share on other sites

It's getting better and better :)

Adding camera movement: 

        //NPC frog = getNpcs().closest(killArea,"Giant frog","Big frog");
        //it's better to use filter here with all conditions that you want for finding frog.
        //in your code before it would only return frog with correct frog name, however, it might return
        // you a frog that was already under attack/frog which has hit bar visible.
        NPC frog = npcs.closest(npc -> (npc.getName().equals("Giant frog") || npc.getName().equals("Big frog")) &&
                !npc.isUnderAttack() && !npc.isHitBarVisible());
        {
            if (frog != null) { //make sure to check if frog is not null
                if (!frog.isOnScreen()) {
                    if (camera.toEntity(frog)) { //move camera to Frog if it is not on the screen
                        //do something if camera was moved to frog - it should be on screen now
                    }
                }
                //if (frog != null && !frog.isUnderAttack() && !frog.isHitBarVisible() && frog.isOnScreen()) {
                log("DIE! FROG! DIE!");
                if (frog.interact("Attack")) { //add a condition to make sure you will call ConditionalSleep only if frog was interacted
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() {
                            return myPlayer().isAnimating();
                        }
                    }.sleep();
                }
            }
        }

 

And about logging out when you don't have any Tunas anymore, it's quite simple

        if (getBank().getAmount("Tuna") == 0) //checks if there is 0 Tunas in bank (you can check for any number, e.g. "< 10" ///less than 10
        {
            log("not enough tuna in bank");
            getBank().close();
            stop(true); // true to log out, false to stay logged in and just stop script
        }

 

Edited by Xx pk xX
  • Like 1
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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...