Ai TRANSPLANT
sample files
Welcome to Part One of the Ai .con Editing tutorial, I will be your host today and my aim is to show you how to create an addon, that will add Co-op & Single Player support to a Battlefield 1942 level.
This part of the tutorial will be brief and short on details, consider it a guided tour through the scripts, other files & folder structure required to add Ai to a Level.
The main task is to get an Ai successfully running first, then we will proceed to customise & further investigate the Ai in the further parts of the Tutorial series.
There are many things that will not be covered in this Tutorial.
Firstly, this tutorial will only cover Land based maps that only use Cars, Infantry, Tanks & Aircraft.
LANDING CRAFT andBOATS (ships) will NOT be covered.
Also, on occasions you may be required to do tasks that requires other software, such as RFA Tools, Image Editors and Map Editors. If you are doing this tutorial, you should already know how to do these tasks.It is not within the scope of this tutorial to teach you other software unless it is a tool or technique specific to Ai Scripting.
With this in mind, lets go botty ; )
--------------------------------------------------------------------------------
The quickest way to get an Ai in to a conquest only map, is to borrow another one. For this we can use another map, grab the required files and add them to ours.
I have chosen Kursk to be our donor as it is a simple map, and has a simple set of strategies that are very general purpose. This will allow the transplant to happen with a minimum of fuss, and will lay the foundations for us to build the Ai to suit a more complicated map.
Aberdeen and Kursk are what i am going to call a "Mirrored" maps, as they have the same basic layout of Bases & Control Points regardless of which Side you are playing. Battleaxe and Midway are two other examples of Mirrored maps.
When choosing a map to pinch an Ai from, i highly recommend that you use Kursk or the Ai produced from the tutorials as your donor as there simplicity allows for easy modification to suit another map, where as many other Dice maps are more complex, subtle and the inner workings are not as easily understood.
If you need to use other maps,look for one that has similar gameplay to your own map. Eg: Battle of the Bulge could suitable where one side starts with a base only and attacks through several Control Points before pushing the Enemy Base & Gazala could be useful when each side starts with a base, and fight for the Control Points in between.
But ... by the end of the Tutorial Series, it is my hope that you will be able to write your own Ai
--------------------------------------------------------------------------------
1.1 – Create the Addon Folder: First, make a folder to create your Co-op Addon in.
Rather than dump all the Ai files in with a complete map, we shall keep them separate for the moment. This allows you to create an Addon for a map, rather than having to compile it into the main archive.
If it's your own map, it is still a good idea to keep it separate as compiling the addon will be much quicker than compiling your full map, textures & all, as their will be lots of adjustments to the Ai as you “tune” it
For this first step, using the desktop is quite handy.
--------------------------------------------------------------------------------
1.2 - Extract Source Maps: We need access to files within the Maps we will be working with.
Extract the following .RFA files to a handy location, these are the original maps and their revision files.
Aberdeen.rfa
Aberdeen_003.rfa
Kursk.rfa
Kursk_000.rfa
Kursk_003.rfa
1.3 - Copying Files: Open the folder that you extracted Kursk into.
Select the following files, and COPY them to the Folder you created in 1.1

--------------------------------------------------------------------------------
1.4 - First Round Editing: Lets go through the files you just copied.
Open your Addon's folder, and we'll have a tour through each file and adjust a few basic settings.
--------------------------------------------------------------------------------
1.4.1 - AI.CON is the main file that details the Ai's setup, starts the Strategic Ai (SAi - BF's Ai “engine”) and calls the other parts of the Ai's files into use. Most of the complex settings in this file are unknown at his time, so its lucky that there are only few items here that require our attention.
Before we start making changes, the first thing i would like you to do, is add a header to the top of this file. Something like this ...
rem *** ABERDEEN ***
rem *** Co-op Addon Tutorial ***
rem *** yourname ***
You can include any details you like, the main point of this is to label the file with the map's name.
Trust me on this one, it will save a lot of confusion when you have a dozen .CON files open.
Highlight the block of text you just typed in, and COPY it to the clipboard
Next, we need to check the worldsize setting, look for ...
aiSettings.setWorldMapSize 1024 1024
This tells the SAi the resolution of the Pathmaps, which in Kursk are 1024 x 1024 pixels.
Lucky for us, Aberdeen is the same size as Kursk, so we don't need to change this, but keep in mind for other maps, this size could be different. A 2048 worldsize will require pathmaps that are 2048 x 2048 pixels.
!!! TIP : Worldsize !!!
You can check your worldsize in INIT / TERRAIN.CON
GeometryTemplate.worldSize 1024
Scroll down a little further, look for
game.showAIstats 0
and Change the value to 1, this will enable displays within the game that will allow us to see detailed statistics related to the SAi, Bots, Strategies and Strategic Areas

