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

[Unsolved] Life/Energy Bar of unit

Status
Not open for further replies.
Level 4
Joined
May 2, 2013
Messages
107
Hi, I was wondering where you can change the looks of an unit its life bar/energy bar. For example Swarm Queen Niadra has an awesome cool life/energy bar with her name on it. Checked it out in data, but cannot find the parameter which are responsible for that awesome life bar/energy bar. Where can I find this?

Thanks!!


Thanks.
 
Level 4
Joined
May 2, 2013
Messages
107
Found the link at the actor tab 'combat'. Too bad it is not possible to add a shield bar to it.


This thread is solved and can be closed.
 
Level 7
Joined
Oct 11, 2008
Messages
304
Actually it is possible to add shield bar to it :)

You'll have to edit the xml in the UI correspondent of the unit bar used by Niadra.

Edit: This is two bars I'm working on for a map.

Hero and Unit.
11407110_1579609942300139_2684904827314471553_n.jpg


The white bar with no segments are the shield of the unit.
 
Level 4
Joined
May 2, 2013
Messages
107
Wauw! That looks very nice. My compliments. I dont understand the XML, is a bit complicated.

Found more bars on the internet people made like you dit. But they had always problems when the shield drops or stuff like that.

If you are willing to share a cool working Life/Energy/Shield bar, I would really appreciate. If not, I understand.

Thanks for the response.


Kind Regards.
 
Level 7
Joined
Oct 11, 2008
Messages
304
To be honest, you'll be surprised how this is simple.

