components/prboom/p_telept.c
//
// Silent TELEPORTATION, by Lee Killough
// Primarily for rooms-over-rooms etc.
//
Silent TELEPORTATION, by Lee Killough
Primarily for rooms-over-rooms etc.
Silent TELEPORTATION by Lee Killough Primarily for rooms - over - rooms etc .
int EV_SilentTeleport(line_t *line, int side, mobj_t *thing)
{
  mobj_t    *m;
  if (side || thing->flags & MF_MISSILE)
    return 0;
  if ((m = P_TeleportDestination(line)) != NULL)
        {
          fixed_t z = thing->z - thing->floorz;
          angle_t angle =
            R_PointToAngle2(0, 0, line->dx, line->dy) - m->angle + ANG90;
          fixed_t s = finesine[angle>>ANGLETOFINESHIFT];
          fixed_t c = finecosine[angle>>ANGLETOFINESHIFT];
          fixed_t momx = thing->momx;
          fixed_t momy = thing->momy;
          player_t *player = thing->player;
          if (!P_TeleportMove(thing, m->x, m->y, false)) 
            return 0;
          thing->angle += angle;
          thing->z = z + thing->floorz;
          thing->momx = FixedMul(momx, c) - FixedMul(momy, s);
          thing->momy = FixedMul(momy, c) + FixedMul(momx, s);
          if (player && player->mo == thing)
            {
              fixed_t deltaviewheight = player->deltaviewheight;
              player->deltaviewheight = 0;
              P_CalcHeight(player);
              player->deltaviewheight = deltaviewheight;
            }
          if (player && player->mo == thing)
            R_ResetAfterTeleport(player);
          return 1;
        }
  return 0;
}
int EV_SilentTeleport ( line_t * line , int side , mobj_t * thing ) { mobj_t * m ; if ( side || thing -> flags & MF_MISSILE ) return 0 ; if ( ( m = P_TeleportDestination ( line ) ) != NULL ) { fixed_t z = thing -> z - thing -> floorz ; angle_t angle = R_PointToAngle2 ( 0 , 0 , line -> dx , line -> dy ) - m -> angle + ANG90 ; fixed_t s = finesine [ angle >> ANGLETOFINESHIFT ] ; fixed_t c = finecosine [ angle >> ANGLETOFINESHIFT ] ; fixed_t momx = thing -> momx ; fixed_t momy = thing -> momy ; player_t * player = thing -> player ; if ( ! P_TeleportMove ( thing , m -> x , m -> y , false ) ) return 0 ; thing -> angle += angle ; thing -> z = z + thing -> floorz ; thing -> momx = FixedMul ( momx , c ) - FixedMul ( momy , s ) ; thing -> momy = FixedMul ( momy , c ) + FixedMul ( momx , s ) ; if ( player && player -> mo == thing ) { fixed_t deltaviewheight = player -> deltaviewheight ; player -> deltaviewheight = 0 ; P_CalcHeight ( player ) ; player -> deltaviewheight = deltaviewheight ; } if ( player && player -> mo == thing ) R_ResetAfterTeleport ( player ) ; return 1 ; } return 0 ; }
Silent TELEPORTATION, by Lee Killough
Primarily for rooms-over-rooms etc.
Silent TELEPORTATION by Lee Killough Primarily for rooms - over - rooms etc .
// don't teleport missiles // Don't teleport if hit back of line, // so you can get out of teleporter. // Height of thing above ground, in case of mid-air teleports: // Get the angle between the exit thing and source linedef. // Rotate 90 degrees, so that walking perpendicularly across // teleporter linedef causes thing to exit in the direction // indicated by the exit thing. // Sine, cosine of angle adjustment // Momentum of thing crossing teleporter linedef // Whether this is a player, and if so, a pointer to its player_t // Attempt to teleport, aborting if blocked /* killough 8/9/98 */ // Rotate thing according to difference in angles // Adjust z position to be same height above ground as before // Rotate thing's momentum to come out of exit just like it entered // Adjust player's view, in case there has been a height change // Voodoo dolls are excluded by making sure player->mo == thing. // Save the current deltaviewheight, used in stepping // Clear deltaviewheight, since we don't want any changes // Set player's view according to the newly set parameters // Reset the delta to have the same dynamics as before // e6y