mitch6024 4 Posted March 15, 2017 Hello all! I've been trying to find the correct method to use to find the NPC that is attacking the getLocalPlayer(). The whole reason I'm trying to locate it is to get the NPC that is attacking me and get it's Center Tile. I'm ultimately trying to then get that distance away from my character's tile. I can figure out the rest, all I need is the correct method to find the NPC that is in combat with me. I'm still a nooby scripter and have been trying different things for about 3 hours. With no luck of course, I'm posting here for help. Thanks in advance for any help!
Eclipseop 194 Posted March 15, 2017 https://dreambot.org/javadocs/org/dreambot/api/wrappers/interactive/Character.html#getCharacterInteractingWithMe--
Kvothe 6 Posted March 15, 2017 if you wanna make a list List<NPC> bastards = getNpcs().all(NPC->NPC!=null && NPC.isInteracting(getLocalPlayer()) && NPC.isInCombat()) or if you want a single npc replace all with closest..etc i read the "NPC->" as "Such that" -> "get all NPCs such that" + your conditions but its called a lambda if you wanna google
mitch6024 4 Author Posted March 15, 2017 https://dreambot.org/javadocs/org/dreambot/api/wrappers/interactive/Character.html#getCharacterInteractingWithMe-- That's what I thought originally but I wasn't sure because it was returning a Character instead of a NPC. Thank you for the help! if you wanna make a list List<NPC> bastards = getNpcs().all(NPC->NPC!=null && NPC.isInteracting(getLocalPlayer()) && NPC.isInCombat()) or if you want a single npc replace all with closest..etc i read the "NPC->" as "Such that" -> "get all NPCs such that" + your conditions but its called a lambda if you wanna google Yeah I just need a Single NPC. ill try both and see which one works best. Thank you!
MrRobot 43 Posted March 25, 2017 //npcToFight is any npc name NPC npcX; if(getLocalPlayer().getCharacterInteractingWithMe().getName().equals(npcToFight)){ log("Attacking aggressive NPC"); npcX = (NPC)getLocalPlayer().getCharacterInteractingWithMe(); fight(npcX); //this is my custom method to fight npcs }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.