To 'fix' Niadra HealthBar you'll just need to:
- Your map needs to use Swarm (Campaign) as dependencies.
- Go in UI Module (Shift + F6)
- Right-Click on the left sided list
- Add Layout (Ctrl + L)
- Name it whatever you want, it will be used in data field 'Combat: Custom Unit Status Frame'
- Paste this code below overwriting the existent one and change as you want.
- Go to Data Module (F7), search for your actor unit and change 'Combat: Custom Unit Status Frame' to NameOfLayoutYouDid/NiadraBar (look at the 'name="NiadraBar"' in the code, you can chage that to whatever you want too, just make sure to refer it in the data field as well.

PHP:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Desc>
    <Frame type="UnitStatusFrame" name="NiadraBar" template="HotS_UnitStatus/KerriganHeroUnitStatusFrameTemplate">
        
        <Frame type="UnitStatusShieldedHealthBar" name="HealthBar">
            <BarCount val="2"/>

            <OwnerColor val="34,90,194" index="1"/>
            <AllyColor val="34,90,194" index="1"/>
            <EnemyColor val="34,90,194" index="1"/>
        </Frame>
    </Frame>
</Desc>

Also you can edit the color value above (the val="34,90,194") to any color you want, so OwnerColor is who own the unit with the bar will see the shield as that color, so goes to AllyColor (team allies) and EnemyColor (enemies, obvious :p).

I'll explain a little bit of what I experienced yesterday doing those bars.
  1. Shield bar is a mess in Starcraft.
  2. Life bar and shield bar use the same bar itself.
  3. The amount calculated bar for each one is % in each other, so unit with 10 current life and 10 current shield will have a 50% life bar and 50% shield bar.
  4. The math of the item above is basically: (currentLife% + currentShield%) - Difference of totalLife, so my unit that has 700/700 shield, 1076/3200 life looks like this:
    ORMQ4Im.png
  5. Shield bar doesn't calculate your maximum shield as life bar does, so it only count the current one (so bar will move a little silly).
  6. If your life is too much for the Starcraft calculate the segment, it will just ignore the segment configs and change the bar to non-segmented, sames applies to shield bar (and energy) like this:
    TTmXoGs.png
    , the first unit has 200/200 shield and 200/200 life, the second unit has 700/700 shield and 3200/3200 life.


Also one more thing, if you want a segmented shield bar, you just need to add this in any part inside the Frame Type UnitStatusShieldedHealthBar:
PHP:
        <Segmented val="true" index="1"/>
        <SegmentValue val="EachSegment" index="1"/>
        <MaxSegmentCount val="MaximumSegments" index="1"/>
And change EachSegment to a number (if 100, then each 100 life will be a segment) and MaximumSegments to another number (if 3, it'll fix the maximum number of segments, if unit pass the EachSegment*MaximumSegments, it starts to calculate as %, so 3 will be 1/3 of life, etc).

Sorry for all the texts :D but hope you learn and enjoy something I writed.

Any question or something more, feel free to ask me anytime.

PS: I saw your PM but I prefer to make this public because as you I searched a lot and didn't found HOW make the mana bar work in Starcraft, so I started to try some tricks.
 
Level 4
Joined
May 2, 2013
Messages
107
Wauuuwww, it totally works. Its great. This is awesome. Thanks for sharing! I really dont understand at what part you added the shield. I'm wondering how you know what code stands for what. Because out of all these codes, I have no idea what part is responsible for the shield.

You really made me happy with this.

Really weird. Sometimes it works and sometimes it says: it cannot find the UI, while i've changed nothing. Any idea how this come?
 
Last edited:
Level 7
Joined
Oct 11, 2008
Messages
304
No, I never get this error o_O... What kinda of problem happen?
Print, or something may help.

The shield is defined on the frame type, UnitStatusShieldedHealthBar, if you remove the Shielded, UnitStatusHealthBar, it will just display the life, ignoring if unit has shield or not.

Also, BarCount define the second bar (the shield itself), so next you just need to do the segment, color, etc in the next index (in this case, 1, since 0 is the default for life)
 
Level 4
Joined
May 2, 2013
Messages
107
oke. It I understand. Thanks for the explanation.

Ya its strange. I put it on 6 heros. The first time is goes well. The second time I test it, no bars at all and it says it cannot create a frame cause he doesn't find it. And if I change the name again of the UI and update it in the actor combat field. Its does work for 1 time and then after that again this error. If I got home I will cope the error in this thread.
 
Level 7
Joined
Oct 11, 2008
Messages
304
o_O'

What a strange error lol

A valid UI error is something with template names inside [], like [UnitStatusShield], if something like [] show up, I didn't know how to resolve the error (happens to me some rarely times) and I just ignore it since the bar work as normal, next test is working as always and no debug text, Starcraft crazy? Maybe? o_O"
 
Level 4
Joined
May 2, 2013
Messages
107
Error given in Bug Window:

UI: Failed to locate soecified File Desc [Hero].
UI: Could not find [Hero/Maarten] while trying to create frame.



What I did is the following:

Add Lay Out (named: Hero)
Copy the XML text in there.
Changed name to: Maarten
Went to data actor combat, put at costem frame: Hero/Maarten

Workst for 1 testing. Now I started the editor and what do ya know: The LayOut is gone and all my other addings (the actor parameters) are still modified, so I didnt forgot to save.
I tested again a few times. But yeah, the LayOut is gone if I reboot the editor (with save ofcourse).

I see that all LayOut's have a frame connected in the UI list. I dont have a frame atm. Only a Layout, is that maybe the cause?
 
Level 7
Joined
Oct 11, 2008
Messages
304
The UI editor need to be saved every time you change something (to apply to the map itself).

You create the frame.
PHP:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<Desc> 
    <Frame type="UnitStatusFrame" name="Maarten" template="HotS_UnitStatus/KerriganHeroUnitStatusFrameTemplate"> 
         
        <Frame type="UnitStatusShieldedHealthBar" name="HealthBar"> 
            <BarCount val="2"/> 

            <OwnerColor val="34,90,194" index="1"/> 
            <AllyColor val="34,90,194" index="1"/> 
            <EnemyColor val="34,90,194" index="1"/> 
        </Frame> 
    </Frame> 
</Desc>

Try to paste the layout, save the map, see if it create the Tree-menu on the layout (with the tree using the frame name maarten).

Probably something is not saving correct in your editor, a lot strange o_O, but we can try figure out :D.
 
Level 4
Joined
May 2, 2013
Messages
107
Aaah. Yes you are right. Now I understand what went wrong. When I tested it with the UI window opened, it was working. But as soon if I closed it, it didn't work anymore (because I didn't pressed save after the UI creation). Makes sensen now, why it worked at first and later it didn't.

I did 3 tests now and it all worked out correct. So it's solved Thanks!

Btw, is this the message you also get?

UI: File [Hero.SC2Layout] Line [2] Column [1]. Attempting to add a desc [Hero] to [] with the same name as an already excsisting child.



Maybe this is usefull?


3. Names need to include the whole path of the existing file.

Reference:
http://www.sc2mapster.com/forums/development/gui/44304-what-am-i-doing-wrong/
 
Status
Not open for further replies.
Top