Jump to content

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

  • Metin2 Dev 243
  • kekw 1
  • Eyes 2
  • Not Good 3
  • Good 55
  • Love 7
  • Love 98

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

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


 

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
  • Cry 1
  • Lmao 1
  • 4 months later...
  • Premium

Thank you, its working for me. ?
Lil tanky doggo
https://metin2.download/picture/bjt2x4wGc6U94iHQ6ACW7sNasMCLYuVM/.png

Edited by Metin2 Dev
Core X - External 2 Internal

Ulthar

  • 1 month later...

Thank you ?

I think with so much HP there is a bug with mob health regen.

For example i tried a mob with 40kk hp and is health regen works okay, but for example with 400kk or 1kkk hp the health regen is like 1hp every 8 sec instead of millions

 

Is this the correct way to fix this?

in char.cpp search EVENTFUNC(recovery_event)

else if (!ch->IsDoor())
	{
		ch->MonsterLog("HP_REGEN +%d", MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
		ch->PointChange(POINT_HP, MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
	}

change to

else if (!ch->IsDoor())
	{
		ch->MonsterLog("HP_REGEN +%d", MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
		ch->PointChange(POINT_HP, MAX(1, ((int64_t)ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));//fix
	}

 

  • 1 year later...

Char_state.cpp

This:
 

int iPercent = (GetHP() * 100) / GetMaxHP();

Change to:
 

int iPercent = ((int64_t)GetHP() * 100) / (int64_t)GetMaxHP();

Now monsters appear when they first hit a metin stone, not when a character is near a metin stone without attacking

  • Good 1
  • 5 months later...
  • Active Member
9 hours ago, Mefarious said:

I refresh topic cuz i dont want make new.
After these changes i see their full hp.
But as soon as i hit once mob their hp is shown as 0.

 

Is there any syserr?

7 minutes ago, jking said:

Is there any syserr?

No, i think its just visual. bad calculations or smth like that.
Without changes mob hp glitches if its over 23mln. 
now hp is shown normally until i hit target then it get back to be glitched. maybe i changed it in bad way.

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



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.