Jump to content

Fix Wrong HP / SP Computing


Evor

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.

  • Metin2 Dev 1
  • Love 10
Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

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.