[Guide] On turrets - a thorough essay (FAQ)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Master of the Force
User avatar
Posts: 6069
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

[Guide] On turrets - a thorough essay (FAQ)

Postby DarthD.U.C.K. » Mon Aug 29, 2011 2:07 pm

"On Turrets", an essay by DarthD.U.C.K.

You may ask whats the point of this essay since there is already this tutorial about creating custom turrets and its really not difficult to set up the odf for one. You are right, if you just want to create a simple turret with a base and a barrel you dont need to read further. If you however want to set up more interesting turrets and understand how it works and what the parameters really do, then read on!

Setting up a turret seems pretty simple but once you are setting up one a little unusual, you will realize how complex and dynamic it actually is.
In the last Months I set up various more or less unusual turrets and will now explain everything as far as i experienced and deduced it.
In the following text you will find a complete explanation/guide of/through the set-up of turrets.

Here is the general hierarchy (in battlefront). A turret usually consists of a turretbase(turretnode) that rotates horizontally. On top of the base is the turrethead(aimer) which rotates vertically. Fixed on the turrethead is the actual cannon/barrel, which moves backwards when the turret fires. The firepoint is where the ordnance is shot from.

First off two general things: All objects in the hierarchy are optional, you dont need a turrethead, barrel or firepoint.
There are two kinds of turrets: The first is the weapon of a vehiclepilot, it doesnt have a Turretnode(base) because the player controls the vehicle itself. The second is an actual turret that standing around by itself or a copilots weapon fixed on a vehicle.


Hierarchy
Because one flyer/armedbuilding can have multiple turrets, the beginning of one is marked with this line:
Code: Select all
FLYERSECTION      = "TURRETnumber"
(vehicle)
Code: Select all
BUILDINGSECTION   = "TURRETnumber"
(armedbuilding)
It can be compred to the "WEAPONSECTION" of a pilot.

The turretbase
In the odf the turretbase is defined with the line:
Code: Select all
TurretNode   = "hardpoint"


The turrets and cameras vertical rotation is controlled through the line:
Code: Select all
PitchLimits   = "smallvalue bigvalue"

The turrets and cameras horizontal rotation is controlled through the line:
Code: Select all
YawLimits   = " smallvalue bigvalue"

If you dont set these values, Battlefront will assume that the limit is "-180 180".
Another very important line is this:
Code: Select all
PitchTurnFactor   = "value"

It determines how much vertical rotation is done by the base. 0 is no pitching and 1 is all pitching.

For vertical rotationlimits negative value is upwardrotation and the positive value is downwards.
For horizontal rotationlimits negative value is rotation to the right and positive to the left.

It seems to be unnecessary to define a pitchlimit for the turretbase since it wont do any pitching in most cases. The reason for it is that when the player controls the turret, the turretnode takes control over it. That means that the yaw- and pitchlimits of the turretnode apply for the whole turret and that the aimer will rotate with it, even if hes not really a child of the turretnode in the models hierarchy.
A turretnode will always be alligned along the z-axis. You can however let it point backwards if you add 180 to both yawlimitvalues.
A turretnode will always aim in the exact same direction as the camera points.
If you dont have a turretnode you still need the rotationlimits because they apply for the camera as well.

A turretnode can have aimers.
A turretnode can have barrels.
A turretnode can have firepoints.

The turrethead

The beginning of an aimer is marked with this line:
Code: Select all
TURRETSECTION       = "TURRETnumber


The head is defined with this line:
Code: Select all
AimerNodeName   "harpoint"


The aimers vertical rotation is controlled through this line:
Code: Select all
AimerPitchLimits   = "smallvalue bigvalue"

The aimers horizontal rotation is controlled through this line:
Code: Select all
AimerYawLimits   = "smallvalue bigvalue"

If you dont set these values, Battlefront will assume that the limit is "-180 180".

Because you can have multiple aimers you tell Battlefront that another one follows with this line:
Code: Select all
NextAimer   = "-"


It seems to be unnecessary to define a yawlimit for the aimer if its overridden by the turretnodes anyway. The reason for it is that when the AI controls the turret, it does not need a turretnode, it controls all aimers seperately. You can notice that on vehicles like the stock gunship or fightertank where the maincannons always point forward when the player pilots them. When they are AI-piloted these move independently from the vehicle. If the turret has multiple aimers and the target is outside the limits of one, this aimer wont shoot.

This line allows the aimers to rotate outside of the given limits:
Code: Select all
FireOutsideLimits   = 1

