mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-23 16:32:36 +00:00
Stop lag when bots respawn
They try to predict their direction while they respawn, which makes them go a bit nuts when air time compensation kicks in. Cap it so that this can't happen.
This commit is contained in:
parent
5107160a27
commit
0c5b42a07e
1 changed files with 9 additions and 2 deletions
11
src/k_bot.c
11
src/k_bot.c
|
|
@ -298,7 +298,7 @@ boolean K_BotCanTakeCut(player_t *player)
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
static fixed_t K_BotSpeedScaled(player_t *player, fixed_t speed)
|
static fixed_t K_BotSpeedScaled(player_t *player, fixed_t speed)
|
||||||
|
|
||||||
Gets the bot's speed value, adjusted for predictions.
|
What the bot "thinks" their speed is, for predictions.
|
||||||
Mainly to make bots brake earlier when on friction sectors.
|
Mainly to make bots brake earlier when on friction sectors.
|
||||||
|
|
||||||
Input Arguments:-
|
Input Arguments:-
|
||||||
|
|
@ -312,6 +312,12 @@ static fixed_t K_BotSpeedScaled(player_t *player, fixed_t speed)
|
||||||
{
|
{
|
||||||
fixed_t result = speed;
|
fixed_t result = speed;
|
||||||
|
|
||||||
|
if (P_IsObjectOnGround(player->mo) == false)
|
||||||
|
{
|
||||||
|
// You have no air control, so don't predict too far ahead.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (player->mo->movefactor != FRACUNIT)
|
if (player->mo->movefactor != FRACUNIT)
|
||||||
{
|
{
|
||||||
fixed_t moveFactor = player->mo->movefactor;
|
fixed_t moveFactor = player->mo->movefactor;
|
||||||
|
|
@ -650,7 +656,8 @@ static botprediction_t *K_CreateBotPrediction(player_t *player)
|
||||||
const fixed_t speed = K_BotSpeedScaled(player, P_AproxDistance(player->mo->momx, player->mo->momy));
|
const fixed_t speed = K_BotSpeedScaled(player, P_AproxDistance(player->mo->momx, player->mo->momy));
|
||||||
|
|
||||||
const INT32 startDist = (DEFAULT_WAYPOINT_RADIUS * 2 * mapobjectscale) / FRACUNIT;
|
const INT32 startDist = (DEFAULT_WAYPOINT_RADIUS * 2 * mapobjectscale) / FRACUNIT;
|
||||||
const INT32 distance = ((speed / FRACUNIT) * futuresight) + startDist;
|
const INT32 maxDist = startDist * 4; // This function gets very laggy when it goes far distances, and going too far isn't very helpful anyway.
|
||||||
|
const INT32 distance = min(((speed / FRACUNIT) * futuresight) + startDist, maxDist);
|
||||||
|
|
||||||
// Halves radius when encountering a wall on your way to your destination.
|
// Halves radius when encountering a wall on your way to your destination.
|
||||||
fixed_t radreduce = FRACUNIT;
|
fixed_t radreduce = FRACUNIT;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue