Improve AI aiming with minigun
authorunC0Rr
Thu, 16 May 2024 14:11:16 +0200
changeset 16014 e66feb918d71
parent 16013 2e529b1a9d5b
child 16015 0e90bdfc2642
Improve AI aiming with minigun
hedgewars/uAI.pas
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAI.pas	Wed May 15 10:05:13 2024 +0200
+++ b/hedgewars/uAI.pas	Thu May 16 14:11:16 2024 +0200
@@ -228,12 +228,14 @@
                         if dAngle > 0 then
                             begin
                             AddAction(BestActions, aia_Up, aim_push, 300 + random(250), 0, 0);
-                            AddAction(BestActions, aia_Up, aim_release, dAngle, 0, 0)
+                            AddAction(BestActions, aia_waitAngle, ap.Angle, 1, 0, 0);
+                            AddAction(BestActions, aia_Up, aim_release, 1, 0, 0)
                             end
                         else if dAngle < 0 then
                             begin
                             AddAction(BestActions, aia_Down, aim_push, 300 + random(250), 0, 0);
-                            AddAction(BestActions, aia_Down, aim_release, -dAngle, 0, 0)
+                            AddAction(BestActions, aia_waitAngle, ap.Angle, 1, 0, 0);
+                            AddAction(BestActions, aia_Down, aim_release, 1, 0, 0)
                             end
                         end;
 
--- a/hedgewars/uAIAmmoTests.pas	Wed May 15 10:05:13 2024 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Thu May 16 14:11:16 2024 +0200
@@ -2478,7 +2478,7 @@
 Vy:= (Targ.Point.Y - y) * 1 / 1024;
 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
 // Minigun angle is limited
-if (ap.Angle < Ammoz[amMinigun].minAngle) or (ap.Angle > Ammoz[amMinigun].maxAngle) then
+if (abs(ap.Angle) < Ammoz[amMinigun].minAngle) or (abs(ap.Angle) > Ammoz[amMinigun].maxAngle) then
     exit(BadTurn);
 
 // Apply inaccuracy