Mattie Casper
March 14, 2008
PyCon 2008, Chicago
Counter-Strike and Source are registered trademarks of Valve Corporation. The author is in no way affiliated with Valve
Corporation, but is a fan of their work.
Background
Demo
Goals and Results
Future Possibilities
Pain Points for Embedding
More Information
Special Thanks
Source engine and EventScripts
Half-Life
• released by Valve in 1998
• Active modding community
Counter-Strike
• First released in 1999
• Still popular: 70,000 players
Source engine
• Half-Life 2, Counter-Strike: Source
• Vampire: The Masquerade Bloodlines
• Portal, Team Fortress 2
Source SDK-based C++ plugin
Initially a shell-like language
Philosophy
• Customize servers
• Friendly community
• Focus on ease-of-use for new scripters
EventScripts 2.0 with Python support
Used by a third of all Source servers
~12,000 servers and ~1,200 addons
Dedicated Server
Player1 [Link]
Rented server instance
[Link]
Player2 (Wild, Wild) EventScripts
Internet
...
Player3
Rented server instance [Link]
Player4
Popcorn in Counter-Strike: Source
Embedding Python in EventScripts
Goal
• Easy to read and learn
Results with Python
• Already a good beginner language
• Dynamic nature allows complexity to be hidden
Before
After
Goals
• Cross-compile for Windows and Linux
• Support rented game servers
Results
• Library loading from a plugin shared object
Delay loading on Windows
RPATH on Linux
• Python path issues (/lib)
• Compilation issues
• Directory names with colons
Goal
• Maintain game responsiveness
Results
• Acceptable performance with shell language
• Python
Bytecode is order of magnitude faster
Psyco for native compilation of bottlenecks
Goal
• Don’t feed the hackers. (Game servers are
attacked for sport.)
Results
• No access to Python from the game console
• Scripters are warned against eval/exec
• Unrelated denial of service exploit found
Goals:
• Many addons loading independently
• Addons should not impact one another
Results
• Loading addons as modules (from packages)
• Register event listeners with central manager
• Continue after isolated exception
• Threading is not so hot
Performance poor when multiple addons thread (GIL)
Embedded apps have no real recourse
Improving Python and EventScripts
eXtensible Admin
es_install
EventScripts classic to bytecode
Lower level SDK wrapper
Auto-update mechanism
Threading – GIL hurts
• Embedding apps can’t fork easily
• App users don’t write C extensions
Embedding – Increase priority
• Improve documentation
• More examples, samples, tutorials
API Documentation – Modernize
• Full pages for functions with examples
• Allow user comments
Viper for SourceMod by Zach Kanzler
EventScripts resources
• [Link]/cs - Downloads
• [Link] – Addon Database
• [Link] - Documentation
• [Link] – Documentation
Helen Casper, Glenn Davis, Ted Shroyer,
Don Lafferty, Michael Barr
Awuh0, [Link], cagemonkey,
Cap’tain ta race, Chun, Colster, Einlanzers,
Errant, GODJonez, GoodfellaDeal,
HitThePipe, ichthys, Lobe, Mbchrono, McFly,
mikesrevenge, murpher, Nicolous, RideGuy,
Saul, sn4k3, SumGuy14, SuperDave,
TIM3PORT, Wonder, [NATO]Hunter,
[YG]Gordaz
Shoot ‘em up.