Ignore z height for connected waypoints on jumps

Resolves #780
This commit is contained in:
Sally Coolatta 2023-12-19 11:24:21 -05:00
parent 1911a45e3f
commit 2689012249

View file

@ -409,7 +409,49 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj, waypoint_t *const hint)
checkdist = P_AproxDistance(
(mobj->x / FRACUNIT) - (checkwaypoint->mobj->x / FRACUNIT),
(mobj->y / FRACUNIT) - (checkwaypoint->mobj->y / FRACUNIT));
checkdist = P_AproxDistance(checkdist, ((mobj->z / FRACUNIT) - (checkwaypoint->mobj->z / FRACUNIT)) * 4);
UINT8 zMultiplier = 4; // Heavily weight z distance, for the sake of overlapping paths
if (hint != NULL)
{
boolean connectedToHint = (checkwaypoint == hint);
if (connectedToHint == false && hint->numnextwaypoints > 0)
{
for (size_t i = 0U; i < hint->numnextwaypoints; i++)
{
if (hint->nextwaypoints[i] == checkwaypoint)
{
connectedToHint = true;
break;
}
}
}
if (connectedToHint == false && hint->numprevwaypoints > 0)
{
for (size_t i = 0U; i < hint->numprevwaypoints; i++)
{
if (hint->prevwaypoints[i] == checkwaypoint)
{
connectedToHint = true;
break;
}
}
}
// Do not consider z height for next/prev waypoints of current waypoint.
// This helps the current waypoint not be behind you when you're taking a jump.
if (connectedToHint == true)
{
zMultiplier = 0;
}
}
if (zMultiplier > 0)
{
checkdist = P_AproxDistance(checkdist, ((mobj->z / FRACUNIT) - (checkwaypoint->mobj->z / FRACUNIT)) * zMultiplier);
}
fixed_t rad = (checkwaypoint->mobj->radius / FRACUNIT);