Jump to content

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


Eliot

Recommended Posts

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
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...