Bobrocket Posted May 29, 2015 Share Posted May 29, 2015 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? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted May 29, 2015 Share Posted May 29, 2015 (edited) 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 May 29, 2015 by FrostBug 1 Quote Link to comment Share on other sites More sharing options...
Woody Posted May 29, 2015 Share Posted May 29, 2015 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 } } Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted May 29, 2015 Author Share Posted May 29, 2015 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? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted May 29, 2015 Share Posted May 29, 2015 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. 1 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted May 29, 2015 Author Share Posted May 29, 2015 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 Quote Link to comment Share on other sites More sharing options...