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.
This commit is contained in:
Zack Middleton 2023-06-04 18:14:48 -05:00
parent 43101bf2f8
commit 51578c980c

View file

@ -3070,6 +3070,15 @@ int AINode_MoveToNextCheckpoint( bot_state_t *bs )
// Com_Printf( "f %f\n", f ); // 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_GetPointOnCurveBetweenCheckpoints( prev, next, f, origin );
G_Get2ndDervOnCurveBetweenCheckpoints( prev, next, f, alpha ); G_Get2ndDervOnCurveBetweenCheckpoints( prev, next, f, alpha );
G_GetDervOnCurveBetweenCheckpoints( prev, next, f, delta ); G_GetDervOnCurveBetweenCheckpoints( prev, next, f, delta );