hedgewars/uAIAmmoTests.pas
changeset 8824 fe9eacd390f2
parent 8822 fc9877ff7f1a
child 8833 c13ebed437cb
child 8862 85eb1f4b4a5f
equal deleted inserted replaced
8822:fc9877ff7f1a 8824:fe9eacd390f2
   227                 dY:= dY + cGravityf;
   227                 dY:= dY + cGravityf;
   228                 dec(t)
   228                 dec(t)
   229             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   229             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   230                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
   230                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
   231 
   231 
   232             if TestCollWithLand(trunc(x), trunc(y), 5) then
   232             if TestCollWithLand(trunc(x), trunc(y), 5) and (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) > 21) then
   233                 begin
   233                 begin
   234                 timer := 500;
   234                 timer := 500;
   235                 t2 := 0.5 / sqrt(sqr(dX) + sqr(dY));
   235                 t2 := 0.5 / sqrt(sqr(dX) + sqr(dY));
   236                 dX := dX * t2;
   236                 dX := dX * t2;
   237                 dY := dY * t2;
   237                 dY := dY * t2;
   238                 repeat
   238                 repeat
   239                     x:= x + dX;
   239                     x:= x + dX;
   240                     y:= y + dY;
   240                     y:= y + dY;
   241                     dec(timer);
   241                     dec(timer);
   242                 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5)
   242                 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 22)
   243                     or (x < 0)
   243                     or (x < 0)
   244                     or (y < 0)
   244                     or (y < 0)
   245                     or (trunc(x) > LAND_WIDTH)
   245                     or (trunc(x) > LAND_WIDTH)
   246                     or (trunc(y) > LAND_HEIGHT)
   246                     or (trunc(y) > LAND_HEIGHT)
   247                     or not TestCollWithLand(trunc(x), trunc(y), 5)
   247                     or not TestCollWithLand(trunc(x), trunc(y), 5)
   257                 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   257                 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   258                 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   258                 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   259                 ap.ExplR:= 100;
   259                 ap.ExplR:= 100;
   260                 ap.ExplX:= EX;
   260                 ap.ExplX:= EX;
   261                 ap.ExplY:= EY;
   261                 ap.ExplY:= EY;
   262                 valueResult:= value-5 // trying to make it slightly less attractive than a bazooka, to prevent waste.  AI could use awareness of weapon count
   262                 valueResult:= value-2500 // trying to make it slightly less attractive than a bazooka, to prevent waste.  AI could use awareness of weapon count
   263                 end;
   263                 end;
   264             end
   264             end
   265     until rTime > 4250;
   265     until rTime > 4250;
   266     TestDrillRocket:= valueResult
   266     TestDrillRocket:= valueResult
   267 end;
   267 end;