From 678302f45f3c8861d85ef1b820f2837c926f0d28 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 2 Jan 2025 21:15:52 +0300 Subject: [PATCH] Floor taken damage for player instead casting to int. Avoid casting issues --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 21b636b24..69c8f6784 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -486,7 +486,7 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that // as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc) - fTookDamage = CBaseMonster::TakeDamage( pevInflictor, pevAttacker, (int)flDamage, bitsDamageType ); + fTookDamage = CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage >= 0.0f ? floor(flDamage) : ceil(flDamage), bitsDamageType ); // reset damage time countdown for each type of time based damage player just sustained {