//Special script, can only be used in Catacomb level 2 unless modified

//-----------------------------------------------------------------------------------------------
//Just in case
IfSpawned
  tmpargument = passage
  ClosePassage

//-----------------------------------------------------------------------------------------------
//Someone pulled a switch
IfOrdered
  tmpx = [OPEN]
  tmpy = selforder
  IfXIsEqualToY
    tmpargument = selfstate + 1
    SetState				//How many switches has been pulled

    IfStateIs3				//All 3 switches done...
      tmpargument = 1
      PlaySound
      tmpargument = 0
      SendMessageNear			//Tell congrats and play sound
      tmpargument = 15
      tmpdistance = EXPDARE
      GiveExperienceToGoodTeam		//Award some xp
      tmpargument = passage
      OpenPassage			//Open the way

//-----------------------------------------------------------------------------------------------
  //Handle opening of individual gates
KeepAction
tmpargument = passage
IfPassageOpen
  tmpargument = 3
  IfContentIs
    tmpargument = ACTIONMG
    DoAction			//Open last gate too
    tmpargument = 4
    SetContent			//Dont repeat
Else				//Only do as long as the passage is closed
  tmpx = selfcontent
  tmpy = selfstate		//If the state of the character is the same as the content
  IfXIsEqualToY			//which means switch 1 opens gate 1, etc.
    tmpargument = ACTIONMG
    DoAction			//Open gate
    tmpargument = 0
    PlaySound			//Play clinking
    tmpargument = 10
    SetState			//Dont do again

//-----------------------------------------------------------------------------------------------
End				// Finished with this character
//-----------------------------------------------------------------------------------------------
