THE BATTLEFIELD: 1942 GAME STRUCTURE

Updated: October 11th 2003

This document outlines the directory structure of the unpacked RFA files from BF 1942, files found in them, and the properties used in the various .con and .inc scripting files. A few relevant MDT programs and their results are presented along the way.

To understand how to modify the game, you need to examine the .con and .inc files that have been made by DICE and others. Step one is to unpack the relevant RFA files in the area C:\Program Files\EA GAMES\Battlefield 1942\Mods. This is where the original game and expansion pack files are stored, along with any other total conversion mods such as Desert Combat or Eve of Destruction. In each subdirectory, such as bf1942, is the Archives directory, where all *.rfa files are stored. Each RFA file is a collection of data files for the game, something like a ZIP file.

Here are what the various RFA files in the Archives directory contain:

There are a number of additional RFAs with a "_00#.rfa" suffix that are updates of these original files, bringing in newer versions. For example, in the bf1942\Archives\bf1942\levels directory, where the original battles are stored, in addition to the file Berlin.rfa are the update files Berlin_001.rfa and berlin_003.rfa. You can, in fact, use this mechanism to make mini-mods of the program; you simply create your own update RFA file with the files you want to change and put it in the proper directory. However, such updates will work only in single-player games, as anti-cheat checking in multiplayer will rightfully flag such additions as non-standard. Still, this mechanism can be useful for testing small additions without having to repack the entire RFA file.

To unpack an RFA, use the MDT's winRFA.exe program, at C:\Program Files\EA GAMES\Battlefield 1942\Mod Development Toolkit\Tools\RFA Tools\winRFA.exe and open up the .rfa file you wish to extract. If you wish to unpack many RFAs, you might prefer using \Mod Development Toolkit\Tools\RFA Tools\Console\rfaUnpack.exe program, which runs from the command line. If you want to unpack all the RFAs in the basic BF1942 game and its two expansion packs, use the unpack_all.bat file in the CON Analysis program package. This file simply runs rfaUnpack.exe, which it assumes is in the directory c:\bin\, and puts the files in the directory c:\temp\bf1942extract. Edit this file and replace these paths with whatever you need.

A listing of all files found in the original game and the two expansion packs' RFA is available in the bf1942files.txt file in the Battlefield Reports archive.

File types in RFA files

Most files inside an RFA file have a suffix such as .con or .dds to identify them. What follows is a brief overview of the various file types, ordered by their suffix.

 

RFA CON File Structures

Including the contents of the two expansion packs, there are well over 4000 .con (and 7 .inc) files in the game Battlefield 1942. These text files are what define the various objects, victory conditions, battlefields, and much else in the game.

There are many facets of making a mod, such as creating new maps, new skins and skeletons for new objects, new sounds, or other new content for menus, etc. A key element is editing the .con files so that the game uses these new elements. As such, we will give a brief overview of the directory structure of the three major RFA file types containing .con files: Objects.rfa, Game.rfa, and the battle level .rfa files. We'll then give an overview of the types and contents of .con files.

Objects.rfa

This file defines the various objects (soldiers, vehicles, weapons, buildings, etc) and their behaviors. Directories are in bold, a directory's typical file contents is listed on the same line:

 

 

 

 

 

 

 

 

 

 

Level.rfa

These are in the Bf1942\levels subdirectory of the game, and define the battles themselves, e.g. Battle_of_the_Bulge.rfa. There are often more than one RFA file with similar names, e.g. Battleaxe.rfa, Battleaxe_000.rfa, Battleaxe_002.rfa. The "_00*.rfa" files are later additions, i.e. they include new files which replace the older files in the main Battleaxe.rfa file. Here is the directory structure for a typical level (El_Alamein, in this case). Directories are shown in bold:

 

Game.rfa

This contains files that contain global settings for all the battles, unpacked to the directory BF1942\Game. Subdirectories are at the end in bold.

CON File Types

Of the over 4000 .con files in the game, these have 248 different names. Many of the different names can be grouped together into similar types of .con files, e.g. there are many different damage files in Bf1942/Game/damage_system. Also, many .con files have the same name, e.g. Objects.con (1065 of these), but with different purposes depending on their location in the directory tree. That said, there are a few different broad categories these files fall into: object definition, level (battle) creation, artificial intelligence (bot) actions, and user settable. What follows is an overview of some of the most important files relevant to each category.

Object Related - for defining types of objects, e.g. a type of tank, vs. placing a specific tank in a battle.

Level Creation Related - having to do with how battles work. Some are specific to a level, others are files that affect all battles.

Artificial Intelligence Related - these determine the behavior of the bots.

User Settable - these are files not in an RFA file, and are settable by the player. Many are profile files for joystick control, etc. One worth mentioning is:

CON File Contents

Most .con (and .inc) files consist mainly of settings for class properties, e.g.
  rem *** Yamato ***
  ObjectTemplate.create PlayerControlObject Yamato
  ObjectTemplate.aiTemplate YamatoAI
  ObjectTemplate.setNetworkableInfo YamatoBodyInfo
  ObjectTemplate.saveInSeparateFile 1
  objectTemplate.cullRadiusScale 5
  ObjectTemplate.hasMobilePhysics 1
