hedgewars/uAIAmmoTests.pas
changeset 79 29b477319854
parent 78 66bb79dd248d
child 80 3c3dc6a148ca
--- a/hedgewars/uAIAmmoTests.pas	Wed Jul 12 15:39:58 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Sun Jul 16 08:13:51 2006 +0000
@@ -39,6 +39,7 @@
 function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
 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;
 
 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 =
@@ -53,7 +54,8 @@
 {amRope}          nil,
 {amMine}          nil,
 {amDEagle}        TestDesertEagle,
-{amDynamite}      nil
+{amDynamite}      nil,
+{amBaseballBat}   TestBaseballBat
                   );
 
 implementation
@@ -175,6 +177,7 @@
 function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
 var Vx, Vy, x, y: real;
 begin
+ExplR:= 0;
 if Metric(round(Me.X), round(Me.Y), Targ.X, Targ.Y) < 80 then
    begin
    Result:= BadTurn;
@@ -182,7 +185,6 @@
    end;
 Time:= 0;
 Power:= 1;
-ExplR:= 0;
 Vx:= (Targ.X - Me.X)/1024;
 Vy:= (Targ.Y - Me.Y)/1024;
 x:= Me.X;
@@ -193,7 +195,7 @@
   y:= y + vY;
   if TestColl(round(x), round(y), 2) then
      begin
-     Result:= RateExplosion(Me, round(x), round(y), 25) * 2;
+     Result:= RateShove(Me, round(x), round(y), 25, 25) * 1024;
      if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64;
      exit
      end
@@ -205,6 +207,7 @@
 var Vx, Vy, x, y, t: real;
     d: Longword;
 begin
+ExplR:= 0;
 if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) < 80 then
    begin
    Result:= BadTurn;
@@ -212,7 +215,6 @@
    end;
 Time:= 0;
 Power:= 1;
-ExplR:= 0;
 t:= sqrt(sqr(Targ.X - Me.X) + sqr(Targ.Y - Me.Y)) * 2;
 Vx:= (Targ.X - Me.X) / t;
 Vy:= (Targ.Y - Me.Y) / t;
@@ -230,4 +232,18 @@
                                          else Result:= Low(integer)
 end;
 
+function TestBaseballBat(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
+begin
+ExplR:= 0;
+if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) >= 25 then
+   begin
+   Result:= BadTurn;
+   exit
+   end;
+Time:= 0;
+Power:= 1;
+Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1);
+Result:= RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y), 15, 30)
+end;
+
 end.