Raised This Month: $32 Target: $400
 8% 

[L4D2] l4d2_direct -- Direct plugin access to L4D2 globals


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 03-09-2012 , 19:01   [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #1

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_GetVSCampaignScoreteamNumber );

stock L4D2Direct_SetVSCampaignScoreteamNumber score );

stock Float:L4D2Direct_GetVSTankFlowPercentroundNumber );

stock L4D2Direct_SetVSTankFlowPercentroundNumber Float:flow );

stock bool:L4D2Direct_GetVSTankToSpawnThisRoundroundNumber );

stock L4D2Direct_SetVSTankToSpawnThisRoundroundNumber bool:spawn );

stock Float:L4D2Direct_GetVSWitchFlowPercentroundNumber );

stock L4D2Direct_SetVSWitchFlowPercentroundNumber Float:flow );

stock bool:L4D2Direct_GetVSWitchToSpawnThisRoundroundNumber );

stock L4D2Direct_SetVSWitchToSpawnThisRoundroundNumber 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.
Attached Files
File Type: zip l4d2_direct.zip (10.7 KB, 2073 views)

Last edited by ProdigySim; 07-14-2013 at 08:20. Reason: gamedata link
ProdigySim is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 03-09-2012 , 22:14   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #2

Excellent example!

However many of these are already in the l4downtown. Maybe its time we get a L4DTools natively in SourceMod?
Mr. Zero is offline
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 03-09-2012 , 22:44   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #3

Quote:
Originally Posted by Mr. Zero View Post
Excellent example!

However many of these are already in the l4downtown. Maybe its time we get a L4DTools natively in SourceMod?
Yeah, I was going to mention that. This has an added advantage of not needing to be recompiled when some offsets change, and it's lower dependency counts I guess.

I think a lot of what's done in left4downtown could be done without an extension, and I'd like to move more that way. However it will still be useful for detouring I think.
ProdigySim is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-10-2012 , 07:35  
Reply With Quote #4

Quote:
Originally Posted by ProdigySim
Nobody was really using the super-nice GameConfGetAddress and LoadFrom/StoreToAddress functions yet, so I decided to try to do something cool with them.
There is a reason for that.
https://bugs.alliedmods.net/show_bug.cgi?id=5226
__________________
asherkin is offline
mcpan313
Senior Member
Join Date: Mar 2010
Old 03-11-2012 , 09:57   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #5

GJ! very useful!
__________________
sorry, for my poor english.
mcpan313 is offline
Send a message via MSN to mcpan313
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 03-11-2012 , 11:41   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #6

Quote:
Originally Posted by mcpan313 View Post
GJ! very useful!
Glad to hear it!

Quote:
Originally Posted by asherkin View Post

Last edited by ProdigySim; 03-11-2012 at 11:42.
ProdigySim is offline
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 03-13-2012 , 14:43   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #7

There was an issue with StoreToAddress in SM 1.4 and 1.5, where it would always write 32 bits and always throw an error.

If you want to use the setter functions in l4d2_direct you should update your SourceMod installation to a snapshot. 1.4: >= hg3454 1.5: >= hg3469
ProdigySim is offline
seattle_ice
Member
Join Date: Dec 2010
Old 03-27-2012 , 14:51   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #8

So does this require your SM to be 1.4 or higher?
seattle_ice is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-27-2012 , 15:19   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #9

Quote:
Originally Posted by seattle_ice View Post
So does this require your SM to be 1.4 or higher?
Yes.

SM 1.3.x is end of life and no longer supported, so you shouldn't be using it any more anyway.
__________________
asherkin is offline
adrianman
Senior Member
Join Date: Sep 2010
Old 11-20-2012 , 16:22   Re: [L4D2] l4d2_direct -- Direct plugin access to L4D2 globals
Reply With Quote #10

links seem dead
__________________
The best thing in life's for free
adrianman is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode