
Positions = {
	q1d04 = { CPos.New(1,1), CPos.New(9,1), CPos.New(1,9), CPos.New(1,14), CPos.New(14,1), CPos.New(22,27), CPos.New(27,22), CPos.New(22,32), CPos.New(27,32), CPos.New(34,34), CPos.New(32,27), CPos.New(32,22), CPos.New(22,37), CPos.New(27,37), CPos.New(37,37), CPos.New(37,34), CPos.New(37,27), CPos.New(37,22), CPos.New(22,42)  , CPos.New(22,46), CPos.New(42,22), CPos.New(46,22), CPos.New(46,46), CPos.New(41,46), CPos.New(36,46), CPos.New(31,46), CPos.New(27,46), CPos.New(46,41), CPos.New(46,36), CPos.New(46,31), CPos.New(46,27), CPos.New(1,19), CPos.New(19,1), CPos.New(41,27), CPos.New(27,42), CPos.New(27,27), CPos.New(34,37) } ,

	q1d12 = { CPos.New(1,6), CPos.New(6,1), CPos.New(6,9), CPos.New(9,6), CPos.New(9,12), CPos.New(12,9), CPos.New(6,12), CPos.New(12,6), CPos.New(6,15), CPos.New(6,18), CPos.New(18,6), CPos.New(6,21), CPos.New(6,24), CPos.New(21,6), CPos.New(24,6), CPos.New(11,37), CPos.New(14,37), CPos.New(19,37), CPos.New(16,37)  , CPos.New(37,11), CPos.New(37,19), CPos.New(37,16), CPos.New(37,13), CPos.New(15,9), CPos.New(18,9), CPos.New(9,18), CPos.New(9,15), CPos.New(15,6), CPos.New(21,9), CPos.New(24,9), CPos.New(9,24), CPos.New(9,21) } ,

	q1d01 = { CPos.New(6,27), CPos.New(6,32), CPos.New(6,37), CPos.New(6,42), CPos.New(6,47), CPos.New(6,51), CPos.New(11,51), CPos.New(16,51), CPos.New(21,51), CPos.New(26,51), CPos.New(31,51), CPos.New(36,51), CPos.New(51,36), CPos.New(51,31), CPos.New(51,26), CPos.New(51,21), CPos.New(51,16), CPos.New(51,11), CPos.New(51,6)  , CPos.New(27,6), CPos.New(32,6), CPos.New(37,6), CPos.New(42,6), CPos.New(47,6), CPos.New(51,46), CPos.New(46,51) } ,

	q1d05 = { CPos.New(15,12), CPos.New(12,15), CPos.New(17,17), CPos.New(17,22), CPos.New(22,17), CPos.New(22,22), CPos.New(12,18), CPos.New(12,23), CPos.New(20,12), CPos.New(23,12), CPos.New(27,17), CPos.New(17,27) } ,

	nix01 = { CPos.New(32,42), CPos.New(33,42), CPos.New(34,42), CPos.New(36,42), CPos.New(35,42), CPos.New(37,42), CPos.New(38,42), CPos.New(39,42), CPos.New(40,42), CPos.New(41,42), CPos.New(42,42), CPos.New(42,41), CPos.New(42,40), CPos.New(42,39), CPos.New(42,38), CPos.New(42,37), CPos.New(42,36), CPos.New(42,35), CPos.New(42,34)  , CPos.New(42,33), CPos.New(42,32), CPos.New(27,11), CPos.New(11,27) } ,

	nix02 = { CPos.New(32,32), CPos.New(32,34), CPos.New(32,36), CPos.New(32,38), CPos.New(32,40), CPos.New(34,32), CPos.New(36,32), CPos.New(38,32), CPos.New(40,32) } ,

	nix03 = { CPos.New(40,19), CPos.New(43,19), CPos.New(32,43), CPos.New(35,43), CPos.New(38,43), CPos.New(41,43), CPos.New(43,43), CPos.New(43,40), CPos.New(43,32), CPos.New(43,35), CPos.New(43,37), CPos.New(46,19), CPos.New(40,16), CPos.New(40,13), CPos.New(43,11), CPos.New(40,11), CPos.New(46,11), CPos.New(48,11), CPos.New(48,14)  , CPos.New(48,17), CPos.New(48,19), CPos.New(19,48), CPos.New(19,45), CPos.New(19,42), CPos.New(19,40), CPos.New(16,48), CPos.New(13,48), CPos.New(11,48), CPos.New(11,45), CPos.New(11,42), CPos.New(11,40), CPos.New(14,40), CPos.New(17,40), CPos.New(3,53), CPos.New(3,50), CPos.New(3,47), CPos.New(3,44), CPos.New(3,41), CPos.New(3,40), CPos.New(3,34), CPos.New(3,32), CPos.New(3,29), CPos.New(3,26), CPos.New(3,24), CPos.New(1,24), CPos.New(53,3), CPos.New(50,3), CPos.New(47,3), CPos.New(44,3), CPos.New(41,3), CPos.New(40,3), CPos.New(34,3), CPos.New(32,3), CPos.New(29,3), CPos.New(26,3), CPos.New(24,3), CPos.New(24,1), CPos.New(6,4), CPos.New(4,6), CPos.New(6,6), CPos.New(19,34), CPos.New(16,34), CPos.New(13,34), CPos.New(11,34), CPos.New(11,31), CPos.New(34,19), CPos.New(34,16), CPos.New(34,13), CPos.New(34,11), CPos.New(31,11), CPos.New(11,28), CPos.New(14,28), CPos.New(28,11), CPos.New(19,32), CPos.New(14,29), CPos.New(32,19), CPos.New(32,16), CPos.New(28,14), CPos.New(31,14), CPos.New(14,31), CPos.New(17,32), CPos.New(1,27), CPos.New(1,30), CPos.New(1,33), CPos.New(1,34), CPos.New(1,40), CPos.New(1,43), CPos.New(1,46), CPos.New(1,49), CPos.New(1,52), CPos.New(1,53), CPos.New(27,1), CPos.New(30,1), CPos.New(33,1), CPos.New(34,1), CPos.New(40,1), CPos.New(42,1), CPos.New(45,1), CPos.New(48,1), CPos.New(51,1), CPos.New(53,1), CPos.New(43,14), CPos.New(45,14), CPos.New(43,16), CPos.New(45,16), CPos.New(16,45), CPos.New(16,43), CPos.New(14,45), CPos.New(14,43) } 
 }


