November 6, 20169 yr 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, 20169 yr by Annointed
November 6, 20169 yr 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);
November 6, 20169 yr 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.
Create an account or sign in to comment