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(3), function()
		AllieInfDelayTimemin = 1


		AllieVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		AllieVehDelayTimemin = 5
		AllieVehUnit = { "1tnk", "1tnk", "jeep" }
		AllieTnkDelayTimemin = 12
		AllieTnkDelayTimemax = 14
		AllieTnkUnit = { "2tnk", "2tnk" }
		AllieTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		AllieInfUnit = { "e1", "e1", "e1", "e3", "e3", "medi", "mech" }
		AllieHeliDelayTimemin = 12
		AllieHeliDelayTimemax = 14
		AllieHeliUnit = { "mh60", "mh60" }
		AllieArtyDelayTimemin = 15
		AllieArtyDelayTimemax = 17
		AllieArtyUnit = { "arty", "arty" }
		AllieArtyIncome()
		AllieHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()

		AllieHeliUnit = { "heli", "mh60", "mh60" }
		AllieTnkUnit = { "2tnk", "2tnk", "ctnk", "2tnk" }
		AllieTnkDelayTimemin = 10
		AllieArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(7), function()
		AllieArtyDelayTimemin = 13


	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		AllieHeliUnit = { "heli", "mh60" }
		AllieTnkUnit = { "2tnk", "2tnk", "ctnk", "2tnk", "2tnk", "2tnk" }

	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		AllieVehUnit = { "1tnk", "1tnk", "1tnk", "jeep" }
		AllieVehDelayTimemin = 4
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), 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(3), function()
		SovietInfDelayTimemin = 1

		SovietVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		SovietInfUnit = { "e1", "e1", "e1", "e2", "e3", "e4", "dog" }
		SovietVehDelayTimemin = 5

		SovietTnkDelayTimemin = 12
		SovietTnkDelayTimemax = 14
		SovietTnkUnit = { "3tnk", "3tnk" }
		SovietTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		SovietVehUnit = { "apc", "ftrk", "ftrk" }
		SovietHeliDelayTimemin = 12
		SovietHeliDelayTimemax = 14
		SovietHeliUnit = { "yak", "yak" }
		SovietArtyDelayTimemin = 15
		SovietArtyDelayTimemax = 17
		SovietArtyUnit = { "v2rl", "v2rl" }
		SovietArtyIncome()
		SovietHeliIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		SovietInfUnit = { "e1", "e1", "shok", "e2", "e3", "e4", "dog" }

		SovietTnkUnit = { "3tnk", "3tnk", "3tnk", "ttnk", "4tnk" }
		SovietTnkDelayTimemin = 10
		SovietArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(7), function()
		SovietArtyDelayTimemin = 13
		SovietHeliUnit = { "yak", "yak", "yak", "mig" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		SovietTnkUnit = { "3tnk", "3tnk", "ttnk", "4tnk" }
		SovietVehUnit = { "apc", "ftrk", "ftrk", "ftrk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		SovietInfUnit = { "e1", "shok", "e2", "e3", "e4", "dog" }
		SovietHeliUnit = { "yak", "yak", "mig" }
		SovietVehDelayTimemin = 4
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), 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(3), function()
		GdiInfDelayTimemin = 1
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc" }
		GdiVehUnit = { "humv", "humv", "apccnc" }
		GdiVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		GdiVehDelayTimemin = 5
		GdiVehUnit = { "humv", "apccnc" }
		GdiTnkDelayTimemin = 12
		GdiTnkDelayTimemax = 14
		GdiTnkUnit = { "mtnk", "mtnk" }
		GdiTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), 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(6), function()
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "e2cnc", "e3cnc", "rmbo" }

		GdiTnkUnit = { "mtnk", "mtnk", "mtnk", "htnk" }
		GdiTnkDelayTimemin = 10
		GdiArtyDelayTimemin = 14
	end)
	Trigger.AfterDelay(DateTime.Minutes(7), function()
		GdiArtyDelayTimemin = 13
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "e3cnc", "rmbo" }
		GdiTnkUnit = { "mtnk", "mtnk", "htnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		GdiInfUnit = { "e1cnc", "e2cnc", "e3cnc", "rmbo" }
		GdiTnkUnit = { "mtnk", "htnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		GdiVehUnit = { "humv", "apccnc", "apccnc", "apccnc" }
		GdiVehDelayTimemin = 4
		GdiTnkUnit = { "mtnk", "htnk", "htnk" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), 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(3), function()
		NodInfDelayTimemin = 1
		NodInfUnit = { "e1cnc", "e1cnc", "e3cnc", "e4cnc" }
		NodVehUnit = { "bike", "bggy", "ftnkcnc" }
		NodVehDelayTimemin = 6
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		NodVehDelayTimemin = 5
		NodInfUnit = { "e1cnc", "e3cnc", "e4cnc" }

		NodTnkDelayTimemin = 12
		NodTnkDelayTimemax = 14
		NodTnkUnit = { "ltnk", "ltnk" }
		NodTnkIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), 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(6), function()
		NodInfUnit = { "e1cnc", "e3cnc", "e3cnc", "e4cnc", "e5cnc" }

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

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

		
	end)
end

-- &&

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

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(3), function()
		AntDelayTimemin = 4
		BurningConditioner()
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(4), function()
		AntDelayTimemin = 3
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
		AntDelayTimemin = 5
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(6), function()
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(7), function()
		AntDelayTimemin = 4
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(8), function()
		AntDelayTimemin = 5
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant", "lavaant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(9), function()
		AntDelayTimemin = 4
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant", "lavaant", "lavaant" }
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
		AntDelayTimemin = 3
		EnemyAntUnit = { "ant", "scoutant", "warriorant", "fireant", "toxicant", "electricant", "fireant", "toxicant", "electricant", "lavaant", "lavaant", "lavaant" }
	end)
end

