mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
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:
parent
6afa7dfc4b
commit
abb5cf71b8
3 changed files with 47 additions and 10 deletions
12
src/k_kart.c
12
src/k_kart.c
|
|
@ -7929,6 +7929,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
|
||||||
|
|
||||||
if (angledelta < nextbestdelta || momdelta < nextbestmomdelta)
|
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];
|
bestwaypoint = waypoint->nextwaypoints[i];
|
||||||
|
|
||||||
if (angledelta < nextbestdelta)
|
if (angledelta < nextbestdelta)
|
||||||
|
|
@ -7975,6 +7981,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
|
||||||
|
|
||||||
if (angledelta < nextbestdelta && momdelta < nextbestmomdelta)
|
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];
|
bestwaypoint = waypoint->prevwaypoints[i];
|
||||||
|
|
||||||
nextbestdelta = angledelta;
|
nextbestdelta = angledelta;
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,12 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj)
|
||||||
// remember: huge radius
|
// remember: huge radius
|
||||||
if (closestdist <= rad && checkdist <= rad && finishline != NULL)
|
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,
|
// If the mobj is touching multiple waypoints at once,
|
||||||
// then solve ties by taking the one closest to the finish line.
|
// then solve ties by taking the one closest to the finish line.
|
||||||
// Prevents position from flickering wildly when taking turns.
|
// 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))
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -578,6 +578,15 @@ static boolean P_CrossBlockingSubsector(size_t num, register traceblocking_t *tb
|
||||||
// This line will always block us
|
// This line will always block us
|
||||||
return false;
|
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
|
// passed the subsector ok
|
||||||
|
|
@ -728,6 +737,15 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
|
||||||
return false;
|
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
|
// set openrange, opentop, openbottom
|
||||||
tmx = tb->compareThing->x;
|
tmx = tb->compareThing->x;
|
||||||
tmy = tb->compareThing->y;
|
tmy = tb->compareThing->y;
|
||||||
|
|
@ -742,10 +760,13 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Treat damage sectors like walls
|
|
||||||
if (tb->compareThing->player != NULL)
|
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)
|
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);
|
P_ClosestPointOnLine(tb->compareThing->x, tb->compareThing->y, line, &pos);
|
||||||
lineside = P_PointOnLineSide(tb->compareThing->x, tb->compareThing->y, line);
|
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.
|
// This line does not block us, but we don't want to be in it.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false)
|
|
||||||
{
|
|
||||||
// Can't go through trip wire.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue