mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-28 15:45:41 +03:00
Use CSEntity member to hold last inflictor from TakeDamage (#896)
This commit is contained in:
parent
e3d70d2b14
commit
9ab1589d32
@ -451,17 +451,13 @@ BOOL CBaseMonster::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, f
|
|||||||
|
|
||||||
if (pev->health <= 0.0f)
|
if (pev->health <= 0.0f)
|
||||||
{
|
{
|
||||||
g_pevLastInflictor = pevInflictor;
|
|
||||||
|
|
||||||
if (bitsDamageType & DMG_ALWAYSGIB)
|
if (bitsDamageType & DMG_ALWAYSGIB)
|
||||||
Killed(pevAttacker, GIB_ALWAYS);
|
KilledInflicted(pevInflictor, pevAttacker, GIB_ALWAYS);
|
||||||
|
|
||||||
else if (bitsDamageType & DMG_NEVERGIB)
|
else if (bitsDamageType & DMG_NEVERGIB)
|
||||||
Killed(pevAttacker, GIB_NEVER);
|
KilledInflicted(pevInflictor, pevAttacker, GIB_NEVER);
|
||||||
else
|
else
|
||||||
Killed(pevAttacker, GIB_NORMAL);
|
KilledInflicted(pevInflictor, pevAttacker, GIB_NORMAL);
|
||||||
|
|
||||||
g_pevLastInflictor = nullptr;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((pev->flags & FL_MONSTER) && !FNullEnt(pevAttacker))
|
if ((pev->flags & FL_MONSTER) && !FNullEnt(pevAttacker))
|
||||||
|
@ -697,7 +697,11 @@ BOOL CBaseEntity::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, fl
|
|||||||
pev->health -= flDamage;
|
pev->health -= flDamage;
|
||||||
if (pev->health <= 0)
|
if (pev->health <= 0)
|
||||||
{
|
{
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
|
KilledInflicted(pevInflictor, pevAttacker, GIB_NORMAL);
|
||||||
|
#else
|
||||||
Killed(pevAttacker, GIB_NORMAL);
|
Killed(pevAttacker, GIB_NORMAL);
|
||||||
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +246,9 @@ public:
|
|||||||
void ResetDmgPenetrationLevel();
|
void ResetDmgPenetrationLevel();
|
||||||
int GetDmgPenetrationLevel() const;
|
int GetDmgPenetrationLevel() const;
|
||||||
|
|
||||||
|
void KilledInflicted(entvars_t *pevInflictor, entvars_t *pevAttacker, int iGib);
|
||||||
|
entvars_t *GetLastInflictor();
|
||||||
|
|
||||||
#ifdef REGAMEDLL_API
|
#ifdef REGAMEDLL_API
|
||||||
CCSEntity *m_pEntity;
|
CCSEntity *m_pEntity;
|
||||||
CCSEntity *CSEntity() const;
|
CCSEntity *CSEntity() const;
|
||||||
|
@ -82,7 +82,9 @@ const char *CDeadHEV::m_szPoses[] =
|
|||||||
"deadtable"
|
"deadtable"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef REGAMEDLL_API
|
||||||
entvars_t *g_pevLastInflictor;
|
entvars_t *g_pevLastInflictor;
|
||||||
|
#endif
|
||||||
|
|
||||||
LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer)
|
LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer)
|
||||||
|
|
||||||
@ -2130,7 +2132,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
|||||||
if (IsBot() && IsBlind()) // dystopm: shouldn't be !IsBot() ?
|
if (IsBot() && IsBlind()) // dystopm: shouldn't be !IsBot() ?
|
||||||
wasBlind = true;
|
wasBlind = true;
|
||||||
|
|
||||||
TheCareerTasks->HandleEnemyKill(wasBlind, GetKillerWeaponName(g_pevLastInflictor, pevAttacker), m_bHeadshotKilled, killerHasShield, pAttacker, this); // last 2 param swapped to match function definition
|
TheCareerTasks->HandleEnemyKill(wasBlind, GetKillerWeaponName(GetLastInflictor(), pevAttacker), m_bHeadshotKilled, killerHasShield, pAttacker, this); // last 2 param swapped to match function definition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2161,7 +2163,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
|||||||
{
|
{
|
||||||
if (TheCareerTasks)
|
if (TheCareerTasks)
|
||||||
{
|
{
|
||||||
TheCareerTasks->HandleEnemyKill(wasBlind, GetKillerWeaponName(g_pevLastInflictor, pevAttacker), m_bHeadshotKilled, killerHasShield, this, pPlayer);
|
TheCareerTasks->HandleEnemyKill(wasBlind, GetKillerWeaponName(GetLastInflictor(), pevAttacker), m_bHeadshotKilled, killerHasShield, this, pPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2171,7 +2173,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
|||||||
|
|
||||||
if (!m_bKilledByBomb)
|
if (!m_bKilledByBomb)
|
||||||
{
|
{
|
||||||
g_pGameRules->PlayerKilled(this, pevAttacker, g_pevLastInflictor);
|
g_pGameRules->PlayerKilled(this, pevAttacker, GetLastInflictor());
|
||||||
}
|
}
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, pev);
|
MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, pev);
|
||||||
|
@ -975,7 +975,9 @@ inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex)
|
|||||||
return pPlayer;
|
return pPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef REGAMEDLL_API
|
||||||
extern entvars_t *g_pevLastInflictor;
|
extern entvars_t *g_pevLastInflictor;
|
||||||
|
#endif
|
||||||
extern CBaseEntity *g_pLastSpawn;
|
extern CBaseEntity *g_pLastSpawn;
|
||||||
extern CBaseEntity *g_pLastCTSpawn;
|
extern CBaseEntity *g_pLastCTSpawn;
|
||||||
extern CBaseEntity *g_pLastTerroristSpawn;
|
extern CBaseEntity *g_pLastTerroristSpawn;
|
||||||
|
@ -46,12 +46,13 @@ public:
|
|||||||
public:
|
public:
|
||||||
CBaseEntity *m_pContainingEntity;
|
CBaseEntity *m_pContainingEntity;
|
||||||
unsigned char m_ucDmgPenetrationLevel; // penetration level of the damage caused by the inflictor
|
unsigned char m_ucDmgPenetrationLevel; // penetration level of the damage caused by the inflictor
|
||||||
|
entvars_t *m_pevLastInflictor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma region reserve_data_Region
|
#pragma region reserve_data_Region
|
||||||
#endif
|
#endif
|
||||||
char CCSEntity_Reserve[0x3FFF];
|
char CCSEntity_Reserve[0x3FF7];
|
||||||
|
|
||||||
virtual void func_reserve1() {};
|
virtual void func_reserve1() {};
|
||||||
virtual void func_reserve2() {};
|
virtual void func_reserve2() {};
|
||||||
@ -91,26 +92,52 @@ private:
|
|||||||
inline void CBaseEntity::SetDmgPenetrationLevel(int iPenetrationLevel)
|
inline void CBaseEntity::SetDmgPenetrationLevel(int iPenetrationLevel)
|
||||||
{
|
{
|
||||||
#ifdef REGAMEDLL_API
|
#ifdef REGAMEDLL_API
|
||||||
m_pEntity->m_ucDmgPenetrationLevel = iPenetrationLevel;
|
CSEntity()->m_ucDmgPenetrationLevel = iPenetrationLevel;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CBaseEntity::ResetDmgPenetrationLevel()
|
inline void CBaseEntity::ResetDmgPenetrationLevel()
|
||||||
{
|
{
|
||||||
#ifdef REGAMEDLL_API
|
#ifdef REGAMEDLL_API
|
||||||
m_pEntity->m_ucDmgPenetrationLevel = 0;
|
CSEntity()->m_ucDmgPenetrationLevel = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int CBaseEntity::GetDmgPenetrationLevel() const
|
inline int CBaseEntity::GetDmgPenetrationLevel() const
|
||||||
{
|
{
|
||||||
#ifdef REGAMEDLL_API
|
#ifdef REGAMEDLL_API
|
||||||
return m_pEntity->m_ucDmgPenetrationLevel;
|
return CSEntity()->m_ucDmgPenetrationLevel;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void CBaseEntity::KilledInflicted(entvars_t* pevInflictor, entvars_t *pevAttacker, int iGib)
|
||||||
|
{
|
||||||
|
#ifdef REGAMEDLL_API
|
||||||
|
CSEntity()->m_pevLastInflictor = pevInflictor;
|
||||||
|
#else
|
||||||
|
g_pevLastInflictor = pevInflictor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Killed(pevAttacker, iGib);
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_API
|
||||||
|
CSEntity()->m_pevLastInflictor = nullptr;
|
||||||
|
#else
|
||||||
|
g_pevLastInflictor = nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline entvars_t* CBaseEntity::GetLastInflictor()
|
||||||
|
{
|
||||||
|
#ifdef REGAMEDLL_API
|
||||||
|
return CSEntity()->m_pevLastInflictor;
|
||||||
|
#else
|
||||||
|
return g_pevLastInflictor;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
class CCSDelay: public CCSEntity
|
class CCSDelay: public CCSEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user