SetupPlayers = function()
	Neutral = Player.GetPlayer("Neutral")
	Multi0 = Player.GetPlayer("Multi0")
	if Multi0 == nil then
		Multi0 = Player.GetPlayer("Neutral")
	end
	Multi1 = Player.GetPlayer("Multi1")
	if Multi1 == nil then
		Multi1 = Player.GetPlayer("Neutral")
	end
	Multi2 = Player.GetPlayer("Multi2")
	if Multi2 == nil then
		Multi2 = Player.GetPlayer("Neutral")
	end
	Multi3 = Player.GetPlayer("Multi3")
	if Multi3 == nil then
		Multi3 = Player.GetPlayer("Neutral")
	end
end

Cratecontrol = function()
	Trigger.AfterDelay(DateTime.Seconds(55), function()
		Sendnormalcrate()
	end)
	Trigger.AfterDelay(DateTime.Seconds(330), function()
		Sendspecialcrate()
		Warningalert()
		Media.DisplayMessage("Okay guys it seems like the special crates will be dropped soon in mid!", "Materia", HSLColor.Red)
	end)
	Trigger.AfterDelay(DateTime.Seconds(530), function()
		Sendsupercrate()
		AlertStarts = false
		Warningalert()
		Media.DisplayMessage("Let the party begin the super crates get into the arena!", "Materia", HSLColor.Red)
	end)

end
AlertStarts = false
BlueLight = 1
GreenLight = 1

Warningalert = function()
	Lighting.Blue = BlueLight
	Lighting.Green = GreenLight
	if Lighting.Blue >= 1 and not AlertStarts then
		GettingRed = true
		Media.PlaySoundNotification( allplayers, "AlertBuzzer")
	end
	if BlueLight >= 0.2 and GettingRed then
		AlertStarts = true
		BlueLight = BlueLight - 0.05
		GreenLight = GreenLight - 0.05
		Trigger.AfterDelay(1, function()
			Warningalert()
		end)
	elseif BlueLight <= 1 then
		BlueLight = BlueLight + 0.05
		GreenLight = GreenLight + 0.05
		GettingRed = false
		Trigger.AfterDelay(1, function()
			Warningalert()
		end)
	end
end


Sendnormalcrate = function()
	DetonationPoint = Actor.Create("waypoint", true, { Location = CPos.New(43,43), Owner = Neutral })
	ParaProxy = Actor.Create("powerproxy.normalcrate", false, { Owner = Neutral })
	crates = ParaProxy.SendParatroopers(DetonationPoint.CenterPosition)
	Trigger.AfterDelay(DateTime.Seconds(80), function()
		Sendnormalcrate()
	end)
end

Sendspecialcrate = function()
	DetonationPoint = Actor.Create("waypoint", true, { Location = CPos.New(43,43), Owner = Neutral })
	ParaProxy = Actor.Create("powerproxy.specialcrate", false, { Owner = Neutral })
	crates = ParaProxy.SendParatroopers(DetonationPoint.CenterPosition)
	Trigger.AfterDelay(DateTime.Seconds(70), function()
		Sendspecialcrate()
	end)
end

Sendsupercrate = function()
	DetonationPoint = Actor.Create("waypoint", true, { Location = CPos.New(43,43), Owner = Neutral })
	ParaProxy = Actor.Create("powerproxy.supercrate", false, { Owner = Neutral })
	crates = ParaProxy.SendParatroopers(DetonationPoint.CenterPosition)
	Trigger.AfterDelay(DateTime.Seconds(60), function()
		Sendsupercrate()
	end)
end

Setteleporttriggers = function()
-- Topteleporter
	Trigger.OnEnteredFootprint({CPos.New(43,20)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 29) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(43,19)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 29) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(43,21)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 29) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(42,20)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 29) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(41,20)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 29) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
