plugins/include/entity_prop_stocks.inc
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 24 10:25:44 2008 +0000 (2008-04-24)
changeset 2023 1bd756a9f8db
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Added any tag to ADT array functions to fix potential tag mismatches
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     5
 * =============================================================================
ds@1952
     6
 *
ds@1952
     7
 * This file is part of the SourceMod/SourcePawn SDK.
ds@1952
     8
 *
ds@1952
     9
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    11
 * Free Software Foundation.
ds@1952
    12
 * 
ds@1952
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    16
 * details.
ds@1952
    17
 *
ds@1952
    18
 * You should have received a copy of the GNU General Public License along with
ds@1952
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    20
 *
ds@1952
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    28
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    29
 *
ds@1952
    30
 * Version: $Id$
ds@1952
    31
 */
ds@1952
    32
 
ds@1952
    33
#if defined _entity_prop_stocks_included
ds@1952
    34
 #endinput
ds@1952
    35
#endif
ds@1952
    36
#define _entity_prop_stocks_included
ds@1952
    37
ds@1952
    38
enum MoveType
ds@1952
    39
{
ds@1952
    40
	MOVETYPE_NONE = 0,			/**< never moves */
ds@1952
    41
	MOVETYPE_ISOMETRIC,			/**< For players */
ds@1952
    42
	MOVETYPE_WALK,				/**< Player only - moving on the ground */
ds@1952
    43
	MOVETYPE_STEP,				/**< gravity, special edge handling -- monsters use this */
ds@1952
    44
	MOVETYPE_FLY,				/**< No gravity, but still collides with stuff */
ds@1952
    45
	MOVETYPE_FLYGRAVITY,		/**< flies through the air + is affected by gravity */
ds@1952
    46
	MOVETYPE_VPHYSICS,			/**< uses VPHYSICS for simulation */
ds@1952
    47
	MOVETYPE_PUSH,				/**< no clip to world, push and crush */
ds@1952
    48
	MOVETYPE_NOCLIP,			/**< No gravity, no collisions, still do velocity/avelocity */
ds@1952
    49
	MOVETYPE_LADDER,			/**< Used by players only when going onto a ladder */
ds@1952
    50
	MOVETYPE_OBSERVER,			/**< Observer movement, depends on player's observer mode */
ds@1952
    51
	MOVETYPE_CUSTOM,			/**< Allows the entity to describe its own physics */
ds@1952
    52
};
ds@1952
    53
ds@1952
    54
enum RenderMode
ds@1952
    55
{	
ds@1952
    56
	RENDER_NORMAL,			/**< src */
ds@1952
    57
	RENDER_TRANSCOLOR,		/**< c*a+dest*(1-a) */
ds@1952
    58
	RENDER_TRANSTEXTURE,	/**< src*a+dest*(1-a) */
ds@1952
    59
	RENDER_GLOW,			/**< src*a+dest -- No Z buffer checks -- Fixed size in screen space */
ds@1952
    60
	RENDER_TRANSALPHA,		/**< src*srca+dest*(1-srca) */
ds@1952
    61
	RENDER_TRANSADD,		/**< src*a+dest */
ds@1952
    62
	RENDER_ENVIRONMENTAL,	/**< not drawn, used for environmental effects */
ds@1952
    63
	RENDER_TRANSADDFRAMEBLEND, /**< use a fractional frame value to blend between animation frames */
ds@1952
    64
	RENDER_TRANSALPHAADD,	/**< src + dest*(1-a) */
ds@1952
    65
	RENDER_WORLDGLOW,		/**< Same as kRenderGlow but not fixed size in screen space */
ds@1952
    66
	RENDER_NONE,			/**< Don't render. */
ds@1952
    67
};
ds@1952
    68
ds@1952
    69
