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 167
  • Eyes 2
  • Not Good 3
  • Good 39
  • Love 5
  • Love 51

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
  • Cry 1
  • Lmao 1
Link to comment
Share on other sites

  • 4 months later...
  • 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
	}

 

Link to comment
Share on other sites

Announcements



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