#include "zcommon.acs"

//LEVEL 2: The Water Castle
//DIFFICULTY VARIATION
//Level 1: Everything is unlocked
//Level 2: The trials now have locks
//Level 3: The buttons now have locks
//Level 4: The buttons are no longer labeled
//Level 5: The trials are no longer labeled

global int 1:KingofDenile;

int reflectingwater[9] = { 1,3,4,13,26,27,37,39,85 },
    kingcount=6,
    waterenemy=20,
    //in first dimension, animalLocks[0] is 0, animalLocks[3] is 1, animalLocks[6] is 2, animalLocks[9] is 3.
    //3 in second dimension holds lock on another animal lock.
    locks[4][4],	
    colors[64][2];

bool hippo=0,
	
animalLocks[16],
doorLocks[4],
hippodoor[6] = {0,0,0,0,0,0},
warpswitch[8] = {0,1,0,1,0,1,0,1},
whoistheking[7] = {0,0,0,0,0,0,0},
exit=0;

str    button[4] = {"HSWI_03A","HSWI_04A","HSWI_05A","HSWI_06A" },

	// Textures used for randomized animal buttons
       hippoStr[16] = {
"HEY!  YOU!  HELP ME OUTTA HERE!",
"I'M THE REAL KING OF DENILE!  PLEASE FREE ME!",
"OH DON'T MIND ME I'M JUST TRAPPED HERE FOR ETERNITY.",
"Y HELO THAR IF YOU FREE ME I'LL GIVE U A COOKIE!",
"THE GUY IN THE THRONE IS A USURPER!  I'M THE REAL KING!",
"SOMEONE'S GOTTA HEAR MY DESPERATE PLEAS EVENTUALLY...",
"HEY!  YOU!  UNLOCK THIS DOOR!",
"LEMME OUT LEMME OUT I'M GOIN CRAZY!",
"AH!  FREE AT LAST!",
"I'M THE KING OF DENILE!  THE GUY POSING AS ME IS AN IMPOSTER!",
"IF YOU HAVE ANY OUNCE OF KINDNESS IN YOUR HEART YOU'LL FREE ME.",
"HEY YOU THERE, CAN YOU GET A KEY FOR THIS PRISON CELL?",
"I'M REALLY GETTING BORED IN THIS CAGE...",
"I WAS SO TOTALLY WRONGED!  PLEASE GIVE ME MY THRONE BACK!",
"HEY YOU!  LEMME OUT AND I'LL GIVE YOU MY CANDY!",
"GROAN... I'LL NEVER GET OUT OF HERE..."
},
	kingStr[7] = {
"OF COURSE I'M THE REAL KING.  I'M IN THE THRONE, AREN'T I?",
"I-I-I-I-I-M THE K-K-KI-KING.\nTH-TH-THE-THE-THAT'S ALL THERE IS TO IT FOLKS!",
"COMON, I'M YOUR BUDDY.  YOU KNOW IT'S ME.\nLOOK SEE THIS IN MY POCKET?  A YUMMY COOKIE!\nBUT I CAN ONLY GIVE OUT COOKIES WHEN I'M WEARING MY CROWN.",
"HONESTLY.  THIS IS ALL ABSURD.  JUST HONESTLY PICK ME AND WE CAN HONESTLY GET ON WITH THE REST OF OUR HONEST LIVES.  HONESTLY!",
"BOOOOOOY HOWDY!  ONCE I DUN BECOMIN THE KING AGAIN I'M A GONNA THROW A DARN SMASH RODEO TO CELEBRATE MY RETURN.\nOF COURSE I RECKON YOU WILL BE PICKIN ME, PARTNER, RIGHT?",
"....... PLEASE...\nOUT OF THE KINDNESS OF YOUR HEART AND WISDOM OF YOUR SOUL......\n...PICK ME...\n...PLEASE?",
"WHY ARE YOU BOTHERING ME?\nI'M NOT THE KING OF DENILE.\nLEAVE ME ALONE."
},
	rescuedStr[6][5] = {
{"THANKS FOR S-S-S-S-SAVING ME!","DON'T HURT ME, P-P-P-P-PLEASE!","I AM THE R-R-REAL K-K-K-K-KING.","THAT GUY ON MY TH-TH-THRONE IS AN IMP-IMP-IMP- A FAKE!","I'LL BE G-G-G-GOING B-B-BACK NOW."},
{"THANKS KID, YOU PULLED ME OUT OF A REAL PICKLE THERE.","EVER SINCE THE REVOLT, NOBODY CAN TELL WHO'S THE REAL KING.","BUT I CAN TELL YA, IT'S ME.","MAYBE YOU SHOULD RELEASE THE OTHER PHONEYS IN THEIR CAGES.","THEN YOU AND ME CAN GIVE THE IMPOSTER TRASH\nON MY THRONE A LIL PIECE OF OUR MINDS." },
{"HONESTLY, I WAS BEGINNING TO DOUBT ANYONE WOULD SAVE ME.","GREETINGS, I AM HONESTLY THE KING OF DENILE.","THAT GUY WHO TOOK THE THRONE IS AN HONEST PAIN, IN MY HONEST","OPINION.  HONESTLY, THANK YOU.  I SHOULD HONESTLY TRY TO","RECLAIM THE THRONE NOW.  HONESTLY HONESTLY HONESTLY." },
{"YEEEEEEEHAAAAWWWWWWWWW!!!  HOWDY PARTNER!","GOSH DARN, THANKEE KINDLY FER SAVIN MY KEISTER BUDDY!","I'S RECKON I SURELY OWE YA A FAVOR, PARTNER.","BUT NOW I'M GOSH DARN DUN MAD AT THAT RATTLESNAKE","WHO TOOK MY CROWN.  I'M GONNA GO KEELHAUL HIM\nSO BAD HE'LL JUMP OUTTA HIS BRITCHES." },
{".....","... HI.","... I'M NOT A VERY GOOD TALKER...","... BUT PLEASE SAVE THOSE OTHER HIPPOES..... I'M THEIR KING... UM....","..." },
{"WHAT DO YOU WANT?","I'M NO KING, GO AWAY.","YOU WASTED YOUR TIME SAVING ME.","I'M NOT A KING, I'M NOT A LIAR, I'M NOT EVEN A HIPPO!","AND I'M CERTAINLY NOT GOING TO STAND HERE ALL DAY!" }
};

