toggle aimprediction when aimming at player

This commit is contained in:
ineedbots 2021-09-06 17:32:49 -06:00
parent aa6daea954
commit 1419089ff5

View File

@ -1109,7 +1109,7 @@ aim_loop()
if ( !nadeAimOffset && conedot > 0.999 && lengthsquared( aimoffset ) < 0.05 ) if ( !nadeAimOffset && conedot > 0.999 && lengthsquared( aimoffset ) < 0.05 )
self thread bot_lookat( aimpos, 0.05 ); self thread bot_lookat( aimpos, 0.05 );
else else
self thread bot_lookat( aimpos, aimspeed, target getVelocity() ); self thread bot_lookat( aimpos, aimspeed, target getVelocity(), true );
} }
else else
{ {
@ -2040,7 +2040,7 @@ botMoveTo( where )
/* /*
Bots will look at the pos Bots will look at the pos
*/ */
bot_lookat( pos, time, vel ) bot_lookat( pos, time, vel, doAimPredict )
{ {
self notify( "bots_aim_overlap" ); self notify( "bots_aim_overlap" );
self endon( "bots_aim_overlap" ); self endon( "bots_aim_overlap" );
@ -2055,6 +2055,9 @@ bot_lookat( pos, time, vel )
if ( !isDefined( pos ) ) if ( !isDefined( pos ) )
return; return;
if ( !isDefined( doAimPredict ) )
doAimPredict = false;
if ( !isDefined( time ) ) if ( !isDefined( time ) )
time = 0.05; time = 0.05;
@ -2067,9 +2070,13 @@ bot_lookat( pos, time, vel )
steps = 1; steps = 1;
myEye = self GetEyePos(); // get our eye pos myEye = self GetEyePos(); // get our eye pos
if ( doAimPredict )
{
myEye += vector_scale( vector_scale( self getVelocity(), 0.05 ), steps - 1 ); // account for our velocity myEye += vector_scale( vector_scale( self getVelocity(), 0.05 ), steps - 1 ); // account for our velocity
pos += vector_scale( vector_scale( vel, 0.05 ), steps - 1 ); // add the velocity vector pos += vector_scale( vector_scale( vel, 0.05 ), steps - 1 ); // add the velocity vector
}
myAngle = self getPlayerAngles(); myAngle = self getPlayerAngles();
angles = VectorToAngles( ( pos - myEye ) - anglesToForward( myAngle ) ); angles = VectorToAngles( ( pos - myEye ) - anglesToForward( myAngle ) );