- AI quickly shoots with desert eagle till hits the target
authorunc0rr
Mon, 07 Oct 2013 23:36:40 +0400
changeset 9495 2fc346fadae3
parent 9493 23c674bfa2e2
child 9497 1813b682c6bd
- AI quickly shoots with desert eagle till hits the target - Also tries for hits with less number of shots needed
hedgewars/uAI.pas
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAI.pas	Mon Oct 07 22:22:49 2013 +0400
+++ b/hedgewars/uAI.pas	Mon Oct 07 23:36:40 2013 +0400
@@ -106,7 +106,7 @@
 procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean);
 var BotLevel: Byte;
     ap: TAttackParams;
-    Score, i, dAngle: LongInt;
+    Score, i, t, n, dAngle: LongInt;
     a, aa: TAmmoType;
 begin
 BotLevel:= Me^.Hedgehog^.BotLevel;
@@ -182,7 +182,15 @@
                         end else
                         if (Ammoz[a].Ammo.Propz and ammoprop_AttackingPut) = 0 then
                             begin
+                            if (AmmoTests[a].flags and amtest_MultipleAttacks) = 0 then
+                                n:= 1 else n:= ap.AttacksNum;
+
                             AddAction(BestActions, aia_attack, aim_push, 650 + random(300), 0, 0);
+                            for t:= 2 to n do
+                                begin
+                                AddAction(BestActions, aia_attack, aim_push, 150, 0, 0);
+                                AddAction(BestActions, aia_attack, aim_release, ap.Power, 0, 0);
+                                end;
                             AddAction(BestActions, aia_attack, aim_release, ap.Power, 0, 0);
                             end;
 
--- a/hedgewars/uAIAmmoTests.pas	Mon Oct 07 22:22:49 2013 +0400
+++ b/hedgewars/uAIAmmoTests.pas	Mon Oct 07 23:36:40 2013 +0400
@@ -22,13 +22,14 @@
 interface
 uses uConsts, uFloat, uTypes, uAIMisc;
 const
-    amtest_Rare     = $00000001; // check only several positions
-    amtest_NoTarget = $00000002; // each pos, but no targetting
+    amtest_Rare            = $00000001; // check only several positions
+    amtest_NoTarget        = $00000002; // each pos, but no targetting
+    amtest_MultipleAttacks = $00000004; // test could result in multiple attacks, set AttacksNum
 
 var windSpeed: real;
 
 type TAttackParams = record
-        Time: Longword;
+        Time, AttacksNum: Longword;
         Angle, Power: LongInt;
         ExplX, ExplY, ExplR: LongInt;
         AttackPutX, AttackPutY: LongInt;
@@ -72,7 +73,7 @@
             (proc: nil;              flags: 0), // amSkip
             (proc: nil;              flags: 0), // amRope
             (proc: nil;              flags: 0), // amMine
-            (proc: @TestDesertEagle; flags: 0), // amDEagle
+            (proc: @TestDesertEagle; flags: amtest_MultipleAttacks), // amDEagle
             (proc: nil;              flags: 0), // amDynamite
             (proc: @TestFirePunch;   flags: amtest_NoTarget), // amFirePunch
             (proc: @TestWhip;        flags: amtest_NoTarget), // amWhip
@@ -715,8 +716,13 @@
     or (d > 48);
 
 if Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) < 5 then
-     valueResult:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, 7, 20, vX*0.125, vY*0.125, afTrackFall)
-else valueResult:= BadTurn;
+    begin
+    ap.AttacksNum:= 1 + (d + 8) div 12;
+    valueResult:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, 7, 20, vX*0.125, vY*0.125, afTrackFall) - ap.AttacksNum
+    end
+else
+    valueResult:= BadTurn;
+
 TestDesertEagle:= valueResult
 end;