AllieunitsConditions = function()
	AllieInfDelayTimemin = 2
	AllieInfDelayTimemax = 3
	AllieInfUnit = { "e1", "e1" }
	AllieInfantryIncome()
	Trigger.AfterDelay(DateTime.Seconds(15), function()
		AllieInfUnit = { "e1", "e1", "e1", "e3" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		AllieInfUnit = { "e1", "e1", "e1", "e3", "e3", "medi" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		AllieVehDelayTimemin = 7
		AllieVehDelayTimemax = 10
		AllieVehUnit = { "1tnk", "jeep" }
		AllieVehicleIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		AllieInfDelayTimemin = 1
		AllieVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		AllieVehDelayTimemin = 5
		AllieVehUnit = { "1tnk", "1tnk", "jeep" }
		AllieTnkDelayTimemin = 12
		AllieTnkDelayTimemax = 14
		AllieTnkUnit = { "2tnk", "2tnk" }
		AllieTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		AllieInfUnit = { "e1", "e1", "e1", "e3", "e3", "medi", "mech" }
		AllieHeliDelayTimemin = 12
		AllieHeliDelayTimemax = 14
		AllieHeliUnit = { "mh60", "mh60" }
		AllieArtyDelayTimemin = 15
		AllieArtyDelayTimemax = 20
		AllieArtyUnit = { "arty", "arty" }
		AllieArtyIncome()
		AllieHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		AllieHeliUnit = { "heli", "mh60", "mh60" }
		AllieTnkUnit = { "2tnk", "2tnk", "ctnk", "2tnk" }
		AllieTnkDelayTimemin = 10
		AllieArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		AllieArtyDelayTimemin = 13
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		AllieHeliUnit = { "heli", "mh60" }
		AllieTnkUnit = { "2tnk", "2tnk", "ctnk", "2tnk", "2tnk", "2tnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		AllieVehUnit = { "1tnk", "1tnk", "1tnk", "jeep" }
		AllieVehDelayTimemin = 4
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		AllieTnkDelayTimemin = 7
		AllieArtyDelayTimemin = 12
		AllieHeliUnit = { "heli", "heli", "heli", "mh60", "mh60" }
		AllieTnkUnit = { "2tnk", "2tnk", "ctnk", "ctnk", "2tnk", "2tnk" }
	end)
end


SovietunitsConditions = function()
	SovietInfDelayTimemin = 1
	SovietInfDelayTimemax = 3
	SovietInfUnit = { "dog", "dog" }
	SovietInfantryIncome()
	Trigger.AfterDelay(DateTime.Seconds(15), function()
		SovietInfDelayTimemin = 2
		SovietInfUnit = { "e1", "dog", "dog", "dog" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		SovietInfUnit = { "e1", "e1", "e2", "e3", "dog", "dog" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		SovietVehDelayTimemin = 7
		SovietVehDelayTimemax = 10
		SovietInfUnit = { "e1", "e1", "e1", "e1", "e2", "e3", "e4", "dog" }
		SovietVehUnit = { "apc", "ftrk" }
		SovietVehicleIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		SovietInfDelayTimemin = 1
		SovietVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		SovietInfUnit = { "e1", "e1", "e1", "e2", "e3", "e4", "dog" }
		SovietVehDelayTimemin = 5
		SovietTnkDelayTimemin = 12
		SovietTnkDelayTimemax = 14
		SovietTnkUnit = { "3tnk", "3tnk" }
		SovietTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		SovietVehUnit = { "apc", "ftrk", "ftrk" }
		SovietHeliDelayTimemin = 12
		SovietHeliDelayTimemax = 14
		SovietHeliUnit = { "yak", "yak" }
		SovietArtyDelayTimemin = 15
		SovietArtyDelayTimemax = 20
		SovietArtyUnit = { "v2rl", "v2rl" }
		SovietArtyIncome()
		SovietHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		SovietInfUnit = { "e1", "e1", "shok", "e2", "e3", "e4", "dog" }
		SovietTnkUnit = { "3tnk", "3tnk", "3tnk", "ttnk", "4tnk" }
		SovietTnkDelayTimemin = 10
		SovietArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		SovietArtyDelayTimemin = 13
		SovietHeliUnit = { "yak", "yak", "yak", "mig" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		SovietTnkUnit = { "3tnk", "3tnk", "ttnk", "4tnk" }
		SovietVehUnit = { "apc", "ftrk", "ftrk", "ftrk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		SovietInfUnit = { "e1", "shok", "e2", "e3", "e4", "dog" }
		SovietHeliUnit = { "yak", "yak", "mig" }
		SovietVehDelayTimemin = 4
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		SovietTnkDelayTimemin = 7
		SovietArtyDelayTimemin = 12
		SovietTnkUnit = { "3tnk", "ttnk", "4tnk" }
	end)
end


GdiunitsConditions = function()
	GdiInfDelayTimemin = 2
	GdiInfDelayTimemax = 3
	GdiInfUnit = { "e1cnc", "e2cnc" }
	GdiInfantryIncome()
	Trigger.AfterDelay(DateTime.Seconds(15), function()
		GdiInfUnit = { "e1cnc", "e1cnc", "e1cnc", "e2cnc", "e3cnc" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		GdiInfUnit = { "e1cnc", "e1cnc", "e2cnc", "e3cnc" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		GdiVehDelayTimemin = 7
		GdiVehDelayTimemax = 10

		GdiVehUnit = { "humv", "humv", "humv", "apccnc" }
		GdiVehicleIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		GdiInfDelayTimemin = 1
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc" }
		GdiVehUnit = { "humv", "humv", "apccnc" }
		GdiVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		GdiVehDelayTimemin = 5
		GdiVehUnit = { "humv", "apccnc" }
		GdiTnkDelayTimemin = 12
		GdiTnkDelayTimemax = 14
		GdiTnkUnit = { "mtnk", "mtnk" }
		GdiTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "e1cnc", "e2cnc", "e3cnc", "rmbo" }
		GdiVehUnit = { "humv", "apccnc", "apccnc" }
		GdiHeliDelayTimemin = 12
		GdiHeliDelayTimemax = 14
		GdiHeliUnit = { "orca", "orca" }
		GdiArtyDelayTimemin = 15
		GdiArtyDelayTimemax = 17
		GdiArtyUnit = { "msam", "msam" }
		GdiArtyIncome()
		GdiHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "e2cnc", "e3cnc", "rmbo" }

		GdiTnkUnit = { "mtnk", "mtnk", "mtnk", "htnk" }
		GdiTnkDelayTimemin = 10
		GdiArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		GdiArtyDelayTimemin = 13
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "e3cnc", "rmbo" }
		GdiTnkUnit = { "mtnk", "mtnk", "htnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "rmbo" }
		GdiTnkUnit = { "mtnk", "htnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		GdiVehUnit = { "humv", "apccnc", "apccnc", "apccnc" }
		GdiVehDelayTimemin = 4
		GdiTnkUnit = { "mtnk", "htnk", "htnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		GdiTnkDelayTimemin = 7
		GdiArtyDelayTimemin = 12
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "rmbo", "rmbo" }

		GdiTnkUnit = { "mtnk", "htnk", "htnk", "htnk" }
	end)
end

NodunitsConditions = function()
	NodInfDelayTimemin = 2
	NodInfDelayTimemax = 3
	NodInfUnit = { "e1cnc", "e4cnc" }
	NodInfantryIncome()
	Trigger.AfterDelay(DateTime.Seconds(15), function()
		NodInfUnit = { "e1cnc", "e1cnc", "e1cnc", "e1cnc", "e3cnc", "e4cnc" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		NodInfUnit = { "e1cnc", "e1cnc", "e1cnc", "e3cnc", "e4cnc" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		NodVehDelayTimemin = 7
		NodVehDelayTimemax = 10

		NodVehUnit = { "bike", "bggy" }
		NodVehicleIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		NodInfDelayTimemin = 1
		NodInfUnit = { "e1cnc", "e1cnc", "e3cnc", "e4cnc" }
		NodVehUnit = { "bike", "bggy", "ftnkcnc" }
		NodVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		NodVehDelayTimemin = 5
		NodInfUnit = { "e1cnc", "e3cnc", "e4cnc" }

		NodTnkDelayTimemin = 12
		NodTnkDelayTimemax = 14
		NodTnkUnit = { "ltnk", "ltnk" }
		NodTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		NodInfUnit = { "e1cnc", "e1cnc", "e3cnc", "e3cnc", "e4cnc", "e5cnc" }
		NodVehUnit = { "bike", "bggy", "ftnkcnc", "mlrs" }
		NodHeliDelayTimemin = 12
		NodHeliDelayTimemax = 14
		NodHeliUnit = { "apache", "apache" }
		NodArtyDelayTimemin = 15
		NodArtyDelayTimemax = 17
		NodArtyUnit = { "artycnc", "artycnc" }
		NodArtyIncome()
		NodHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		NodInfUnit = { "e1cnc", "e3cnc", "e3cnc", "e4cnc", "e5cnc" }

		NodTnkUnit = { "ltnk", "ltnk", "stnkcnc" }
		NodTnkDelayTimemin = 10
		NodArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		NodArtyDelayTimemin = 13
		NodInfUnit = { "e1cnc", "e3cnc", "e4cnc", "e5cnc" }
		NodTnkUnit = { "ltnk", "stnkcnc" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		NodInfUnit = { "e1cnc", "e3cnc", "e4cnc", "e4cnc", "e5cnc" }
		NodTnkUnit = { "ltnk", "stnkcnc", "stnkcnc" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		NodInfUnit = { "e1cnc", "e3cnc", "e4cnc", "e4cnc", "e5cnc", "e5cnc" }

		NodVehDelayTimemin = 4
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		NodTnkDelayTimemin = 7
		NodTnkUnit = { "ltnk", "stnkcnc", "stnkcnc", "stnkcnc" }
		NodArtyDelayTimemin = 12

		
	end)
end

-- &&

-- "pvice" "bspi" "reve" "imp" "pinky" "manc" "mechwarrior" "exciter" "tripod"
MonsterConditions = function()
	MonsterDelayTimemin = 5
	MonsterDelayTimemax = 7
	EnemyMonsterUnit = { "PVICE", "zombie" }
	EnemyMonsterIncome()
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		MonsterDelayTimemin = 6
		EnemyMonsterUnit = { "PVICE", "BSPI", "zombie" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		MonsterDelayTimemin = 7
		EnemyMonsterUnit = { "PVICE", "IMP", "BSPI", "BSPI", "zombie" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		MonsterDelayTimemin = 8
		EnemyMonsterUnit = { "PVICE", "IMP", "IMP", "BSPI", "BSPI", "REVE", "zombie" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		MonsterDelayTimemin = 9
		EnemyMonsterUnit = { "PVICE", "IMP", "IMP", "BSPI", "BSPI", "REVE", "REVE", "zombie" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		MonsterDelayTimemin = 8
		EnemyMonsterUnit = { "PVICE", "IMP", "IMP", "BSPI", "BSPI", "REVE", "REVE" }
		CustomHeliDelayTimemin = 20
		CustomHeliDelayTimemax = 25
		EnemyCustomHeliUnit = { "UFO.Beamer", "UFO.Beamer" }
		EnemyCustomHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		MonsterDelayTimemin = 7
		EnemyMonsterUnit = { "PVICE", "IMP", "IMP", "IMP", "REVE", "REVE", "BSPI", "BSPI", "PINKY" }
		EnemyCustomHeliUnit = { "UFO.Beamer", "UFO.Beamer", "UFO.LASER" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		EnemyMonsterUnit = { "PVICE", "IMP", "IMP", "IMP", "REVE", "REVE", "BSPI", "BSPI", "PINKY", "MANC" }
		CustomHeliDelayTimemin = 18
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		CustomHeliDelayTimemin = 15
		EnemyCustomHeliUnit = { "UFO.Beamer", "UFO.Beamer", "UFO.LASER", "UFO.LASER", "UFO" }
		CustomHeavyDelayTimemin = 25
		CustomHeavyDelayTimemax = 27
		EnemyCustomHeavyUnit = { "mechwarrior", "mechwarrior" }
		EnemyCustomHeavyIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		EnemyMonsterUnit = { "IMP", "IMP", "IMP", "REVE", "REVE", "BSPI", "BSPI", "BSPI", "PINKY", "MANC" }
		CustomHeliDelayTimemin = 13
		EnemyCustomHeliUnit = { "UFO.Beamer", "UFO.Beamer", "UFO.LASER", "UFO.LASER", "UFO" }
		EnemyCustomHeavyUnit = { "mechwarrior", "exciter" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		CustomHeliDelayTimemin = 11
		EnemyCustomHeliUnit = { "UFO.Beamer", "UFO.LASER", "UFO" }
		EnemyCustomHeavyUnit = { "mechwarrior", "exciter" }
		MonsterDelayTimemin = 6
	end)
end
-- "UFO.Beamer" "UFO.LASER" "UFO"
AntConditions = function()
	AntDelayTimemin = 3
	AntDelayTimemax = 5
	EnemyAntUnit = { "ant", "scoutant" }
	EnemyAntIncome()
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		EnemyAntUnit = { "ant", "scoutant", "warriorant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "warriorant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		AntDelayTimemin = 4
		BurningConditioner()
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		AntDelayTimemin = 3
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		AntDelayTimemin = 5
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		AntDelayTimemin = 4
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		AntDelayTimemin = 5
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant", "lavaant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		AntDelayTimemin = 4
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant", "lavaant", "lavaant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		AntDelayTimemin = 3
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant", "lavaant", "lavaant", "lavaant" }
	end)
end

DinoConditions = function()
	DinoDelayTimemin = 5
	DinoDelayTimemax = 7
	EnemyDinoUnit = { "GALLIMUS", "GALLIMUS" }
	EnemyDinoIncome()
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		DinoDelayTimemin = 7
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "GALLIMUS", "GALLIMUS", "PARAUSAR" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(2), function()
		DinoDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "GALLIMUS", "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		DinoDelayTimemin = 8
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS", "ALLOSAURUS" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS", "ALLOSAURUS", "TYREX" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS", "ALLOSAURUS", "TYREX" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		DinoDelayTimemin = 7
		EnemyDinoUnit = { "GALLIMUS", "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS", "ALLOSAURUS", "TYREX", "BRACHIOSAURUS" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		DinoDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		DinoDelayTimemin = 6
		EnemyDinoUnit = { "GALLIMUS", "PARAUSAR", "STEGOSAUR", "TRICERATOPS", "ALLOSAURUS", "TYREX", "BRACHIOSAURUS" }
	end)
end

AllieUnits = true
SovietUnits = true
GdiUnits = false
NodUnits = false
MonsterUnits = true
AntUnits = false
DinoUnits = false

UnitAmountCheck = function()
	AllieUnitsAmount()
	SovietUnitsAmount()
--	GdiUnitsAmount()
--	NodUnitsAmount()
	MonsterAmount()
--	AntAmount()
--	DinoAmount()
	Light = 0
	Trigger.AfterDelay(1, function()
		if AllieUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				AllieunitsConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					AllieWaveInterrupter()
				end)
			end)
		end
		if SovietUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				SovietunitsConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					SovietWaveInterrupter()
				end)
			end)
		end
		if GdiUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				GdiunitsConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					GdiWaveInterrupter()
				end)
			end)
		end
		if NodUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				NodunitsConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					NodWaveInterrupter()
				end)
			end)
		end
		if MonsterUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				MonsterConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					MonsterWaveInterrupter()
				end)
			end)
		end
		if AntUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				AntConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					AntWaveInterrupter()
				end)
			end)
		end
		if DinoUnits then
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
				DinoConditions()
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					DinoWaveInterrupter()
				end)
			end)
		end
		if SneakAttacks then
			SneakattackConditions()
		end
	end)
end
Difficulty = Map.LobbyOption("difficulty")
ChosenAllieAmount = Map.LobbyOption("allieamount")
ChosenSovietAmount = Map.LobbyOption("sovietamount")
--ChosenGdiAmount = Map.LobbyOption("gdiamount")
--ChosenNodAmount = Map.LobbyOption("nodamount")
ChosenMonsterAmount = Map.LobbyOption("monsteramount")
--ChosenAntAmount = Map.LobbyOption("antamount")
--ChosenDinoAmount = Map.LobbyOption("dinoamount")

AllieUnitsAmount = function()
	if ChosenAllieAmount == "100%" then
		AllieWaveInterval = 0
	elseif ChosenAllieAmount == "90%" then
		AllieWaveInterval = 1
	elseif ChosenAllieAmount == "80%" then
		AllieWaveInterval = 2
	elseif ChosenAllieAmount == "70%" then
		AllieWaveInterval = 3
	elseif ChosenAllieAmount == "60%" then
		AllieWaveInterval = 4
	elseif ChosenAllieAmount == "50%" then
		AllieWaveInterval = 5
	elseif ChosenAllieAmount == "40%" then
		AllieWaveInterval = 6
	elseif ChosenAllieAmount == "30%" then
		AllieWaveInterval = 7
	elseif ChosenAllieAmount == "20%" then
		AllieWaveInterval = 8
	elseif ChosenAllieAmount == "10%" then
		AllieWaveInterval = 9
	elseif ChosenAllieAmount == "0" then
		AllieUnits = false
		AllieWaveInterval = 10
	end
	AllieUnitPercent = 10 - AllieWaveInterval
end

SovietUnitsAmount = function()
	if ChosenSovietAmount == "100%" then
		SovietWaveInterval = 0
	elseif ChosenSovietAmount == "90%" then
		SovietWaveInterval = 1
	elseif ChosenSovietAmount == "80%" then
		SovietWaveInterval = 2
	elseif ChosenSovietAmount == "70%" then
		SovietWaveInterval = 3
	elseif ChosenSovietAmount == "60%" then
		SovietWaveInterval = 4
	elseif ChosenSovietAmount == "50%" then
		SovietWaveInterval = 5
	elseif ChosenSovietAmount == "40%" then
		SovietWaveInterval = 6
	elseif ChosenSovietAmount == "30%" then
		SovietWaveInterval = 7
	elseif ChosenSovietAmount == "20%" then
		SovietWaveInterval = 8
	elseif ChosenSovietAmount == "10%" then
		SovietWaveInterval = 9
	elseif ChosenSovietAmount == "0" then
		SovietUnits = false
		SovietWaveInterval = 10
	end
	SovietUnitPercent = 10 - SovietWaveInterval
end

GdiUnitsAmount = function()
	if ChosenGdiAmount == "100%" then
		GdiWaveInterval = 0
	elseif ChosenGdiAmount == "90%" then
		GdiWaveInterval = 1
	elseif ChosenGdiAmount == "80%" then
		GdiWaveInterval = 2
	elseif ChosenGdiAmount == "70%" then
		GdiWaveInterval = 3
	elseif ChosenGdiAmount == "60%" then
		GdiWaveInterval = 4
	elseif ChosenGdiAmount == "50%" then
		GdiWaveInterval = 5
	elseif ChosenGdiAmount == "40%" then
		GdiWaveInterval = 6
	elseif ChosenGdiAmount == "30%" then
		GdiWaveInterval = 7
	elseif ChosenGdiAmount == "20%" then
		GdiWaveInterval = 8
	elseif ChosenGdiAmount == "10%" then
		GdiWaveInterval = 9
	elseif ChosenGdiAmount == "0" then
		GdiUnits = false
		GdiWaveInterval = 10
	end
	GdiUnitPercent = 10 - GdiWaveInterval
end

NodUnitsAmount = function()
	if ChosenNodAmount == "100%" then
		NodWaveInterval = 0
	elseif ChosenNodAmount == "90%" then
		NodWaveInterval = 1
	elseif ChosenNodAmount == "80%" then
		NodWaveInterval = 2
	elseif ChosenNodAmount == "70%" then
		NodWaveInterval = 3
	elseif ChosenNodAmount == "60%" then
		NodWaveInterval = 4
	elseif ChosenNodAmount == "50%" then
		NodWaveInterval = 5
	elseif ChosenNodAmount == "40%" then
		NodWaveInterval = 6
	elseif ChosenNodAmount == "30%" then
		NodWaveInterval = 7
	elseif ChosenNodAmount == "20%" then
		NodWaveInterval = 8
	elseif ChosenNodAmount == "10%" then
		NodWaveInterval = 9
	elseif ChosenNodAmount == "0" then
		NodUnits = false
		NodWaveInterval = 10
	end
	NodUnitPercent = 10 - NodWaveInterval
end

MonsterAmount = function()
	if ChosenMonsterAmount == "100%" then
		MonsterWaveInterval = 0
	elseif ChosenMonsterAmount == "90%" then
		MonsterWaveInterval = 1
	elseif ChosenMonsterAmount == "80%" then
		MonsterWaveInterval = 2
	elseif ChosenMonsterAmount == "70%" then
		MonsterWaveInterval = 3
	elseif ChosenMonsterAmount == "60%" then
		MonsterWaveInterval = 4
	elseif ChosenMonsterAmount == "50%" then
		MonsterWaveInterval = 5
	elseif ChosenMonsterAmount == "40%" then
		MonsterWaveInterval = 6
	elseif ChosenMonsterAmount == "30%" then
		MonsterWaveInterval = 7
	elseif ChosenMonsterAmount == "20%" then
		MonsterWaveInterval = 8
	elseif ChosenMonsterAmount == "10%" then
		MonsterWaveInterval = 9
	elseif ChosenMonsterAmount == "0" then
		MonsterUnits = false
		MonsterWaveInterval = 10
	end
	MonsterUnitPercent = 10 - MonsterWaveInterval
end
AntAmount = function()
	if ChosenAntAmount == "100%" then
		AntWaveInterval = 0
	elseif ChosenAntAmount == "90%" then
		AntWaveInterval = 1
	elseif ChosenAntAmount == "80%" then
		AntWaveInterval = 2
	elseif ChosenAntAmount == "70%" then
		AntWaveInterval = 3
	elseif ChosenAntAmount == "60%" then
		AntWaveInterval = 4
	elseif ChosenAntAmount == "50%" then
		AntWaveInterval = 5
	elseif ChosenAntAmount == "40%" then
		AntWaveInterval = 6
	elseif ChosenAntAmount == "30%" then
		AntWaveInterval = 7
	elseif ChosenAntAmount == "20%" then
		AntWaveInterval = 8
	elseif ChosenAntAmount == "10%" then
		AntWaveInterval = 9
	elseif ChosenAntAmount == "0" then
		AntUnits = false
		AntWaveInterval = 10
	end
	AntUnitPercent = 10 - AntWaveInterval
end
DinoAmount = function()
	if ChosenDinoAmount == "100%" then
		DinoWaveInterval = 0
	elseif ChosenDinoAmount == "90%" then
		DinoWaveInterval = 1
	elseif ChosenDinoAmount == "80%" then
		DinoWaveInterval = 2
	elseif ChosenDinoAmount == "70%" then
		DinoWaveInterval = 3
	elseif ChosenDinoAmount == "60%" then
		DinoWaveInterval = 4
	elseif ChosenDinoAmount == "50%" then
		DinoWaveInterval = 5
	elseif ChosenDinoAmount == "40%" then
		DinoWaveInterval = 6
	elseif ChosenDinoAmount == "30%" then
		DinoWaveInterval = 7
	elseif ChosenDinoAmount == "20%" then
		DinoWaveInterval = 8
	elseif ChosenDinoAmount == "10%" then
		DinoWaveInterval = 9
	elseif ChosenDinoAmount == "0" then
		DinoUnits = false
		DinoWaveInterval = 10
	end
	DinoUnitPercent = 10 - DinoWaveInterval
end

PeaceTime = false
MonsterPeaceTime = false
DinoPeaceTime = false
AntPeaceTime = false
AllieWaveInterrupter = function()
	AlliePeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(AllieWaveInterval), function()
		AlliePeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		AllieWaveInterrupter()
	end)
end

SovietWaveInterrupter = function()
	SovietPeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(SovietWaveInterval), function()
		SovietPeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		SovietWaveInterrupter()
	end)
end

GdiWaveInterrupter = function()
	GdiPeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(GdiWaveInterval), function()
		GdiPeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		GdiWaveInterrupter()
	end)
