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.

Something like isAttacking

Featured Replies

So im making a bot that safespots npcs and therefore wont be in combat, i tried isAnimating but it doesn't really work. Any ideas what i could use for this?

Not sure I feel this would work but won't npc.isIntwracting(myaplayer) not work? Or jus the check that npc.isUnderAttack() and that we're in combat grtCombat().isFIghting(); it's 9am forgive me for typos I'm also on my phone

If you want to know if your player is interacting with an NPC you can do:

myPlayer().getInteracting() != null

Edited by Explv

  • Author

If you want to know if your player is interacting with an NPC you can do:

myPlayer().getInteracting() != null

 

Works perfectly, thanks alot bro.

Works perfectly, thanks alot bro.

 

You could extend it further to make sure you are attacking the correct NPC, and that the NPC is still alive like so:

public final boolean isAttacking(final String npcName) {
    final Character character = myPlayer().getInteracting();
    return character != null &&
           character.getName().equals(npcName) &&
           character.getHealthPercent() > 0 &&
           character.isHitBarVisible();
}

Edited by Explv

 

You could extend it further to make sure you are attacking the correct NPC, and that the NPC is still alive like so:

public final boolean isAttacking(final String npcName) {
    final Character character = myPlayer().getInteracting();
    return character != null && 
           character.getName().equals(npcName) && 
           character.isUnderAttack() &&
           character.getHealthPercent() > 0;
}

 

character.isUnderAttack() returns false when you are not being hit by a player/npc

character.isUnderAttack() returns false when you are not being hit by a player/npc

 

No that is not true.

character.isUnderAttack()

Will return true if the character's hit bar is visible and if another NPC or Player is interacting with it:

public boolean isUnderAttack() {
    if(!this.isHitBarVisible()) {
        return false;
    } else {
        List<Character> allCharacters = new ArrayList<>();
        allCharacters.addAll(getMethods().getNpcs().getAll());
        allCharacters.addAll(getMethods().getPlayers().getAll());
    
        for(final Character character : allCharacters) {
            if(character.isInteracting(this)) return true;
        }
    }
    return false;
}

Because OP's bot is interacting with the character, the method would return true if the NPC's hit bar is visible.

 

I have replace the isUnderAttack() method with isHitBarVisible() because we already know that the player is interacting with that NPC, so we only need to check if the hit bar is visible.

Edited by Explv

No that is not true.

character.isUnderAttack()

Will return true if the character's hit bar is visible and if the character is interacting with another NPC or Player.

 

Because OP's bot is interacting with the character, the method would return true if the NPC's hit bar is visible.

 

I have replace the isUnderAttack() method with isHitBarVisible() because we already know that the player is interacting with that NPC, so we only need to check if the hit bar is visible.

 

 

You just said it  yourself...

"Will return true if the character's hit bar is visible AND if the character is interacting"

If you're safe spacing an NPC it'll return false.

 

 

Edit: Zapps retarded

Edited by Zappster

You just said it  yourself...

"Will return true if the character's hit bar is visible AND if the character is interacting"

If you're safe spacing an NPC it'll return false.

 

Sorry I meant to say, if any character is interacting with it. See the code I posted.

Edited by Explv

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.