• 🏆 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!

How to show a status bar above a unit?

Status
Not open for further replies.
Level 28
Joined
Jan 26, 2007
Messages
4,789
Yeah, sure.

First thing you do is store all cast times in an arrayed variable.
Then, when a spell is cast, you check which cast-time matches with that spell (such as: if ability being cast equal to storedAbility[2], then use storedCastTime[2]).
I hope it's still clear here :p

Then, whenever the ability is cast, create a dummy unit (no model, locust, not shown on map, no shadow etc). Save the cast time, "0.00", the coordinates (or location) and any other values (such as the ability name or whatever you want) in a hashtable, with as key the ID of the dummy you just created.
Put the dummy in a unit group and run another (repeating) trigger.

This repeating trigger will create the floating texts.
Create an empty string.

If your cast time is 5.00 sec, and you are already casting it for 3.00 sec, the current percentage is 60%, right (3 * 100 / 5)?
And let's say you have 20 "|"s in your bar (||||||||||||||||||||), then you must fill it to 60% of that bar, which is 12 (20 * 0.6).
1 such line ("|") represents 5% of the entire progress bar. So:

loop from 0 to 20
If ({current cast time} >= {total cast time} * (0.05 * {loop integer}) then
set string variable = string variable + (colored |)
else
set string variable = string variable + (white/grey |)

The "{total cast time} * (0.05 * {loop integer})" is simple: you increase the loop by 5% at a time (remember what I said before? 5% is equal to 1 line in the entire progress bar).


I hope you could follow all of this. If not, I'd be glad to make a test-map out of it.
 
Level 16
Joined
Apr 4, 2011
Messages
995
I was thinking more along the lines of there are 20 bars, and whenever a unit is killed the bar goes up one. When the bar is full, do conditions. I want the bar to be constant, and follow the unit around wherever he goes, as part of a system that gives the hero a special ability after 20 kills.
 
Status
Not open for further replies.
Top