O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stage Direction
Stage direction is probably the most common utilization of scripting in
games at the time of this book’s publication. These types of scripts turn the
common or garden-variety game designer into a virtual film director, a ver
-
itable cyber-Spielberg capable of manipulating the actions of the game
characters and environments at will, enabling the designer to create
immersive and entertaining game scenarios without so much as a whisper
in the AI or engine programmers ear. These type of scripts open up the
guts of the game engine to the wannabe Scorseses on your development
team, allowing game objects and events to be easily handled and created.
Here’s how such a script might look:
FUNCTION script_castle_guard (player)
** create a guard situated at the castle’s drawbridge
guard = Guard(GetPos(Drawbridge))
**focus and lock the camera on the guard
LockCamera(guard)
**move the guard toward the player
guard.Move(GetPos(player))
IF Player.Has(GetFlag(AUTHORIZATION_FROM_KING)) THEN
**welcome the player and escort him to the king
guard.Speak(“Good Evening” + player.Name()+” His Majesty is expecting you. Come this way”)
guard.Move(GetPos(Throne_Room))
player.Follow(guard)
ELSE
**give the player some verbal abuse, then dump him in the dungeon
guard.Speak(“OI! Wot are you doin’ on my bridge! You are coming with me, my son!”)
guard.Move(GetPos(Dungeon))
player.Follow(guard)
END IF
**move guard back to drawbridge
guard.Move(GetPos(Drawbridge))
END FUNCTION
Used correctly, scripted sequences enhance the game playing experience
and are an ideal vehicle to move a story line forward. Lionhead’s Black &
White made great use of this type of stage direction to control the game’s
quests.
254 | Chapter 6
What a Scripting Language Can Do for You

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required