From 98e9997c66e31797d6bd4b835bdc99e8d4650caa Mon Sep 17 00:00:00 2001 From: ineedbots Date: Wed, 19 May 2021 15:50:47 -0600 Subject: [PATCH] Improved bot aim --- maps/mp/bots/_bot_internal.gsc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/maps/mp/bots/_bot_internal.gsc b/maps/mp/bots/_bot_internal.gsc index 783100e..de03cbc 100644 --- a/maps/mp/bots/_bot_internal.gsc +++ b/maps/mp/bots/_bot_internal.gsc @@ -1386,7 +1386,7 @@ aim() if (conedot > 0.999 && lengthsquared(aimoffset) < 0.05) self thread bot_lookat(aimpos, 0.05); else - self thread bot_lookat(aimpos, aimspeed); + self thread bot_lookat(aimpos, aimspeed, target getVelocity()); } else { @@ -2336,7 +2336,7 @@ botMoveTo(where) /* Bots will look at the pos */ -bot_lookat(pos, time) +bot_lookat(pos, time, vel) { self notify("bots_aim_overlap"); self endon("bots_aim_overlap"); @@ -2351,12 +2351,23 @@ bot_lookat(pos, time) if (!isDefined(pos)) return; - steps = time / 0.05; - if (!isDefined(steps) || steps <= 0) + if (!isDefined(time)) + time = 0.05; + + if (!isDefined(vel)) + vel = (0, 0, 0); + + steps = int(time * 20); + if (steps < 1) steps = 1; + myEye = self GetEyePos(); // get our eye pos + myEye += (self getVelocity() * 0.05) * (steps - 1); // account for our velocity + + pos += (vel * 0.05) * (steps - 1); // add the velocity vector + myAngle=self getPlayerAngles(); - angles = VectorToAngles( (pos - self GetEye()) - anglesToForward(myAngle) ); + angles = VectorToAngles( (pos - myEye) - anglesToForward(myAngle) ); X=(angles[0]-myAngle[0]); while(X > 170.0)