HunterRS Posted September 10, 2017 Posted September 10, 2017 (edited) I cant for the life of me get this to work. I am trying to attack a cow while my player is not in combat and the cow is not in combat. I used so many freaking filters but non of them work. Here is what I currently have: State definer NPC cow = getNpcs().closest(cowFilter); if (cow != null && !myPlayer().isAnimating()) return State.ATTACK; switch case case ATTACK: NPC cow = getNpcs().closest(cowFilter); if (cow != null && !myPlayer().isAnimating()) cow.interact("Attack"); break; cow filter Filter<NPC> cowFilter = new Filter<NPC>(){ public boolean match(NPC npc){ return (npc.getName().equalsIgnoreCase("Cow") || npc.getName().equalsIgnoreCase("Cow calf")) && !npc.isHitBarVisible() && !npc.isAnimating() && npc.isAttackable() && getMap().canReach(npc); } }; Anyone has any idea what I am doing wrong? Edited September 10, 2017 by HunterRS
GPSwap Posted September 10, 2017 Posted September 10, 2017 (edited) combat.isFighting(); cow.isUnderAttack combat.isFighting checks if your player is in combat - so change your !myPlayer().isAnimating to !combat.isFighting() Entity.isUnderAttack will check if entity is under attack - and add this to your cow filter Edited September 10, 2017 by GPSwap 2
HunterRS Posted September 10, 2017 Author Posted September 10, 2017 20 minutes ago, GPSwap said: combat.isFighting(); cow.isUnderAttack combat.isFighting checks if your player is in combat - so change your !myPlayer().isAnimating to !combat.isFighting() Entity.isUnderAttack will check if entity is under attack - and add this to your cow filter ya just found isFighting, was exactly what I was looking for. Ty for your help 1
Alek Posted September 10, 2017 Posted September 10, 2017 Why not contains "Cow"? Why do you have to make two separate checks?
HunterRS Posted September 10, 2017 Author Posted September 10, 2017 Just now, Alek said: Why not contains "Cow"? Why do you have to make two separate checks? Just did 2 seperate checks one for the State define and the other for the attack itself.
Alek Posted September 10, 2017 Posted September 10, 2017 npc.getName().equalsIgnoreCase("Cow") || npc.getName().equalsIgnoreCase("Cow calf"))