Jump to content
For maintenance and updates, the community will be offline on 31 December 2022 ×

Target board HP percentage when monster HP is above 21 millions


Recommended Posts

  • Honorable Member

I think some of you faced this bug when you had a monster with more then 21 million HP: the gauge showed 0% even when it was on full HP.

It's because when the server calculates the HP percentage is like MINMAX(0, (m_pkChrTarget->GetHP() * 100) / m_pkChrTarget->GetMaxHP(), 100), so 21 million will overflow when it's multiplied by 100.

The fix is really quick and easy:

This is the hidden content, please

WRnRW3H.gif

Link to comment
Share on other sites

  • 3 months later...
  • Premium
10 hours ago, PetePeter said:

This is enough

 

p.bHPPercent = MINMAX(0, static_cast<int64_t>(static_cast<int64_t>(m_pkChrTarget->GetHP()) * 100) / static_cast<int64_t>(m_pkChrTarget->GetMaxHP()), 100);

 

p.bHPPercent = MINMAX(0, ((int64_t)m_pkChrTarget->GetHP() * 100) / m_pkChrTarget->GetMaxHP(), 100);

p.bHPPercent = MINMAX(0, (((int64_t)GetHP()) * 100) / GetMaxHP(), 100);

This is enough, Dear Peter.
 


 

Link to comment
Share on other sites

2 hours ago, TAUMP said:
p.bHPPercent = MINMAX(0, ((int64_t)m_pkChrTarget->GetHP() * 100) / m_pkChrTarget->GetMaxHP(), 100);

p.bHPPercent = MINMAX(0, (((int64_t)GetHP()) * 100) / GetMaxHP(), 100);

This is enough, Dear Peter.
 

p.bHPPercent = MINMAX(0, (((int64_t)GetHP()) * 100) / GetMaxHP(), 100);

p.bHPPercent = std::minmax<uint8_t>((GetHP() * 100) / GetMaxHP(), 100).first;

This is enough, Dear TAUMP.

Edited by Denizeri24
Link to comment
Share on other sites



  • Similar Content

  • Activity

    1. 1

      Looking for a good designer

    2. 2

      Where are those maps/dungeons coming from?

    3. 3

      Press F10 to close the client immediately

    4. 2

      Where are those maps/dungeons coming from?

    5. 2

      Where are those maps/dungeons coming from?

    6. 4

      Visual studio 2022 compiling issue

    7. 1

      Count players function

    8. 64
  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.