function CreateMap()
	PPlant = Actor.Create("POWR.notarget", true, { Location = (CPos.New(36,36)), Owner = Multi1 })
	NIX1 = Actor.Create("nix03", true, { Location = (CPos.New(37,1)), Owner = Neutral })
	NIX2 = Actor.Create("nix03", true, { Location = (CPos.New(37,3)), Owner = Neutral })
	NIX3 = Actor.Create("nix03", true, { Location = (CPos.New(1,37)), Owner = Neutral })
	NIX4 = Actor.Create("nix03", true, { Location = (CPos.New(3,37)), Owner = Neutral })
	newactor = Actor.Create("q1d06", true, { Location = (CPos.New(12,12)), Owner = Neutral })
	newactor = Actor.Create("q1d13", true, { Location = (CPos.New(9,9)), Owner = Neutral })
	newactor = Actor.Create("q1d03", true, { Location = (CPos.New(51,41)), Owner = Neutral })
	newactor = Actor.Create("q1d03", true, { Location = (CPos.New(51,51)), Owner = Neutral })
	newactor = Actor.Create("q1d03", true, { Location = (CPos.New(41,51)), Owner = Neutral })
	for i,v in pairs(Positions.q1d04) do
		Actor.Create('q1d04', true, {
			Owner = Neutral,
			Location = v
		})
	end
	for i,v in pairs(Positions.q1d12) do
		Actor.Create('q1d12', true, {
			Owner = Neutral,
			Location = v
		})
	end
	for i,v in pairs(Positions.q1d05) do
		Actor.Create('q1d05', true, {
			Owner = Neutral,
			Location = v
		})
	end
	for i,v in pairs(Positions.nix01) do
		Actor.Create('nix01', true, {
			Owner = Neutral,
			Location = v
		})
	end
	for i,v in pairs(Positions.nix02) do
		Actor.Create('nix02', true, {
			Owner = Neutral,
			Location = v
		})
	end
	for i,v in pairs(Positions.nix03) do
		Actor.Create('nix03', true, {
			Owner = Neutral,
			Location = v
		})
	end
	for i,v in pairs(Positions.q1d01) do
		Actor.Create('q1d01', true, {
			Owner = Neutral,
			Location = v
		})
	end
