From b5d7434caa6e3f2e67b002d75ca8a16a2c5a23bc Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 5 Feb 2021 21:34:16 -0500 Subject: [PATCH 01/29] Turn confirm goes back to neutral when they aren't trying to turn. --- src/k_bot.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/k_bot.c b/src/k_bot.c index 21cd4f18e..e1217357a 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -720,11 +720,15 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // Complete override of all ticcmd functionality if (LUAh_BotTiccmd(player, cmd)) + { return; + } // Start boost handler if (leveltime <= starttime) { + // TODO: Move towards finish line during position, but not too close. + tic_t length = (TICRATE/6); tic_t boosthold = starttime - K_GetSpindashChargeTime(player); @@ -869,6 +873,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) if (turnamt > 0) { + // Count up if (player->botvars.turnconfirm < BOTTURNCONFIRM) { player->botvars.turnconfirm++; @@ -876,11 +881,24 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } else if (turnamt < 0) { + // Count down if (player->botvars.turnconfirm > -BOTTURNCONFIRM) { player->botvars.turnconfirm--; } } + else + { + // Back to neutral + if (player->botvars.turnconfirm < 0) + { + player->botvars.turnconfirm++; + } + else if (player->botvars.turnconfirm > 0) + { + player->botvars.turnconfirm--; + } + } if (abs(player->botvars.turnconfirm) >= BOTTURNCONFIRM) { From 79d5867c5e6c6a4d3f067901b6d4e37e5e2fdba7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 5 Feb 2021 22:44:31 -0500 Subject: [PATCH 02/29] Add spindashing logic for bots They will charge a spindash when they're moving too slow, don't have another boost, and aren't flashing. --- src/k_bot.c | 119 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 97 insertions(+), 22 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index e1217357a..811efe54b 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -686,6 +686,84 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) return predict; } +/*-------------------------------------------------- + static UINT8 K_TrySpindash(player_t *player) + + Determines conditions where the bot should attempt to spindash. + + Input Arguments:- + player - Bot player to check. + + Return:- + 0 to make the bot drive normally, 1 to e-brake, 2 to e-brake & charge spindash. + (TODO: make this an enum) +--------------------------------------------------*/ +static UINT8 K_TrySpindash(player_t *player) +{ + const tic_t difficultyModifier = (TICRATE/6); + + if (player->kartstuff[k_spindashboost] || player->kartstuff[k_tiregrease]) + { + // You just released a spindash, you don't need to try again yet, jeez. + return 0; + } + + // Try "start boosts" first + if (leveltime == starttime+1) + { + // Forces them to release, even if they haven't fully charged. + // Don't want them to keep charging if they didn't have time to. + return 0; + } + + if (leveltime <= starttime) + { + INT32 boosthold = starttime - K_GetSpindashChargeTime(player); + + boosthold -= (MAXBOTDIFFICULTY - player->botvars.difficulty) * difficultyModifier; + + if (leveltime >= (unsigned)boosthold) + { + // Start charging... + return 2; + } + else + { + // Just hold your ground and e-brake. + return 1; + } + } + + // Logic for normal racing. + if (player->powers[pw_flashing] > 0) + { + // Don't bother trying to spindash. + // Trying to spindash while flashing is fine during POSITION, but not during the actual race. + return 0; + } + + if (player->speed < K_GetKartSpeed(player, false) / 4 // Below the speed threshold + && player->kartstuff[k_speedboost] < (FRACUNIT/8)) // If you have other boosts, you can probably trust it. + { + INT32 chargingPoint = (K_GetSpindashChargeTime(player) + difficultyModifier); + + // Release quicker the higher the difficulty is. + // Sounds counter-productive, but that's actually the best strategy after the race has started. + chargingPoint -= player->botvars.difficulty * difficultyModifier; + + if (player->kartstuff[k_spindash] > chargingPoint) + { + // Time to release. + return 0; + } + + return 2; + } + + // We're doing just fine, we don't need to spindash, thanks. + return 0; +} + /*-------------------------------------------------- void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) @@ -694,6 +772,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) { botprediction_t *predict = NULL; + UINT8 spindash = 0; INT32 turnamt = 0; // Can't build a ticcmd if we aren't spawned... @@ -724,26 +803,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) return; } - // Start boost handler - if (leveltime <= starttime) - { - // TODO: Move towards finish line during position, but not too close. - - tic_t length = (TICRATE/6); - tic_t boosthold = starttime - K_GetSpindashChargeTime(player); - - cmd->buttons |= BT_EBRAKEMASK; - - boosthold -= (MAXBOTDIFFICULTY - player->botvars.difficulty) * length; - - if (leveltime >= boosthold) - { - cmd->buttons |= BT_DRIFT; - } - - return; - } - // Handle steering towards waypoints! if (player->nextwaypoint != NULL && player->nextwaypoint->mobj != NULL && !P_MobjWasRemoved(player->nextwaypoint->mobj)) { @@ -857,8 +916,24 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } } - // Handle item usage - K_BotItemUsage(player, cmd, turnamt); + // Spindashing + spindash = K_TrySpindash(player); + + if (spindash > 0) + { + cmd->buttons |= BT_EBRAKEMASK; + + if (spindash == 2 && player->speed < 6*mapobjectscale) + { + cmd->buttons |= BT_DRIFT; + } + } + else + { + // Handle item usage here, so they don't pointlessly try to use rings/sneakers while charging a spindash. + // TODO: Allowing projectile items like orbinaut while e-braking would probably be fine, maybe just pass in the spindash variable? + K_BotItemUsage(player, cmd, turnamt); + } if (turnamt != 0) { From fb1d495b5c6ba97d018959a4ed93f9d5e2ae6e18 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 6 Feb 2021 01:40:39 -0500 Subject: [PATCH 03/29] Bots can recover from dying Rogue code that came back from vanilla --- src/p_user.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 0df4aa756..87997cedc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2632,9 +2632,6 @@ static void P_DeathThink(player_t *player) if (player->deadtimer < INT32_MAX) player->deadtimer++; - if (player->bot) // don't allow bots to do any of the below, B_CheckRespawn does all they need for respawning already - goto notrealplayer; - if ((player->pflags & PF_GAMETYPEOVER) && (gametyperules & GTR_CIRCUIT)) { player->karthud[khud_timeovercam]++; @@ -2677,8 +2674,6 @@ static void P_DeathThink(player_t *player) } } -notrealplayer: - if (!player->mo) return; From 2344d94a6e3532442aa1b80c59eede08093e7692 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 6 Feb 2021 01:40:58 -0500 Subject: [PATCH 04/29] Minor adjustments to starting difficulty calculations for big GPs --- src/k_grandprix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_grandprix.c b/src/k_grandprix.c index 57e31a885..e46a6a7be 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -167,9 +167,9 @@ void K_InitGrandPrixBots(void) difficultylevels[10] = max(1, startingdifficulty-5); difficultylevels[11] = max(1, startingdifficulty-6); difficultylevels[12] = max(1, startingdifficulty-6); - difficultylevels[13] = max(1, startingdifficulty-6); + difficultylevels[13] = max(1, startingdifficulty-7); difficultylevels[14] = max(1, startingdifficulty-7); - difficultylevels[15] = max(1, startingdifficulty-7); + difficultylevels[15] = max(1, startingdifficulty-8); } for (i = 0; i < MAXPLAYERS; i++) From efb636aebe4362babfe94902aa374c26be4392af Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 6 Feb 2021 05:14:15 -0500 Subject: [PATCH 05/29] Bots do things during POSITION --- src/k_bot.c | 123 ++++++++++++++++++++++++++++++++++++++++++--------- src/k_race.c | 2 +- src/k_race.h | 2 + 3 files changed, 105 insertions(+), 22 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 811efe54b..9432638af 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -26,6 +26,7 @@ #include "d_ticcmd.h" #include "m_random.h" #include "r_things.h" // numskins +#include "k_race.h" // finishBeamLine /*-------------------------------------------------- @@ -521,6 +522,26 @@ fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict) --------------------------------------------------*/ fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy) { +#if 1 + // This function ended up with overflow issues (and too much) + // I'm kinda tired of looking at this so I'mma just gonna wildly cheat + + vertex_t v1, v2; // fake vertexes + line_t junk; // fake linedef + vertex_t result; + + v1.x = v1x; + v1.y = v1y; + + v2.x = v2x; + v2.y = v2y; + + junk.v1 = &v1; + junk.v2 = &v2; + + P_ClosestPointOnLine(cx, cy, &junk, &result); + return R_PointToDist2(cx, cy, result.x, result.y); +#else fixed_t v1toc[2] = {cx - v1x, cy - v1y}; fixed_t v1tov2[2] = {v2x - v1x, v2y - v1y}; @@ -540,7 +561,8 @@ fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t px = v1x + FixedMul(v1tov2[0], t); py = v1y + FixedMul(v1tov2[1], t); - return P_AproxDistance(cx - px, cy - py); + return FixedHypot(cx - px, cy - py); +#endif } /*-------------------------------------------------- @@ -709,14 +731,14 @@ static UINT8 K_TrySpindash(player_t *player) } // Try "start boosts" first - if (leveltime == starttime+1) + if (leveltime == starttime) { // Forces them to release, even if they haven't fully charged. // Don't want them to keep charging if they didn't have time to. return 0; } - if (leveltime <= starttime) + if (leveltime < starttime) { INT32 boosthold = starttime - K_GetSpindashChargeTime(player); @@ -772,6 +794,7 @@ static UINT8 K_TrySpindash(player_t *player) void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) { botprediction_t *predict = NULL; + boolean trySpindash = false; UINT8 spindash = 0; INT32 turnamt = 0; @@ -784,19 +807,16 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // Remove any existing controls memset(cmd, 0, sizeof(ticcmd_t)); - if (gamestate != GS_LEVEL - || player->mo->scale <= 1) // funny post-finish death + if ( + gamestate != GS_LEVEL + || player->mo->scale <= 1 + || player->playerstate == PST_DEAD + ) { // No need to do anything else. return; } - if (player->playerstate == PST_DEAD) - { - cmd->buttons |= BT_ACCELERATE; - return; - } - // Complete override of all ticcmd functionality if (LUAh_BotTiccmd(player, cmd)) { @@ -916,22 +936,83 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } } - // Spindashing - spindash = K_TrySpindash(player); - - if (spindash > 0) + if (leveltime <= starttime && finishBeamLine != NULL) { - cmd->buttons |= BT_EBRAKEMASK; + const fixed_t distBase = 1024*mapobjectscale; + const fixed_t distAdjust = 64*mapobjectscale; - if (spindash == 2 && player->speed < 6*mapobjectscale) + const fixed_t closeDist = distBase + (distAdjust * (9 - player->kartweight)); + const fixed_t farDist = closeDist + (distAdjust * 2); + + fixed_t distToFinish = K_DistanceOfLineFromPoint( + finishBeamLine->v1->x, finishBeamLine->v1->y, + finishBeamLine->v2->x, finishBeamLine->v2->y, + player->mo->x, player->mo->y + ); + + // Don't run the spindash code at all until we're in the right place + trySpindash = false; + + // If you're too far, enable spindash & stay still. + // If you're too close, start backing up. + + if (player - players == displayplayers[0]) { - cmd->buttons |= BT_DRIFT; + CONS_Printf("closeDist: %d\n", closeDist / FRACUNIT); + CONS_Printf("farDist: %d\n", farDist / FRACUNIT); + CONS_Printf("distToFinish: %d\n", distToFinish / FRACUNIT); + CONS_Printf("========\n"); + } + + if (distToFinish < closeDist) + { + // Silly way of getting us to reverse, but it respects the above code + // where we figure out what the shape of the track looks like. + UINT16 oldButtons = cmd->buttons; + + cmd->buttons &= ~(BT_ACCELERATE|BT_BRAKE); + + if (oldButtons & BT_ACCELERATE) + { + cmd->buttons |= BT_BRAKE; + } + + if (oldButtons & BT_BRAKE) + { + cmd->buttons |= BT_ACCELERATE; + } + + cmd->forwardmove = -cmd->forwardmove; + } + else if (distToFinish < farDist) + { + // We're in about the right place, spindash now. + cmd->forwardmove = 0; + trySpindash = true; } } - else + + if (trySpindash == true) { - // Handle item usage here, so they don't pointlessly try to use rings/sneakers while charging a spindash. - // TODO: Allowing projectile items like orbinaut while e-braking would probably be fine, maybe just pass in the spindash variable? + // Spindashing + spindash = K_TrySpindash(player); + + if (spindash > 0) + { + cmd->buttons |= BT_EBRAKEMASK; + cmd->forwardmove = 0; + + if (spindash == 2 && player->speed < 6*mapobjectscale) + { + cmd->buttons |= BT_DRIFT; + } + } + } + + if (spindash == 0) + { + // Don't pointlessly try to use rings/sneakers while charging a spindash. + // TODO: Allowing projectile items like orbinaut while e-braking would be nice, maybe just pass in the spindash variable? K_BotItemUsage(player, cmd, turnamt); } diff --git a/src/k_race.c b/src/k_race.c index 7d65ee2e6..0ac9cb679 100644 --- a/src/k_race.c +++ b/src/k_race.c @@ -41,7 +41,7 @@ #include "k_bot.h" #include "k_hud.h" -static line_t *finishBeamLine = NULL; +line_t *finishBeamLine = NULL; static mobj_t *beamPoints[2]; static UINT8 numBeamPoints = 0; diff --git a/src/k_race.h b/src/k_race.h index 13d870f8e..b9021893e 100644 --- a/src/k_race.h +++ b/src/k_race.h @@ -14,6 +14,8 @@ #include "r_defs.h" +extern line_t *finishBeamLine; + #define FINISHLINEBEAM_SPACING (48*mapobjectscale) /*-------------------------------------------------- From e0f931072cfcd14757036f3a8a89343d02ef42aa Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 6 Feb 2021 05:14:54 -0500 Subject: [PATCH 06/29] Leftover from old comment --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 9432638af..b3c2abe9e 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -523,7 +523,7 @@ fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict) fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy) { #if 1 - // This function ended up with overflow issues (and too much) + // This function ended up with overflow issues // I'm kinda tired of looking at this so I'mma just gonna wildly cheat vertex_t v1, v2; // fake vertexes From 93c5942ceb8a268d312b46aeacc5bec316c620df Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 7 Feb 2021 14:07:27 -0500 Subject: [PATCH 07/29] Air failsafe boost While in the air: release accelerate while at nearly-still speeds, and you'll preform a minisucle air drift boost. This mechanic is meant to fix the long-standing issue where you can get stuck in 0 speed in the air and not be able to do anything. --- src/d_clisrv.c | 2 ++ src/d_clisrv.h | 1 + src/d_player.h | 1 + src/k_kart.c | 50 ++++++++++++++++++++++++++++++++++++++++++++- src/lua_playerlib.c | 4 ++++ src/p_mobj.c | 4 ++++ src/p_saveg.c | 2 ++ 7 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 814320fce..e63cafe33 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -617,6 +617,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->airtime = (tic_t)LONG(players[i].airtime); rsp->driftInput = players[i].driftInput; + rsp->airFailsafe = players[i].airFailsafe; rsp->trickpanel = (UINT8)players[i].trickpanel; rsp->trickdelay = (boolean)players[i].trickdelay; @@ -779,6 +780,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].airtime = (tic_t)LONG(rsp->airtime); players[i].driftInput = (boolean)rsp->driftInput; + players[i].airFailsafe = (boolean)rsp->airFailsafe; players[i].trickpanel = (UINT8)rsp->trickpanel; players[i].trickdelay = (boolean)rsp->trickdelay; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index f5e21d2e3..82baf6581 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -281,6 +281,7 @@ typedef struct INT32 kartstuff[NUMKARTSTUFF]; tic_t airtime; boolean driftInput; + boolean airFailsafe; UINT8 trickpanel; boolean trickdelay; fixed_t trickmomx; diff --git a/src/d_player.h b/src/d_player.h index fc98e93bd..95fd8adea 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -525,6 +525,7 @@ typedef struct player_s respawnvars_t respawn; // Respawn info tic_t airtime; // Keep track of how long you've been in the air boolean driftInput; // Whenever or not try drifting. + boolean airFailsafe; // Whenever or not try the air boost UINT8 trickpanel; // Trick panel state boolean trickdelay; // Prevent tricks until control stick is neutral diff --git a/src/k_kart.c b/src/k_kart.c index 2f01f2dc0..d001b0d0c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6984,6 +6984,7 @@ INT32 K_GetKartDriftSparkValue(player_t *player) Stage 1: red sparks Stage 2: blue sparks Stage 3: big large rainbow sparks +Stage 0: air failsafe */ void K_SpawnDriftBoostExplosion(player_t *player, int stage) { @@ -7014,6 +7015,11 @@ void K_SpawnDriftBoostExplosion(player_t *player, int stage) S_StartSound(player->mo, sfx_kc5b); S_StartSound(player->mo, sfx_s3kc4l); break; + + case 0: + overlay->color = SKINCOLOR_SILVER; + overlay->fuse = 16; + break; } overlay->extravalue1 = stage; @@ -7574,6 +7580,39 @@ static void K_KartSpindash(player_t *player) } } +static void K_AirFailsafe(player_t *player) +{ + const fixed_t maxSpeed = 6*player->mo->scale; + const fixed_t thrustSpeed = 6*player->mo->scale; // 10*player->mo->scale + + ticcmd_t *cmd = &player->cmd; + + if (player->speed > maxSpeed) + { + // Above the max speed that you're allowed to use this technique. + player->airFailsafe = false; + return; + } + + if ((cmd->buttons & BT_ACCELERATE) || K_GetForwardMove(player) != 0) + { + // Queue up later + player->airFailsafe = true; + return; + } + + if (player->airFailsafe == true) + { + // Push the player forward + P_Thrust(player->mo, K_MomentumAngle(player->mo), thrustSpeed); + + S_StartSound(player->mo, sfx_s23c); + K_SpawnDriftBoostExplosion(player, 0); + + player->airFailsafe = false; + } +} + // // K_AdjustPlayerFriction // @@ -8447,9 +8486,18 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } } - K_KartDrift(player, P_IsObjectOnGround(player->mo)); // Not using onground, since we don't want this affected by spring pads + K_KartDrift(player, onground); K_KartSpindash(player); + if (onground == false) + { + K_AirFailsafe(player); + } + else + { + player->airFailsafe = false; + } + // Play the starting countdown sounds if (player == &players[g_localplayers[0]]) // Don't play louder in splitscreen { diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index a8e0e5810..61c6e85b1 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -220,6 +220,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->airtime); else if (fastcmp(field,"driftInput")) lua_pushboolean(L, plr->driftInput); + else if (fastcmp(field,"airFailsafe")) + lua_pushboolean(L, plr->airFailsafe); else if (fastcmp(field,"tumbleBounces")) lua_pushinteger(L, plr->tumbleBounces); else if (fastcmp(field,"tumbleHeight")) @@ -533,6 +535,8 @@ static int player_set(lua_State *L) plr->airtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"driftInput")) plr->driftInput = luaL_checkboolean(L, 3); + else if (fastcmp(field,"airFailsafe")) + plr->airFailsafe = luaL_checkboolean(L, 3); else if (fastcmp(field,"tumbleBounces")) plr->tumbleBounces = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"tumbleHeight")) diff --git a/src/p_mobj.c b/src/p_mobj.c index 2fd5375f5..afc24f668 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6743,6 +6743,10 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->fuse == 16)/* to red*/ K_SpawnDriftBoostClip(mobj->target->player); break; + + case 0:/* air failsafe boost */ + mobj->color = SKINCOLOR_SILVER; // force white + break; } { diff --git a/src/p_saveg.c b/src/p_saveg.c index 0eff1e1d3..e24e3d2f7 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -258,6 +258,7 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].airtime); WRITEUINT8(save_p, players[i].driftInput); + WRITEUINT8(save_p, players[i].airFailsafe); WRITEUINT8(save_p, players[i].trickpanel); WRITEUINT8(save_p, players[i].trickdelay); @@ -463,6 +464,7 @@ static void P_NetUnArchivePlayers(void) players[i].airtime = READUINT32(save_p); players[i].driftInput = (boolean)READUINT8(save_p); + players[i].airFailsafe = (boolean)READUINT8(save_p); players[i].trickpanel = READUINT8(save_p); players[i].trickdelay = READUINT8(save_p); From f4e23bc4e2a13dd0df5ab5b4bda20d22b19f16ac Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 7 Feb 2021 15:25:09 -0500 Subject: [PATCH 08/29] Allow spindash while flashing, but you lose rings while doing so. I really hated that one of your controls would just... turn off while you were flashing. Even if there was a very good reason to not allow it (Funky Kong's Ring Racers:tm:). So instead, you CAN spindash in flashing ticks... but you're punished so harshly for it that it's not worth it. Which will actually teach people to not do it more than just the input arbitrarily not working :p --- src/k_kart.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2f01f2dc0..fced743ff 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7526,11 +7526,14 @@ static void K_KartSpindash(player_t *player) return; } - if (player->speed < 6*mapobjectscale && player->powers[pw_flashing] == 0) + if (player->speed == 0 && cmd->turning != 0 && leveltime % 8 == 0) { - if (cmd->turning != 0 && leveltime % 8 == 0) - S_StartSound(player->mo, sfx_ruburn); + // Rubber burn turn sfx + S_StartSound(player->mo, sfx_ruburn); + } + if (player->speed < 6*player->mo->scale) + { if ((cmd->buttons & (BT_DRIFT|BT_BRAKE)) == (BT_DRIFT|BT_BRAKE)) { INT16 chargetime = MAXCHARGETIME - ++player->kartstuff[k_spindash]; @@ -7547,6 +7550,15 @@ static void K_KartSpindash(player_t *player) K_KartSpindashWind(player->mo); } + if (player->powers[pw_flashing] > 0 && (leveltime & 1)) + { + // Every frame that you're invisible from flashing, spill a ring. + // Intentionally a lop-sided trade-off, so the game doesn't become + // Funky Kong's Ring Racers. + + P_PlayerRingBurst(player, 1); + } + if (chargetime > 0) { UINT16 soundcharge = 0; From 233d25779138ef68fe94a7b3d63cb25c4bdf139d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 7 Feb 2021 15:30:45 -0500 Subject: [PATCH 09/29] Give fling rings shadows, remove afterimages Both oni requests --- src/p_enemy.c | 5 +---- src/p_mobj.c | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 01f8f6bb7..a2c719609 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4229,7 +4229,7 @@ void A_AttractChase(mobj_t *actor) else actor->drawflags &= ~MFD_DONTDRAW; - // spilled rings have ghost trails and get capped to a certain speed + // spilled rings get capped to a certain speed if (actor->type == (mobjtype_t)actor->info->reactiontime) { const fixed_t maxspeed = 4<momx = FixedMul(FixedDiv(actor->momx, oldspeed), newspeed); actor->momy = FixedMul(FixedDiv(actor->momy, oldspeed), newspeed); } - - if (!P_IsObjectOnGround(actor)) - P_SpawnGhostMobj(actor)->tics = 3; } if (actor->tracer && actor->tracer->player && actor->tracer->health diff --git a/src/p_mobj.c b/src/p_mobj.c index 2fd5375f5..96d75fd3e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9197,6 +9197,7 @@ static void P_DefaultMobjShadowScale(mobj_t *thing) thing->shadowscale = FRACUNIT; break; case MT_RING: + case MT_FLINGRING: case MT_DEBTSPIKE: case MT_FLOATINGITEM: case MT_BLUESPHERE: From 038dd17de39dcc77c7263a654aaf7e858d6e5bbb Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 7 Feb 2021 15:44:43 -0500 Subject: [PATCH 10/29] Debt spikes set their fuse when they land Another request from oni --- src/p_inter.c | 2 +- src/p_mobj.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index e9fae2943..8be346257 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2240,6 +2240,6 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) while (i < num_rings) { P_FlingBurst(player, fa, z, - MT_DEBTSPIKE, 90, 3 * player->mo->scale / 2, i++); + MT_DEBTSPIKE, 0, 3 * player->mo->scale / 2, i++); } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 96d75fd3e..438b88099 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2296,6 +2296,11 @@ boolean P_ZMovement(mobj_t *mo) { mom.x = mom.y = 0; mom.z = -mom.z/2; + + if (mo->fuse == 0) + { + mo->fuse = 90; + } } else if (mo->flags & MF_MISSILE) { From 4c26c4fd81d2f9015f1132e6a7cfab1830cf90ae Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 10 Feb 2021 19:23:07 -0500 Subject: [PATCH 11/29] Shadows use additive/subtractive --- src/r_things.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index e1e38041b..25a33b33f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1236,7 +1236,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, patch_t *patch; fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; INT32 light = 0; - fixed_t scalemul; UINT8 trans; + UINT8 trans = tr_transsub; + fixed_t scalemul; fixed_t floordiff; fixed_t groundz; pslope_t *groundslope; @@ -1246,14 +1247,15 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, if (abs(groundz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes + if (thing->whiteshadow == true) + { + trans = tr_transadd; + } + floordiff = abs((isflipped ? thing->height : 0) + thing->z - groundz); - - trans = floordiff / (100*FRACUNIT) + 3; - if (trans >= 9) return; - scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - patch = W_CachePatchName((thing->whiteshadow == true ? "LSHADOW" : "DSHADOW"), PU_CACHE); + patch = W_CachePatchName("DSHADOW", PU_CACHE); xscale = FixedDiv(projection[viewssnum], tz); yscale = FixedDiv(projectiony[viewssnum], tz); shadowxscale = FixedMul(thing->radius*2, scalemul); @@ -1354,16 +1356,9 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, else shadow->extra_colormap = thing->subsector->sector->extra_colormap; - shadow->transmap = transtables + (trans<transmap = transtables + ((trans-1) << FF_TRANSSHIFT); - if (thing->whiteshadow == true) - { - shadow->colormap = scalelight[LIGHTLEVELS - 1][0]; // full bright! - } - else - { - shadow->colormap = scalelight[0][0]; // full dark! - } + shadow->colormap = colormaps; objectsdrawn++; } From e250c35489b2acfb979f10b9357c58a55cc7a2f6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 10 Feb 2021 20:03:29 -0500 Subject: [PATCH 12/29] Remove ground scaling I dun like it, it makes the gameplay purpose of shadows harder to discern --- src/r_things.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 25a33b33f..c4e76303d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1237,11 +1237,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; INT32 light = 0; UINT8 trans = tr_transsub; - fixed_t scalemul; - fixed_t floordiff; fixed_t groundz; pslope_t *groundslope; - boolean isflipped = thing->eflags & MFE_VERTICALFLIP; groundz = R_GetShadowZ(thing, &groundslope); @@ -1252,14 +1249,11 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, trans = tr_transadd; } - floordiff = abs((isflipped ? thing->height : 0) + thing->z - groundz); - scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - patch = W_CachePatchName("DSHADOW", PU_CACHE); xscale = FixedDiv(projection[viewssnum], tz); yscale = FixedDiv(projectiony[viewssnum], tz); - shadowxscale = FixedMul(thing->radius*2, scalemul); - shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz)); + shadowxscale = FixedMul(thing->radius*2, scale); + shadowyscale = FixedMul(FixedMul(thing->radius*2, scale), FixedDiv(abs(groundz - viewz), tz)); shadowyscale = min(shadowyscale, shadowxscale) / SHORT(patch->height); shadowxscale /= SHORT(patch->width); shadowskew = 0; @@ -1276,9 +1270,9 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); if (viewz < groundz) - shadowyscale += FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope); + shadowyscale += FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scale), zslope); else - shadowyscale -= FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope); + shadowyscale -= FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scale), zslope); shadowyscale = abs(shadowyscale); From 346b69e31205ee6493d56ffed7de75c9d10795d6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 11 Feb 2021 13:05:40 -0500 Subject: [PATCH 13/29] Not in respawn --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index d001b0d0c..056b7bc73 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7587,9 +7587,9 @@ static void K_AirFailsafe(player_t *player) ticcmd_t *cmd = &player->cmd; - if (player->speed > maxSpeed) + if (player->speed > maxSpeed // Above the max speed that you're allowed to use this technique. + || player->respawn.state != RESPAWNST_NONE) // Respawning, you don't need this AND drop dash :V { - // Above the max speed that you're allowed to use this technique. player->airFailsafe = false; return; } From 1c7f6e9c09ccfafb8e191fb048fdebd70e1f8e1b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 11 Feb 2021 13:12:15 -0500 Subject: [PATCH 14/29] Hyudoro does not count as flashing --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index fced743ff..eb7f10720 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7550,7 +7550,7 @@ static void K_KartSpindash(player_t *player) K_KartSpindashWind(player->mo); } - if (player->powers[pw_flashing] > 0 && (leveltime & 1)) + if (player->powers[pw_flashing] > 0 && (leveltime & 1) && player->kartstuff[k_hyudorotimer] == 0) { // Every frame that you're invisible from flashing, spill a ring. // Intentionally a lop-sided trade-off, so the game doesn't become From c58b5e92a193254f0cc87569ca26be0a817e8e9d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 11 Feb 2021 16:25:35 -0500 Subject: [PATCH 15/29] Fixed weird issues with finish beam dist, properly use old behavior without beam, make bots get way closer --- src/k_bot.c | 62 +++++++++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index b3c2abe9e..3eb52519e 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -520,49 +520,35 @@ fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict) See header file for description. --------------------------------------------------*/ -fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy) +fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t px, fixed_t py) { -#if 1 - // This function ended up with overflow issues - // I'm kinda tired of looking at this so I'mma just gonna wildly cheat - - vertex_t v1, v2; // fake vertexes - line_t junk; // fake linedef - vertex_t result; - - v1.x = v1x; - v1.y = v1y; - - v2.x = v2x; - v2.y = v2y; - - junk.v1 = &v1; - junk.v2 = &v2; - - P_ClosestPointOnLine(cx, cy, &junk, &result); - return R_PointToDist2(cx, cy, result.x, result.y); -#else - fixed_t v1toc[2] = {cx - v1x, cy - v1y}; - fixed_t v1tov2[2] = {v2x - v1x, v2y - v1y}; - - fixed_t mag = FixedMul(v1tov2[0], v1tov2[0]) + FixedMul(v1tov2[1], v1tov2[1]); - fixed_t dot = FixedMul(v1toc[0], v1tov2[0]) + FixedMul(v1toc[1], v1tov2[1]); + // Copy+paste from P_ClosestPointOnLine :pensive: + fixed_t startx = v1x; + fixed_t starty = v1y; + fixed_t dx = v2x - v1x; + fixed_t dy = v2y - v1y; + fixed_t cx, cy; + fixed_t vx, vy; + fixed_t magnitude; fixed_t t; - fixed_t px, py; - if (mag == 0) - { - return 0; - } + cx = px - startx; + cy = py - starty; - t = FixedDiv(dot, mag); + vx = dx; + vy = dy; - px = v1x + FixedMul(v1tov2[0], t); - py = v1y + FixedMul(v1tov2[1], t); + magnitude = R_PointToDist2(v2x, v2y, startx, starty); + vx = FixedDiv(vx, magnitude); + vy = FixedDiv(vy, magnitude); - return FixedHypot(cx - px, cy - py); -#endif + t = (FixedMul(vx, cx) + FixedMul(vy, cy)); + + vx = FixedMul(vx, t); + vy = FixedMul(vy, t); + + return R_PointToDist2(px, py, startx + vx, starty + vy); } /*-------------------------------------------------- @@ -794,7 +780,7 @@ static UINT8 K_TrySpindash(player_t *player) void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) { botprediction_t *predict = NULL; - boolean trySpindash = false; + boolean trySpindash = true; UINT8 spindash = 0; INT32 turnamt = 0; @@ -938,7 +924,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) if (leveltime <= starttime && finishBeamLine != NULL) { - const fixed_t distBase = 1024*mapobjectscale; + const fixed_t distBase = 384*mapobjectscale; const fixed_t distAdjust = 64*mapobjectscale; const fixed_t closeDist = distBase + (distAdjust * (9 - player->kartweight)); From 1f7fd96e3266d0c9e0ea7a459b3f5a6a4c5e4233 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 11 Feb 2021 19:08:44 -0500 Subject: [PATCH 16/29] Bot controller linedef Controls bot behavior while they're touching a tagged sector. X texture offset is angle to force the bot in (0 is east, 90 is north, 180 is west, 270 is south) Y texture offset is trick type -- if a bot enters the sector while in trick panel state, then they'll do the input for the trick. Without the effect present, they'll do nothing and eventually tumble. Y offset 1 does a left trick, 2 is right, 3 is forward, 4 is back/up. --- src/k_bot.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++--- src/p_spec.c | 2 + 2 files changed, 123 insertions(+), 6 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 3eb52519e..88ba76495 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -772,6 +772,67 @@ static UINT8 K_TrySpindash(player_t *player) return 0; } +/*-------------------------------------------------- + static INT16 K_FindBotController(mobj_t *mo) + + Finds if any bot controller linedefs are tagged to the bot's sector. + + Input Arguments:- + mo - The bot player's mobj. + + Return:- + Line number of the bot controller. -1 if it doesn't exist. +--------------------------------------------------*/ +static INT16 K_FindBotController(mobj_t *mo) +{ + msecnode_t *node; + ffloor_t *rover; + INT16 lineNum = -1; + + I_Assert(mo != NULL); + I_Assert(!P_MobjWasRemoved(mo)); + + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (!node->m_sector) + { + continue; + } + + lineNum = P_FindSpecialLineFromTag(2004, node->m_sector->tag, -1); + + if (lineNum != -1) + { + return lineNum; + } + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + sector_t *rs = NULL; + + if (!(rover->flags & FF_EXISTS)) + { + continue; + } + + if (mo->z > *rover->topheight || mo->z + mo->height < *rover->bottomheight) + { + continue; + } + + rs = §ors[rover->secnum]; + lineNum = P_FindSpecialLineFromTag(2004, rs->tag, -1); + + if (lineNum != -1) + { + return lineNum; + } + } + } + + return -1; +} + /*-------------------------------------------------- void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) @@ -783,6 +844,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) boolean trySpindash = true; UINT8 spindash = 0; INT32 turnamt = 0; + INT16 botController = -1; // Can't build a ticcmd if we aren't spawned... if (!player->mo) @@ -809,18 +871,71 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) return; } - // Handle steering towards waypoints! - if (player->nextwaypoint != NULL && player->nextwaypoint->mobj != NULL && !P_MobjWasRemoved(player->nextwaypoint->mobj)) + botController = K_FindBotController(player->mo); + + if (player->trickpanel != 0) { + // Trick panel state -- do nothing until a controller line is found, in which case do a trick. + + if (player->trickpanel == 1 && botController != -1) + { + line_t *controllerLine = &lines[botController]; + INT32 type = (sides[controllerLine->sidenum[0]].rowoffset / FRACUNIT); + + // Y Offset: Trick type + switch (type) + { + case 1: + cmd->turning = KART_FULLTURN; + break; + case 2: + cmd->turning = -KART_FULLTURN; + break; + case 3: + cmd->buttons |= BT_FORWARD; + break; + case 4: + cmd->buttons |= BT_BACKWARD; + break; + } + } + + // Don't do anything else. + return; + } + + if ((player->nextwaypoint != NULL + && player->nextwaypoint->mobj != NULL + && !P_MobjWasRemoved(player->nextwaypoint->mobj)) + || (botController != -1)) + { + // Handle steering towards waypoints! SINT8 turnsign = 0; angle_t destangle, moveangle, angle; INT16 anglediff; - predict = K_CreateBotPrediction(player); + if (botController != -1) + { + const fixed_t dist = (player->mo->radius * 4); + line_t *controllerLine = &lines[botController]; + + // X Offset: Movement direction + destangle = FixedAngle(sides[controllerLine->sidenum[0]].textureoffset); + + // Overwritten prediction + predict = Z_Calloc(sizeof(botprediction_t), PU_LEVEL, NULL); + + predict->x = player->mo->x + FixedMul(dist, FINECOSINE(destangle >> ANGLETOFINESHIFT)); + predict->y = player->mo->y + FixedMul(dist, FINESINE(destangle >> ANGLETOFINESHIFT)); + predict->radius = (DEFAULT_WAYPOINT_RADIUS / 4) * mapobjectscale; + } + else + { + predict = K_CreateBotPrediction(player); + destangle = R_PointToAngle2(player->mo->x, player->mo->y, predict->x, predict->y); + } - destangle = R_PointToAngle2(player->mo->x, player->mo->y, predict->x, predict->y); moveangle = player->mo->angle; - angle = (moveangle - destangle); if (angle < ANGLE_180) @@ -846,7 +961,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) else { const fixed_t playerwidth = (player->mo->radius * 2); - const fixed_t realrad = predict->radius - (playerwidth * 4); // Remove a "safe" distance away from the edges of the road + fixed_t realrad = predict->radius - (playerwidth * 4); // Remove a "safe" distance away from the edges of the road fixed_t rad = realrad; fixed_t dirdist = K_DistanceOfLineFromPoint( player->mo->x, player->mo->y, diff --git a/src/p_spec.c b/src/p_spec.c index 96caeacc9..97fb66c06 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6955,6 +6955,8 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 2003: // Respawn Line break; + case 2004: // Bot controller + break; default: break; From 25ac5c9853b9bdaa51080fe6f16d7ae77ce63e30 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 11 Feb 2021 19:37:39 -0500 Subject: [PATCH 17/29] Speedometer crash fix --- src/k_hud.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 93d1ec46a..fc1a3d995 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2085,7 +2085,8 @@ static void K_drawKartSpeedometer(void) } // Don't overflow - if (convSpeed > 999) + // (negative speed IS really high speed :V) + if (convSpeed > 999 || convSpeed < 0) convSpeed = 999; numbers[0] = ((convSpeed / 100) % 10); From 49b43375648c092dec075cc771cdcf6d054eee9f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 11 Feb 2021 19:46:39 -0500 Subject: [PATCH 18/29] While I'm at it, remove dumb multiplier for percentage mode Hasn't been needed after all of the movement bugs causing this discrepency were fixed, so now it just looks weird when you use a Sneaker and it shows you at 105% afterwards. --- src/k_hud.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index fc1a3d995..8736eb8e2 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2066,7 +2066,7 @@ static void K_drawKartSpeedometer(void) { case 1: // Sonic Drift 2 style percentage default: - convSpeed = (((25*stplyr->speed)/24) * 100) / K_GetKartSpeed(stplyr, false); // Based on top speed! (cheats with the numbers due to some weird discrepancy) + convSpeed = (stplyr->speed * 100) / K_GetKartSpeed(stplyr, false); // Based on top speed! labeln = 0; break; case 2: // Kilometers From 13285d0ca45c95e5f4f37b8c37a180f43d568338 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 00:55:41 -0500 Subject: [PATCH 19/29] OpenGL shader updated to be subtractive Not a big fan of how it separately checks each channel but grumble grumble --- src/hardware/r_opengl/r_opengl.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1ded58204..ca591e1af 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -698,7 +698,36 @@ static INT32 shader_leveltime = 0; "float fd = fe - fs;\n" \ "darkness = clamp((darkness - fs) * (1.0 / fd), 0.0, 1.0);\n" \ "}\n" \ - "final_color = mix(final_color, fade_color, darkness);\n" + "float colorBrightness = sqrt((final_color.r * final_color.r) + (final_color.g * final_color.g) + (final_color.b * final_color.b));\n" \ + "float fogBrightness = sqrt((fade_color.r * fade_color.r) + (fade_color.g * fade_color.g) + (fade_color.b * fade_color.b));\n" \ + "float colorIntensity = 0.0;\n" \ + "if (fogBrightness > colorBrightness) {\n" \ + "colorIntensity = 1.0 - min(final_color.r, min(final_color.g, final_color.b));\n" \ + "} else {\n" \ + "colorIntensity = max(final_color.r, max(final_color.g, final_color.b));\n" \ + "}\n" \ + "colorIntensity *= darkness;\n" \ + "if (abs(final_color.r - fade_color.r) <= colorIntensity) {\n" \ + "final_color.r = fade_color.r;\n" \ + "} else if (final_color.r < fade_color.r) {\n" \ + "final_color.r += colorIntensity;\n" \ + "} else {\n" \ + "final_color.r -= colorIntensity;\n" \ + "}\n" \ + "if (abs(final_color.g - fade_color.g) <= colorIntensity) {\n" \ + "final_color.g = fade_color.g;\n" \ + "} else if (final_color.g < fade_color.g) {\n" \ + "final_color.g += colorIntensity;\n" \ + "} else {\n" \ + "final_color.g -= colorIntensity;\n" \ + "}\n" \ + "if (abs(final_color.b - fade_color.b) <= colorIntensity) {\n" \ + "final_color.b = fade_color.b;\n" \ + "} else if (final_color.b < fade_color.b) {\n" \ + "final_color.b += colorIntensity;\n" \ + "} else {\n" \ + "final_color.b -= colorIntensity;\n" \ + "}\n" \ #define GLSL_SOFTWARE_FRAGMENT_SHADER \ "uniform sampler2D tex;\n" \ From 9bf22934811ce49b5d7c40467caf657231c9205a Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 02:07:47 -0500 Subject: [PATCH 20/29] Increase rubberband range --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 88ba76495..60cf61d0d 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -297,7 +297,7 @@ boolean K_BotCanTakeCut(player_t *player) --------------------------------------------------*/ static UINT32 K_BotRubberbandDistance(player_t *player) { - const UINT32 spacing = FixedDiv(512 * FRACUNIT, K_GetKartGameSpeedScalar(gamespeed)) / FRACUNIT; + const UINT32 spacing = FixedDiv(640 * FRACUNIT, K_GetKartGameSpeedScalar(gamespeed)) / FRACUNIT; const UINT8 portpriority = player - players; UINT8 pos = 0; UINT8 i; From f236fcc5e228af54df685ce4434af58da4a3d2d1 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 02:08:10 -0500 Subject: [PATCH 21/29] Decrease max top speed rubberband --- src/k_bot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 60cf61d0d..0d687d8cd 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -430,8 +430,8 @@ fixed_t K_BotTopSpeedRubberband(player_t *player) } else { - // Max at +25% for level 9 bots - rubberband = FRACUNIT + ((rubberband - FRACUNIT) / 4); + // Max at +10% for level 9 bots + rubberband = FRACUNIT + ((rubberband - FRACUNIT) / 10); } // Only allow you to go faster than your regular top speed if you're facing the right direction From 87158825b6bf4ce392e229501f39a1c27ab9b8f1 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 02:36:03 -0500 Subject: [PATCH 22/29] Increase base bot top speed depending on difficulty --- src/k_kart.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2f01f2dc0..162eca3c1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2470,10 +2470,17 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower) finalspeed = FixedMul(finalspeed, FRACUNIT + (sphereAdd * player->spheres)); } - if (K_PlayerUsesBotMovement(player) && player->botvars.rival == true) + if (K_PlayerUsesBotMovement(player)) { - // +10% top speed for the rival - finalspeed = FixedMul(finalspeed, 11*FRACUNIT/10); + // Increase bot speed by 1-10% depending on difficulty + fixed_t add = (player->botvars.difficulty * (FRACUNIT/10)) / 9; + finalspeed = FixedMul(finalspeed, FRACUNIT + add); + + if (player->botvars.rival == true) + { + // +10% top speed for the rival + finalspeed = FixedMul(finalspeed, 11*FRACUNIT/10); + } } if (player->mo && !P_MobjWasRemoved(player->mo)) From ce9ece3c0b030b849e9c061248946cef11e4901b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 03:19:57 -0500 Subject: [PATCH 23/29] Increase ring power for bots --- src/k_kart.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 162eca3c1..15070c61c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2473,7 +2473,7 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower) if (K_PlayerUsesBotMovement(player)) { // Increase bot speed by 1-10% depending on difficulty - fixed_t add = (player->botvars.difficulty * (FRACUNIT/10)) / 9; + fixed_t add = (player->botvars.difficulty * (FRACUNIT/10)) / MAXBOTDIFFICULTY; finalspeed = FixedMul(finalspeed, FRACUNIT + add); if (player->botvars.rival == true) @@ -6845,7 +6845,15 @@ void K_UpdateDistanceFromFinishLine(player_t *const player) INT32 K_GetKartRingPower(player_t *player) { - return (((9 - player->kartspeed) + (9 - player->kartweight)) / 2); + INT32 ringPower = ((9 - player->kartspeed) + (9 - player->kartweight)) / 2; + + if (K_PlayerUsesBotMovement(player)) + { + // Double for Lv. 9 + ringPower += (player->botvars.difficulty * ringPower) / MAXBOTDIFFICULTY; + } + + return ringPower; } // Returns false if this player being placed here causes them to collide with any other player From f134c07c0024717908c965729f071b85d35152d9 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 03:20:43 -0500 Subject: [PATCH 24/29] Severely decrease spindash threshold --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 0d687d8cd..ee9ab2cb6 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -750,7 +750,7 @@ static UINT8 K_TrySpindash(player_t *player) return 0; } - if (player->speed < K_GetKartSpeed(player, false) / 4 // Below the speed threshold + if (player->speed < 10*mapobjectscale // Below the speed threshold && player->kartstuff[k_speedboost] < (FRACUNIT/8)) // If you have other boosts, you can probably trust it. { INT32 chargingPoint = (K_GetSpindashChargeTime(player) + difficultyModifier); From 839d5fdd09af2f57a59843acae37102569d30418 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 12 Feb 2021 01:16:51 -0800 Subject: [PATCH 25/29] Title card is always available, regardless of level title This had the really mean side effect of disabling lt_ticker, forcing anything drawn with V_SLIDEIN to never appear (basically the entire hud). --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 0a494918f..6cc1f9aa2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1309,9 +1309,11 @@ void G_PreLevelTitleCard(void) // boolean G_IsTitleCardAvailable(void) { +#if 0 // The current level has no name. if (!mapheaderinfo[gamemap-1]->lvlttl[0]) return false; +#endif // The title card is available. return true; From bf047291fd17f77c830a26fe334f31af5c29bf48 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 12 Feb 2021 07:08:42 -0800 Subject: [PATCH 26/29] Fix double scaling on vertical momentum for ring burst P_SetObjectMomZ already applies object scale. It also applies gravity flipping, so both of these were being done twice. :v --- src/p_inter.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index e9fae2943..6bc645327 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2182,10 +2182,7 @@ static void P_FlingBurst mo->momy = (mo->target->momy/2) + FixedMul(FINESINE(fa>>ANGLETOFINESHIFT), ns); ns = FixedMul(momz, player->mo->scale); - P_SetObjectMomZ(mo, (mo->target->momz/2) + ns, false); - - if (player->mo->eflags & MFE_VERTICALFLIP) - mo->momz *= -1; + mo->momz = (mo->target->momz/2) + ns * P_MobjFlip(mo); } /** Spills an injured player's rings. From 8734db6cfda3c53f6e70715cd8eed21ff7f044a8 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 12 Feb 2021 11:21:35 -0500 Subject: [PATCH 27/29] Remove prints --- src/k_bot.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index ee9ab2cb6..9fcee08ce 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -1057,14 +1057,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // If you're too far, enable spindash & stay still. // If you're too close, start backing up. - if (player - players == displayplayers[0]) - { - CONS_Printf("closeDist: %d\n", closeDist / FRACUNIT); - CONS_Printf("farDist: %d\n", farDist / FRACUNIT); - CONS_Printf("distToFinish: %d\n", distToFinish / FRACUNIT); - CONS_Printf("========\n"); - } - if (distToFinish < closeDist) { // Silly way of getting us to reverse, but it respects the above code From 223e411fa515aad1d5368d71ca7766c7a4c15409 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 12 Feb 2021 09:23:18 -0800 Subject: [PATCH 28/29] parenthesism --- src/p_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 6bc645327..6d2d89d36 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2182,7 +2182,7 @@ static void P_FlingBurst mo->momy = (mo->target->momy/2) + FixedMul(FINESINE(fa>>ANGLETOFINESHIFT), ns); ns = FixedMul(momz, player->mo->scale); - mo->momz = (mo->target->momz/2) + ns * P_MobjFlip(mo); + mo->momz = (mo->target->momz/2) + ((ns) * P_MobjFlip(mo)); } /** Spills an injured player's rings. From ca531738abad5afb1d02177826f4af1a98d33ff0 Mon Sep 17 00:00:00 2001 From: Sryder Date: Fri, 12 Feb 2021 18:41:16 +0000 Subject: [PATCH 29/29] Fix for missing part of lighting calculation compared to software. --- src/hardware/r_opengl/r_opengl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ca591e1af..9e9bbee81 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -150,8 +150,8 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...) char str[4096] = ""; va_list arglist; - if (gllogstream) - { + if (gllogstream) + { va_start(arglist, format); vsnprintf(str, 4096, format, arglist); va_end(arglist); @@ -703,8 +703,10 @@ static INT32 shader_leveltime = 0; "float colorIntensity = 0.0;\n" \ "if (fogBrightness > colorBrightness) {\n" \ "colorIntensity = 1.0 - min(final_color.r, min(final_color.g, final_color.b));\n" \ + "colorIntensity = abs(colorIntensity - (1.0 - fogBrightness));\n" \ "} else {\n" \ "colorIntensity = max(final_color.r, max(final_color.g, final_color.b));\n" \ + "colorIntensity = abs(colorIntensity - (fogBrightness));\n" \ "}\n" \ "colorIntensity *= darkness;\n" \ "if (abs(final_color.r - fade_color.r) <= colorIntensity) {\n" \