Vampire: The Masquerade - Bloodlines Designer Diary #7
Programmer Dennis Taylor explains how vampires and humans alike will be powered by artificial intelligence.
We'll begin emailing you updates about %gameName%.
Though there are a number of high-profile role-playing games on the horizon, one of the most tantalizing and intriguing is Vampire: The Masquerade--Bloodlines. The game, which is set in the rich role-playing universe of White Wolf's popular Vampire: The Masquerade pen-and-paper game, is powered by Valve Software's Source engine, the same technology being used for Half-Life 2. In Bloodlines, you'll be able to play as a vampire in the Los Angeles underworld, interacting with the various clans while you choose your own destiny. In the latest chapter of our designer diaries, programmer Dennis Taylor tells us about the game's artificial intelligence and how humans and vampires will behave realistically.
Smart VampiresDennis Taylor
Programmer, Troika Games
The artificial intelligence in Bloodlines is broken down into several core components. Anyone who has worked with the original Half-Life or Quake scripting language will recognize the core elements (even though much of the code that controls these elements underneath has changed). Most of the AI's work is done by conditions, tasks, schedules, and states.
Conditions are the AI's representation of the world around them. They mark things that a non-player character might choose to react to. This includes more mundane things like sight and hearing. It also includes more conceptual things, such as whether the NPC would like to block an incoming attack or whether it can pounce on the player. These conditions are used to switch NPCs between the different states and between different schedules within each state.
Tasks are tiny chunks of functionality that an NPC can perform. A task might be telling the NPC to start using a specific animation, to fire a weapon, or to find a path to a target.
Schedules are lists of these tasks, and they provide a general action for an NPC to perform. For example, there can be a schedule to perform a melee attack on an enemy. In order to do that, the NPC would need a task to find a path to the enemy, a task to walk to the enemy, a task to face the enemy, and one to swing its weapon. At any time, a condition can interrupt this schedule to allow the NPC to respond in a timely manner to important events. If an NPC is walking to go press a button, you probably wouldn't want it to continue if it got shot on the way there. At that point you would want it to run away or fight back or even die.
The final element in the AI code is the state. A state is the highest level of the elements. It determines in general what types of actions the NPC is looking to perform. An NPC can be in an idle state, doing whatever it is normal for that type of character to be doing. While in an alert state, the NPC is cautious or expecting something to happen. Or an NPC can be in a combat state, actively attacking an enemy.
Currently, our AI has the following main states:
- Idle: NPC is going about its normal routine--walking about, patrolling, or talking to buddies.
- Alert: NPC is alerted to the player's presence. NPC investigates foreign sounds and sights.
- Combat: NPC is actively engaged in combat with an enemy.
- Hunting: NPC was in combat, but lost track of the target. NPC combs the area looking for its target again.
- Fleeing: NPC is afraid of someone or something and will run and hide in a corner.
There are also a few special-case states:
- Dead: NPC is, well, dead.
- Dialogue: NPC is locked in dialogue with the player.
- Script: NPC is playing a scripted sequence or cinematic.
- Criminal Suspicion: NPC (cop) is warning a player about doing bad things.
- Oblivious: NPC is mesmerized or dazed.
What an NPC will do in each of these AI states depends on its class. There are several different classes of NPCs in the game, each with its own unique behaviors.
One of the major classes of NPCs you will encounter often in the game is the pedestrian class. When they are idle, pedestrians will walk around looking for things to do. Some like to dance. Some like to window-shop. Some are bums who like to sit by the fire with a little brown bag.
All pedestrians will obey the traffic laws and wait at crosswalks and won't jaywalk. That is, unless you scare them. Normally you want to try not to break the laws or break the masquerade, but when you do, all hell breaks loose. Pedestrians panic very easily.
You will also meet a lot of thug guards. Much of the game is set up to allow for stealthy characters to find noncombat solutions to finishing the levels. So you can expect to see a fair share of guys on patrols or performing some interesting activities. It can be great fun to listen in on the conversations that the NPCs are having or sneaking up and catching them off guard playing a game of cards.
So long as the player successfully sneaks around, most levels will be much easier. But NPCs can be alerted by many different things. The player could alert them by walking too close and making audible footsteps, firing weapons, walking in lighted areas, knocking over physical objects, and so on. Then the NPCs will come and check out what's going on. Of course, this can be to the player's advantage, as you can use it to lead them away from key places.
A lot of work has gone into providing the player with a believable stealth experience during the game. But if the player fails to be stealthy, or simply chooses not to be, you will encounter plenty of characters fully willing to go toe-to-toe in ranged or melee combat with you.
The ranged combat borrows as much as possible from Half-Life 2's ranged combat. Most combatants will also try to find places to shoot at you from behind cover. They will kick things at you or kick them over and use them for cover. They will dive behind crates and tables to get out of the way.