end

Alliesfaction = {"germany", "france", "england"}
Sovietfaction = {"ukraine", "russia"}

Multi1Air = function()
	for i=1,4 do
		if Multi1.Faction == Alliesfaction[i] then
			Helipad1 = Actor.Create("hpad", true, { Location = CPos.New(39,35), Owner = Multi1 })
			Helipad2 = Actor.Create("hpad", true, { Location = CPos.New(39,39), Owner = Multi1 })
			Helipad3 = Actor.Create("hpad", true, { Location = CPos.New(35,39), Owner = Multi1 })
			Trigger.OnKilled(Helipad1,Multi1Hpad1)
			Trigger.OnKilled(Helipad2,Multi1Hpad2)
			Trigger.OnKilled(Helipad3,Multi1Hpad3)
		end
		if Multi1.Faction == Sovietfaction[i] then
			Airfield1 = Actor.Create("afld", true, { Location = CPos.New(38,35), Owner = Multi1 })
			Airfield2 = Actor.Create("afld", true, { Location = CPos.New(38,39), Owner = Multi1 })
			Airfield3 = Actor.Create("afld", true, { Location = CPos.New(35,39), Owner = Multi1 })
			Trigger.OnKilled(Airfield1,Multi1Afld1)
			Trigger.OnKilled(Airfield2,Multi1Afld2)
			Trigger.OnKilled(Airfield3,Multi1Afld3)
		end
	end
end
Multi1Hpad1 = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 15)), function()
		Helipad = Actor.Create("hpad", true, { Location = CPos.New(39,35), Owner = Multi1 })
		Trigger.OnKilled(Helipad,Multi1Hpad1)
	end)
end
Multi1Afld1 = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 15)), function()
		Airfield = Actor.Create("afld", true, { Location = CPos.New(38,35), Owner = Multi1 })
		Trigger.OnKilled(Airfield,Multi1Afld1)
	end)
end
Multi1Hpad2 = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 15)), function()
		Helipad = Actor.Create("hpad", true, { Location = CPos.New(39,39), Owner = Multi1 })
		Trigger.OnKilled(Helipad,Multi1Hpad2)
	end)
end
Multi1Afld2 = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 15)), function()
		Airfield = Actor.Create("afld", true, { Location = CPos.New(38,39), Owner = Multi1 })
		Trigger.OnKilled(Airfield,Multi1Afld2)
	end)
end
Multi1Hpad3 = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 15)), function()
		Helipad = Actor.Create("hpad", true, { Location = CPos.New(35,39), Owner = Multi1 })
		Trigger.OnKilled(Helipad,Multi1Hpad3)
	end)
end
Multi1Afld3 = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(7, 15)), function()
		Airfield = Actor.Create("afld", true, { Location = CPos.New(35,39), Owner = Multi1 })
		Trigger.OnKilled(Airfield,Multi1Afld3)
	end)
end


Multi3Base = function()
	Base = Actor.Create("fact", true, { Location = (CPos.New(20,20)), Owner = Multi3 })
	Trigger.OnKilled(Base,Multi3Base)
end

Rescuepoint1= { CPos.New(1, 1), CPos.New(1, 2), CPos.New(1, 3), CPos.New(1, 4), CPos.New(1, 5), CPos.New(1, 6), CPos.New(1, 7), CPos.New(1, 8), CPos.New(1, 9), CPos.New(1, 10), CPos.New(1, 11), CPos.New(1, 12), CPos.New(1, 13), CPos.New(1, 14), CPos.New(1, 15), CPos.New(1, 16), CPos.New(1, 17), CPos.New(1, 18), CPos.New(1, 19), CPos.New(1, 20), CPos.New(1, 21), CPos.New(1, 22), CPos.New(1, 23) }
Rescuepoint2= { CPos.New(2, 1), CPos.New(3, 1), CPos.New(4, 1), CPos.New(5, 1), CPos.New(6, 1), CPos.New(7, 1), CPos.New(8, 1), CPos.New(9, 1), CPos.New(10, 1), CPos.New(11, 1), CPos.New(12, 1), CPos.New(13, 1), CPos.New(14, 1), CPos.New(15, 1), CPos.New(16, 1), CPos.New(17, 1), CPos.New(18, 1), CPos.New(19, 1), CPos.New(20, 1), CPos.New(21, 1), CPos.New(22, 1), CPos.New(23, 1) }
Rescuepoint3= { CPos.New(1, 37), CPos.New(1, 38), CPos.New(1, 39) }
Rescuepoint4= { CPos.New(37, 1), CPos.New(38, 1), CPos.New(39, 1) }

