plugins/include/entity_prop_stocks.inc
author David Anderson <dvander@alliedmods.net>
Thu Jan 03 06:11:26 2008 +0000 (2008-01-03)
changeset 1829 97cd42e800e8
parent 1828 0df571678652
child 1834 74d7a2edeb49
permissions -rw-r--r--
added amb1336 - GetTrieSize()
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2007 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 _entity_prop_stocks_included
    34  #endinput
    35 #endif
    36 #define _entity_prop_stocks_included
    37 
    38 enum
    39 {
    40 	MOVETYPE_NONE = 0,			/** never moves */
    41 	MOVETYPE_ISOMETRIC,			/** For players */
    42 	MOVETYPE_WALK,				/** Player only - moving on the ground */
    43 	MOVETYPE_STEP,				/** gravity, special edge handling -- monsters use this */
    44 	MOVETYPE_FLY,				/** No gravity, but still collides with stuff */
    45 	MOVETYPE_FLYGRAVITY,			/** flies through the air + is affected by gravity */
    46 	MOVETYPE_VPHYSICS,			/** uses VPHYSICS for simulation */
    47 	MOVETYPE_PUSH,				/** no clip to world, push and crush */
    48 	MOVETYPE_NOCLIP,			/** No gravity, no collisions, still do velocity/avelocity */
    49 	MOVETYPE_LADDER,			/** Used by players only when going onto a ladder */
    50 	MOVETYPE_OBSERVER,			/** Observer movement, depends on player's observer mode */
    51 	MOVETYPE_CUSTOM,			/** Allows the entity to describe its own physics */
    52 };
    53 
    54 #define IN_ATTACK		(1 << 0)
    55 #define IN_JUMP			(1 << 1)
    56 #define IN_DUCK			(1 << 2)
    57 #define IN_FORWARD		(1 << 3)
    58 #define IN_BACK			(1 << 4)
    59 #define IN_USE			(1 << 5)
    60 #define IN_CANCEL		(1 << 6)
    61 #define IN_LEFT			(1 << 7)
    62 #define IN_RIGHT		(1 << 8)
    63 #define IN_MOVELEFT		(1 << 9)
    64 #define IN_MOVERIGHT	(1 << 10)
    65 #define IN_ATTACK2		(1 << 11)
    66 #define IN_RUN			(1 << 12)
    67 #define IN_RELOAD		(1 << 13)
    68 #define IN_ALT1			(1 << 14)
    69 #define IN_ALT2			(1 << 15)
    70 #define IN_SCORE		(1 << 16)   // Used by client.dll for when scoreboard is held down
    71 #define IN_SPEED		(1 << 17)	// Player is holding the speed key
    72 #define IN_WALK			(1 << 18)	// Player holding walk key
    73 #define IN_ZOOM			(1 << 19)	// Zoom key for HUD zoom
    74 #define IN_WEAPON1		(1 << 20)	// weapon defines these bits
    75 #define IN_WEAPON2		(1 << 21)	// weapon defines these bits
    76 #define IN_BULLRUSH		(1 << 22)
    77 #define IN_GRENADE1		(1 << 23)	// grenade 1
    78 #define IN_GRENADE2		(1 << 24)	// grenade 2
    79 
    80 /**
    81  * Gets an entity's movetype.
    82  *
    83  * @param index		Entity index
    84  * @return		Movetype, see enum above
    85  */
    86 stock GetEntityMovetype(index)
    87 {
    88 	new offset = GetEntSendPropOffs(index, "movetype");
    89 	return GetEntData(index, offset, 1);
    90 }
    91 
    92 /**
    93  * Sets an entity's movetype.
    94  *
    95  * @param index		Entity index
    96  * @param mt		Movetype, see enum above
    97  * @noreturn
    98  */
    99 stock SetEntityMovetype(index, mt)
   100 {
   101 	new offset = GetEntSendPropOffs(index, "movetype");
   102 	SetEntData(index, offset, mt, 1, true);
   103 }
   104 
   105 /**
   106  * Sets an entity's color.
   107  *
   108  * @param index		Entity index
   109  * @param r 		Amount of red (0-255)
   110  * @param g 		Amount of green (0-255)
   111  * @param b 		Amount of blue (0-255)
   112  * @param a 		Amount of alpha (0-255)
   113  * @noreturn
   114  */
   115 stock SetEntityRenderColor(index, r=255, g=255, b=255, a=255)
   116 {
   117 	new offset = GetEntSendPropOffs(index, "m_clrRender");
   118 	SetEntData(index, offset, r, 1, true);
   119 	SetEntData(index, offset + 1, g, 1, true);
   120 	SetEntData(index, offset + 2, b, 1, true);
   121 	SetEntData(index, offset + 3, a, 1, true);
   122 }
   123 
   124 /**
   125  * Gets an entity's gravity.
   126  *
   127  * @param index		Entity index
   128  * @return		Entity's m_flGravity value
   129  */
   130 stock Float:GetEntityGravity(index)
   131 {
   132 	new offset = FindDataMapOffs(index, "m_flGravity");
   133 	return GetEntDataFloat(index, offset);	
   134 }
   135 
   136 /**
   137  * Sets an entity's gravity.
   138  *
   139  * @param index		Entity index
   140  * @param amount	Gravity to set. Default = 800
   141  * @noreturn
   142  */
   143 stock SetEntityGravity(index, Float:amount)
   144 {
   145 	new offset = FindDataMapOffs(index, "m_flGravity");
   146 	SetEntDataFloat(index, offset, amount, true);	
   147 }
   148 
   149 /**
   150  * Sets an entity's health
   151  *
   152  * @param index		Entity index
   153  * @param amount	Health
   154  * @noreturn
   155  */
   156 stock SetEntityHealth(index, amount)
   157 {
   158 	SetEntProp(client, Prop_Send, "m_iHealth", amount, 4)
   159 	SetEntProp(client, Prop_Data, "m_iHealth", amount, 4)
   160 }
   161 
   162 /**
   163  * Get's a users current pressed buttons
   164  *
   165  * @param client	Client index
   166  * @return			Bitsum of buttons
   167  */
   168 stock GetClientButtons(client)
   169 {
   170 	new offset = FindDataMapOffs(client, "m_nButtons");
   171 	return GetEntData(client, offset, 4);
   172 }