//Special optional reward for fast players
IfSpawned
  tmpargument = 1
  IfContentIs
    tmpargument = 3000 * difficulty
    tmpargument = 27000 - tmpargument  //9 minutes - 1 for every difficulty level
    SetContent

//Countdown the timer
tmpx = selfcontent
tmpy = 0
IfXIsMoreThanY
  
  //Stop countdown if the final door has been opened (they made it!)
  tmpargument = 20
  IfPassageOpen
    tmpargument = 0
    SetContent
    
    //Award some bonus XP too!
    tmpargument = 100
    tmpdistance = EXPSECRET
    GiveExperienceToGoodTeam
    
    //Tell the archmage ghosts
    tmpargument = [FAST]
    tmpdistance = [FAST]
    OrderSpecialID
    
  tmpargument = selfcontent - 1
  SetContent
  //ShowTimer       //Uncomment to display the time left for extra award
  
  //time out?
  tmpx = 1
  tmpy = selfcontent
  IfXIsEqualToY
    tmpdistance = BLAHITEMS
    tmpargument = [BOOK]      //also orb
    SetTargetToNearestBlahID
      PoofTarget              //Take away the orb as well
    GoPoof
    
//Spawn magic orbs, but not two of the same type
IfSpawned
  IfStateIs0
    tmpargument = rand % 7 + 114
  Else
    tmpx = selfstate                //last orb is 120
    tmpy = 220
    IfXIsMoreThanY
      tmpargument = 114       //First orb is 114
    Else
      tmpargument = rand & 2 + selfstate + 1
      tmpx = tmpargument
      tmpy = 220
      IfXIsMoreThanY
        tmpargument = 214
  
  //Now spawn it!
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz + 250
  SpawnExactCharacterXYZ
  IssueOrder
  
//try not to spawn two of the same orbs
IfOrdered
  tmpx = selforder
  tmpy = 113              //First orb is 114
  IfXIsMoreThanY
    tmpy = 221                //last orb is 120
    IfXIsLessThanY
      tmpargument = selforder
      SetState
    
End
