
Anystartlocation = { (CPos.New(1,67)),  (CPos.New(68,1)),  (CPos.New(128,64)),  (CPos.New(67,128)) }
Anypatrollocation = { { (CPos.New(65,52)),  (CPos.New(47,67)),  (CPos.New(65,77)),  (CPos.New(83,63)) }, { (CPos.New(74,74)),  (CPos.New(55,74)),  (CPos.New(74,55)),  (CPos.New(55,55)) } }
PinkyMaker = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(90, 150)), function()
		pStartLocation = Utils.Random(Anystartlocation)
		pPatrolLocations = Utils.Random(Anypatrollocation)
		Flare = Actor.Create("bigflare", true, { Location = pStartLocation, Owner = Neutral })
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 12)), function()
			Pinky = Actor.Create("pinky", true, { Location = pStartLocation, Owner = Creeps })
			Pinky.Patrol(pPatrolLocations, true, Utils.RandomInteger(66, 90))
			Trigger.OnKilled(Pinky,PinkyMaker)
			Media.PlaySound("PinkyKill" .. Utils.RandomInteger(1, 4) .. ".aud")
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 12)), function()
				Flare.Destroy()
			end)
		end)
	end)
end

MancubusMaker = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(120, 210)), function()
		mStartLocation = Utils.Random(Anystartlocation)
		mPatrolLocations = Utils.Random(Anypatrollocation)
		Flare2 = Actor.Create("bigflare", true, { Location = mStartLocation, Owner = Neutral })
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 12)), function()
			Mancubus = Actor.Create("manc", true, { Location = mStartLocation, Owner = Creeps })
			Mancubus.Patrol(mPatrolLocations, true, Utils.RandomInteger(90, 333))
			Trigger.OnKilled(Mancubus,MancubusMaker)
			Media.PlaySound("MancKill" .. Utils.RandomInteger(1, 3) .. ".aud")
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 12)), function()
				Flare2.Destroy()
			end)
		end)
	end)
end

BlueLight = 0.77
GreenLight = 0.80
turnOn = function()
	Lighting.Blue = BlueLight
	Lighting.Green = GreenLight
	if BlueLight < 0.99 then
		BlueLight = BlueLight + 0.001
		GreenLight = GreenLight + 0.001
		Trigger.AfterDelay(14, function()
			turnOn()
		end)
	else
		Trigger.AfterDelay(2000, function()
			turnOff()
		end)
	end	
end

turnOff = function()
	Lighting.Blue = BlueLight
	Lighting.Green = GreenLight
	if BlueLight > 0.68 then
		BlueLight = BlueLight - 0.001
		GreenLight = GreenLight - 0.001
		Trigger.AfterDelay(11, function()
			turnOff()
		end)	
	else
		Trigger.AfterDelay(1000, function()
			turnOn()
		end)
	end
end

WorldLoaded = function()
	SetupPlayers()
	if Map.LobbyOption("difficulty") == "5min" then
		PeaceTime = DateTime.Minutes(5)
	end
	if Map.LobbyOption("difficulty") == "10min" then
		PeaceTime = DateTime.Minutes(10)
	end
	if Map.LobbyOption("difficulty") == "15min" then
		PeaceTime = DateTime.Minutes(15)
	end
	if Map.LobbyOption("difficulty") == "20min" then
		PeaceTime = DateTime.Minutes(20)
	end
	if Map.LobbyOption("difficulty") == "30min" then
		PeaceTime = DateTime.Minutes(30)
	end
	Media.DisplayMessage("My buddy GOD is here for a cup of tea!\nWe came to conclusion that there should be no more war.\nbut he will leave us in " .. Utils.FormatTime(PeaceTime) .. " minutes ;D", "Satan", Red)
	WarningTime = PeaceTime - DateTime.Minutes(1)
	Trigger.AfterDelay(WarningTime, function()
		Trigger.AfterDelay(DateTime.Seconds(58), function()
			BlueLight = 1
			GreenLight = 1
			Warningalert()
		end)
	end)
	Trigger.AfterDelay(PeaceTime, function()
		Media.DisplayMessage("Okay see you next century lordy have fun! >:D", "Satan", Red)
		PeaceContractEnds()
	end)
end