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.

Determine who is attacking myself/NPC?

Featured Replies

So, I want to be able to see if someone else is attacking an NPC I targetted.

For example:

if (man.isUnderAttack() && man.<attacker> != myPlayer()) //I'm not attacking the man
if (man.isUnderAttack() && man.<attacker> == myPlayer()) //I'm attacking the man

Is there any way to do this?

If the sole purpose is to check if YOU are the one attacking the man, then you could just do:

if (man.isUnderAttack() && !man.equals(myPlayer().getInteracting())) //I'm not attacking the man
if (man.isUnderAttack() && man.equals(myPlayer().getInteracting())) //I'm attacking the man

For the second case tho, you should probably add some more checks (We ARE in combat / the man is also interacting with us), in order to prevent any confusion that could occur if someone else is attacking the man, but we're still interacting with it for whatever reason.

Edited by FrostBug

NPC monster = npcs.closest(monsterID);

if(monster != null) { 
   if(monster.isInteracting(myPlayer()) {
      //monster is interacting with my player
   }
}

OR

NPC monster = npcs.closest(monsterID);

if(monster != null) {
  if(myPlayer().isInteracting(monster)) {
     // my player is interacting with monster
  }
}
  • Author

If the sole purpose is to check if YOU are the one attacking the man, then you could just do:

if (man.isUnderAttack() && !man.equals(myPlayer().getInteracting())) //I'm not attacking the man
if (man.isUnderAttack() && man.equals(myPlayer().getInteracting())) //I'm attacking the man

For the second case tho, you should probably add some more checks (We ARE in combat / the man is also interacting with us), in order to prevent any confusion that could occur if someone else is attacking the man, but we're still interacting with it for whatever reason.

 

The idea is that if someone tries to attack the man while I am pickpocketing it, it will stop and say "dude wtf" or something similar. Sometimes, the bot does misclick and attack the man too (which I want to detect)

 

So I would use the first example to check if someone is attacking him?

 

The idea is that if someone tries to attack the man while I am pickpocketing it, it will stop and say "dude wtf" or something similar. Sometimes, the bot does misclick and attack the man too (which I want to detect)

 

So I would use the first example to check if someone is attacking him?

 

 

That may work, but only while you're not focusing on the man as well (eg. will not work right before you pickpocket the man, while the player is focusing the man).

 

What you could do instead is simply check if your own player is under attack. If both you and the man are under attack, you'll be the one attacking him. If the man is under attack, but you are not, then it's probably someone else.

 

  • Author

That may work, but only while you're not focusing on the man as well (eg. will not work right before you pickpocket the man, while the player is focusing the man).

 

What you could do instead is simply check if your own player is under attack. If both you and the man are under attack, you'll be the one attacking him. If the man is under attack, but you are not, then it's probably someone else.

 

 

Thanks, I will try that :)

 

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.