vhh 3 Share 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); } Link to comment Share on other sites More sharing options...
Pandemic 2434 Share 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now