From 69aa74b9bf3b7ed9872c58144e368f92318acefa Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 20 May 2022 21:59:45 -0400 Subject: [PATCH 1/3] Allow pathfind traversal thru shortcuts when starting from one Fixes shortcut pathfinding behavior when the entire shortcut's waypoints have the flag instead of only the entrance. --- src/k_pathfind.c | 2 +- src/k_pathfind.h | 2 +- src/k_waypoint.c | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/k_pathfind.c b/src/k_pathfind.c index eb91dda2b..857f0343a 100644 --- a/src/k_pathfind.c +++ b/src/k_pathfind.c @@ -427,7 +427,7 @@ boolean K_PathfindAStar(path_t *const path, pathfindsetup_t *const pathfindsetup else { // skip this node if it isn't traversable - if (pathfindsetup->gettraversable(checknodedata) == false) + if (pathfindsetup->gettraversable(checknodedata, currentnode->nodedata) == false) { continue; } diff --git a/src/k_pathfind.h b/src/k_pathfind.h index ba0e38f47..7b7f1475f 100644 --- a/src/k_pathfind.h +++ b/src/k_pathfind.h @@ -27,7 +27,7 @@ typedef UINT32*(*getnodeconnectioncostsfunc)(void*); typedef UINT32(*getnodeheuristicfunc)(void*, void*); // function pointer for getting if a node is traversable from its base data -typedef boolean(*getnodetraversablefunc)(void*); +typedef boolean(*getnodetraversablefunc)(void*, void*); // A pathfindnode contains information about a node from the pathfinding diff --git a/src/k_waypoint.c b/src/k_waypoint.c index 903e66e2a..ec50a96be 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -975,10 +975,12 @@ static UINT32 K_WaypointPathfindGetHeuristic(void *data1, void *data2) Return:- True if the waypoint is traversable, false otherwise. --------------------------------------------------*/ -static boolean K_WaypointPathfindTraversableAllEnabled(void *data) +static boolean K_WaypointPathfindTraversableAllEnabled(void *data, void *prevdata) { boolean traversable = false; + (void)prevdata; + if (data == NULL) { CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableAllEnabled received NULL data.\n"); @@ -1004,18 +1006,21 @@ static boolean K_WaypointPathfindTraversableAllEnabled(void *data) Return:- True if the waypoint is traversable, false otherwise. --------------------------------------------------*/ -static boolean K_WaypointPathfindTraversableNoShortcuts(void *data) +static boolean K_WaypointPathfindTraversableNoShortcuts(void *data, void *prevdata) { boolean traversable = false; - if (data == NULL) + if (data == NULL || prevdata == NULL) { CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableNoShortcuts received NULL data.\n"); } else { waypoint_t *waypoint = (waypoint_t *)data; - traversable = ((K_GetWaypointIsShortcut(waypoint) == false) && (K_GetWaypointIsEnabled(waypoint) == true)); + waypoint_t *prevWaypoint = (waypoint_t *)prevdata; + + traversable = ((K_GetWaypointIsEnabled(waypoint) == true) + && (K_GetWaypointIsShortcut(waypoint) == false || K_GetWaypointIsShortcut(prevWaypoint) == true)); // Allow shortcuts to be used if the starting waypoint is already a shortcut. } return traversable; From a3592da4f107f09332cb5044290a793c8a6b99c7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 20 May 2022 22:32:23 -0400 Subject: [PATCH 2/3] More waypoint debug visualizations - Shortcut waypoints are pink now instead of blue. (barkley's ran into the issue of a shortcut waypoint on the main path too many times) - Waypoint debug uses a shaded blue sphere sprite instead of a thok sprite, because it makes the color easier to see on different backgrounds. - Use 1 splat for waypoint radius instead of shittons of orbs --- src/deh_tables.c | 2 ++ src/info.c | 3 +++ src/info.h | 3 +++ src/k_waypoint.c | 40 +++++++++++++++++++++------------------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index faa5010ad..6452e45d3 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4415,6 +4415,8 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_BATTLECAPSULE_SUPPORT", "S_BATTLECAPSULE_SUPPORTFLY", + "S_WAYPOINTORB", + "S_WAYPOINTSPLAT", "S_EGOORB", "S_WATERTRAIL1", diff --git a/src/info.c b/src/info.c index bd1d60b03..367bb673d 100644 --- a/src/info.c +++ b/src/info.c @@ -742,6 +742,7 @@ char sprnames[NUMSPRITES + 1][5] = "DBOS", // Drift boost flame + "WAYP", "EGOO", "WTRL", // Water Trail @@ -4996,6 +4997,8 @@ state_t states[NUMSTATES] = {SPR_CAPS, 4, -1, {NULL}, 0, 0, S_NULL}, // S_BATTLECAPSULE_SUPPORT {SPR_CAPS, FF_ANIMATE|5, -1, {NULL}, 3, 1, S_NULL}, // S_BATTLECAPSULE_SUPPORTFLY + {SPR_WAYP, 0, 1, {NULL}, 0, 0, S_NULL}, // S_WAYPOINTORB + {SPR_WAYP, 1|FF_FLOORSPRITE, 1, {NULL}, 0, 0, S_NULL}, // S_WAYPOINTSPLAT {SPR_EGOO, 0, 1, {NULL}, 0, 0, S_NULL}, // S_EGOORB // Water Trail diff --git a/src/info.h b/src/info.h index f8dbb90bd..8d8fe1228 100644 --- a/src/info.h +++ b/src/info.h @@ -1288,6 +1288,7 @@ typedef enum sprite SPR_DBOS, // Drift boost flame + SPR_WAYP, SPR_EGOO, SPR_WTRL, // Water Trail @@ -5420,6 +5421,8 @@ typedef enum state S_BATTLECAPSULE_SUPPORT, S_BATTLECAPSULE_SUPPORTFLY, + S_WAYPOINTORB, + S_WAYPOINTSPLAT, S_EGOORB, S_WATERTRAIL1, diff --git a/src/k_waypoint.c b/src/k_waypoint.c index ec50a96be..62652ee01 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -558,11 +558,9 @@ static void K_DebugWaypointsSpawnLine(waypoint_t *const waypoint1, waypoint_t *c --------------------------------------------------*/ static void K_DebugWaypointDrawRadius(waypoint_t *const waypoint) { + const fixed_t spriteRadius = 96*FRACUNIT; mobj_t *radiusOrb; mobj_t *waypointmobj; - const INT32 numRadiusMobjs = 64; - INT32 i = 0; - angle_t spawnAngle = 0U; fixed_t spawnX= 0; fixed_t spawnY= 0; fixed_t spawnZ= 0; @@ -572,22 +570,21 @@ static void K_DebugWaypointDrawRadius(waypoint_t *const waypoint) waypointmobj = waypoint->mobj; - for (i = 0; i < numRadiusMobjs; i++) - { - spawnAngle = (ANGLE_MAX / numRadiusMobjs) * i; + spawnX = waypointmobj->x; + spawnY = waypointmobj->y; + spawnZ = waypointmobj->z + 16*mapobjectscale; - spawnZ = waypointmobj->z; - spawnX = waypointmobj->x + P_ReturnThrustX(waypointmobj, spawnAngle, waypointmobj->radius); - spawnY = waypointmobj->y + P_ReturnThrustY(waypointmobj, spawnAngle, waypointmobj->radius); + radiusOrb = P_SpawnMobj(spawnX, spawnY, spawnZ, MT_SPARK); - radiusOrb = P_SpawnMobj(spawnX, spawnY, spawnZ, MT_SPARK); - P_SetMobjState(radiusOrb, S_THOK); - radiusOrb->tics = 1; - radiusOrb->frame &= ~FF_TRANSMASK; - radiusOrb->frame |= FF_FULLBRIGHT; - radiusOrb->color = SKINCOLOR_PURPLE; - radiusOrb->scale = radiusOrb->scale / 4; - } + P_SetMobjState(radiusOrb, S_WAYPOINTSPLAT); + radiusOrb->tics = 1; + + radiusOrb->frame &= ~FF_TRANSMASK; + radiusOrb->frame |= FF_FULLBRIGHT; + radiusOrb->color = SKINCOLOR_PURPLE; + + radiusOrb->destscale = FixedDiv(waypointmobj->radius, spriteRadius); + P_SetScale(radiusOrb, radiusOrb->destscale); } /*-------------------------------------------------- @@ -620,10 +617,10 @@ void K_DebugWaypointsVisualise(void) waypoint = K_SearchWaypointHeapForMobj(waypointmobj); debugmobj = P_SpawnMobj(waypointmobj->x, waypointmobj->y, waypointmobj->z, MT_SPARK); - P_SetMobjState(debugmobj, S_THOK); + P_SetMobjState(debugmobj, S_WAYPOINTORB); debugmobj->frame &= ~FF_TRANSMASK; - debugmobj->frame |= FF_TRANS20|FF_FULLBRIGHT; + debugmobj->frame |= FF_FULLBRIGHT; //FF_TRANS20 // There's a waypoint setup for this mobj! So draw that it's a valid waypoint and draw lines to its connections if (waypoint != NULL) @@ -648,6 +645,11 @@ void K_DebugWaypointsVisualise(void) else { debugmobj->color = SKINCOLOR_BLUE; + + if (K_GetWaypointIsShortcut(waypoint)) + { + debugmobj->color = SKINCOLOR_PINK; + } } if (!K_GetWaypointIsEnabled(waypoint)) From e02ebfa20d3792d551e75e5269cebec76f44b4c9 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 20 May 2022 22:41:52 -0400 Subject: [PATCH 3/3] No respawn waypoints are transparent --- src/k_waypoint.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/k_waypoint.c b/src/k_waypoint.c index 62652ee01..06d0a1a84 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -657,6 +657,11 @@ void K_DebugWaypointsVisualise(void) debugmobj->color = SKINCOLOR_GREY; } + if (!K_GetWaypointIsSpawnpoint(waypoint)) + { + debugmobj->frame |= FF_TRANS40; + } + // Valid waypoint, so draw lines of SPARKLES to its next or previous waypoints if (cv_kartdebugwaypoints.value == 1) {