hedgewars/uAIMisc.pas
changeset 8895 95177c18e38c
parent 8884 08fe08651130
child 8924 13ac59499066
equal deleted inserted replaced
8893:8f92e94d0b32 8895:95177c18e38c
    62 function  RatePlace(Gear: PGear): LongInt;
    62 function  RatePlace(Gear: PGear): LongInt;
    63 function  TestColl(x, y, r: LongInt): boolean; inline;
    63 function  TestColl(x, y, r: LongInt): boolean; inline;
    64 function  TestCollExcludingObjects(x, y, r: LongInt): boolean; inline;
    64 function  TestCollExcludingObjects(x, y, r: LongInt): boolean; inline;
    65 function  TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
    65 function  TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
    66 function  TraceShoveFall(x, y, dX, dY: Real): LongInt;
    66 function  TraceShoveFall(x, y, dX, dY: Real): LongInt;
    67 function  TestCollWithLand(x, y, r: LongInt): boolean; inline;
       
    68 
    67 
    69 function  RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline;
    68 function  RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline;
    70 function  RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
    69 function  RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
    71 function  RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
    70 function  RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
    72 function  RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
    71 function  RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   306        exit(true);
   305        exit(true);
   307     
   306     
   308     TestColl:= false;
   307     TestColl:= false;
   309 end;
   308 end;
   310 
   309 
   311 function TestCollWithLand(x, y, r: LongInt): boolean; inline;
       
   312 begin
       
   313     if not CheckBounds(x, y, r) then
       
   314         exit(false);
       
   315 
       
   316     if (Land[y-r, x-r] > lfAllObjMask) or
       
   317        (Land[y+r, x-r] > lfAllObjMask) or 
       
   318        (Land[y-r, x+r] > lfAllObjMask) or
       
   319        (Land[y+r, x+r] > lfAllObjMask) then
       
   320        exit(true);
       
   321     
       
   322     TestCollWithLand:= false;
       
   323 end;
       
   324 
       
   325 
   310 
   326 // Wrapper to test various approaches.  If it works reasonably, will just replace.
   311 // Wrapper to test various approaches.  If it works reasonably, will just replace.
   327 // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with...
   312 // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with...
   328 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
   313 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
   329 var MeX, MeY: LongInt;
   314 var MeX, MeY: LongInt;
   355     begin
   340     begin
   356         x:= x + dX;
   341         x:= x + dX;
   357         y:= y + dY;
   342         y:= y + dY;
   358         dY:= dY + cGravityf;
   343         dY:= dY + cGravityf;
   359         skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
   344         skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
   360         if not skipLandCheck and TestCollWithLand(trunc(x), trunc(y), cHHRadius) then
   345         if not skipLandCheck and TestCollExcludingObjects(trunc(x), trunc(y), cHHRadius) then
   361         begin
   346         begin
   362             if 0.4 < dY then
   347             if 0.4 < dY then
   363             begin
   348             begin
   364                 dmg := 1 + trunc((abs(dY) - 0.4) * 70);
   349                 dmg := 1 + trunc((abs(dY) - 0.4) * 70);
   365                 if dmg >= 1 then
   350                 if dmg >= 1 then