--[[
Task Queues!
]]--

math.randomseed( os.time() )
math.random(); math.random(); math.random()

local function AirOrLand()
   if (ai.factories < 5) or (ai.factories == nil) then
		local r = math.random(0,3)
		if r == 0 then
			return "ebasefactory"
		elseif r == 1 then
			return "eairplant"
		elseif r == 2 then
			return "eamphibfac"
		else 
			return "eminifac"
		end
	else
		return nil
	end
end

local function Destroyer()
   if (ai.factories < 4) then
   		return "eexperimentalfac"
	else
		return nil
	end
end

local function StartFactory()
	local r = math.random(0,2)
	if r == 0 then
		return "ebasefactory"
	elseif r == 1 then
		return "eamphibfac"
	else
		return "eminifac"
	end
end


local factory = {
   "eengineer5",
   "eengineer5",
   { action="wait",frames=64},
   "elighttank3",
   "elighttank3",
   "eengineer5",
   "eriottank2",
   "elighttank3",
   "elighttank3",
   "eriottank2",
   "elighttank3",
   "elighttank3",
   "eriottank2",
   "eengineer5",
   "eriottank2",
   "eheavytank3",
   "eaatank",
   "eaatank",
   "eaatank",
   "emissiletank",
   "emissiletank",
   { action="wait",frames=200},
   "emissiletank",
   "eheavytank3",
   "eheavytank3",
   "eheavytank3",
   "eheavytank3",
   "eaatank",
   "eengineer5",
   "elighttank3",
   "elighttank3",
   "eaatank",
   "elighttank3",
   "eartytank",
   "eriottank2",
   "eriottank2",
   "eartytank",
   "eheavytank3",
   "emissiletank",
   "emissiletank",
   "emissiletank",
   { action="wait",frames=200},
}

local firstEngineer = {
   "emetalextractor",
   "emetalextractor",
   "emetalextractor",
   StartFactory,
   { action="wait",frames=128},
   "esolar2",
   "esolar2",
   "esolar2",
   "elightturret2",
   { action="wait",frames=32},
   "esolar2",
   "esolar2",
   "elightturret2",
   "esolar2",
   "esolar2",
   "emetalextractor",
   "emetalextractor",
   "emetalextractor",
   "esolar2",
   "esolar2",
   "esolar2",
   "esolar2",
   "esolar2",
   "elightturret2",
   "esolar2",
   { action="wait",frames=100},
   "efusion2",
   "emetalextractor",
   "emetalextractor",
   "emetalextractor",
   "emetalextractor",
   "esolar2",
   "esolar2",
   "emetalextractor",
   "eaaturret",
   "emetalextractor",
   "emetalextractor",
   "elightturret2",
   "emetalextractor",
   "eaaturret",
   { action="wait",frames=64},
   AirOrLand,
   { action="wait",frames=64},
   "emetalextractor",
   "esolar2",
   "emetalextractor",
   "ejammer2",
   "estorage",
   "emetalextractor",
   "emetalextractor",
   "estorage",
   "emetalextractor",
   "emetalextractor",
   "elightturret2",
   "eaaturret",
   "eheavyturret2",
   { action="wait",frames=64},
   "efusion2",
}

local engineers = {
   "emetalextractor",
   "emetalextractor",
   "emetalextractor",
   "esolar2",
   "emetalextractor",
   "elightturret2",
   "emetalextractor",
   "emetalextractor",
   "elightturret2",
   { action="wait",frames=64},
   "efusion2",
   AirOrLand,
   "eaaturret",
   "emetalextractor",
   "emetalextractor",
   "emetalextractor",
   "esolar2",
   "elightturret2",
   "emetalextractor",
   "esolar2",
   "emetalextractor",
   "eaaturret",
   "emetalextractor",
   "esolar2",
   "emetalextractor",
   "elightturret2",
   "emetalextractor",
   "emetalextractor",
   "elightturret2",
   "esolar2",
   "emetalextractor",
   "ejammer2",
   "esolar2",
   "elightturret2",
   "elrpc",
   "efusion2",
   "eheavyturret2",
   { action="wait",frames=64},
   "efusion2",
   { action="wait",frames=64},
   "efusion2",
   "esolar2",
   "emetalextractor",
   "emetalextractor",
   "eheavyturret2",
   "estorage",
   "emetalextractor",
   "emetalextractor",
   "eheavyturret2",
   "estorage",
   "eaaturret",
   "estorage",
   { action="wait",frames=64},
   "efusion2",
   Destroyer,
}

local airplant = {
   "eairengineer",
   { action="wait",frames=64},
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "eairengineer",
   { action="wait",frames=64},
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "eairengineer",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   { action="wait",frames=64},
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
   "efighter",
   "ebomber",
   "ebomber",
   "egunship2",
   "egunship2",
}

local amphibfactory = {
   "eamphibengineer",
   { action="wait",frames=64},
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibriot",
   "eamphibriot",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibarty",
   "eamphibarty",
   "eamphibarty",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibriot",
   "eamphibriot",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibarty",
   "eamphibarty",
   "eamphibarty",
   "eamphibengineer",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibriot",
   "eamphibriot",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibarty",
   "eamphibarty",
   "eamphibarty",
   "eamphibengineer",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibbuggy",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibmedtank",
   "eamphibriot",
   "eamphibriot",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibrock",
   "eamphibarty",
   "eamphibarty",
   "eamphibarty",   
}

local allterrfactory = {
   "eallterrengineer",
   "eallterrengineer",
   { action="wait",frames=64},
   "eallterrlight",
   "eallterrlight",
   "eallterrlight",
   "eallterrlight",
   "eallterrriot",
   "eallterrriot",
   "eallterrmed",
   "eallterrmed",
   "eallterrmed",
   "eallterrmed",
   "eallterrengineer",
   "eallterrengineer",
   "eallterrlight",
   "eallterrlight",
   "eallterrheavy",
   "eallterrheavy",
   "eallterrheavy",
   "eallterrheavy",
   "eallterrheavy",
   "eallterrheavy",
   "eallterrassault",
   "eallterrassault",
   "eallterrassault",
   "eallterrassault",
   "eallterrengineer",
}

local destroyerfactory = {
   { action="wait",frames=200},
   "eexkrabgroth",
}

local function engineerlist(beh)
   if ai.engineerfirst == true then
      return engineers
   else
      ai.engineerfirst = true
      return firstEngineer
   end
end

taskqueues = {
   ecommander = engineerlist,
   ebasefactory = factory,
   eengineer5 = engineerlist,
   eallterrengineer = engineerlist,
   eamphibengineer = engineerlist,
   eairengineer = engineerlist,
   eairplant = airplant,
   eamphibfac = amphibfactory,
   eminifac = allterrfactory,
   eexperimentalfac = destroyerfactory,
   
}