This does generate a awful amount of information, most of which we will not need. Each Bot's individual Stats go beyond our requirements until we are fine tuning or troubleshooting, and can be disabled by adding the following statement. This will also reduce your CPU load by a decent amount.
ai.showBotStats 0

Thats all the changes we are making for now, but before we Save & Close the file, scroll down to the bottom and have a look at ...
ai.addSAIStrategy 1 breakOut
ai.addSAIStrategy 1 holdAndCamp
ai.addSAIStrategy 1 single
ai.addSAIStrategy 1 double
ai.addSAIStrategy 2 breakOut
ai.addSAIStrategy 2 holdAndCamp
ai.addSAIStrategy 2 single
ai.addSAIStrategy 2 double
This is a list of Strategies that are available for each side to use.
Notice that both Side 1 & Side 2 have the same Strategies ... this is part of what i refer to as being "Mirrored"
Save your file, close it, and lets move on
--------------------------------------------------------------------------------
1.4.2 - AIpathFinding.con manages settings for the Bot's pathmapping, and calls the pathmaps that will be used into action.
Again, the first thing i want you to do is add your header. If the text you copied in the previous step is still in the clipboard, PASTE it down, or type it in ... again.
This file can enable a tool that will allow us to test the pathmapping in game, and will display some pathmapping related information.
rem game.aiPathfindingDebuggingActive 1
Remove the rem statement. When in game, you can “shoot” two points and a test will be run to determine if the Ai can find a valid path for a bot to follow, and will draw a valid path with a purple line.

