plugins/include/sdktools_gamerules.inc
author Nicholas Hastings <skamonkey@gmail.com>
Mon May 13 15:33:55 2013 -0400 (2013-05-13)
changeset 3914 ec79ea87c2e7
parent 3608 afa46954ccac
child 3967 ceafb87d38a7
permissions -rw-r--r--
One more dota build fix.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2011 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _sdktools_gamerules_included
    34   #endinput
    35 #endif
    36 #define _sdktools_gamerules_included
    37 
    38 enum RoundState {
    39 	// initialize the game, create teams
    40 	RoundState_Init,
    41 	
    42 	//Before players have joined the game. Periodically checks to see if enough players are ready
    43 	//to start a game. Also reverts to this when there are no active players
    44 	RoundState_Pregame,
    45 	
    46 	//The game is about to start, wait a bit and spawn everyone
    47 	RoundState_StartGame,
    48 	
    49 	//All players are respawned, frozen in place
    50 	RoundState_Preround,
    51 	
    52 	//Round is on, playing normally
    53 	RoundState_RoundRunning,
    54 	
    55 	//Someone has won the round
    56 	RoundState_TeamWin,
    57 	
    58 	//Noone has won, manually restart the game, reset scores
    59 	RoundState_Restart,
    60 	
    61 	//Noone has won, restart the game
    62 	RoundState_Stalemate,
    63 	
    64 	//Game is over, showing the scoreboard etc
    65 	RoundState_GameOver,
    66 	
    67 	//Game is over, doing bonus round stuff
    68 	RoundState_Bonus,
    69 	
    70 	//Between rounds
    71 	RoundState_BetweenRounds,
    72 };
    73 
    74 /**
    75  * Retrieves an integer value from a property of the gamerules entity.
    76  * 
    77  * @param prop			Property name.
    78  * @param size			Number of bytes to read (valid values are 1, 2, or 4).
    79  *						This value is auto-detected, and the size parameter is 
    80  *						only used as a fallback in case detection fails.
    81  * @param element		Element # (starting from 0) if property is an array.
    82  * @return				Value at the given property offset.
    83  * @error				Not supported.
    84  */
    85 native GameRules_GetProp(const String:prop[], size=4, element=0);
    86 
    87 /**
    88  * Sets an integer value for a property of the gamerules entity.
    89  *
    90  * @param prop			Property name.
    91  * @param value			Value to set.
    92  * @param size			Number of bytes to write (valid values are 1, 2, or 4).
    93  *						This value is auto-detected, and the size parameter is 
    94  *						only used as a fallback in case detection fails.
    95  * @param element		Element # (starting from 0) if property is an array.
    96  * @error				Not supported.
    97  * @noreturn
    98  */
    99 native GameRules_SetProp(const String:prop[], any:value, size=4, element=0, bool:changeState=false);
   100 
   101 /**
   102  * Retrieves a float value from a property of the gamerules entity.
   103  * 
   104  * @param prop			Property name.
   105  * @param element		Element # (starting from 0) if property is an array.
   106  * @return				Value at the given property offset.
   107  * @error				Not supported.
   108  */
   109 native Float:GameRules_GetPropFloat(const String:prop[], element=0);
   110 
   111 /**
   112  * Sets a float value for a property of the gamerules entity.
   113  * 
   114  * @param prop			Property name.
   115  * @param value			Value to set.
   116  * @param element		Element # (starting from 0) if property is an array.
   117  * @noreturn
   118  * @error				Not supported.
   119  */
   120 native GameRules_SetPropFloat(const String:prop[], Float:value, element=0, bool:changeState=false);
   121 
   122 /**
   123  * Retrieves a entity index from a property of the gamerules entity.
   124  * 
   125  * @param prop			Property name.
   126  * @param element		Element # (starting from 0) if property is an array.
   127  * @return				Entity index at the given property.
   128  *						If there is no entity, or the entity is not valid, 
   129  *						then -1 is returned.
   130  * @error				Not supported.
   131  */
   132 native GameRules_GetPropEnt(const String:prop[], element=0);
   133 
   134 /**
   135  * Sets an entity index for a property of the gamerules entity.
   136  * 
   137  * @param prop			Property name.
   138  * @param other			Entity index to set, or -1 to unset.
   139  * @param element		Element # (starting from 0) if property is an array.
   140  * @noreturn
   141  * @error				Not supported.
   142  */
   143 native GameRules_SetPropEnt(const String:prop[], other, element=0, bool:changeState=false);
   144 
   145 /**
   146  * Retrieves a vector of floats from the gamerules entity, given a named network property.
   147  * 
   148  * @param prop			Property name.
   149  * @param vec			Vector buffer to store data in.
   150  * @param element		Element # (starting from 0) if property is an array.
   151  * @noreturn
   152  * @error				Not supported.
   153  */
   154 native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0);
   155 
   156 /**
   157  * Sets a vector of floats in the gamerules entity, given a named network property.
   158  *
   159  * @param prop			Property name.
   160  * @param vec			Vector to set.
   161  * @param element		Element # (starting from 0) if property is an array.
   162  * @noreturn
   163  * @error				Not supported.
   164  */
   165 native GameRules_SetPropVector(const String:prop[], const Float:vec[3], element=0, bool:changeState=false);
   166 
   167 /**
   168  * Gets a gamerules property as a string.
   169  * 
   170  * @param prop			Property to use.
   171  * @param buffer		Destination string buffer.
   172  * @param maxlen		Maximum length of output string buffer.
   173  * @return				Number of non-null bytes written.
   174  * @error				Not supported.
   175  */
   176 native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen);
   177 
   178 /**
   179  * Sets a gamerules property as a string.
   180  *
   181  * @param prop			Property to use.
   182  * @param buffer		String to set.		
   183  * @return				Number of non-null bytes written.
   184  * @error				Not supported.
   185  */
   186 native GameRules_SetPropString(const String:prop[], const String:buffer[], bool:changeState=false);
   187 
   188 /**
   189  * Gets the current round state.
   190  *
   191  * @return				Round state.
   192  * @error				Game doesn't support round state.
   193  */
   194 stock RoundState:GameRules_GetRoundState()
   195 {
   196 	return RoundState:GameRules_GetProp("m_iRoundState");
   197 }