Annointed Posted November 6, 2016 Share Posted November 6, 2016 (edited) Hey guys, so I currently have a problem where, my script will still attack an NPC that is under attack from someone using Magic that does no damage. Currently someone is using magic, and they're doing no damage to the cow, so the cow's hp bar isn't showing up, but the cow is attacking back, but my script thinks it's not fighting and tries to attack it? Here's my filter: NPC cow = getNpcs().closest(new Filter<NPC>() { @@Override public boolean match(NPC cow) { return cow.getName().startsWith("Cow") && cow.isAttackable() && !cow.isUnderAttack() && cow.getHealthPercent() > 0 && cowArea.contains(cow); } }); Thanks! Edited November 6, 2016 by Annointed Quote Link to comment Share on other sites More sharing options...
House Posted November 6, 2016 Share Posted November 6, 2016 check if its not interacting with anything? Quote Link to comment Share on other sites More sharing options...
Explv Posted November 6, 2016 Share Posted November 6, 2016 Hey guys, so I currently have a problem where, my script will still attack an NPC that is under attack from someone using Magic that does no damage. Currently someone is using magic, and they're doing no damage to the cow, so the cow's hp bar isn't showing up, but the cow is attacking back, but my script thinks it's not fighting and tries to attack it? Here's my filter: Thanks! Just FYI the: !cow.isUnderAttack() && cow.getHealthPercent() > 0 Is redundant because: cow.isAttackable() Does: npc.getHealthPercent() > 0 && !npc.isUnderAttack() || npc.isInteracting(getMethods().myPlayer()) As for your issue you could try doing: NPC cow = getNpcs().closest(npc -> npc.getName().startsWith("Cow") && cowArea.contains(npc) && npc.isAttackable() && npc.getInteracting() == null); 1 Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted November 6, 2016 Share Posted November 6, 2016 Just FYI the: !cow.isUnderAttack() && cow.getHealthPercent() > 0 Is redundant because: cow.isAttackable() Does: npc.getHealthPercent() > 0 && !npc.isUnderAttack() || npc.isInteracting(getMethods().myPlayer()) As for your issue you could try doing: NPC cow = getNpcs().closest(npc -> npc.getName().startsWith("Cow") && cowArea.contains(npc) && npc.isAttackable() && npc.getInteracting() == null); +1. Perfect explanation as always. .getInteracting is very useful. 1 Quote Link to comment Share on other sites More sharing options...