Classic Battlefield Modding Wikia
Advertisement

HOW TO ADD A LAND VEHICLE INTO BATTLEFIELD 1942

Updated: October 2nd 2003

This tutorial will walk you through the necessary steps to add a new land vehicle into Battlefield: 1942 (BF: 1942). You will learn how to setup a new land vehicle, configure the inner workings of the land vehicle and place it in-game. The tutorial will show how to add a new land vehicle name Jeep into the game based on the existing Willy land vehicle which is already in BF: 1942. As a result of what you will learn in this tutorial, you will be able to modify land vehicle files in any way to add a limitless amount of new land vehicles into BF:1942.

PREPARATION: 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.

Enter the Objects\Vehicles\Land\ directory. Copy the Willy directory . Rename the new directory Jeep. Enter the Jeep directory. Within the Jeep directory, there are 4 files and 2 directories. The 4 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 land vehicle.

STEP 1: Objects.con Scripting Changes Open the Objects.con

42Limage001.gif

Image File: 42Limage001.gif


The second line, ObjectTemplate.create PlayerControlObject Willy, begins the creation of a player-controllable object named Willy. The lines directly following the creation of this object configure some of the settings that will be applied to this vehicle, including the vehicles mass, amount of hitpoints and the types of damage it can take. These lines also define the special effects that the Willy will have and when they will occur. For example, the line ObjectTemplate.addArmorEffect 30 e_willyDamage 0/1.7/0 says that when the Willy drops to 30 hitpoints the e_willyDamage special effect (contained in the Objects\Effects\ folder) will occur at position 0/1.7/0.

The line ObjectTemplate.setVehicleIcon sets the location of the image file that will be used to represent the vehicle.This icon will be displayed in the lower left-hand corner of the screen next to the health bar for the vehicle. Changing the numerical value in the ObjectTemplate.setVehicleIconPos line can be used to adjust position of the dot on the image.

The VehicleCategory is VCLand and the VehicleType is set to VTScoutCar. The setting 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 line ObjectTemplate.setMinimapIcon sets the location of the image file that will be used to represent this vehicle on the minimap that appears in the upper right-hand of the screen.

      • ?NOTE: Setting the mass below 2500 causes problems with how the vehicle will interact with the ground. The mass should not be any lower than 2500.
42Limage002.gif

Image File: 42Limage002.gif


The next section in this file is the creation of the LodObject (Lod is short for Level of Detail). This object defines 3 different ways that the vehicle will appear to a user; WillyComplex close range, WillySimple long range and Willywreck when destroyed. The order of these items is very important. The main object (Complex) is always first, followed by the low-polygon object (Simple) and ending with the wrecked version of the vehicle.

42Limage003.gif

Image File: 42Limage003.gif


The creation of the WillyComplex 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, etc. The line below each addTemplate line (ObjectTemplate.setPosition) is the position of each item in relation to the center-point of the vehicle. Seventeen lines into the creation of this object WillyPassengerPCO is added (PCO is short for Player Controllable Object). Each new PCO that is added to a vehicle is a new position for a passenger. The order of the PCOs in the main Bundle determines what position that PCO will be. In this vehicle, WillyPassengerPCO will be the second position. If we added another PCO into the WillyComplex bundle after the WillyPassengerPCO, it would be the third position.

42Limage004.gif

Image File: 42Limage004.gif


These next 4 sections set up the vehicles cockpit and how it will be seen. The willyCockpitExternal line defines what model a player will see when outside the vehicle. The willyCockpitInternal line displays a different (more detailed) model to the player who is inside the vehicle. Notice that each object (willyCockpitExternal and willyCockpitInternal) uses a different model via the ObjectTemplate.geometry line.

42Limage005.gif

Image File: 42Limage005.gif


The Camera created in the image above (WillyCamera) is the object that defines the ability to see for the driver of the vehicle. This object sets how far the player can look to the right or left as well as up and down via the setMinRotation and setMaxRotation lines. The next object created is the SeatObject. This object sets the flags for the player while he is in the vehicle. The flag c_SeatShowFullBodySoldier means that anyone looking at the vehicle will see the whole body of the player. 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 last object created in this image is the EntryPoint. 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.

Each of these objects is included in the WillyComplex bundle that we looked at earlier. Because WillyComplex is part of the PlayerControlObject Willy, all of these configurations apply to the driver of the vehicle. The next set of scripting we will look at will set up the configuration for the passenger of this vehicle.

42Limage006.gif

Image File: 42Limage006.gif


The second PlayerControlObject (PCO) is created so that a second player can enter the vehicle. If you review the Templates that are added to this PCO, you will notice that it reuses some of the objects that were used by the WillyComplex bundle. The EntryPoint and Camera objects are set with different positions that coincide with where the passenger will be sitting. The position of the passenger PCO is set in the WillyComplex bundle. The following object created is the SeatObject for the passenger. Along with the same flags that WillySeat used, this SeatObject contains settings for particular animations that will be used.

