-
Notifications
You must be signed in to change notification settings - Fork 5
/
d_player.pas
261 lines (213 loc) · 6.71 KB
/
d_player.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
//------------------------------------------------------------------------------
//
// 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 d_player;
interface
uses
// The player data structure depends on a number
// of other structs: items (internal inventory),
// animation states (closely tied to the sprites
// used to represent them, unfortunately).
p_pspr_h,
// In addition, the player is just a special
// case of the generic moving object/actor.
p_mobj_h,
// Finally, for odd reasons, the player input
// is buffered within the player data struct,
// as commands per game tick.
d_ticcmd,
m_fixed, doomdef;
//
// Player states.
//
type
playerstate_t = (
// Playing or camping.
PST_LIVE,
// Dead on the ground, view follows killer.
PST_DEAD,
// Ready to restart/respawn???
PST_REBORN);
//
// Player internal flags, for cheats and debug.
//
const
// No clipping, walk through barriers.
CF_NOCLIP = 1;
// No damage, no health loss.
CF_GODMODE = 2;
// Not really a cheat, just a debug aid.
CF_NOMOMENTUM = 4;
// Low gravity cheat
CF_LOWGRAVITY = 8;
type
//
// Extended player object info: player_t
//
player_t = record
mo: Pmobj_t;
playerstate: playerstate_t;
cmd: ticcmd_t;
// Determine POV,
// including viewpoint bobbing during movement.
// Focal origin above r.z
viewz: fixed_t;
// Base height above floor for viewz.
viewheight: fixed_t;
// Bob/squat speed.
deltaviewheight: fixed_t;
// bounded/scaled total momentum.
bob: fixed_t;
// Look UP/DOWN support
lookupdown: integer; // JVAL Look Up/Down
centering: boolean;
// Look LEFT/RIGHT support
lookleftright: byte;
oldlook2: integer;
forwarding: boolean;
// jump
oldjump: integer;
// This is only used between levels,
// mo->health is used during levels.
health: integer;
armorpoints: integer;
// Armor type is 0-2.
armortype: integer;
// Power ups. invinc and invis are tic counters.
powers: array[0..Ord(NUMPOWERS) - 1] of integer;
cards: array[0..Ord(NUMCARDS) - 1] of boolean;
backpack: boolean;
// Frags, kills of other players.
frags: array[0..MAXPLAYERS - 1] of integer;
readyweapon: weapontype_t;
// Is wp_nochange if not changing.
pendingweapon: weapontype_t;
weaponowned: array[0..Ord(NUMWEAPONS) - 1] of integer;
ammo: array[0..Ord(NUMAMMO) - 1] of integer;
maxammo: array[0..Ord(NUMAMMO) - 1] of integer;
// True if button down last tic.
attackdown: boolean;
usedown: boolean;
// Bit flags, for cheats and debug.
// See cheat_t, above.
cheats: integer;
// Refired shots are less accurate.
refire: integer;
// For intermission stats.
killcount: integer;
itemcount: integer;
secretcount: integer;
// Hint messages.
_message: string[255];
// For screen flashing (red or bright).
damagecount: integer;
bonuscount: integer;
// Who did damage (NULL for floors/ceilings).
attacker: Pmobj_t;
// So gun flashes light up areas.
extralight: integer;
// Current PLAYPAL, ???
// can be set to REDCOLORMAP for pain, etc.
fixedcolormap: integer;
// Player skin colorshift,
// 0-3 for which color to draw player.
colormap: integer;
// Overlay view sprites (gun, etc).
psprites: array[0..Ord(NUMPSPRITES) - 1] of pspdef_t;
// True if secret level has been done.
didsecret: boolean;
attackerx: fixed_t;
attackery: fixed_t;
end;
Pplayer_t = ^player_t;
//
// INTERMISSION
// Structure passed e.g. to WI_Start(wb)
//
wbplayerstruct_t = record
_in: boolean; // whether the player is in game
// Player stats, kills, collected items etc.
skills: integer;
sitems: integer;
ssecret: integer;
stime: integer;
frags: array[0..3] of integer;
score: integer; // current score on entry, modified on return
end;
Pwbplayerstruct_t = ^wbplayerstruct_t;
wbplayerstruct_tArray = packed array[0..$FFFF] of wbplayerstruct_t;
Pwbplayerstruct_tArray = ^wbplayerstruct_tArray;
wbstartstruct_t = record
epsd: integer; // episode # (0-2)
// if true, splash the secret level
didsecret: boolean;
// previous and next levels, origin 0
last: integer;
next: integer;
maxkills: integer;
maxitems: integer;
maxsecret: integer;
maxfrags: integer;
// the par time
partime: integer;
// index of this player in game
pnum: integer;
plyr: array[0..MAXPLAYERS - 1] of wbplayerstruct_t;
end;
Pwbstartstruct_t = ^wbstartstruct_t;
var
// JVAL -> moved from g_game
players: array[0..MAXPLAYERS - 1] of player_t;
// JVAL Min and Max values for player.lookdir
const
MINLOOKDIR = -110;
MAXLOOKDIR = 90;
//==============================================================================
//
// PlayerToId
//
//==============================================================================
function PlayerToId(const p: Pplayer_t): integer;
implementation
//==============================================================================
//
// PlayerToId
//
//==============================================================================
function PlayerToId(const p: Pplayer_t): integer;
var
i: integer;
begin
for i := 0 to MAXPLAYERS - 1 do
if p = @players[i] then
begin
result := i;
exit;
end;
result := -1;
end;
end.