--- a/hedgewars/uAIAmmoTests.pas Mon Aug 22 17:22:11 2011 +0400
+++ b/hedgewars/uAIAmmoTests.pas Mon Aug 22 17:44:30 2011 +0400
@@ -43,6 +43,7 @@
function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
+function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
TAmmoTest = record
@@ -101,7 +102,7 @@
(proc: @TestShotgun; flags: 0), // amSineGun
(proc: nil; flags: 0), // amFlamethrower
(proc: @TestGrenade; flags: 0), // amSMine
- (proc: @TestFirePunch; flags: 0), // amHammer
+ (proc: @TestHammer; flags: 0), // amHammer
(proc: nil; flags: 0), // amResurrector
(proc: nil; flags: 0), // amDrillStrike
(proc: @TestSnowball; flags: 0), // amSnowball
@@ -665,6 +666,23 @@
TestFirePunch:= valueResult;
end;
+function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
+var rate: LongInt;
+begin
+Level:= Level; // avoid compiler hint
+ap.ExplR:= 0;
+ap.Time:= 0;
+ap.Power:= 1;
+ap.Angle:= 0;
+
+if (Abs(hwRound(Me^.X) + hwSign(Me^.dX) * 10 - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) > 20) then
+ rate:= 0
+ else
+ rate:= RateHammer(Me);
+if rate = 0 then rate:= BadTurn;
+TestHammer:= rate;
+end;
+
function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
const cShift = 4;
var X, Y, dY: hwFloat;