SCRIPT 01 OPEN //sets all lineid functions and sets sector colors
{
  //ceiling_Waggle(255,64,8,0,0);	//Water Tide
  
  //sets water color and reflection

  //for (int count = 0; count < 9; count++)
   	//Sector_SetPlaneReflection(reflectingwater[count],16,0);

  for (int countx = 0; countx < 64; countx++)
	for (int county = 0; county <= 8; county++)
	{
		colors[countx][0] = 208 - (countx * 8);
		colors[countx][1] = 208 - (county*8);
	}

  Sector_SetColor(const:28, 64, 128, 255);
  //Sector_SetFade(28,0,0,128);
  Sector_SetFade(38,255,255,255);
  Sector_SetFade(39,255,255,255);
  Sector_SetFade(85,255,255,255);

  //Sets up for maze puzzle
  setlinespecial(1,80,70,2,10);
  setlinespecial(2,80,70,2,11);
  setlinespecial(3,80,70,2,12);
  setlinespecial(4,80,70,2,13);
  setlinespecial(5,80,71,2,5,1);
  setlinespecial(6,80,71,2,6,2);
  setlinespecial(7,80,71,2,7,3);
  setlinespecial(8,80,71,2,8,4);
  setlinespecial(26,80,71,2,26,5);

  if (GameType () != GAME_NET_DEATHMATCH)  //Does not happen in deathmatch
 {
  setlinespecial(25,80,3,0,0);
  
  //The teleporty room lines
  setlinespecial(9,0,0,0,0);
  setlinespecial(10,70,9,0,0);
  SetLineTexture(10, SIDE_FRONT, TEXTURE_MIDDLE, "FRCFLDB1");
  setlinespecial(11,0,0,0,0);
  setlinespecial(12,70,9,0,0);
  SetLineTexture(12, SIDE_FRONT, TEXTURE_MIDDLE, "FRCFLDB1");
  setlinespecial(13,0,0,0,0);
  setlinespecial(14,70,9,0,0);
  SetLineTexture(14, SIDE_FRONT, TEXTURE_MIDDLE, "FRCFLDB1");
  setlinespecial(15,0,0,0,0);
  setlinespecial(16,70,9,0,0);
  SetLineTexture(16, SIDE_FRONT, TEXTURE_MIDDLE, "FRCFLDB1");
  
  //ANIMAL LOCKS
  setlinespecial(17,80,36,0,0);
  setlinespecial(27,80,79,2,0);
  setlinespecial(28,80,79,2,1);
  setlinespecial(29,80,79,2,2);
  setlinespecial(30,80,79,2,3);

   //changes the pics of the switches
 int rand,
     cupholder;
 str cupholderStr;
 for (int count = 0; count < 4; count++)
 {
	rand = random(0,3);
	cupholderStr = button[count];
	button[count] = button[rand];
	button[rand] = cupholderStr;
 }

  //changes each of the functions the buttons control
  for (countx = 0; countx < 4; countx++)
      for (county = 0; county < 4; county++)
	{
	 if (county == 3)
 	   locks[countx][county] = countx + 12;
	 else
	   locks[countx][county] = (countx * 3) + county;	 
	}

	int rand1,
	    rand2;

   //and randomizes them
   for (countx = 0; countx < 4; countx++)
      for (county = 0; county < 3; county++)
        {
	   rand1 = random(0,3);
	   rand2 = random(0,2);
	   cupholder = locks[countx][county];
	   locks[countx][county] = locks[rand1][rand2];
	   locks[rand1][rand2] = cupholder;
	}
	
//randomizes the switch doors they unlock as well.
do {
	   rand1 = random(0,3);
	   rand2 = random(0,3);
	   cupholder = locks[rand1][3];
	   locks[rand1][3] = locks[rand2][3];
	   locks[rand2][3] = cupholder;
    }
//keeps locks from unlocking themselves.
//keeps locks from linking back and forth
   while (locks[0][3] == 12 || locks[1][3] == 13 || locks[2][3] == 14 || locks[3][3] == 15 ||
locks[0][3] == 13 && locks[1][3] == 12 && locks[2][3] == 15 && locks[3][3] == 14 ||
locks[0][3] == 14 && locks[1][3] == 15 && locks[2][3] == 12 && locks[3][3] == 13 ||
locks[0][3] == 15 && locks[1][3] == 14 && locks[2][3] == 13 && locks[3][3] == 12
);


   for (count = 0; count < 2; count++)
   {
	animalLocks[locks[count * 2][0]] = 1;
	animalLocks[locks[count * 2][1]] = 0;
	animalLocks[locks[count * 2][2]] = 1;
	if (GameSkill () == SKILL_EASY)
		animalLocks[locks[count * 2][3]] = 1;
	else
		animalLocks[locks[count * 2][3]] = 0;
	animalLocks[locks[(count * 2) + 1][0]] = 0;
	animalLocks[locks[(count * 2) + 1][1]] = 1;
	animalLocks[locks[(count * 2) + 1][2]] = 0;
	animalLocks[locks[(count * 2) + 1][3]] = 1;
   }

	//sets the pictures on the buttons
   if (GameSkill () == SKILL_EASY || GameSkill () == SKILL_NORMAL)
   {
	for (count = 0; count < 4; count++)
	{
		SetLineTexture( count + 27, SIDE_FRONT, TEXTURE_TOP, button[count]);
		SetLineTexture( count + 27, SIDE_BACK, TEXTURE_BOTTOM, button[count]);
	}
   }

   if (GameSkill () != SKILL_VERY_EASY && GameSkill () != SKILL_VERY_HARD)
   {
	//sets pictures on the pictures.
   for (countx = 0; countx < 4; countx++)
	for (county = 0; county < 4; county++)
	{
	if (locks[countx][county] == 0)
		SetLineTexture( locks[countx][county] + 31, SIDE_FRONT, TEXTURE_TOP, button[countx]);

	else if (locks[countx][county] == 4 || locks[countx][county] == 3)
		SetLineTexture( locks[countx][county] + 31, SIDE_BACK, TEXTURE_BOTTOM, button[countx]);

	else if (locks[countx][county] == 1 || locks[countx][county] == 2 || locks[countx][county] >= 5)
	{
		SetLineTexture( locks[countx][county] + 31, SIDE_BACK, TEXTURE_TOP, button[countx]);
		SetLineTexture( locks[countx][county] + 31, SIDE_BACK, TEXTURE_BOTTOM, button[countx]);
	}
	}
   }
   else if (GameSkill () == SKILL_VERY_EASY || GameSkill () == SKILL_VERY_HARD)
   {
	//sets pictures on the pictures.
   for (countx = 0; countx < 4; countx++)
	for (county = 0; county < 4; county++)
   {
	if (locks[countx][county] == 0)
		SetLineTexture( locks[countx][county] + 31, SIDE_FRONT, TEXTURE_TOP, "HSWI_13A");

	else if (locks[countx][county] == 4 || locks[countx][county] == 3)
		SetLineTexture( locks[countx][county] + 31, SIDE_BACK, TEXTURE_BOTTOM, "HSWI_13A");

	else if (locks[countx][county] == 1 || locks[countx][county] == 2 || locks[countx][county] >= 5)
	{
		SetLineTexture( locks[countx][county] + 31, SIDE_BACK, TEXTURE_TOP, "HSWI_13A");
		SetLineTexture( locks[countx][county] + 31, SIDE_BACK, TEXTURE_BOTTOM, "HSWI_13A");
	}
	}
   }
 }
 
 if (GameSkill () != SKILL_VERY_EASY)
 {
 if (animalLocks[2]==0)
 {
  Floor_RaiseByValue(63,255,128);
  Floor_RaiseByValue(62,255,72);
 }


// animalLocks[3] Switch.  Default on map is 2 so only changes if it equals 1.

 if (animalLocks[3]==0)
 {
  Floor_LowerByValue(71,255,72);
  Floor_LowerByValue(72,255,128);
  Floor_LowerByValue(73,255,256);
  Floor_LowerByValue(74,255,320);
  Floor_LowerByValue(75,255,384);
  Floor_LowerByValue(76,255,512);
  Floor_LowerByValue(77,255,640);
  Floor_LowerByValue(78,255,768);
  Floor_LowerByValue(79,255,896);
  Floor_LowerByValue(80,255,1024);
  Floor_LowerByValue(81,255,1152);
  Floor_LowerByValue(82,255,1280);
 }

 if (animalLocks[4]==0)
 {
  Floor_LowerByValue(55,255,248);
  Floor_LowerByValue(56,255,152);
 }

 if (animalLocks[5]==0)
   Ceiling_LowerByValue(83,255,64);

 if (animalLocks[8]==0)
  Ceiling_LowerByValue(65,255,64);


 if (animalLocks[10]==0)
  Ceiling_LowerInstant(61,0,13);

 if (animalLocks[11]==0)
  Ceiling_LowerInstant(64,0,13);

// The doors that bar the switches.  These are raised and lowered by OTHER switches
// (and is designed so it is impossible for all doors to be locked

if (animalLocks[12]==1)
  Ceiling_RaiseInstant(53,0,13);

if (animalLocks[13]==1)
  Ceiling_RaiseInstant(25,0,13);

if (animalLocks[14]==1)
  Ceiling_RaiseInstant(24,0,13);

if (animalLocks[15]==1)
  Ceiling_RaiseInstant(54,0,13);

}
 
}

