1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Resolved CombatGauge not functioning correctly

Discussion in 'Client & Site Support' started by Liquid, Jul 14, 2014.

Thread Status:
Not open for further replies.
  1. Liquid

    Joined:
    Jul 13, 2014
    Messages:
    8
    Likes Received:
    0
    Players.getLocal().getHealthGauge().getPercent() throws a NPE if the over-head adrenaline bar (example) is not visible. If it is visible, it'll return the player's adrenaline percent.

    Likely caused by the recent game-updates surrounding combat (legacy mode, graphical changes, etc.)
     
  2. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Not a bug actually, if the health/adrenaline gauge isn't visible then the data related to it isn't available, so the gauge returns null.
     
  3. Liquid

    Joined:
    Jul 13, 2014
    Messages:
    8
    Likes Received:
    0
    getHealthGauge()#getPercent() is returns the value of getAdrenalineGauge()#getPercent(), and getAdrenalineGauge()#getPercent() returns null even if it is visible.

    It is a bug.

    Also, I would much rather it was implemented from the gathering of data of the actionbar. Why one should only be able to return the player's health percent whilst they are in combat, I do not know.
     
  4. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Oh I'm sorry originally I misunderstood you. I'll check into it.

    In response to your other question, if you'd like to get the data from the actionbar then you can. The rs3 package contains an ActionBar class that contains methods such as getHealth and getMaximumHealth. Those are more appropriate for when you're just looking for the local players health, but when it comes to other npcs the only way you can check their health is through the combat gauges
     
    Liquid likes this.
  5. Liquid

    Joined:
    Jul 13, 2014
    Messages:
    8
    Likes Received:
    0
    I see it now, thanks (-:

    Ended up re-coding it myself, using the text from the action-bar

    Code (Text):
    1.  
    2. private static final InterfaceComponent HEALTH_COMPONENT = Interfaces.getAt(1430, 4, 7);
    3.  
    4. private static String healthTextAb() {
    5.   return HEALTH_COMPONENT.getText();
    6. }
    7.  
    8. private static double getMaximumHealthAb() {
    9.   String h = healthTextAb();
    10.   return Double.parseDouble(h.substring(h.indexOf("/") + 1, h.length()));
    11. }
    12.  
    13. private static double getHealthAb() {
    14.   String h = healthTextAb();
    15.   return Double.parseDouble(h.substring(0, h.indexOf("/")));
    16. }
    17.  
    18. public static int getHealthPercentAb() {
    19.   return (int) Math.round(getHealthAb() / getMaximumHealthAb() * 100);
    20. }
    21.  
     
  6. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    May I ask why you did that (Unless it was before you knew in which case I completely understand)?
     
  7. Liquid

    Joined:
    Jul 13, 2014
    Messages:
    8
    Likes Received:
    0
    Already started before you posted the reply

    By the way, this pretty much sums up the problem

    [​IMG]

    As you see, health is reported to be at 100%.
     
  8. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Yeah I found the problem in the code, I'm writing a better framework for the data structure the game uses so I don't have any similar problems in the future
     
    #8 Cloud, Jul 14, 2014
    Last edited: Jul 14, 2014
  9. Wyn

    Wyn

    Joined:
    Jul 10, 2014
    Messages:
    65
    Likes Received:
    7
    Use settings/varps for getting actionbar you nub. You shouldn't be using widgets with almost all of the bars accessible through them.
     
  10. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    What? We're talking about the combat gauges that appear above players heads?
     
  11. Wyn

    Wyn

    Joined:
    Jul 10, 2014
    Messages:
    65
    Likes Received:
    7
    Players.getLocal().getHealthGauge().getPercent()
    Players.getLocal().getAdrenalineGauge()#getPercent()

    There are settings/varps for those, same for maximum health. No reason to check widgets.
     
  12. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    As a followup, I've gone ahead and written a nice wrapper around a LinkedList implementation in the game engine to help me better manage when things related to their linked lists. The hooks were also updated, and because of that until the next release both gauges will return the health gauges value (instead of the adrenaline gauges, but everything is fixed in the next release).
     
  13. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Mate, that's only for the local player, you're forgetting that other Actors also have combat gauges lol. Using the CombatBar class to just get the local players data works fine and does use varps, but for other Actors you need to rely on their CombatGauges
     
  14. Wyn

    Wyn

    Joined:
    Jul 10, 2014
    Messages:
    65
    Likes Received:
    7
    I assumed you used settings automatically for the localplayer for any methods that can easily be checked with settings. :(.
     
  15. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    Yeah no problem mate, but when somethings local player specific I tend to put it in separate classes to not cause any confusion.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...