Fix player gaining health when drowning with god mode enabled and recovering health after surfacing
This commit is contained in:
parent
7e1518a6ff
commit
3718cf2659
2 changed files with 9 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
* Fixed Gauss gun dealing full damage when saving and loading right after starting a charged shot (Thanks Oxofemple.)
|
||||
* Prevent breakables from spawning multiple items when destroyed by gunfire and explosives at the same time (Thanks Oxofemple.)
|
||||
* Fixed save game system not saving arrays of EHANDLEs if the first half of the array contains null handles (mainly affected Nihilanth's spheres) [#224](https://github.com/SamVanheer/halflife-updated/issues/224) (Thanks Ronin4862)
|
||||
* Fixed player gaining health when drowning with god mode enabled and recovering health after surfacing (Thanks malortie)
|
||||
|
||||
### Features
|
||||
|
||||
|
|
|
@ -1098,13 +1098,20 @@ void CBasePlayer::WaterMove()
|
|||
pev->dmg += 1;
|
||||
if (pev->dmg > 5)
|
||||
pev->dmg = 5;
|
||||
|
||||
const float oldHealth = pev->health;
|
||||
|
||||
TakeDamage(CWorld::World->pev, CWorld::World->pev, pev->dmg, DMG_DROWN);
|
||||
pev->pain_finished = gpGlobals->time + 1;
|
||||
|
||||
// track drowning damage, give it back when
|
||||
// player finally takes a breath
|
||||
|
||||
m_idrowndmg += pev->dmg;
|
||||
// Account for god mode, the unkillable flag, potential damage mitigation
|
||||
// and gaining health from drowning to avoid counting damage not actually taken.
|
||||
const float drownDamageTaken = std::min(0.f, std::floor(oldHealth - pev->health));
|
||||
|
||||
m_idrowndmg += drownDamageTaken;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue