• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
 Page 1 of 19 
Case Study: Embedding Python intoCounter-Strike: Source
Mattie CasperMarch 1, 2008PyCon 2008, Chicago
Abstract
The EventScripts plugin is the most popular scripting engine addon for Valve Software’s Source games,
running on more than eleven thousand servers globally as of January 2008. Its most recent version,EventScripts 2.0, has added support for Python 2.5 scripts. ( http://python.eventscripts.com ) In this informal case study, I discuss the considerations of embedding Python into popular cross-platform game servers. Areas covered include the need for a simple scripter interface for the gamingaudience, issues in cross-platform embedding, and methods for handling performance and stabilityissues.This study is of interest as an example of embedding Python in existing software packages. It is alsouseful in understanding the limitations and difficulties associated with embedding the language runtime.
Table of Contents
Abstract .................................................................................................................................................. 1Table of Contents .................................................................................................................................... 1Introduction ............................................................................................................................................ 2Background ............................................................................................................................................. 2Multiplayer PC Gaming ........................................................................................................................ 2Source-based Games ........................................................................................................................... 3EventScripts Plugin .............................................................................................................................. 4Goals and Results .................................................................................................................................... 6Simplicity ............................................................................................................................................. 6Platforms ............................................................................................................................................. 9Performance ...................................................................................................................................... 12Security ............................................................................................................................................. 13Multiplicity ........................................................................................................................................ 14Future Possibilities ................................................................................................................................ 16Recommendations for Improving Python............................................................................................... 17Make cross-platform embedding easier ............................................................................................. 17Support true threading ...................................................................................................................... 17
 
Introduction
This informal case study reflects upon the
results of a development community’s
success at embedding
Python into a plugin for Valve’s Source games.
For readers unfamiliar with the project, an overview isprovided of multiplayer PC games, the Source engine, and EventScripts history. The primary content of the paper describes the different goals and results in areas such as performance, stability, and platformsupport. Finally, recommendations are made for continuing to expand upon EventScripts and also forimproving Python for the embedding community.This project is primarily useful as an example of embedding CPython inside existing software packages. Itshould also help show the limitations and difficulties associated with embedding the language runtime.
Background
Multiplayer PC Gaming
Multiplayer PC games are growing every year in popularity. One popular subset of these online games is
called “first person shooters”
(FPS) that allow players to simulate contests around combat-orientedobjectives. The game players in this genre are historically very loyal; for example, the game
Counter-Strike
from Valve Software was first introduced in 1999 and still has as many as 60,000 players at anygiven time according to popular game-statistic websites (1).
Game Servers
Most first-person shooter games use player-hosted servers that connect players for their battles. Theseservers typically host 16 to 64 players who find each other
through centralized services like Valve’s
Steam software or GameSpy.While games
servers can often be run on one of the player’s machine
alongside their game client, theCPU intensive nature of these games can lead to performance issues. As such, players often host gameson dedicated game servers to mitigate any CPU contention. This practice has created a robust businesssector for game server rental providers. These companies configure servers and rent them, often on amonthly basis, to players who have private or public gameplay needs.
Extensibility
Many of the most-popular player-hosted game engines are extensible, offering SDKs and plugins thatcan extend the functionality of the servers. For example, games like
Battlefield 2
use a scripting interface
 
 Page 3 of 19 in Python to allow game administrators to customize their servers with new objectives and newgameplay rules. Many other games allow for extensions written in C++.Popular games that do not have a vendor-supplied extensibility model often find that one is provided forthem. For example, the original
Counter-Strike
game did not include an SDK, but community hackersdeveloped plugin hooks via a project called
Metamod 
that allowed server-side customizations.
Source-based Games
Overview
Half-Life
by Valve Software was one of the most popular first-person shooters of all time. The
game’s
physics and graphics engines became a prolific basis for new content in the gaming community. Popular
games (or “mods”) like
Counter-Strike
.After the success of the Half-
Life engine, Valve began work on their “Source” game engine, whi
ch wasfirst released in 2004 with
Half-Life 2
and
Vampire: The Masquerade
– 
Bloodlines.
(Interestingly,
Bloodlines
embedded its own Python interpreter to control some story elements, goals, and entityinteractions.)
Counter-Strike: Source
was released for the PC in late October 2004 and has grown anaudience nearly as large as its predecessor.
Source Server Plugin Model
The Source engine was released with the Source SDK
 –
a development kit for the PC which providedsource code and tools to create mods for Source. In addition, it included a C++ interface for creatingserver-side plugins for games written on the engine. This paper discusses one such plugin, EventScripts.Server-side plugins for Source are driven primarily by callbacks and event notifications. These C++projects implement the IServerPlugin interface and the engine uses that to deliver interface factoriesand general callbacks as the game progresses. (2)When the server starts, the engine enumerates the
game’s
addons
folder and loads any plugin DLLsfrom that directory. Each plugin is given a turn to use interface factories to access global servicesprovided by the Source engine. For example, the Source engine provides the following services accessedthrough interfaces:
 
Player information lookup
 
Generic visual/sound effects
 
Registering console commands
 
Registering new and adjusting existing server variables (e.g.
sv_gravity 
to adjust simulatedgravity)
 
Physics engine interaction
 
Basic entity manipulation
 
Bot and player manipulation
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...