Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • getHealthPercent()


    Ayylmao42000

    Recommended Posts

    NPC newGargoyle = getNpcs().closest(n -> n != null && n.getName().equals("Gargoyle") && n.hasAction("Attack") && n.getHealthPercent() > 0 && n.canAttack()); 
    
     

    Still attacks the npc even though the health is at 0 aka it's doing the dying animation.

    Link to comment
    Share on other sites

     

    You could try

    && n.getAnimation() != deathAnimationID
    

    Sure, that'd work but then again the api method would still stay broke and would have to manually get death animation ids for npcs.

    Link to comment
    Share on other sites

    Sure, that'd work but then again the api method would still stay broke and would have to manually get death animation ids for npcs.

    I know, I'm not saying you shouldn't post about it.  :)

    Just offering a possible solution until your issue is fixed.

     

    PS; if you try to log the health percentage, do you get a proper value?

    Link to comment
    Share on other sites

    getNpcs().closest(npc -> npc != null && npc.getName().equals("Gargoyle") && !npc.isInCombat()).interact("Attack");

     

    This works if you're just trying to find and attack a new gargoyle.

    Link to comment
    Share on other sites

    NPC newGargoyle = getNpcs().closest(n -> n != null && n.getName().equals("Gargoyle") && !n.isHealthBarVisible() && n.canAttack()); 
    

    use this.

    getNpcs().closest(npc -> npc != null && npc.getName().equals("Gargoyle") && !npc.isInCombat()).interact("Attack");

     

    This works if you're just trying to find and attack a new gargoyle.

     

    no. you'll get a null pointer exception too often for this to be worth it. also, this just doesnt fix his problem.

    Link to comment
    Share on other sites

    NPC newGargoyle = getNpcs().closest(n -> n != null && n.getName().equals("Gargoyle") && !n.isHealthBarVisible() && n.canAttack()); 
    

    use this.

     

    no. you'll get a null pointer exception too often for this to be worth it. also, this just doesnt fix his problem.

     

     

    I use this exact line to attack gargoyles in my gargoyle slayer and it's never thrown an exception trying to find and attack a gargoyle. Use what you want, there's obviously more than one way to filter out other gargoyles in combat already.

    Link to comment
    Share on other sites

    I use this exact line to attack gargoyles in my gargoyle slayer and it's never thrown an exception trying to find and attack a gargoyle. Use what you want, there's obviously more than one way to filter out other gargoyles in combat already.

     

    right.. if there's no attackable gargoyle, thats going to throw a null pointer. thats just undeniable logic.

    Link to comment
    Share on other sites

    right.. if there's no attackable gargoyle, thats going to throw a null pointer. thats just undeniable logic.

     

    I'm just telling you that out of the 20+ hours of me testing my gargoyle script, it's never thrown that error. I'm not arguing with the logic, I'm just saying that an exception wasn't thrown "too often" in my case.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.