Jump to content
For maintenance and updates, the community will be offline on 31 December 2022 ×
  • 0

HP negative when dead


backtop

Question

Hey can someone help me fix that, when a player have 4k HP and getting 5k damage, that his HP is going into negative (-1k in that case). I want to prevent that (for example his HP should be 0 not -1k).

Sorry for my bad english 😅

Edited by backtop
Link to comment
Share on other sites

  • Answers 3
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

3 answers to this question

Recommended Posts

  • 0

char_battle.cpp

Search:

    if (!cannot_dead)
    {
        PointChange(POINT_HP, -dam, false);
    }

Change:

    if (!cannot_dead)
    {
        if (GetHP() - dam <= 0)
            dam = GetHP();

        PointChange(POINT_HP, -dam, false);
    }

Borrowed from MARTY's source.

Link to comment
Share on other sites

  • 0

void CHARACTER::PointChange

 

				SetHP(GetHP() + amount);
				val = GetHP();

				BroadcastTargetPacket();

to

				SetHP(GetHP() + amount);
				val = GetHP();

				if (GetHP() < 0)
				{
					SetHP(0);
					val = 0;
				}

				BroadcastTargetPacket();

 

Link to comment
Share on other sites

  • 0
20 minutes ago, Chookez said:

char_battle.cpp

Search:

    if (!cannot_dead)
    {
        PointChange(POINT_HP, -dam, false);
    }

Change:

    if (!cannot_dead)
    {
        if (GetHP() - dam <= 0)
            dam = GetHP();

        PointChange(POINT_HP, -dam, false);
    }

Borrowed from MARTY's source.

Working perfect. Thank you 😀

Link to comment
Share on other sites

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


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