//This function makes an item fall to the floor when spawned
IfSpawned
  tmpargument = ACTIONJB
  DoAction
  KeepAction
  MakeCrushValid
  
//Crushed in a passage
IfCrushed
  tmpargument = 3
  tmpdistance = selfz
  tmpx = selfx
  tmpy = selfy
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  GoPoof
  tmpargument = 2
  SendMessageNear
  
IfDropped				// Make it lie on floor
  KeepAction
  tmpargument = 0
  SetState
IfGrabbed				// Tell them what they've won, Johnny!
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 0
    SendMessageNear
IfHitGround
  tmpargument = 2
  PlaySound
  tmpargument = ACTIONDB
  DoAction
IfHeld			//Hide in hand
  tmpargument = 1
  SetState
Else
  tmpargument = 0
  SetState

IfTakenOut
  tmpargument = 0
  SetContent
  SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      tmpargument = 0
      SendMessageNear

IfTimeOut
  tmpargument = 500
  SetTime
  tmpargument = 0
  SetContent

// Allow it to be used
IfUsed
  tmpargument = 50
  SetReloadTime
  SetTargetToWhoeverIsHolding
    tmpx = targetmana
    tmpy = 255
    IfXIsMoreThanY                  //Need 1 mana to cast
    
      // Give experience...
      IfTargetIsAPlayer
        IfNameIsKnown
          DoNothing
        Else
          MakeUsageKnown
          MakeNameKnown
          tmpargument = 30
          tmpdistance = EXPSECRET
          GiveExperienceToTarget
      
      // Do the effect
      tmpargument = 256
      CostTargetMana
        tmpdistance = 0
        SetTargetToWideEnemy
          tmpx = targetmana
          tmpy = 256
          IfXIsMoreThanY
            tmpdistance = 1
        Else
          SetTargetToNearestFriend
            tmpx = targetmana
            tmpy = 256
            IfXIsMoreThanY
              tmpdistance = 1
            
            IfTargetIsSelf
              DoNothing
            Else
              tmpx = targetdistance
              tmpy = 600
              IfXIsMoreThanY
                tmpdistance = 0
          Else
            tmpdistance = 0
                
        tmpturn = 0
        IfDistanceIsMoreThanTurn       //If proceeds then found a target 
          tmpx = targetx
          tmpy = targety
          tmpdistance = targetz
          tmpargument = 1
          SpawnExactParticle
          tmpargument = rand & 511 + 256         //1-3 mana
          CostTargetMana                  //Syphon opponent
            SetTargetToWhoeverIsHolding
            PumpTarget                      //And charge the holder
        Else
          tmpargument = 100
          SetReloadTime
          SetTargetToWhoeverIsHolding
          IfTargetIsAPlayer
            tmpargument = 1
            SendMessageNear
            PlaySound
End