enum RenderFx
ds@1952
    70
{	
ds@1952
    71
	RENDERFX_NONE = 0, 
ds@1952
    72
	RENDERFX_PULSE_SLOW, 
ds@1952
    73
	RENDERFX_PULSE_FAST, 
ds@1952
    74
	RENDERFX_PULSE_SLOW_WIDE, 
ds@1952
    75
	RENDERFX_PULSE_FAST_WIDE, 
ds@1952
    76
	RENDERFX_FADE_SLOW, 
ds@1952
    77
	RENDERFX_FADE_FAST, 
ds@1952
    78
	RENDERFX_SOLID_SLOW, 
ds@1952
    79
	RENDERFX_SOLID_FAST, 	   
ds@1952
    80
	RENDERFX_STROBE_SLOW, 
ds@1952
    81
	RENDERFX_STROBE_FAST, 
ds@1952
    82
	RENDERFX_STROBE_FASTER, 
ds@1952
    83
	RENDERFX_FLICKER_SLOW, 
ds@1952
    84
	RENDERFX_FLICKER_FAST,
ds@1952
    85
	RENDERFX_NO_DISSIPATION,
ds@1952
    86
	RENDERFX_DISTORT,			/**< Distort/scale/translate flicker */
ds@1952
    87
	RENDERFX_HOLOGRAM,			/**< kRenderFxDistort + distance fade */
ds@1952
    88
	RENDERFX_EXPLODE,			/**< Scale up really big! */
ds@1952
    89
	RENDERFX_GLOWSHELL,			/**< Glowing Shell */
ds@1952
    90
	RENDERFX_CLAMP_MIN_SCALE,	/**< Keep this sprite from getting very small (SPRITES only!) */
ds@1952
    91
	RENDERFX_ENV_RAIN,			/**< for environmental rendermode, make rain */
ds@1952
    92
	RENDERFX_ENV_SNOW,			/**<  "        "            "    , make snow */
ds@1952
    93
	RENDERFX_SPOTLIGHT,			/**< TEST CODE for experimental spotlight */
ds@1952
    94
	RENDERFX_RAGDOLL,			/**< HACKHACK: TEST CODE for signalling death of a ragdoll character */
ds@1952
    95
	RENDERFX_PULSE_FAST_WIDER,
ds@1952
    96
	RENDERFX_MAX
ds@1952
    97
};
ds@1952
    98
ds@1952
    99
// These defines are for client button presses.
ds@1952
   100
#define IN_ATTACK		(1 << 0)
ds@1952
   101
#define IN_JUMP			(1 << 1)
ds@1952
   102
#define IN_DUCK			(1 << 2)
ds@1952
   103
#define IN_FORWARD		(1 << 3)
ds@1952
   104
#define IN_BACK			(1 << 4)
ds@1952
   105
#define IN_USE			(1 << 5)
ds@1952
   106
#define IN_CANCEL		(1 << 6)
ds@1952
   107
#define IN_LEFT			(1 << 7)
ds@1952
   108
#define IN_RIGHT		(1 << 8)
ds@1952
   109
#define IN_MOVELEFT		(1 << 9)
ds@1952
   110
#define IN_MOVERIGHT		(1 << 10)
ds@1952
   111
#define IN_ATTACK2		(1 << 11)
ds@1952
   112
#define IN_RUN			(1 << 12)
ds@1952
   113
#define IN_RELOAD		(1 << 13)
ds@1952
   114
#define IN_ALT1			(1 << 14)
ds@1952
   115
#define IN_ALT2			(1 << 15)
ds@1952
   116
#define IN_SCORE		(1 << 16)   	// Used by client.dll for when scoreboard is held down
ds@1952
   117
#define IN_SPEED		(1 << 17)	// Player is holding the speed key
ds@1952
   118
#define IN_WALK			(1 << 18)	// Player holding walk key
ds@1952
   119
#define IN_ZOOM			(1 << 19)	// Zoom key for HUD zoom
ds@1952
   120
#define IN_WEAPON1		(1 << 20)	// weapon defines these bits
ds@1952
   121
#define IN_WEAPON2		(1 << 21)	// weapon defines these bits
ds@1952
   122