I dont know what purpose that has. Its function is probably AI-exclusive.


It is possible to create a hierarchy of aimers, with his line:
Code: Select all
HierarchyLevel   = 1

When put above "AimerNodename", this makes the aimer parent of all following aimers until the next aimer with this line is listed.
This will not work with a turretnode defined. You can however use it as substitute for a turretnode because it isn't automatically aligned along the z-axis.
A (parent) aimer will always aim so that it can shoot into the direction the camera points, it is not forced to point in the same direction.

If the weapon has multiple salvos, one aimer will fire one salvo.

An aimer can have barrels.
An aimer can have firepoints.

The barrel
A barrel is defined with this line:
Code: Select all
BarrelNodeName   = "hardpoint"

The recoilstrength of the barrel is defined with this line:
Code: Select all
BarrelRecoil   = "value"

If you dont set the recoil value Battlefront will assume that its zero.

Because you can have multiple barrels you tell Battlefront that another one follows with this line:
Code: Select all
NextBarrel   = "-"


If the weapon has multiple shots, one barrel will fire one shot.

A barrel can have firepoints.

The firepoint
A firepoint is defined with this line:
Code: Select all
FirePointName = "harpoint"


If no firepoint is defined the ordnance will be fired from the next higher element in the hierarchy. if you have a barrel it will be fired from there. If you dont have a barrel it will be fired from the aimer.


Piloting
Pilot types
A turret/vehicle can have various pilottypes, they are defined with the line:
Code: Select all
PilotType   = "type"


These types are:
  • none -used in the flyers in campaign that are animed through their vehiclespawn, together with the line:
    Code: Select all
    NeverCrashWhenUnpiloted = "1"

  • vehicle -default, enterable by units
  • self -selfpiloted, cant be entered by anyone
  • vehicleself-the cool one: selfpiloted, but can also be entered by units
  • remote -controlled through remote terminal

With the following line the turret will shoot even if it does not have a target:
Code: Select all
AutoFire= "1"


If you want to enable units to use their own weapons while being in a vehicle, follow this tutorial

Visible pilots
In order to make the pilot visible you have to add this line:
Code: Select all
PilotPosition          = "hardpoint"

In Walker vehicles, the following line is used, supposedly because the pilot has to move with the walkers animations.
Code: Select all
AnimatedPilotPosition = "hardpoint"


Through defining the pilots position, he/she/it automatically becomes visible and vulnerable.
The pilot will always look into the direction in which the turret/vehicle he controls aims.

You need to define an animation for the pilot with this line:
Code: Select all
PilotAnimation         = "animation"

You can find the names of stock pilotanimations in the "assets\Animations\SoldierAnimationBank\human_4"-folder.

You can also instead define a 9pose animation for the pilot with this line:
Code: Select all
Pilot9Pose   = "animation"

This allows dynamic movement of the pilot controlled by the vehicles/turrets movement. It requires a special animation that has the frames 0-8, hence the name.
You can learn how to set up such an animation in this thread.
A 9pose is not only for vehicles but also looks cool on turrets. For example you can have the unit lean to the side when the turret rotates or grab the trigger all the time, even when its fixed on the cannon and rotates up and down.
Turret9poses are set up like this:
Hidden/Spoiler:
Frame 0: -
Frame 1: turn up
Frame 2: -
Frame 3: turn right
Frame 4: idle
Frame 5: turn left
Frame 6: -
Frame 7: turn down
Frame 8: -


It is possible to hide the pilot even though a position is defined with this line:
Code: Select all
IsPilotExposed   = "0"


Pilot deaths
It seems to be unnecassery to have a command that hides the pilot when there is a pilotposition and animation to make him/her/it visible in the first place. The reason for this is that pilots will automatically die and fall down when the vehicle/turret he controls is destroyed. Pandemic used the above command to prevent this in the flyer odfs because in SWBF2 they are only present in space and its pretty stupid that pilots fall down even though there isn't supposed to be any gravity in space.

There is however one line that controls how the pilot acts when the vehicle/turret is destroyed:
Code: Select all
PilotDeath   = "type"


Sadly there are only two types:
  • fall -default, the pilot falls down in the usual stiff dead pose
  • fly -the pilot falls down flailing until he hits and object, then switches to stiff dead pose.
    The later type makes the falling-down issue tolerable. I prefer a visible, falling down flailing pilot over a never visible one.

Camera

