diff --git a/src/p_map.c b/src/p_map.c index 6f3b9f9fe..2c21a7718 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2601,7 +2601,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) return false; // mobj must lower itself to fit } } - else if (!(P_MobjTouchingSectorSpecial(thing, 1, 14, false))) // Step down + else if (thing->momz * P_MobjFlip(thing) <= 0 // Step down requires moving down. + && !(P_MobjTouchingSectorSpecial(thing, 1, 14, false))) { // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. diff --git a/src/p_mobj.c b/src/p_mobj.c index 621da9d9f..b12430889 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1800,8 +1800,7 @@ void P_XYMovement(mobj_t *mo) */ } - else if (predictedz - mo->z > abs(slopemom.z/2) - && P_CanApplySlopePhysics(mo, mo->standingslope) == true) // Sryder 2018-11-26: Don't launch here if it's a slope without physics, we stick to those like glue anyway + else if (predictedz - mo->z > abs(slopemom.z / 2)) { // Now check if we were supposed to stick to this slope //CONS_Printf("%d-%d > %d\n", (predictedz), (mo->z), (slopemom.z/2)); diff --git a/src/p_slopes.c b/src/p_slopes.c index 6c749506b..1347a8759 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -928,6 +928,27 @@ boolean P_CanApplySlopePhysics(mobj_t *mo, pslope_t *slope) return true; } +// Returns true if we should run slope launch code on an object. +boolean P_CanApplySlopeLaunch(mobj_t *mo, pslope_t *slope) +{ + if (slope == NULL || mo == NULL || P_MobjWasRemoved(mo) == true) + { + // Invalid input. + return false; + } + + // No physics slopes are fine to launch off of. + + if (slope->normal.x == 0 && slope->normal.y == 0) + { + // Flat slope? No such thing, man. No such thing. + return false; + } + + // We can do slope launching. + return true; +} + // // P_QuantizeMomentumToSlope // @@ -963,11 +984,8 @@ void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // Handles slope ejection for objects void P_SlopeLaunch(mobj_t *mo) { - if (P_CanApplySlopePhysics(mo, mo->standingslope) == true) // If there's physics, time for launching. + if (P_CanApplySlopeLaunch(mo, mo->standingslope) == true) // If there's physics, time for launching. { - // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the - // vertical launch given from slopes while increasing the horizontal launch - // given. Good for SRB2's gravity and horizontal speeds. vector3_t slopemom; slopemom.x = mo->momx; slopemom.y = mo->momy; @@ -1002,7 +1020,7 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope) vector3_t slopemom, axis; angle_t ang; - if (P_CanApplySlopePhysics(mo, mo->standingslope) == false) + if (P_CanApplySlopeLaunch(mo, mo->standingslope) == false) { return false; } diff --git a/src/p_slopes.h b/src/p_slopes.h index 6f9764fa9..5eb4f83bb 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -83,6 +83,7 @@ fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y); // Lots of physics-based bullshit boolean P_CanApplySlopePhysics(mobj_t *mo, pslope_t *slope); +boolean P_CanApplySlopeLaunch(mobj_t *mo, pslope_t *slope); void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_SlopeLaunch(mobj_t *mo);