#define IN_BULLRUSH		(1 << 22)
ds@1952
   123
#define IN_GRENADE1		(1 << 23)	// grenade 1
ds@1952
   124
#define IN_GRENADE2		(1 << 24)	// grenade 2
ds@1952
   125
ds@1952
   126
// CBaseEntity::m_fFlags
ds@1952
   127
// PLAYER SPECIFIC FLAGS FIRST BECAUSE WE USE ONLY A FEW BITS OF NETWORK PRECISION
ds@1952
   128
#define	FL_ONGROUND			(1 << 0)	// At rest / on the ground
ds@1952
   129
#define FL_DUCKING			(1 << 1)	// Player flag -- Player is fully crouched
ds@1952
   130
#define	FL_WATERJUMP			(1 << 2)	// player jumping out of water
ds@1952
   131
#define FL_ONTRAIN			(1 << 3)	// Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
ds@1952
   132
#define FL_INRAIN			(1 << 4)	// Indicates the entity is standing in rain
ds@1952
   133
#define FL_FROZEN			(1 << 5)	// Player is frozen for 3rd person camera
ds@1952
   134
#define FL_ATCONTROLS			(1 << 6)	// Player can't move, but keeps key inputs for controlling another entity
ds@1952
   135
#define	FL_CLIENT			(1 << 7)	// Is a player
ds@1952
   136
#define FL_FAKECLIENT			(1 << 8)	// Fake client, simulated server side; don't send network messages to them
ds@1952
   137
// NOTE if you move things up, make sure to change this value
ds@1952
   138
#define PLAYER_FLAG_BITS		9
ds@1952
   139
// NON-PLAYER SPECIFIC (i.e., not used by GameMovement or the client .dll ) -- Can still be applied to players, though
ds@1952
   140
#define	FL_INWATER			(1 << 9)	// In water
ds@1952
   141
#define	FL_FLY				(1 << 10)	// Changes the SV_Movestep() behavior to not need to be on ground
ds@1952
   142
#define	FL_SWIM				(1 << 11)	// Changes the SV_Movestep() behavior to not need to be on ground (but stay in water)
ds@1952
   143
#define	FL_CONVEYOR			(1 << 12)
ds@1952
   144
#define	FL_NPC				(1 << 13)
ds@1952
   145
#define	FL_GODMODE			(1 << 14)
ds@1952
   146
#define	FL_NOTARGET			(1 << 15)
ds@1952
   147
#define	FL_AIMTARGET			(1 << 16)	// set if the crosshair needs to aim onto the entity
ds@1952
   148
#define	FL_PARTIALGROUND		(1 << 17)	// not all corners are valid
ds@1952
   149
#define FL_STATICPROP			(1 << 18)	// Eetsa static prop!		
ds@1952
   150
#define FL_GRAPHED			(1 << 19)	// worldgraph has this ent listed as something that blocks a connection
ds@1952
   151
#define FL_GRENADE			(1 << 20)
ds@1952
   152
#define FL_STEPMOVEMENT			(1 << 21)	// Changes the SV_Movestep() behavior to not do any processing
ds@1952
   153
#define FL_DONTTOUCH			(1 << 22)	// Doesn't generate touch functions, generates Untouch() for anything it was touching when this flag was set
ds@1952
   154
#define FL_BASEVELOCITY			(1 << 23)	// Base velocity has been applied this frame (used to convert base velocity into momentum)
ds@1952
   155
#define FL_WORLDBRUSH			(1 << 24)	// Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something)
ds@1952
   156
#define FL_OBJECT			(1 << 25)	// Terrible name. This is an object that NPCs should see. Missiles, for example.
ds@1952
   157
#define FL_KILLME			(1 << 26)	// This entity is marked for death -- will be freed by game DLL
ds@1952
   158
#define FL_ONFIRE			(1 << 27)	// You know...
ds@1952
   159
#define FL_DISSOLVING			(1 << 28)	// We're dissolving!
ds@1952
   160
