Bots aims not directly at the center of enemy hedgehog
authorunc0rr
Fri, 13 Jul 2007 19:59:49 +0000
changeset 556 49675457d76e
parent 555 0376fdcc6322
child 557 a7d49d5e8257
Bots aims not directly at the center of enemy hedgehog
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAIAmmoTests.pas	Thu Jul 12 14:44:41 2007 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Fri Jul 13 19:59:49 2007 +0000
@@ -113,7 +113,7 @@
 Result:= BadTurn;
 repeat
   rTime:= rTime + 300 + Level * 50 + random(300);
-  Vx:= - cWindSpeed * rTime * _0_5 + (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(rTime);
+  Vx:= - cWindSpeed * rTime * _0_5 + (int2hwFloat(Targ.X + AIrndSign(2)) - Me^.X) / int2hwFloat(rTime);
   Vy:= cGravity * rTime * _0_5 - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(rTime);
   r:= Distance(Vx, Vy);
   if not (r > _1) then
@@ -281,6 +281,7 @@
 end;
 
 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
+const cShift = 4;
 var X, Y, dY: hwFloat;
     b: array[0..9] of boolean;
     dmg: array[0..9] of LongInt;
@@ -294,7 +295,7 @@
 ap.AttackPutX:= Targ.X;
 ap.AttackPutY:= Targ.Y;
 
-X:= int2hwFloat(Targ.X - 135);
+X:= int2hwFloat(Targ.X - 135 - cShift); // hh center - cShift
 X:= X - cBombsSpeed * hwSqrt(int2hwFloat((Targ.Y + 128) * 2) / cGravity);
 Y:= -_128;
 dY:= _0;
@@ -336,7 +337,7 @@
     if t > Result then
        begin
        Result:= t;
-       ap.AttackPutX:= Targ.X - 30 + i * 30
+       ap.AttackPutX:= Targ.X - 30 - cShift + i * 30
        end
     end;