HOW TO ADD AN AIR VEHICLE INTO BATTLEFIELD: 1942

This tutorial will walk you through the necessary steps to add a new air vehicle into Battlefield: 1942 (BF: 1942). You will learn how to set up a new air vehicle, configure the inner workings of the vehicle and place it in-game. The tutorial will show how to add a new air vehicle named “F16” into the game based on the existing “Zero” air vehicle which is already in BF: 1942. As a result of what you will learn in this tutorial, you will be able to modify air vehicle files in any way to add a limitless amount of new air 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.

Within the “F16” directory, there are five files and two directories. The five files are “Objects.con”, “Physics.con”, “Network.con”, “Weapons.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 Zero”, begins the creation of a player-controllable object named “Zero”. 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 “Zero” will have and when they will occur. For example, the line “ObjectTemplate.addArmorEffect 65 em_ZeroDamage 0/0.202/2” says that when the “Zero” drops to 65 hitpointsthe “em_ZeroDamage” special effect (contained in the “Objects\Effects\” folder) will occur at position “0/0.202/2”.

The line “ObjectTemplate.addTemplate lodZero” adds a “Level of Detail” object that will contain the rest of the vehicle. 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 “VCAir” and the “VehicleType” is set to “VTFighter”. The settings of these lines determine what controls the vehicle will use. This vehicle will utilize the controls that were configured in the “Air 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.

The next section in this file is the creation of the “LodObject”. This object defines three different ways that the vehicle will appear to a user; ZeroComplex – close range, ZeroSimple– long range and Zerowreck – 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.

The creation of the “ZeroComplex” 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. The engine, flaps, wings, guns and bombs are only a few of the things that are added into this object so that the driver of the vehicle will have control over all of them.

These next five sections set up the vehicle’s cockpit and how it will be seen. “lodZeroCockpit” is the object that contains both the internal and external view of the cockpit as well as the “lodSelector” object that decides which cockpit will be seen by each player. The “ZeroCockpitExternal” line defines what model a player will see when outside the vehicle and the “ ZeroCockpitInternal” line displays a different (more detailed) model to the player who is inside the vehicle. Notice that each object (“ZeroCockpitExternal” and “ZeroCockpitInternal”) uses a different model via the “ObjectTemplate.geometry” line.Finally, the “ZeroCockpitSelector” is the object that decides which cockpit view will be seen by which player.

The Camera created in the image above (“ZeroCamera”) 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 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. The last object created is the SeatObject. This object sets the flags for the player while he is in the vehicle. The flag “c_SeatShowHalfBodySoldier” means that anyone looking at the vehicle will see half of the body of the player. If the flag was set as “c_SeatShowFullBodySoldier”, the whole body would appear.

Each of these objects is included in the “ZeroComplex” bundle that we looked at earlier.Because “ZeroComplex” is part of the “PlayerControlObject Zero”, all of these configurations apply to the driver of the vehicle.

The “lodZeroPropeller” is another “LOD” object that contains two ways to view the propeller (static and blurred) and includes the “lodSelector” which decides when to show each particular view. As you will see later in the tutorial, the “lodZeroPropeller” object is added into the engine of the vehicle so that the movement f the propeller will be dependant on the speed of the engine.

There are two “SimpleObject” creations which contain the geometry for the two views of the propeller (static and blurred). The final object created is the “ZeroPropSelector”. This is the “Selector” which will actually make the decision on which propeller to show at any given time.

The next two objects created are “LandingGear” objects for the right and left side of the air vehicle. Both objects have a model associated with them (via the “ObjectTemplate.geometry” line) as well as the “Min” rotation(right gear) and “Max” rotation (left gear) values set.

***NOTE: In each landing gear object, a “ZeroWheel” object is added. We will review these objects when we review the “Physics.con” file.

The line “ObjectTemplate.setGearUpHeight” sets how far off the ground the air vehicle must be before the landing gear will be raised. In addition, the “ObjectTemplate.setGearDownEngineInput” defines how the slow the engine must be going before the gear will be lowered.