DinoConditions = function()
    DinoDelayTimemin = 5
    if Difficulty == "easy" then
        DinoDelayTimemax = 9
        EnemyDinoUnit = { "gallimussm", "gallimussm", "gallimussm", "gallimus", "gallimus" }
    elseif Difficulty == "normal" then
        DinoDelayTimemax = 7
        EnemyDinoUnit = { "gallimussm", "gallimussm", "gallimus", "gallimus" }
    elseif Difficulty == "hard" then
        DinoDelayTimemax = 6
        EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg" }
    end
    Trigger.AfterDelay(DateTime.Seconds(30), function()
        EnemyDinoIncome()
    end)
    Trigger.AfterDelay(DateTime.Minutes(1), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimussm", "gallimus", "gallimus" }
        elseif Difficulty == "normal" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "gallimuslg" }
            EnemyParasaurusUnit = { "parasaursm", "parasaursm", "parasaursm", "parasaur" }
            ParasaurusDelayTimemin = 12
            ParasaurusDelayTimemax = 20
            EnemyParasaurusIncome()
        elseif Difficulty == "hard" then
            EnemyDinoUnit = { "gallimus", "gallimus", "gallimuslg" }
            EnemyParasaurusUnit = { "parasaursm", "parasaursm", "parasaur", "parasaur" }
            ParasaurusDelayTimemin = 11
            ParasaurusDelayTimemax = 19
            EnemyParasaurusIncome()
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(2), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus" }
            EnemyParasaurusUnit = { "parasaursm", "parasaursm", "parasaursm", "parasaur" }
            ParasaurusDelayTimemin = 14
            ParasaurusDelayTimemax = 22
            EnemyParasaurusIncome()
        elseif Difficulty == "normal" then
            ParasaurusDelayTimemin = 11
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "gallimuslg" }
            EnemyParasaurusUnit = { "parasaursm", "parasaursm", "parasaur" }
        elseif Difficulty == "hard" then
            ParasaurusDelayTimemin = 10
            EnemyDinoUnit = { "gallimus", "gallimus", "gallimuslg", "gallimuslg" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur" }
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(3), function()
        if Difficulty == "easy" then
            ParasaurusDelayTimemin = 13
        elseif Difficulty == "normal" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm" }
        elseif Difficulty == "hard" then
            DinoDelayTimemin = 4
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "gallimuslg", "gallimuslg", "stegosaursm", "triceratopssm",
                "triceratops", "stegosaur" }
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(4), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "gallimuslg" }
            EnemyParasaurusUnit = { "parasaursm", "parasaursm", "parasaur" }
        elseif Difficulty == "normal" then
            DinoDelayTimemin = 4
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur" }
            ParasaurusDelayTimemin = 10
            RepeatMultiplier = 0.45
        elseif Difficulty == "hard" then
            DinoDelayTimemin = 3
            EnemyDinoUnit = { "gallimus", "gallimuslg", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg" }
            ParasaurusDelayTimemin = 9
            RepeatMultiplier = 0.5
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(5), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "stegosaursm", "triceratopssm" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur" }
            ParasaurusDelayTimemin = 12
        elseif Difficulty == "normal" then
            DinoDelayTimemin = 3
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg" }
            ParasaurusDelayTimemin = 9
            RepeatMultiplier = 0.55
        elseif Difficulty == "hard" then
            DinoDelayTimemin = 2
            EnemyDinoUnit = { "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 8
            RepeatMultiplier = 0.6
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(6), function()
        if Difficulty == "easy" then
            DinoDelayTimemin = 3
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg" }
            ParasaurusDelayTimemin = 11
        elseif Difficulty == "normal" then
            DinoDelayTimemin = 2
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 8
            RepeatMultiplier = 0.65
        elseif Difficulty == "hard" then
            DinoDelayTimemin = 1
            EnemyDinoUnit = { "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur",
                "allosaurussm", "allosaurus" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 7
            RepeatMultiplier = 0.7
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(8), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimus", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            RepeatMultiplier = 0.5
        elseif Difficulty == "normal" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            RepeatMultiplier = 0.75
        elseif Difficulty == "hard" then
            EnemyDinoUnit = { "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur",
                "allosaurussm", "allosaurus", "tyrexsm", "tyrex" }
            EnemyParasaurusUnit = { "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            RepeatMultiplier = 0.8
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(9), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm" }
            EnemyParasaurusUnit = { "parasaursm", "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 10
        elseif Difficulty == "normal" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm", "tyrex" }
            EnemyParasaurusUnit = { "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 7
            RepeatMultiplier = 0.85
        elseif Difficulty == "hard" then
            EnemyDinoUnit = { "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur",
                "allosaurussm", "allosaurus", "allosauruslg", "tyrexsm", "tyrex", "tyrexlg", "brachiosaurussm" }
            EnemyParasaurusUnit = { "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 6
            RepeatMultiplier = 0.9
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(10), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm", "tyrex" }
            EnemyParasaurusUnit = { "parasaur", "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 9
            RepeatMultiplier = 0.6
        elseif Difficulty == "normal" then
            DinoDelayTimemin = 1
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm", "tyrex", "tyrexlg", "brachiosaurussm" }
            EnemyParasaurusUnit = { "parasaur", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 6
            RepeatMultiplier = 0.95
        elseif Difficulty == "hard" then
            DinoDelayTimemin = 0
            EnemyDinoUnit = { "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur",
                "allosaurussm", "allosaurus", "allosauruslg", "tyrexsm", "tyrex", "tyrexlg", "brachiosaurussm",
                "brachiosaurus" }
            EnemyParasaurusUnit = { "parasaur", "parasaurlg", "parasaurlg", "parasaurlg" }
            ParasaurusDelayTimemin = 5
            RepeatMultiplier = 1
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(11), function()
        if Difficulty == "easy" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm", "tyrex", "brachiosaurussm" }
            ParasaurusDelayTimemin = 8
        elseif Difficulty == "normal" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "tyrexsm", "tyrex", "tyrexlg", "brachiosaurussm",
                "brachiosaurus" }
            ParasaurusDelayTimemin = 5
            RepeatMultiplier = 1.2
        elseif Difficulty == "hard" then
            EnemyDinoUnit = { "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur",
                "allosaurussm", "allosaurus", "allosauruslg", "tyrexsm", "tyrex", "tyrexlg", "brachiosaurussm",
                "brachiosaurus", "brachiosauruslg" }
            ParasaurusDelayTimemin = 4
            RepeatMultiplier = 1.4
            AddExtraUnit()
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(12), function()
        if Difficulty == "easy" then
            RepeatMultiplier = 0.7
        elseif Difficulty == "normal" then
            EnemyDinoUnit = { "gallimussm", "gallimus", "gallimuslg", "stegosaursm", "triceratopssm", "triceratops",
                "stegosaur", "allosaurussm", "allosaurus", "allosauruslg", "tyrexsm", "tyrex", "tyrexlg",
                "brachiosaurussm", "brachiosaurus", "brachiosauruslg" }
            ParasaurusDelayTimemin = 4
            RepeatMultiplier = 1.5
            AddExtraUnit()
        elseif Difficulty == "hard" then
            EnemyDinoUnit = { "gallimuslg", "stegosaursm", "triceratopssm", "triceratops", "stegosaur", "allosaurussm",
                "allosaurus", "allosauruslg", "tyrexsm", "tyrex", "tyrexlg", "brachiosaurussm", "brachiosaurus",
                "brachiosauruslg" }
            ParasaurusDelayTimemin = 3
            RepeatMultiplier = 1.8
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(13), function()
        if Difficulty == "easy" then
            DinoDelayTimemin = 2
            RepeatMultiplier = 0.8
        elseif Difficulty == "normal" then
            RepeatMultiplier = 1.6
        elseif Difficulty == "hard" then
            RepeatMultiplier = 2
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(14), function()
        if Difficulty == "easy" then
            RepeatMultiplier = 0.9
        elseif Difficulty == "normal" then
            RepeatMultiplier = 1.75
        elseif Difficulty == "hard" then
            RepeatMultiplier = 2.2
        end
    end)
    Trigger.AfterDelay(DateTime.Minutes(15), function()
        if Difficulty == "easy" then
            RepeatMultiplier = 1
        elseif Difficulty == "normal" then
            RepeatMultiplier = 2
        elseif Difficulty == "hard" then
            RepeatMultiplier = 2.5
        end
    end)
end

AddExtraUnit = function()
    ExtraUnit = ExtraUnit + 1
    Trigger.AfterDelay(DateTime.Minutes(1), function()
        AddExtraUnit()
    end)
end

GeneralConditions = function()
	Light = 0
    --    StartMusic1()
    CheckSneakAttacks()
	Trigger.AfterDelay(DateTime.Minutes(1), function()
		EngyDelayTimemin = 45
		EngyDelayTimemax = 90
		EnemyEngyIncome()
	end)
	Trigger.AfterDelay(DateTime.Minutes(5), function()
--		WriteStatisticsTeam1()
--		WriteStatisticsTeam2()
		EngyDelayTimemin = 35
		EngyDelayTimemax = 80
	end)
	Trigger.AfterDelay(DateTime.Minutes(7), function()
		EngyDelayTimemin = 30
		EngyDelayTimemax = 60
	end)
	Trigger.AfterDelay(DateTime.Minutes(10), function()
--		WriteStatisticsTeam1()
--		WriteStatisticsTeam2()
		EngyDelayTimemin = 15
		EngyDelayTimemax = 30
    end)
    if Difficulty == "easy" then
        Trigger.AfterDelay(DateTime.Seconds(1), function()
            Media.PlayMusic("track3")
        end)
        Trigger.AfterDelay(DateTime.Seconds(220), function()
            Media.StopMusic()
            Media.PlayMusic("track2")
            Trigger.AfterDelay(DateTime.Seconds(145), function()
                Media.StopMusic()
                Media.PlayMusic("track1")
            end)
        end)
        DinoDelay = 5
        ParasaurusDelay = 6
        IcDuration = 7
        HeliReinforcements = { "e1", "e3", "e2", "e1" }
        ApcReinforcements = { "e3", "e2", "e1" }
        Tanya = { "e1", "e1", "e3", "medi" }
        TimerColor = HSLColor.LawnGreen
    end
    if Difficulty == "normal" then
            Trigger.AfterDelay(DateTime.Seconds(1), function()
                Media.PlayMusic("track1")
            end)
            Trigger.AfterDelay(DateTime.Seconds(303), function()
                Media.StopMusic()
                Media.PlayMusic("track2")
                Trigger.AfterDelay(DateTime.Seconds(145), function()
                    Media.StopMusic()
                    Media.PlayMusic("track3")
                end)
        end)
            DifficultyMultiplier = 1.5
            DinoDelay = 3
            ParasaurusDelay = 4
            IcDuration = 15
            HeliReinforcements = { "e1", "e3", "e2", "e1", "e1", "e4" }
            ApcReinforcements = { "e3", "e2", "e1", "e1" }
            Tanya = { "e7", "medi", "medi" }
            TimerColor = HSLColor.Orange
        end
    if Difficulty == "hard" then
        Trigger.AfterDelay(DateTime.Seconds(1), function()
            Media.PlayMusic("track2")
        end)
        Trigger.AfterDelay(DateTime.Seconds(146), function()
            Media.StopMusic()
            Media.PlayMusic("track1")
            Trigger.AfterDelay(DateTime.Seconds(302), function()
                Media.StopMusic()
                Media.PlayMusic("track3")
            end)
        end)
        DinoDelay = 2
        ParasaurusDelay = 3
        IcDuration = 25
        ExtraUnit = 1
        HeliReinforcements = { "e1", "e3", "e2", "e1", "e1", "e1", "e4" }
        ApcReinforcements = { "e3", "e2", "e1", "e1", "e4" }
        Tanya = { "e7", "medi", "medi", "medi", "medi" }
        TimerColor = HSLColor.Red
    end
end

AllieUnits = true
SovietUnits = true
--GdiUnits = true
--NodUnits = true
MonsterUnits = true
--AntUnits = true
DinoUnits = true
AlliesText = ""
SovietText = ""
--GdiText = ""
--NodText = ""
MonsterText = ""
--AntText = ""
DinoText = ""
SneakattackDinoBonus = 10
RepeatMultiplier = 0
TemporaryRepeatProbability = 0
TemporaryRepeatBonus = 0
MaxRepeatCounter = 0
AllEnemyUnitsAmount = 0
DifficultyMultiplier = 1
ExtraUnit = 0

UnitAmountCheck = function()
    AllieUnitsAmount()
    SovietUnitsAmount()
    --    GdiUnitsAmount()
    --    NodUnitsAmount()
    MonsterAmount()
    --    AntAmount()
    DinoAmount()
    GeneralConditions()
    AllEnemyUnitsAmount = (AllieUnitPercent + SovietUnitPercent + MonsterUnitPercent + DinoUnitPercent) *
    DifficultyMultiplier
    Trigger.AfterDelay(1, function()
        if SneakAttacks then
            SneakattackConditions()
        else
            SneakattackDinoBonus = 25
        end
        if AllieUnits then
            AlliesText = "Allied: " .. AllieUnitPercent .. "0%\n"
            Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
                AllieunitsConditions()
                Trigger.AfterDelay(DateTime.Seconds(3), function()
                    AllieWaveInterrupter()
                end)
            end)
        end
        if SovietUnits then
            SovietText = "Soviet: " .. SovietUnitPercent .. "0%\n"
            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
            MonsterText = "Monsters: " .. MonsterUnitPercent .. "0%\n"
            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
            DinoText = "Dinosaurs: " .. DinoUnitPercent .. "0%"
            Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(5, 15)), function()
                DinoConditions()
                Trigger.AfterDelay(DateTime.Seconds(3), function()
                    DinoWaveInterrupter()
                end)
            end)
        end
    end)
end

ChosenAllieAmount = Map.LobbyOption("allieamount")
ChosenSovietAmount = Map.LobbyOption("sovietamount")
--ChosenGdiAmount = Map.LobbyOption("gdiamount")
--ChosenNodAmount = Map.LobbyOption("nodamount")
ChosenMonsterAmount = Map.LobbyOption("monsteramount")
SneakattackLevel = Map.LobbyOption("difficulty")
--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

AllieInfantryIncome = function()
	if not AlliePeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomInfUnit = Utils.Random(AllieInfUnit)
		if RandomInfUnit == "e1" then AllieInfDelayTimemax = 5
		elseif RandomInfUnit == "e3" then AllieInfDelayTimemax = 6
		elseif RandomInfUnit == "medi" then AllieInfDelayTimemax = 4
		elseif RandomInfUnit == "mech" then AllieInfDelayTimemax = 6 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(AllieInfDelayTimemin, AllieInfDelayTimemax)), function()
			AllieInfantryIncome()
		end)
	end)
end

SovietInfantryIncome = function()
	if not SovietPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomInfUnit = Utils.Random(SovietInfUnit)
		if RandomInfUnit == "e1" then SovietInfDelayTimemax = 5
		elseif RandomInfUnit == "e2" then SovietInfDelayTimemax = 4
		elseif RandomInfUnit == "e3" then SovietInfDelayTimemax = 6
		elseif RandomInfUnit == "e4" then SovietInfDelayTimemax = 9
		elseif RandomInfUnit == "shok" then SovietInfDelayTimemax = 10
		elseif RandomInfUnit == "dog" then SovietInfDelayTimemax = 4
			AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), CPos.New(26,8) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(26,14) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(4,7) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)) }
			AttackpathS = { CPos.New(1,37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), CPos.New(26,41) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(26,47) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(4,48) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)) }
		end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))			
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(SovietInfDelayTimemin, SovietInfDelayTimemax)), function()
			SovietInfantryIncome()
		end)
	end)
end

GdiInfantryIncome = function()
	if not GdiPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomInfUnit = Utils.Random(GdiInfUnit)
		if RandomInfUnit == "e1cnc" then GdiInfDelayTimemax = 5
		elseif RandomInfUnit == "e2cnc" then GdiInfDelayTimemax = 4
		elseif RandomInfUnit == "e3cnc" then GdiInfDelayTimemax = 6
		elseif RandomInfUnit == "gnrl" then GdiInfDelayTimemax = 10 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }			
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))			
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(GdiInfDelayTimemin, GdiInfDelayTimemax)), function()
			GdiInfantryIncome()
		end)
	end)
end

NodInfantryIncome = function()
	if not NodPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomInfUnit = Utils.Random(NodInfUnit)
		if RandomInfUnit == "e1cnc" then NodInfDelayTimemax = 5
		elseif RandomInfUnit == "e3cnc" then NodInfDelayTimemax = 6
		elseif RandomInfUnit == "e4cnc" then NodInfDelayTimemax = 7
		elseif RandomInfUnit == "e5cnc" then NodInfDelayTimemax = 8 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomInfUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(NodInfDelayTimemin, NodInfDelayTimemax)), function()
			NodInfantryIncome()
		end)
	end)
end

AllieVehicleIncome = function()
	if not AlliePeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomVehUnit = Utils.Random(AllieVehUnit)
		if RandomVehUnit == "1tnk" then AllieVehDelayTimemax = 13
		elseif RandomVehUnit == "jeep" then AllieVehDelayTimemax = 8 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(AllieVehDelayTimemin, AllieVehDelayTimemax)), function()
			AllieVehicleIncome()
		end)
	end)
end
SovietVehicleIncome = function()
	if not SovietPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomVehUnit = Utils.Random(SovietVehUnit)
		if RandomVehUnit == "apc" then SovietVehDelayTimemax = 12
		elseif RandomVehUnit == "ftrk" then SovietVehDelayTimemax = 10 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(SovietVehDelayTimemin, SovietVehDelayTimemax)), function()
			SovietVehicleIncome()
		end)
	end)
end

GdiVehicleIncome = function()
	if not GdiPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomVehUnit = Utils.Random(GdiVehUnit)
		if RandomVehUnit == "apccnc" then GdiVehDelayTimemax = 13
		elseif RandomVehUnit == "humv" then GdiVehDelayTimemax = 8 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(GdiVehDelayTimemin, GdiVehDelayTimemax)), function()
			GdiVehicleIncome()
		end)
	end)
end

NodVehicleIncome = function()
	if not NodPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomVehUnit = Utils.Random(NodVehUnit)
		if RandomVehUnit == "bggy" then NodVehDelayTimemax = 8
		elseif RandomVehUnit == "bike" then NodVehDelayTimemax = 13
		elseif RandomVehUnit == "ftnkcnc" then NodVehDelayTimemax = 10
		elseif RandomVehUnit == "mlrs" then NodVehDelayTimemax = 8 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomVehUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(NodVehDelayTimemin, NodVehDelayTimemax)), function()
			NodVehicleIncome()
		end)
	end)
end

AllieTnkIncome = function()
	if not AlliePeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomTnkUnit = Utils.Random(AllieTnkUnit)
		if RandomTnkUnit == "2tnk" then AllieTnkDelayTimemax = 16
		elseif RandomTnkUnit == "ctnk" then AllieTnkDelayTimemax = 14 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(AllieTnkDelayTimemin, AllieTnkDelayTimemax)), function()
			AllieTnkIncome()
		end)
	end)
end

SovietTnkIncome = function()
	if not SovietPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomTnkUnit = Utils.Random(SovietTnkUnit)
		if RandomTnkUnit == "3tnk" then SovietTnkDelayTimemax = 20
		elseif RandomTnkUnit == "4tnk" then SovietTnkDelayTimemax = 26
		elseif RandomTnkUnit == "ttnk" then SovietTnkDelayTimemax = 15 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(SovietTnkDelayTimemin, SovietTnkDelayTimemax)), function()
			SovietTnkIncome()
		end)
	end)
end

GdiTnkIncome = function()
	if not GdiPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomTnkUnit = Utils.Random(GdiTnkUnit)
		if RandomTnkUnit == "mtnk" then GdiTnkDelayTimemax = 16
		elseif RandomTnkUnit == "htnk" then GdiTnkDelayTimemax = 27 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(GdiTnkDelayTimemin, GdiTnkDelayTimemax)), function()
			GdiTnkIncome()
		end)
	end)
end

NodTnkIncome = function()
	if not NodPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomTnkUnit = Utils.Random(NodTnkUnit)
		if RandomTnkUnit == "ltnk" then NodTnkDelayTimemax = 14
		elseif RandomTnkUnit == "stnkcnc" then NodTnkDelayTimemax = 16 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomTnkUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(19)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(NodTnkDelayTimemin, NodTnkDelayTimemax)), function()
			NodTnkIncome()
		end)
	end)
end

AllieArtyIncome = function()
	if not AlliePeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomArtyUnit = Utils.Random(AllieArtyUnit)
		if RandomArtyUnit == "arty" then AllieArtyDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(AllieArtyDelayTimemin, AllieArtyDelayTimemax)), function()
			AllieArtyIncome()
		end)
	end)
