HOW TO ADD A SEA VEHICLE INTO BATTLEFIELD: 1942
Updated: October 10th 2003
This tutorial will walk you through the necessary steps to add a new sea vehicle into Battlefield: 1942 (BF: 1942). You will learn how to set up a new sea vehicle, configure the inner workings of the vehicle and place it in-game. The tutorial will show how to add a new sea vehicle name “AttackBoat” into the game based on the existing “Lcvp” sea vehicle which is already in BF: 1942. As a result of what you will learn in this tutorial, you will be able to modify sea vehicle files in any way to add a limitless amount of new sea vehicles into BF:1942 .
This tutorial assumes that you have used the winRFA extraction tool from the Mod Development Toolkit to extract the “Objects.rfa” file into the base directory of your BF:1942 installation. For reference purposes, we will assume that your base installation directory is the default installation directory (Program Files\EA Games\Battlefield 1942\). We need to begin by setting up the necessary directory and file structure.
Within the “AttackBoat” directory, there are four files and two directories. The four files are “Objects.con”, “Physics.con”, “Network.con” and “Geometries.con”. The directories are “Sounds” and “AI”. All of these items will need to be edited to create a new sea vehicle.
STEP 1: Objects.con Scripting Changes
The second line, “ObjectTemplate.create PlayerControlObject Lcvp”, begins the creation of a player-controllable object named “Lcvp”. The lines directly following the creation of this object configure some of the settings that will be applied to this vehicle, including the vehicle’s mass, amount of hitpoints and drag, etc. These lines also define the special effects that the “Lcvp” will have and when they will occur. For example, the line “ObjectTemplate.addArmorEffect 80 em_LcvpDamage 0/0/0” says that when the “Lcvp” drops to 80 hitpoints the “em_LcvpDamage” special effect (contained in the “Objects\Effects\” folder) will occur at position “0/0/0”.
The next section of this script deals with adding most of the sub-objects into the main “PlayerControlObject”. Each line starting with “ObjectTemplate.addTemplate” is adding a sub-object (created further down in the file) into the primary object “Lcvp”. Three of the items added have “Floater” in the line. Floaters will be explained further down in this tutorial. Additional “PCO” positions are added here as well.
***NOTE: The order of the “PCO” objects is indicative of what position they will be in this vehicle.
The “VehicleCategory” is “VCSea” and the “VehicleType” is set to “VTLcvp”. The settings of these lines determine what controls the vehicle will use. This vehicle will utilize the controls that were configured in the “Land & Sea Controls” menu in BF :1942
The next section in this file is the creation of the “LodObject” (Lod is short for Level of detail). This object defines two different ways that the vehicle will appear to a user; LcvpComplex – close range and LcvpSimple – long range. The order of these items is very important. The main object (Complex) is always first, followed by the low-polygon object (Simple).
The creation of the “LcvpComplex” bundle is integral to the functionality of the vehicle. This bundle adds templates (via the “ObjectTemplate.addTemplate” lines) that include the engine, how a user will enter/exit the vehicle, the rudders, etc. The line below each “addTemplate” line (“ObjectTemplate.setPosition”) is the position of each item in relation to the center-point of the vehicle. Eighteen lines into the creation of this object “Lcvp_GunnerPCO” is added. Because of the position of “lodLcvp” (which contains “LcvpComplex”) in the PCO “Lcvp”, the gunner position will be the second position on this vehicle.
At the bottom of this “Bundle”, the water effects are added in the lines containing “e_waterFront” and “e_waterbacksmall”. These effects will simulate the water churn and spray while the vehicle is moving.
The “AnimatedBundle LcvpDriverHandDummy” is created to animate the drivers hands while driving the vehicle. The numerical values in the “ObjectTemplate.addSkeletonIK” define the positioning of the hands on the steering wheel.
***NOTE: Each of the two “addSkeletonIK” lines configure different items (“Bipl01_R_Hand” and “Bip01_L_Hand”).
The following 4 sections set up the vehicle’s cockpit and how it will be seen. The “LcvpCockpitExternal” line defines what model a player will see when outside the vehicle.The “LcvpCockpitInternal” line displays a different (more detailed) model to the player who is inside the vehicle. Notice that each object (“LcvpCockpitExternal” and “LcvpCockpitInternal”) uses a different model via the “ObjectTemplate.geometry” line. The “LcvpCockpitSelector” makes the decision on which cockpit a player will see.
The next object created is “SeatObject LcvpPassengerSeat”. This object sets the flags for the player while he is in the vehicle. The flag “c_SeatShowStandingSoldier” means that anyone looking at the vehicle will see the whole player’s body standing up. If the flag was set as “c_SeatShowHalfBodySoldier”, only half of the body would appear. The other flag, “c_SeatIsOutside”, means that player can be shot even though he is in a vehicle. Without this flag, the player would be treated as if he were surrounded by the vehicle and unable to be attacked directly.
The “RotationalBundle Lcvp_Ramp” is set up to allow the front ramp to open and close. The actual model of the ramp is separate from the main body of the “Lcvp”.The “ObjectTemplate.geometry” line sets the particular geometry object that will be used (geometry objects are contained in the “Geometries.con” file). The following three lines set the rotational speed, maximum speed and the acceleration of the rotational bundle. The last line in this item defines which button will control the ramp. In this case, “c_PIPitch” (“PI” is short for Player Input) means that the keys mapped to the pitch controls will control the ramp on this vehicle.
“Lcvp_Door” is created to add the model of the door to the driving cabin of the “Lcvp” vehicle.
The “Lcvp_GunnerPCO” Player Controllable Object is the next object created in this file. The “Lcvp_GunnerPCO” consists of an entry point, a seat object and the weapon (“Lcvp_BrowningBase”).
The “Lcvp_BrowningBase” rotational bundle is what contains all of the objects that make the machine gun functional on this vehicle. Notice that in addition to setting the “LcvpBrowningMount” position, the rotation is set via the “set.Rotation” line. The last line in this object binds the movement of this rotational bundle to “c_PIMouseLookX”. This means that the movement on the X axis will be controlled by the motion of the mouse.
The next major object is the “LcvpBrowningRotation” bundle. The “Camera” object is included in this bundle via the “ObjectTemplate.addTemplate” line. Additionally, this object sets up the movement of the machine gun on the Y axis (up and down) via the movement of the mouse. ***NOTE: Because the “LcvpBrowningRotation” is included inside the “Lcvp_BrowningBase”, all of the settings will carry over into the “Lcvp_BrowningBase”. This is how both X and Y axis movement is configured.
The two cameras created define where the player’s viewpoint is while inside of the vehicle. There are two “EntryPoint” objects created as well. Without an entry point, no player could enter this vehicle. The radius set within this object defines how close a player needs to be to the vehicle before he can enter it.
The next three objects are “SimpleObject” objects that are used to add non-moving models as part of the vehicle. They are added in the “LcvpComplex” object that we reviewed earlier. Next is the creation of the “LcvpLodSelector” which we reviewed earlier as part of the “lodLcvp” object. The two “AnimatedBundle” objects are next. Notice that the only things these objects contain are two “addSkeletonIK” lines. The “addSkeletonIK” lines use their positioning values to lock the position of the player’s hands while in the vehicle. The given values attach the hands to certain locations on the vehicle. “LcvpHandDummy” is used by “LcvpPassangerPCO3” and “LcvpPassangerPCO4” (right side of the vehicle) and “LcvpHandDummy2” is used for “LcvpPassangerPCO5” and “LcvpPassangerPCO06” (left side of the vehicle).
The image above shows the “LcvpPassangerPCO3”, which is one of the four passenger “PCO” that this vehicle contains. Each of the four objects has an entry point, camera object, seat object and a “HandDummy” (discussed in the above paragraph). Each passenger “PCO” object is positioned via the “ObjectTemplate.setPosition” in the “Lcvp” object at the beginning of this tutorial.
The final section of the “Objects.con” file contains the creation of the “LcvpPassangerEntry”, the “LcvpPassengerSeat” and the “LcvpPassangerCamera”. The “LcvpPassangerEntry” consists of only one line which sets the “EntryRadius” to “3”. “LcvpPassengerSeat” contains both the “c_SeatShowStandingSoldier” and “c_SeatIsOutside” flags. The final object is “LcvpPassangerCamera” which configures the camera view that each of the passengers (excluding the driver and gunner) will have while inside the vehicle.
Now that we have reviewed how everything in the “Objects.con” file works, lets make the necessary changes to create a new vehicle named “AttackBoat” for BF:1942 .
STEP 2: Physics.con Scripting Changes
The “Physics.con” file contains objects that define the physics of the vehicle. It includes the engine, the rudders and the floaters.
The Engine is what makes the vehicle move in-game. Remember that the “Lcvp_Engine” was included in the “Objects.con” file as part of the “LcvpComplex” bundle. This means that the driver of the vehicle will have control over the Engine. The Min and Max rotation on an engine represent the maximum speed that the vehicle can attain while going forward (Max) or backward (Min). “ObjectTemplate.setEngineType c_ETShip” sets the type of engine that the vehicle will be using. In contrast, a tank uses the “c_ETTank” engine. Below the engine type, you can set the engine torque, differential, number of gears, and the gear ratio. These items can be tweaked at anytime to adjust the feel of the vehicle.
The next two objects created are the rudders. The “MinRotation” and “MaxRotation” set how much the rudder can rotate. The line “ObjectTemplate.setInputToPitch c_PIYaw” indicates that the movement of the rudders is bound to the Yaw controls. The “FlapLift” defines how much the rudder can affect a turn.
The final lines in this file configure the floaters. The floaters buoy the boat and keep it from sinking while driving. The creation line, “ObjectTemplate.create FloatingBundle”, sets the object as a “FloatingBundle”. The settings contained in these objects define how much lift the floater has, the distance between the hull and the water, and how fast it will sink into the water.
Now that we have reviewed how the objects in the “Physics.con” file work, let’s make the necessary changes so that these objects can be used in our new vehicle.
STEP 3: Geometries.con Scripting Changes
The “Geometries.con” file contains all of the geometry objects to which the “Objects.con” and “Physics.con” file refer. Our next step will be to open this file and make the necessary changes. < Open the “Geometries.con” file.
Note that each object starts with the line “GeometryTemplate.create StandardMesh”. StandardMesh is the object that contains the model that will be seen in-game. The second line in each Geometry object is “GeometryTemplate.file”. The line is ended by the filename of the model. The default folder for the model files is the “StandardMesh” directory which is contained in the “StandardMesh.rfa” file. If you wanted to put a different hull in place of the standard Lcvp hull, all you would need to do is place the exported model file into the “StandardMesh” directory and then adjust the “GeometryTemplate.file Lcvp_Hul_M1” line to read “GeometryTemplate.file newfilename”.
STEP 4: Network.con Scripting Changes
The last file we will need to change is the “Network.con” file.
This file contains the network objects that will transmit the vehicle data in a multiplayer game. Each of the network objects created in this file were part of major portions of the objects created in the “Objects.con” and “Physics.con” files. You will find these network objects (within the aforementioned files) in lines that begin with “ObjectTemplate.setNetworkableInfo”. We need to make the appropriate changes in this file to make sure this new vehicle can be used in a multiplayer game.
STEP 5: Sound configuration
The next step in setting up this new vehicle is making the necessary changes to the Sound files. All sound effect settings are contained in the “Sounds” subdirectory of each vehicle’s main folder. BF:1942 has three different settings for sound. You can choose 11 khz (Low), 22 khz (Medium) or 44 khz (High). The “Lcvp_Engine_Water.ssc” and “Lcvp_Ramp” are text files.They are the central sound files that include all the settings from other three sound files for the vehicle’s ramp and engine. The six sound files (three for “Lcvp_Engine_Water” and three for “Lcvp_Ramp”) that contain the settings are in the “High”, “Mid” and “Low” directories.
The sound configuration changes have been completed.
6: AI Configuration
The final step is to make sure that the Artificial Intelligence (AI) is configured. The AI for this vehicle is contained in the AI directory in the “Objects.con” file. This file contains AI configurations for how bots will drive the vehicle, react to the opposing team, etc. Additionally, it contains AI for the passenger. This will help the passenger know how to react to certain situations (if the vehicle is being damaged, if an enemy is nearby, etc.).
Now that all of the proper changes have been made, this new sea vehicle can be added into the game. A new “Objects.rfa” file will need to be created that includes these new configuration files. This can be done using the winRFA tool from the Mod Development Toolkit.
STEP 7: Examples
Let’s apply some of the knowledge we’ve gained and make some tweaks to our new sea vehicle. We will begin by turning this slow moving boat into a speed boat. Open the “Physics.con” file.
Re-pack the “Objects.rfa” file and start BF:1942. The sea vehicle will now be incredibly fast with much more power than before. Play with these settings to tune the vehicle to your personal preference.
Let’s finish up our changes by raising our boat off the water to ride like a hovercraft.
***NOTE: Remember that these “Floaters” were added into the main vehicle object “AttackBoat” at the beginning of the “Objects.con” file.
Once you re-pack the Objects.rfa file and begin a game, you will notice that the vehicle rides higher off the water. If you replaced the default hull with a hovercraft hull, these latest changes would make it both appear and handle more realistically like a hovercraft.
***NOTE: Notice how much water effects are visible because of the increased hull contact with the water.
After "HullHeight" changes:
***NOTE: Now the water effects are lessened because much less of the boat has contact with the water.
If you replaced the default hull with a hovercraft hull, these latest changes would make it both appear and handle more realistically like a hovercraft.