Edit3: This was for health/shield bar, energy later but thats easy. But finally It appears everything is working (almost) (think dow2 or even sc2 but with health bars instead) The dialogs for this dont get created until a unit is selected and get destroyed when that unit deselected, or killed, whichever. It works good, the bars/labels only stays to your currently selected unit.
The only problem is (which is small thing but a small thing id like to get fixed) is that the bars dont deplete all the way down depending on attack damage and health, so if your unit were to get one shotted the the bar would still be there if not for the dialogs getting destroyed. The problem with that being my units have shields, so.. yeah, also, say your unit has no shields left 0/80, naturally a small piece of the shield bar would still be there, but if you were to deselect that unit, and select him again, the 0/80 shield bar would reset and be at full again. (this part was fixed, small piece of bar not yet fixed)
If anybody has a fix to this please post it, thank you in advance
EDIT: Sorry about the block triggers. I guess sometimes these posts dont like the enter key XD.
To help with your problem, I must ask a few questions myself. What is this dialog supposed to do? Does it simply keep track of a selected unit's stats? If so, you're looking at it a bit wrong. Make an initialization trigger to create and set all bars to max, and hide the dialog. (Each bar should have two images: a foreground and a background.) Make a var named Selected unit (array of size = number of players). Make another trig as follows:
Events
Any unit is selected by player Any Player
Conditions
Owner of (Triggering Unit) = Triggering Player
Variables
Actions
Set Selected Unit[(Triggering Player - 1)] = Triggering Unit
Set HPBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Triggering Player - 1)] LifePercent / 100) Current), <your bar height>)
Set ShieldsBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Triggering Player - 1)] ShieldsPercent / 100) Current), <your bar height>) for (Conver player (Triggering Player) to player group
Show HPBarFront for (Conver player (Triggering Player) to player group
Show ShieldsBarFront for (Conver player (Triggering Player) to player group
Make another trig as follows:
Events
Any unit takes damage
Conditions
(Triggering Unit) is in Selected Units for player (Owner of (Triggering Unit)) = true
Variables
Actions
Set HPBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Owner of (Triggering Unit) - 1)] LifePercent / 100) Current), <your bar height>)
Set ShieldsBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Owner of (Triggering Unit) - 1)] ShieldsPercent / 100) Current), <your bar height>)
Make another trigger a follows:
Events
Any unit is Deselected by player Any Player
Conditions
Owner of (Triggering Unit) = Triggering Player
Variables
Actions
Set Selected Unit[(Triggering Player - 1)] = No Unit
Hide HPBarFront for (Convert player (Triggering Player) to player group)
Hide ShieldsBarFront for (Convert player (Triggering Player) to player group)
This will update, in real time, each player's dialogs based on which unit they have selected, assuming each player can only select one unit. Otherwise it will only update for the last selected unit in the group. As for that problem about the very small sliver of bar remaining at 0, make a trigger as follows:
Events
Every 0.25 seconds
Conditions
Variables
Int = 0 <Integer>
Actions
For each integer Int from 0 to <number of players> Do Actions
Actions
If (Conditions) then Do (Actions)
If
Selected Unit[Int] != No Unit
Then
If (Conditions) the Do (Actions)
If
Selected Unit[Int] ShieldsPercent (Current) = 0
Then
Hide ShieldsBarFront for player (Int + 1)
Edit3: This was for health/shield bar, energy later but thats easy. But finally It appears everything is working (almost) (think dow2 or even sc2 but with health bars instead) The dialogs for this dont get created until a unit is selected and get destroyed when that unit deselected, or killed, whichever. It works good, the bars/labels only stays to your currently selected unit.
The only problem is (which is small thing but a small thing id like to get fixed) is that the bars dont deplete all the way down depending on attack damage and health, so if your unit were to get one shotted the the bar would still be there if not for the dialogs getting destroyed. The problem with that being my units have shields, so.. yeah, also, say your unit has no shields left 0/80, naturally a small piece of the shield bar would still be there, but if you were to deselect that unit, and select him again, the 0/80 shield bar would reset and be at full again. (this part was fixed, small piece of bar not yet fixed)
If anybody has a fix to this please post it, thank you in advance
Look at this trigger here (where i got mine from but needs a couple additions) http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-658/how-create-dialog-health-bar-166370/ and go to the bottom of the first post, im assuming thats where a fix is needed.
Edit: Delete
EDIT: Sorry about the block triggers. I guess sometimes these posts dont like the enter key XD. To help with your problem, I must ask a few questions myself. What is this dialog supposed to do? Does it simply keep track of a selected unit's stats? If so, you're looking at it a bit wrong. Make an initialization trigger to create and set all bars to max, and hide the dialog. (Each bar should have two images: a foreground and a background.) Make a var named Selected unit (array of size = number of players). Make another trig as follows:
Events Any unit is selected by player Any Player
Conditions Owner of (Triggering Unit) = Triggering Player Variables Actions Set Selected Unit[(Triggering Player - 1)] = Triggering Unit Set HPBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Triggering Player - 1)] LifePercent / 100) Current), <your bar height>) Set ShieldsBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Triggering Player - 1)] ShieldsPercent / 100) Current), <your bar height>) for (Conver player (Triggering Player) to player group Show HPBarFront for (Conver player (Triggering Player) to player group Show ShieldsBarFront for (Conver player (Triggering Player) to player group
Make another trig as follows:
Events Any unit takes damage
Conditions (Triggering Unit) is in Selected Units for player (Owner of (Triggering Unit)) = true Variables Actions Set HPBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Owner of (Triggering Unit) - 1)] LifePercent / 100) Current), <your bar height>) Set ShieldsBarFront size to (Convert Real to Int(<your max bar width> * (Selected Unit[(Owner of (Triggering Unit) - 1)] ShieldsPercent / 100) Current), <your bar height>)
Make another trigger a follows:
Events Any unit is Deselected by player Any Player Conditions Owner of (Triggering Unit) = Triggering Player Variables Actions Set Selected Unit[(Triggering Player - 1)] = No Unit Hide HPBarFront for (Convert player (Triggering Player) to player group) Hide ShieldsBarFront for (Convert player (Triggering Player) to player group)
This will update, in real time, each player's dialogs based on which unit they have selected, assuming each player can only select one unit. Otherwise it will only update for the last selected unit in the group. As for that problem about the very small sliver of bar remaining at 0, make a trigger as follows:
Events Every 0.25 seconds Conditions Variables Int = 0 <Integer> Actions For each integer Int from 0 to <number of players> Do Actions Actions If (Conditions) then Do (Actions) If Selected Unit[Int] != No Unit Then If (Conditions) the Do (Actions) If Selected Unit[Int] ShieldsPercent (Current) = 0 Then Hide ShieldsBarFront for player (Int + 1)
@Drakken255: Go
Almost everything is working fine for what i have, could you take a look at my map, i think its fixable.
@kottonmouthx8: Go
It is a simple fix. Simply add this to your current updating trigger:
If <Selected Unit> ShieldsPercent Current = 0 Then Hide ShieldsBarFront for player (Owner of <Selected Unit>) Else
This should hide the bar whenever whatever selected unit runs out of shields.