The camera will always point straight forward and the reticule will always be in the middle of the screen.
If you set a turretnode, the camera will automatically revolve around it.
Code: Select all
TurretNode   = "hardpoint"

If you didn't define a turretnode because you need the turretbase rotated somehow you can still define the point around which the camera revolves with this line:
Code: Select all
MountPos   = "x-coord y-coord z-coord"


You can define the cameras offset from the turretnode/mountpos with this line:
Code: Select all
TrackCenter   = "x-coord y-coord z-coord"

there is another line:
Code: Select all
TrackOffset   = "x-coord y-coord z-coord"

which does about the same, not completely but the effect is really similar.

To set up a cockpit view for the turret/vehicle, use this line:
Code: Select all
FirstPerson         = "sidename\cockpitreqname;modelname"

if you dont know how to set up a firstperson, follow this tutorial (pay attention to the note on the bottom)

The firstperson will be in the position of the turretnode/mountpos(?) or dummyroot(for vehiclepilots). You can offset it with this line:
Code: Select all
EyePointOffset          = "x-coord y-coord z-coord"


With this line you control the cockpits inertia/how much it sways
Code: Select all
CockpitTension          = "value"

The higher the value, the more it sways.

These two lines control how big the field of view is for first- and thirdperson is:
Code: Select all
ThirdPersonFOV          = "value"

Code: Select all
FirstPersonFOV          = "value"



Examples
Gunship Wingturret, uses parent aimer instead of turretnode, 2 childaimers
Hidden/Spoiler:
//********************************
//********** L WING TURRET *****
//********************************

FLYERSECTION = "TURRET4"

Pilottype = "vehicleself" //This makes the turret AI controlled but the player can still enter it

WeaponName = "rep_weap_fly_gunship_beam"
WeaponAmmo = "0"

PitchRate = 0.8
PitchFilter = 2.75
TurnRate = 1.3
TurnFilter = 2.75

MountPos = "8 -0.09 -1.63" //instead of turretnode to allow tilted turret
TrackCenter = "0.0 1.2 -10.0"
TrackOffset = "0.0 0.0 10.0"
TiltValue = "5.0"

PitchLimits = "-75 75" //overrides aimerpitch, for playercontrols
YawLimits = "-30 105" //overrides aimer yaw, for playercontrol

TURRETSECTION = "TURRET4"

HierarchyLevel = 1 //makes this aimer parent of the following aimers
AimerNodeName = "wing_turret_1" //the wingturretbubble itself
AimerPitchLimits = "0 0"
AimerYawLimits = "-75 105" //rotates only horizontally

NextAimer = "-"

AimerNodeName = "wing_turret_1_2" //upper laser
AimerPitchLimits = "-75 25"
AimerYawLimits = "-7.5 7.5" //little yawtolerance to get both aimers to shoot both at one target

NextAimer = "-"

AimerNodeName = "wing_turret_1_1" //lower laser
AimerPitchLimits = "-75 25"
AimerYawLimits = "-7.5 7.5" //little yawtolerance to get both aimers to shoot both at one target

TurretYawSound = "turret_whir_yaw_lp"
TurretYawSoundPitch = "0.7"
TurretPitchSound = "turret_whir_pitch_lp"
TurretPitchSoundPitch = "0.7"
TurretActivateSound = "vehicle_equip"

VehiclePosition = "common.vehiclepositions.wingturret"


E-Web turret, with 9pose and firstperson
Hidden/Spoiler:
BUILDINGSECTION = "TURRET1"

TurretNodeName = "aimer_y" //the base, where unit stands

PitchLimits = "-35 35" //pitch limits for whole turret on playercontrol
YawLimits = "-180 180"

PitchTurnFactor = "0.2" // amount of pitching done by the turret, remaining pitching done by the aimer

EyePointOffset = "0.0 1.5 1"
TrackCenter = "0.0 0.65 -2.0"
TrackOffset = "0.0 0.5 1.5"
TiltValue = "5"

ThirdPersonFOV = "65"
WeaponName = "tur_weap_chaingun"
WeaponAmmo = "0"

MaxTurnSpeed = "5.0"
MaxPitchSpeed = "5.0"
//PitchRate = "2.0"
//TurnRate = "5.0"
PCMaxPitchSpeed = "5.0"
PCMaxTurnSpeed = "5.0"

PilotPosition = "hp_pilot"
Pilot9Pose = "eweb_9pose"
FirstPerson = "com\eweb;rep_weap_eweb_1stperson"

