Shields in HWRM - HWRM/KarosGraveyard GitHub Wiki

I'm making this guide as I spent around 6 months on and off making a good shield system in HWRM for Stargate: Space Conflict (remastered version) and thought id share what I learnt. Huge thanks goes out to @Nathanius and the hwrm-modding chat in the Homeworld Universe discord for their help along the way. I haven't gone into too deep detail on my solution as this post would be considerably longer but if anyone is interested I can make a post in the future.


My criteria for a 'good shield system'

  • When weapons hit the shields there is a shield effect and when it hits the hull there is an explosion effect
  • Shield HP is presented in a way that is not in the main ship HP health bar (ie it should be displayed on a subsystem or in another UI element)
  • Different amount of damage is done depending on the weapon used whether it's against a hull type or shield type (ie beam doing more damage to a shield than a missile)

There are a few approaches you can take for shields, all having there own positives and negatives. Ill quickly go over them.

  1. Hull & shield collision mesh in the ship with additional usage of scripts
  2. Hull collision mesh on the ship & shield collision mesh in a subsystem
  3. Shield collision mesh in the ship, with the hull collision mesh in a subsystem with additional usage of scripts
  4. Using the built-in addShield() function on .ship files, with additional usage of scripts

For approach number 1, this is what's used by Star Trek: Continuum mods on remastered.

Positives: It's the easiest & is well displayed in a UI element.

Negatives: Weapons will always deal the same amount of damage to a shield & hull. Weapons can only do 1 hit effect, for example in STC beam weapons only do shield effects, even when the shield is down.

The shield collision mesh is just on the ship as well as the usual hull, and a script handles the shield HP which is displayed in a UI underneath the health bar. It does this by (simplified); as the ship takes damage it is removed from the shield HP first (a variable), once depleted it plays a shield dropping effect and then damage is dealt to the hull as per usual.

https://youtu.be/XU4yHk0h7Xw


For approach number 2, it was used by @EvilleJedi for Warlords (which was described in this tutorial https://web.archive.org/web/20090530185348/https://warlords.swrebellion.com/tutorials/TUTORIAL_SHIELD/TUTORIAL_SHIELD.php). However in remastered, this trick isn't as successful.

Positives: Fulfils all my criteria for a good shield system & doesn't require too much work to implement.

Negatives: The bugs.

This method works by the shield collision mesh being on a subsystem, and it having a different armour type. Your weapon's will have no effect nor do any damage, but will trigger 2 AddWeaponResult's (essentially other weapon files) which one has a shield effect for hitting shield type armour with another having an explosion effect for hitting hull type armour which also include their damage amounts.

For classic I remember EvilleJedi mentioning in his tutorial something along the lines that missiles would collide with the inside of the shield mesh so their position in 3dsmax (or your software of choice) had to start from outside the shield mesh. On remastered (potentially from patch 2.0/1) in my testing it also seems that beams & bullet weapons also hit the inside of the shield mesh for (mostly) directly in-front of the ship, whilst for the rest of the mesh it's perfectly fine. It's quite annoying and makes it unusable (unless your ship has no front facing weapons!).

Huge bummer as this would have been the best way of doing it without too much extra effort.

https://www.youtube.com/watch?v=-iBIrjM1JFw


For approach 3, this is the one I am now using in the remastered Stargate mod. It is a hybrid approach of both methods 1 & 2, with the big difference from number 2 being that the shield & hull collision meshes are switched, meaning that the shield collision mesh is on the ship and the hull collision mesh is on the subsystem. The script is also more advanced.

Positives: It achieves al my goals for a shield system

Negatives: It's not 100% reliable & is considerably more effort and fiddly.

It usually works best when a ship is moving and/or engaging as otherwise all incoming fire will skip the shield and hit the hull (I assume the secondary collision mesh is made inactive for some optimization reason), but this usually isn't a problem ships are typically in combat when shields are being used.

It requires much more effort however in the modelling side when creating ships. This is because homeworld uses the root collision mesh of a ship to also make the ship clickable & it only takes into account a small distance around it. This means that the mesh has to be slightly smaller than your actual hull collision mesh on the subsystem & your shield has to be quite close your ship (big shield spheres seem to be a no-go sadly :frowning:)

It also has a script which is required to shift damage from the ship's hull (which is essentially the shield) over to the shield subsystem whilst keeping the ship HP at 100%, as well as to activate an effect. It doesn't need to do it vice-versa however as damage to subsystem is passed to the ship when it is at 0HP by the game.

https://i.gyazo.com/627dd396e9abb5eda601cf08c97ca2de.gif


For approach 4, this is a recently discovered method which isn't used anywhere - but has it's own set of downfalls. It works simply by adding the function addShield("Bullet", 500, 5) to the ship's. ship and a little bit of code to assess if the shield has gone up or down to play relevant animation.

Positives: Incredibly easy to implement, most of the code is handled by the engine.

Negatives: You can't view the health of the shield. Weapons can't do shield only damage, but can do hull only damage.

Something to note is that it aggressively recharges the shield, even during combat. This means it's important to have a slow recharge rate.

Sadly, the big catch is that it seems impossible to view the health of the shield. This also leaves some ambiguity of how you determine the shield has come back up. In my test scenario I just waited a period of time after the ship hadn't taken damage before doing the animation.

As you aren't dealing with bounds of subsystem's however - it means much more is blocked by the shield leading to a better visual experience.


Conclusion: Depends on how much effort & time you are willing to put in. Quite frankly, partly due to my inexperience with 3dsmax, it makes it incredibly time consuming to make new, basic (can literally be a few big squares/triangles) collision meshes just smaller than the ones that go on the subsystem for every ship - and then to adjust the shield size till it fits in the invisible radius that homeworld decides it takes into account secondary meshes. It becomes a guessing game which involves a 5–10-minute conversion process each time (from 3dsmax to HODOR to game). If you don't think that's a problem for you - method 3 is your best bet for the best shield system. Otherwise, I’d suggest method 4, giving up the ability to view the shield's health.

Hopefully this helps some fool like me who decides to do this for your mod down the line (my advice: pick a franchise which doesn't have shields :laughing:)!

If anyone knows something with solution 4 which might let me show the shield UI for Bullet type, let me know!