Adding Bot Support for Maps

Topics related to map making for D-Day.
User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Adding Bot Support for Maps

Post by Fafner » Tue Oct 13, 2009 12:00 pm

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

MAKING THE .NAV 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:
Image


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!

"removenode"
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.


ADDING CAMP SPOTS
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:
team
location
angle
stance

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)

OBJECTIVES
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.

ROTATING DOORS
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.

BRIDGES/WINDOWS/DESTROYABLE OBJECTS
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.

CUSTOM SPAWNS FOR BOTS
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.


"showlinks"
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.
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
PowaBanga
Posts: 241
Joined: Wed Aug 12, 2009 5:25 am
Location: Belgium
Contact:

Re: Adding Bot Support for Maps

Post by PowaBanga » Sun Oct 25, 2009 7:27 am

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...
You can join me on IRC : in irc.quakenet.org chan : #ddayhome or on Freenode, chan #ddaynormandy .
Do not hesitate to type my pseudo to highlight me.
Or open an issue on github to highligh me by mail.
RSS

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Sun Oct 25, 2009 11:09 am

Do you type "sv savenodes"?
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
PowaBanga
Posts: 241
Joined: Wed Aug 12, 2009 5:25 am
Location: Belgium
Contact:

Re: Adding Bot Support for Maps

Post by PowaBanga » Sun Oct 25, 2009 12:50 pm

this comand work, thanks you :D
You can join me on IRC : in irc.quakenet.org chan : #ddayhome or on Freenode, chan #ddaynormandy .
Do not hesitate to type my pseudo to highlight me.
Or open an issue on github to highligh me by mail.
RSS

User avatar
simbioz
Posts: 122
Joined: Mon May 19, 2008 1:45 pm
Location: Chile

Re: Adding Bot Support for Maps

Post by simbioz » Thu Oct 29, 2009 11:25 am

What about the q2 stock AI code?

User avatar
InFerNo
Developer
Developer
Posts: 4371
Joined: Mon Aug 25, 2003 11:07 am
Location: dday2
Contact:

Re: Adding Bot Support for Maps

Post by InFerNo » Mon Nov 02, 2009 7:52 am

What about it?
Image

User avatar
simbioz
Posts: 122
Joined: Mon May 19, 2008 1:45 pm
Location: Chile

Re: Adding Bot Support for Maps

Post by simbioz » Tue Dec 08, 2009 7:17 pm

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?

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Tue Dec 08, 2009 9:43 pm

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.
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
Dirk
Developer
Developer
Posts: 1956
Joined: Mon Oct 20, 2003 12:51 am
Location: Ohio
Contact:

Re: Adding Bot Support for Maps

Post by Dirk » Wed Feb 10, 2010 2:30 am

If you make some .NAV files, send them to me and I'll upload them. Please verify that they work first.
Image

User avatar
GypsyLlama
Site Admin
Site Admin
Posts: 2905
Joined: Wed Aug 20, 2003 6:06 pm
Location: Beautiful British Columbia
Contact:

Re: Adding Bot Support for Maps

Post by GypsyLlama » Fri Feb 12, 2010 4:59 pm

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
Attachments
rmg4botsupport.rar
(5.93 KiB) Downloaded 310 times
Image

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Fri Feb 12, 2010 7:43 pm

Added :smt069
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
Rab,d
Developer
Developer
Posts: 3301
Joined: Tue Dec 21, 2004 5:20 pm
Location: Charlotte, NC USA
Contact:

Re: Adding Bot Support for Maps

Post by Rab,d » Sat Feb 13, 2010 8:17 pm

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.
Attachments
grand_bot.zip
(10.9 KiB) Downloaded 295 times

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Sat Feb 13, 2010 9:27 pm

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.
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
Rab,d
Developer
Developer
Posts: 3301
Joined: Tue Dec 21, 2004 5:20 pm
Location: Charlotte, NC USA
Contact:

Re: Adding Bot Support for Maps

Post by Rab,d » Sun Feb 14, 2010 12:18 pm

that was helpful info. Thx.

Here's .nav and .cmp for poldday1
It worked out pretty smooth on this one.
Attachments
poldday1_bot.zip
(11.37 KiB) Downloaded 284 times
Last edited by Rab,d on Tue Feb 16, 2010 6:59 am, edited 1 time in total.

User avatar
GypsyLlama
Site Admin
Site Admin
Posts: 2905
Joined: Wed Aug 20, 2003 6:06 pm
Location: Beautiful British Columbia
Contact:

Re: Adding Bot Support for Maps

Post by GypsyLlama » Sun Feb 14, 2010 6:02 pm

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.
Attachments
itadday1botsupport.rar
(5.74 KiB) Downloaded 327 times
Image

User avatar
Rab,d
Developer
Developer
Posts: 3301
Joined: Tue Dec 21, 2004 5:20 pm
Location: Charlotte, NC USA
Contact:

Re: Adding Bot Support for Maps

Post by Rab,d » Tue Feb 16, 2010 7:02 am

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.

User avatar
Rab,d
Developer
Developer
Posts: 3301
Joined: Tue Dec 21, 2004 5:20 pm
Location: Charlotte, NC USA
Contact:

Re: Adding Bot Support for Maps

Post by Rab,d » Wed Feb 17, 2010 7:44 am

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 way...like 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

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Wed Feb 17, 2010 11:32 am

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.
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
GypsyLlama
Site Admin
Site Admin
Posts: 2905
Joined: Wed Aug 20, 2003 6:06 pm
Location: Beautiful British Columbia
Contact:

Re: Adding Bot Support for Maps

Post by GypsyLlama » Wed Feb 17, 2010 7:44 pm

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.
Image

User avatar
Rab,d
Developer
Developer
Posts: 3301
Joined: Tue Dec 21, 2004 5:20 pm
Location: Charlotte, NC USA
Contact:

Re: Adding Bot Support for Maps

Post by Rab,d » Sat Feb 20, 2010 10:36 am

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.
Attachments
addbots_1.zip
(16.64 KiB) Downloaded 304 times

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Sun Feb 21, 2010 2:09 am

Added the pol ones to Dirk's. I did province_b2 bots a week or 2 ago.
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Mon Mar 01, 2010 9:20 am

New dll/code with some bot fixes & new commands:
http://www.ddaydev.com/downloads/dday5012.zip

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*
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
Fafner
Developer
Developer
Posts: 3637
Joined: Sun Jun 29, 2003 2:04 pm
Contact:

Re: Adding Bot Support for Maps

Post by Fafner » Thu Mar 04, 2010 10:01 pm

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.
Attachments
dday5013b.zip
(252.23 KiB) Downloaded 294 times
1RB: http://www.1rb.mav.net
Speedway: http://www.ddaydev.com/speedway
If you need help, start a thread. That way other people can learn from the information given. DON'T PM ME unless it's necessary.

User avatar
Rab,d
Developer
Developer
Posts: 3301
Joined: Tue Dec 21, 2004 5:20 pm
Location: Charlotte, NC USA
Contact:

Re: Adding Bot Support for Maps

Post by Rab,d » Thu Apr 01, 2010 5:27 pm

needs to be a sticky

klompen
Posts: 4
Joined: Sat Apr 17, 2010 9:15 pm

Re: Adding Bot Support for Maps

Post by klompen » Sun Apr 18, 2010 1:08 pm

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.

Post Reply