ZombieTeam1 = { "c8" }
ZombieTeam2 = { "c9" }
ZombieTeam3 = { "zombie", "zombie", "zombie", "zombie" }
ZombieTeam4 = { "c6", "c3", "c6", "c6", "c6",  "c3", "c6", "c3", "c6", "c3", "c6", "c6" }
ZombieTeam5 = { "zombie", "zombie", "zombie", "zombie" }
ZombieTeam6 = { "c5", "c6", "c7", "c8", "c9" }
ZombieTeam7 = { "c2", "c3", "c4", "c5", "c6", "c7", "c8" }
ZombieTeam8 = { "c1", "c2", "c6", "c7", "c8", "c9", "c1" }
ZombieTeam9 = { "c7", "c7", "c7", "c7" }
ZombieTeam10 = { "c7", "c8", "c9", "c4", "c4" }
ZombieTeam11 = { "c4", "c4", "c4", "c4", "c4" }
ZombieTeam12 = { "c5", "c5", "c5", "c5", "c5" }
ZombieTeam13 = { "c4", "c5", "c6", "c7", "c8", "c9", }
ZombieTeam14 = { "c1", "c1" }
ZombieTeam15 = { "c5", "c8", "c5", "c8", "c5", "c8" }
ZombieTeam16 = { "c9", "c9", "c9", "c9", "c9" }
ZombieTeam17 = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9" }
ZombieTeam18 = { "c9", "c9", "c9", "c9", "c9" }
ZombieTeam19 = { "zombie", "zombie", "zombie", "zombie" }
ZombieTeam20 = { "c4", "c5", "c6"  }
ZombieTeam21 = { "c9", "c1", "c7" }
ZombieTeam22 = { "c9", "c7", "c8" }
ZombieTeam23 = { "c9", "c1", "c7" }

AttackersTeam = { "ZombieAttacker1", "ZombieAttacker2" }
ZombieReinforcements1 = { "c6", "c7", "c9" }

Teams =
{
	{ units = ZombieTeam1, entryCell = ZombieWaypoint1.Location, building = House1 },
	{ units = ZombieTeam2, entryCell = ZombieWaypoint2.Location, building = House2 },
	{ units = ZombieTeam3, entryCell = ZombieWaypoint3.Location, building = House3 },
	{ units = ZombieTeam4, entryCell = ZombieWaypoint4.Location, building = House4 },
	{ units = ZombieTeam5, entryCell = ZombieWaypoint5.Location, building = House5 },
	{ units = ZombieTeam6, entryCell = ZombieWaypoint6.Location, building = House6 },
	{ units = ZombieTeam7, entryCell = ZombieWaypoint7.Location, building = House7 },
	{ units = ZombieTeam8, entryCell = ZombieWaypoint8.Location, building = House8 },
	{ units = ZombieTeam9, entryCell = ZombieWaypoint9.Location, building = House9 },
	{ units = ZombieTeam10, entryCell = ZombieWaypoint10.Location, building = House10 },
	{ units = ZombieTeam11, entryCell = ZombieWaypoint11.Location, building = House11 },
	{ units = ZombieTeam12, entryCell = ZombieWaypoint12.Location, building = House12 },
	{ units = ZombieTeam13, entryCell = ZombieWaypoint13.Location, building = House13 },
	{ units = ZombieTeam14, entryCell = ZombieWaypoint14.Location, building = House14 },
	{ units = ZombieTeam15, entryCell = ZombieWaypoint15.Location, building = House15 },
	{ units = ZombieTeam16, entryCell = ZombieWaypoint16.Location, building = House16 },
	{ units = ZombieTeam17, entryCell = ZombieWaypoint17.Location, building = House17 },
	{ units = ZombieTeam18, entryCell = ZombieWaypoint18.Location, building = House18 },
	{ units = ZombieTeam19, entryCell = ZombieWaypoint19.Location, building = House19 },
	{ units = ZombieTeam20, entryCell = ZombieWaypoint20.Location, building = House20 },
	{ units = ZombieTeam21, entryCell = ZombieWaypoint21.Location, building = House21 },
	{ units = ZombieTeam22, entryCell = ZombieWaypoint22.Location, building = House22 }
}