end
SovietArtyIncome = function()
	if not SovietPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomArtyUnit = Utils.Random(SovietArtyUnit)
		if RandomArtyUnit == "v2rl" then AllieArtyDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(SovietArtyDelayTimemin, SovietArtyDelayTimemax)), function()
			SovietArtyIncome()
		end)
	end)
end
GdiArtyIncome = function()
	if not GdiPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomArtyUnit = Utils.Random(GdiArtyUnit)
		if RandomArtyUnit == "msam" then GdiArtyDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(GdiArtyDelayTimemin, GdiArtyDelayTimemax)), function()
			GdiArtyIncome()
		end)
	end)
end
NodArtyIncome = function()
	if not NodPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomArtyUnit = Utils.Random(NodArtyUnit)
		if RandomArtyUnit == "artycnc" then NodArtyDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			if ICTime then EnemyUnitN.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomArtyUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			if ICTime then EnemyUnitS.GrantCondition("invulnerability", DateTime.Seconds(15)) end
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(NodArtyDelayTimemin, NodArtyDelayTimemax)), function()
			NodArtyIncome()
		end)
	end)
end
AllieHeliIncome = function()
	if not AlliePeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomHeliUnit = Utils.Random(AllieHeliUnit)
		if RandomHeliUnit == "mh60" then AllieHeliDelayTimemax = 18
		elseif RandomHeliUnit == "heli" then AllieHeliDelayTimemax = 25 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,0) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(AllieHeliDelayTimemin, AllieHeliDelayTimemax)), function()
			AllieHeliIncome()
		end)
	end)
end
SovietHeliIncome = function()
	if not SovietPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomHeliUnit = Utils.Random(SovietHeliUnit)
		if RandomHeliUnit == "yak" then SovietHeliDelayTimemax = 18
		elseif RandomHeliUnit == "mig" then SovietHeliDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,0) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(SovietHeliDelayTimemin, SovietHeliDelayTimemax)), function()
			SovietHeliIncome()
		end)
	end)
end
GdiHeliIncome = function()
	if not GdiPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomHeliUnit = Utils.Random(GdiHeliUnit)
		if RandomHeliUnit == "orca" then GdiHeliDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,0) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(GdiHeliDelayTimemin, GdiHeliDelayTimemax)), function()
			GdiHeliIncome()
		end)
	end)
end
NodHeliIncome = function()
	if not NodPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomHeliUnit = Utils.Random(NodHeliUnit)
		if RandomHeliUnit == "apache" then NodHeliDelayTimemax = 20 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,0) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomHeliUnit, true, { Location = CPos.New(57,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(NodHeliDelayTimemin, NodHeliDelayTimemax)), function()
			NodHeliIncome()
		end)
	end)
end
EnemyMonsterIncome = function()
	if not MonsterPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomMonsterUnit = Utils.Random(EnemyMonsterUnit)
		
		if RandomMonsterUnit == "PVICE" then MonsterDelayTimemax = 13
		elseif RandomMonsterUnit == "zombie" then MonsterDelayTimemax = 10
		elseif RandomMonsterUnit == "IMP" then MonsterDelayTimemax = 28
		elseif RandomMonsterUnit == "REVE" then MonsterDelayTimemax = 30
		elseif RandomMonsterUnit == "BSPI" then MonsterDelayTimemax = 22
		elseif RandomMonsterUnit == "PINKY" then MonsterDelayTimemax = 35
		elseif RandomMonsterUnit == "MANC" then MonsterDelayTimemax = 45 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomMonsterUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomMonsterUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(MonsterDelayTimemin, MonsterDelayTimemax)), function()
			EnemyMonsterIncome()
		end)
	end)
end

EnemyAntIncome = function()
    if not AntPeaceTime then
        AttackpathN = { CPos.New(1, 1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 1) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 1) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
        AttackpathS = { CPos.New(1, 31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 31) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 31) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
        RandomPosition = Utils.RandomInteger(0, 20)
        RandomAntUnit = Utils.Random(EnemyAntUnit)
        if RandomAntUnit == "ant" then
            AntDelayTimemax = 11
        elseif RandomAntUnit == "scoutant" then
            AntDelayTimemax = 8
        elseif RandomAntUnit == "warriorant" then
            AntDelayTimemax = 12
        elseif RandomAntUnit == "fireant" then
            AntDelayTimemax = 13
        elseif RandomAntUnit == "toxicant" then
            AntDelayTimemax = 14
        elseif RandomAntUnit == "electricant" then
            AntDelayTimemax = 15
        elseif RandomAntUnit == "lavaant" then
            AntDelayTimemax = 23
        end
        if Team1plays then
            EnemyUnitN = Actor.Create(RandomAntUnit, true,
                { Location = CPos.New(55, 1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
            EnemyN = { EnemyUnitN }
            GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
        end
        if Team2plays then
            EnemyUnitS = Actor.Create(RandomAntUnit, true,
                { Location = CPos.New(55, 36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
            EnemyS = { EnemyUnitS }
            GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
        end
    end
    Trigger.AfterDelay(1, function()
        Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(AntDelayTimemin, AntDelayTimemax)), function()
            EnemyAntIncome()
        end)
    end)
end

EnemyDinoIncome = function()
    if not DinoPeaceTime then
        if TemporaryRepeatProbability < 33 then
            TemporaryRepeatProbability = TemporaryRepeatProbability + 7
        end
        DinoAttackpathN = { CPos.New(1, 1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 1) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 1) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
        DinoAttackpathS = { CPos.New(1, 31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 31) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 31) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
        DinoRandomPosition = Utils.RandomInteger(0, 16)
        RandomDinoUnit = Utils.Random(EnemyDinoUnit)
        if RandomDinoUnit == "triceratopssm" then
            DinoDelayTimemax = 6
            TemporaryRepeatBonus = 18
            MaxRepeatCounter = 4
        elseif RandomDinoUnit == "triceratops" then
            DinoDelayTimemax = 13
            TemporaryRepeatBonus = 9
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "triceratopslg" then
            DinoDelayTimemax = 14
            TemporaryRepeatBonus = 7
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "stegosaursm" then
            DinoDelayTimemax = 6
            TemporaryRepeatBonus = 16
            MaxRepeatCounter = 4
        elseif RandomDinoUnit == "stegosaur" then
            DinoDelayTimemax = 14
            TemporaryRepeatBonus = 8
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "stegosaurlg" then
            DinoDelayTimemax = 15
            TemporaryRepeatBonus = 6
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "allosaurussm" then
            DinoDelayTimemax = 6
            TemporaryRepeatBonus = 10
            MaxRepeatCounter = 3
        elseif RandomDinoUnit == "allosaurus" then
            DinoDelayTimemax = 17
            TemporaryRepeatBonus = 6
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "allosauruslg" then
            DinoDelayTimemax = 18
            TemporaryRepeatBonus = 5
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "tyrexsm" then
            DinoDelayTimemax = 6
            TemporaryRepeatBonus = 8
            MaxRepeatCounter = 3
        elseif RandomDinoUnit == "tyrex" then
            DinoDelayTimemax = 16
            TemporaryRepeatBonus = 4
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "tyrexlg" then
            DinoDelayTimemax = 18
            TemporaryRepeatBonus = 3
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "brachiosaurussm" then
            DinoDelayTimemax = 6
            TemporaryRepeatBonus = 8
            MaxRepeatCounter = 4
        elseif RandomDinoUnit == "brachiosaurus" then
            DinoDelayTimemax = 15
            TemporaryRepeatBonus = 4
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "brachiosauruslg" then
            DinoDelayTimemax = 17
            TemporaryRepeatBonus = 3
            MaxRepeatCounter = 2
        elseif RandomDinoUnit == "gallimussm" or RandomDinoUnit == "gallimus" or RandomDinoUnit == "gallimuslg" then
            DinoAttackpathN = { CPos.New(1, 1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), CPos
            .New(
                26, 8) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(26, 14) +
            CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(4, 7) +
            CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)) }
            DinoAttackpathS = { CPos.New(1, 37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), CPos
            .New(
                26, 41) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(26, 47) +
            CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(4, 48) +
            CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)) }
            if RandomDinoUnit == "gallimussm" then
                DinoDelayTimemax = 6
                TemporaryRepeatBonus = 25
                MaxRepeatCounter = 6
            elseif RandomDinoUnit == "gallimus" then
                DinoDelayTimemax = 8
                TemporaryRepeatBonus = 15
                MaxRepeatCounter = 3
            elseif RandomDinoUnit == "gallimuslg" then
                DinoDelayTimemax = 10
                TemporaryRepeatBonus = 10
                MaxRepeatCounter = 2
            end
        end
        MaxRepeatCounter = MaxRepeatCounter + ExtraUnit
        CreateAttackingDinos(RandomDinoUnit, DinoAttackpathN, DinoAttackpathS, DinoRandomPosition, MaxRepeatCounter)
    end
    Trigger.AfterDelay(1, function()
        Trigger.AfterDelay(
        DateTime.Seconds(Utils.RandomInteger(DinoDelayTimemin + DinoDelay, DinoDelayTimemax + DinoDelay)), function()
            EnemyDinoIncome()
        end)
    end)
end

CreateAttackingDinos = function(RandomDinoUnit, DinoAttackpathN, DinoAttackpathS, DinoRandomPosition, MaxRepeatCounter)
    ExtraRandomPosition = CVec.New(0, Utils.RandomInteger(-2, 2))
    PreliminaryResult = ((SneakattackDinoBonus + TemporaryRepeatProbability + TemporaryRepeatBonus) * RepeatMultiplier)
    if PreliminaryResult > 100 then
        PreliminaryResult = 100
    end
    result = PreliminaryResult - AllEnemyUnitsAmount
    --    Media.DisplayMessage("((" .. SneakattackDinoBonus .. " + " .. TemporaryRepeatProbability .. " + " .. TemporaryRepeatBonus .. ") * " .. RepeatMultiplier .. ") - " .. AllEnemyUnitsAmount .. " = " .. result .. " Max: " .. MaxRepeatCounter .. RandomDinoUnit .. "", "Materia", Multi0.Color)
    if Team1plays then
        EnemyUnitN = Actor.Create(RandomDinoUnit, true,
            { Location = CPos.New(55, 3) + CVec.New(0, DinoRandomPosition) + ExtraRandomPosition, Owner = EnemysTop })
        EnemyN = { EnemyUnitN }
        GroupPatrol(EnemyN, DinoAttackpathN, DateTime.Seconds(1))
    end
    if Team2plays then
        EnemyUnitS = Actor.Create(RandomDinoUnit, true,
            { Location = CPos.New(55, 38) + CVec.New(0, DinoRandomPosition) + ExtraRandomPosition, Owner = EnemysBottom })
        EnemyS = { EnemyUnitS }
        GroupPatrol(EnemyS, DinoAttackpathS, DateTime.Seconds(1))
    end
    if result > Utils.RandomInteger(0, 100) and MaxRepeatCounter > 0 then
        MaxRepeatCounter = MaxRepeatCounter - 1
        Trigger.AfterDelay(Utils.RandomInteger(5, 15), function()
            --            Media.DisplayMessage("repeating", "!!!", Multi0.Color)
            CreateAttackingDinos(RandomDinoUnit, DinoAttackpathN, DinoAttackpathS, DinoRandomPosition, MaxRepeatCounter)
        end)
        Trigger.AfterDelay(DateTime.Seconds(3), function()
            TemporaryRepeatProbability = 0
        end)
    end
end

allDinoSounds = { "AllosaurDeath.aud", "AllosaurVictory.aud", "StegosaurAttackGroan.aud", "StegosaurDeath.aud", "StegosaurVictory.aud", "TrexAttackGrowl.aud", "TrexDeath.aud", "TrexVictory.aud", "TriceratopsAttackGrunt.aud", "TriceratopsDeath.aud" }

PlayDinoSounds = function()
    randomDinoSound = Utils.Random(allDinoSounds)
    Media.PlaySound(randomDinoSound)
    Trigger.AfterDelay(DateTime.Seconds((Utils.RandomInteger(20, 40))), function()
        if Dinos then
            PlayDinoSounds()
        end
    end)
end

