Azure117 1 Share Posted August 19, 2021 Hi, how can I calculate how far I am from a given NPC? I just want to basically check if I should try walking somewhere or not based on how far I am from an NPC. Having a bit of trouble with syntax. NPC spot = NPCs.closest(new String[]{"NPC NAME"}); is how I get the NPC I want. Thanks, Azure Link to comment Share on other sites More sharing options...
Bonfire 331 Share Posted August 19, 2021 Hey @Azure117, you can use the "Entity.distance()" method. By default it'll compare the entity's distance to your local player. An example can be found below: NPC nearbyNPC = NPCs.closest("NPC Name Here"); if (nearbyNPC != null) { int npcDistance = nearbyNPC.distance(); } For NPCs specifically, you can see the JavaDocs here: https://dreambot.org/javadocs/org/dreambot/api/methods/interactive/NPCs.html With the general Entity methods being found here: https://dreambot.org/javadocs/org/dreambot/api/wrappers/interactive/Entity.html Link to comment Share on other sites More sharing options...
Azure117 1 Author Share Posted August 19, 2021 Oh awesome! Thank you so much. That's dope. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.