Game Development Community

Tactical AI Kit: Squad Movement and Other Stuff

by Bryce · 02/20/2009 (3:52 pm) · 7 comments

Hello Everyone!

I thought I'd keep up the documentation on the Tactical AI Kit. I've finally addressed a lot of old ideas I had scribbled down a few months ago that I was too lazy to implement.
Every couple weeks or so, I have one of my gamer friends I know come over to my house and test out my AI implementation, give me suggestions, tell me what sucks, point out bugs, etc...He has been telling me to figure out why the player's squad AI “is so retarded” and fix it so they can be a little more helpful, rather than just getting in the way.
There were a lot of bugs in the squad code, mainly due to my messy, hacky code with random blocks commented out and things that don't make sense. I finally cleaned up the squad code so it's readable, which assists me in my next step: fixing the bugs. A lot of people who played my last AI demo complained that the squad members bunched together too closely and crowded the player into corners. The stuck avoidance system was conflicting with the squad members, because when I would order them to move somewhere, all three would be trying to land on that point, which would cause them to run into each other, go into wild spins, and look incredibly dumb. I finally added a system that modifies the move position for each squad member, so they will move to path nodes or cover points within a radius of the move position that was ordered. This way, they spread out, get stuck far less, and stand in a way that makes sense.
If an NPC moves to a nearby cover point, they will animate properly (hide, lean out of cover, etc) to search for threats. The cover they move to depends on the ordered move position, and the direction the player wants them to move (so they take cover in the direction they are advancing, where enemies are most likely to be present).

img261.imageshack.us/img261/5489/13745091ox9.pngimg261.imageshack.us/img261/2865/20757875hp5.jpgimg261.imageshack.us/img261/1025/38424597zg9.jpg
Another thing I added was a rules of engagement system. It's a work in progress, but it is looking very good right now. Rules of engagement for a squad can currently be Fire at Will, or Return Fire Only. This can be toggled by the player using the 'o' key, or by setting the squad's roe value to 0 or 1.
Under Fire at Will mode, the squad members operate like they normally do, moving quickly and shooting threats on sight. Under Return Fire Only mode, things are a little different. If you were given an order to only shoot at enemies if they see you, you would probably do as much as you can to not attract the enemy's attention, correct? Keeping this in mind, I created a stealth behavior for the squad members. Squad members in return fire only mode will move slowly, crouch as they near their destination, and stay hidden however they can. They won't shoot at enemies unless that enemy fires upon them or their squad, or if the enemy is facing them and is close enough (they think that they have been spotted, kill him before he can shoot).
This system is still a work in progress...in the future, I want them to be able to calculate paths that go through low-visible areas. I would rather they not move down a street in the open, but instead take a small alleyway that runs parallel to the street to lower the chances of being seen.

img11.imageshack.us/img11/9151/82507822wd3.pngimg11.imageshack.us/img11/9135/70269096ki0.png
The last feature I added was an idea I had a few months ago to improve the reaction system. Before, NPCs would only be able to react and take cover based on where they heard gunfire. If the player happened to be using a silenced sniper rifle from far away, the NPC would have no idea where he should take cover.
Even if there is no solid knowledge of where the sniper may be, the NPC should still be able to make an educated guess as to where the attacker may be hiding. By using information about his orientation, the walls and other environmental objects surrounding him, and the position that the hostile bullet landed, the NPC can figure out a logical place to expect the sniper to be, and will then take cover from that position. An NPC sitting in a skyscraper office who notices a bullet fragment the wall behind him will be able to check the distances and positions of the objects around him (in his case, the walls) and decide that the bullet probably came through the window from an adjacent building, and would take cover behind his desk. The scary thing about this system? Most of the time, the NPCs are right. They would take cover behind a stack of crates, poke their head out for a second, look almost right at me, and hide.

img261.imageshack.us/img261/7087/69023641ma2.png
One more feature I added was reaction to gunfire. One thing NPCs didn't do before was check to see what was going on when they hear gunfire outside the house they are in. Now they do, and things become much more realistic as you notice enemy backup arriving at a firefight, completely unscripted.

That's all, folks. Remember to leave a comment, feedback is what encourages me to add on to this project!

VIDEO:
www.youtube.com/watch?v=4onwnb2Lq6M

#1
02/20/2009 (4:02 pm)
Sounds like your doing great with progress and bug fixing. Keep it up!
#2
02/20/2009 (4:07 pm)
Yes indeed, keep up the good work! It sounds like your kit will be a great addition for just about any FPS type of game. I've been following your blogs and my interest remains high.
#3
02/20/2009 (4:12 pm)
Totally awesome man. I defiantly see this kit taking off once you're all said and done with it.

Here's a suggestion not that you need one, but you could have a script where certain guys loose their cool under fire.

You could have a random guy not react well to a fire fight and either charge at you or run and hide pleading for his life kinda deal (maybe if you're fighting a group of guys and you kill all of them but one off and he realizes that he doesn't have a much of a chance to live through it). Again just an idea to make the people seem more human, but again up to you.

Edit: another idea for you just because you asked.

Another idea you could use is the good old human shield idea. Say you're fighting a group of guys and one of the enemies is hit and hurting but not dead, you could have another heartless enemy grab him and force him to stand as his shield. This could also work the other way round as in you hit one of the enemies, he's down and hurting but still alive, but his buddy was on his squad so he runs to him a little more carelessly than he should cause he's worried bout his bud or charge you cause he's pissed his friend is downed (this working with the earlier idea).
#4
02/21/2009 (12:25 am)
This is looking really good. Very exciting stuff.

If the enemy is disturbed and goes off to see what is happening from gunshots, noise etc and they find nothing do they go back to guarding the house?
#5
02/21/2009 (5:58 am)
Very cool... I always love hearing about the kit! Is the desert environment new, or is it the end of the old demo level? (I haven't finished the demo, admittedly :P.)
#6
02/21/2009 (6:24 am)
Edward: If they hear gunshots, they won't go back to guarding the house. They will raise their alert level, and wander around the area while looking in all directions. If the gunshots are close enough (by default it's 50 I think, but this can be changed via a global variable), the NPC will cautiously move to that location to see if anybody is in danger.

Daniel: I've got a lot of random levels that I built to make it easier to test out the AI. The desert level you see in the video is new, but it's just a small area with a few cars and a wall so that I can see how well NPCs can find snipers. Some missions I added are a palace (testing close-quarters combat), sniper town (the player is looking out the window of a tall apartment building onto the town of enemies below, another sniper test level), the AI-rigged Stronghold (I added the spawn points, cover points, and path nodes. It's fun to do stealth infiltrations there :-D), and I've been considering adding a Ghost Recon 1-style city to make a lot of firefights happen at once. I don't think all will be in the next demo, but I will add the palace, sniper town, AI stronghold, and that city if I ever decide to build it.
Also, if you're interested, the second screen is the ending of the last demo mission, just graphically enhanced :-)
#7
03/03/2009 (10:46 am)
nice to see this advancing. keep it up