Thelast “LandingGear” object is for the back wheel. The setup is essentially the same as the other wheels, with the exception that the back wheel has both a rotational bundle and a spring whereas the front two wheels only have springs. Additionally, the line “ObjectTemplate.setInputToYaw c_PIYaw” indicates that the movement of the back wheel (used to turn the air vehicle) will be controlled by whatever input device is bound to the “Yaw” controls in the “Air Controls” menu of BF:1942.

The final part of this file contains the creation of the final two Simple Objects that were included in the LodObject “lodZero”. Simple Objects usually just refer to the geometry object, in this case “ZeroSimple” refers to the low-polygon model of the vehicle hull and “ZeroWreck” refers to the wrecked model. The “ZeroLodSelector” that is created at the bottom of the file is the selector used for the “lodZero” 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 “F16” for BF:1942.

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, wheels, flaps and rudder configurations.

The Engine is what makes the vehicle move in-game. Remember that the “ZeroEngine” was included in the “Objects.con” file as part of the “ZeroComplex” bundle. This means that the driver of the vehicle will have control over the Engine. There are four templates added to the engine object: “lodZeroPropeller”, “ZeroLandingGearLeft”, “ZeroLandingGearRight” and “ZeroLandingGearBack”.

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_ETPlane” sets the type of engine that the vehicle will be using. In contrast, a jeep uses the “c_ETCar” engine. Below the engine type, you can set the engine torque, differential, number of gears, and the gear ratio. These items can be changed at anytime to adjust the feel of the vehicle.

***NOTE: If the air vehicle drops below a certain speed, the propeller will switch back to its static state and appear to not be moving. This effect is handled via the “ObjectTemplate.setNoPropellerEffectAtSpeed 70” line.

The next three objects are the springs that are included in the “ZeroLandingGearRight”, “ZeroLandingGearLeft” and “ZeroLandingGearBack” objects we reviewed in the “Objects.con” file. Each of the springs have an “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 special effects that will be seen when the tires have contact with either water or the ground.

This image is an example of the rest of the “>Physics.con” file. The remainder of the file configures the flaps and rudders used to maneuver the air vehicle. Each of the “Wing” objects uses a model (“ObjectTemplate.geometry” line), sets the “Min” and “Max” rotation for the model and sets how much lift one of these flaps could cause to the vehicle. The lift power is handled via the “ObjectTemplate.setWingLife” and “ObjectTemplate.setFlapLift” lines. The values in these lines can be adjusted to completely change the way this vehicle handles while in the air.

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.

Note that each object starts with the line “ GeometryTemplate.create StandardMesh”. >StandardMesh is the object that contains the model 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 body in place of the standard Zero body, place the new exported model file into the “StandardMesh” directory and then adjust the “GeometryTemplate.file zero_fus_m1” line to read “GeometryTemplate.file newfilename”.

Let’s make the changes needed for this new vehicle to work in-game.

STEP 4: Network.con Scripting Changes

The last file we will need to make changes to 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 in those 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: Weapons.con Scripting Changes

The “Weapons.con” file contains all of the weapon configurations that the “Zero” vehicle uses.

The second line creates the weapon with the “ObjectTemplate.create Firearms” line.The “ObjectTemplate.visibleBarrelTemplate e_MuzzSG44” defines the muzzle flash that will be seen every time the machine gun is fired. ObjectTemplate.projectile ZeroProjectile” defines the type of projectile (bullet) that this weapon will fire and the “ObjectTemplate.projectilePosition” line defines the position at which the projectile will be created when fired. The weapon has a maximum of 900 bullets that it can hold (defined via “magSize”) and the bullets are fired at a velocity of “400” (defined via “velocity”).The “ObjectTemplate.roundofFire” line defines how quickly the weapon can fire multiple shots. The lower the value, the slower the rate of fire. Because this air vehicle has a machine gun mounted on both sides of the fuselage, we use the “ObjectTemplate.addFireArmsPosition” line to position more than one instance of this weapon on the plane. This way, you can have more than one instance but both will be fired by the same controls at the same time.

