hedgewars/uAIAmmoTests.pas
changeset 4157 f8898d6cca6e
parent 3963 6090d2a2472e
child 4226 b39ca9d087a2
equal deleted inserted replaced
4156:bb1a82bbe9e3 4157:f8898d6cca6e
   496      valueResult:= RateShotgun(Me, rx, ry) * 2;
   496      valueResult:= RateShotgun(Me, rx, ry) * 2;
   497      if valueResult = 0 then valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64
   497      if valueResult = 0 then valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64
   498                    else dec(valueResult, Level * 4000);
   498                    else dec(valueResult, Level * 4000);
   499      exit(valueResult)
   499      exit(valueResult)
   500      end
   500      end
   501 until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x.isNegative) or (y.isNegative) or (x.Round > LAND_WIDTH) or (y.Round > LAND_HEIGHT);
   501 until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4)
       
   502     or (x.isNegative)
       
   503     or (y.isNegative)
       
   504     or (x.Round > LongWord(LAND_WIDTH))
       
   505     or (y.Round > LongWord(LAND_HEIGHT));
       
   506 
   502 TestShotgun:= BadTurn
   507 TestShotgun:= BadTurn
   503 end;
   508 end;
   504 
   509 
   505 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   510 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   506 var Vx, Vy, x, y, t: hwFloat;
   511 var Vx, Vy, x, y, t: hwFloat;
   524 repeat
   529 repeat
   525   x:= x + vX;
   530   x:= x + vX;
   526   y:= y + vY;
   531   y:= y + vY;
   527   if ((hwRound(x) and LAND_WIDTH_MASK) = 0)and((hwRound(y) and LAND_HEIGHT_MASK) = 0)
   532   if ((hwRound(x) and LAND_WIDTH_MASK) = 0)and((hwRound(y) and LAND_HEIGHT_MASK) = 0)
   528      and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d);
   533      and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d);
   529 until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x.isNegative) or (y.isNegative) or (x.Round > LAND_WIDTH) or (y.Round > LAND_HEIGHT) or (d > 200);
   534 until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4)
       
   535     or (x.isNegative)
       
   536     or (y.isNegative)
       
   537     or (x.Round > LongWord(LAND_WIDTH))
       
   538     or (y.Round > LongWord(LAND_HEIGHT))
       
   539     or (d > 200);
   530 
   540 
   531 if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then valueResult:= max(0, (4 - d div 50) * 7 * 1024)
   541 if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then valueResult:= max(0, (4 - d div 50) * 7 * 1024)
   532                                                            else valueResult:= BadTurn;
   542                                                            else valueResult:= BadTurn;
   533 TestDesertEagle:= valueResult
   543 TestDesertEagle:= valueResult
   534 end;
   544 end;