hedgewars/uAIMisc.pas
changeset 6769 44ad49a3a126
parent 6768 a142cf8dbbd3
child 6770 7d2c6cdb816a
equal deleted inserted replaced
6768:a142cf8dbbd3 6769:44ad49a3a126
   254 
   254 
   255 function TraceDrown(eX, eY: LongInt; x, y, dX, dY: Real; r: LongWord): boolean;
   255 function TraceDrown(eX, eY: LongInt; x, y, dX, dY: Real; r: LongWord): boolean;
   256 var skipLandCheck: boolean;
   256 var skipLandCheck: boolean;
   257     rCorner: real;
   257     rCorner: real;
   258 begin
   258 begin
       
   259     skipLandCheck:= true;
   259     if x - eX < 0 then dX*=-1;
   260     if x - eX < 0 then dX*=-1;
   260     if y - eY < 0 then dY*=-1;
   261     if y - eY < 0 then dY*=-1;
   261     // ok. attempt approximate search for an unbroken trajectory into water.  if it continues far enough, assume out of map
   262     // ok. attempt approximate search for an unbroken trajectory into water.  if it continues far enough, assume out of map
   262     rCorner:= r * 0.75;
   263     rCorner:= r * 0.75;
   263     while true do
   264     while true do
   264         begin
   265         begin
   265         x:= x + dX;
   266         x:= x + dX;
   266         y:= y + dY;
   267         y:= y + dY;
   267         dY:= dY + cGravityf;
   268         dY:= dY + cGravityf;
   268         skipLandCheck:= (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
   269         skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
   269         if not skipLandCheck and TestCollWithLand(trunc(x), trunc(y), cHHRadius) then exit(false);
   270         if not skipLandCheck and TestCollWithLand(trunc(x), trunc(y), cHHRadius) then exit(false);
   270         if (y > cWaterLine) or (x > 4096) or (x < 0) then exit(true);
   271         if (y > cWaterLine) or (x > 4096) or (x < 0) then exit(true);
   271         end;
   272         end;
   272 end;
   273 end;
   273 
   274