[TUTORIAL] Turrets

This tutorial considers how to rig a turret with two barrels. It builds on my previous tutorial “getting a simple ship in game”. We will be replacing the Hiigaran Assault Corvette with our own model.

Tools used in this tutorial:

  1. 3ds Max 2014 (some other versions work, Blender is also a possibility)
  2. HODOR
4 Likes

+++ STEP 1 - CREATE THE TURRET MESH +++

Create a mesh of your ship body and separate meshes of the top turret and both barrels. The pivot axis for the turret body must be at the point about which the turret will rotate (traverse). The pivot axes of the barrels must be at the end (muzzle) of each barrel:

pivots

The meshes can be called any name, but they must be of the format MULT[name].

+++ STEP 2 - CREATE AND POSITION THE DUMMIES +++

In order for the game to calculate the position, traverse (left-to-right rotation), elevation (up and down movement) of the turret, a number of dummies are required. These dummies are similar to the dummies used for the weapons of the Kadeshi Swarmer example explored in the previous tutorial. The difference here is that we need one extra (latitude). Create, name and position the dummies as shown here:

The name “TurretTop” is how the ship files refer to the corvette’s top turret and the dummies tell the game the following information:
Position = the root node of the turret, the point about which the turret traverses (rotates side-to-side)
Direction = the z-axis (up) from the turret
Rest = the default rotation of the turret
Latitude = the point about which the barrels elevate (aim up and down)
Muzzle = the muzzle of the gun (where the projectile comes out and where the flash animation will be).

Since we are using a twin-barrelled turret, we need to make some “slave nodes” to define the parameters for the second barrel. To do this, create copies of the following dummies in the same locations:

  • JNT[Weapon_TurretTop_Position] -> as JNT[Weapon_TurretTopSlave_Position]

  • JNT[Weapon_TurretTop_Direction] -> as JNT[Weapon_TurretTopSlave_Direction]

  • JNT[Weapon_TurretTop_Rest] -> as JNT[Weapon_TurretTopSlave_Rest]

+++ STEP 3 - CREATE THE HIERARCHY +++

The names of the dummies are important, but also the hierarchy - the way the dummies are linked to each other. The hierarchy of the turret defines how the different parts of the turret will move in relation to each other. The correct hierarchy for the twin barrelled turret is shown here:

tree1

The correct hierarchy for the slave barrel is shown here:

tree2

+++ STEP 4 - CREATE THE BOTTOM TURRET +++

The bottom turret functions in exactly the same way as the top turret. Do not try to invert the pivots or relative positions. As far as the game is concerned there is no difference between the top and bottom turrets for the Hiigaran corvette. The turret name is,predictably, “TurretBottom”.

dummies-annotated-btm

Duplicate the position, direction and rest dummies for the slave barrel as in step 2.

+++ STEP 5 - TEST +++

Now its time to test your ship. Create the DAE file and use HODOR to make the HOD file (see step 4 of my previous tutorial) as hgn_assaultcorvette.HOD and place it in C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Data\ship\hgn_assaultcorvette\

Now launch the game and have a look:

2015-05-04_00001

You should see the turret behaving nicely. If not, turrets are fairly easy to troubleshoot - once you understand the hierarchy you can usually understand which part is not functioning correctly.

2 Likes

Maybe one more step to show how easy it is to add extra barrels?

OK, here goes:

+++ STEP 6 - ADDING AN EXTRA BARREL +++

Adding extra barrels is quite straightforward. First, create the mesh of the third barrel. Then create the hierarchy of dummies as in step 3 above, but use the name “Weapon_TurretTopSlave1” or “Weapon_TurretBottomSlave1”.

third-barrel

The game will automatically fire the barrels in sequence (“master”, Slave, Slave1, Slave2, etc.)

1 Like

I can’t say enough about your tutorials - they’re great. If we can create new ones (edited into a single post, no replies, etc) - I can have them moved to our ‘protected’ area and kept there (completely full credit to you).

3 Likes

Glad you like them, just trying to share what I’m learning!

Do you think that’s necessary - I kept the steps as separate posts so that they could be linked to, and I think it can be helpful to keep tutorial posts open to allow questions/debate…

The way we’ve structured our examples (and I am bit behind) - is that there’s a single place with no replies/traffic to store the info (that we edit and update, keep clean, etc) - and then another thread (under the Mods section) we link to it for people to talk under…

