View Single Post
Author Message
psychonic

BAFFLED
Join Date: May 2008
Old 04-04-2011 , 13:11   GameRules Prop Hax
Reply With Quote #1

GameRules Prop Hax

Note: Currently requires an SM 1.4.0-dev snapshot >= hg3157 or later.
(if there's enough interest in this, I can later make it able to work on SM 1.3.x releases/snapshots)

This extension allows you to directly get or set property values on the GameRules class, rather than only having access to the GameRules proxy (which will have delayed or plain incorrect values).

You can currently get or set the actual value of any property that exists on the proxy entity. I'll probably also add natives for using your own offset so that non-networked data can also be accessed.

Code:
/*  * Gets or Sets a GameRules prop.  * size is auto-detected. paramter is only used if auto-detection fails  * element is element number in array if prop is array  * changeState when setting will propagate change over net to clients  */ native GameRules_GetProp(const String:prop[], size=4, element=0); native Float:GameRules_GetPropFloat(const String:prop[], element=0); native GameRules_SetProp(const String:prop[], value, size=4, element=0, bool:changeState=false); native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);

The natives work similar to GetEntProp/SetEntProp, with the exceptions of 1) being able to specify the element# if the property is an array, and 2) being able mark the property as changed (like SetEntData), so that the new value is sent to clients.

Some included stocks for games utilizing the TeamplayRoundBased class (ex. TF2).
Code:
stock RoundState:GameRules_GetRoundState() stock Float:GameRules_GetTimeUntilRndReset() stock Float:GameRules_GetTimeBetweenSpawns(team) stock GameRules_SetTimeBetweenSpawns(team, Float:time) stock Float:GameRules_GetNextSpawnTime(team) stock GameRules_SetNextSpawnTime(team, Float:time)

Click here to view the full include.


Some examples of useful, game-specific properties that can be accessed:
TF2
Code:
m_bInWaitingForPlayers
m_iWinningTeam
m_bInOvertime
m_bInSetup
m_bSwitchedTeamsThisRound
m_bStopWatch
m_bMultipleTrains
m_nGameType
m_nStopWatchState
m_nHudType
CS:S
Code:
m_iRoundTime
m_bMapHasBombTarget
m_bMapHasRescueZone
DOD:S
Code:
m_bAlliesAreBombing
m_bAxisAreBombing
m_AlliesRespawnQueue
m_AxisRespawnQueue
m_iAlliesRespawnHead
m_iAlliesRespawnTail
m_iAxisRespawnHead
m_iAxisRespawnTail
L4D2
Code:
m_iSurvivorScore
m_iCampaignScore
m_iScavengeTeamScore
m_iScavengeMatchScore
m_flTeamRoundTime
m_iVersusDistancePerSurvivor
m_iVersusSurvivorDeathDistance
m_iVersusSurvivalMultiplier
m_iVersusDefibsUsed
m_bInIntro
m_iServerRank
m_flTeamBestRoundTime
m_nScavengeItemsRemaining
m_bAreTeamsFlipped
m_bInSecondHalfOfRound
m_bIsTransitioningToNextMap
For a full list, use sm_dump_netprops and look for the game's specific gamerules proxy entry.

Binary support is included for all games/engines that SM supports. To enable support for specific games not already included, you need only add the netclass name of the gamerules proxy to the gamedata file.

Source code attached.
Attached Files
File Type: zip gamerules.zip (328.5 KB, 942 views)
File Type: zip gamerules-src.zip (349.2 KB, 515 views)

Last edited by psychonic; 11-06-2012 at 11:29.
psychonic is offline