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() returning 100 indefinitely.


    Rubick

    Recommended Posts

    I've got an issue where getHealthPercent() returns 100 no matter what. I've got a log printing it's value and I'm looking at my character at 10% HP. What's up with it? Pretty sure it worked before.

     

    Also what's up with the suggested method being struck out in IntelliJ?

     

    AJQFvI5.png

     

     

    Edit: Apparently getHealthPercent() is only when in combat, and apparently this is the workaround:

    getSkills().getBoostedLevels(Skill.HITPOINTS)
    

    But it returns the current health points, which makes things tricky when using accounts with different HP levels, but it will do.

     

    Edit 2: This is what I needed, works outside of combat and returns a percent instead of the HP integer.

    getCombat().getHealthPercent()
    
    Link to comment
    Share on other sites

    I've got an issue where getHealthPercent() returns 100 no matter what. I've got a log printing it's value and I'm looking at my character at 10% HP. What's up with it? Pretty sure it worked before.

     

    Also what's up with the suggested method being struck out in IntelliJ?

     

    AJQFvI5.png

     

     

    Edit: Apparently getHealthPercent() is only when in combat, and apparently this is the workaround:

    getSkills().getBoostedLevels(Skill.HITPOINTS)
    

    But it returns the current health points, which makes things tricky when using accounts with different HP levels, but it will do.

     

    Struck out methods are deprecated, meaning you shouldn't attempt to use them.

    Link to comment
    Share on other sites

    Struck out methods are deprecated, meaning you shouldn't attempt to use them.

     

    I figured i was just curious! Thanks.

    Link to comment
    Share on other sites

    getCombat().getHealthPercent() works just fine though ;)

     

     

    If you're checking the health percent for your local player only, you can use getCombat().getHealthPercent() as it will always work and is based on your skills.

     

    Thanks gents, works perfect. Should have edited post showing i found this. :)

    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.