Bridgepoint1= { CPos.New(37,6), CPos.New(39,6), CPos.New(37,7), CPos.New(39,7), CPos.New(37,8), CPos.New(38,8), CPos.New(39,8) }
Bridgepoint2= { CPos.New(6,37), CPos.New(6,39), CPos.New(7,37), CPos.New(7,39), CPos.New(8,37), CPos.New(8,38), CPos.New(8,39) }

EvilnogoArea1 = {  CPos.New(33, 45), CPos.New(33, 46), CPos.New(33, 47), CPos.New(33, 48), CPos.New(33, 49), CPos.New(33, 50), CPos.New(33, 51), CPos.New(33, 52), CPos.New(33, 53), CPos.New(33, 54), CPos.New(33, 55) }

EvilnogoArea2 = { CPos.New(45, 33), CPos.New(46, 33), CPos.New(47, 33), CPos.New(48, 33), CPos.New(49, 33), CPos.New(50, 33), CPos.New(51, 33), CPos.New(52, 33), CPos.New(53, 33), CPos.New(54, 33), CPos.New(55, 33) }

Rescued = 0
Kills = 0

RandomHostageentry = { CPos.New(45,55), CPos.New(50,55), CPos.New(55,55), CPos.New(55,50), CPos.New(55,45) }
RandomHostagemove = { CPos.New(45,50), CPos.New(50,50), CPos.New(50,45) }
Refugees = { "c2", "c3", "c5", "civ4", "civ5", "civ6", "civ7", "civ8", "civ9", "civ10", "civ11", "civ12", "civ13", "civ14", "civ15", "civ16", "civ17" }

Insertrefugee = function() 
	RandomRefugee = Utils.Random(Refugees)
	RandomRefugeeentry = Utils.Random(RandomHostageentry)
	RandomRefugeemove = Utils.Random(RandomHostagemove)
	Refugee = Actor.Create(RandomRefugee, true, { Location = RandomRefugeeentry, Owner = Multi0 })
	if not Refugee.IsDead then Refugee.Move(RandomRefugeemove + CVec.New(Utils.RandomInteger(-3, 3), Utils.RandomInteger(-3, 3))) end
	Trigger.OnKilled(Refugee, function() Kills = Kills + 1 end)
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(2, 3)), function()
		Insertrefugee()
	end)
end

RandomEvilentry = { CPos.New(1,1), CPos.New(1,5), CPos.New(1,10), CPos.New(5,1), CPos.New(10,1) }
RandomEvilmove = { CPos.New(10,10), CPos.New(5,10), CPos.New(10,5) }

EvilPVICE = function()
	Evilentry = Utils.Random(RandomEvilentry)
	Evilmove = Utils.Random(RandomEvilmove)
	PVICE = Actor.Create("PVICE", true, { Location = Evilentry, Owner = Multi2 })
	if not PVICE.IsDead then PVICE.AttackMove(Evilmove + CVec.New(Utils.RandomInteger(-2, 2), Utils.RandomInteger(-2, 2))) end
	Trigger.OnKilled(PVICE,EvilPVICE)
end

EvilIMP = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Evilentry = Utils.Random(RandomEvilentry)
	Evilmove = Utils.Random(RandomEvilmove)
		IMP = Actor.Create("IMP", true, { Location = Evilentry, Owner = Multi2 })
		if not IMP.IsDead then IMP.AttackMove(Evilmove + CVec.New(Utils.RandomInteger(-2, 2), Utils.RandomInteger(-2, 2))) end
		Trigger.OnKilled(IMP,EvilIMP)
	end)
end
EvilReve = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Evilentry = Utils.Random(RandomEvilentry)
	Evilmove = Utils.Random(RandomEvilmove)
		Reve = Actor.Create("REVE", true, { Location = Evilentry, Owner = Multi2 })
		if not Reve.IsDead then Reve.AttackMove(Evilmove + CVec.New(Utils.RandomInteger(-2, 2), Utils.RandomInteger(-2, 2))) end
		Trigger.OnKilled(Reve,EvilReve)
	end)