EnemyParasaurusIncome = function()
    if not DinoPeaceTime then
        AttackpathN = { CPos.New(1, 1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 1) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 1) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
        AttackpathS = { CPos.New(1, 31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 31) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1, 31) +
        CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
        RandomPosition = Utils.RandomInteger(0, 20)
        RandomParasaurusUnit = Utils.Random(EnemyParasaurusUnit)
        if RandomParasaurusUnit == "parasaur" then
            ParasaurusDelayTimemax = 18
        elseif RandomParasaurusUnit == "parasaurlg" then
            ParasaurusDelayTimemax = 17
        elseif RandomParasaurusUnit == "parasaursm" then
            ParasaurusDelayTimemax = 15
        end
        if Team1plays then
            EnemyUnit0 = Actor.Create(RandomParasaurusUnit, true, { Location = CPos.New(55, 1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
            Enemy0 = { EnemyUnit0 }
            GroupPatrol(Enemy0, AttackpathN, DateTime.Seconds(1))
        end
        if Team2plays then
            EnemyUnit1 = Actor.Create(RandomParasaurusUnit, true, { Location = CPos.New(55, 36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
            Enemy1 = { EnemyUnit1 }
            GroupPatrol(Enemy1, AttackpathS, DateTime.Seconds(1))
        end
    end
    Trigger.AfterDelay(1, function()
        Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(ParasaurusDelayTimemin + ParasaurusDelay, ParasaurusDelayTimemax + ParasaurusDelay)), function()
            EnemyParasaurusIncome()
        end)
    end)
end

EnemyCustomHeliIncome = function()
	if not MonsterPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomCustomUnit = Utils.Random(EnemyCustomHeliUnit)
		if RandomCustomUnit == "lynx" then CustomHeliDelayTimemax = 19
		elseif RandomCustomUnit == "cobra" then CustomHeliDelayTimemax = 20
		elseif RandomCustomUnit == "huey" then CustomHeliDelayTimemax = 21
		elseif RandomCustomUnit == "UFO.Beamer" then CustomHeliDelayTimemax = 20
		elseif RandomCustomUnit == "UFO.LASER" then CustomHeliDelayTimemax = 25
		elseif RandomCustomUnit == "UFO" then CustomHeliDelayTimemax = 27 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomCustomUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomCustomUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(CustomHeliDelayTimemin, CustomHeliDelayTimemax)), function()
			EnemyCustomHeliIncome()
		end)
	end)
end

EnemyCustomHeavyIncome = function()
	if not MonsterPeaceTime then
		AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
		RandomPosition = Utils.RandomInteger(0, 20)
		RandomCustomUnit = Utils.Random(EnemyCustomHeavyUnit)
		if RandomCustomUnit == "godzilla" then CustomHeavyDelayTimemax = 35
		elseif RandomCustomUnit == "kingkong" then CustomHeavyDelayTimemax = 37
		elseif RandomCustomUnit == "superman" then CustomHeavyDelayTimemax = 40 end
		if Team1plays then
			EnemyUnitN = Actor.Create(RandomCustomUnit, true, { Location = CPos.New(55,1) + CVec.New(0, RandomPosition), Owner = EnemysTop })
			EnemyN = { EnemyUnitN }
			GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
		end
		if Team2plays then
			EnemyUnitS = Actor.Create(RandomCustomUnit, true, { Location = CPos.New(55,36) + CVec.New(0, RandomPosition), Owner = EnemysBottom })
			EnemyS = { EnemyUnitS }
			GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
		end
	end
	Trigger.AfterDelay(1, function()
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(CustomHeavyDelayTimemin, CustomHeavyDelayTimemax)), function()
			EnemyCustomHeavyIncome()
		end)
	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()
            SneakattackDinoBonus = 10
        end
        if EnemySpecialattack == 2 and not GameIsOver then
            TargetAirstrikeHelis()
            SneakattackDinoBonus = 10
        end
        if EnemySpecialattack == 3 and not GameIsOver then
            TargetAirstrikeYaks()
            SneakattackDinoBonus = 10
        end
        if EnemySpecialattack == 4 and not GameIsOver then
            SendParatroopers()
            SneakattackDinoBonus = 9
        end
        if EnemySpecialattack == 5 and not GameIsOver then
            SendParazombies()
            SneakattackDinoBonus = 8
        end
        if EnemySpecialattack == 6 and not GameIsOver then
            SneakHeils()
            SneakattackDinoBonus = 6
        end
        if EnemySpecialattack == 7 and not GameIsOver then
            SneakApcs()
            SneakattackDinoBonus = 6
        end
        if EnemySpecialattack == 8 and not GameIsOver then
            StealthTanya()
            SneakattackDinoBonus = 6
        end
        if EnemySpecialattack == 9 and not GameIsOver then
            IronCurtain()
            SneakattackDinoBonus = 4
        end
        if EnemySpecialattack == 10 and not GameIsOver then
            Chronotanks()
            SneakattackDinoBonus = 2
        end
        if EnemySpecialattack == 11 and not GameIsOver then
            Demotruckincome()
            SneakattackDinoBonus = 0
        end
        if EnemySpecialattack == 12 and not GameIsOver then
            DropBomb()
            SneakattackDinoBonus = 0
        end
        Trigger.AfterDelay(DateTime.Seconds(15), function()
            SpecialAttack()
        end)
    end)
end

DropBomb = function()
    if not MSilo1Killed and Team1plays and EnemysTop.PowerState == "Normal" then
        DetonationPoint = Actor.Create("waypoint", true,
            { Location = CPos.New(18, 6) + CVec.New(Utils.RandomInteger(0, 8), Utils.RandomInteger(0, 10)), Owner =
            Neutral })
        BomB = MSilo1.ActivateNukePower(DetonationPoint.Location)
        Media.PlaySpeechNotification(allplayers, "AbombLaunchDetected")
    end
    if not MSilo2Killed and Team2plays and EnemysBottom.PowerState == "Normal" then
        DetonationPoint = Actor.Create("waypoint", true,
            { Location = CPos.New(18, 39) + CVec.New(Utils.RandomInteger(0, 8), Utils.RandomInteger(0, 10)), Owner =
            Neutral })
        BomB = MSilo2.ActivateNukePower(DetonationPoint.Location)
        Media.PlaySpeechNotification(allplayers, "AbombLaunchDetected")
    end
end

TargetAirstrikeHelis = function()
    if Team1plays then
        DetonationPoint1 = Actor.Create("waypoint", true,
            { Location = CPos.New(6, 6) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy1 = Actor.Create("powerproxy.parahelis", false, { Owner = EnemysTop })
        units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
        DetonationPoint2 = Actor.Create("waypoint", true,
            { Location = CPos.New(6, 39) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy2 = Actor.Create("powerproxy.parahelis", false, { Owner = EnemysBottom })
        units2 = ParaProxy2.TargetAirstrike(DetonationPoint2.CenterPosition)
    end
end

TargetAirstrikeYaks = function()
	if Team2plays then
		DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(6,6) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner = Neutral })
		ParaProxy1 = Actor.Create("powerproxy.parayaks", false, { Owner = EnemysTop })
		units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
		DetonationPoint2 = Actor.Create("waypoint", true, { Location = CPos.New(6,39) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner = Neutral })
		ParaProxy2 = Actor.Create("powerproxy.parayaks", false, { Owner = EnemysBottom })
		units2 = ParaProxy2.TargetAirstrike(DetonationPoint2.CenterPosition)
	end
end

SendParazombies = function()
    if Team1plays then
        DetonationPoint1 = Actor.Create("waypoint", true,
            { Location = CPos.New(6, 6) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy1 = Actor.Create("powerproxy.parazombies", false, { Owner = EnemysTop })
        units2 = ParaProxy1.TargetParatroopers(DetonationPoint1.CenterPosition)
        Utils.Do(units2, function(a)
            Trigger.OnPassengerExited(a, function(t, p)
                IdleHunt(p)
            end)
        end)
    end
    if Team2plays then
        DetonationPoint2 = Actor.Create("waypoint", true,
            { Location = CPos.New(6, 39) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy2 = Actor.Create("powerproxy.parazombies", false, { Owner = EnemysBottom })
        units2 = ParaProxy2.TargetParatroopers(DetonationPoint2.CenterPosition)
        Utils.Do(units2, function(a)
            Trigger.OnPassengerExited(a, function(t, p)
                IdleHunt(p)
            end)
        end)
    end
end

SendParabombs = function()
	if Team1plays then
		DetonationPoint1 = Actor.Create("waypoint", true, { Location = CPos.New(6,6) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner = Neutral })
		ParaProxy1 = Actor.Create("powerproxy.parabombs", false, { Owner = EnemysTop })
		units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
	end
	if Team2plays then
		DetonationPoint2 = Actor.Create("waypoint", true, { Location = CPos.New(6,39) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner = Neutral })
		ParaProxy2 = Actor.Create("powerproxy.parabombs", false, { Owner = EnemysBottom })
		units2 = ParaProxy2.TargetAirstrike(DetonationPoint2.CenterPosition)
	end
end
TargetAirstrike = function()
    if Team1plays then
        DetonationPoint1 = Actor.Create("waypoint", true,
            { Location = CPos.New(6, 6) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy1 = Actor.Create("powerproxy.parayaks", false, { Owner = EnemysTop })
        units1 = ParaProxy1.TargetAirstrike(DetonationPoint1.CenterPosition)
    end
    if Team2plays then
        DetonationPoint2 = Actor.Create("waypoint", true,
            { Location = CPos.New(6, 39) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy2 = Actor.Create("powerproxy.parayaks", false, { Owner = EnemysBottom })
        units2 = ParaProxy2.TargetAirstrike(DetonationPoint2.CenterPosition)
    end
end

SendParatroopers = function()
    if Team1plays then
        DetonationPoint1 = Actor.Create("waypoint", true,
            { Location = CPos.New(3, 3) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 4)), Owner =
            Neutral })
        ParaProxy1 = Actor.Create("powerproxy.paratroopers", false, { Owner = EnemysTop })
        units1 = ParaProxy1.TargetParatroopers(DetonationPoint1.CenterPosition)
    end
    if Team2plays then
        DetonationPoint2 = Actor.Create("waypoint", true,
            { Location = CPos.New(3, 48) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 4)), Owner =
            Neutral })
        ParaProxy2 = Actor.Create("powerproxy.paratroopers", false, { Owner = EnemysBottom })
        units2 = ParaProxy2.TargetParatroopers(DetonationPoint2.CenterPosition)
    end
end

SendParaparazombies = function()
    if Team1plays then
        DetonationPoint1 = Actor.Create("waypoint", true,
            { Location = CPos.New(3, 3) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy1 = Actor.Create("powerproxy.parazombies", false, { Owner = EnemysTop })
        units1 = ParaProxy1.TargetParatroopers(DetonationPoint1.CenterPosition)
    end
    if Team2plays then
        DetonationPoint2 = Actor.Create("waypoint", true,
            { Location = CPos.New(3, 42) + CVec.New(Utils.RandomInteger(0, 25), Utils.RandomInteger(0, 11)), Owner =
            Neutral })
        ParaProxy2 = Actor.Create("powerproxy.parazombies", false, { Owner = EnemysBottom })
        units2 = ParaProxy2.TargetParatroopers(DetonationPoint2.CenterPosition)
    end
end

Demotruckincome = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(20, 30)), function()
		if Team1plays then
			AttackpathN = { CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
			DemoN = Actor.Create("dtrk", true, { Location = CPos.New(55,5), Owner = EnemysTop })
			DtrukN = { DemoN }
			MovePatrol(DtrukN, AttackpathN, DateTime.Seconds(3))
		end
		if Team2plays then
			AttackpathS = { CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)), CPos.New(1,31) + CVec.New(Utils.RandomInteger(0, 7), Utils.RandomInteger(0, 23)) }
			DemoS = Actor.Create("dtrk", true, { Location = CPos.New(55,50), Owner = EnemysBottom })
			DtrukS = { DemoS }
			MovePatrol(DtrukS, AttackpathS, DateTime.Seconds(3))
		end
	end)
end
HeliReinforcements = { "e1", "e3", "e2", "e1", "e1", "e1", "e4" }
ApcReinforcements = { "e3", "e2", "e1", "e1", "e4" }
TshipReinforcements = { "e3", "e2", "e4", "e4", "e4" }
Tanya = { "e7", "medi", "medi", "medi" }

SneakHeils = function()
	if Team1plays then
	Topsneakheliunits = Reinforcements.ReinforceWithTransport(EnemysTop, "tran", HeliReinforcements, { CPos.New(20,55) + CVec.New(Utils.RandomInteger(-5, 5), 0), CPos.New(9,10) + CVec.New(Utils.RandomInteger(-1, 1), 0) }, { CPos.New(55,10) + CVec.New(0, Utils.RandomInteger(-8, 8)) })
	end
	if Team2plays then
	Bottomsneakheliunits = Reinforcements.ReinforceWithTransport(EnemysBottom, "tran", HeliReinforcements, { CPos.New(20,1) + CVec.New(Utils.RandomInteger(-5, 5), 0), CPos.New(9,43) + CVec.New(Utils.RandomInteger(-1, 1), 0) }, { CPos.New(55,45) + CVec.New(0, Utils.RandomInteger(-8, 8)) })
	end
end


SneakApcs = function()
	if Team1plays then
		Topsneakapcunits = Reinforcements.ReinforceWithTransport(EnemysTop, "apc", ApcReinforcements, { CPos.New(25,1) + CVec.New(Utils.RandomInteger(-1, 1), 0), CPos.New(9,18) + CVec.New(Utils.RandomInteger(-1, 1), 0) }, { CPos.New(55,10) + CVec.New(0, Utils.RandomInteger(-5, 5)) })[2]
	end
	if Team2plays then
		Bottomsneakapcunits = Reinforcements.ReinforceWithTransport(EnemysBottom, "apc", ApcReinforcements, { CPos.New(25,55) + CVec.New(Utils.RandomInteger(-1, 1), 0), CPos.New(9,51) + CVec.New(Utils.RandomInteger(-1, 1), 0) }, { CPos.New(55,45) + CVec.New(0, Utils.RandomInteger(-5, 5)) })[2]
	end
end

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

StealthTanya = function()
	if Team1plays then
		local TopTanya = Reinforcements.ReinforceWithTransport(EnemysTop, "stnk", Tanya, { CPos.New(23,1) + CVec.New(Utils.RandomInteger(-1, 1), 0), CPos.New(9,18) + CVec.New(Utils.RandomInteger(-1, 1), 0) }, { CPos.New(55,10) + CVec.New(0, Utils.RandomInteger(-5, 5)) })[2]
		Utils.Do(TopTanya, function(a)
			Trigger.OnAddedToWorld(a, function()
				AttackpathN = { CPos.New(26,8) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(26,14) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(4,7) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)) }
				EnemyN = { a }
				GroupPatrol(EnemyN, AttackpathN, DateTime.Seconds(1))
			end)
		end)
	end	
	if Team2plays then
		local BottomTanya = Reinforcements.ReinforceWithTransport(EnemysBottom, "stnk", Tanya, { CPos.New(23,55) + CVec.New(Utils.RandomInteger(-1, 1), 0), CPos.New(9,51) + CVec.New(Utils.RandomInteger(-1, 1), 0) }, { CPos.New(55,45) + CVec.New(0, Utils.RandomInteger(-5, 5)) })[2]
		Utils.Do(BottomTanya, function(unit)
			Trigger.OnAddedToWorld(unit, function()
				AttackpathS = { CPos.New(26,41) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(26,47) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(4,48) + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3)), CPos.New(1,37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18))  }
				EnemyS = { unit }
				GroupPatrol(EnemyS, AttackpathS, DateTime.Seconds(1))
			end)
		end)
	end		