--SpawnPoints = { Tanya1, Tanya2 }

CreateTeam = function(Team)
	if Team.building.IsDead then
		return
	end
	local units = Reinforcements.Reinforce(BadGuy, Team.units, { Team.entryCell }, 25)
	SendUnits(units)
	Utils.Do(units, function(actor)
		if not actor.IsDead then
			Trigger.OnIdle(actor, actor.Hunt)
		end
	end)
	Trigger.AfterDelay(DateTime.Seconds(30), function()
		CreateTeam(Team)
	end)
end

SendUnits = function(units)
	--Get random player spawnpoint
	local player = Utils.Random(players)
	local waypoint = player.Spawn
	Utils.Do(units, function(unit)
	end)
end

WorldLoaded = function()
	BadGuy = Player.GetPlayer("BadGuy")
	players = { }
	for i = 0, 7, 1 do
		local player = Player.GetPlayer("Multi" ..i)
		if player ~= nil then
			table.insert(players, player)
		end
	end

	Trigger.AfterDelay(DateTime.Seconds(15), function()
		CreateTeam(Teams[1])
	end)
	Trigger.AfterDelay(DateTime.Seconds(20), function()
		CreateTeam(Teams[2])
	end)
	Trigger.AfterDelay(DateTime.Seconds(30), function()
		CreateTeam(Teams[2])
	end)
	Trigger.AfterDelay(DateTime.Seconds(39), function()
		CreateTeam(Teams[3])
	end)
	Trigger.AfterDelay(DateTime.Seconds(60), function()
		CreateTeam(Teams[4])
	end)
	Trigger.AfterDelay(DateTime.Seconds(100), function()
		CreateTeam(Teams[5])
	end)
	Trigger.AfterDelay(DateTime.Seconds(130), function()
		CreateTeam(Teams[6])
	end)
	Trigger.AfterDelay(DateTime.Seconds(130), function()
		CreateTeam(Teams[7])
	end)
	Trigger.AfterDelay(DateTime.Seconds(180), function()
		CreateTeam(Teams[8])
	end)
	Trigger.AfterDelay(DateTime.Seconds(280), function()
		CreateTeam(Teams[9])
	end)
	Trigger.AfterDelay(DateTime.Seconds(280), function()
		CreateTeam(Teams[10])
	end)
	Trigger.AfterDelay(DateTime.Seconds(300), function()
		CreateTeam(Teams[11])
	end)
	Trigger.AfterDelay(DateTime.Seconds(300), function()
		CreateTeam(Teams[12])
	end)
	Trigger.AfterDelay(DateTime.Seconds(360), function()
		CreateTeam(Teams[13])
	end)
	Trigger.AfterDelay(DateTime.Seconds(390), function()
		CreateTeam(Teams[14])
	end)
	Trigger.AfterDelay(DateTime.Seconds(360), function()
		CreateTeam(Teams[15])
	end)
	Trigger.AfterDelay(DateTime.Seconds(360), function()
		CreateTeam(Teams[16])
	end)
	Trigger.AfterDelay(DateTime.Seconds(480), function()
		CreateTeam(Teams[17])
	end)
	Trigger.AfterDelay(DateTime.Seconds(480), function()
		CreateTeam(Teams[18])
	end)
	Trigger.AfterDelay(DateTime.Seconds(530), function()
		CreateTeam(Teams[19])
	end)
	Trigger.AfterDelay(DateTime.Seconds(530), function()
		CreateTeam(Teams[20])
	end)
	Trigger.AfterDelay(DateTime.Seconds(530), function()
		CreateTeam(Teams[21])
	end)
	Trigger.AfterDelay(DateTime.Seconds(530), function()
		CreateTeam(Teams[22])
	end)
end

Tick = function()
	if (Utils.RandomInteger(1, 200) == 10) then
		local delay = Utils.RandomInteger(1, 10)
		Lighting.Flash("LightningStrike", delay)
		Trigger.AfterDelay(delay, function()
			Media.PlaySound("thunder" .. Utils.RandomInteger(1,6) .. ".aud")
		end)
	end
end