mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-12-06 18:18:23 +00:00
Added missing fields to the CTakeDamageInfo class, the actual size of the structure is 96 bytes.
- Updated `CTakeDamageInfo` to include new class fields (`m_flRadius` and `m_iDamageVictimIndex`) for clarity and future compatibility. - Existing hooks remain fully compatible. - Crashes in SourceMod do not occur due to an incorrect stack, because the structure is always passed by reference or pointer. - Updating the structure is recommended for cases where manual access to all fields or other special use cases is required.
This commit is contained in:
parent
3a9fe33d2c
commit
f7250c8288
@ -16,18 +16,20 @@ ConVar phys_pushscale( "phys_pushscale", "1", FCVAR_REPLICATED );
|
||||
|
||||
BEGIN_SIMPLE_DATADESC( CTakeDamageInfo )
|
||||
DEFINE_FIELD( m_vecDamageForce, FIELD_VECTOR ),
|
||||
DEFINE_FIELD( m_vecDamagePosition, FIELD_POSITION_VECTOR),
|
||||
DEFINE_FIELD( m_vecReportedPosition, FIELD_POSITION_VECTOR),
|
||||
DEFINE_FIELD( m_hInflictor, FIELD_EHANDLE),
|
||||
DEFINE_FIELD( m_hAttacker, FIELD_EHANDLE),
|
||||
DEFINE_FIELD( m_hWeapon, FIELD_EHANDLE),
|
||||
DEFINE_FIELD( m_flDamage, FIELD_FLOAT),
|
||||
DEFINE_FIELD( m_flMaxDamage, FIELD_FLOAT),
|
||||
DEFINE_FIELD( m_vecDamagePosition, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( m_vecReportedPosition, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( m_hInflictor, FIELD_EHANDLE ),
|
||||
DEFINE_FIELD( m_hAttacker, FIELD_EHANDLE ),
|
||||
DEFINE_FIELD( m_hWeapon, FIELD_EHANDLE ),
|
||||
DEFINE_FIELD( m_flDamage, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_flMaxDamage, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_flBaseDamage, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_bitsDamageType, FIELD_INTEGER),
|
||||
DEFINE_FIELD( m_iDamageCustom, FIELD_INTEGER),
|
||||
DEFINE_FIELD( m_iDamageStats, FIELD_INTEGER),
|
||||
DEFINE_FIELD( m_iAmmoType, FIELD_INTEGER),
|
||||
DEFINE_FIELD( m_bitsDamageType, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( m_iDamageCustom, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( m_iDamageStats, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( m_iAmmoType, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( m_flRadius, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_iDamageVictimIndex, FIELD_INTEGER ),
|
||||
END_DATADESC()
|
||||
|
||||
void CTakeDamageInfo::Init( CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBaseEntity *pWeapon, const Vector &damageForce, const Vector &damagePosition, const Vector &reportedPosition, float flDamage, int bitsDamageType, int iCustomDamage )
|
||||
@ -56,6 +58,10 @@ void CTakeDamageInfo::Init( CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBa
|
||||
m_vecDamagePosition = damagePosition;
|
||||
m_vecReportedPosition = reportedPosition;
|
||||
m_iAmmoType = -1;
|
||||
|
||||
m_vecDamageDirection = vec3_origin;
|
||||
m_flRadius = 0.0;
|
||||
m_iDamageVictimIndex = 0;
|
||||
}
|
||||
|
||||
CTakeDamageInfo::CTakeDamageInfo()
|
||||
|
||||
@ -80,6 +80,15 @@ public:
|
||||
void SetAmmoType( int iAmmoType );
|
||||
const char * GetAmmoName() const;
|
||||
|
||||
Vector GetDamageDirection() const;
|
||||
void SetDamageDirection( const Vector &damageDirection );
|
||||
|
||||
float GetRadius() const;
|
||||
void SetRadius( float flRadius );
|
||||
|
||||
float GetVictimIndex() const;
|
||||
void SetVictimIndex( int iVictimIndex );
|
||||
|
||||
void Set( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, int iKillType = 0 );
|
||||
void Set( CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBaseEntity *pWeapon, float flDamage, int bitsDamageType, int iKillType = 0 );
|
||||
void Set( CBaseEntity *pInflictor, CBaseEntity *pAttacker, const Vector &damageForce, const Vector &damagePosition, float flDamage, int bitsDamageType, int iKillType = 0, Vector *reportedPosition = NULL );
|
||||
@ -102,7 +111,7 @@ protected:
|
||||
Vector m_vecDamageForce;
|
||||
Vector m_vecDamagePosition;
|
||||
Vector m_vecReportedPosition; // Position players are told damage is coming from
|
||||
Vector m_vecUnknown;
|
||||
Vector m_vecDamageDirection; // The type matches, but I'm not sure about the name; the name is taken from new games.
|
||||
EHANDLE m_hInflictor;
|
||||
EHANDLE m_hAttacker;
|
||||
EHANDLE m_hWeapon;
|
||||
@ -113,6 +122,8 @@ protected:
|
||||
int m_iDamageCustom;
|
||||
int m_iDamageStats;
|
||||
int m_iAmmoType; // AmmoType of the weapon used to cause this damage, if any
|
||||
int m_flRadius;
|
||||
int m_iDamageVictimIndex;
|
||||
|
||||
DECLARE_SIMPLE_DATADESC();
|
||||
};
|
||||
@ -331,6 +342,35 @@ inline void CTakeDamageInfo::CopyDamageToBaseDamage()
|
||||
m_flBaseDamage = m_flDamage;
|
||||
}
|
||||
|
||||
inline Vector CTakeDamageInfo::GetDamageDirection() const
|
||||
{
|
||||
return m_vecDamageDirection;
|
||||
}
|
||||
|
||||
inline void CTakeDamageInfo::SetDamageDirection( const Vector &damageDirection )
|
||||
{
|
||||
m_vecDamageDirection = damageDirection;
|
||||
}
|
||||
|
||||
inline float CTakeDamageInfo::GetRadius() const
|
||||
{
|
||||
return m_flRadius;
|
||||
}
|
||||
|
||||
inline void CTakeDamageInfo::SetRadius( float flRadius )
|
||||
{
|
||||
m_flRadius = flRadius;
|
||||
}
|
||||
|
||||
inline float CTakeDamageInfo::GetVictimIndex() const
|
||||
{
|
||||
return m_iDamageVictimIndex;
|
||||
}
|
||||
|
||||
inline void CTakeDamageInfo::SetVictimIndex( int iVictimIndex )
|
||||
{
|
||||
m_iDamageVictimIndex = iVictimIndex;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// Inlines.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user