hedgewars/uAIAmmoTests.pas
changeset 8793 43e106417a05
parent 8751 4609823efc94
child 8822 fc9877ff7f1a
equal deleted inserted replaced
8789:caba5291face 8793:43e106417a05
   195     EX, EY: LongInt;
   195     EX, EY: LongInt;
   196     valueResult: LongInt;
   196     valueResult: LongInt;
   197     x, y, dX, dY: real;
   197     x, y, dX, dY: real;
   198     t: LongInt;
   198     t: LongInt;
   199     value: LongInt;
   199     value: LongInt;
       
   200     t2: real;
       
   201     timer: Longint;
   200 begin
   202 begin
   201     mX:= hwFloat2Float(Me^.X);
   203     mX:= hwFloat2Float(Me^.X);
   202     mY:= hwFloat2Float(Me^.Y);
   204     mY:= hwFloat2Float(Me^.Y);
   203     ap.Time:= 0;
   205     ap.Time:= 0;
   204     rTime:= 350;
   206     rTime:= 350;
   222                 dX:= dX + windSpeed;
   224                 dX:= dX + windSpeed;
   223                 dY:= dY + cGravityf;
   225                 dY:= dY + cGravityf;
   224                 dec(t)
   226                 dec(t)
   225             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   227             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
   226                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
   228                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
   227             
   229 
       
   230             if TestCollWithLand(trunc(x), trunc(y), 5) then
       
   231                 begin
       
   232                 timer := 500;
       
   233                 t2 := 0.5 / sqrt(sqr(dX) + sqr(dY));
       
   234                 dX := dX * t2;
       
   235                 dY := dY * t2;
       
   236                 repeat
       
   237                     x:= x + dX;
       
   238                     y:= y + dY;
       
   239                     dec(timer);
       
   240                 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5)
       
   241                     or (x < 0)
       
   242                     or (y < 0)
       
   243                     or (trunc(x) > LAND_WIDTH)
       
   244                     or (trunc(y) > LAND_HEIGHT)
       
   245                     or not TestCollWithLand(trunc(x), trunc(y), 5)
       
   246                     or (timer = 0)
       
   247                 end;
   228             EX:= trunc(x);
   248             EX:= trunc(x);
   229             EY:= trunc(y);
   249             EY:= trunc(y);
   230             if Level = 1 then
   250             if Level = 1 then
   231                 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   251                 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   232             else value:= RateExplosion(Me, EX, EY, 101);
   252             else value:= RateExplosion(Me, EX, EY, 101);