kushad Posted December 2, 2016 Posted December 2, 2016 What im trying to do is find a specific npc When he is the region of the minimap as a yellow dot or you can see him on screen visually, it finds him but when he is not in that specific region I have trouble scripting to find him can anyone shed some light on this? thanks in advance
Vilius Posted December 2, 2016 Posted December 2, 2016 Area yourArea = new Area(...); NPC npc = getNpcs().filter(npc -> npc != null && yourArea.contains(npc) && npc.getName().equals("NPC NAME")); 2
Butters Posted December 2, 2016 Posted December 2, 2016 (edited) Area yourArea = new Area(...); NPC npc = getNpcs().filter(npc -> npc != null && yourArea.contains(npc) && npc.getName().equals("NPC NAME")); Will work great if the NPC is in the area, bu here's some messy code to walk to npc if it's too far away Filter npcFilter = new Filter<NPC>() { public boolean match(NPC npc) { return npc != null && npc.getName().equals("NPC NAME"); } }; NPC npc = npcs.closest(npcFilter); if (npc != null) { if (npc.isVisible()) { //Interact } else { Area npcArea = npc.getArea(6); // Radius around the NPC if (!npcArea.contains(myPlayer())) { walking.walk(npcArea); } else { camera.toEntity(npc); } } } Edited December 2, 2016 by nosepicker 1
Sikkunt Aaron Posted December 2, 2016 Posted December 2, 2016 semi-related to this thread, but every time i use id's in my code for npcs it laggs client...am i doing something wrong in this code? NPC npc = getNpcs().closest(420); npc.interact("use");and before you say to use Filters/names that won't work in this situation.sorry for being autism
Butters Posted December 2, 2016 Posted December 2, 2016 semi-related to this thread, but every time i use id's in my code for npcs it laggs client... am i doing something wrong in this code? NPC npc = getNpcs().closest(420); npc.interact("use");and before you say to use Filters/names that won't work in this situation. sorry for being autism Well two things here that may produce "Lag", though I think you should be getting an error in the logs. First of all check if the ID's are right, then check if the npc is found with if (npc != null) . Then a good idea would be to check if the NPC is visible, cause it won't interact with it the other way (correct me if I'm wrong). And finally, I seriously doubt that an NPC has an action "use". I don't remember the outcome if you use an action that isn't there. Either nothing happens or you'll get an error.