SCRIPT 02 (int doorTID) //TIDs are 3 and 4
{
 if (hippo==1 || GameType () == GAME_NET_DEATHMATCH)
 	Polyobj_DoorSwing(doorTID, 16, 64, 32);
 else
 	print(s:"THE DOOR WON'T OPEN FOR SOME REASON.");

}

SCRIPT 03 (VOID)
{
 if (hippo==0 && GameType () != GAME_NET_DEATHMATCH)
 {
 str classFace = "SQAR";
 int color = CR_PURPLE;
 LocalAmbientSound("misc/chat", 127);
 switch (PlayerClass(PlayerNumber()))
 {
 	case 0:
		classFace = "SQAR";
		color = CR_TAN;
		break;
	case 1:
		classFace = "SINE";
		color = CR_TAN;
		break;
	default:
		classFace = "SQAR";
		color = CR_TAN;
		break;
 } 

SetPlayerProperty(0,1,PROP_TOTALLYFROZEN); 
int buttons;
bool ok = false;
messageBox_PortraitBold("Hello.  Allow me to introduce myself.\nI am The King of Denile.\nthe REAL King of Denile.","BILFONT","KING",0,CR_TAN);
delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_PortraitBold("Why did your guards stop us from\ncrossing the River?","BILFONT",classFace,0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_PortraitBold("I will allow no one to cross the river at this time.\nbecause they may be conspiring with those who are.\ntrying to usurp me.  So you will be held here for\nthe time being.\n","BILFONT","KING",0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_PortraitBold("That's no good.  I need to cross\nso I can get to the mango mountains.","BILFONT",classFace,0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_Portrait("If you want to be granted permission to pass,.\nyou may prove yourself an ally by stamping out.\nwhoever is plotting my fall from the throne.","BILFONT","KING",0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_PortraitBold("And how would I know who that is?.","BILFONT",classFace,0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_PortraitBold("Well, all of us look exactly alike, wear the same clothes,\nhave the same voices, and everyone's name is King of Denile.\nThat information should narrow it down for you.","BILFONT","KING",0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  ok = false;
  LocalAmbientSound("menu/change", 127);
  messageBox_PortraitBold("Gee thanks a lot\n","BILFONT",classFace,0,CR_TAN);
  delay(8);
 
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }

 messageBox_ClearBold();
 SetPlayerProperty(0,0,PROP_TOTALLYFROZEN);
 hippo = 1;
 }
}

SCRIPT 04 OPEN // Light on Stairs
{
 Light_ChangeToValue(5,160);
 Light_ChangeToValue(6,152);
 Light_ChangeToValue(7,144);
 Light_ChangeToValue(8,136);
 Light_ChangeToValue(9,128);
 Light_ChangeToValue(10,120);
 Light_ChangeToValue(11,112);
 Light_ChangeToValue(12,104);
 delay(3);
 Light_ChangeToValue(6,160);
 Light_ChangeToValue(7,152);
 Light_ChangeToValue(8,144);
 Light_ChangeToValue(9,136);
 Light_ChangeToValue(10,128);
 Light_ChangeToValue(11,120);
 Light_ChangeToValue(12,112);
 Light_ChangeToValue(5,104);
 delay(3);
 Light_ChangeToValue(7,160);
 Light_ChangeToValue(8,152);
 Light_ChangeToValue(9,144);
 Light_ChangeToValue(10,136);
 Light_ChangeToValue(11,128);
 Light_ChangeToValue(12,120);
 Light_ChangeToValue(5,112);
 Light_ChangeToValue(6,104);
 delay(3);
 Light_ChangeToValue(8,160);
 Light_ChangeToValue(9,152);
 Light_ChangeToValue(10,144);
 Light_ChangeToValue(11,136);
 Light_ChangeToValue(12,128);
 Light_ChangeToValue(5,120);
 Light_ChangeToValue(6,112);
 Light_ChangeToValue(7,104);
 delay(3);
 Light_ChangeToValue(9,160);
 Light_ChangeToValue(10,152);
 Light_ChangeToValue(11,144);
 Light_ChangeToValue(12,136);
 Light_ChangeToValue(5,128);
 Light_ChangeToValue(6,120);
 Light_ChangeToValue(7,112);
 Light_ChangeToValue(8,104);
 delay(3);
 Light_ChangeToValue(10,160);
 Light_ChangeToValue(11,152);
 Light_ChangeToValue(12,144);
 Light_ChangeToValue(5,136);
 Light_ChangeToValue(6,128);
 Light_ChangeToValue(7,120);
 Light_ChangeToValue(8,112);
 Light_ChangeToValue(9,104);
 delay(3);
 Light_ChangeToValue(11,160);
 Light_ChangeToValue(12,152);
 Light_ChangeToValue(5,144);
 Light_ChangeToValue(6,136);
 Light_ChangeToValue(7,128);
 Light_ChangeToValue(8,120);
 Light_ChangeToValue(9,112);
 Light_ChangeToValue(10,104);
 delay(3);
 Light_ChangeToValue(12,160);
 Light_ChangeToValue(5,152);
 Light_ChangeToValue(6,144);
 Light_ChangeToValue(7,136);
 Light_ChangeToValue(8,128);
 Light_ChangeToValue(9,120);
 Light_ChangeToValue(10,112);
 Light_ChangeToValue(11,104);
 delay(3);
 restart;
}

SCRIPT 05 OPEN	//random color loop
{
 int randomcolor = random(0,63);
 Sector_SetColor(15, colors[randomcolor][0], colors[randomcolor][1], 0);
 delay(random(1,12)*8);
 restart;
}

SCRIPT 06 (VOID)
{
 PolyObj_Move(5,8,128,16);
 delay(32);
 PolyObj_OR_Move(5,16,192,73);
}

/*
SCRIPT 07 (int swiNum) // animal switches
{
 if (GameType () != GAME_NET_DEATHMATCH)
 {
	for (int count = 0; count < 4; count++)
	{
		if (animalLocks[Locks[swiNum][count]] == 0)
			animalLocks[Locks[swiNum][count]] = 1;
		else
			animalLocks[Locks[swiNum][count]] = 0;
	}
	ACS_EXECUTE(84,2,swiNum,0,0);
 }
}
*/

//doorNum ranges from 0-5
//door tags are 6,52,50,51,49,48 respectively
SCRIPT 08 (int doorNum, int doorTag) // Hippo Cage #1
{
 If (CheckInventory("DinkyKey") == 0 && hippodoor[doorNum] == 0 && GameType () != GAME_NET_DEATHMATCH)
  Print(s:"THIS DOOR IS LOCKED");

 else If (hippodoor[doorNum] == 1 || GameType () == GAME_NET_DEATHMATCH)
  Polyobj_DoorSwing(doorTag, 16, 64, 32);

 else
 {
  hippodoor[doorNum]=1;
  TakeInventory("DinkyKey", 1);
  sectorSound("DOORUNLOCKED",127);
  delay(16);
  Polyobj_DoorSwing(doorTag, 16, 64, 32);
 }
}

//hippos range from 0-5
//their tids are 8,48,49,50,51,52
//their sector tags are 18,19,20,21,22,23
SCRIPT 09 (int hippoNum, int hippoTID) // Hippo Rescued Talk #1
{
 if (GameType () != GAME_NET_DEATHMATCH)
 {
 SetPlayerProperty(0,1,PROP_TOTALLYFROZEN);
 LocalAmbientSound("misc/chat", 127);
 SetFont("BILFONT");
 HudMessage(s:rescuedStr[(hippoNum - 1)][0], s:"\n", s:rescuedStr[(hippoNum - 1)][1], s:"\n", s:rescuedStr[(hippoNum - 1)][2], s:"\n", s:rescuedStr[(hippoNum - 1)][3], s:"\n", s:rescuedStr[(hippoNum - 1)][4]; HUDMSG_PLAIN, 1, CR_TAN, -0.21, -0.01, 0);
 setPortraitMsgBox();
 setPortrait("KING");
 
 int buttons;
 bool ok = false;
 delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }

 messageBox_Clear();
 Thing_Remove(hippoTID);
 SetPlayerProperty(0,0,PROP_TOTALLYFROZEN);
 SetLineBlocking((hippoNum + 17),ON);
 Floor_RaiseByValue((hippoNum + 17),32,48);
 ChangeFloor((hippoNum + 17),"HF_015");
 if (hipponum <= 4)
 	Thing_SpawnNoFog((hippoNum + 1),T_FROZENHIPPO,0);
 else
 	Thing_SpawnNoFog((hippoNum + 1),T_FROZENHIPPO,127);
 ACS_EXECUTE(57,0,0,0,0);
 }
}

//look in the mirror
SCRIPT 10 (VOID)
{
 str classFace = "SQAR";
 str classFaceWink = "SQARWINK";
 int color = CR_PURPLE;
 
 int buttons;
 bool ok = false;
 delay(8);
 
 LocalAmbientSound("misc/chat", 127);
 switch (PlayerClass(PlayerNumber()))
 {
 	case CLASS_ADULT_MALE_AKHET :
		classFace = "SQAR";
		classFaceWink = "SQARWINK";
		color = CR_PURPLE;
		break;
	case CLASS_ADULT_FEMALE_AKHET :
		classFace = "SINE";
		classFaceWink = "SINEWINK";
		color = CR_GREEN;
		break;
	default:
		classFace = "SQAR";
		classFaceWink = "SQARWINK";
		color = CR_PURPLE;
		break;
 } 
 SetPlayerProperty(0,1,PROP_TOTALLYFROZEN); 
 messageBox_Portrait("Hi gorgeous!","BILFONT",classFace,0,CR_TAN);
 
 while (ok == false)
	    {
			buttons = GetPlayerInput(-1, INPUT_BUTTONS);
			if (buttons & BT_USE)
				ok = true;
			delay(1);
	    }

 LocalAmbientSound("DING", 127);
 setPortrait(classFaceWink);
 
 ok = false;
 delay(8);
 
 while (ok == false)
	    {
			buttons = GetPlayerInput(-1, INPUT_BUTTONS);
			if (buttons & BT_USE)
				ok = true;
			delay(1);
	    }

 messageBox_Clear();
 SetPlayerProperty(0,0,PROP_TOTALLYFROZEN); 
}

SCRIPT 23 (VOID) // Hippo Prisoner random speak
{
 if (GameType () != GAME_NET_DEATHMATCH)
 {
 int prisonerspeak=random(0,15);
  print(s:HippoStr[prisonerspeak]);
  delay(120);
  print(s:"");
 }
}

//there are 8 switches
//lines are 9,10,11,12,13,14,15,16
SCRIPT 24 (int swiNum, int line)
{
 if (GameType () != GAME_NET_DEATHMATCH)
 {
 if (warpswitch[swiNum]==0)
 {
  warpswitch[swiNum]=1;
  setlinespecial(line,70,9,0,0);
  SetLineTexture(line, SIDE_FRONT, TEXTURE_MIDDLE, "FRCFLDB1");
 }
 else
 {
  warpswitch[swiNum]=0;
  setlinespecial(line,0,0,0,0);
  SetLineTexture(line, SIDE_FRONT, TEXTURE_MIDDLE, "-");
 }
 if (warpswitch[0]==0 && warpswitch[1]==0 && warpswitch[2]==0 && warpswitch[3]==0 && warpswitch[4]==0 &&warpswitch[5]==0 && warpswitch[6]==0 && warpswitch[7]==0)
 {
  SectorSound("FANFARE", 127);
 }
 }
}

SCRIPT 33 (VOID)
{
 if (GameType () != GAME_NET_DEATHMATCH)	//Does not work in deathmatch
 {
 waterenemy--;
 if (waterenemy >> 0)
  print(d:waterenemy,s:" more to go...");
 else if (waterenemy == 0)
 {
  SectorSound("FANFARE", 127);
  print(s:"sequence completed!");
  Ceiling_RaiseByValue(28,16,96);
 }
 }
}

SCRIPT 34 (VOID)
{
 if (GameType () != GAME_NET_DEATHMATCH)	//Does not work in deathmatch
 {
 delay(35*5);
 Thing_Spawn(15,T_FIREJACKAL,0);
 delay(35*5);
 Thing_Spawn(16,T_FIREJACKAL,0);
 }
}

SCRIPT 35 (VOID)
{
 if (GameType () != GAME_NET_DEATHMATCH)	//Does not work in deathmatch
 {
 delay(35*5);
 Thing_Spawn(16,T_ICEJACKAL,0);
 delay(35*5);
 Thing_Spawn(15,T_ICEJACKAL,0);
 }
}

SCRIPT 36 (VOID) // shoots arrows
{
 if (GameType () != GAME_NET_DEATHMATCH)	//Does not work in deathmatch
 {
 setlinespecial(17,0,0,0,0);
 for (int count = 21; count <=30; count++)
 {
 Thing_Projectile(count,T_NITARROW,128,128,0);
 Thing_Projectile(count + 10,T_NITARROW,0,128,0);
 delay(4);
 }
 restart;
 }
}

SCRIPT 37 (VOID) // deadly pillars
{
 if (GameType () != GAME_NET_DEATHMATCH)	//Does not work in deathmatch
 {
 Polyobj_OR_RotateLeft(11,96,255);
 Polyobj_OR_RotateLeft(13,96,255);
 Polyobj_OR_RotateLeft(15,96,255);
 Polyobj_OR_RotateLeft(17,96,255);
 Polyobj_OR_RotateLeft(19,96,255);
 Polyobj_OR_RotateLeft(21,96,255);
 Polyobj_OR_Move(11,128,128,96);
 delay(8);
 Polyobj_OR_Move(13,128,128,96);
 delay(8);
 Polyobj_OR_Move(15,128,128,96);
 delay(8);
 Polyobj_OR_Move(17,128,128,96);
 delay(8);
 Polyobj_OR_Move(19,128,128,96);
 delay(8);
 Polyobj_OR_Move(21,128,128,96);
 delay(8);
 Polyobj_OR_Move(11,128,0,96);
 delay(8);
 Polyobj_OR_Move(13,128,0,96);
 delay(8);
 Polyobj_OR_Move(15,128,0,96);
 delay(8);
 Polyobj_OR_Move(17,128,0,96);
 delay(8);
 Polyobj_OR_Move(19,128,0,96);
 delay(8);
 Polyobj_OR_Move(21,128,0,96);
 delay(8);
 restart;
 }
}

SCRIPT 38 (VOID) // bodyguards
{
 if (GameType () != GAME_NET_DEATHMATCH)	//Does not work in deathmatch
 {
 delay(16);
 Thing_Spawn(17,T_BANANADISCO,0);
 delay(128);
 Thing_Spawn(18,T_FIREJACKAL,0);
 Thing_Spawn(19,T_ICEJACKAL,0);
 delay(128);
 Thing_Spawn(18,T_RIVERKING,0);
 }
}

SCRIPT 39 (int tag) // 43-52 57-60 tags will slide open when animalLocks[0] in right position
{
 if (animalLocks[0]==1 || GameType () == GAME_NET_DEATHMATCH)
  Door_Raise(tag,64,72,43);
 else
  print(s:"... WON'T BUDGE!");
}

//door tids are 7,47,23,and 45
//Animal Lock numbers are 1,6,7, and 9
SCRIPT 40 (int doorTID, int lockNum) // animalLocks doors
{
 if (animalLocks[lockNum]==1 || GameType () == GAME_NET_DEATHMATCH)
  polyobj_DoorSwing(doorTID,16,64,64);
 else
  print(s:"... WON'T BUDGE!");
}

SCRIPT 57 (VOID)// happens with every king resue.
{
 kingcount--;
 delay(16);
 if (kingcount==0)
 {
  ActivatorSound("FANFARE",127);
  printbold(s:"SEQUENE COMPLETED!");
  setlinespecial(25,80,65,0,0);
 }
 else
  printbold(d:kingcount,s:" MORE TO GO...");
}

SCRIPT 58 (int kingNum) // Hippo analysis #1-7
{
  int buttons;
  bool ok = false;
  bool answer = true;
  SetPlayerProperty(0,1,PROP_TOTALLYFROZEN); 
  SetFont("BILFONT");
  HudMessage(s:kingStr[(kingNum - 1)]; HUDMSG_PLAIN, 1, CR_TAN, -0.21, -0.01, 0);
  setPortraitMsgBox();
  setPortrait("KING");
 
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
  
  LocalAmbientSound("menu/change", 127);
  messageBox_Clear();
  
  SetFont("BILFONT");
	   HudMessage(s:"Is this the King of Denile?"; HUDMSG_PLAIN, 1, CR_TAN, -0.01, -0.01, 0);
	   HudMessage(s:"\n\n\n\nYES"; HUDMSG_PLAIN, 2, CR_GREEN, -0.01, -0.01, 0);
	   HudMessage(s:"\n\n\n\n                no"; HUDMSG_PLAIN, 3, CR_RED, -0.01, -0.01, 0);
	   setPlainMsgBox();
  
  ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
	{
	   LocalAmbientSound("menu/change", 127);
       ok = true;
	}
	if (buttons & BT_LEFT)
	{
	   LocalAmbientSound("menu/change", 127);
       answer = true;
	   messageBox_Clear();
	   SetFont("BILFONT");
	   HudMessage(s:"Is this the King of Denile?"; HUDMSG_PLAIN, 1, CR_TAN, -0.01, -0.01, 0);
	   HudMessage(s:"\n\n\n\nYES"; HUDMSG_PLAIN, 2, CR_GREEN, -0.01, -0.01, 0);
	   HudMessage(s:"\n\n\n\n                no"; HUDMSG_PLAIN, 3, CR_RED, -0.01, -0.01, 0);
	   setPlainMsgBox();
	}
	if (buttons & BT_RIGHT)
	{
	   LocalAmbientSound("menu/change", 127);
       answer = false;
	   messageBox_Clear();
	   SetFont("BILFONT");
	   HudMessage(s:"Is this the King of Denile?"; HUDMSG_PLAIN, 1, CR_TAN, -0.01, -0.01, 0);
	   HudMessage(s:"\n\n\n\nyes"; HUDMSG_PLAIN, 2, CR_RED, -0.01, -0.01, 0);
	   HudMessage(s:"\n\n\n\n                NO"; HUDMSG_PLAIN, 3, CR_GREEN, -0.01, -0.01, 0);
	   setPlainMsgBox();
	}
    delay(1);
  }
  
  messageBox_Clear();
  if (answer == true)
  {
    whoistheking[(kingNum - 1)]=3;
  	ACS_EXECUTE(66,0,0,0,0);
  }
  else if (answer == false)
  {
  	SetPlayerProperty(0,0,PROP_TOTALLYFROZEN); 
  }
}


/*----DEPRECATED SCRIPT----
SCRIPT 58 (int kingNum) // Hippo analysis #1-7
{
 if (whoistheking[(kingNum - 1)]==0)
 {
 for (int count = 0; count < 7; count++)
		whoistheking[count] = 0;
		
 whoistheking[(kingNum - 1)]=1;
 SetFont("BILFONT");
 HudMessage(s:kingStr[(kingNum - 1)]; HUDMSG_PLAIN, 1, CR_TAN, -0.21, -0.01, 0);
 setPortraitMsgBox();
 setPortrait("KING");
 delay(128);
 messageBox_Clear();
 }
 else if (whoistheking[(kingNum - 1)]==1)
 {
 whoistheking[(kingNum - 1)]=2;
 messageBox_PlainBold("ARE YOU REALLY, REALLY SURE THIS GUY IS THE KING?  SELECT ONE MORE TIME TO CONFIRM.","BILFONT",0,CR_TAN);
 delay(128);
 messageBox_Clear();
 }
 else if (whoistheking[(kingNum - 1)]==2)
 {
 whoistheking[(kingNum - 1)] = 3;
 ACS_EXECUTE(66,0,0,0,0);
 }
}
----------------*/
SCRIPT 65 (VOID) // begin hippo analysis
{
  //localsetmusic("VOICE");
  SetPlayerProperty(0,1,PROP_FROZEN);
  setlinespecial(18,80,58,2,1);
  setlinespecial(19,80,58,2,2);
  setlinespecial(20,80,58,2,3);
  setlinespecial(21,80,58,2,4);
  setlinespecial(22,80,58,2,5);
  setlinespecial(23,80,58,2,6);
  setlinespecial(24,80,58,2,7);
  setlinespecial(25,0,0,0,0);
  
  //setlinespecial(18,80,64,0,0);
  //setlinespecial(19,80,58,0,0);
  //setlinespecial(20,80,59,0,0);
  //setlinespecial(21,80,60,0,0);
  //setlinespecial(22,80,61,0,0);
  //setlinespecial(23,80,62,0,0);
  //setlinespecial(24,80,63,0,0);
  //setlinespecial(25,0,0,0,0);
  
  messageBox_PortraitBold("WELL, YOU SAY I'M NOT THE REAL KING,\nAND ONE OF THESE HIPPOS IS?\nSINCE YOU'RE SO SMART, I'LL LET YOU DECIDE.\nBUT I THINK WE ALL KNOW\nI'M THE WINNER HERE.","BILFONT","KING",0,CR_TAN);

  int buttons;
  bool ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }

  //delay(128);
  SetPlayerProperty(0,0,PROP_FROZEN);
  //setlinespecial(25,0,0,0,0);
  //delay(128);
  messageBox_ClearBold();
}

SCRIPT 66 (VOID) // begin hippo analysis
{
  int buttons;
  bool ok = false;
  SetPlayerProperty(0,1,PROP_FROZEN);
  setlinespecial(18,0,0,0,0);
  setlinespecial(19,0,0,0,0);
  setlinespecial(20,0,0,0,0);
  setlinespecial(21,0,0,0,0);
  setlinespecial(22,0,0,0,0);
  setlinespecial(23,0,0,0,0);
  setlinespecial(24,0,0,0,0);
  exit=1;
  if (whoistheking[6]==3)
  {
   AmbientSound("FANFARE",127);
   KingofDenile = 1;
   messageBox_PortraitBold("WELL DONE!\nYOU HAVE DEDUCED THAT ONLY THE TRUE\nKING OF DENILE WOULD NEVER ADMIT IT!","BILFONT","KING",0,CR_TAN);
   
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
   LocalAmbientSound("menu/change", 127);
   messageBox_PortraitBold("I THANK YOU FOR RESTORING MY RIGHTFUL PLACE.\nMAYBE US HIPPOES WOULDN'T HAVE THIS PROBLEM\nIF WE DIDN'T ALL LOOK THE SAME.\nAS FOR YOU USURPERS...","BILFONT","KING",0,CR_TAN);
   ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
   LocalAmbientSound("menu/change", 127);
   messageBox_PortraitBold("LET US CELEBRATE MY RECORONATION WITH\nA ROUND OF BANANAMILK!","BILFONT","KING",0,CR_TAN);
   ok = false;
   delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
       ok = true;
    delay(1);
  }
   LocalAmbientSound("menu/change", 127);
   messageBox_ClearBold();
   SetPlayerProperty(0,0,PROP_FROZEN);
  }
  else
  {
   KingofDenile = 0;
   SetPlayerProperty(0,0,PROP_FROZEN);  
   messageBox_PlainBold("Well now that you've restored the rightful king to the throne...\nyou can go on to the mango mountains.\n.................","BILFONT",0,CR_TAN);

   delay(8);
   while (ok == false)
   {
     buttons = GetPlayerInput(-1, INPUT_BUTTONS);
     if (buttons & BT_USE)
        ok = true;
     delay(1);
   }
   LocalAmbientSound("menu/change", 127);
   messageBox_PlainBold("... You did pick the right guy, didn't you?","BILFONT",0,CR_TAN);

   ok = false;
   delay(8);
   while (ok == false)
   {
     buttons = GetPlayerInput(-1, INPUT_BUTTONS);
     if (buttons & BT_USE)
        ok = true;
     delay(1);
   }
   LocalAmbientSound("menu/change", 127);
   messageBox_ClearBold();
 } 
 SetPlayerProperty(0,0,PROP_TOTALLYFROZEN); 
}

SCRIPT 67 (VOID) // exit
{
 if (exit==0)
  print(s:"YOU CAN'T LEAVE UNTIL YOU SOLVE THE POLITICAL CRISIS.");
 else if (exit==1)
  Exit_Normal(0);
}

//Sigh.....
SCRIPT 68 (VOID) // a hint *DOES NOT DISPLAY IN DEATHMATCH*
{
 if (GameType () != GAME_NET_DEATHMATCH)
 {
  SetPlayerProperty(0,1,PROP_TOTALLYFROZEN);  
  LocalAmbientSound("misc/chat", 127);
  messageBox_Plain("LIST OF ANCESTRAL RULERS:\nKING OF DENILE: REIGNED 42 YEARS.\nKING OF DENILE: REIGNED 7 YEARS.\nKING OF DENILE: REIGNED 1 MONTH AND 19 DAYS.\nKING OF DENILE: REIGNED 2 WEEKS.\nKING OF DENILE: REIGNED 2 DAYS AND 1 HOUR","BILFONT",0,CR_TAN);
 
  int buttons;
  bool ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
	{
       ok = true;
	   LocalAmbientSound("menu/change", 127);
	}
    delay(1);
  }
  messageBox_Clear();

  messageBox_Plain("KING OF DENILE: REIGNED 3 hours AND 58 MINUTES\nKING OF DENILE: REIGNED 5 MINUTES AND 53 SECONDS\nKING OF DENILE: REIGNED 14 SECONDS.","BILFONT",0,CR_TAN);
  ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
	{
       ok = true;
	   LocalAmbientSound("menu/change", 127);
	}
    delay(1);
  }
  messageBox_Clear();

  messageBox_Plain("To pass through the labyrinth you must go:\nLEFT\nRIGHT\nSTRAIGHT\nLEFT\nRIGHT","BILFONT",0,CR_TAN);
  ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
	{
       ok = true;
	   LocalAmbientSound("menu/change", 127);
	}
    delay(1);
  }
  messageBox_Clear();

  messageBox_Plain("Then turn around and go back to find your goal.","BILFONT",0,CR_TAN);
  ok = false;
  delay(8);
  while (ok == false)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
	{
       ok = true;
	   LocalAmbientSound("menu/change", 127);
	}
    delay(1);
  }
  messageBox_Clear();
  
 SetPlayerProperty(0,0,PROP_TOTALLYFROZEN);  
 }
}

