Check cake and air attack again if walked far from initial position (not tested)
authorunc0rr
Mon, 22 Oct 2012 21:24:38 +0400
changeset 7789 838d2e06c377
parent 7788 27f7f0190e44
child 7790 040fc517fece
Check cake and air attack again if walked far from initial position (not tested)
hedgewars/uAI.pas
hedgewars/uAIAmmoTests.pas
--- 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
--- a/hedgewars/uAIAmmoTests.pas	Mon Oct 22 14:39:49 2012 +0400
+++ b/hedgewars/uAIAmmoTests.pas	Mon Oct 22 21:24:38 2012 +0400
@@ -22,7 +22,7 @@
 interface
 uses SDLh, uConsts, uFloat, uTypes;
 const 
-    amtest_OnTurn   = $00000001; // from one position
+    amtest_Rare     = $00000001; // check only several positions
     amtest_NoTarget = $00000002; // each pos, but no targetting
 
 var windSpeed: real;
@@ -77,7 +77,7 @@
             (proc: @TestWhip;        flags: amtest_NoTarget), // amWhip
             (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat
             (proc: nil;              flags: 0), // amParachute
-            (proc: @TestAirAttack;   flags: amtest_OnTurn), // amAirAttack
+            (proc: @TestAirAttack;   flags: amtest_Rare), // amAirAttack
             (proc: nil;              flags: 0), // amMineStrike
             (proc: nil;              flags: 0), // amBlowTorch
             (proc: nil;              flags: 0), // amGirder
@@ -86,7 +86,7 @@
             (proc: nil;              flags: 0), // amSwitch
             (proc: @TestMortar;      flags: 0), // amMortar
             (proc: @TestKamikaze;    flags: 0), // amKamikaze
-            (proc: @TestCake;        flags: amtest_OnTurn or amtest_NoTarget), // amCake
+            (proc: @TestCake;        flags: amtest_Rare or amtest_NoTarget), // amCake
             (proc: nil;              flags: 0), // amSeduction
             (proc: @TestWatermelon;  flags: 0), // amWatermelon
             (proc: nil;              flags: 0), // amHellishBomb