hedgewars/uAIAmmoTests.pas
changeset 7474 bbecb1b4f59b
parent 7471 ce5d3e39361e
child 7486 f3a13da9fa4e
equal deleted inserted replaced
7471:ce5d3e39361e 7474:bbecb1b4f59b
   858     TestWhip:= valueResult;
   858     TestWhip:= valueResult;
   859 end;
   859 end;
   860 
   860 
   861 function TestKamikaze(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   861 function TestKamikaze(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   862 const step = 8;
   862 const step = 8;
   863 var valueResult, i, v: LongInt;
   863 var valueResult, i, v, tx: LongInt;
   864     trackFall: LongInt;
   864     trackFall: LongInt;
   865     t, d, x, y, dx, dy, cx: real;
   865     t, d, x, y, dx, dy, cx: real;
   866 begin
   866 begin
   867     ap.ExplR:= 0;
   867     ap.ExplR:= 0;
   868     ap.Time:= 0;
   868     ap.Time:= 0;
   877         
   877         
   878     valueResult:= 0;
   878     valueResult:= 0;
   879 
   879 
   880     x:= hwFloat2Float(Me^.X);
   880     x:= hwFloat2Float(Me^.X);
   881     y:= hwFloat2Float(Me^.Y);
   881     y:= hwFloat2Float(Me^.Y);
   882     
       
   883     d:= sqrt(sqr(Targ.X - x) + sqr(Targ.Y - y));
   882     d:= sqrt(sqr(Targ.X - x) + sqr(Targ.Y - y));
   884     t:= step / d;
   883     if d = 0 then
   885     dx:= (Targ.X - x) * t;
   884         begin
   886     dy:= (Targ.Y - y) * t;
   885         dx:= 0;
   887 
   886         dy:= 8;
   888     ap.Angle:= DxDy2AttackAnglef(dx, -dy);
   887         ap.Angle:= 2048
       
   888         end
       
   889     else
       
   890         begin
       
   891         t:= step / d;
       
   892         dx:= (Targ.X - x) * t;
       
   893         dy:= (Targ.Y - y) * t;
       
   894 
       
   895         ap.Angle:= DxDy2AttackAnglef(dx, -dy)
       
   896         end;
   889     
   897     
   890     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
   898     if dx >= 0 then cx:= 0.45 else cx:= -0.45;
   891 
   899 
   892     for i:= 0 to 512 div step - 2 do
   900     for i:= 0 to 512 div step - 2 do
   893         begin
   901         begin
   896                 , 30, 30, 25
   904                 , 30, 30, 25
   897                 , cx, -0.9, trackFall or afSetSkip);
   905                 , cx, -0.9, trackFall or afSetSkip);
   898                 
   906                 
   899         x:= x + dx;
   907         x:= x + dx;
   900         y:= y + dy;
   908         y:= y + dy;
       
   909         end;
       
   910     if dx = 0 then
       
   911         begin
       
   912         v:= 0;
       
   913         x:= hwFloat2Float(Me^.X);
       
   914         y:= hwFloat2Float(Me^.Y);
       
   915         tx:= trunc(x);
       
   916         RateShove(Me, tx, trunc(y)
       
   917             , 30, 30, 25
       
   918             , -cx, -0.9, trackFall);
       
   919         for i:= 1 to 512 div step - 2 do
       
   920             begin
       
   921             y:= y + dy;
       
   922             v:= v + 
       
   923                 RateShove(Me, tx, trunc(y)
       
   924                     , 30, 30, 25
       
   925                     , -cx, -0.9, trackFall or afSetSkip);
       
   926             end
       
   927         end;
       
   928     if v > valueResult then
       
   929         begin
       
   930         ap.Angle:= -2048;
       
   931         valueResult:= v
   901         end;
   932         end;
   902         
   933         
   903     v:= RateShove(Me, trunc(x), trunc(y)
   934     v:= RateShove(Me, trunc(x), trunc(y)
   904             , 30, 30, 25
   935             , 30, 30, 25
   905             , cx, -0.9, trackFall);
   936             , cx, -0.9, trackFall);