hedgewars/uAIAmmoTests.pas
changeset 82 2f4f3236cccc
parent 80 3c3dc6a148ca
child 107 b08ce0293a51
--- a/hedgewars/uAIAmmoTests.pas	Fri Jul 21 20:37:44 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Sun Jul 23 21:22:44 2006 +0000
@@ -40,6 +40,7 @@
 function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
 function TestDesertEagle(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
 function TestBaseballBat(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
+function TestFirePunch(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
 
 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
 const AmmoTests: array[TAmmoType] of TAmmoTestProc =
@@ -55,7 +56,8 @@
 {amMine}          nil,
 {amDEagle}        TestDesertEagle,
 {amDynamite}      nil,
-{amBaseballBat}   TestBaseballBat
+{amBaseballBat}   TestBaseballBat,
+{amFirePunch}     TestFirePunch
                   );
 
 implementation
@@ -96,11 +98,11 @@
 
 begin
 Time:= 0;
-rTime:= 10;
+rTime:= 50;
 ExplR:= 0;
 Result:= BadTurn;
 repeat
-  rTime:= rTime + 100 + random*250;
+  rTime:= rTime + 150 + random*250;
   Vx:= - cWindSpeed * rTime / 2 + (Targ.X - Me.X) / rTime;
   Vy:= cGravity * rTime / 2 - (Targ.Y - Me.Y) / rTime;
   r:= sqr(Vx) + sqr(Vy);
@@ -118,7 +120,7 @@
         Result:= Score
         end;
      end
-until (rTime >= 5000)
+until (rTime >= 4500)
 end;
 
 function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
@@ -246,4 +248,21 @@
 Result:= RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y), 15, 30)
 end;
 
+function TestFirePunch(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
+var i: integer;
+begin
+ExplR:= 0;
+if (abs(Me.X - Targ.X) > 25) or (abs(Me.Y - 50 - Targ.Y) > 50) then
+   begin
+   Result:= BadTurn;
+   exit
+   end;
+Time:= 0;
+Power:= 1;
+Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1);
+Result:= 0;
+for i:= 0 to 4 do
+    Result:= Result + RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30)
+end;
+
 end.