SCRIPT 69 (VOID)		//Player trips over trigger to drain water in key room.  Turned off in deathmatch.
{
 if (GameType () != GAME_NET_DEATHMATCH)	//does not work in deathmatch
  Ceiling_LowerByValue(28,16,96);
}

SCRIPT 70 (int teleTID) //teletid is 10-13
{
 setlinespecial(5,80,71,2,5,1);
 setlinespecial(6,80,71,2,6,2);
 setlinespecial(7,80,71,2,7,3);
 setlinespecial(8,80,71,2,8,4);
 //setlinespecial(26,80,71,2,26,5);
 //setlinespecial(27,80,72,2,0,0);
 //setlinespecial(28,80,70,2,10,0);
 Teleport_Nofog(teleTID);
 ActivatorSound("ERROR2",127);
}

SCRIPT 71 (int line, int alertStrNum) //lines are 5-8 & 26-28
{
 setlinespecial(line,0,0,0,0);
 str alertStr = "ALERT_1";
 switch(alertStrNum)
 {
	case 1:
		alertStr = "ALERT_1";
		break;
	case 2:
		alertStr = "ALERT_2";
		break;
	case 3:
		alertStr = "ALERT_3";
		break;
	case 4:
		alertStr = "ALERT_4";
		break;
	case 5:
		alertStr = "ALERT_5";
		break;
	default:
		alertStr = "ALERT_1";
		break;
 }
 //ActivatorSound("ALERT_" + alertStrNum,127);
 ActivatorSound(alertStr,127);
}

