components/prboom/p_map.c
//
// PTR_AimTraverse
// Sets linetaget and aimslope when a target is aimed at.
//
PTR_AimTraverse
Sets linetaget and aimslope when a target is aimed at.
PTR_AimTraverse Sets linetaget and aimslope when a target is aimed at .
boolean PTR_AimTraverse (intercept_t* in)
  {
  line_t* li;
  mobj_t* th;
  fixed_t slope;
  fixed_t thingtopslope;
  fixed_t thingbottomslope;
  fixed_t dist;
  if (in->isaline)
    {
    li = in->d.line;
    if ( !(li->flags & ML_TWOSIDED) )
      return false;   
    P_LineOpening (li);
    if (openbottom >= opentop)
      return false;   
    dist = FixedMul (attackrange, in->frac);
    if (li->frontsector->floorheight != li->backsector->floorheight)
      {
      slope = FixedDiv (openbottom - shootz , dist);
      if (slope > bottomslope)
        bottomslope = slope;
      }
    if (li->frontsector->ceilingheight != li->backsector->ceilingheight)
      {
      slope = FixedDiv (opentop - shootz , dist);
      if (slope < topslope)
        topslope = slope;
      }
    if (topslope <= bottomslope)
      return false;   
    return true;    
    }
  th = in->d.thing;
  if (th == shootthing)
    return true;    
  if (!(th->flags&MF_SHOOTABLE))
    return true;    
  if (th->flags & shootthing->flags & aim_flags_mask && !th->player)
    return true;
  dist = FixedMul (attackrange, in->frac);
  thingtopslope = FixedDiv (th->z+th->height - shootz , dist);
  if (thingtopslope < bottomslope)
    return true;    
  thingbottomslope = FixedDiv (th->z - shootz, dist);
  if (thingbottomslope > topslope)
    return true;    
  if (thingtopslope > topslope)
    thingtopslope = topslope;
  if (thingbottomslope < bottomslope)
    thingbottomslope = bottomslope;
  aimslope = (thingtopslope+thingbottomslope)/2;
  linetarget = th;
  return false;   
  }
boolean PTR_AimTraverse ( intercept_t * in ) { line_t * li ; mobj_t * th ; fixed_t slope ; fixed_t thingtopslope ; fixed_t thingbottomslope ; fixed_t dist ; if ( in -> isaline ) { li = in -> d . line ; if ( ! ( li -> flags & ML_TWOSIDED ) ) return false ; P_LineOpening ( li ) ; if ( openbottom >= opentop ) return false ; dist = FixedMul ( attackrange , in -> frac ) ; if ( li -> frontsector -> floorheight != li -> backsector -> floorheight ) { slope = FixedDiv ( openbottom - shootz , dist ) ; if ( slope > bottomslope ) bottomslope = slope ; } if ( li -> frontsector -> ceilingheight != li -> backsector -> ceilingheight ) { slope = FixedDiv ( opentop - shootz , dist ) ; if ( slope < topslope ) topslope = slope ; } if ( topslope <= bottomslope ) return false ; return true ; } th = in -> d . thing ; if ( th == shootthing ) return true ; if ( ! ( th -> flags & MF_SHOOTABLE ) ) return true ; if ( th -> flags & shootthing -> flags & aim_flags_mask && ! th -> player ) return true ; dist = FixedMul ( attackrange , in -> frac ) ; thingtopslope = FixedDiv ( th -> z + th -> height - shootz , dist ) ; if ( thingtopslope < bottomslope ) return true ; thingbottomslope = FixedDiv ( th -> z - shootz , dist ) ; if ( thingbottomslope > topslope ) return true ; if ( thingtopslope > topslope ) thingtopslope = topslope ; if ( thingbottomslope < bottomslope ) thingbottomslope = bottomslope ; aimslope = ( thingtopslope + thingbottomslope ) / 2 ; linetarget = th ; return false ; }
PTR_AimTraverse
Sets linetaget and aimslope when a target is aimed at.
PTR_AimTraverse Sets linetaget and aimslope when a target is aimed at .
// stop // Crosses a two sided line. // A two sided line will restrict // the possible target ranges. // stop // stop // shot continues // shoot a thing // can't shoot self // corpse or something /* killough 7/19/98, 8/2/98:
   * friends don't aim at friends (except players), at least not first
   */ // check angles to see if the thing can be aimed at // shot over the thing // shot under the thing // this thing can be hit! // don't go any farther