hedgewars/uGears.pas
changeset 3832 f949798219bf
parent 3831 3410db7ac43e
child 3836 833c0f32e326
equal deleted inserted replaced
3831:3410db7ac43e 3832:f949798219bf
  1564         inc(Team^.stats.AIKills);
  1564         inc(Team^.stats.AIKills);
  1565         if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex);
  1565         if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex);
  1566         Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
  1566         Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
  1567     end;
  1567     end;
  1568     tempTeam := PHedgehog(gear^.Hedgehog)^.Team;
  1568     tempTeam := PHedgehog(gear^.Hedgehog)^.Team;
       
  1569     DeleteCI(gear);
  1569     FindPlace(gear, false, 0, LAND_WIDTH); 
  1570     FindPlace(gear, false, 0, LAND_WIDTH); 
  1570     if gear <> nil then begin
  1571     if gear <> nil then begin
  1571         RenderHealth(PHedgehog(gear^.Hedgehog)^);
  1572         RenderHealth(PHedgehog(gear^.Hedgehog)^);
  1572         ScriptCall('onResurrect', gear^.uid);
  1573         ScriptCall('onResurrect', gear^.uid);
  1573     end;
  1574     end;
  1730     x:= Left + LongInt(GetRandom(Delta));
  1731     x:= Left + LongInt(GetRandom(Delta));
  1731     repeat
  1732     repeat
  1732         inc(x, Delta);
  1733         inc(x, Delta);
  1733         cnt:= 0;
  1734         cnt:= 0;
  1734         y:= min(1024, topY) - 2 * Gear^.Radius;
  1735         y:= min(1024, topY) - 2 * Gear^.Radius;
  1735         while y < LAND_HEIGHT do
  1736         while y < cWaterLine do
  1736             begin
  1737             begin
  1737             repeat
  1738             repeat
  1738                 inc(y, 2);
  1739                 inc(y, 2);
  1739             until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0);
  1740             until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0);
  1740 
  1741 
  1741             sy:= y;
  1742             sy:= y;
  1742 
  1743 
  1743             repeat
  1744             repeat
  1744                 inc(y);
  1745                 inc(y);
  1745             until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
  1746             until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
  1746 
  1747 
  1747             if (y - sy > Gear^.Radius * 2) and
  1748             if (y - sy > Gear^.Radius * 2) and
  1748                (((Gear^.Kind = gtExplosives)
  1749                (((Gear^.Kind = gtExplosives)
  1749                    and (y < LAND_HEIGHT-1)
  1750                    and (y < cWaterLine)
  1750                    and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil)
  1751                    and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil)
  1751                    and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
  1752                    and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
  1752                or
  1753                or
  1753                  ((Gear^.Kind <> gtExplosives)
  1754                  ((Gear^.Kind <> gtExplosives)
  1754                    and (y < LAND_HEIGHT)
  1755                    and (y < cWaterLine)
  1755                    and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil))) then
  1756                    and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil))) then
  1756                 begin
  1757                 begin
  1757                 ar[cnt].X:= x;
  1758                 ar[cnt].X:= x;
  1758                 if withFall then ar[cnt].Y:= sy + Gear^.Radius
  1759                 if withFall then ar[cnt].Y:= sy + Gear^.Radius
  1759                             else ar[cnt].Y:= y - Gear^.Radius;
  1760                             else ar[cnt].Y:= y - Gear^.Radius;
  1785         {$ENDIF}
  1786         {$ENDIF}
  1786         end
  1787         end
  1787     else
  1788     else
  1788     begin
  1789     begin
  1789     OutError('Can''t find place for Gear', false);
  1790     OutError('Can''t find place for Gear', false);
       
  1791     if Gear^.Kind = gtHedgehog then PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] := false;
  1790     DeleteGear(Gear);
  1792     DeleteGear(Gear);
  1791     Gear:= nil
  1793     Gear:= nil
  1792     end
  1794     end
  1793 end;
  1795 end;
  1794 
  1796