Even the best of combat systems would be for naught, if the enemies stood motionless waiting to be decapitated. That’s why we put so much effort into improving the AI of our demonic creatures. Today we want to tell you more about the Artificial Intelligence in general and how it exactly works on the example of the Skeleton hordes in Hellraid.
Let’s start with the basics: what the AI of the in-game enemies really is. To put it simply, it’s a collection of abilities and actions, the interdependencies between them, and the rules of their occurrence. Many game developers try to predict single-handedly dozens if not hundreds of various situations that may occur in the game and then include them in the code. With Hellraid, though, we use a more advanced technique called HTN Planner. Not only does it analyze scrupulously the whole situation around any AI unit, but also adjusts their behavior to dynamic changes of gameplay conditions.
You can say that the HTN Planner is a kind of the AI’s thought process that also checks if particular conditions have occurred. The first stage is to determine if the enemy should see or hear the player at the moment (for example, they can be separated by a wall) and consequently take any action. The subsequent stages are concerned with the distance between them, the terrain configuration and placement of obstacles, other AI units nearby, and so on.
An important element of the HTN Planner are the tools that measure the duration and frequency of given actions. This way, the AI is never caught in a loop of infinitely repeated actions. The result is obvious: the enemy doesn’t walk in circles and uses more than one type of attack.
The simplest example of AI is a Skeleton that approaches the player and attacks him mindlessly the moment it sees him.
When we started the development of Hellraid, we set the goal to have very aggressive AI. However, the result was quite disappointing. The Skeletons would swarm the player and attack all at once. Soon it became clear to us that it wasn’t such a good idea.
The Skeletons would either walk in a single file like geese or clog a narrow corridor. What’s worse, when they got to the player, they would obscure his or her field of vision completely. Not only did the player have no chance of escape, but she or he couldn’t even fight back, because the incessant storm of blows from all sides blocked the player’s attacks.
After a series of playtests, we came to the conclusion that the Skeletons should be smarter as well as more creative. The first step was to divide the Skeleton hordes into subgroups based on their battle skills: from typical cannon fodder, to cunning units, to the formidable Skeleton Warriors. Their skills are reflected in the equipment, which we discussed earlier.
Another decision was to make their behavior more realistic. We knew they should resemble the actual reactions of warriors from a real battlefield as much as possible. We will tell you how exactly we achieve it in our next blog update. Till next time!