From 2c55e28ea54664cf4fa82de7049bb66eef58f24b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 21:34:02 +0100 Subject: [PATCH] use FRACUNIT in rumbleticker + some changes - brakedrift will now add to any rumble thats currently going on - both hyu and invul now rumble less heavy on offroad --- src/p_tick.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 829ca9aa8..8b9412f07 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -378,21 +378,31 @@ static void P_DeviceRumbleTick(void) UINT16 high = 0; if (!cv_usejoystick[i].value) + { continue; + } if (!cv_rumble[i].value) + { continue; + } player_t *player = &players[displayplayers[i]]; if (!P_IsLocalPlayer(player)) + { continue; + } if (!playeringame[displayplayers[i]] || player->spectator) + { continue; + } if (player->mo == NULL) + { continue; + } if (player->exiting) { @@ -402,26 +412,50 @@ static void P_DeviceRumbleTick(void) if (player->kartstuff[k_spinouttimer]) { - low = high = 65536 / 4; + low = high = FRACUNIT / 4; } else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) { - low = high = 65536 / 8; + low = high = FRACUNIT / 8; } - else if ((player->kartstuff[k_offroad] && !player->kartstuff[k_hyudorotimer]) + else if ((player->kartstuff[k_offroad]) && P_IsObjectOnGround(player->mo) && player->speed != 0) { - low = high = 65536 / 64; + if (player->kartstuff[k_hyudorotimer]) + { + high = FRACUNIT / 128; + } + else if (player->kartstuff[k_invincibilitytimer]) + { + high = FRACUNIT / 64; + } + else + { + low = high = FRACUNIT / 64; + } } - else if (player->kartstuff[k_brakedrift]) + + if (player->kartstuff[k_brakedrift]) { - low = 0; - high = 65536 / 256; + high += FRACUNIT / 256; } // hack alert! i just dont want this thing constantly resetting the rumble lol if (low == 0 && high == 0) + { continue; + } + + // pls dont overflow or smth lel + if (low > FRACUNIT-1) + { + low = FRACUNIT-1; + } + + if (high > FRACUNIT-1) + { + high = FRACUNIT-1; + } G_PlayerDeviceRumble(i, low, high, 57); } @@ -795,8 +829,15 @@ void P_PreTicker(INT32 frames) // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) - P_PlayerAfterThink(&players[i]); + { + if (!playeringame[i]) + continue; + + if (!players[i].mo || P_MobjWasRemoved(players[i].mo)) + continue; + + P_PlayerAfterThink(&players[i]); + } LUA_HookThinkFrame();