| 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 |
* Game completion, final screen animation. |
| 31 |
* |
| 32 |
*----------------------------------------------------------------------------- |
| 33 |
*/ |
| 34 |
|
| 35 |
#include "doomstat.h" |
| 36 |
#include "d_event.h" |
| 37 |
#include "g_game.h" |
| 38 |
#include "lprintf.h" |
| 39 |
#include "v_video.h" |
| 40 |
#include "w_wad.h" |
| 41 |
#include "s_sound.h" |
| 42 |
#include "sounds.h" |
| 43 |
#include "d_deh.h" // Ty 03/22/98 - externalizations |
| 44 |
|
| 45 |
#include "heretic/f_finale.h" |
| 46 |
#include "hexen/f_finale.h" |
| 47 |
|
| 48 |
#include "dsda/font.h" |
| 49 |
#include "dsda/mapinfo.h" |
| 50 |
|
| 51 |
#include "f_finale.h" // CPhipps - hmm... |
| 52 |
|
| 53 |
// defines for the end mission display text // phares |
| 54 |
|
| 55 |
#define TEXTSPEED 3 // original value // phares |
| 56 |
#define TEXTWAIT 250 // original value // phares |
| 57 |
#define NEWTEXTSPEED 0.01f // new value // phares |
| 58 |
#define NEWTEXTWAIT 1000 // new value // phares |
| 59 |
|
| 60 |
// Stage of animation: |
| 61 |
// 0 = text, 1 = art screen, 2 = character cast |
| 62 |
int finalestage; |
| 63 |
int finalecount; |
| 64 |
const char* finaletext; |
| 65 |
const char* finaleflat; |
| 66 |
const char* finalepatch; |
| 67 |
|
| 68 |
// defines for the end mission display text // phares |
| 69 |
|
| 70 |
// CPhipps - removed the old finale screen text message strings; |
| 71 |
// they were commented out for ages already |
| 72 |
// Ty 03/22/98 - ... the new s_WHATEVER extern variables are used |
| 73 |
// in the code below instead. |
| 74 |
|
| 75 |
void F_CastTicker (void); |
| 76 |
dboolean F_CastResponder (event_t *ev); |
| 77 |
void F_CastDrawer (void); |
| 78 |
|
| 79 |
void WI_checkForAccelerate(void); // killough 3/28/98: used to |
| 80 |
extern int acceleratestage; // accelerate intermission screens |
| 81 |
int midstage; // whether we're in "mid-stage" |
| 82 |
|
| 83 |
// |
| 84 |
// F_StartFinale |
| 85 |
// |
| 86 |
void F_StartFinale (void) |
| 87 |
{ |
| 88 |
int mnum; |
| 89 |
int muslump; |
| 90 |
|
| 91 |
if (heretic) return Heretic_F_StartFinale(); |
| 92 |
if (hexen) return Hexen_F_StartFinale(); |
| 93 |
|
| 94 |
gameaction = ga_nothing; |
| 95 |
gamestate = GS_FINALE; |
| 96 |
automap_active = false; |
| 97 |
|
| 98 |
// killough 3/28/98: clear accelerative text flags |
| 99 |
acceleratestage = midstage = 0; |
| 100 |
|
| 101 |
finaletext = NULL; |
| 102 |
finaleflat = NULL; |
| 103 |
finalepatch = NULL; |
| 104 |
|
| 105 |
dsda_InterMusic(&mnum, &muslump); |
| 106 |
|
| 107 |
if (muslump >= 0) |
| 108 |
{ |
| 109 |
S_ChangeMusInfoMusic(muslump, true); |
| 110 |
} |
| 111 |
else |
| 112 |
{ |
| 113 |
S_ChangeMusic(mnum, true); |
| 114 |
} |
| 115 |
|
| 116 |
// Okay - IWAD dependend stuff. |
| 117 |
// This has been changed severly, and |
| 118 |
// some stuff might have changed in the process. |
| 119 |
switch ( gamemode ) |
| 120 |
{ |
| 121 |
// DOOM 1 - E1, E3 or E4, but each nine missions |
| 122 |
case shareware: |
| 123 |
case registered: |
| 124 |
case retail: |
| 125 |
{ |
| 126 |
switch (gameepisode) |
| 127 |
{ |
| 128 |
case 1: |
| 129 |
finaleflat = bgflatE1; // Ty 03/30/98 - new externalized bg flats |
| 130 |
finaletext = s_E1TEXT; // Ty 03/23/98 - Was e1text variable. |
| 131 |
break; |
| 132 |
case 2: |
| 133 |
finaleflat = bgflatE2; |
| 134 |
finaletext = s_E2TEXT; // Ty 03/23/98 - Same stuff for each |
| 135 |
break; |
| 136 |
case 3: |
| 137 |
finaleflat = bgflatE3; |
| 138 |
finaletext = s_E3TEXT; |
| 139 |
break; |
| 140 |
case 4: |
| 141 |
finaleflat = bgflatE4; |
| 142 |
finaletext = s_E4TEXT; |
| 143 |
break; |
| 144 |
default: |
| 145 |
// Ouch. |
| 146 |
break; |
| 147 |
} |
| 148 |
break; |
| 149 |
} |
| 150 |
|
| 151 |
// DOOM II and missions packs with E1, M34 |
| 152 |
case commercial: |
| 153 |
{ |
| 154 |
// Ty 08/27/98 - added the gamemission logic |
| 155 |
switch (gamemap) |
| 156 |
{ |
| 157 |
case 6: |
| 158 |
finaleflat = bgflat06; |
| 159 |
finaletext = (gamemission==pack_tnt) ? s_T1TEXT : |
| 160 |
(gamemission==pack_plut) ? s_P1TEXT : s_C1TEXT; |
| 161 |
break; |
| 162 |
case 11: |
| 163 |
finaleflat = bgflat11; |
| 164 |
finaletext = (gamemission==pack_tnt) ? s_T2TEXT : |
| 165 |
(gamemission==pack_plut) ? s_P2TEXT : s_C2TEXT; |
| 166 |
break; |
| 167 |
case 20: |
| 168 |
finaleflat = bgflat20; |
| 169 |
finaletext = (gamemission==pack_tnt) ? s_T3TEXT : |
| 170 |
(gamemission==pack_plut) ? s_P3TEXT : s_C3TEXT; |
| 171 |
break; |
| 172 |
case 30: |
| 173 |
finaleflat = bgflat30; |
| 174 |
finaletext = (gamemission==pack_tnt) ? s_T4TEXT : |
| 175 |
(gamemission==pack_plut) ? s_P4TEXT : s_C4TEXT; |
| 176 |
break; |
| 177 |
case 15: |
| 178 |
finaleflat = bgflat15; |
| 179 |
finaletext = (gamemission==pack_tnt) ? s_T5TEXT : |
| 180 |
(gamemission==pack_plut) ? s_P5TEXT : s_C5TEXT; |
| 181 |
break; |
| 182 |
case 31: |
| 183 |
finaleflat = bgflat31; |
| 184 |
finaletext = (gamemission==pack_tnt) ? s_T6TEXT : |
| 185 |
(gamemission==pack_plut) ? s_P6TEXT : s_C6TEXT; |
| 186 |
break; |
| 187 |
default: |
| 188 |
// Ouch. |
| 189 |
break; |
| 190 |
} |
| 191 |
if (gamemission == pack_nerve && gamemap == 8) |
| 192 |
{ |
| 193 |
finaleflat = bgflat06; |
| 194 |
finaletext = s_C6TEXT; |
| 195 |
} |
| 196 |
break; |
| 197 |
// Ty 08/27/98 - end gamemission logic |
| 198 |
} |
| 199 |
|
| 200 |
// Indeterminate. |
| 201 |
default: // Ty 03/30/98 - not externalized |
| 202 |
finaleflat = "F_SKY1"; // Not used anywhere else. |
| 203 |
finaletext = s_C1TEXT; // FIXME - other text, music? |
| 204 |
break; |
| 205 |
} |
| 206 |
|
| 207 |
if (dsda_FinaleShortcut()) { |
| 208 |
switch (gamemode) { |
| 209 |
case shareware: |
| 210 |
case registered: |
| 211 |
case retail: |
| 212 |
switch (gameepisode) { |
| 213 |
case 1: |
| 214 |
finaleflat = bgflatE1; |
| 215 |
finaletext = s_E1TEXT; |
| 216 |
break; |
| 217 |
case 2: |
| 218 |
finaleflat = bgflatE2; |
| 219 |
finaletext = s_E2TEXT; |
| 220 |
break; |
| 221 |
case 3: |
| 222 |
finaleflat = bgflatE3; |
| 223 |
finaletext = s_E3TEXT; |
| 224 |
break; |
| 225 |
case 4: |
| 226 |
default: |
| 227 |
finaleflat = bgflatE4; |
| 228 |
finaletext = s_E4TEXT; |
| 229 |
break; |
| 230 |
} |
| 231 |
break; |
| 232 |
case commercial: |
| 233 |
if (gamemission == pack_nerve) { |
| 234 |
finaleflat = bgflat06; |
| 235 |
finaletext = s_C6TEXT; |
| 236 |
} |
| 237 |
else { |
| 238 |
finaleflat = bgflat30; |
| 239 |
finaletext = (gamemission == pack_tnt) ? s_T4TEXT : |
| 240 |
(gamemission == pack_plut) ? s_P4TEXT : s_C4TEXT; |
| 241 |
} |
| 242 |
break; |
| 243 |
case indetermined: |
| 244 |
break; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
dsda_StartFinale(); |
| 249 |
|
| 250 |
finalestage = 0; |
| 251 |
finalecount = 0; |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
dboolean F_Responder (event_t *event) |
| 257 |
{ |
| 258 |
if (heretic) return Heretic_F_Responder(event); |
| 259 |
if (hexen) return Hexen_F_Responder(event); |
| 260 |
|
| 261 |
if (finalestage == 2) |
| 262 |
return F_CastResponder (event); |
| 263 |
|
| 264 |
return false; |
| 265 |
} |
| 266 |
|
| 267 |
// Get_TextSpeed() returns the value of the text display speed // phares |
| 268 |
// Rewritten to allow user-directed acceleration -- killough 3/28/98 |
| 269 |
|
| 270 |
float Get_TextSpeed(void) |
| 271 |
{ |
| 272 |
return midstage ? NEWTEXTSPEED : (midstage=acceleratestage) ? |
| 273 |
acceleratestage=0, NEWTEXTSPEED : TEXTSPEED; |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
// |
| 278 |
// F_Ticker |
| 279 |
// |
| 280 |
// killough 3/28/98: almost totally rewritten, to use |
| 281 |
// player-directed acceleration instead of constant delays. |
| 282 |
// Now the player can accelerate the text display by using |
| 283 |
// the fire/use keys while it is being printed. The delay |
| 284 |
// automatically responds to the user, and gives enough |
| 285 |
// time to read. |
| 286 |
// |
| 287 |
// killough 5/10/98: add back v1.9 demo compatibility |
| 288 |
// |
| 289 |
|
| 290 |
dboolean F_ShowCast(void) |
| 291 |
{ |
| 292 |
return gamemap == 30 || |
| 293 |
(gamemission == pack_nerve && allow_incompatibility && gamemap == 8) || |
| 294 |
dsda_FinaleShortcut(); |
| 295 |
} |
| 296 |
|
| 297 |
void F_Ticker(void) |
| 298 |
{ |
| 299 |
int i; |
| 300 |
|
| 301 |
if (heretic) return Heretic_F_Ticker(); |
| 302 |
if (hexen) return Hexen_F_Ticker(); |
| 303 |
|
| 304 |
if (dsda_FTicker()) |
| 305 |
{ |
| 306 |
return; |
| 307 |
} |
| 308 |
|
| 309 |
if (!demo_compatibility) |
| 310 |
WI_checkForAccelerate(); // killough 3/28/98: check for acceleration |
| 311 |
else |
| 312 |
if (gamemode == commercial && finalecount > 50) // check for skipping |
| 313 |
for (i = 0; i < g_maxplayers; i++) |
| 314 |
if (players[i].cmd.buttons) |
| 315 |
goto next_level; // go on to the next level |
| 316 |
|
| 317 |
// advance animation |
| 318 |
finalecount++; |
| 319 |
|
| 320 |
if (finalestage == 2) |
| 321 |
F_CastTicker(); |
| 322 |
|
| 323 |
if (!finalestage) |
| 324 |
{ |
| 325 |
float speed = demo_compatibility ? TEXTSPEED : Get_TextSpeed(); |
| 326 |
/* killough 2/28/98: changed to allow acceleration */ |
| 327 |
if (finalecount > strlen(finaletext)*speed + |
| 328 |
(midstage ? NEWTEXTWAIT : TEXTWAIT) || |
| 329 |
(midstage && acceleratestage)) { |
| 330 |
if (gamemode != commercial) // Doom 1 / Ultimate Doom episode end |
| 331 |
{ // with enough time, it's automatic |
| 332 |
if (gameepisode == 3) |
| 333 |
F_StartScroll(NULL, NULL, NULL, true); |
| 334 |
else |
| 335 |
F_StartPostFinale(); |
| 336 |
} |
| 337 |
else // you must press a button to continue in Doom 2 |
| 338 |
if (!demo_compatibility && midstage) |
| 339 |
{ |
| 340 |
next_level: |
| 341 |
if (F_ShowCast()) |
| 342 |
F_StartCast(NULL, NULL, true); // cast of Doom 2 characters |
| 343 |
else |
| 344 |
gameaction = ga_worlddone; // next level, e.g. MAP07 |
| 345 |
} |
| 346 |
} |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
// |
| 351 |
// F_TextWrite |
| 352 |
// |
| 353 |
// This program displays the background and text at end-mission // phares |
| 354 |
// text time. It draws both repeatedly so that other displays, // | |
| 355 |
// like the main menu, can be drawn over it dynamically and // V |
| 356 |
// erased dynamically. The TEXTSPEED constant is changed into |
| 357 |
// the Get_TextSpeed function so that the speed of writing the // ^ |
| 358 |
// text can be increased, and there's still time to read what's // | |
| 359 |
// written. // phares |
| 360 |
// CPhipps - reformatted |
| 361 |
|
| 362 |
#include "hu_stuff.h" |
| 363 |
|
| 364 |
void F_TextWrite (void) |
| 365 |
{ |
| 366 |
if (finalepatch) |
| 367 |
{ |
| 368 |
V_ClearBorder(); |
| 369 |
V_DrawNamePatchFS(0, 0, 0, finalepatch, CR_DEFAULT, VPT_STRETCH); |
| 370 |
} |
| 371 |
else |
| 372 |
V_DrawBackground(finaleflat, 0); |
| 373 |
|
| 374 |
{ // draw some of the text onto the screen |
| 375 |
int cx = 10; |
| 376 |
int cy = 10; |
| 377 |
const char* ch = finaletext; // CPhipps - const |
| 378 |
int count = (int)((float)(finalecount - 10)/Get_TextSpeed()); // phares |
| 379 |
int w; |
| 380 |
|
| 381 |
if (count < 0) |
| 382 |
count = 0; |
| 383 |
|
| 384 |
for ( ; count ; count-- ) { |
| 385 |
int c = *ch++; |
| 386 |
|
| 387 |
if (!c) |
| 388 |
break; |
| 389 |
|
| 390 |
if (c == '\n') { |
| 391 |
cx = 10; |
| 392 |
cy += 11; |
| 393 |
continue; |
| 394 |
} |
| 395 |
|
| 396 |
c = toupper(c) - HU_FONTSTART; |
| 397 |
if (c < 0 || c> HU_FONTSIZE) { |
| 398 |
cx += 4; |
| 399 |
continue; |
| 400 |
} |
| 401 |
|
| 402 |
w = hud_font.font[c].width; |
| 403 |
if (cx+w > SCREENWIDTH) |
| 404 |
break; |
| 405 |
|
| 406 |
// CPhipps - patch drawing updated |
| 407 |
V_DrawNumPatch(cx, cy, 0, hud_font.font[c].lumpnum, CR_DEFAULT, VPT_STRETCH); |
| 408 |
cx+=w; |
| 409 |
} |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
// |
| 414 |
// Final DOOM 2 animation |
| 415 |
// Casting by id Software. |
| 416 |
// in order of appearance |
| 417 |
// |
| 418 |
typedef struct |
| 419 |
{ |
| 420 |
const char **name; // CPhipps - const** |
| 421 |
mobjtype_t type; |
| 422 |
} castinfo_t; |
| 423 |
|
| 424 |
static const castinfo_t castorder_d2[] = { |
| 425 |
{ &s_CC_ZOMBIE, MT_POSSESSED }, |
| 426 |
{ &s_CC_SHOTGUN, MT_SHOTGUY }, |
| 427 |
{ &s_CC_HEAVY, MT_CHAINGUY }, |
| 428 |
{ &s_CC_IMP, MT_TROOP }, |
| 429 |
{ &s_CC_DEMON, MT_SERGEANT }, |
| 430 |
{ &s_CC_LOST, MT_SKULL }, |
| 431 |
{ &s_CC_CACO, MT_HEAD }, |
| 432 |
{ &s_CC_HELL, MT_KNIGHT }, |
| 433 |
{ &s_CC_BARON, MT_BRUISER }, |
| 434 |
{ &s_CC_ARACH, MT_BABY }, |
| 435 |
{ &s_CC_PAIN, MT_PAIN }, |
| 436 |
{ &s_CC_REVEN, MT_UNDEAD }, |
| 437 |
{ &s_CC_MANCU, MT_FATSO }, |
| 438 |
{ &s_CC_ARCH, MT_VILE }, |
| 439 |
{ &s_CC_SPIDER, MT_SPIDER }, |
| 440 |
{ &s_CC_CYBER, MT_CYBORG }, |
| 441 |
{ &s_CC_HERO, MT_PLAYER }, |
| 442 |
{ NULL, 0 } |
| 443 |
}; |
| 444 |
|
| 445 |
static const castinfo_t castorder_d1[] = { |
| 446 |
{ &s_CC_ZOMBIE, MT_POSSESSED }, |
| 447 |
{ &s_CC_SHOTGUN, MT_SHOTGUY }, |
| 448 |
{ &s_CC_IMP, MT_TROOP }, |
| 449 |
{ &s_CC_DEMON, MT_SERGEANT }, |
| 450 |
{ &s_CC_LOST, MT_SKULL }, |
| 451 |
{ &s_CC_CACO, MT_HEAD }, |
| 452 |
{ &s_CC_BARON, MT_BRUISER }, |
| 453 |
{ &s_CC_SPIDER, MT_SPIDER }, |
| 454 |
{ &s_CC_CYBER, MT_CYBORG }, |
| 455 |
{ &s_CC_HERO, MT_PLAYER }, |
| 456 |
{ NULL, 0 } |
| 457 |
}; |
| 458 |
|
| 459 |
static const castinfo_t *castorder = castorder_d2; |
| 460 |
|
| 461 |
static int castnum; |
| 462 |
static int casttics; |
| 463 |
static state_t* caststate; |
| 464 |
static dboolean castdeath; |
| 465 |
static int castframes; |
| 466 |
static int castonmelee; |
| 467 |
static dboolean castattacking; |
| 468 |
static const char *castbackground; |
| 469 |
|
| 470 |
// |
| 471 |
// F_StartCast |
| 472 |
// |
| 473 |
|
| 474 |
static void F_StartCastMusic(const char* music, dboolean loop_music) |
| 475 |
{ |
| 476 |
if (music) |
| 477 |
{ |
| 478 |
if (!S_ChangeMusicByName(music, loop_music)) |
| 479 |
lprintf(LO_WARN, "Finale cast music not found: %s\n", music); |
| 480 |
} |
| 481 |
else if (gamemode == commercial) |
| 482 |
{ |
| 483 |
S_ChangeMusic(mus_evil, loop_music); |
| 484 |
} |
| 485 |
else |
| 486 |
{ |
| 487 |
lprintf(LO_WARN, "Finale cast music unspecified\n"); |
| 488 |
S_StopMusic(); |
| 489 |
} |
| 490 |
} |
| 491 |
|
| 492 |
void F_StartCast (const char* background, const char* music, dboolean loop_music) |
| 493 |
{ |
| 494 |
castorder = (gamemode == commercial ? castorder_d2 : castorder_d1); |
| 495 |
castbackground = (background ? background : bgcastcall); |
| 496 |
|
| 497 |
wipegamestate = -1; // force a screen wipe |
| 498 |
castnum = 0; |
| 499 |
caststate = &states[mobjinfo[castorder[castnum].type].seestate]; |
| 500 |
casttics = caststate->tics; |
| 501 |
castdeath = false; |
| 502 |
finalestage = 2; |
| 503 |
castframes = 0; |
| 504 |
castonmelee = 0; |
| 505 |
castattacking = false; |
| 506 |
|
| 507 |
F_StartCastMusic(music, loop_music); |
| 508 |
} |
| 509 |
|
| 510 |
// |
| 511 |
// F_CastTicker |
| 512 |
// |
| 513 |
void F_CastTicker (void) |
| 514 |
{ |
| 515 |
int st; |
| 516 |
int sfx; |
| 517 |
|
| 518 |
if (--casttics > 0) |
| 519 |
return; // not time to change state yet |
| 520 |
|
| 521 |
if (caststate->tics == -1 || caststate->nextstate == S_NULL) |
| 522 |
{ |
| 523 |
// switch from deathstate to next monster |
| 524 |
castnum++; |
| 525 |
castdeath = false; |
| 526 |
if (castorder[castnum].name == NULL) |
| 527 |
castnum = 0; |
| 528 |
if (mobjinfo[castorder[castnum].type].seesound) |
| 529 |
S_StartVoidSound(mobjinfo[castorder[castnum].type].seesound); |
| 530 |
caststate = &states[mobjinfo[castorder[castnum].type].seestate]; |
| 531 |
castframes = 0; |
| 532 |
} |
| 533 |
else |
| 534 |
{ |
| 535 |
// just advance to next state in animation |
| 536 |
if (caststate == &states[S_PLAY_ATK1]) |
| 537 |
goto stopattack; // Oh, gross hack! |
| 538 |
st = caststate->nextstate; |
| 539 |
caststate = &states[st]; |
| 540 |
castframes++; |
| 541 |
|
| 542 |
// sound hacks.... |
| 543 |
switch (st) |
| 544 |
{ |
| 545 |
case S_PLAY_ATK1: sfx = sfx_dshtgn; break; |
| 546 |
case S_POSS_ATK2: sfx = sfx_pistol; break; |
| 547 |
case S_SPOS_ATK2: sfx = sfx_shotgn; break; |
| 548 |
case S_VILE_ATK2: sfx = sfx_vilatk; break; |
| 549 |
case S_SKEL_FIST2: sfx = sfx_skeswg; break; |
| 550 |
case S_SKEL_FIST4: sfx = sfx_skepch; break; |
| 551 |
case S_SKEL_MISS2: sfx = sfx_skeatk; break; |
| 552 |
case S_FATT_ATK8: |
| 553 |
case S_FATT_ATK5: |
| 554 |
case S_FATT_ATK2: sfx = sfx_firsht; break; |
| 555 |
case S_CPOS_ATK2: |
| 556 |
case S_CPOS_ATK3: |
| 557 |
case S_CPOS_ATK4: sfx = sfx_shotgn; break; |
| 558 |
case S_TROO_ATK3: sfx = sfx_claw; break; |
| 559 |
case S_SARG_ATK2: sfx = sfx_sgtatk; break; |
| 560 |
case S_BOSS_ATK2: |
| 561 |
case S_BOS2_ATK2: |
| 562 |
case S_HEAD_ATK2: sfx = sfx_firsht; break; |
| 563 |
case S_SKULL_ATK2: sfx = sfx_sklatk; break; |
| 564 |
case S_SPID_ATK2: |
| 565 |
case S_SPID_ATK3: sfx = sfx_shotgn; break; |
| 566 |
case S_BSPI_ATK2: sfx = sfx_plasma; break; |
| 567 |
case S_CYBER_ATK2: |
| 568 |
case S_CYBER_ATK4: |
| 569 |
case S_CYBER_ATK6: sfx = sfx_rlaunc; break; |
| 570 |
case S_PAIN_ATK3: sfx = sfx_sklatk; break; |
| 571 |
default: sfx = 0; break; |
| 572 |
} |
| 573 |
|
| 574 |
if (sfx) |
| 575 |
S_StartVoidSound(sfx); |
| 576 |
} |
| 577 |
|
| 578 |
if (castframes == 12) |
| 579 |
{ |
| 580 |
// go into attack frame |
| 581 |
castattacking = true; |
| 582 |
if (castonmelee) |
| 583 |
caststate=&states[mobjinfo[castorder[castnum].type].meleestate]; |
| 584 |
else |
| 585 |
caststate=&states[mobjinfo[castorder[castnum].type].missilestate]; |
| 586 |
castonmelee ^= 1; |
| 587 |
if (caststate == &states[S_NULL]) |
| 588 |
{ |
| 589 |
if (castonmelee) |
| 590 |
caststate= |
| 591 |
&states[mobjinfo[castorder[castnum].type].meleestate]; |
| 592 |
else |
| 593 |
caststate= |
| 594 |
&states[mobjinfo[castorder[castnum].type].missilestate]; |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
if (castattacking) |
| 599 |
{ |
| 600 |
if (castframes == 24 |
| 601 |
|| caststate == &states[mobjinfo[castorder[castnum].type].seestate] ) |
| 602 |
{ |
| 603 |
stopattack: |
| 604 |
castattacking = false; |
| 605 |
castframes = 0; |
| 606 |
caststate = &states[mobjinfo[castorder[castnum].type].seestate]; |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
casttics = caststate->tics; |
| 611 |
if (casttics == -1) |
| 612 |
casttics = 15; |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
// |
| 617 |
// F_CastResponder |
| 618 |
// |
| 619 |
|
| 620 |
dboolean F_CastResponder (event_t* ev) |
| 621 |
{ |
| 622 |
if (ev->type != ev_keydown) |
| 623 |
return false; |
| 624 |
|
| 625 |
if (castdeath) |
| 626 |
return true; // already in dying frames |
| 627 |
|
| 628 |
// go into death frame |
| 629 |
castdeath = true; |
| 630 |
caststate = &states[mobjinfo[castorder[castnum].type].deathstate]; |
| 631 |
casttics = caststate->tics; |
| 632 |
castframes = 0; |
| 633 |
castattacking = false; |
| 634 |
if (mobjinfo[castorder[castnum].type].deathsound) |
| 635 |
S_StartVoidSound(mobjinfo[castorder[castnum].type].deathsound); |
| 636 |
|
| 637 |
return true; |
| 638 |
} |
| 639 |
|
| 640 |
|
| 641 |
static void F_CastPrint (const char* text) // CPhipps - static, const char* |
| 642 |
{ |
| 643 |
const char* ch; // CPhipps - const |
| 644 |
int c; |
| 645 |
int cx; |
| 646 |
int w; |
| 647 |
int width; |
| 648 |
|
| 649 |
// find width |
| 650 |
ch = text; |
| 651 |
width = 0; |
| 652 |
|
| 653 |
while (ch) |
| 654 |
{ |
| 655 |
c = *ch++; |
| 656 |
if (!c) |
| 657 |
break; |
| 658 |
c = toupper(c) - HU_FONTSTART; |
| 659 |
if (c < 0 || c> HU_FONTSIZE) |
| 660 |
{ |
| 661 |
width += 4; |
| 662 |
continue; |
| 663 |
} |
| 664 |
|
| 665 |
w = hud_font.font[c].width; |
| 666 |
width += w; |
| 667 |
} |
| 668 |
|
| 669 |
// draw it |
| 670 |
cx = 160-width/2; |
| 671 |
ch = text; |
| 672 |
while (ch) |
| 673 |
{ |
| 674 |
c = *ch++; |
| 675 |
if (!c) |
| 676 |
break; |
| 677 |
c = toupper(c) - HU_FONTSTART; |
| 678 |
if (c < 0 || c> HU_FONTSIZE) |
| 679 |
{ |
| 680 |
cx += 4; |
| 681 |
continue; |
| 682 |
} |
| 683 |
|
| 684 |
w = hud_font.font[c].width; |
| 685 |
// CPhipps - patch drawing updated |
| 686 |
V_DrawNumPatch(cx, 180, 0, hud_font.font[c].lumpnum, CR_DEFAULT, VPT_STRETCH); |
| 687 |
cx+=w; |
| 688 |
} |
| 689 |
} |
| 690 |
|
| 691 |
|
| 692 |
// |
| 693 |
// F_CastDrawer |
| 694 |
// |
| 695 |
|
| 696 |
void F_CastDrawer (void) |
| 697 |
{ |
| 698 |
spritedef_t* sprdef; |
| 699 |
spriteframe_t* sprframe; |
| 700 |
int lump; |
| 701 |
dboolean flip; |
| 702 |
|
| 703 |
// e6y: wide-res |
| 704 |
V_ClearBorder(); |
| 705 |
// erase the entire screen to a background |
| 706 |
// CPhipps - patch drawing updated |
| 707 |
V_DrawNamePatchFS(0,0,0, castbackground, CR_DEFAULT, VPT_STRETCH); // Ty 03/30/98 bg texture extern |
| 708 |
|
| 709 |
F_CastPrint (*(castorder[castnum].name)); |
| 710 |
|
| 711 |
// draw the current frame in the middle of the screen |
| 712 |
sprdef = &sprites[caststate->sprite]; |
| 713 |
sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK]; |
| 714 |
lump = sprframe->lump[0]; |
| 715 |
flip = (dboolean)(sprframe->flip & 1); |
| 716 |
|
| 717 |
// CPhipps - patch drawing updated |
| 718 |
V_DrawNumPatch(160, 170, 0, lump+firstspritelump, CR_DEFAULT, |
| 719 |
VPT_STRETCH | (flip ? VPT_FLIP : 0)); |
| 720 |
} |
| 721 |
|
| 722 |
// |
| 723 |
// F_BunnyScroll |
| 724 |
// |
| 725 |
static const char* pfub1 = "PFUB1"; |
| 726 |
static const char* pfub2 = "PFUB2"; |
| 727 |
|
| 728 |
static const char* scrollpic1; |
| 729 |
static const char* scrollpic2; |
| 730 |
|
| 731 |
static void F_StartScrollMusic(const char* music, dboolean loop_music) |
| 732 |
{ |
| 733 |
if (music) { |
| 734 |
if (!S_ChangeMusicByName(music, loop_music)) |
| 735 |
lprintf(LO_WARN, "Finale scroll music not found: %s\n", music); |
| 736 |
} |
| 737 |
else if (W_LumpNameExists("D_BUNNY")) |
| 738 |
S_ChangeMusic(mus_bunny, loop_music); |
| 739 |
else { |
| 740 |
lprintf(LO_WARN, "Finale scroll music unspecified\n"); |
| 741 |
S_StopMusic(); |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
static dboolean end_patches_exist; |
| 746 |
|
| 747 |
void F_StartScroll (const char* right, const char* left, const char* music, dboolean loop_music) |
| 748 |
{ |
| 749 |
wipegamestate = -1; // force a wipe |
| 750 |
scrollpic1 = right ? right : pfub1; |
| 751 |
scrollpic2 = left ? left : pfub2; |
| 752 |
finalecount = 0; |
| 753 |
finalestage = 1; |
| 754 |
|
| 755 |
end_patches_exist = W_CheckNumForName("END0") != LUMP_NOT_FOUND && |
| 756 |
W_CheckNumForName("END1") != LUMP_NOT_FOUND && |
| 757 |
W_CheckNumForName("END2") != LUMP_NOT_FOUND && |
| 758 |
W_CheckNumForName("END3") != LUMP_NOT_FOUND && |
| 759 |
W_CheckNumForName("END4") != LUMP_NOT_FOUND && |
| 760 |
W_CheckNumForName("END5") != LUMP_NOT_FOUND && |
| 761 |
W_CheckNumForName("END6") != LUMP_NOT_FOUND; |
| 762 |
|
| 763 |
F_StartScrollMusic(music, loop_music); |
| 764 |
} |
| 765 |
|
| 766 |
void F_BunnyScroll (void) |
| 767 |
{ |
| 768 |
char name[10]; |
| 769 |
int stage; |
| 770 |
static int laststage; |
| 771 |
static int p1offset, p2width; |
| 772 |
|
| 773 |
if (finalecount == 0) |
| 774 |
{ |
| 775 |
const rpatch_t *p1, *p2; |
| 776 |
p1 = R_PatchByName(scrollpic1); |
| 777 |
p2 = R_PatchByName(scrollpic2); |
| 778 |
|
| 779 |
p2width = p2->width; |
| 780 |
if (p1->width == 320) |
| 781 |
{ |
| 782 |
// Unity or original PFUBs. |
| 783 |
p1offset = (p2width - 320) / 2; |
| 784 |
} |
| 785 |
else |
| 786 |
{ |
| 787 |
// Widescreen mod PFUBs. |
| 788 |
p1offset = 0; |
| 789 |
} |
| 790 |
} |
| 791 |
|
| 792 |
{ |
| 793 |
int scrolled = 320 - (finalecount-230)/2; |
| 794 |
if (scrolled <= 0) { |
| 795 |
V_DrawNamePatchFS(0, 0, 0, scrollpic2, CR_DEFAULT, VPT_STRETCH); |
| 796 |
} else if (scrolled >= 320) { |
| 797 |
V_DrawNamePatchFS(p1offset, 0, 0, scrollpic1, CR_DEFAULT, VPT_STRETCH); |
| 798 |
if (p1offset > 0) |
| 799 |
V_DrawNamePatchFS(-320, 0, 0, scrollpic2, CR_DEFAULT, VPT_STRETCH); |
| 800 |
} else { |
| 801 |
V_DrawNamePatchFS(p1offset + 320 - scrolled, 0, 0, scrollpic1, CR_DEFAULT, VPT_STRETCH); |
| 802 |
V_DrawNamePatchFS(-scrolled, 0, 0, scrollpic2, CR_DEFAULT, VPT_STRETCH); |
| 803 |
} |
| 804 |
if (p2width == 320) |
| 805 |
V_ClearBorder(); |
| 806 |
} |
| 807 |
|
| 808 |
if (!end_patches_exist) |
| 809 |
return; |
| 810 |
|
| 811 |
if (finalecount < 1130) |
| 812 |
return; |
| 813 |
if (finalecount < 1180) |
| 814 |
{ |
| 815 |
// CPhipps - patch drawing updated |
| 816 |
V_DrawNamePatch((320-13*8)/2, (200-8*8)/2,0, "END0", CR_DEFAULT, VPT_STRETCH); |
| 817 |
laststage = 0; |
| 818 |
return; |
| 819 |
} |
| 820 |
|
| 821 |
stage = (finalecount-1180) / 5; |
| 822 |
if (stage > 6) |
| 823 |
stage = 6; |
| 824 |
if (stage > laststage) |
| 825 |
{ |
| 826 |
S_StartVoidSound(sfx_pistol); |
| 827 |
laststage = stage; |
| 828 |
} |
| 829 |
|
| 830 |
snprintf(name, sizeof name, "END%i", stage); |
| 831 |
// CPhipps - patch drawing updated |
| 832 |
V_DrawNamePatch((320-13*8)/2, (200-8*8)/2, 0, name, CR_DEFAULT, VPT_STRETCH); |
| 833 |
} |
| 834 |
|
| 835 |
void F_StartPostFinale (void) |
| 836 |
{ |
| 837 |
finalecount = 0; |
| 838 |
finalestage = 1; |
| 839 |
wipegamestate = -1; // force a wipe |
| 840 |
} |
| 841 |
|
| 842 |
// |
| 843 |
// F_Drawer |
| 844 |
// |
| 845 |
void F_Drawer (void) |
| 846 |
{ |
| 847 |
if (heretic) return Heretic_F_Drawer(); |
| 848 |
if (hexen) return Hexen_F_Drawer(); |
| 849 |
|
| 850 |
if (dsda_FDrawer()) |
| 851 |
{ |
| 852 |
return; |
| 853 |
} |
| 854 |
|
| 855 |
if (finalestage == 2) |
| 856 |
{ |
| 857 |
F_CastDrawer (); |
| 858 |
return; |
| 859 |
} |
| 860 |
|
| 861 |
if (!finalestage) |
| 862 |
F_TextWrite (); |
| 863 |
else |
| 864 |
{ |
| 865 |
const char* finalelump = NULL; |
| 866 |
|
| 867 |
// Allows use of HELP2 screen for PWADs under DOOM 1 |
| 868 |
dboolean showhelp2 = (gamemode == retail && pwad_help2_check) || gamemode <= registered; |
| 869 |
|
| 870 |
switch (gameepisode) |
| 871 |
{ |
| 872 |
// CPhipps - patch drawing updated |
| 873 |
case 1: |
| 874 |
finalelump = showhelp2 ? "HELP2" : "CREDIT"; |
| 875 |
break; |
| 876 |
case 2: |
| 877 |
finalelump = "VICTORY2"; |
| 878 |
break; |
| 879 |
case 3: |
| 880 |
F_BunnyScroll (); |
| 881 |
break; |
| 882 |
case 4: |
| 883 |
finalelump = "ENDPIC"; |
| 884 |
break; |
| 885 |
} |
| 886 |
|
| 887 |
if (finalelump) |
| 888 |
{ |
| 889 |
V_ClearBorder(); // e6y: wide-res |
| 890 |
V_DrawNamePatchFS(0, 0, 0, finalelump, CR_DEFAULT, VPT_STRETCH); |
| 891 |
} |
| 892 |
} |
| 893 |
} |