1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod (C)2009-2013 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*/
#if defined _sdkhooks_included
#endinput
#endif
#define _sdkhooks_included
// this is obviously _not_ a robust check, but it will solve most conflict and is clean
#if !defined DMG_GENERIC
#define DMG_GENERIC 0 /**< generic damage was done */
#define DMG_CRUSH (1 << 0) /**< crushed by falling or moving object.
NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead. */
#define DMG_BULLET (1 << 1) /**< shot */
#define DMG_SLASH (1 << 2) /**< cut, clawed, stabbed */
#define DMG_BURN (1 << 3) /**< heat burned */
#define DMG_VEHICLE (1 << 4) /**< hit by a vehicle */
#define DMG_FALL (1 << 5) /**< fell too far */
#define DMG_BLAST (1 << 6) /**< explosive blast damage */
#define DMG_CLUB (1 << 7) /**< crowbar, punch, headbutt */
#define DMG_SHOCK (1 << 8) /**< electric shock */
#define DMG_SONIC (1 << 9) /**< sound pulse shockwave */
#define DMG_ENERGYBEAM (1 << 10) /**< laser or other high energy beam */
#define DMG_PREVENT_PHYSICS_FORCE (1 << 11) /**< Prevent a physics force */
#define DMG_NEVERGIB (1 << 12) /**< with this bit OR'd in, no damage type will be able to gib victims upon death */
#define DMG_ALWAYSGIB (1 << 13) /**< with this bit OR'd in, any damage type can be made to gib victims upon death. */
#define DMG_DROWN (1 << 14) /**< Drowning */
#define DMG_PARALYZE (1 << 15) /**< slows affected creature down */
#define DMG_NERVEGAS (1 << 16) /**< nerve toxins, very bad */
#define DMG_POISON (1 << 17) /**< blood poisoning - heals over time like drowning damage */
#define DMG_RADIATION (1 << 18) /**< radiation exposure */
#define DMG_DROWNRECOVER (1 << 19) /**< drowning recovery */
#define DMG_ACID (1 << 20) /**< toxic chemicals or acid burns */
#define DMG_SLOWBURN (1 << 21) /**< in an oven */
#define DMG_REMOVENORAGDOLL (1 << 22) /**< with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
use this to kill an entity that you've already got a server-side ragdoll for */
#define DMG_PHYSGUN (1 << 23) /**< Hit by manipulator. Usually doesn't do any damage. */
#define DMG_PLASMA (1 << 24) /**< Shot by Cremator */
#define DMG_AIRBOAT (1 << 25) /**< Hit by the airboat's gun */
#define DMG_DISSOLVE (1 << 26) /**< Dissolving! */
#define DMG_BLAST_SURFACE (1 << 27) /**< A blast on the surface of water that cannot harm things underwater */
#define DMG_DIRECT (1 << 28)
#define DMG_BUCKSHOT (1 << 29) /**< not quite a bullet. Little, rounder, different. */
#endif
#if !defined DMG_CRIT
// TF2 crits and minicrits
#define DMG_CRIT DMG_ACID
#endif
enum SDKHookType
{
SDKHook_EndTouch,
SDKHook_FireBulletsPost,
SDKHook_OnTakeDamage,
SDKHook_OnTakeDamagePost,
SDKHook_PreThink,
SDKHook_PostThink,
SDKHook_SetTransmit,
SDKHook_Spawn,
SDKHook_StartTouch,
SDKHook_Think,
SDKHook_Touch,
SDKHook_TraceAttack,
SDKHook_TraceAttackPost,
SDKHook_WeaponCanSwitchTo,
SDKHook_WeaponCanUse,
SDKHook_WeaponDrop,
SDKHook_WeaponEquip,
SDKHook_WeaponSwitch,
SDKHook_ShouldCollide,
SDKHook_PreThinkPost,
SDKHook_PostThinkPost,
SDKHook_ThinkPost,
SDKHook_EndTouchPost,
SDKHook_GroundEntChangedPost,
SDKHook_SpawnPost,
SDKHook_StartTouchPost,
SDKHook_TouchPost,
SDKHook_VPhysicsUpdate,
SDKHook_VPhysicsUpdatePost,
SDKHook_WeaponCanSwitchToPost,
SDKHook_WeaponCanUsePost,
SDKHook_WeaponDropPost,
SDKHook_WeaponEquipPost,
SDKHook_WeaponSwitchPost,
SDKHook_Use,
SDKHook_UsePost,
SDKHook_Reload,
SDKHook_ReloadPost,
SDKHook_GetMaxHealth, /**< ep2v and later */
};
/*
Alphabetized for easy readability
SDKHook_EndTouch,
SDKHook_EndTouchPost,
SDKHook_FireBulletsPost,
SDKHook_GetMaxHealth, (ep2v and later)
SDKHook_GroundEntChangedPost,
SDKHook_OnTakeDamage,
SDKHook_OnTakeDamagePost,
SDKHook_PreThink,
SDKHook_PreThinkPost,
SDKHook_PostThink,
SDKHook_PostThinkPost,
SDKHook_Reload,
SDKHook_ReloadPost,
SDKHook_SetTransmit,
SDKHook_ShouldCollide,
SDKHook_Spawn,
SDKHook_SpawnPost,
SDKHook_StartTouch,
SDKHook_StartTouchPost,
SDKHook_Think,
SDKHook_ThinkPost,
SDKHook_Touch,
SDKHook_TouchPost,
SDKHook_TraceAttack,
SDKHook_TraceAttackPost,
SDKHook_Use,
SDKHook_UsePost,
SDKHook_VPhysicsUpdate,
SDKHook_VPhysicsUpdatePost,
SDKHook_WeaponCanSwitchTo,
SDKHook_WeaponCanSwitchToPost,
SDKHook_WeaponCanUse,
SDKHook_WeaponCanUsePost,
SDKHook_WeaponDrop,
SDKHook_WeaponDropPost,
SDKHook_WeaponEquip,
SDKHook_WeaponEquipPost,
SDKHook_WeaponSwitch,
SDKHook_WeaponSwitchPost
*/
enum UseType
{
Use_Off,
Use_On,
Use_Set,
Use_Toggle
};
funcenum SDKHookCB
{
// PreThink/Post
// PostThink/Post
public(client),
// Spawn
Action:public(entity),
// GroundEntChanged
// SpawnPost
// Think/Post
// VPhysicsUpdate/Post
public(entity),
// EndTouch
// StartTouch
// Touch
Action:public(entity, other),
// EndTouchPost
// StartTouchPost
// TouchPost
public(entity, other),
// SetTransmit
Action:public(entity, client),
// WeaponCanSwitchTo
// WeaponCanUse
// WeaponDrop
// WeaponEquip
// WeaponSwitch
Action:public(client, weapon),
// WeaponCanSwitchToPost
// WeaponCanUsePost
// WeaponDropPost
// WeaponEquipPost
// WeaponSwitchPost
public(client, weapon),
// GetMaxHealth (ep2v and later)
Action:public(entity, &maxhealth),
// OnTakeDamage
// Note: The weapon parameter is not used by all games and damage sources.
// Note: Force application is dependent on game and damage type(s)
// SDKHooks 1.0+
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype),
// SDKHooks 2.0+
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]),
// SDKHooks 2.1+ (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability.
// DON'T attempt to access 'damagecustom' var if feature status != available
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon,
Float:damageForce[3], Float:damagePosition[3], damagecustom),
// OnTakeDamagePost
public(victim, attacker, inflictor, Float:damage, damagetype),
public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]),
// FireBulletsPost
public(client, shots, const String:weaponname[]),
// TraceAttack
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
// TraceAttackPost
public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
// ShouldCollide
bool:public(entity, collisiongroup, contentsmask, bool:originalResult),
// Use
Action:public(entity, activator, caller, UseType:type, Float:value),
// UsePost
public(entity, activator, caller, UseType:type, Float:value),
// Reload
Action:public(weapon),
// Reload post
public(weapon, bool:bSuccessful)
};
/**
* @brief When an entity is created
*
* @param entity Entity index
* @param classname Class name
* @noreturn
*/
forward OnEntityCreated(entity, const String:classname[]);
/**
* @brief When an entity is destroyed
*
* @param entity Entity index
* @noreturn
*/
forward OnEntityDestroyed(entity);
/**
* @brief When the game description is retrieved
*
* @note Not supported on ep2v.
*
* @param gameDesc Game description
* @noreturn
*/
forward Action:OnGetGameDescription(String:gameDesc[64]);
/**
* @brief When the level is initialized
*
* @param mapName Name of the map
* @param mapEntities Entities of the map
* @noreturn
*/
forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
/**
* @brief Hooks an entity
*
* @param entity Entity index
* @param type Type of function to hook
* @param callback Function to call when hook is called
* @noreturn
*/
native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
/**
* @brief Hooks an entity
*
* @param entity Entity index
* @param type Type of function to hook
* @param callback Function to call when hook is called
* @return bool Hook Successful
*/
native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
/**
* @brief Unhooks an entity
*
* @param entity Entity index
* @param type Type of function to unhook
* @param callback Callback function to unhook
* @noreturn
*/
native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
/**
* @brief Applies damage to an entity
*
* @note Force application is dependent on game and damage type(s)
*
* @param entity Entity index taking damage
* @param inflictor Inflictor entity index
* @param attacker Attacker entity index
* @param damage Amount of damage
* @param damageType Bitfield of damage types
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
* @param damageForce Velocity of damage force
* @param damagePosition Origin of damage
* @noreturn
*/
native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR);
/**
* @brief Forces a client to drop the specified weapon
*
* @param client Client index.
* @param weapon Weapon entity index.
* @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
* @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
* @noreturn
* @error Invalid client or weapon entity, weapon not owned by client.
*/
native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR);
/**
* Do not edit below this line!
*/
public Extension:__ext_sdkhooks =
{
name = "SDKHooks",
file = "sdkhooks.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
|