backtop 17 Posted April 9, 2022 Share Posted April 9, 2022 (edited) 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 April 9, 2022 by backtop Link to comment Share on other sites More sharing options...
DrTurk 133 Posted April 9, 2022 Share Posted April 9, 2022 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 More sharing options...
Solution Chookez 71 Posted April 9, 2022 Solution Share Posted April 9, 2022 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 More sharing options...
backtop 17 Posted April 9, 2022 Author Share Posted April 9, 2022 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 More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now