end


Chronotanks = function()
	if Team1plays then
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank2 = Actor.Create("CTNK", true, { Location = CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysTop })
			Chronotank2.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank3 = Actor.Create("CTNK", true, { Location = CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysTop })
			Chronotank3.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank4 = Actor.Create("CTNK", true, { Location = CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysTop })
			Chronotank4.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank5 = Actor.Create("CTNK", true, { Location = CPos.New(1,1) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysTop })
			Chronotank5.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
	end		
	if Team2plays then
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank7 = Actor.Create("CTNK", true, { Location = CPos.New(1,37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysBottom })
			Chronotank7.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank8 = Actor.Create("CTNK", true, { Location = CPos.New(1,37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysBottom })
			Chronotank8.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank9 = Actor.Create("CTNK", true, { Location = CPos.New(1,37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysBottom })
			Chronotank9.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(0, 88), function()
			Chronotank10 = Actor.Create("CTNK", true, { Location = CPos.New(1,37) + CVec.New(Utils.RandomInteger(0, 5), Utils.RandomInteger(0, 18)), Owner = EnemysBottom })
			Chronotank10.Scatter()
			Media.PlaySound("chrotnk1.aud")
		end)
		Trigger.AfterDelay(Utils.RandomInteger(88, 105), function()
			Media.PlaySpeechNotification( allplayers, "ChronosphereTestSuccessful")
		end)
	end
end

BridgePathNorth = { CPos.New(43, 25), CPos.New(40, 25), CPos.New(37, 25), CPos.New(34, 25), CPos.New(31, 25), CPos.New(28, 25), CPos.New(25, 25), CPos.New(22, 25), CPos.New(19, 25), CPos.New(16, 25) }
BridgePathSouth = { CPos.New(43, 31), CPos.New(40, 31), CPos.New(37, 31), CPos.New(34, 31), CPos.New(31, 31), CPos.New(28, 31), CPos.New(25, 31), CPos.New(22, 31), CPos.New(19, 31), CPos.New(16, 31) }
EnemyEngyIncome = function()
	if Team1plays then
		EnemyUnitN = Actor.Create("e6", true, { Location = CPos.New(55,25), Owner = EnemysTop })
		EnemyN = { EnemyUnitN }
		MovePatrol(EnemyN, BridgePathNorth, DateTime.Seconds(0))
	end
	if Team2plays then
		EnemyUnitS = Actor.Create("e6", true, { Location = CPos.New(55,30), Owner = EnemysBottom })
		EnemyS = { EnemyUnitS }
		MovePatrol(EnemyS, BridgePathSouth, DateTime.Seconds(0))
	end
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(EngyDelayTimemin, EngyDelayTimemax)), function()
		EnemyEngyIncome()
	end)
end

EnemyEngyRush = function()
	if Team1plays then
		EnemyUnitN = Actor.Create("e6", true, { Location = CPos.New(55,25), Owner = EnemysTop })
		EnemyN = { EnemyUnitN }
		MovePatrol(EnemyN, BridgePathNorth, DateTime.Seconds(0))
	end
	if Team2plays then
		EnemyUnitS = Actor.Create("e6", true, { Location = CPos.New(55,30), Owner = EnemysBottom })
		EnemyS = { EnemyUnitS }
		MovePatrol(EnemyS, BridgePathSouth, DateTime.Seconds(0))
	end
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 3)), function()
		if EngieRushTime then
			EnemyEngyRush()
		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

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
DestroyedBuildings1 = 0
DestroyedBuildings2 = 0

MCVincome = function()
	if AntUnits then
		newEnemylar5 = Actor.Create("LAR1", true, { Location = CPos.New(42,8) + CVec.New(0, Utils.RandomInteger(-5, 5)), Owner = EnemysTop })
		newEnemylar6 = Actor.Create("LAR2", true, { Location = CPos.New(41,16) + CVec.New(0, Utils.RandomInteger(-5, 5)), Owner = EnemysTop }) 
		newEnemylar7 = Actor.Create("LAR1", true, { Location = CPos.New(42,41) + CVec.New(0, Utils.RandomInteger(-5, 5)), Owner = EnemysBottom })
		newEnemylar8 = Actor.Create("LAR2", true, { Location = CPos.New(41,49) + CVec.New(0, Utils.RandomInteger(-5, 5)), Owner = EnemysBottom })
		if AntWaveInterval < 8 then
			TopQueen = Actor.Create("QUEEN", true, { Location = CPos.New(44,11), Owner = EnemysTop })
			BottomQueen = Actor.Create("QUEEN", true, { Location = CPos.New(44,44), Owner = EnemysBottom }) 
		end
	end
	M0Live = Actor.Create("emptydummy", true, { Location = CPos.New(0,0), Owner = Multi0 })
	M1Live = Actor.Create("emptydummy", true, { Location = CPos.New(0,0), Owner = Multi1 })
	M2Live = Actor.Create("emptydummy", true, { Location = CPos.New(0,0), Owner = Multi2 })
	M3Live = Actor.Create("emptydummy", true, { Location = CPos.New(0,0), Owner = Multi3 })
	fact0 = "mcv"
	allactors = Multi0.GetActors()
	for i,v in pairs(allactors) do
		if v.Type == "mcvgdi" then
			fact0 = "factgdi"
			v.Destroy()
		elseif v.Type == "mcvnod" then
			fact0 = "factnod"
			v.Destroy()
		elseif v.Type == "mcv" then
			fact0 = "fact"
			v.Destroy()
		end
	end
	fact1 = "mcv"
	newmcv0 = Actor.Create(fact0, true, { Location = CPos.New(8,7), Owner = Multi0 })
	allactors = Multi1.GetActors()
	for i,v in pairs(allactors) do
		if v.Type == "mcvgdi" then
			fact1 = "factgdi"
			v.Destroy()
		elseif v.Type == "mcvnod" then
			fact1 = "factnod"
			v.Destroy()
		elseif v.Type == "mcv" then
			fact1 = "fact"
			v.Destroy()
		end
	end
	fact2 = "mcv"
	newmcv1 = Actor.Create(fact1, true, { Location = CPos.New(8,15), Owner = Multi1 }) 
	allactors = Multi2.GetActors()
	for i,v in pairs(allactors) do
		if v.Type == "mcvgdi" then
			fact2 = "factgdi"
			v.Destroy()
		elseif v.Type == "mcvnod" then
			fact2 = "factnod"
			v.Destroy()
		elseif v.Type == "mcv" then
			fact2 = "fact"
			v.Destroy()
		end
	end
	newmcv2 = Actor.Create(fact2, true, { Location = CPos.New(8,40), Owner = Multi2 })
	fact3 = "mcv"
	allactors = Multi3.GetActors()
	for i,v in pairs(allactors) do
		if v.Type == "mcvgdi" then
			fact3 = "factgdi"
			v.Destroy()
		elseif v.Type == "mcvnod" then
			fact3 = "factnod"
			v.Destroy()
		elseif v.Type == "mcv" then
			fact3 = "fact"
			v.Destroy()
		end
	end
	newmcv3 = Actor.Create(fact3, true, { Location = CPos.New(8,48), Owner = Multi3 })