This tool is rarely needed, and can even become annoying. You can turned off again at anytime, by “rem”ing the statement out, or changing the value to 0.
Also, there is a problem that occasionally pops-up in this file to haunt people. In some Dice levels the word “infantry” is mis-spelled as “infantery.” If you stuck to my suggestion of using Kursk, or the Tutorial Ai as templates, you will probably never encounter this problem, however, check it and make the correction if required.
We don't need to make any other changes to this file, so Save & Close the file
--------------------------------------------------------------------------------
1.4.3 - Ai \ Strategies.con contains the code for the Strategies that we're listed Ai.con. Strategies are the “plans” of attack and/or defense that will be used by the Ai throughout a game. Strategies will be further detailed in Part 3.
yet again, the first thing i want you to do is add your header.
Now look at the four blocks of text in this file, notice they are the Four Strategies that we're listed in AI.CON
in Ai.con
ai.addSAIStrategy 1 breakOut
references to ... in Strategies.con
aiStrategy.createStrategy breakOut
Before we go, have a look at the code in a strategy ... keep this line in your mind.
aiStrategy.setPrerequisite breakOutPrereq
No other changes to this file, so Save & Close.
--------------------------------------------------------------------------------
1.4.4 - Ai \ prerequisites.con is part of the Ai's decision making process and will be covered in detail in Part 3
Still yet again, the first thing i want you to do is add your header.
Again in this file we have four blocks of text, if you look at this line ...
aiStrategy.createPrerequisite breakOutPrereq
Notice that is a reference to the Strategy we just looked at ...
Something to look at before we move on ...
aiStrategy.addCondition noFriendlyCPCond 10.0
Save & Close the file.
--------------------------------------------------------------------------------
1.4.5 - Ai \ conditions.con is the main part of the Ai's decision making process and is also covered in Part 3 1.4.5 - Ai \ conditions.con is the main part of the Ai's decision making process and is also covered in Part 3
You guessed it, add your header first.
This file isn't broken up nicely for us, but have a look around & you'll find this line ...
aiStrategy.createConstantCondition noFriendlyCPCond Crisp Equal Friendly ControlPoint 0
Once again, the reference between Conditions & a Prerestiquite is there
Save & close the file
--------------------------------------------------------------------------------
1.4.6 - Ai \ StrategicAreas.con describes areas of the map that have strategic value, their purpose, location and information on which areas link to another.
Paste your header in, Save & Close the file, we're not even touching this for the moment and will be covered in Part 2
--------------------------------------------------------------------------------
1.4.7 - "Gametype" .cons
Open Coop.con, and add your header.
All we need to with this file, is make the settings the same to Aberdeen in Conquest.
Open Aberdeen's Conquest.con, and look at the following settings ...
Game.setNumberOfTickets 1 100
Game.setNumberOfTickets 2 100
Game.setTicketLostPerMin 1 7
Game.setTicketLostPerMin 2 7
.setNumberOfTickets determines how many tickets a side starts with in a 100% Ticket game.
.setTicketLostPerMin controls the rate of ticket loss when a side is “bleeding”
The settings for Kursk are different, so change them to match or to your own preference.
You also need to open Singleplayerallies.con & Singleplayeraxis.con and make similar changes.
Next ... browse into the Gametypes folder, and delete all the old Kursk files. Go back and select Coop.con, COPY it and PASTE into the Gametypes folder. Whenever you change Coop.con in the root directory of your map, you must duplicate the file or changes to Coop.con in the Gametypes folder
--------------------------------------------------------------------------------
1.4.8 - Pathfinding Folder will store the pathmaps for the map.
Copy the Pathmaps you created for your map to this Folder.
If you have no idea what pathmaps are i would suggest that you at least complete Pathmapping Tutorial One first.
--------------------------------------------------------------------------------
1.4.9 - Singleplayer Folder much like the conquest folder, this folder stores the files containing the layout & detailed information for the Object Spawns, Soldier Spawns, and Control points.
Two extra files required for the singleplayer folder are; skirmish.con, & bots.con which reference to the Bot names within the Battlefield's .RFAs.
Now, browse to the extracted Aberdeen Conquest folder, COPY the contents and PASTE them into your Addon's Singleplayer folder. This will overwrite the old Kursk files, with Aberdeen's Conquest layout.
If you have made any adjustments to this layout in the Pathing Tutorial, or at anytime for that matter, now is as good as ever to add the updated files.
--------------------------------------------------------------------------------
1.4.10 - RFA Creation
When you create your .RFA we want to take advantage of the update system the game supports.
Aberdeen already has one update file, Aberdeen_003.rfa, we want to make sure our file supersedes all previous updates, and allows room for more updates, so use the filename Aberdeen_010.rfa
Create the .RFA and we are now ready for our first test run.
--------------------------------------------------------------------------------
1.4.11 - First Test
Start Battlefield, Create a Multiplayer game, select CO-OP and add Operation Aberdeen to the list
These are the settings I use for testing:
|
Players:
|
37
|
|
Time Limit:
|
0
|
|
NR Rounds:
|
100
|
|
Tickets:
|
100%
|
|
|
|
|
|
10
|
|
|
85%
|
|
|
25%
|
These settings will provide 18 bots on each side, and allows you (one human player) to be in the game on the Allied Side, without throwing the team balance out. Once the game has started you can swap sides and there will be still 18 bots on each side.
Having no time limit is useful, as if you do set a limit, by “Murphy's law,” just as something important is about to happen ... the round will end. Also you can always leave the game running overnight to see how the balance is over multiple rounds.
Start the game, and when it's loaded you should see this.

If you see your desktop, you have missed something ...
Rather than waste a bucket load of time trying to find the error, Delete it, and start again. It doesn't take long, and it's good practice anyway ; )
!!! TIP : Free Camera Mode !!!
Have a look around the level
Drop the console by pressing the tilde key [~] and type ...
freecam 1
this is the short version or “Alias” for
game.enablefreecamera
You may even want to shorten the “Alias” for this command as you will be using it often
Open the file:
<Your Battlefield Folder> / MODS / bf1942 / Settings / AliasedCommands.con
and remove “free” from the line
alias freecam game.enablefreecamera
now when you use the console you can type the shorter
cam 1
- END OF PART 1 -
--------------------------------------------------------------------------------

Credits:
Arc D'Wraith - Author
Coralon – Proof Reading & Feedback
White Thunder - Title Image
Special Thanks to the toolmakers, for without your work modding Battlefield would be a joke.
Resources:
Bf1942 Modder's Wiki
bf42.com Editing Forums
Original Battlefield Maps
Tools Used:
Battlefield 1942
Corel Photo-Paint
GMakeRFA
Notepad
Open Office
RFA Extractor
Please excuse my english, i'm Australian ; )