//Make it throw or used in melee
IfUsed
  tmpargument = selfcontent +1
  SetContent

  //Tell its ready to be thrown
  tmpx = selfcontent
  tmpy = 60             //50 is 1 second
  IfXIsMoreThanY
    tmpargument = YELLOW
    SparkleIcon
    
Else
  tmpx = selfcontent
  tmpy = 1
  IfXIsMoreThanY
    tmpy = 60               //The time needed before it's thrown
    IfXIsMoreThanY
      SetTargetToWhoeverIsHolding
        tmpargument = ACTIONTA  // Must be an A...  ZA, BA, CA, DA, etc...
        CorrectActionForHand    // ZA or ZB if in left hand, ZC or ZD if in right
        TargetDoAction
      DetachFromHolder
        
      //Make it fly
      tmpargument = targetstr > 7
      tmpdistance = 50 + tmpargument          //+2 range pr. strength     
      //SetTargetToNearestEnemy
      //IfFacingTarget
      //  tmpturn = targetturnto
      //Else
      //  SetTargetToWhoeverIsHolding
      //  tmpturn = targetturn
      tmpdistance = -1600
      tmpturn = targetturn
      tmpx = 0
      tmpy = 0
      Compass
      SetTargetToSelf
      AccelerateTarget

      //Throwing particle
      tmpargument = 2
      tmpdistance = SPAWNLAST
      SpawnAttachedParticle

      //Return
      tmpargument = 300
      SetSpeedPercent
      tmpargument = 40
      SetFlyHeight
    Else
      tmpargument = ACTIONTA  // Must be an A...  ZA, BA, CA, DA, etc...
      CorrectActionForHand    // ZA or ZB if in left hand, ZC or ZD if in right
      SetTargetToWhoeverIsHolding
      TargetDoAction
  tmpargument = 0
  SetContent
  UnsparkleIcon

IfHitGround				  // Make a sound
  tmpargument = 1
  PlaySound
  DisaffirmCharacter			  // Stop thrown attack

//This function makes an item fall to the floor when spawned
IfSpawned
  tmpargument = ACTIONJB
  DoAction
  KeepAction
  MakeCrushValid

//Crushing stuff
IfCrushed
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 1
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  GoPoof
  tmpargument = 1
  SendMessageNear

IfDropped				  // Make it lie on floor
  KeepAction
  tmpx = selfx
  tmpy = selfy
  ClearWaypoints
  AddWaypoint

IfTakenOut				  // Make a sound
  tmpargument = 2
  PlaySound
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 2
    SendMessageNear

IfGrabbed				  // Tell them what they've won...
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 0
    SendMessageNear
  tmpargument = 0
  SetFlyHeight
  SetSpeedPercent
End					  // All done
