May 29, 201510 yr 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?
May 29, 201510 yr 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, 201510 yr by FrostBug
May 29, 201510 yr 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 } }
May 29, 201510 yr 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?
May 29, 201510 yr 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.
May 29, 201510 yr 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