--	Trigger.OnKilledOrCaptured(newmcv3, function() Multi3.MarkFailedObjective(KillbaseP4) end)
	Team1Mainbases = { newmcv0, newmcv1 }
	Team2Mainbases = { newmcv2, newmcv3 }
	Trigger.OnAllKilledOrCaptured(Team1Mainbases, Team1Lost)
	Trigger.OnAllKilledOrCaptured(Team2Mainbases, Team2Lost)
	newMine1 = Actor.Create("mine", true, { Location = CPos.New(3, 37), Owner = Neutral })
	newMine2 = Actor.Create("mine", true, { Location = CPos.New(3, 45), Owner = Neutral })
	newMine3 = Actor.Create("mine", true, { Location = CPos.New(3, 53), Owner = Neutral })
	newMine4 = Actor.Create("mine", true, { Location = CPos.New(3, 3), Owner = Neutral })
	newMine5 = Actor.Create("mine", true, { Location = CPos.New(3, 11), Owner = Neutral })
	newMine6 = Actor.Create("mine", true, { Location = CPos.New(3, 19), Owner = Neutral })
	newMine1.GrantCondition("charging", 75)
	newMine2.GrantCondition("charging", 75)
	newMine3.GrantCondition("charging", 75)
	newMine4.GrantCondition("charging", 75)
	newMine5.GrantCondition("charging", 75)
	newMine6.GrantCondition("charging", 75)
	Actor37 = Actor.Create("oilb", true, { Location = CPos.New(21, 8), Owner = Neutral })
	Actor38 = Actor.Create("oilb", true, { Location = CPos.New(30, 8), Owner = Neutral })
	Actor39 = Actor.Create("oilb", true, { Location = CPos.New(21, 14), Owner = Neutral })
	Actor40 = Actor.Create("oilb", true, { Location = CPos.New(30, 14), Owner = Neutral })
	Actor41 = Actor.Create("oilb", true, { Location = CPos.New(21,41), Owner = Neutral })
	Actor42 = Actor.Create("oilb", true, { Location = CPos.New(30,41), Owner = Neutral })
	Actor43 = Actor.Create("oilb", true, { Location = CPos.New(21,47), Owner = Neutral })
	Actor44 = Actor.Create("oilb", true, { Location = CPos.New(30,47), Owner = Neutral })

	Actor45 = Actor.Create("ctflag", true, { Location = CPos.New(21,8), Owner = Neutral })
	Actor46 = Actor.Create("ctflag", true, { Location = CPos.New(30,8), Owner = Neutral })
	Actor47 = Actor.Create("ctflagii", true, { Location = CPos.New(21,14), Owner = Neutral })
	Actor48 = Actor.Create("ctflagii", true, { Location = CPos.New(30,14), Owner = Neutral })
	Actor49 = Actor.Create("ctflagiii", true, { Location = CPos.New(21,41), Owner = Neutral })
	Actor50 = Actor.Create("ctflagiii", true, { Location = CPos.New(30,41), Owner = Neutral })
	Actor51 = Actor.Create("ctflagiv", true, { Location = CPos.New(21,47), Owner = Neutral })
	Actor52 = Actor.Create("ctflagiv", true, { Location = CPos.New(30,47), Owner = Neutral })
	Actor53 = Actor.Create("ctflagra", true, { Location = CPos.New(42,44), Owner = Neutral })
	Actor54 = Actor.Create("ctflagra", true, { Location = CPos.New(42,11), Owner = Neutral })


	newEnemymcv0 = Actor.Create("fact.enemy", true, { Location = CPos.New(51,7), Owner = EnemysTop })
	newEnemymcv1 = Actor.Create("fact.enemy", true, { Location = CPos.New(51,15), Owner = EnemysTop }) 
	newEnemymcv2 = Actor.Create("fact.enemy", true, { Location = CPos.New(51,40), Owner = EnemysBottom })
	newEnemymcv3 = Actor.Create("fact.enemy", true, { Location = CPos.New(51,48), Owner = EnemysBottom })
	newEnemyhpad0 = Actor.Create("hpad", true, { Location = CPos.New(47,7), Owner = EnemysTop })
	newEnemyhpad1 = Actor.Create("hpad", true, { Location = CPos.New(47,15), Owner = EnemysTop }) 
	newEnemyhpad2 = Actor.Create("hpad", true, { Location = CPos.New(47,40), Owner = EnemysBottom })
	newEnemyhpad3 = Actor.Create("hpad", true, { Location = CPos.New(47,48), Owner = EnemysBottom })
	newEnemyapwr1 = Actor.Create("much.apwr", true, { Location = CPos.New(50,11), Owner = EnemysTop })
	newEnemyapwr2 = Actor.Create("much.apwr", true, { Location = CPos.New(50,44), Owner = EnemysBottom })
	if Difficulty ~= "easy" then
		MSilo1 = Actor.Create("mslo", true, { Location = CPos.New(51,6), Owner = EnemysTop })
		Trigger.OnDamaged(MSilo1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 5/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(MSilo1, function() MSilo1Killed = true end)
		MSilo2 = Actor.Create("mslo", true, { Location = CPos.New(51,39), Owner = EnemysBottom })
		Trigger.OnDamaged(MSilo2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 5/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(MSilo2, function() MSilo2Killed = true end)
	end
	Trigger.OnDamaged(newEnemymcv0, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 5/6 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemymcv1, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 5/6 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemymcv2, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 5/6 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemymcv3, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 5/6 then
			building.StartBuildingRepairs()
		end
	end)

	Trigger.OnDamaged(newEnemyhpad0, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 5/6 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemyhpad1, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemyhpad2, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemyhpad3, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)

	Trigger.OnDamaged(newEnemyapwr1, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 5/4 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemyapwr2, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 5/4 then
			building.StartBuildingRepairs()
		end
	end)

	Trigger.OnKilled(newEnemymcv0, function() DestroyedBuildings1 = DestroyedBuildings1 + 1 end)
	Trigger.OnKilled(newEnemymcv1, function() DestroyedBuildings1 = DestroyedBuildings1 + 1 end)
	Trigger.OnKilled(newEnemymcv2, function() DestroyedBuildings2 = DestroyedBuildings2 + 1 end)
	Trigger.OnKilled(newEnemymcv3, function() DestroyedBuildings2 = DestroyedBuildings2 + 1 end)

	Trigger.OnKilled(newEnemyhpad0, function() DestroyedBuildings1 = DestroyedBuildings1 + 1 end)
	Trigger.OnKilled(newEnemyhpad1, function() DestroyedBuildings1 = DestroyedBuildings1 + 1 end)
	Trigger.OnKilled(newEnemyhpad2, function() DestroyedBuildings2 = DestroyedBuildings2 + 1 end)
	Trigger.OnKilled(newEnemyhpad3, function() DestroyedBuildings2 = DestroyedBuildings2 + 1 end)

	Trigger.OnKilled(newEnemyapwr1, function() DestroyedBuildings1 = DestroyedBuildings1 + 1 end)
	Trigger.OnKilled(newEnemyapwr2, function() DestroyedBuildings2 = DestroyedBuildings2 + 1 end)
	Team1Enemybases = { newEnemymcv0, newEnemymcv1, newEnemyhpad0, newEnemyhpad1, newEnemyapwr1 }
	Team2Enemybases = { newEnemymcv2, newEnemymcv3, newEnemyhpad2, newEnemyhpad3, newEnemyapwr2 }
	Trigger.OnAllKilledOrCaptured(Team1Enemybases, Team1Won)
	Trigger.OnAllKilledOrCaptured(Team2Enemybases, Team2Won)
	newEnemytsla0 = Actor.Create("tsla", true, { Location = CPos.New(45,8) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysTop })
	newEnemytsla1 = Actor.Create("tsla", true, { Location = CPos.New(45,16) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysTop }) 
	newEnemytsla2 = Actor.Create("tsla", true, { Location = CPos.New(45,41) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysBottom })
	newEnemytsla3 = Actor.Create("tsla", true, { Location = CPos.New(45,49) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysBottom })
	Trigger.OnDamaged(newEnemytsla0, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemytsla1, function(building)
		if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemytsla2, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)
	Trigger.OnDamaged(newEnemytsla3, function(building)
		if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
			building.StartBuildingRepairs()
		end
	end)
	newEnemypbox0 = Actor.Create("hbox", true, { Location = CPos.New(50,10), Owner = EnemysTop })
	newEnemypbox1 = Actor.Create("hbox", true, { Location = CPos.New(50,18), Owner = EnemysTop }) 
	newEnemypbox2 = Actor.Create("hbox", true, { Location = CPos.New(50,43), Owner = EnemysBottom })
	newEnemypbox3 = Actor.Create("hbox", true, { Location = CPos.New(50,51), Owner = EnemysBottom })
--	if Map.LobbyOption("difficulty") ~= "easy" then
		newEnemyaa0 = Actor.Create("agun", true, { Location = CPos.New(49,7), Owner = EnemysTop })
		newEnemyaa1 = Actor.Create("agun", true, { Location = CPos.New(49,15), Owner = EnemysTop }) 
		newEnemyaa2 = Actor.Create("agun", true, { Location = CPos.New(49,40), Owner = EnemysBottom })
		newEnemyaa3 = Actor.Create("agun", true, { Location = CPos.New(49,48), Owner = EnemysBottom })
		newEnemypbox4 = Actor.Create("hbox", true, { Location = CPos.New(48,10), Owner = EnemysTop })
		newEnemypbox5 = Actor.Create("hbox", true, { Location = CPos.New(48,18), Owner = EnemysTop }) 
		newEnemypbox6 = Actor.Create("hbox", true, { Location = CPos.New(48,43), Owner = EnemysBottom })
		newEnemypbox7 = Actor.Create("hbox", true, { Location = CPos.New(48,51), Owner = EnemysBottom })
		Trigger.OnDamaged(newEnemyaa0, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemyaa1, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemyaa2, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemyaa3, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		newEnemytsla4 = Actor.Create("tsla", true, { Location = CPos.New(46,8) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysTop })
		newEnemytsla5 = Actor.Create("tsla", true, { Location = CPos.New(46,16) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysTop }) 
		newEnemytsla6 = Actor.Create("tsla", true, { Location = CPos.New(46,41) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysBottom })
		newEnemytsla7 = Actor.Create("tsla", true, { Location = CPos.New(46,49) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysBottom })
		Trigger.OnDamaged(newEnemytsla4, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemytsla5, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemytsla6, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemytsla7, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
--	end
--	if Map.LobbyOption("difficulty") == "hard" or Map.LobbyOption("difficulty") == "unbelievable" then
		newEnemypbox8 = Actor.Create("hbox", true, { Location = CPos.New(50,8), Owner = EnemysTop })
		newEnemypbox9 = Actor.Create("hbox", true, { Location = CPos.New(50,16), Owner = EnemysTop }) 
		newEnemypbox10 = Actor.Create("hbox", true, { Location = CPos.New(50,41), Owner = EnemysBottom })
		newEnemypbox11 = Actor.Create("hbox", true, { Location = CPos.New(50,49), Owner = EnemysBottom })
		newEnemyaa4 = Actor.Create("agun", true, { Location = CPos.New(53,6), Owner = EnemysTop })
		newEnemyaa5 = Actor.Create("agun", true, { Location = CPos.New(53,14), Owner = EnemysTop }) 
		newEnemyaa6 = Actor.Create("agun", true, { Location = CPos.New(53,39), Owner = EnemysBottom })
		newEnemyaa7 = Actor.Create("agun", true, { Location = CPos.New(53,47), Owner = EnemysBottom })
		Trigger.OnDamaged(newEnemyaa4, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemyaa5, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemyaa6, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemyaa7, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		newEnemygap1 = Actor.Create("gap", true, { Location = CPos.New(48,11), Owner = EnemysTop })
		newEnemygap2 = Actor.Create("gap", true, { Location = CPos.New(48,44), Owner = EnemysBottom })
		Trigger.OnDamaged(newEnemygap1, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemygap2, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		newEnemytsla8 = Actor.Create("tsla", true, { Location = CPos.New(44,8) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysTop })
		newEnemytsla9 = Actor.Create("tsla", true, { Location = CPos.New(44,16) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysTop }) 
		newEnemytsla10 = Actor.Create("tsla", true, { Location = CPos.New(44,41) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysBottom })
		newEnemytsla11 = Actor.Create("tsla", true, { Location = CPos.New(44,49) + CVec.New(0, Utils.RandomInteger(-1, 1)), Owner = EnemysBottom })
		Trigger.OnDamaged(newEnemytsla8, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemytsla9, function(building)
			if building.Owner == EnemysTop and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemytsla10, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnDamaged(newEnemytsla11, function(building)
			if building.Owner == EnemysBottom and building.Health < building.MaxHealth * 3/4 then
				building.StartBuildingRepairs()
			end
		end)
--	end
end


SetupPlayers = function()
	EnemysTop = Player.GetPlayer("EnemysTop")
	EnemysBottom = Player.GetPlayer("EnemysBottom")
	France = Player.GetPlayer("france")
	Neutral = Player.GetPlayer("Neutral")
	Multi0 = Player.GetPlayer("Multi0")
	if Multi0 == nil then
		Multi0 = Player.GetPlayer("Multi1")
		if Multi0 == nil then
			Team1plays = false
			CoverTop()
			Multi0 = Player.GetPlayer("Creeps")
		end
	end
	Multi1 = Player.GetPlayer("Multi1")
	if Multi1 == nil then
		Multi1 = Player.GetPlayer("Multi0")
		if Multi1 == nil then
			Multi1 = Player.GetPlayer("Creeps")
		end
	end
	Multi2 = Player.GetPlayer("Multi2")
	if Multi2 == nil then
		Multi2 = Player.GetPlayer("Multi3")
		if Multi2 == nil then
			Team2plays = false
			CoverBottom()
			Multi2 = Player.GetPlayer("Creeps")
		end
	end
	Multi3 = Player.GetPlayer("Multi3")
	if Multi3 == nil then
		Multi3 = Player.GetPlayer("Multi2")
		if Multi3 == nil then
			Multi3 = Player.GetPlayer("Creeps")
		end
	end
	Humans = { Multi0, Multi1, Multi2, Multi3 }
end

GameIsOver = false

WriteStatisticsTeam1 = function()
	Utils.Do(Humans, function(player)
--		Player1Name = Multi0.Name
		Player1Color = Multi0.Color
--		Player1Faction = Multi0.Faction
		Player1Kills = Multi0.UnitsKilled
		Player1Looses = Multi0.UnitsLost
		Player1KillsCost = Multi0.KillsCost
		Player1DeathsCost = Multi0.DeathsCost
		Player1Experience = Multi0.Experience
--		Player2Name = Multi1.Name
--		Player2Color = Multi1.Color
--		Player2Faction = Multi1.Faction
		Player2Kills = Multi1.UnitsKilled
		Player2Looses = Multi1.UnitsLost
		Player2KillsCost = Multi1.KillsCost
		Player2DeathsCost = Multi1.DeathsCost
		Player2Experience = Multi1.Experience
		Team1Kills = Player1Kills + Player2Kills
		Team1Looses = Player1Looses + Player2Looses
		Team1KillsCost = Player1KillsCost + Player2KillsCost
		Team1DeathsCost = Player1DeathsCost + Player2DeathsCost
		Team1Experience = Player1Experience + Player2Experience
	end)
	Media.DisplayMessage("" .. Multi0.Name .. " + " .. Multi1.Name .. "\nKilled/Lost " .. Team1Kills .. " / " .. Team1Looses .. " Units\nDestroyed " .. Team1KillsCost .. " $ and wasted " .. Team1DeathsCost .. " $\nScore : " .. Team1Experience .. "", "Team 1", Player1Color)

end

WriteStatisticsTeam2 = function()
	Utils.Do(Humans, function(player)
--		Player3Name = Multi2.Name
		Player3Color = Multi2.Color
--		Player3Faction = Multi2.Faction
		Player3Kills = Multi2.UnitsKilled
		Player3Looses = Multi2.UnitsLost
		Player3KillsCost = Multi2.KillsCost
		Player3DeathsCost = Multi2.DeathsCost
		Player3Experience = Multi2.Experience
--		Player4Name = Multi3.Name
--		Player4Color = Multi3.Color
--		Player4Faction = Multi3.Faction
		Player4Kills = Multi3.UnitsKilled
		Player4Looses = Multi3.UnitsLost
		Player4KillsCost = Multi3.KillsCost
		Player4DeathsCost = Multi3.DeathsCost
		Player4Experience = Multi3.Experience
		Team2Kills = Player3Kills + Player4Kills
		Team2Looses = Player3Looses + Player4Looses
		Team2KillsCost = Player3KillsCost + Player4KillsCost
		Team2DeathsCost = Player3DeathsCost + Player4DeathsCost
		Team2Experience = Player3Experience + Player4Experience
	end)
	Media.DisplayMessage("" .. Multi2.Name .. " + " .. Multi3.Name .. "\nKilled/Lost " .. Team2Kills .. " / " .. Team2Looses .. " Units\nDestroyed " .. Team2KillsCost .. " $ and wasted " .. Team2DeathsCost .. " $\nScore : " .. Team2Experience .. "", "Team 2", Player3Color)

end

Team1Lost = function()
--	if not GameIsOver then
		Team1plays = false
		Team1Killed = true

		Media.PlaySoundNotification( allplayers, "AlertBuzzer")
		Media.DisplayMessage("" .. Multi0.Name .. " and " ..Multi1.Name .. " loses!" , "Materia", TimerColor)
--		BombTop()
		Trigger.AfterDelay(DateTime.Seconds(1), function()
			T1Lost = Actor.Create("team1loose", true, { Location = CPos.New(26,10), Owner = EnemysTop })
			Multi0.MarkFailedObjective(KillbaseP1)
			Multi1.MarkFailedObjective(KillbaseP2)
			Multi0actors = Multi0.GetActors()
			for i,v in pairs(Multi0actors) do
				if v.HasProperty("Health") then
					v.Destroy()
				end
			end
			Multi1actors = Multi1.GetActors()
			for i,v in pairs(Multi1actors) do
				if v.HasProperty("Health") then
					v.Destroy()
				end
			end
			tenemyactors = EnemysTop.GetActors()
			for i,v in pairs(tenemyactors) do
				if v.HasProperty("Health") then
					v.Destroy()
				end
			end
			CoverTop()
			if Team2Killed then
				Multi2actors = Multi2.GetActors()
				for i,v in pairs(Multi2actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
				Multi3actors = Multi3.GetActors()
				for i,v in pairs(Multi3actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
				Multi2.MarkFailedObjective(KillbaseP3)
				Multi3.MarkFailedObjective(KillbaseP4)
			elseif GameIsOver then
				Multi0actors = Multi0.GetActors()
				for i,v in pairs(Multi0actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
				Multi1actors = Multi1.GetActors()
				for i,v in pairs(Multi1actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
--				Multi0.MarkFailedObjective(KillbaseP1)
--				Multi1.MarkFailedObjective(KillbaseP2)
			end
		end)
--	end
end
Team1Won = function()
	if not GameIsOver and Team1plays then
		Team1plays = false
		GameIsOver = true
		turnOff()
		Media.PlaySoundNotification( allplayers, "AlertBuzzer")
		Media.DisplayMessage("Congratulations! Team 1 wins the Game!", "Materia", TimerColor)
		Trigger.AfterDelay(DateTime.Seconds(3), function()
			Media.PlayMusic("track2")
--			WriteStatisticsTeam1()
			if Multi0 ~= Multi1 then Playername = Actor.Create("nix01pname", true, { Location = CPos.New(27,26), Owner = Multi0 }) end
			if Multi0 ~= Multi1 then And = Actor.Create("nix01and", true, { Location = CPos.New(28,28), Owner = Multi0 }) end
			Playername = Actor.Create("nix01pname", true, { Location = CPos.New(27,32), Owner = Multi1 })
			Wins = Actor.Create("nix01wins", true, { Location = CPos.New(24,35), Owner = Multi1 })
			Trigger.AfterDelay(DateTime.Seconds(7), function()
--				WriteStatisticsTeam2()
			end)
		end)
		Trigger.AfterDelay(DateTime.Seconds(8), function()
			EndLight = 1.05
			Lighting.Ambient = EndLight
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				if not Team1Killed then
					Multi0.MarkCompletedObjective(KillbaseP1) 
					Multi1.MarkCompletedObjective(KillbaseP2)
				end
				if Team2Killed then
					Multi2actors = Multi2.GetActors()
					for i,v in pairs(Multi2actors) do
						if v.HasProperty("Health") then
							v.Destroy()
						end
					end
					Multi3actors = Multi3.GetActors()
					for i,v in pairs(Multi3actors) do
						if v.HasProperty("Health") then
							v.Destroy()
						end
					end
--					Multi2.MarkFailedObjective(KillbaseP3)
--					Multi3.MarkFailedObjective(KillbaseP4)
				end
			end)
		end)
	end
end
Team2Lost = function()
--	if not GameIsOver then
		Team2plays = false
		Team2Killed = true

		Media.PlaySoundNotification( allplayers, "AlertBuzzer")
		Media.DisplayMessage("" .. Multi2.Name .. " and " ..Multi3.Name .. " loses!" , "Materia", TimerColor)
--		BombBottom()
		Trigger.AfterDelay(DateTime.Seconds(1), function()
			T1Lost = Actor.Create("team2loose", true, { Location = CPos.New(26,45), Owner = EnemysBottom })
			Multi2.MarkFailedObjective(KillbaseP3)
			Multi3.MarkFailedObjective(KillbaseP4)
			CoverBottom()
			Multi2actors = Multi2.GetActors()
			for i,v in pairs(Multi2actors) do
				if v.HasProperty("Health") then
					v.Destroy()
				end
			end
			Multi3actors = Multi3.GetActors()
			for i,v in pairs(Multi3actors) do
				if v.HasProperty("Health") then
					v.Destroy()
				end
			end
			benemyactors = EnemysBottom.GetActors()
			for i,v in pairs(benemyactors) do
				if v.HasProperty("Health") then
					v.Destroy()
				end
			end
			if Team1Killed then
				Multi0actors = Multi0.GetActors()
				for i,v in pairs(Multi0actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
				Multi1actors = Multi1.GetActors()
				for i,v in pairs(Multi1actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
				Multi0.MarkFailedObjective(KillbaseP1)
				Multi1.MarkFailedObjective(KillbaseP2)
			elseif GameIsOver then
				Multi2actors = Multi2.GetActors()
				for i,v in pairs(Multi2actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
				Multi3actors = Multi3.GetActors()
				for i,v in pairs(Multi3actors) do
					if v.HasProperty("Health") then
						v.Destroy()
					end
				end
--				Multi2.MarkFailedObjective(KillbaseP3)
--				Multi3.MarkFailedObjective(KillbaseP4)
			end
		end)
--	end
end



Team2Won = function()
	if not GameIsOver and Team2plays then
		Team2plays = false
		GameIsOver = true
		turnOff()
		Media.PlaySoundNotification( allplayers, "AlertBuzzer")
		Media.DisplayMessage("Congratulations! Team 2 wins the Game!", "Materia", TimerColor)
		Trigger.AfterDelay(DateTime.Seconds(3), function()
			Media.PlayMusic("track2")
--			WriteStatisticsTeam2()
			if Multi2 ~= Multi3 then Playername = Actor.Create("nix01pname", true, { Location = CPos.New(27,26), Owner = Multi2 }) end
			if Multi2 ~= Multi3 then And = Actor.Create("nix01and", true, { Location = CPos.New(28,28), Owner = Multi2 }) end
			Playername = Actor.Create("nix01pname", true, { Location = CPos.New(27,32), Owner = Multi3 })
			Wins = Actor.Create("nix01wins", true, { Location = CPos.New(24,35), Owner = Multi3 })
			Trigger.AfterDelay(DateTime.Seconds(7), function()
--				WriteStatisticsTeam1()
			end)
		end)
		Trigger.AfterDelay(DateTime.Seconds(8), function()
			EndLight = 1.05
			Lighting.Ambient = EndLight
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				if not Team2Killed then
					Multi2.MarkCompletedObjective(KillbaseP3) 
					Multi3.MarkCompletedObjective(KillbaseP4)
				end
				if Team1Killed then
					Multi0actors = Multi0.GetActors()
					for i,v in pairs(Multi0actors) do
						if v.HasProperty("Health") then
							v.Destroy()
						end
					end
					Multi1actors = Multi1.GetActors()
					for i,v in pairs(Multi1actors) do
						if v.HasProperty("Health") then
							v.Destroy()
						end
					end
--					Multi0.MarkFailedObjective(KillbaseP1)
--					Multi1.MarkFailedObjective(KillbaseP2)
				end
			end)
		end)
	end
end
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


turnOn = function()
	Lighting.Ambient = Light
	if Light < 1 then
		Light = Light + 0.01
		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

GiveMoney = function()
	if not newmcv0.IsDead and Multi0.Experience>0 and not GameIsOver then
		Multi0.Cash = Multi0.Cash + Multi0.Experience
		Media.FloatingText("" .. (Multi0.Experience) .. " $ Scorebonus", newmcv0.CenterPosition, 30, Multi0.Color)
	end
	if not newmcv1.IsDead and Multi1.Experience>0 and not GameIsOver then
		Multi1.Cash = Multi1.Cash + Multi1.Experience
		Media.FloatingText("" .. (Multi1.Experience) .. " $ Scorebonus", newmcv1.CenterPosition, 30, Multi1.Color)
	end
	if not newmcv2.IsDead and Multi2.Experience>0 and not GameIsOver then
		Multi2.Cash = Multi2.Cash + Multi2.Experience
		Media.FloatingText("" .. (Multi2.Experience) .. " $ Scorebonus", newmcv2.CenterPosition, 30, Multi2.Color)
	end
	if not newmcv3.IsDead and Multi3.Experience>0 and not GameIsOver then
		Multi3.Cash = Multi3.Cash + Multi3.Experience
		Media.FloatingText("" .. (Multi3.Experience) .. " $ Scorebonus", newmcv3.CenterPosition, 30, Multi3.Color)
	end
	Trigger.AfterDelay(DateTime.Seconds(4), function()
		GiveMoney()
	end)
end

Actors1 = { "q1d06", "q1d07", "q1d13" }
Actors2 = { "q1d06", "q1d07", "q1d13" }
Actors3 = { "q1d06", "q1d07", "q1d12", "q1d13" }
RandomActor1 = Utils.Random(Actors1)
RandomActor2 = Utils.Random(Actors2)
RandomActor3 = Utils.Random(Actors3)
countH1 = 0
countV1 = 0
countH2 = 0
countH3 = 0
countV3 = 0
GroundMaker = function()
	if countV1 < 22 then
		if countH1 < 22 then
--			newactor = Actor.Create("q1d08", true, { Location = CPos.New(0,-2) + CVec.New(countH1, countV1), Owner = France })
--			newactor = Actor.Create("q1d11", true, { Location = CPos.New(0,34) + CVec.New(countH1, countV1), Owner = France })
			countH1 = countH1 + 5
		elseif countH1 > 22 then
--			RandomActor1 = Utils.Random(Actors1)
--			RandomActor2 = Utils.Random(Actors1)
--			newactor = Actor.Create(RandomActor1, true, { Location = CPos.New(0,-2) + CVec.New(countH1, countV1), Owner = France })
--			newactor = Actor.Create(RandomActor2, true, { Location = CPos.New(0,34) + CVec.New(countH1, countV1), Owner = France })
			countH1 = countH1 + 5
			if countH1 > 55 then
				countV1 = countV1 + 5
				countH1 = 0
			end
		
		end
		GroundMaker()
	end
	if countH2 < 15 then
		newactor = Actor.Create("nix03", true, { Location = CPos.New(0,26) + CVec.New(countH2, 0), Owner = France })
		newactor = Actor.Create("nix03", true, { Location = CPos.New(0,28) + CVec.New(countH2, 0), Owner = France })
	end
	if countH2 < 45 then
		newactor = Actor.Create(RandomActor1, true, { Location = CPos.New(0,23) + CVec.New(countH2, 0), Owner = France })

		newactor = Actor.Create(RandomActor2, true, { Location = CPos.New(0,31) + CVec.New(countH2, 0), Owner = France })
		countH2 = countH2 + 3
	end
	if countV3 < 9 then
		newactor = Actor.Create("q1d12", true, { Location = CPos.New(45,23) + CVec.New(countH3, countV3), Owner = France })
		countH3 = countH3 + 3	
		if countH3 > 9 then
			countH3 = 0
			if countV3 < 6 or countV3 > 6 then
				countV3 = countV3 + 3
			elseif countV3 == 6 then
				countV3 = countV3 + 2
			end
		end
	end
end
countVT = 0
countHT = 0
CoverTop = function()
	if countVT < 30 then
		newactor = Actor.Create("nix04", true, { Location = CPos.New(0,0) + CVec.New(countHT, countVT), Owner = France })
		countHT = countHT + 3	
		if countHT > 55 then
			countHT = 0
			countVT = countVT + 3
		end
		CoverTop()
	end
end
countVB = 0
countHB = 0
CoverBottom = function()
	if countVB < 30 then
		newactor = Actor.Create("nix04", true, { Location = CPos.New(0,27) + CVec.New(countHB, countVB), Owner = France })
		countHB = countHB + 3	
		if countHB > 55 then
			countHB = 0
			countVB = countVB + 3
		end
		CoverBottom()
	end
end

countVTB = 0
countHTB = 0
BombTop = function()
	if countVTB < 20 then
		newactor = Actor.Create("dtrk", true, { Location = CPos.New(5,5) + CVec.New(countHTB, countVTB), Owner = France })
		countHTB = countHTB + 10	
		if countHTB > 50 then
			countHTB = 0
			countVTB = countVTB + 6
		end
--		Trigger.AfterDelay(1, function()
--		newactor.Kill()
		BombTop()
--		end)
	end
end

countVBB = 0
countHBB = 0
BombBottom = function()
	if countVBB < 20 then
		newactor = Actor.Create("dtrk", true, { Location = CPos.New(10,35) + CVec.New(countHBB, countVBB), Owner = France })
		countHBB = countHBB + 10	
		if countHBB > 50 then
			countHBB = 0
			countVBB = countVBB + 6
		end
--		Trigger.AfterDelay(1, function()
--		newactor.Kill()
		BombBottom()
--		end)
	end
end


PlayerObjectives = function()
	KillPlayer1 = EnemysTop.AddPrimaryObjective("Kill the top players Mainbase")
	KillPlayer2 = EnemysBottom.AddPrimaryObjective("Kill the bottom players Mainbase")
	KillbaseP1 = Multi0.AddPrimaryObjective("Kill the top enemys Mainbase")
	KillbaseP2 = Multi1.AddPrimaryObjective("Kill the top enemys Mainbase")
	KillbaseP3 = Multi2.AddPrimaryObjective("Kill the bottom enemys Mainbase")
	KillbaseP4 = Multi3.AddPrimaryObjective("Kill the bottom enemys Mainbase")
end
SetStartingCamera = function()
	Trigger.AfterDelay(1, function()
		Protectorsign = Actor.Create("nix01pr", true, { Location = CPos.New(5,28), Owner = Multi0 })
		if Multi0.IsLocalPlayer then
			SetCamera(Multi0)
		elseif Multi1.IsLocalPlayer then
			SetCamera(Multi1)
		elseif Multi2.IsLocalPlayer then
			SetCamera(Multi2)
		elseif Multi3.IsLocalPlayer then
			SetCamera(Multi3)
		end
	end)
end
BurningConditioner = function()
    fireantz = EnemysTop.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 = EnemysTop.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 = EnemysBottom.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 = EnemysBottom.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

PlayersCheck = function()
    return Player.GetPlayers(function(player)
        return true
    end);
end

CheckSneakAttacks = function()
    Utils.Do(PlayersCheck(), function(thesePlayers)
        if thesePlayers.HasPrerequisites({ "sneakattacks_on" }) then
            SneakAttacks = true
            SneakMessage = "enabled"
        else
            SneakAttacks = false
            SneakMessage = "disabled"
        end
    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(6), function()
		Media.DisplayMessage("Difficulty is set to " .. SneakattackLevel .. "\n\nEnemy forces:\n" .. AlliesText .. SovietText .. MonsterText .. DinoText .. "", "Materia", TimerColor)
    end)
    Trigger.AfterDelay(DateTime.Seconds(10), function()
        Media.DisplayMessage("Sneakattacks are " .. SneakMessage .. "", "Materia", TimerColor)
    end)
	Trigger.AfterDelay(DateTime.Seconds(13), function()
		Media.DisplayMessage("You can capture oil derricks by stepping any Unit close to the flag next to them.", "Materia", TimerColor)
		Media.PlaySoundNotification( allplayers, "Beacon")
		Beacon.New(Multi0, Actor37.CenterPosition, 1000, true)
		Beacon.New(Multi0, Actor38.CenterPosition, 1000, true)
		Beacon.New(Multi1, Actor39.CenterPosition, 1000, true)
		Beacon.New(Multi1, Actor40.CenterPosition, 1000, true)
		Beacon.New(Multi2, Actor41.CenterPosition, 1000, true)
		Beacon.New(Multi2, Actor42.CenterPosition, 1000, true)
		Beacon.New(Multi3, Actor43.CenterPosition, 1000, true)
		Beacon.New(Multi3, Actor44.CenterPosition, 1000, true)

	end)
	Trigger.AfterDelay(DateTime.Seconds(20), function()
		Media.DisplayMessage("Oil derricks give you build radius.", "Materia", TimerColor)
	end)
	Trigger.AfterDelay(DateTime.Seconds(27), function()
		Media.DisplayMessage("Reduced charging times for all superpowers.", "Materia", TimerColor)
	end)
--	Trigger.AfterDelay(DateTime.Seconds(34), function()
--		Media.DisplayMessage("", "Materia", TimerColor)
--	end)
end
TBridgebuilder1= { CPos.New(42, 25), CPos.New(43, 25), CPos.New(44, 25) }
TBridgebuilder2= { CPos.New(39, 25), CPos.New(40, 25), CPos.New(41, 25) }
TBridgebuilder3= { CPos.New(36, 25), CPos.New(37, 25), CPos.New(38, 25) }
TBridgebuilder4= { CPos.New(33, 25), CPos.New(34, 25), CPos.New(35, 25) }
TBridgebuilder5= { CPos.New(30, 25), CPos.New(31, 25), CPos.New(32, 25) }
TBridgebuilder6= { CPos.New(27, 25), CPos.New(28, 25), CPos.New(29, 25) }
TBridgebuilder7= { CPos.New(24, 25), CPos.New(25, 25), CPos.New(26, 25) }
TBridgebuilder8= { CPos.New(21, 25), CPos.New(22, 25), CPos.New(23, 25) }
TBridgebuilder9= { CPos.New(18, 25), CPos.New(19, 25), CPos.New(20, 25) }
TBridgebuilder10= { CPos.New(15, 25), CPos.New(16, 25), CPos.New(17, 25) }
BBridgebuilder1= { CPos.New(42, 31), CPos.New(43, 31), CPos.New(44, 31) }
BBridgebuilder2= { CPos.New(39, 31), CPos.New(40, 31), CPos.New(41, 31) }
BBridgebuilder3= { CPos.New(36, 31), CPos.New(37, 31), CPos.New(38, 31) }
BBridgebuilder4= { CPos.New(33, 31), CPos.New(34, 31), CPos.New(35, 31) }
BBridgebuilder5= { CPos.New(30, 31), CPos.New(31, 31), CPos.New(32, 31) }
BBridgebuilder6= { CPos.New(27, 31), CPos.New(28, 31), CPos.New(29, 31) }
BBridgebuilder7= { CPos.New(24, 31), CPos.New(25, 31), CPos.New(26, 31) }
BBridgebuilder8= { CPos.New(21, 31), CPos.New(22, 31), CPos.New(23, 31) }
BBridgebuilder9= { CPos.New(18, 31), CPos.New(19, 31), CPos.New(20, 31) }
BBridgebuilder10= { CPos.New(15, 31), CPos.New(16, 31), CPos.New(17, 31) }
EngiePointN= { CPos.New(16, 25) }
EngiePointS= { CPos.New(16, 31) }

SetBridgeTriggers = function()
	Trigger.OnEnteredFootprint(EngiePointN, function(a, id) 
		if a.Type == "e6" and a.Owner == EnemysTop and Team1plays then
			a.Stop()
			if a.IsInWorld and newmcv1.IsInWorld and newmcv1.Owner ~= Player.GetPlayer("Creeps") and newmcv1.Owner ~= EnemysTop and not newmcv1.IsDead  then
				a.Capture(newmcv1)
			elseif a.IsInWorld and newmcv0.IsInWorld and newmcv0.Owner ~= Player.GetPlayer("Creeps") and newmcv0.Owner ~= EnemysTop then
				a.Capture(newmcv0)
			elseif a.IsInWorld then
				a.Scatter()
			end
		end
	end)
	Trigger.OnEnteredFootprint(EngiePointS, function(a, id) 
		if a.Type == "e6" and a.Owner == EnemysBottom and Team2plays then
			a.Stop()
			if a.IsInWorld and newmcv2.IsInWorld and newmcv2.Owner ~= Player.GetPlayer("Creeps") and newmcv2.Owner ~= EnemysBottom and not newmcv2.IsDead  then
				a.Capture(newmcv2)
			elseif a.IsInWorld and newmcv3.IsInWorld and newmcv3.Owner ~= Player.GetPlayer("Creeps") and newmcv3.Owner ~= EnemysBottom then
				a.Capture(newmcv3)
			elseif a.IsInWorld then
				a.Scatter()
			end
		end
	end)
	NIX1 = Actor.Create("nix03", true, { Location = CPos.New(42,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder1, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX1.Destroy()
				a.Owner = Neutral
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(42,26)), Owner = France })
			end)
		end
	end)
	NIX2 = Actor.Create("nix03", true, { Location = CPos.New(39,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder2, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX2.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(39,26)), Owner = France })
			end)
		end
	end)
	NIX3 = Actor.Create("nix03", true, { Location = CPos.New(36,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder3, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX3.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(36,26)), Owner = France })
			end)
		end
	end)
	NIX4 = Actor.Create("nix03", true, { Location = CPos.New(33,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder4, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX4.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(33,26)), Owner = France })
			end)
		end
	end)
	NIX5 = Actor.Create("nix03", true, { Location = CPos.New(30,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder5, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX5.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(30,26)), Owner = France })
			end)
		end
	end)
	NIX6 = Actor.Create("nix03", true, { Location = CPos.New(27,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder6, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX6.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(27,26)), Owner = France })
			end)
		end
	end)
	NIX7 = Actor.Create("nix03", true, { Location = CPos.New(24,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder7, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX7.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(24,26)), Owner = France })
			end)
		end
	end)
	NIX8 = Actor.Create("nix03", true, { Location = CPos.New(21,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder8, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX8.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(21,26)), Owner = France })
			end)
		end
	end)
	NIX9 = Actor.Create("nix03", true, { Location = CPos.New(18,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder9, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX9.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(18,26)), Owner = France })
			end)
		end
	end)
	NIX10 = Actor.Create("nix03", true, { Location = CPos.New(15,26), Owner = France })
	Trigger.OnEnteredFootprint(TBridgebuilder10, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX10.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(15,26)), Owner = France })
			end)
		end
	end)
	NIX11 = Actor.Create("nix03", true, { Location = CPos.New(42,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder1, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX11.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(42,28)), Owner = France })
			end)
		end
	end)
	NIX12 = Actor.Create("nix03", true, { Location = CPos.New(39,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder2, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX12.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(39,28)), Owner = France })
			end)
		end
	end)
	NIX13 = Actor.Create("nix03", true, { Location = CPos.New(36,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder3, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX13.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(36,28)), Owner = France })
			end)
		end
	end)
	NIX14 = Actor.Create("nix03", true, { Location = CPos.New(33,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder4, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX14.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(33,28)), Owner = France })
			end)
		end
	end)
	NIX15 = Actor.Create("nix03", true, { Location = CPos.New(30,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder5, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX15.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(30,28)), Owner = France })
			end)
		end
	end)
	NIX16 = Actor.Create("nix03", true, { Location = CPos.New(27,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder6, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX16.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(27,28)), Owner = France })
			end)
		end
	end)
	NIX17 = Actor.Create("nix03", true, { Location = CPos.New(24,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder7, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX17.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(24,28)), Owner = France })
			end)
		end
	end)
	NIX18 = Actor.Create("nix03", true, { Location = CPos.New(21,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder8, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX18.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(21,28)), Owner = France })
			end)
		end
	end)
	NIX19 = Actor.Create("nix03", true, { Location = CPos.New(18,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder9, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX19.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(18,28)), Owner = France })
			end)
		end
	end)
	NIX20 = Actor.Create("nix03", true, { Location = CPos.New(15,28), Owner = France })
	Trigger.OnEnteredFootprint(BBridgebuilder10, function(a, id) 
		if a.Type == "e6" and a.Owner ~= Neutral then
			Trigger.RemoveFootprintTrigger(id)
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				NIX20.Destroy()
				a.Owner = Neutral 
				if not a.IsDead then a.Destroy() end
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(15,28)), Owner = France })
			end)
		end
	end)
