Brian Posted May 21, 2020 Share Posted May 21, 2020 Filter<NPC> gorillaFilter; if(myPlayer().isUnderAttack()){ gorillaFilter = n -> n.getName().contains("Demonic") && n.getInteracting() == myPlayer(); }else{ gorillaFilter = n -> n.getName().contains("Demonic") && !n.isUnderAttack(); } NPC a = npcs.closest(gorillaFilter); I am having some trouble determining which gorilla to attack. (Demonic gorilla) After I do boulder dodge, it will sometimes pick some random gorilla very far away and occasionally will just start trying to attack some other gorilla. How can I enhance my `gorillaFilter` ? Quote Link to comment Share on other sites More sharing options...
Chris Posted May 22, 2020 Share Posted May 22, 2020 (edited) private NPC getInteractingNPC() { return getNpcs().closest((Filter<NPC>) npc -> npc != null && npc.hasAction("Attack") && (myPlayer().isInteracting(npc) || (npc.isInteracting(myPlayer()) && !npc.isUnderAttack()))); } What this does: Looks for npc that has attack option AND (we are interacting with it OR it is interacting with us AND not under attack) Then for our main check we do public NPC getAvailableNPC() { NPC npc = getInteractingNPC(); return npc != null ? npc : PRIMARY_FILTER_HERE); } It will make a call to getInteractingNPC() if its null it will try to do your primary filter PRIMARY_FILTER_HERE can be substituted with what you have on the main thread. getNpcs().closest(n -> n.getName().contains("Demonic") && !n.isUnderAttack()); though I recommend adding more checks Then when you want to call NPC a = getAvailableNPC(); If (a != null && a.interact("Attack")) { // sleep until in combat ....... or w.e } @Brian Edited May 22, 2020 by Chris 1 Quote Link to comment Share on other sites More sharing options...