Ejemplo n.º 1
0
static void ST_updateFaceWidget(void)
{
  int         i;
  angle_t     badguyangle;
  angle_t     diffang;
  static int  lastattackdown = -1;
  static int  priority = 0;
  dboolean     doevilgrin;

  if (priority < 10)
    {
      // dead
      if (!plyr->health)
        {
          priority = 9;
          st_faceindex = ST_DEADFACE;
          st_facecount = 1;
        }
    }

  if (priority < 9)
    {
      if (plyr->bonuscount)
        {
          // picking up bonus
          doevilgrin = false;

          for (i=0;i<NUMWEAPONS;i++)
            {
              if (oldweaponsowned[i] != plyr->weaponowned[i])
                {
                  doevilgrin = true;
                  oldweaponsowned[i] = plyr->weaponowned[i];
                }
            }
          if (doevilgrin)
            {
              // evil grin if just picked up weapon
              priority = 8;
              st_facecount = ST_EVILGRINCOUNT;
              st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
            }
        }

    }

  if (priority < 8)
    {
      if (plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo)
        {
          // being attacked
          priority = 7;

           // 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)
           // e6y: compatibility optioned
           if((comp[comp_ouchface]?
              (plyr->health - st_oldhealth):
              (st_oldhealth - plyr->health)) > ST_MUCHPAIN)
            {
              // e6y
              // There are TWO bugs in the ouch face code.
              // Not only was the condition reversed, but the priority system is
              // broken in a way that makes the face not work with monster damage.
              if(!comp[comp_ouchface])
                priority = 8;

              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)
                {
                  // whether right or left
                  diffang = badguyangle - plyr->mo->angle;
                  i = diffang > ANG180;
                }
              else
                {
                  // whether left or right
                  diffang = plyr->mo->angle - badguyangle;
                  i = diffang <= ANG180;
                } // confusing, aint it?


              st_facecount = ST_TURNCOUNT;
              st_faceindex = ST_calcPainOffset();

              if (diffang < ANG45)
                {
                  // head-on
                  st_faceindex += ST_RAMPAGEOFFSET;
                }
              else if (i)
                {
                  // turn face right
                  st_faceindex += ST_TURNOFFSET;
                }
              else
                {
                  // turn face left
                  st_faceindex += ST_TURNOFFSET+1;
                }
            }
        }
    }

  if (priority < 7)
    {
      // getting hurt because of your own damn stupidity
      if (plyr->damagecount)
        {
           // 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)
           // e6y: compatibility optioned
           if((comp[comp_ouchface]?
              (plyr->health - st_oldhealth):
              (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)
    {
      // rapid firing
      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)
    {
      // invulnerability
      if ((plyr->cheats & CF_GODMODE)
          || plyr->powers[pw_invulnerability])
        {
          priority = 4;

          st_faceindex = ST_GODFACE;
          st_facecount = 1;

        }

    }

  // look left or look right if the facecount has timed out
  if (!st_facecount)
    {
      st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
      st_facecount = ST_STRAIGHTFACECOUNT;
      priority = 0;
    }

  st_facecount--;

}
Ejemplo n.º 2
0
//
// 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
//
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)
    {
	// dead
	if (!plyr->health)
	{
	    priority = 9;
	    st_faceindex = ST_DEADFACE;
	    st_facecount = 1;
	}
    }

    if (priority < 9)
    {
	if (plyr->bonuscount)
	{
	    // picking up bonus
	    doevilgrin = false;

	    for (i=0;i<NUMWEAPONS;i++)
	    {
		if (oldweaponsowned[i] != plyr->weaponowned[i])
		{
		    doevilgrin = true;
		    oldweaponsowned[i] = plyr->weaponowned[i];
		}
	    }
	    if (doevilgrin) 
	    {
		// evil grin if just picked up weapon
		priority = 8;
		st_facecount = ST_EVILGRINCOUNT;
		st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
	    }
	}

    }
  
    if (priority < 8)
    {
	if (plyr->damagecount
	    && plyr->attacker
	    && plyr->attacker != plyr->mo)
	{
	    // being attacked
	    priority = 7;
	    
	    if (plyr->health - st_oldhealth > 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)
		{
		    // whether right or left
		    diffang = badguyangle - plyr->mo->angle;
		    i = diffang > ANG180; 
		}
		else
		{
		    // whether left or right
		    diffang = plyr->mo->angle - badguyangle;
		    i = diffang <= ANG180; 
		} // confusing, aint it?

		
		st_facecount = ST_TURNCOUNT;
		st_faceindex = ST_calcPainOffset();
		
		if (diffang < ANG45)
		{
		    // head-on    
		    st_faceindex += ST_RAMPAGEOFFSET;
		}
		else if (i)
		{
		    // turn face right
		    st_faceindex += ST_TURNOFFSET;
		}
		else
		{
		    // turn face left
		    st_faceindex += ST_TURNOFFSET+1;
		}
	    }
	}
    }
  
    if (priority < 7)
    {
	// getting hurt because of your own damn stupidity
	if (plyr->damagecount)
	{
	    if (plyr->health - st_oldhealth > 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)
    {
	// rapid firing
	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)
    {
	// invulnerability
	if ((plyr->cheats & CF_GODMODE)
	    || plyr->powers[pw_invulnerability])
	{
	    priority = 4;

	    st_faceindex = ST_GODFACE;
	    st_facecount = 1;

	}

    }

    // look left or look right if the facecount has timed out
    if (!st_facecount)
    {
	st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
	st_facecount = ST_STRAIGHTFACECOUNT;
	priority = 0;
    }

    st_facecount--;

}
Ejemplo n.º 3
0
//
// ST_updateFaceWidget
//
// 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()
{
   int        i;
   angle_t    badguyangle;
   angle_t    diffang;
   static int lastattackdown = -1;
   static int priority = ST_PRIORITY_NONE;
   bool       doevilgrin;
   
   if(priority < ST_PRIORITY_MAX)
   {
      // dead
      if(!plyr->health)
      {
         priority = ST_PRIORITY_DEAD;
         st_faceindex = ST_DEADFACE;
         st_facecount = 1;
      }
   }

   // haleyjd 06/27/08: ouch face when player screams from falling
   if(priority < ST_PRIORITY_DEAD)
   {
      if(plyr->mo->intflags & MIF_SCREAMED)
      {
         priority = ST_PRIORITY_FALLING;
         st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
         st_facecount = 1;
      }
   }

   if(priority < ST_PRIORITY_FALLING)
   {
      if(plyr->bonuscount)
      {
         // picking up bonus
         doevilgrin = false;

         for(i = 0; i < NUMWEAPONS; i++)
         {
            if(oldweaponsowned[i] != weaponsowned[i])
            {
               doevilgrin = true;
               oldweaponsowned[i] = weaponsowned[i];
            }
         }
         if(doevilgrin)
         {
            // evil grin if just picked up weapon
            priority = ST_PRIORITY_EVILGRIN;
            st_facecount = ST_EVILGRINCOUNT;
            st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
         }
      }
   }

   if(priority < ST_PRIORITY_EVILGRIN)
   {
      if(plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo)
      {
         // being attacked
         priority = ST_PRIORITY_PAIN;

         // 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)
         if(st_oldhealth - plyr->health > ST_MUCHPAIN)
         {
            priority = ST_PRIORITY_MUCHPAIN;
            st_facecount = ST_TURNCOUNT;
            st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
         }
         else
         {
            badguyangle = R_PointToAngle2(plyr->mo->x,
                                          plyr->mo->y,
                                          getThingX(plyr->mo, plyr->attacker),
                                          getThingY(plyr->mo, plyr->attacker));

            if(badguyangle > plyr->mo->angle)
            {
               // whether right or left
               diffang = badguyangle - plyr->mo->angle;
               i = diffang > ANG180;
            }
            else
            {
               // whether left or right
               diffang = plyr->mo->angle - badguyangle;
               i = diffang <= ANG180;
            } // confusing, aint it?

            st_facecount = ST_TURNCOUNT;
            st_faceindex = ST_calcPainOffset();

            if(diffang < ANG45)
            {
               // head-on
               st_faceindex += ST_RAMPAGEOFFSET;
            }
            else if(i)
            {
               // turn face right
               st_faceindex += ST_TURNOFFSET;
            }
            else
            {
               // turn face left
               st_faceindex += ST_TURNOFFSET+1;
            }
         }
      }
   }

   if(priority < ST_PRIORITY_PAIN)
   {
      // getting hurt because of your own damn stupidity
      if(plyr->damagecount)
      {
         // 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)
         if(st_oldhealth - plyr->health > ST_MUCHPAIN)
         {
            priority = ST_PRIORITY_MUCHPAIN_SELF;
            st_facecount = ST_TURNCOUNT;
            st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
         }
         else
         {
            priority = ST_PRIORITY_PAIN_SELF;
            st_facecount = ST_TURNCOUNT;
            st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
         }
      }
   }

   if(priority < ST_PRIORITY_PAIN_SELF)
   {
      // rapid firing
      if(plyr->attackdown)
      {
         if(lastattackdown==-1)
            lastattackdown = ST_RAMPAGEDELAY;
         else if(!--lastattackdown)
         {
            priority = ST_PRIORITY_RAMPAGE;
            st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
            st_facecount = 1;
            lastattackdown = 1;
         }
      }
      else
         lastattackdown = -1;
   }

   if(priority < ST_PRIORITY_RAMPAGE)
   {
      // invulnerability
      if((plyr->cheats & CF_GODMODE) || plyr->powers[pw_invulnerability])
      {
         priority = ST_PRIORITY_GODMODE;
         
         st_faceindex = ST_GODFACE;
         st_facecount = 1;
      }
   }

   // look left or look right if the facecount has timed out
   if(!st_facecount)
   {
      // sf: remove st_randomnumber
      st_faceindex = ST_calcPainOffset() + (M_Random() % 3);
      st_facecount = ST_STRAIGHTFACECOUNT;
      priority = ST_PRIORITY_NONE;
   }
   
   st_facecount--;
}