end
EvilBSPI = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Evilentry = Utils.Random(RandomEvilentry)
	Evilmove = Utils.Random(RandomEvilmove)
		BSPI = Actor.Create("BSPI", true, { Location = Evilentry, Owner = Multi2 })
		if not BSPI.IsDead then BSPI.AttackMove(Evilmove + CVec.New(Utils.RandomInteger(-2, 2), Utils.RandomInteger(-2, 2))) end
		Trigger.OnKilled(BSPI,EvilBSPI)
	end)
end
EvilPINKY = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Evilentry = Utils.Random(RandomEvilentry)
	Evilmove = Utils.Random(RandomEvilmove)
		PINKY = Actor.Create("PINKY", true, { Location = Evilentry, Owner = Multi2 })
		if not PINKY.IsDead then PINKY.AttackMove(Evilmove + CVec.New(Utils.RandomInteger(-2, 2), Utils.RandomInteger(-2, 2))) end
		Trigger.OnKilled(PINKY,EvilPINKY)
	end)
end
EvilMANC = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Evilentry = Utils.Random(RandomEvilentry)
	Evilmove = Utils.Random(RandomEvilmove)
		MANC = Actor.Create("MANC", true, { Location = Evilentry, Owner = Multi2 })
		if not MANC.IsDead then MANC.AttackMove(Evilmove + CVec.New(Utils.RandomInteger(-2, 2), Utils.RandomInteger(-2, 2))) end
		Trigger.OnKilled(MANC,EvilMANC)
	end)
end


RandomUfomove = { CPos.New(40,40), CPos.New(40,45), CPos.New(45,40) }

GoodBeamerUfo = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Ufomove = Utils.Random(RandomUfomove)
		Beamer = Actor.Create("UFO.Beamer", true, { Location = CPos.New(80,80), Owner = Multi1 })
		if not Beamer.IsDead then Beamer.AttackMove(Ufomove + CVec.New(Utils.RandomInteger(-5, 5), Utils.RandomInteger(-5, 5))) end
		Trigger.OnKilled(Beamer,GoodBeamerUfo)
	end)
end

GoodLaserUfo = function()
	Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3, 10)), function()
	Ufomove = Utils.Random(RandomUfomove)
		Laser = Actor.Create("UFO.Laser", true, { Location = CPos.New(80,80), Owner = Multi1 })
		if not Laser.IsDead then Laser.AttackMove(Ufomove + CVec.New(Utils.RandomInteger(-5, 5), Utils.RandomInteger(-5, 5))) end
		Trigger.OnKilled(Laser,GoodLaserUfo)
	end)
end

