-
Notifications
You must be signed in to change notification settings - Fork 5
/
p_telept.pas
184 lines (161 loc) · 4.7 KB
/
p_telept.pas
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//------------------------------------------------------------------------------
//
// FPCDoom - Port of Doom to Free Pascal Compiler
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2004-2007 by Jim Valavanis
// Copyright (C) 2017-2022 by Jim Valavanis
//
// 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
//------------------------------------------------------------------------------
// E-Mail: [email protected]
// Site : https://sourceforge.net/projects/fpcdoom/
//------------------------------------------------------------------------------
{$I FPCDoom.inc}
unit p_telept;
interface
uses
doomdef,
m_fixed,
p_mobj_h,
r_defs;
//==============================================================================
// EV_Teleport
//
// TELEPORTATION
//
//==============================================================================
function EV_Teleport(line: Pline_t; side: integer; thing: Pmobj_t): integer;
const
TELEPORTZOOM = 15 * FRACUNIT;
var
teleporttics: array[-1..MAXPLAYERS - 1] of integer;
useteleportzoomeffect: boolean = true;
implementation
uses
d_fpc,
d_think,
d_player,
info_h,
p_setup,
p_tick,
p_mobj,
p_map,
s_sound,
sounds,
tables;
//==============================================================================
//
// EV_Teleport
//
//==============================================================================
function EV_Teleport(line: Pline_t; side: integer; thing: Pmobj_t): integer;
var
i: integer;
tag: integer;
m: Pmobj_t;
fog: Pmobj_t;
an: LongWord;
thinker: Pthinker_t;
sector: Psector_t;
p: Pplayer_t;
oldx: fixed_t;
oldy: fixed_t;
oldz: fixed_t;
begin
// don't teleport missiles
if thing.flags and MF_MISSILE <> 0 then
begin
result := 0;
exit;
end;
// Don't teleport if hit back of line,
// so you can get out of teleporter.
if side = 1 then
begin
result := 0;
exit;
end;
tag := line.tag;
for i := 0 to numsectors - 1 do
begin
if sectors[i].tag = tag then
begin
thinker := thinkercap.next;
while thinker <> @thinkercap do
begin
// not a mobj
if @thinker._function.acp1 <> @P_MobjThinker then
begin
thinker := thinker.next;
continue;
end;
m := Pmobj_t(thinker);
// not a teleportman
if m._type <> Ord(MT_TELEPORTMAN) then
begin
thinker := thinker.next;
continue;
end;
sector := Psubsector_t(m.subsector).sector;
// wrong sector
if sector <> @sectors[i] then
begin
thinker := thinker.next;
continue;
end;
oldx := thing.x;
oldy := thing.y;
oldz := thing.z;
if not P_TeleportMove(thing, m.x, m.y) then
begin
result := 0;
exit;
end;
thing.z := thing.floorz; //fixme: not needed?
p := Pplayer_t(thing.player);
if p <> nil then
begin
p.viewz := thing.z + p.viewheight;
p.lookupdown := 0; // JVAL Look Up/Down
end;
// spawn teleport fog at source and destination
fog := P_SpawnMobj(oldx, oldy, oldz, Ord(MT_TFOG));
S_StartSound(fog, Ord(sfx_telept));
an := _SHRW(m.angle, ANGLETOFINESHIFT);
fog := P_SpawnMobj(m.x + 20 * finecosine[an],
m.y + 20 * finesine[an],
thing.z, Ord(MT_TFOG));
// emit sound, where?
S_StartSound(fog, Ord(sfx_telept));
// don't move for a bit
if thing.player <> nil then
begin
thing.reactiontime := 18;
teleporttics[PlayerToId(thing.player)] := TELEPORTZOOM;
end;
thing.angle := m.angle;
thing.momx := 0;
thing.momy := 0;
thing.momz := 0;
result := 1;
exit;
end;
end;
end;
result := 0;
end;
end.