AI: Don't end ammo tests too early for knife and drill rocket
authorWuzzy <Wuzzy2@mail.ru>
Sun, 19 Jul 2020 11:32:30 +0200
changeset 15751 34138bf36c5c
parent 15750 cc8882e46784
child 15752 680dc787408c
AI: Don't end ammo tests too early for knife and drill rocket
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAIAmmoTests.pas	Sun Jul 19 11:20:20 2020 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Sun Jul 19 11:32:30 2020 +0200
@@ -412,10 +412,12 @@
             EX:= trunc(x);
             EY:= trunc(y);
             // Try to prevent AI from thinking firing into water will cause a drowning
-            if (EY < cWaterLine-5) and (timer > 0) and (Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) > 21) then exit(BadTurn);
-            if Level = 1 then
+            if (EY < cWaterLine-5) and (timer > 0) and (Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) > 21) then
+                value:= BadTurn
+            else if Level = 1 then
                 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
-            else value:= RateExplosion(Me, EX, EY, 101);
+            else
+                value:= RateExplosion(Me, EX, EY, 101);
             if valueResult <= value then
                 begin
                 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
@@ -2270,12 +2272,12 @@
         // Sanity check: Make sure we're not too close to impact location
         range:= Metric(trunc(meX), trunc(meY), EX, EY);
         if (range <= 40) then
-            exit(BadTurn);
-
-        if t >= -timeLimit then
-            value:= RateShove(Me, EX, EY, 16, trunc(sqr((abs(dY)+abs(dX))*40000/10000)), 0, dX, dY, 0)
+            value:= BadTurn
+        // Timeout
+        else if t < -timeLimit then
+            value:= BadTurn
         else
-            value:= BadTurn;
+            value:= RateShove(Me, EX, EY, 16, trunc(sqr((abs(dY)+abs(dX))*40000/10000)), 0, dX, dY, 0);
 
         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
             value := BadTurn;