-- Startup
function InitGame(levelTime, randomSeed, restart)
	game.Print("Lua Level Init...");
	game.Print("-map_restart ...");
		game.Print("--workaround-setup ...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_levelchange");
			ent:SetKeyValue("targetname", "map_restart");
			ent:SetKeyValue("target", "dn1");
			entity.CallSpawn(ent);
		game.Print("--trigger-setup ...");
		if restart == 1 then
			game.ClientPrint(-1, "Please don't use map_restart, use map or devmap instead.");
			game.Print("Please don't use map_restart, use map or devmap instead.");
			ent = entity.Find("map_restart")
			entity.Use(ent)
		end
	game.Print("-Shuttle Bay Script...");
		game.Print("--Forcefield");;
			ent = entity.Find("forcefield");
			ent:SetKeyValue("classname", "func_forcefield");
			entity.CallSpawn(ent);
		game.Print("--switch");
			ent = entity.FindBModel(83);
			ent:SetKeyValue("targetname", "sbswitch");
			ent:SetKeyValue("target", "forcefield");
			ent:SetKeyValue("luaUse", "sound38");
			ent:SetKeyValue("spawnflags", "512");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(38);
			ent:SetKeyValue("targetname", "forcefield");
			ent:SetKeyValue("team", "2");
			entity.CallSpawn(ent);
		game.Print("--gravity");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_gravity");
			ent:SetKeyValue("targetname", "forcefield");
			ent:SetKeyValue("targetname2", "800");
			entity.CallSpawn(ent);
		game.Print("--dooropener");
			ent = entity.FindBModel(135);
			ent:SetKeyValue("classname", "func_usable");
			ent:SetKeyValue("target", "hangerdoorcount");
			ent:SetKeyValue("luaUse", "sound135");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "1");
			entity.CallSpawn(ent);
			mover.SetAngles(ent, 0, 270, 0);
			mover.SetPosition(ent, -1775, -680, 128);
		game.Print("--elevator");
			game.Print("---reconfig ...");
				ent = entity.FindBModel(52);
				ent:SetKeyValue("classname", "func_door");
				ent:SetKeyValue("spawnflags", "32");
				ent:SetKeyValue("targetname", "lift-a");
				ent:SetKeyValue("angle", "-2");
				ent:SetKeyValue("wait", "5");
				ent:SetKeyValue("speed", "50");
				ent:SetKeyValue("count", "-242");
				entity.CallSpawn(ent);
			game.Print("---set up boolean ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_boolean");
				ent:SetKeyValue("targetname", "lift-a-bool");
				ent:SetKeyValue("falsetarget", "lift-a");
				ent:SetKeyValue("swapname", "lift-a-swap");
				entity.CallSpawn(ent);
			game.Print("---set up delay ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_delay");
				ent:SetKeyValue("targetname", "lift-a");
				ent:SetKeyValue("target", "lift-a-swap");
				ent:SetKeyValue("spawnflags", "1");
				ent:SetKeyValue("wait", "18");
				entity.CallSpawn(ent);
			game.Print("---set up relay ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "lift-a");
				ent:SetKeyValue("target", "lift-a-swap");
				ent:SetKeyValue("spawnflags", "8");
				entity.CallSpawn(ent);
	game.Print("-Lift-1-Script...");
		game.Print("--set up usables ...");
			ent = entity.FindBModel(21);
			ent:SetKeyValue("targetname", "liftaswitch");
			ent:SetKeyValue("target", "liftabool");
			ent:SetKeyValue("luaUse", "sound21");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(22);
			ent:SetKeyValue("targetname", "liftaswitch");
			ent:SetKeyValue("target", "liftabool");
			ent:SetKeyValue("luaUse", "sound22");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(117);
			ent:SetKeyValue("classname", "func_usable");
			ent:SetKeyValue("targetname", "liftaswitch");
			ent:SetKeyValue("target", "liftabool");
			ent:SetKeyValue("luaUse", "sound117");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -955, -1994, 691)
			ent = entity.FindBModel(136);
			ent:SetKeyValue("classname", "func_usable");
			ent:SetKeyValue("targetname", "liftaswitch");
			ent:SetKeyValue("target", "liftabool");
			ent:SetKeyValue("luaUse", "sound1367");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1056, -1715, 687)
			mover.SetAngles(ent, 0, 180, 0)
			ent = entity.FindBModel(137);
			ent:SetKeyValue("classname", "func_usable");
			ent:SetKeyValue("targetname", "liftaswitch");
			ent:SetKeyValue("target", "liftabool");
			ent:SetKeyValue("luaUse", "sound1367");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1056, -1727, 687)
			mover.SetAngles(ent, 0, 180, 0)
		game.Print("--set up upper doors ...");
			ent = entity.FindBModel(56);
			ent:SetKeyValue("targetname", "liftaupperdoor");
			ent:SetKeyValue("angle", "0");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(57);
			ent:SetKeyValue("targetname", "liftaupperdoor");
			ent:SetKeyValue("angle", "0");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(58);
			ent:SetKeyValue("targetname", "liftaupperdoor");
			ent:SetKeyValue("angle", "180");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(59);
			ent:SetKeyValue("targetname", "liftaupperdoor");
			ent:SetKeyValue("angle", "180");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
		game.Print("--set up lower doors ...");
			ent = entity.FindBModel(66);
			ent:SetKeyValue("targetname", "liftalowerdoor");
			ent:SetKeyValue("angle", "0");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(67);
			ent:SetKeyValue("targetname", "liftalowerdoor");
			ent:SetKeyValue("angle", "0");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(68);
			ent:SetKeyValue("targetname", "liftalowerdoor");
			ent:SetKeyValue("angle", "180");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(69);
			ent:SetKeyValue("targetname", "liftalowerdoor");
			ent:SetKeyValue("angle", "180");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
		game.Print("--set up lift and opener-relay ...");
			ent = entity.FindBModel(60);
			ent:SetKeyValue("classname", "func_static");
			ent:SetKeyValue("luaReached", "liftareachedsound");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "opendoor");
			ent:SetKeyValue("target", "newdoor");
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent);
		game.Print("--set up overwrite-savety ...");
			game.Print("---set up boolean ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_boolean");
				ent:SetKeyValue("targetname", "liftabool");
				ent:SetKeyValue("truetarget", "liftastuff");
				ent:SetKeyValue("falsetarget", "liftastartup");
				ent:SetKeyValue("swapname", "liftaswap");
				ent:SetKeyValue("spawnflags", "4");
				entity.CallSpawn(ent);
			game.Print("---set up delay ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_delay");
				ent:SetKeyValue("targetname", "liftastuff");
				ent:SetKeyValue("target", "liftaswap");
				ent:SetKeyValue("spawnflags", "1");
				ent:SetKeyValue("wait", "15");
				entity.CallSpawn(ent);
			game.Print("---set up relay ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "liftastuff");
				ent:SetKeyValue("target", "liftaswap");
				ent:SetKeyValue("spawnflags", "8");
				entity.CallSpawn(ent);
		game.Print("--set up door-bool");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_boolean");
			ent:SetKeyValue("targetname", "liftastuff");
			ent:SetKeyValue("falsetarget", "liftalowerdoor");
			ent:SetKeyValue("truetarget", "liftaupperdoor");
			ent:SetKeyValue("swapname", "newdoor");
			ent:SetKeyValue("spawnflags", "2");
			entity.CallSpawn(ent);
		game.Print("--set up lift-direction-control ...");
			game.Print("---set up delay ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_delay");
				ent:SetKeyValue("targetname", "liftastuff");
				ent:SetKeyValue("target", "liftadir");
				ent:SetKeyValue("spawnflags", "1");
				ent:SetKeyValue("wait", "3");
				entity.CallSpawn(ent);
			game.Print("---set up boolean ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_boolean");
				ent:SetKeyValue("falsetarget", "liftadownrelay");
				ent:SetKeyValue("truetarget", "liftauprelay");
				ent:SetKeyValue("swapname", "liftadir");
				ent:SetKeyValue("spawnflags", "2");
				entity.CallSpawn(ent);
			game.Print("---set up relays...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "liftauprelay");
				ent:SetKeyValue("luaUse", "liftaup");
				entity.CallSpawn(ent);
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "liftadownrelay");
				ent:SetKeyValue("luaUse", "liftadown");
				entity.CallSpawn(ent);
		game.Print("--set up startup ...");
			game.Print("---set up counter ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_counter");
				ent:SetKeyValue("targetname", "liftastartup");
				ent:SetKeyValue("target", "liftastartuprelays");
				ent:SetKeyValue("count", "1");
				entity.CallSpawn(ent);
			game.Print("---set up relays...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "liftastartuprelays");
				ent:SetKeyValue("target", "liftalowerdoor");
				entity.CallSpawn(ent);
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_delay");
				ent:SetKeyValue("targetname", "liftastartuprelays");
				ent:SetKeyValue("target", "liftaswap");
				ent:SetKeyValue("wait", "3");
				ent:SetKeyValue("spawnflags", "1");
				entity.CallSpawn(ent);
	game.Print("-Lift-2-Script...");
		game.Print("--set up usables ...");
			ent = entity.FindBModel(18);
			ent:SetKeyValue("targetname", "liftbswitch");
			ent:SetKeyValue("target", "liftbdoor");
			ent:SetKeyValue("luaUse", "sound18");
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(138);
			ent:SetKeyValue("classname", "func_usable");
			ent:SetKeyValue("targetname", "liftbswitch");
			ent:SetKeyValue("target", "liftbstuff");
			ent:SetKeyValue("luaUse", "sound1389");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -949, 92, 693)
			mover.SetAngles(ent, 0, 270, 0)
			ent = entity.FindBModel(139);
			ent:SetKeyValue("classname", "func_usable");
			ent:SetKeyValue("targetname", "liftbswitch");
			ent:SetKeyValue("target", "liftbstuff");
			ent:SetKeyValue("luaUse", "sound1389");
			ent:SetKeyValue("spawnflags", "8");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -961, 92, 693)
			mover.SetAngles(ent, 0, 270, 0)
		game.Print("--set up doors ...");
			ent = entity.FindBModel(71);
			ent:SetKeyValue("targetname", "liftbdoor");
			ent:SetKeyValue("angle", "0");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(72);
			ent:SetKeyValue("targetname", "liftbdoor");
			ent:SetKeyValue("angle", "0");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(73);
			ent:SetKeyValue("targetname", "liftbdoor");
			ent:SetKeyValue("angle", "180");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(74);
			ent:SetKeyValue("targetname", "liftbdoor");
			ent:SetKeyValue("angle", "180");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "0");
			entity.CallSpawn(ent);
		game.Print("--set up lift and transfer ...");
			ent = entity.FindBModel(61);
			ent:SetKeyValue("classname", "func_static");
			ent:SetKeyValue("luaReached", "liftbreachedsound");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_levelchange");
			ent:SetKeyValue("targetname", "transfer");
			ent:SetKeyValue("target", "dn2");
			ent:SetKeyValue("wait", "-1");
			entity.CallSpawn(ent);
		game.Print("--set up delay ...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_delay");
			ent:SetKeyValue("targetname", "liftbstuff");
			ent:SetKeyValue("target", "liftbmove");
			ent:SetKeyValue("spawnflags", "1");
			ent:SetKeyValue("wait", "3");
			entity.CallSpawn(ent);
		game.Print("--set up relay for doors ...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "liftbstuff");
			ent:SetKeyValue("target", "liftbdoor");
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent);
		game.Print("--set up relay for move ...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "liftbmove");
			ent:SetKeyValue("luaUse", "liftbup");
			entity.CallSpawn(ent);
	game.Print("-Laser-Script...");
		game.Print("--set up laser-model and Phasers ...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "misc_model_breakable");
			ent:SetKeyValue("targetname", "laser");
			ent:SetKeyValue("model", "models/mapobjects/forge/probe.md3");
			ent:SetKeyValue("spawnflags", "24");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1594, -1156, 764)
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "info_notnull");
			ent:SetKeyValue("targetname", "lasertgt");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1095, -1185, 670)
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "fx_phaser");
			ent:SetKeyValue("targetname", "laser1");
			ent:SetKeyValue("target", "lasertgt");
			ent:SetKeyValue("wait", "999999");
			ent:SetKeyValue("spawnflags", "1");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1585, -1154.25, 750)
			mover.SetAngles(ent, 1, 0, 0)
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "fx_phaser");
			ent:SetKeyValue("targetname", "laser2");
			ent:SetKeyValue("target", "lasertgt");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1585, -1154.25, 750)
			mover.SetAngles(ent, 2.5, 1000, 1)
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "fx_phaser");
			ent:SetKeyValue("targetname", "laser3");
			ent:SetKeyValue("target", "lasertgt");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1585, -1154.25, 750)
			mover.SetAngles(ent, 5, 1000, 1)
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "fx_phaser");
			ent:SetKeyValue("targetname", "laser4");
			ent:SetKeyValue("target", "lasertgt");
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -1585, -1154.25, 750)
			mover.SetAngles(ent, 10, 1000, 1)
		game.Print("--set up breakables ...");
			ent = entity.FindBModel(14);
			ent:SetKeyValue("classname", "func_breakable");
			ent:SetKeyValue("target", "left_off");
			ent:SetKeyValue("spawnflags", "272");
			ent:SetKeyValue("health", "10");
			entity.CallSpawn(ent);
			entity.Use(ent)
			ent = entity.FindBModel(13);
			ent:SetKeyValue("classname", "func_breakable");
			ent:SetKeyValue("target", "up_off");
			ent:SetKeyValue("spawnflags", "272");
			ent:SetKeyValue("health", "10");
			entity.CallSpawn(ent);
			entity.Use(ent)
			ent = entity.FindBModel(12);
			ent:SetKeyValue("classname", "func_breakable");
			ent:SetKeyValue("target", "down_off");
			ent:SetKeyValue("spawnflags", "272");
			ent:SetKeyValue("health", "10");
			entity.CallSpawn(ent);
			entity.Use(ent)
			ent = entity.FindBModel(140);
			ent:SetKeyValue("classname", "func_breakable");
			ent:SetKeyValue("target", "right_off");
			ent:SetKeyValue("spawnflags", "272");
			ent:SetKeyValue("health", "10");
			entity.CallSpawn(ent);
			entity.Use(ent)
		game.Print("--set up usables ...");
			ent = entity.FindBModel(8);
			ent:SetKeyValue("team", "2");
			entity.CallSpawn(ent);
			entity.Use(ent)
			ent = entity.FindBModel(9);
			ent:SetKeyValue("team", "2");
			entity.CallSpawn(ent);
			entity.Use(ent)
			ent = entity.FindBModel(10);
			ent:SetKeyValue("team", "2");
			entity.CallSpawn(ent);
			entity.Use(ent)
			ent = entity.FindBModel(11);
			ent:SetKeyValue("team", "2");
			entity.CallSpawn(ent);
			entity.Use(ent)
		game.Print("--set up relays to counters...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "left_off");
			ent:SetKeyValue("target", "lasercount");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "up_off");
			ent:SetKeyValue("target", "lasercount");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "down_off");
			ent:SetKeyValue("target", "lasercount");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "right_off");
			ent:SetKeyValue("target", "lasercount");
			entity.CallSpawn(ent);        
		game.Print("--set up counters ..."); 
			ent:SetKeyValue("classname", "target_counter");
			ent:SetKeyValue("targetname", "lasercount");
			ent:SetKeyValue("target", "laser1");
			ent:SetKeyValue("count", "1");
			entity.CallSpawn(ent); 
			ent:SetKeyValue("classname", "target_counter");
			ent:SetKeyValue("targetname", "lasercount");
			ent:SetKeyValue("target", "laser2relay");
			ent:SetKeyValue("count", "2");
			entity.CallSpawn(ent); 
			ent:SetKeyValue("classname", "target_counter");
			ent:SetKeyValue("targetname", "lasercount");
			ent:SetKeyValue("target", "laser3relay");
			ent:SetKeyValue("count", "3");
			entity.CallSpawn(ent); 
			ent:SetKeyValue("classname", "target_counter");
			ent:SetKeyValue("targetname", "lasercount");
			ent:SetKeyValue("target", "laser4relay");
			ent:SetKeyValue("count", "4");
			entity.CallSpawn(ent);
		game.Print("--set up relays for boolean-swaping...");
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "laser2relay");
			ent:SetKeyValue("target", "laserboolswap2");
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "laser3relay");
			ent:SetKeyValue("target", "laserboolswap3"); 
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_relay");
			ent:SetKeyValue("targetname", "laser4relay");
			ent:SetKeyValue("target", "laserboolswap4");
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent); 
		game.Print("--set up booleans..."); 
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_boolean");
			ent:SetKeyValue("targetname", "laserbool1");
			ent:SetKeyValue("truetarget", "laserbool2");  
			ent:SetKeyValue("targetname", "laserboolswap2");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_boolean");
			ent:SetKeyValue("targetname", "laserbool3");
			ent:SetKeyValue("falsetarget", "laser2");
			ent:SetKeyValue("truetarget", "laserbool3");  
			ent:SetKeyValue("targetname", "laserboolswap3");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_boolean");
			ent:SetKeyValue("targetname", "laserbool3");
			ent:SetKeyValue("falsetarget", "laser3");
			ent:SetKeyValue("truetarget", "laser4");  
			ent:SetKeyValue("swapname", "laserboolswap4");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent); 
		game.Print("--set up usable..."); 
			ent = entity.FindBModel(36);
			ent:SetKeyValue("target", "laserbool1");
			ent:SetKeyValue("targetname2", "lasercontrol");
			ent:SetKeyValue("wait", "5");
			ent:SetKeyValue("luause", "sound36");
			ent:SetKeyValue("spawnflags", "8");
			entity.CallSpawn(ent);
		game.Print("--system-crash..."); 
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_deactivate");
			ent:SetKeyValue("targetname", "laser4");
			ent:SetKeyValue("target", "lasercontrol");
			entity.CallSpawn(ent); 
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_delay");
			ent:SetKeyValue("targetname", "laser4");
			ent:SetKeyValue("target", "doorchair"); 
			ent:SetKeyValue("wait", "4");
			entity.CallSpawn(ent); 
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_delay");
			ent:SetKeyValue("targetname", "laser4");
			ent:SetKeyValue("target", "laser"); 
			ent:SetKeyValue("wait", "4");
			entity.CallSpawn(ent); 
	game.Print("-jeffries-door..."); 
		game.Print("--set up doors ..."); 
			ent = entity.FindBModel(85);
			ent:SetKeyValue("classname", "func_door_rotating");
			ent:SetKeyValue("targetname", "jeffriesdoor");
			ent:SetKeyValue("spawnflags", "17");
			ent:SetKeyValue("wait", "10");
			ent:SetKeyValue("distance", "90");
			ent:SetKeyValue("speed", "60");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(29);
			ent:SetKeyValue("classname", "func_door_rotating");
			ent:SetKeyValue("targetname", "jeffriesdoor");
			ent:SetKeyValue("spawnflags", "21");
			ent:SetKeyValue("wait", "10");
			ent:SetKeyValue("distance", "90");
			ent:SetKeyValue("speed", "60");
			entity.CallSpawn(ent);
			entity.Use(entity.Find("clipfloor")); 
		game.Print("--set up trigger below the doors ...");
			ent = entity.Spawn();
			ent.SetupTrigger(ent, 128, 112, 56);
			ent:SetKeyValue("classname", "trigger_multiple");
			ent:SetKeyValue("target", "jeffries-bool");
			ent:SetKeyValue("wait", 1);
			entity.CallSpawn(ent);
			mover.SetPosition(ent, -944, -464, 604);
		game.Print("--set up trigger script ..."); 
			game.Print("---set up delays ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_delay");
				ent:SetKeyValue("targetname", "jeffriesstuff");
				ent:SetKeyValue("target", "jeffriesswap");
				ent:SetKeyValue("spawnflags", "1");
				ent:SetKeyValue("wait", "15");
				entity.CallSpawn(ent);
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_delay");
				ent:SetKeyValue("targetname", "jeffriesstuff");
				ent:SetKeyValue("target", "clipfloor");
				ent:SetKeyValue("spawnflags", "1");
				ent:SetKeyValue("wait", "12");
				entity.CallSpawn(ent);
			game.Print("---set up boolean ...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_boolean");
				ent:SetKeyValue("falsetarget", "jeffriesstuff");
				ent:SetKeyValue("swapname", "jeffriesswap");
				ent:SetKeyValue("targetname", "jeffries-bool");
				entity.CallSpawn(ent);
			game.Print("---set up relays...");
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "jeffriesstuff");
				ent:SetKeyValue("target", "jeffriesdoor");
				entity.CallSpawn(ent);
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "jeffriesstuff");
				ent:SetKeyValue("target", "jeffriesswap");
				entity.CallSpawn(ent);
				ent = entity.Spawn();
				ent:SetKeyValue("classname", "target_relay");
				ent:SetKeyValue("targetname", "jeffriesstuff");
				ent:SetKeyValue("target", "clipfloor");
				entity.CallSpawn(ent);
	game.Print("-corridoors ...");
		game.Print("--set up sickbay doors ...");
			ent = entity.FindBModel(43);
			ent:SetKeyValue("targetname", "laser");
			ent:SetKeyValue("angle", "90");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(39);
			ent:SetKeyValue("classname", "func_door");
			ent:SetKeyValue("targetname", "laser");
			ent:SetKeyValue("angle", "90");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(40);
			ent:SetKeyValue("targetname", "laser");
			ent:SetKeyValue("angle", "270");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(44);
			ent:SetKeyValue("classname", "func_door");
			ent:SetKeyValue("targetname", "laser");
			ent:SetKeyValue("angle", "270");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
		game.Print("--set up cargodoors ...");
			ent = entity.FindBModel(79);
			ent:SetKeyValue("targetname", "cargodoors");
			ent:SetKeyValue("angle", "90");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(78);
			ent:SetKeyValue("targetname", "cargodoors");
			ent:SetKeyValue("angle", "90");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(76);
			ent:SetKeyValue("targetname", "cargodoors");
			ent:SetKeyValue("angle", "270");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "40");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.FindBModel(77);
			ent:SetKeyValue("targetname", "cargodoors");
			ent:SetKeyValue("angle", "270");
			ent:SetKeyValue("wait", "-1");
			ent:SetKeyValue("speed", "25");
			ent:SetKeyValue("count", "32");
			ent:SetKeyValue("spawnflags", "4");
			entity.CallSpawn(ent);
			ent = entity.Spawn();
			ent:SetKeyValue("classname", "target_counter");
			ent:SetKeyValue("targetname", "bubba");
			ent:SetKeyValue("target", "cargodoors");
			ent:SetKeyValue("count", "1");
			entity.CallSpawn(ent);
	game.Print("-Setting up spawnpoints...");
		entity.RemoveSpawns();
		ent = entity.Spawn();
		ent:SetKeyValue("classname", "info_player_deathmatch");
		mover.SetPosition(ent, -2192, 336, 112); 
		mover.SetAngles(ent, 0, 0, 0);
		entity.CallSpawn(ent);
		ent = entity.Spawn();
		ent:SetKeyValue("classname", "info_player_deathmatch");
		mover.SetPosition(ent, -2160, 368, 112); 
		mover.SetAngles(ent, 0, 0, 0);
		entity.CallSpawn(ent);
		ent = entity.Spawn();
		ent:SetKeyValue("classname", "info_player_deathmatch");
		mover.SetPosition(ent, -2160, 304, 112); 
		mover.SetAngles(ent, 0, 0, 0);
		entity.CallSpawn(ent);
		ent = entity.Spawn();
		ent:SetKeyValue("classname", "info_player_deathmatch");
		mover.SetPosition(ent, -2224, 368, 112);  
		mover.SetAngles(ent, 0, 0, 0);
		entity.CallSpawn(ent);
		ent = entity.Spawn();
		ent:SetKeyValue("classname", "info_player_deathmatch");
		mover.SetPosition(ent, -2224, 304, 112);
		mover.SetAngles(ent, 0, 0, 0);
		entity.CallSpawn(ent);
	game.Print("-Breakable-Mod...");
		game.Print("--misc_model_breakable...");
			game.Print("---checking for local or dedicated...");
				if not entity.FindNumber(280) == nil then
				ent = entity.FindNumber(280);
				test = ent.GetClassname(ent);
				if test == "misc_model_breakable" then
			game.Print("----dedicated...");
				ent = entity.FindNumber(243);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(244);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(245);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(246);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(247);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(248);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(249);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(274);
				ent:SetKeyValue("spawnflags", "24");
				ent:SetKeyValue("health", "0");
				ent:SetTakedamage(not ent:GetTakedamage());
				entity.CallSpawn(ent);
				ent = entity.FindNumber(280);
				ent:SetKeyValue("material", "1");
				ent:SetKeyValue("spawnflags", "24");
				ent:SetTakedamage(not ent:GetTakedamage());
				ent:SetKeyValue("targetname", "doorchair");
				ent:SetKeyValue("health", "0");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				else
			game.Print("----local...");
				ent = entity.FindNumber(235);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(236);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(237);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(238);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(239);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(240);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(241);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(263);
				ent:SetKeyValue("spawnflags", "24");
				ent:SetKeyValue("health", "0");
				ent:SetTakedamage(not ent:GetTakedamage());
				entity.CallSpawn(ent);
				ent = entity.FindNumber(264);
				ent:SetKeyValue("material", "1");
				ent:SetKeyValue("spawnflags", "24");
				ent:SetTakedamage(not ent:GetTakedamage());
				ent:SetKeyValue("targetname", "doorchair");
				ent:SetKeyValue("health", "0");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				end
				else
			game.Print("----local...");
				ent = entity.FindNumber(235);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(236);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(237);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(238);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(239);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(240);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(241);
				ent:SetKeyValue("material", "3");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				ent = entity.FindNumber(263);
				ent:SetKeyValue("spawnflags", "24");
				ent:SetKeyValue("health", "0");
				ent:SetTakedamage(not ent:GetTakedamage());
				entity.CallSpawn(ent);
				ent = entity.FindNumber(264);
				ent:SetKeyValue("material", "1");
				ent:SetKeyValue("spawnflags", "24");
				ent:SetTakedamage(not ent:GetTakedamage());
				ent:SetKeyValue("targetname", "doorchair");
				ent:SetKeyValue("health", "0");
				ent:SetKeyValue("splashDamage", "75");
				ent:SetKeyValue("splashRadius", "75");
				entity.CallSpawn(ent);
				end
