l4d2_direct -- Direct plugin access to L4D2 global variables.
LATEST GAMEDATA
http://github.com/ConfoglTeam/l4d2_direct/
Nobody was really using the super-nice GameConfGetAddress and LoadFrom/StoreToAddress functions yet, so I decided to try to do something cool with them.
l4d2_direct is a set of includes files for sourcemod plugins which give plugin developers simple, direct access to a number of global variables in L4D2.
Currently, l4d2_direct has natives for finding the global instances of
- CDirector (TheDirector)
- CDirectorVersusMode
- CDirectorScavengeMode
- TerrorNavMesh (TheNavMesh)
We hope to add more of these in the future as needs for them arise.
In addition to this, we've wrapped up a number of simple variable accessors/modifiers for these classes in a few stocks for players to use.
Our current (truncated) list of variable access stocks is:
PHP Code:
/* CDirector Variable access */
stock L4D2Direct_GetTankCount();
stock CountdownTimer:L4D2Direct_GetMobSpawnTimer();
stock IntervalTimer:L4D2Direct_GetSIClassDeathTimer(class);
stock CountdownTimer:L4D2Direct_GetSIClassSpawnTimer(class);
/* CDirectorVersusMode Variable access */
stock L4D2Direct_GetVSCampaignScore( teamNumber );
stock L4D2Direct_SetVSCampaignScore( teamNumber , score );
stock Float:L4D2Direct_GetVSTankFlowPercent( roundNumber );
stock L4D2Direct_SetVSTankFlowPercent( roundNumber , Float:flow );
stock bool:L4D2Direct_GetVSTankToSpawnThisRound( roundNumber );
stock L4D2Direct_SetVSTankToSpawnThisRound( roundNumber , bool:spawn );
stock Float:L4D2Direct_GetVSWitchFlowPercent( roundNumber );
stock L4D2Direct_SetVSWitchFlowPercent( roundNumber , Float:flow );
stock bool:L4D2Direct_GetVSWitchToSpawnThisRound( roundNumber );
stock L4D2Direct_SetVSWitchToSpawnThisRound( roundNumber , bool:spawn );
stock CountdownTimer:L4D2Direct_GetVSStartTimer();
/* CDirectorScavengeMode Variable access */
stock CountdownTimer:L4D2Direct_GetScavengeRoundSetupTimer();
stock CountdownTimer:L4D2Direct_GetScavengeOvertimeGraceTimer();
/* TerrorNavMesh Variable access */
stock Float:L4D2Direct_GetMapMaxFlowDistance();
You can find a full listing (with comments!)
in l4d2_direct.inc.
You may notice some of those functions return either a CountdownTimer or an IntervalTimer. The relevant functions to deal with those types are in
l4d2d_timers.inc. Additionally, direct accessors to gamedata and globals addresses are in
l4d2d_internals.inc
All of these includes are included in the download package on this thread.
Plugins using l4d2_direct
--None yet!
There is a sample test plugin included with l4d2_direct that demonstrates some basic reading of variables using l4d2_direct. It also has commands available for making dumps of global variables. You should not run this plugin on a production server.
Gamedata
Keep in mind, with updates to L4D2, the offsets and addresses in this project could break. You can keep your gamedata updated by grabbing the latest version
here.
Future additions
l4d2_direct is young, and there's still much to be done with it. You'll notice some offsets and addresses in the gamedata that aren't being touched yet. There's plenty of things that can be implemented, but I haven't gotten around to making get/set functions for every variable.