hedgewars/uAIAmmoTests.pas
changeset 7041 76a9274f280f
parent 7007 0ccdff4ae8e9
child 7078 a3408d9ba5ad
--- a/hedgewars/uAIAmmoTests.pas	Thu May 10 13:45:47 2012 +0400
+++ b/hedgewars/uAIAmmoTests.pas	Thu May 10 22:55:13 2012 +0400
@@ -479,18 +479,18 @@
     TestTime: Longword;
     x, y, dY, meX, meY: real;
 begin
-TestMortar:= BadTurn;
-ap.ExplR:= 0;
-meX:= hwFloat2Float(Me^.X);
-meY:= hwFloat2Float(Me^.Y);
+    TestMortar:= BadTurn;
+    ap.ExplR:= 0;
+    meX:= hwFloat2Float(Me^.X);
+    meY:= hwFloat2Float(Me^.Y);
 
-if (Level > 2) then
-    exit;
+    if (Level > 2) then
+        exit(BadTurn);
 
-TestTime:= Solve(Targ.X, Targ.Y, trunc(meX), trunc(meY));
+    TestTime:= Solve(Targ.X, Targ.Y, trunc(meX), trunc(meY));
 
-if TestTime = 0 then
-    exit;
+    if TestTime = 0 then
+        exit(BadTurn);
 
     Vx:= (Targ.X - meX) / TestTime;
     Vy:= cGravityf * (TestTime div 2) - (Targ.Y - meY) / TestTime;
@@ -548,7 +548,8 @@
 y:= hwFloat2Float(Me^.Y);
 range:= Metric(trunc(x), trunc(y), Targ.X, Targ.Y);
 if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then
-    exit;
+    exit(BadTurn);
+
 Vx:= (Targ.X - x) * 1 / 1024;
 Vy:= (Targ.Y - y) * 1 / 1024;
 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
@@ -568,8 +569,7 @@
         else 
             dec(valueResult, Level * 4000);
         // 27/20 is reuse bonus
-        TestShotgun:= valueResult * 27 div 20;
-        exit 
+        exit(valueResult * 27 div 20)
     end
 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4)
     or (x < 0)
@@ -593,10 +593,10 @@
 x:= hwFloat2Float(Me^.X);
 y:= hwFloat2Float(Me^.Y);
 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then
-begin
+    begin
     TestDesertEagle:= BadTurn;
-    exit;
-end;
+    exit(BadTurn);
+    end;
 t:= 0.5 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y));
 Vx:= (Targ.X - x) * t;
 Vy:= (Targ.Y - y) * t;
@@ -638,7 +638,7 @@
 x:= hwFloat2Float(Me^.X);
 y:= hwFloat2Float(Me^.Y);
 if (Level > 2) or (Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) > 25) then
-    exit;
+    exit(BadTurn);
 
 ap.Time:= 0;
 ap.Power:= 1;
@@ -676,8 +676,7 @@
         val1:= Succ(BadTurn)
     else
         val1:= BadTurn;
-    TestFirePunch:= val1;
-    exit;
+    exit(val1);
     end;
 (*
 For some silly reason, having this enabled w/ the AI 
@@ -725,8 +724,7 @@
         valueResult:= Succ(BadTurn)
     else
         valueResult:= BadTurn;
-    TestWhip:= valueResult;
-    exit;
+    exit(valueResult);
     end;
 
 valueResult:= 0;
@@ -770,10 +768,7 @@
 ap.ExplR:= 0;
 ap.Time:= 0;
 if (Level > 3) then
-begin
-    TestAirAttack:= BadTurn;
-    exit;
-end;
+    exit(BadTurn);
 
 ap.AttackPutX:= Targ.X;
 ap.AttackPutY:= Targ.Y;
@@ -837,7 +832,7 @@
     maxTop: longword;
 begin
     TestTeleport := BadTurn;
-    exit;
+    exit(BadTurn);
     Level:= Level; // avoid compiler hint
     //FillBonuses(true, [gtCase]);
     if bonuses.Count = 0 then