Jump to content

[10 Minute Scripts] Make an AIO Fighter Script in 10 Minutes??? (Part 1)


Recommended Posts

Posted

In this video, I write the beginnings of an "AIO" Fighter script which can be extended in future videos. Feel free to use the source code for any purpose.

Source code:

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.util.Arrays;

@ScriptManifest(name = "10MinFighter", version = 1.0, info = "", author = "", logo = "")
public class Driver extends Script {
    String npcName;

    @Override
    public int onLoop() throws InterruptedException {
        // 1. decide which type of npcs to attack
        if (npcName == null) {
            if (myPlayer().getInteracting() != null) {
                npcName = myPlayer().getInteracting().getName();
            } else {
                return 500;
            }
        }
        // 2. attack them
        if (!myPlayer().isAnimating() && myPlayer().getInteracting() == null) {
            NPC next = getNpcs().closest(npc -> npc.getName().equals(npcName) &&
                    npc.isAttackable() && !npc.isUnderAttack() &&
                    npc.getInteracting() == null);
            if (next != null) {
                next.interact("Attack");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return myPlayer().getInteracting() != null;
                    }
                }.sleep();
            }
        }
        // 3. eat food so we don't die
        if (myPlayer().getHealthPercent() < 50) {
            Item food = getInventory().getItem(item ->
                    Arrays.asList(item.getActions()).contains("Eat"));
            if (food != null) {
                food.interact("Eat");
                sleep(2500);
            }
        }
        // 4. (optional) loot and bank
        return 500;
    }
}

Previous tutorial: 

 

 

  • Like 13
  • Heart 1
  • Mald 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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