end

NodWaveInterrupter = function()
	NodPeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(NodWaveInterval), function()
		NodPeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		NodWaveInterrupter()
	end)
end

MonsterWaveInterrupter = function()
	MonsterPeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(MonsterWaveInterval), function()
		MonsterPeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		MonsterWaveInterrupter()
	end)
end
AntWaveInterrupter = function()
	AntPeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(AntWaveInterval), function()
		AntPeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		AntWaveInterrupter()
	end)
end
DinoWaveInterrupter = function()
	DinoPeaceTime = true
	Trigger.AfterDelay(DateTime.Seconds(DinoWaveInterval), function()
		DinoPeaceTime = false
	end)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		DinoWaveInterrupter()
	end)
end

-- &&

SneakattackConditions = function()
	Trigger.AfterDelay(DateTime.Minutes(3), function()
		if Difficulty == "hard" then
			SpecialminTime = 35
			SpecialmaxTime = 45
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }
			SpecialAttack()
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		if Difficulty == "hard" then
			SpecialminTime = 30
			SpecialmaxTime = 35
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7 }
		elseif Difficulty == "normal" then
			SpecialminTime = 35
			SpecialmaxTime = 45
			AnySpecialattack = { 1, 2, 3, 4, 5 }
			SpecialAttack()
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		if Difficulty == "hard" then
			SpecialminTime = 25
			SpecialmaxTime = 30
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7 }
		elseif Difficulty == "normal" then
			SpecialminTime = 30
			SpecialmaxTime = 35
			AnySpecialattack = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }
		elseif Difficulty == "easy" then
			SpecialminTime = 40
			SpecialmaxTime = 50
			AnySpecialattack = { 1, 2, 3, 4, 5 }
			SpecialAttack()
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		if Difficulty == "hard" then
			SpecialminTime = 22
			SpecialmaxTime = 27
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8 }
		elseif Difficulty == "normal" then
			SpecialminTime = 27
			SpecialmaxTime = 33
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7 }
		elseif Difficulty == "easy" then
			SpecialminTime = 37
			SpecialmaxTime = 48
			AnySpecialattack = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 }
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(7), function()
		if Difficulty == "hard" then
			SpecialminTime = 20
			SpecialmaxTime = 25
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 6, 7, 8, 6, 7, 8, 9, 10 }
		elseif Difficulty == "normal" then
			SpecialminTime = 25
			SpecialmaxTime = 30
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8 }
		elseif Difficulty == "easy" then
			SpecialminTime = 35
			SpecialmaxTime = 45
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7 }
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		if Difficulty == "hard" then
			SpecialminTime = 19
			SpecialmaxTime = 24
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11 }
		elseif Difficulty == "normal" then
			SpecialminTime = 22
			SpecialmaxTime = 28
			AnySpecialattack = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10 }
		elseif Difficulty == "easy" then
			SpecialminTime = 33
			SpecialmaxTime = 40
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8 }
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		if Difficulty == "hard" then
			SpecialminTime = 18
			SpecialmaxTime = 23
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11 }
		elseif Difficulty == "normal" then
			SpecialminTime = 20
			SpecialmaxTime = 25
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 11 }
		elseif Difficulty == "easy" then
			SpecialminTime = 31
			SpecialmaxTime = 39
			AnySpecialattack = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10 }
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		if Difficulty == "hard" then
			SpecialminTime = 17
			SpecialmaxTime = 22
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 12 }
		elseif Difficulty == "normal" then
			SpecialminTime = 18
			SpecialmaxTime = 23
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11 }
		elseif Difficulty == "easy" then
			SpecialminTime = 28
			SpecialmaxTime = 36
			AnySpecialattack = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 6, 7, 8, 6, 7, 8, 9, 10 }
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(11), function()
		if Difficulty == "hard" then
			SpecialminTime = 16
			SpecialmaxTime = 21
			AnySpecialattack = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
		elseif Difficulty == "normal" then
			SpecialminTime = 17
			SpecialmaxTime = 22
			AnySpecialattack = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 12 }
		elseif Difficulty == "easy" then
			SpecialminTime = 25
			SpecialmaxTime = 35
			AnySpecialattack = { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 6, 7, 8, 6, 7, 8, 9, 10, 6, 7, 8, 6, 7, 8, 9, 10 }
		end
	end)
	Trigger.AfterDelay(DateTime.Minutes(12), function()
		if Difficulty == "hard" then
			SpecialminTime = 13
			SpecialmaxTime = 18
			AnySpecialattack = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 6, 7, 8, 9, 10, 11, 12 }
		elseif Difficulty == "normal" then
			SpecialminTime = 16
			SpecialmaxTime = 21
			AnySpecialattack = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
		elseif Difficulty == "easy" then
			SpecialminTime = 22
			SpecialmaxTime = 33
			AnySpecialattack = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
		end
	end)
