hedgewars/uAIAmmoTests.pas
changeset 15546 fbcee515b946
parent 15387 381c828865e7
child 15623 7d3877231b00
equal deleted inserted replaced
15545:f4f6060b536c 15546:fbcee515b946
    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     amtest_MultipleAttacks = $00000004; // test could result in multiple attacks, set AttacksNum
       
    28     amtest_NoTrackFall     = $00000008; // skip fall tracing.  
    28 
    29 
    29 var windSpeed: real;
    30 var windSpeed: real;
    30 
    31 
    31 type TAttackParams = record
    32 type TAttackParams = record
    32         Time, AttacksNum: Longword;
    33         Time, AttacksNum: Longword;
    33         Angle, Power: LongInt;
    34         Angle, Power: LongInt;
    34         ExplX, ExplY, ExplR: LongInt;
    35         ExplX, ExplY, ExplR: LongInt;
    35         AttackPutX, AttackPutY: LongInt;
    36         AttackPutX, AttackPutY: LongInt;
    36         end;
    37         end;
    37 
    38 
    38 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    39 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    39 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    40 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    40 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    41 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    41 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    42 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    42 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    43 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    43 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    44 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    44 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    45 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    45 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    46 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    46 function TestMortar(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    47 function TestMortar(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    47 function TestShotgun(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    48 function TestShotgun(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    48 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    49 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    49 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    50 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    50 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    51 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    51 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    52 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    52 function TestWhip(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    53 function TestWhip(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    53 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    54 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    54 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    55 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    55 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    56 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    56 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    57 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    57 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    58 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    58 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    59 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    59 
    60 
    60 type TAmmoTestProc = function (Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    61 type TAmmoTestProc = function (Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
    61     TAmmoTest = record
    62     TAmmoTest = record
    62             proc: TAmmoTestProc;
    63             proc: TAmmoTestProc;
    63             flags: Longword;
    64             flags: Longword;
    64             end;
    65             end;
    65 
    66 
   108             (proc: nil;              flags: 0), // amJetpack
   109             (proc: nil;              flags: 0), // amJetpack
   109             (proc: @TestMolotov;     flags: 0), // amMolotov
   110             (proc: @TestMolotov;     flags: 0), // amMolotov
   110             (proc: nil;              flags: 0), // amBirdy
   111             (proc: nil;              flags: 0), // amBirdy
   111             (proc: nil;              flags: 0), // amPortalGun
   112             (proc: nil;              flags: 0), // amPortalGun
   112             (proc: nil;              flags: 0), // amPiano
   113             (proc: nil;              flags: 0), // amPiano
   113             (proc: @TestGrenade;     flags: 0), // amGasBomb
   114             (proc: @TestGrenade;     flags: amtest_NoTrackFall), // amGasBomb
   114             (proc: @TestShotgun;     flags: 0), // amSineGun
   115             (proc: @TestShotgun;     flags: 0), // amSineGun
   115             (proc: nil;              flags: 0), // amFlamethrower
   116             (proc: nil;              flags: 0), // amFlamethrower
   116             (proc: @TestGrenade;     flags: 0), // amSMine
   117             (proc: @TestGrenade;     flags: 0), // amSMine
   117             (proc: @TestHammer;      flags: amtest_NoTarget), // amHammer
   118             (proc: @TestHammer;      flags: amtest_NoTarget), // amHammer
   118             (proc: nil;              flags: 0), // amResurrector
   119             (proc: nil;              flags: 0), // amResurrector
   134 function Metric(x1, y1, x2, y2: LongInt): LongInt; inline;
   135 function Metric(x1, y1, x2, y2: LongInt): LongInt; inline;
   135 begin
   136 begin
   136 Metric:= abs(x1 - x2) + abs(y1 - y2)
   137 Metric:= abs(x1 - x2) + abs(y1 - y2)
   137 end;
   138 end;
   138 
   139 
   139 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   140 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   140 const cExtraTime = 300;
   141 const cExtraTime = 300;
   141 var Vx, Vy, r, mX, mY: real;
   142 var Vx, Vy, r, mX, mY: real;
   142     rTime: LongInt;
   143     rTime: LongInt;
   143     EX, EY: LongInt;
   144     EX, EY: LongInt;
   144     valueResult: LongInt;
   145     valueResult: LongInt;
   145     targXWrap, x, y, dX, dY: real;
   146     targXWrap, x, y, dX, dY: real;
   146     t: LongInt;
   147     t: LongInt;
   147     value: LongInt;
   148     value: LongInt;
   148 begin
   149 begin
       
   150 Flags:= Flags; // avoid compiler hint
   149 mX:= hwFloat2Float(Me^.X);
   151 mX:= hwFloat2Float(Me^.X);
   150 mY:= hwFloat2Float(Me^.Y);
   152 mY:= hwFloat2Float(Me^.Y);
   151 ap.Time:= 0;
   153 ap.Time:= 0;
   152 rTime:= 350;
   154 rTime:= 350;
   153 ap.ExplR:= 0;
   155 ap.ExplR:= 0;
   265     end
   267     end
   266     else
   268     else
   267         calcBeeFlight:= BadTurn
   269         calcBeeFlight:= BadTurn
   268 end;
   270 end;
   269 
   271 
   270 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   272 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   271 var i, j: LongInt;
   273 var i, j: LongInt;
   272     valueResult, v, a, p: LongInt;
   274     valueResult, v, a, p: LongInt;
   273     mX, mY: real;
   275     mX, mY: real;
   274     eX, eY: LongInt;
   276     eX, eY: LongInt;
   275 begin
   277 begin
       
   278 Flags:= Flags; // avoid compiler hint
   276     if Level > 1 then
   279     if Level > 1 then
   277         exit(BadTurn);
   280         exit(BadTurn);
   278 
   281 
   279     eX:= 0;
   282     eX:= 0;
   280     eY:= 0;
   283     eY:= 0;
   318         TestBee:= valueResult - 5000
   321         TestBee:= valueResult - 5000
   319     else
   322     else
   320         TestBee:= BadTurn // no digging
   323         TestBee:= BadTurn // no digging
   321 end;
   324 end;
   322 
   325 
   323 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   326 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   324 var Vx, Vy, r, mX, mY: real;
   327 var Vx, Vy, r, mX, mY: real;
   325     rTime: LongInt;
   328     rTime: LongInt;
   326     EX, EY: LongInt;
   329     EX, EY: LongInt;
   327     valueResult: LongInt;
   330     valueResult: LongInt;
   328     targXWrap, x, y, dX, dY: real;
   331     targXWrap, x, y, dX, dY: real;
   329     t: LongInt;
   332     t: LongInt;
   330     value: LongInt;
   333     value: LongInt;
   331     t2: real;
   334     t2: real;
   332     timer: Longint;
   335     timer: Longint;
   333 begin
   336 begin
       
   337 Flags:= Flags; // avoid compiler hint
   334     if (Level > 3) then exit(BadTurn);
   338     if (Level > 3) then exit(BadTurn);
   335 
   339 
   336     mX:= hwFloat2Float(Me^.X);
   340     mX:= hwFloat2Float(Me^.X);
   337     mY:= hwFloat2Float(Me^.Y);
   341     mY:= hwFloat2Float(Me^.Y);
   338     ap.Time:= 0;
   342     ap.Time:= 0;
   406     until rTime > 5050 - Level * 800;
   410     until rTime > 5050 - Level * 800;
   407     TestDrillRocket:= valueResult
   411     TestDrillRocket:= valueResult
   408 end;
   412 end;
   409 
   413 
   410 
   414 
   411 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   415 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   412 var Vx, Vy, r: real;
   416 var Vx, Vy, r: real;
   413     rTime: LongInt;
   417     rTime: LongInt;
   414     EX, EY: LongInt;
   418     EX, EY: LongInt;
   415     valueResult: LongInt;
   419     valueResult: LongInt;
   416     targXWrap, x, y, dX, dY, meX, meY: real;
   420     targXWrap, x, y, dX, dY, meX, meY: real;
   417     t: LongInt;
   421     t: LongInt;
   418     value: LongInt;
   422     value: LongInt;
   419 
   423 
   420 begin
   424 begin
       
   425 Flags:= Flags; // avoid compiler hint
   421 meX:= hwFloat2Float(Me^.X);
   426 meX:= hwFloat2Float(Me^.X);
   422 meY:= hwFloat2Float(Me^.Y);
   427 meY:= hwFloat2Float(Me^.Y);
   423 ap.Time:= 0;
   428 ap.Time:= 0;
   424 rTime:= 350;
   429 rTime:= 350;
   425 ap.ExplR:= 0;
   430 ap.ExplR:= 0;
   471      end
   476      end
   472 until (rTime > 5050 - Level * 800);
   477 until (rTime > 5050 - Level * 800);
   473 TestSnowball:= valueResult
   478 TestSnowball:= valueResult
   474 end;
   479 end;
   475 
   480 
   476 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   481 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   477 var Vx, Vy, r: real;
   482 var Vx, Vy, r: real;
   478     Score, EX, EY, valueResult: LongInt;
   483     Score, EX, EY, valueResult: LongInt;
   479     TestTime: LongInt;
   484     TestTime: LongInt;
   480     targXWrap, x, y, dY, meX, meY: real;
   485     targXWrap, x, y, dY, meX, meY: real;
   481     t: LongInt;
   486     t: LongInt;
   482 begin
   487 begin
       
   488 Flags:= Flags; // avoid compiler hint
   483 meX:= hwFloat2Float(Me^.X);
   489 meX:= hwFloat2Float(Me^.X);
   484 meY:= hwFloat2Float(Me^.Y);
   490 meY:= hwFloat2Float(Me^.Y);
   485 valueResult:= BadTurn;
   491 valueResult:= BadTurn;
   486 TestTime:= 0;
   492 TestTime:= 0;
   487 ap.ExplR:= 0;
   493 ap.ExplR:= 0;
   529         end
   535         end
   530 until (TestTime > 5050 - Level * 800);
   536 until (TestTime > 5050 - Level * 800);
   531 TestMolotov:= valueResult
   537 TestMolotov:= valueResult
   532 end;
   538 end;
   533 
   539 
   534 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   540 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   535 const tDelta = 24;
   541 const tDelta = 24;
   536 var Vx, Vy, r: real;
   542 var Vx, Vy, r: real;
   537     Score, EX, EY, valueResult: LongInt;
   543     Score, EX, EY, valueResult: LongInt;
   538     TestTime: LongInt;
   544     TestTime: LongInt;
   539     targXWrap, x, y, meX, meY, dY: real;
   545     targXWrap, x, y, meX, meY, dY: real;
   570         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   576         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   571                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t = 0);
   577                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t = 0);
   572     EX:= trunc(x);
   578     EX:= trunc(x);
   573     EY:= trunc(y);
   579     EY:= trunc(y);
   574     if t < 50 then
   580     if t < 50 then
   575         if Level = 1 then
   581         if (Level = 1) and (Flags and amtest_NoTrackFall = 0) then
   576             Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   582             Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   577         else Score:= RateExplosion(Me, EX, EY, 101)
   583         else Score:= RateExplosion(Me, EX, EY, 101)
   578     else
   584     else
   579         Score:= BadTurn;
   585         Score:= BadTurn;
   580 
   586 
   592 //until (Score > 204800) or (TestTime > 4000);
   598 //until (Score > 204800) or (TestTime > 4000);
   593 until TestTime > 4500 - Level * 512;
   599 until TestTime > 4500 - Level * 512;
   594 TestGrenade:= valueResult
   600 TestGrenade:= valueResult
   595 end;
   601 end;
   596 
   602 
   597 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   603 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   598 const tDelta = 24;
   604 const tDelta = 24;
   599 var Vx, Vy, r: real;
   605 var Vx, Vy, r: real;
   600     Score, EX, EY, valueResult: LongInt;
   606     Score, EX, EY, valueResult: LongInt;
   601     TestTime: Longword;
   607     TestTime: Longword;
   602     x, y, dY, meX, meY: real;
   608     x, y, dY, meX, meY: real;
   603     t: LongInt;
   609     t: LongInt;
   604 begin
   610 begin
       
   611 Flags:= Flags; // avoid compiler hint
   605 valueResult:= BadTurn;
   612 valueResult:= BadTurn;
   606 TestTime:= 500;
   613 TestTime:= 500;
   607 ap.ExplR:= 0;
   614 ap.ExplR:= 0;
   608 meX:= hwFloat2Float(Me^.X);
   615 meX:= hwFloat2Float(Me^.X);
   609 meY:= hwFloat2Float(Me^.Y);
   616 meY:= hwFloat2Float(Me^.Y);
   649      end
   656      end
   650 until (TestTime = 4100);
   657 until (TestTime = 4100);
   651 TestClusterBomb:= valueResult
   658 TestClusterBomb:= valueResult
   652 end;
   659 end;
   653 
   660 
   654 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   661 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   655 const tDelta = 24;
   662 const tDelta = 24;
   656 var Vx, Vy, r: real;
   663 var Vx, Vy, r: real;
   657     Score, EX, EY, valueResult: LongInt;
   664     Score, EX, EY, valueResult: LongInt;
   658     TestTime: Longword;
   665     TestTime: Longword;
   659     targXWrap, x, y, dY, meX, meY: real;
   666     targXWrap, x, y, dY, meX, meY: real;
   660     t: LongInt;
   667     t: LongInt;
   661 begin
   668 begin
       
   669 Flags:= Flags; // avoid compiler hint
   662 valueResult:= BadTurn;
   670 valueResult:= BadTurn;
   663 TestTime:= 500;
   671 TestTime:= 500;
   664 ap.ExplR:= 0;
   672 ap.ExplR:= 0;
   665 meX:= hwFloat2Float(Me^.X);
   673 meX:= hwFloat2Float(Me^.X);
   666 meY:= hwFloat2Float(Me^.Y);
   674 meY:= hwFloat2Float(Me^.Y);
   732             end
   740             end
   733             else
   741             else
   734                 Solve:= 0
   742                 Solve:= 0
   735     end;
   743     end;
   736 
   744 
   737 function TestMortar(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   745 function TestMortar(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   738 //const tDelta = 24;
   746 //const tDelta = 24;
   739 var Vx, Vy: real;
   747 var Vx, Vy: real;
   740     Score, EX, EY: LongInt;
   748     Score, EX, EY: LongInt;
   741     TestTime: Longword;
   749     TestTime: Longword;
   742     x, y, dY, meX, meY: real;
   750     x, y, dY, meX, meY: real;
   743 begin
   751 begin
       
   752 Flags:= Flags; // avoid compiler hint
   744     TestMortar:= BadTurn;
   753     TestMortar:= BadTurn;
   745     ap.ExplR:= 0;
   754     ap.ExplR:= 0;
   746 
   755 
   747     meX:= hwFloat2Float(Me^.X);
   756     meX:= hwFloat2Float(Me^.X);
   748     meY:= hwFloat2Float(Me^.Y);
   757     meY:= hwFloat2Float(Me^.Y);
   794         ap.ExplY:= EY;
   803         ap.ExplY:= EY;
   795         TestMortar:= Score
   804         TestMortar:= Score
   796         end;
   805         end;
   797 end;
   806 end;
   798 
   807 
   799 function TestShotgun(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   808 function TestShotgun(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   800 const
   809 const
   801     MIN_RANGE =  80;
   810     MIN_RANGE =  80;
   802     MAX_RANGE = 400;
   811     MAX_RANGE = 400;
   803 var Vx, Vy, x, y: real;
   812 var Vx, Vy, x, y: real;
   804     rx, ry, valueResult: LongInt;
   813     rx, ry, valueResult: LongInt;
   805     range: integer;
   814     range: integer;
   806 begin
   815 begin
       
   816 Flags:= Flags; // avoid compiler hint
   807 TestShotgun:= BadTurn;
   817 TestShotgun:= BadTurn;
   808 ap.ExplR:= 0;
   818 ap.ExplR:= 0;
   809 ap.Time:= 0;
   819 ap.Time:= 0;
   810 ap.Power:= 1;
   820 ap.Power:= 1;
   811 x:= hwFloat2Float(Me^.X);
   821 x:= hwFloat2Float(Me^.X);
   847     or (trunc(y) > LAND_HEIGHT);
   857     or (trunc(y) > LAND_HEIGHT);
   848 
   858 
   849 TestShotgun:= BadTurn
   859 TestShotgun:= BadTurn
   850 end;
   860 end;
   851 
   861 
   852 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   862 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   853 var Vx, Vy, x, y, t: real;
   863 var Vx, Vy, x, y, t: real;
   854     d: Longword;
   864     d: Longword;
   855     ix, iy, valueResult: LongInt;
   865     ix, iy, valueResult: LongInt;
   856 begin
   866 begin
       
   867 Flags:= Flags; // avoid compiler hint
   857 if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn);
   868 if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn);
   858 Level:= Level; // avoid compiler hint
   869 Level:= Level; // avoid compiler hint
   859 ap.ExplR:= 1;
   870 ap.ExplR:= 1;
   860 ap.Time:= 0;
   871 ap.Time:= 0;
   861 ap.Power:= 1;
   872 ap.Power:= 1;
   900 
   911 
   901 TestDesertEagle:= valueResult
   912 TestDesertEagle:= valueResult
   902 end;
   913 end;
   903 
   914 
   904 
   915 
   905 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   916 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   906 var Vx, Vy, x, y, t, dmg: real;
   917 var Vx, Vy, x, y, t, dmg: real;
   907     d: Longword;
   918     d: Longword;
   908     //fallDmg: LongInt;
   919     //fallDmg: LongInt;
   909 begin
   920 begin
       
   921 Flags:= Flags; // avoid compiler hint
   910 if (Level > 3) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn);
   922 if (Level > 3) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn);
   911 Level:= Level; // avoid compiler hint
   923 Level:= Level; // avoid compiler hint
   912 ap.ExplR:= 0;
   924 ap.ExplR:= 0;
   913 ap.Time:= 0;
   925 ap.Time:= 0;
   914 ap.Power:= 1;
   926 ap.Power:= 1;
   942      TestSniperRifle:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, trunc(dmg), 20, vX*0.166, vY*0.166, afTrackFall)
   954      TestSniperRifle:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, trunc(dmg), 20, vX*0.166, vY*0.166, afTrackFall)
   943 else TestSniperRifle:= BadTurn;
   955 else TestSniperRifle:= BadTurn;
   944 end;
   956 end;
   945 
   957 
   946 
   958 
   947 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   959 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
   948 var valueResult, a, v1, v2: LongInt;
   960 var valueResult, a, v1, v2: LongInt;
   949     x, y, trackFall: LongInt;
   961     x, y, trackFall: LongInt;
   950     dx, dy: real;
   962     dx, dy: real;
   951 begin
   963 begin
       
   964 Flags:= Flags; // avoid compiler hint
   952     Targ:= Targ; // avoid compiler hint
   965     Targ:= Targ; // avoid compiler hint
   953 
   966 
   954     if Level < 3 then trackFall:= afTrackFall
   967     if Level < 3 then trackFall:= afTrackFall
   955         else trackFall:= 0;
   968         else trackFall:= 0;
   956 
   969 
   994         valueResult:= BadTurn;
  1007         valueResult:= BadTurn;
   995 
  1008 
   996     TestBaseballBat:= valueResult;
  1009     TestBaseballBat:= valueResult;
   997 end;
  1010 end;
   998 
  1011 
   999 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1012 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1000 var valueResult, v1, v2, i: LongInt;
  1013 var valueResult, v1, v2, i: LongInt;
  1001     x, y, trackFall: LongInt;
  1014     x, y, trackFall: LongInt;
  1002 begin
  1015 begin
       
  1016 Flags:= Flags; // avoid compiler hint
  1003     Targ:= Targ; // avoid compiler hint
  1017     Targ:= Targ; // avoid compiler hint
  1004 
  1018 
  1005     if Level = 1 then trackFall:= afTrackFall
  1019     if Level = 1 then trackFall:= afTrackFall
  1006     else trackFall:= 0;
  1020     else trackFall:= 0;
  1007 
  1021 
  1052 
  1066 
  1053     TestFirePunch:= valueResult;
  1067     TestFirePunch:= valueResult;
  1054 end;
  1068 end;
  1055 
  1069 
  1056 
  1070 
  1057 function TestWhip(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1071 function TestWhip(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1058 var valueResult, v1, v2: LongInt;
  1072 var valueResult, v1, v2: LongInt;
  1059     x, y, trackFall: LongInt;
  1073     x, y, trackFall: LongInt;
  1060 begin
  1074 begin
       
  1075 Flags:= Flags; // avoid compiler hint
  1061     Targ:= Targ; // avoid compiler hint
  1076     Targ:= Targ; // avoid compiler hint
  1062 
  1077 
  1063     if Level = 1 then trackFall:= afTrackFall
  1078     if Level = 1 then trackFall:= afTrackFall
  1064     else trackFall:= 0;
  1079     else trackFall:= 0;
  1065 
  1080 
  1107         inc(valueResult);
  1122         inc(valueResult);
  1108 
  1123 
  1109     TestWhip:= valueResult;
  1124     TestWhip:= valueResult;
  1110 end;
  1125 end;
  1111 
  1126 
  1112 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1127 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1113 const step = 8;
  1128 const step = 8;
  1114 var valueResult, i, v, tx: LongInt;
  1129 var valueResult, i, v, tx: LongInt;
  1115     trackFall: LongInt;
  1130     trackFall: LongInt;
  1116     t, d, x, y, dx, dy, cx: real;
  1131     t, d, x, y, dx, dy, cx: real;
  1117 begin
  1132 begin
       
  1133 Flags:= Flags; // avoid compiler hint
  1118     ap.ExplR:= 0;
  1134     ap.ExplR:= 0;
  1119     ap.Time:= 0;
  1135     ap.Time:= 0;
  1120     ap.Power:= 1;
  1136     ap.Power:= 1;
  1121 
  1137 
  1122     if Level = 1 then
  1138     if Level = 1 then
  1194         inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30));
  1210         inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30));
  1195 
  1211 
  1196     TestKamikaze:= valueResult;
  1212     TestKamikaze:= valueResult;
  1197 end;
  1213 end;
  1198 
  1214 
  1199 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1215 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1200 var rate: LongInt;
  1216 var rate: LongInt;
  1201 begin
  1217 begin
       
  1218 Flags:= Flags; // avoid compiler hint
  1202 Level:= Level; // avoid compiler hint
  1219 Level:= Level; // avoid compiler hint
  1203 Targ:= Targ;
  1220 Targ:= Targ;
  1204 
  1221 
  1205 ap.ExplR:= 0;
  1222 ap.ExplR:= 0;
  1206 ap.Time:= 0;
  1223 ap.Time:= 0;
  1211 if rate = 0 then
  1228 if rate = 0 then
  1212     rate:= BadTurn;
  1229     rate:= BadTurn;
  1213 TestHammer:= rate;
  1230 TestHammer:= rate;
  1214 end;
  1231 end;
  1215 
  1232 
  1216 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1233 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1217 const cShift = 4;
  1234 const cShift = 4;
  1218 var bombsSpeed, X, Y, dY: real;
  1235 var bombsSpeed, X, Y, dY: real;
  1219     b: array[0..9] of boolean;
  1236     b: array[0..9] of boolean;
  1220     dmg: array[0..9] of LongInt;
  1237     dmg: array[0..9] of LongInt;
  1221     fexit: boolean;
  1238     fexit: boolean;
  1222     i, t, valueResult: LongInt;
  1239     i, t, valueResult: LongInt;
  1223 begin
  1240 begin
       
  1241 Flags:= Flags; // avoid compiler hint
  1224 ap.ExplR:= 0;
  1242 ap.ExplR:= 0;
  1225 ap.Time:= 0;
  1243 ap.Time:= 0;
  1226 if (Level > 3) or (cGravityf = 0) then
  1244 if (Level > 3) or (cGravityf = 0) then
  1227     exit(BadTurn);
  1245     exit(BadTurn);
  1228 
  1246 
  1284     valueResult:= BadTurn;
  1302     valueResult:= BadTurn;
  1285 TestAirAttack:= valueResult;
  1303 TestAirAttack:= valueResult;
  1286 end;
  1304 end;
  1287 
  1305 
  1288 
  1306 
  1289 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1307 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1290 var
  1308 var
  1291     i, failNum: longword;
  1309     i, failNum: longword;
  1292     maxTop: longword;
  1310     maxTop: longword;
  1293 begin
  1311 begin
       
  1312 Flags:= Flags; // avoid compiler hint
  1294     TestTeleport := BadTurn;
  1313     TestTeleport := BadTurn;
  1295     exit(BadTurn);
  1314     exit(BadTurn);
  1296     Level:= Level; // avoid compiler hint
  1315     Level:= Level; // avoid compiler hint
  1297     //FillBonuses(true, [gtCase]);
  1316     //FillBonuses(true, [gtCase]);
  1298     if bonuses.Count = 0 then
  1317     if bonuses.Count = 0 then
  1348         ap.Power:= v
  1367         ap.Power:= v
  1349         end
  1368         end
  1350     end;
  1369     end;
  1351 end;
  1370 end;
  1352 
  1371 
  1353 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1372 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1354 var valueResult, v1, v2: LongInt;
  1373 var valueResult, v1, v2: LongInt;
  1355     cake: TGear;
  1374     cake: TGear;
  1356 begin
  1375 begin
       
  1376 Flags:= Flags; // avoid compiler hint
  1357     Targ:= Targ; // avoid compiler hint
  1377     Targ:= Targ; // avoid compiler hint
  1358 
  1378 
  1359     if (Level > 2) then
  1379     if (Level > 2) then
  1360         exit(BadTurn);
  1380         exit(BadTurn);
  1361 
  1381 
  1404         valueResult:= BadTurn;
  1424         valueResult:= BadTurn;
  1405 
  1425 
  1406     TestCake:= valueResult;
  1426     TestCake:= valueResult;
  1407 end;
  1427 end;
  1408 
  1428 
  1409 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
  1429 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt;
  1410 var valueResult: LongInt;
  1430 var valueResult: LongInt;
  1411     x, y, dx, dy: real;
  1431     x, y, dx, dy: real;
  1412     EX, EY, t: LongInt;
  1432     EX, EY, t: LongInt;
  1413 begin
  1433 begin
       
  1434 Flags:= Flags; // avoid compiler hint
  1414 Targ:= Targ; // avoid compiler hint
  1435 Targ:= Targ; // avoid compiler hint
  1415 
  1436 
  1416 x:= hwFloat2Float(Me^.X) + hwSign(Me^.dX) * 7;
  1437 x:= hwFloat2Float(Me^.X) + hwSign(Me^.dX) * 7;
  1417 y:= hwFloat2Float(Me^.Y);
  1438 y:= hwFloat2Float(Me^.Y);
  1418 dx:= hwSign(Me^.dX) * 0.03;
  1439 dx:= hwSign(Me^.dX) * 0.03;