Skip to content

Commit

Permalink
Fix status bar face hysteresis
Browse files Browse the repository at this point in the history
- from Crispy-Doom
  • Loading branch information
andrikpowell committed Feb 18, 2025
1 parent a34576b commit 625e05c
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions prboom2/src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ static int ST_calcPainOffset(void)
// dead > evil grin > turned head > straight ahead
//

// [crispy] fix status bar face hysteresis
static int faceindex;

static void ST_updateFaceWidget(void)
{
int i;
Expand All @@ -562,13 +565,19 @@ static void ST_updateFaceWidget(void)
static int priority = 0;
dboolean doevilgrin;

// [crispy] fix status bar face hysteresis
int painoffset;

painoffset = ST_calcPainOffset();

if (priority < 10)
{
// dead
if (!plyr->health)
{
priority = 9;
st_faceindex = ST_DEADFACE;
painoffset = 0;
faceindex = ST_DEADFACE;
st_facecount = 1;
}
}
Expand All @@ -593,7 +602,7 @@ static void ST_updateFaceWidget(void)
// evil grin if just picked up weapon
priority = 8;
st_facecount = ST_EVILGRINCOUNT;
st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
faceindex = ST_EVILGRINOFFSET;
}
}

Expand Down Expand Up @@ -622,7 +631,7 @@ static void ST_updateFaceWidget(void)
priority = 8;

st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
faceindex = ST_OUCHOFFSET;
}
else
{
Expand All @@ -646,22 +655,21 @@ static void ST_updateFaceWidget(void)


st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset();

if (diffang < ANG45)
{
// head-on
st_faceindex += ST_RAMPAGEOFFSET;
faceindex = ST_RAMPAGEOFFSET;
}
else if (i)
{
// turn face right
st_faceindex += ST_TURNOFFSET;
faceindex = ST_TURNOFFSET;
}
else
{
// turn face left
st_faceindex += ST_TURNOFFSET+1;
faceindex = ST_TURNOFFSET+1;
}
}
}
Expand All @@ -682,13 +690,13 @@ static void ST_updateFaceWidget(void)
{
priority = 7;
st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
faceindex = ST_OUCHOFFSET;
}
else
{
priority = 6;
st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
faceindex = ST_RAMPAGEOFFSET;
}

}
Expand All @@ -705,7 +713,7 @@ static void ST_updateFaceWidget(void)
else if (!--lastattackdown)
{
priority = 5;
st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
faceindex = ST_RAMPAGEOFFSET;
st_facecount = 1;
lastattackdown = 1;
}
Expand All @@ -723,7 +731,8 @@ static void ST_updateFaceWidget(void)
{
priority = 4;

st_faceindex = ST_GODFACE;
painoffset = 0;
faceindex = ST_GODFACE;
st_facecount = 1;

}
Expand All @@ -733,13 +742,15 @@ static void ST_updateFaceWidget(void)
// look left or look right if the facecount has timed out
if (!st_facecount)
{
st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
faceindex = st_randomnumber % 3;
st_facecount = ST_STRAIGHTFACECOUNT;
priority = 0;
}

st_facecount--;

// [crispy] fix status bar face hysteresis
st_faceindex = painoffset + faceindex;
}

int sts_traditional_keys; // killough 2/28/98: traditional status bar keys
Expand Down Expand Up @@ -1353,6 +1364,7 @@ static void ST_initData(void)

st_statusbaron = true;

faceindex = 0; // [crispy] fix status bar face hysteresis across level changes
st_faceindex = 0;
st_palette = -1;

Expand Down

0 comments on commit 625e05c

Please sign in to comment.