Page 1 of 5

Adding Bot Support for Maps

Posted: Tue Oct 13, 2009 12:00 pm
by Fafner
First thing, make sure you have the latest dll available that has bot support.

To add bot support, load dday, type
"set cheats 1"
then load whatever map you want.

There are 2 main parts to adding bot support, creating the .nav (navigation) file and the .cmp (camp) file


Load a map and join a team, then type "sv makenodes" in the console. You should see things like "Dropped Node" and Link: LINK_MOVE in the console. If not, then you probably don't have the dll installed correctly.

******note: "sv makenodes" overwrites any .nav file you might have for the map. If you already have a .nav file and just want to add onto it, type "sv editnodes" instead. ******

What you have to do is move around to create paths that the bots will follow around the map. The code is saving 2 things, nodes, which are hundreds of spots around the map, and links, which are how the bots move between 2 nodes.

So if it a node is dropped at one point, then you jump up a step, a new node will be created at the second spot and it will say LINK_JUMP and the bot will know to jump to get up there. If you drop back to the first node it will say LINK_FALL, and the bot will know to fall to get back to that spot. Nodes and links will be created automatically as you walk around.

Try to cover the entire map if you can

Just walk in a straight line, don't go running all over in zig zags trying to cover every inch because it doesn't work well that way. Just look at each area and for every way in and out of that area, make a path through it. Like for this part of inland4, a simple way to do routes would be this:

If at any point you hear a beep and see LINK_INVALID in the console, that means the code can't figure out how you got from one node to another. So what you do is move back and retrace your steps and keep going back and forth until you see it say LINK_MOVE and you know the link is saved correctly. Some parts of some maps just won't work under any circumstances. Especially with big jumps like if you have to jump up on a crate and with certain ladders. There's really nothing you can do to fix it, so either you have to give up on the map or the bots just won't be able to move through that area.

Nodes are dropped automatically, however if you are having problems getting a lot of LINK_INVALIDs, you can drop a node by typing "sv dropnode" in the console. This will especially be useful when going through doorways and turning tight corners. For a doorway I would drop 1 on the inside, 1 under the doorway and one on the outside and that will usually get them to work. If there is an invalid link in a key part of the map, it might mean the bot will get stuck, like if you have one in the middle of the sewer of dday2, no bots would be able to go through the sewer. Try not to drop too many nodes though because it could cause problems.

Make sure you create paths starting from every spawn point. If a bot spawns and isn't near a node it will just "wander" around which looks stupid.

When you are done, type "sv savenodes" to save everything. If you don't do this all your work will be lost! You might want to start simple and create backups of your .nav file as you go along, and add onto them bit by bit with "sv editnodes" because sometimes you can screw things up and it's difficult to fix things once they are.

If there is some complicated route (like the church underground part of dday2) don't even bother trying to make paths there because it probably won't work and you'll just end up messing up your .nav file. For the same reason, try to stay in the middle of any corridors because the bots can get stuck on corners and stuff. The bots can duck at times to get under spots, but that doesn't work perfectly so don't count on it. Don't try to get cute or you'll just mess up your .nav file!

This is kind of a hack, so don't overuse it, but when you type "removenode" in cheats mode, it will remove the closest node to you (it actually moves it to -9999,-9999,-9999 and sets all the links invalid, I'll have to figure out how to actually delete it later). To use it, you have to be out of edit mode. Just type "removenode", then "removedoors" (if needed), then type "sv savenodes" and it should be gone. Don't type "sv editnodes" before that or it won't work.

Once you are done with the .nav file (or you can also do this at the same time as making the .nav file) you have to create camp spots for the bots to go to. Bind a key to "sv campspot" and join whatever team you want to set up first. Then go to various spots around the map wherever you want the bots to camp and hit that key. Try to copy where people camp on the servers to make it realistic. When you set a camp spot 4 things are saved:

So when you set the camp spot, make sure you are situated exactly as you want the bot to camp, including whether you are standing, ducked or crawling, and that's how the bot will camp. If you store a spot as a standing camp spot, hmgs won't go to that spot. Don't put the spots close to each other or the bots might all bunch up. When bots spawn they will either go to the nearest camp spot or a random one. Try to put the bulk of the camp spots near the other teams spawn otherwise you might end up with 2 teams of bots camping all day and never seeing each other.

The .cmp file will be stored in dday/navigation.
(You can edit that file in notepad if you want to tweak it without having to start over. Each camp spot is 6 lines, 1st line is team, lines 2-4 are origin(x,y,z location) , 5th line is angle, 6th is stance 1=stand,2=duck,4=crawl. You can find your origin in the map by typing "spot" in the console when cheats are on)

Bots should attack objectives and claim objectives. Make sure you have a campspot near any destroyable objective and inside objective_touches (1 for each team). The closest campspot to each objective will be designated as an objective campspot and will only be used for capturing or destroying objectives. When you use "showlinks" (see below) the flags over these campspots will be translucent.

If you have a rotating door in your map, when you save your nodes, any links through the doors will be broken. So with cheats on, type "removedoors". This will remove all rotating doors in the map. Then type "sv savenodes" and the bots should be able to go through rotating doors ok. Any time you save your nodes, you will have to do removedoors first, even if you only added a few links to your map that are nowhere near any door. Be aware that when you type "removedoors" the map becomes very unstable and will sometimes crash causing you to lose your navigation data. So save your nodes quickly then restart the map.

Bots will destroy any func_explosive it gets close to so you don't have to worry about windows blocking their path (like on outpost). But similar to rotating doors, when you save your nodes, the links will save according to what state the bridge/window/destroyable object is in. If you have a window that you want the bot to go through, you must make sure the window is destroyed when you save the nodes, otherwise it won't be able to get through it. Likewise if there is a bridge you want the bot to cross, if you destroy it the links across the bridge will become invalid.

If you are making a map or an ent file you can create an entity called "bot_spawn". It works similar to "info_reinforcements_start" except just the bot spawns there. Give it an obj_owner of "0" for allied or "1" for axis. This is good for if the normal spawn is in a tight spot that the bots are having problems getting out of.

SOME MAPS JUST WON'T WORK due to stuff like the bridges on dday3 or some spawn areas that are too hard to get out of.

Examples of maps I couldn't get to work:
dday3, dday5, soviet1

That's it for now. I'll probably edit this as I think of more stuff. I didn't code any of the .nav file stuff so I don't know exactly how everything works and had to figure out most of this by trial and error. So if anyone has anything to add, feel free to add it. And let me know if you have any problems. Hopefully some people will actually work on this and post their .cmp & .nav files for other people to use.

In cheats mode, you can type "showlinks" and a laser will point from each bot to their campspot. It will also show the closest node to you and all the links coming out of that node. LINK_MOVE's will be green LINK_JUMP's will be blue. Also, a team flag will appear at every campspot. Objective campspots will be translucent. This only works correctly when you are not in edit mode.

Re: Adding Bot Support for Maps

Posted: Sun Oct 25, 2009 7:27 am
by PowaBanga
Me i can not to create nav file.
I writte
sv makenodes
sv editnodes

i walk, after i writte
sv editnodes

but nothing...

I have the cmp file so when i launch bots, the console say :
AI error, nodes files is not found

It is on gold map...

Re: Adding Bot Support for Maps

Posted: Sun Oct 25, 2009 11:09 am
by Fafner
Do you type "sv savenodes"?

Re: Adding Bot Support for Maps

Posted: Sun Oct 25, 2009 12:50 pm
by PowaBanga
this comand work, thanks you :D

Re: Adding Bot Support for Maps

Posted: Thu Oct 29, 2009 11:25 am
by simbioz
What about the q2 stock AI code?

Re: Adding Bot Support for Maps

Posted: Mon Nov 02, 2009 7:52 am
by InFerNo
What about it?

Re: Adding Bot Support for Maps

Posted: Tue Dec 08, 2009 7:17 pm
by simbioz
InFerNo wrote:What about it?
q2 had support for single player game with bots, so I wonder if that capability could be used in dday, because, if i understand correctly, fafner is using some AI code from another proyect and "glued" it to dday. How much difficult could it had been to use the q2 AI code instead of this one?

Re: Adding Bot Support for Maps

Posted: Tue Dec 08, 2009 9:43 pm
by Fafner
it would take a lot of work. Everything is coded to work for "deathmatch 1". Once you change to "deathmatch 0" there are a ton of bugs with changing levels and spawning monsters and stuff.

Re: Adding Bot Support for Maps

Posted: Wed Feb 10, 2010 2:30 am
by Dirk
If you make some .NAV files, send them to me and I'll upload them. Please verify that they work first.

Re: Adding Bot Support for Maps

Posted: Fri Feb 12, 2010 4:59 pm
by GypsyLlama
Tried my hand at a few maps and I failed a lot but I tried it with rmg4 and played for awhile, it works quite decently. For the most part they stay close to the ground but they are able to climb up the ladders and navigate the rooftops and whatnot. Add to dirks??

extract into your dday\navigation folder

Re: Adding Bot Support for Maps

Posted: Fri Feb 12, 2010 7:43 pm
by Fafner
Added :smt069

Re: Adding Bot Support for Maps

Posted: Sat Feb 13, 2010 8:17 pm
by Rab,d
Damn this was tough. :blushes: ...took all f0rking day.
It would be great if you could prioritze what way the bots go where paths cross nodes.
They seem to be single minded.

Re: Adding Bot Support for Maps

Posted: Sat Feb 13, 2010 9:27 pm
by Fafner
Added it to Dirk's server.