In this example, the class ObjectTemplate has a number of properties, set one after the other. Note that capitalization is unimportant; "objecttemplate.cullradiusscale" is the same as "ObjectTemplate.CullRadiusScale" as far as the program is concerned. In most cases physical values are in MKS (meters/kilograms/seconds) units.

These files can all be edited by a simple text editor.

Every .con file consists of class property definitions and keywords. These keywords are used for various purposes.

Alias - defines a shortcut for a longer console command.
BeginRem - begins a comment, like the C language's "/*".
Echo - used in addbot.con addunspawnedbot.con aidefault.con soldier2.con spawnbot.con spawnsoldier.con
EndRem - ends a comment, like the C language's "*/".
If/Else/Endif - this is commonly used in "if v_arg1 == host", which checks if the computer is hosting the game or is joining the game.
Include - a way to include an .inc file, essentially like the C language's "#include".
Rem - a comment line, like the C++ language's "//".
Run - a way to include a .con file, essentially, like the C++ language's "#include".
Var - variables, used in the AI system for assigning attributes to a bot.

CON Analysis Program

There are over 1000 class properties that can be set. This document is an overview of the overall structure of the file system, so we will not detail each of these here. Other documents deal with what the various classes and properties do. One of the best ways to create a new object is to start with a similar existing object and modify it. Even if undocumented, many of the properties can be determined by examination and experimentation.

I have made a tool that will give you some sense of what a .con file property is about, if you cannot find any relevant documentation about it. The results of running this analysis on all the standard BF942 files and the two expansion packs is available in the bf1942conreport.txt file in the Battlefield Reports archive.

The perl script conanalysis.pl script in the CON Analysis program package runs through all the .con and .inc files in a directory and its subdirectories and analyzes the keywords and properties found in each.

A ".pl" file is a Perl script, a text file that is run as a program when running Perl. Perl is a nice language for various system and analysis tasks, as the Perl language is ideal for performing system calls and text manipulation. In Perl you simply write programs in a text editor and immediately run them from a command line; there's no compile text or intermediate files to worry about. To use Perl, you first need to install a Perl distribution, if you do not have one. ActiveState's Perl distribution is free and high-quality.

To run the conanalysis.pl script, you need to do a few things:

You're now ready to run the perl script. To analyze a set of files, type:
    perl c:\perlprogs\conanalysis.pl > myconreport.txt
The file myconreport.txt contains the analysis. Note that this analysis can be done on any modification of the game, not just basic BF 1942 files. Doing this can be useful for getting a sense of what the designers did to their various weapons, etc.

You can also pick a specific directory:

    perl c:\perlprogs\conanalysis.pl c:\bf1942extract\objects\HandWeapons > hwreport.txt
which will then analyze only these particular .con files.

Analysis Output

The output from this program is in three parts. In the first part, all of the values used for each property are shown in alphabetical order, by class. For example:
  ObjectTemplate.setSpawnRotation 1: x/y/z
  ObjectTemplate.setSpeedDev 1: 0.6 0.8 1.1 1.5 1.8 2.2 2.25 2.3
                             2: 0.2 0.4 0.5
                             3: 0.1 0.2 0.4 0.5
                             4: 0.1
  ObjectTemplate.setStartOnEffects 1: 0 1
  ObjectTemplate.setStrength 1: 0 00 14 15 16 17.5 18 19 20 24 25 28 30 36 4
The "1:" means that the first argument for this property, the "2:" means the second argument, etc. So for setSpeedDev the first argument ranges from 0.6 to 2.3, the second argument from 0.2 to 0.5, etc. The "x/y/z" notation means that the argument has a wide range of 3 values, separated by "/".

In the second section of the analysis, the names of files where each property is found are listed, e.g.:

  ObjectTemplate.fireingForce       weapons.con (objects/Vehicles)
  ObjectTemplate.fireOnce           objects.con weapons.con (objects/Vehicles objects/HandWeapons Bf1942/Levels)
  ObjectTemplate.flagTemplate       objects.con (objects/Items)
So fireOnce is found in both Objects.con and Weapons.con files. The values in parentheses are the subdirectories (up to two levels deep) in which these files can be found. For example, fireingForce is actually found in 25 different .con files, but these files are all somewhere in or below the objects/Vehicles directory.

Finally, each different con file is listed, alphabetically, along with what properties are found inside it. Each property is categorized as always being present in the .con file named (and so is likely to be required), or is optional. Here is an example:

  File ai.con (31 occurrences)

  Required tokens for file
  ------------------------

  Used once and only once in each file:
  ai.init
  ai.saiEnable
  ai.saiMapXDimension
  ai.saiMapYDimension
  aiSettings.setWorldMapSize

  Always used multiple times in each file:
  if

  Optional tokens for file
  ------------------------

  Sometimes used once in each file:
  ai.addSAIStrategy
  ai.botStatisticUpdateSpeed
  ai.showBotStats
  ...
This concludes the overview, and I hope it's been useful.