Added {get,set}_pdata_cbase{_safe} - compliments Fakemeta's get_pdata functions, but this will set/get an offset that is a CBaseEntity.

Split constants from hamsandwich.inc into ham_const.inc.

Finished commenting native calls, need to finish the constant comments.
This commit is contained in:
Steve Dudenhoeffer 2007-05-13 13:59:54 +00:00
parent 504ddb4c2f
commit b1a086ee93
5 changed files with 684 additions and 508 deletions

View File

@ -25,7 +25,7 @@ BIN_SUFFIX = amxx_i386.so
OBJECTS = sdk/amxxmodule.cpp amxx_api.cpp config_parser.cpp \
hook_callbacks.cpp hook_native.cpp srvcmd.cpp \
call_funcs.cpp hook_create.cpp DataHandler.cpp
call_funcs.cpp hook_create.cpp DataHandler.cpp pdata.cpp
LINK =

View File

@ -17,6 +17,9 @@ extern CVector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
extern AMX_NATIVE_INFO RegisterNatives[];
extern AMX_NATIVE_INFO ReturnNatives[];
extern AMX_NATIVE_INFO pdata_natives[];
extern AMX_NATIVE_INFO pdata_natives_safe[];
extern hook_t hooklist[];
@ -27,12 +30,14 @@ void OnAmxxAttach(void)
// Assert that the enum is aligned properly with the table
assert(strcmp(hooklist[Ham_NS_UpdateOnRemove].name, "ns_updateonremove")==0);
MF_AddNatives(pdata_natives_safe);
if (ReadConfig() > 0)
{
if (Offsets.IsValid())
{
MF_AddNatives(RegisterNatives);
MF_AddNatives(ReturnNatives);
MF_AddNatives(pdata_natives);
}
else
{

View File

@ -0,0 +1,491 @@
#if defined _ham_const_included
#endinput
#endif
#define _ham_const_included
/**
* Ham return types.
* -
* Return these from hooks to disable calling the target function.
* Numbers match up with fakemeta's FMRES_* for clarity. They are interchangable.
* 0 (or no return) is also interpretted as HAM_IGNORED.
*/
#define HAM_IGNORED 1 /**< Calls target function, returns normal value */
#define HAM_HANDLED 2 /**< Tells the module you did something, still calls target function and returns normal value */
#define HAM_OVERRIDE 3 /**< Still calls the target function, but returns whatever is set with SetHamReturn*() */
#define HAM_SUPERCEDE 4 /**< Block the target call, and use your return value (if applicable) (Set with SetHamReturn*()) */
/**
* A few notes about all of the following functions:
* - Not all functions will do as you expect on all mods.
* If a function does not do what you would believe it should
* DO NOT file a bug report, you will be ignored.
*
* - Passing invalid parameters has potential to crash the server
* So be careful, and adequately test!
*
* - All functions take (and pass) a "this" index as the first param.
* This is the entity from which the function is being executed on.
*
* - All functions and forwards (eg: {Register,Execute}Ham[B]) require
* the mod to have the pev and base keys in addition to the function
* keys for the corresponding mod/operating system in hamdata.ini
*/
enum Ham
{
/**
* Description: This is typically called whenever an entity is created.
* It is the virtual equivilent of spawn from the engine.
* Some mods call this on player spawns too.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Spawn, this);
*/
Ham_Spawn = 0,
/**
* Description: This is typically called on map change.
* This will typically precache all assets required by the entity.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Precache, this);
*/
Ham_Precache,
/**
* Description: Typically this is similar to an engine keyvalue call.
* Use the kvd natives from fakemeta to handle the kvd_handle passed.
* NOTE: Do not pass handle 0 to this! Use get_kvd_handle(0) from fakemeta instead!
* Forward params: function(this, kvd_handle);
* Return type: None.
* Execute params: ExecuteHam(Ham_Keyvalue, this, kvd_handle);
*/
Ham_Keyvalue,
/**
* Description: Returns flags for how an entity can be used (FCAP_* constants in hlsdk_const.inc)
* Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_ObjectCaps, this);
*/
Ham_ObjectCaps,
/**
* Description: Usually called to activate some objects.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Activate, this);
*/
Ham_Activate,
/**
* Description: Usually called after the engine call with the same name.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_SetObjectCollisionBox, this);
*/
Ham_SetObjectCollisionBox,
/**
* Description: Returns an integer number that corresponds with what type of entity this is.
* Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_Classify, this);
*/
Ham_Classify,
/**
* Description: Typically called when an entity dies to notify any children entities about the death.
* Forward params: function(this, idchild)
* Return type: None.
* Execute params: ExecuteHam(Ham_DeathNotice, this, idchild)
*/
Ham_DeathNotice,
/**
* Description: Usually called whenever an entity gets attacked by a hitscan (such as a gun) weapon.
* Use the get/set tr2 natives in fakemeta to handle the traceresult data.
* Do not use a handle of 0 as a traceresult in execution, use get_tr_handle(0) instead.
* Forward params: function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
* Return type: None.
* Execute params: ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits);
*/
Ham_TraceAttack,
/**
* Description: Usually called whenever an entity takes any kind of damage.
* Inflictor is the entity that caused the damage (such as a gun).
* Attacker is the entity that tirggered the damage (such as the gun's owner).
* Forward params: function(this, idinflictor, idattacker, Float:damage, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
*/
Ham_TakeDamage,
/**
* Description: Usually called whenever an entity gets a form of a heal.
* Forward params: function(this, Float:health, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeHealth, this, Float:health, damagebits);
*/
Ham_TakeHealth,
/**
* Description: Normally called whenever an entity dies.
* Forward params: function(this, idattacker, shouldgib)
* Return type: None.
* Execute params: ExecuteHam(Ham_Killed, this, idattacker, shouldgib);
*/
Ham_Killed,
/**
* Description: Normally returns the blood color of the entity.
* Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_BloodColor, this)
*/
Ham_BloodColor,
Ham_TraceBleed,
Ham_IsTriggered,
Ham_MyMonsterPointer,
Ham_MySquadMonsterPointer,
Ham_GetToggleState,
/**
* Description: Typically adds points to the entity.
* Forward params: function(this, points, bool:cangonegative);
* Return type: None.
* Execute params: ExecuteHam(Ham_BloodColor, this, points, bool:cangonegative);
*/
Ham_AddPoints,
/**
* Description: Typically adds points to the entity's team.
* Forward params: function(this, points, bool:cangonegative);
* Return type: None.
* Execute params: ExecuteHam(Ham_BloodColor, this, points, bool:cangonegative);
*/
Ham_AddPointsToTeam,
/**
* Description: Adds an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_AddPlayerItem, this, idother);
*/
Ham_AddPlayerItem,
/**
* Description: Removes an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_RemovePlayerItem, this, idother);
*/
Ham_RemovePlayerItem,
Ham_GiveAmmo,
Ham_GetDelay,
/**
* Description: Whether or not the entity is moving.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsMoving, this);
*/
Ham_IsMoving,
Ham_OverrideReset,
Ham_DamageDecal,
Ham_SetToggleState,
/**
* Description: Not entirely sure what this does.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_StartSneaking, this);
*/
Ham_StartSneaking,
/**
* Description: Not entirely sure what this does.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_StopSneaking, this);
*/
Ham_StopSneaking,
Ham_OnControls,
/**
* Description: Whether or not the entity is sneaking.
* Forward params: function(this);
* Return type: None.
* Execute params: ExecuteHam(Ham_IsSneaking, this);
*/
Ham_IsSneaking,
/**
* Description: Whether or not the entity is alive.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsAlive, this);
*/
Ham_IsAlive,
/**
* Description: Whether or not the entity uses a BSP model.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsBSPModel, this);
*/
Ham_IsBSPModel,
/**
* Description: Whether or not the entity can reflect gauss shots..
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_ReflectGauss, this);
*/
Ham_ReflectGauss,
Ham_HasTarget,
/**
* Description: Whether or not the entity is in the world.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsInWorld, this);
*/
Ham_IsInWorld,
/**
* Description: Whether or not the entity is a player.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsPlayer, this);
*/
Ham_IsPlayer,
/**
* Description: Whether or not the entity is a net client.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsNetClient, this);
*/
Ham_IsNetClient,
/**
* Description: Get the entity's team id.
* Forward params: function(this);
* Return type: String (string length returned and string byref'd in ExecuteHam).
* Execute params: ExecuteHam(Ham_IsPlayer, this, buffer[], size);
*/
Ham_TeamId,
/**
* Description: Returns the next target of this.
* Forward params: function(this);
* Execute params: ExecuteHam(Ham_GetNextTarget, this);
*/
Ham_GetNextTarget,
/**
* Description: Called whenever an entity thinks.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Think, this);
*/
Ham_Think,
/**
* Description: Called whenever two entities touch.
* Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Touch, this, idother);
*/
Ham_Touch,
/**
* Description: Called whenver one entity uses another.
* Forward params: function(this, idcaller, idactivator, use_type, Float:value)
* Return type: None.
* Execute params: ExecuteHam(Ham_Use, this, idcaller, idactivator, use_type, Float:value);
*/
Ham_Use,
/**
* Description: Normally called whenever one entity blocks another from moving.
* Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Blocked, this, idother);
*/
Ham_Blocked,
/**
* Description: Normally called when a map-based item respawns, such as a health kit or something.
* Forward params: function(this);
* Return type: CBaseEntity.
* Execute params: ExecuteHam(Ham_Respawn, this);
*/
Ham_Respawn,
/**
* Description: Used in Half-Life to update a monster's owner.
* Forward params: function(this);
* Return type: None.
* Execute params: ExecuteHam(Ham_UpdateOwner, this);
*/
Ham_UpdateOwner,
/**
* Description: Normally called whenever a barnacle grabs the entity.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_FBecomeProne, this);
*/
Ham_FBecomeProne,
/**
* Description: Returns the center of the entity.
* Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_Center, this, Float:output[3]);
*/
Ham_Center,
/**
* Description: Returns the eye position of the entity.
* Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_EyePosition, this, Float:output[3]);
*/
Ham_EyePosition,
/**
* Description: Returns the ear position of the entity.
* Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_EarPosition, this, Float:output[3]);
*/
Ham_EarPosition,
/**
* Description: Position to shoot at.
* Forward params: function(this, Float:srcvector[3]);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_BodyTarget, Float:srcvector[3], Float:returnvector[3])
*/
Ham_BodyTarget,
Ham_Illumination,
Ham_FVisible,
Ham_FVecVisible,
Ham_Player_Jump,
Ham_Player_Duck,
Ham_Player_PreThink,
Ham_Player_PostThink,
Ham_Player_GetGunPosition,
Ham_Player_ShouldFadeOnDeath,
Ham_Player_ImpulseCommands,
Ham_Player_UpdateClientData,
/**
* Items have all the attributes of normal entities in addition to these.
*/
Ham_Item_AddToPlayer,
Ham_Item_AddDuplicate,
Ham_Item_GetItemInfo,
Ham_Item_CanDeploy,
Ham_Item_Deploy,
Ham_Item_CanHolster,
Ham_Item_Holster,
Ham_Item_UpdateItemInfo,
Ham_Item_PreFrame,
Ham_Item_PostFrame,
Ham_Item_Drop,
Ham_Item_Kill,
Ham_Item_AttachToPlayer,
Ham_Item_PrimaryAmmoIndex,
Ham_Item_SecondaryAmmoIndex,
Ham_Item_UpdateClientData,
Ham_Item_GetWeaponPtr,
Ham_Item_ItemSlot,
/**
* Weapons have all the attributes to Ham_Item_*, in addition to these.
*/
Ham_Weapon_ExtractAmmo,
Ham_Weapon_ExtractClipAmmo,
Ham_Weapon_AddWeapon,
Ham_Weapon_PlayEmptySound,
Ham_Weapon_ResetEmptySound,
Ham_Weapon_SendWeaponAnim,
Ham_Weapon_IsUsable,
Ham_Weapon_PrimaryAttack,
Ham_Weapon_SecondaryAttack,
Ham_Weapon_Reload,
Ham_Weapon_WeaponIdle,
Ham_Weapon_RetireWeapon,
Ham_Weapon_ShouldWeaponIdle,
Ham_Weapon_UseDecrement,
Ham_TS_BreakableRespawn,
Ham_TS_CanUsedThroughWalls,
Ham_TS_RespawnWait,
/**
* Description: This is called on a map reset for most map based entities.
* Forward params: function(this);
* Execute params: ExecuteHam(Ham_CS_Restart, this);
*/
Ham_CS_Restart,
/**
* Description: Respawn function for players/bots only! Do not use this on non player/bot entities!
* Forward params: function(this);
* Execute params: ExecuteHam(Ham_CS_RoundRespawn, this);
*/
Ham_CS_RoundRespawn,
Ham_DOD_RoundRespawn,
Ham_DOD_RoundRespawnEnt,
Ham_DOD_RoundStore,
Ham_DOD_AreaSetIndex,
Ham_DOD_AreaSendStatus,
Ham_DOD_GetState,
Ham_DOD_GetStateEnt,
Ham_TFC_EngineerUse,
Ham_TFC_Finished,
Ham_TFC_EmpExplode,
Ham_TFC_CalcEmpDmgRad,
Ham_TFC_TakeEmpBlast,
Ham_TFC_EmpRemove,
Ham_TFC_TakeConcussionBlast,
Ham_TFC_Concuss,
Ham_ESF_IsEnvModel, // Only valid in ESF Open Beta
Ham_ESF_TakeDamage2, // Only valid in ESF Open Beta
Ham_NS_GetPointValue,
Ham_NS_AwardKill,
Ham_NS_ResetEntity,
Ham_NS_UpdateOnRemove,
/**
* DONT USE ME LOL
*/
HAM_LAST_ENTRY_DONT_USE_ME_LOL
};
enum HamError
{
HAM_OK = 0,
HAM_INVALID_FUNC, // The function is not valid
HAM_FUNC_NOT_CONFIGURED, // This function is not configured in hamdata.ini
HAM_ERR_END
};

View File

@ -29,7 +29,8 @@
*/
/**
* Ham Sandwich is a module that is used to hook virtual functions of entities.
* Ham Sandwich is a module that is used to hook and call virtual functions of
* entities.
* Virtual functions are mod-specific functions. This means that in order
* for this to work on a mod, it needs to be configured with the hamdata.ini
* file.
@ -41,6 +42,8 @@
#endif
#define _hamsandwich_included
#include <ham_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib hamsandwich
#if !defined AMXMODX_NOAUTOLOAD
@ -50,485 +53,6 @@
#pragma library hamsandwich
#endif
/**
* A few notes about all of the following functions:
* - Not all functions will do as you expect on all mods.
* If a function does not do what you would believe it should
* DO NOT file a bug report, you will be ignored.
*
* - Passing invalid parameters has potential to crash the server
* So be careful, and adequately test!
*
* - All functions take (and pass) a "this" index as the first param.
* This is the entity from which the function is being executed on.
*
* - All functions and forwards (eg: {Register,Execute}Ham[B]) require
* the mod to have the pev and base keys in addition to the function
* keys for the corresponding mod/operating system in hamdata.ini
*/
enum Ham
{
/**
* Description: This is typically called whenever an entity is created.
* It is the virtual equivilent of spawn from the engine.
* Some mods call this on player spawns too.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Spawn, this);
*/
Ham_Spawn = 0,
/**
* Description: This is typically called on map change.
* This will typically precache all assets required by the entity.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Precache, this);
*/
Ham_Precache,
/**
* Description: Typically this is similar to an engine keyvalue call.
* Use the kvd natives from fakemeta to handle the kvd_handle passed.
* NOTE: Do not pass handle 0 to this! Use get_kvd_handle(0) from fakemeta instead!
* Forward params: function(this, kvd_handle);
* Return type: None.
* Execute params: ExecuteHam(Ham_Keyvalue, this, kvd_handle);
*/
Ham_Keyvalue,
/**
* Description: Returns flags for how an entity can be used (FCAP_* constants in hlsdk_const.inc)
* Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_ObjectCaps, this);
*/
Ham_ObjectCaps,
/**
* Description: Usually called to activate some objects.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Activate, this);
*/
Ham_Activate,
/**
* Description: Usually called after the engine call with the same name.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_SetObjectCollisionBox, this);
*/
Ham_SetObjectCollisionBox,
/**
* Description: Returns an integer number that corresponds with what type of entity this is.
* Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_Classify, this);
*/
Ham_Classify,
/**
* Description: Typically called when an entity dies to notify any children entities about the death.
* Forward params: function(this, idchild)
* Return type: None.
* Execute params: ExecuteHam(Ham_DeathNotice, this, idchild)
*/
Ham_DeathNotice,
/**
* Description: Usually called whenever an entity gets attacked by a hitscan (such as a gun) weapon.
* Use the get/set tr2 natives in fakemeta to handle the traceresult data.
* Do not use a handle of 0 as a traceresult in execution, use get_tr_handle(0) instead.
* Forward params: function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
* Return type: None.
* Execute params: ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits);
*/
Ham_TraceAttack,
/**
* Description: Usually called whenever an entity takes any kind of damage.
* Inflictor is the entity that caused the damage (such as a gun).
* Attacker is the entity that tirggered the damage (such as the gun's owner).
* Forward params: function(this, idinflictor, idattacker, Float:damage, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
*/
Ham_TakeDamage,
/**
* Description: Usually called whenever an entity gets a form of a heal.
* Forward params: function(this, Float:health, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeHealth, this, Float:health, damagebits);
*/
Ham_TakeHealth,
/**
* Description: Normally called whenever an entity dies.
* Forward params: function(this, idattacker, shouldgib)
* Return type: None.
* Execute params: ExecuteHam(Ham_Killed, this, idattacker, shouldgib);
*/
Ham_Killed,
/**
* Description: Normally returns the blood color of the entity.
* Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_BloodColor, this)
*/
Ham_BloodColor,
Ham_TraceBleed,
Ham_IsTriggered,
Ham_MyMonsterPointer,
Ham_MySquadMonsterPointer,
Ham_GetToggleState,
/**
* Description: Typically adds points to the entity.
* Forward params: function(this, points, bool:cangonegative);
* Return type: None.
* Execute params: ExecuteHam(Ham_BloodColor, this, points, bool:cangonegative);
*/
Ham_AddPoints,
/**
* Description: Typically adds points to the entity's team.
* Forward params: function(this, points, bool:cangonegative);
* Return type: None.
* Execute params: ExecuteHam(Ham_BloodColor, this, points, bool:cangonegative);
*/
Ham_AddPointsToTeam,
/**
* Description: Adds an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_AddPlayerItem, this, idother);
*/
Ham_AddPlayerItem,
/**
* Description: Removes an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_RemovePlayerItem, this, idother);
*/
Ham_RemovePlayerItem,
Ham_GiveAmmo,
Ham_GetDelay,
/**
* Description: Whether or not the entity is moving.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsMoving, this);
*/
Ham_IsMoving,
Ham_OverrideReset,
Ham_DamageDecal,
Ham_SetToggleState,
/**
* Description: Not entirely sure what this does.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_StartSneaking, this);
*/
Ham_StartSneaking,
/**
* Description: Not entirely sure what this does.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_StopSneaking, this);
*/
Ham_StopSneaking,
Ham_OnControls,
/**
* Description: Whether or not the entity is sneaking.
* Forward params: function(this);
* Return type: None.
* Execute params: ExecuteHam(Ham_IsSneaking, this);
*/
Ham_IsSneaking,
/**
* Description: Whether or not the entity is alive.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsAlive, this);
*/
Ham_IsAlive,
/**
* Description: Whether or not the entity uses a BSP model.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsBSPModel, this);
*/
Ham_IsBSPModel,
/**
* Description: Whether or not the entity can reflect gauss shots..
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_ReflectGauss, this);
*/
Ham_ReflectGauss,
Ham_HasTarget,
/**
* Description: Whether or not the entity is in the world.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsInWorld, this);
*/
Ham_IsInWorld,
/**
* Description: Whether or not the entity is a player.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsPlayer, this);
*/
Ham_IsPlayer,
/**
* Description: Whether or not the entity is a net client.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsNetClient, this);
*/
Ham_IsNetClient,
/**
* Description: Get the entity's team id.
* Forward params: function(this);
* Return type: String (string length returned and string byref'd in ExecuteHam).
* Execute params: ExecuteHam(Ham_IsPlayer, this, buffer[], size);
*/
Ham_TeamId,
/**
* Description: Returns the next target of this.
* Forward params: function(this);
* Execute params: ExecuteHam(Ham_GetNextTarget, this);
*/
Ham_GetNextTarget,
/**
* Description: Called whenever an entity thinks.
* Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Think, this);
*/
Ham_Think,
/**
* Description: Called whenever two entities touch.
* Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Touch, this, idother);
*/
Ham_Touch,
/**
* Description: Called whenver one entity uses another.
* Forward params: function(this, idcaller, idactivator, use_type, Float:value)
* Return type: None.
* Execute params: ExecuteHam(Ham_Use, this, idcaller, idactivator, use_type, Float:value);
*/
Ham_Use,
/**
* Description: Normally called whenever one entity blocks another from moving.
* Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Blocked, this, idother);
*/
Ham_Blocked,
/**
* Description: Normally called when a map-based item respawns, such as a health kit or something.
* Forward params: function(this);
* Return type: CBaseEntity.
* Execute params: ExecuteHam(Ham_Respawn, this);
*/
Ham_Respawn,
/**
* Description: Used in Half-Life to update a monster's owner.
* Forward params: function(this);
* Return type: None.
* Execute params: ExecuteHam(Ham_UpdateOwner, this);
*/
Ham_UpdateOwner,
/**
* Description: Normally called whenever a barnacle grabs the entity.
* Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_FBecomeProne, this);
*/
Ham_FBecomeProne,
/**
* Description: Returns the center of the entity.
* Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_Center, this, Float:output[3]);
*/
Ham_Center,
/**
* Description: Returns the eye position of the entity.
* Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_EyePosition, this, Float:output[3]);
*/
Ham_EyePosition,
/**
* Description: Returns the ear position of the entity.
* Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_EarPosition, this, Float:output[3]);
*/
Ham_EarPosition,
/**
* Description: Position to shoot at.
* Forward params: function(this, Float:srcvector[3]);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_BodyTarget, Float:srcvector[3], Float:returnvector[3])
*/
Ham_BodyTarget,
Ham_Illumination,
Ham_FVisible,
Ham_FVecVisible,
Ham_Player_Jump,
Ham_Player_Duck,
Ham_Player_PreThink,
Ham_Player_PostThink,
Ham_Player_GetGunPosition,
Ham_Player_ShouldFadeOnDeath,
Ham_Player_ImpulseCommands,
Ham_Player_UpdateClientData,
/**
* Items have all the attributes of normal entities in addition to these.
*/
Ham_Item_AddToPlayer,
Ham_Item_AddDuplicate,
Ham_Item_GetItemInfo,
Ham_Item_CanDeploy,
Ham_Item_Deploy,
Ham_Item_CanHolster,
Ham_Item_Holster,
Ham_Item_UpdateItemInfo,
Ham_Item_PreFrame,
Ham_Item_PostFrame,
Ham_Item_Drop,
Ham_Item_Kill,
Ham_Item_AttachToPlayer,
Ham_Item_PrimaryAmmoIndex,
Ham_Item_SecondaryAmmoIndex,
Ham_Item_UpdateClientData,
Ham_Item_GetWeaponPtr,
Ham_Item_ItemSlot,
/**
* Weapons have all the attributes to Ham_Item_*, in addition to these.
*/
Ham_Weapon_ExtractAmmo,
Ham_Weapon_ExtractClipAmmo,
Ham_Weapon_AddWeapon,
Ham_Weapon_PlayEmptySound,
Ham_Weapon_ResetEmptySound,
Ham_Weapon_SendWeaponAnim,
Ham_Weapon_IsUsable,
Ham_Weapon_PrimaryAttack,
Ham_Weapon_SecondaryAttack,
Ham_Weapon_Reload,
Ham_Weapon_WeaponIdle,
Ham_Weapon_RetireWeapon,
Ham_Weapon_ShouldWeaponIdle,
Ham_Weapon_UseDecrement,
Ham_TS_BreakableRespawn,
Ham_TS_CanUsedThroughWalls,
Ham_TS_RespawnWait,
/**
* Description: This is called on a map reset for most map based entities.
* Forward params: function(this);
* Execute params: ExecuteHam(Ham_CS_Restart, this);
*/
Ham_CS_Restart,
/**
* Description: Respawn function for players/bots only! Do not use this on non player/bot entities!
* Forward params: function(this);
* Execute params: ExecuteHam(Ham_CS_RoundRespawn, this);
*/
Ham_CS_RoundRespawn,
Ham_DOD_RoundRespawn,
Ham_DOD_RoundRespawnEnt,
Ham_DOD_RoundStore,
Ham_DOD_AreaSetIndex,
Ham_DOD_AreaSendStatus,
Ham_DOD_GetState,
Ham_DOD_GetStateEnt,
Ham_TFC_EngineerUse,
Ham_TFC_Finished,
Ham_TFC_EmpExplode,
Ham_TFC_CalcEmpDmgRad,
Ham_TFC_TakeEmpBlast,
Ham_TFC_EmpRemove,
Ham_TFC_TakeConcussionBlast,
Ham_TFC_Concuss,
Ham_ESF_IsEnvModel, // Only valid in ESF Open Beta
Ham_ESF_TakeDamage2, // Only valid in ESF Open Beta
Ham_NS_GetPointValue,
Ham_NS_AwardKill,
Ham_NS_ResetEntity,
Ham_NS_UpdateOnRemove,
/**
* DONT USE ME LOL
*/
HAM_LAST_ENTRY_DONT_USE_ME_LOL
};
/**
* Ham return types.
* -
* Return these from hooks to disable calling the target function.
* Numbers match up with fakemeta's FMRES_* for clarity. They are interchangable.
* 0 (or no return) is also interpretted as HAM_IGNORED.
*/
#define HAM_IGNORED 1 /**< Calls target function, returns normal value */
#define HAM_HANDLED 2 /**< Tells the module you did something, still calls target function and returns normal value */
#define HAM_OVERRIDE 3 /**< Still calls the target function, but returns whatever is set with SetHamReturn*() */
#define HAM_SUPERCEDE 4 /**< Block the target call, and use your return value (if applicable) (Set with SetHamReturn*()) */
/**
* Hooks the virtual table for the specified entity class.
* An example would be: RegisterHam(Ham_TakeDamage, "player_hurt", "player");
@ -558,8 +82,6 @@ native DisableHamForward(HamHook:fwd);
*/
native EnableHamForward(HamHook:fwd);
/**
* Executes the virtual function on the entity.
* Look at the Ham enum for parameter lists.
@ -579,32 +101,183 @@ native ExecuteHam(Ham:function, this, any:...);
*/
native ExecuteHamB(Ham:function, this, any:...);
/**
* Gets the return status of the current hook.
* This is useful to determine what return natives to use.
*
* @return The current status of the hook (such as HAM_SUPERCEDE).
*/
native GetHamReturnStatus();
native SetHamParamInteger(which, value);
native SetHamParamFloat(which, Float:value);
native SetHamParamVector(which, const Float:value[3]);
native SetHamParamEntity(which, value);
native SetHamParamString(which, const output[]);
native SetHamParamTraceResult(which, tr_handle);
/**
* Gets the return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetHamReturnInteger(&output);
/**
* Gets the return value of a hook for hooks that return float.
*
* @param output The variable to store the value in.
*/
native GetHamReturnFloat(&Float:output);
/**
* Gets the return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetHamReturnVector(Float:output[3]);
/**
* Gets the return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. Will be -1 on null.
*/
native GetHamReturnEntity(&output);
/**
* Gets the return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The string size of the buffer.
*/
native GetHamReturnString(output[], size);
/**
* Gets the original return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnInteger(&output);
/**
* Gets the original return value of a hook for hooks that return floats.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnFloat(&Float:output);
/**
* Gets the original return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnVector(Float:output[3]);
native GetOrigHamReturnCbase(&output);
/**
* Gets the original return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. -1 on null.
*/
native GetOrigHamReturnEntity(&output);
/**
* Gets the original return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The size of the buffer.
*/
native GetOrigHamReturnString(output[], size);
/**
* Sets the return value of a hook that returns an integer or boolean.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnInteger(value);
/**
* Sets the return value of a hook that returns a float.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnFloat(Float:value);
/**
* Sets the return value of a hook that returns a Vector.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnVector(const Float:value[3]);
/**
* Sets the return value of a hook that returns an entity. Set to -1 for null.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnEntity(value);
/**
* Sets the return value of a hook that returns a string.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnString(const value[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are integers.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamInteger(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are floats.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamFloat(which, Float:value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are Vectors.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamVector(which, const Float:value[3]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are entities.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamEntity(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are strings.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamString(which, const output[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are trace result handles.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamTraceResult(which, tr_handle);
/**
* Returns whether or not the function for the specified Ham is valid.
* Things that would make it invalid would be bounds (an older module version
@ -618,9 +291,10 @@ native bool:IsHamValid(Ham:function);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev field set in hamdata.ini.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
@ -631,38 +305,40 @@ native get_pdata_cbase(id, offset, linuxdiff=5);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev field set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* This will set the corresponding cbase field in private data with the index.
* Pass -1 to null the entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param value The index to store.
* @param value The index to store, -1 for invalid
* @param linuxdiff The linux difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
*/
native set_pdata_cbase(id, offset, value, linuxdiff=5);
/**
* This is similar to the get_pdata_cbase, however it does not dereference memory.
* This is many times slower than get_pdata_cbase, and this should only be used
* for testing and finding of offsets, not actual release quality plugins.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry. -2 on an invalid entry.
*
* @param id Entry to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @return The index of the corresponding pdata field, -1 for null, -2 for invalid.
*/
native get_pdata_cbase_safe(id, offset, linuxdiff=5);
enum HamError
{
HAM_OK = 0,
HAM_INVALID_FUNC, // The function is not valid
HAM_FUNC_NOT_CONFIGURED, // This function is not configured in hamdata.ini
HAM_ERR_END
};
// This is the callback from the module, this handles any fatal errors.
// This will in turn call the "HamFilter(Ham:id, HamError:err, const reason[])" public, if it exists.
// Return PLUGIN_HANDLED from within the HamFilter to stop the plugin from failing.
// Any other return value will fail the plugin.
// You do not need to have a HamFilter, if there is none, all fatal errors will fail the plugin.
// Do not modify this!
public __fatal_ham_error(Ham:id, HamError:err, const reason[])
{
@ -684,4 +360,4 @@ public __fatal_ham_error(Ham:id, HamError:err, const reason[])
set_fail_state(reason);
}
}
}

View File

@ -275,6 +275,10 @@
RelativePath="..\DataHandler.h"
>
</File>
<File
RelativePath="..\pdata.cpp"
>
</File>
<File
RelativePath="..\sh_stack.h"
>