]> git.lizzy.rs Git - plan9front.git/blob - sys/src/games/doom/p_spec.h
bring games/swar from 1ed sources.
[plan9front.git] / sys / src / games / doom / p_spec.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:  none
18 //      Implements special effects:
19 //      Texture animation, height or lighting changes
20 //       according to adjacent sectors, respective
21 //       utility functions, etc.
22 //
23 //-----------------------------------------------------------------------------
24
25
26 #ifndef __P_SPEC__
27 #define __P_SPEC__
28
29
30 //
31 // End-level timer (-TIMER option)
32 //
33 extern  boolean levelTimer;
34 extern  int     levelTimeCount;
35
36
37 //      Define values for map objects
38 #define MO_TELEPORTMAN          14
39
40
41 // at game start
42 void    P_InitPicAnims (void);
43
44 // at map load
45 void    P_SpawnSpecials (void);
46
47 // every tic
48 void    P_UpdateSpecials (void);
49
50 // when needed
51 boolean
52 P_UseSpecialLine
53 ( mobj_t*       thing,
54   line_t*       line,
55   int           side );
56
57 void
58 P_ShootSpecialLine
59 ( mobj_t*       thing,
60   line_t*       line );
61
62 void
63 P_CrossSpecialLine
64 ( int           linenum,
65   int           side,
66   mobj_t*       thing );
67
68 void    P_PlayerInSpecialSector (player_t* player);
69
70 int
71 twoSided
72 ( int           sector,
73   int           line );
74
75 sector_t*
76 getSector
77 ( int           currentSector,
78   int           line,
79   int           side );
80
81 side_t*
82 getSide
83 ( int           currentSector,
84   int           line,
85   int           side );
86
87 fixed_t P_FindLowestFloorSurrounding(sector_t* sec);
88 fixed_t P_FindHighestFloorSurrounding(sector_t* sec);
89
90 fixed_t
91 P_FindNextHighestFloor
92 ( sector_t*     sec,
93   int           currentheight );
94
95 fixed_t P_FindLowestCeilingSurrounding(sector_t* sec);
96 fixed_t P_FindHighestCeilingSurrounding(sector_t* sec);
97
98 int
99 P_FindSectorFromLineTag
100 ( line_t*       line,
101   int           start );
102
103 int
104 P_FindMinSurroundingLight
105 ( sector_t*     sector,
106   int           max );
107
108 sector_t*
109 getNextSector
110 ( line_t*       line,
111   sector_t*     sec );
112
113
114 //
115 // SPECIAL
116 //
117 int EV_DoDonut(line_t* line);
118
119
120
121 //
122 // P_LIGHTS
123 //
124 typedef struct
125 {
126     thinker_t   thinker;
127     sector_t*   sector;
128     int         count;
129     int         maxlight;
130     int         minlight;
131     
132 } fireflicker_t;
133
134
135
136 typedef struct
137 {
138     thinker_t   thinker;
139     sector_t*   sector;
140     int         count;
141     int         maxlight;
142     int         minlight;
143     int         maxtime;
144     int         mintime;
145     
146 } lightflash_t;
147
148
149
150 typedef struct
151 {
152     thinker_t   thinker;
153     sector_t*   sector;
154     int         count;
155     int         minlight;
156     int         maxlight;
157     int         darktime;
158     int         brighttime;
159     
160 } strobe_t;
161
162
163
164
165 typedef struct
166 {
167     thinker_t   thinker;
168     sector_t*   sector;
169     int         minlight;
170     int         maxlight;
171     int         direction;
172
173 } glow_t;
174
175
176 #define GLOWSPEED                       8
177 #define STROBEBRIGHT            5
178 #define FASTDARK                        15
179 #define SLOWDARK                        35
180
181 void    P_SpawnFireFlicker (sector_t* sector);
182 void    T_LightFlash (void* flash, void*);
183 void    P_SpawnLightFlash (sector_t* sector);
184 void    T_StrobeFlash (void* flash, void*);
185
186 void
187 P_SpawnStrobeFlash
188 ( sector_t*     sector,
189   int           fastOrSlow,
190   int           inSync );
191
192 void    EV_StartLightStrobing(line_t* line);
193 void    EV_TurnTagLightsOff(line_t* line);
194
195 void
196 EV_LightTurnOn
197 ( line_t*       line,
198   int           bright );
199
200 void    T_Glow(void *g, void*);
201 void    P_SpawnGlowingLight(sector_t* sector);
202
203
204
205
206 //
207 // P_SWITCH
208 //
209 typedef struct
210 {
211     char        name1[9];
212     char        name2[9];
213     short       episode;
214     
215 } switchlist_t;
216
217
218 typedef enum
219 {
220     top,
221     middle,
222     bottom
223
224 } bwhere_e;
225
226
227 typedef struct
228 {
229     line_t*     line;
230     bwhere_e    where;
231     int         btexture;
232     int         btimer;
233     mobj_t*     soundorg;
234
235 } button_t;
236
237
238
239
240  // max # of wall switches in a level
241 #define MAXSWITCHES             50
242
243  // 4 players, 4 buttons each at once, max.
244 #define MAXBUTTONS              16
245
246  // 1 second, in ticks. 
247 #define BUTTONTIME      35             
248
249 extern button_t buttonlist[MAXBUTTONS]; 
250
251 void
252 P_ChangeSwitchTexture
253 ( line_t*       line,
254   int           useAgain );
255
256 void P_InitSwitchList(void);
257
258
259 //
260 // P_PLATS
261 //
262 typedef enum
263 {
264     up,
265     down,
266     waiting,
267     in_stasis
268
269 } plat_e;
270
271
272
273 typedef enum
274 {
275     perpetualRaise,
276     downWaitUpStay,
277     raiseAndChange,
278     raiseToNearestAndChange,
279     blazeDWUS
280
281 } plattype_e;
282
283
284
285 typedef struct
286 {
287     thinker_t   thinker;
288     sector_t*   sector;
289     fixed_t     speed;
290     fixed_t     low;
291     fixed_t     high;
292     int         wait;
293     int         count;
294     plat_e      status;
295     plat_e      oldstatus;
296     boolean     crush;
297     int         tag;
298     plattype_e  type;
299     
300 } plat_t;
301
302
303
304 #define PLATWAIT                3
305 #define PLATSPEED               FRACUNIT
306 #define MAXPLATS                30
307
308
309 extern plat_t*  activeplats[MAXPLATS];
310
311 void    T_PlatRaise(void *plat, void*);
312
313 int
314 EV_DoPlat
315 ( line_t*       line,
316   plattype_e    type,
317   int           amount );
318
319 void    P_AddActivePlat(plat_t* plat);
320 void    P_RemoveActivePlat(plat_t* plat);
321 void    EV_StopPlat(line_t* line);
322 void    P_ActivateInStasis(int tag);
323
324
325 //
326 // P_DOORS
327 //
328 typedef enum
329 {
330     Normal,
331     Close30ThenOpen,
332     Close,
333     Open,
334     RaiseIn5Mins,
335     BlazeRaise,
336     BlazeOpen,
337     BlazeClose
338
339 } vldoor_e;
340
341
342
343 typedef struct
344 {
345     thinker_t   thinker;
346     vldoor_e    type;
347     sector_t*   sector;
348     fixed_t     topheight;
349     fixed_t     speed;
350
351     // 1 = up, 0 = waiting at top, -1 = down
352     int             direction;
353     
354     // tics to wait at the top
355     int             topwait;
356     // (keep in case a door going down is reset)
357     // when it reaches 0, start going down
358     int             topcountdown;
359     
360 } vldoor_t;
361
362
363
364 #define VDOORSPEED              FRACUNIT*2
365 #define VDOORWAIT               150
366
367 void
368 EV_VerticalDoor
369 ( line_t*       line,
370   mobj_t*       thing );
371
372 int
373 EV_DoDoor
374 ( line_t*       line,
375   vldoor_e      type );
376
377 int
378 EV_DoLockedDoor
379 ( line_t*       line,
380   vldoor_e      type,
381   mobj_t*       thing );
382
383 void    T_VerticalDoor (void *door, void*);
384 void    P_SpawnDoorCloseIn30 (sector_t* sec);
385
386 void
387 P_SpawnDoorRaiseIn5Mins
388 ( sector_t*     sec );
389
390
391 //
392 // P_CEILNG
393 //
394 typedef enum
395 {
396     lowerToFloor,
397     raiseToHighest,
398     lowerAndCrush,
399     crushAndRaise,
400     fastCrushAndRaise,
401     silentCrushAndRaise
402
403 } ceiling_e;
404
405
406
407 typedef struct
408 {
409     thinker_t   thinker;
410     ceiling_e   type;
411     sector_t*   sector;
412     fixed_t     bottomheight;
413     fixed_t     topheight;
414     fixed_t     speed;
415     boolean     crush;
416
417     // 1 = up, 0 = waiting, -1 = down
418     int         direction;
419
420     // ID
421     int         tag;                   
422     int         olddirection;
423     
424 } ceiling_t;
425
426
427
428
429
430 #define CEILSPEED               FRACUNIT
431 #define CEILWAIT                150
432 #define MAXCEILINGS             30
433
434 extern ceiling_t*       activeceilings[MAXCEILINGS];
435
436 int
437 EV_DoCeiling
438 ( line_t*       line,
439   ceiling_e     type );
440
441 void    T_MoveCeiling (void*, void*);
442 void    P_AddActiveCeiling(ceiling_t* c);
443 void    P_RemoveActiveCeiling(ceiling_t* c);
444 int     EV_CeilingCrushStop(line_t* line);
445 void    P_ActivateInStasisCeiling(line_t* line);
446
447
448 //
449 // P_FLOOR
450 //
451 typedef enum
452 {
453     // lower floor to highest surrounding floor
454     lowerFloor,
455     
456     // lower floor to lowest surrounding floor
457     lowerFloorToLowest,
458     
459     // lower floor to highest surrounding floor VERY FAST
460     turboLower,
461     
462     // raise floor to lowest surrounding CEILING
463     raiseFloor,
464     
465     // raise floor to next highest surrounding floor
466     raiseFloorToNearest,
467
468     // raise floor to shortest height texture around it
469     raiseToTexture,
470     
471     // lower floor to lowest surrounding floor
472     //  and change floorpic
473     lowerAndChange,
474   
475     raiseFloor24,
476     raiseFloor24AndChange,
477     raiseFloorCrush,
478
479      // raise to next highest floor, turbo-speed
480     raiseFloorTurbo,       
481     donutRaise,
482     raiseFloor512
483     
484 } floor_e;
485
486
487
488
489 typedef enum
490 {
491     build8,     // slowly build by 8
492     turbo16     // quickly build by 16
493     
494 } stair_e;
495
496
497
498 typedef struct
499 {
500     thinker_t   thinker;
501     floor_e     type;
502     boolean     crush;
503     sector_t*   sector;
504     int         direction;
505     int         newspecial;
506     short       texture;
507     fixed_t     floordestheight;
508     fixed_t     speed;
509
510 } floormove_t;
511
512
513
514 #define FLOORSPEED              FRACUNIT
515
516 typedef enum
517 {
518     ok,
519     crushed,
520     pastdest
521     
522 } result_e;
523
524 result_e
525 T_MovePlane
526 ( sector_t*     sector,
527   fixed_t       speed,
528   fixed_t       dest,
529   boolean       crush,
530   int           floorOrCeiling,
531   int           direction );
532
533 int
534 EV_BuildStairs
535 ( line_t*       line,
536   stair_e       type );
537
538 int
539 EV_DoFloor
540 ( line_t*       line,
541   floor_e       floortype );
542
543 void T_MoveFloor(void *floor, void*);
544
545 //
546 // P_TELEPT
547 //
548 int
549 EV_Teleport
550 ( line_t*       line,
551   int           side,
552   mobj_t*       thing );
553
554 #endif
555 //-----------------------------------------------------------------------------
556 //
557 // $Log:$
558 //
559 //-----------------------------------------------------------------------------