end

SpecialAttack = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(SpecialminTime, SpecialmaxTime)), function()
		EnemySpecialattack =  Utils.Random(AnySpecialattack)
		if EnemySpecialattack == 1 and not GameIsOver then
			SendParabombs()
		end
		if EnemySpecialattack == 2 and not GameIsOver then
			TargetAirstrikeHelis()
		end
		if EnemySpecialattack == 3 and not GameIsOver then
			TargetAirstrikeYaks()
		end
		if EnemySpecialattack == 4 and not GameIsOver then
			SendParatroopers()
		end
		if EnemySpecialattack == 5 and not GameIsOver then
			SendParazombies()
		end
		if EnemySpecialattack == 6 and not GameIsOver then
			SneakHeils()
		end
		if EnemySpecialattack == 7 and not GameIsOver then
			SneakApcs()
		end
		if EnemySpecialattack == 8 and not GameIsOver then
			StealthTanya()
		end
		if EnemySpecialattack == 9 and not GameIsOver then
			IronCurtain()
		end
		if EnemySpecialattack == 10 and not GameIsOver then
			Chronotanks()
		end
		if EnemySpecialattack == 11 and not GameIsOver then
			Demotruckincome()
		end
		if EnemySpecialattack == 12 and not GameIsOver then
			DropBomb()
		end
		Trigger.AfterDelay(DateTime.Seconds(10), function()
			SpecialAttack()
		end)
	end)
