--- a/hedgewars/uAIAmmoTests.pas Mon Aug 22 15:11:48 2011 +0200
+++ b/hedgewars/uAIAmmoTests.pas Mon Aug 22 17:46:16 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
@@ -558,10 +559,13 @@
begin
x:= x + vX * 8;
y:= y + vY * 8;
- valueResult:= RateShotgun(Me, rx, ry) * 2;
- if valueResult = 0 then valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64
- else dec(valueResult, Level * 4000);
- exit(valueResult)
+ valueResult:= RateShotgun(Me, rx, ry);
+
+ if valueResult = 0 then
+ valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64
+ else
+ dec(valueResult, Level * 4000);
+ exit(valueResult * 27 div 20) // 27/20 is reuse bonus
end
until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4)
or (x.isNegative)
@@ -662,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 15:11:48 2011 +0200
+++ b/hedgewars/uAIMisc.pas Mon Aug 22 17:46:16 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;
@@ -231,10 +232,11 @@
for i:= 0 to Targets.Count do
with Targets.ar[i] do
begin
- dmg:= r + cHHRadius div 2 - hwRound(DistanceI(Point.x - x, Point.y - y));
+ dmg:= hwRound(_0_01 * cDamageModifier
+ * min((r + cHHRadius div 2 - DistanceI(Point.x - x, Point.y - y).Round) div 2, r) * cDamagePercent);
+
if dmg > 0 then
begin
- dmg:= min(dmg div 2, r);
if dmg >= abs(Score) then
if Score > 0 then inc(rate, KillScore)
else dec(rate, KillScore * friendlyfactor div 100)
@@ -255,6 +257,7 @@
with Targets.ar[i] do
begin
dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
+ dmg:= hwRound(_0_01 * cDamageModifier * dmg * cDamagePercent);
if dmg > 0 then
begin
if power >= abs(Score) then
@@ -269,8 +272,6 @@
end;
function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
-const
- REUSE_BONUS = 1.35;
var i, dmg, rate: LongInt;
begin
rate:= 0;
@@ -285,16 +286,39 @@
for i:= 0 to Targets.Count do
with Targets.ar[i] do
begin
- dmg:= min(cHHRadius + cShotgunRadius - hwRound(DistanceI(Point.x - x, Point.y - y)), 25);
- dmg := round(dmg * REUSE_BONUS);
+ dmg:= min(cHHRadius + cShotgunRadius + 4 - hwRound(DistanceI(Point.x - x, Point.y - y)), 25);
+ dmg:= hwRound(_0_01 * cDamageModifier * dmg * cDamagePercent);
if dmg > 0 then
begin
if dmg >= abs(Score) then dmg := KillScore;
if Score > 0 then inc(rate, dmg)
else dec(rate, dmg * friendlyfactor div 100);
end;
+ end;
+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;
-RateShotgun:= rate * 1024;
+RateHammer:= rate * 1024;
end;
function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;