2 //**************************************************************************
4 //** p_telept.c : Heretic 2 : Raven Software, Corp.
11 //**************************************************************************
13 // HEADER FILES ------------------------------------------------------------
19 // MACROS ------------------------------------------------------------------
21 // TYPES -------------------------------------------------------------------
23 // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
25 // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
27 // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
29 // EXTERNAL DATA DECLARATIONS ----------------------------------------------
31 // PUBLIC DATA DEFINITIONS -------------------------------------------------
33 // PRIVATE DATA DEFINITIONS ------------------------------------------------
35 // CODE --------------------------------------------------------------------
37 //==========================================================================
41 //==========================================================================
43 boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle,
58 aboveFloor = thing->z-thing->floorz;
59 if(!P_TeleportMove(thing, x, y))
65 player = thing->player;
66 if(player->powers[pw_flight] && aboveFloor)
68 thing->z = thing->floorz+aboveFloor;
69 if(thing->z+thing->height > thing->ceilingz)
71 thing->z = thing->ceilingz-thing->height;
73 player->viewz = thing->z+player->viewheight;
77 thing->z = thing->floorz;
78 player->viewz = thing->z+player->viewheight;
85 else if(thing->flags&MF_MISSILE)
87 thing->z = thing->floorz+aboveFloor;
88 if(thing->z+thing->height > thing->ceilingz)
90 thing->z = thing->ceilingz-thing->height;
95 thing->z = thing->floorz;
97 // Spawn teleport fog at source and destination
100 fogDelta = thing->flags&MF_MISSILE ? 0 : TELEFOGHEIGHT;
101 fog = P_SpawnMobj(oldx, oldy, oldz+fogDelta, MT_TFOG);
102 S_StartSound(fog, SFX_TELEPORT);
103 an = angle>>ANGLETOFINESHIFT;
104 fog = P_SpawnMobj(x+20*finecosine[an],
105 y+20*finesine[an], thing->z+fogDelta, MT_TFOG);
106 S_StartSound(fog, SFX_TELEPORT);
107 if(thing->player && !thing->player->powers[pw_speed])
108 { // Freeze player for about .5 sec
109 thing->reactiontime = 18;
111 thing->angle = angle;
113 if(thing->flags2&MF2_FLOORCLIP)
115 if(thing->z == thing->subsector->sector->floorheight
116 && P_GetThingFloorType(thing) > FLOOR_SOLID)
118 thing->floorclip = 10*FRACUNIT;
122 thing->floorclip = 0;
125 if(thing->flags&MF_MISSILE)
127 angle >>= ANGLETOFINESHIFT;
128 thing->momx = FixedMul(thing->info->speed, finecosine[angle]);
129 thing->momy = FixedMul(thing->info->speed, finesine[angle]);
131 else if(useFog) // no fog doesn't alter the player's momentums
133 thing->momx = thing->momy = thing->momz = 0;
138 //==========================================================================
142 //==========================================================================
144 boolean EV_Teleport(int tid, mobj_t *thing, boolean fog)
148 mobj_t *mo = NULL; /* jim added initialiser */
152 { // Teleport function called with an invalid mobj
155 if(thing->flags2&MF2_NOTELEPORT)
161 while(P_FindMobjFromTID(tid, &searcher) != NULL)
169 count = 1+(P_Random()%count);
171 for(i = 0; i < count; i++)
173 mo = P_FindMobjFromTID(tid, &searcher);
175 if (!mo) I_Error("Can't find teleport mapspot\n");
176 return P_Teleport(thing, mo->x, mo->y, mo->angle, fog);