From 8d06145377238a789fe5ee7b0a2cc2d781345147 Mon Sep 17 00:00:00 2001 From: spherallic Date: Fri, 9 Sep 2022 15:35:05 +0200 Subject: [PATCH] Play gravity flip sound on jump in jumpflip sectors, reorganize code --- src/lua_baselib.c | 24 ++++++++++++------------ src/p_local.h | 2 +- src/p_setup.c | 2 +- src/p_user.c | 7 +++++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 96500ad68..d56749d5c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1290,17 +1290,6 @@ static int lib_pInSpaceSector(lua_State *L) return 1; } -static int lib_pInJumpFlipSector(lua_State *L) -{ - mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - //HUDSAFE - INLEVEL - if (!mo) - return LUA_ErrInvalid(L, "mobj_t"); - lua_pushboolean(L, P_InJumpFlipSector(mo)); - return 1; -} - static int lib_pInQuicksand(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -1312,6 +1301,17 @@ static int lib_pInQuicksand(lua_State *L) return 1; } +static int lib_pInJumpFlipSector(lua_State *L) +{ + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + //HUDSAFE + INLEVEL + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_InJumpFlipSector(mo)); + return 1; +} + static int lib_pSetObjectMomZ(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -4019,8 +4019,8 @@ static luaL_Reg lib[] = { {"P_IsObjectInGoop",lib_pIsObjectInGoop}, {"P_IsObjectOnGround",lib_pIsObjectOnGround}, {"P_InSpaceSector",lib_pInSpaceSector}, - {"P_InJumpFlipSector",lib_pInJumpFlipSector}, {"P_InQuicksand",lib_pInQuicksand}, + {"P_InJumpFlipSector",lib_pInJumpFlipSector}, {"P_SetObjectMomZ",lib_pSetObjectMomZ}, {"P_PlayJingle",lib_pPlayJingle}, {"P_PlayJingleMusic",lib_pPlayJingleMusic}, diff --git a/src/p_local.h b/src/p_local.h index b4763a7e2..dabde0281 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -149,8 +149,8 @@ boolean P_PlayerShouldUseSpinHeight(player_t *player); boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo); boolean P_InSpaceSector(mobj_t *mo); -boolean P_InJumpFlipSector(mobj_t *mo); boolean P_InQuicksand(mobj_t *mo); +boolean P_InJumpFlipSector(mobj_t *mo); boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff); void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative); diff --git a/src/p_setup.c b/src/p_setup.c index e8b5e0f21..b58df7c67 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -5940,7 +5940,7 @@ static void P_ConvertBinarySectorTypes(void) case 5: //Speed pad sectors[i].specialflags |= SSF_SPEEDPAD; break; - case 6: //Gravity flip on jump + case 6: //Gravity flip on jump (think VVVVVV) sectors[i].specialflags |= SSF_JUMPFLIP; break; default: diff --git a/src/p_user.c b/src/p_user.c index a82704ad9..ddbf48206 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2516,7 +2516,7 @@ boolean P_InJumpFlipSector(mobj_t *mo) // Returns true if you are in a jumpflip } } - return false; // No jumpflip here, Captain! + return false; // No gravity jumping here, Captain Viridian! } static boolean P_PlayerCanBust(player_t *player, ffloor_t *rover) @@ -4484,8 +4484,11 @@ void P_DoJump(player_t *player, boolean soundandstate) if (player->charflags & SF_NOJUMPDAMAGE) player->pflags &= ~PF_SPINNING; - if (P_InJumpFlipSector(player->mo)) + if (P_InJumpFlipSector(player->mo)) // Flip gravity on jump? + { player->mo->flags2 ^= MF2_OBJECTFLIP; + S_StartSound(player->mo, sfx_s3k73); // Play gravity flip sound + } if (soundandstate) {