Ok guys, I made a few functions for creating cylinders and spheres within the map file. Feel free to use, alter or improve at your leisure:
Cylinder Maker
Sphere MakerCode:function CreateCylinder(positionx, positiony, positionz, radius, length, roty, rotz, numAst1, numAst2, numAst3, numAst4, numAst5, numPeb, TotalRUs) x1 = -(length/2) if TotalRUs > 0 then if (numAst3 == 0 and numAst4 == 0 and numAst5 == 0) then RUamount = 0 else RUamount = TotalRUs/((numAst3*90)+(numAst4*180)+(numAst5*400)) if RUamount < 1 then RUamount = 1 end end else RUamount = 0 end for k = 1,6,1 do skip = 0 if k == 1 then if numAst1 > 0 then spacing = length/numAst1 numRocks = numAst1 else skip = 1 end elseif k == 2 then if numAst2 > 0 then spacing = length/numAst2 numRocks = numAst2 else skip = 1 end elseif k == 3 then if numAst3 > 0 then spacing = length/numAst3 numRocks = numAst3 else skip = 1 end elseif k == 4 then if numAst4 > 0 then spacing = length/numAst4 numRocks = numAst4 else skip = 1 end elseif k == 5 then if numAst5 > 0 then spacing = length/numAst5 numRocks = numAst5 else skip = 1 end elseif k ==6 then if numPeb > 0 then spacing = length/numPeb numRocks = numPeb else skip = 1 end end if skip == 0 then posx = x1 + (spacing/2) for i = 1,numRocks,1 do xstagger = random(1,(spacing/2)) if random(1,100) < 50 then xstagger = -xstagger end staggerradius = random(1,radius) staggerangle = random(1,360) ystagger = staggerradius*cos(staggerangle) zstagger = staggerradius*sin(staggerangle) x = posx + xstagger y = ystagger z = zstagger radius1 = sqrt(x^2 +z^2) angle1 = atan(z/x) if ((x < 0) and (z > 0)) or ((x < 0) and (z < 0)) then angle1 = angle1 + 180 end rotatey = roty + angle1 x = radius1*cos(rotatey) z = radius1*sin(rotatey) radius2 = sqrt(x^2+y^2) angle2 = atan(y/x) if ((x < 0) and (y > 0)) or ((x < 0) and (y < 0)) then angle2 = angle2 + 180 end rotatez = angle2 + rotz x = radius2*cos(rotatez) y = radius2*sin(rotatez) if k < 6 then addAsteroid("Asteroid_"..k,{x+positionx,z+positionz,y+positiony}, 10,0,0,0,0) else addPebble("Pebble_0", {x+positionx, z+positionz, y+positiony}, 0, 0, 0) end posx = posx + spacing end end end end
Just call these within DetermChunk() with:Code:function CreateSphere(positionx, positiony, positionz, radius, numAst1, numAst2, numAst3, numAst4, numAst5, numPeb, TotalRUs) if TotalRUs > 0 then if (numAst3 == 0 and numAst4 == 0 and numAst5 == 0) then RUamount = 0 else RUamount = TotalRUs/((numAst3*90)+(numAst4*180)+(numAst5*400)) if RUamount < 1 then RUamount = 1 end end else RUamount = 0 end for k = 1,6,1 do skip = 0 if k == 1 then if numAst1 > 0 then numRocks = numAst1 else skip = 1 end elseif k == 2 then if numAst2 > 0 then numRocks = numAst2 else skip = 1 end elseif k == 3 then if numAst3 > 0 then numRocks = numAst3 else skip = 1 end elseif k == 4 then if numAst4 > 0 then numRocks = numAst4 else skip = 1 end elseif k == 5 then if numAst5 > 0 then numRocks = numAst5 else skip = 1 end elseif k ==6 then if numPeb > 0 then numRocks = numPeb else skip = 1 end end if skip == 0 then for i = 1,numRocks,1 do angle1 = random(1,360) angle2 = random(1,360) randomradius = random(1,radius) x = randomradius*sin(angle1)*cos(angle2) y = randomradius*sin(angle1)*sin(angle2) z = randomradius*cos(angle1) if k < 6 then addAsteroid("Asteroid_"..k,{x+positionx,z+positionz,y+positiony}, RUamount,0,0,0,0) else addPebble("Pebble_0", {x+positionx, z+positionz, y+positiony}, 0, 0, 0) end end end end end
where:Code:CreateCylinder(x, y, z, radius, length, roty ,rotz, numAst1, numAst2, numAst3, numAst4, numAst5, numPeb, TotalRus) CreateSphere(x, y, z, radius, numAst1, numAst2, numAst3, numAst4, numAst5, numPeb, TotalRUs)
numAst1, numAst2....numPeb = the number of rocks of each type
roty & roz = rotation angles for the cylinders
TotalRUs - this is what you want the total RU value of the rock patch to be. It will only give appoximate results though.
notes: sorry for huge number of variables in the functions. Since we don't have distribution files like in HW, I decided to include everything you need to make something similar to what you get in HW/HWcata, only more precise.
These likely won't work online (yet - not sure what Relic has planned with a patch) because there's random calculations.
If anyone makes a function, maybe this should be the thread to put them in?


