top of page

ENEMY ARTIFICIAL INTELLIGENCE

I’m only a scripter, not a programmer, but I know I need to give my enemies some sort of Artificial Intelligence (AI) in order to make them fun to fight against. After all, who really likes to just beat up on dummies who stand still? While it might be good practice to hone in-game skills, it is definitely not fun to encounter them in combat. I knew I wanted to focus on two enemy types, one being ranged and one melee, in order to create a basic combat scenario that allowed for the player to make choices during combat.

I immediately knew what I wanted to do with the ranged enemy in terms of behavior. First off, it would act as a sort of immovable turret. Since it couldn’t move, I didn’t just want it act like a regular turret, it had to have a defining feature that would make that enemy memorable. And so I thought up two functions that dealt with Line of Sight (LoS) to the player. If the enemy had a direct LoS to the player with nothing obstructing its view, it would fire a high speed arrow in a straight line directly at the player’s chest. By the way, the ranged enemy uses a bow and arrow as their ranged weapon of choice. But what if the LoS to the player was obstructed? I wouldn’t want the enemy to fire an arrow unto the Terrain for no reason or even shoot a friendly unit in the back. So, when LoS is obstructed, the enemy would instead fire an arcing arrow into the air and is aimed directly at the player’s head. This slow moving arrow would arc through the air and hit the position where the player is at when the enemy releases the arrow. This way, the player must be wary of facing ranged enemies when dealing with melee enemies at the same time but they need to physically look towards the sky around them to make sure no arrows are coming to deplete the player’s health. I think this type of dynamic physicality of looking around the battlefield that makes a very good use of the Oculus Rift’s tracking and allows for a more immersed combat experience.

The melee enemies were a bit trickier and I didn’t think of a better melee system until I decided that there had to be two melee-type enemies. Originally, I had scripted the melee enemy to simply rely on LoS to the player and attack the player, if within an aggression area, with basic swinging attacks; this melee enemy uses a sword. It felt boring and didn’t bring the same dynamic that the ranged enemy did. So I decided to change the behavior of the melee enemy so that instead of simply charging the player and attacking when presented with the opportunity, it should move to a specific position away from the initial reach of the player and being charging a sword-based skill to unleash after a set amount of seconds. I liked this idea and how it worked within the combat system but it was still not complete for a vertical slice. It was here where I thought I should have a second melee-type enemy to play off of my current melee enemy to create that dynamic combat experience. I changed the first melee enemy to be a small enemy that tends to stay in groups while the second melee enemy is a big creature that swings around a massive sword or ax with basic attacks against the player. The big melee enemy would simply charge the player, so that they position themselves out of reach of the player but within reach of its own attack, and just hammer away with basic swinging attacks against the player. I felt this was the perfect answer in regards to bringing in that dynamism that the ranged enemy did. Having to battle a big melee enemy while being wary of the smaller melee enemies and their charged attacks gives the player a lot of different options in how, when, and in what order the player should dispatch their foes.

One combat scenario could be one ranged enemy on a ledge, one big melee enemy, and three small melee enemies in a group. The player will have to think about several things in order to deal with this setup of enemies:

  • How far is the ranged enemy?

  • Can I take out the ranged enemy first?

  • How much of a problem does he pose if I ignore him?

  • Should I take out the big enemy first?

  • His basic attacks are weaker than the charging enemies but he is the most annoying with faster attacks.

  • Should I take out the small enemies first?

  • Their charged attacks hurt but they are easier to pick off.

  • Should I block some attacks?

  • Should I evade some attacks?

  • Which spells would help me best here? (I will talk about spells in a future post)

  • Do I have enough Health and Mana to take on this group?

  • Should I just brute force everything and just block/evade whatever I can?

I think that if I’m able to create situations where the player thinks and strategizes on how they are going to approach and deal with the enemies, and have fun while doing so, then I would have done my job well in creating the AI for these enemies as well as the combat system.

Single post: Blog_Single_Post_Widget
bottom of page