The bots choose a camp spot as soon as they spawn so basically they choose the shortest route to their camp spot. I also threw in a hack so they randomly might go a longer distance (so they'll go through the sewer on dday2 and stuff). If they're going a really weird path or never going a certain way there might be a bad link somewhere.

It's supposed to be that if there are objectives, they always choose an uncaptured/destroyed objective and go towards that first. It's all faaarr from perfect though.

I updated the first post to write about a bot_spawn entity I added.

And I'm going to move this to mapping since I think it fits there better.

Re: Adding Bot Support for Maps

Posted: Sun Feb 14, 2010 12:18 pm
by Rab,d
that was helpful info. Thx.

Here's .nav and .cmp for poldday1
It worked out pretty smooth on this one.

Re: Adding Bot Support for Maps

Posted: Sun Feb 14, 2010 6:02 pm
by GypsyLlama
What a great way to get people to play our maps more hey Rabbi'd??

Set up itadday1, works great. I watched the bots fight each other for an entire round, was fast paced and entertaining. They more or less meet in the middle at the canal, but will occasionally cross to the other teams side.

Re: Adding Bot Support for Maps

Posted: Tue Feb 16, 2010 7:02 am
by Rab,d
Rab,d wrote:that was helpful info. Thx.

Here's .nav and .cmp for poldday1
It worked out pretty smooth on this one.
I improved the nav and cmp files and re-uploaded it.
Put this on the server please.

Re: Adding Bot Support for Maps

Posted: Wed Feb 17, 2010 7:44 am
by Rab,d
I have a few suggestions for the bots

-have them respond to the shouts "move out" or "attack". The bots all or the ones nearest to you will leave their campspot and move to the next one. It would be great if the direction that the player is facing when he yells "move out" is the direction that the bot goes.
-at the start of a map..i believe the bots pick a random camspot and/or the nearest ones. When they pick a random spot that is not in direct route it seems they try to go as a crow flys and sometimes there are parts of the map in the a horseshoe shaped map. Maybe just have them go to the nearest spots.
-have them only stay at a campspot for only maybe 15-30 seconds before they move on to another one, if no enemy is in sight...and that one should be further away from their spawn than the current one they are at.
-have spawnprotect kill them also.
-this may be tricky...allow players to assign temp campspots on the fly, in-game. Maybe with the "get down and fire" shout...the bots would stay there camping til the same or another player tells it to "move out"
-a functional bot medic would be kewl

Re: Adding Bot Support for Maps

Posted: Wed Feb 17, 2010 11:32 am
by Fafner
The only time they go in a straight line into walls is when they can't figure out how to get to where they're going or they don't have a campspot picked out for some reason (either when they're all taken or due to bugs I have to work on). I don't want them to go to just the closest spot because every game would be the same and they'd be too predictable and the bots would all stay on their own ends too much.

They already do move after a while only it's like 60 seconds instead of 30.

I'll probably add the spawn_protect thing eventually. I really don't mind when they do it so I haven't tried to fix it but it should be added.

I'd like to add the shouts thing & the medic, it might be a while before I get to them though.

Re: Adding Bot Support for Maps

Posted: Wed Feb 17, 2010 7:44 pm
by GypsyLlama
With some maps I had to completely leave out areas for navigation purposes. Itadday1 for instance had all the bots on the allied side jumping into the canal and going that way because it was the most direct route to the campspots. I had to completely omit that part of the canal otherwise every allied bot would go down it rather than going over land, which was easily faster than swimming.

Re: Adding Bot Support for Maps

Posted: Sat Feb 20, 2010 10:36 am
by Rab,d
Here are the files for poldday4, poldday5 and province_b2
They all worked out nice. I am getting much quicker at it. :)
I tweak them til i get ~even scores from them.

Re: Adding Bot Support for Maps

Posted: Sun Feb 21, 2010 2:09 am
by Fafner
Added the pol ones to Dirk's. I did province_b2 bots a week or 2 ago.

Re: Adding Bot Support for Maps

Posted: Mon Mar 01, 2010 9:20 am
by Fafner
New dll/code with some bot fixes & new commands:

The last version was messed up (removedoors removed everything but doors, oops) so make sure you get this if you want to make nav files.

Also added a couple commands that should help which I added to the first post "showlinks" and "removenode". Also you should use "sv dropnode" instead of "sv addbotroam" now.

I also worked on the objective code, they work much better now. I added this note to the first post:
*put exactly 1 campspot inside of objective_touches. That way when they are claimed, bots will leave and go to another campspot or objective*

Re: Adding Bot Support for Maps

Posted: Thu Mar 04, 2010 10:01 pm
by Fafner
Here is an updated dll that refines the previous one a bit so it works a lot better. I made it so the nearest campspot to each objective will only be used for objectives. When you use showlinks, those will be translucent. Also it fixes it so the bots laser doesn't disappear when they die.

I think the map crashing with complex nav files that was happening before was from using "sv addbotroam" too much. If you use "sv dropnode" instead I don't think you have to worry about making the map too complex.

I think it's a lot easier to add bot support to maps now. With removenode you don't have to worry about messing things up and starting over as much, and you can really see why things aren't working when you use showlinks.

Re: Adding Bot Support for Maps

Posted: Thu Apr 01, 2010 5:27 pm
by Rab,d
needs to be a sticky

Re: Adding Bot Support for Maps

Posted: Sun Apr 18, 2010 1:08 pm
by klompen
please make a zip file of all waypoints or a download section for waypoints so it would be easier to access for players and to put on servers . that would be cool. thanks :D
and yes sticky.