Commercial Games

[ LiB ]

Commercial Games

Game engines and graphics are all well and good, but what about actual commercial games, you ask? You're in luck, for Python has slithered its way into many a shop. The language has been used as the primary scripting tongue for quite a few major games, and there are also a handful of game development tools, scriptable via Python, that have also been released.

Eve Online

Eve Online is a massive multiplayer online game that won the award for best online game in Game Revolution's The Best of E3 2002 Online Awards, and was also featured shortly after its release at 2003's E3 conference. Created by Iceland's CCP Games and released in 2001, Eve's world is a massive RPG science- fiction environment featuring photo-realistic graphics and a real space-faring feel.

What makes Eve special for us is that its game-logic is controlled by Stackless Python. CCP used Stackless on both the client and server side to free its programmers from many of the mundane tasks of model behavior and instead focus on the creative parts of AI. Stackless also allows CCG to easily make changes to the game and game behavior, even while the game is running, which is extremely important for its persistent online world model.

Freedom Force

Freedom Force , a popular super-hero multiplayer game from Irrational Games, was nominated for handfuls of PC Gamer's annual 2002 awards, and Irrational is currently working on an expansion of the game. Irrational used NDL's NetImmerse game engine and Freedom Force was co-published by Crave Entertainment and Electronic Arts. Many of the game's functions were exported to the Python side, so that Python could set and move objects and control camera movements. The single-player levels were scripted with Python as well, in order to control mission control and cut-scenes.

Python was used with custom extensions provided by the Freedom Force engine, and the key to using these extensions is understanding the scripting guides, which you can download from Irrational games at http://www.irrationalgames.com/modforce/Editor/script.htm.

Freedom Force launches two Python scripts (located in its system folder): startup.py and init.py. Both of these files are used to set the data paths for the game; by adding to the default path , you can change which module ff ( Freedom Force ) loads up at the beginning:

 import ff ff.DefaultPath = "MyModule;data" 

Python scripts control the flow of a module or adventure and can be used to script missions, create events that spawn new enemies, check for mission success and failure, trigger speech, and run cut-scenes. Each mission has a single script file (called mission, py) with which it is associated and must be in the same folder as mission.dat (this file is commonly know as a mission script ).

There are also level offshoots, called briefings and intermissions , that are loaded in between missions. These are scripted in the same way as missions but use a base.py file and a base.dat file instead.

The custom extensions provided by the Freedom Force engine are huge. Everything from AI to Object control to missions to camera movement is completely accessible via the Python scripting interface. Let's take a look at one example, a cut-scene snip from Freedom Force . The Freedom Force camera has a number of methods for using cut-scenes, as illustrated in Table 5.6.

Table 5.6. Freedom Force Cut-Scene Methods

Method

Purpose

play()

Plays a cut-scene

isPlaying()

Determines whether a cut-scene or scripted sequence is currently playing

startCS()

Starts a cut-scene

endCS()

Ends a cut-scene

endBriefingCS()

Ends a briefing

startCSNormalScreen()

Starts a cut-scene but doesn't go into widescreen mode

isCSPlaying()

Returns true if a cut-scene is currently playing

playTransition()

Plays the logo transition


Using these methods to start and stop a cut-scene would look like the following:

 # Define Cutscene MyCutscene = [ ( # Start Cutscene   "startCS()", ) # End Cutscene   "endCS()", ) 

Those who have been paying attention will notice that cut-scenes in Freedom Force are Python lists; here is the same code condensed to one line for familiarity :

 MyCutscene=[(item1,)(item2,)(etc)] 

Later in the code you call the play() function and viola! The MyCutscene cut-scene would run:

 play(MyCutscene) 

Of course, this cut-scene doesn't do much at all, but that's where FF's camera controls come in. The camera is enabled by a Camera_LookAtObject() command and released back to the player with the Camera_Release() command. Camera_LookAtObject() can be set with a number of commands common to the FF camera, as shown in Table 5.7:

Table 5.7. Freedom Force Camera Controls

Command

Description

objectName

The object to track

camDist

The zoom distance

camPitchRot

Angle of pitch around object right vector, in degrees

camYawRot

Angle of yaw around object up vector, in degrees

camSpeed

Time in seconds it will take to complete the move

movePathMode

Set camera snap ( CPM_SNAP , CPM_SCROLLTO , CPM_HOMING , or CPM_SIMPLEPATH )

camAction

Set camera move ( CA_MOVE ) or tracking ( CA_TRACK )

callbackFunc

Sets a Python script function to call when finished

fUser

User defined data


Given the camera controls in Table 5.7, you can move the camera around the main player or protagonist:

 MyCutscene = [ (   "startCS()",   "Camera_LookAtObject('My_Player',-195,30,384,3,CPM_SCROLLTO,CA_MOVE)",   "Camera_LookAtObject('My_Player',-200,20,320,3,CPM_SCROLLTO,CA_MOVE)", )   "endCS()", ) ] 

Table 5.7. Freedom Force Camera Controls

Command

Description

objectName

The object to track

camDist

The zoom distance

camPitchRot

Angle of pitch around object right vector, in degrees

camYawRot

Angle of yaw around object up vector, in degrees

camSpeed

Time in seconds it will take to complete the move

movePathMode

Set camera snap ( CPM_SNAP , CPM_SCROLLTO , CPM_HOMING , or CPM_SIMPLEPATH )

camAction

Set camera move ( CA_MOVE ) or tracking ( CA_TRACK )

callbackFunc

Sets a Python script function to call when finished

fUser

User defined data


Not bad for a quick delve into the Freedom Force APIand we've really just begun. There are actually a number of other camera commands to set wide-screen, introduce camera jitter, snap to objects or markers, fade in and out, and so on. Outside of the camera there are whole suites of functions and methods to set up narration, music, and sound effects, control NPCs and characters , set mission objectives and game flow, and so on and so on.

