hedgewars/uGearsUtils.pas
changeset 9809 1e32628eb167
parent 9706 5178d2263521
child 9814 c740c865294d
equal deleted inserted replaced
9808:37891ba5e10b 9809:1e32628eb167
   299     end
   299     end
   300 end;
   300 end;
   301 
   301 
   302 procedure CheckHHDamage(Gear: PGear);
   302 procedure CheckHHDamage(Gear: PGear);
   303 var 
   303 var 
   304     dmg: Longword;
   304     dmg: LongInt;
   305     i: LongWord;
   305     i: LongWord;
   306     particle: PVisualGear;
   306     particle: PVisualGear;
   307 begin
   307 begin
   308 if _0_4 < Gear^.dY then
   308 if _0_4 < Gear^.dY then
   309     begin
   309     begin
   312          PlaySound(sndBump)
   312          PlaySound(sndBump)
   313     else PlaySound(sndFrozenHogImpact);
   313     else PlaySound(sndFrozenHogImpact);
   314     if dmg < 1 then
   314     if dmg < 1 then
   315         exit;
   315         exit;
   316 
   316 
   317     for i:= min(12, (3 + dmg div 10)) downto 0 do
   317     for i:= min(12, 3 + dmg div 10) downto 0 do
   318         begin
   318         begin
   319         particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
   319         particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
   320         if particle <> nil then
   320         if particle <> nil then
   321             particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480);
   321             particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480);
   322         end;
   322         end;
   592 ignoreNearObjects:= false; // try not skipping proximity at first
   592 ignoreNearObjects:= false; // try not skipping proximity at first
   593 ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates).  Saving it for a 3rd pass.  With this active, winning AI Survival goes back to virtual impossibility
   593 ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates).  Saving it for a 3rd pass.  With this active, winning AI Survival goes back to virtual impossibility
   594 tryAgain:= true;
   594 tryAgain:= true;
   595 if WorldEdge <> weNone then 
   595 if WorldEdge <> weNone then 
   596     begin
   596     begin
   597     Left:= max(Left,leftX+Gear^.Radius);
   597     Left:= max(Left, LongInt(leftX) + Gear^.Radius);
   598     Right:= min(Right,rightX-Gear^.Radius)
   598     Right:= min(Right,rightX-Gear^.Radius)
   599     end;
   599     end;
   600 while tryAgain do
   600 while tryAgain do
   601     begin
   601     begin
   602     delta:= LAND_WIDTH div 16;
   602     delta:= LAND_WIDTH div 16;
   604     repeat
   604     repeat
   605         x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta)));
   605         x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta)));
   606         repeat
   606         repeat
   607             inc(x, Delta);
   607             inc(x, Delta);
   608             cnt:= 0;
   608             cnt:= 0;
   609             y:= min(1024, topY) - 2 * Gear^.Radius;
   609             y:= min(1024, topY) - Gear^.Radius shl 1;
   610             while y < cWaterLine do
   610             while y < cWaterLine do
   611                 begin
   611                 begin
   612                 repeat
   612                 repeat
   613                     inc(y, 2);
   613                     inc(y, 2);
   614                 until (y >= cWaterLine) or
   614                 until (y >= cWaterLine) or
  1218 function WorldWrap(var Gear: PGear): boolean;
  1218 function WorldWrap(var Gear: PGear): boolean;
  1219 var tdx: hwFloat;
  1219 var tdx: hwFloat;
  1220 begin
  1220 begin
  1221 WorldWrap:= false;
  1221 WorldWrap:= false;
  1222 if WorldEdge = weNone then exit(false);
  1222 if WorldEdge = weNone then exit(false);
  1223 if (hwRound(Gear^.X)-Gear^.Radius < leftX) or
  1223 if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) or
  1224    (hwRound(Gear^.X)+Gear^.Radius > rightX) then
  1224    (hwRound(Gear^.X) + LongInt(Gear^.Radius) > LongInt(rightX)) then
  1225     begin
  1225     begin
  1226     if WorldEdge = weWrap then
  1226     if WorldEdge = weWrap then
  1227         begin
  1227         begin
  1228         if (hwRound(Gear^.X)-Gear^.Radius < leftX) then
  1228         if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) then
  1229              Gear^.X:= int2hwfloat(rightX-Gear^.Radius)
  1229              Gear^.X:= int2hwfloat(rightX - Gear^.Radius)
  1230         else Gear^.X:= int2hwfloat(leftX+Gear^.Radius);
  1230         else Gear^.X:= int2hwfloat(LongInt(leftX) + Gear^.Radius);
  1231         LeftImpactTimer:= 150;
  1231         LeftImpactTimer:= 150;
  1232         RightImpactTimer:= 150
  1232         RightImpactTimer:= 150
  1233         end
  1233         end
  1234     else if WorldEdge = weBounce then
  1234     else if WorldEdge = weBounce then
  1235         begin
  1235         begin
  1236         if (hwRound(Gear^.X)-Gear^.Radius < leftX) then
  1236         if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) then
  1237             begin
  1237             begin
  1238             LeftImpactTimer:= 333;
  1238             LeftImpactTimer:= 333;
  1239             Gear^.dX.isNegative:= false;
  1239             Gear^.dX.isNegative:= false;
  1240             Gear^.X:= int2hwfloat(leftX+Gear^.Radius)
  1240             Gear^.X:= int2hwfloat(LongInt(leftX) + Gear^.Radius)
  1241             end
  1241             end
  1242         else 
  1242         else 
  1243             begin
  1243             begin
  1244             RightImpactTimer:= 333;
  1244             RightImpactTimer:= 333;
  1245             Gear^.dX.isNegative:= true;
  1245             Gear^.dX.isNegative:= true;