hedgewars/uAIAmmoTests.pas
changeset 4436 94c948a92759
parent 4374 bcefeeabaa33
child 4578 f3cf226fad16
equal deleted inserted replaced
4366:d19adc635c99 4436:94c948a92759
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uAIAmmoTests;
    21 unit uAIAmmoTests;
    22 interface
    22 interface
    23 uses SDLh, uGears, uConsts, uFloat;
    23 uses SDLh, uConsts, uFloat, uTypes;
    24 const amtest_OnTurn = $00000001;
    24 const amtest_OnTurn = $00000001;
    25 
    25 
    26 type TAttackParams = record
    26 type TAttackParams = record
    27             Time: Longword;
    27             Time: Longword;
    28             Angle, Power: LongInt;
    28             Angle, Power: LongInt;
   106             );
   106             );
   107 
   107 
   108 const BadTurn = Low(LongInt) div 4;
   108 const BadTurn = Low(LongInt) div 4;
   109 
   109 
   110 implementation
   110 implementation
   111 uses uMisc, uAIMisc, uLand;
   111 uses uAIMisc, uVariables, uUtils;
   112 
   112 
   113 function Metric(x1, y1, x2, y2: LongInt): LongInt;
   113 function Metric(x1, y1, x2, y2: LongInt): LongInt;
   114 begin
   114 begin
   115 Metric:= abs(x1 - x2) + abs(y1 - y2)
   115 Metric:= abs(x1 - x2) + abs(y1 - y2)
   116 end;
   116 end;
   537     or (y.isNegative)
   537     or (y.isNegative)
   538     or (x.Round > LongWord(LAND_WIDTH))
   538     or (x.Round > LongWord(LAND_WIDTH))
   539     or (y.Round > LongWord(LAND_HEIGHT))
   539     or (y.Round > LongWord(LAND_HEIGHT))
   540     or (d > 200);
   540     or (d > 200);
   541 
   541 
   542 if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then valueResult:= max(0, (4 - d div 50) * 7 * 1024)
   542 if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then valueResult:= Max(0, (4 - d div 50) * 7 * 1024)
   543                                                            else valueResult:= BadTurn;
   543                                                            else valueResult:= BadTurn;
   544 TestDesertEagle:= valueResult
   544 TestDesertEagle:= valueResult
   545 end;
   545 end;
   546 
   546 
   547 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   547 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;