Jump to content

Recommended Posts

Hi, I have a problem with the MAX_HP_PCT life percentage bonus, my functions look like this:

 

		case POINT_MAX_HP:
			{
				SetPoint(type, GetPoint(type) + amount);

				int hp = GetRealPoint(POINT_MAX_HP);
				int add_hp = hp * GetPoint(POINT_MAX_HP_PCT) / 100;
				add_hp += GetPoint(POINT_MAX_HP);
				add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);

				sys_log(0, "DEBUG: Base HP: %d, MAX_HP_PCT: %d%%, Additional HP: %d", hp, GetPoint(POINT_MAX_HP_PCT), add_hp);

				SetMaxHP(hp + add_hp);

				sys_log(0, "DEBUG: Final MaxHP: %d", GetMaxHP());

				val = GetMaxHP();
			}
			break;

		
		case POINT_MAX_HP_PCT:
			SetPoint(type, GetPoint(type) + amount);
			val = GetPoint(type);

			sys_log(0, "DEBUG: Updated MAX_HP_PCT: %d", GetPoint(POINT_MAX_HP_PCT));

			PointChange(POINT_MAX_HP, 0);
			break;

		case APPLY_MAX_HP_PCT:
			{
				int i = GetMaxHP(); if(i == 0) break;
				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
				float fRatio = (float)GetMaxHP() / (float)i;
				PointChange(POINT_HP, GetHP() * fRatio - GetHP());
			}
			break;

From the logs it appears that the wrong HP of the character is being retrieved via: int hp = GetRealPoint(POINT_MAX_HP);
The starting HP of the character is 60112, after equipping an item with MAX_HP_PCT +5% it is 60867 which is incorrect.
 

Jan 26 13:39:53 :: DEBUG: GetMaxHP called. Current MaxHP: 60112
Jan 26 13:39:53 :: DEBUG: Updated MAX_HP_PCT: 5
Jan 26 13:39:53 :: DEBUG: Base HP: 15112, MAX_HP_PCT: 5%, Additional HP: 0
Jan 26 13:39:53 :: DEBUG: SetMaxHP called. New MaxHP: 60867
Jan 26 13:39:53 :: DEBUG: GetMaxHP called. Current MaxHP: 60867
Jan 26 13:39:53 :: DEBUG: Final MaxHP: 60867
Jan 26 13:39:53 :: DEBUG: GetMaxHP called. Current MaxHP: 60867


You can see that as base hp did not take 60112 but 15112. Why? How to fix it?
Thanks in advance.

My char.cpp: https://pastebin.com/raw/0KA1Kssa
My char.h: https://pastebin.com/raw/2NgdZpPi

Link to comment
https://metin2.dev/topic/33417-bug-max_hp_pct-hp-percentage-bonus/
Share on other sites

18 hours ago, enisina said:

This is absolutely not wrong, this bonus is just coded to calculate the value of GetRealPoint(POINT_MAX_HP).

So this was intentionally done so that equipment bonuses wouldn't be taken into account?
How can I change this to work the way I want?

  • Active+ Member
2 hours ago, Typical said:

So this was intentionally done so that equipment bonuses wouldn't be taken into account?
How can I change this to work the way I want?

Just look at your prints.. 

On 1/26/2025 at 4:02 PM, Typical said:
sys_log(0, "DEBUG: Final MaxHP: %d", GetMaxHP());
On 1/26/2025 at 4:02 PM, Typical said:
DEBUG: Final MaxHP: 60867

This gives the maxhp you want to edit, so change:

 

On 1/26/2025 at 4:02 PM, Typical said:
int hp = GetRealPoint(POINT_MAX_HP);

into:

int hp = GetMaxHP();

 

22 hours ago, [GF]Froslass said:

Just look at your prints.. 

This gives the maxhp you want to edit, so change:

 

into:

int hp = GetMaxHP();

 

You think I haven't tried that?
Then hp duplicates when equipping and unequipping items.

  • Active+ Member
1 hour ago, Typical said:

You think I haven't tried that?
Then hp duplicates when equipping and unequipping items.

I can't read your mind, i don't know what you have and haven't tried if you don't state it. And i don't know what you mean by hp duplicates if you don't post an example, just search this function inside the whole source and see where it gets called to fix the issue, i'm done trying to help you, good luck!

8 minutes ago, [GF]Froslass said:

I can't read your mind, i don't know what you have and haven't tried if you don't state it. And i don't know what you mean by hp duplicates if you don't post an example, just search this function inside the whole source and see where it gets called to fix the issue, i'm done trying to help you, good luck!

If I have it set like this and the character's HP is 61,506, then after putting on an item with HP_PCT+50% I have 92,645. This works correctly.

If I remove an item with HP_PCT+50%, the HP does not return to 61,506, but then the character has 64,695 HP.

