(Resolved) Problems establishing if player is in combat

Discussion in 'Client & Site Support' started by Ozzy, Dec 9, 2014.

  1. I'm having loads of trouble trying to establish if the local player is in combat, methods which have worked fine in the past are now not working correctly.

    I've tried a few different ways, but this is the method which I have used in the past which is consistently returning false even when the player is attacking and being attacked by loads of different npcs.

    Code (Text):
    1. private Boolean isInCombat(Actor a) {
    2.         return a.getTarget() != null || !Npcs.newQuery().within(fightArea).filter(new Filter<Npc>() {
    3.             @Override
    4.             public boolean accepts(Npc npc) {
    5.                 return npc.getTarget() == a;
    6.             }
    7.         }).results().isEmpty();
    8.     }
    Any idea what's up with this?


  2. The first bug I see is npc.getTarget() == a should be .equals instead
  3. Thanks, I've read up on why that fixed the problem and I've updated my code.

Share This Page