Skip to content
Permalink
Browse files

- fixed handling of the "ouch" face.

This depended on order of execution, taking the health values to compare from variables which were not synchronized properly.
Now both the last and current health being used here are being retrieved in the same place so that further changes cannot break this again.
  • Loading branch information...
coelckers committed Aug 9, 2019
1 parent 5ca1bb3 commit c3e3fda94add6ac82f9c73dd875c997d8d2acd92
Showing with 10 additions and 8 deletions.
  1. +2 −1 src/g_statusbar/sbar.h
  2. +8 −7 src/g_statusbar/sbar_mugshot.cpp
@@ -293,7 +293,8 @@ class FMugShot
FMugShotState *CurrentState;
int RampageTimer;
int LastDamageAngle;
int FaceHealth;
int FaceHealthNow;
int FaceHealthLast;
bool bEvilGrin;
bool bDamageFaceActive;
bool bNormal;
@@ -221,7 +221,7 @@ FMugShot::FMugShot()

void FMugShot::Reset()
{
FaceHealth = -1;
FaceHealthNow = FaceHealthLast = -1;
bEvilGrin = false;
bNormal = true;
bDamageFaceActive = false;
@@ -262,7 +262,8 @@ void FMugShot::Tick(player_t *player)
{
RampageTimer = 0;
}
FaceHealth = player->health;
FaceHealthLast = FaceHealthNow;
FaceHealthNow = player->health;
}

//===========================================================================
@@ -328,7 +329,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
{
FString full_state_name;

if (player->health > 0)
if (FaceHealthNow > 0)
{
if (bEvilGrin && !(stateflags & DISABLEGRIN))
{
@@ -340,10 +341,10 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
}
bEvilGrin = false;

bool ouch = (!st_oldouch && FaceHealth - player->health > ST_MUCHPAIN) || (st_oldouch && player->health - FaceHealth > ST_MUCHPAIN);
bool ouch = (!st_oldouch && FaceHealthLast - FaceHealthNow > ST_MUCHPAIN) || (st_oldouch && FaceHealthNow - FaceHealthLast > ST_MUCHPAIN);
if (player->damagecount &&
// Now go in if pain is disabled but we think ouch will be shown (and ouch is not disabled!)
(!(stateflags & DISABLEPAIN) || (((FaceHealth != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH))))
(!(stateflags & DISABLEPAIN) || (((FaceHealthLast != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH))))
{
int damage_angle = 1;
if (player->attacker && player->attacker != player->mo)
@@ -364,7 +365,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
}
}
bool use_ouch = false;
if (((FaceHealth != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH))
if (((FaceHealthLast != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH))
{
use_ouch = true;
full_state_name = "ouch.";
@@ -391,7 +392,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
else
{
bool use_ouch = false;
if (((FaceHealth != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH))
if (((FaceHealthLast != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH))
{
use_ouch = true;
full_state_name = "ouch.";

0 comments on commit c3e3fda

Please sign in to comment.
You can’t perform that action at this time.