From 8bbfd5b68a289ddf933f78d369606f1f22dd91c6 Mon Sep 17 00:00:00 2001 From: James Haley Date: Wed, 22 Sep 2010 08:07:35 +0000 Subject: Rewrote P_GiveItemToPlayer to exactly match binary, particularly with treatment of SPR_TOKN objects, and playing proper sounds for different item types. Fixed most S_StartSound calls in the menu engine. Removed call to S_StopSound in S_StartSound, as Strife doesn't do it. Added call to P_DialogDoChoice(-1) in M_Responder when menuindialog is asserted and the menu exit key is pressed. Subversion-branch: /branches/strife-branch Subversion-revision: 2130 --- src/strife/m_menu.c | 59 +++---- src/strife/p_dialog.c | 415 +++++++++++++++++++++++++++++--------------------- src/strife/p_inter.c | 2 +- src/strife/s_sound.c | 2 +- 4 files changed, 273 insertions(+), 205 deletions(-) diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index 62a56ab2..74700c9f 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -64,6 +64,7 @@ #include "sounds.h" #include "m_menu.h" +#include "p_dialog.h" extern void M_QuitStrife(int); @@ -691,8 +692,8 @@ void M_QuickSaveResponse(int key) { if (key == key_menu_confirm) { - M_DoSave(quickSaveSlot); - S_StartSound(NULL,sfx_swish); // villsa [STRIFE] TODO - fix sounds + M_DoSave(quickSaveSlot); + S_StartSound(NULL, sfx_mtalht); // [STRIFE] sound } } @@ -700,7 +701,7 @@ void M_QuickSave(void) { if (!usergame) { - S_StartSound(NULL,sfx_oof); + S_StartSound(NULL, sfx_oof); return; } @@ -728,8 +729,8 @@ void M_QuickLoadResponse(int key) { if (key == key_menu_confirm) { - M_LoadSelect(quickSaveSlot); - S_StartSound(NULL,sfx_swish); // villsa [STRIFE] TODO - fix sounds + M_LoadSelect(quickSaveSlot); + S_StartSound(NULL, sfx_mtalht); // [STRIFE] sound } } @@ -1685,7 +1686,7 @@ boolean M_Responder (event_t* ev) messageRoutine(key); menuactive = false; - S_StartSound(NULL,sfx_swish); // villsa [STRIFE] TODO - fix sounds + S_StartSound(NULL, sfx_mtalht); // [STRIFE] sound return true; } @@ -1703,7 +1704,7 @@ boolean M_Responder (event_t* ev) if (automapactive || chat_on) return false; M_SizeDisplay(0); - S_StartSound(NULL,sfx_stnmov); + S_StartSound(NULL, sfx_stnmov); return true; } else if (key == key_menu_incscreen) // Screen size up @@ -1711,7 +1712,7 @@ boolean M_Responder (event_t* ev) if (automapactive || chat_on) return false; M_SizeDisplay(1); - S_StartSound(NULL,sfx_stnmov); + S_StartSound(NULL, sfx_stnmov); return true; } else if (key == key_menu_help) // Help key @@ -1721,20 +1722,20 @@ boolean M_Responder (event_t* ev) currentMenu = &ReadDef1; itemOn = 0; - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); return true; } else if (key == key_menu_save) // Save { M_StartControlPanel(); - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); M_SaveGame(0); return true; } else if (key == key_menu_load) // Load { M_StartControlPanel(); - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); M_LoadGame(0); return true; } @@ -1743,7 +1744,7 @@ boolean M_Responder (event_t* ev) M_StartControlPanel (); currentMenu = &SoundDef; itemOn = sfx_vol; - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); return true; } /* @@ -1756,31 +1757,31 @@ boolean M_Responder (event_t* ev) */ else if (key == key_menu_qsave) // Quicksave { - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); M_QuickSave(); return true; } else if (key == key_menu_endgame) // End game { - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); M_EndGame(0); return true; } else if (key == key_menu_messages) // Toggle messages { M_ChangeMessages(0); - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); return true; } else if (key == key_menu_qload) // Quickload { - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); M_QuickLoad(); return true; } else if (key == key_menu_quit) // Quit DOOM { - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); M_QuitStrife(0); return true; } @@ -1801,7 +1802,7 @@ boolean M_Responder (event_t* ev) if (key == key_menu_activate) { M_StartControlPanel (); - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); return true; } return false; @@ -1819,7 +1820,7 @@ boolean M_Responder (event_t* ev) if (itemOn+1 > currentMenu->numitems-1) itemOn = 0; else itemOn++; - S_StartSound(NULL,sfx_pstop); + S_StartSound(NULL, sfx_pstop); } while(currentMenu->menuitems[itemOn].status==-1); return true; @@ -1833,7 +1834,7 @@ boolean M_Responder (event_t* ev) if (!itemOn) itemOn = currentMenu->numitems-1; else itemOn--; - S_StartSound(NULL,sfx_pstop); + S_StartSound(NULL, sfx_pstop); } while(currentMenu->menuitems[itemOn].status==-1); return true; @@ -1845,7 +1846,7 @@ boolean M_Responder (event_t* ev) if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) { - S_StartSound(NULL,sfx_stnmov); + S_StartSound(NULL, sfx_stnmov); currentMenu->menuitems[itemOn].routine(0); } return true; @@ -1857,7 +1858,7 @@ boolean M_Responder (event_t* ev) if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) { - S_StartSound(NULL,sfx_stnmov); + S_StartSound(NULL, sfx_stnmov); currentMenu->menuitems[itemOn].routine(1); } return true; @@ -1873,12 +1874,12 @@ boolean M_Responder (event_t* ev) if (currentMenu->menuitems[itemOn].status == 2) { currentMenu->menuitems[itemOn].routine(1); // right arrow - S_StartSound(NULL,sfx_stnmov); + S_StartSound(NULL, sfx_stnmov); } else { currentMenu->menuitems[itemOn].routine(itemOn); - S_StartSound(NULL,sfx_swish); // villsa [STRIFE] TODO - fix sounds + //S_StartSound(NULL, sfx_swish); [STRIFE] No sound is played here. } } return true; @@ -1886,10 +1887,12 @@ boolean M_Responder (event_t* ev) else if (key == key_menu_activate) { // Deactivate menu + if(menuindialog) // [STRIFE] - Get out of dialog engine semi-gracefully + P_DialogDoChoice(-1); currentMenu->lastOn = itemOn; M_ClearMenus (0); - S_StartSound(NULL,sfx_swish); // villsa [STRIFE] TODO - fix sounds + S_StartSound(NULL, sfx_mtalht); // villsa [STRIFE] TODO - fix sounds return true; } else if (key == key_menu_back) @@ -1901,7 +1904,7 @@ boolean M_Responder (event_t* ev) { currentMenu = currentMenu->prevMenu; itemOn = currentMenu->lastOn; - S_StartSound(NULL,sfx_swtchn); + S_StartSound(NULL, sfx_swtchn); } return true; } @@ -1914,7 +1917,7 @@ boolean M_Responder (event_t* ev) if (currentMenu->menuitems[i].alphaKey == ch) { itemOn = i; - S_StartSound(NULL,sfx_pstop); + S_StartSound(NULL, sfx_pstop); return true; } } @@ -1924,7 +1927,7 @@ boolean M_Responder (event_t* ev) if (currentMenu->menuitems[i].alphaKey == ch) { itemOn = i; - S_StartSound(NULL,sfx_pstop); + S_StartSound(NULL, sfx_pstop); return true; } } diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c index a7ef8107..5095afce 100644 --- a/src/strife/p_dialog.c +++ b/src/strife/p_dialog.c @@ -702,6 +702,7 @@ boolean P_GiveItemToPlayer(player_t *player, int sprnum, mobjtype_t type) int i = 0; line_t junk; boolean ok = true; + int sound = sfx_itemup; // haleyjd 09/21/10: different sounds for items // set quest if mf_givequest flag is set if(mobjinfo[type].flags & MF_GIVEQUEST) @@ -719,263 +720,326 @@ boolean P_GiveItemToPlayer(player_t *player, int sprnum, mobjtype_t type) { if(mobjinfo[type].name) { - strncpy(pickupstring, mobjinfo[type].name, 39); + strncpy(pickupstring, DEH_String(mobjinfo[type].name), 39); player->message = pickupstring; } player->questflags |= 1 << (type - MT_TOKEN_QUEST1); + + if(player == &players[consoleplayer]) + S_StartSound(NULL, sound); + return true; } - // check for other types - else switch(type) + + // haleyjd 09/22/10: Refactored to give sprites higher priority than + // mobjtypes and to implement missing logic. + switch(sprnum) { - // severed hand - case MT_KEY_HAND: - P_GiveCard(player, key_SeveredHand); + case SPR_HELT: // STRIFE-TODO: verify - I believe this is related to a cheat + P_GiveInventoryItem(player, SPR_HELT, MT_TOKEN_TOUGHNESS); + P_GiveInventoryItem(player, SPR_GUNT, MT_TOKEN_ACCURACY); + + // [STRIFE] Bizarre... + for(i = 0; i < 5 * player->accuracy + 300; i++) + P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); break; - // 300 gold - case MT_MONY_300: - for(i = 0; i < 300; i++) + case SPR_ARM1: // Armor 1 + if(!P_GiveArmor(player, -2)) + P_GiveInventoryItem(player, sprnum, type); + break; + + case SPR_ARM2: // Armor 2 + if(!P_GiveArmor(player, -1)) + P_GiveInventoryItem(player, sprnum, type); + break; + + case SPR_COIN: // 1 Gold + P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + break; + + case SPR_CRED: // 10 Gold + for(i = 0; i < 10; i++) P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); break; - // ammo refill (at training) - case MT_TOKEN_AMMO: - if(player->ammo[am_bullets] >= 50) - return false; + case SPR_SACK: // 25 gold + for(i = 0; i < 25; i++) + P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + break; - player->ammo[am_bullets] = 50; + case SPR_CHST: // 50 gold + for(i = 0; i < 50; i++) + P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + + case SPR_BBOX: // Box of Bullets + if(!P_GiveAmmo(player, am_bullets, 5)) + return false; break; - // health refill (at front HQ) - case MT_TOKEN_HEALTH: - if(!P_GiveBody(player, healthamounts[gameskill])) + case SPR_BLIT: // Bullet Clip + if(!P_GiveAmmo(player, am_bullets, 1)) return false; break; - // alarm - case MT_TOKEN_ALARM: - P_NoiseAlert(player->mo, player->mo); - A_AlertSpectreC(dialogtalker); + case SPR_PMAP: // Map powerup + if(!P_GivePower(player, pw_allmap)) + return false; + sound = sfx_yeah; // bluh-doop! break; - // door special 1 - case MT_TOKEN_DOOR1: - junk.tag = 222; - EV_DoDoor(&junk, open); + case SPR_COMM: // Communicator + if(!P_GivePower(player, pw_communicator)) + return false; + sound = sfx_yeah; // bluh-doop! break; - // door special 2 - case MT_TOKEN_PRISON_PASS: - junk.tag = 223; - EV_DoDoor(&junk, open); - if(gamemap == 2) - P_GiveInventoryItem(player, sprnum, type); + case SPR_MSSL: // Mini-missile + if(!P_GiveAmmo(player, am_missiles, 1)) + return false; break; - // door special 3 - case MT_TOKEN_SHOPCLOSE: - junk.tag = 222; - EV_DoDoor(&junk, close); + case SPR_ROKT: // Crate of missiles + if(!P_GiveAmmo(player, am_missiles, 5)) + return false; break; - // door special 4 - case MT_TOKEN_DOOR3: - junk.tag = 224; - EV_DoDoor(&junk, close); + case SPR_BRY1: // Battery cell + if(!P_GiveAmmo(player, am_cell, 1)) + return false; break; - // stamina upgrade - case MT_TOKEN_STAMINA: - if(player->stamina >= 100) + case SPR_CPAC: // Cell pack + if(!P_GiveAmmo(player, am_cell, 5)) return false; + break; - player->stamina += 10; - P_GiveBody(player, 200); + case SPR_PQRL: // Poison bolts + if(!P_GiveAmmo(player, am_poisonbolts, 5)) + return false; break; - // accuracy upgrade - case MT_TOKEN_NEW_ACCURACY: - if(player->accuracy >= 100) + case SPR_XQRL: // Electric bolts + if(!P_GiveAmmo(player, am_elecbolts, 5)) return false; + break; - player->accuracy += 10; + case SPR_GRN1: // HE Grenades + if(!P_GiveAmmo(player, am_hegrenades, 1)) + return false; break; - // slideshow - case MT_SLIDESHOW: - gameaction = ga_victory; - if(gamemap == 10) - P_GiveItemToPlayer(player, SPR_TOKN, MT_TOKEN_QUEST17); + case SPR_GRN2: // WP Grenades + if(!P_GiveAmmo(player, am_wpgrenades, 1)) + return false; break; - default: - // check for sprites if no specific type is found - switch(sprnum) + case SPR_BKPK: // Backpack (aka Ammo Satchel) + if(!player->backpack) { - // bullets - case SPR_BLIT: - ok = P_GiveAmmo(player, am_bullets, 1); - break; + for(i = 0; i < NUMAMMO; i++) + player->maxammo[i] *= 2; - // box of bullets - case SPR_BBOX: - ok = P_GiveAmmo(player, am_bullets, 5); - break; + player->backpack = true; + } + for(i = 0; i < NUMAMMO; i++) + P_GiveAmmo(player, i, 1); + break; - // missile - case SPR_MSSL: - ok = P_GiveAmmo(player, am_missiles, 1); - break; + case SPR_RIFL: // Assault Rifle + if(player->weaponowned[wp_rifle]) + return false; - // box of missiles - case SPR_ROKT: - ok = P_GiveAmmo(player, am_missiles, 5); - break; + if(!P_GiveWeapon(player, wp_rifle, false)) + return false; + + sound = sfx_wpnup; // SHK-CHK! + break; - // battery - case SPR_BRY1: - ok = P_GiveAmmo(player, am_cell, 1); - break; + case SPR_FLAM: // Flamethrower + if(player->weaponowned[wp_flame]) + return false; - // cell pack - case SPR_CPAC: - ok = P_GiveAmmo(player, am_cell, 5); - break; + if(!P_GiveWeapon(player, wp_flame, false)) + return false; - // poison bolts - case SPR_PQRL: - ok = P_GiveAmmo(player, am_poisonbolts, 5); - break; + sound = sfx_wpnup; // SHK-CHK! + break; - // electric bolts - case SPR_XQRL: - ok = P_GiveAmmo(player, am_elecbolts, 5); - break; + case SPR_MMSL: // Mini-missile Launcher + if(player->weaponowned[wp_missile]) + return false; - // he grenades - case SPR_GRN1: - ok = P_GiveAmmo(player, am_hegrenades, 1); - break; + if(!P_GiveWeapon(player, wp_missile, false)) + return false; - // wp grenades - case SPR_GRN2: - ok = P_GiveAmmo(player, am_wpgrenades, 1); - break; + sound = sfx_wpnup; // SHK-CHK! + break; - // backpack - case SPR_BKPK: - if(!player->backpack) - { - for(i = 0; i < NUMAMMO; i++) - player->maxammo[i] *= 2; + case SPR_TRPD: // Mauler + if(player->weaponowned[wp_mauler]) + return false; - player->backpack = true; - } - for(i = 0; i < NUMAMMO; i++) - P_GiveAmmo(player, i, 1); - break; + if(!P_GiveWeapon(player, wp_mauler, false)) + return false; - // coin - case SPR_COIN: - P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); - break; + sound = sfx_wpnup; // SHK-CHK! + break; - // gold 10 - case SPR_CRED: - for(i = 0; i < 10; i++) - P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + case SPR_CBOW: // Here's a crossbow. Just aim straight, and *SPLAT!* + if(player->weaponowned[wp_elecbow]) + return false; + + if(!P_GiveWeapon(player, wp_elecbow, false)) + return false; + + sound = sfx_wpnup; // SHK-CHK! + break; + + case SPR_TOKN: // Miscellaneous items - These are determined by thingtype. + switch(type) + { + case MT_KEY_HAND: // Severed hand + P_GiveCard(player, key_SeveredHand); break; - // gold 25 - case SPR_SACK: - for(i = 0; i < 25; i++) + case MT_MONY_300: // 300 Gold (this is the only way to get it, in fact) + for(i = 0; i < 300; i++) P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); break; - // gold 50 - case SPR_CHST: - for(i = 0; i < 50; i++) - P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + case MT_TOKEN_AMMO: // Ammo token - you get this from the Weapons Trainer + if(player->ammo[am_bullets] >= 50) + return false; + + player->ammo[am_bullets] = 50; break; - // ??? - case SPR_HELT: - P_GiveInventoryItem(player, SPR_HELT, MT_TOKEN_TOUGHNESS); - P_GiveInventoryItem(player, SPR_GUNT, MT_TOKEN_ACCURACY); + case MT_TOKEN_HEALTH: // Health token - from the Front's doctor + if(!P_GiveBody(player, healthamounts[gameskill])) + return false; + break; - // [STRIFE] TODO - verify - for(i = 0; i < 5 * player->numinventory + 300; i++) - P_GiveInventoryItem(player, SPR_COIN, MT_MONY_1); + case MT_TOKEN_ALARM: // Alarm token - particularly from the Oracle. + P_NoiseAlert(player->mo, player->mo); + A_AlertSpectreC(dialogtalker); // BUG: assumes in a dialog o_O break; - // metal armor - case SPR_ARM1: - if(!P_GiveArmor(player, -2)) - P_GiveInventoryItem(player, sprnum, type); + case MT_TOKEN_DOOR1: // Door special 1 + junk.tag = 222; + EV_DoDoor(&junk, open); break; - // leather armor - case SPR_ARM2: - if(!P_GiveArmor(player, -1)) + case MT_TOKEN_PRISON_PASS: // Door special 1 - Prison pass + junk.tag = 223; + EV_DoDoor(&junk, open); + if(gamemap == 2) // If on Tarnhill, give Prison pass object P_GiveInventoryItem(player, sprnum, type); break; - // communicator - case SPR_COMM: - if(!P_GivePower(player, pw_communicator)) - return false; + case MT_TOKEN_SHOPCLOSE: // Door special 3 - "Shop close" - unused? + junk.tag = 222; + EV_DoDoor(&junk, close); break; - // map - case SPR_PMAP: - if(!P_GivePower(player, pw_allmap)) - return false; + case MT_TOKEN_DOOR3: // Door special 4 (or 3? :P ) + junk.tag = 224; + EV_DoDoor(&junk, close); break; - // rifle - case SPR_RIFL: - if(player->weaponowned[wp_rifle]) + case MT_TOKEN_STAMINA: // Stamina upgrade + if(player->stamina >= 100) return false; - if(!P_GiveWeapon(player, wp_rifle, false)) - return false; + player->stamina += 10; + P_GiveBody(player, 200); // full healing break; - // flame thrower - case SPR_FLAM: - if(player->weaponowned[wp_flame]) + case MT_TOKEN_NEW_ACCURACY: // Accuracy upgrade + if(player->accuracy >= 100) return false; - if(!P_GiveWeapon(player, wp_flame, false)) - return false; + player->accuracy += 10; break; - // missile launcher - case SPR_MMSL: - if(player->weaponowned[wp_missile]) - return false; - - if(!P_GiveWeapon(player, wp_missile, false)) - return false; + case MT_SLIDESHOW: // Slideshow (start a finale) + gameaction = ga_victory; + if(gamemap == 10) + P_GiveItemToPlayer(player, SPR_TOKN, MT_TOKEN_QUEST17); break; + + default: // The default is to just give it as an inventory item. + P_GiveInventoryItem(player, sprnum, type); + break; + } + break; - // mauler - case SPR_TRPD: - if(player->weaponowned[wp_mauler]) - return false; + default: // The ultimate default: Give it as an inventory item. + if(!P_GiveInventoryItem(player, sprnum, type)) + return false; + break; + } - if(!P_GiveWeapon(player, wp_mauler, false)) - return false; - break; + // Play sound. + if(player == &players[consoleplayer]) + S_StartSound(NULL, sound); - // crossbow - case SPR_CBOW: - if(player->weaponowned[wp_elecbow]) - return false; + return true; + + // check for other types + /* + switch(type) + { + // severed hand + + // 300 gold + + // ammo refill (at training) + + // health refill (at front HQ) + + // alarm + + // door special 1 + + // door special 2 + + // door special 3 + + // door special 4 + + // stamina upgrade + + // slideshow + + default: + // check for sprites if no specific type is found + switch(sprnum) + { + // bullets + + // box of bullets + + // missile + + // box of missiles + + // battery + + + + // backpack + + // communicator + + + // rifle + + // flame thrower + + // missile launcher + + // mauler - if(!P_GiveWeapon(player, wp_elecbow, false)) - return false; - break; // misc item default: @@ -988,6 +1052,7 @@ boolean P_GiveItemToPlayer(player_t *player, int sprnum, mobjtype_t type) S_StartSound(player->mo, sfx_itemup); return true; + */ } // diff --git a/src/strife/p_inter.c b/src/strife/p_inter.c index 8f770c2e..07d5d411 100644 --- a/src/strife/p_inter.c +++ b/src/strife/p_inter.c @@ -418,7 +418,7 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) if(delta > toucher->height || delta < -8*FRACUNIT) return; // out of reach - sound = sfx_itemup; + sound = sfx_itemup; player = toucher->player; // Dead thing touching. diff --git a/src/strife/s_sound.c b/src/strife/s_sound.c index 47b33089..bedde12c 100644 --- a/src/strife/s_sound.c +++ b/src/strife/s_sound.c @@ -480,7 +480,7 @@ void S_StartSound(void *origin_p, int sfx_id) } // kill old sound - S_StopSound(origin); + //S_StopSound(origin); // try to find a channel cnum = S_GetChannel(origin, sfx, false); // haleyjd: not a voice. -- cgit v1.2.3