end

SendParabombs = function()
	DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)), Owner = Neutral })
	ParaProxy1 = Actor.Create("powerproxy.parabombs", false, { Owner = Enemys })
	units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
end
TargetAirstrikeHelis = function()
	DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)), Owner = Neutral })
	ParaProxy1 = Actor.Create("powerproxy.parahelis", false, { Owner = Enemys })
	units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
end
TargetAirstrikeYaks = function()
	DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)), Owner = Neutral })
	ParaProxy1 = Actor.Create("powerproxy.parayaks", false, { Owner = Enemys })
	units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
end
SendParatroopers = function()
	DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)), Owner = Neutral })
	ParaProxy1 = Actor.Create("powerproxy.paratroopers", false, { Owner = Enemys })
	units1 = ParaProxy1.TargetParatroopers(DetonationPoint1.CenterPosition)
	Utils.Do(units1, function(a)
		Trigger.OnPassengerExited(a, function(t, p)
			IdleHunt(p)
		end)
	end)
end
SendParazombies = function()
	DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)), Owner = Neutral })
	ParaProxy1 = Actor.Create("powerproxy.parazombies", false, { Owner = Enemys })
	units2 = ParaProxy1.TargetParatroopers(DetonationPoint1.CenterPosition)
	Utils.Do(units2, function(a)
		Trigger.OnPassengerExited(a, function(t, p)
			IdleHunt(p)
		end)
	end)
end

SneakHeils = function()
	local Topsneakheliunits = Reinforcements.ReinforceWithTransport(Enemys, "tran", HeliReinforcements, { CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)), CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)) }, { CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)) })[2]
	Utils.Do(Topsneakheliunits, function(unit)
		BindActorTriggers(unit)
	end)
end

SneakApcs = function()
	local Topsneakapcunits = Reinforcements.ReinforceWithTransport(Enemys, "apc", ApcReinforcements, { CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)), CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)) }, { CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)) })[2]
	Utils.Do(Topsneakapcunits, function(unit)
		BindActorTriggers(unit)
	end)
end

ICTime = false
IronCurtain = function()
	ICTime = true
	Media.PlaySound("ironcur9.aud")
	Trigger.AfterDelay(DateTime.Seconds(IcDuration), function()
		ICTime = false
	end)
end

StealthTanya = function()
	local TopTanya = Reinforcements.ReinforceWithTransport(Enemys, "stnk", Tanya, { CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)), CPos.New(10,17) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 80)) }, { CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)) })[2]
	Utils.Do(TopTanya, function(unit)
		BindActorTriggers(unit)
	end)
end

Chronotanks = function()
	ChronoPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(4,20) + CVec.New(Utils.RandomInteger(0, 6), Utils.RandomInteger(0, 72)), Owner = Neutral })
	Trigger.AfterDelay(Utils.RandomInteger(1, 88), function()
		Chronotank2 = Actor.Create("CTNK", true, { Location = ChronoPoint1.Location + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), Owner = Enemys })
		Chronotank2.Scatter()
		Chronotank2.Hunt()
		Media.PlaySound("chrotnk1.aud")
	end)
	Trigger.AfterDelay(Utils.RandomInteger(1, 88), function()
		Chronotank3 = Actor.Create("CTNK", true, { Location = ChronoPoint1.Location + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), Owner = Enemys })
		Chronotank3.Scatter()
		Chronotank3.Hunt()
		Media.PlaySound("chrotnk1.aud")
	end)
	if Difficulty ~= "easy" then
		Trigger.AfterDelay(Utils.RandomInteger(1, 88), function()
			Chronotank4 = Actor.Create("CTNK", true, { Location = ChronoPoint1.Location + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), Owner = Enemys })
			Chronotank4.Scatter()
			Chronotank4.Hunt()
			Media.PlaySound("chrotnk1.aud")
		end)
	end
	if Difficulty == "hard" then
		Trigger.AfterDelay(Utils.RandomInteger(1, 88), function()
			Chronotank5 = Actor.Create("CTNK", true, { Location = ChronoPoint1.Location + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), Owner = Enemys })
			Chronotank5.Scatter()
			Chronotank5.Hunt()
			Media.PlaySound("chrotnk1.aud")
		end)
	end
	Trigger.AfterDelay(Utils.RandomInteger(100, 120), function()
		Media.PlaySpeechNotification( allplayers, "ChronosphereTestSuccessful")
		ChronoPoint1.Destroy()
	end)
