Make AI aware of damage modifiers
authorunc0rr
Mon, 22 Aug 2011 17:22:11 +0400
changeset 5642 0ce9e01bae56
parent 5640 07676ee23aff
child 5645 b434ba5d064e
Make AI aware of damage modifiers
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
--- a/hedgewars/uAIAmmoTests.pas	Sun Aug 21 22:41:10 2011 -0400
+++ b/hedgewars/uAIAmmoTests.pas	Mon Aug 22 17:22:11 2011 +0400
@@ -558,10 +558,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)
--- a/hedgewars/uAIMisc.pas	Sun Aug 21 22:41:10 2011 -0400
+++ b/hedgewars/uAIMisc.pas	Mon Aug 22 17:22:11 2011 +0400
@@ -231,10 +231,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 +256,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 +271,6 @@
 end;
 
 function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
-const
-  REUSE_BONUS = 1.35;
 var i, dmg, rate: LongInt;
 begin
 rate:= 0;
@@ -285,15 +285,15 @@
 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;
+         end;        
 RateShotgun:= rate * 1024;
 end;