-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathp_telept.c
88 lines (80 loc) · 2.57 KB
/
p_telept.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// Copyright (C) 1993-1996 Id Software, Inc.
// Copyright (C) 2023 Frenkel Smeijers
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// P_telept.c
#include "doomdef.h"
#include "p_local.h"
#include "soundst.h"
//==================================================================
//
// TELEPORTATION
//
//==================================================================
void EV_Teleport( line_t *line, int32_t side, mobj_t *thing )
{
int32_t i;
int32_t tag;
mobj_t *m,*fog;
uint32_t an;
thinker_t *thinker;
sector_t *sector;
fixed_t oldx, oldy, oldz;
if (thing->flags & MF_MISSILE)
return; // don't teleport missiles
if (side == 1) // don't teleport if hit back of line,
return; // so you can get out of teleporter
tag = line->tag;
for (i = 0; i < numsectors; i++)
if (sectors[ i ].tag == tag )
{
thinker = thinkercap.next;
for (thinker = thinkercap.next; thinker != &thinkercap;
thinker = thinker->next)
{
if (thinker->function != P_MobjThinker)
continue; // not a mobj
m = (mobj_t *)thinker;
if (m->type != MT_TELEPORTMAN )
continue; // not a teleportman
sector = m->subsector->sector;
if (sector-sectors != i )
continue; // wrong sector
oldx = thing->x;
oldy = thing->y;
oldz = thing->z;
if (!P_TeleportMove (thing, m->x, m->y))
return;
#if (APPVER_DOOMREV != AV_DR_DM19F)
thing->z = thing->floorz; //fixme: not needed?
#endif
if (thing->player)
thing->player->viewz = thing->z+thing->player->viewheight;
// spawn teleport fog at source and destination
fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG);
S_StartSound (fog, sfx_telept);
an = m->angle >> ANGLETOFINESHIFT;
fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an]
, thing->z, MT_TFOG);
S_StartSound (fog, sfx_telept);
if (thing->player)
thing->reactiontime = 18; // don't move for a bit
thing->angle = m->angle;
thing->momx = thing->momy = thing->momz = 0;
return;
}
}
}