-- Rightteleporter
	Trigger.OnEnteredFootprint({CPos.New(66,43)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(57, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(65,43)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(57, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(67,43)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(57, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(66,42)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(57, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(66,44)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(57, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
-- Bottomteleporter
	Trigger.OnEnteredFootprint({CPos.New(43,66)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 57) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(43,65)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 57) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(43,67)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 57) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(42,66)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 57) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(41,66)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(43, 57) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
-- Leftteleporter
	Trigger.OnEnteredFootprint({CPos.New(20,43)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(29, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(19,43)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(29, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(21,43)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(29, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(20,42)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(29, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
	Trigger.OnEnteredFootprint({CPos.New(20,41)}, function(a, id)
		if a.Type == "dog" or a.Type == "e1" or a.Type == "e2" or a.Type == "e3" or a.Type == "e4"or a.Type == "e6" or a.Type == "spy" or a.Type == "spy.england" or a.Type == "e7" or a.Type == "medi" or a.Type == "mech" or a.Type == "thf" or a.Type == "shok" or a.Type == "sniper" or a.Type == "zombie" or a.Type == "ant" or a.Type == "fireant" or a.Type == "scoutant" or a.Type == "warriorant" or a.Type == "tecn" or a.Type == "clarkkent" then
			a.Stop()
			a.Teleport(CPos.New(29, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-1, 2)))
		end
	end)
end

Northmove = { CPos.New(42,28), CPos.New(43,28), CPos.New(44,28), CPos.New(42,29), CPos.New(43,29), CPos.New(44,29), CPos.New(42,30), CPos.New(43,30), CPos.New(44,30) }

Rightmove = { CPos.New(56,42), CPos.New(57,42), CPos.New(58,42), CPos.New(56,43), CPos.New(57,43), CPos.New(58,43), CPos.New(56,44), CPos.New(57,44), CPos.New(58,44) }


Bottommove = { CPos.New(42,56), CPos.New(43,56), CPos.New(44,56), CPos.New(42,57), CPos.New(43,57), CPos.New(44,57), CPos.New(42,58), CPos.New(43,58), CPos.New(44,58) }

Leftmove = { CPos.New(28,42), CPos.New(29,42), CPos.New(30,42), CPos.New(28,43), CPos.New(29,43), CPos.New(30,43), CPos.New(28,44), CPos.New(29,44), CPos.New(30,44) }

Setmovetriggers = function()
-- Topteleporter
	Trigger.OnEnteredFootprint(Northmove, function(a, id)
		a.Move(CPos.New(43, 33) + CVec.New(Utils.RandomInteger(-2, 3), Utils.RandomInteger(-1, 2)))
	end)
-- Rightteleporter
	Trigger.OnEnteredFootprint(Rightmove, function(a, id)
		a.Move(CPos.New(53, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-2, 3)))
	end)
-- Bottomteleporter
	Trigger.OnEnteredFootprint(Bottommove, function(a, id)
		a.Move(CPos.New(43, 53) + CVec.New(Utils.RandomInteger(-2, 3), Utils.RandomInteger(-1, 2)))
	end)
-- Leftteleporter
	Trigger.OnEnteredFootprint(Leftmove, function(a, id)
		a.Move(CPos.New(33, 43) + CVec.New(Utils.RandomInteger(-1, 2), Utils.RandomInteger(-2, 3)))
	end)
end
Notifications = function()
	Trigger.AfterDelay(DateTime.Seconds(1), function()
		Media.DisplayMessage("Hi, there are many new special crates in this map!", "Materia", HSLColor.Red)	
	end)
	Trigger.AfterDelay(DateTime.Seconds(6), function()
		Media.DisplayMessage("The special crates are only dropped in the middle!", "Materia", HSLColor.Red)
	end)
	Trigger.AfterDelay(DateTime.Seconds(11), function()
		Media.DisplayMessage("You can enter the middle only with infantry, through the round teleporter next to your base!", "Materia", HSLColor.Red)
		Media.PlaySoundNotification( allplayers, "Beacon")
		Beacon.New(Neutral, Actor12.CenterPosition, 4500, true)
		Beacon.New(Neutral, Actor13.CenterPosition, 4500, true)
		Beacon.New(Neutral, Actor14.CenterPosition, 4500, true)
		Beacon.New(Neutral, Actor15.CenterPosition, 4500, true)
	end)
	Trigger.AfterDelay(DateTime.Seconds(16), function()
		Media.DisplayMessage("gl hf", "Materia", HSLColor.Red)
	end)
end



function WorldLoaded()
	SetupPlayers()
	Cratecontrol()
	Setteleporttriggers()
	Setmovetriggers()
	Notifications()
end
