mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-04 16:02:48 +00:00
SPB circles in place if it goes past on accident
This commit is contained in:
parent
4952a2d2ae
commit
8b160a996b
1 changed files with 30 additions and 6 deletions
|
|
@ -311,6 +311,8 @@ static void SPBSeek(mobj_t *spb, player_t *bestPlayer)
|
||||||
fixed_t steerDist = INT32_MAX;
|
fixed_t steerDist = INT32_MAX;
|
||||||
mobj_t *steerMobj = NULL;
|
mobj_t *steerMobj = NULL;
|
||||||
|
|
||||||
|
boolean circling = false;
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
spb_lastplayer(spb) = -1; // Just make sure this is reset
|
spb_lastplayer(spb) = -1; // Just make sure this is reset
|
||||||
|
|
@ -417,9 +419,8 @@ static void SPBSeek(mobj_t *spb, player_t *bestPlayer)
|
||||||
if (destWaypoint != NULL)
|
if (destWaypoint != NULL)
|
||||||
{
|
{
|
||||||
// Go to next waypoint.
|
// Go to next waypoint.
|
||||||
const boolean huntbackwards = false;
|
|
||||||
const boolean useshortcuts = K_GetWaypointIsShortcut(destWaypoint); // If the player is on a shortcut, use shortcuts. No escape.
|
const boolean useshortcuts = K_GetWaypointIsShortcut(destWaypoint); // If the player is on a shortcut, use shortcuts. No escape.
|
||||||
|
boolean huntbackwards = false;
|
||||||
path_t pathtoplayer = {0};
|
path_t pathtoplayer = {0};
|
||||||
|
|
||||||
pathfindsuccess = K_PathfindToWaypoint(
|
pathfindsuccess = K_PathfindToWaypoint(
|
||||||
|
|
@ -430,9 +431,27 @@ static void SPBSeek(mobj_t *spb, player_t *bestPlayer)
|
||||||
|
|
||||||
if (pathfindsuccess == true)
|
if (pathfindsuccess == true)
|
||||||
{
|
{
|
||||||
if (pathtoplayer.numnodes > 1)
|
path_t reversepath = {0};
|
||||||
|
boolean reversesuccess = false;
|
||||||
|
|
||||||
|
huntbackwards = true;
|
||||||
|
reversesuccess = K_PathfindToWaypoint(
|
||||||
|
curWaypoint, destWaypoint,
|
||||||
|
&reversepath,
|
||||||
|
useshortcuts, huntbackwards
|
||||||
|
);
|
||||||
|
|
||||||
|
if (reversesuccess == true
|
||||||
|
&& reversepath.totaldist < pathtoplayer.totaldist)
|
||||||
{
|
{
|
||||||
// Go to next.
|
// It's faster to go backwards than to chase forward.
|
||||||
|
// Keep curWaypoint the same, so the SPB waits around for them.
|
||||||
|
circling = true;
|
||||||
|
Z_Free(reversepath.array);
|
||||||
|
}
|
||||||
|
else if (pathtoplayer.numnodes > 1)
|
||||||
|
{
|
||||||
|
// Go to the next waypoint.
|
||||||
curWaypoint = (waypoint_t *)pathtoplayer.array[1].nodedata;
|
curWaypoint = (waypoint_t *)pathtoplayer.array[1].nodedata;
|
||||||
}
|
}
|
||||||
else if (spb->fuse > 0 && destWaypoint->numnextwaypoints > 0)
|
else if (spb->fuse > 0 && destWaypoint->numnextwaypoints > 0)
|
||||||
|
|
@ -443,6 +462,7 @@ static void SPBSeek(mobj_t *spb, player_t *bestPlayer)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Sort of wait at the player's dest waypoint.
|
// Sort of wait at the player's dest waypoint.
|
||||||
|
circling = true;
|
||||||
curWaypoint = destWaypoint;
|
curWaypoint = destWaypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -539,8 +559,12 @@ static void SPBSeek(mobj_t *spb, player_t *bestPlayer)
|
||||||
// Always spawn speed lines while seeking
|
// Always spawn speed lines while seeking
|
||||||
SpawnSPBSpeedLines(spb);
|
SpawnSPBSpeedLines(spb);
|
||||||
|
|
||||||
// Spawn a trail of rings behind the SPB!
|
// Don't run this while we're circling around one waypoint intentionally.
|
||||||
SPBMantaRings(spb);
|
if (circling == false)
|
||||||
|
{
|
||||||
|
// Spawn a trail of rings behind the SPB!
|
||||||
|
SPBMantaRings(spb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SPBChase(mobj_t *spb, player_t *bestPlayer)
|
static void SPBChase(mobj_t *spb, player_t *bestPlayer)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue