Waypoint sight improvements

- Reorganized bot traversal
- Blocking line traversal includes tripwire
- Next waypoint detection uses blocking line trace now (this means bots can't sit outside of a tripwire wanting to go through it)
This commit is contained in:
Sally Coolatta 2022-05-24 17:30:42 -04:00
parent 6afa7dfc4b
commit abb5cf71b8
3 changed files with 47 additions and 10 deletions

View file

@ -7929,6 +7929,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
if (angledelta < nextbestdelta || momdelta < nextbestmomdelta)
{
if (P_TraceBlockingLines(player->mo, waypoint->nextwaypoints[i]->mobj) == false)
{
// Save sight checks when all of the other checks pass, so we only do it if we have to
continue;
}
bestwaypoint = waypoint->nextwaypoints[i];
if (angledelta < nextbestdelta)
@ -7975,6 +7981,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
if (angledelta < nextbestdelta && momdelta < nextbestmomdelta)
{
if (P_TraceBlockingLines(player->mo, waypoint->prevwaypoints[i]->mobj) == false)
{
// Save sight checks when all of the other checks pass, so we only do it if we have to
continue;
}
bestwaypoint = waypoint->prevwaypoints[i];
nextbestdelta = angledelta;

View file

@ -361,6 +361,12 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj)
// remember: huge radius
if (closestdist <= rad && checkdist <= rad && finishline != NULL)
{
if (!P_TraceBlockingLines(mobj, checkwaypoint->mobj))
{
// Save sight checks when all of the other checks pass, so we only do it if we have to
continue;
}
// If the mobj is touching multiple waypoints at once,
// then solve ties by taking the one closest to the finish line.
// Prevents position from flickering wildly when taking turns.
@ -375,7 +381,7 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj)
{
if (!P_TraceBlockingLines(mobj, checkwaypoint->mobj))
{
// Save sight checks for the end, so we only do it if we have to
// Save sight checks when all of the other checks pass, so we only do it if we have to
continue;
}

View file

@ -578,6 +578,15 @@ static boolean P_CrossBlockingSubsector(size_t num, register traceblocking_t *tb
// This line will always block us
return false;
}
if (tb->compareThing->player != NULL)
{
if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false)
{
// Can't go through trip wire.
return false;
}
}
}
// passed the subsector ok
@ -728,6 +737,15 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
return false;
}
if (tb->compareThing->player != NULL)
{
if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false)
{
// Can't go through trip wire.
return false;
}
}
// set openrange, opentop, openbottom
tmx = tb->compareThing->x;
tmy = tb->compareThing->y;
@ -742,10 +760,13 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
return false;
}
// Treat damage sectors like walls
if (tb->compareThing->player != NULL)
{
boolean alreadyHates = K_BotHatesThisSector(tb->compareThing->player, tb->compareThing->subsector->sector, tb->compareThing->x, tb->compareThing->y);
// Treat damage sectors like walls
boolean alreadyHates = K_BotHatesThisSector(
tb->compareThing->player, tb->compareThing->subsector->sector,
tb->compareThing->x, tb->compareThing->y
);
if (alreadyHates == false)
{
@ -755,18 +776,16 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
P_ClosestPointOnLine(tb->compareThing->x, tb->compareThing->y, line, &pos);
lineside = P_PointOnLineSide(tb->compareThing->x, tb->compareThing->y, line);
if (K_BotHatesThisSector(tb->compareThing->player, ((lineside == 1) ? line->frontsector : line->backsector), pos.x, pos.y))
if (K_BotHatesThisSector(
tb->compareThing->player,
((lineside == 1) ? line->frontsector : line->backsector),
pos.x, pos.y
))
{
// This line does not block us, but we don't want to be in it.
return false;
}
}
if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false)
{
// Can't go through trip wire.
return false;
}
}
}