skamonkey@3767: /**
skamonkey@3767: * vim: set ts=4 :
skamonkey@3767: * =============================================================================
skamonkey@3767: * SourceMod (C)2009-2013 AlliedModders LLC. All rights reserved.
skamonkey@3767: * =============================================================================
skamonkey@3767: *
skamonkey@3767: * This file is part of the SourceMod/SourcePawn SDK.
skamonkey@3767: *
skamonkey@3767: * This program is free software; you can redistribute it and/or modify it under
skamonkey@3767: * the terms of the GNU General Public License, version 3.0, as published by the
skamonkey@3767: * Free Software Foundation.
skamonkey@3767: *
skamonkey@3767: * This program is distributed in the hope that it will be useful, but WITHOUT
skamonkey@3767: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
skamonkey@3767: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
skamonkey@3767: * details.
skamonkey@3767: *
skamonkey@3767: * You should have received a copy of the GNU General Public License along with
skamonkey@3767: * this program. If not, see .
skamonkey@3767: *
skamonkey@3767: * As a special exception, AlliedModders LLC gives you permission to link the
skamonkey@3767: * code of this program (as well as its derivative works) to "Half-Life 2," the
skamonkey@3767: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
skamonkey@3767: * by the Valve Corporation. You must obey the GNU General Public License in
skamonkey@3767: * all respects for all other code used. Additionally, AlliedModders LLC grants
skamonkey@3767: * this exception to all derivative works. AlliedModders LLC defines further
skamonkey@3767: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
skamonkey@3767: * or .
skamonkey@3767: */
skamonkey@3767:
skamonkey@3767: #if defined _sdkhooks_included
skamonkey@3767: #endinput
skamonkey@3767: #endif
skamonkey@3767: #define _sdkhooks_included
skamonkey@3767:
skamonkey@3767: // this is obviously _not_ a robust check, but it will solve most conflict and is clean
skamonkey@3767: #if !defined DMG_GENERIC
erik@3967: #define DMG_GENERIC 0 /**< generic damage was done */
erik@3967: #define DMG_CRUSH (1 << 0) /**< crushed by falling or moving object.
erik@3967: NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
erik@3967: DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead. */
erik@3967: #define DMG_BULLET (1 << 1) /**< shot */
erik@3967: #define DMG_SLASH (1 << 2) /**< cut, clawed, stabbed */
erik@3967: #define DMG_BURN (1 << 3) /**< heat burned */
erik@3967: #define DMG_VEHICLE (1 << 4) /**< hit by a vehicle */
erik@3967: #define DMG_FALL (1 << 5) /**< fell too far */
erik@3967: #define DMG_BLAST (1 << 6) /**< explosive blast damage */
erik@3967: #define DMG_CLUB (1 << 7) /**< crowbar, punch, headbutt */
erik@3967: #define DMG_SHOCK (1 << 8) /**< electric shock */
erik@3967: #define DMG_SONIC (1 << 9) /**< sound pulse shockwave */
erik@3967: #define DMG_ENERGYBEAM (1 << 10) /**< laser or other high energy beam */
erik@3967: #define DMG_PREVENT_PHYSICS_FORCE (1 << 11) /**< Prevent a physics force */
erik@3967: #define DMG_NEVERGIB (1 << 12) /**< with this bit OR'd in, no damage type will be able to gib victims upon death */
erik@3967: #define DMG_ALWAYSGIB (1 << 13) /**< with this bit OR'd in, any damage type can be made to gib victims upon death. */
erik@3967: #define DMG_DROWN (1 << 14) /**< Drowning */
erik@3967: #define DMG_PARALYZE (1 << 15) /**< slows affected creature down */
erik@3967: #define DMG_NERVEGAS (1 << 16) /**< nerve toxins, very bad */
erik@3967: #define DMG_POISON (1 << 17) /**< blood poisoning - heals over time like drowning damage */
erik@3967: #define DMG_RADIATION (1 << 18) /**< radiation exposure */
erik@3967: #define DMG_DROWNRECOVER (1 << 19) /**< drowning recovery */
erik@3967: #define DMG_ACID (1 << 20) /**< toxic chemicals or acid burns */
erik@3967: #define DMG_SLOWBURN (1 << 21) /**< in an oven */
erik@3967: #define DMG_REMOVENORAGDOLL (1 << 22) /**< with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
erik@3967: use this to kill an entity that you've already got a server-side ragdoll for */
erik@3967: #define DMG_PHYSGUN (1 << 23) /**< Hit by manipulator. Usually doesn't do any damage. */
erik@3967: #define DMG_PLASMA (1 << 24) /**< Shot by Cremator */
erik@3967: #define DMG_AIRBOAT (1 << 25) /**< Hit by the airboat's gun */
erik@3967: #define DMG_DISSOLVE (1 << 26) /**< Dissolving! */
erik@3967: #define DMG_BLAST_SURFACE (1 << 27) /**< A blast on the surface of water that cannot harm things underwater */
skamonkey@3767: #define DMG_DIRECT (1 << 28)
erik@3967: #define DMG_BUCKSHOT (1 << 29) /**< not quite a bullet. Little, rounder, different. */
skamonkey@3767: #endif
skamonkey@3767:
skamonkey@3767: #if !defined DMG_CRIT
skamonkey@3767: // TF2 crits and minicrits
skamonkey@3767: #define DMG_CRIT DMG_ACID
skamonkey@3767: #endif
skamonkey@3767:
skamonkey@3767: enum SDKHookType
skamonkey@3767: {
skamonkey@3767: SDKHook_EndTouch,
skamonkey@3767: SDKHook_FireBulletsPost,
skamonkey@3767: SDKHook_OnTakeDamage,
skamonkey@3767: SDKHook_OnTakeDamagePost,
skamonkey@3767: SDKHook_PreThink,
skamonkey@3767: SDKHook_PostThink,
skamonkey@3767: SDKHook_SetTransmit,
skamonkey@3767: SDKHook_Spawn,
skamonkey@3767: SDKHook_StartTouch,
skamonkey@3767: SDKHook_Think,
skamonkey@3767: SDKHook_Touch,
skamonkey@3767: SDKHook_TraceAttack,
skamonkey@3767: SDKHook_TraceAttackPost,
skamonkey@3767: SDKHook_WeaponCanSwitchTo,
skamonkey@3767: SDKHook_WeaponCanUse,
skamonkey@3767: SDKHook_WeaponDrop,
skamonkey@3767: SDKHook_WeaponEquip,
skamonkey@3767: SDKHook_WeaponSwitch,
skamonkey@3767: SDKHook_ShouldCollide,
skamonkey@3767: SDKHook_PreThinkPost,
skamonkey@3767: SDKHook_PostThinkPost,
skamonkey@3767: SDKHook_ThinkPost,
skamonkey@3767: SDKHook_EndTouchPost,
skamonkey@3767: SDKHook_GroundEntChangedPost,
skamonkey@3767: SDKHook_SpawnPost,
skamonkey@3767: SDKHook_StartTouchPost,
skamonkey@3767: SDKHook_TouchPost,
skamonkey@3767: SDKHook_VPhysicsUpdate,
skamonkey@3767: SDKHook_VPhysicsUpdatePost,
skamonkey@3767: SDKHook_WeaponCanSwitchToPost,
skamonkey@3767: SDKHook_WeaponCanUsePost,
skamonkey@3767: SDKHook_WeaponDropPost,
skamonkey@3767: SDKHook_WeaponEquipPost,
skamonkey@3767: SDKHook_WeaponSwitchPost,
skamonkey@3767: SDKHook_Use,
skamonkey@3767: SDKHook_UsePost,
skamonkey@3767: SDKHook_Reload,
skamonkey@3767: SDKHook_ReloadPost,
erik@3967: SDKHook_GetMaxHealth, /**< ep2v and later */
skamonkey@3767: };
skamonkey@3767:
skamonkey@3767: /*
skamonkey@3767: Alphabetized for easy readability
skamonkey@3767:
skamonkey@3767: SDKHook_EndTouch,
skamonkey@3767: SDKHook_EndTouchPost,
skamonkey@3767:
skamonkey@3767: SDKHook_FireBulletsPost,
skamonkey@3767:
skamonkey@3767: SDKHook_GetMaxHealth, (ep2v and later)
skamonkey@3767:
skamonkey@3767: SDKHook_GroundEntChangedPost,
skamonkey@3767:
skamonkey@3767: SDKHook_OnTakeDamage,
skamonkey@3767: SDKHook_OnTakeDamagePost,
skamonkey@3767:
skamonkey@3767: SDKHook_PreThink,
skamonkey@3767: SDKHook_PreThinkPost,
skamonkey@3767:
skamonkey@3767: SDKHook_PostThink,
skamonkey@3767: SDKHook_PostThinkPost,
skamonkey@3767:
skamonkey@3767: SDKHook_Reload,
skamonkey@3767: SDKHook_ReloadPost,
skamonkey@3767:
skamonkey@3767: SDKHook_SetTransmit,
skamonkey@3767:
skamonkey@3767: SDKHook_ShouldCollide,
skamonkey@3767:
skamonkey@3767: SDKHook_Spawn,
skamonkey@3767: SDKHook_SpawnPost,
skamonkey@3767:
skamonkey@3767: SDKHook_StartTouch,
skamonkey@3767: SDKHook_StartTouchPost,
skamonkey@3767:
skamonkey@3767: SDKHook_Think,
skamonkey@3767: SDKHook_ThinkPost,
skamonkey@3767:
skamonkey@3767: SDKHook_Touch,
skamonkey@3767: SDKHook_TouchPost,
skamonkey@3767:
skamonkey@3767: SDKHook_TraceAttack,
skamonkey@3767: SDKHook_TraceAttackPost,
skamonkey@3767:
skamonkey@3767: SDKHook_Use,
skamonkey@3767: SDKHook_UsePost,
skamonkey@3767:
skamonkey@3767: SDKHook_VPhysicsUpdate,
skamonkey@3767: SDKHook_VPhysicsUpdatePost,
skamonkey@3767:
skamonkey@3767: SDKHook_WeaponCanSwitchTo,
skamonkey@3767: SDKHook_WeaponCanSwitchToPost,
skamonkey@3767:
skamonkey@3767: SDKHook_WeaponCanUse,
skamonkey@3767: SDKHook_WeaponCanUsePost,
skamonkey@3767:
skamonkey@3767: SDKHook_WeaponDrop,
skamonkey@3767: SDKHook_WeaponDropPost,
skamonkey@3767:
skamonkey@3767: SDKHook_WeaponEquip,
skamonkey@3767: SDKHook_WeaponEquipPost,
skamonkey@3767:
skamonkey@3767: SDKHook_WeaponSwitch,
skamonkey@3767: SDKHook_WeaponSwitchPost
skamonkey@3767: */
skamonkey@3767:
skamonkey@3767: enum UseType
skamonkey@3767: {
skamonkey@3767: Use_Off,
skamonkey@3767: Use_On,
skamonkey@3767: Use_Set,
skamonkey@3767: Use_Toggle
skamonkey@3767: };
skamonkey@3767:
skamonkey@3767: funcenum SDKHookCB
skamonkey@3767: {
skamonkey@3767: // PreThink/Post
skamonkey@3767: // PostThink/Post
skamonkey@3767: public(client),
skamonkey@3767:
skamonkey@3767: // Spawn
skamonkey@3767: Action:public(entity),
skamonkey@3767:
skamonkey@3767: // GroundEntChanged
skamonkey@3767: // SpawnPost
skamonkey@3767: // Think/Post
skamonkey@3767: // VPhysicsUpdate/Post
skamonkey@3767: public(entity),
skamonkey@3767:
skamonkey@3767: // EndTouch
skamonkey@3767: // StartTouch
skamonkey@3767: // Touch
skamonkey@3767: Action:public(entity, other),
skamonkey@3767:
skamonkey@3767: // EndTouchPost
skamonkey@3767: // StartTouchPost
skamonkey@3767: // TouchPost
skamonkey@3767: public(entity, other),
skamonkey@3767:
skamonkey@3767: // SetTransmit
skamonkey@3767: Action:public(entity, client),
skamonkey@3767:
skamonkey@3767: // WeaponCanSwitchTo
skamonkey@3767: // WeaponCanUse
skamonkey@3767: // WeaponDrop
skamonkey@3767: // WeaponEquip
skamonkey@3767: // WeaponSwitch
skamonkey@3767: Action:public(client, weapon),
skamonkey@3767:
skamonkey@3767: // WeaponCanSwitchToPost
skamonkey@3767: // WeaponCanUsePost
skamonkey@3767: // WeaponDropPost
skamonkey@3767: // WeaponEquipPost
skamonkey@3767: // WeaponSwitchPost
skamonkey@3767: public(client, weapon),
skamonkey@3767:
skamonkey@3767: // GetMaxHealth (ep2v and later)
skamonkey@3767: Action:public(entity, &maxhealth),
skamonkey@3767:
skamonkey@3767: // OnTakeDamage
skamonkey@3767: // Note: The weapon parameter is not used by all games and damage sources.
skamonkey@3767: // Note: Force application is dependent on game and damage type(s)
skamonkey@3767: // SDKHooks 1.0+
skamonkey@3767: Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype),
skamonkey@3767: // SDKHooks 2.0+
skamonkey@3767: Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]),
skamonkey@3767: // SDKHooks 2.1+ (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability.
skamonkey@3767: // DON'T attempt to access 'damagecustom' var if feature status != available
skamonkey@3767: Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon,
skamonkey@3767: Float:damageForce[3], Float:damagePosition[3], damagecustom),
skamonkey@3767:
skamonkey@3767: // OnTakeDamagePost
skamonkey@3767: public(victim, attacker, inflictor, Float:damage, damagetype),
skamonkey@3767: public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]),
skamonkey@3767:
skamonkey@3767: // FireBulletsPost
skamonkey@3767: public(client, shots, const String:weaponname[]),
skamonkey@3767:
skamonkey@3767: // TraceAttack
skamonkey@3767: Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
skamonkey@3767:
skamonkey@3767: // TraceAttackPost
skamonkey@3767: public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
skamonkey@3767:
skamonkey@3767: // ShouldCollide
skamonkey@3767: bool:public(entity, collisiongroup, contentsmask, bool:originalResult),
skamonkey@3767:
skamonkey@3767: // Use
skamonkey@3767: Action:public(entity, activator, caller, UseType:type, Float:value),
skamonkey@3767:
skamonkey@3767: // UsePost
skamonkey@3767: public(entity, activator, caller, UseType:type, Float:value),
skamonkey@3767:
skamonkey@3767: // Reload
skamonkey@3767: Action:public(weapon),
skamonkey@3767:
skamonkey@3767: // Reload post
skamonkey@3767: public(weapon, bool:bSuccessful)
skamonkey@3767: };
skamonkey@3767:
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief When an entity is created
skamonkey@3767: *
skamonkey@3767: * @param entity Entity index
skamonkey@3767: * @param classname Class name
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: forward OnEntityCreated(entity, const String:classname[]);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief When an entity is destroyed
skamonkey@3767: *
skamonkey@3767: * @param entity Entity index
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: forward OnEntityDestroyed(entity);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief When the game description is retrieved
skamonkey@3767: *
skamonkey@3767: * @note Not supported on ep2v.
skamonkey@3767: *
skamonkey@3767: * @param gameDesc Game description
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: forward Action:OnGetGameDescription(String:gameDesc[64]);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief When the level is initialized
skamonkey@3767: *
skamonkey@3767: * @param mapName Name of the map
skamonkey@3767: * @param mapEntities Entities of the map
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief Hooks an entity
skamonkey@3767: *
skamonkey@3767: * @param entity Entity index
skamonkey@3767: * @param type Type of function to hook
skamonkey@3767: * @param callback Function to call when hook is called
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief Hooks an entity
skamonkey@3767: *
skamonkey@3767: * @param entity Entity index
skamonkey@3767: * @param type Type of function to hook
skamonkey@3767: * @param callback Function to call when hook is called
skamonkey@3767: * @return bool Hook Successful
skamonkey@3767: */
skamonkey@3767: native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief Unhooks an entity
skamonkey@3767: *
skamonkey@3767: * @param entity Entity index
skamonkey@3767: * @param type Type of function to unhook
skamonkey@3767: * @param callback Callback function to unhook
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief Applies damage to an entity
skamonkey@3767: *
skamonkey@3767: * @note Force application is dependent on game and damage type(s)
skamonkey@3767: *
skamonkey@3767: * @param entity Entity index taking damage
skamonkey@3767: * @param inflictor Inflictor entity index
skamonkey@3767: * @param attacker Attacker entity index
skamonkey@3767: * @param damage Amount of damage
skamonkey@3767: * @param damageType Bitfield of damage types
skamonkey@3767: * @param weapon Weapon index (orangebox and later) or -1 for unspecified
skamonkey@3767: * @param damageForce Velocity of damage force
skamonkey@3767: * @param damagePosition Origin of damage
skamonkey@3767: * @noreturn
skamonkey@3767: */
skamonkey@3767: 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);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * @brief Forces a client to drop the specified weapon
skamonkey@3767: *
skamonkey@3767: * @param client Client index.
skamonkey@3767: * @param weapon Weapon entity index.
skamonkey@3767: * @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
skamonkey@3767: * @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
skamonkey@3767: * @noreturn
skamonkey@3767: * @error Invalid client or weapon entity, weapon not owned by client.
skamonkey@3767: */
skamonkey@3767: native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR);
skamonkey@3767:
skamonkey@3767: /**
skamonkey@3767: * Do not edit below this line!
skamonkey@3767: */
skamonkey@3767: public Extension:__ext_sdkhooks =
skamonkey@3767: {
skamonkey@3767: name = "SDKHooks",
skamonkey@3767: file = "sdkhooks.ext",
skamonkey@3767: #if defined AUTOLOAD_EXTENSIONS
skamonkey@3767: autoload = 1,
skamonkey@3767: #else
skamonkey@3767: autoload = 0,
skamonkey@3767: #endif
skamonkey@3767: #if defined REQUIRE_EXTENSIONS
skamonkey@3767: required = 1,
skamonkey@3767: #else
skamonkey@3767: required = 0,
skamonkey@3767: #endif
skamonkey@3767: };