]> git.lizzy.rs Git - plan9front.git/blob - sys/src/games/doom/p_local.h
games/doom: fix unterminated comment causing sound bugs (from qu7uux)
[plan9front.git] / sys / src / games / doom / p_local.h
1 // Emacs style mode select   -*- C++ -*- 
2 //-----------------------------------------------------------------------------
3 //
4 // $Id:$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
11 //
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15 // for more details.
16 //
17 // DESCRIPTION:
18 //      Play functions, animation, global header.
19 //
20 //-----------------------------------------------------------------------------
21
22
23 #ifndef __P_LOCAL__
24 #define __P_LOCAL__
25
26 #ifndef __R_LOCAL__
27 #include "r_local.h"
28 #endif
29
30 #define FLOATSPEED              (FRACUNIT*4)
31
32
33 #define MAXHEALTH               100
34 #define VIEWHEIGHT              (41*FRACUNIT)
35
36 // mapblocks are used to check movement
37 // against lines and things
38 #define MAPBLOCKUNITS   128
39 #define MAPBLOCKSIZE    (MAPBLOCKUNITS*FRACUNIT)
40 #define MAPBLOCKSHIFT   (FRACBITS+7)
41 #define MAPBMASK                (MAPBLOCKSIZE-1)
42 #define MAPBTOFRAC              (MAPBLOCKSHIFT-FRACBITS)
43
44
45 // player radius for movement checking
46 #define PLAYERRADIUS    16*FRACUNIT
47
48 // MAXRADIUS is for precalculated sector block boxes
49 // the spider demon is larger,
50 // but we do not have any moving sectors nearby
51 #define MAXRADIUS               32*FRACUNIT
52
53 #define GRAVITY         FRACUNIT
54 #define MAXMOVE         (30*FRACUNIT)
55
56 #define USERANGE                (64*FRACUNIT)
57 #define MELEERANGE              (64*FRACUNIT)
58 #define MISSILERANGE    (32*64*FRACUNIT)
59
60 // follow a player exlusively for 3 seconds
61 #define BASETHRESHOLD           100
62
63 extern  boolean noztele;
64 extern  boolean nobounce;
65
66
67 //
68 // P_TICK
69 //
70
71 // both the head and tail of the thinker list
72 extern  thinker_t       thinkercap;     
73
74
75 void P_InitThinkers (void);
76 void P_AddThinker (thinker_t* thinker);
77 void P_RemoveThinker (thinker_t* thinker);
78
79
80 //
81 // P_PSPR
82 //
83 void P_SetupPsprites (player_t* curplayer);
84 void P_MovePsprites (player_t* curplayer);
85 void P_DropWeapon (player_t* player);
86
87
88 //
89 // P_USER
90 //
91 void    P_PlayerThink (player_t* player);
92
93
94 //
95 // P_MOBJ
96 //
97 #define ONFLOORZ                MININT
98 #define ONCEILINGZ              MAXINT
99
100 // Time interval for item respawning.
101 #define ITEMQUESIZE             128
102
103 extern mapthing_t       itemrespawnque[ITEMQUESIZE];
104 extern int              itemrespawntime[ITEMQUESIZE];
105 extern int              iquehead;
106 extern int              iquetail;
107
108
109 void P_RespawnSpecials (void);
110
111 mobj_t*
112 P_SpawnMobj
113 ( fixed_t       x,
114   fixed_t       y,
115   fixed_t       z,
116   mobjtype_t    type );
117
118 void    P_RemoveMobj (mobj_t* th);
119 boolean P_SetMobjState (mobj_t* mobj, statenum_t state);
120 void    P_MobjThinker (void *mobj, void*);
121
122 void    P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z);
123 void    P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage);
124 mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type);
125 void    P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type);
126
127
128 //
129 // P_ENEMY
130 //
131 void P_NoiseAlert (mobj_t* target, mobj_t* emmiter);
132
133
134 //
135 // P_MAPUTL
136 //
137 typedef struct
138 {
139     fixed_t     x;
140     fixed_t     y;
141     fixed_t     dx;
142     fixed_t     dy;
143     
144 } divline_t;
145
146 typedef struct
147 {
148     fixed_t     frac;           // along trace line
149     boolean     isaline;
150     union {
151         mobj_t* thing;
152         line_t* line;
153     }                   d;
154 } intercept_t;
155
156 #define MAXINTERCEPTS   128
157
158 extern intercept_t      intercepts[MAXINTERCEPTS];
159 extern intercept_t*     intercept_p;
160
161 typedef boolean (*traverser_t) (intercept_t *in);
162
163 fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
164 int     P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line);
165 int     P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t* line);
166 void    P_MakeDivline (line_t* li, divline_t* dl);
167 fixed_t P_InterceptVector (divline_t* v2, divline_t* v1);
168 int     P_BoxOnLineSide (fixed_t* tmbox, line_t* ld);
169
170 extern fixed_t          opentop;
171 extern fixed_t          openbottom;
172 extern fixed_t          openrange;
173 extern fixed_t          lowfloor;
174
175 void    P_LineOpening (line_t* linedef);
176
177 boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) );
178 boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) );
179
180 #define PT_ADDLINES             1
181 #define PT_ADDTHINGS    2
182 #define PT_EARLYOUT             4
183
184 extern divline_t        trace;
185
186 boolean
187 P_PathTraverse
188 ( fixed_t       x1,
189   fixed_t       y1,
190   fixed_t       x2,
191   fixed_t       y2,
192   int           flags,
193   boolean       (*trav) (intercept_t *));
194
195 void P_UnsetThingPosition (mobj_t* thing);
196 void P_SetThingPosition (mobj_t* thing);
197
198
199 //
200 // P_MAP
201 //
202
203 // If "floatok" true, move would be ok
204 // if within "tmfloorz - tmceilingz".
205 extern boolean          floatok;
206 extern fixed_t          tmfloorz;
207 extern fixed_t          tmceilingz;
208
209
210 extern  line_t*         ceilingline;
211
212 boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y);
213 boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y);
214 boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y);
215 void    P_SlideMove (mobj_t* mo);
216 boolean P_CheckSight (mobj_t* t1, mobj_t* t2);
217 void    P_UseLines (player_t* player);
218
219 boolean P_ChangeSector (sector_t* sector, boolean crunch);
220
221 extern mobj_t*  linetarget;     // who got hit (or NULL)
222
223 fixed_t
224 P_AimLineAttack
225 ( mobj_t*       t1,
226   angle_t       angle,
227   fixed_t       distance );
228
229 void
230 P_LineAttack
231 ( mobj_t*       t1,
232   angle_t       angle,
233   fixed_t       distance,
234   fixed_t       slope,
235   int           damage );
236
237 void
238 P_RadiusAttack
239 ( mobj_t*       spot,
240   mobj_t*       source,
241   int           damage );
242
243
244
245 //
246 // P_SETUP
247 //
248 extern byte*            rejectmatrix;   // for fast sight rejection
249 extern short*           blockmaplump;   // offsets in blockmap are from here
250 extern short*           blockmap;
251 extern int              bmapwidth;
252 extern int              bmapheight;     // in mapblocks
253 extern fixed_t          bmaporgx;
254 extern fixed_t          bmaporgy;       // origin of block map
255 extern mobj_t**         blocklinks;     // for thing chains
256
257
258
259 //
260 // P_INTER
261 //
262 extern int              maxammo[NUMAMMO];
263 extern int              clipammo[NUMAMMO];
264
265 void
266 P_TouchSpecialThing
267 ( mobj_t*       special,
268   mobj_t*       toucher );
269
270 void
271 P_DamageMobj
272 ( mobj_t*       target,
273   mobj_t*       inflictor,
274   mobj_t*       source,
275   int           damage );
276
277
278 //
279 // P_SPEC
280 //
281 #include "p_spec.h"
282
283
284 #endif  // __P_LOCAL__
285 //-----------------------------------------------------------------------------
286 //
287 // $Log:$
288 //
289 //-----------------------------------------------------------------------------
290
291