//Spawned in hands/inventory of the owner
IfSpawned
  IfHeld
    SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      SetOwnerToTarget
      MakeNameKnown
      tmpargument = 1
      SetState
      MakeAmmoKnown
      
//Someone took us
IfGrabbed
  SetTargetToWhoeverIsHolding
  IfNameIsKnown
    SetOldTarget
    SetTargetToOwner
    IfTargetIsOldTarget  //Say hello
      tmpargument = 10
      SendMessageNear
      IfSpawned             //Dont when just spawned
        DoNothing
      Else
        tmpargument = 2
        PlaySound             //Giggle
    Else
      DetachFromHolder      //Can't get me!
      tmpargument = 9
      SendMessageNear
  Else                      //We got a new owner!   
    SetOwnerToTarget
    tmpargument = 12
    SendMessageNear
    MakeNameKnown
    tmpargument = 1
    SetState
    MakeAmmoKnown
    
//Let the player know what this is
IfTakenOut
  SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      tmpargument = 11
      SendMessageNear
      
//bye bye :(
IfKilled
  GoPoof
  tmpargument = 0
  SendMessage
  tmpargument = 1
  PlayFullSound
    
//Sparkle friendlies
IfUsed
  SetTargetToWhoeverIsHolding
    tmpargument = 50
    SetTargetReloadTime
  
    //Enchant them
    IfTargetIsAPlayer
      tmpargument = 0
      IfContentIs
        EnchantTarget
        tmpargument = 1
        SetContent
        tmpargument = 14
        SendMessageNear
        tmpargument = YELLOW
        SparkleIcon
        tmpargument = 0
        PlaySound
        CostAmmo
      Else
        UndoEnchant
        tmpargument = 0
        SetContent

  //Show stats
  IfTargetIsAPlayer
    // Print =NAME=
    SetTargetToSelf
    tmpargument = 1
    SendMessageNear      

    // Level
    tmpx = targetlevel+1
    tmpargument = 2
    SendMessageNear

    // Physical Stats
    tmpx = targetlife > 9
    tmpy = 2
    IfXIsMoreThanY
      tmpx = 3
    tmpargument = 4 + tmpx
    tmpx = selfstr > 8
    tmpy = selfdex > 8
    SendMessageNear

    // Mental Stats
    tmpdistance = targetexp
    tmpx = targetint > 8
    tmpy = targetwis > 8
    tmpargument = 8
    SendMessageNear
  
//Dont sparkle
tmpargument = 0
IfContentIs
  UnsparkleIcon
  
//Remove sparklies
IfDropped
  tmpargument = 1
  IfContentIs
    UndoEnchant
    tmpargument = 0
    SetContent
IfPutAway
  tmpargument = 1
  IfContentIs
    UndoEnchant
    tmpargument = 0
    SetContent
    
//Begin to glow
IfTakenOut
  ReaffirmCharacter

      
// ZZ> This controls the faerie AI
IfTimeOut
  tmpargument = rand & 15 + 25
  SetTime
  
  //Handle charging
  tmpargument = 1
  IfContentIs
    CostAmmo
  Else
    IncreaseAmmo
  
  //Out of charge
  tmpx = selfammo
  tmpy = 0
  IfXIsEqualToY
    UndoEnchant
    tmpargument = 0
    SetContent
    
  IfStateIs0
    // Circle around start location
    tmpx = rand & 511 + selfx - 256
    tmpy = rand & 511 + selfy - 255
    ClearWaypoints
    AddWaypoint
  Else
    tmpx = ownerdistance
    tmpy = 300
    IfXIsMoreThanY
      // Catch up fast
      tmpx = ownerx
      tmpy = ownery
      tmpturn = ownerturnto
      tmpdistance = 500
      Compass
    Else
      // Circle around the player
      tmpx = ownerx
      tmpy = ownery
      tmpturn = xyturnto + 16384
      tmpdistance = 100
      Compass
    ClearWaypoints
    AddWaypoint
      
// All done
End
