shaba123 Posted May 16, 2018 Posted May 16, 2018 If there is 5 different npcs in an area with different names how can i attack the closest one?
Tommm39 Posted May 16, 2018 Posted May 16, 2018 NPC monsterToAttack = getNPCs().closest("Name 1", "Name 2", "Name 3", "Name 4", "Name 5"); if (monsterToAttack != null && monsterToAttack.interact()) { } 2
TheMcPker Posted May 16, 2018 Posted May 16, 2018 17 minutes ago, Tommm39 said: NPC monsterToAttack = getNPCs().closest("Name 1", "Name 2", "Name 3", "Name 4", "Name 5"); if (monsterToAttack != null && monsterToAttack.interact()) { } small note its best to make the NPC monsterToAttack; in your class and when you use it in a method use monsterToAttack = getNPCs().closest("Name 1", "Name 2", "Name 3", "Name 4", "Name 5");
Stimpack Posted May 16, 2018 Posted May 16, 2018 8 hours ago, TheMcPker said: small note its best to make the NPC monsterToAttack; in your class and when you use it in a method use monsterToAttack = getNPCs().closest("Name 1", "Name 2", "Name 3", "Name 4", "Name 5"); +1 @Tommm39 1
Canidae Posted May 17, 2018 Posted May 17, 2018 (edited) On 5/16/2018 at 2:06 PM, TheMcPker said: small note its best to make the NPC monsterToAttack; in your class and when you use it in a method use monsterToAttack = getNPCs().closest("Name 1", "Name 2", "Name 3", "Name 4", "Name 5"); If you are not using the NPC outside the method, there's no reason to do so. Edited May 17, 2018 by Canidae 1