42Limage007.gif

Image File: 42Limage007.gif


Because only the front two tires on this vehicle rotate, we only need two RotationalBundle objects; one for the left tire and one for the right tire. You will note that once again you see that the MinRotation and MaxRotation are set; but also notice that there is no geometry object associated with it. This is for the same reason you dont see any objects about the rear tires yet. In the 7 thl ine of each object, a Spring template is added. The Spring objects are located in the Physics.con file and contain the geometry objects for the wheels. Because the Spring object is added as part of the RotationalBundle, the wheel geometry will become part of it as well.

42Limage008.gif

Image File: 42Limage008.gif


The portion of the Objects.con file above sets up how the players hands will connect to the steering wheel as well as how it will rotate when the player goes left or right.The main object for steering is the AnimatedBundle. Notice that the only things this object contains are a template for WillySteering and two addSkeletonIK lines. The addSkeletonIK lines use their positioning values to lock the location where the playershands will be stuck while in the vehicle. The values given attach the hands to certain locations on the steering wheel, which is added via the WillySteering template. WillySteering is a rotational bundle which contains the lodwillySteering object. The lodwillySteering LodObject acts just like the WillyLod we looked at earlier. It defines how the steeringwheel will appear to different players. The line at the bottom of this LodObject, ObjectTemplate lodSelector WillySteeringSelector, refers to the DistanceSelector object that is created at the bottom of the image. The DistanceSelector object is actually what determines which version of the steering wheel (WillyHighRSteering or WillyLowSteering) a player will see.

42Limage009.gif

Image File: 42Limage009.gif


The final part of this file contains the creation of the final two Simple Objects that were included in the LodObject lodWilly. Simple Objects usually just refer to the geometry object, in this case WillySimple refers to the low-polygon model of the vehicle hull and WillyWreck refers to the wrecked model. The WillyLodSelector that is created at the bottom of the file is the selector used for the lodWilly object. Notice that there is an additional line, LodSelectorTemplate.hasDestroyedLod 1, which tells the game engine that, in addition to the standard model and low-polygon model, there is a wrecked model which must be shown.

Now that we have reviewed how everything in the Objects.con file works, lets make the necessary changes to create a new vehicle named Jeep for BF:1942

With the exception of lines 29, 30, 31, 40 and 161 replace all instances of Willy in this file with Jeep. Close and save the objects.con file STEP 2: Physics.con Scripting Changes The Physics.con file contains objects that define the physics of the vehicle. Included in this file are the engine and wheel springs configurations.

Open the Physics.con file

42Limage010.gif

Image File: 42Limage010.gif


The Engine is what makes the vehicle move in-game. Remember that the WillyEngine was included in the Objects.con file as part of the WillyComplex bundle. This means that the driver of the vehicle will have control over the Engine. The WillyEngine has four templates added to it. Two of the templates are the front tires (setup as rotational bundles in the Objects.con file). The other two templates are the back wheels. Because the back wheels dont rotate, they are only set up as springs instead of springs inside of a rotational bundle. If you wanted to adjust the positions of the wheels in relation to the vehicle, it would be done with the setPosition lines under the addTemplate lines.

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_ETCar sets the type of engine that the vehicle will be using. In contrast, an airplane uses the c_ETPlane engine. Below the engine type, you can set the engine torque, differential, number the feel of the vehicle.

42Limage011.gif

Image File: 42Limage011.gif


The last portion of the Physics.con file is the setup of each Spring(wheel). Each of the wheels is set up with identical settings, with the exception of the wheel model. The two right side springs (WillyFrontSpringR and WillyBackSpringR) use ObjectTemplate.geometry Willy_WheelR_M1 while the 2 left side springs (WillyFrontSpringL and WillyBackSpringL) use ObjectTemplate.geometry WillyWheelL_M1. Notice that all of the springs have the ObjectTemplate.Grip line. This enables these springs (wheels) to grip the ground and use that traction to move the vehicle. The two ObjectTemplate.addTemplate lines in each spring configuration are the dust effects that will be seen when the tires are moving and touching the ground.

Now that we have reviewed how the objects in the Physics.con file work, lets make the necessary changes so that these objects can be used in our new vehicle.

Replace every instance of Willy in the file with Jeep. Close and save the Physics.con file. 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

42Limage012.gif

Image File: 42Limage012.gif


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 Willy hull, all you would need to do is place the exported model file into the StandardMesh directory and then adjust the GeometryTemplate.file Willy_Hul_M1 line to read GeometryTemplate.file newfilename.

Lets make the changes needed for this new vehicle to work in-game.

In line 1, replace Willy with Jeep. In every line that begins with GeometryTemplate.create, replace Willy with Jeep. Close and save the Geometries.con file. STEP 4: Network.con Scripting Changes The last file we will need to make changes to isthe Network.con file.

