hedgewars/uAIAmmoTests.pas
branchui-scaling
changeset 15288 c4fd2813b127
parent 14591 e54e41554529
child 15371 381c828865e7
equal deleted inserted replaced
13395:0135e64c6c66 15288:c4fd2813b127
   117             (proc: @TestHammer;      flags: amtest_NoTarget), // amHammer
   117             (proc: @TestHammer;      flags: amtest_NoTarget), // amHammer
   118             (proc: nil;              flags: 0), // amResurrector
   118             (proc: nil;              flags: 0), // amResurrector
   119             (proc: nil;              flags: 0), // amDrillStrike
   119             (proc: nil;              flags: 0), // amDrillStrike
   120             (proc: nil;              flags: 0), // amSnowball
   120             (proc: nil;              flags: 0), // amSnowball
   121             (proc: nil;              flags: 0), // amTardis
   121             (proc: nil;              flags: 0), // amTardis
   122             //(proc: nil;              flags: 0), // amStructure
       
   123             (proc: nil;              flags: 0), // amLandGun
   122             (proc: nil;              flags: 0), // amLandGun
   124             (proc: nil;              flags: 0), // amIceGun
   123             (proc: nil;              flags: 0), // amIceGun
   125             (proc: nil;              flags: 0), // amKnife
   124             (proc: nil;              flags: 0), // amKnife
   126             (proc: nil;              flags: 0), // amRubber
   125             (proc: nil;              flags: 0), // amRubber
   127             (proc: nil;              flags: 0), // amAirMine
   126             (proc: nil;              flags: 0), // amAirMine
   128             (proc: nil;              flags: 0), // amDuck
   127             (proc: nil;              flags: 0), // amCreeper
   129             (proc: @TestShotgun;     flags: 0)  // amMinigun
   128             (proc: @TestShotgun;     flags: 0)  // amMinigun
   130             );
   129             );
   131 
   130 
   132 implementation
   131 implementation
   133 uses uVariables, uUtils, uGearsHandlers;
   132 uses uVariables, uUtils, uGearsHandlers;
   136 begin
   135 begin
   137 Metric:= abs(x1 - x2) + abs(y1 - y2)
   136 Metric:= abs(x1 - x2) + abs(y1 - y2)
   138 end;
   137 end;
   139 
   138 
   140 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   139 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
       
   140 const cExtraTime = 300;
   141 var Vx, Vy, r, mX, mY: real;
   141 var Vx, Vy, r, mX, mY: real;
   142     rTime: LongInt;
   142     rTime: LongInt;
   143     EX, EY: LongInt;
   143     EX, EY: LongInt;
   144     valueResult: LongInt;
   144     valueResult: LongInt;
   145     x, y, dX, dY: real;
   145     targXWrap, x, y, dX, dY: real;
   146     t: LongInt;
   146     t: LongInt;
   147     value: LongInt;
   147     value: LongInt;
   148 begin
   148 begin
   149 mX:= hwFloat2Float(Me^.X);
   149 mX:= hwFloat2Float(Me^.X);
   150 mY:= hwFloat2Float(Me^.Y);
   150 mY:= hwFloat2Float(Me^.Y);
   151 ap.Time:= 0;
   151 ap.Time:= 0;
   152 rTime:= 350;
   152 rTime:= 350;
   153 ap.ExplR:= 0;
   153 ap.ExplR:= 0;
       
   154 if (WorldEdge = weWrap) then
       
   155     if (Targ.Point.X < mX) then
       
   156          targXWrap:= Targ.Point.X + (RightX-LeftX)
       
   157     else targXWrap:= Targ.Point.X - (RightX-LeftX);
   154 valueResult:= BadTurn;
   158 valueResult:= BadTurn;
   155 repeat
   159 repeat
   156     rTime:= rTime + 300 + Level * 50 + random(300);
   160     rTime:= rTime + 300 + Level * 50 + random(300);
   157     Vx:= - windSpeed * rTime * 0.5 + (Targ.Point.X + AIrndSign(2) - mX) / rTime;
   161     if (WorldEdge = weWrap) and (random(2)=0) then
       
   162          Vx:= - windSpeed * rTime * 0.5 + (targXWrap + AIrndSign(2) + AIrndOffset(Targ, Level) - mX) / rTime
       
   163     else Vx:= - windSpeed * rTime * 0.5 + (Targ.Point.X + AIrndSign(2) + AIrndOffset(Targ, Level) - mX) / rTime;
   158     Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y + 1 - mY) / rTime;
   164     Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y + 1 - mY) / rTime;
   159     r:= sqr(Vx) + sqr(Vy);
   165     r:= sqr(Vx) + sqr(Vy);
   160     if not (r > 1) then
   166     if not (r > 1) then
   161         begin
   167         begin
   162         x:= mX;
   168         x:= mX;
   163         y:= mY;
   169         y:= mY;
   164         dX:= Vx;
   170         dX:= Vx;
   165         dY:= -Vy;
   171         dY:= -Vy;
   166         t:= rTime;
   172         t:= rTime;
   167         repeat
   173         repeat
       
   174             x:= CheckWrap(x);
   168             x:= x + dX;
   175             x:= x + dX;
       
   176 
   169             y:= y + dY;
   177             y:= y + dY;
   170             dX:= dX + windSpeed;
   178             dX:= dX + windSpeed;
       
   179             //dX:= CheckBounce(x,dX);
   171             dY:= dY + cGravityf;
   180             dY:= dY + cGravityf;
   172             dec(t)
   181             dec(t)
   173         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   182         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   174                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t <= 0);
   183                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t < -cExtraTime);
   175 
   184 
   176         EX:= trunc(x);
   185         EX:= trunc(x);
   177         EY:= trunc(y);
   186         EY:= trunc(y);
   178         if Level = 1 then
   187         if t >= -cExtraTime then
   179             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   188             begin
   180         else value:= RateExplosion(Me, EX, EY, 101);
   189                 if Level = 1 then
       
   190                     value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
       
   191                 else
       
   192                     value:= RateExplosion(Me, EX, EY, 101);
       
   193             end else
       
   194                 value:= BadTurn;
       
   195 
   181         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   196         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   182             if GameFlags and gfSolidLand = 0 then
   197             if GameFlags and gfSolidLand = 0 then
   183                  value := 1024 - Metric(Targ.Point.X, Targ.Point.Y, EX, EY) div 64
   198                  value := 1024 - Metric(Targ.Point.X, Targ.Point.Y, EX, EY) div 64
   184             else value := BadTurn;
   199             else value := BadTurn;
   185         if valueResult <= value then
   200 
       
   201         if (valueResult < value) or ((valueResult = value) and (Level < 3)) then
   186             begin
   202             begin
   187             ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   203             ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   188             ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   204             ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   189             ap.ExplR:= 100;
   205             ap.ExplR:= 100;
   190             ap.ExplX:= EX;
   206             ap.ExplX:= EX;
   191             ap.ExplY:= EY;
   207             ap.ExplY:= EY;
   192             valueResult:= value
   208             valueResult:= value
   193             end;
   209             end;
   194         end
   210         end
   195 //until (value > 204800) or (rTime > 4250); not so useful since adding score to the drowning
       
   196 until rTime > 5050 - Level * 800;
   211 until rTime > 5050 - Level * 800;
   197 TestBazooka:= valueResult
   212 TestBazooka:= valueResult
   198 end;
   213 end;
   199 
   214 
   200 function calcBeeFlight(Me: PGear; x, y, dx, dy, tX, tY: real; var eX, eY: LongInt): LongInt;
   215 function calcBeeFlight(Me: PGear; x, y, dx, dy, tX, tY: real; var eX, eY: LongInt): LongInt;
   308 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   323 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   309 var Vx, Vy, r, mX, mY: real;
   324 var Vx, Vy, r, mX, mY: real;
   310     rTime: LongInt;
   325     rTime: LongInt;
   311     EX, EY: LongInt;
   326     EX, EY: LongInt;
   312     valueResult: LongInt;
   327     valueResult: LongInt;
   313     x, y, dX, dY: real;
   328     targXWrap, x, y, dX, dY: real;
   314     t: LongInt;
   329     t: LongInt;
   315     value: LongInt;
   330     value: LongInt;
   316     t2: real;
   331     t2: real;
   317     timer: Longint;
   332     timer: Longint;
   318 begin
   333 begin
   322     mY:= hwFloat2Float(Me^.Y);
   337     mY:= hwFloat2Float(Me^.Y);
   323     ap.Time:= 0;
   338     ap.Time:= 0;
   324     rTime:= 350;
   339     rTime:= 350;
   325     ap.ExplR:= 0;
   340     ap.ExplR:= 0;
   326     valueResult:= BadTurn;
   341     valueResult:= BadTurn;
       
   342     if (WorldEdge = weWrap) then
       
   343         if (Targ.Point.X < mX) then
       
   344              targXWrap:= Targ.Point.X + (RightX-LeftX)
       
   345         else targXWrap:= Targ.Point.X - (RightX-LeftX);
   327     timer:= 0;
   346     timer:= 0;
   328     repeat
   347     repeat
   329         rTime:= rTime + 300 + Level * 50 + random(300);
   348         rTime:= rTime + 300 + Level * 50 + random(300);
   330         Vx:= - windSpeed * rTime * 0.5 + (Targ.Point.X + AIrndSign(2) - mX) / rTime;
   349         if (WorldEdge = weWrap) and (random(2)=0) then
       
   350              Vx:= - windSpeed * rTime * 0.5 + (targXWrap + AIrndSign(2) - mX) / rTime
       
   351         else Vx:= - windSpeed * rTime * 0.5 + (Targ.Point.X + AIrndSign(2) - mX) / rTime;
   331         Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y - 35 - mY) / rTime;
   352         Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y - 35 - mY) / rTime;
   332         r:= sqr(Vx) + sqr(Vy);
   353         r:= sqr(Vx) + sqr(Vy);
   333         if not (r > 1) then
   354         if not (r > 1) then
   334             begin
   355             begin
   335             x:= mX;
   356             x:= mX;
   336             y:= mY;
   357             y:= mY;
   337             dX:= Vx;
   358             dX:= Vx;
   338             dY:= -Vy;
   359             dY:= -Vy;
   339             t:= rTime;
   360             t:= rTime;
   340             repeat
   361             repeat
       
   362                 x:= CheckWrap(x);
   341                 x:= x + dX;
   363                 x:= x + dX;
   342                 y:= y + dY;
   364                 y:= y + dY;
   343                 dX:= dX + windSpeed;
   365                 dX:= dX + windSpeed;
   344                 dY:= dY + cGravityf;
   366                 dY:= dY + cGravityf;
   345                 dec(t)
   367                 dec(t)
   389 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   411 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   390 var Vx, Vy, r: real;
   412 var Vx, Vy, r: real;
   391     rTime: LongInt;
   413     rTime: LongInt;
   392     EX, EY: LongInt;
   414     EX, EY: LongInt;
   393     valueResult: LongInt;
   415     valueResult: LongInt;
   394     x, y, dX, dY, meX, meY: real;
   416     targXWrap, x, y, dX, dY, meX, meY: real;
   395     t: LongInt;
   417     t: LongInt;
   396     value: LongInt;
   418     value: LongInt;
   397 
   419 
   398 begin
   420 begin
   399 meX:= hwFloat2Float(Me^.X);
   421 meX:= hwFloat2Float(Me^.X);
   400 meY:= hwFloat2Float(Me^.Y);
   422 meY:= hwFloat2Float(Me^.Y);
   401 ap.Time:= 0;
   423 ap.Time:= 0;
   402 rTime:= 350;
   424 rTime:= 350;
   403 ap.ExplR:= 0;
   425 ap.ExplR:= 0;
   404 valueResult:= BadTurn;
   426 valueResult:= BadTurn;
       
   427 if (WorldEdge = weWrap) then
       
   428     if (Targ.Point.X < meX) then
       
   429          targXWrap:= Targ.Point.X + (RightX-LeftX)
       
   430     else targXWrap:= Targ.Point.X - (RightX-LeftX);
   405 repeat
   431 repeat
   406     rTime:= rTime + 300 + Level * 50 + random(1000);
   432     rTime:= rTime + 300 + Level * 50 + random(1000);
   407     Vx:= - windSpeed * rTime * 0.5 + ((Targ.Point.X + AIrndSign(2)) - meX) / rTime;
   433     if (WorldEdge = weWrap) and (random(2)=0) then
       
   434          Vx:= - windSpeed * rTime * 0.5 + ((targXWrap + AIrndSign(2)) - meX) / rTime
       
   435     else Vx:= - windSpeed * rTime * 0.5 + ((Targ.Point.X + AIrndSign(2)) - meX) / rTime;
   408     Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y - meY) / rTime;
   436     Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y - meY) / rTime;
   409     r:= sqr(Vx) + sqr(Vy);
   437     r:= sqr(Vx) + sqr(Vy);
   410     if not (r > 1) then
   438     if not (r > 1) then
   411         begin
   439         begin
   412         x:= meX;
   440         x:= meX;
   413         y:= meY;
   441         y:= meY;
   414         dX:= Vx;
   442         dX:= Vx;
   415         dY:= -Vy;
   443         dY:= -Vy;
   416         t:= rTime;
   444         t:= rTime;
   417         repeat
   445         repeat
       
   446             x:= CheckWrap(x);
   418             x:= x + dX;
   447             x:= x + dX;
   419             y:= y + dY;
   448             y:= y + dY;
   420             dX:= dX + windSpeed;
   449             dX:= dX + windSpeed;
   421             dY:= dY + cGravityf;
   450             dY:= dY + cGravityf;
   422             dec(t)
   451             dec(t)
   446 
   475 
   447 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   476 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   448 var Vx, Vy, r: real;
   477 var Vx, Vy, r: real;
   449     Score, EX, EY, valueResult: LongInt;
   478     Score, EX, EY, valueResult: LongInt;
   450     TestTime: LongInt;
   479     TestTime: LongInt;
   451     x, y, dY, meX, meY: real;
   480     targXWrap, x, y, dY, meX, meY: real;
   452     t: LongInt;
   481     t: LongInt;
   453 begin
   482 begin
   454 meX:= hwFloat2Float(Me^.X);
   483 meX:= hwFloat2Float(Me^.X);
   455 meY:= hwFloat2Float(Me^.Y);
   484 meY:= hwFloat2Float(Me^.Y);
   456 valueResult:= BadTurn;
   485 valueResult:= BadTurn;
   457 TestTime:= 0;
   486 TestTime:= 0;
   458 ap.ExplR:= 0;
   487 ap.ExplR:= 0;
       
   488 if (WorldEdge = weWrap) then
       
   489     if (Targ.Point.X < meX) then
       
   490          targXWrap:= Targ.Point.X + (RightX-LeftX)
       
   491     else targXWrap:= Targ.Point.X - (RightX-LeftX);
   459 repeat
   492 repeat
   460     inc(TestTime, 300);
   493     inc(TestTime, 300);
   461     Vx:= (Targ.Point.X - meX) / TestTime;
   494     if (WorldEdge = weWrap) and (random(2)=0) then
       
   495          Vx:= (targXWrap - meX) / TestTime
       
   496     else Vx:= (Targ.Point.X - meX) / TestTime;
   462     Vy:= cGravityf * (TestTime div 2) - Targ.Point.Y - meY / TestTime;
   497     Vy:= cGravityf * (TestTime div 2) - Targ.Point.Y - meY / TestTime;
   463     r:= sqr(Vx) + sqr(Vy);
   498     r:= sqr(Vx) + sqr(Vy);
   464     if not (r > 1) then
   499     if not (r > 1) then
   465         begin
   500         begin
   466         x:= meX;
   501         x:= meX;
   467         y:= meY;
   502         y:= meY;
   468         dY:= -Vy;
   503         dY:= -Vy;
   469         t:= TestTime;
   504         t:= TestTime;
   470         repeat
   505         repeat
       
   506             x:= CheckWrap(x);
   471             x:= x + Vx;
   507             x:= x + Vx;
   472             y:= y + dY;
   508             y:= y + dY;
   473             dY:= dY + cGravityf;
   509             dY:= dY + cGravityf;
   474             dec(t)
   510             dec(t)
   475         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or
   511         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or
   498 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   534 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   499 const tDelta = 24;
   535 const tDelta = 24;
   500 var Vx, Vy, r: real;
   536 var Vx, Vy, r: real;
   501     Score, EX, EY, valueResult: LongInt;
   537     Score, EX, EY, valueResult: LongInt;
   502     TestTime: LongInt;
   538     TestTime: LongInt;
   503     x, y, meX, meY, dY: real;
   539     targXWrap, x, y, meX, meY, dY: real;
   504     t: LongInt;
   540     t: LongInt;
   505 begin
   541 begin
   506 valueResult:= BadTurn;
   542 valueResult:= BadTurn;
   507 TestTime:= 0;
   543 TestTime:= 0;
   508 ap.ExplR:= 0;
   544 ap.ExplR:= 0;
   509 meX:= hwFloat2Float(Me^.X);
   545 meX:= hwFloat2Float(Me^.X);
   510 meY:= hwFloat2Float(Me^.Y);
   546 meY:= hwFloat2Float(Me^.Y);
       
   547 if (WorldEdge = weWrap) then
       
   548     if (Targ.Point.X < meX) then
       
   549          targXWrap:= Targ.Point.X + (RightX-LeftX)
       
   550     else targXWrap:= Targ.Point.X - (RightX-LeftX);
   511 repeat
   551 repeat
   512     inc(TestTime, 1000);
   552     inc(TestTime, 1000);
   513     Vx:= (Targ.Point.X - meX) / (TestTime + tDelta);
   553     if (WorldEdge = weWrap) and (random(2)=0) then
       
   554          Vx:= (targXWrap + AIrndOffset(Targ, Level) - meX) / (TestTime + tDelta)
       
   555     else Vx:= (Targ.Point.X + AIrndOffset(Targ, Level) - meX) / (TestTime + tDelta);
   514     Vy:= cGravityf * ((TestTime + tDelta) div 2) - (Targ.Point.Y - meY) / (TestTime + tDelta);
   556     Vy:= cGravityf * ((TestTime + tDelta) div 2) - (Targ.Point.Y - meY) / (TestTime + tDelta);
   515     r:= sqr(Vx) + sqr(Vy);
   557     r:= sqr(Vx) + sqr(Vy);
   516     if not (r > 1) then
   558     if not (r > 1) then
   517         begin
   559         begin
   518         x:= meX;
   560         x:= meX;
   519         y:= meY;
   561         y:= meY;
   520         dY:= -Vy;
   562         dY:= -Vy;
   521         t:= TestTime;
   563         t:= TestTime;
   522         repeat
   564         repeat
       
   565             x:= CheckWrap(x);
   523             x:= x + Vx;
   566             x:= x + Vx;
   524             y:= y + dY;
   567             y:= y + dY;
   525             dY:= dY + cGravityf;
   568             dY:= dY + cGravityf;
   526             dec(t)
   569             dec(t)
   527         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   570         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   611 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   654 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
   612 const tDelta = 24;
   655 const tDelta = 24;
   613 var Vx, Vy, r: real;
   656 var Vx, Vy, r: real;
   614     Score, EX, EY, valueResult: LongInt;
   657     Score, EX, EY, valueResult: LongInt;
   615     TestTime: Longword;
   658     TestTime: Longword;
   616     x, y, dY, meX, meY: real;
   659     targXWrap, x, y, dY, meX, meY: real;
   617     t: LongInt;
   660     t: LongInt;
   618 begin
   661 begin
   619 valueResult:= BadTurn;
   662 valueResult:= BadTurn;
   620 TestTime:= 500;
   663 TestTime:= 500;
   621 ap.ExplR:= 0;
   664 ap.ExplR:= 0;
   622 meX:= hwFloat2Float(Me^.X);
   665 meX:= hwFloat2Float(Me^.X);
   623 meY:= hwFloat2Float(Me^.Y);
   666 meY:= hwFloat2Float(Me^.Y);
       
   667 if (WorldEdge = weWrap) then
       
   668     if (Targ.Point.X < meX) then
       
   669          targXWrap:= Targ.Point.X + (RightX-LeftX)
       
   670     else targXWrap:= Targ.Point.X - (RightX-LeftX);
   624 repeat
   671 repeat
   625     inc(TestTime, 900);
   672     inc(TestTime, 900);
   626     Vx:= (Targ.Point.X - meX) / (TestTime + tDelta);
   673     if (WorldEdge = weWrap) and (random(2)=0) then
       
   674 		 Vx:= (targXWrap - meX) / (TestTime + tDelta)
       
   675     else Vx:= (Targ.Point.X - meX) / (TestTime + tDelta);
   627     Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Point.Y-50) - meY) / (TestTime + tDelta);
   676     Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Point.Y-50) - meY) / (TestTime + tDelta);
   628     r:= sqr(Vx)+sqr(Vy);
   677     r:= sqr(Vx)+sqr(Vy);
   629     if not (r > 1) then
   678     if not (r > 1) then
   630         begin
   679         begin
   631         x:= meX;
   680         x:= meX;
   632         y:= meY;
   681         y:= meY;
   633         dY:= -Vy;
   682         dY:= -Vy;
   634         t:= TestTime;
   683         t:= TestTime;
   635         repeat
   684         repeat
       
   685             x:= CheckWrap(x);
   636             x:= x + Vx;
   686             x:= x + Vx;
   637             y:= y + dY;
   687             y:= y + dY;
   638             dY:= dY + cGravityf;
   688             dY:= dY + cGravityf;
   639             dec(t)
   689             dec(t)
   640        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or
   690        until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or
  1083     y:= hwFloat2Float(Me^.Y);
  1133     y:= hwFloat2Float(Me^.Y);
  1084     d:= sqrt(sqr(Targ.Point.X - x) + sqr(Targ.Point.Y - y));
  1134     d:= sqrt(sqr(Targ.Point.X - x) + sqr(Targ.Point.Y - y));
  1085     if d < 10 then
  1135     if d < 10 then
  1086         begin
  1136         begin
  1087         dx:= 0;
  1137         dx:= 0;
  1088         dy:= 8;
  1138         dy:= step;
  1089         ap.Angle:= 2048
  1139         ap.Angle:= 2048
  1090         end
  1140         end
  1091     else
  1141     else
  1092         begin
  1142         begin
  1093         t:= step / d;
  1143         t:= step / d;
  1097         ap.Angle:= DxDy2AttackAnglef(dx, -dy)
  1147         ap.Angle:= DxDy2AttackAnglef(dx, -dy)
  1098         end;
  1148         end;
  1099 
  1149 
  1100     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
  1150     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
  1101 
  1151 
  1102     for i:= 0 to 512 div step - 2 do
  1152     for i:= 1 to 512 div step - 2 do
  1103         begin
  1153         begin
       
  1154         x:= x + dx;
       
  1155         y:= y + dy;
       
  1156 
  1104         valueResult:= valueResult +
  1157         valueResult:= valueResult +
  1105             RateShove(Me, trunc(x), trunc(y)
  1158             RateShove(Me, trunc(x), trunc(y)
  1106                 , 30, 30, 25
  1159                 , 30, 30, 25
  1107                 , cx, -0.9, trackFall or afSetSkip);
  1160                 , cx, -0.9, trackFall or afSetSkip);
  1108 
  1161         end;
  1109         x:= x + dx;
  1162 
  1110         y:= y + dy;
  1163     if (d < 10) and (dx = 0) then
  1111         end;
       
  1112     if dx = 0 then
       
  1113         begin
  1164         begin
  1114         x:= hwFloat2Float(Me^.X);
  1165         x:= hwFloat2Float(Me^.X);
  1115         y:= hwFloat2Float(Me^.Y);
  1166         y:= hwFloat2Float(Me^.Y);
  1116         tx:= trunc(x);
  1167         tx:= trunc(x);
  1117         v:= RateShove(Me, tx, trunc(y)
  1168         v:= RateShove(Me, tx, trunc(y)
  1124                 RateShove(Me, tx, trunc(y)
  1175                 RateShove(Me, tx, trunc(y)
  1125                     , 30, 30, 25
  1176                     , 30, 30, 25
  1126                     , -cx, -0.9, trackFall or afSetSkip);
  1177                     , -cx, -0.9, trackFall or afSetSkip);
  1127             end
  1178             end
  1128         end;
  1179         end;
       
  1180 
  1129     if v > valueResult then
  1181     if v > valueResult then
  1130         begin
  1182     begin
       
  1183         cx:= -cx;
  1131         ap.Angle:= -2048;
  1184         ap.Angle:= -2048;
  1132         valueResult:= v
  1185         valueResult:= v
  1133         end;
  1186         end;
  1134 
  1187 
  1135     v:= RateShove(Me, trunc(x), trunc(y)
  1188     v:= RateShove(Me, trunc(x), trunc(y)
  1207                 // 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets)
  1260                 // 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets)
  1208                 end
  1261                 end
  1209             end;
  1262             end;
  1210 until fexit or (Y > cWaterLine);
  1263 until fexit or (Y > cWaterLine);
  1211 
  1264 
  1212 for i:= 0 to 5 do inc(valueResult, dmg[i]);
  1265 for i:= 0 to 5 do
       
  1266     if dmg[i] <> BadTurn then
       
  1267         inc(valueResult, dmg[i]);
  1213 t:= valueResult;
  1268 t:= valueResult;
  1214 ap.AttackPutX:= Targ.Point.X - 60;
  1269 ap.AttackPutX:= Targ.Point.X - 60;
  1215 
  1270 
  1216 for i:= 0 to 3 do
  1271 for i:= 0 to 3 do
  1217     begin
  1272     if dmg[i] <> BadTurn then
  1218     dec(t, dmg[i]);
  1273         begin
  1219     inc(t, dmg[i + 6]);
  1274         dec(t, dmg[i]);
  1220     if t > valueResult then
  1275         inc(t, dmg[i + 6]);
  1221         begin
  1276         if t > valueResult then
  1222         valueResult:= t;
  1277             begin
  1223         ap.AttackPutX:= Targ.Point.X - 30 - cShift + i * 30
  1278             valueResult:= t;
  1224         end
  1279             ap.AttackPutX:= Targ.Point.X - 30 - cShift + i * 30
  1225     end;
  1280             end
       
  1281         end;
  1226 
  1282 
  1227 if valueResult <= 0 then
  1283 if valueResult <= 0 then
  1228     valueResult:= BadTurn;
  1284     valueResult:= BadTurn;
  1229 TestAirAttack:= valueResult;
  1285 TestAirAttack:= valueResult;
  1230 end;
  1286 end;
  1307     ap.Time:= 0;
  1363     ap.Time:= 0;
  1308     ap.Power:= BadTurn; // use it as max score value in checkCakeWalk
  1364     ap.Power:= BadTurn; // use it as max score value in checkCakeWalk
  1309 
  1365 
  1310     //FillChar(cake, sizeof(cake), 0);
  1366     //FillChar(cake, sizeof(cake), 0);
  1311     cake.Radius:= 7;
  1367     cake.Radius:= 7;
  1312     cake.CollisionMask:= lfNotCurrentMask;
  1368     cake.CollisionMask:= lfNotCurHogCrate;
  1313     cake.Hedgehog:= Me^.Hedgehog;
  1369     cake.Hedgehog:= Me^.Hedgehog;
  1314 
  1370 
  1315     // check left direction
  1371     // check left direction
  1316     cake.Angle:= 3;
  1372     cake.Angle:= 3;
  1317     cake.dX.isNegative:= true;
  1373     cake.dX.isNegative:= true;