diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 0b0ac740..82c9b984 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -2451,7 +2451,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib) HintMessage("#Hint_cannot_play_because_tk", TRUE, TRUE); } - if ((pev->health < -9000 && iGib != GIB_NEVER) || iGib == GIB_ALWAYS) + if (ShouldGibPlayer(iGib)) { #ifndef REGAMEDLL_FIXES diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 8221bd48..a3f0411f 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -448,7 +448,7 @@ public: edict_t *EntSelectSpawnPoint_OrigFunc(); void PlayerDeathThink_OrigFunc(); void Observer_Think_OrigFunc(); - + CCSPlayer *CSPlayer() const; #endif // REGAMEDLL_API @@ -641,6 +641,7 @@ public: bool ShouldToShowAccount(CBasePlayer *pReceiver) const; bool ShouldToShowHealthInfo(CBasePlayer *pReceiver) const; const char *GetKillerWeaponName(entvars_t *pevInflictor, entvars_t *pevKiller) const; + bool ShouldGibPlayer(int iGib); CBasePlayerItem *GetItemByName(const char *itemName); CBasePlayerItem *GetItemById(WeaponIdType weaponID); @@ -954,7 +955,24 @@ inline bool CBasePlayer::HasTimePassedSinceDeath(float duration) const inline CCSPlayer *CBasePlayer::CSPlayer() const { return reinterpret_cast(this->m_pEntity); } -#endif +#else // !REGAMEDLL_API + +// Determine whether player can be gibbed or not +inline bool CBasePlayer::ShouldGibPlayer(int iGib) +{ + // Always gib the player regardless of incoming damage + if (iGib == GIB_ALWAYS) + return true; + + // Gib the player if health is below the gib damage threshold + if (pev->health < GIB_PLAYER_THRESHOLD && iGib != GIB_NEVER) + return true; + + // do not gib the player + return false; +} + +#endif // !REGAMEDLL_API #ifdef REGAMEDLL_FIXES diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index dd44697e..0b867233 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -56,7 +56,8 @@ public: m_flLongJumpHeight(0), m_flLongJumpForce(0), m_flDuckSpeedMultiplier(0), - m_iUserID(-1) + m_iUserID(-1), + m_iGibDamageThreshold(GIB_PLAYER_THRESHOLD) { m_szModel[0] = '\0'; @@ -172,6 +173,8 @@ public: void RecordDamage(CBasePlayer *pAttacker, float flDamage, float flFlashDurationTime = -1); int m_iNumKilledByUnanswered[MAX_CLIENTS]; // [0-31] how many unanswered kills this player has been dealt by each other player bool m_bPlayerDominated[MAX_CLIENTS]; // [0-31] array of state per other player whether player is dominating other players + + int m_iGibDamageThreshold; // negative health to reach to gib player }; // Inlines @@ -210,3 +213,20 @@ inline void CCSPlayer::SetPlayerDominated(CBasePlayer *pPlayer, bool bDominated) Assert(iPlayerIndex > 0 && iPlayerIndex <= MAX_CLIENTS); m_bPlayerDominated[iPlayerIndex - 1] = bDominated; } + +#ifdef REGAMEDLL_API +// Determine whether player can be gibbed or not +inline bool CBasePlayer::ShouldGibPlayer(int iGib) +{ + // Always gib the player regardless of incoming damage + if (iGib == GIB_ALWAYS) + return true; + + // Gib the player if health is below the gib damage threshold + if (pev->health < CSPlayer()->m_iGibDamageThreshold && iGib != GIB_NEVER) + return true; + + // do not gib the player + return false; +} +#endif diff --git a/regamedll/public/regamedll/regamedll_const.h b/regamedll/public/regamedll/regamedll_const.h index ddbe62af..4599c58f 100644 --- a/regamedll/public/regamedll/regamedll_const.h +++ b/regamedll/public/regamedll/regamedll_const.h @@ -106,3 +106,4 @@ #define GIB_NEVER 1 // Never gib, no matter how much death damage is done ( freezing, etc ) #define GIB_ALWAYS 2 // Always gib ( Houndeye Shock, Barnacle Bite ) #define GIB_HEALTH_VALUE -30 +#define GIB_PLAYER_THRESHOLD -9000