SCRIPT 72 (VOID)
{
  Teleport_Nofog(14);
  //ActivatorSound("",127);
}

SCRIPT 79 (int swiNum) // animal switches
{
 if (GameType () != GAME_NET_DEATHMATCH)
 {
	for (int count = 0; count < 4; count++)
	{
		if (animalLocks[Locks[swiNum][count]] == 0)
			animalLocks[Locks[swiNum][count]] = 1;
		else
			animalLocks[Locks[swiNum][count]] = 0;
	}
	ACS_EXECUTE(84,2,swiNum,0,0);
 }
}

SCRIPT 80 (VOID)
{
 setlinespecial(5,80,71,2,5,1);
 setlinespecial(6,80,71,2,6,2);
 setlinespecial(7,80,71,2,7,3);
 setlinespecial(8,80,71,2,8,4);
 //setlinespecial(5,80,74,0,0);
 //setlinespecial(6,80,75,0,0);
 //setlinespecial(7,80,76,0,0);
 //setlinespecial(8,80,77,0,0);
 //setlinespecial(26,80,78,0,0);
 //setlinespecial(27,80,79,0,0);
 //setlinespecial(28,80,80,0,0);
 Teleport_Nofog(10);
}

SCRIPT 81 OPEN	//DEATHMATCH SETUP
{
 if (GameType () == GAME_NET_DEATHMATCH)	//sets up for deathmatch
 {

  // Releases the 'locks' the animalLocks[6] switch had made

  Ceiling_RaiseInstant(65,0,13);

  // Releases the 'locks' the animalLocks[3] switch had made

  Ceiling_RaiseInstant(24,0,13);

  Ceiling_LowerByValue(83,255,64);
  Ceiling_RaiseByValue(36,255,72);


  // Releases the 'locks' the animalLocks[0] switch had made
  // But it seems all animalLocks[0] things are setup to be unlocked on deathmatch anyway.

  // Releases the 'locks' the animalLocks[9] switch had made

  Ceiling_RaiseInstant(25,0,13);
 }
}