end
Demotruckincome = function()
	AttackpathM = { CPos.New(8,50) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(8,22) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(8,91) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)) }
	DemoN = Actor.Create("dtrk", true, { Location = CPos.New(150,1) + CVec.New(0, Utils.RandomInteger(0, 99)), Owner = Enemys })
	DtrukN = { DemoN }
	MovePatrol(DtrukN, AttackpathM, DateTime.Seconds(3))
end
DropBomb = function()
	if not MSiloKilled then
		DetonationPoint = Actor.Create("waypoint", true, { Location = CPos.New(5,20) + CVec.New(Utils.RandomInteger(0, 15), Utils.RandomInteger(0, 70)), Owner = Neutral })
		BomB = MSilo.ActivateNukePower(DetonationPoint.Location)
		Media.PlaySpeechNotification( allplayers, "AbombLaunchDetected")
	end
end

BindActorTriggers = function(a)
	if a.HasProperty("Hunt") then
		if a.Owner == Enemys then
			Trigger.OnIdle(a, function(a)
				if a.IsInWorld then
					a.Hunt()
				end
			end)
		else
			Trigger.OnIdle(a, function(a)
				if a.IsInWorld then
					a.AttackMove(CPos.New(12,20) + CVec.New(Utils.RandomInteger(0, 10), Utils.RandomInteger(0, 75)))
				end
			end)
		end
	end
	if a.HasProperty("HasPassengers") then
		Trigger.OnPassengerExited(a, function(t, p)
			BindActorTriggers(p)
		end)

		Trigger.OnDamaged(a, function()
			if a.HasPassengers and a.Type ~= "tran" then
				a.Stop()
				a.UnloadPassengers()
			end
		end)
	end
end

IdleHunt = function(actor)
	Trigger.OnIdle(actor, function(a)
		if a.IsInWorld then
			a.Hunt()
		end
	end)
end

GroupPatrol = function(units, waypoints, delay) 
	local i = 1
	local stop = false

	Utils.Do(units, function(unit)
		Trigger.OnIdle(unit, function()
			if stop then
				return
			end
			if unit.Location == waypoints[i] then
				local bool = Utils.All(units, function(actor) return actor.IsIdle end)
				if bool then
					stop = true
					i = i + 1
					if i > #waypoints then
						i = 1
					end
					Trigger.AfterDelay(delay, function() stop = false end)
				end
			else
				unit.AttackMove(waypoints[i])
			end
		end)
	end)
end

MovePatrol = function(units, waypoints, delay) 
	local i = 1
	local stop = false

	Utils.Do(units, function(unit)
		Trigger.OnIdle(unit, function()
			if stop then
				return
			end
			if unit.Location == waypoints[i] then
				local bool = Utils.All(units, function(actor) return actor.IsIdle end)
				if bool then
					stop = true
					i = i + 1
					if i > #waypoints then
						i = 1
					end
					Trigger.AfterDelay(delay, function() stop = false end)
				end
			else
				unit.Move(waypoints[i])
			end
		end)
	end)
end

DestroyedBuildings1 = 0
DestroyedBuildings2 = 0
GameIsOver = false

Musictracks = { "track1", "track2", "track3" }
StartMusic1 = function()
	RandomTrack1 = Utils.Random(Musictracks)
	Media.PlayMusic(RandomTrack1)
	if RandomTrack1 == "track1" or RandomTrack1 == "track2" then
		PlayTime = 300
	else
		PlayTime = 218
	end
	Trigger.AfterDelay(DateTime.Seconds(PlayTime), function()
		StartMusic2()
	end)
end

StartMusic2 = function()
	RandomTrack2 = Utils.Random(Musictracks)
	if RandomTrack2 == RandomTrack1 then
		StartMusic2()
		return
	end
	Media.PlayMusic(RandomTrack2)
	if RandomTrack2 == "track1" or RandomTrack2 == "track2" then
		PlayTime = 300
	else
		PlayTime = 218
	end
	Trigger.AfterDelay(DateTime.Seconds(PlayTime), function()
		StartMusic3()
	end)
end

StartMusic3 = function()
	RandomTrack3 = Utils.Random(Musictracks)
	if RandomTrack3 == RandomTrack1 or RandomTrack3 == RandomTrack2 then
		StartMusic3()
		return
	end
	Media.PlayMusic(RandomTrack3)
	if RandomTrack2 == "track1" or RandomTrack2 == "track2" then
		PlayTime = 300
	else
		PlayTime = 218
	end
	Trigger.AfterDelay(DateTime.Seconds(PlayTime), function()
		StartMusic1()
	end)
end

SetCamera = function(Multi)
	local mainbase = Multi.GetActorsByType("fact")[1]
	if mainbase ~= nil then
		Camera.Position = mainbase.CenterPosition
	end
end
Year = 2022
Season = Map.LobbyOption("season")
RedLight = 1
BlueLight = 1
GreenLight = 1
--																 Weatherfunctions

InitialiseWeather = function()
	if Season == "spring" then
		Month = 3
		Light = 0.91
		RedLight = 0.95
		GreenLight = 1.07
		BlueLight = 1.07
	elseif Season == "summer" then
		Month = 6
		Light = 0.93
		RedLight = 1.09
		GreenLight = 0.94
		BlueLight = 0.97
	elseif Season == "fall" or Season == "defmode" then
		Month = 9
		Light = 0.89
		RedLight = 1.05
		GreenLight = 0.93
		BlueLight = 1.04
	elseif Season == "winter"then
		StartingWinter()
		Month = 12
		Light = 0.88
		RedLight = 1.03
		GreenLight = 1.07
		BlueLight = 1.08
	end
	ColorChangeSpeed = 28
	MonthConditions()
	ColorChanger()
	if Month > 7 then
		turnOffWeather()
	else
		turnOnWeather()
	end
end

RateOfIncrease = 0.001

AllTrees = {"t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "tc02", "tc05"}
AllNeedleTrees = {"t01", "t02", "t05", "t06", "t07", "t08", "t16", "tc01", "tc03", "tc04"}
AllBuildings = {"v01", "v02", "v03", "v04", "v05", "v06", "v07", "v08", "v09", "v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18"}
AllTNumbers = {"01", "02", "03", "04", "05", "06", "07", "08", "10", "11", "12", "13", "14", "15", "16", "17", "18"}
AllTCNumbers = {"01", "02", "03", "04", "05"}
AllVNumbers = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18"}
AllWinterStufft = {"t01winter", "t02winter", "t03winter", "t05winter", "t06winter", "t07winter", "t08winter", "t10winter", "t11winter", "t12winter", "t13winter", "t14winter", "t15winter", "t16winter", "t17winter"}
AllWinterStufftc = {"tc01winter", "tc02winter", "tc03winter", "tc04winter", "tc05winter"}
AllWinterStuffv = {"v01winter", "v02winter", "v03winter", "v04winter", "v05winter", "v06winter", "v07winter", "v08winter", "v09winter", "v10winter", "v11winter", "v12winter", "v13winter", "v14winter", "v15winter", "v16winter", "v17winter", "v18winter"}

AprilTrees = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 210)), function()
					if not tree.IsDead and tree.IsInWorld and tree.HasProperty("GrantCondition") and tree.AcceptsCondition("spring2") then
						tree.GrantCondition("spring2", 0)
					end
				end)
			end
		end
	end
end

MaiTrees = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 380)), function()
					if not tree.IsDead and tree.IsInWorld and tree.HasProperty("GrantCondition") and tree.AcceptsCondition("summer") then
						tree.GrantCondition("summer", 0)
					end
				end)
			end
		end
	end
end

SeptemberTrees = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 290)), function()
					if not tree.IsDead and tree.IsInWorld and tree.HasProperty("GrantCondition") and tree.AcceptsCondition("fall") then
						tree.GrantCondition("fall", 0)
					end
				end)
			end
		end
	end
