Jump to content

Determine who is attacking myself/NPC?


Bobrocket

Recommended Posts

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
  • Like 1
Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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.

 

  • Like 1
Link to comment
Share on other sites

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 :)

 

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