- Joined
- Sep 29, 2006
- Messages
- 447
Hey, so I made an HP bar for my zealot and it initializes just fine, but whenever I need to update it, it comes out funky. Here are some images to show what happens:
As you can see, it looks fine normally. When the Zealot takes damage, the bar expands for whatever reason, then when it dies the bar doesn't shrink all the way. It's very odd.
Basically, the text needs to update, I need a Label above the bar saying "Health" and the bar should shrink toward the middle and disappear when the zealot dies. Can anyone help me out?
Here are my triggers:
Variables:



As you can see, it looks fine normally. When the Zealot takes damage, the bar expands for whatever reason, then when it dies the bar doesn't shrink all the way. It's very odd.
Basically, the text needs to update, I need a Label above the bar saying "Health" and the bar should shrink toward the middle and disappear when the zealot dies. Can anyone help me out?
Here are my triggers:
Variables:
-
healthBar = No Dialog <Dialog[16]>
-
healthDialogItem = No Dialog Item <Dialog Item[16]>
-
healthBarWidth = 400 <Integer>
-
healthBarHeight = 75 <Integer>
-
healthBarImageWidth = 340 <Integer>
-
healthBarImageHeight = 40 <Integer>
-
setHealthBar
-
Options: Action
-
Return Type: (None)
-
Parameters
-
player = 0 <Integer>
-
unit = No Unit <Unit>
-
-
Grammar Text: setHealthBar(player, unit)
-
Hint Text: (None)
-
Custom Script Code
-
Local Variables
-
unitCurHPInt = (Integer((unit Life (Current)))) <Integer>
-
unitMaxHPInt = (Integer((unit Maximum Life (Current)))) <Integer>
-
hpBarImgHtPercentInt = (Integer(((Real(healthBarImageHeight)) * 0.7))) <Integer>
-
hpImgWthPercentInt = (Integer(((Real(healthBarImageWidth)) * 0.4))) <Integer>
-
-
Actions
-
Dialog - Create a Modal dialog of size (healthBarWidth, healthBarHeight) at (0, -500) relative to Center of screen
-
Variable - Set healthBar[player] = (Last created dialog)
-
Dialog - Create an image for dialog healthBar[player] with the dimensions (healthBarImageWidth, healthBarImageHeight) anchored to Center with an offset of (0, 0) setting the tooltip to "Health" using the image Assets/Textures/ui_loadingbarsegment_center.dds as a Normal type with tiled set to false tint color White and blend mode Normal
-
Variable - Set healthDialogItem[player] = (Last created dialog item)
-
Dialog - Create a label for dialog healthBar[player] with the dimensions (hpImgWthPercentInt, hpBarImgHtPercentInt) anchored to Center with an offset of (0, 0) with the text (Combine ((Text(unitCurHPInt)), "/", (Text(unitMaxHPInt)))) color set to White text writeout set to false with a writeout duration of 0.0
-
-
-
UpdateHealthBar
-
Events
-
Unit - Any Unit Life changes
-
-
Local Variables
-
unit = (Triggering unit) <Unit>
-
player = (Owner of unit) <Integer>
-
unitCurHPInt = (Integer((unit Life (Current)))) <Integer>
-
unitMaxHPInt = (Integer((unit Maximum Life (Current)))) <Integer>
-
-
Conditions
-
unit == camUnit[player]
-
-
Actions
-
Dialog - Set healthDialogItem[player] text to (Combine ((Text(unitCurHPInt)), "/", (Text(unitMaxHPInt)))) for (Player group(player))
-
Dialog - Set healthDialogItem[player] size to ((* (healthBarImageWidth, (Integer((unit Life (Percent) (Current)))))), healthBarImageHeight) for (Player group(player))
-
-
Last edited: