3 * =============================================================================
4 * SourceMod (C)2009-2013 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
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.
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
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/>.
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>.
31 #if defined _sdkhooks_included
34 #define _sdkhooks_included
36 // this is obviously _not_ a robust check, but it will solve most conflict and is clean
37 #if !defined DMG_GENERIC
38 #define DMG_GENERIC 0 // generic damage was done
39 #define DMG_CRUSH (1 << 0) // crushed by falling or moving object.
40 // NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
41 // DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead.
42 #define DMG_BULLET (1 << 1) // shot
43 #define DMG_SLASH (1 << 2) // cut, clawed, stabbed
44 #define DMG_BURN (1 << 3) // heat burned
45 #define DMG_VEHICLE (1 << 4) // hit by a vehicle
46 #define DMG_FALL (1 << 5) // fell too far
47 #define DMG_BLAST (1 << 6) // explosive blast damage
48 #define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
49 #define DMG_SHOCK (1 << 8) // electric shock
50 #define DMG_SONIC (1 << 9) // sound pulse shockwave
51 #define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
52 #define DMG_PREVENT_PHYSICS_FORCE (1 << 11) // Prevent a physics force
53 #define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
54 #define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
55 #define DMG_DROWN (1 << 14) // Drowning
56 #define DMG_PARALYZE (1 << 15) // slows affected creature down
57 #define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
58 #define DMG_POISON (1 << 17) // blood poisoning - heals over time like drowning damage
59 #define DMG_RADIATION (1 << 18) // radiation exposure
60 #define DMG_DROWNRECOVER (1 << 19) // drowning recovery
61 #define DMG_ACID (1 << 20) // toxic chemicals or acid burns
62 #define DMG_SLOWBURN (1 << 21) // in an oven
63 #define DMG_REMOVENORAGDOLL (1 << 22) // with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
64 // use this to kill an entity that you've already got a server-side ragdoll for
65 #define DMG_PHYSGUN (1 << 23) // Hit by manipulator. Usually doesn't do any damage.
66 #define DMG_PLASMA (1 << 24) // Shot by Cremator
67 #define DMG_AIRBOAT (1 << 25) // Hit by the airboat's gun
68 #define DMG_DISSOLVE (1 << 26) // Dissolving!
69 #define DMG_BLAST_SURFACE (1 << 27) // A blast on the surface of water that cannot harm things underwater
70 #define DMG_DIRECT (1 << 28)
71 #define DMG_BUCKSHOT (1 << 29) // not quite a bullet. Little, rounder, different.
75 // TF2 crits and minicrits
76 #define DMG_CRIT DMG_ACID
82 SDKHook_FireBulletsPost,
84 SDKHook_OnTakeDamagePost,
93 SDKHook_TraceAttackPost,
94 SDKHook_WeaponCanSwitchTo,
99 SDKHook_ShouldCollide,
100 SDKHook_PreThinkPost,
101 SDKHook_PostThinkPost,
103 SDKHook_EndTouchPost,
104 SDKHook_GroundEntChangedPost,
106 SDKHook_StartTouchPost,
108 SDKHook_VPhysicsUpdate,
109 SDKHook_VPhysicsUpdatePost,
110 SDKHook_WeaponCanSwitchToPost,
111 SDKHook_WeaponCanUsePost,
112 SDKHook_WeaponDropPost,
113 SDKHook_WeaponEquipPost,
114 SDKHook_WeaponSwitchPost,
119 SDKHook_GetMaxHealth, // ep2v and later
123 Alphabetized for easy readability
126 SDKHook_EndTouchPost,
128 SDKHook_FireBulletsPost,
130 SDKHook_GetMaxHealth, (ep2v and later)
132 SDKHook_GroundEntChangedPost,
134 SDKHook_OnTakeDamage,
135 SDKHook_OnTakeDamagePost,
138 SDKHook_PreThinkPost,
141 SDKHook_PostThinkPost,
148 SDKHook_ShouldCollide,
154 SDKHook_StartTouchPost,
163 SDKHook_TraceAttackPost,
168 SDKHook_VPhysicsUpdate,
169 SDKHook_VPhysicsUpdatePost,
171 SDKHook_WeaponCanSwitchTo,
172 SDKHook_WeaponCanSwitchToPost,
174 SDKHook_WeaponCanUse,
175 SDKHook_WeaponCanUsePost,
178 SDKHook_WeaponDropPost,
181 SDKHook_WeaponEquipPost,
183 SDKHook_WeaponSwitch,
184 SDKHook_WeaponSwitchPost
202 Action:public(entity),
207 // VPhysicsUpdate/Post
213 Action:public(entity, other),
218 public(entity, other),
221 Action:public(entity, client),
228 Action:public(client, weapon),
230 // WeaponCanSwitchToPost
235 public(client, weapon),
237 // GetMaxHealth (ep2v and later)
238 Action:public(entity, &maxhealth),
241 // Note: The weapon parameter is not used by all games and damage sources.
242 // Note: Force application is dependent on game and damage type(s)
244 Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype),
246 Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]),
247 // SDKHooks 2.1+ (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability.
248 // DON'T attempt to access 'damagecustom' var if feature status != available
249 Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon,
250 Float:damageForce[3], Float:damagePosition[3], damagecustom),
253 public(victim, attacker, inflictor, Float:damage, damagetype),
254 public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]),
257 public(client, shots, const String:weaponname[]),
260 Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
263 public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
266 bool:public(entity, collisiongroup, contentsmask, bool:originalResult),
269 Action:public(entity, activator, caller, UseType:type, Float:value),
272 public(entity, activator, caller, UseType:type, Float:value),
275 Action:public(weapon),
278 public(weapon, bool:bSuccessful)
283 * @brief When an entity is created
285 * @param entity Entity index
286 * @param classname Class name
289 forward OnEntityCreated(entity, const String:classname[]);
292 * @brief When an entity is destroyed
294 * @param entity Entity index
297 forward OnEntityDestroyed(entity);
300 * @brief When the game description is retrieved
302 * @note Not supported on ep2v.
304 * @param gameDesc Game description
307 forward Action:OnGetGameDescription(String:gameDesc[64]);
310 * @brief When the level is initialized
312 * @param mapName Name of the map
313 * @param mapEntities Entities of the map
316 forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
319 * @brief Hooks an entity
321 * @param entity Entity index
322 * @param type Type of function to hook
323 * @param callback Function to call when hook is called
326 native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
329 * @brief Hooks an entity
331 * @param entity Entity index
332 * @param type Type of function to hook
333 * @param callback Function to call when hook is called
334 * @return bool Hook Successful
336 native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
339 * @brief Unhooks an entity
341 * @param entity Entity index
342 * @param type Type of function to unhook
343 * @param callback Callback function to unhook
346 native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
349 * @brief Applies damage to an entity
351 * @note Force application is dependent on game and damage type(s)
353 * @param entity Entity index taking damage
354 * @param inflictor Inflictor entity index
355 * @param attacker Attacker entity index
356 * @param damage Amount of damage
357 * @param damageType Bitfield of damage types
358 * @param weapon Weapon index (orangebox and later) or -1 for unspecified
359 * @param damageForce Velocity of damage force
360 * @param damagePosition Origin of damage
363 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);
366 * @brief Forces a client to drop the specified weapon
368 * @param client Client index.
369 * @param weapon Weapon entity index.
370 * @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
371 * @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
373 * @error Invalid client or weapon entity, weapon not owned by client.
375 native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR);
378 * Do not edit below this line!
380 public Extension:__ext_sdkhooks =
383 file = "sdkhooks.ext",
384 #if defined AUTOLOAD_EXTENSIONS
389 #if defined REQUIRE_EXTENSIONS