#define FL_TRANSRAGDOLL			(1 << 29)	// In the process of turning into a client side ragdoll.
ds@1952
   161
#define FL_UNBLOCKABLE_BY_PLAYER	(1 << 30)	// pusher that can't be blocked by the player
ds@1952
   162
// END m_fFlags #defines
ds@1952
   163
ds@1952
   164
/**
ds@1952
   165
 * Get an entity's flags.
ds@1952
   166
 *
ds@1952
   167
 * @param entity	Entity index.
ds@1952
   168
 * @return			Entity's flags, see m_fFlag defines above
ds@1952
   169
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   170
 */
ds@1952
   171
stock GetEntityFlags(entity)
ds@1952
   172
{
ds@1952
   173
	return GetEntProp(entity, Prop_Data, "m_fFlags");
ds@1952
   174
}
ds@1952
   175
ds@1952
   176
/**
ds@1952
   177
 * Gets an entity's movetype.
ds@1952
   178
 *
ds@1952
   179
 * @param entity	Entity index.
ds@1952
   180
 * @return			Movetype, see enum above.
ds@1952
   181
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   182
 */
ds@1952
   183
stock MoveType:GetEntityMoveType(entity)
ds@1952
   184
{
ds@1952
   185
	new offset = GetEntSendPropOffs(entity, "movetype");
ds@1952
   186
	return MoveType:GetEntData(entity, offset, 1);
ds@1952
   187
}
ds@1952
   188
ds@1952
   189
/**
ds@1952
   190
 * Sets an entity's movetype.
ds@1952
   191
 *
ds@1952
   192
 * @param entity	Entity index.
ds@1952
   193
 * @param mt		Movetype, see enum above.
ds@1952
   194
 * @noreturn
ds@1952
   195
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   196
 */
ds@1952
   197
stock SetEntityMoveType(entity, MoveType:mt)
ds@1952
   198
{
ds@1952
   199
	new offset = GetEntSendPropOffs(entity, "movetype");
ds@1952
   200
	SetEntData(entity, offset, mt, 1, true);
ds@1952
   201
}
ds@1952
   202
ds@1952
   203
/**
ds@1952
   204
 * Gets an entity's render mode.
ds@1952
   205
 *
ds@1952
   206
 * @param entity	Entity index.
ds@1952
   207
 * @return			RenderMode value.
ds@1952
   208
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   209
 */
ds@1952
   210
stock RenderMode:GetEntityRenderMode(entity)
ds@1952
   211
{
ds@1952
   212
	return RenderMode:GetEntProp(entity, Prop_Send, "m_nRenderMode", 1);
ds@1952
   213
}
ds@1952
   214
ds@1952
   215
/**
ds@1952
   216
 * Sets an entity's render mode.
ds@1952
   217
 *
ds@1952
   218
 * @param entity	Entity index.
ds@1952
   219
 * @param mode		RenderMode value.
ds@1952
   220
 * @noreturn
ds@1952
   221
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   222
 */
ds@1952
   223
stock SetEntityRenderMode(entity, RenderMode:mode)
ds@1952
   224
{
ds@1952
   225
	SetEntProp(entity, Prop_Send, "m_nRenderMode", mode, 1);
ds@1952
   226
}
ds@1952
   227
ds@1952
   228
/**
ds@1952
   229
 * Gets an entity's render Fx.
ds@1952
   230
 *
ds@1952
   231
 * @param entity	Entity index.
ds@1952
   232
 * @return			RenderFx value.
ds@1952
   233
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   234
 */
ds@1952
   235
stock RenderFx:GetEntityRenderFx(entity)
ds@1952
   236
{
ds@1952
   237
	return RenderFx:GetEntProp(entity, Prop_Send, "m_nRenderFX", 1);
ds@1952
   238
}
ds@1952
   239
ds@1952
   240
/**
ds@1952
   241
 * Sets an entity's render Fx.
ds@1952
   242
 *
ds@1952
   243
 * @param entity	Entity index.
ds@1952
   244
 * @param fx		RenderFx value.
ds@1952
   245
 * @noreturn
ds@1952
   246
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   247
 */
ds@1952
   248
stock SetEntityRenderFx(entity, RenderFx:fx)
ds@1952
   249
{
ds@1952
   250
	SetEntProp(entity, Prop_Send, "m_nRenderFX", fx, 1);
ds@1952
   251
}
ds@1952
   252
ds@1952
   253
/**
ds@1952
   254
 * Sets an entity's color.
ds@1952
   255
 *
ds@1952
   256
 * @param entity	Entity index
ds@1952
   257
 * @param r 		Amount of red (0-255)
ds@1952
   258
 * @param g 		Amount of green (0-255)
ds@1952
   259
 * @param b 		Amount of blue (0-255)
ds@1952
   260
 * @param a 		Amount of alpha (0-255)
ds@1952
   261
 * @noreturn
ds@1952
   262
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   263
 */
ds@1952
   264
stock SetEntityRenderColor(entity, r=255, g=255, b=255, a=255)
ds@1952
   265
{
ds@1952
   266
	new offset = GetEntSendPropOffs(entity, "m_clrRender");
ds@1952
   267
	SetEntData(entity, offset, r, 1, true);
ds@1952
   268
	SetEntData(entity, offset + 1, g, 1, true);
ds@1952
   269
	SetEntData(entity, offset + 2, b, 1, true);
ds@1952
   270
	SetEntData(entity, offset + 3, a, 1, true);
ds@1952
   271
}
ds@1952
   272
ds@1952
   273
/* GuessSDKVersion */
ds@1952
   274
ds@1952
   275
/**
ds@1952
   276
 * Gets an entity's gravity.
ds@1952
   277
 *
ds@1952
   278
 * @param entity 	Entity index.
ds@1952
   279
 * @return			Entity's m_flGravity value.
ds@1952
   280
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   281
 */
ds@1952
   282
stock Float:GetEntityGravity(entity)
ds@1952
   283
{
ds@1952
   284
	return GetEntPropFloat(entity, Prop_Data, "m_flGravity");
ds@1952
   285
}
ds@1952
   286
ds@1952
   287
/**
ds@1952
   288
 * Sets an entity's gravity.
ds@1952
   289
 *
ds@1952
   290
 * @param entity	Entity index.
ds@1952
   291
 * @param amount	Gravity to set (default = 1.0, half = 0.5, double = 2.0).
ds@1952
   292
 * @noreturn
ds@1952
   293
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   294
 */
ds@1952
   295
stock SetEntityGravity(entity, Float:amount)
ds@1952
   296
{
ds@1952
   297
	SetEntPropFloat(entity, Prop_Data, "m_flGravity", amount);
ds@1952
   298
}
ds@1952
   299
ds@1952
   300
/**
ds@1952
   301
 * Sets an entity's health
ds@1952
   302
 *
ds@1952
   303
 * @param entity	Entity index.
ds@1952
   304
 * @param amount	Health amount.
ds@1952
   305
 * @noreturn
ds@1952
   306
 * @error			Invalid entity index, or lack of mod compliance.
ds@1952
   307
 */
ds@1952
   308
stock SetEntityHealth(entity, amount)
ds@1952
   309
{
ds@1952
   310
	SetEntProp(entity, Prop_Send, "m_iHealth", amount);
ds@1952
   311
}
ds@1952
   312
ds@1952
   313
/**
ds@1952
   314
 * Get's a users current pressed buttons
ds@1952
   315
 *
ds@1952
   316
 * @param client	Client index
ds@1952
   317
 * @return			Bitsum of buttons
ds@1952
   318
 * @error			Invalid client index, client not in game, 
ds@1952
   319
 *					or lack of mod compliance.
ds@1952
   320
 */
ds@1952
   321
stock GetClientButtons(client)
ds@1952
   322
{
ds@1952
   323
	return GetEntProp(client, Prop_Data, "m_nButtons");
ds@1952
   324
}