Mr Asshole Posted July 26, 2013 Share Posted July 26, 2013 (edited) Decided to share this as the get closestAttackableNPC wasn't working that great for me. Enjoy guys private NPC getTarget(int [] ids){ List<NPC> NPCs = closestNPCList(ids); for (NPC i:NPCs){ if (i.getFacing() == null && !i.isAnimating()){ return i; } } return null; } Edited July 29, 2013 by Exarticus Link to comment Share on other sites More sharing options...
Cyro Posted July 26, 2013 Share Posted July 26, 2013 nice only that i see NPCs there useless as you can just do for(NPC i:enemies){ ... } Link to comment Share on other sites More sharing options...
Mr Asshole Posted July 26, 2013 Author Share Posted July 26, 2013 nice only that i see NPCs there useless as you can just do for(NPC i:enemies){ ... } Fixed thanks. Link to comment Share on other sites More sharing options...
GoldenGates Posted July 26, 2013 Share Posted July 26, 2013 Filterrrrsss. Link to comment Share on other sites More sharing options...
Mr Asshole Posted July 26, 2013 Author Share Posted July 26, 2013 Filterrrrsss.More input please and your love for adriana grande is slightly disturbing. Link to comment Share on other sites More sharing options...
GoldenGates Posted July 26, 2013 Share Posted July 26, 2013 Filterrrrsss.More input please and your love for adriana grande is slightly disturbing. You're disturbing. l2spell Link to comment Share on other sites More sharing options...
Mr Asshole Posted July 26, 2013 Author Share Posted July 26, 2013 Filterrrrsss.More input please and your love for adriana grande is slightly disturbing. You're disturbing. l2spell L2spell? Lol what did i spell wrong? Link to comment Share on other sites More sharing options...
GoldenGates Posted July 26, 2013 Share Posted July 26, 2013 Filterrrrsss.More input please and your love for adriana grande is slightly disturbing. You're disturbing. l2spell L2spell? Lol what did i spell wrong? ...Ariana Grande... Link to comment Share on other sites More sharing options...
Illumi Posted July 27, 2013 Share Posted July 27, 2013 Use of filters is more efficient. Also, NPC#isUnderAttack is bad. Link to comment Share on other sites More sharing options...
Mr Asshole Posted July 27, 2013 Author Share Posted July 27, 2013 Use of filters is more efficient. Also, NPC#isUnderAttack is bad. I'm not seeing anything related to filters in the api. Care to explain? Link to comment Share on other sites More sharing options...
Peach Posted July 27, 2013 Share Posted July 27, 2013 This won't return any NPCs that are offscreen because of NPC#isVisible(), it's probably best to remove that entirely and have the script itself run to the off-screen enemy if necessary. Also, like mentioned earlier, NPC#isUnderAttack() isn't the most reliable thing to use. Rather, I'd recommend using NPC#getFacing() to see who the NPC is interacting with. If it's you, always return that one. If it's someone else, they're in combat already, so skip it. If it's null, they're likely not in combat (idle), so chose that one. Link to comment Share on other sites More sharing options...
Mr Asshole Posted July 27, 2013 Author Share Posted July 27, 2013 This won't return any NPCs that are offscreen because of NPC#isVisible(), it's probably best to remove that entirely and have the script itself run to the off-screen enemy if necessary. Also, like mentioned earlier, NPC#isUnderAttack() isn't the most reliable thing to use. Rather, I'd recommend using NPC#getFacing() to see who the NPC is interacting with. If it's you, always return that one. If it's someone else, they're in combat already, so skip it. If it's null, they're likely not in combat (idle), so chose that one. Updated according to your comments. Link to comment Share on other sites More sharing options...
Peach Posted July 28, 2013 Share Posted July 28, 2013 (edited) The way you wrote it unfortunately won't work, although it is a step in the right direction. The line-by-line on yours would go like this: NPC: Man, Level 3 -Player: PlayerOne, Level 126, is interacting with NPC Man. Do not return NPC Man. -Player: PlayerTwo, Level 3, is not interacting with NPC Man. Return NPC Man. Then it'd be returning NPC Man even though he's interacting with PlayerOne. edit: walked through too much Edited July 28, 2013 by Peach Link to comment Share on other sites More sharing options...
Cyro Posted July 29, 2013 Share Posted July 29, 2013 you are trying to see If the character is interacting with another and dont care which one it is #getFacing will return the character that the npc is interacting with if its not interacting with anything then it will return null so Use #getFacing()==null instead of #isFacing(character) Link to comment Share on other sites More sharing options...
Mr Asshole Posted July 29, 2013 Author Share Posted July 29, 2013 you are trying to see If the character is interacting with another and dont care which one it is #getFacing will return the character that the npc is interacting with if its not interacting with anything then it will return null so Use #getFacing()==null instead of #isFacing(character) Thanks fixed. Link to comment Share on other sites More sharing options...