Post Thu Aug 31, 2006 3:53 pm

**Tutorial** Making explosions damage capship shields

Large shields will very often not register damage from explosions. You can try to work around this by increasing the radius of the explosion, but that comes with all kinds of unwanted side effects. A better solution is to directly modify the shield surface, like so:

First off, find the shield surface you want to modify. In shiparch.ini, find the shield link of your ship:

[Ship
...
nickname = li_fighter
...
shield_link = l_fighter_shield01, HpMount, HpShield01
...

l_fighter_shield01 is a reference to a shield defined in select_equip.ini:

[Shield
nickname = l_fighter_shield01
DA_archetype = Ships\liberty\li_fighter\li_fighter_shield.3db
HP_child = SpConnect

ships\liberty\li_fighter\li_fighter_shield.3db is a real file, but it is pretty much empty. However, it is linked (by name) to a .sur file, li_fighter_shield.sur. Open the .sur file using a hex editor (such as this one). You may also want to use flmodeltool to help you find the values that you want to change.

The things to change are the two radius values, both of which are in 4-byte single-precision floating point format. The first radius value is found 28 bytes after the end of "surf", near the beginning of the file. This is the more important of the two values, and it must be set to something large. You can start with the radius of the ship as suggested by flmodeltool, or perhaps you can determine it for yourself, but in general I have found that I need to set the value even higher. For example, on the star destroyer model I use, the bow of the ship is a bit over 900 meters from the ship center (so the engines are about 700 meters aft of center). However, the radius value is set to 1500, and this was pretty much the lowest value I could go with and still have reliable explosion detection everywhere on the ship. My suggestion is to keep trying until you get it down to the absolute minimum, so that you don't get unexpected detection.

The second radius value is found starting 8 bytes back from the end of the file. This one does not seem to be as critical to explosion detection, though you might as well set it to the actual radius of the ship. Note that if you make this value larger than the radius of the hull of the ship, it will take precedence over the hull in determining the distance to the ship. In other words, if you make it 10k and your ship is only 200 meters long, another player can be 10 kilometers away from you but the HUD will say you are 0 meters away. It's kind of silly.

A recap of the layout for a shield surface .sur file:

"vers" (4 bytes)
Header stuff... (typically 44 bytes)
"surf" (4 bytes)
other stuff... (28 bytes)
-> first_radius_value (4 bytes)
lots of other stuff... (length varies)
-> second_radius_value (4 bytes)
last four bytes... (4 bytes)
end of file

The method has been tried and tested repeatedly on ships ranging from 100 meters to over a kilometer, so as far as I know there aren't any problems with it.