SetTriggers = function()
	Trigger.OnEnteredFootprint(Rescuepoint1, function(a, id) 
		if a.Owner == Multi0 then
			Rescued = Rescued + 1
			a.Owner = Neutral
			Trigger.OnIdle(a, function()
				Trigger.ClearAll(a)
				a.Destroy()
			end)
		end
	end)
	Trigger.OnEnteredFootprint(Rescuepoint2, function(a, id) 
		if a.Owner == Multi0 then
			Rescued = Rescued + 1
			a.Owner = Neutral
			Trigger.OnIdle(a, function()
				Trigger.ClearAll(a)
				a.Destroy()
			end)
		end
	end)
	Trigger.OnEnteredFootprint(Rescuepoint3, function(a, id) 
		if a.Owner == Multi0 then
			Rescued = Rescued + 1
			a.Owner = Neutral
			Trigger.OnIdle(a, function()
				Trigger.ClearAll(a)
				a.Destroy()
			end)
		end
	end)
	Trigger.OnEnteredFootprint(Rescuepoint4, function(a, id) 
		if a.Owner == Multi0 then
			Rescued = Rescued + 1
			a.Owner = Neutral
			Trigger.OnIdle(a, function()
				Trigger.ClearAll(a)
				a.Destroy()
			end)
		end
	end)
	Trigger.OnEnteredFootprint(EvilnogoArea1, function(a, id) 
		if a.Owner == Multi2 or a.Owner == Multi3 then
			a.Owner = Neutral
			a.Kill()
			Trigger.OnIdle(a, function()
				Trigger.ClearAll(a)
				a.Move(CPos.New(33, 55))
				a.Kill()
			end)
		end
	end)
	Trigger.OnEnteredFootprint(EvilnogoArea2, function(a, id) 
		if a.Owner == Multi2 or a.Owner == Multi3 then
			a.Owner = Neutral
			a.Kill()
			Trigger.OnIdle(a, function()
				Trigger.ClearAll(a)
				a.Move(CPos.New(55, 33))
				a.Kill()
			end)
		end
	end)
	Trigger.OnEnteredFootprint(Bridgepoint1, function(a, id)
		if a.Owner == Multi0 then
			Trigger.RemoveFootprintTrigger(id)
			Waypoint1 = Actor.Create("waypoint", true, { Location = (CPos.New(38,5)), Owner = Neutral })
			Media.PlaySoundNotification( allplayers, "Beacon")
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				Camera.Position = Waypoint1.CenterPosition
				Beacon.New(Multi0, Waypoint1.CenterPosition, 150, true)
				Beacon.New(Multi2, Waypoint1.CenterPosition, 150, true)
				NIX2.Destroy()
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(37,3)), Owner = Neutral })
				Trigger.AfterDelay(DateTime.Seconds(2), function()
					NIX1.Destroy()
					Bridge2 = Actor.Create("q1d12", true, { Location = (CPos.New(37,1)), Owner = Neutral })
				end)
			end)
		end
	end)
	Trigger.OnEnteredFootprint(Bridgepoint2, function(a, id) 
		if a.Owner == Multi0 then
			Trigger.RemoveFootprintTrigger(id)
			Waypoint2 = Actor.Create("waypoint", true, { Location = (CPos.New(5,38)), Owner = Neutral })
			Media.PlaySoundNotification( allplayers, "Beacon")
			Trigger.AfterDelay(DateTime.Seconds(1), function()
				Camera.Position = Waypoint2.CenterPosition
				Beacon.New(Multi0, Waypoint2.CenterPosition, 150, true)
				Beacon.New(Multi2, Waypoint2.CenterPosition, 150, true)
				NIX4.Destroy()
				Bridge1 = Actor.Create("q1d12", true, { Location = (CPos.New(3,37)), Owner = Neutral })
				Trigger.AfterDelay(DateTime.Seconds(2), function()
					NIX3.Destroy()
					Bridge2 = Actor.Create("q1d12", true, { Location = (CPos.New(1,37)), Owner = Neutral })
				end)
			end)
		end
	end)
end

Thiscolor = HSLColor.New(115, 115, 143)

GoodGuysWinsGame = function()
	Media.PlaySoundNotification( allplayers, "AlertBuzzer")
	Media.DisplayMessage("100 hostages has been rescued good job team 1", "Materia", Thiscolor)
	Trigger.AfterDelay(DateTime.Seconds(5), function()
		Multi0.MarkCompletedObjective(Save100Hostages)
		Multi1.MarkCompletedObjective(GuideTheHostages)
		Multi2.MarkFailedObjective(Kill100Hostages1)
		Multi3.MarkFailedObjective(Kill100Hostages2)
	end)
end


BadGuysWinsGame = function()
	Media.PlaySoundNotification( allplayers, "AlertBuzzer")
	Media.DisplayMessage("100 hostages has been killed what a bad day in History", "Materia", Thiscolor)
	Trigger.AfterDelay(DateTime.Seconds(5), function()
		Multi0.MarkFailedObjective(Save100Hostages)
		Multi1.MarkFailedObjective(GuideTheHostages)
		Multi2.MarkCompletedObjective(Kill100Hostages1)
		Multi3.MarkCompletedObjective(Kill100Hostages2)
	end)
end


