components/prboom/p_map.c
//
// P_HitSlideLine
// Adjusts the xmove / ymove
// so that the next move will slide along the wall.
// If the floor is icy, then you can bounce off a wall.             // phares
//
P_HitSlideLine
Adjusts the xmove / ymove
so that the next move will slide along the wall.
If the floor is icy, then you can bounce off a wall.             // phares
P_HitSlideLine Adjusts the xmove / ymove so that the next move will slide along the wall . If the floor is icy then you can bounce off a wall . // phares
void P_HitSlideLine (line_t* ld)
  {
  int     side;
  angle_t lineangle;
  angle_t moveangle;
  angle_t deltaangle;
  fixed_t movelen;
  fixed_t newlen;
  boolean icyfloor;  
  if (mbf_features)
  {
    icyfloor =
    P_AproxDistance(tmxmove, tmymove) > 4*FRACUNIT &&
    variable_friction &&  
    slidemo->z <= slidemo->floorz &&
    P_GetFriction(slidemo, NULL) > ORIG_FRICTION;
  }
  else
  {
    extern boolean onground;
    icyfloor = !compatibility &&
    variable_friction &&
    slidemo->player &&
    onground && 
    slidemo->friction > ORIG_FRICTION;
  }
  if (ld->slopetype == ST_HORIZONTAL)
    {
    if (icyfloor && (D_abs(tmymove) > D_abs(tmxmove)))
      {
      tmxmove /= 2; 
      tmymove = -tmymove/2;
      S_StartSound(slidemo,sfx_oof); 
      }
    else
      tmymove = 0; 
    return;
    }
  if (ld->slopetype == ST_VERTICAL)
    {
    if (icyfloor && (D_abs(tmxmove) > D_abs(tmymove)))
      {
      tmxmove = -tmxmove/2; 
      tmymove /= 2;
      S_StartSound(slidemo,sfx_oof);                       
      }                                                             
    else                                                            
      tmxmove = 0; 
    return;
    }
  // The wall is angled. Bounce if the angle of approach is         
  // less than 45 degrees.                                          
  side = P_PointOnLineSide (slidemo->x, slidemo->y, ld);
  lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy);
  if (side == 1)
    lineangle += ANG180;
  moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove);
  if (!demo_compatibility)
    moveangle += 10; // prevents sudden path reversal due to        
                     // rounding error                              
  deltaangle = moveangle-lineangle;                                 
  movelen = P_AproxDistance (tmxmove, tmymove);
  if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90+ANG45))
    {
    moveangle = lineangle - deltaangle;
    movelen /= 2; 
    S_StartSound(slidemo,sfx_oof); 
    moveangle >>= ANGLETOFINESHIFT;
    tmxmove = FixedMul (movelen, finecosine[moveangle]);
    tmymove = FixedMul (movelen, finesine[moveangle]);
    }                                                               
  else                                                              
    {                                                               
    if (deltaangle > ANG180)
      deltaangle += ANG180;
    lineangle >>= ANGLETOFINESHIFT;
    deltaangle >>= ANGLETOFINESHIFT;
    newlen = FixedMul (movelen, finecosine[deltaangle]);
    tmxmove = FixedMul (newlen, finecosine[lineangle]);
    tmymove = FixedMul (newlen, finesine[lineangle]);
    }                                                               
  }
void P_HitSlideLine ( line_t * ld ) { int side ; angle_t lineangle ; angle_t moveangle ; angle_t deltaangle ; fixed_t movelen ; fixed_t newlen ; boolean icyfloor ; if ( mbf_features ) { icyfloor = P_AproxDistance ( tmxmove , tmymove ) > 4 * FRACUNIT && variable_friction && slidemo -> z <= slidemo -> floorz && P_GetFriction ( slidemo , NULL ) > ORIG_FRICTION ; } else { extern boolean onground ; icyfloor = ! compatibility && variable_friction && slidemo -> player && onground && slidemo -> friction > ORIG_FRICTION ; } if ( ld -> slopetype == ST_HORIZONTAL ) { if ( icyfloor && ( D_abs ( tmymove ) > D_abs ( tmxmove ) ) ) { tmxmove /= 2 ; tmymove = - tmymove / 2 ; S_StartSound ( slidemo , sfx_oof ) ; } else tmymove = 0 ; return ; } if ( ld -> slopetype == ST_VERTICAL ) { if ( icyfloor && ( D_abs ( tmxmove ) > D_abs ( tmymove ) ) ) { tmxmove = - tmxmove / 2 ; tmymove /= 2 ; S_StartSound ( slidemo , sfx_oof ) ; } else tmxmove = 0 ; return ; } side = P_PointOnLineSide ( slidemo -> x , slidemo -> y , ld ) ; lineangle = R_PointToAngle2 ( 0 , 0 , ld -> dx , ld -> dy ) ; if ( side == 1 ) lineangle += ANG180 ; moveangle = R_PointToAngle2 ( 0 , 0 , tmxmove , tmymove ) ; if ( ! demo_compatibility ) moveangle += 10 ; deltaangle = moveangle - lineangle ; movelen = P_AproxDistance ( tmxmove , tmymove ) ; if ( icyfloor && ( deltaangle > ANG45 ) && ( deltaangle < ANG90 + ANG45 ) ) { moveangle = lineangle - deltaangle ; movelen /= 2 ; S_StartSound ( slidemo , sfx_oof ) ; moveangle >>= ANGLETOFINESHIFT ; tmxmove = FixedMul ( movelen , finecosine [ moveangle ] ) ; tmymove = FixedMul ( movelen , finesine [ moveangle ] ) ; } else { if ( deltaangle > ANG180 ) deltaangle += ANG180 ; lineangle >>= ANGLETOFINESHIFT ; deltaangle >>= ANGLETOFINESHIFT ; newlen = FixedMul ( movelen , finecosine [ deltaangle ] ) ; tmxmove = FixedMul ( newlen , finecosine [ lineangle ] ) ; tmymove = FixedMul ( newlen , finesine [ lineangle ] ) ; } }
P_HitSlideLine
Adjusts the xmove / ymove
so that the next move will slide along the wall.
P_HitSlideLine Adjusts the xmove / ymove so that the next move will slide along the wall .
// is floor icy?                               // phares //   | // Under icy conditions, if the angle of approach to the wall     //   V // is more than 45 degrees, then you'll bounce and lose half // your momentum. If less than 45 degrees, you'll slide along // the wall. 45 is arbitrary and is believable. // Check for the special cases of horz or vert walls. /* killough 10/98: only bounce if hit hard (prevents wobbling)
   * cph - DEMOSYNC - should only affect players in Boom demos? */ //e6y // killough 8/28/98: calc friction on demand // absorb half the momentum // oooff! // no more movement in the Y direction // absorb half the momentum // oooff!                      //   ^ //   | // phares // no more movement in the X direction // The wall is angled. Bounce if the angle of approach is         // phares // less than 45 degrees.                                          // phares // killough 3/2/98: // The moveangle+=10 breaks v1.9 demo compatibility in // some demos, so it needs demo_compatibility switch. // prevents sudden path reversal due to        // phares // rounding error                              //   | //   V // absorb // oooff! //   ^ //   | // phares //  I_Error ("SlideLine: ang>ANG180"); // phares