#include "common.acs"

int TorchOn;

script 1 OPEN
{
	switch(gametype())
	{
		case GAME_NET_COOPERATIVE:
			print(s:"NOW YOU'VE ANGERED ME!");
			delay(32);
			print(s:"LET THE GODS RAIN DOWN UPON THEE!")
			delay(9);
			Thing_Destroy(255);
			Thing_Destroy(254);
			Thing_Destroy(253);
			Thing_Destroy(252);
			break;
		case GAME_NET_DEATHMATCH:
			print(s:"GREETINGS MORTALS, GREETINGS!");
			delay(32);
			print(s:"WELCOME TO MY FUNHOUSE...");
			delay(32);
			print(s:"ER, WELCOME TO MY KEEP!");
			break;
		case GAME_SINGLE_PLAYER:
			print(s:"LOOSER!");
			delay(32);
			print(s:"THIS IS A DM LEVEL...");
			break;
	}
	Light_Strobe(7,200,0,2,2);     // INIT Strobe Effect
	ACS_Execute(5,1,13,180,0);     // INIT Torch Lighting
	ACS_Execute(10,1,0,0,0);       // INIT FunRoom  1/10 
	ACS_Execute(11,1,0,0,0);       // INIT FunRoom  2/10
	ACS_Execute(12,1,0,0,0);       // INIT FunRoom  3/10
	ACS_Execute(14,1,0,0,0);       // INIT FunRoom  4/10
	ACS_Execute(15,1,0,0,0);       // INIT FunRoom  5/10
	ACS_Execute(13,1,0,0,0);       // INIT FunRoom  6/10
	ACS_Execute(16,1,0,0,0);       // INIT FunRoom  7/10
	ACS_Execute(17,1,0,0,0);       // INIT FunRoom  8/10
	ACS_Execute(18,1,0,0,0);       // INIT FunRoom  9/10
	ACS_Execute(19,1,0,0,0);       // INIT FunRoom 10/10

}


script 2 (int Mode, int STID, int ETID)
{
	switch(Mode)
	{
		case 1:
			until(STID > ETID)
			{
				Thing_Spawn(STID, T_BRIDGE, 0); // Another way?? I want to keep the TID!
				STID += 1;
			} 
			print(s: "THY SEA HATH PARTED!");
			terminate;
			break;
		case 2:
			until(STID > ETID)
			{
				Thing_Remove(STID);
				STID += 1;
			} 
			print(s: "THY BRIDGE NEEDITH REPAIRS!");
			terminate;
			break;
	}
	
}

Script 3 (int tag, int bright)
{
	int x;
	int i;
	x = random(1,5);
	i = random(5,8);
	switch (random(1,3))
	{
		case 1:
			until (x == 0)
			{
				Light_Fade (tag, bright + random(10,20), i);
				x -= 1;
				delay(i);
				i = random(5,8);
			}
			break;
		case 2:
			until (x == 0)
			{
				switch(random(1,2))
				{
					case 1:
						Light_Fade (tag, bright - random(0,9), i);
						break;
					case 2:
						Light_Fade (tag, bright + random(0,9), i);
						break;
				}
				x -= 1;
				delay(i);
				i = random(5,8);
			}
			break;
		case 3:
			until (x == 0)
			{
				Light_Fade (tag, bright - random(10,20), i);
				x -= 1;
				delay(i);
				i = random(5,8);
			}
			break;
	}
	if(TorchOn == 1) restart;
}

Script 4 (int tag)
{
	int bright;
	bright=180;
	Switch(TorchOn)
	{
	case 1:
		print(s:"Goodnight!");
		Thing_Deactivate(tag);
		TorchOn = 0;
		scriptwait(3);
		delay(8);
		Light_Fade(tag,100,16);
		break;
	default:
		Thing_Activate(tag);
		delay(8);
		Light_Fade(tag,bright,16);
		delay(16);
		TorchOn = 1;
		ACS_Execute(3,1,tag,bright,0);
		break;
	}
}

Script 5 (void)
{
	ACS_Execute(4,1,13,180,0);     // INIT Torch Lighting
	delay(9600);
	ACS_Execute(4,1,13,180,0);
	delay(960);
	restart;
}
/* 
**************************************************************************
** From here down is the moving pillars!                                **
** Is there a way to create functions? Or a script that act's like one? **   
** It sucks wasting these script slots on something this dumb!          **
**************************************************************************
*/

// special
//        6:Polyobj_MoveTimes8(4);


Script 10 (void)
{
	int poid;
	poid = 10;
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	restart;
}

Script 11 (void)
{
	int poid;
	poid = 11;
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	restart;
}

Script 12 (void)
{
	int poid;
	poid = 12;
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	restart;
}

Script 14 (void)
{
	int poid;
	poid = 14;
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	restart;
}

Script 15 (void)
{
	int poid;
	poid = 15;
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	restart;
}


Script 13 (void)
{
	int poid;
	poid = 13;
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	restart;
}

Script 16 (void)
{
	int poid;
	poid = 16;
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	restart;
}

Script 17 (void)
{
	int poid;
	poid = 17;
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	restart;
}

Script 18 (void)
{
	int poid;
	poid = 18;
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	restart;
}

Script 19 (void)
{
	int poid;
	poid = 19;
	Polyobj_MoveTimes8(poid,32,192,64);
	polywait(poid);
	Polyobj_MoveTimes8(poid,32,64,64);
	polywait(poid);
	restart;
}
