Add damageCustom argument to SDKHooks_TakeDamage native.

This commit is contained in:
BotoX 2019-09-27 17:48:35 +02:00 committed by zaCade
parent 8c534e770b
commit c2a86c77fd
4 changed files with 20 additions and 13 deletions

View File

@ -9,7 +9,7 @@
* 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
@ -70,7 +70,7 @@ cell_t Native_Hook(IPluginContext *pContext, const cell_t *params)
{
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
}
break;
}
}
@ -105,7 +105,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pVictim = gamehelpers->ReferenceToEntity(params[1]);
if (!pVictim)
return pContext->ThrowNativeError("Invalid entity index %d for victim", params[1]);
CBaseEntity *pInflictor = gamehelpers->ReferenceToEntity(params[2]);
if (!pInflictor)
return pContext->ThrowNativeError("Invalid entity index %d for inflictor", params[2]);
@ -173,9 +173,15 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
vecDamagePosition = vec3_origin;
}
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition);
int iDamageCustom = 0;
if (params[0] >= 9)
{
iDamageCustom = params[9];
}
if (params[0] < 9 || params[9] != 0)
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition, iDamageCustom);
if (params[0] < 10 || params[9] != 0)
{
SH_MCALL(pVictim, OnTakeDamage)((CTakeDamageInfoHack&)info);
}
@ -188,7 +194,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
{
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
}
}
PassInfo pass[2];
pass[0].type = PassType_Object;
@ -225,7 +231,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
IGamePlayer *pGamePlayer = playerhelpers->GetGamePlayer(gamehelpers->ReferenceToIndex(params[1]));
if (!pGamePlayer || !pGamePlayer->IsInGame())
return pContext->ThrowNativeError("Client index %d not in game", params[1]);
CBaseEntity *pWeapon = gamehelpers->ReferenceToEntity(params[2]);
if (!pWeapon)
return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);

View File

@ -35,7 +35,7 @@
CTakeDamageInfo::CTakeDamageInfo(){}
CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition )
CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom )
{
m_hInflictor = pInflictor;
if ( pAttacker )
@ -64,9 +64,9 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
m_iAmmoType = -1;
#if SOURCE_ENGINE < SE_ORANGEBOX
m_iCustomKillType = 0;
m_iCustomKillType = iDamageCustom;
#else
m_iDamageCustom = 0;
m_iDamageCustom = iDamageCustom;
#endif
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \

View File

@ -9,7 +9,7 @@
* 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
@ -58,7 +58,7 @@
class CTakeDamageInfoHack : public CTakeDamageInfo
{
public:
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition );
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0);
int GetAttacker() const;
void SetAttacker(CBaseEntity *pAttacker);
inline int GetInflictor() const { return m_hInflictor.IsValid() ? m_hInflictor.GetEntryIndex() : -1; }

View File

@ -428,12 +428,13 @@ native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback);
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
* @param damageForce Velocity of damage force
* @param damagePosition Origin of damage
* @param damageCustom User custom
* @param bypassHooks If true, bypass SDK hooks on OnTakeDamage
* @error Invalid entity, attacker, inflictor, or weapon entity.
*/
native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker,
float damage, int damageType=DMG_GENERIC, int weapon=-1,
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR,
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR, int damageCustom=0,
bool bypassHooks = true);
/**