#include "zcommon.acs"

#define SLIMETAG_COUNT 2

int openroom=0,
    Door1=0;
	//SlimeTag[2]={4,28};
    //SlimeTag[4]={4,19,20,28};

bool DoorCount[4]={0,0,0,0},
     SlimeLever=false;
	 

SCRIPT 01 (VOID)
{
 openroom ++;
 if (openroom==2)
  {
   SectorSound("FANFARE", 127);
   printbold(s:"SEQUENCE COMPLETED!");
   Door_Open(3,16,3);
  }
 else
  {
   printbold(s:"1 MORE TO GO...");
  }
}

SCRIPT 02 (int DoorTag, int DoorLock) // 
{
 If (CheckInventory("DinkyKey") > 0 && DoorCount[DoorLock] == false)
 {
  DoorCount[DoorLock]=true;
  TakeInventory("DinkyKey",1);
  SectorSound("DOORUNLOCKED",127);
  delay(16);
  Door_Open(DoorTag,16,2);
 }
 Else if (CheckInventory("DinkyKey") == 0 && DoorCount[DoorLock] == false)
 {
  Print(s:"THIS DOOR IS LOCKED");
 }
}

SCRIPT 03 OPEN // sets sector colors
{
 ceiling_Waggle(254,64,8,0,0);	//Slime Tide
 
 Sector_SetColor(17, 0, 160, 64); // Slime
 //Sector_SetFade(17,0,128,32);
 ceiling_Waggle(17,2944,8,0,0);	//Super Slime Tide (368*8=2944)
 //ceiling_Waggle(4,64,8,0,0);	//Slime Tide
 Sector_SetColor(4, 0, 160, 64); // Slime
 Sector_SetColor(28, 0, 160, 64); // Slime
 
 /*
 for (int count = 0; count < SLIMETAG_COUNT; count++)
 {
  Sector_SetColor(SlimeTag[count], 0, 160, 64); // Slime
  //Sector_SetFade(SlimeTag[count],0,128,32);
  //ceiling_Waggle(SlimeTag[count],64,8,0,0);	//Slime Tide
 }
 */
}

//Used for locked doors that require dinky keys
SCRIPT 04 (int doorNum, int poly) // locked door
{
 if (doorCount[doorNum] == true || GameType () == GAME_NET_DEATHMATCH)
	Polyobj_DoorSwing(poly, 32, 64, 64);

 else if (CheckInventory("DinkyKey") == 0 && doorCount[doorNum] == false && GameType () != GAME_NET_DEATHMATCH)
	Print(s:"THIS DOOR IS LOCKED");
  
 else if (CheckInventory("DinkyKey") > 0 && doorCount[doorNum] == false && GameType () != GAME_NET_DEATHMATCH)
 {
  doorCount[doorNum] = true;
  TakeInventory("DinkyKey", 1);
  SectorSound("DOORUNLOCKED",127);
  delay(16);
  Polyobj_DoorSwing(poly, 32, 64, 64);
 }
}

//opens bars
SCRIPT 05(int tag, int gem)
{
	str gemStr = "GEMLCKG1";
	LocalAmbientSound("SWITCH1", 127);
	
	if(gem == 2)
		gemStr = "GEMLCKG1";
	else if(gem == 3)
		gemStr = "GEMLCKY1";
	SetLineTexture(gem, SIDE_FRONT, TEXTURE_MIDDLE, gemStr);
	Door_Open(tag,16);
}

//raises water level because the button is crap.....
SCRIPT 06(VOID)
{
	ceiling_MovetoValue(28,16,592);
}