How to get the health of shield when using addShield() on .ship?

It was asked in this topic (Anyone tried this build-in Shield before? - #13 by Bings) but I thought I’d make a new one with the title as the question!

I’ve tried looking for a SobGroup_ function that returns this but no luck. I’ve also looked through the UI code to see if I can get it in there but also no luck (sadly the defenceField and defenceShield are separate systems to when using addShield on a ship so I can’t use those values).

I was wondering if anyone had any ideas of where/if this can be accessed?

For context addShield is only used as an “EMP” shield in the base game, but it can also be used against anything that triggers DamageHealth (when set to “Bullet”). It’s applied to a ship in its .ship file and looks like this:

addShield(NewShipType, "EMP", 50000, 300)
## or
addShield(NewShipType, "Bullet", 50000, 300)

Thanks in advance!

1 Like

I have seen people looking for the loss of steering ability to find out if a so had been disabled… Not sure if that helps.

1 Like

Sadly that only seems to apply to the EMP shield type as when bullet shield goes down the steering and such is not affected. :frowning:

This is from the original RDN document HW2_ATI.pdf:

EMP shield value above which ships have no EMP healthbar displayed.

But I can’t find a similar value in HomeworldRM.exe for bullet shield.

1 Like

Hmm, I remember stumbling into EMPLevelIgnore when looking at the UI files but never touched it!

I wonder if it’s for both bullet and EMP as a shield is just a shield at the end of the day, and if shields were only meant for EMP they might of just called it EMP instead of shield here.

Ill do some tinkering - huge thanks for the response!

Had no luck as of yet - with EMPLevelIgnore I set my test ship shield’s to 40 and recharge rate of 20, and also made it type EMP.

The only other thing on the UI code is AVF_EMPShield. It seems it would be a bar like where the defence field bar is, with this colour EMPColour = {58/255,110/255,165/255,1}. In the code for these 'auxiliary power` pieces, there is this on a bunch of them:

visibility = {"AVF_Selected", "AVF_AuxiliaryPower", "AVF_MainGameView", "AVF_HealthBarStyle0" },
visibility1 = {"AVF_Selected", "AVF_EMPShield", "AVF_MainGameView", "AVF_HealthBarStyle0" },

The difference between visibility and visibility1 is a mystery to me, but if I swap out AVF_AuxiliaryPower with AVF_EMPShield nothing changes. If I swap AVF_AuxiliaryPower for AVF_EMPShield the defence field bar disappears, but nothing takes it’s place.

I wonder if the difference between visibility and visibility1 is visibility1 is shown when you are zoomed in super close, visibility is when not zoomed in OR visibility is for NewShipType.healthBarStyle = 0 and visbility1 is for NewShipType.healthBarStyle = 1, but healthbar2 just uses visibility1. I really have no idea though.

This also leaves the mystery of AVF_EMPShield and how to force it to show.


Here is the structure of the ATI friendly component, this is what is displayed when hovering over a ship

In comparing the healthBarMouseoverStyle0 to healthBarMouseoverStyle1 the only differences other than sizes is that it calls AVF_HealthBarStyle0 and AVF_HealthBarStyle1 respectively.


Each key for every entry in the ATI is just iX (for example i21) which is totally useless so I wondered how the game knows what component is related to which table entry.

Looking at healthBarStyle0 and healthBarStyle1 other than sizes, there are 2 differences. The 1st is that healthBarStyle0 uses visbility0 and healthBarStyle1 uses visibility. healthBarStyle2 however uses visibility too.

The other big change is the final argument of visibility.., this being either AVF_HealthBarStyle0 or AVF_HealthBarStyle1. So by my assessment, the final call of visibility is the key of this component?


Taking a look back at the 1st comparison, it’s final argument is AVF_MouseOver, so does this mean the previous arguments in visibility, "AVF_Selected", "AVF_MainGameView", are called/ran when the final argument, AVF_MouseOver, is called/ran by the engine?

AVF_EMPShield is only found in the 2nd argument of visibility1 for all the auxiliaryPowerOutlineX and auxiliaryPowerContents0, apart form in auxiliaryPowerOutline2 where I suspect I found a typo as visbility is there twice.

auxiliaryPowerOutline0 & auxiliaryPowerOutline1:


From my deduction whenever visibility1 is active, and the ship is selected - it will display the AVF_EMPShield - which I assume is defined engine side as it’s not defined in these files.

Very, very, very strange implementation for a UI. Whoever made this must of been very miserable!

Edit 2:
Here is what the EMP shield looks like (only activated when shot at):

Sadly it would seem the EMP shield is exclusively for EMP type, which dashes my hopes it would be for bullet too!

It’s possible to have the weapon do damage to both EMP and Bullet shield which simulates the shield health bar, but once the EMP shield hits 0, the entire ship is disabled - which isn’t good in my case! EMP weapons also can’t be used in that scenario.

Even so would anyone know if it’s possible to disable the ‘disabling’ effect?

That’s an interesting approach. One thing I know though, is that how long a ship is disabled related to the “disable damage” of the single shot it took before its EMP Shield went empty.
About ati.lua, you can learn more in HW2_ATI.pdf.

I was able to get around the disabling with a SOBGROUP function that immediatly re-enables the ship - but the shield health bar just reset’s to max health :frowning:

Do you know where I can find ATI.pdf? (I only own steam version of game)

Thanks again :slight_smile:

1 Like
This should be what you are looking for.

1 Like

@VaultHunter101 Sorry to @ you but you seem to be the only gearbox related person who posts on the homeworld forums from time to time!

I know this is a huge long-shot but I was wondering if it’s possible if a snippet of the code that defines AVF_EMPShield could be shared (it’s defined engine-side meaning someone with access to the source code of the game would have to retrieve it)? Or if I could be pointed in the right direction for where to ask this question?

It’s just a small bit of UI code that displays a health bar but if it shows a variable for where it get’s the shield value from or a way of accessing the variable this would be invaluable.

This would give a final answer on what’s going on behind the scenes with shields and potentially let modders use the shields handled by the engine making modding shields a million times easier (or find out for sure it’s not possible!)?

Thanks in advance!

Hate to disappoint you but I’m not a GBX employee, just one of the volunteer moderators. The last person associated with HW to post here from GBX that I know of was @BitVenom, but he hasn’t been signed in to the forums for 2 years now. At this point, I don’t know who there would be to ask.

1 Like

Ah damn! I don’t think there a chance of him responding! Oh well - thanks for responding anyway!

Cheeky little bump for this just in case someone who comes along this thread has any ideas…

tldr; need a way to get the health value of a shield (a base game mechanic, which is set by adding addShield(NewShipType, "EMP", 50000, 300) to a .ship file)