I am currently working on a Health bar dialog for all players to see at the top left corner of the screen. I can see how to make this work for Heroes with life, but I need it to combine the Shields and Life for a total percentage on the bar. I've tried adding the Life Percentage and Shield percentage and the bar is too big for the Dialog box and doesn't go down until the life starts getting damaged, ending with a small portion of a bar left by the time I die. Can anyone show me how to make this work for Shields + Life (protoss units)
Thanks
-demon
Unit - Any Unit Life changes
Local Variables
Conditions
Actions
Dialog - Set Unit Bar Health Bar size to ((/ ((* (280, (Integer(((Triggering unit) Life (Percent) (Current)))))), 100)), (Height of Unit Bar Health Bar for (Owner of (Triggering unit)))) for (Player group((Owner of (Triggering unit))))
Also make sure that you do the calculation as REAL ARITHMETHIC and not as INTEGER ARITHMETIC.
There might also be a problem once the formula returns 0 (this is when currentshields + currentlife = 0), since dialog items get infinitely wide when setting their width to 0. So you might need to check if the formula returns 0 and if yes set the dialog item width to 1 to avoid this problem. (Or just plainly add a +1 at the end of the formula, which would result in a slight loss in accuracy).
I am currently working on a Health bar dialog for all players to see at the top left corner of the screen. I can see how to make this work for Heroes with life, but I need it to combine the Shields and Life for a total percentage on the bar. I've tried adding the Life Percentage and Shield percentage and the bar is too big for the Dialog box and doesn't go down until the life starts getting damaged, ending with a small portion of a bar left by the time I die. Can anyone show me how to make this work for Shields + Life (protoss units)
Thanks
-demon
Unit - Any Unit Life changes
Local Variables Conditions Actions
Dialog - Set Unit Bar Health Bar size to ((/ ((* (280, (Integer(((Triggering unit) Life (Percent) (Current)))))), 100)), (Height of Unit Bar Health Bar for (Owner of (Triggering unit)))) for (Player group((Owner of (Triggering unit))))
Try this formula:
maxbarwidth / (maxshields + maxlife) * (currentshields + currentlife)
Also make sure that you do the calculation as REAL ARITHMETHIC and not as INTEGER ARITHMETIC.
There might also be a problem once the formula returns 0 (this is when currentshields + currentlife = 0), since dialog items get infinitely wide when setting their width to 0. So you might need to check if the formula returns 0 and if yes set the dialog item width to 1 to avoid this problem. (Or just plainly add a +1 at the end of the formula, which would result in a slight loss in accuracy).