Jump to content
Forgot your email address? ×
×
×
  • Create New...

Fix Wrong HP / SP Computing


Recommended Posts

Hello folks.

I don't know if it was "a feature" or not, but it was really annoying and it caused some bugs.

 

So, let's begin.

 

Firstly, we should go to the char.cpp (and we will stay here)

Now, let's find the ApplyPoint function and then certain cases..

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 APPLY_MAX_SP:
		case APPLY_MAX_SP_PCT:
			{
				int i = GetMaxSP(); if(i == 0) break;
				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
				float fRatio = (float)GetMaxSP() / (float)i;
				PointChange(POINT_SP, GetSP() * fRatio - GetSP());
			}
			break;

This part of code is written by Nova, which is used in novaline, but i know that some of you use it in other branches.

It is causing the main problem, we should change it to look like this:

case APPLY_MAX_HP:
		case APPLY_MAX_HP_PCT:
			{
				int i = GetMaxHP(); if(i == 0) break;
				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
			}
			break;

		case APPLY_MAX_SP:
		case APPLY_MAX_SP_PCT:
			{
				int i = GetMaxSP(); if(i == 0) break;
				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
			}
			break;

Done, now we should conern next problem, it will cause a disproportion between max_hp and current hp.
Moving on, we should find PointChange function (still in char.cpp).

Then, find case POINT_MAX_HP and POINT_MAX_SP, and change it like that:

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);
				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;

		case POINT_MAX_SP:
			{
				SetPoint(type, GetPoint(type) + amount);
                                int i = GetMaxSP();
				int sp = GetRealPoint(POINT_MAX_SP);
				int add_sp = MIN(800, sp * GetPoint(POINT_MAX_SP_PCT) / 100);
				add_sp += GetPoint(POINT_MAX_SP);
				add_sp += GetPoint(POINT_PARTY_SKILL_MASTER_BONUS);
				SetMaxSP(sp + add_sp);
                                float fRatio = (float)GetMaxSP() / (float)i;
                                PointChange(POINT_SP, GetSP() * fRatio - GetSP());
				val = GetMaxSP();
			}
			break;

Short description:

I'm using  Nova method to calculate HP/SP ratio gain. It should prevent people from using it as a infinite source of hp (using affect.add(max_hp.. affect.add(hp... we would create another bug.)

Kind regards,

Evor.

@DISCLAIMER

This method was tested by me and my team. We find it fixing the whole problem, but whenever you find another bug, please report it.

Ratio calculation courtesy of Nova.

  • Love 10
Link to comment
  • 1 year later...
  • 2 years later...

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

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


  • Read our Rules
  • Activity

    1. 7

      PHOENIX2 !OLDSCHOOL SERVER, PAYTOWIN REMOVED!

    2. 0

      special_item_group and chest apprentice

    3. 2

      Alternative Alternative Zodiac Suit - Ninja M

    4. 0

      character details negative bonus

    5. 0

      Questlib mysql_query function problem

  • Recently Browsing

    • No registered users viewing this page.

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.