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