From 3076e73c5956639bd5662cbdafcd7e9e7eb5f8f8 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 12 May 2025 18:13:34 -0400 Subject: [PATCH 1/3] WIP: Nerf bumper car bots --- src/d_player.h | 2 ++ src/k_bot.cpp | 3 +++ src/k_kart.c | 11 +++++++++++ src/lua_playerlib.c | 4 ++++ src/p_map.c | 3 +++ src/p_saveg.cpp | 4 ++++ 6 files changed, 27 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 64547b348..babfa6a86 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -844,6 +844,8 @@ struct player_t UINT8 trickboost; // Trick boost. This one is weird and has variable speed. Dear god. UINT8 tricklock; // Input safety for 2.2 lenient tricks. + UINT8 bumpslow; + UINT8 dashRingPullTics; // Timer during which the player is pulled towards a dash ring UINT8 dashRingPushTics; // Timer during which the player displays effects and has no gravity after being thrust by a dash ring diff --git a/src/k_bot.cpp b/src/k_bot.cpp index c55766189..1e8cc323b 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -806,6 +806,9 @@ fixed_t K_UpdateRubberband(player_t *player) // Ease into the new value. ret += (dest - player->botvars.rubberband) / 8; + if (player->bumpslow) + ret = FRACUNIT/2; // Magic number! + return ret; } diff --git a/src/k_kart.c b/src/k_kart.c index 5173fa3eb..5fa6ff7aa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9438,6 +9438,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->trickboost) player->trickboost--; + if (player->bumpslow) + player->bumpslow--; + if (player->flamedash) { player->flamedash--; @@ -10224,6 +10227,14 @@ void K_KartResetPlayerColor(player_t *player) goto base; } + if (player->bumpslow) + { + player->mo->colorized = true; + player->mo->color = SKINCOLOR_RED; + fullbright = true; + goto finalise; + } + if (player->eggmanexplode) // You're gonna diiiiie { const INT32 flashtime = 4<<(player->eggmanexplode/TICRATE); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 62eca4611..4833edfa5 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -526,6 +526,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->trickboost); else if (fastcmp(field,"tricklock")) lua_pushinteger(L, plr->tricklock); + else if (fastcmp(field,"bumpslow")) + lua_pushinteger(L, plr->bumpslow); else if (fastcmp(field,"dashringpulltics")) lua_pushinteger(L, plr->dashRingPullTics); else if (fastcmp(field,"dashringpushtics")) @@ -1136,6 +1138,8 @@ static int player_set(lua_State *L) plr->trickboost = luaL_checkinteger(L, 3); else if (fastcmp(field,"tricklock")) plr->tricklock = luaL_checkinteger(L, 3); + else if (fastcmp(field,"bumpslow")) + plr->bumpslow = luaL_checkinteger(L, 3); else if (fastcmp(field,"dashringpulltics")) plr->dashRingPullTics = luaL_checkinteger(L, 3); else if (fastcmp(field,"dashringpushtics")) diff --git a/src/p_map.c b/src/p_map.c index c4e831118..dc66c03af 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -4117,6 +4117,9 @@ static void P_BouncePlayerMove(mobj_t *mo, TryMoveResult_t *result) if (mo->player) mo->player->bumpUnstuck += 5; + if (K_PlayerUsesBotMovement(mo->player)) + mo->player->bumpslow = TICRATE*2; + // Combo avoidance! if (mo->player && P_PlayerInPain(mo->player) && gametyperules & GTR_BUMPERS && mo->health == 1) { diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 9f11fbb70..b3072b409 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -569,6 +569,8 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT8(save->p, players[i].trickboost); WRITEUINT8(save->p, players[i].tricklock); + WRITEUINT8(save->p, players[i].bumpslow); + WRITEUINT8(save->p, players[i].dashRingPullTics); WRITEUINT8(save->p, players[i].dashRingPushTics); @@ -1206,6 +1208,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].trickboost = READUINT8(save->p); players[i].tricklock = READUINT8(save->p); + players[i].bumpslow = READUINT8(save->p); + players[i].dashRingPullTics = READUINT8(save->p); players[i].dashRingPushTics = READUINT8(save->p); From e19473e32238c594e5ef6356ef9c35fddf384f9b Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 13 May 2025 01:22:21 -0400 Subject: [PATCH 2/3] Bot bump slowdown refinements --- src/k_bot.cpp | 10 ++++++---- src/k_kart.c | 19 ++++++++++--------- src/k_kart.h | 2 ++ src/p_inter.c | 1 + src/p_map.c | 3 +-- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/k_bot.cpp b/src/k_bot.cpp index 1e8cc323b..3875c56ab 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -803,11 +803,13 @@ fixed_t K_UpdateRubberband(player_t *player) fixed_t dest = K_BotRubberband(player); fixed_t ret = player->botvars.rubberband; - // Ease into the new value. - ret += (dest - player->botvars.rubberband) / 8; + UINT8 ease_soften = 8; - if (player->bumpslow) - ret = FRACUNIT/2; // Magic number! + if (player->bumpslow && dest > ret) + ease_soften *= 10; + + // Ease into the new value. + ret += (dest - player->botvars.rubberband) / ease_soften; return ret; } diff --git a/src/k_kart.c b/src/k_kart.c index 5fa6ff7aa..22e7bc2d2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9438,7 +9438,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->trickboost) player->trickboost--; - if (player->bumpslow) + if (player->bumpslow && player->incontrol) player->bumpslow--; if (player->flamedash) @@ -10227,14 +10227,6 @@ void K_KartResetPlayerColor(player_t *player) goto base; } - if (player->bumpslow) - { - player->mo->colorized = true; - player->mo->color = SKINCOLOR_RED; - fullbright = true; - goto finalise; - } - if (player->eggmanexplode) // You're gonna diiiiie { const INT32 flashtime = 4<<(player->eggmanexplode/TICRATE); @@ -15460,4 +15452,13 @@ UINT32 K_GetNumGradingPoints(void) return numlaps * (1 + Obj_GetCheckpointCount()); } +void K_BotHitPenalty(player_t *player) +{ + if (K_PlayerUsesBotMovement(player)) + { + player->botvars.rubberband = max(player->botvars.rubberband/2, FRACUNIT/2); + player->bumpslow = TICRATE*2; + } +} + //} diff --git a/src/k_kart.h b/src/k_kart.h index 00b0e44c3..0ffc59387 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -312,6 +312,8 @@ UINT16 K_GetDisplayEXP(player_t *player); UINT32 K_GetNumGradingPoints(void); +void K_BotHitPenalty(player_t *player); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_inter.c b/src/p_inter.c index b3d178254..af5947728 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -3193,6 +3193,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (source && source != player->mo && source->player) { K_SpawnAmps(source->player, K_PvPAmpReward((type == DMG_WHUMBLE) ? 30 : 20, source->player, player), target); + K_BotHitPenalty(player); // Extend the invincibility if the hit was a direct hit. if (inflictor == source && source->player->invincibilitytimer && diff --git a/src/p_map.c b/src/p_map.c index dc66c03af..382be7d3c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -4117,8 +4117,7 @@ static void P_BouncePlayerMove(mobj_t *mo, TryMoveResult_t *result) if (mo->player) mo->player->bumpUnstuck += 5; - if (K_PlayerUsesBotMovement(mo->player)) - mo->player->bumpslow = TICRATE*2; + K_BotHitPenalty(mo->player); // Combo avoidance! if (mo->player && P_PlayerInPain(mo->player) && gametyperules & GTR_BUMPERS && mo->health == 1) From eae8e1516bd16b40e9f598ccabebff198b824c86 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 13 May 2025 20:23:54 -0400 Subject: [PATCH 3/3] Move bumpslow to botvars --- src/d_player.h | 3 +-- src/k_bot.cpp | 2 +- src/k_kart.c | 6 +++--- src/lua_playerlib.c | 4 ---- src/p_saveg.cpp | 6 ++---- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index babfa6a86..2c0979103 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -406,6 +406,7 @@ struct botvars_t // All entries above persist between rounds and must be recorded in demos fixed_t rubberband; // Bot rubberband value + UINT8 bumpslow; tic_t itemdelay; // Delay before using item at all tic_t itemconfirm; // When high enough, they will use their item @@ -844,8 +845,6 @@ struct player_t UINT8 trickboost; // Trick boost. This one is weird and has variable speed. Dear god. UINT8 tricklock; // Input safety for 2.2 lenient tricks. - UINT8 bumpslow; - UINT8 dashRingPullTics; // Timer during which the player is pulled towards a dash ring UINT8 dashRingPushTics; // Timer during which the player displays effects and has no gravity after being thrust by a dash ring diff --git a/src/k_bot.cpp b/src/k_bot.cpp index 3875c56ab..041a0be38 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -805,7 +805,7 @@ fixed_t K_UpdateRubberband(player_t *player) UINT8 ease_soften = 8; - if (player->bumpslow && dest > ret) + if (player->botvars.bumpslow && dest > ret) ease_soften *= 10; // Ease into the new value. diff --git a/src/k_kart.c b/src/k_kart.c index 22e7bc2d2..6d6ac23fc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9438,8 +9438,8 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->trickboost) player->trickboost--; - if (player->bumpslow && player->incontrol) - player->bumpslow--; + if (K_PlayerUsesBotMovement(players) && player->botvars.bumpslow && player->incontrol) + player->botvars.bumpslow--; if (player->flamedash) { @@ -15457,7 +15457,7 @@ void K_BotHitPenalty(player_t *player) if (K_PlayerUsesBotMovement(player)) { player->botvars.rubberband = max(player->botvars.rubberband/2, FRACUNIT/2); - player->bumpslow = TICRATE*2; + player->botvars.bumpslow = TICRATE*2; } } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 4833edfa5..62eca4611 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -526,8 +526,6 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->trickboost); else if (fastcmp(field,"tricklock")) lua_pushinteger(L, plr->tricklock); - else if (fastcmp(field,"bumpslow")) - lua_pushinteger(L, plr->bumpslow); else if (fastcmp(field,"dashringpulltics")) lua_pushinteger(L, plr->dashRingPullTics); else if (fastcmp(field,"dashringpushtics")) @@ -1138,8 +1136,6 @@ static int player_set(lua_State *L) plr->trickboost = luaL_checkinteger(L, 3); else if (fastcmp(field,"tricklock")) plr->tricklock = luaL_checkinteger(L, 3); - else if (fastcmp(field,"bumpslow")) - plr->bumpslow = luaL_checkinteger(L, 3); else if (fastcmp(field,"dashringpulltics")) plr->dashRingPullTics = luaL_checkinteger(L, 3); else if (fastcmp(field,"dashringpushtics")) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index b3072b409..3723417c6 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -569,8 +569,6 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT8(save->p, players[i].trickboost); WRITEUINT8(save->p, players[i].tricklock); - WRITEUINT8(save->p, players[i].bumpslow); - WRITEUINT8(save->p, players[i].dashRingPullTics); WRITEUINT8(save->p, players[i].dashRingPushTics); @@ -733,6 +731,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT8(save->p, players[i].botvars.diffincrease); WRITEUINT8(save->p, players[i].botvars.rival); WRITEFIXED(save->p, players[i].botvars.rubberband); + WRITEUINT8(save->p, players[i].botvars.bumpslow); WRITEUINT32(save->p, players[i].botvars.itemdelay); WRITEUINT32(save->p, players[i].botvars.itemconfirm); WRITESINT8(save->p, players[i].botvars.turnconfirm); @@ -1208,8 +1207,6 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].trickboost = READUINT8(save->p); players[i].tricklock = READUINT8(save->p); - players[i].bumpslow = READUINT8(save->p); - players[i].dashRingPullTics = READUINT8(save->p); players[i].dashRingPushTics = READUINT8(save->p); @@ -1372,6 +1369,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].botvars.diffincrease = READUINT8(save->p); players[i].botvars.rival = (boolean)READUINT8(save->p); players[i].botvars.rubberband = READFIXED(save->p); + players[i].botvars.bumpslow = READUINT8(save->p); players[i].botvars.itemdelay = READUINT32(save->p); players[i].botvars.itemconfirm = READUINT32(save->p); players[i].botvars.turnconfirm = READSINT8(save->p);