Jump to content
Official BF Editor Forums
mschoeldgen[Xww2]

Creating Your First Bot Support / Navmesh

Recommended Posts

Here's a small wrapup of whats needed to make the first basic AI for your map:

Building your first navmeshes

using the AI tools provided with the new editor from Jan, 4th :

You need to have the python environment installed. This link contains the installer for Python on windows:

http://www.python.org/ftp/python/2.4.2/pyt...ython-2.4.2.msi

After installation, assign the *.py files to open with the newly installed python interpreter. Their icons should change to the green snake.

This is NO tutorial for making maps. I assume you have a fully working, bugfree Conquest map. This is vital for the things to come, as the following process relies on error-free loading of your map !

Launch the editor and load the SinglePlayerEditor part of it by using the ADD-in manager and checking the 'loaded' box. Load your map.

In Level Editor:

Make sure you have a valid Combat Area, this is needed else navmeshing will fail. Combat areas are drawn in the level editor (big 'C' icon) by rightclicking in the map , add a 'Controlpoint' and continue counterclockwise until you close the area. Check the 'usedByPathFinding' box in the combat area tweaker window.

Now, only items in layer 1 (default) will contribute to the navmesh process, take care that all your SP things are in layer 1. ( if you have another layer for SP, e.g. layer 3 its a good idea to create a backup of editor/gameplayobjects.con and change all things in layer 3 to layer 1 in the working gameplayobjects.con )

You need to have a minimum of one soldier spawnpoint and one vehicle in layer 1 to avoid the "no keypoints defined" error by navmesh.exe.

In Level Editor make sure that no spawnpoint has the 'ScatterSpawnPositions' options checked . Failing to do so will crash the editor when creating GTSData !

Save, then change into SinglePlayerEditor.

Add StrategicAreas at least for your ControlPoints. The SA tool allows automated generating, use it for now. Its the button 'Place on All' in the wizard window. Select AI rendering from the 'Render' menu and check if the areas looks right.

Now adjust neighbouring between your Strategic Areas (SA) . Select one SA by clicking it (Its border should turn from bright blue to dark blue) and move to a neighbouring SA. Rightclick it to bring up the context menu and choose 'make neighbour' with the <> symbol. This will create a bidirectional connection between the two SA's. Continue this for your map until all SA's have at least one neighbour. one way connections are used for uncappable ControlPoints. Bots will not go a one-way in the wrong direction. A one-way neighbour is created by selecting the DESTINATION SA, then rightclicking your uncappable SA . Select 'One Way Neighbour' now .

Waypoints are optional and should show the bots alternative ways to reach a SA. They are not necessary but will add variation to the bot pathes. They are basically created like the neighbours, by clicking the start SA and then rightclicking the ground somewhere between the start and the target SA.

OrderPositions : Every SA has 2 orderpositions, one for infantry the other for vehicles. These should be inside the StrategicArea and are the spots which the bots try to reach when capturing the attached ControlPoint. By default these orderpositions are placed directly on the flagpole which is not a valid position !

Alter the locations by first selecting the SA then press one of the OrderPosition button in the wizard. Dismiss the dialog, then click inside the SA to set the first orderposition. Select the other type ( Infantry/Vehicle) and repeat for this orderposition. Walk over your other SA's and set all orderpositions to good locations.

The latest Editor (0.1.237.0) obviously has a problem with the +forceLoadPlugin argument. Make sure to have both 'Loaded' and 'Autoload' in the Add-in manager checked for the SinglePlayerEditor before leaving the editor,else navmeshing will not work.

Save your map. Quit the editor.

Copy the AI folder from an existing map and put it into your map folder.

Change into the /NavMesh folder , its in the BF2.EXE directory.

Edit the 'GenerateNavmeshLocal.py' file with a texteditor for your mod , its a few lines below the start of file. The default entry is 'xpack' , change that to the mod you're working on ('bf2' for the standard game).

Hint from [bGF]Godfather : instead of editing the file for the mod name simply put

mod = sys.argv[1]

