Game Development Community

AI Under Heavy Fire

by none · in Torque Game Engine · 05/14/2010 (10:00 pm) · 1 replies

Hey everyone! Sorry for the large amount of questions lately, but I have actually been learning quite a lot from them. I have successfully integrated the Killer Kork resource into my project, but there is something I would like to add to it, which I believe will not be too difficult, but nonetheless, I need some help to add it. Here's what I'm looking to do: When 4 or more explosions (not just small arms fire) occur within a certain distance from he AI Player, he will run for the nearest interior. Any pointers? Please try to give detailed explanations if possible, I want to dissect it as best as possible. Thank you!!!

#1
05/15/2010 (3:08 am)
Not going to go into too detailed a solution - I can't really claim to have the expertise (nor the time! ;P). But hopefully I can help you start to solve the problem yourself.

Break it down - what is involved in this behaviour?

1. Sensing the explosions somehow. You need to know that an explosion occurred, where it happened, and maybe whether it was friendly fire.

2. Deciding when enough is enough. This might just be an 'explosion counter' on the AIPlayer that you increase when explosions happen and decrease over time, or you might like to tie it to a generalised 'stress level' you can use for other things. Either way, somehow you have to decide when the AIPlayer will break, and integrate this with Killer Kork's existing AI (I believe it's a state machine, so it shouldn't be too difficult to add a new state).

3. Finding somewhere to run. I guess this will basically entail finding the closest interior then moving there, but how will the AI know the exact location to run to? You could treat the interior as a convex block and just run to the nearest corner, which will hopefully put you out of sight behind the building. Or you could do something more advanced like adding 'cover' nodes in the world editor, which belong to the building somehow (maybe in a SimGroup with the building), and choosing one of those to run to.

4. Optional - deciding when it's safe again! This doesn't really need to be here - hopefully your regular state machine can take over once the character has reached cover.


A word about detecting explosions. It might be tempting to have explosions do a radius search for nearby characters, which does make some sort of sense, since it is the explosion that 'causes' the stimulus. However, I'd recommend looking at this resource instead.