Update SDKHooks_TakeDamage for CS:GO changes (#1319)
See alliedmodders/hl2sdk#77
This commit is contained in:
parent
b7650b11d6
commit
af76f757b5
extensions/sdkhooks
@ -30,6 +30,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "extension.h"
|
||||
#include "takedamageinfohack.h"
|
||||
|
||||
CTakeDamageInfo::CTakeDamageInfo(){}
|
||||
@ -39,11 +40,11 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
|
||||
m_hInflictor = pInflictor;
|
||||
if ( pAttacker )
|
||||
{
|
||||
m_hAttacker = pAttacker;
|
||||
SetAttacker(pAttacker);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hAttacker = pInflictor;
|
||||
SetAttacker(pInflictor);
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX && SOURCE_ENGINE != SE_LEFT4DEAD
|
||||
@ -95,3 +96,43 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
|
||||
m_uiRecoilIndex = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSGO
|
||||
int CTakeDamageInfoHack::GetAttacker() const
|
||||
{
|
||||
return m_CSGOAttacker.m_hHndl.IsValid() ? m_CSGOAttacker.m_hHndl.GetEntryIndex() : -1;
|
||||
}
|
||||
|
||||
void CTakeDamageInfoHack::SetAttacker(CBaseEntity *pAttacker)
|
||||
{
|
||||
m_CSGOAttacker.m_bNeedInit = false;
|
||||
m_CSGOAttacker.m_hHndl = pAttacker;
|
||||
m_CSGOAttacker.m_bIsWorld = true;
|
||||
|
||||
int entity = gamehelpers->EntityToBCompatRef(pAttacker);
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(entity);
|
||||
if (player) {
|
||||
m_CSGOAttacker.m_bIsWorld = false;
|
||||
m_CSGOAttacker.m_bIsPlayer = true;
|
||||
m_CSGOAttacker.m_iClientIndex = player->GetIndex();
|
||||
m_CSGOAttacker.m_iUserId = player->GetUserId();
|
||||
|
||||
IPlayerInfo *playerinfo = player->GetPlayerInfo();
|
||||
if (!playerinfo) {
|
||||
return;
|
||||
}
|
||||
m_CSGOAttacker.m_iTeamChecked = playerinfo->GetTeamIndex();
|
||||
m_CSGOAttacker.m_iTeamNum = playerinfo->GetTeamIndex();
|
||||
}
|
||||
}
|
||||
#else
|
||||
int CTakeDamageInfoHack::GetAttacker() const
|
||||
{
|
||||
return m_hAttacker.IsValid() ? m_hAttacker.GetEntryIndex() : -1;
|
||||
}
|
||||
|
||||
void CTakeDamageInfoHack::SetAttacker(CBaseEntity *pAttacker)
|
||||
{
|
||||
CTakeDamageInfo::SetAttacker(pAttacker);
|
||||
}
|
||||
#endif
|
||||
|
@ -59,7 +59,8 @@ class CTakeDamageInfoHack : public CTakeDamageInfo
|
||||
{
|
||||
public:
|
||||
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition );
|
||||
inline int GetAttacker() const { return m_hAttacker.IsValid() ? m_hAttacker.GetEntryIndex() : -1; }
|
||||
int GetAttacker() const;
|
||||
void SetAttacker(CBaseEntity *pAttacker);
|
||||
inline int GetInflictor() const { return m_hInflictor.IsValid() ? m_hInflictor.GetEntryIndex() : -1; }
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX && SOURCE_ENGINE != SE_LEFT4DEAD
|
||||
inline int GetWeapon() const { return m_hWeapon.IsValid() ? m_hWeapon.GetEntryIndex() : -1; }
|
||||
|
Loading…
Reference in New Issue
Block a user