into the line . The final excerpt from the file looks like :

# Change the line below to the mod you are working on
mod = sys.argv[1]

1. Copy 'ExportGTS.con' and 'saveQuadNoP4.con' from the /NavMesh folder to the BF2.EXE directory.

2. Make sure your map contains an 'overgrowth' folder with the 'OvergrowthCollision.con' file. If you don't use overgrowth, put an empty file there and name it 'OvergrowthCollision.con' (Into <MyMAP>/Overgrowth)

3. Run 'CreateNavmesh.bat' from the /navmesh folder and fill in mod- and levelname. LetterCase does matter here,make sure for the _exact_ name of your mod and map. The editor will remotedly being launched by the batch file to export data from your map. This is normal and explains why its necessary to have a 100% working map.

4. This process will take a while. After the process , the editor is launched once again automatically and creates the files in /AIPathfinding . When finished, import the infantry.obj and vehicle.obj from the /navmesh/work/>LEVEL>/GTSData/output folder into 3DS (as WaveFront object) More on this later...

5. Delete isolated elements, polies and vertices from them and export them as WaveFront (.obj) again into the /navmesh/work/>LEVEL>/GTSData/output folder.

6. Run the 'FixNavmesh.bat' , again the editor will be launched remotedly to create the AIPathfinding files for the game. This will place the necessary navmeshes files into your levels AIPathfinding folder. Do a test drive with bots :D

If something goes wrong, remember the logfiles are your friend :P The BF2editor writes to /<BF2.EXE DIR>/bf2editor/logs/

As a general rule, the /NavMesh/work/<LEVEL>/GTSData/debug/islands/infantry and /vehicle should contain the number of islands. If there is more than 1 file, the navmesh needs editing.

Here are the settings for the Wavefront (.obj) importer for importing navmeshes into 3DS (thanks to clivewil for those)

----------------------------------------------

Settings for import to Max:

navmeshimport.jpg

----------------------------------------------

After import open the Material Manager and use the eyedropper tool on the imported mesh to set the materials according to that following shot:

Settings for MTL export from Max:

navmeshexport.jpg

After export open the *.OBJ with a texteditor and change the material library settings to read :

mtllib materials.mtl

----------------------------------------------

Have fun navmeshing !

Edited by mschoeldgen[Xww2]

Share this post


Link to post
Share on other sites

Why would you have to download something for pyton isn't that part of the new editor ? Just seems stange there is no mention of that .

Share this post


Link to post
Share on other sites

