diff --git a/src/k_kart.c b/src/k_kart.c index 129a8f555..eca635005 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3420,7 +3420,7 @@ boolean K_TripwirePass(player_t *player) boolean K_MovingHorizontally(mobj_t *mobj) { - return (P_AproxDistance(mobj->momx, mobj->momy) / 5 > abs(mobj->momz)); + return (P_AproxDistance(mobj->momx, mobj->momy) / 4 > abs(mobj->momz)); } boolean K_WaterRun(mobj_t *mobj) diff --git a/src/p_map.c b/src/p_map.c index e235cb9a4..677954b43 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2618,7 +2618,7 @@ increment_move if (!(thing->flags & MF_NOCLIP)) { //All things are affected by their scale. - fixed_t maxstep = P_GetThingStepUp(thing, x, y); + fixed_t maxstep = P_GetThingStepUp(thing, tryx, tryy); if (tmceilingz - tmfloorz < thing->height) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 794e3a0be..d5924de51 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3126,16 +3126,14 @@ boolean P_CanRunOnWater(mobj_t *mobj, ffloor_t *rover) fixed_t surfaceheight = INT32_MAX; fixed_t surfDiff = INT32_MAX; - fixed_t floorheight = INT32_MAX; - fixed_t floorDiff = INT32_MAX; - fixed_t mobjbottom = INT32_MAX; fixed_t maxStep = INT32_MAX; boolean doifit = false; pslope_t *waterSlope = NULL; - angle_t ourZAng = 0; - angle_t waterZAng = 0; + angle_t moveDir = 0; + fixed_t ourZAng = 0; + fixed_t waterZAng = 0; if (rover == NULL) { @@ -3169,20 +3167,36 @@ boolean P_CanRunOnWater(mobj_t *mobj, ffloor_t *rover) return false; } - if (mobj->standingslope != NULL) + moveDir = K_MomentumAngle(mobj); + + if (mobj->standingslope != NULL && mobj->standingslope->zangle != 0) { - ourZAng = mobj->standingslope->zangle; + angle_t dir = mobj->standingslope->xydirection; + angle_t workang = mobj->standingslope->zangle; + if (workang >= ANGLE_180) + { + workang = InvAngle(workang); + dir = InvAngle(dir); + } + ourZAng = P_ReturnThrustX(mobj, dir - moveDir, AngleFixed(workang)); } waterSlope = (flip ? *rover->b_slope : *rover->t_slope); - if (waterSlope != NULL) + if (waterSlope != NULL && waterSlope->zangle != 0) { - waterZAng = waterSlope->zangle; + angle_t dir = waterSlope->xydirection; + angle_t workang = waterSlope->zangle; + if (workang >= ANGLE_180) + { + workang = InvAngle(workang); + dir = InvAngle(dir); + } + waterZAng = P_ReturnThrustX(mobj, dir - moveDir, AngleFixed(workang)); } - if (ourZAng != waterZAng) + if (abs(ourZAng - waterZAng) > 11*FRACUNIT) { - // The surface slopes are different. + // The surface slopes are too different. return false; } @@ -3200,16 +3214,20 @@ boolean P_CanRunOnWater(mobj_t *mobj, ffloor_t *rover) maxStep = P_GetThingStepUp(mobj, mobj->x, mobj->y); surfDiff = flip ? (surfaceheight - mobjbottom) : (mobjbottom - surfaceheight); + + // We start water run IF we can step onto it! if (surfDiff <= maxStep && surfDiff >= 0) { - // We start water run IF we can step-down! - floorheight = flip ? P_GetSectorCeilingZAt(mobj->subsector->sector, mobj->x, mobj->y) : P_GetSectorFloorZAt(mobj->subsector->sector, mobj->x, mobj->y); - floorDiff = flip ? (floorheight - mobjbottom) : (mobjbottom - floorheight); - if (floorDiff <= maxStep && floorDiff >= 0) + if (ourZAng < 0) { - // ... but NOT if real floor is in range. - // FIXME: Count solid FOFs in this check - return false; + fixed_t floorheight = flip ? P_GetSectorCeilingZAt(mobj->subsector->sector, mobj->x, mobj->y) : P_GetSectorFloorZAt(mobj->subsector->sector, mobj->x, mobj->y); + fixed_t floorDiff = flip ? (floorheight - mobjbottom) : (mobjbottom - floorheight); + if (floorDiff <= maxStep && floorDiff >= -maxStep) + { + // ... but NOT if going down and real floor is in range. + // FIXME: Count solid FOFs in this check + return false; + } } return true;