Open the Network.con file

42Limage013.gif

Image File: 42Limage013.gif


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 in those files in lines that begin with ObjectTemplate.setNetworkableInfo.We need to make the appropriate changes in this file to make sure

Replace Willy in every line with Jeep. Close and save the Network.con file. 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 weapons main folder.BF: 1942 has three different settings for sound.You can choose 11 khz(Low), 22 khz (Medium) or 44 khz (High). The WillyEngine.ssc file is a text file and is the central sound file that includes all the settings from other three sound files for the vehicles engine. The three sound files that contain the settings are in the High, Mid and Low directories.

Enter the Sounds directory.

42Limage014.gif

Image File: 42Limage014.gif


Rename the file WillyEngine.ssc to JeepEngine.ssc. Open the JeepEngine.ssc file.

42Limage015.gif

Image File: 42Limage015.gif


Change every instance of Willy to Jeep. Close and save the JeepEngine.ssc file. Enter the High directory. Rename the file WillyEngine.ssc to JeepEngine.ssc. Leave this directory. Enter the Low directory. Rename the file WillyEngine.ssc to JeepEngine.ssc. Leave this directory. Enter the Mid directory. Rename the file WillyEngine.ssc to JeepEngine.ssc. Leave this directory and return to the main Jeep directory. Rename the file WillyEngine.ssc to JeepEngine.ssc. The sound configuration changes have been completed. STEP 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.).

Enter the AI directory. Open the Objects.con file .

42Limage016.gif

Image File: 42Limage016.gif


Replace every instance of Willy with Jeep. Close and save the Objects.con file. Now that all off the proper changes have been made, this new vehicle named Jeep 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.

This tutorial has shown you the intricacies of a BF:1942 vehicle. A basic vehicle in BF:1942 only requires the following items: a Player Controllable Object, an Engine, wheels (knows as Springs in this scripting language), a Seat, a Camera (the drivers viewpoint while operating the vehicle) and an Entry Point (how a player will enter the vehicle). Items like the Steering object are not necessary but add the realism to a vehicle that players want to see.

STEP 7: Examples With the knowledge you have gained, lets make a few changes as an example of what you can do with this scripting language. As our first change, lets add an extra passenger position into the Jeep. We will place this new position in the back seat of the Jeep.

42Limage17.gif

Image File: 42Limage17.gif


Open the "Objects.con" file. Locate the "JeepComplex" object. Add the following lines right before the line with "JeepEngine" in it: 1st line - "ObjectTemplate.addTemplate JeepPassengerPCO2"; 2nd line - "ObjectTemplate.setPosition -0.30/.45/-1.15".

Find and copy the "JeepPassengerPCO" object. You should be copying twenty-eight lines in total. Paste the data underneath the "JeepPassengerPCO" object. Change "JeepPassengerPCO" to "JeepPassengerPCO2" in lines 1 and 2 of the new object. Change the line "ObjectTemplate.aiTemplate JeepPassenger" to "ObjectTemplate.aiTemplate JeepPassengerPCO2". In the line that begins with "ObjectTemplate.setVehicleIconPos", set the values to "30/70". Close and save the "Objects.con" file.

42Limage18.gif

Image File: 42Limage18.gif


We need to add the proper Artificial Intelligence so that bots will utilize the new position.

Enter the AI directory. Open the "Objects.con" file. Locate the line "aiTemplate.create JeepPassenger". Copy the eleven lines that make-up "JeepPassenger" and paste them below the original object. In the new object, rename "JeepPassenger" to "JeepPassengerPCO2".

42Limage19.gif

Image File: 42Limage19.gif


Close and save the "Objects.con" file. Now that we've added this lines, repack the "Objects.rfa" using "winRFA.exe" from the Mod Development Tool. Once you start a game and get into the "Jeep", you will notice that you are able to switch to a third position. The image below is what you will see.

42Limage20.gif

Image File: 42Limage20.gif


Let make another change to the "Jeep".

Open the "Physics.con" file. Examine the "WillyEngine" object. There is a section containing the "ObjectTemplate.addTemplate" lines (the section is surrounded by "rem----" lines.

Add the following four lines to the bottom of the "ObjectTemplate.addTemplate" section: 1st - "ObjectTemplate.addTemplate JeepBackSpringR"; 2nd - "ObjectTemplate.setPosition 0.79/-0.472/1.21";3rd - "ObjectTemplate.addTemplate JeepBackSpringL"; 4th - "ObjectTemplate.setPosition -0.79/-0.472/-1.21".

42Limage21.gif

Image File: 42Limage21.gif


By adding these lines, we are adding a second set of rear wheels. The "setPosition" lines position the new tires right next to the existing tires to make the "Jeep" look like it has an additional set of tires for off-roading.

42Limage22.gif

Image File: 42Limage22.gif

Advertisement