Fix broken kamikaze logic when target position is close to attacker
authorunc0rr
Thu, 10 Jan 2019 21:22:07 +0100
changeset 14546 7e4862823649
parent 14545 adf3e7d94db0
child 14547 90893b397933
Fix broken kamikaze logic when target position is close to attacker
.hgignore
hedgewars/uAIAmmoTests.pas
--- a/.hgignore	Thu Jan 10 19:47:18 2019 +0100
+++ b/.hgignore	Thu Jan 10 21:22:07 2019 +0100
@@ -90,3 +90,5 @@
 *.user
 *.iml
 build-qmlfrontend*
+.cabal-sandbox
+cabal.sandbox.config
--- a/hedgewars/uAIAmmoTests.pas	Thu Jan 10 19:47:18 2019 +0100
+++ b/hedgewars/uAIAmmoTests.pas	Thu Jan 10 21:22:07 2019 +0100
@@ -1149,17 +1149,18 @@
 
     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
 
-    for i:= 0 to 512 div step - 2 do
+    for i:= 1 to 512 div step - 2 do
         begin
+        x:= x + dx;
+        y:= y + dy;
+
         valueResult:= valueResult +
             RateShove(Me, trunc(x), trunc(y)
                 , 30, 30, 25
                 , cx, -0.9, trackFall or afSetSkip);
+        end;
 
-        x:= x + dx;
-        y:= y + dy;
-        end;
-    if dx = 0 then
+    if (d < 10) and (dx = 0) then
         begin
         x:= hwFloat2Float(Me^.X);
         y:= hwFloat2Float(Me^.Y);
@@ -1176,8 +1177,10 @@
                     , -cx, -0.9, trackFall or afSetSkip);
             end
         end;
+
     if v > valueResult then
-        begin
+    begin
+        cx:= -cx;
         ap.Angle:= -2048;
         valueResult:= v
         end;