--- 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;
--- a/hedgewars/uAIMisc.pas Mon Aug 22 17:22:11 2011 +0400
+++ b/hedgewars/uAIMisc.pas Mon Aug 22 17:44:30 2011 +0400
@@ -56,6 +56,7 @@
function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
+function RateHammer(Me: PGear): LongInt;
function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
function AIrndSign(num: LongInt): LongInt;
@@ -297,6 +298,29 @@
RateShotgun:= rate * 1024;
end;
+function RateHammer(Me: PGear): LongInt;
+var x, y, i, r, rate: LongInt;
+begin
+// hammer hit shift against attecker hog is 10
+x:= hwRound(Me^.X) + hwSign(Me^.dX) * 10;
+y:= hwRound(Me^.Y);
+rate:= 0;
+
+for i:= 0 to Pred(Targets.Count) do
+ with Targets.ar[i] do
+ begin
+ // hammer hit radius is 8, shift is 10
+ r:= hwRound(DistanceI(Point.x - x, Point.y - y));
+
+ if r <= 18 then
+ if Score > 0 then
+ inc(rate, Score div 3)
+ else
+ inc(rate, Score div 3 * friendlyfactor div 100)
+ end;
+RateHammer:= rate * 1024;
+end;
+
function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
var bX, bY: LongInt;
bRes: boolean;