From 51578c980c9a22eedbdd088886c542c28aa79e9a Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 4 Jun 2023 18:14:48 -0500 Subject: [PATCH] Fix bots going in reverse for no reason in races On some maps bots went in reverse right away or got (almost to?) the first checkpoint and then went in reverse forever. Race movement uses derivatives on a curve but they seem to be invalid at fraction 0 and 1 so limit it to 0.05 to 0.95 (arbitrary). This change fixes bots being stuck near the beginning of q3r_nightcity, q3r_ridgeracer, and q3r_valley. The bots can complete the maps now. --- engine/code/game/ai_dmnet.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/code/game/ai_dmnet.c b/engine/code/game/ai_dmnet.c index ae5a75b0..52157003 100644 --- a/engine/code/game/ai_dmnet.c +++ b/engine/code/game/ai_dmnet.c @@ -3070,6 +3070,15 @@ int AINode_MoveToNextCheckpoint( bot_state_t *bs ) // Com_Printf( "f %f\n", f ); + // Bot goes backward if f is 0 or 1 so limit range. + // origin is fine but derivitives seem to be invalid. + // --zturtleman + if ( f > 0.95f ) { + f = 0.95f; + } else if ( f < 0.05f ) { + f = 0.05f; + } + G_GetPointOnCurveBetweenCheckpoints( prev, next, f, origin ); G_Get2ndDervOnCurveBetweenCheckpoints( prev, next, f, alpha ); G_GetDervOnCurveBetweenCheckpoints( prev, next, f, delta );