//Open only for the correct player
IfTimeOut
  tmpargument = 10
  SetTime
  tmpargument = passage + 1
  SetTargetToWhoeverIsInPassage

  tmpargument = 0
  IfContentIs			//Find the class of the player
    tmpargument = [PALA]	//Paladin
  Else
    tmpargument = 1
    IfContentIs
      tmpargument = [ROGU]	//Rouge

  IfTargetHasID 		//Open the gate
    tmpargument = passage
    OpenPassage
  Else
    tmpx = tmpargument		//Is it the Paladin gate?
    tmpy = [PALA]
    IfXIsEqualToY
      tmpargument = [HEAL]	//Then Healers can also enter paladin order
      IfTargetHasID
        tmpargument = passage
        OpenPassage
  tmpargument = passage 	//Close it if noone is inside passage
  ClosePassage

//This function makes the door open if its passage is open
KeepAction			//
tmpargument = passage		// Is the passage clear?
IfPassageOpen			//
  tmpargument = 0		  //
  IfStateIs			  // State 0 ( Closed )
    tmpargument = ACTIONMG	    //
    DoAction			    //
      tmpargument = 1		      // Open it
      SetState			      //
      tmpargument = 0		      //
      tmpdistance = 11025	      //
      PlaySound			      //
Else
  tmpargument = 1		  //
  IfStateIs			  // State 1 ( Open )
    tmpargument = ACTIONMJ	    // 71 is the code for MJ
    DoAction			    //
      tmpargument = 0		      // Close it
      SetState			      //
      tmpargument = 1		      // Sound effect
      tmpdistance = 11025	      //
      PlaySound			      //

End				// Finished with this character
