From ecf950e7498ee179155c7cdb3e08331b41c4874e Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:54:51 -0500 Subject: [PATCH] Add "allowflip" Parameter to P_DoJump --- src/lua_baselib.c | 3 ++- src/p_local.h | 2 +- src/p_user.c | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8cb6d185d..8485376b5 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1659,11 +1659,12 @@ static int lib_pDoJump(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); boolean soundandstate = (boolean)lua_opttrueboolean(L, 2); + boolean allowflip = (boolean)lua_opttrueboolean(L, 3); NOHUD INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); - P_DoJump(player, soundandstate); + P_DoJump(player, soundandstate, allowflip); return 0; } diff --git a/src/p_local.h b/src/p_local.h index 4b330184b..a1804d302 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -203,7 +203,7 @@ 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); -void P_DoJump(player_t *player, boolean soundandstate); +void P_DoJump(player_t *player, boolean soundandstate, boolean allowflip); #define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG) boolean P_TransferToNextMare(player_t *player); UINT8 P_FindLowestMare(void); diff --git a/src/p_user.c b/src/p_user.c index 24e3f8111..850d0b448 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4415,7 +4415,7 @@ boolean P_SuperReady(player_t *player) // // Jump routine for the player // -void P_DoJump(player_t *player, boolean soundandstate) +void P_DoJump(player_t *player, boolean soundandstate, boolean allowflip) { fixed_t factor; const fixed_t dist6 = FixedMul(FixedDiv(player->speed, player->mo->scale), player->actionspd)/20; @@ -4588,7 +4588,7 @@ void P_DoJump(player_t *player, boolean soundandstate) if (player->charflags & SF_NOJUMPDAMAGE) player->pflags &= ~PF_SPINNING; - if (P_InJumpFlipSector(player->mo)) // Flip gravity on jump? + if (allowflip && P_InJumpFlipSector(player->mo)) // Flip gravity on jump? { player->mo->flags2 ^= MF2_OBJECTFLIP; S_StartSound(player->mo, sfx_s3k73); // Play gravity flip sound @@ -4806,7 +4806,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) #if 0 if ((player->charability == CA_TWINSPIN) && (player->speed > FixedMul(player->runspeed, player->mo->scale))) { - P_DoJump(player, false); + P_DoJump(player, false, false); player->pflags &= ~PF_STARTJUMP; player->mo->momz = FixedMul(player->mo->momz, 3*FRACUNIT/2); // NOT 1.5 times the jump height, but 2.25 times. P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN); @@ -4886,7 +4886,7 @@ void P_DoJumpShield(player_t *player) return; player->pflags &= ~PF_JUMPED; - P_DoJump(player, false); + P_DoJump(player, false, true); player->secondjump = 0; player->pflags |= PF_THOKKED|PF_SHIELDABILITY; player->pflags &= ~(PF_STARTJUMP|PF_SPINNING|PF_BOUNCING); @@ -4929,7 +4929,7 @@ void P_DoBubbleBounce(player_t *player) player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SHIELDABILITY); S_StartSound(player->mo, sfx_s3k44); P_MobjCheckWater(player->mo); - P_DoJump(player, false); + P_DoJump(player, false, false); if (player->charflags & SF_NOJUMPSPIN) P_SetPlayerMobjState(player->mo, S_PLAY_FALL); else @@ -4959,7 +4959,7 @@ void P_DoAbilityBounce(player_t *player, boolean changemomz) else if (player->mo->eflags & MFE_UNDERWATER) prevmomz /= 2; - P_DoJump(player, false); + P_DoJump(player, false, false); player->pflags &= ~(PF_STARTJUMP|PF_JUMPED); minmomz = FixedMul(player->mo->momz, 3*FRACUNIT/2); @@ -5332,7 +5332,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) // Jump S3&K style while in quicksand. else if (P_InQuicksand(player->mo)) { - P_DoJump(player, true); + P_DoJump(player, true, false); player->secondjump = 0; player->pflags &= ~PF_THOKKED; } @@ -5345,7 +5345,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) // can't jump while in air, can't jump while jumping else if (onground || player->climbing || player->powers[pw_carry]) { - P_DoJump(player, true); + P_DoJump(player, true, true); player->secondjump = 0; player->pflags &= ~PF_THOKKED; } @@ -5381,7 +5381,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) if ((player->charability == CA_JUMPTHOK) && !(player->pflags & PF_THOKKED)) { player->pflags &= ~PF_JUMPED; - P_DoJump(player, false); + P_DoJump(player, false, true); } P_InstaThrust(player->mo, player->mo->angle, FixedMul(actionspd, player->mo->scale)); @@ -5490,7 +5490,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { player->pflags |= PF_THOKKED; player->pflags &= ~(PF_JUMPED|PF_SPINNING); - P_DoJump(player, true); + P_DoJump(player, true, true); player->secondjump++; } break;