📄 st_stuff.c
字号:
static int st_randomnumber;int stbarheight = ST_HEIGHT;int ST_Y = BASEVIDHEIGHT - ST_HEIGHT;int st_x = 0;int fgbuffer = FG;int st_scalex,st_scaley;// ------------------------------------------// status bar overlay// ------------------------------------------// icons for overlaystatic int sbohealth;static int sbofrags;static int sboarmor;static int sboammo[NUMWEAPONS];//// STATUS BAR CODE//static void ST_refreshBackground(void){ byte* colormap; if (st_statusbaron) { int flags = (fgbuffer & 0xffff0000) | BG; // software mode copies patch to BG buffer, // hardware modes directly draw the statusbar to the screen V_DrawScaledPatch(st_x, ST_Y, flags, sbar); // draw the faceback for the statusbarplayer if (plyr->skincolor==0) colormap = colormaps; else colormap = translationtables - 256 + (plyr->skincolor<<8); V_DrawMappedPatch (st_x+ST_FX, ST_Y, flags, faceback, colormap); // copy the statusbar buffer to the screen if ( rendermode==render_soft ) V_CopyRect(0, vid.height-stbarheight, BG, vid.width, stbarheight, 0, vid.height-stbarheight, FG); }}// Respond to keyboard input events,// intercept cheats.boolean ST_Responder (event_t* ev){ if (ev->type == ev_keyup) { // Filter automap on/off : activates the statusbar while automap is active if( (ev->data1 & 0xffff0000) == AM_MSGHEADER ) { switch(ev->data1) { case AM_MSGENTERED: st_firsttime = true; // force refresh of status bar break; case AM_MSGEXITED: break; } } } return false;}static int ST_calcPainOffset(void){ int health; static int lastcalc; static int oldhealth = -1; health = plyr->health > 100 ? 100 : plyr->health; if (health != oldhealth) { lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); oldhealth = health; } return lastcalc;}//// This is a not-very-pretty routine which handles// the face states and their timing.// the precedence of expressions is:// dead > evil grin > turned head > straight ahead//static void ST_updateFaceWidget(void){ int i; angle_t badguyangle; angle_t diffang; static int lastattackdown = -1; static int priority = 0; boolean doevilgrin; if (priority < 10) { // dead if (!plyr->health) { priority = 9; st_faceindex = ST_DEADFACE; st_facecount = 1; } } if (priority < 9) { if (plyr->bonuscount) { // picking up bonus doevilgrin = false; for (i=0;i<NUMWEAPONS;i++) { if (oldweaponsowned[i] != plyr->weaponowned[i]) { doevilgrin = true; oldweaponsowned[i] = plyr->weaponowned[i]; } } if (doevilgrin) { // evil grin if just picked up weapon priority = 8; st_facecount = ST_EVILGRINCOUNT; st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET; } } } if (priority < 8) { if (plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo) { // being attacked priority = 7; if (plyr->health - st_oldhealth > ST_MUCHPAIN) { st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; } else { badguyangle = R_PointToAngle2(plyr->mo->x, plyr->mo->y, plyr->attacker->x, plyr->attacker->y); if (badguyangle > plyr->mo->angle) { // whether right or left diffang = badguyangle - plyr->mo->angle; i = diffang > ANG180; } else { // whether left or right diffang = plyr->mo->angle - badguyangle; i = diffang <= ANG180; } // confusing, aint it? st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset(); if (diffang < ANG45) { // head-on st_faceindex += ST_RAMPAGEOFFSET; } else if (i) { // turn face right st_faceindex += ST_TURNOFFSET; } else { // turn face left st_faceindex += ST_TURNOFFSET+1; } } } } if (priority < 7) { // getting hurt because of your own damn stupidity if (plyr->damagecount) { if (plyr->health - st_oldhealth > ST_MUCHPAIN) { priority = 7; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; } else { priority = 6; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; } } } if (priority < 6) { // rapid firing if (plyr->attackdown) { if (lastattackdown==-1) lastattackdown = ST_RAMPAGEDELAY; else if (!--lastattackdown) { priority = 5; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; st_facecount = 1; lastattackdown = 1; } } else lastattackdown = -1; } if (priority < 5) { // invulnerability if ((plyr->cheats & CF_GODMODE) || plyr->powers[pw_invulnerability]) { priority = 4; st_faceindex = ST_GODFACE; st_facecount = 1; } } // look left or look right if the facecount has timed out if (!st_facecount) { st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3); st_facecount = ST_STRAIGHTFACECOUNT; priority = 0; } st_facecount--;}boolean ST_SameTeam(player_t *a,player_t *b){ switch (cv_teamplay.value) { case 0 : return false; case 1 : return (a->skincolor == b->skincolor); case 2 : return (a->skin == b->skin); } return false;}// count the frags of the playernum player//Fab: made as a tiny routine so ST_overlayDrawer() can use it//Boris: rename ST_countFrags in to ST_PlayerFrags for use anytime// when we need the fragsint ST_PlayerFrags (int playernum){ int i,frags; frags = players[playernum].addfrags; for (i=0 ; i<MAXPLAYERS ; i++) { if ((cv_teamplay.value==0 && i != playernum) || (cv_teamplay.value && !ST_SameTeam(&players[i],&players[playernum])) ) frags += players[playernum].frags[i]; else frags -= players[playernum].frags[i]; } return frags;}static void ST_updateWidgets(void){ static int largeammo = 1994; // means "n/a" int i;#ifdef PARANOIA if(!plyr) I_Error("plyr==NULL\n");#endif // must redirect the pointer if the ready weapon has changed. // if (w_ready.data != plyr->readyweapon) // { if (plyr->weaponinfo[plyr->readyweapon].ammo == am_noammo) w_ready.num = &largeammo; else w_ready.num = &plyr->ammo[plyr->weaponinfo[plyr->readyweapon].ammo]; //{ // static int tic=0; // static int dir=-1; // if (!(tic&15)) // plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir; // if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100) // dir = 1; // tic++; // } w_ready.data = plyr->readyweapon; // if (*w_ready.on) // STlib_updateNum(&w_ready, true); // refresh weapon change // } // update keycard multiple widgets for (i=0;i<3;i++) { keyboxes[i] = (plyr->cards & (1<<i)) ? i : -1; if (plyr->cards & (1<<(i+3)) ) keyboxes[i] = i+3; } // refresh everything if this is him coming back to life ST_updateFaceWidget(); // used by the w_armsbg widget st_notdeathmatch = !cv_deathmatch.value; // used by w_arms[] widgets st_armson = st_statusbaron && !cv_deathmatch.value; // used by w_frags widget st_fragson = cv_deathmatch.value && st_statusbaron; st_fragscount = ST_PlayerFrags(statusbarplayer); // get rid of chat window if up because of message if (!--st_msgcounter) st_chat = st_oldchat;}static boolean st_stopped = true;void ST_Ticker (void){ if( st_stopped ) return; if( gamemode == heretic ) { SB_Ticker(); return; } st_clock++; st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = plyr->health;}static int st_palette = 0;void ST_doPaletteStuff(void){ int palette; int cnt; int bzc; cnt = plyr->damagecount; if (plyr->powers[pw_strength]) { // slowly fade the berzerk out bzc = 12 - (plyr->powers[pw_strength]>>6); if (bzc > cnt) cnt = bzc; } if (cnt) { palette = (cnt+7)>>3; if (palette >= NUMREDPALS) palette = NUMREDPALS-1; palette += STARTREDPALS; } else if (plyr->bonuscount) { palette = (plyr->bonuscount+7)>>3; if (palette >= NUMBONUSPALS) palette = NUMBONUSPALS-1; palette += STARTBONUSPALS; } else if ( plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet]&8) palette = RADIATIONPAL; else palette = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -