From bb3d01495a782be5d3789e69bbae711360209dd9 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 8 Oct 2018 21:31:55 -0400 Subject: [PATCH] New engine sounds 9 unique engine classes with 13 sounds each, which smoothly change. Each character sounds distinct now! --- src/d_player.h | 1 + src/dehacked.c | 1 + src/k_kart.c | 34 +++++++++++++ src/p_user.c | 39 ++++----------- src/sounds.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++-- src/sounds.h | 132 +++++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 303 insertions(+), 35 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 373110dd..02f7f45e 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -284,6 +284,7 @@ typedef enum k_voices, // Used to stop the player saying more voices than it should k_tauntvoices, // Used to specifically stop taunt voice spam k_instashield, // Instashield no-damage animation timer + k_enginesnd, // Engine sound number you're on. k_floorboost, // Prevents Sneaker sounds for a breif duration when triggered by a floor panel k_spinouttype, // Determines whether to thrust forward or not while spinning out; 0 = move forwards, 1 = stay still diff --git a/src/dehacked.c b/src/dehacked.c index 67071d88..8429d401 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7744,6 +7744,7 @@ static const char *const KARTSTUFF_LIST[] = { "VOICES", "TAUNTVOICES", "INSTASHIELD", + "ENGINESND", "FLOORBOOST", "SPINOUTTYPE", diff --git a/src/k_kart.c b/src/k_kart.c index b37c8f49..c8203e8b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3646,6 +3646,39 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) return wtarg; } +// Engine Sounds. +static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) +{ + INT32 forwardamount = (6*cmd->forwardmove) / 25; // max of 50 is 12 + INT32 momamount = ((player->speed>>FRACBITS) / 5); + INT32 targetsnd = (forwardamount+momamount)/2; + INT32 class = ((player->kartspeed-1)/3) + (3*((player->kartweight-1)/3)); // engine class (3*weight/3 LOOKS redundant, but it's to reduce the precision and get things into 3 unique categories) + const INT32 numsnds = 13; + + if (leveltime < 6) // stats may not be set on level start, so it plays class A sounds + return; + + if (leveltime % 6) + return; + + if (targetsnd < 0) + targetsnd = 0; + if (targetsnd > 12) + targetsnd = 12; + + if (player->kartstuff[k_enginesnd] < targetsnd) + player->kartstuff[k_enginesnd]++; + if (player->kartstuff[k_enginesnd] > targetsnd) + player->kartstuff[k_enginesnd]--; + + if (player->kartstuff[k_enginesnd] < 0) + player->kartstuff[k_enginesnd] = 0; + if (player->kartstuff[k_enginesnd] > 12) + player->kartstuff[k_enginesnd] = 12; + + S_StartSound(player->mo, (sfx_krta00 + player->kartstuff[k_enginesnd]) + (class*numsnds)); +} + /** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c \param player player object passed from P_PlayerThink @@ -3656,6 +3689,7 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { K_UpdateOffroad(player); + K_UpdateEngineSounds(player, cmd); K_GetKartBoostPower(player); // Speed lines diff --git a/src/p_user.c b/src/p_user.c index dfc56a8c..e49c8fda 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6662,36 +6662,17 @@ static void P_MovePlayer(player_t *player) P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND //{ SRB2kart - // Engine Sounds. - if (!player->exiting) - { - if (player->speed == 0 && onground && player->speed == 0 && leveltime % 6 == 0) - S_StartSound(player->mo, sfx_kart1); - if ((player->speed < runspd && player->speed != 0) && leveltime % 8 == 0) - S_StartSound(player->mo, sfx_kart2); - - if ((player->speed > runspd) && leveltime % 8 == 0) - S_StartSound(player->mo, sfx_kart3); - - // Drifting sound - { - // Start looping the sound now. - if (leveltime % 50 == 0 && onground - && player->kartstuff[k_drift] != 0) - S_StartSound(player->mo, sfx_mkdrft); - // Leveltime being 50 might take a while at times. We'll start it up once, isntantly. - else if ((player->kartstuff[k_drift] >= 1 || player->kartstuff[k_drift] <= -1) && !S_SoundPlaying(player->mo, sfx_mkdrft) && onground) - S_StartSound(player->mo, sfx_mkdrft); - // Ok, we'll stop now. - else if ((player->kartstuff[k_drift] == 0) - && (player == &players[consoleplayer] - || (splitscreen && player == &players[secondarydisplayplayer]) - || (splitscreen > 1 && player == &players[thirddisplayplayer]) - || (splitscreen > 2 && player == &players[fourthdisplayplayer]))) - S_StopSoundByID(player->mo, sfx_mkdrft); - } - } + // Drifting sound + // Start looping the sound now. + if (leveltime % 50 == 0 && onground && player->kartstuff[k_drift] != 0) + S_StartSound(player->mo, sfx_mkdrft); + // Leveltime being 50 might take a while at times. We'll start it up once, isntantly. + else if (!S_SoundPlaying(player->mo, sfx_mkdrft) && onground && player->kartstuff[k_drift] != 0) + S_StartSound(player->mo, sfx_mkdrft); + // Ok, we'll stop now. + else if (player->kartstuff[k_drift] == 0) + S_StopSoundByID(player->mo, sfx_mkdrft); K_MoveKartPlayer(player, onground); //} diff --git a/src/sounds.c b/src/sounds.c index 8e0ed4e0..6e102186 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -771,9 +771,6 @@ sfxinfo_t S_sfx[NUMSFX] = {"lkt1", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, {"lkt2", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, {"lkt3", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"kart1", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"kart2", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"kart3", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, {"mlap", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, {"sboost", true, 90, 0, -1, NULL, 0, -1, -1, LUMPERROR}, {"mush", false, 90, 0, -1, NULL, 0, -1, -1, LUMPERROR}, @@ -821,6 +818,134 @@ sfxinfo_t S_sfx[NUMSFX] = {"itfree", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, {"dbgsal", false, 110, 8, -1, NULL, 0, -1, -1, LUMPERROR}, + // SRB2Kart - Engine sounds + // Engine class A + {"krta00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krta12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class B + {"krtb00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtb12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class C + {"krtc00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtc12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class D + {"krtd00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtd12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class E + {"krte00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krte12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class F + {"krtf00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtf12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class G + {"krtg00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krtg12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class H + {"krth00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krth12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // Engine class I + {"krti00", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti01", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti02", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti03", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti04", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti05", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti06", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti07", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti08", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti09", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti10", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti11", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"krti12", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + // SRB2kart - Skin sounds {"kwin", false, 64, 96, -1, NULL, 0, SKSKWIN, -1, LUMPERROR}, {"klose", false, 64, 96, -1, NULL, 0, SKSKLOSE, -1, LUMPERROR}, diff --git a/src/sounds.h b/src/sounds.h index 301b3912..2516b646 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -846,9 +846,6 @@ typedef enum sfx_lkt1, sfx_lkt2, sfx_lkt3, - sfx_kart1, - sfx_kart2, - sfx_kart3, sfx_mlap, sfx_sboost, sfx_mush, @@ -896,6 +893,135 @@ typedef enum sfx_itfree, sfx_dbgsal, + // Next up: UNIQUE ENGINE SOUNDS! Hoooooo boy... + // Engine class A - Low Speed, Low Weight + sfx_krta00, + sfx_krta01, + sfx_krta02, + sfx_krta03, + sfx_krta04, + sfx_krta05, + sfx_krta06, + sfx_krta07, + sfx_krta08, + sfx_krta09, + sfx_krta10, + sfx_krta11, + sfx_krta12, + // Engine class B - Average Speed, Low Weight + sfx_krtb00, + sfx_krtb01, + sfx_krtb02, + sfx_krtb03, + sfx_krtb04, + sfx_krtb05, + sfx_krtb06, + sfx_krtb07, + sfx_krtb08, + sfx_krtb09, + sfx_krtb10, + sfx_krtb11, + sfx_krtb12, + // Engine class C - High Speed, Low Weight + sfx_krtc00, + sfx_krtc01, + sfx_krtc02, + sfx_krtc03, + sfx_krtc04, + sfx_krtc05, + sfx_krtc06, + sfx_krtc07, + sfx_krtc08, + sfx_krtc09, + sfx_krtc10, + sfx_krtc11, + sfx_krtc12, + // Engine class D - Low Speed, Average Weight + sfx_krtd00, + sfx_krtd01, + sfx_krtd02, + sfx_krtd03, + sfx_krtd04, + sfx_krtd05, + sfx_krtd06, + sfx_krtd07, + sfx_krtd08, + sfx_krtd09, + sfx_krtd10, + sfx_krtd11, + sfx_krtd12, + // Engine class E - Average Speed, Average Weight + sfx_krte00, + sfx_krte01, + sfx_krte02, + sfx_krte03, + sfx_krte04, + sfx_krte05, + sfx_krte06, + sfx_krte07, + sfx_krte08, + sfx_krte09, + sfx_krte10, + sfx_krte11, + sfx_krte12, + // Engine class F - High Speed, Average Weight + sfx_krtf00, + sfx_krtf01, + sfx_krtf02, + sfx_krtf03, + sfx_krtf04, + sfx_krtf05, + sfx_krtf06, + sfx_krtf07, + sfx_krtf08, + sfx_krtf09, + sfx_krtf10, + sfx_krtf11, + sfx_krtf12, + // Engine class G - Low Speed, High Weight + sfx_krtg00, + sfx_krtg01, + sfx_krtg02, + sfx_krtg03, + sfx_krtg04, + sfx_krtg05, + sfx_krtg06, + sfx_krtg07, + sfx_krtg08, + sfx_krtg09, + sfx_krtg10, + sfx_krtg11, + sfx_krtg12, + // Engine class H - Average Speed, High Weight + sfx_krth00, + sfx_krth01, + sfx_krth02, + sfx_krth03, + sfx_krth04, + sfx_krth05, + sfx_krth06, + sfx_krth07, + sfx_krth08, + sfx_krth09, + sfx_krth10, + sfx_krth11, + sfx_krth12, + // Engine class I - High Speed, High Weight + sfx_krti00, + sfx_krti01, + sfx_krti02, + sfx_krti03, + sfx_krti04, + sfx_krti05, + sfx_krti06, + sfx_krti07, + sfx_krti08, + sfx_krti09, + sfx_krti10, + sfx_krti11, + sfx_krti12, + + // And LASTLY, Kart's skin sounds. sfx_kwin, sfx_klose, sfx_khurt1,