Zombie Brains
July 21, 2007
It seems like only yesterday I was writing an update for the Dream Game competition, when it was a whole week ago. I’ve been really busy this week, and I think I didn’t notice the time go because I was working long and hard on one problem – zombie brains.
I was updating the AI and pathfinding for the monsters in Inspire all this week. I say zombie brains because that’s about the level of intelligence they were at, and aren’t much better now. I’m not that great at maths, vectors and algorithms, but I’m getting by, and continuously learning.
So the old AI system had them scanning around them, if they spotted an enemy they would walk straight towards it and try and kill it, simple as that. If there was no enemy, they would try to capture the player’s spawn point, ending the game. That’s ok, but I wanted them to be a bit smarter. There’s other objects of interest, like their friends, enemies, powerups, items etc around that they need to decide how to deal with. There’s also the problem that each monster is solid with a collision box, so they can’t just pass through each other to get to these objects.
So this week I had to add decent pathfinding to their brain, so they would navigate their way to their target. This is all done in script, without prebuilt nodes on the map as well. It’s more of a best fit system – monsters get a target, and try to walk straight there. If there’s an obstruction closer than 5m then they will scan the locations around themselves in a 3×3 virtual grid, in an attempt to navigate around it. There’s more to it than that, but that’s the basic principle, and the system still needs a lot of work.
The other AI system is the threat system. Individual monsters decide what action to take personally by their own threat list. When they scan around themselves, they build up a list of enemies with their personal threat levels. They can then attack the player or tower who tops that list. That’s normally the entity which is doing the most harm to it. There is a second, meta layer to the AI. When an event happens to a monster, they ‘yell’. This yell is something only other monsters can hear, and it tells a global manager about the event. If a monster is down to 50% health, he may send out a ‘heal me’ yell. Each scan cycle, other monsters will check the global threat list. If one has the ability to heal, he will accept that yell, and his next goal will be to try and heal the hurt monster. This works for as many situations I add. There is 2 components to a situation – the specifics of an event, and if another monster has the feat to deal with those specifics.
So the system is working so far, but still needs polishing and testing, to make sure nothing odd happens, as is the case with procedural functionality.