Merge branch 'waterstep' into 'master'

Waterstep fixes (resolves #319)

Closes #319

See merge request KartKrew/Kart!771
This commit is contained in:
Oni 2022-11-19 00:54:46 +00:00
commit c331958ef4
3 changed files with 38 additions and 20 deletions

View file

@ -3420,7 +3420,7 @@ boolean K_TripwirePass(player_t *player)
boolean K_MovingHorizontally(mobj_t *mobj) 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) boolean K_WaterRun(mobj_t *mobj)

View file

@ -2618,7 +2618,7 @@ increment_move
if (!(thing->flags & MF_NOCLIP)) if (!(thing->flags & MF_NOCLIP))
{ {
//All things are affected by their scale. //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) if (tmceilingz - tmfloorz < thing->height)
{ {

View file

@ -3126,16 +3126,14 @@ boolean P_CanRunOnWater(mobj_t *mobj, ffloor_t *rover)
fixed_t surfaceheight = INT32_MAX; fixed_t surfaceheight = INT32_MAX;
fixed_t surfDiff = INT32_MAX; fixed_t surfDiff = INT32_MAX;
fixed_t floorheight = INT32_MAX;
fixed_t floorDiff = INT32_MAX;
fixed_t mobjbottom = INT32_MAX; fixed_t mobjbottom = INT32_MAX;
fixed_t maxStep = INT32_MAX; fixed_t maxStep = INT32_MAX;
boolean doifit = false; boolean doifit = false;
pslope_t *waterSlope = NULL; pslope_t *waterSlope = NULL;
angle_t ourZAng = 0; angle_t moveDir = 0;
angle_t waterZAng = 0; fixed_t ourZAng = 0;
fixed_t waterZAng = 0;
if (rover == NULL) if (rover == NULL)
{ {
@ -3169,20 +3167,36 @@ boolean P_CanRunOnWater(mobj_t *mobj, ffloor_t *rover)
return false; 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); 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; return false;
} }
@ -3200,16 +3214,20 @@ boolean P_CanRunOnWater(mobj_t *mobj, ffloor_t *rover)
maxStep = P_GetThingStepUp(mobj, mobj->x, mobj->y); maxStep = P_GetThingStepUp(mobj, mobj->x, mobj->y);
surfDiff = flip ? (surfaceheight - mobjbottom) : (mobjbottom - surfaceheight); surfDiff = flip ? (surfaceheight - mobjbottom) : (mobjbottom - surfaceheight);
// We start water run IF we can step onto it!
if (surfDiff <= maxStep && surfDiff >= 0) if (surfDiff <= maxStep && surfDiff >= 0)
{ {
// We start water run IF we can step-down! if (ourZAng < 0)
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)
{ {
// ... but NOT if real floor is in range. fixed_t floorheight = flip ? P_GetSectorCeilingZAt(mobj->subsector->sector, mobj->x, mobj->y) : P_GetSectorFloorZAt(mobj->subsector->sector, mobj->x, mobj->y);
// FIXME: Count solid FOFs in this check fixed_t floorDiff = flip ? (floorheight - mobjbottom) : (mobjbottom - floorheight);
return false; 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; return true;