mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Improve the new wall detection further
They didn't fall off on Hardhat, I'm so proud of my sons
This commit is contained in:
parent
19463d6b20
commit
08bfd6e881
3 changed files with 23 additions and 33 deletions
34
src/k_bot.c
34
src/k_bot.c
|
|
@ -576,9 +576,9 @@ static botprediction_t *K_CreateBotPrediction(player_t *player)
|
|||
const INT16 normal = KART_FULLTURN; // "Standard" handling to compare to
|
||||
|
||||
const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict
|
||||
const fixed_t speed = P_AproxDistance(player->rmomx, player->rmomy);
|
||||
const fixed_t speed = P_AproxDistance(player->mo->momx, player->mo->momy);
|
||||
|
||||
const INT32 startDist = (1536 * mapobjectscale) / FRACUNIT;
|
||||
const INT32 startDist = (768 * mapobjectscale) / FRACUNIT;
|
||||
const INT32 distance = ((speed / FRACUNIT) * futuresight) + startDist;
|
||||
|
||||
botprediction_t *predict = Z_Calloc(sizeof(botprediction_t), PU_STATIC, NULL);
|
||||
|
|
@ -653,11 +653,6 @@ static botprediction_t *K_CreateBotPrediction(player_t *player)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[i]->mobj) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Unlike the other parts of this function, we're comparing the player's physical position, NOT the position of the waypoint!!
|
||||
// This should roughly correspond with how players will think about path splits.
|
||||
a = R_PointToAngle2(
|
||||
|
|
@ -677,24 +672,6 @@ static botprediction_t *K_CreateBotPrediction(player_t *player)
|
|||
delta = a;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == wp->numnextwaypoints)
|
||||
{
|
||||
// No usable waypoint, we don't want to check any further
|
||||
radreduce /= 2;
|
||||
distanceleft = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[nwp]->mobj) == false)
|
||||
{
|
||||
// If we can't get a direct path to this waypoint, we don't want to check any further.
|
||||
radreduce /= 2;
|
||||
distanceleft = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
angletonext = R_PointToAngle2(
|
||||
|
|
@ -704,6 +681,13 @@ static botprediction_t *K_CreateBotPrediction(player_t *player)
|
|||
|
||||
disttonext = (INT32)wp->nextwaypointdistances[nwp];
|
||||
|
||||
if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[nwp]->mobj) == false)
|
||||
{
|
||||
// If we can't get a direct path to this waypoint, we don't want to check much further...
|
||||
disttonext *= 2;
|
||||
radreduce = FRACUNIT/2;
|
||||
}
|
||||
|
||||
if (disttonext > distanceleft)
|
||||
{
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "k_waypoint.h"
|
||||
#include "d_player.h"
|
||||
#include "r_defs.h"
|
||||
|
||||
// Maximum value of botvars.difficulty
|
||||
#define MAXBOTDIFFICULTY 9
|
||||
|
|
|
|||
|
|
@ -742,16 +742,21 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t
|
|||
// Treat damage sectors like walls
|
||||
if (tb->compareThing->player != NULL)
|
||||
{
|
||||
INT32 lineside = 0;
|
||||
vertex_t pos;
|
||||
boolean alreadyHates = K_BotHatesThisSector(tb->compareThing->player, tb->compareThing->subsector->sector, tb->compareThing->x, tb->compareThing->y);
|
||||
|
||||
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 ? line->frontsector : line->backsector, pos.x, pos.y))
|
||||
if (alreadyHates == false)
|
||||
{
|
||||
// This line does not block us, but we don't want to be in it.
|
||||
return false;
|
||||
INT32 lineside = 0;
|
||||
vertex_t pos;
|
||||
|
||||
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))
|
||||
{
|
||||
// This line does not block us, but we don't want to be in it.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue