Battlefield Botinator 5 Tutorial

A tutorial by: cajunwolf

Tutorials


Note!

This tutorial is out of date and I am in the process of rewriting it. If you run into problems post them at Battlefield Singleplayer forums in the BF1942\BFV AI Editing Thread. I always monitor post in this forum. You can email the link at the bottom but I prefer you to post at the forums for this reason. Others might have the same question's and a search in the forums will bring it up so others can learn.

Thanks for your patience

cajunwolf


 

We must thank Ben (Benji_$$$) because if he had not taken the time to write this great little program none of this would have been possible. Battlefield AI would still be a dark and foreboding area for all but a serious few coders.

This tutorial covers the use of the BF Botinator version 5, a tool for adding quick  SinglePlayer and COOP support for Battlefield 1942/Vietnam maps. This tool is a work in progress beta by Benji_$$$ and you use it at your own risk. The Author nor myself takes any responsibility what so ever in any way for anything that might happen. This is a medium skill level task and it assumes you have the necessary skills and tools to perform it. If you can extract and re-pack a map and do minor con file editing it shouldn't be a problem. If you do not have these skills yet you need to learn them first.

Now this tool will give your map Basic AI support. What I mean is that it will have the bots moving on the map with both sides using a basic Attack strategy. You will be able to play the map in COOP or Single Player mode. You have to understand here that AI is a map specific thing and you will have to learn how to edit and write strategies, edit the StrategicAreas.con file, and minor to major Pathmap editing to get bots to use the right strategies at the right time to play your maps well. I suggest you read the tutorials by "Arc D Wrath" which can be down loaded from the Battlefield Single Player forums along with the EA/DICE official AI documents. These documents can also be down loaded from this site on the Files Page.  Both of these are a must read to be able to understand and edit the Battlefield AI. Once you get bots fighting on a map this will  not seem so daunting and you will begin to understand AI a little more.

Now I Strongly Suggest you do this on a test map for the first time because as I said above AI is a map specific thing. I have more people complaining they cannot get it to work or the game is crashing to the desktop because they are trying to use it on a map that will need serious edits before AI will ever work on it if at all. I have a bf 1942 test map I made for this purpose and can be down loaded from this site from the Files Page. I will have a BfVietnam map up shortly. I know these maps work so if you have trouble with one of yours use one of mine.  If you make a test map be sure and make it simple. Make a small map and put some hills and valleys. Add three or four control points with solider spawns plus jeeps and tanks, no boats at this time that is a whole new ball game. You can use helicopters and planes. Remember to have all spawns out in the open. Let me say that again, have all spawns out in the open not in buildings or bunkers. You will learn why later.

With all that said lets get started. Fire up WinRFA and extract your map to a working folder. Now by a working folder I mean one you make or normally use when extracting maps to work with them. Ok start the Botinator and you will get this screen.

 

 

Here we want to click on Bot Wizard. I will cover the use of the advanced tweaker in a later tutorial. It is still in beta stage and is for advanced AI coders. There is a pathmap editor there you will learn to use later. Once you click on Bot Wizard you will get the following screen.

 

 

This is basically instructions so read them and click next and you get the following screen.

 

 

Now here at step 1 we need to browse to the folder you extracted your map to. Click on browse and you get this screen.

 

 

Now read carefully here. You want to click on the base path folder which is "BfVietnam" (or bf1942 if your doing a Battlefield 1942 map) and open it to the "Levels" folder, open it and click on the map name folder which in this case is called "Dumb_Test" (don't ask) just like I show in the above image and click OK. The Botinator screen now looks like this.

 

 

Notice where my cursor is pointing in the image. See the file path? Yours should look the same except your map name will replace Dumb_Test. If it is a bf 1942 map it will be like this ...

"..\..\bf1942\levels\your_Map_Name"

Ok now click next and we will go to step two.

 

 

Here it copies all the necessary files into your map and ask a bunch of questions. Here it is asking about the control points. In the above example you would chose no as the answer. For neutral bases select no also.  This will finish and take you to this next screen.

 

 

Here it shows you what it has done so click next. This is the next screen and more questions.

 

 

 

Here the choices are fairly obvious, Tanks are Tanks, Jeeps are Cars and so on. Use Heli for choppers, jets, and planes. Once finished answering all these questions it takes you to step 3.

 

 

This step confuses a lot of people. Basically the Botinator has done its job at this point for a Battlefield Vietnam map.  All it needs to do is remove the scripts\lines of code that evokes the Battlefield debugger to generate the pathmaps when you load into COOP and shows the stats on screen in game. If you want it to remove this and the stats LEAVE IT RUNNING until you have run in COOP to generate your pathmaps. Then click the next button and it will remove the lines that call the debugger and show the stats.  I prefer to do this myself and there is a feature in the Advance Tweaker that will add remove the stats. I quit the program at this point by clicking the "X" in the top right corner. Either way you do it is your choice, if this is your first time with AI,  I suggest you leave the Botinator running through the next step. Just minimize it 

  IF you are doing a Battlefield 1942 map there are additional editing steps yet to do.  Benji_$$$ has some upgrades yet to do for full bf 1942 support. This tool was designed originally for BfVietnam maps and just recently has bf 1942 support. This will be fixed in the up coming version. Skip this next step until you have complete the edits farther on down.

Ok if we are doing a BfVietnam map lets fire up WinRFA and pack our map back into the game levels directory and start the map in COOP mode. It will take longer to load as the debugger is generating your pathmaps. Once the maps loads you will see the stats all over the screen and bots spawning in with you. They will either just stand around or take off moving in all directions sometimes running into things. The reason is the Botinator puts a set of all black pathmaps into the maps new Pathfinding folder so the debugger will generate all the pathmaps at one time. The Bots should move but if they do not don't worry about it yet. Lets get your new pathmaps in your map first. Quit the game and extract your map back to the working folder. Now open it up to the "Pathfinding" folder and open it. Leave this window open and in another explorer window navigate to the games root directory like so.

If it is a Battlefield Vietnam map go here.

"C:\Program Files\EA GAMES\Battlefield Vietnam"

You will find a new folder called "BfVietnam" in here will be your new pathmaps.

If it is a Battlefield 1942 map go here.

"C:\Program Files\EA GAMES\Battlefield 1942"

You will find a new folder called "bf1942" in here will be your new pathmaps.

You can view the"Level0Map8bit.raw" pathmaps in Photoshop or any other image editor that supports this format. The other pathmaps are stored in EA/Dice's special format and cannot be opened without being converted with special tools ... go figure. Here is what the "Infantry1Level0Map8Bit.raw" looks like. This one is from my bf1942 test map.

 

Are you starting to see here how the bots find there way around? They cannot go where there is white. You will see where the debugging engine has pathed the bridge and other objects. Also note its pathed out where the out of bounds area material is placed.

Now the "Level0Map8bit.raw" maps are not used by the game and can be removed to save map size but save them somewhere as the Botinator uses them in the Advanced Tweaker section for the pathmap editor. You can save them in a backup folder somewhere if you are concerned about map size.

Which ever  map version you are doing copy all the new pathmaps into the maps "Pathfinding" folder over writing all the all black pathmaps that are in there. Let me say that again, Copy All the New Pathmaps into Your Maps "Pathfinding" folder. Remember the one we left open? 

Now if you left the Botinator running from the above step click next now and Botinator will remove the lines of code that run the debugger and stats. If you quit the program and want to run the stats so you can see what is going on I will explain how to do this farther down. You for sure need to disable the debugger mode or it will generate pathmaps every time you load into COOP. Now pack your map up and load into coop. The bots should take off and attack, kill, and take bases. You should now be able to load into Single Player mode also. If this does not happen you have done something wrong along the way. Retrace your steps and see. It works if you have everything set up right.

Now the additional steps for battlefield 1942 maps. The only difference and hence our edit is the call in the "AIpathFinding.con" file for the second layer maps and the difference between the boats / landing craft searchmap calls. Open it up in notepad and you will see this. The items in RED are the calls for second layer maps and bf 1942 does not use these but BfVietnam does so we have to remove them. Remove ALL the lines in red and be careful because if you mess up you will be saying hello to Mr. desktop.  I highlighted the area in neon green so you can see what each number means in the searchMap call.

 

if v_arg1 == host
rem *** pathfinding debug mode
rem game.aiPathfindingDebuggingActive 1

rem *** Set number of maps ***
rem ai.setNSearchMaps 2 *** DEPRICATED ***
rem ai.setNSearchTypes 2 *** DEPRICATED ***

rem *** Set number of AStar resources ***
rem ai.numAStarResources 12
rem *** Setup map parameters ***
rem *** Tank ***
rem ***
searchMap name/ waterHeight/ waterDepth/maxSlope/brush/lowClipLevel/hiClipLevel/ 
rem
considerAITypes/createSecondLayerMap/ firstLevel-secondlevel-thirdlevel (for second layer map)
rem ***
searchType name/mapNum/minSearchLevel
rem *** Tank ***
ai.addSearchMap Tank0 0 0 30 3.0 0.3 2.5 0
0 1.0/3.0/7.0 
ai.addSearchType Tank 0 0
ai.setMapSpawnPoints 0 605/274 , 590/270 , 374/389 , 414/612 , 600/834 , 582/828
ai.setSmoothing 0 20
rem *** Infantry ***
ai.addSearchMap Infantry1 0 1.5 40 1.0 0.4 2.0 1
0 1.0/3.0/7.0 
ai.addSearchType Infantry 1 0
ai.setMapSpawnPoints 1 610/256 , 605/822 , 380/407 , 500/560 , 521/463 , 430/619 , 581/270 , 577/834
ai.setSmoothing 1 10
rem *** Boat ***
ai.addSearchMap Boat2
1 1.4 30 4.0 0.3 2.5 0 0 0/0/0 
ai.addSearchType Boat 2 2
ai.setMapSpawnPoints 2 
ai.setSmoothing 2 20
rem *** Landingcraft ***
ai.addSearchMap LandingCraft3 1
1.4 30 4.0 0.3 2.5 0 0 0/0/0 
ai.addSearchType LandingCraft 3 2
ai.setMapSpawnPoints 3 
ai.setSmoothing 3 20
rem *** Car ***
ai.addSearchMap Car4 0 0 35 3.0 0.3 2.5 0
0 1.0/3.0/7.0 
ai.addSearchType Car 4 0
ai.setMapSpawnPoints 4 606/267 , 606/262 , 381/413 , 435/622 , 426/622 , 598/819 , 586/819 , 395/384
ai.setSmoothing 4 6
rem *** Load maps ***
ai.loadMaps
run StaticObjects.con
ai.createAllMaps
endif

Now the areas in Blue may need to be edited as they are different for battlefield 1942 and the Botinator still uses the BFV settings. You need to look at some of the stock bf maps and make changes and additions to suite the particular situation of your map for  "Boat2" and "LandingCraft3" searchmaps only. The settings below will generate pathmaps in most cases.

rem *** Boat ***
ai.addSearchMap Boat2
1 1.4 30 4.0 0.3 2.5 0 2 5 
ai.addSearchType Boat 2 2
ai.setMapSpawnPoints 2 
ai.setSmoothing 2 20
rem *** Landingcraft ***
ai.addSearchMap LandingCraft3 1
  1.4 30 4.0 0.3 2.5 0 2 5 
ai.addSearchType LandingCraft 3 2
ai.setMapSpawnPoints 3 
ai.setSmoothing 3 20

The 2 5 added to the end is 2 space 5 by the way and not 25. This means create and use level 2 through level 5 pathmaps for Boats and LandingCraft. Battlefield Vietnam uses level 0 through level 3 pathmaps for boats. The other three items are water depth, max slope, and hull width or brush size.

Now pack it up and run in COOP mode like above to generate your pathmaps then copy them over into your map. This should run like the BfVietnam map above. 

Now to edit this file and the "AI.con" file for the debugger and stats calls.

On the bottom of the "AIpathFinding.con" file above we need to do this.

 

rem *** Load maps ***
ai.loadMaps
rem run StaticObjects.con
rem ai.createAllMaps
endif

See the rem's in red? These two calls are what tell the debugger to create pathmaps. You want to delete or rem these out or every time you load into COOP it will generate pathmaps. We already have ours so lets turn this feature off.

Now open the "AI.con" file in notepad and you will see the following.

 

rem ************** LEVEL SPECIFIC AI SETTINGS ***************************

aiSettings.setWorldMapSize 1024 1024
aiSettings.setViewDistance 305
aiSettings.setInformationGridDimension 32

rem ********************** START THE AI *********************************

rem *** Init AI using current settings ****
ai.init 2

rem *** init Botmanager ***
AIBotManager.setLodLevelTicks 6 6 6
AIBotManager.setLodLevelPriority 6 4 2
AIBotManager.setPlannedDecisionMakingThreshold 0.5 1.0 3.0
AIBotManager.setUnplannedDecisionMakingThreshold 0.3 0.8 2.0
AIBotManager.setDecisionMakingInterleave 2 2
AIBotManager.setSensingQuotient 2 1
AIBotManager.setSystemQuotient 30 40 30

rem *** Strategic map dimension, MUST BE DONE BEFORE CREATING SAI! ***
ai.saiMapXDimension 64
ai.saiMapYDimension 64

rem *** Create Strategic AI ***
ai.createSAI

rem *** Enabled or disabled as default ***
ai.saiEnable 1
game.showAIstats
1
ai.showBotStats
1

rem *** Bot statistic ***
ai.botStatisticUpdateSpeed 3


run AIPathFinding.con

rem *** Create strategically important areas ***
run ai/StrategicAreas

rem *** Load and set strategies for each side ***

run ai/conditions
run ai/prerequisites
run ai/Strategies

ai.addSAIStrategy 1 TeamAAttack
ai.addSAIStrategy 1 TeamADefend
ai.addSAIStrategy 1 TeamARepulse
ai.addSAIStrategy 2 TeamBAttack
ai.addSAIStrategy 2 TeamBDefend
ai.addSAIStrategy 2 TeamBRepulse

 

You see the numbers in RED? These are the switches that turn on or off the AI and BOT stats. 1= stats on and 0=stats off. If you want to leave the AI stats on so you can see your StrategicAreas, strategies being played by each team, and much more useful information then leave this line like so.

game.showAIstats 1

You will want to turn off the bot stats unless you need to know what each bot is doing and where he is headed which is rare. Set this line like so.

ai.showBotStats 0

You can also add or remove stats in the Botinator's Advanced Tweaker.

Now your all set to add AI to Battlefield Vietnam and Battlefield 1942 maps. If you want to do a mod of bf 1942 or BfVietnam you will have to do some editing in the AIpathFinding.con file. The problem with doing a mod is the lack of AiMeshes. These are mesh files stored in the Battlefield 1942\BfVietnam game archive. The debugger uses them in pathing the static objects for the infantry searchmaps. They are the most detailed maps and are the only ones the AiMeshes are used for. You will need to disable them and increase the brush size in the infantry searchmaps only. Like so.

 

rem *** Infantry ***
ai.addSearchMap Infantry1 0 1.5 40
2.0 0.4 2.0 0  
ai.addSearchType Infantry 1 0
ai.setMapSpawnPoints 1 610/256 , 605/822 , 380/407 , 500/560 , 521/463 , 430/619 , 581/270 , 577/834
ai.setSmoothing 1 10

 

After the "40" which is the max slope a bot can climb, you see we have increased the brush size to 2.0 from 1.0 and on the end we changed the 1 to a 0 to turn off the AiMeshes. If you do not do this you will probably get a freeze, or see Mr. Desktop. If it does generate pathmaps the Infantry maps will be streaked and no good.

This should get you going for most Mods. If you have GMAX or 3DsMax you can make the AiMeshes for custom objects in your mod maps.

Custom objects can cause problems. You  can disable them to generate pathmaps by re-naming the "objects.con" file in the objects folder in your maps root to "objects.bak".

If you are on the metric system you will need to set your computer to the US number system to run the Botinator or you will get some really wild coordinates in your searchmaps calls which usually brings you to yes you guessed it, Mr. Desktop. Just switch it back once you finish running the program. This should be fixed in the next version.

One last thing to look for. Somehow during the process a line gets written  to the conquest template you want to rem or remove. Look at the conquest in the maps root directory and in the Games Type folder and rem or remove this line if found.

run ai

If not you will not be able to play the map in conquest mode and it will CTD.

This completes the tutorial and I think I have covered all the bases. If you have trouble with the Botinator or just want to learn more about AI editing  I and many others can help you at  Battlefield Single Player  website. Please post in the forums under the version of the game your editing.

If you have comments or suggestion on this tutorial email here

Comments and Suggestions

Note, DO NOT email questions about the Botinator here, use the forums if you want an answer.

Back to Top