• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Life percentage window

Status
Not open for further replies.
Level 14
Joined
Jul 12, 2011
Messages
1,370
Hey people!
I'm trying to make a window which displays the percentage of a units health (or the remaining HP if no way around) like a timer is shown (in a small windows top right corner of the screen), but I don't know how?
Any ideas?
 
Level 11
Joined
Jun 2, 2013
Messages
613
Hmm, I'd probably go with a GetLocalPlayer mulitboard that updates every few seconds. Just set a real variable to your unit's health percentage and update your multiboard with that or something along those lines. If you want to get real crazy with it, you could convert that to a string so say you Create an 'I' for every 5 or 10% of that units health; so at max health it looks like IIIIIIIIIIIIII, if you wanted to use something like that instead.
 
Level 12
Joined
May 22, 2015
Messages
1,051
There is a GUI function get a unit's % life, I'm pretty sure.

Anyway, it is easy to calculate like:
current health / max health * 100 = percent health remaining

You can display this number the same way you display the timer. Update it each second or whatever and display the timer and the % life.

EDIT:
I thought you wanted it inside a multiboard with other stuff.

A multiboard might be the best way to do it.
 
Status
Not open for further replies.
Top