From 267ccae3a95526444ffd359fb62b22f98049025e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 3 Aug 2025 15:34:54 +0200 Subject: [PATCH] Add driftpulse controller rumble inspired by radioracers, this does a "weak" rumble pulse the moment the sparks pulse (this is slightly after reaching the new driftlevel) may want a toggle for this --- src/d_player.h | 2 ++ src/k_kart.c | 19 ++++++++++++++++--- src/p_tick.c | 13 +++++++++++++ src/p_user.c | 2 ++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 8f312ecfa..11ccf8079 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -568,6 +568,8 @@ typedef struct player_s squishdance_t squishdance; fixed_t fovadd; // adjust FOV for hw rendering + + SINT8 driftlevel; // just for controller rumble for now } player_t; #endif diff --git a/src/k_kart.c b/src/k_kart.c index a699c5603..843d459d6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6029,14 +6029,27 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->speed > minspeed*2) player->kartstuff[k_getsparks] = 1; + const boolean driftblue = (player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone); + const boolean driftred = (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo); + const boolean driftrainbow = (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree); + // Sound whenever you get a different tier of sparks - if ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) - || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) - || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) + if (driftblue + || driftred + || driftrainbow) { //S_StartSound(player->mo, sfx_s3ka2); if (P_IsLocalPlayer(player)) // UGHGHGH... + { S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... + } + + if (driftrainbow) + player->driftlevel = 3; + else if (driftred) + player->driftlevel = 2; + else if (driftblue) + player->driftlevel = 1; player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; } diff --git a/src/p_tick.c b/src/p_tick.c index ce985a5e2..3b030aeca 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -545,6 +545,19 @@ static void P_DeviceRumbleTick(void) high = CLAMP((high + FRACUNIT / 256), 0, UINT16_MAX); } + // pulse when gettin new driftlevel + // let this come last + if (player->kartstuff[k_driftcharge] + && player->driftlevel) + { + high = CLAMP((high + FRACUNIT / 256), 0, UINT16_MAX); + + if (player->driftlevel == 2) + lenght = 114; + else if (player->driftlevel == 3) + lenght = 174; + } + // hack alert! i just dont want this thing constantly resetting the rumble lol if (low == 0 && high == 0) { diff --git a/src/p_user.c b/src/p_user.c index 731135ebd..c3feff198 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4455,6 +4455,8 @@ void P_PlayerThink(player_t *player) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); #endif + player->driftlevel = 0; // idk where to put this + // todo: Figure out what is actually causing these problems in the first place... if ((player->health <= 0 || player->mo->health <= 0) && player->playerstate == PST_LIVE) //you should be DEAD! {