If I have an item with HP_PCT+50% and I have 92,645 HP, and I put on an item that increases HP by 9,000, I have 120,017 HP, and when I remove an item that adds 9,000 HP, my HP is 127,167. xD
 

        case POINT_MAX_HP:
            {

                SetPoint(type, GetPoint(type) + amount);
                int i = GetMaxHP();
                int hp = GetRealPoint(POINT_MAX_HP);
                // int add_hp = MIN(3500, hp * GetPoint(POINT_MAX_HP_PCT) / 100);
                int add_hp = i * GetPoint(POINT_MAX_HP_PCT) / 100;
                add_hp += GetPoint(POINT_MAX_HP);
                add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);
                SetMaxHP(hp + add_hp);
                float fRatio = (float)GetMaxHP() / (float)i;
                PointChange(POINT_HP, GetHP() * fRatio - GetHP());
                val = GetMaxHP();
            }
            break;


 

 

Edited by Typical

That's exactly what you want.

case POINT_ATTBONUS_STONE:
	case POINT_RESIST_HUMAN:
	{
		int PointValue = GetPointIndex(type);
		m_pointsInstant.OldPointValue[PointValue] += amount;
		SetPoint(type, m_pointsInstant.OldPointValue[PointValue] + (m_pointsInstant.OldPointValue[PointValue] * GetPoint(GetPointPer(type))) / 100);
#else
		SetPoint(type, GetPoint(type) + amount);
#endif
		val = GetPoint(type);
		BroadcastTargetPacket();
	}
	break;

 

case POINT_MAX_HP:
    {
        SetPoint(type, GetPoint(type) + amount);

        //SetMaxHP(GetMaxHP() + amount);
        // ÃÖ´ë »ı¸í·Â = (±âº» ÃÖ´ë »ı¸í·Â + Ãß°¡) * ÃÖ´ë»ı¸í·Â%
        int64_t hp = GetRealPoint(POINT_MAX_HP);
        int64_t add_hp = GetPoint(POINT_MAX_HP) + GetPoint(POINT_PARTY_TANKER_BONUS);
//        add_hp += GetPoint(POINT_MAX_HP);
//        add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);
        int64_t hp_pct = (hp + add_hp) * GetPoint(POINT_MAX_HP_PCT) / 100;
        SetMaxHP(hp + add_hp + hp_pct);

        val = GetMaxHP();
    }
    break;

Adjusted

1 hour ago, enisina said:

That's exactly what you want.

case POINT_ATTBONUS_STONE:
	case POINT_RESIST_HUMAN:
	{
		int PointValue = GetPointIndex(type);
		m_pointsInstant.OldPointValue[PointValue] += amount;
		SetPoint(type, m_pointsInstant.OldPointValue[PointValue] + (m_pointsInstant.OldPointValue[PointValue] * GetPoint(GetPointPer(type))) / 100);
#else
		SetPoint(type, GetPoint(type) + amount);
#endif
		val = GetPoint(type);
		BroadcastTargetPacket();
	}
	break;

 

case POINT_MAX_HP:
    {
        SetPoint(type, GetPoint(type) + amount);

        //SetMaxHP(GetMaxHP() + amount);
        // ÃÖ´ë »ı¸í·Â = (±âº» ÃÖ´ë »ı¸í·Â + Ãß°¡) * ÃÖ´ë»ı¸í·Â%
        int64_t hp = GetRealPoint(POINT_MAX_HP);
        int64_t add_hp = GetPoint(POINT_MAX_HP) + GetPoint(POINT_PARTY_TANKER_BONUS);
//        add_hp += GetPoint(POINT_MAX_HP);
//        add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);
        int64_t hp_pct = (hp + add_hp) * GetPoint(POINT_MAX_HP_PCT) / 100;
        SetMaxHP(hp + add_hp + hp_pct);

        val = GetMaxHP();
    }
    break;

Adjusted

spacer.png

It almost works fine, but I still get errors when equipping other items
Additionally, there are HP jumps when equipping/unequipping items, and when add statistics as well

Edited by Typical
Core X - External 2 Internal
2 hours ago, Typical said:

spacer.png

It almost works fine, but I still get errors when equipping other items
Additionally, there are HP jumps when equipping/unequipping items, and when add statistics as well

Find all end change:

 

	case POINT_MAX_HP_PCT:
		SetPoint(type, GetPoint(type) + amount);
		val = GetPoint(type);

		PointChange(POINT_MAX_HP, 0);
		break;
	case APPLY_MAX_HP:
	case APPLY_MAX_HP_PCT:
	{
		int i = GetMaxHP(); if (i == 0) break;
		PointChange(aApplyInfo[bApplyType].bPointType, iVal);
		float fRatio = (float)GetMaxHP() / (float)i;
		PointChange(POINT_HP, GetHP() * fRatio - GetHP());
	}
	break;
	case POINT_HP:
	{
		if (IsDead() || IsStun())
			return;

		int prev_hp = GetHP();

		amount = MIN(GetMaxHP() - GetHP(), amount);
		SetHP(GetHP() + amount);
		val = GetHP();

		BroadcastTargetPacket();
#ifdef ENABLE_HEALTH_BOARD_SYSTEM
		HealthBoardPacket();
#endif

		if (GetParty() && IsPC() && val != prev_hp)
			GetParty()->SendPartyInfoOneToAll(this);
	}
	break;

I just tested this in Marty version 5.4 and it works perfectly. You should check the source files for the code that calls the hp function.

  • Metin2 Dev 1

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.