

WarStarts = false

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

PeaceContractEnds = function()
	WarStarts = true
	Barb = Creeps.GetActorsByType("abarb")
	for p,fences in pairs(Barb) do
		fences.Kill()
	end
	Trigger.AfterDelay(5, function()
		AA = Creeps.GetActorsByType("aagun")
		for p,aaguns in pairs(AA) do
			aaguns.Kill()
		end
	end)
	Trigger.AfterDelay(10, function()
		Gap = Creeps.GetActorsByType("agap")
		for p,generators in pairs(Gap) do
			generators.Kill()
		end
	end)
	Trigger.AfterDelay(30, function()
		if Multi0 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi0 }) end
		if Multi1 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi1 }) end
		if Multi2 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi2 }) end
		if Multi3 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi3 }) end
		if Multi4 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi4 }) end
		if Multi5 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi5 }) end
		if Multi6 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi6 }) end
		if Multi7 ~= nil then Wartime = Actor.Create("wartime", true, { Location = (CPos.New(0,0)), Owner = Multi7 }) end
		PinkyMaker()
		turnOff()
		Trigger.AfterDelay(DateTime.Minutes(5), function()
			MancubusMaker()
		end)
	end)
end

SetupPlayers = function()
	Neutral = Player.GetPlayer("Neutral")
	Creeps = Player.GetPlayer("Creeps")
	Multi0 = Player.GetPlayer("Multi0")
	Multi1 = Player.GetPlayer("Multi1")
	Multi2 = Player.GetPlayer("Multi2")
	Multi3 = Player.GetPlayer("Multi3")
	Multi4 = Player.GetPlayer("Multi4")
	Multi5 = Player.GetPlayer("Multi5")
	Multi6 = Player.GetPlayer("Multi6")
	Multi7 = Player.GetPlayer("Multi7")
end

Red = HSLColor.Red
White = HSLColor.White

Tick = function()
	if PeaceTime > DateTime.Minutes(1) then
		TimerColor = White
	else TimerColor = Red end

	if PeaceTime == DateTime.Minutes(5) and Map.LobbyOption("difficulty") ~= "5min" then
		Media.PlaySpeechNotification( allplayers, "WarningFiveMinutesRemaining")
	end
	if PeaceTime < DateTime.Seconds(300) and PeaceTime > DateTime.Seconds(298) and Map.LobbyOption("difficulty") ~= "5min" then
		TimerColor = Red
	end
	if PeaceTime == DateTime.Minutes(4) then
		Media.PlaySpeechNotification( allplayers, "WarningFourMinutesRemaining")
	end
	if PeaceTime < DateTime.Seconds(240) and PeaceTime > DateTime.Seconds(238) then
		TimerColor = Red
	end
	if PeaceTime == DateTime.Minutes(3) then
		Media.PlaySpeechNotification( allplayers, "WarningThreeMinutesRemaining")
	end
	if PeaceTime < DateTime.Seconds(180) and PeaceTime > DateTime.Seconds(178) then
		TimerColor = Red
	end
	if PeaceTime == DateTime.Minutes(2) then
		Media.PlaySpeechNotification( allplayers, "WarningTwoMinutesRemaining")
	end
	if PeaceTime < DateTime.Seconds(120) and PeaceTime > DateTime.Seconds(118) then
		TimerColor = Red
	end
	if PeaceTime == DateTime.Minutes(1) then
		Media.PlaySpeechNotification( allplayers, "WarningOneMinuteRemaining")
	end
	if PeaceTime >= 0 then
		UserInterface.SetMissionText("God leaves us in " .. Utils.FormatTime(PeaceTime) .. " minutes", TimerColor)
		PeaceTime = PeaceTime - 1
	else
		UserInterface.SetMissionText(" ", TimerColor)
	end
end


