//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
    GetState
    tmpargument = tmpargument + 1
    SetState				//How many switches has been pulled

    IfStateIs3				//All 3 switches done...
      tmpargument = 1
      tmpdistance = rand % 8500 + 11000
      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
  GetContent
  tmpx = tmpargument
  GetState
  tmpy = tmpargument		//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
    tmpdistance = rand & 3600 + 10000
    PlaySound			//Play clinking
    tmpargument = 10
    SetState			//Dont do again

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