// Remove the charge
IfTakenOut
  tmpargument = 0
  SetContent
  SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      tmpargument = 6
      SendMessageNear

//tell them what they found
IfGrabbed
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 0
    SendMessageNear
    
//Clank!
IfHitGround
  tmpargument = 0
  PlaySound
    
// Allow it to be used
IfUsed
  UndoEnchant
    tmpargument = 50
    SetReloadTime
    UnsparkleIcon
  Else
    SetTargetToWhoeverIsHolding
    tmpx = selfcontent
    tmpy = 1280			//Max charge
    IfXIsLessThanY
      tmpy = targetmanaflow
      IfXIsLessThanY
        tmpx = 4			//Cast speed
        tmpargument = tmpx
        CostTargetMana
          tmpargument = selfcontent + tmpx
          SetContent

// Allow it to be cast or fizzle
Else
  tmpx = selfcontent
  tmpy = 1279						//Needed charge
  IfXIsMoreThanY
    // Make the holder cast it
    SetTargetToWhoeverIsHolding
      SetOwnerToTarget
      tmpargument = ACTIONZA
      CorrectActionForHand
      TargetDoAction

    EnchantTarget
      tmpx = targetx
      tmpy = targety
      tmpdistance = targetz
      tmpargument = 2
      SpawnExactParticle		//Spawn some Dust
      tmpargument = 1
      SendMessageNear
      tmpargument = 1
      PlaySound
      tmpargument = PURPLE
      SparkleIcon
    Else
      tmpargument = 2
      SendMessageNear
      PlaySound
    tmpargument = 70
    SetReloadTime

  Else
    tmpy = 0
    IfXIsMoreThanY
      // Didn't pump it enough
      tmpargument = 2
      SendMessageNear
      PlaySound
	  
  // Reset the charge counter
  tmpargument = 0
  SetContent
  
// Put the little mana ball on the
// character's hand
GetContent
tmpx = tmpargument
tmpy = 0
IfXIsMoreThanY
  tmpturn = tmpargument * 10 + 5800
  tmpdistance = SPAWNLAST
  tmpargument = 1
  SpawnAttachedSizedParticle
  
  //And spawn particles around the target
  SetTargetToWhoeverIsHolding
    tmpx = targetx
    tmpy = targety
    tmpdistance = targetz
    tmpargument = 0
    SpawnExactParticle


End
