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

//Spell stuff
IfUsed
  SetTargetToWhoeverIsHolding
  SetOwnerToTarget
  tmpargument = [HMAG]
  IfTargetHasSkillID				//Need divine spell skill

    //Aiming Cursor
    SetTargetToOwner
    GetContent
    tmpdistance = tmpargument > 8 + 4 < 6
    tmpturn = targetturn
    tmpx = targetx
    tmpy = targety
    Compass
    tmpdistance = targetz
    tmpargument = 4
    SpawnExactParticle

    GetContent
    tmpx = tmpargument
    tmpy = 768					//Don't overcharge
    IfXIsLessThanY
      tmpy = targetmanaflow			//Enough spell power?
      IfYIsMoreThanX
        tmpy = rand & 400 + targetwis			//Enough wisdom? Need about 22
        tmpx = rand & 4700 + tmpargument
        IfYIsMoreThanX
          tmpargument = 6				//Mana cost
          CostTargetMana
            GetContent				//Increase the charge
            tmpargument = tmpargument + 4		//Casting Time
            SetContent
        Else
          tmpargument = 4
          SendMessageNear
          tmpargument = 50
          SetReloadTime
    tmpargument = YELLOW			//Icon sparkles
    SparkleIcon

Else
  GetContent
  tmpx = tmpargument
  tmpy = 750
  IfXIsMoreThanY		//Enough power to activate?
    GetContent
    tmpdistance = tmpargument > 8 + 4 < 6
    tmpturn = targetturn
    tmpx = targetx
    tmpy = targety
    Compass
    tmpdistance = targetz
    tmpargument = 2
    SpawnExactParticle
    tmpargument = 100		//Set cooldown time
    SetReloadTime
    tmpargument = 3
    SendMessageNear		//Tell what happened
    tmpargument = 1
    tmpdistance = rand & 6000 + 11000
    PlaySound
  Else				
    GetContent
    tmpx = tmpargument
    tmpy = 0
    IfXIsMoreThanY		//Only if there was a charge
      tmpargument = 1
      SendMessageNear		//Tell it didn't work
      tmpargument = 2
      tmpdistance = rand & 6000 + 11000
      PlaySound
  tmpargument = 0
  SetContent			//Reset counter
  UnsparkleIcon

  //Award xp and stuff for daring to do it
  IfNameIsKnown
    DoNothing
  Else
    tmpargument = 20
    tmpdistance = EXPDARE
    GiveExperienceToTarget
    MakeNameKnown
    MakeUsageKnown

// 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