Severance: Blade of Darkness

Severance: Blade of Darkness is a fantasy combat game from Codemasters / Rebel Act Studios (which is now defunct ). It is a mature-audience game released in 2001 along with a level editor (called LED) and a set of tools (called RAS) for making levels and mods, which are, of course, based on Python and wholly scriptable. A Blade of Darkness level generally includes:

  • A .bw file which has the map architecture details, compiled from the LED map editor (uncompiled maps are .mp files).

  • .mmp files, which are files with the textures used in and on the map.

  • One or more Blade of Darkness (BOD) files that define the objects and characters that inhabit the mod.

  • A number of Python scripts that initialize and make objects and npcs and so on.

  • A level file (.lvl) that loads things up to the game engine (the .mmp bitmaps and the .bw map file).

The LED editor is shown in Figure 5.10 (notice Python on the top toolbar).

Figure 5.10. The LED editor with an open sample file

graphic/05fig10.gif


In the Python scripts, you'll find that objects (weapons, torches, and so on) are usually defined with a objs.py file, players with a pl.py file, configurations with a cfg.py file, the placement of the sun and its position with a sol.py file, and any water coordinates with a agua.py file.

Take a look at a sample agua.py file:

 import Bladex pool1=Bladex.CreateEntity("pool1","Entity Water",72000,39800,-2000) pool1.Reflection=0.9 pool1.Color=90,20,20 pool2=Bladex.CreateEntity("pool2","Entity Water",116000,39800,54000) pool2.Reflection=0.1 pool2.Color=60,10,10 pool3=Bladex.CreateEntity("pool3","Entity Water",116000,39700,46000) pool3.Reflection=-0.5 pool3.Color=0,0,0 

First, the necessary Bladex libraries (which hold most of the necessary commands and functions) are imported. CreateEntity is then called on to create three separate pools of water at three separate locations. Once instantiated , each pool is then further defined with the Reflection and Color methods.

NOTE

A handful of developers from Rebel Act started their own company called Digital Legends Entertainment at http://www.digital-legends.net/ shortly after RAS closed its doors. They are currently focused on producing their first game, Nightfall Dragons at http://www.nightfalldragons.com .

ToonTown

ToonTown , an online cartoon style mulit-player game, is the latest from the Walt Disney Imagineering studio. Players create their own cartoon avatars and explore a rich world where they can meet and interact with other "toons," earn jelly beans to put in the bank, and buy things (like a toon house or items for a toon house). There is even a bit of conflict thrown in, in the form of a "Cog Invasion" that is threatening the city.

Disney's ToonTown uses Python in a direct and powerful way. The ToonTown executable actually calls Python on the client when the program is instantiated. Python was also used in development of the game, particularly in the Panda3D rendering engine.

Panda3D is powered by Python, DirectX, and the Fmod music and sound effects system. After being used to create Disney's ToonTown it was released to the open source community and is currently under even more extensive development by both the VR Studio and the Entertainment Technology Center at Carnegie Mellon University. ETC is working on making a simple installer for Panda3D (the current installation is somewhat of a bear ahem), creating solid documentation, adding to the basic model import functionality, and creating tools like level and script editors.

Note that there are two versions of Panda. One is the original release to the community from Disney, located on Sourceforge and found there at http:// sourceforge .net/projects/panda3d/).

The second version is the release from Carnegie Mellon's ETC, and can be found online at http://www.etc.cmu.edu/projects/panda3d/downloads.

Panda is capable of importing Maya and 3D Studio Max models, as well as the standard .gif, .tiff, and .jpeg image formats. It has a fairly extensive API that is still undergoing documentation. It can also be extended with the SDK, and the engine itself is tweakable, as the code has been released to the community.

The two most important lines in any Pythoned Panda script are

 from ShowBaseGlobal import * 

and

 run() 

The first line imports the necessary Panda files (which takes quite a bit of time) and the second line runs the environment. Running these two lines in a script after installing Panda will create a large, blank, gray window. These two lines are the minimum needed to create a Panda environment.

Panda3D is built around the scene-graph, which is a tree-like object hierarchy structure. Individual objects, which are normally 3D models or GUI elements, are called NodePath objects. NodePath objects inherit behavior from their parents, and there are a number of built-in, base, pre-defined NodePath objects in Panda.

Panda3D models are either .egg or .bam. EGG files are ASCII format (and therefore readable by humans ), and .bam is their corresponding binary format (for faster load times). You load a 3D object in Panda using its global loader object, like so:

 My3Dobject = loader.loadModel("3Dobject.egg") 

All loaded objects in Panda are, by default, hidden from view. To change this, take the loaded object (which is now a NodeObject ) and change its parent to render ; doing so will make the object render onscreen:

 My3Dobject.reparentTo(render) 

Once the object is loaded, you can call upon all sorts of fun methods to manipulate it, from setting the x,y, and z coordinates with setX() , setY() , setZ() or setPos(x,y,z) :

 My3Dobject.setX(4) # Moves the object 4 "feet: on the X coordinate 

to changing the heading, pitch, and roll with setHPR(heading, pitch, roll) :

 My3Dobject.setHPR(50, 30, 0) # Changes the model heading by 50 degrees and pitches the model upward 30 degrees 

to changing the object's scale with setScale() :

 My3Dobject.setScale(10) # sets the scale uniformly x10 in each direction (x,y, and z) 

Panda is also capable of handling events (mouse clicks and key presses), has a GUI system for creating UI elements like buttons and dialog boxes (which can be bound to Python functions), and can incorporate sound effects and music.

[ LiB ]


Game Programming with Pyton, Lua and Ruby
Game Programming with Pyton, Lua and Ruby
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 133

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