hedgewars/uAI.pas
changeset 7789 838d2e06c377
parent 7787 67c96b9c179c
child 7790 040fc517fece
--- a/hedgewars/uAI.pas	Mon Oct 22 14:39:49 2012 +0400
+++ b/hedgewars/uAI.pas	Mon Oct 22 21:24:38 2012 +0400
@@ -108,7 +108,7 @@
 
 
 
-procedure TestAmmos(var Actions: TActions; Me: PGear; isMoved: boolean);
+procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean);
 var BotLevel: Byte;
     ap: TAttackParams;
     Score, i, dAngle: LongInt;
@@ -130,7 +130,7 @@
 {$ENDIF}       
         repeat
         if (CanUseAmmo[a]) 
-            and ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) 
+            and ((not rareChecks) or ((AmmoTests[a].flags and amtest_Rare) = 0)) 
             and ((i = 0) or ((AmmoTests[a].flags and amtest_NoTarget) = 0)) 
             then
             begin
@@ -217,7 +217,7 @@
 procedure Walk(Me: PGear; var Actions: TActions);
 const FallPixForBranching = cHHRadius;
 var
-    ticks, maxticks, steps, tmp: Longword;
+    ticks, maxticks, oldticks, steps, tmp: Longword;
     BaseRate, BestRate, Rate: integer;
     GoInfo: TGoInfo;
     CanGo: boolean;
@@ -225,7 +225,8 @@
     BotLevel: Byte;
     a: TAmmoType;
 begin
-ticks:= 0; // avoid compiler hint
+ticks:= 0;
+oldticks:= 0; // avoid compiler hint
 Stack.Count:= 0;
 
 clearAllMarks;
@@ -274,6 +275,7 @@
     {$HINTS OFF}
             CanGo:= HHGo(Me, @AltMe, GoInfo);
     {$HINTS ON}
+            oldticks:= ticks;
             inc(ticks, GoInfo.Ticks);
             if ticks > maxticks then
                 break;
@@ -349,8 +351,8 @@
                 if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere) then
                     break;                    
                 addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
-                
-                TestAmmos(Actions, Me, true);
+
+                TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12);
                 end;
                 
             if GoInfo.FallPix >= FallPixForBranching then