Scripting


Of course, game AI does not need to spontaneously think up every behavior that is performed in the game. In some games, a combination of dynamic AI with predetermined paths and scripted behaviors may create the most exciting experience possible for the player. Usually scripted behaviors work best in games that have predefined locations and where players are not likely to play through those levels repeatedly. In these games , players are likely to come into a given area from a certain location, and therefore the designer can make assumptions about what plan of attack will provide the most interesting challenge for the player.

First-person shooters are a good example of a game genre that works well with somewhat scripted AI behaviors. Half-Life was one of the first games to show how complex scripting could be used to make opponents that were a lot of fun to fight. That game was widely praised in the gaming press for the strength of its AI, while in fact much of that perceived intelligence was accomplished using scripted paths that the AI agents would move to in specific situations. RTS games such as StarCraft have used extensive scripting in their single-player scenario maps for as long as they have been around. In these games the AI receives instructions from the script about what to do when players finally reach a certain location or after they have built a certain number of units. This makes each level present a more unique challenge to the player than if all the maps were run off of a purely general-purpose AI.

Setting up scripted behaviors that are specific to a level is very much the concern of the level designer. The level designer already needed to concern himself with where the opponents should be placed to create maximum gameplay effect. But with scripted behaviors the designer needs to repeatedly play an area to figure out the most devilish places for the AI to hide, where it should retreat to when low on health, and how it should best reposition to have the greatest chance of defeating the player. Of course, the AI agent cannot only be on a path , at least not if the player is likely to interact with it. The AI must still be used to enable the agent to determine which location it should try to get to in which situation. Furthermore, the AI must be able to realize when the scripted plans are not working out and when to try an unscripted, more general behavior. One might think that having AI agents that use scripted, predetermined behaviors will fail to produce the unpredictability I discussed earlier. One might wonder how a scripted behavior can be anything but predictable. For just this reason, scripted behavior should be used just to give the AI agent hints as to where good locations to duck and cover might be, not to specify where the agent must always go, regardless of the situation. The agent must still be able to react to the player s tactics in order to avoid looking too foolish.

click to expand
The Suffering used a lot of scripted AI actions to make the enemies and companions appear more intelligent than they actually were.

Of the games I have worked on, The Suffering relied the most on scripted AI behaviors to make its characters appear smart and to create a compelling gameplay experience for the player. This scripting took a number of forms. Frequently, we would use some light scripting to introduce a creature into the environment. For example, when the player runs through a trigger along the top of a wall, we then activated a number of creatures to jump up onto the wall and run down it toward the player. After the creatures landed on the wall, they would follow a path toward the trigger the player hit, breaking off from that path as soon as they took damage or when they detected the player as a viable target. One particularly crafty creature early in the game was scripted to rip a door off its hinges (which happens in a cut-scene), and then run to the various dark corners of the room until the creature either takes damage or a timer runs out. This gives it the illusion of playing cat and mouse with the player. This only happened until the player was able to damage the creature, since after that it seemed foolish to continue taunting. There were a number of places in the game where players were able to attack NPCs with ranged weapons from a high and inaccessible position where the melee combat based NPCs were unable to retaliate. Unfortunately, the creatures were unable to figure this out on their own, so without some type of scripting they would tend to fruitlessly attempt to navigate to the player s position and ended up looking fairly stupid doing so. In these situations, we added scripting that would switch the NPCs between a hostile and a flee behavior depending on whether the player was in the sniper spot or not.

The human companions the player encounters throughout the game were heavily scripted. Some of these characters lead the player from location to location over the course of a particular level. These destinations were specifically mapped out by the level designer ahead of time. Sometimes they were set to be on the watch for hostile creatures while moving to those positions , while other times they are set to blindly move to a location and only then become hostile to whatever threats they might find. Typically the AI agent would then stay hostile until a certain success condition was met in the environment, such as all the creatures in an area being killed or the player having solved a particular puzzle. Only then would they be triggered to move to the next destination. Typically, only the specific destination point is specified by the level designer, with the AI dynamically figuring out the best path to get to that location based on its current position. These friendly NPCs also tended to be big talkers, and hence said specific dialog at different points throughout the level, all integrated into the more active behaviors they performed as part of their scripting.

Beyond event-based scripting, The Suffering also used a lot of NPC helper objects that were set up by hand by level designers. These took primarily two forms: flee positions and targeting positions. The NPCs would know to use the former when they needed to flee from combat in a room, and we placed these positions in little nooks, behind pillars, and in other places that it would look intelligent for an NPC to hide. Before actually using one of these positions, the AI agent would need to analyze all the locations within a certain radius around it, picking the one where its enemies did not have line-of-sight to it and where, in order to reach that position, it would not need to pass too close to any active threats. Even once the AI picked a particular flee location to use, the AI would continually reevaluate its decision, potentially moving to a different position if an enemy ran too close to a given location and thereby made it significantly less desirable. Targeting positions used essentially the same concept, except these helpers would be placed in locations where the AI would want to go in order to look smart while shooting at a target; while flee positions would be placed in good locations for hiding, targeting positions were placed on top of ledges, at junctions in hallways, and other locations where the AI was likely to be out in the open and able to get a shot off at a variety of targets. Some targeting positions were tied to other targeting positions around a particular piece of low-level geometry that could be used as cover. The AI knew to pick one targeting position from a group that would make it appear to hide behind the desk, rock, or other low object while blasting away at its target.

The Suffering combined dynamic AI behaviors with scripted ones to create agents that look much smarter than if they were all dynamic or all scripted. It is through this combination that we were able to pull off some of the most exciting scenarios in the game, where AI agents appear to have dynamic battles with each other but where these situations have actually been very carefully set up by the level designer for optimal effect. The trick is to maintain that precarious balance between too much scripting and too little so the game is still fun, challenging, and dynamic while also providing complex and memorable scenarios in which players can participate.




Game Design Theory and Practice
Game Design: Theory and Practice (2nd Edition) (Wordware Game Developers Library)
ISBN: 1556229127
EAN: 2147483647
Year: 2005
Pages: 189

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net