end

OktoberTrees = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 320)), function()
					if not tree.IsDead and tree.IsInWorld and tree.HasProperty("GrantCondition") and tree.AcceptsCondition("fall2") then
						tree.GrantCondition("fall2", 0)
					end
				end)
			end
		end
	end
end

NovemberTrees = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 30)), function()
					if not tree.IsDead and tree.IsInWorld then
						Newtree = Actor.Create(tree.Type .. "winter" , true, { Location = tree.Location, Owner = Neutral })
						tree.Destroy()
					end
				end)
			end
		end
	end
end

StartingWinter = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				Newtree = Actor.Create(tree.Type .. "winter" , true, { Location = tree.Location, Owner = Neutral })
				tree.Destroy()
			end
		end
	end
	for i=1,#AllNeedleTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllNeedleTrees[i])
			for p,tree in pairs(Trees) do
				Newtree = Actor.Create(tree.Type .. "winter" , true, { Location = tree.Location, Owner = Neutral })
				tree.Destroy()
			end
		end
	end
	for i=1,#AllBuildings do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllBuildings[i])
			for p,tree in pairs(Trees) do
				Newtree = Actor.Create(tree.Type .. "winter" , true, { Location = tree.Location, Owner = Neutral })
				tree.Destroy()
			end
		end
	end
end

NeedleTrees = function()
	for i=1,#AllNeedleTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllNeedleTrees[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 30)), function()
					if not tree.IsDead and tree.IsInWorld then
						Newtree = Actor.Create(tree.Type .. "winter" , true, { Location = tree.Location, Owner = Neutral })
						tree.Destroy()
					end
				end)
			end
		end
	end
	for i=1,#AllBuildings do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllBuildings[i])
			for p,tree in pairs(Trees) do
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 30)), function()
					if not tree.IsDead and tree.IsInWorld then
						Newtree = Actor.Create(tree.Type .. "winter" , true, { Location = tree.Location, Owner = Neutral })
						tree.Destroy()
					end
				end)
			end
		end
	end
end

ChangeSpringTrees = function()
	for u=1,#AllWinterStufft do
		if u ~= nil then
			local Trees = Neutral.GetActorsByType(AllWinterStufft[u])
			for p,tree in pairs(Trees) do
				for i=1,#AllTNumbers do
					if tree.Type == "t0" .. i .. "winter" then
						Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
							if not tree.IsDead and tree.IsInWorld then
								Newtree = Actor.Create("t0" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
								if Newtree.HasProperty("GrantCondition") and Newtree.AcceptsCondition("spring") then
									Newtree.GrantCondition("spring", 0)
								end
								tree.Destroy()
							end
						end)
					elseif tree.Type == "t" .. i .. "winter" then
						Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
							if not tree.IsDead and tree.IsInWorld then
								Newtree = Actor.Create("t" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
								if Newtree.HasProperty("GrantCondition") and Newtree.AcceptsCondition("spring") then
									Newtree.GrantCondition("spring", 0)
								end
								tree.Destroy()
							end
						end)
					end
				end
			end
		end
	end
	for u=1,#AllWinterStufftc do
		if u ~= nil then
			local Trees = Neutral.GetActorsByType(AllWinterStufftc[u])
			for p,tree in pairs(Trees) do
				for i=1,#AllTCNumbers do
					if tree.Type == "tc0" .. i .. "winter" then
						Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
							if not tree.IsDead and tree.IsInWorld then
								Newtree = Actor.Create("tc0" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
								if Newtree.HasProperty("GrantCondition") and Newtree.AcceptsCondition("spring") then
									Newtree.GrantCondition("spring", 0)
								end
								tree.Destroy()
							end
						end)
					end
				end
			end
		end
	end
	for u=1,#AllWinterStuffv do
		if u ~= nil then
			local Trees = Neutral.GetActorsByType(AllWinterStuffv[u])
			for p,tree in pairs(Trees) do
				for i=1,#AllVNumbers do
					if tree.Type == "v" .. i .. "winter" then
						Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
							if not tree.IsDead and tree.IsInWorld then
								Newtree = Actor.Create("v" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
								tree.Destroy()
							end
						end)
					elseif tree.Type == "v0" .. i .. "winter" then
						Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
							if not tree.IsDead and tree.IsInWorld then
								Newtree = Actor.Create("v0" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
								tree.Destroy()
							end
						end)
					end
				end
			end
		end
	end
end


StartingSpringTrees = function()
	for i=1,#AllTrees do
		if i ~= nil then
			local Trees = Neutral.GetActorsByType(AllTrees[i])
			for p,tree in pairs(Trees) do
				if not tree.IsDead and tree.IsInWorld and tree.HasProperty("GrantCondition") and tree.AcceptsCondition("spring") then
					tree.GrantCondition("spring", 0)
				end
			end
		end
	end
end

MonthConditions = function()
	if Month == 1 then
		BrightnessChangeSpeed = 7
		ColorChangeSpeed = 16
		BrightestLight = 0.92
		DarkestLight = 0.55
		DayDuration = 5000
		NightDuration = 6000
		DesiredRed = 1
		DesiredGreen = 1
		DesiredBlue = 1
		MonthName = "Januar"
		ThunderRiskfactor = { 1, 2, 3 }
		TimerColor = HSLColor.Cyan
	elseif Month == 2 then
		Firstyear = true
		BrightnessChangeSpeed = 8
		ColorChangeSpeed = 18
		BrightestLight = 0.94
		DarkestLight = 0.58
		DayDuration = 5400
		NightDuration = 5500
		DesiredRed = 1.15
		DesiredGreen = 0.91
		DesiredBlue = 1.18
		MonthName = "Februar"
		ThunderRiskfactor = { 1, 2, 3 }
		TimerColor = HSLColor.Blue
--												Spring
	elseif Month == 3 then
		if not Firstyear then
			Firstyear = true
			StartingSpringTrees()
		else
			ChangeSpringTrees()
		end
		BrightnessChangeSpeed = 9
		ColorChangeSpeed = 20
		BrightestLight = 0.96
		DarkestLight = 0.60
		DayDuration = 5800
		NightDuration = 5000
		DesiredRed = 0.97
		DesiredGreen = 1.10
		DesiredBlue = 1.05
		MonthName = "Maerz"
		ThunderRiskfactor = { 1, 2, 3 }
		TimerColor = HSLColor.LawnGreen
	elseif Month == 4 then
		BrightnessChangeSpeed = 10
		ColorChangeSpeed = 22
		BrightestLight = 0.98
		DarkestLight = 0.62
		DayDuration = 6300
		NightDuration = 4900
		DesiredRed = 0.97
		DesiredGreen = 1.10
		DesiredBlue = 1.05
		MonthName = "April"
		AprilTrees()
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 11, 12, 13 }
		TimerColor = HSLColor.Green
	elseif Month == 5 then
		BrightnessChangeSpeed = 11
		ColorChangeSpeed = 25
		BrightestLight = 1.0
		DarkestLight = 0.65
		DayDuration = 6800
		NightDuration = 4300
		DesiredRed = 0.97
		DesiredGreen = 1.10
		DesiredBlue = 1.05
		MonthName = "Mai"
		MaiTrees()
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13 }
		TimerColor = HSLColor.LimeGreen
--												Summer
	elseif Month == 6 then
		BrightnessChangeSpeed = 12
		ColorChangeSpeed = 28
		BrightestLight = 1.03
		DarkestLight = 0.68
		DayDuration = 7300
		NightDuration = 3700
		DesiredRed = 1.15
		DesiredGreen = 1.15
		DesiredBlue = 0.95
		MonthName = "Juni"
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 12, 13 }
		TimerColor = HSLColor.LightYellow
	elseif Month == 7 then
		BrightnessChangeSpeed = 12
		ColorChangeSpeed = 26
		BrightestLight = 1.03
		DarkestLight = 0.68
		DayDuration = 7300
		NightDuration = 3700
		DesiredRed = 1.17
		DesiredGreen = 1.17
		DesiredBlue = 0.94
		MonthName = "Juli"
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 12, 13 }
		TimerColor = HSLColor.Gold
	elseif Month == 8 then
		BrightnessChangeSpeed = 11
		ColorChangeSpeed = 24
		BrightestLight = 1.0
		DarkestLight = 0.65
		DayDuration = 6800
		NightDuration = 4300
		DesiredRed = 1.13
		DesiredGreen = 1.1
		DesiredBlue = 0.93
		MonthName = "August"
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13 }
		TimerColor = HSLColor.DarkRed
