@ -809,7 +809,7 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){
hurtRumbleTime = " Player.Hurt Rumble Time " _F ;
Input : : StartVibration ( ) ;
Input : : SetLightbar ( PixelLerp ( DARK_RED , GREEN , GetHealth ( ) / float ( GetMaxHealth ( ) ) ) ) ;
Input : : SetLightbar ( PixelLerp ( DARK_RED , GREEN , GetHealthRatio ( ) ) ) ;
if ( lastHitTimer > 0 ) {
damageNumberPtr . get ( ) - > damage + = int ( mod_dmg ) ;
@ -821,7 +821,7 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){
}
lastHitTimer = 0.05f ;
if ( ! lowHealthSoundPlayed & & lowHealthSoundPlayedTimer = = 0.f & & GetHealth ( ) / float ( GetMaxHealth ( ) ) < = " Player.Health Warning Pct " _F / 100.f ) {
if ( ! lowHealthSoundPlayed & & lowHealthSoundPlayedTimer = = 0.f & & GetHealthRatio ( ) < = " Player.Health Warning Pct " _F / 100.f ) {
SoundEffect : : PlaySFX ( " Health Warning " , SoundEffect : : CENTERED ) ;
lowHealthSoundPlayed = true ;
lowHealthSoundPlayedTimer = " Player.Health Warning Cooldown " _F ;
@ -1088,7 +1088,7 @@ bool Player::Heal(int damage,bool suppressDamageNumber){
if ( ! suppressDamageNumber & & damage > 0 ) {
DAMAGENUMBER_LIST . push_back ( std : : make_shared < DamageNumber > ( GetPos ( ) , damage , true , HEALTH_GAIN ) ) ;
}
Input : : SetLightbar ( PixelLerp ( DARK_RED , GREEN , GetHealth ( ) / float ( GetMaxHealth ( ) ) ) ) ;
Input : : SetLightbar ( PixelLerp ( DARK_RED , GREEN , GetHealthRatio ( ) ) ) ;
return true ;
}
@ -1358,7 +1358,7 @@ void Player::PerformHPRecovery(){
Heal ( hpRecoveryAmt ) ;
}
if ( GetHealth ( ) / float ( GetMaxHealth ( ) ) > " Player.Health Warning Pct " _F / 100.f ) {
if ( GetHealthRatio ( ) > " Player.Health Warning Pct " _F / 100.f ) {
lowHealthSoundPlayed = false ;
}
}
@ -1584,4 +1584,8 @@ void Player::ProximityKnockback(const vf2d centerPoint,const float knockbackFact
void Player : : AddVelocity ( vf2d vel ) {
this - > vel + = vel * game - > GetElapsedTime ( ) ;
}
const float Player : : GetHealthRatio ( ) const {
return GetHealth ( ) / float ( GetMaxHealth ( ) ) ;
}