//This function makes an item fall to the floor when spawned
IfSpawned
  tmpargument = ACTIONJB
  DoAction
  KeepAction
  MakeCrushValid
IfDropped				// Make it lie on floor
  KeepAction
IfGrabbed				// Tell them what they've won, Johnny!
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 0
    SendMessageNear
IfHitGround
  tmpargument = 0
  PlaySound
  tmpargument = ACTIONDB
  DoAction
IfHeld			//Hide in hand
  tmpargument = 1
  SetState
Else
  tmpargument = 0
  SetState

//Spell stuff
IfUsed
  SetTargetToWhoeverIsHolding
  tmpargument = [HMAG]
  IfTargetHasSkillID				//Need divine spell skill
    GetContent
    tmpx = tmpargument
    tmpy = 512					//Don't overcharge
    IfXIsLessThanY
      tmpy = targetmanaflow			//Enough spell power?
      IfYIsMoreThanX
        tmpargument = 14				//Mana cost
        CostTargetMana
          GetContent				//Increase the charge
          tmpargument = tmpargument + 8		//Casting Time
          SetContent

Else
  GetContent
  tmpx = tmpargument
  tmpy = 511
  IfXIsMoreThanY		//Enough power to activate?
    tmpargument = 2
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    SpawnExactParticle
    tmpargument = 0		//Set cooldown time
    SetReloadTime
    tmpargument = 3
    SendMessageNear		//Tell what happened
  Else				
    GetContent
    tmpx = tmpargument
    tmpy = 0
    IfXIsMoreThanY		//Only if there was a charge
      tmpargument = 1
      SendMessageNear		//Tell it didn't work
  tmpargument = 0
  SetContent			//Reset counter

// Put the little mana ball on the
// character's hand
GetContent
tmpx = tmpargument
tmpy = 0
IfXIsMoreThanY
  tmpturn = tmpargument < 4 + 3000
  tmpdistance = SPAWNORIGIN
  tmpargument = 0
  SpawnAttachedSizedParticle

End					// All done