end

function WorldLoaded()
	Difficulty = Map.LobbyOption("difficulty")
	SetupPlayers()
	SetStartingCamera()
	GroundMaker()
	SetBridgeTriggers()
	UnitAmountCheck()
	MCVincome()
	GetandsetFlags()
	GiveMoney()
	PlayerObjectives()
    turnOn()
    StartingMessages()
    PlayDinoSounds()
--	BurningConditioner()
end

Team1plays = true
Team2plays = true
TimerColor = HSLColor.LawnGreen
M0isdead = false
M1isdead = false
M2isdead = false
M3isdead = false
Wait = 0
Tick = function()
	if DestroyedBuildings1 > 3 or DestroyedBuildings2 > 3 and not TimerRed then
		TimerColor = HSLColor.Red
		TimerRed = true
	end
	if Team1plays and Team2plays then
		UserInterface.SetMissionText("Team 1   " .. (DestroyedBuildings1) .. " / 5 destroyed enemy buildings                                   Team 2   " .. (DestroyedBuildings2) .. " / 5 destroyed enemy buildings" , TimerColor)
	elseif Team1plays and not Team2plays then
		UserInterface.SetMissionText("Team 1   " .. (DestroyedBuildings1) .. " / 5 destroyed enemy buildings" , TimerColor)

	elseif Team2plays and not Team1plays then
		UserInterface.SetMissionText("Team 2   " .. (DestroyedBuildings2) .. " / 5 destroyed enemy buildings" , TimerColor)
	else
		UserInterface.SetMissionText(" ", TimerColor)
	end
	if Wait > 90 and not M0isdead and not newmcv0.IsInWorld and Team1plays then
		M0isdead = true
		Multi0actors = Multi0.GetActors()
		for i,v in pairs(Multi0actors) do
			if v.HasProperty("Health") then
				v.Kill()
			end
		end
	end
	if Wait > 90 and not M1isdead and not newmcv1.IsInWorld and Team1plays then
		M1isdead = true
		Multi1actors = Multi1.GetActors()
		for i,v in pairs(Multi1actors) do
			if v.HasProperty("Health") then
				v.Kill()
			end
		end
	end
	if Wait > 90 and not M2isdead and not newmcv2.IsInWorld and Team2plays then
		M2isdead = true
		Multi2actors = Multi2.GetActors()
		for i,v in pairs(Multi2actors) do
			if v.HasProperty("Health") then
				v.Kill()
			end
		end
	end
	if Wait > 90 and not M3isdead and not newmcv3.IsInWorld and Team2plays then
		M3isdead = true
		Multi3actors = Multi3.GetActors()
		for i,v in pairs(Multi3actors) do
			if v.HasProperty("Health") then
				v.Kill()
			end
		end
	end
	if Wait < 91 then
		Wait = Wait + 1
	end
end
