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 // villsa [STRIFE]
42 typedef enum
43 {
44     FLOOR_WATER = 0,
45     FLOOR_SLIME = 1,
46     FLOOR_SOLID = 2,
47     FLOOR_END   = -1
48 } terraintype_e;
49 
50 void P_InitTerrainTypes(void);                  // villsa [STRIFE]
51 terraintype_e P_GetTerrainType(mobj_t* mobj);   // villsa [STRIFE]
52 
53 // at map load
54 void    P_SpawnSpecials (void);
55 
56 // every tic
57 void    P_UpdateSpecials (void);
58 
59 // when needed
60 boolean
61 P_UseSpecialLine
62 ( mobj_t*	thing,
63   line_t*	line,
64   int		side );
65 
66 void
67 P_ShootSpecialLine
68 ( mobj_t*	thing,
69   line_t*	line );
70 
71 void
72 P_CrossSpecialLine
73 ( int		linenum,
74   int		side,
75   mobj_t*	thing );
76 
77 void    P_PlayerInSpecialSector (player_t* player);
78 
79 int
80 twoSided
81 ( int		sector,
82   int		line );
83 
84 sector_t*
85 getSector
86 ( int		currentSector,
87   int		line,
88   int		side );
89 
90 side_t*
91 getSide
92 ( int		currentSector,
93   int		line,
94   int		side );
95 
96 fixed_t P_FindLowestFloorSurrounding(sector_t* sec);
97 fixed_t P_FindHighestFloorSurrounding(sector_t* sec);
98 
99 fixed_t
100 P_FindNextHighestFloor
101 ( sector_t*	sec,
102   int		currentheight );
103 
104 fixed_t P_FindLowestCeilingSurrounding(sector_t* sec);
105 fixed_t P_FindHighestCeilingSurrounding(sector_t* sec);
106 
107 int
108 P_FindSectorFromLineTag
109 ( line_t*	line,
110   int		start );
111 
112 int
113 P_FindMinSurroundingLight
114 ( sector_t*	sector,
115   int		max );
116 
117 sector_t*
118 getNextSector
119 ( line_t*	line,
120   sector_t*	sec );
121 
122 
123 //
124 // SPECIAL
125 //
126 int     EV_DoDonut(line_t* line);
127 boolean EV_ClearForceFields(line_t* line);  // villsa [STRIFE]
128 
129 
130 //
131 // P_LIGHTS
132 //
133 typedef struct
134 {
135     thinker_t	thinker;
136     sector_t*	sector;
137     int		count;
138     int		maxlight;
139     int		minlight;
140 
141 } fireflicker_t;
142 
143 
144 
145 typedef struct
146 {
147     thinker_t	thinker;
148     sector_t*	sector;
149     int		count;
150     int		maxlight;
151     int		minlight;
152     int		maxtime;
153     int		mintime;
154 
155 } lightflash_t;
156 
157 
158 
159 typedef struct
160 {
161     thinker_t	thinker;
162     sector_t*	sector;
163     int		count;
164     int		minlight;
165     int		maxlight;
166     int		darktime;
167     int		brighttime;
168 
169 } strobe_t;
170 
171 
172 
173 
174 typedef struct
175 {
176     thinker_t	thinker;
177     sector_t*	sector;
178     int		minlight;
179     int		maxlight;
180     int		direction;
181 
182 } glow_t;
183 
184 
185 #define GLOWSPEED			8
186 #define STROBEBRIGHT		5
187 #define FASTDARK			15
188 #define SLOWDARK			35
189 
190 void    P_SpawnFireFlicker (sector_t* sector);
191 void    T_LightFlash (lightflash_t* flash);
192 void    P_SpawnLightFlash (sector_t* sector);
193 void    T_StrobeFlash (strobe_t* flash);
194 
195 void
196 P_SpawnStrobeFlash
197 ( sector_t*	sector,
198   int		fastOrSlow,
199   int		inSync );
200 
201 void    EV_StartLightStrobing(line_t* line);
202 void    EV_TurnTagLightsOff(line_t* line);
203 
204 void
205 EV_LightTurnOn
206 ( line_t*	line,
207   int		bright );
208 
209 void    T_Glow(glow_t* g);
210 void    P_SpawnGlowingLight(sector_t* sector);
211 
212 
213 
214 
215 //
216 // P_SWITCH
217 //
218 typedef struct
219 {
220     char	name1[9];
221     char	name2[9];
222     short	episode;
223     int         sound;  // villsa [STRIFE]
224 
225 } switchlist_t;
226 
227 
228 typedef enum
229 {
230     top,
231     middle,
232     bottom
233 
234 } bwhere_e;
235 
236 
237 typedef struct
238 {
239     line_t*	line;
240     bwhere_e	where;
241     int		btexture;
242     int		btimer;
243     degenmobj_t *soundorg;
244 
245 } button_t;
246 
247 
248 
249 
250  // max # of wall switches in a level
251 #define MAXSWITCHES		80  // villsa [STRIFE] changed from 50 to 80
252 
253  // 4 players, 4 buttons each at once, max.
254 #define MAXBUTTONS		16
255 
256  // 1 second, in ticks.
257 #define BUTTONTIME      35
258 
259 extern button_t	buttonlist[MAXBUTTONS];
260 
261 void
262 P_ChangeSwitchTexture
263 ( line_t*	line,
264   int		useAgain );
265 
266 void P_InitSwitchList(void);
267 
268 
269 //
270 // P_PLATS
271 //
272 typedef enum
273 {
274     up,
275     down,
276     waiting,
277     in_stasis
278 
279 } plat_e;
280 
281 
282 
283 typedef enum
284 {
285     perpetualRaise,
286     downWaitUpStay,
287     slowDWUS,           // villsa [STRIFE]
288     raiseAndChange,
289     raiseToNearestAndChange,
290     blazeDWUS,
291     upWaitDownStay      // villsa [STRIFE]
292 
293 } plattype_e;
294 
295 
296 
297 typedef struct
298 {
299     thinker_t	thinker;
300     sector_t*	sector;
301     fixed_t	speed;
302     fixed_t	low;
303     fixed_t	high;
304     int		wait;
305     int		count;
306     plat_e	status;
307     plat_e	oldstatus;
308     boolean	crush;
309     int		tag;
310     plattype_e	type;
311 
312 } plat_t;
313 
314 
315 
316 #define PLATWAIT		3
317 #define PLATSPEED		FRACUNIT
318 #define MAXPLATS		30
319 
320 
321 extern plat_t*	activeplats[MAXPLATS];
322 
323 void    T_PlatRaise(plat_t*	plat);
324 
325 int
326 EV_DoPlat
327 ( line_t*	line,
328   plattype_e	type,
329   int		amount );
330 
331 void    P_AddActivePlat(plat_t* plat);
332 void    P_RemoveActivePlat(plat_t* plat);
333 void    EV_StopPlat(line_t* line);
334 void    P_ActivateInStasis(int tag);
335 
336 
337 //
338 // P_DOORS
339 //
340 typedef enum
341 {
342     vld_normal,
343     vld_close30ThenOpen,
344     vld_close,
345     vld_open,
346     vld_raiseIn5Mins,
347     vld_blazeRaise,
348     vld_blazeOpen,
349     vld_blazeClose,
350     vld_shopClose,          // villsa [STRIFE]
351     vld_splitRaiseNearest,  // villsa [STRIFE]
352     vld_splitOpen           // villsa [STRIFE]
353 
354 } vldoor_e;
355 
356 
357 
358 typedef struct
359 {
360     thinker_t   thinker;
361     vldoor_e    type;
362     sector_t*   sector;
363     fixed_t     topheight;
364     fixed_t     speed;
365 
366     // 1 = up, 0 = waiting at top, -1 = down
367     int         direction;
368 
369     // tics to wait at the top
370     int         topwait;
371     // (keep in case a door going down is reset)
372     // when it reaches 0, start going down
373     int         topcountdown;
374 
375     // villsa [STRIFE] new field - sound to play when opening
376     int         opensound;
377 
378     // villsa [STRIFE] new field - sound to play when closing
379     int         closesound;
380 
381 } vldoor_t;
382 
383 
384 
385 #define VDOORSPEED		FRACUNIT*2
386 #define VDOORWAIT		150
387 
388 void
389 EV_VerticalDoor
390 ( line_t*	line,
391   mobj_t*	thing );
392 
393 int
394 EV_DoDoor
395 ( line_t*	line,
396   vldoor_e	type );
397 
398 int
399 EV_DoLockedDoor
400 ( line_t*	line,
401   vldoor_e	type,
402   mobj_t*	thing );
403 
404 void    T_VerticalDoor (vldoor_t* door);
405 void    P_SpawnDoorCloseIn30 (sector_t* sec);
406 
407 void
408 P_SpawnDoorRaiseIn5Mins
409 ( sector_t*	sec,
410   int		secnum );
411 
412 
413 
414 // villsa [STRIFE] resurrected sliding doors
415 //
416 //      Sliding doors...
417 //
418 typedef enum
419 {
420     sd_opening,
421     sd_waiting,
422     sd_closing
423 
424 } sd_e;
425 
426 
427 
428 typedef enum
429 {
430     sdt_openOnly,
431     sdt_closeOnly,
432     sdt_openAndClose
433 
434 } sdt_e;
435 
436 
437 
438 // villsa [STRIFE] Rogue added a second line_t in the struct
439 // backsector is removed
440 typedef struct
441 {
442     thinker_t   thinker;
443     sdt_e       type;
444     line_t*     line1;
445     line_t*     line2;
446     int         frame;
447     int         whichDoorIndex;
448     int         timer;
449     sector_t*   frontsector;
450     sd_e        status;
451 
452 } slidedoor_t;
453 
454 // villsa [STRIFE] no front/back frames
455 typedef struct
456 {
457     char    frame1[9];
458     char    frame2[9];
459     char    frame3[9];
460     char    frame4[9];
461     char    frame5[9];
462     char    frame6[9];
463     char    frame7[9];
464     char    frame8[9];
465 
466 } slidename_t;
467 
468 // villsa [STRIFE] no front/back frames
469 typedef struct
470 {
471     int frames[8];
472 
473 } slideframe_t;
474 
475 // haleyjd 09/29/10: [STRIFE] Externalized for savegames
476 void T_SlidingDoor(slidedoor_t* door);
477 
478 
479 // how many frames of animation
480 #define SNUMFRAMES      8       // villsa [STRIFE] changed from 4 to 8
481 
482 #define SDOORWAIT       TICRATE*3
483 #define SWAITTICS       4
484 
485 // how many diff. types of anims
486 #define MAXSLIDEDOORS	8       // villsa [STRIFE] changed from 5 to 8
487 
488 void P_InitSlidingDoorFrames(void);
489 void EV_SlidingDoor(line_t* line, mobj_t* thing);
490 int EV_RemoteSlidingDoor(line_t* line, mobj_t* thing);
491 
492 
493 
494 //
495 // P_CEILNG
496 //
497 typedef enum
498 {
499     lowerToFloor,
500     raiseToHighest,
501     lowerAndCrush,
502     crushAndRaise,
503     fastCrushAndRaise,
504     silentCrushAndRaise
505 
506 } ceiling_e;
507 
508 
509 
510 typedef struct
511 {
512     thinker_t	thinker;
513     ceiling_e	type;
514     sector_t*	sector;
515     fixed_t	bottomheight;
516     fixed_t	topheight;
517     fixed_t	speed;
518     boolean	crush;
519 
520     // 1 = up, 0 = waiting, -1 = down
521     int		direction;
522 
523     // ID
524     int		tag;
525     int		olddirection;
526 
527 } ceiling_t;
528 
529 
530 
531 
532 
533 #define CEILSPEED		FRACUNIT
534 #define CEILWAIT		150
535 #define MAXCEILINGS		30
536 
537 extern ceiling_t*	activeceilings[MAXCEILINGS];
538 
539 int
540 EV_DoCeiling
541 ( line_t*	line,
542   ceiling_e	type );
543 
544 void    T_MoveCeiling (ceiling_t* ceiling);
545 void    P_AddActiveCeiling(ceiling_t* c);
546 void    P_RemoveActiveCeiling(ceiling_t* c);
547 int	EV_CeilingCrushStop(line_t* line);
548 void    P_ActivateInStasisCeiling(line_t* line);
549 
550 
551 //
552 // P_FLOOR
553 //
554 typedef enum
555 {
556     // lower floor to highest surrounding floor
557     lowerFloor,
558 
559     // lower floor to lowest surrounding floor
560     lowerFloorToLowest,
561 
562     // lower floor to highest surrounding floor VERY FAST
563     turboLower,
564 
565     // raise floor to lowest surrounding CEILING
566     raiseFloor,
567 
568     // raise floor to next highest surrounding floor
569     raiseFloorToNearest,
570 
571     // raise floor to shortest height texture around it
572     raiseToTexture,
573 
574     // lower floor to lowest surrounding floor
575     //  and change floorpic
576     lowerAndChange,
577 
578     raiseFloor64,          // [STRIFE] changed from 24 to 64
579     raiseFloor24AndChange,
580     raiseFloorCrush,
581 
582      // raise to next highest floor, turbo-speed
583     raiseFloorTurbo,
584     donutRaise,
585     raiseFloor512,
586 
587     // [STRIFE] New floor type - used for the coolant reactor pit
588     raiseFloor512AndChange
589 
590 } floor_e;
591 
592 
593 
594 
595 typedef enum
596 {
597     build8,     // slowly build by 8
598     turbo16,    // quickly build by 16
599     buildDown16 // haleyjd 09/24/10: [STRIFE] new stair type
600 } stair_e;
601 
602 
603 
604 typedef struct
605 {
606     thinker_t	thinker;
607     floor_e	type;
608     boolean	crush;
609     sector_t*	sector;
610     int		direction;
611     int		newspecial;
612     short	texture;
613     fixed_t	floordestheight;
614     fixed_t	speed;
615 
616 } floormove_t;
617 
618 
619 
620 #define FLOORSPEED		FRACUNIT
621 
622 typedef enum
623 {
624     ok,
625     crushed,
626     pastdest
627 
628 } result_e;
629 
630 result_e
631 T_MovePlane
632 ( sector_t*	sector,
633   fixed_t	speed,
634   fixed_t	dest,
635   boolean	crush,
636   int		floorOrCeiling,
637   int		direction );
638 
639 int
640 EV_BuildStairs
641 ( line_t*	line,
642   stair_e	type );
643 
644 int
645 EV_DoFloor
646 ( line_t*	line,
647   floor_e	floortype );
648 
649 void T_MoveFloor( floormove_t* floor);
650 
651 //
652 // P_TELEPT
653 //
654 
655 // [STRIFE] Teleportation flags - teleflags
656 // Not to be conflated with telefrags, though they be tangentially related ;)
657 typedef enum teleflags
658 {
659     TF_NOSRCSND = 0x01,
660     TF_NODSTSND = 0x02,
661     TF_NODSTFOG = 0x10,
662     TF_NOSRCFOG = 0x20,
663 
664     TF_NORMAL      = 0,
665     TF_DSTSILENCE  = (TF_NODSTSND|TF_NODSTFOG),    // 0x12 (18) (Not used)
666     TF_SRCSILENCE  = (TF_NOSRCSND|TF_NOSRCFOG),    // 0x21 (33)
667     TF_FULLSILENCE = (TF_SRCSILENCE|TF_DSTSILENCE) // 0x33 (51)
668 
669 } teleflags_e;
670 
671 int
672 EV_Teleport
673 ( line_t*       line,
674   int           side,
675   mobj_t*       thing,
676   teleflags_e   flags);
677 
678 #endif
679