--- a/hedgewars/uAIAmmoTests.pas Wed Feb 20 02:21:58 2013 +0100
+++ b/hedgewars/uAIAmmoTests.pas Tue Apr 02 21:00:57 2013 +0200
@@ -197,7 +197,11 @@
x, y, dX, dY: real;
t: LongInt;
value: LongInt;
+ t2: real;
+ timer: Longint;
begin
+ if (Level > 3) then exit(BadTurn);
+
mX:= hwFloat2Float(Me^.X);
mY:= hwFloat2Float(Me^.Y);
ap.Time:= 0;
@@ -225,13 +229,29 @@
until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
+ if TestCollWithLand(trunc(x), trunc(y), 5) and (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) > 21) then
+ begin
+ timer := 500;
+ t2 := 0.5 / sqrt(sqr(dX) + sqr(dY));
+ dX := dX * t2;
+ dY := dY * t2;
+ repeat
+ x:= x + dX;
+ y:= y + dY;
+ dec(timer);
+ until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 22)
+ or (x < 0)
+ or (y < 0)
+ or (trunc(x) > LAND_WIDTH)
+ or (trunc(y) > LAND_HEIGHT)
+ or not TestCollWithLand(trunc(x), trunc(y), 5)
+ or (timer = 0)
+ end;
EX:= trunc(x);
EY:= trunc(y);
if Level = 1 then
value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
else value:= RateExplosion(Me, EX, EY, 101);
- if value = 0 then
- value:= 1024 - Metric(Targ.X, Targ.Y, EX, EY) div 64;
if valueResult <= value then
begin
ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
@@ -239,7 +259,7 @@
ap.ExplR:= 100;
ap.ExplX:= EX;
ap.ExplY:= EY;
- valueResult:= value
+ valueResult:= value-2500 // trying to make it slightly less attractive than a bazooka, to prevent waste. AI could use awareness of weapon count
end;
end
until rTime > 4250;
@@ -1171,7 +1191,7 @@
//FillChar(cake, sizeof(cake), 0);
cake.Radius:= 7;
- cake.CollisionMask:= $FF7F;
+ cake.CollisionMask:= lfNotCurrentMask;
cake.Hedgehog:= Me^.Hedgehog;
// check left direction