private State getState() {
NPC yak = npcs.closest("Yak");
if (yak != null)
return State.ATTACK;
return State.WAIT;
}
remove this
NPC yak = npcs.closest("Yak");
if (yak != null)
return State.ATTACK;
return State.WAIT;
and you could change it in different ways. Mine may not be the best but it works
if (!myplayer().isanimating && !myplayer.isUnderAttack)
return State.ATTACK;
return State.WAIT;
then your case can be changed from
to..
case ATTACK:
NPC target = npcs.closest(new Filter<NPC>() //add the whole filter code snippet i gave at top. here
if (target != null && !combat.isFighting() && target.isAttackable()) {
target.interact("Attack");
status = "Interacting with Yak";
sleep(random(500, 800));
}
break;