// Someone cast an unlock spell
IfOrdered
  tmpx = selforder
  tmpy = 491  // The unique code for an unlock order
  IfXIsEqualToY
    tmpargument = 1
    SendMessageNear
    tmpargument = 2
    PlaySound

// See if there is a character in the detect passage
IfTimeOut
  tmpargument = 10
  SetTime
  KeepAction
  tmpargument = passage
  IfPassageOpen
    DoNothing
  Else
    tmpargument = passage + 1
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        tmpargument = [TOUR]
        IfTargetHasQuest          //Only open if they have the quest
          // Give EXP
          tmpargument = 10
          tmpdistance = EXPQUEST
          GiveExperienceToTarget

          // Display text
          tmpargument = 2
          SendMessageNear

          // Open it up
          tmpargument = passage
          OpenPassage
        Else
          tmpargument = 0
          SendMessageNear
          tmpargument = 120
          SetTime

// Handle the animation and sound
tmpargument = passage	// Is the passage clear?
IfPassageOpen			// 
  tmpargument = 0		  //
  IfStateIs			  // State 0 ( Closed )
    tmpargument = ACTIONMG	    //
    DoAction			    //
      tmpargument = 1		      // Open it
      SetState			      //
      tmpargument = 0		      //
      PlaySound			      //
Else
  tmpargument = 1		  //
  IfStateIs			  // State 1 ( Open )
    tmpargument = ACTIONMJ	    //
    DoAction			    //
      tmpargument = 0		      // Close it
      SetState			      //
      tmpargument = 1		      //
      PlaySound			      //
End				// Finished with this character
