Creating compelling Artificial Intelligence on games can be a very challenging task, as a well done AI system can make a big difference (good) for your game, whereas a bad and dumb Artificial Intelligence (many call Artificial Stupidity lol) can completely break your game.
In the last 40 years gaming technology evolved immensely in all aspects, especially in regards to Artificial Intelligence.
We can say that enemies evoluted from small pixels moving into a simple line of the screen trying to "touch" the player, or shooting some pixels against the player "spaceship", in games like Space Invaders:
To real life human behaviour in games like Tom Clancy’s Splinter Cell: Blacklist, which is considered by many a revolution. Splinter Cell is an action-adventure game that relies on stealth and strategy in the gameplay. Splinter Cell: Blacklist is a trully gem of the Stealth Genre. The opponent AI gets into the details. AI responds to every move made by the player and acts accordingly. Be it the different maneuvers in the game, the “Guard AI” is simply exceptional:
I know that for just one person, a solo developer, is almost impossible to create a very advanced AI System (in the same level of Splinter Cell) for a game. But we can do something very similar.
So it took for me almost one month of intense work, research, tutorials, and headaches :D to be able to complete the creation of the Enemies AI for my game, using Kismet, the Visual Programming Language of Unreal Engine 3.
The first step is to recognize your limitations. Because of that I decided to nail down the enemies AI behaviour to just 3 kinds of AI, which I call Enemies AI Types: Cover & Shoot, Patrol Move and Patrol Idle.
I always try to make things simple for me, as I am not by any means a professional programmer, just a crazy dude diving into the world of game development. I prefeer to make simple features which work perfectly rather than making too complex features which are broken.
The second step was to study these series of tutorials from Digital Tutors, about Creating AI Algorithms in Kismet:
The third step, and the hardest one, was to get my dirty hands on it :D
I can't give all details, step by step of the creation of the enemies AI, but I will try to summarize it, so anyone can understand and have an idea of how it works.
The basic behaviour pattern of the Cover & Shoot AI is to move to the closest cover object as soon as it spawns (I placed manually these cover objects on the map). Then he crouches by some seconds (random value between 1 to 2.5s), then he stands up and looks for the player. If the player can be seen, he shoots at the player by some seconds (random value between 1 to 2.5s), then he crouches again. If the player can't be seen whenever the enemy is standing, the enemy randomly moves to another cover point. I can make the enemy move to as many cover points as I want, however, for the sake of simplicity, I decided to stick to 2 cover points for each enemy.
But for increasing the challenge, as I want to make my game HARD, I added a shooting function to the enemy whenever he is moving from one cover point to another. So in this translation, if the player can be seen, the enemy shoots at the player. That's very important otherwise, the player could kill the enemy by simply awaiting the soldier move to another cover point.
And the Patrol Move Behaviour is more simple. The enemy walks, patrols between two, three or four points going forth and back, walking, and if he sees the player, he shoots at him while moving to another patrol point (like evading from the player).
The last AI Behaviour, Patrol Idle, as the name says, the enemy does not move from his point. He stays idle waiting to see the player, and whenever the player can be seen, he shoots at the player, without moving from his spawn point. This AI Behaviour is to facilitate the perform of knife kills by the player, as it is hard to do the knife kills while the enemy is moving, because the knife kills code needs that the player be at a specific distance from the enemy. So with the enemy idle, it helps for this effect to work.
Last but not least, is that each AI Behaviour needs some specific character animations sets, and the setup of the enemy properties, like speed. Patrol Move has a slow speed, as it walks, does not run. It needs aswell walking locomotion animations, which is different from Cover and Shoot, which runs instead of walking (so it needs running locomotion animations), and also have the crouching and standing up animation. The Patrol Idle Behaviour has a looping patrolling idle animation.
I hope have been able to at least explain the basic idea of the enemies AI on Fursan al-Aqsa Game.
Cheers and until next update.