Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

AutoFighter script not running smooth

Featured Replies

3 minutes ago, Prolax said:

Hmm, still attacks the npc twice. Anything I can add?

 

 

Sorry, previous answer was completely wrong, not sure why I wrote that, try storing the seagull in a global variable, and checking like this:

private NPC seagull;

@Override
public final int onLoop() throws InterruptedException {
    if (seagull == null || !myPlayer().isInteracting(seagull)) {
        attackNpc();
    }
    return random(100,300);
}

And of course assign seagull in your attackNPC method

  • Author
22 hours ago, Explv said:

 

Sorry, previous answer was completely wrong, not sure why I wrote that, try storing the seagull in a global variable, and checking like this:


private NPC seagull;

@Override
public final int onLoop() throws InterruptedException {
    if (seagull == null || !myPlayer().isInteracting(seagull)) {
        attackNpc();
    }
    return random(100,300);
}

And of course assign seagull in your attackNPC method

public final class ProlaxAutoFighter extends Script {
    private NPC seagull;

    @Override
    public final int onLoop() throws InterruptedException {
        seagull = getNpcs().closest(npc -> npc.getName().equals("Seagull"));

        if (!myPlayer().isInteracting(seagull) && seagull != null && !seagull.isUnderAttack() && seagull.getHealthPercent() > 0 && !getCombat().isFighting()) {
            attackNpc();
        }

        return random(100,300);
    }

    public void attackNpc(){
        NPC seagull = getNpcs().closest(npc -> npc.getName().equals("Seagull"));
            seagull.interact("Attack");
            new ConditionalSleep(3000,500) {
                @Override
                public boolean condition() {
                    return seagull.getHealthPercent() == 0 || getCombat().isFighting() || seagull == null;
                }
            }.sleep();

    }
}

Runs pretty good now. Is there any better way to store the seagull variable once?

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.