--												Fall
	elseif Month == 9 then
		BrightnessChangeSpeed = 10
		ColorChangeSpeed = 22
		BrightestLight = 0.98
		DarkestLight = 0.62
		DayDuration = 6300
		NightDuration = 4900
		DesiredRed = 1.08
		DesiredGreen = 1.03
		DesiredBlue = 0.94
		MonthName = "September"
		SeptemberTrees()
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }
		TimerColor = HSLColor.DarkOrange
	elseif Month == 10 then
		BrightnessChangeSpeed = 9
		ColorChangeSpeed = 20
		BrightestLight = 0.96
		DarkestLight = 0.60
		DayDuration = 5800
		NightDuration = 5000
		DesiredRed = 1.13
		DesiredGreen = 1
		DesiredBlue = 0.97
		MonthName = "Oktober"
		OktoberTrees()
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13 }
		TimerColor = HSLColor.DarkGray
	elseif Month == 11 then
		BrightnessChangeSpeed = 8
		ColorChangeSpeed = 18
		BrightestLight = 0.94
		DarkestLight = 0.58
		DayDuration = 5400
		NightDuration = 5500
		DesiredRed = 1.14
		DesiredGreen = 0.97
		DesiredBlue = 1.04
		MonthName = "November"
		NovemberTrees()
		ThunderRiskfactor = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
		TimerColor = HSLColor.DarkGray
--								Winter
	elseif Month == 12 then
		BrightnessChangeSpeed = 7
		ColorChangeSpeed = 15
		BrightestLight = 0.92
		DarkestLight = 0.55
		DayDuration = 5000
		NightDuration = 6000
		DesiredRed = 1.15
		DesiredGreen = 0.93
		DesiredBlue = 1.12
		MonthName = "Dezember"
		ThunderRiskfactor = { 1, 2, 3 }
		TimerColor = HSLColor.White
	end
	Trigger.AfterDelay(5, function()
		Month = Month + 1
		if Month == 13 then
			Month = 1
			Year = Year + 1  -- Happy new year :D
		end
	end)
end

ColorChanger = function()
	if RedLight < DesiredRed then
		RedLight = RedLight + 0.001
	elseif RedLight > DesiredRed then
		RedLight = RedLight - 0.001
	end
	if GreenLight < DesiredGreen then
		GreenLight = GreenLight + 0.001
	elseif GreenLight > DesiredGreen then
		GreenLight = GreenLight - 0.001
	end
	if BlueLight < DesiredBlue then
		BlueLight = BlueLight + 0.001
	elseif BlueLight > DesiredBlue then
		BlueLight = BlueLight - 0.001
	end
	Lighting.Red = RedLight
	Lighting.Green = GreenLight
	Lighting.Blue = BlueLight
	Trigger.AfterDelay(ColorChangeSpeed, function()
		ColorChanger()
	end)
end

turnOnWeather = function()
	Lighting.Ambient = Light
	if Light < 0.794 and Light > 0.793 then
--		POWER.Destroy()
--		Trigger.AfterDelay(100, function()
--			Media.PlayMusic()
--		end)
	end
	if Light < BrightestLight and not PlayersWon then
		Light = Light + RateOfIncrease
		Trigger.AfterDelay(BrightnessChangeSpeed, function()
			turnOnWeather()
		end)

	else
		NoturnOnWeather = true
		Trigger.AfterDelay(DayDuration, function()
			turnOffWeather()
		end)
	end
end

turnOffWeather = function()
	if Light < 0.734 and Light > 0.733 then
		DesiredRed = 0.93
		DesiredGreen = 1.07
		DesiredBlue = 1.13
	end
	if Light < 0.734 and Light > 0.733 then
		GettingDark = true
--		POWER = Actor.Create("dummypower", true, { Location = CPos.New(0,0), Owner = Neutral })
		Trigger.AfterDelay(350, function()
			Media.StopMusic()
		end)
	end
	if Light < 0.691 and Light > 0.690 then
		ThunderManager()
	end
	if Light > DarkestLight and not PlayersWon then
		Light = Light - RateOfIncrease
		Trigger.AfterDelay(BrightnessChangeSpeed, function()
			turnOffWeather()
		end)
	else
		Trigger.AfterDelay(NightDuration, function()
			if Month == 12 then
				NeedleTrees()
			end
			NoturnOnWeather = false
			Thunderstorm = false
			MonthConditions()
			turnOnWeather()
		end)
	end
	Lighting.Ambient = Light
end
ThunderManager = function()
	ThunderstormRisk = Utils.Random(ThunderRiskfactor)
	if ThunderstormRisk == 11 then
		SmoothThunderstorm = true
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(45, 65)), function()
			SmoothThunderstorm = false
		end)
	elseif ThunderstormRisk == 12 then
		SmoothThunderstorm = true
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15, 30)), function()
			SmoothThunderstorm = false
			NormalThunderstorm = true
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(30, 60)), function()
				NormalThunderstorm = false
				SmoothThunderstorm = true
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15, 30)), function()
					SmoothThunderstorm = false
				end)
			end)
		end)
	elseif ThunderstormRisk == 13 then
		SmoothThunderstorm = true
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15, 30)), function()
			SmoothThunderstorm = false
			NormalThunderstorm = true
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(20, 30)), function()
				NormalThunderstorm = false
				HardThunderstorm = true
				Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(30, 60)), function()
					HardThunderstorm = false
					NormalThunderstorm = true
					Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15, 30)), function()
						NormalThunderstorm = false
						SmoothThunderstorm = true
						Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15, 30)), function()
							SmoothThunderstorm = false
						end)
					end)
				end)
			end)
		end)

	end
end

turnOn = function()
	Lighting.Ambient = Light
	if Light < 1 then
		Light = Light + 0.02
		Trigger.AfterDelay(1, function()
			turnOn()
		end)
	end
end
turnOff = function()
	Lighting.Ambient = Light
	if Light > 0.05 then
		Light = Light - 0.025
		Trigger.AfterDelay(1, function()
			turnOff()
		end)
	end
end

BurningConditioner = function()
	fireantz = Enemys.GetActorsByType("fireant")
	for p,fireants in pairs(fireantz) do
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 10)), function()
			if fireants.IsInWorld then fireants.GrantCondition("fireon", Utils.RandomInteger(43, 185)) end
		end)
	end
	lavaantz = Enemys.GetActorsByType("lavaant")
	for p,lavaants in pairs(lavaantz) do
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 10)), function()
			if lavaants.IsInWorld then lavaants.GrantCondition("fireon", Utils.RandomInteger(60, 235)) end
		end)
	end
	fireantz = Enemys.GetActorsByType("fireant")
	for p,fireants in pairs(fireantz) do
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 10)), function()
			if fireants.IsInWorld then fireants.GrantCondition("fireon", Utils.RandomInteger(43, 185)) end
		end)
	end
	lavaantz = Enemys.GetActorsByType("lavaant")
	for p,lavaants in pairs(lavaantz) do
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 10)), function()
			if lavaants.IsInWorld then lavaants.GrantCondition("fireon", Utils.RandomInteger(60, 235)) end
		end)
	end
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(12, 18)), function()
		BurningConditioner()
	end)
end

StartingMessages = function()
	Media.DisplayMessage("Defend your base against incoming forces and destroy the enemy's base to win the game!", "Materia", TimerColor)	
	Trigger.AfterDelay(DateTime.Seconds(8), function()
		Media.DisplayMessage("You can capture oil derricks by stepping close to the flag next to them.", "Materia", TimerColor)
	end)
	Trigger.AfterDelay(DateTime.Seconds(16), function()
		Media.DisplayMessage("Reduced charging times for all superpowers.", "Materia", TimerColor)
	end)
	Trigger.AfterDelay(DateTime.Seconds(24), function()
		Media.DisplayMessage("These are the enemy force amounts.\nAllie units: " .. AllieUnitPercent .. "0%\nSoviet units: " .. SovietUnitPercent .. "0%\nMonsters: " .. MonsterUnitPercent .. "0%", "Materia", TimerColor)
	end)
	Trigger.AfterDelay(DateTime.Seconds(29), function()
		Media.DisplayMessage("Difficulty is " .. Difficulty .. "", "Materia", TimerColor)
	end)
	Trigger.AfterDelay(DateTime.Seconds(36), function()
		Media.DisplayMessage("Sneakattacks are " .. SneakMessage .. "", "Materia", TimerColor)
	end)
end

