hedgewars/uAIAmmoTests.pas
branchwebgl
changeset 9521 8054d9d775fd
parent 9160 fc46e75f6b72
parent 9495 2fc346fadae3
child 9950 2759212a27de
equal deleted inserted replaced
9282:92af50454cf2 9521:8054d9d775fd
    20 
    20 
    21 unit uAIAmmoTests;
    21 unit uAIAmmoTests;
    22 interface
    22 interface
    23 uses uConsts, uFloat, uTypes, uAIMisc;
    23 uses uConsts, uFloat, uTypes, uAIMisc;
    24 const
    24 const
    25     amtest_Rare     = $00000001; // check only several positions
    25     amtest_Rare            = $00000001; // check only several positions
    26     amtest_NoTarget = $00000002; // each pos, but no targetting
    26     amtest_NoTarget        = $00000002; // each pos, but no targetting
       
    27     amtest_MultipleAttacks = $00000004; // test could result in multiple attacks, set AttacksNum
    27 
    28 
    28 var windSpeed: real;
    29 var windSpeed: real;
    29 
    30 
    30 type TAttackParams = record
    31 type TAttackParams = record
    31         Time: Longword;
    32         Time, AttacksNum: Longword;
    32         Angle, Power: LongInt;
    33         Angle, Power: LongInt;
    33         ExplX, ExplY, ExplR: LongInt;
    34         ExplX, ExplY, ExplR: LongInt;
    34         AttackPutX, AttackPutY: LongInt;
    35         AttackPutX, AttackPutY: LongInt;
    35         end;
    36         end;
    36 
    37 
    70             (proc: @TestShotgun;     flags: 0), // amShotgun
    71             (proc: @TestShotgun;     flags: 0), // amShotgun
    71             (proc: nil;              flags: 0), // amPickHammer
    72             (proc: nil;              flags: 0), // amPickHammer
    72             (proc: nil;              flags: 0), // amSkip
    73             (proc: nil;              flags: 0), // amSkip
    73             (proc: nil;              flags: 0), // amRope
    74             (proc: nil;              flags: 0), // amRope
    74             (proc: nil;              flags: 0), // amMine
    75             (proc: nil;              flags: 0), // amMine
    75             (proc: @TestDesertEagle; flags: 0), // amDEagle
    76             (proc: @TestDesertEagle; flags: amtest_MultipleAttacks), // amDEagle
    76             (proc: nil;              flags: 0), // amDynamite
    77             (proc: nil;              flags: 0), // amDynamite
    77             (proc: @TestFirePunch;   flags: amtest_NoTarget), // amFirePunch
    78             (proc: @TestFirePunch;   flags: amtest_NoTarget), // amFirePunch
    78             (proc: @TestWhip;        flags: amtest_NoTarget), // amWhip
    79             (proc: @TestWhip;        flags: amtest_NoTarget), // amWhip
    79             (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat
    80             (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat
    80             (proc: nil;              flags: 0), // amParachute
    81             (proc: nil;              flags: 0), // amParachute
   713     or (trunc(x) > LAND_WIDTH)
   714     or (trunc(x) > LAND_WIDTH)
   714     or (trunc(y) > LAND_HEIGHT)
   715     or (trunc(y) > LAND_HEIGHT)
   715     or (d > 48);
   716     or (d > 48);
   716 
   717 
   717 if Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) < 5 then
   718 if Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) < 5 then
   718      valueResult:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, 7, 20, vX*0.125, vY*0.125, afTrackFall)
   719     begin
   719 else valueResult:= BadTurn;
   720     ap.AttacksNum:= 1 + (d + 8) div 12;
       
   721     valueResult:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, 7, 20, vX*0.125, vY*0.125, afTrackFall) - ap.AttacksNum
       
   722     end
       
   723 else
       
   724     valueResult:= BadTurn;
       
   725 
   720 TestDesertEagle:= valueResult
   726 TestDesertEagle:= valueResult
   721 end;
   727 end;
   722 
   728 
   723 
   729 
   724 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   730 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;