components/prboom/st_stuff.c
//
// This is a not-very-pretty routine which handles
//  the face states and their timing.
// the precedence of expressions is:
//  dead > evil grin > turned head > straight ahead
//
This is a not-very-pretty routine which handles
the face states and their timing.
the precedence of expressions is:
dead > evil grin > turned head > straight ahead
This is a not - very - pretty routine which handles the face states and their timing . the precedence of expressions is : dead > evil grin > turned head > straight ahead
static void ST_updateFaceWidget(void)
{
  int         i;
  angle_t     badguyangle;
  angle_t     diffang;
  static int  lastattackdown = -1;
  static int  priority = 0;
  boolean     doevilgrin;
  if (priority < 10)
    {
      if (!plyr->health)
        {
          priority = 9;
          st_faceindex = ST_DEADFACE;
          st_facecount = 1;
        }
    }
  if (priority < 9)
    {
      if (plyr->bonuscount)
        {
          doevilgrin = false;
          for (i=0;i<NUMWEAPONS;i++)
            {
              if (oldweaponsowned[i] != plyr->weaponowned[i])
                {
                  doevilgrin = true;
                  oldweaponsowned[i] = plyr->weaponowned[i];
                }
            }
          if (doevilgrin)
            {
              priority = 8;
              st_facecount = ST_EVILGRINCOUNT;
              st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
            }
        }
    }
  if (priority < 8)
    {
      if (plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo)
        {
          priority = 7;
          if(st_oldhealth - plyr->health > ST_MUCHPAIN)
            {
              st_facecount = ST_TURNCOUNT;
              st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
            }
          else
            {
              badguyangle = R_PointToAngle2(plyr->mo->x,
                                            plyr->mo->y,
                                            plyr->attacker->x,
                                            plyr->attacker->y);
              if (badguyangle > plyr->mo->angle)
                {
                  diffang = badguyangle - plyr->mo->angle;
                  i = diffang > ANG180;
                }
              else
                {
                  diffang = plyr->mo->angle - badguyangle;
                  i = diffang <= ANG180;
                } 
              st_facecount = ST_TURNCOUNT;
              st_faceindex = ST_calcPainOffset();
              if (diffang < ANG45)
                {
                  st_faceindex += ST_RAMPAGEOFFSET;
                }
              else if (i)
                {
                  st_faceindex += ST_TURNOFFSET;
                }
              else
                {
                  st_faceindex += ST_TURNOFFSET+1;
                }
            }
        }
    }
  if (priority < 7)
    {
      if (plyr->damagecount)
        {
          if(st_oldhealth - plyr->health > ST_MUCHPAIN)
            {
              priority = 7;
              st_facecount = ST_TURNCOUNT;
              st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
            }
          else
            {
              priority = 6;
              st_facecount = ST_TURNCOUNT;
              st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
            }
        }
    }
  if (priority < 6)
    {
      if (plyr->attackdown)
        {
          if (lastattackdown==-1)
            lastattackdown = ST_RAMPAGEDELAY;
          else if (!--lastattackdown)
            {
              priority = 5;
              st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
              st_facecount = 1;
              lastattackdown = 1;
            }
        }
      else
        lastattackdown = -1;
    }
  if (priority < 5)
    {
      if ((plyr->cheats & CF_GODMODE)
          || plyr->powers[pw_invulnerability])
        {
          priority = 4;
          st_faceindex = ST_GODFACE;
          st_facecount = 1;
        }
    }
  if (!st_facecount)
    {
      st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
      st_facecount = ST_STRAIGHTFACECOUNT;
      priority = 0;
    }
  st_facecount--;
}
static void ST_updateFaceWidget ( void ) { int i ; angle_t badguyangle ; angle_t diffang ; static int lastattackdown = -1 ; static int priority = 0 ; boolean doevilgrin ; if ( priority < 10 ) { if ( ! plyr -> health ) { priority = 9 ; st_faceindex = ST_DEADFACE ; st_facecount = 1 ; } } if ( priority < 9 ) { if ( plyr -> bonuscount ) { doevilgrin = false ; for ( i = 0 ; i < NUMWEAPONS ; i ++ ) { if ( oldweaponsowned [ i ] != plyr -> weaponowned [ i ] ) { doevilgrin = true ; oldweaponsowned [ i ] = plyr -> weaponowned [ i ] ; } } if ( doevilgrin ) { priority = 8 ; st_facecount = ST_EVILGRINCOUNT ; st_faceindex = ST_calcPainOffset ( ) + ST_EVILGRINOFFSET ; } } } if ( priority < 8 ) { if ( plyr -> damagecount && plyr -> attacker && plyr -> attacker != plyr -> mo ) { priority = 7 ; if ( st_oldhealth - plyr -> health > ST_MUCHPAIN ) { st_facecount = ST_TURNCOUNT ; st_faceindex = ST_calcPainOffset ( ) + ST_OUCHOFFSET ; } else { badguyangle = R_PointToAngle2 ( plyr -> mo -> x , plyr -> mo -> y , plyr -> attacker -> x , plyr -> attacker -> y ) ; if ( badguyangle > plyr -> mo -> angle ) { diffang = badguyangle - plyr -> mo -> angle ; i = diffang > ANG180 ; } else { diffang = plyr -> mo -> angle - badguyangle ; i = diffang <= ANG180 ; } st_facecount = ST_TURNCOUNT ; st_faceindex = ST_calcPainOffset ( ) ; if ( diffang < ANG45 ) { st_faceindex += ST_RAMPAGEOFFSET ; } else if ( i ) { st_faceindex += ST_TURNOFFSET ; } else { st_faceindex += ST_TURNOFFSET + 1 ; } } } } if ( priority < 7 ) { if ( plyr -> damagecount ) { if ( st_oldhealth - plyr -> health > ST_MUCHPAIN ) { priority = 7 ; st_facecount = ST_TURNCOUNT ; st_faceindex = ST_calcPainOffset ( ) + ST_OUCHOFFSET ; } else { priority = 6 ; st_facecount = ST_TURNCOUNT ; st_faceindex = ST_calcPainOffset ( ) + ST_RAMPAGEOFFSET ; } } } if ( priority < 6 ) { if ( plyr -> attackdown ) { if ( lastattackdown == -1 ) lastattackdown = ST_RAMPAGEDELAY ; else if ( ! -- lastattackdown ) { priority = 5 ; st_faceindex = ST_calcPainOffset ( ) + ST_RAMPAGEOFFSET ; st_facecount = 1 ; lastattackdown = 1 ; } } else lastattackdown = -1 ; } if ( priority < 5 ) { if ( ( plyr -> cheats & CF_GODMODE ) || plyr -> powers [ pw_invulnerability ] ) { priority = 4 ; st_faceindex = ST_GODFACE ; st_facecount = 1 ; } } if ( ! st_facecount ) { st_faceindex = ST_calcPainOffset ( ) + ( st_randomnumber % 3 ) ; st_facecount = ST_STRAIGHTFACECOUNT ; priority = 0 ; } st_facecount -- ; }
This is a not-very-pretty routine which handles
the face states and their timing.
This is a not - very - pretty routine which handles the face states and their timing .
// dead // picking up bonus // evil grin if just picked up weapon // being attacked // haleyjd 10/12/03: classic DOOM problem of missing OUCH face // was due to inversion of this test: // if(plyr->health - st_oldhealth > ST_MUCHPAIN) // whether right or left // whether left or right // confusing, aint it? // head-on // turn face right // turn face left // getting hurt because of your own damn stupidity // haleyjd 10/12/03: classic DOOM problem of missing OUCH face // was due to inversion of this test: // if(plyr->health - st_oldhealth > ST_MUCHPAIN) // rapid firing // invulnerability // look left or look right if the facecount has timed out