ok let’s do it… do I have to do anything?

Question: I’ve set up a twin barrel turret, and I’ve set the weapon config in the ship file to use a weapon that can have slaved guns (in this instance the Tai_DestroyerGun), and my ship is in-game okay, but while both barrels animate and generate projectiles, it only makes a firing sound and a shot flare when the master barrel fires.

I’ve got my hierarchy set up exactly like yours. Do I need a JNT[Gun.0Slave] as a child of my primary ship JNT or something?

That seems like an events file issue, as the firing sounds and muzzle flash are generated in the effects file. You’ll have to copy the first firing event and then alter the animtime of that second event to when the second barrel should fire, plus set the marker to the right muzzle joint. Timing wise, the Taiidan Destroyer uses 0.5 in the events file, so that’d be a good place to start.

1 Like

Bob’s right. .events file is the culprit.

You can also put the muzzle sound and fire effects in the .wf (weaponfire) script so you don’t have to futz with the .events file as much.

-Stefan-

That sort of works. The flares and sounds are firing in the correct sequence, but they’re not synched to the barrel recoil animations and projectile firing.

I think there are more interdependencies on this than I was aware of. I guess the .wepn file determines time between barrels firing when there are slaved guns, so you have to reference that time then multiply by number of barrels on your custom turret to get the total animation length for the animations section of the events file, then get the percentage of time for each barrel for the weapons section of the events file. And then if your ship’s tactics are wrong they can mess up the synchronization by moving so that not all the barrels can fire on time, but the effects sequence is triggered with the initial firing solution.

@sastrei: or I guess I can do that. Does the .wf script live with the .wepn file, or can that be lumped in with the .ship file?

Data > scripts > weaponfire >

Not having a lot of luck parsing the .wf scripts. There’s a block of commented out ‘formats,’ but the file doesn’t seem to be following them.

I feel like I should be using SetFireEffect, but I don’t know if the filename argument is supposed to be a sound or a muzzleflash script or something else. If it’s the flash script, then how do I tell it to play the sound, too?

SetFireEffect(NewWeaponFireType, ART/FX/MUZZLE_FLASH_COMBO_SMALL_FRIGATE, 100000) just crashes the game, so that’s not it.

This is what I have in my events file:

wpn5 = { { "anim", "Weapon_Gun0" }, { "animtime", "0" }, { "marker", "Weapon_Gun0_Muzzle" }, { "fx", "muzzle_flash_combo_small_capital" }, { "sound", "WEAPON/CARRIER/FIRE/WEAPON_DESTROYER_CANNON_SHELL" }, { "fx_scale", "2" }, { "fx_nlips", "on" }, }, wpn6 = { { "anim", "Weapon_Gun0" }, { "animtime", "0.5" }, { "marker", "Weapon_Gun0Slave_Muzzle" }, { "fx", "muzzle_flash_combo_small_capital" }, { "sound", "WEAPON/CARRIER/FIRE/WEAPON_DESTROYER_CANNON_SHELL" }, { "fx_scale", "2" }, { "fx_nlips", "on" }, }, wpn7 = { { "anim", "Weapon_Gun2" }, { "animtime", "0" }, { "marker", "Weapon_Gun2_Muzzle" }, { "fx", "muzzle_flash_combo_small_capital" }, { "sound", "WEAPON/CARRIER/FIRE/WEAPON_DESTROYER_CANNON_SHELL" }, { "fx_scale", "2" }, { "fx_nlips", "on" }, }, wpn8 = { { "anim", "Weapon_Gun2" }, { "animtime", "0.5" }, { "marker", "Weapon_Gun2Slave_Muzzle" }, { "fx", "muzzle_flash_combo_small_capital" }, { "sound", "WEAPON/CARRIER/FIRE/WEAPON_DESTROYER_CANNON_SHELL" }, { "fx_scale", "2" }, { "fx_nlips", "on" }, },

The ship has two twin-barrelled turrets (Weapon_Gun0 and Weapon_Gun2). The weapon file itself is copied from the Taiidan Destroyer cannon. I think “animtime” might be the key to your problem.

Now that I’ve taken some time and been able to get a few ships in-game from blender and have poked and prodded around the joint structures from the example daes I feel WAY more confident about what this tutorial is even trying to teach me and could prob adapt them to blender myself now :stuck_out_tongue:

That’s probably why I was surprised to see this was posted about 2 months ago and feeling like I never saw it.