From 34afebfc060ff41db1c46d4115fbc746c6772720 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony <ZwipZwapZapony@gmail.com> Date: Sat, 24 Feb 2024 15:41:51 +0100 Subject: [PATCH] Revert P_SuperReady to a boolean transform type --- src/deh_tables.c | 5 ---- src/lua_baselib.c | 6 ++--- src/p_local.h | 10 +------- src/p_user.c | 58 ++++++++++++----------------------------------- 4 files changed, 18 insertions(+), 61 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 2ccf80e145..a3b6f2334d 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5315,11 +5315,6 @@ struct int_const_s const INT_CONST[] = { //// Masks {"DMG_CANHURTSELF",DMG_CANHURTSELF}, {"DMG_DEATHMASK",DMG_DEATHMASK}, - // For P_SuperReady - {"SUPERREADY_CLASSIC",SUPERREADY_CLASSIC}, - {"SUPERREADY_TRANSFORM",SUPERREADY_TRANSFORM}, - {"SUPERREADY_DETRANSFORM",SUPERREADY_DETRANSFORM}, - {"NUMSUPERREADY",NUMSUPERREADY}, // Intermission types {"int_none",int_none}, diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a5162837ef..ee5f934a75 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1712,14 +1712,12 @@ static int lib_pResetCamera(lua_State *L) static int lib_pSuperReady(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - superready_t type = luaL_optinteger(L, 2, SUPERREADY_CLASSIC); + boolean transform = (boolean)lua_opttrueboolean(L, 2); //HUDSAFE INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); - if (type < 0 || type >= NUMSUPERREADY) - return luaL_error(L, "superready type %d out of range (0 - %d)", type, NUMSUPERREADY-1); - lua_pushboolean(L, P_SuperReady(player, type)); + lua_pushboolean(L, P_SuperReady(player, transform)); return 1; } diff --git a/src/p_local.h b/src/p_local.h index da8956ae17..a4ec0262e9 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -113,14 +113,6 @@ typedef struct camera_s fixed_t momx, momy, momz; } camera_t; -typedef enum -{ - SUPERREADY_CLASSIC, // Two-button play mode, when Spin and Shield are bound to the same button (pressed on the same tic) - SUPERREADY_TRANSFORM, - SUPERREADY_DETRANSFORM, - NUMSUPERREADY -} superready_t; - extern camera_t camera, camera2; extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height; extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed, cv_cam_turnmultiplier, cv_cam_orbit, cv_cam_adjust; @@ -211,7 +203,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); void P_Earthquake(mobj_t *inflictor, mobj_t *source, fixed_t radius); boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user -boolean P_SuperReady(player_t *player, superready_t type); +boolean P_SuperReady(player_t *player, boolean transform); void P_DoJump(player_t *player, boolean soundandstate, boolean allowflip); void P_DoSpinDashDust(player_t *player); #define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG) diff --git a/src/p_user.c b/src/p_user.c index 30650b5bb7..ec8894e6e7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4431,47 +4431,18 @@ static void P_DoSuperStuff(player_t *player) // // Returns true if player is ready to transform or detransform // -boolean P_SuperReady(player_t *player, superready_t type) -{ - switch (type) // Transformation-type-specific checks - { - case SUPERREADY_CLASSIC: - // Pressed Spin and Shield on the same tic? Then you've probably bound them to the same button, - // so let's match the earlier Spin-only button behaviour to still support two-button play - if (!player->powers[pw_super] - && !player->powers[pw_invulnerability] - && !player->powers[pw_tailsfly] - && (player->charflags & SF_SUPER) - && (player->pflags & PF_JUMPED) - && !(player->powers[pw_shield] & SH_NOSTACK) - && !(maptol & TOL_NIGHTS) - && ALL7EMERALDS(emeralds) - && (player->rings >= 50)) - return true; - else - return false; - break; - - case SUPERREADY_TRANSFORM: - // Turning Super by pressing Shield? - if (player->powers[pw_super] - || !ALL7EMERALDS(emeralds) - || !(player->rings >= 50)) - return false; - break; - - case SUPERREADY_DETRANSFORM: - // Reverting from Super by pressing Shield? - if ((player->powers[pw_super] < TICRATE*3/2) // No spamming the transformation sound! - || !G_CoopGametype()) // No turning back in competitive! - return false; - break; - - default: // "type" is an enum, so having a case for every enum value pleases the compiler - break; - } +boolean P_SuperReady(player_t *player, boolean transform) +{ + if (!transform && + (player->powers[pw_super] < TICRATE*3/2 + || !G_CoopGametype())) // No turning back in competitive! + return false; + else if (transform + && (player->powers[pw_super] + || !ALL7EMERALDS(emeralds) + || !(player->rings >= 50))) + return false; - // These checks apply to both SUPERREADY_TRANSFORM and SUPERREADY_DETRANSFORM if (player->mo && !player->powers[pw_tailsfly] && !player->powers[pw_carry] @@ -5335,7 +5306,8 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd, boolean spinshieldhac ; else if (cmd->buttons & BT_SPIN) { - if (spinshieldhack && !(player->pflags & PF_SPINDOWN) && P_SuperReady(player, SUPERREADY_CLASSIC)) + if (spinshieldhack && !(player->pflags & PF_SPINDOWN) && P_SuperReady(player, true) + && !player->powers[pw_invulnerability] && !(player->powers[pw_shield] & SH_NOSTACK)) // These two checks are no longer in P_SuperReady { // If you're using two-button play, can turn Super and aren't already, // and you don't have a shield, then turn Super! @@ -8827,11 +8799,11 @@ void P_MovePlayer(player_t *player) if ((cmd->buttons & BT_SHIELD) && !(player->pflags & PF_SHIELDDOWN) && !spinshieldhack) { // Transform into super if we can! - if (P_SuperReady(player, SUPERREADY_TRANSFORM)) + if (P_SuperReady(player, true)) P_DoSuperTransformation(player, false); // Detransform from super if we can! - else if (P_SuperReady(player, SUPERREADY_DETRANSFORM)) + else if (P_SuperReady(player, false)) P_DoSuperDetransformation(player); } } -- GitLab