Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Kusanagi on August 13, 2010, 12:31:30 pm

Title: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 12:31:30 pm
Greetings, ya'll!

While working on and importing some homeworld ships, I've ended up converting and importing the Taiidani Destroyer. I've used Scooby's and JGZinv's method for exporting Collada format to PCS2.

The problem comes when converting these turrets. Scooby's tutorial stated that you could position the turrets and their normals along non-Z-axis lines. My turrets are set at a 45 degree angle with the corresponding normals, as shown here.

(http://img43.imageshack.us/img43/4017/destroyerf.th.jpg) (http://img43.imageshack.us/i/destroyerf.jpg/)

Both the turrets and the arms are set to rotate along the Z axis as they are in most multipart turrets and the normal firing points look ok. I've given them a 90 degree FOV.

When I run the game, I get an interesting error. The flak fires out of the ends of the barrels jut fine, but the barrels don't track the target properly. The turrets will rotate in random directions including almost fully backwards (which they should not do) and the flak will fire out of the barrel at a 90 degree angle as if it's making a sharp left of right when leaving the barrel and it won't elevate properly. Here's two screenshots to show what I mean. You can see the flak guns firing, but they are firing AT ME.

(http://img441.imageshack.us/img441/2056/screen0006td1.th.jpg) (http://img441.imageshack.us/i/screen0006td1.jpg/)

[IMG=http://img710.imageshack.us/img710/3342/screen0008td1.jpg][/IMG] (http://img710.imageshack.us/i/screen0008td1.jpg/)

Can someone explain why it does this? I haven't seen it do this on retail ships. If someone can also explain http://www.hard-light.net/wiki/index.php/Turret_setup (http://www.hard-light.net/wiki/index.php/Turret_setup) to me, I would appreciate it. It looks like the engine has been upgraded to allow the FOV to have more options, but after searching I have no clue how to implement it.

Title: Re: Turrets not tracking properly
Post by: Commander Zane on August 13, 2010, 02:09:48 pm
I've seen it on many occasions with Retail ships. Though I recall reading there was a flag that forced the weapon to shoot only in the direction the barrel was pointing, it would make it nearly impossible for them to ever fire at moving fighters / bombers.
Title: Re: Turrets not tracking properly
Post by: General Battuta on August 13, 2010, 02:13:45 pm
I believe blowfish has some clue how to handle this.
Title: Re: Turrets not tracking properly
Post by: blowfish on August 13, 2010, 02:17:13 pm
Okay, here's the thing:

The barrels should be facing UP in the model, not at an angle like you have them.  If you want to change their rest orientation, you can do that in the tables, but freespace requires them to be pointing up in order to work properly.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 02:24:17 pm
Not up but it the direction of the uvec.  Uvec = axis of rotation = direction barrels need to point. 
Title: Re: Turrets not tracking properly
Post by: chief1983 on August 13, 2010, 02:26:10 pm
I've seen it on many occasions with Retail ships. Though I recall reading there was a flag that forced the weapon to shoot only in the direction the barrel was pointing, it would make it nearly impossible for them to ever fire at moving fighters / bombers.

If you're going to enable that for point defense turrets (which it should, to be realistic) you better enable those turrets to have some chance of tracking fighters and bombers.  But that does give a nimble fighter the ability to outmaneuver a turret, which also does make some sense.  I think it would be cool if turret rotations were damped too.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 02:44:58 pm
So the only way the guns will track is if the guns point straight up? Damn. Then how do I set it so the turret only fires in the upper front quadrant? I had thought that it had something to do with the turret setup page I linked, but I haven't been able to find any helpful information on that.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 02:48:13 pm
You use a combination of uvec/fvec, animation code (for the initial turret position) and fov or other subsystem flags for the elevation and base rotation.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 03:12:50 pm
Is there a model with a working example or a link to a setup that shows how to do this? It sounds like you would just give the turret a 180 degree field of vision and then restrict its movements via the tables, but aside from that page I linked, I haven't been able to make sense of it and can't find any information in the ships or weapons tables wiki entries.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 03:45:35 pm
Is there a model with a working example or a link to a setup that shows how to do this? It sounds like you would just give the turret a 180 degree field of vision and then restrict its movements via the tables, but aside from that page I linked, I haven't been able to make sense of it and can't find any information in the ships or weapons tables wiki entries.

Pics work better:

(http://fubar5.fubar.org/fubar/FS2/turret.jpg)

This turret faces forward, the base can only turn so far, and it has limited elevation (inverse FOV). 
This is what it looks like in PCS2.  In this case the barrels are facing up but if they were on the side of the ship they could be facing left and the UVEC would then be 1,0,0.  Note the FVEC and UVEC x axis is -x show in PCS2.   

As for the rotation that is handled via tables.  Specificially these entries:
Code: [Select]
$Maximum Barrel Elevation: 50
$Turret Base FOV: 115
......................
$animation: triggered
$type: initial
+relative_angle:       90,52.5,0

Note the fvec is 52.5 degrees off of forward and can rotate 115 degrees.  The 90 lowers the barrels to level with the base at mission start.  So both the barrels and base face forward in game.  Now if you want the turret to rotate from the uvec down instead of the fvec up as this one does you use FOV in PCS2 instead of Maximum Barrel Elevation:

Hope this makes it a bit clearer.
Title: Re: Turrets not tracking properly
Post by: chief1983 on August 13, 2010, 04:23:32 pm
It's not tracking that fixing their orientation fixes, it's whether they point in the right direction when they fire at all I believe.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 06:10:00 pm
That seems to make sense, that picture was worth a thousand words.

So, basically, I want to have the $uvec at 0,1,0 and the $fvec at 0,0,1 to have the turret face forward.

Looking at the turret setup page, I want the turret to have a maximum elevation of 90 degrees and a limited base rotation of 180 degrees. That should cover everything in the forward firing arc...do the related flags go in the subsystem properties in PCS2 or do they go in the entry in the ships.tbl file?

I'm very glad for that explanation as those things you mentioned aren't in the wiki and I can't find them in the search.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 06:27:47 pm
Well in that case you can do either FOV 180 or the limited elevation at 90 in the tables.  Both come out the same.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 06:36:04 pm
Well in that case you can do either FOV 180 or the limited elevation at 90 in the tables.  Both come out the same.

   $Maximum Barrel Elevation:   50
   $Turret Base FOV:      115
......................
   $animation:       triggered
   $type:          initial
    +relative_angle:       90,52.5,0

Where do these go? In the subobject properties in PCS2 or in the ships.tbl?

This is what I have for the turret in the ships.tbl:

Code: [Select]
$Subsystem:                     turret01,4,2.0
$Default PBanks:        ( "Long Range Flak" )
$Maximum Barrel Elevation: 90
$Turret Base FOV: 180
$animation: triggered
$type: initial
+relative_angle:       90,0,0

I either got the order wrong or something else wrong as well, because it crashes.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 06:50:58 pm
Run debug and post the message it crashes with.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 06:59:48 pm
Run debug and post the message it crashes with.

Code: [Select]
Error: ships.tbl(line 9155:
Error: Required token = [#End], [$Subsystem:], [$Name], or [$Template], found [$Maximum Barrel Elevation: 90].

File: PARSELO.CPP
Line: 670


Call stack:
------------------------------------------------------------------
------------------------------------------------------------------


It then gives me a dozen more errors for every line of code for the two turrets.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 07:27:21 pm
You using 3.6.12final or a 3.6.13Knightly?  This feature wasn't in 3.6.10.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 07:40:31 pm
...oy, that was the problem? According to the wiki the animation code was in 3.6.10.

I was trying to use it in 3.6.10. I just tried using it with the 3.6.12 INF SSE2 build and now the turrets don't show up at all.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 08:03:07 pm
Animation was but the base rotation and elevations were added in 3.6.11.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 08:05:33 pm
Ok, that explains that. There was no information on it or I'm out of the loop :P

Now the turrets don't show up ingame at all!  :mad:
Title: Re: Turrets not tracking properly
Post by: chief1983 on August 13, 2010, 08:26:54 pm
When using a new build, or changing the table?
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 08:29:37 pm
Try deleting the cache file and letting it recreate.  Might not have finished when it crashed before.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 09:27:20 pm
Try deleting the cache file and letting it recreate.  Might not have finished when it crashed before.

That did the trick! The turrets now track the way they're supposed to and look beautiful in game. Thank you so much!  :yes:
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 13, 2010, 09:48:22 pm
I'll just put tonight on your bar tab and we'll call it even.   :pimp:
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 13, 2010, 10:17:31 pm
I'll just put tonight on your bar tab and we'll call it even.   :pimp:

I could use some myself actually.

Turns out the collada importer isn't perfect when it comes to working on hierarchies. You still have to do a fair amount of work in PCS2 to get the engine to recognize multipart turrets.
Title: Re: Turrets not tracking properly
Post by: JGZinv on August 14, 2010, 03:15:30 am
Heh maybe if you can get this down, you can write a summary and we can stick it in the PCS2 guide 2.0.
Title: Re: Turrets not tracking properly
Post by: Scooby_Doo on August 14, 2010, 03:48:33 am
Okay, here's the thing:

The barrels should be facing UP in the model, not at an angle like you have them.  If you want to change their rest orientation, you can do that in the tables, but freespace requires them to be pointing up in order to work properly.

Yup, this is the easiest way to do that.

What I was referring to in the tutorial is when the entire turret is at an odd angle.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 14, 2010, 12:20:06 pm
Heh maybe if you can get this down, you can write a summary and we can stick it in the PCS2 guide 2.0.

I may have to do that. When you open up the DAE file in PCS2, the turrets are there, but the turret arms are listed as the turrets and their own parents. You need to copy the information for the turret to the turret base and make sure each turret arm has its base as the parent.

Either Scooby set something up differently in his hierarchy than I did or that wasn't covered by the guide.
Title: Re: Turrets not tracking properly
Post by: JGZinv on August 14, 2010, 01:21:55 pm
Turrets are not covered in my guide as I never learned them.
Title: Re: Turrets not tracking properly
Post by: Scooby_Doo on August 14, 2010, 01:59:37 pm
Heh maybe if you can get this down, you can write a summary and we can stick it in the PCS2 guide 2.0.

I may have to do that. When you open up the DAE file in PCS2, the turrets are there, but the turret arms are listed as the turrets and their own parents. You need to copy the information for the turret to the turret base and make sure each turret arm has its base as the parent.

Either Scooby set something up differently in his hierarchy than I did or that wasn't covered by the guide.

Hmmmm..... here's how it should work (I've never had a problem with heirarchy with it)

Code: [Select]
Turret0X
     Turret0X-arm
     helper
          firepoints
               firepoint

Both HELPER and TURRET0X-ARM are siblings to TURRET0X
Title: Re: Turrets not tracking properly
Post by: pecenipicek on August 14, 2010, 02:54:43 pm
kusanagi, for a perfectly working example of properly tracking turrets and all, check the HGN_Dest.pof in the TAP models folder.
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 15, 2010, 02:09:44 am
Heh maybe if you can get this down, you can write a summary and we can stick it in the PCS2 guide 2.0.

I may have to do that. When you open up the DAE file in PCS2, the turrets are there, but the turret arms are listed as the turrets and their own parents. You need to copy the information for the turret to the turret base and make sure each turret arm has its base as the parent.

Either Scooby set something up differently in his hierarchy than I did or that wasn't covered by the guide.

Hmmmm..... here's how it should work (I've never had a problem with heirarchy with it)

Code: [Select]
Turret0X
     Turret0X-arm
     helper
          firepoints
               firepoint

Both HELPER and TURRET0X-ARM are siblings to TURRET0X

When I set it up that way and import it to PCS2, the turret0X-arm is what the converter reads as the turret and gives it all the details, not the turret0X submodel. It's an easy fix.
Title: Re: Turrets not tracking properly
Post by: Scooby_Doo on August 15, 2010, 03:26:33 am
That's strange   :confused:


Edit:Hmmmm... could you send me a sample where it does that?  Perhaps then I'll see what's going on.

Double Edit: Oh.. just thought of this... which dae converter are you using?

Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 15, 2010, 03:15:11 pm
The Collada one listed in JGZinv's fighter creation tutorial, which is the one you linked in your Max to PCS2 tutorial thread.
Title: Re: Turrets not tracking properly
Post by: Scooby_Doo on August 15, 2010, 04:23:00 pm
Ohhhhh does the turret have these properties:  (in max it's right click on the object ->Object Properties->User Defined.

Code: [Select]
$special=subsystem
$fov=180
$name=turret0X

The turret arm shouldn't have any properties
Title: Re: Turrets not tracking properly
Post by: Kusanagi on August 15, 2010, 04:39:18 pm
Huh...now it works. Damn, this is confusing  :confused:

I wonder if it's possible to have a one part rotating turret.
Title: Re: Turrets not tracking properly
Post by: Scooby_Doo on August 15, 2010, 04:49:13 pm
All subsystems must have at least the $special and $name tags otherwise the game will ignore them as subsystems (they will still appear on the model [this is how you get around the max polycount per system]).

I ended up writing a small max script that automatically renumbers turrets and another that gives them these property tags.
Title: Re: Turrets not tracking properly
Post by: FUBAR-BDHR on August 15, 2010, 05:11:29 pm
$name is not required and is the same as $alt subsystem name in the tables. Both are optional.
Title: Re: Turrets not tracking properly
Post by: pecenipicek on August 15, 2010, 05:26:01 pm
also, do take note that some collada exporters (namely c4d's one...) export any special characters in the names of objects as underscores


(so for example $special=subystem becomes __special_subsystem...


discovered that one the hard way, much to my chagrin...