ID:225300
 
Keywords: hp, icon, issue, state, wrong
(See the best response by Kccmt.)
Code:
mob/proc/UpdateHP() {
var/Percent = round(src.HP / src.MaxHP * 100); // We get the percent of the Exp / MaxExp.
var/obj/Battling_System/Player_HUD/HP_Filler/MyBar = src.client.screen[2]; // We get the HP Filler HUD, well i know it's 2 since ihave 2 elements only. :P
for(var/Counter = 0; Counter < Percent - 52; Counter++) { // We loop until Counter is the percent - 52 (- 52 is because we don't have 100 states, just 48, otherwise w hen we reach the max amount of states icon will go blank
MyBar.icon_state = "[Counter]"; // We change the icon_state
world << Counter; // Debug.
sleep(0.1); // We make it animated with a sleep()
}
}


Problem description: This is just debugigng code, isn't the original game. :3 What i'm doing is to "animate the HP bar" however the result isn't the same as in game.

Picture:



(1 = My debugging | 2 = Original game). Both are with same HP. 16/21 As you can see there's a big difference in the bars.

If you want to know the amount of states in the HP Bar.dmi is 48.
Best response
So if you have 100% HP you will stop counting at 48, and if you have 50%... you stop at -2? (well, at 0 actually)
What you probably need to do instead is forget the -52 and change the line at beginning with:
var/Percent = round(src.HP / src.MaxHP * 48);
I see, it works! Thank you. +1
Actually i have an issue, whenever the Experience is the same as the max experience the bar isn't full. Should that be a missing state (I don't think)?, this is fixed by doing * 80 + 1 o.o
Might be a rounding problem somewhere