I do it like that:
Code: Select all
        local SpotList = {}
        local MinSpotDist = math.max(Game.extractorRadius,112)
        local minmetal, maxmetal = nil, nil
        for x = 16,Game.mapSizeX,32 do
            for z = 16,Game.mapSizeZ,32 do
                local _,m = Spring.GetGroundInfo(x,z)
                if not minmetal or m<minmetal then
                    minmetal = m
                end
                if not maxmetal or m>maxmetal then
                    maxmetal = m
                end
            end
        end
        local mediummetal = (maxmetal - minmetal)/2
        Spring.Echo("Metal: ["..maxmetal.."-"..minmetal.."]")
        if maxmetal == minmetal then -- Special case for metal map, or no metal map
            local MinSpotDist = math.sqrt(Game.mapSizeX*Game.mapSizeZ/(4*#Spring.GetTeamList()))
            for x = MinSpotDist/2,Game.mapSizeX,MinSpotDist do
                for z = MinSpotDist/2,Game.mapSizeZ,MinSpotDist do
                    table.insert(SpotList, {x=x, y=Spring.GetGroundHeight(x,z), z=z})
                end
            end
        else
            for x = 16,Game.mapSizeX,32 do
                for z = 16,Game.mapSizeZ,32 do
                    local _,m = Spring.GetGroundInfo(x,z)
                    if m >= mediummetal then
                        local newSpot=true
                        for _,g in ipairs(SpotList) do
                            if math.sqrt((x-g.x)*(x-g.x) + (z-g.z)*(z-g.z)) < MinSpotDist then
                                newSpot = false
                                break
                            end
                        end
                        if newSpot then
                            Spring.Echo("Insert!")
                            table.insert(SpotList, {x=x, y=Spring.GetGroundHeight(x,z), z=z})
                        end
                    end
                end
            end
        end
        for _,g in ipairs(SpotList) do
            Spring.CreateFeature("geovent", g.x, g.y, g.z)
        end
Not sure if optimised. On metal maps, put about four spots per team.