The batch files in the NavMesh folder fire up python scripts. If you try to run without the python environment installed , it will simply not work. (if you're lucky :wink: , it will open a texteditor showing the script) The python engine in BF2 is only run from within the game and won't work on standard *.py scripts. The editor itself comes with no python.

Believe me, i've tried it....

Share this post


Link to post
Share on other sites
Guest

Hi mschoeldgen,

thanks for this fantastic toutorial. I could first time easily create my infantry.obj and vehicle.obj. Maybe worth to mention, that the SinglePlayer Level should have in <mymap>EditorGamePlayObjects.con at the end of the matching level an additional entry to avoid combat area problems like this:

CombatArea.create CombatArea_0_SP1_16

CombatArea.min 0.000000/0.000000

.

.

.

CombatArea.addAreaPoint 20.013611/401.118042

CombatArea.team 0

CombatArea.vehicles 4

CombatArea.layer 5

CombatArea.usedByPathFinding 1

I now like to learn about which MAX you are talking. I have downloaded the gmax from the Battlefield tools. There i do not find any "WaveFront" option. If i simply rename the infantry.obj to infantry.3DS my gmax tells me to have got a wrong format. If it is not gmax, any chance to update gmax with that feature or do you have any freeware MAX doing that job?

Share this post


Link to post
Share on other sites

Glad i could help :D

Maybe you overread this ?

Check the 'usedByPathFinding' box in the combat area tweaker window.

I guess the standard gmax doesn't come with the *.obj import/export. But there was a site with tons of plugins for both 3DS and gmax, although i can't remember the URL atm. Try your luck googling for it.

I did it and stumbled across :

http://www.turbosquid.com/Forum/Index.cfm/...tThreadID/16045

These seem to be links to the plugin:

http://pages.videotron.com/browser/Downloa...s/importobj.zip

http://pages.videotron.com/browser/Downloa...ts/importobj.ms

Updated tutorial for pathnames...

Share this post


Link to post
Share on other sites

Hi, nice tut.

Now i got a little prob i was sloppy with the waypoints and only made them in one direction now my USMC team is stuck in thier base lol. n(unless im comader and oder them to move)

Do i have to start from scratch again or can i just add some new way points?.

My Bots wont use APC´s and Tanks for some strange reason they arent even entering them.(Did try to pick one up).How can i fix that?

To add something usefull.

You can just use Milkshape to edit the Navmesh its free for a Month i think and is cheap to if you wanna buy it the Obj export/import works.

Anim8or seems to work too but i didnt edit the file with it but its a nice little freeware tool you can abuse for renders and modelviewing.

Share this post


Link to post
Share on other sites

Those links to the obj plugin for gmax are good but I had to increase script memory to use it but the guy who wrote it is well respected as far as I have seen . what I usually use is this one

http://www.tru7h.org/halo/gmax_render/xzzy_obj_tool.ms

it can export as well where the first one does not seem to you can put xzzy_obj_tool.ms in gmaxgamepacksBattlefield2scriptsstartup and it will be on the maxscript dropdown menu at the bottom , but what I use to export is gMAX2OBJ.ms. You can get that here

http://www.shorthike.com/wiki/MeshExporters

What ever one you use it sends output to the listener window and you can't copy and paste from it gmax has some kind of thing that won't let you copy and paste more than a few lines but there is a utility that will it is called GMaxSLGRAB you can get that here

http://www.icecreamhasnobones.org/GMaxThin.../GMaxSLGRAB.zip

just run it after you have exported it will grab what is in the listener window and then after what seems like a long while it will ask you for a filename to save it to ( don't you love gmax :) )

Share this post


Link to post
Share on other sites
Guest
5. Delete isolated polies and vertices from them and export them as WaveFront (.obj) again into the /navmesh/work/>LEVEL>/GTSData/output folder.

I NEED HELP

in max i import exactly as you say. I then select "editable mesh"

then i can choose verties, edge, face, polies, element

so i first choose vertices, i select All by dragging box around entire navmesh.

on the left bar/options

I choose "Delete Isolated vertices"

is this what you mean by the ABOVE quote?

most all i understand, just NO-one explains details, just what to do.

so am i even close or what?

I need to know HOW not WHAT.

I would appreciate a more detailed explanation of this step. (5)

I appreciate all information provided by ALL!(entire bf community)

Share this post


Link to post
Share on other sites

Hi Bdbodger,

i am not familiar with gmax. Maybe i am blind. I got your max-scripts and others like 'importobj.ms'. I stored them as mentioned by you in the startup folder. I do find them right hand in the utilities tab as drop down menu, if i click there maxscript.

BUT: I have no clue how to use them. If i click 'run' in the maxscript menu, i am not aware of anything happening. :(

The help of gmax is explaining a lot how to create those maxscripts, but i found no hint of how to use them. :?:

Any hint or feedback of how to use maxscripts for import/export in gmax highly welcome.

Btw: Great post here. Thanks to mschoeldgen :D

Share this post


Link to post
Share on other sites

@ JonnyC : Its not only the waypoints, you need to announce the neighbouring areas to each Strategic area. You can delete unwanted waypoints by rightclicking them and delete. Only make sure the context menu says the right thing about start and destination.

Neighbours are either bidirectional or one-way. In one of my testmaps i have two uncappable bases and a central CP to fight over, so i made the central CP a one-way neighbour to the bases. By this the bots don't feel the need to conquer an uncappable ControlPoint.

@Don Juan: Currently the best way to get rid of islands seems to be to select the main mesh, switch to 'Element' selection, select the main element and then 'Invert Selection'. This should select the other unwanted elements (islands) in the navmesh. You can then simply delete them (Press 'DEL'). Like i said above, the /work/<LEVEL>/GTSData/debug/islands folder contains the islands, At least giving you a hint on what you have to edit. You could even import the island002.obj to see where its located.

Deleting isolated vertices is a good start, just continue and delete isolated elements in the second step...

@BierPizzaChips: If you have the new import script in your scripts folder, you should be able to use it by simply go to 'File>Import' and have a new format in there (*.obj). No special action is needed. The scripts are initialized at startup and add their magic to the importer menu... :D

Share this post


Link to post
Share on other sites

Ya i found that out when i remade the waypoints my bots where a bit stupid because i made the whole map oneway, now they like to baserape beacuse i made all ways [<->] but hey its like online ^^;.

The bots not using Vehicles is fixed too im not 100% sure why they didnt enter them but now after i made a new mesh it works.

My only problem is that some Cars (APC´s) seem to be cut out of the navmesh because bots enter them but dont drive i guess thats because my map is so tight and has some boxes etc next to cars so the navmesh is blank on this spots.

Anyways that tut helped a lot finaly I can test maps and not just look at them.

I will upload the new version of my first map later ^^

btw. When you said generating the navmeshes takes a while i didnt expect 2h lol

Share this post


Link to post
Share on other sites

yay for double post >.<...damn lag

edit for something usefull:

If you import the Mesh into milkshape you could open all Islands that you have and put them on top of eachother so you can see where the isolated areas are if your lazy^^;(it has a poly limit so look out)

If not you´ll have to search the whole navmesh for unconected places or single polys but its not realy hard took me 10min of editing to get rid of all isolated areas.

been bored so heres a vid of my map with bot support (kinda dark might need to turn gamma up a bit^^;)

http://files.filefront.com/bottestwmv/;464...;/fileinfo.html

fixed the link

Share this post


Link to post
Share on other sites

This may be a very stupid question: Can i test a SinglePlayer map not packed as i do with Multi-Player or do i have to have it packed for test run?

(MP runs smooth and fine, but my SP crashes at end of Object loading ... i still have not done any mesh fixing, just got rid of vehicles because that mesh did look terrible)

Share this post


Link to post
Share on other sites
Guest

Hey guys

Please make a video tut!!!!!

I get after createtnewmesh.bat crash!!!editor start also always in addon xpack although the map for bf2 am meant assistance please

Sniperhanz

Share this post


Link to post
Share on other sites
Guest

Check the 'usedByPathFinding' box in the combat area tweaker window. Save, then change into SinglePlayerEditor.

Share this post


Link to post
Share on other sites

Ok i think i did everything right, but the 3ds part, i imported the infatry.obj whit al these settings and exported it right too, than i fixed the navmeshes but when i test the map it crashs on half loading :?

Cant anyone do a videotutorial or make some screenshots of what you have to do in 3dsmax?? Its realy hard because i never use 3dsmax :(

Share this post


Link to post
Share on other sites

Hi all mesh experts,

my gmax does not offer at import obj (maybe because of my German OS or a version problem), therefore i downloaded the trial of Autodesk 3DS MAX 8 and got the import very smooth. I found that i can make my mesh looking better by deleting obviose vertex via Edit Mesh -> Weld -> Selected -> 2. My infantry mesh looks good now.

But my vehicle mesh is splitted into three objects, one has a a high amount of polygons, it looks like a fishingnet. I am neither able to get rid of all obviose vertex nor can i unit this fishingnet to become one polygone.

Does anybody know how to unit in Autodesk polygons to become one? Is there any option to unit cutted streets?

Any tip or hint highly welcome.

Share this post


Link to post
Share on other sites

thanks for the tut, good job, however im a little confussed on a few points and would like some help, please,

when u say click on menu and click Ai rendering, i do not see this wording i do see some other 3 things to do with Ai is that it and which one,

also when u add in the statric control points and then add in the things for the bots and vechiles do i place them between the spawn point and flag, ie how many do i need to place around one statric control point, one of each , or more then one, each,

and with this python scripts you have were are meant to be installed i have them installed in programs are they meant to be in the bf2 python folder or is the programs folder, python find,

apart from that i like your tut, and big Props to you, keep it up

Share this post


Link to post
Share on other sites

To avoid double or triple posts in this forum, just press 'Submit' once . Then just navigate your way back into the forums.

In the 'Render' menu of the editor you'll find the 'AI' section. There you can render the AI items, the infantry navmesh and the vehicle navmesh. Rendering the AI items enables the visual display of waypoints and StrategicAreas .

ObjectsSpawners and SpawnPoints are added like you would do for any other map. Its a good thing for bots to let them spawn in the open, a bit apart from objects, statics and flagpoles. Same for the vehicles. Let them spawn with some free space around.

More than 1 navmesh-element is a problem. You can try to attach the other elements to your first island, but they must be physically connected (share a common edge).

You would select the main island , then select 'Attach List' in the Editable Mesh rollout. In the select window, choose the meshes you want to attach, effectively making them a single mesh.

There's no need to edit the location of the python files. They all sit in the /NavMesh folder and they are pretty happy there. If you did install the editor from Jan 4th, you only need to copy the 2 *.con files to the BF2.EXE folder and it should run. If it doesn't you might have other problems. Examine the editor's log files ....

@Jones: Crashing a map halfway through loading is not necessarily AI - related :wink: . Either run BF2 in windowed mode or use the debugger EXE to find out more about the cause .

Share this post


Link to post
Share on other sites

i have a little problem. I can start the fixNavmesh.bat, but when the program finished, there are no navmeshes on my map :( i dont know why, but it doesnt work :(

sry for my english, it sucks :D

Share this post


Link to post
Share on other sites

There are a few reasons why this could happen:

1. You never ran the 'CreateNavmeshes' :wink:

2. Don't confuse the 'Fix_Navmeshes.bat' with the other similar named batch file. I've the name right in the tutorial, use that one. It should fire up the editor to generate the Quadtree and Cluster files, while the other (unused) batch file never does it.

3. For some reason the first batch went wrong and no navmeshes were created. You can check by examining the /work/<MYLEVEL>/GTSData/output folder. There should be a 'infantry.obj', 'vehicle.obj', 'manifold.obj' and a 'preopt.obj' file in it.

If any error happened, chances are good to have them in the log files. While the NavMesh.EXE talks in form of *.obj files, the editor places its log into /bf2editor/logs. Examine it to get an idea of what went wrong.

Share this post


Link to post
Share on other sites
]There are a few reasons why this could happen:  

1. You never ran the 'CreateNavmeshes'  :wink:  

2. Don't confuse the 'Fix_Navmeshes.bat' with the other similar named batch file. I've the name right in the tutorial, use that one. It should fire up the editor to generate the Quadtree and Cluster files, while the other (unused) batch file never does it.  

3. For some reason the first batch went wrong and no navmeshes were created. You can check by examining the /work/<MYLEVEL>/GTSData/output folder. There should be a 'infantry.obj', 'vehicle.obj', 'manifold.obj' and a 'preopt.obj' file in it.  

If any error happened, chances are good to have them in the log files. While the NavMesh.EXE talks in form of *.obj files, the editor places its log into /bf2editor/logs. Examine it to get an idea of what went wrong.

1. hahaha :mrgreen:

2. used the one from tutorial.

3. i have all 4 files in my output folder. but after using the fixnavmeshblablabla i can find in omy map a folder called GTSdata/output , with the same files from the work/Mapname/GTSdata/output folder :?

4. under construction :)

I think i got it.

D:bf2editorCodeBF2IOConsoleConsole.cpp(1697): Couldn't open console script "saveQuadNoP4.con"

I forgot to copy the saveQuadNoP4 into my bf2 Directory :oops:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×