| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* Door animation code (opening/closing) |
| 31 |
* |
| 32 |
*-----------------------------------------------------------------------------*/ |
| 33 |
|
| 34 |
#include "doomstat.h" |
| 35 |
#include "p_spec.h" |
| 36 |
#include "p_tick.h" |
| 37 |
#include "s_sound.h" |
| 38 |
#include "sounds.h" |
| 39 |
#include "r_main.h" |
| 40 |
#include "dstrings.h" |
| 41 |
#include "d_deh.h" // Ty 03/27/98 - externalized |
| 42 |
#include "lprintf.h" |
| 43 |
#include "e6y.h"//e6y |
| 44 |
|
| 45 |
#include "dsda/id_list.h" |
| 46 |
#include "dsda/map_format.h" |
| 47 |
#include "dsda/messenger.h" |
| 48 |
|
| 49 |
#include "hexen/p_acs.h" |
| 50 |
#include "hexen/sn_sonix.h" |
| 51 |
|
| 52 |
/////////////////////////////////////////////////////////////// |
| 53 |
// |
| 54 |
// Door action routines, called once per tick |
| 55 |
// |
| 56 |
/////////////////////////////////////////////////////////////// |
| 57 |
|
| 58 |
// |
| 59 |
// T_VerticalDoor |
| 60 |
// |
| 61 |
// Passed a door structure containing all info about the door. |
| 62 |
// See P_SPEC.H for fields. |
| 63 |
// Returns nothing. |
| 64 |
// |
| 65 |
// jff 02/08/98 all cases with labels beginning with gen added to support |
| 66 |
// generalized line type behaviors. |
| 67 |
|
| 68 |
void T_VerticalCompatibleDoor(vldoor_t *door) |
| 69 |
{ |
| 70 |
result_e res; |
| 71 |
|
| 72 |
// Is the door waiting, going up, or going down? |
| 73 |
switch(door->direction) |
| 74 |
{ |
| 75 |
case 0: |
| 76 |
// Door is waiting |
| 77 |
if (!--door->topcountdown) // downcount and check |
| 78 |
{ |
| 79 |
switch(door->type) |
| 80 |
{ |
| 81 |
case blazeRaise: |
| 82 |
case genBlazeRaise: |
| 83 |
door->direction = -1; // time to go back down |
| 84 |
S_StartSectorSound(door->sector, sfx_bdcls); |
| 85 |
break; |
| 86 |
|
| 87 |
case normal: |
| 88 |
case genRaise: |
| 89 |
case vld_normal: |
| 90 |
door->direction = -1; // time to go back down |
| 91 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 92 |
break; |
| 93 |
|
| 94 |
case close30ThenOpen: |
| 95 |
case genCdO: |
| 96 |
case vld_close30ThenOpen: |
| 97 |
door->direction = 1; // time to go back up |
| 98 |
S_StartSectorSound(door->sector, g_sfx_doropn); |
| 99 |
break; |
| 100 |
|
| 101 |
case genBlazeCdO: |
| 102 |
door->direction = 1; // time to go back up |
| 103 |
S_StartSectorSound(door->sector, sfx_bdopn); |
| 104 |
break; |
| 105 |
|
| 106 |
default: |
| 107 |
break; |
| 108 |
} |
| 109 |
} |
| 110 |
break; |
| 111 |
|
| 112 |
case 2: |
| 113 |
// Special case for sector type door that waits before starting |
| 114 |
if (!--door->topcountdown) |
| 115 |
{ |
| 116 |
switch(door->type) |
| 117 |
{ |
| 118 |
case waitRaiseDoor: |
| 119 |
case vld_raiseIn5Mins: |
| 120 |
door->direction = 1; // time to raise then |
| 121 |
door->type = g_door_normal; // door acts just like normal 1 DR door now |
| 122 |
S_StartSectorSound(door->sector, g_sfx_doropn); |
| 123 |
break; |
| 124 |
|
| 125 |
case waitCloseDoor: |
| 126 |
door->direction = -1; |
| 127 |
door->type = closeDoor; |
| 128 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 129 |
|
| 130 |
default: |
| 131 |
break; |
| 132 |
} |
| 133 |
} |
| 134 |
break; |
| 135 |
|
| 136 |
case -1: |
| 137 |
// Door is moving down |
| 138 |
res = T_MoveCeilingPlane |
| 139 |
( |
| 140 |
door->sector, |
| 141 |
door->speed, |
| 142 |
door->sector->floorheight, |
| 143 |
NO_CRUSH, |
| 144 |
door->direction, |
| 145 |
false |
| 146 |
); |
| 147 |
|
| 148 |
/* killough 10/98: implement gradual lighting effects */ |
| 149 |
// e6y: "Tagged doors don't trigger special lighting" handled wrong |
| 150 |
// http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943 |
| 151 |
// Old code: if (door->lighttag && door->topheight - door->sector->floorheight) |
| 152 |
if ( |
| 153 |
door->lighttag && |
| 154 |
door->topheight - door->sector->floorheight && |
| 155 |
compatibility_level >= mbf_compatibility |
| 156 |
) |
| 157 |
EV_LightTurnOnPartway(door->line, |
| 158 |
FixedDiv(door->sector->ceilingheight - |
| 159 |
door->sector->floorheight, |
| 160 |
door->topheight - |
| 161 |
door->sector->floorheight)); |
| 162 |
|
| 163 |
// handle door reaching bottom |
| 164 |
if (res == pastdest) |
| 165 |
{ |
| 166 |
switch(door->type) |
| 167 |
{ |
| 168 |
// regular open and close doors are all done, remove them |
| 169 |
case blazeRaise: |
| 170 |
case blazeClose: |
| 171 |
case genBlazeRaise: |
| 172 |
case genBlazeClose: |
| 173 |
door->sector->ceilingdata = NULL; //jff 2/22/98 |
| 174 |
P_RemoveThinker (&door->thinker); // unlink and free |
| 175 |
// killough 4/15/98: remove double-closing sound of blazing doors |
| 176 |
if (comp[comp_blazing]) |
| 177 |
S_StartSectorSound(door->sector, sfx_bdcls); |
| 178 |
break; |
| 179 |
|
| 180 |
case normal: |
| 181 |
case closeDoor: |
| 182 |
case genRaise: |
| 183 |
case genClose: |
| 184 |
door->sector->ceilingdata = NULL; //jff 2/22/98 |
| 185 |
P_RemoveThinker (&door->thinker); // unlink and free |
| 186 |
break; |
| 187 |
|
| 188 |
case vld_normal: |
| 189 |
case vld_close: |
| 190 |
door->sector->ceilingdata = NULL; |
| 191 |
P_RemoveThinker(&door->thinker); // unlink and free |
| 192 |
S_StartSectorSound(door->sector, g_sfx_dorlnd); |
| 193 |
break; |
| 194 |
|
| 195 |
// close then open doors start waiting |
| 196 |
case close30ThenOpen: |
| 197 |
case vld_close30ThenOpen: |
| 198 |
door->direction = 0; |
| 199 |
door->topcountdown = TICRATE*30; |
| 200 |
break; |
| 201 |
|
| 202 |
case genCdO: |
| 203 |
case genBlazeCdO: |
| 204 |
door->direction = 0; |
| 205 |
door->topcountdown = door->topwait; // jff 5/8/98 insert delay |
| 206 |
break; |
| 207 |
|
| 208 |
default: |
| 209 |
break; |
| 210 |
} |
| 211 |
// e6y: "Tagged doors don't trigger special lighting" handled wrong |
| 212 |
// http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943 |
| 213 |
if ( |
| 214 |
!heretic && |
| 215 |
door->lighttag && |
| 216 |
door->topheight - door->sector->floorheight && |
| 217 |
compatibility_level < mbf_compatibility |
| 218 |
) |
| 219 |
EV_LightTurnOnPartway(door->line,0); |
| 220 |
} |
| 221 |
/* jff 1/31/98 turn lighting off in tagged sectors of manual doors |
| 222 |
* killough 10/98: replaced with gradual lighting code |
| 223 |
*/ |
| 224 |
else if (res == crushed) // handle door meeting obstruction on way down |
| 225 |
{ |
| 226 |
switch(door->type) |
| 227 |
{ |
| 228 |
case genClose: |
| 229 |
case genBlazeClose: |
| 230 |
case blazeClose: |
| 231 |
case closeDoor: |
| 232 |
case vld_close: // Close types do not bounce, merely wait |
| 233 |
break; |
| 234 |
|
| 235 |
case blazeRaise: |
| 236 |
case genBlazeRaise: |
| 237 |
door->direction = 1; |
| 238 |
if (!comp[comp_blazing]) { |
| 239 |
S_StartSectorSound(door->sector, sfx_bdopn); |
| 240 |
break; |
| 241 |
} |
| 242 |
// fallthrough |
| 243 |
|
| 244 |
default: // other types bounce off the obstruction |
| 245 |
door->direction = 1; |
| 246 |
S_StartSectorSound(door->sector, g_sfx_doropn); |
| 247 |
break; |
| 248 |
} |
| 249 |
} |
| 250 |
break; |
| 251 |
|
| 252 |
case 1: |
| 253 |
// Door is moving up |
| 254 |
res = T_MoveCeilingPlane |
| 255 |
( |
| 256 |
door->sector, |
| 257 |
door->speed, |
| 258 |
door->topheight, |
| 259 |
NO_CRUSH, |
| 260 |
door->direction, |
| 261 |
false |
| 262 |
); |
| 263 |
|
| 264 |
/* killough 10/98: implement gradual lighting effects */ |
| 265 |
// e6y: "Tagged doors don't trigger special lighting" handled wrong |
| 266 |
// http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943 |
| 267 |
// Old code: if (door->lighttag && door->topheight - door->sector->floorheight) |
| 268 |
if ( |
| 269 |
door->lighttag && |
| 270 |
door->topheight - door->sector->floorheight && |
| 271 |
compatibility_level >= mbf_compatibility |
| 272 |
) |
| 273 |
EV_LightTurnOnPartway(door->line, |
| 274 |
FixedDiv(door->sector->ceilingheight - |
| 275 |
door->sector->floorheight, |
| 276 |
door->topheight - |
| 277 |
door->sector->floorheight)); |
| 278 |
|
| 279 |
// handle door reaching the top |
| 280 |
if (res == pastdest) |
| 281 |
{ |
| 282 |
switch(door->type) |
| 283 |
{ |
| 284 |
case blazeRaise: // regular open/close doors start waiting |
| 285 |
case normal: |
| 286 |
case genRaise: |
| 287 |
case genBlazeRaise: |
| 288 |
case vld_normal: |
| 289 |
door->direction = 0; // wait at top with delay |
| 290 |
door->topcountdown = door->topwait; |
| 291 |
break; |
| 292 |
|
| 293 |
case close30ThenOpen: // close and close/open doors are done |
| 294 |
case blazeOpen: |
| 295 |
case openDoor: |
| 296 |
case genBlazeOpen: |
| 297 |
case genOpen: |
| 298 |
case genCdO: |
| 299 |
case genBlazeCdO: |
| 300 |
door->sector->ceilingdata = NULL; //jff 2/22/98 |
| 301 |
P_RemoveThinker (&door->thinker); // unlink and free |
| 302 |
break; |
| 303 |
|
| 304 |
case vld_close30ThenOpen: |
| 305 |
case vld_open: |
| 306 |
door->sector->ceilingdata = NULL; |
| 307 |
P_RemoveThinker(&door->thinker); // unlink and free |
| 308 |
S_StopSound(&door->sector->soundorg); |
| 309 |
break; |
| 310 |
|
| 311 |
default: |
| 312 |
break; |
| 313 |
} |
| 314 |
|
| 315 |
/* jff 1/31/98 turn lighting on in tagged sectors of manual doors |
| 316 |
* killough 10/98: replaced with gradual lighting code */ |
| 317 |
// e6y: "Tagged doors don't trigger special lighting" handled wrong |
| 318 |
// http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943 |
| 319 |
if ( |
| 320 |
!heretic && |
| 321 |
door->lighttag && |
| 322 |
door->topheight - door->sector->floorheight && |
| 323 |
compatibility_level < mbf_compatibility |
| 324 |
) |
| 325 |
EV_LightTurnOnPartway(door->line,FRACUNIT); |
| 326 |
} |
| 327 |
break; |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
void T_VerticalHexenDoor(vldoor_t *door) |
| 332 |
{ |
| 333 |
result_e res; |
| 334 |
|
| 335 |
switch (door->direction) |
| 336 |
{ |
| 337 |
case 0: // WAITING |
| 338 |
if (!--door->topcountdown) |
| 339 |
switch (door->type) |
| 340 |
{ |
| 341 |
case DREV_NORMAL: |
| 342 |
door->direction = -1; // time to go back down |
| 343 |
SN_StartSequence((mobj_t *) & door->sector->soundorg, |
| 344 |
SEQ_DOOR_STONE + |
| 345 |
door->sector->seqType); |
| 346 |
break; |
| 347 |
case DREV_CLOSE30THENOPEN: |
| 348 |
door->direction = 1; |
| 349 |
break; |
| 350 |
default: |
| 351 |
break; |
| 352 |
} |
| 353 |
break; |
| 354 |
case 2: // INITIAL WAIT |
| 355 |
if (!--door->topcountdown) |
| 356 |
{ |
| 357 |
switch (door->type) |
| 358 |
{ |
| 359 |
case DREV_RAISEIN5MINS: |
| 360 |
door->direction = 1; |
| 361 |
door->type = DREV_NORMAL; |
| 362 |
break; |
| 363 |
default: |
| 364 |
break; |
| 365 |
} |
| 366 |
} |
| 367 |
break; |
| 368 |
case -1: // DOWN |
| 369 |
res = T_MoveCeilingPlane(door->sector, door->speed, |
| 370 |
door->sector->floorheight, NO_CRUSH, |
| 371 |
door->direction, true); |
| 372 |
if (res == pastdest) |
| 373 |
{ |
| 374 |
SN_StopSequence((mobj_t *) & door->sector->soundorg); |
| 375 |
switch (door->type) |
| 376 |
{ |
| 377 |
case DREV_NORMAL: |
| 378 |
case DREV_CLOSE: |
| 379 |
door->sector->ceilingdata = NULL; |
| 380 |
P_TagFinished(door->sector->tag); |
| 381 |
P_RemoveThinker(&door->thinker); // unlink and free |
| 382 |
break; |
| 383 |
case DREV_CLOSE30THENOPEN: |
| 384 |
door->direction = 0; |
| 385 |
door->topcountdown = 35 * 30; |
| 386 |
break; |
| 387 |
default: |
| 388 |
break; |
| 389 |
} |
| 390 |
} |
| 391 |
else if (res == crushed) |
| 392 |
{ |
| 393 |
switch (door->type) |
| 394 |
{ |
| 395 |
case DREV_CLOSE: // DON'T GO BACK UP! |
| 396 |
break; |
| 397 |
default: |
| 398 |
door->direction = 1; |
| 399 |
break; |
| 400 |
} |
| 401 |
} |
| 402 |
break; |
| 403 |
case 1: // UP |
| 404 |
res = T_MoveCeilingPlane(door->sector, door->speed, |
| 405 |
door->topheight, NO_CRUSH, door->direction, true); |
| 406 |
if (res == pastdest) |
| 407 |
{ |
| 408 |
SN_StopSequence((mobj_t *) & door->sector->soundorg); |
| 409 |
switch (door->type) |
| 410 |
{ |
| 411 |
case DREV_NORMAL: |
| 412 |
door->direction = 0; // wait at top |
| 413 |
door->topcountdown = door->topwait; |
| 414 |
break; |
| 415 |
case DREV_CLOSE30THENOPEN: |
| 416 |
case DREV_OPEN: |
| 417 |
door->sector->ceilingdata = NULL; |
| 418 |
P_TagFinished(door->sector->tag); |
| 419 |
P_RemoveThinker(&door->thinker); // unlink and free |
| 420 |
break; |
| 421 |
default: |
| 422 |
break; |
| 423 |
} |
| 424 |
} |
| 425 |
break; |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
|
| 430 |
void T_VerticalDoor (vldoor_t* door) |
| 431 |
{ |
| 432 |
map_format.t_vertical_door(door); |
| 433 |
} |
| 434 |
|
| 435 |
/////////////////////////////////////////////////////////////// |
| 436 |
// |
| 437 |
// Door linedef handlers |
| 438 |
// |
| 439 |
/////////////////////////////////////////////////////////////// |
| 440 |
|
| 441 |
// |
| 442 |
// EV_DoLockedDoor |
| 443 |
// |
| 444 |
// Handle opening a tagged locked door |
| 445 |
// |
| 446 |
// Passed the line activating the door, the type of door, |
| 447 |
// and the thing that activated the line |
| 448 |
// Returns true if a thinker created |
| 449 |
// |
| 450 |
int EV_DoLockedDoor |
| 451 |
( line_t* line, |
| 452 |
vldoor_e type, |
| 453 |
mobj_t* thing ) |
| 454 |
{ |
| 455 |
player_t* p; |
| 456 |
|
| 457 |
// only players can open locked doors |
| 458 |
p = thing->player; |
| 459 |
if (!p) |
| 460 |
return 0; |
| 461 |
|
| 462 |
// check type of linedef, and if key is possessed to open it |
| 463 |
switch(line->special) |
| 464 |
{ |
| 465 |
case 99: // Blue Lock |
| 466 |
case 133: |
| 467 |
if (!p->cards[it_bluecard] && !p->cards[it_blueskull]) |
| 468 |
{ |
| 469 |
dsda_AddPlayerMessage(s_PD_BLUEO, p); |
| 470 |
S_StartMobjSound(p->mo,sfx_oof); // killough 3/20/98 |
| 471 |
return 0; |
| 472 |
} |
| 473 |
break; |
| 474 |
|
| 475 |
case 134: // Red Lock |
| 476 |
case 135: |
| 477 |
if (!p->cards[it_redcard] && !p->cards[it_redskull]) |
| 478 |
{ |
| 479 |
dsda_AddPlayerMessage(s_PD_REDO, p); |
| 480 |
S_StartMobjSound(p->mo,sfx_oof); // killough 3/20/98 |
| 481 |
return 0; |
| 482 |
} |
| 483 |
break; |
| 484 |
|
| 485 |
case 136: // Yellow Lock |
| 486 |
case 137: |
| 487 |
if (!p->cards[it_yellowcard] && !p->cards[it_yellowskull]) |
| 488 |
{ |
| 489 |
dsda_AddPlayerMessage(s_PD_YELLOWO, p); |
| 490 |
S_StartMobjSound(p->mo,sfx_oof); // killough 3/20/98 |
| 491 |
return 0; |
| 492 |
} |
| 493 |
break; |
| 494 |
} |
| 495 |
|
| 496 |
// got the key, so open the door |
| 497 |
return EV_DoDoor(line,type); |
| 498 |
} |
| 499 |
|
| 500 |
|
| 501 |
// |
| 502 |
// EV_DoDoor |
| 503 |
// |
| 504 |
// Handle opening a tagged door |
| 505 |
// |
| 506 |
// Passed the line activating the door and the type of door |
| 507 |
// Returns true if a thinker created |
| 508 |
// |
| 509 |
int EV_DoDoor |
| 510 |
( line_t* line, |
| 511 |
vldoor_e type ) |
| 512 |
{ |
| 513 |
const int *id_p; |
| 514 |
int rtn; |
| 515 |
sector_t* sec; |
| 516 |
vldoor_t* door; |
| 517 |
|
| 518 |
rtn = 0; |
| 519 |
|
| 520 |
// open all doors with the same tag as the activating line |
| 521 |
FIND_SECTORS(id_p, line->tag) |
| 522 |
{ |
| 523 |
sec = §ors[*id_p]; |
| 524 |
// if the ceiling already moving, don't start the door action |
| 525 |
if (P_CeilingActive(sec)) //jff 2/22/98 |
| 526 |
continue; |
| 527 |
|
| 528 |
// new door thinker |
| 529 |
rtn = 1; |
| 530 |
door = Z_MallocLevel (sizeof(*door)); |
| 531 |
memset(door, 0, sizeof(*door)); |
| 532 |
P_AddThinker (&door->thinker); |
| 533 |
sec->ceilingdata = door; //jff 2/22/98 |
| 534 |
|
| 535 |
door->thinker.function = T_VerticalDoor; |
| 536 |
door->sector = sec; |
| 537 |
door->type = type; |
| 538 |
door->topwait = VDOORWAIT; |
| 539 |
door->speed = VDOORSPEED; |
| 540 |
door->line = line; // jff 1/31/98 remember line that triggered us |
| 541 |
door->lighttag = 0; /* killough 10/98: no light effects with tagged doors */ |
| 542 |
|
| 543 |
// setup door parameters according to type of door |
| 544 |
switch(type) |
| 545 |
{ |
| 546 |
case blazeClose: |
| 547 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 548 |
door->topheight -= 4*FRACUNIT; |
| 549 |
door->direction = -1; |
| 550 |
door->speed = VDOORSPEED * 4; |
| 551 |
S_StartSectorSound(door->sector, sfx_bdcls); |
| 552 |
break; |
| 553 |
|
| 554 |
case closeDoor: |
| 555 |
case vld_close: |
| 556 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 557 |
door->topheight -= 4*FRACUNIT; |
| 558 |
door->direction = -1; |
| 559 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 560 |
break; |
| 561 |
|
| 562 |
case close30ThenOpen: |
| 563 |
case vld_close30ThenOpen: |
| 564 |
door->topheight = sec->ceilingheight; |
| 565 |
door->direction = -1; |
| 566 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 567 |
break; |
| 568 |
|
| 569 |
case blazeRaise: |
| 570 |
case blazeOpen: |
| 571 |
door->direction = 1; |
| 572 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 573 |
door->topheight -= 4*FRACUNIT; |
| 574 |
door->speed = VDOORSPEED * 4; |
| 575 |
if (door->topheight != sec->ceilingheight) |
| 576 |
S_StartSectorSound(door->sector, sfx_bdopn); |
| 577 |
break; |
| 578 |
|
| 579 |
case vld_normal_turbo: |
| 580 |
door->type = vld_normal; |
| 581 |
door->speed = VDOORSPEED * 3; |
| 582 |
// fall through |
| 583 |
|
| 584 |
case normal: |
| 585 |
case openDoor: |
| 586 |
case vld_normal: |
| 587 |
case vld_open: |
| 588 |
door->direction = 1; |
| 589 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 590 |
door->topheight -= 4*FRACUNIT; |
| 591 |
if (door->topheight != sec->ceilingheight) |
| 592 |
S_StartSectorSound(door->sector, g_sfx_doropn); |
| 593 |
break; |
| 594 |
|
| 595 |
default: |
| 596 |
break; |
| 597 |
} |
| 598 |
} |
| 599 |
return rtn; |
| 600 |
} |
| 601 |
|
| 602 |
|
| 603 |
// |
| 604 |
// EV_VerticalDoor |
| 605 |
// |
| 606 |
// Handle opening a door manually, no tag value |
| 607 |
// |
| 608 |
// Passed the line activating the door and the thing activating it |
| 609 |
// Returns true if a thinker created |
| 610 |
// |
| 611 |
// jff 2/12/98 added int return value, fixed all returns |
| 612 |
// |
| 613 |
int EV_VerticalDoor |
| 614 |
( line_t* line, |
| 615 |
mobj_t* thing ) |
| 616 |
{ |
| 617 |
player_t* player; |
| 618 |
sector_t* sec; |
| 619 |
vldoor_t* door; |
| 620 |
|
| 621 |
// heretic_note: I don't see where the return value is used...keeping heretic signature |
| 622 |
if (heretic) { Heretic_EV_VerticalDoor(line, thing); return 0; } |
| 623 |
|
| 624 |
// Check for locks |
| 625 |
player = thing->player; |
| 626 |
|
| 627 |
switch(line->special) |
| 628 |
{ |
| 629 |
case 26: // Blue Lock |
| 630 |
case 32: |
| 631 |
if ( !player ) |
| 632 |
return 0; |
| 633 |
if (!player->cards[it_bluecard] && !player->cards[it_blueskull]) |
| 634 |
{ |
| 635 |
dsda_AddPlayerMessage(s_PD_BLUEK, player); |
| 636 |
S_StartMobjSound(player->mo,sfx_oof); // killough 3/20/98 |
| 637 |
return 0; |
| 638 |
} |
| 639 |
break; |
| 640 |
|
| 641 |
case 27: // Yellow Lock |
| 642 |
case 34: |
| 643 |
if ( !player ) |
| 644 |
return 0; |
| 645 |
if (!player->cards[it_yellowcard] && !player->cards[it_yellowskull]) |
| 646 |
{ |
| 647 |
dsda_AddPlayerMessage(s_PD_YELLOWK, player); |
| 648 |
S_StartMobjSound(player->mo,sfx_oof); // killough 3/20/98 |
| 649 |
return 0; |
| 650 |
} |
| 651 |
break; |
| 652 |
|
| 653 |
case 28: // Red Lock |
| 654 |
case 33: |
| 655 |
if ( !player ) |
| 656 |
return 0; |
| 657 |
if (!player->cards[it_redcard] && !player->cards[it_redskull]) |
| 658 |
{ |
| 659 |
dsda_AddPlayerMessage(s_PD_REDK, player); |
| 660 |
S_StartMobjSound(player->mo,sfx_oof); // killough 3/20/98 |
| 661 |
return 0; |
| 662 |
} |
| 663 |
break; |
| 664 |
|
| 665 |
default: |
| 666 |
break; |
| 667 |
} |
| 668 |
|
| 669 |
// if the wrong side of door is pushed, give oof sound |
| 670 |
if (line->sidenum[1]==NO_INDEX) // killough |
| 671 |
{ |
| 672 |
S_StartMobjSound(player->mo,sfx_oof); // killough 3/20/98 |
| 673 |
return 0; |
| 674 |
} |
| 675 |
|
| 676 |
// get the sector on the second side of activating linedef |
| 677 |
sec = sides[line->sidenum[1]].sector; |
| 678 |
|
| 679 |
/* if door already has a thinker, use it |
| 680 |
* cph 2001/04/05 - |
| 681 |
* Ok, this is a disaster area. We're assuming that sec->ceilingdata |
| 682 |
* is a vldoor_t! What if this door is controlled by both DR lines |
| 683 |
* and by switches? I don't know how to fix that. |
| 684 |
* Secondly, original Doom didn't distinguish floor/lighting/ceiling |
| 685 |
* actions, so we need to do the same in demo compatibility mode. |
| 686 |
*/ |
| 687 |
door = sec->ceilingdata; |
| 688 |
if (demo_compatibility) { |
| 689 |
if (!door) door = sec->floordata; |
| 690 |
} |
| 691 |
/* If this is a repeatable line, and the door is already moving, then we can just reverse the current action. Note that in prboom 2.3.0 I erroneously removed the if-this-is-repeatable check, hence the prboom_4_compatibility clause below (foolishly assumed that already moving implies repeatable - but it could be moving due to another switch, e.g. lv19-509) */ |
| 692 |
if ( |
| 693 |
door && |
| 694 |
( |
| 695 |
(compatibility_level == prboom_4_compatibility) || |
| 696 |
(line->special == 1) || (line->special == 117) || (line->special == 26) || (line->special == 27) || (line->special == 28) |
| 697 |
) |
| 698 |
) { |
| 699 |
/* For old demos we have to emulate the old buggy behavior and |
| 700 |
* mess up non-T_VerticalDoor actions. |
| 701 |
*/ |
| 702 |
if (compatibility_level < prboom_4_compatibility || |
| 703 |
door->thinker.function == T_VerticalDoor) { |
| 704 |
/* cph - we are writing outval to door->direction iff it is non-zero */ |
| 705 |
signed int outval = 0; |
| 706 |
|
| 707 |
/* An already moving repeatable door which is being re-pressed, or a |
| 708 |
* monster is trying to open a closing door - so change direction |
| 709 |
* DEMOSYNC: we only read door->direction now if it really is a door. |
| 710 |
*/ |
| 711 |
if (door->thinker.function == T_VerticalDoor && door->direction == -1) { |
| 712 |
outval = 1; /* go back up */ |
| 713 |
} else if (player) { |
| 714 |
outval = -1; /* go back down */ |
| 715 |
} |
| 716 |
|
| 717 |
/* Write this to the thinker. In demo compatibility mode, we might be |
| 718 |
* overwriting a field of a non-vldoor_t thinker - we need to add any |
| 719 |
* other thinker types here if any demos depend on specific fields |
| 720 |
* being corrupted by this. |
| 721 |
*/ |
| 722 |
if (outval) { |
| 723 |
if (door->thinker.function == T_VerticalDoor) { |
| 724 |
door->direction = outval; |
| 725 |
} else if (door->thinker.function == T_PlatRaise) { |
| 726 |
plat_t* p = (plat_t*)door; |
| 727 |
p->wait = outval; |
| 728 |
} else { |
| 729 |
lprintf(LO_DEBUG, "EV_VerticalDoor: unknown thinker.function in thinker corruption emulation"); |
| 730 |
} |
| 731 |
|
| 732 |
return 1; |
| 733 |
} |
| 734 |
} |
| 735 |
/* Either we're in prboom >=v2.3 and it's not a door, or it's a door but |
| 736 |
* we're a monster and don't want to shut it; exit with no action. |
| 737 |
*/ |
| 738 |
return 0; |
| 739 |
} |
| 740 |
|
| 741 |
// emit proper sound |
| 742 |
switch(line->special) |
| 743 |
{ |
| 744 |
case 117: // blazing door raise |
| 745 |
case 118: // blazing door open |
| 746 |
S_StartSectorSound(sec, sfx_bdopn); |
| 747 |
break; |
| 748 |
|
| 749 |
default: // normal or locked door sound |
| 750 |
S_StartSectorSound(sec, sfx_doropn); |
| 751 |
break; |
| 752 |
} |
| 753 |
|
| 754 |
// new door thinker |
| 755 |
door = Z_MallocLevel (sizeof(*door)); |
| 756 |
memset(door, 0, sizeof(*door)); |
| 757 |
P_AddThinker (&door->thinker); |
| 758 |
sec->ceilingdata = door; //jff 2/22/98 |
| 759 |
door->thinker.function = T_VerticalDoor; |
| 760 |
door->sector = sec; |
| 761 |
door->direction = 1; |
| 762 |
door->speed = VDOORSPEED; |
| 763 |
door->topwait = VDOORWAIT; |
| 764 |
door->line = line; // jff 1/31/98 remember line that triggered us |
| 765 |
|
| 766 |
/* killough 10/98: use gradual lighting changes if nonzero tag given */ |
| 767 |
door->lighttag = comp[comp_doorlight] ? 0 : line->tag; |
| 768 |
|
| 769 |
// set the type of door from the activating linedef type |
| 770 |
switch(line->special) |
| 771 |
{ |
| 772 |
case 1: |
| 773 |
case 26: |
| 774 |
case 27: |
| 775 |
case 28: |
| 776 |
door->type = normal; |
| 777 |
break; |
| 778 |
|
| 779 |
case 31: |
| 780 |
case 32: |
| 781 |
case 33: |
| 782 |
case 34: |
| 783 |
door->type = openDoor; |
| 784 |
line->special = 0; |
| 785 |
break; |
| 786 |
|
| 787 |
case 117: // blazing door raise |
| 788 |
door->type = blazeRaise; |
| 789 |
door->speed = VDOORSPEED*4; |
| 790 |
break; |
| 791 |
case 118: // blazing door open |
| 792 |
door->type = blazeOpen; |
| 793 |
line->special = 0; |
| 794 |
door->speed = VDOORSPEED*4; |
| 795 |
break; |
| 796 |
|
| 797 |
default: |
| 798 |
door->lighttag = 0; // killough 10/98 |
| 799 |
break; |
| 800 |
} |
| 801 |
|
| 802 |
// find the top and bottom of the movement range |
| 803 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 804 |
door->topheight -= 4*FRACUNIT; |
| 805 |
return 1; |
| 806 |
} |
| 807 |
|
| 808 |
|
| 809 |
/////////////////////////////////////////////////////////////// |
| 810 |
// |
| 811 |
// Sector type door spawners |
| 812 |
// |
| 813 |
/////////////////////////////////////////////////////////////// |
| 814 |
|
| 815 |
// |
| 816 |
// P_SpawnDoorCloseIn30() |
| 817 |
// |
| 818 |
// Spawn a door that closes after 30 seconds (called at level init) |
| 819 |
// |
| 820 |
// Passed the sector of the door, whose type specified the door action |
| 821 |
// Returns nothing |
| 822 |
// |
| 823 |
void P_SpawnDoorCloseIn30 (sector_t* sec) |
| 824 |
{ |
| 825 |
vldoor_t* door; |
| 826 |
|
| 827 |
door = Z_MallocLevel ( sizeof(*door)); |
| 828 |
|
| 829 |
memset(door, 0, sizeof(*door)); |
| 830 |
P_AddThinker (&door->thinker); |
| 831 |
|
| 832 |
sec->ceilingdata = door; //jff 2/22/98 |
| 833 |
sec->special = 0; |
| 834 |
|
| 835 |
door->thinker.function = T_VerticalDoor; |
| 836 |
door->sector = sec; |
| 837 |
door->direction = 0; |
| 838 |
door->type = g_door_normal; |
| 839 |
door->speed = VDOORSPEED; |
| 840 |
door->topcountdown = 30 * 35; |
| 841 |
door->line = NULL; // jff 1/31/98 remember line that triggered us |
| 842 |
door->lighttag = 0; /* killough 10/98: no lighting changes */ |
| 843 |
} |
| 844 |
|
| 845 |
// |
| 846 |
// P_SpawnDoorRaiseIn5Mins() |
| 847 |
// |
| 848 |
// Spawn a door that opens after 5 minutes (called at level init) |
| 849 |
// |
| 850 |
// Passed the sector of the door, whose type specified the door action |
| 851 |
// Returns nothing |
| 852 |
// |
| 853 |
void P_SpawnDoorRaiseIn5Mins |
| 854 |
( sector_t* sec, |
| 855 |
int secnum ) |
| 856 |
{ |
| 857 |
vldoor_t* door; |
| 858 |
|
| 859 |
door = Z_MallocLevel ( sizeof(*door)); |
| 860 |
|
| 861 |
memset(door, 0, sizeof(*door)); |
| 862 |
P_AddThinker (&door->thinker); |
| 863 |
|
| 864 |
sec->ceilingdata = door; //jff 2/22/98 |
| 865 |
sec->special = 0; |
| 866 |
|
| 867 |
door->thinker.function = T_VerticalDoor; |
| 868 |
door->sector = sec; |
| 869 |
door->direction = 2; |
| 870 |
door->type = g_door_raise_in_5_mins; |
| 871 |
door->speed = VDOORSPEED; |
| 872 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 873 |
door->topheight -= 4*FRACUNIT; |
| 874 |
door->topwait = VDOORWAIT; |
| 875 |
door->topcountdown = 5 * 60 * 35; |
| 876 |
door->line = NULL; // jff 1/31/98 remember line that triggered us |
| 877 |
door->lighttag = 0; /* killough 10/98: no lighting changes */ |
| 878 |
} |
| 879 |
|
| 880 |
// heretic |
| 881 |
|
| 882 |
#include "p_inter.h" |
| 883 |
#include "heretic/dstrings.h" |
| 884 |
|
| 885 |
void Heretic_EV_VerticalDoor(line_t * line, mobj_t * thing) |
| 886 |
{ |
| 887 |
player_t *player; |
| 888 |
sector_t *sec; |
| 889 |
vldoor_t *door; |
| 890 |
int side; |
| 891 |
|
| 892 |
side = 0; // only front sides can be used |
| 893 |
// |
| 894 |
// Check for locks |
| 895 |
// |
| 896 |
player = thing->player; |
| 897 |
switch (line->special) |
| 898 |
{ |
| 899 |
case 26: // Blue Lock |
| 900 |
case 32: |
| 901 |
if (!player) |
| 902 |
{ |
| 903 |
return; |
| 904 |
} |
| 905 |
if (!player->cards[key_blue]) |
| 906 |
{ |
| 907 |
P_SetMessage(player, HERETIC_TXT_NEEDBLUEKEY, false); |
| 908 |
S_StartVoidSound(heretic_sfx_plroof); |
| 909 |
return; |
| 910 |
} |
| 911 |
break; |
| 912 |
case 27: // Yellow Lock |
| 913 |
case 34: |
| 914 |
if (!player) |
| 915 |
{ |
| 916 |
return; |
| 917 |
} |
| 918 |
if (!player->cards[key_yellow]) |
| 919 |
{ |
| 920 |
P_SetMessage(player, HERETIC_TXT_NEEDYELLOWKEY, false); |
| 921 |
S_StartVoidSound(heretic_sfx_plroof); |
| 922 |
return; |
| 923 |
} |
| 924 |
break; |
| 925 |
case 28: // Green Lock |
| 926 |
case 33: |
| 927 |
if (!player) |
| 928 |
{ |
| 929 |
return; |
| 930 |
} |
| 931 |
if (!player->cards[key_green]) |
| 932 |
{ |
| 933 |
P_SetMessage(player, HERETIC_TXT_NEEDGREENKEY, false); |
| 934 |
S_StartVoidSound(heretic_sfx_plroof); |
| 935 |
return; |
| 936 |
} |
| 937 |
break; |
| 938 |
} |
| 939 |
|
| 940 |
// if the sector has an active thinker, use it |
| 941 |
sec = sides[line->sidenum[side ^ 1]].sector; |
| 942 |
if (sec->ceilingdata) |
| 943 |
{ |
| 944 |
door = sec->ceilingdata; |
| 945 |
switch (line->special) |
| 946 |
{ |
| 947 |
case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s |
| 948 |
case 26: |
| 949 |
case 27: |
| 950 |
case 28: |
| 951 |
if (door->direction == -1) |
| 952 |
{ |
| 953 |
door->direction = 1; // go back up |
| 954 |
} |
| 955 |
else |
| 956 |
{ |
| 957 |
if (!thing->player) |
| 958 |
{ // Monsters don't close doors |
| 959 |
return; |
| 960 |
} |
| 961 |
door->direction = -1; // start going down immediately |
| 962 |
} |
| 963 |
return; |
| 964 |
} |
| 965 |
} |
| 966 |
|
| 967 |
S_StartSectorSound(sec, heretic_sfx_doropn); |
| 968 |
|
| 969 |
// |
| 970 |
// new door thinker |
| 971 |
// |
| 972 |
door = Z_MallocLevel(sizeof(*door)); |
| 973 |
memset(door, 0, sizeof(*door)); |
| 974 |
P_AddThinker(&door->thinker); |
| 975 |
sec->ceilingdata = door; |
| 976 |
door->thinker.function = T_VerticalDoor; |
| 977 |
door->sector = sec; |
| 978 |
door->direction = 1; |
| 979 |
door->speed = VDOORSPEED; |
| 980 |
door->topwait = VDOORWAIT; |
| 981 |
door->line = line; // heretic_note: this is from doom |
| 982 |
door->lighttag = 0; |
| 983 |
switch (line->special) |
| 984 |
{ |
| 985 |
case 1: |
| 986 |
case 26: |
| 987 |
case 27: |
| 988 |
case 28: |
| 989 |
door->type = vld_normal; |
| 990 |
break; |
| 991 |
case 31: |
| 992 |
case 32: |
| 993 |
case 33: |
| 994 |
case 34: |
| 995 |
door->type = vld_open; |
| 996 |
line->special = 0; |
| 997 |
break; |
| 998 |
} |
| 999 |
|
| 1000 |
// |
| 1001 |
// find the top and bottom of the movement range |
| 1002 |
// |
| 1003 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1004 |
door->topheight -= 4 * FRACUNIT; |
| 1005 |
} |
| 1006 |
|
| 1007 |
// hexen |
| 1008 |
|
| 1009 |
static void P_SpawnZDoomDoor(sector_t *sec, vldoor_e type, line_t *line, fixed_t speed, |
| 1010 |
int topwait, int lightTag, int topcountdown) |
| 1011 |
{ |
| 1012 |
vldoor_t *door; |
| 1013 |
|
| 1014 |
door = Z_MallocLevel(sizeof(*door)); |
| 1015 |
memset(door, 0, sizeof(*door)); |
| 1016 |
P_AddThinker(&door->thinker); |
| 1017 |
sec->ceilingdata = door; |
| 1018 |
|
| 1019 |
door->thinker.function = T_VerticalDoor; |
| 1020 |
door->sector = sec; |
| 1021 |
door->type = type; |
| 1022 |
door->topwait = topwait; |
| 1023 |
door->topcountdown = topcountdown; |
| 1024 |
door->speed = speed; |
| 1025 |
door->line = line; |
| 1026 |
door->lighttag = lightTag; |
| 1027 |
|
| 1028 |
switch (type) |
| 1029 |
{ |
| 1030 |
case closeDoor: |
| 1031 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1032 |
door->topheight -= 4 * FRACUNIT; |
| 1033 |
door->direction = -1; |
| 1034 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 1035 |
break; |
| 1036 |
case genCdO: |
| 1037 |
door->topheight = sec->ceilingheight; |
| 1038 |
door->direction = -1; |
| 1039 |
door->topwait = topwait; |
| 1040 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 1041 |
break; |
| 1042 |
case normal: |
| 1043 |
case openDoor: |
| 1044 |
door->direction = 1; |
| 1045 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1046 |
door->topheight -= 4 * FRACUNIT; |
| 1047 |
S_StartSectorSound(door->sector, g_sfx_doropn); |
| 1048 |
break; |
| 1049 |
case waitRaiseDoor: |
| 1050 |
door->direction = 2; |
| 1051 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1052 |
door->topheight -= 4 * FRACUNIT; |
| 1053 |
break; |
| 1054 |
case waitCloseDoor: |
| 1055 |
door->direction = 2; |
| 1056 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1057 |
door->topheight -= 4 * FRACUNIT; |
| 1058 |
break; |
| 1059 |
default: |
| 1060 |
break; |
| 1061 |
} |
| 1062 |
} |
| 1063 |
|
| 1064 |
int EV_DoZDoomDoor(vldoor_e type, line_t *line, mobj_t *mo, int tag, fixed_t speed, int topwait, |
| 1065 |
zdoom_lock_t lock, int lightTag, dboolean boomgen, int topcountdown) |
| 1066 |
{ |
| 1067 |
sector_t *sec; |
| 1068 |
vldoor_t *door; |
| 1069 |
|
| 1070 |
speed *= FRACUNIT / 8; |
| 1071 |
|
| 1072 |
if (lock && !P_CheckKeys(mo, lock, true)) |
| 1073 |
return 0; |
| 1074 |
|
| 1075 |
if (!tag) |
| 1076 |
{ |
| 1077 |
if (!line) |
| 1078 |
return 0; |
| 1079 |
|
| 1080 |
// if the wrong side of door is pushed, give oof sound |
| 1081 |
if (line->sidenum[1] == NO_INDEX) |
| 1082 |
{ |
| 1083 |
if (mo->player) // is this check necessary? |
| 1084 |
S_StartMobjSound(mo, sfx_oof); |
| 1085 |
return 0; |
| 1086 |
} |
| 1087 |
|
| 1088 |
// get the sector on the second side of activating linedef |
| 1089 |
sec = sides[line->sidenum[1]].sector; |
| 1090 |
|
| 1091 |
door = sec->ceilingdata; |
| 1092 |
|
| 1093 |
if (door) |
| 1094 |
{ |
| 1095 |
// Boom used remote door logic for generalized doors, even if they are manual |
| 1096 |
if (boomgen) |
| 1097 |
return 0; |
| 1098 |
|
| 1099 |
if (door->thinker.function == T_VerticalDoor) |
| 1100 |
{ |
| 1101 |
// ONLY FOR "RAISE" DOORS, NOT "OPEN"s |
| 1102 |
if (door->type == DREV_NORMAL && type == DREV_NORMAL) |
| 1103 |
{ |
| 1104 |
if (door->direction == -1) |
| 1105 |
{ |
| 1106 |
door->direction = 1; |
| 1107 |
|
| 1108 |
S_StartSectorSound(door->sector, g_sfx_doropn); |
| 1109 |
return 1; |
| 1110 |
} |
| 1111 |
else if (!(line->activation & (SPAC_PUSH | SPAC_MPUSH))) |
| 1112 |
// [RH] activate push doors don't go back down when you |
| 1113 |
// run into them (otherwise opening them would be |
| 1114 |
// a real pain). |
| 1115 |
{ |
| 1116 |
if (!mo->player) |
| 1117 |
return 0; // JDC: bad guys never close doors |
| 1118 |
|
| 1119 |
door->direction = -1; // start going down immediately |
| 1120 |
|
| 1121 |
S_StartSectorSound(door->sector, g_sfx_dorcls); |
| 1122 |
return 1; |
| 1123 |
} |
| 1124 |
else |
| 1125 |
{ |
| 1126 |
return 0; |
| 1127 |
} |
| 1128 |
} |
| 1129 |
} |
| 1130 |
|
| 1131 |
return 0; |
| 1132 |
} |
| 1133 |
|
| 1134 |
P_SpawnZDoomDoor(sec, type, line, speed, topwait, lightTag, topcountdown); |
| 1135 |
return 1; |
| 1136 |
} |
| 1137 |
else |
| 1138 |
{ |
| 1139 |
const int *id_p; |
| 1140 |
int retcode = 0; |
| 1141 |
|
| 1142 |
FIND_SECTORS(id_p, tag) |
| 1143 |
{ |
| 1144 |
sec = §ors[*id_p]; |
| 1145 |
if (sec->ceilingdata) |
| 1146 |
{ |
| 1147 |
continue; |
| 1148 |
} |
| 1149 |
retcode = 1; |
| 1150 |
P_SpawnZDoomDoor(sec, type, line, speed, topwait, lightTag, topcountdown); |
| 1151 |
} |
| 1152 |
|
| 1153 |
return retcode; |
| 1154 |
} |
| 1155 |
} |
| 1156 |
|
| 1157 |
int Hexen_EV_DoDoor(line_t * line, byte * args, vldoor_e type) |
| 1158 |
{ |
| 1159 |
const int *id_p; |
| 1160 |
int retcode; |
| 1161 |
sector_t *sec; |
| 1162 |
vldoor_t *door; |
| 1163 |
fixed_t speed; |
| 1164 |
|
| 1165 |
speed = args[1] * FRACUNIT / 8; |
| 1166 |
retcode = 0; |
| 1167 |
FIND_SECTORS(id_p, args[0]) |
| 1168 |
{ |
| 1169 |
sec = §ors[*id_p]; |
| 1170 |
if (sec->floordata || sec->ceilingdata) |
| 1171 |
{ |
| 1172 |
continue; |
| 1173 |
} |
| 1174 |
// Add new door thinker |
| 1175 |
retcode = 1; |
| 1176 |
door = Z_MallocLevel(sizeof(*door)); |
| 1177 |
memset(door, 0, sizeof(*door)); |
| 1178 |
P_AddThinker(&door->thinker); |
| 1179 |
sec->ceilingdata = door; |
| 1180 |
door->thinker.function = T_VerticalDoor; |
| 1181 |
door->sector = sec; |
| 1182 |
door->line = line; |
| 1183 |
switch (type) |
| 1184 |
{ |
| 1185 |
case DREV_CLOSE: |
| 1186 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1187 |
door->topheight -= 4 * FRACUNIT; |
| 1188 |
door->direction = -1; |
| 1189 |
break; |
| 1190 |
case DREV_CLOSE30THENOPEN: |
| 1191 |
door->topheight = sec->ceilingheight; |
| 1192 |
door->direction = -1; |
| 1193 |
break; |
| 1194 |
case DREV_NORMAL: |
| 1195 |
case DREV_OPEN: |
| 1196 |
door->direction = 1; |
| 1197 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1198 |
door->topheight -= 4 * FRACUNIT; |
| 1199 |
break; |
| 1200 |
default: |
| 1201 |
break; |
| 1202 |
} |
| 1203 |
door->type = type; |
| 1204 |
door->speed = speed; |
| 1205 |
door->topwait = args[2]; |
| 1206 |
SN_StartSequence((mobj_t *) & door->sector->soundorg, |
| 1207 |
SEQ_DOOR_STONE + door->sector->seqType); |
| 1208 |
} |
| 1209 |
return (retcode); |
| 1210 |
} |
| 1211 |
|
| 1212 |
dboolean Hexen_EV_VerticalDoor(line_t * line, mobj_t * thing) |
| 1213 |
{ |
| 1214 |
sector_t *sec; |
| 1215 |
vldoor_t *door; |
| 1216 |
int side; |
| 1217 |
|
| 1218 |
side = 0; // only front sides can be used |
| 1219 |
|
| 1220 |
// if the sector has an active thinker, use it |
| 1221 |
sec = sides[line->sidenum[side ^ 1]].sector; |
| 1222 |
if (sec->floordata || sec->ceilingdata) |
| 1223 |
{ |
| 1224 |
return false; |
| 1225 |
} |
| 1226 |
// |
| 1227 |
// new door thinker |
| 1228 |
// |
| 1229 |
door = Z_MallocLevel(sizeof(*door)); |
| 1230 |
memset(door, 0, sizeof(*door)); |
| 1231 |
P_AddThinker(&door->thinker); |
| 1232 |
sec->ceilingdata = door; |
| 1233 |
door->thinker.function = T_VerticalDoor; |
| 1234 |
door->sector = sec; |
| 1235 |
door->line = line; |
| 1236 |
door->direction = 1; |
| 1237 |
switch (line->special) |
| 1238 |
{ |
| 1239 |
case 11: |
| 1240 |
door->type = DREV_OPEN; |
| 1241 |
line->special = 0; |
| 1242 |
break; |
| 1243 |
case 12: |
| 1244 |
case 13: |
| 1245 |
door->type = DREV_NORMAL; |
| 1246 |
break; |
| 1247 |
default: |
| 1248 |
door->type = DREV_NORMAL; |
| 1249 |
break; |
| 1250 |
} |
| 1251 |
door->speed = line->special_args[1] * (FRACUNIT / 8); |
| 1252 |
door->topwait = line->special_args[2]; |
| 1253 |
|
| 1254 |
// |
| 1255 |
// find the top and bottom of the movement range |
| 1256 |
// |
| 1257 |
door->topheight = P_FindLowestCeilingSurrounding(sec); |
| 1258 |
door->topheight -= 4 * FRACUNIT; |
| 1259 |
SN_StartSequence((mobj_t *) & door->sector->soundorg, |
| 1260 |
SEQ_DOOR_STONE + door->sector->seqType); |
| 1261 |
return true; |
| 1262 |
} |