Tick = function()
	if Kills > 19 then
		if not Kills20 then
			Kills20 = true
			GoodBeamerUfo()
		end
	end
	if Kills > 29 then
		if not Kills30 then
			Kills30 = true
			GoodLaserUfo()
		end
	end
	if Kills > 39 then
		if not Kills40 then
			Kills40 = true
			GoodLaserUfo()
		end
	end
	if Kills > 49 then
		if not Kills50 then
			Kills50 = true
			GoodBeamerUfo()
		end
	end
	if Kills > 59 then
		if not Kills60 then
			Kills60 = true
			GoodLaserUfo()
		end
	end
	if Kills > 69 then
		if not Kills70 then
			Kills70 = true
			GoodBeamerUfo()
		end
	end
	if Kills > 79 then
		if not Kills80 then
			Kills80 = true
			GoodLaserUfo()
		end
	end
	if Kills > 89 then
		if not Kills90 then
			Kills90 = true
			GoodBeamerUfo() GoodLaserUfo()
		end
	end
	if Kills > 99 then Kills = 100
		if Kills == 100 then
			if not Goodwon then
				Goodwon = true
				BadGuysWinsGame()
			end
		end
	end


	if Rescued > 19 then
		if not Rescued20 then
			Rescued20 = true
			EvilPVICE()
		end
	end
	if Rescued > 29 then
		if not Rescued30 then
			Rescued30 = true
			EvilBSPI()
		end
	end
	if Rescued > 39 then
		if not Rescued40 then
			Rescued40 = true
			EvilPINKY()
		end
	end
	if Rescued > 49 then
		if not Rescued50 then
			Rescued50 = true
			EvilMANC()
		end
	end
	if Rescued > 59 then
		if not Rescued60 then
			Rescued60 = true
			EvilPVICE()
		end
	end
	if Rescued > 69 then
		if not Rescued70 then
			Rescued70 = true
			EvilPVICE()
		end
	end
	if Rescued > 79 then
		if not Rescued80 then
			Rescued80 = true
			EvilBSPI()
		end
	end
	if Rescued > 89 then
		if not Rescued90 then
			Rescued90 = true
			EvilBSPI() EvilIMP()
		end
	end
	if Rescued > 99 then Rescued = 100
		if Rescued == 100 then
			if not Goodwon then
				Goodwon = true
				GoodGuysWinsGame()
			end
		end
	end
	UserInterface.SetMissionText("Saved hostages: " .. (Rescued) .. "/100         Killed hostages: " .. (Kills) .. "/100")
end
GiveMoney = function()
	Multi1Bonus = 10 * Rescued
	Multi3Bonus = 30 * Kills
	Multi1.Cash = Multi1.Cash + Multi1Bonus
	Multi3.Cash = Multi3.Cash + Multi3Bonus
	Media.FloatingText("" .. (Multi1Bonus) .. "", PPlant.CenterPosition, 30, HSLColor.Red)
	Media.FloatingText("" .. (Multi3Bonus) .. "", Base.CenterPosition, 30, HSLColor.Red)
	Trigger.AfterDelay(DateTime.Seconds(10), function()
		GiveMoney()
	end)
end

SetupPlayers = function()
	EnemysTop = Player.GetPlayer("EnemysTop")
	EnemysBottom = Player.GetPlayer("EnemysBottom")
	Neutral = Player.GetPlayer("Neutral")
	Multi0 = Player.GetPlayer("Multi0")
	if Multi0 == nil then
		Multi0 = Player.GetPlayer("Multi1")
		if Multi0 == nil then
			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
			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


function WorldLoaded()
	SetupPlayers()
	CreateMap()
	Multi1Air()
	Multi3Base()
	Insertrefugee()
	EvilReve()
	EvilReve()
	EvilIMP()
	SetTriggers()
	GiveMoney()
	Save100Hostages = Multi0.AddPrimaryObjective("Save 100 hostages, reach the upper left edge of the map.")
	GuideTheHostages = Multi1.AddPrimaryObjective("Protect the hostages from getting killed by the evil forces.")
	Kill100Hostages1 = Multi2.AddPrimaryObjective("Kill as many hostages as you can and prevent that they can escape.")
	Kill100Hostages2 = Multi3.AddPrimaryObjective("Kill as many hostages as you can and prevent that they can escape.")
	Trigger.AfterDelay(DateTime.Seconds(3), function() -- player announcements
		Utils.Do(humans, function(player)
			Player1Name = Multi0.Name
			Player2Name = Multi1.Name
			Player3Name = Multi2.Name
			Player4Name = Multi3.Name
		end)
		Media.DisplayMessage("" .. Player1Name .. " Save 100 hostages, reach the upper left edge of the map. (Look for secret path!)")
		Trigger.AfterDelay(DateTime.Seconds(5), function()
			Media.DisplayMessage("" .. Player2Name .. " Protect the hostages from getting killed by the evil forces.")
			Trigger.AfterDelay(DateTime.Seconds(5), function()
				Media.DisplayMessage("" .. Player3Name .. " and " .. Player4Name .. " you must just kill as many hostages as you can and let none escape.")
			end)
		end)
	end)
end
