vhh 3 Posted January 23, 2021 Hi, my script is almost complete. I just have this issue: After I have killed a monster, I want to attack the next closest one that is not already in combat with another player. My issue is that if a Monster respawns next to me as I finish my kill, it wont attack it. It ignores it and attacks one further away. If there are no other monsters, it throws a NullPointerException. This suggests that whenever a monster respawns, it is Null. However, I have declared the NPC within the method so I thought it would be checking every return what the nearest NPC is. Can someone help me figure out why any respawned NPC's are showing as null and aren't getting attacked? Thank you. @Override public int onLoop() { if (KillArea.contains(getLocalPlayer()) && !getLocalPlayer().isInCombat() && !getLocalPlayer().isAnimating()){ log("Attacking NPC"); sleep(500,1100); NPC Monster = NPCs.closest(NPC->NPC!=null && !NPC.isInCombat()); Monster.interact("Attack"); sleepUntil(() -> getLocalPlayer().isAnimating(), Calculations.random( 5000,8000)); } return Calculations.random(850,1150); }
Pandemic 2816 Posted January 23, 2021 Respawned NPC's don't show up as null, could you take a short video of this script running to show it choosing a further away NPC?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.