Azure117 1 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
Bonfire 334 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.