The next object created is the projectile object. This sets up the configuration of the projectile (bullet) that will be fired by the air vehicle’s machine gun. The projectile needs to have Mobile, Collision and Response physics so that it will be able to move and interact when it collides with a target. These values are set to “1” (“0” is off, “1” is on). The “ ObjectTemplate.timeToLive ” line defines how long this projectile will last before it will disappear. By setting a time limit on the projectile’s life, it prevents projectiles from staying in the game perpetually and affecting the games performance. The material setting defines how this projectile will damage other types of material. For example, this type of projectile would have more of an effect on a body versus a tank. ObjectTemplate.stopAtEndEffect 1” means that the projectile will cease to exist once it has collided with something and caused it’s damage.

The “ZeroBombDummy” firearm is the second firearm that this vehicle has. It uses the generic “FighterBomb” projectile template that many of the BF:1942 planes share (The configuration for this projectile can be found in the “\Objects\Vehicles\Common\Weapons.con” file). Notice that this firearm configuration uses a lot of the same types of settings as the “ZeroGuns” firearms we looked at above. This bomb firearm is fired using the “AltFire” button. This is defined within the “ObjectTemplate.setInputFire c_PIAltFire” line.

STEP 6: 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 “Sounds” directory contains eight files.

Four of the files are sound configurations for the engine (“ZeroEngine”, “EngineLow”, “EngineMedium”, “EngineHigh”) and four files are sound configurations for the machine gun(“ZeroMG”, “FireLow”, “FireMedium”, “FireHigh”). Within each set of four files, the three files containing the words “Low”, “Medium” and “High” correspond to the settings 11 khz, 22 khzand 44 khz settings mentioned above.

The fourth file is the central sound file that includes all the settings from the other three sound files. The image shows that the “ZeroEngine.ssc” fileincludes all of the other engine files.

STEP 7: AI Configuration

The final step is to configure the Artificial Intelligence (AI). The AI for this vehicle is contained in the AI directory in the “Objects.con” and “Weapons.con” files. These files contain AI configurations for how bots will drive the vehicle, fire the weapons, react to the opposing team, etc. Enter the “AI” directory.

Now that all off the proper changes have been made, this new air vehicle named “F16” 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 the intricacies of a BF:1942 air vehicle. A basic air vehicle in BF :1942 only requires the following items: a Player Controllable Object, an Engine, wheels (springs), a Seat, a Camera (the drivers viewpoint while operating the vehicle) and an Entry Point (how a player will enter the vehicle). Additional items that can be added increase the realism of a vehicle and make it more fun to operate.

STEP 8: Examples

Now that we have named our new air vehicle “F16”, we should make it more like the real-life “F16”. One major things we need to change is the speed of this vehicle. The “F16” is much faster than any original BF:1942 plane, so let’s change our new vehicle appropriately.

Changing the speed involves two lines within the “F16Engine” file. The first line we need to change, “ ObjectTemplate.setMaxSpeed ”, sets the maximum speed that this vehicle can travel. The second line we need to change, “ObjectTemplate.setTorque”, defines how fast the vehicle will accelerate.

***NOTE: These changes will increase how fast the vehicle can move on both the X and Z axis. These values are based on the “X/Y/Z” axis.

Repack the “Objects.rfa” file and try out your vehicle’s new speed. Once you have tested these changes, you can go back into this file to make additional changes to adjust the vehicle’s handling to your preferences.

Now let’s equip this “F16” with the proper weapon. We will replace the bullets that the plane fires with rockets and slow down the rate of fire. The rocket we will fire will be the “BazookaProjectile” that the “Bazooka” hand weapon uses.

***NOTE: The “BazookaProjectile” we are using as our rocket projectile can be found in “Objects\HandWeapons\Common\Weapons.con”.

***NOTE: Remember that the “ObjectTemplate.roundofFire” value defines how fast the weapon will fire; the higher the value, the faster the rate of fire.

Since we are adding a new type of weapon to the plane, lets adjust the rotation of the weapon so that the rockets fire straight at their target. To do this, we need to adjust the “ObjectTemplate.addFireArmsPosition” lines.

***NOTE: The numerical values represent positional and rotational coordinates.For example, the first set of numbers (“1.99/-0.21/1.38”) dictate the position on the X/Y/Z axis. The second set of numbers (“-1.3/0/0”) dictate the rotation on the X/Y/Z axis.

Repack the “Objects.rfa” file and start the game to see your changes in action.