TURRETSECTION = "TURRET1"

AimerNodeName = "aimer_x" //the cannon, held by unit
MaxTurnSpeed = "2.85"
MaxPitchSpeed = "0.75"
AimerPitchLimits = "-35 35"
AimerYawLimits = "0 0"

BarrelNodeName = "hp_barrel"
FirePointName = "hp_fire"
BarrelRecoil = "0.1"


*phew*That's really the biggest text i've ever written here.
Did I wrote anything wrong? Do you have a question about another command or a general one? Please post it.
Last edited by DarthD.U.C.K. on Tue Sep 27, 2011 4:10 pm, edited 9 times in total.

Space Ranger
User avatar
Posts: 6120
Joined: Tue Aug 17, 2010 3:30 pm
Location: Columbus, Ohio
Projects :: Evolved 2

Re: [Guide] On turrets - an essay

Postby THEWULFMAN » Mon Aug 29, 2011 2:15 pm

Very nice comprehensive document on how turrets work. This should be in the everythingyouneedthread. :)

Master Bounty Hunter
User avatar
Posts: 1464
Joined: Fri Dec 11, 2009 6:24 pm
Location: minisnowta
Projects :: BFSM
Games I'm Playing :: SWBFII
xbox live or psn: skelltor95

Re: [Guide] On turrets - an essay

Postby skelltor » Mon Aug 29, 2011 2:21 pm

Very nice :)
just checking but does the pilot type vehicleself work on any enterable thing ie ships,turrets, and vehicles?

Space Ranger
User avatar
Posts: 6120
Joined: Tue Aug 17, 2010 3:30 pm
Location: Columbus, Ohio
Projects :: Evolved 2

Re: [Guide] On turrets - an essay

Postby THEWULFMAN » Mon Aug 29, 2011 2:23 pm

skelltor wrote:just checking but does the pilot type vehicleself work on any enterable thing ie ships,turrets, and vehicles?


Yes. Pilottype = "self" should work on any flyer or turret. Except Hovers do not work, I have found they cause a CTD. I do not know about walkers.
So to put it simply.
  • Flyers (Xwing, etc) Pilottype = "self" Yes
  • Turrets (Turbolaser, etc) Pilottype = "self" Yes
  • Hovers (AAT, etc) Pilottype = "self" No
  • Walkers (AT-ST, etc) Pilottype = "self" Unknown
Last edited by THEWULFMAN on Mon Aug 29, 2011 2:31 pm, edited 3 times in total.

Master of the Force
User avatar
Posts: 6069
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: [Guide] On turrets - an essay

Postby DarthD.U.C.K. » Mon Aug 29, 2011 2:27 pm

it will work as long as the "self" tpye works. i doubt that it works for vehiclepilots of vehicles though. do the selfcontrolled flyers fly like they are controlled by normal ai-units?
Last edited by DarthD.U.C.K. on Mon Aug 29, 2011 2:29 pm, edited 1 time in total.

Space Ranger
User avatar
Posts: 6120
Joined: Tue Aug 17, 2010 3:30 pm
Location: Columbus, Ohio
Projects :: Evolved 2

Re: [Guide] On turrets - an essay

Postby THEWULFMAN » Mon Aug 29, 2011 2:29 pm

DarthD.U.C.K. wrote:do the selfcontrolled flyers fly like they are controlled by normal ai-units?


Yeah, pretty much.

Major General
User avatar
Posts: 659
Joined: Fri Jan 07, 2011 4:57 pm
Location: Germany
Games I'm Playing :: SWBF2

Re: [Guide] On turrets - a thorough essay

Postby naru1305 » Mon Aug 29, 2011 4:12 pm

ah my friend, you finaly did it, great work on this, it is SO useful, i canĀ“t describe :faint:
you taught me this when we work on the laat and i learned much, thx for this :bowdown:

Master Bounty Hunter
User avatar
Posts: 1649
Joined: Thu Jul 08, 2010 5:53 pm
Location: New York, USA
Projects :: WIP. I will reveal what it is later on..
Games I'm Playing :: SWBF2-SWRC
xbox live or psn: No gamertag set

Re: [Guide] On turrets - a thorough essay

Postby Cerfon Rournes » Mon Aug 29, 2011 6:57 pm

Great work D.U.C.K. And thanks. :thumbs:

Return to SWBF2 Modding

Who is online

Users browsing this forum: No registered users and 4 guests