diff options
author | James Haley | 2010-09-21 07:24:45 +0000 |
---|---|---|
committer | James Haley | 2010-09-21 07:24:45 +0000 |
commit | 6ae54ada023321ec629a52cc4f91ccd8e3aa06ff (patch) | |
tree | 5b76b883c4add6f31f4a41e689c6f9f35c8c8a03 /src | |
parent | 663e27b891c796a76dde61f8a7b195b6dd228511 (diff) | |
download | chocolate-doom-6ae54ada023321ec629a52cc4f91ccd8e3aa06ff.tar.gz chocolate-doom-6ae54ada023321ec629a52cc4f91ccd8e3aa06ff.tar.bz2 chocolate-doom-6ae54ada023321ec629a52cc4f91ccd8e3aa06ff.zip |
Working health bars on the status bar, and numerous fixes to
P_TouchSpecialThing.
Subversion-branch: /branches/strife-branch
Subversion-revision: 2127
Diffstat (limited to 'src')
-rw-r--r-- | src/strife/p_inter.c | 97 | ||||
-rw-r--r-- | src/strife/st_stuff.c | 254 |
2 files changed, 240 insertions, 111 deletions
diff --git a/src/strife/p_inter.c b/src/strife/p_inter.c index 92ce6187..8f770c2e 100644 --- a/src/strife/p_inter.c +++ b/src/strife/p_inter.c @@ -404,6 +404,8 @@ static char pickupmsg[80]; // // P_TouchSpecialThing // +// [STRIFE] Rewritten for Strife collectables. +// void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) { player_t* player; @@ -416,7 +418,6 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) if(delta > toucher->height || delta < -8*FRACUNIT) return; // out of reach - sound = sfx_itemup; player = toucher->player; @@ -425,11 +426,21 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) if(toucher->health <= 0) return; - // villsa [STRIFE] damage toucher if special has spectral flag - if(special->flags & MF_SPECTRAL) + // villsa [STRIFE] damage toucher if special is spectral + // haleyjd 09/21/10: corrected to test for SPECTRE thingtypes specifically + switch(special->type) { + case MT_SPECTRE_A: + case MT_SPECTRE_B: + case MT_SPECTRE_C: + case MT_SPECTRE_D: + case MT_SPECTRE_E: + case MT_ENTITY: + case MT_SUBENTITY: P_DamageMobj(toucher, NULL, NULL, 5); return; + default: + break; } // villsa [STRIFE] @@ -440,8 +451,8 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) switch(special->sprite) { // bullets - case SPR_BLIT: - if(!P_GiveAmmo(player, am_bullets, 1)) + case SPR_BLIT: // haleyjd: fixed missing MF_DROPPED check + if(!P_GiveAmmo(player, am_bullets, !(special->flags & MF_DROPPED))) return; break; @@ -501,38 +512,64 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // rifle case SPR_RIFL: - if(!P_GiveWeapon(player, wp_rifle, special->flags&MF_DROPPED)) + if(!P_GiveWeapon(player, wp_rifle, special->flags & MF_DROPPED)) return; + sound = sfx_wpnup; // haleyjd: SHK-CHK! break; // flame thrower case SPR_FLAM: if(!P_GiveWeapon(player, wp_flame, false)) return; + // haleyjd: gives extra ammo. + P_GiveAmmo(player, am_cell, 3); + sound = sfx_wpnup; // haleyjd: SHK-CHK! break; // missile launcher case SPR_MMSL: if(!P_GiveWeapon(player, wp_missile, false)) return; + sound = sfx_wpnup; // haleyjd: SHK-CHK! break; - // missile launcher + // grenade launcher case SPR_GRND: - if(!P_GiveWeapon(player, wp_hegrenade, special->flags&MF_DROPPED)) + if(!P_GiveWeapon(player, wp_hegrenade, special->flags & MF_DROPPED)) return; + sound = sfx_wpnup; // haleyjd: SHK-CHK! break; // mauler case SPR_TRPD: if(!P_GiveWeapon(player, wp_mauler, false)) return; + sound = sfx_wpnup; // haleyjd: SHK-CHK! break; - // crossbow + // electric bolt crossbow case SPR_CBOW: - if(!P_GiveWeapon(player, wp_elecbow, special->flags&MF_DROPPED)) + if(!P_GiveWeapon(player, wp_elecbow, special->flags & MF_DROPPED)) + return; + sound = sfx_wpnup; // haleyjd: SHK-CHK! + break; + + // haleyjd 09/21/10: missed case: THE SIGIL! + case SPR_SIGL: + if(!P_GiveWeapon(player, wp_sigil, special->flags & MF_DROPPED)) + { + player->sigiltype = special->frame; + return; + } + + if(netgame) + player->sigiltype = 4; + + player->pendingweapon = wp_sigil; + player->st_update = true; + if(deathmatch) return; + sound = sfx_wpnup; break; // backpack @@ -548,62 +585,92 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) P_GiveAmmo(player, i, 1); break; + // 1 Gold case SPR_COIN: P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); break; + // 10 Gold case SPR_CRED: for(i = 0; i < 10; i++) P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); break; + // 25 Gold case SPR_SACK: - for(i = 0; i < 25; i++) - P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + // haleyjd 09/21/10: missed code: if a SPR_SACK object has negative + // health, it will give that much gold - STRIFE-TODO: verify + if(special->health < 0) + { + for(i = special->health; i != 0; i++) + P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + } + else + { + for(i = 0; i < 25; i++) + P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + } break; + // 50 Gold case SPR_CHST: for(i = 0; i < 50; i++) P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); break; + // Leather Armor case SPR_ARM1: if(!P_GiveArmor(player, -2)) if(!P_GiveInventoryItem(player, special->sprite, special->type)) pickupmsg[0] = '!'; break; + // Metal Armor case SPR_ARM2: if(!P_GiveArmor(player, -1)) if(!P_GiveInventoryItem(player, special->sprite, special->type)) pickupmsg[0] = '!'; break; + // All-map powerup case SPR_PMAP: if(!P_GivePower(player, pw_allmap)) return; - sound = sfx_yeah; + sound = sfx_yeah; break; + // The Comm Unit - because you need Blackbird whining in your ear the + // whole time and telling you how lost she is :P case SPR_COMM: if(!P_GivePower(player, pw_communicator)) return; sound = sfx_yeah; break; + // haleyjd 09/21/10: missed case - Shadow Armor; though, I do not know why + // this has a case distinct from generic inventory items... Maybe it started + // out as an auto-use-if-possible item much like regular armor... + case SPR_SHD1: + if(!P_GiveInventoryItem(player, SPR_SHD1, special->type)) + pickupmsg[0] = '!'; + break; + // villsa [STRIFE] check default items case SPR_TOKN: default: if(special->type >= MT_KEY_BASE && special->type <= MT_NEWKEY5) { + // haleyjd 09/21/10: Strife player still picks up keys that + // he has already found. (break, not return) if(!P_GiveCard(player, special->type - MT_KEY_BASE)) - return; + break; } else { if(!P_GiveInventoryItem(player, special->sprite, special->type)) - pickupmsg[0] = '!'; + pickupmsg[0] = '!'; } + break; } // villsa [STRIFE] set message diff --git a/src/strife/st_stuff.c b/src/strife/st_stuff.c index c89a69e6..df15278a 100644 --- a/src/strife/st_stuff.c +++ b/src/strife/st_stuff.c @@ -315,106 +315,19 @@ cheatseq_t cheat_powerup[7] = // STRIFE-TODO //cheatseq_t cheat_choppers = CHEAT("idchoppers", 0); [STRIFE] no such thing -// Forward declarations: -void ST_drawNumFontY(int x, int y, int num); -void ST_drawNumFontY2(int x, int y, int num); // // STATUS BAR CODE // void ST_Stop(void); -// -// ST_refreshBackground -// -// [STRIFE] Completely overhauled. -// + +// [STRIFE] Unused. +/* void ST_refreshBackground(void) { - if (st_statusbaron) - { - int firstinventory, icon_x, num_x, i, numdrawn; - - // haleyjd 09/19/10: No backscreen caching in Strife. - //V_UseBuffer(st_backing_screen); - - // TODO: only sometimes drawing? - - plyr->st_update = false; - - // cache data - st_lastcursorpos = plyr->inventorycursor; - st_lastammo = weaponinfo[plyr->readyweapon].ammo; - st_lastarmortype = plyr->armortype; - st_lasthealth = plyr->health; - st_firsttime = false; - - // draw main status bar - V_DrawPatch(ST_X, ST_Y, invback); - - // draw multiplayer armor backdrop if netgame - if(netgame) - V_DrawPatch(ST_X, 173, stback); - - if(plyr->inventorycursor >= 6) - firstinventory = plyr->inventorycursor - 5; - else - firstinventory = 0; - - // Draw cursor. - if(plyr->numinventory) - { - V_DrawPatch(35 * (plyr->inventorycursor - firstinventory) + 42, - 180, invcursor); - } - - // Draw inventory bar - for(num_x = 68, icon_x = 48, i = firstinventory, numdrawn = 0; - num_x < 278; - num_x += 35, icon_x += 35, i++, numdrawn++) - { - int lumpnum; - patch_t *patch; - char iconname[8]; - - if(plyr->numinventory <= numdrawn) - break; - - DEH_snprintf(iconname, sizeof(iconname), "I_%s", - DEH_String(sprnames[plyr->inventory[i].sprite])); - - lumpnum = W_CheckNumForName(iconname); - if(lumpnum == -1) - patch = W_CacheLumpName(DEH_String("STCFN063"), PU_CACHE); - else - patch = W_CacheLumpNum(lumpnum, PU_STATIC); - - V_DrawPatch(icon_x, 182, patch); - ST_drawNumFontY(num_x, 191, plyr->inventory[i].amount); - } - - // haleyjd 09/19/10: Draw sigil icon - if(plyr->weaponowned[wp_sigil]) - V_DrawPatch(253, 175, invsigil[plyr->sigiltype]); - - // haleyjd 09/19/10: Draw ammo - if(st_lastammo < NUMAMMO) - V_DrawPatch(290, 180, invammo[st_lastammo]); - - // haleyjd 09/19/10: Draw armor - if(plyr->armortype) - { - V_DrawPatch(2, 177, invarmor[plyr->armortype - 1]); - ST_drawNumFontY(20, 191, plyr->armorpoints); - } - - // STRIFE-TODO: health bars - - // haleyjd 09/19/10: nope, not in Strife. - //V_RestoreBuffer(); - //V_CopyRect(ST_X, 0, st_backing_screen, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y); - } } +*/ // [STRIFE] static char st_msgbuf[52]; @@ -921,12 +834,161 @@ void ST_drawNumFontY2(int x, int y, int num) } } -void ST_doRefresh(void) +// +// ST_drawLine +// +// haleyjd 09/20/10: [STRIFE] New function +// Basic horizontal line drawing routine used for the health bars. +// +void ST_drawLine(int x, int y, int len, int color) { - st_firsttime = false; + byte putcolor = (byte)(color); + byte *drawpos = I_VideoBuffer + y * SCREENWIDTH + x; + int i = 0; + while(i < len) + { + *drawpos++ = putcolor; + ++i; + } +} + +// +// ST_doRefresh +// +// haleyjd 09/20/10: Evidence more than suggests that Rogue moved all status bar +// drawing down to this function. +// +void ST_doRefresh(void) +{ // draw status bar background to off-screen buff - ST_refreshBackground(); + if (st_statusbaron) + { + int firstinventory, icon_x, num_x, i, numdrawn; + + // haleyjd 09/19/10: No backscreen caching in Strife. + //V_UseBuffer(st_backing_screen); + + // TODO: only sometimes drawing? + + plyr->st_update = false; + + // cache data + st_lastcursorpos = plyr->inventorycursor; + st_lastammo = weaponinfo[plyr->readyweapon].ammo; + st_lastarmortype = plyr->armortype; + st_lasthealth = plyr->health; + st_firsttime = false; + + // draw main status bar + V_DrawPatch(ST_X, ST_Y, invback); + + // draw multiplayer armor backdrop if netgame + if(netgame) + V_DrawPatch(ST_X, 173, stback); + + if(plyr->inventorycursor >= 6) + firstinventory = plyr->inventorycursor - 5; + else + firstinventory = 0; + + // Draw cursor. + if(plyr->numinventory) + { + V_DrawPatch(35 * (plyr->inventorycursor - firstinventory) + 42, + 180, invcursor); + } + + // Draw inventory bar + for(num_x = 68, icon_x = 48, i = firstinventory, numdrawn = 0; + num_x < 278; + num_x += 35, icon_x += 35, i++, numdrawn++) + { + int lumpnum; + patch_t *patch; + char iconname[8]; + + if(plyr->numinventory <= numdrawn) + break; + + DEH_snprintf(iconname, sizeof(iconname), "I_%s", + DEH_String(sprnames[plyr->inventory[i].sprite])); + + lumpnum = W_CheckNumForName(iconname); + if(lumpnum == -1) + patch = W_CacheLumpName(DEH_String("STCFN063"), PU_CACHE); + else + patch = W_CacheLumpNum(lumpnum, PU_STATIC); + + V_DrawPatch(icon_x, 182, patch); + ST_drawNumFontY(num_x, 191, plyr->inventory[i].amount); + } + + // haleyjd 09/19/10: Draw sigil icon + if(plyr->weaponowned[wp_sigil]) + V_DrawPatch(253, 175, invsigil[plyr->sigiltype]); + + // haleyjd 09/19/10: Draw ammo + if(st_lastammo < NUMAMMO) + V_DrawPatch(290, 180, invammo[st_lastammo]); + + // haleyjd 09/19/10: Draw armor + if(plyr->armortype) + { + V_DrawPatch(2, 177, invarmor[plyr->armortype - 1]); + ST_drawNumFontY(20, 191, plyr->armorpoints); + } + + // haleyjd 09/20/10: Draw life bars. + { + int barlength; + int lifecolor1; + int lifecolor2; + + barlength = plyr->health; + if(barlength > 100) + barlength = 200 - plyr->health; + barlength *= 2; + + if(plyr->health < 11) // Danger, Will Robinson! + lifecolor1 = 64; + else if(plyr->health < 21) // Caution + lifecolor1 = 80; + else // All is well. + lifecolor1 = 96; + + if(plyr->cheats & CF_GODMODE) // Gold, probably a throwback to DOOM. + lifecolor1 = 226; + + lifecolor2 = lifecolor1 + 3; + + // Draw the normal health bars + ST_drawLine(49, 172, barlength, lifecolor1); + ST_drawLine(49, 173, barlength, lifecolor2); + ST_drawLine(49, 175, barlength, lifecolor1); + ST_drawLine(49, 176, barlength, lifecolor2); + + // Draw the > 100 health lines + if(plyr->health > 100) + { + int oldbarlength = barlength; + lifecolor1 = 112; // Shades of blue + lifecolor2 = lifecolor1 + 3; + + // take up the difference not drawn by the first (<= 100) bar + barlength = 200 - barlength; + + ST_drawLine(49 + oldbarlength, 172, barlength, lifecolor1); + ST_drawLine(49 + oldbarlength, 173, barlength, lifecolor2); + ST_drawLine(49 + oldbarlength, 175, barlength, lifecolor1); + ST_drawLine(49 + oldbarlength, 176, barlength, lifecolor2); + } + } // end local-scope block + + // haleyjd 09/19/10: nope, not in Strife. + //V_RestoreBuffer(); + //V_CopyRect(ST_X, 0, st_backing_screen, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y); + } } void ST_diffDraw(void) @@ -945,9 +1007,9 @@ void ST_Drawer (boolean fullscreen, boolean refresh) // haleyjd 09/01/10: STRIFE-TODO: work out statbar details // If just after ST_Start(), refresh all - /*if (st_firsttime)*/ ST_doRefresh(); + ST_doRefresh(); // Otherwise, update as little as possible - /*else*/ ST_diffDraw(); + ST_diffDraw(); } // |