game.Print(ent.GetTakedamage(entity.FindNumber(263)));
game.Print("...Done");
end     

-- Functions

function liftbup(ent)
	ent = entity.FindBModel(61);
	mover.ToPosition(ent, 75, -946, 92, 1234);
    sound.PlaySound(ent, "sound/movers/doors/largedoorstart.mp3", 0);
end

function liftaup(ent)
	ent = entity.FindBModel(60);
	mover.ToPosition(ent, 75, -948, -1824, 642);
    sound.PlaySound(ent, "sound/movers/doors/largedoorstart.mp3", 0);
end

function liftadown(ent)
	ent = entity.FindBModel(60);
	mover.ToPosition(ent, 75, -948, -1824, 40);
    sound.PlaySound(ent, "sound/movers/doors/largedoorstart.mp3", 0);
end

--Sounds

function sound38(ent, other, activator)
    sound.PlaySound(entity.FindBModel(38), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
	ent = entity.Spawn(); --Door Activation
	ent:SetKeyValue("classname", "target_counter");
	ent:SetKeyValue("targetname", "hangerdoorcount");
	ent:SetKeyValue("target", "hangerdoor");
	ent:SetKeyValue("count", "1");
	entity.CallSpawn(ent); --elevator trigger
	ent = entity.Spawn();
	ent.SetupTrigger(ent, 88, 120, 8);
	ent:SetKeyValue("classname", "trigger_multiple");
	ent:SetKeyValue("target", "lift-a-bool");
	ent:SetKeyValue("wait", 1);
	entity.CallSpawn(ent);
	mover.SetPosition(ent, -1982, 60, 352);
end

function sound36(ent, other, activator)
    sound.PlaySound(entity.FindBModel(36), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function sound135(ent, other, activator)
    sound.PlaySound(entity.FindBModel(135), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function sound22(ent, other, activator)
    sound.PlaySound(entity.FindBModel(22), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function sound1367(ent, other, activator)
    sound.PlaySound(entity.FindBModel(136), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
    sound.PlaySound(entity.FindBModel(137), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function sound18(ent, other, activator)
    sound.PlaySound(entity.FindBModel(18), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function sound1389(ent, other, activator)
    sound.PlaySound(entity.FindBModel(138), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
    sound.PlaySound(entity.FindBModel(139), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function sound117(ent, other, activator)
    sound.PlaySound(entity.FindBModel(117), "sound/ambience/dreadnaught/dnlcarpattern1.wav", 0);
end

function liftareachedsound(ent, other, activator)
    sound.PlaySound(entity.FindBModel(60), "sound/movers/doors/largedoorstop.mp3", 0);
    entity.Use(entity.Find("opendoor"));
end

function liftbreachedsound(ent, other, activator)
    sound.PlaySound(entity.FindBModel(60), "sound/movers/doors/largedoorstop.mp3", 0);
    entity.Use(entity.Find("transfer"));
end