DifficultieConditions = function()
	if Difficulty == "easy" then
		Media.PlayMusic("track1")
		Trigger.AfterDelay(DateTime.Minutes(5), function()
			Media.StopMusic()
			Media.PlayMusic("track2")
			Trigger.AfterDelay(DateTime.Minutes(5), function()
				Media.StopMusic()
				Media.PlayMusic("track3")
			end)
		end)
		AllieInfDelay = 4
		SovietInfDelay = 4
		GdiInfDelay = 3
		NodInfDelay = 3
		AllieVehDelay = 6
		SovietVehDelay = 6
		GdiVehDelay = 5
		NodVehDelay = 5
		AllieTnkDelay = 8
		SovietTnkDelay = 8
		GdiTnkDelay = 8
		NodTnkDelay = 8
		AllieArtyDelay = 10
		SovietArtyDelay = 10
		GdiArtyDelay = 10
		NodArtyDelay = 10
		AllieHeliDelay = 9
		SovietHeliDelay = 9
		GdiHeliDelay = 9
		NodHeliDelay = 9
		MonsterDelay = 7
		AntDelay = 6
		DinoDelay = 8
		CustomHeliDelay = 9
		CustomHeavyDelay = 9
		IcDuration = 1
		HeliReinforcements = { "e1", "e3", "e2", "e1" }
		ApcReinforcements = { "e3", "e2", "e1" }
		Tanya = { "e1", "e1", "e3", "medi" }
		TimerColor = HSLColor.LawnGreen
	end
	if Difficulty == "normal" then
		Media.PlayMusic("track2")
		Trigger.AfterDelay(DateTime.Minutes(5), function()
			Media.StopMusic()
			Media.PlayMusic("track3")
			Trigger.AfterDelay(DateTime.Minutes(5), function()
				Media.StopMusic()
				Media.PlayMusic("track1")
			end)
		end)
		AllieInfDelay = 2
		SovietInfDelay = 2
		GdiInfDelay = 1
		NodInfDelay = 1
		AllieVehDelay = 3
		SovietVehDelay = 3
		GdiVehDelay = 2
		NodVehDelay = 2
		AllieTnkDelay = 4
		SovietTnkDelay = 4
		GdiTnkDelay = 4
		NodTnkDelay = 4
		AllieArtyDelay = 5
		SovietArtyDelay = 5
		GdiArtyDelay = 5
		NodArtyDelay = 5
		AllieHeliDelay = 4
		SovietHeliDelay = 4
		GdiHeliDelay = 4
		NodHeliDelay = 4
		MonsterDelay = 3
		AntDelay = 3
		DinoDelay = 4
		CustomHeliDelay = 3
		CustomHeavyDelay = 3
		IcDuration = 20
		HeliReinforcements = { "e1", "e3", "e2", "e1", "e1", "e4" }
		ApcReinforcements = { "e3", "e2", "e1", "e1" }
		Tanya = { "e7" }
		TimerColor = HSLColor.Orange
	end
	if Difficulty == "hard" then
		Media.PlayMusic("track3")
		Trigger.AfterDelay(DateTime.Minutes(5), function()
			Media.StopMusic()
			Media.PlayMusic("track2")
			Trigger.AfterDelay(DateTime.Minutes(5), function()
				Media.StopMusic()
				Media.PlayMusic("track1")
			end)
		end)
		AllieInfDelay = 0
		SovietInfDelay = 0
		GdiInfDelay = 0
		NodInfDelay = 0
		AllieVehDelay = 0
		SovietVehDelay = 0
		GdiVehDelay = 0
		NodVehDelay = 0
		AllieTnkDelay = 0
		SovietTnkDelay = 0
		GdiTnkDelay = 0
		NodTnkDelay = 0
		AllieArtyDelay = 1
		SovietArtyDelay = 1
		GdiArtyDelay = 0
		NodArtyDelay = 0
		AllieHeliDelay = 1
		SovietHeliDelay = 1
		GdiHeliDelay = 0
		NodHeliDelay = 0
		MonsterDelay = 0
		AntDelay = 0
		DinoDelay = 0
		CustomHeliDelay = 0
		CustomHeavyDelay = 0
		IcDuration = 25
		HeliReinforcements = { "e1", "e3", "e2", "e1", "e1", "e1", "e4" }
		ApcReinforcements = { "e3", "e2", "e1", "e1", "e4" }
		Tanya = { "e7", "medi", "medi", "medi" }
		TimerColor = HSLColor.Red
	end
	if Difficulty ~= "easy" then
		RandomNukePosition = Utils.Random(NukePositions)
		MSilo = Actor.Create("mslo", true, { Location = RandomNukePosition + CVec.New(Utils.RandomInteger(0, 10), Utils.RandomInteger(0, 10)), Owner = Enemys })
		Trigger.OnDamaged(MSilo, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(MSilo, function() MSiloKilled = true end)
	end
end

function WorldLoaded()
	Media.StopMusic()
	SetupPlayers()
	DifficultieConditions()
	PlayerConquestConditions()
	UnitAmountCheck()
	GetandsetFlags()
	turnOn()
	CheckSneakAttacks()
	StartingMessages()
	if Season == "noweather" then
	else
		InitialiseWeather()
	end
end

TimerColor = HSLColor.Orange

Tick = function()
	if M0True then
		if DestroyedBuildingsM0 < buildingM0 then
			M0Text = "" .. Multi0.Name .. "   " .. (DestroyedBuildingsM0) .. " / " .. (buildingM0) .. " Enemy buildings destroyed\n"
		else
			M0Text = "" .. Multi0.Name .. "   won!\n"
		end
	elseif 	M0Dead then
			M0Text = "" .. Multi0.Name .. "   Dead!   " .. (DestroyedBuildingsM0) .. " / " .. (buildingM0) .. " Enemy buildings destroyed\n"
	else
		M0Text = "\n"
	end
	if M1True then
		if DestroyedBuildingsM1 < buildingM1 then
			M1Text = "" .. Multi1.Name .. "   " .. (DestroyedBuildingsM1) .. " / " .. (buildingM1) .. " Enemy buildings destroyed\n"
		else
			M1Text = "" .. Multi1.Name .. "   won!\n"
		end
	elseif 	M1Dead then
			M1Text = "" .. Multi1.Name .. "   Dead!   " .. (DestroyedBuildingsM1) .. " / " .. (buildingM1) .. " Enemy buildings destroyed\n"
	else
		M1Text = "\n"
	end
	if M2True then
		if DestroyedBuildingsM2 < buildingM2 then
			M2Text = "" .. Multi2.Name .. "   " .. (DestroyedBuildingsM2) .. " / " .. (buildingM2) .. " Enemy buildings destroyed\n"
		else
			M2Text = "" .. Multi2.Name .. "   won!\n"
		end
	elseif 	M2Dead then
			M2Text = "" .. Multi2.Name .. "   Dead!   " .. (DestroyedBuildingsM2) .. " / " .. (buildingM2) .. " Enemy buildings destroyed\n"
	else
		M2Text = "\n"
	end
	if M3True then
		if DestroyedBuildingsM3 < buildingM3 then
			M3Text = "" .. Multi3.Name .. "   " .. (DestroyedBuildingsM3) .. " / " .. (buildingM3) .. " Enemy buildings destroyed\n"
		else
			M3Text = "" .. Multi3.Name .. "   won!\n"
		end
	elseif 	M3Dead then
			M3Text = "" .. Multi3.Name .. "   Dead!   " .. (DestroyedBuildingsM3) .. " / " .. (buildingM3) .. " Enemy buildings destroyed\n"
	else
		M3Text = "\n"
	end
	if M4True then
		if DestroyedBuildingsM4 < buildingM4 then
			M4Text = "" .. Multi4.Name .. "   " .. (DestroyedBuildingsM4) .. " / " .. (buildingM4) .. " Enemy buildings destroyed"
		else
			M4Text = "" .. Multi4.Name .. "   won!"
		end
	elseif 	M4Dead then
			M4Text = "" .. Multi4.Name .. "   Dead!   " .. (DestroyedBuildingsM4) .. " / " .. (buildingM4) .. " Enemy buildings destroyed"
	else
		M4Text = ""
	end
	AllDestroyedBuildings = DestroyedBuildingsM0 + DestroyedBuildingsM1 + DestroyedBuildingsM2 + DestroyedBuildingsM3 + DestroyedBuildingsM4
	UserInterface.SetMissionText(M0Text .. M1Text .. M2Text .. M3Text .. M4Text, TimerColor)
	if AllDestroyedBuildings == AllEnemyBuildings then
		if not Goodwon then
			Goodwon = true
			PlayersWin()
		end
	end
	if DateTime.Minutes(1) >= 0 and Difficulty ~= "easy" and BioCount == 0 and MonsterUnits and not TripodSpawned then
		TripodSpawned = true
		MakeTripod()
	end
end
BioCount = 0