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"
Code: Select all
BUILDINGSECTION = "TURRETnumber"
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"
Code: Select all
PitchLimits = "smallvalue bigvalue"
Code: Select all
YawLimits = " smallvalue bigvalue"
Another very important line is this:
Code: Select all
PitchTurnFactor = "value"
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
Code: Select all
AimerNodeName "harpoint"
Code: Select all
AimerPitchLimits = "smallvalue bigvalue"
Code: Select all
AimerYawLimits = "smallvalue bigvalue"
Because you can have multiple aimers you tell Battlefront that another one follows with this line:
Code: Select all
NextAimer = "-"
This line allows the aimers to rotate outside of the given limits:
Code: Select all
FireOutsideLimits = 1
It is possible to create a hierarchy of aimers, with his line:
Code: Select all
HierarchyLevel = 1
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"
Code: Select all
BarrelRecoil = "value"
Because you can have multiple barrels you tell Battlefront that another one follows with this line:
Code: Select all
NextBarrel = "-"
A barrel can have firepoints.
The firepoint
A firepoint is defined with this line:
Code: Select all
FirePointName = "harpoint"
Piloting
Pilot types
A turret/vehicle can have various pilottypes, they are defined with the line:
Code: Select all
PilotType = "type"
- 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
Code: Select all
AutoFire= "1"
Visible pilots
In order to make the pilot visible you have to add this line:
Code: Select all
PilotPosition = "hardpoint"
Code: Select all
AnimatedPilotPosition = "hardpoint"
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 also instead define a 9pose animation for the pilot with this line:
Code: Select all
Pilot9Pose = "animation"
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:
Code: Select all
IsPilotExposed = "0"
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"
- 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.
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"
Code: Select all
MountPos = "x-coord y-coord z-coord"
Code: Select all
TrackCenter = "x-coord y-coord z-coord"
Code: Select all
TrackOffset = "x-coord y-coord z-coord"
To set up a cockpit view for the turret/vehicle, use this line:
Code: Select all
FirstPerson = "sidename\cockpitreqname;modelname"
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"
Code: Select all
CockpitTension = "value"
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
Did I wrote anything wrong? Do you have a question about another command or a general one? Please post it.