1 //
2 // Copyright(C) 1993-1996 Id Software, Inc.
3 // Copyright(C) 2005-2014 Simon Howard
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // DESCRIPTION:  none
16 //	Implements special effects:
17 //	Texture animation, height or lighting changes
18 //	 according to adjacent sectors, respective
19 //	 utility functions, etc.
20 //
21 
22 
23 #ifndef __P_SPEC__
24 #define __P_SPEC__
25 
26 
27 //
28 // End-level timer (-TIMER option)
29 //
30 extern	boolean levelTimer;
31 extern	int	levelTimeCount;
32 
33 
34 //      Define values for map objects
35 #define MO_TELEPORTMAN          14
36 
37 
38 // at game start
39 void    P_InitPicAnims (void);
40 
41 // at map load
42 void    P_SpawnSpecials (void);
43 
44 // every tic
45 void    P_UpdateSpecials (void);
46 
47 // when needed
48 boolean
49 P_UseSpecialLine
50 ( mobj_t*	thing,
51   line_t*	line,
52   int		side );
53 
54 void
55 P_ShootSpecialLine
56 ( mobj_t*	thing,
57   line_t*	line );
58 
59 void
60 P_CrossSpecialLine
61 ( int		linenum,
62   int		side,
63   mobj_t*	thing );
64 
65 void    P_PlayerInSpecialSector (player_t* player);
66 
67 int
68 twoSided
69 ( int		sector,
70   int		line );
71 
72 sector_t*
73 getSector
74 ( int		currentSector,
75   int		line,
76   int		side );
77 
78 side_t*
79 getSide
80 ( int		currentSector,
81   int		line,
82   int		side );
83 
84 fixed_t P_FindLowestFloorSurrounding(sector_t* sec);
85 fixed_t P_FindHighestFloorSurrounding(sector_t* sec);
86 
87 fixed_t
88 P_FindNextHighestFloor
89 ( sector_t*	sec,
90   int		currentheight );
91 
92 fixed_t P_FindLowestCeilingSurrounding(sector_t* sec);
93 fixed_t P_FindHighestCeilingSurrounding(sector_t* sec);
94 
95 int
96 P_FindSectorFromLineTag
97 ( line_t*	line,
98   int		start );
99 
100 int
101 P_FindMinSurroundingLight
102 ( sector_t*	sector,
103   int		max );
104 
105 sector_t*
106 getNextSector
107 ( line_t*	line,
108   sector_t*	sec );
109 
110 
111 //
112 // SPECIAL
113 //
114 int EV_DoDonut(line_t* line);
115 
116 
117 
118 //
119 // P_LIGHTS
120 //
121 typedef struct
122 {
123     thinker_t	thinker;
124     sector_t*	sector;
125     int		count;
126     int		maxlight;
127     int		minlight;
128 
129 } fireflicker_t;
130 
131 
132 
133 typedef struct
134 {
135     thinker_t	thinker;
136     sector_t*	sector;
137     int		count;
138     int		maxlight;
139     int		minlight;
140     int		maxtime;
141     int		mintime;
142 
143 } lightflash_t;
144 
145 
146 
147 typedef struct
148 {
149     thinker_t	thinker;
150     sector_t*	sector;
151     int		count;
152     int		minlight;
153     int		maxlight;
154     int		darktime;
155     int		brighttime;
156 
157 } strobe_t;
158 
159 
160 
161 
162 typedef struct
163 {
164     thinker_t	thinker;
165     sector_t*	sector;
166     int		minlight;
167     int		maxlight;
168     int		direction;
169 
170 } glow_t;
171 
172 
173 #define GLOWSPEED			8
174 #define STROBEBRIGHT		5
175 #define FASTDARK			15
176 #define SLOWDARK			35
177 
178 void    P_SpawnFireFlicker (sector_t* sector);
179 void    T_LightFlash (lightflash_t* flash);
180 void    P_SpawnLightFlash (sector_t* sector);
181 void    T_StrobeFlash (strobe_t* flash);
182 
183 void
184 P_SpawnStrobeFlash
185 ( sector_t*	sector,
186   int		fastOrSlow,
187   int		inSync );
188 
189 void    EV_StartLightStrobing(line_t* line);
190 void    EV_TurnTagLightsOff(line_t* line);
191 
192 void
193 EV_LightTurnOn
194 ( line_t*	line,
195   int		bright );
196 
197 void    T_Glow(glow_t* g);
198 void    P_SpawnGlowingLight(sector_t* sector);
199 
200 
201 
202 
203 //
204 // P_SWITCH
205 //
206 typedef struct
207 {
208     char	name1[9];
209     char	name2[9];
210     short	episode;
211 
212 } switchlist_t;
213 
214 
215 typedef enum
216 {
217     top,
218     middle,
219     bottom
220 
221 } bwhere_e;
222 
223 
224 typedef struct
225 {
226     line_t*	line;
227     bwhere_e	where;
228     int		btexture;
229     int		btimer;
230     degenmobj_t *soundorg;
231 
232 } button_t;
233 
234 
235 
236 
237  // max # of wall switches in a level
238 #define MAXSWITCHES		50
239 
240  // 4 players, 4 buttons each at once, max.
241 #define MAXBUTTONS		16
242 
243  // 1 second, in ticks.
244 #define BUTTONTIME      35
245 
246 extern button_t	buttonlist[MAXBUTTONS];
247 
248 void
249 P_ChangeSwitchTexture
250 ( line_t*	line,
251   int		useAgain );
252 
253 void P_InitSwitchList(void);
254 
255 
256 //
257 // P_PLATS
258 //
259 typedef enum
260 {
261     up,
262     down,
263     waiting,
264     in_stasis
265 
266 } plat_e;
267 
268 
269 
270 typedef enum
271 {
272     perpetualRaise,
273     downWaitUpStay,
274     raiseAndChange,
275     raiseToNearestAndChange,
276     blazeDWUS
277 
278 } plattype_e;
279 
280 
281 
282 typedef struct
283 {
284     thinker_t	thinker;
285     sector_t*	sector;
286     fixed_t	speed;
287     fixed_t	low;
288     fixed_t	high;
289     int		wait;
290     int		count;
291     plat_e	status;
292     plat_e	oldstatus;
293     boolean	crush;
294     int		tag;
295     plattype_e	type;
296 
297 } plat_t;
298 
299 
300 
301 #define PLATWAIT		3
302 #define PLATSPEED		FRACUNIT
303 #define MAXPLATS		30
304 
305 
306 extern plat_t*	activeplats[MAXPLATS];
307 
308 void    T_PlatRaise(plat_t*	plat);
309 
310 int
311 EV_DoPlat
312 ( line_t*	line,
313   plattype_e	type,
314   int		amount );
315 
316 void    P_AddActivePlat(plat_t* plat);
317 void    P_RemoveActivePlat(plat_t* plat);
318 void    EV_StopPlat(line_t* line);
319 void    P_ActivateInStasis(int tag);
320 
321 
322 //
323 // P_DOORS
324 //
325 typedef enum
326 {
327     vld_normal,
328     vld_close30ThenOpen,
329     vld_close,
330     vld_open,
331     vld_raiseIn5Mins,
332     vld_blazeRaise,
333     vld_blazeOpen,
334     vld_blazeClose
335 
336 } vldoor_e;
337 
338 
339 
340 typedef struct
341 {
342     thinker_t	thinker;
343     vldoor_e	type;
344     sector_t*	sector;
345     fixed_t	topheight;
346     fixed_t	speed;
347 
348     // 1 = up, 0 = waiting at top, -1 = down
349     int             direction;
350 
351     // tics to wait at the top
352     int             topwait;
353     // (keep in case a door going down is reset)
354     // when it reaches 0, start going down
355     int             topcountdown;
356 
357 } vldoor_t;
358 
359 
360 
361 #define VDOORSPEED		FRACUNIT*2
362 #define VDOORWAIT		150
363 
364 void
365 EV_VerticalDoor
366 ( line_t*	line,
367   mobj_t*	thing );
368 
369 int
370 EV_DoDoor
371 ( line_t*	line,
372   vldoor_e	type );
373 
374 int
375 EV_DoLockedDoor
376 ( line_t*	line,
377   vldoor_e	type,
378   mobj_t*	thing );
379 
380 void    T_VerticalDoor (vldoor_t* door);
381 void    P_SpawnDoorCloseIn30 (sector_t* sec);
382 
383 void
384 P_SpawnDoorRaiseIn5Mins
385 ( sector_t*	sec,
386   int		secnum );
387 
388 
389 
390 #if 0 // UNUSED
391 //
392 //      Sliding doors...
393 //
394 typedef enum
395 {
396     sd_opening,
397     sd_waiting,
398     sd_closing
399 
400 } sd_e;
401 
402 
403 
404 typedef enum
405 {
406     sdt_openOnly,
407     sdt_closeOnly,
408     sdt_openAndClose
409 
410 } sdt_e;
411 
412 
413 
414 
415 typedef struct
416 {
417     thinker_t	thinker;
418     sdt_e	type;
419     line_t*	line;
420     int		frame;
421     int		whichDoorIndex;
422     int		timer;
423     sector_t*	frontsector;
424     sector_t*	backsector;
425     sd_e	 status;
426 
427 } slidedoor_t;
428 
429 
430 
431 typedef struct
432 {
433     char	frontFrame1[9];
434     char	frontFrame2[9];
435     char	frontFrame3[9];
436     char	frontFrame4[9];
437     char	backFrame1[9];
438     char	backFrame2[9];
439     char	backFrame3[9];
440     char	backFrame4[9];
441 
442 } slidename_t;
443 
444 
445 
446 typedef struct
447 {
448     int             frontFrames[4];
449     int             backFrames[4];
450 
451 } slideframe_t;
452 
453 
454 
455 // how many frames of animation
456 #define SNUMFRAMES		4
457 
458 #define SDOORWAIT		35*3
459 #define SWAITTICS		4
460 
461 // how many diff. types of anims
462 #define MAXSLIDEDOORS	5
463 
464 void P_InitSlidingDoorFrames(void);
465 
466 void
467 EV_SlidingDoor
468 ( line_t*	line,
469   mobj_t*	thing );
470 #endif
471 
472 
473 
474 //
475 // P_CEILNG
476 //
477 typedef enum
478 {
479     lowerToFloor,
480     raiseToHighest,
481     lowerAndCrush,
482     crushAndRaise,
483     fastCrushAndRaise,
484     silentCrushAndRaise
485 
486 } ceiling_e;
487 
488 
489 
490 typedef struct
491 {
492     thinker_t	thinker;
493     ceiling_e	type;
494     sector_t*	sector;
495     fixed_t	bottomheight;
496     fixed_t	topheight;
497     fixed_t	speed;
498     boolean	crush;
499 
500     // 1 = up, 0 = waiting, -1 = down
501     int		direction;
502 
503     // ID
504     int		tag;
505     int		olddirection;
506 
507 } ceiling_t;
508 
509 
510 
511 
512 
513 #define CEILSPEED		FRACUNIT
514 #define CEILWAIT		150
515 #define MAXCEILINGS		30
516 
517 extern ceiling_t*	activeceilings[MAXCEILINGS];
518 
519 int
520 EV_DoCeiling
521 ( line_t*	line,
522   ceiling_e	type );
523 
524 void    T_MoveCeiling (ceiling_t* ceiling);
525 void    P_AddActiveCeiling(ceiling_t* c);
526 void    P_RemoveActiveCeiling(ceiling_t* c);
527 int	EV_CeilingCrushStop(line_t* line);
528 void    P_ActivateInStasisCeiling(line_t* line);
529 
530 
531 //
532 // P_FLOOR
533 //
534 typedef enum
535 {
536     // lower floor to highest surrounding floor
537     lowerFloor,
538 
539     // lower floor to lowest surrounding floor
540     lowerFloorToLowest,
541 
542     // lower floor to highest surrounding floor VERY FAST
543     turboLower,
544 
545     // raise floor to lowest surrounding CEILING
546     raiseFloor,
547 
548     // raise floor to next highest surrounding floor
549     raiseFloorToNearest,
550 
551     // raise floor to shortest height texture around it
552     raiseToTexture,
553 
554     // lower floor to lowest surrounding floor
555     //  and change floorpic
556     lowerAndChange,
557 
558     raiseFloor24,
559     raiseFloor24AndChange,
560     raiseFloorCrush,
561 
562      // raise to next highest floor, turbo-speed
563     raiseFloorTurbo,
564     donutRaise,
565     raiseFloor512
566 
567 } floor_e;
568 
569 
570 
571 
572 typedef enum
573 {
574     build8,	// slowly build by 8
575     turbo16	// quickly build by 16
576 
577 } stair_e;
578 
579 
580 
581 typedef struct
582 {
583     thinker_t	thinker;
584     floor_e	type;
585     boolean	crush;
586     sector_t*	sector;
587     int		direction;
588     int		newspecial;
589     short	texture;
590     fixed_t	floordestheight;
591     fixed_t	speed;
592 
593 } floormove_t;
594 
595 
596 
597 #define FLOORSPEED		FRACUNIT
598 
599 typedef enum
600 {
601     ok,
602     crushed,
603     pastdest
604 
605 } result_e;
606 
607 result_e
608 T_MovePlane
609 ( sector_t*	sector,
610   fixed_t	speed,
611   fixed_t	dest,
612   boolean	crush,
613   int		floorOrCeiling,
614   int		direction );
615 
616 int
617 EV_BuildStairs
618 ( line_t*	line,
619   stair_e	type );
620 
621 int
622 EV_DoFloor
623 ( line_t*	line,
624   floor_e	floortype );
625 
626 void T_MoveFloor( floormove_t* floor);
627 
628 //
629 // P_TELEPT
630 //
631 int
632 EV_Teleport
633 ( line_t*	line,
634   int		side,
635   mobj_t*	thing );
636 
637 #endif
638