From 672bf9631dc1479f4c07673d8adde491a4e13efb Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 6 Mar 2022 22:44:42 +0000 Subject: [PATCH] * Allow the digestion to "catch up" a bit if you suddenly get a huge burst of spheres (such as a spherebox). * Refactor a little, since the previous code required casting and could penalise 40 spheres a bit TOO much if you would be pushed beyond it that tic. --- src/k_kart.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index d7d610605..630be29c8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7061,6 +7061,10 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) else if (player->rings < -20) player->rings = -20; + if (player->spheres > 40) + player->spheres = 40; + // where's the < 0 check? see below the following block! + if ((gametyperules & GTR_BUMPERS) && (player->bumpers <= 0)) { // Deplete 1 every tic when removed from the game. @@ -7069,33 +7073,45 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } else { - INT16 spheredigestion = TICRATE; // Base rate of 1 every second when playing. - INT16 digestionpower = ((10 - player->kartspeed) + (10 - player->kartweight))-1; // 1 to 17 - spheredigestion -= ((player->spheres*digestionpower)/20); + tic_t spheredigestion = TICRATE; // Base rate of 1 every second when playing. + tic_t digestionpower = ((10 - player->kartspeed) + (10 - player->kartweight))-1; // 1 to 17 - if (spheredigestion < 1) // just in case + // currently 0-34 + digestionpower = ((player->spheres*digestionpower)/20); + + if (digestionpower >= spheredigestion) { spheredigestion = 1; } + else + { + spheredigestion -= digestionpower; + } if ((player->spheres > 0) && (player->spheredigestion > 0)) { + // If you got a massive boost in spheres, catch up digestion as necessary. + if (spheredigestion < player->spheredigestion) + { + player->spheredigestion = (spheredigestion + player->spheredigestion)/2; + } + player->spheredigestion--; + if (player->spheredigestion == 0) { player->spheres--; - player->spheredigestion = (tic_t)spheredigestion; + player->spheredigestion = spheredigestion; } } else { - player->spheredigestion = (tic_t)spheredigestion; + player->spheredigestion = spheredigestion; } } - if (player->spheres > 40) - player->spheres = 40; - else if (player->spheres < 0) + // where's the > 40 check? see above the previous block! + if (player->spheres < 0) player->spheres = 0; if (comeback == false || !(gametyperules & GTR_KARMA) || (player->pflags & PF_ELIMINATED))