SCRIPT 82 (VOID)				//A door that does NOT open in Deathmatch
{
 if (GameType () != GAME_NET_DEATHMATCH)
 Polyobj_DoorSwing(27, 16, 64, 100);
}

SCRIPT 83 (VOID)
{
 ActivatorSound("FANFARE",127);
}

SCRIPT 84 (int LockNum)		//Sets the animal locks and makes the level vary upon entrance
{

//Gives each animal lock a random setting.  Makes sure they are evenly sided so everything is not locked or open.

if (GameType () != GAME_NET_DEATHMATCH)
{
 for (int count; count < 4; count++)
 {

 if (Locks[LockNum][count] == 2 && animalLocks[2]==1)
 {
  Floor_LowerByValue(63,255,128);
  Floor_LowerByValue(62,255,72);
 }
 else if (Locks[LockNum][count] == 2 && animalLocks[2]==0)
 {
  Floor_RaiseByValue(63,255,128);
  Floor_RaiseByValue(62,255,72);
 }


// animalLocks[3] Switch.  Default on map is 2 so only changes if it equals 1.

 if (Locks[LockNum][count] == 3 && animalLocks[3]==1)
 {
  Floor_RaiseByValue(71,255,72);
  Floor_RaiseByValue(72,255,128);
  Floor_RaiseByValue(73,255,256);
  Floor_RaiseByValue(74,255,320);
  Floor_RaiseByValue(75,255,384);
  Floor_RaiseByValue(76,255,512);
  Floor_RaiseByValue(77,255,640);
  Floor_RaiseByValue(78,255,768);
  Floor_RaiseByValue(79,255,896);
  Floor_RaiseByValue(80,255,1024);
  Floor_RaiseByValue(81,255,1152);
  Floor_RaiseByValue(82,255,1280);
  
 }
 else if (Locks[LockNum][count] == 3 && animalLocks[3]==0)
 {
  Floor_LowerByValue(71,255,72);
  Floor_LowerByValue(72,255,128);
  Floor_LowerByValue(73,255,256);
  Floor_LowerByValue(74,255,320);
  Floor_LowerByValue(75,255,384);
  Floor_LowerByValue(76,255,512);
  Floor_LowerByValue(77,255,640);
  Floor_LowerByValue(78,255,768);
  Floor_LowerByValue(79,255,896);
  Floor_LowerByValue(80,255,1024);
  Floor_LowerByValue(81,255,1152);
  Floor_LowerByValue(82,255,1280);
 }

 if (Locks[LockNum][count] == 4 && animalLocks[4]==1)
 {
  Floor_RaiseByValue(55,255,248);
  Floor_RaiseByValue(56,255,152);
 }
 else if (Locks[LockNum][count] == 4 && animalLocks[4]==0)
 {
  Floor_LowerByValue(55,255,248);
  Floor_LowerByValue(56,255,152);
 }

 if (Locks[LockNum][count] == 5 && animalLocks[5]==1)
   Ceiling_RaiseByValue(83,255,64);
 else if (Locks[LockNum][count] == 5 && animalLocks[5]==0)
   Ceiling_LowerByValue(83,255,64);

 if (Locks[LockNum][count] == 8 && animalLocks[8]==1)
  Ceiling_RaiseByValue(65,255,64);
 else if (Locks[LockNum][count] == 8 && animalLocks[8]==0)
  Ceiling_LowerByValue(65,255,64);


 if (Locks[LockNum][count] == 10 && animalLocks[10]==1)
  Ceiling_RaiseInstant(61,0,13);
 else if (Locks[LockNum][count] == 10 && animalLocks[10]==0)
  Ceiling_LowerInstant(61,0,13);

 if (Locks[LockNum][count] == 11 && animalLocks[11]==1)
  Ceiling_RaiseInstant(64,0,13);
 else if (Locks[LockNum][count] == 11 && animalLocks[11]==0)
  Ceiling_LowerInstant(64,0,13);

// The doors that bar the switches.  These are raised and lowered by OTHER switches
// (and is designed so it is impossible for all doors to be locked

if (GameSkill () != SKILL_EASY)
 {

if (Locks[LockNum][count] == 12 && animalLocks[12]==1)
  Ceiling_RaiseInstant(53,0,13);
else if (Locks[LockNum][count] == 12 && animalLocks[12]==0)
  Ceiling_LowerInstant(53,0,13);

if (Locks[LockNum][count] == 13 && animalLocks[13]==1)
  Ceiling_RaiseInstant(25,0,13);
else if (Locks[LockNum][count] == 13 && animalLocks[13]==0)
  Ceiling_LowerInstant(25,0,13);

if (Locks[LockNum][count] == 14 && animalLocks[14]==1)
  Ceiling_RaiseInstant(24,0,13);
else if (Locks[LockNum][count] == 14 && animalLocks[14]==0)
  Ceiling_LowerInstant(24,0,13);

if (Locks[LockNum][count] == 15 && animalLocks[15]==1)
  Ceiling_RaiseInstant(54,0,13);
else if (Locks[LockNum][count] == 15 && animalLocks[15]==0)
  Ceiling_LowerInstant(54,0,13);
 }
}

 }
}