Tactical AI Kit: Interacting with NPCs
by Bryce · 07/12/2007 (10:04 pm) · 25 comments
Whew!
I've been spending the better part of the day working on some Artificial Intelligence code. I have no job, not old enough to even get a real job, so I need to save up to buy my Torque Engine code on something other than allowance.
So, I eventually decided that an Artificial Intelligence kit would be helpful to a lot of users trying to include some AI that does more than running a simple path. Then, I got an idea that has been almost untouched in Torque Games...Tactical AI! If I (somehow) manage to pull the whole thing off in Torque Script because that is all I have access to, I could see if GarageGames will post it on the product page so I can rake in some cash :-D
The first step to making pretty cool AI (IMHO) is to let the player be able to interact with them. Tell them where to go, to follow, regroup, take cover, et cetera, et cetera. That took me about six hours of coding today, and it was worth it. I've got 7 keys that all perform different commands to the AI. T, Y, U, I, O, P, and L.
The first step to interacting with my AI is to select one of them to feed commands into. By moving the crosshair over a nearby AI, I press the T key. A few variables are changed in the player's and the AI's code, and the AI's shapename is changed to look like >>> THIS <<<. Now, you can tell it to either execute orders upon receiving them or stand by, follow the player, look in a direction, move to a point, or select rules of engagement (Assault all Enemies, Return Fire Only, Hold Fire). Now, what makes a .plan file a .plan file, screenshots:
1. Here's "Tom" (I was using a random name generator based on some members' names you can find around GG) selected. You can see my ugly, untextured Spas-12 shotgun and some centerprint. The centerprint says "Tom: Standing by for new orders." In other words, you can activate this setting, issue a movement and look command without him performing the command, and when you're ready, you can hit the Execute Orders key and he will then perform them. Useful if you need to have him do something for you like barge through a door and clear a room, while you need to get to a position where you can deliver some covering fire first. If you have good eyes, you can see who we will be gunning down in the upper right.
2. Here, Tom is set to Hold Fire. When I took this shot he was executing the movement and look command I had given him while I prepared to cover him from behind the tree. Even though he sees "TARGET" out there about 50 feet, he won't engage, like I told him. Good Tom!
3. This I didn't mean to happen. I set Tom out to slowly approach TARGET, but I accidentally tapped the mouse button and the shotgun went off, kind of giving Tom away. No worries, before I told him to approach, I set him to Return Fire Only, and Tom did a good job of cover search and fire accuracy (probably not important with the exploding arrows, but still...) and killed TARGET. Good Tom! :-D
4. Here's me giving Tom the command to follow me around. Not much action here.
5. Look out, Bob! I set this scene up using the movement and execute orders commands. This sparks the idea of using my system to program in-game cinematics.
6. Here's me and Steve striking manly poses outside the Great Hall (you cant see it). We're about to gun down Bob with our M249's as soon as he steps out of cover. We've been in a pretty fierce firefight with him for about ten minutes now...Me and Steve finally won after I set him up to give me covering fire while I flanked him. Shoulda watched your six, Bob :-D
Well, I'd post a video, but my laptop is dead so I'm using my mom's Windows 98-based piece of junk to run Torque. A blazing 3 frames per second without Fraps, and a crash with Fraps running! Powerful :-p
I've been spending the better part of the day working on some Artificial Intelligence code. I have no job, not old enough to even get a real job, so I need to save up to buy my Torque Engine code on something other than allowance.
So, I eventually decided that an Artificial Intelligence kit would be helpful to a lot of users trying to include some AI that does more than running a simple path. Then, I got an idea that has been almost untouched in Torque Games...Tactical AI! If I (somehow) manage to pull the whole thing off in Torque Script because that is all I have access to, I could see if GarageGames will post it on the product page so I can rake in some cash :-D
The first step to making pretty cool AI (IMHO) is to let the player be able to interact with them. Tell them where to go, to follow, regroup, take cover, et cetera, et cetera. That took me about six hours of coding today, and it was worth it. I've got 7 keys that all perform different commands to the AI. T, Y, U, I, O, P, and L.
The first step to interacting with my AI is to select one of them to feed commands into. By moving the crosshair over a nearby AI, I press the T key. A few variables are changed in the player's and the AI's code, and the AI's shapename is changed to look like >>> THIS <<<. Now, you can tell it to either execute orders upon receiving them or stand by, follow the player, look in a direction, move to a point, or select rules of engagement (Assault all Enemies, Return Fire Only, Hold Fire). Now, what makes a .plan file a .plan file, screenshots:
1. Here's "Tom" (I was using a random name generator based on some members' names you can find around GG) selected. You can see my ugly, untextured Spas-12 shotgun and some centerprint. The centerprint says "Tom: Standing by for new orders." In other words, you can activate this setting, issue a movement and look command without him performing the command, and when you're ready, you can hit the Execute Orders key and he will then perform them. Useful if you need to have him do something for you like barge through a door and clear a room, while you need to get to a position where you can deliver some covering fire first. If you have good eyes, you can see who we will be gunning down in the upper right.
2. Here, Tom is set to Hold Fire. When I took this shot he was executing the movement and look command I had given him while I prepared to cover him from behind the tree. Even though he sees "TARGET" out there about 50 feet, he won't engage, like I told him. Good Tom!
3. This I didn't mean to happen. I set Tom out to slowly approach TARGET, but I accidentally tapped the mouse button and the shotgun went off, kind of giving Tom away. No worries, before I told him to approach, I set him to Return Fire Only, and Tom did a good job of cover search and fire accuracy (probably not important with the exploding arrows, but still...) and killed TARGET. Good Tom! :-D
4. Here's me giving Tom the command to follow me around. Not much action here.
5. Look out, Bob! I set this scene up using the movement and execute orders commands. This sparks the idea of using my system to program in-game cinematics.
6. Here's me and Steve striking manly poses outside the Great Hall (you cant see it). We're about to gun down Bob with our M249's as soon as he steps out of cover. We've been in a pretty fierce firefight with him for about ten minutes now...Me and Steve finally won after I set him up to give me covering fire while I flanked him. Shoulda watched your six, Bob :-DWell, I'd post a video, but my laptop is dead so I'm using my mom's Windows 98-based piece of junk to run Torque. A blazing 3 frames per second without Fraps, and a crash with Fraps running! Powerful :-p
About the author
#2
but maybe in stead of assigning 7 keys with will be difficult for a player to remember plus it takes use of a lot of keys you can assing one button with will open a menu and therout you can select your action or you can make it totaly awesome and make it dynamicly for example, you aim at a box, and you press the AI key(lets say "H") and a menu opens with, go there, take cover behind the box and such things, while aiming at an enemy you can go like you did before, return fire only, fire at will and such things
just making suggestions here ;)
07/13/2007 (12:10 am)
cool ^^but maybe in stead of assigning 7 keys with will be difficult for a player to remember plus it takes use of a lot of keys you can assing one button with will open a menu and therout you can select your action or you can make it totaly awesome and make it dynamicly for example, you aim at a box, and you press the AI key(lets say "H") and a menu opens with, go there, take cover behind the box and such things, while aiming at an enemy you can go like you did before, return fire only, fire at will and such things
just making suggestions here ;)
#3
07/13/2007 (12:13 am)
Maybe we should all chip in and buy BrYcE a license :)
#4
@Andy: Very good, my mischeivious plan has worked......hehehe
07/13/2007 (12:15 am)
@Florian: That's a good idea. I'll implement that, but I will keep (maybe change to a more conveinient spot on the keyboard?) the key bindings. If the player and his team are ambushed, the player shouldn't want to watch everyone get shot at while he fiddles around with that little GUI :-)@Andy: Very good, my mischeivious plan has worked......hehehe
#5
07/13/2007 (3:04 am)
illd buy it, especially if the bots know when to duck behind cover, reload,crouch e.t.c
#6
Interaction (duh!)
Reloading as needed
Cover searching
Coming soon:
A-star pathfinding for interiors! I'll get to it tomorrow.
Point and Suppressing Fire on targets
Firing from cover
07/13/2007 (4:01 am)
Features right now:Interaction (duh!)
Reloading as needed
Cover searching
Coming soon:
A-star pathfinding for interiors! I'll get to it tomorrow.
Point and Suppressing Fire on targets
Firing from cover
#7
07/13/2007 (5:07 am)
Awesome work!
#8
07/13/2007 (6:05 am)
I'll contribute to the Bryce Torque fund.
#9
07/13/2007 (7:03 am)
I would buy it as well :D
#10
07/13/2007 (10:16 am)
If you price the AI pack at $20 US then it'll take about 15 of us to buy it to cover your license of TGEA or 8 or us to cover your cost for TGE. Also if you can do this all using TorqueScript it means no engine recompiling which is my pet fav.
#11
07/13/2007 (12:29 pm)
Thanks for the positive feedback, everyone. Going to put together an A-star algorithm and implement Florian's idea today. Wish me luck!
#12
07/13/2007 (1:51 pm)
Hi ya remember me? Little of topic but can you make player.dts files? I need a viking for this dudes game and I suck at DTS!
#13
07/13/2007 (1:52 pm)
yeah I'll buy it.
#14
07/13/2007 (1:55 pm)
Hey I may be able to provide you some support. contact me. calmasacow@yahoo.com
#15
@James: Right now, I have everything going smoothly. If I have any questions I'll contact you.
07/13/2007 (2:35 pm)
@Jacque: Yes, that was a little off-topic :-). My player.dts models suck too, you may want to try the 3d modeling forums or check the help wanted section (community->marketplace).@James: Right now, I have everything going smoothly. If I have any questions I'll contact you.
#16
07/13/2007 (4:16 pm)
Your doing a good job there, I'd pay $20 for it as well to help towards a license, as Ian said about the crouch and hide scenario if thats in there as well it'll be "wicked", the popup menu system reminds me of TomClancy's GhostRecon (pc version) which i think would be cool as well
#17
07/13/2007 (4:44 pm)
EDIT: dumb question
#18
07/13/2007 (4:47 pm)
I meant possibly providing you with resources for you development. you stated that you do not have TGEA or a very good system. but if you are not interested.
#19
07/13/2007 (4:51 pm)
Good stuff Bryce. I'd say your skills are ahead of your age.
#20
07/13/2007 (4:55 pm)
@James: No thanks, not interested. But thank you anyway!
Torque Owner Chris "C2" Byars