//The different states:
//0: Closed
//1: Open
//------------------------------------------------------------------
//Just in case
IfSpawned
  tmpargument = passage
  ClosePassage
  tmpargument = ACTIONMJ
  DoAction			//Closed animation

//------------------------------------------------------------------
// Someone cast an unlock spell
IfOrdered
  tmpx = selforder
  tmpy = 491  			// The unique code for an unlock order
  IfXIsEqualToY
    tmpargument = 0		    // Is it closed?
    IfStateIs
      tmpargument = 2
      SendMessageNear		//Tell it dint work
      tmpdistance = 11000
      PlaySound			//Funky sound

//------------------------------------------------------------------
//Open if both keys are used
IfTimeOut
  tmpargument = passage
  SetTargetToWhoeverIsInPassage
  tmpargument = [KEYB]
  IfTargetHasItemID
    CostTargetItemID
      tmpargument = passage
      OpenPassage			//Yep
      tmpargument = 0
      SendMessageNear

//------------------------------------------------------------------
// Handle the animation and sound
KeepAction
tmpargument = passage	// Is the passage clear?
IfPassageOpen
  tmpargument = 0
  IfStateIs				//Don't loop
    tmpargument = ACTIONMG
    DoAction
      SetState
      tmpargument = 1		      //Spooky sounds
      PlayFullSound
      tmpargument = 0
      PlayFullSound

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