Jump to content
  • 0

Mob HP Bug


Minton

Question

Posted (edited)

Hi,

As default in sources, you cannot exceed mob hp's by ~21,4 million because there some part of the game where a percentage calculation happens. When calculating the percentage it multiplies the current HP with 100 then divide by the full HP. At the multiplying part it runs out of Int limits and because of that things get buggy. I dont really want to change the datatype of HP stuff in the whole source. I've made a "ghetto" fix but im looking for better solutions. Suggestions?

 

Or just multiply after dividing? Like (currentHP / maxHP) * 100?

 

WARNING: !!GHETTO CODE!!

Spoiler

spacer.png

 

Thanks!

Edited by Minton
Link to comment

3 answers to this question

Recommended Posts

  • 0
3 hours ago, LordZiege said:

Use static_cast and cast it to long long and your problems should be solved.

What should i cast? everything as i did?

Link to comment
  • 0
Posted (edited)
bHPPercent = MINMAX(0, reinterpret_cast<uint64_t>((static_cast<int64_t>(TargetPacket.icurHP * static_cast<int64_t>(100)) / static_cast<int64_t>(TargetPacket.iMaxHP)), 100));

edit :

uint64_t limit = 18,446,744,073,709,551,615

 

ALSO BIG NOTE;

 

int MINMAX(int  min, int value, int max)
{
    int tv;

    tv = (min > value ? min : value);
    return (max < tv) ? max : tv;
}

Edited by Denizeri24
  • Love 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.