//Maybe the character identifies the gem?
IfUsed
  IfStateIs0
      //Intelligence checks show if others find it out
      tmpx = targetint
      tmpy = rand & 255 * 10 + 2750
      IfXIsMoreThanY
        // Character identifies the gem
        tmpargument = 2
        SendMessageNear
        MakeNameKnown
        tmpargument = 30
        tmpdistance = EXPSECRET
        GiveExperienceToTarget
        tmpargument = 2
        SetState
        tmpargument = 100
        SetTime
      Else
        tmpargument = 6
        SendMessageNear
        tmpargument = 4
        SetState
        tmpargument = 100
        SetTime            
        
//This is a ingredient
  IfStateIs1
    tmpargument = 5
    SendMessageNear
    tmpargument = 3
    SetState
    tmpargument = 100
    SetTime

IfTimeOut
  IfStateIs2
    tmpargument = 1
    SetState

  IfStateIs3
    tmpargument = 1
    SetState

  IfStateIs4
    tmpargument = 0
    SetState

// Set up general stuff
IfSpawned
  tmpargument = ACTIONJB
  DoAction
  KeepAction

// Make it lie on the floor
IfDropped
  KeepAction

// Play a clink or clang
IfHitGround
  tmpargument = 0
  tmpdistance = rand & 2047 + 10000
  PlaySound

// Alert others to draw
IfTakenOut
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 3
    SendMessageNear

// Tell them what they've won...
IfGrabbed
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 0
    SendMessageNear

// Finish up
End
