function LevelSetup()
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(0)
Globals.G.GreysProbability=(0)
Globals.AI.GraceTimer=(99999)
SetBackdropColour(0,0,0)
a = AddAsteroidWithAttribs(2000,0, 0.3,0.3,0.3)
a.Owner = 0
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 3500
a:Reveal(1)
a.Moveable = false
a = AddAsteroidWithAttribs(0,0, 0.7,0.6,0.5)
a.Owner = 1
a.TreeCap = 20
a:SetRadius(500)
a.SendDistance = 7000
a.Moveable = false
a:AddSeedlings(20)
a = AddAsteroidWithAttribs(4000,0, 0.3,0.3,0.3)
a.Owner = 0
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 2500
a:Reveal(1)
a.Moveable = false
a = AddAsteroidWithAttribs(6000,0, 0.3,0.3,0.3)
a.Owner = 0
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 2500
a:Reveal(1)
a.Moveable = false
a = AddAsteroidWithAttribs(8000,0, 0.3,0.3,0.3)
a.Owner = 3
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 2500
a:Reveal(1)
a.Moveable = false
a:AddSeedlings(68)
a = AddAsteroidWithAttribs(0,-2000, 0.3,0.3,0.3)
a.Owner = 0
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 3500
a:Reveal(1)
a.Moveable = false
a = AddAsteroidWithAttribs(0,-4000, 0.3,0.3,0.3)
a.Owner = 0
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 2500
a:Reveal(1)
a.Moveable = false
a = AddAsteroidWithAttribs(0,-6000, 0.3,0.3,0.3)
a.Owner = 0
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 2500
a:Reveal(1)
a.Moveable = false
a = AddAsteroidWithAttribs(0,-8000, 0.3,0.3,0.3)
a.Owner = 2
a.TreeCap = 2
a:SetRadius(300)
a.SendDistance = 2500
a:Reveal(1)
a.Moveable = false
a:AddSeedlings(68)
SetCameraPositionToAsteroidID(1)
SetCameraZoomNow(5)
AddAsteroidRing(200, 0, 0, 15000, 150)
CCInit()
end
function ScreenDraw()
maxx = GetScreenWidth()
maxy = GetScreenHeight()
x1 = maxx
y1 = maxy
x2 = maxx - (maxx/15)
y2 = maxy
DrawLine(x1,y1,x2,y2,255,0,0,255,255,0,0,255,5)
x1 = maxx - (maxx/15)
y1 = maxy
x2 = maxx - (maxx/15)
y2 = maxy - (maxy/15)
DrawLine(x1,y1,x2,y2,255,0,0,255,255,0,0,255,5)
x1 = maxx
y1 = maxy
x2 = maxx
y2 = maxy - (maxy/15)
DrawLine(x1,y1,x2,y2,255,0,0,255,255,0,0,255,5)
x1 = maxx
y1 = maxy - (maxy/15)
x2 = maxx - (maxx/15)
y2 = maxy - (maxy/15)
DrawLine(x1,y1,x2,y2,255,0,0,255,255,0,0,255,5)
end
function LevelLogic()
while GameRunning() do
CCEngine()
coroutine.yield()
end
end
function CCInit()
numberofroids=-1
for i = 0,300 do
if GetAsteroid(i) ~= nil then
if GetAsteroid(i).radius > 10 then
numberofroids = numberofroids + 1
end
end
end
neighbourstart = {}
neighbourend = {}
neighbournumber = -1
neighbour = {}
for i = 0,numberofroids do
if neighbournumber == -1 then
neighbourstart[i] = 0
else
neighbourstart[i] = neighbournumber + 1
end
for j = 0,numberofroids do
if j ~= i then
length = GetAsteroid(i).position.x - GetAsteroid(j).position.x
height = GetAsteroid(i).position.y - GetAsteroid(j).position.y
distancetoroid = math.sqrt((length * length) + (height * height))
distancetoroid = distancetoroid - GetAsteroid(j).Radius
if distancetoroid < GetAsteroid(i).SendDistance then
neighbournumber = neighbournumber + 1
neighbour[j] = j
end
end
end
neighbourend[i] = neighbournumber
end
CCpriorities = {}
barrier = {}
CCdefensive = 10
checked = {}
for i = 0,numberofroids do
CCpriorities[i] = numberofroids
barrier[i] = false
checked[i] = 0
end
end
function CCEngine()
for i = 0,numberofroids do
if barrier[i] == false then
for j = neighbourstart[i],neighbourend[i] do
if neighbour[j] ~= i and neighbour[j] ~= nil then
if CCpriorities[i] > CCpriorities[neighbour[j]] then
CCpriorities[i] = CCpriorities[neighbour[j]] + 1
if GetAsteroid(i):GetNumSeedlings(1) > CCdefensive then
sendthisamount = GetAsteroid(i):GetNumSeedlings(1) - CCdefensive
GetAsteroid(i):SendSeedlingsToTarget(1, sendthisamount, GetAsteroid(neighbour[j]))
end
checked[i] = 1
end
end
end
end
end
end
function OnMouseLeftDownScreen(x,y)
if x >= maxx - maxx and x <= maxx - maxx + (maxx/15) and y >= maxy - maxy and y <= maxy - maxy + (maxy/15) then
for i = 0,numberofroids do
CCpriorities[i] = numberofroids
checked[i] = 0
end
CCpriorities[selectedid] = 0
end
end
function OnAsteroidSelected(id)
print(CCpriorities[id] .. " " .. neighbourstart[id] .. " " .. neighbourend[id] .. " " .. id .. " " .. checked[id])
selectedid = id
end
The checked shows that it ain't checking all roids, acctually just the two first (0,1) but why???