#include "wi_data.h" #include "dutils.h" #include "r_local.h" #include // // GENERAL DATA // static int acceleratestage; // used to accelerate or skip a stage static int me; // wbs->pnum static stateenum_t state; // specifies current state static wbstartstruct_t *wbs; // contains information passed into intermission static wbplayerstruct_t *plrs; // wbs->plyr[] static int cnt; // used for general timing static int bcnt; // used for timing of background animation static int firstrefresh; // signals to refresh everything for one frame static int cnt_kills[MAXPLAYERS], cnt_items[MAXPLAYERS], cnt_secret[MAXPLAYERS]; static int cnt_time, cnt_par; static int cnt_pause; static int NUMCMAPS; // # of commercial levels // GRAPHICS static patch_t *bg; // background (map of levels) static patch_t *yah[2]; // You Are Here graphic static patch_t *splat; // splat static patch_t *percent, *colon; // %, : graphics static patch_t *num[10]; // 0-9 graphic static patch_t *wiminus; // minus sign static patch_t *finished; // "Finished!" graphics static patch_t *entering; // "Entering" graphic static patch_t *sp_secret; // "secret" static patch_t *kills, *secret, *items, *frags; // "Kills", "Scrt", "Items", "Frags" static patch_t *time, *par, *sucks; static patch_t *killers, *victims; // "killers", "victims" static patch_t *total, *star, *bstar; // "Total", your face, your dead face static patch_t *p[MAXPLAYERS]; // "red P[1..MAXPLAYERS]" static patch_t *bp[MAXPLAYERS]; // "gray P[1..MAXPLAYERS]" static patch_t **lnames; // Name graphics of each level (centered) // // CODE // // slam background static unsigned char *background=0; void WI_slamBackground(void) { memcpy(screens[0], screens[1], SCREENWIDTH * SCREENHEIGHT); V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); } // The ticker is used to detect keys because of timing issues in netgames boolean WI_Responder(event_t *ev) { return false; } // Draws " Finished!" void WI_drawLF(void) { int y = WI_TITLEY; // draw V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2, y, FB, lnames[wbs->last]); // draw "Finished!" y += (5*SHORT(lnames[wbs->last]->height))/4; V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2, y, FB, finished); } // draws Entering void WI_drawEL(void) { int y = WI_TITLEY; // draw "Entering" V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2, y, FB, entering); // draw level y += (5*SHORT(lnames[wbs->next]->height))/4; V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2, y, FB, lnames[wbs->next]); } void WI_drawOnLnode(int n, patch_t *c[]) { int i, left, top, right, bottom; boolean fits = false; i = 0; do { left = lnodes[wbs->epsd][n].x - SHORT(c[i]->leftoffset); top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset); right = left + SHORT(c[i]->width); bottom = top + SHORT(c[i]->height); if (left >= 0 && right < SCREENWIDTH && top >= 0 && bottom < SCREENHEIGHT) fits = true; else i++; } while (!fits && i!=2); if (fits && i<2) { V_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, FB, c[i]); } else printf("Could not place patch on level %d", n+1); // DEBUG } void WI_initAnimatedBack(void) { int i; anim_t *a; if (commercial) return; for (i=0;iepsd];i++) { a = &anims[wbs->epsd][i]; // init variables a->ctr = -1; // specify the next time to draw it if (a->type == ANIM_ALWAYS) a->nexttic = bcnt + 1 + (M_Random()%a->period); else if (a->type == ANIM_RANDOM) a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1); else if (a->type == ANIM_LEVEL) a->nexttic = bcnt + 1; } } void WI_updateAnimatedBack(void) { int i; anim_t *a; if (commercial) return; for (i=0;iepsd];i++) { a = &anims[wbs->epsd][i]; if (bcnt == a->nexttic) { switch (a->type) { case ANIM_ALWAYS: if (++a->ctr >= a->nanims) a->ctr = 0; a->nexttic = bcnt + a->period; break; case ANIM_RANDOM: a->ctr++; if (a->ctr == a->nanims) { a->ctr = -1; a->nexttic = bcnt+a->data2+(M_Random()%a->data1); } else a->nexttic = bcnt + a->period; break; case ANIM_LEVEL: // gawd-awful hack for level anims if (!(state == StatCount && i == 7) && wbs->next == a->data1) { a->ctr++; if (a->ctr == a->nanims) a->ctr--; a->nexttic = bcnt + a->period; } break; } } } } void WI_drawAnimatedBack(void) { int i; anim_t *a; if (commercial) return; for (i=0 ; iepsd] ; i++) { a = &anims[wbs->epsd][i]; if (a->ctr >= 0) V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]); } } // // draws a number. if digits > 0, then use that many digits minimum, // otherwise only use as many as necessary. Returns new x position. // int WI_drawNum(int x, int y, int n, int digits) { int fontwidth = SHORT(num[0]->width); int neg; int temp; if (digits < 0) { if (!n) digits = 1; // make variable-length 0's 1 digit long else { // figure out # of digits in # digits = 0; temp = n; while (temp) { temp /= 10; digits++; } } } neg = n < 0; if (neg) n = -n; // if non-number, don't draw it if (n == 1994) return 0; // draw the new number while (digits--) { x -= fontwidth; V_DrawPatch(x, y, FB, num[ n % 10 ]); n /= 10; } // draw a minus sign if necessary if (neg) V_DrawPatch(x-=8, y, FB, wiminus); return x; } void WI_drawPercent(int x, int y, int p) { if (p < 0) return; V_DrawPatch(x, y, FB, percent); WI_drawNum(x, y, p, -1); } void WI_drawTime(int x, int y, int t) { int div, n; if (t<0) return; if (t <= 61*59) { div = 1; do { n = (t / div) % 60; x = WI_drawNum(x, y, n, 2) - SHORT(colon->width); div *= 60; if (div==60 || t / div) V_DrawPatch(x, y, FB, colon); // draw } while (t / div); } else V_DrawPatch(x - SHORT(sucks->width), y, FB, sucks); // "sucks" } void WI_End(void) { void WI_unloadData(void); WI_unloadData(); } void WI_initNoState(void) { state = NoState; acceleratestage = 0; cnt = 10; } void WI_updateNoState(void) { WI_updateAnimatedBack(); if (!--cnt) { WI_End(); G_WorldDone(); } } static boolean snl_pointeron = false; void WI_initShowNextLoc(void) { state = ShowNextLoc; acceleratestage = 0; cnt = SHOWNEXTLOCDELAY * TICRATE; WI_initAnimatedBack(); } void WI_updateShowNextLoc(void) { WI_updateAnimatedBack(); if (!--cnt || acceleratestage) WI_initNoState(); else snl_pointeron = (cnt & 31) < 20; } void WI_drawShowNextLoc(void) { int i, last; WI_slamBackground(); WI_drawAnimatedBack(); // draw animated background if (!commercial) { last = (wbs->last == 8) ? wbs->next - 1 : wbs->last; for (i=0 ; i<=last ; i++) WI_drawOnLnode(i, &splat); // draw a splat on taken cities. if (wbs->didsecret) WI_drawOnLnode(8, &splat); // splat the secret level if (snl_pointeron) WI_drawOnLnode(wbs->next, yah); // draw flashing ptr } if (!commercial || wbs->next != 30) WI_drawEL(); // draws which level you're entering.. } void WI_drawNoState(void) { snl_pointeron = true; WI_drawShowNextLoc(); } int WI_fragSum(int playernum) { int i, frags = 0; for (i=0 ; i 99) dm_frags[i][j] = 99; if (dm_frags[i][j] < -99) dm_frags[i][j] = -99; stillticking = true; } dm_totals[i] = WI_fragSum(i); if (dm_totals[i] > 99) dm_totals[i] = 99; if (dm_totals[i] < -99) dm_totals[i] = -99; } if (!stillticking) { S_StartSound(0, sfx_barexp); dm_state++; } } else if (dm_state == 4) { if (acceleratestage) { S_StartSound(0, sfx_slop); if (commercial) WI_initNoState(); else WI_initShowNextLoc(); } } else if (dm_state & 1) { if (!--cnt_pause) { dm_state++; cnt_pause = TICRATE; } } } void WI_drawDeathmatchStats(void) { int i, j, x, y, w; int lh; // line height lh = WI_SPACINGY; WI_slamBackground(); WI_drawAnimatedBack(); // draw animated background WI_drawLF(); // draw stat titles (top line) V_DrawPatch(DM_TOTALSX-SHORT(total->width)/2, DM_MATRIXY-WI_SPACINGY+10, FB, total); V_DrawPatch(DM_KILLERSX, DM_KILLERSY, FB, killers); V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, FB, victims); // draw P?'s. x = DM_MATRIXX + DM_SPACINGX; y = DM_MATRIXY; for (i=0 ; iwidth)/2, DM_MATRIXY - WI_SPACINGY, FB, p[i]); V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, FB, p[i]); if (i == me) { V_DrawPatch(x-SHORT(p[i]->width)/2, DM_MATRIXY - WI_SPACINGY, FB, bstar); V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, FB, star); } } else { // V_DrawPatch(x-SHORT(bp[i]->width)/2, DM_MATRIXY - WI_SPACINGY, FB, bp[i]); // V_DrawPatch(DM_MATRIXX-SHORT(bp[i]->width)/2, y, FB, bp[i]); } x += DM_SPACINGX; y += WI_SPACINGY; } // draw stats y = DM_MATRIXY+10; w = SHORT(num[0]->width); for (i=0 ; imaxkills; cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; if (dofrags) cnt_frags[i] = WI_fragSum(i); } S_StartSound(0, sfx_barexp); ng_state = 10; } if (ng_state == 2) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); stillticking = false; for (i=0 ; i= (plrs[i].skills * 100) / wbs->maxkills) cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; else stillticking = true; } if (!stillticking) { S_StartSound(0, sfx_barexp); ng_state++; } } else if (ng_state == 4) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); stillticking = false; for (i=0 ; i= (plrs[i].sitems * 100) / wbs->maxitems) cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; else stillticking = true; } if (!stillticking) { S_StartSound(0, sfx_barexp); ng_state++; } } else if (ng_state == 6) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); stillticking = false; for (i=0 ; i= (plrs[i].ssecret * 100) / wbs->maxsecret) cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; else stillticking = true; } if (!stillticking) { S_StartSound(0, sfx_barexp); ng_state += 1 + 2*!dofrags; } } else if (ng_state == 8) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); stillticking = false; for (i=0 ; i= (fsum = WI_fragSum(i))) cnt_frags[i] = fsum; else stillticking = true; } if (!stillticking) { S_StartSound(0, sfx_pldeth); ng_state++; } } else if (ng_state == 10) { if (acceleratestage) { S_StartSound(0, sfx_sgcock); if (commercial) WI_initNoState(); else WI_initShowNextLoc(); } } else if (ng_state & 1) { if (!--cnt_pause) { ng_state++; cnt_pause = TICRATE; } } } void WI_drawNetgameStats(void) { int i, x, y, pwidth = SHORT(percent->width); WI_slamBackground(); WI_drawAnimatedBack(); // draw animated background WI_drawLF(); // draw stat titles (top line) V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(kills->width), NG_STATSY, FB, kills); V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(items->width), NG_STATSY, FB, items); V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width), NG_STATSY, FB, secret); if (dofrags) V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width), NG_STATSY, FB, frags); // draw stats y = NG_STATSY + SHORT(kills->height); for (i=0 ; iwidth), y, FB, p[i]); if (i == me) V_DrawPatch(x-SHORT(p[i]->width), y, FB, star); x += NG_SPACINGX; WI_drawPercent(x-pwidth, y+10, cnt_kills[i]); x += NG_SPACINGX; WI_drawPercent(x-pwidth, y+10, cnt_items[i]); x += NG_SPACINGX; WI_drawPercent(x-pwidth, y+10, cnt_secret[i]); x += NG_SPACINGX; if (dofrags) WI_drawNum(x, y+10, cnt_frags[i], -1); y += WI_SPACINGY; } } static int sp_state; void WI_initStats(void) { state = StatCount; acceleratestage = 0; sp_state = 1; cnt_kills[0] = cnt_items[0] = cnt_secret[0] = -1; cnt_time = cnt_par = -1; cnt_pause = TICRATE; WI_initAnimatedBack(); } void WI_updateStats(void) { WI_updateAnimatedBack(); if (acceleratestage && sp_state != 10) { acceleratestage = 0; cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; cnt_time = plrs[me].stime / TICRATE; cnt_par = wbs->partime / TICRATE; S_StartSound(0, sfx_barexp); sp_state = 10; } if (sp_state == 2) { cnt_kills[0] += 2; if (!(bcnt&3)) S_StartSound(0, sfx_pistol); if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills) { cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; S_StartSound(0, sfx_barexp); sp_state++; } } else if (sp_state == 4) { cnt_items[0] += 2; if (!(bcnt&3)) S_StartSound(0, sfx_pistol); if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems) { cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; S_StartSound(0, sfx_barexp); sp_state++; } } else if (sp_state == 6) { cnt_secret[0] += 2; if (!(bcnt&3)) S_StartSound(0, sfx_pistol); if (cnt_secret[0] >= (plrs[me].ssecret * 100) / wbs->maxsecret) { cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; S_StartSound(0, sfx_barexp); sp_state++; } } else if (sp_state == 8) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); cnt_time += 3; if (cnt_time >= plrs[me].stime / TICRATE) cnt_time = plrs[me].stime / TICRATE; cnt_par += 3; if (cnt_par >= wbs->partime / TICRATE) { cnt_par = wbs->partime / TICRATE; if (cnt_time >= plrs[me].stime / TICRATE) { S_StartSound(0, sfx_barexp); sp_state++; } } } else if (sp_state == 10) { if (acceleratestage) { S_StartSound(0, sfx_sgcock); if (commercial) WI_initNoState(); else WI_initShowNextLoc(); } } else if (sp_state & 1) { if (!--cnt_pause) { sp_state++; cnt_pause = TICRATE; } } } void WI_drawStats(void) { int lh; // line height lh = (3*SHORT(num[0]->height))/2; WI_slamBackground(); WI_drawAnimatedBack(); // draw animated background WI_drawLF(); V_DrawPatch(SP_STATSX, SP_STATSY, FB, kills); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, items); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]); V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, time); WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time); V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, FB, par); WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par); } void WI_checkForAccelerate(void) { int i; player_t *player; // check for button presses to skip delays for (i=0, player = players ; icmd.buttons & BT_ATTACK) { if (!player->attackdown) acceleratestage = 1; player->attackdown = true; } else player->attackdown = false; if (player->cmd.buttons & BT_USE) { if (!player->usedown) acceleratestage = 1; player->usedown = true; } else player->usedown = false; } } // Updates stuff each tick void WI_Ticker(void) { bcnt++; // counter for general background animation if (bcnt == 1) { commercial ? S_ChangeMusic(mus_dm2int, true): S_ChangeMusic(mus_inter, true); // intermission music } WI_checkForAccelerate(); switch (state) { case StatCount: if (deathmatch) WI_updateDeathmatchStats(); else if (netgame) WI_updateNetgameStats(); else WI_updateStats(); break; case ShowNextLoc: WI_updateShowNextLoc(); break; case NoState: WI_updateNoState(); break; } } void WI_loadData(void) { int i, j; char name[9]; anim_t *a; unsigned char *pic = screens[1]; if (commercial) strcpy(name, "INTERPIC"); else sprintf(name, "WIMAP%d", wbs->epsd); bg = W_CacheLumpName(name, PU_CACHE); // background V_DrawPatch(0, 0, 1, bg); /* if (commercial) // if (0) { // darken the background image while (pic != screens[1] + SCREENHEIGHT*SCREENWIDTH) { *pic = colormaps[256*25 + *pic]; pic++; } } */ if (commercial) { #if 0 int level_start; level_start = GetNumForName("CLVSTART")+1; NUMCMAPS = W_GetNumForName("CLVEND") - level_start + 1; lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMCMAPS, PU_STATIC, 0); for (i=0 ; iepsd, i); lnames[i] = W_CacheLumpName(name, PU_STATIC); } yah[0] = W_CacheLumpName("WIURH0", PU_STATIC); // you are here yah[1] = W_CacheLumpName("WIURH1", PU_STATIC); // you are here (alt.) splat = W_CacheLumpName("WISPLAT", PU_STATIC); // splat for (j=0;jepsd];j++) { a = &anims[wbs->epsd][j]; for (i=0;inanims;i++) { if (wbs->epsd != 1 || j != 8) // MONDO HACK! { sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i); // animations a->p[i] = W_CacheLumpName(name, PU_STATIC); } else { a->p[i] = anims[1][4].p[i]; // HACK ALERT! } } } } wiminus = W_CacheLumpName("WIMINUS", PU_STATIC); // minus sign for (i=0;i<10;i++) { sprintf(name, "WINUM%d", i); // numbers 0-9 num[i] = W_CacheLumpName(name, PU_STATIC); } percent = W_CacheLumpName("WIPCNT", PU_STATIC); // percent sign finished = W_CacheLumpName("WIF", PU_STATIC); // "finished" entering = W_CacheLumpName("WIENTER", PU_STATIC); // "entering" kills = W_CacheLumpName("WIOSTK", PU_STATIC); // "kills" secret = W_CacheLumpName("WIOSTS", PU_STATIC); // "scrt" sp_secret = W_CacheLumpName("WISCRT2", PU_STATIC); // "secret" if (french) { if (netgame && !deathmatch) items = W_CacheLumpName("WIOBJ", PU_STATIC); // "items" else items = W_CacheLumpName("WIOSTI", PU_STATIC); // "items" } else items = W_CacheLumpName("WIOSTI", PU_STATIC); // "items" frags = W_CacheLumpName("WIFRGS", PU_STATIC); // "frgs" colon = W_CacheLumpName("WICOLON", PU_STATIC); // ":" time = W_CacheLumpName("WITIME", PU_STATIC); // "time" sucks = W_CacheLumpName("WISUCKS", PU_STATIC); // "sucks" par = W_CacheLumpName("WIPAR", PU_STATIC); // "par" killers = W_CacheLumpName("WIKILRS", PU_STATIC); // "killers" (vertical) victims = W_CacheLumpName("WIVCTMS", PU_STATIC); // "victims" (horiz) total = W_CacheLumpName("WIMSTT", PU_STATIC); // "total" star = W_CacheLumpName("STFST01", PU_STATIC); // your face bstar = W_CacheLumpName("STFDEAD0", PU_STATIC); // dead face for (i=0 ; iepsd];j++) { if (wbs->epsd != 1 || j != 8) for (i=0;iepsd][j].nanims;i++) Z_ChangeTag(anims[wbs->epsd][j].p[i], PU_CACHE); } } Z_Free(lnames); Z_ChangeTag(percent, PU_CACHE); Z_ChangeTag(colon, PU_CACHE); Z_ChangeTag(finished, PU_CACHE); Z_ChangeTag(entering, PU_CACHE); Z_ChangeTag(kills, PU_CACHE); Z_ChangeTag(secret, PU_CACHE); Z_ChangeTag(sp_secret, PU_CACHE); Z_ChangeTag(items, PU_CACHE); Z_ChangeTag(frags, PU_CACHE); Z_ChangeTag(time, PU_CACHE); Z_ChangeTag(sucks, PU_CACHE); Z_ChangeTag(par, PU_CACHE); Z_ChangeTag(victims, PU_CACHE); Z_ChangeTag(killers, PU_CACHE); Z_ChangeTag(total, PU_CACHE); // Z_ChangeTag(star, PU_CACHE); // Z_ChangeTag(bstar, PU_CACHE); for (i=0 ; iepsd, 0, 2); RNGCHECK(wbs->last, 0, 8); RNGCHECK(wbs->next, 0, 8); } RNGCHECK(wbs->pnum, 0, MAXPLAYERS); RNGCHECK(wbs->pnum, 0, MAXPLAYERS); #endif acceleratestage = 0; cnt = bcnt = 0; firstrefresh = 1; me = wbs->pnum; plrs = wbs->plyr; if (!wbs->maxkills) wbs->maxkills = 1; if (!wbs->maxitems) wbs->maxitems = 1; if (!wbs->maxsecret) wbs->maxsecret = 1; if (wbs->epsd > 2) wbs->epsd -= 3; } void WI_Start(wbstartstruct_t *wbstartstruct) { WI_initVariables(wbstartstruct); WI_loadData(); if (deathmatch) WI_initDeathmatchStats(); else if (netgame) WI_initNetgameStats(); else WI_initStats(); }