hedgewars/uAIAmmoTests.pas
changeset 15729 34138bf36c5c
parent 15728 cc8882e46784
child 15730 680dc787408c
equal deleted inserted replaced
15728:cc8882e46784 15729:34138bf36c5c
   410                     or (timer = 0)
   410                     or (timer = 0)
   411                 end;
   411                 end;
   412             EX:= trunc(x);
   412             EX:= trunc(x);
   413             EY:= trunc(y);
   413             EY:= trunc(y);
   414             // Try to prevent AI from thinking firing into water will cause a drowning
   414             // Try to prevent AI from thinking firing into water will cause a drowning
   415             if (EY < cWaterLine-5) and (timer > 0) and (Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) > 21) then exit(BadTurn);
   415             if (EY < cWaterLine-5) and (timer > 0) and (Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) > 21) then
   416             if Level = 1 then
   416                 value:= BadTurn
       
   417             else if Level = 1 then
   417                 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   418                 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   418             else value:= RateExplosion(Me, EX, EY, 101);
   419             else
       
   420                 value:= RateExplosion(Me, EX, EY, 101);
   419             if valueResult <= value then
   421             if valueResult <= value then
   420                 begin
   422                 begin
   421                 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   423                 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   422                 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   424                 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   423                 ap.ExplR:= 100;
   425                 ap.ExplR:= 100;
  2268         EY:= trunc(y);
  2270         EY:= trunc(y);
  2269 
  2271 
  2270         // Sanity check: Make sure we're not too close to impact location
  2272         // Sanity check: Make sure we're not too close to impact location
  2271         range:= Metric(trunc(meX), trunc(meY), EX, EY);
  2273         range:= Metric(trunc(meX), trunc(meY), EX, EY);
  2272         if (range <= 40) then
  2274         if (range <= 40) then
  2273             exit(BadTurn);
  2275             value:= BadTurn
  2274 
  2276         // Timeout
  2275         if t >= -timeLimit then
  2277         else if t < -timeLimit then
  2276             value:= RateShove(Me, EX, EY, 16, trunc(sqr((abs(dY)+abs(dX))*40000/10000)), 0, dX, dY, 0)
  2278             value:= BadTurn
  2277         else
  2279         else
  2278             value:= BadTurn;
  2280             value:= RateShove(Me, EX, EY, 16, trunc(sqr((abs(dY)+abs(dX))*40000/10000)), 0, dX, dY, 0);
  2279 
  2281 
  2280         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
  2282         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
  2281             value := BadTurn;
  2283             value := BadTurn;
  2282 
  2284 
  2283         if (valueResult < value) or ((valueResult = value) and (Level = 1)) then
  2285         if (valueResult < value) or ((valueResult = value) and (Level = 1)) then