// Set up general stuff
IfSpawned
  tmpargument = ACTIONJB
  DoAction
  KeepAction
  MakeCrushValid
  MakeAmmoKnown

// Make it poof
IfCrushed
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 0
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  GoPoof
  tmpargument = 1
  SendMessageNear

// Make it lie on the floor
IfDropped
  KeepAction

// Play a clink or clang
IfHitGround
  tmpargument = 0
  PlaySound

// Alert others to draw
IfTakenOut
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 2
    SendMessageNear

// Tell them what they've won...
IfGrabbed
  SetTargetToWhoeverIsHolding
  IfTargetIsAPlayer
    tmpargument = 0
    SendMessageNear

// Give the user a bonus, but it's addictive...
IfUsed
  SetTargetToWhoeverIsHolding
  tmpargument = 40
  SetReloadTime
  MakeSimilarNamesKnown
  IfUsageIsKnown
    IfTargetIsHurt
      tmpargument = 1		//Make them drink it
      SetState
      tmpargument = 3
    Else
      tmpargument = 6
    SendMessageNear
  Else			//They don't know what it was
    MakeUsageKnown
    tmpargument = 4
    IfTargetIsAPlayer
      tmpargument = 5
    SendMessageNear
    tmpargument = 40
    tmpdistance = EXPDARE
    GiveExperienceToTarget
    tmpargument = 1		//Make them drink it
    SetState

  //This proceeds if the player drank the potion
  IfStateIs1
  
    //Normal potion
    tmpargument = 0
    IfArmorIs
      // Decrease max life a little
      tmpargument = -16		      
      GiveLifeToTarget

      // Increase current life
      tmpargument = rand % 2047 + 2048	//Amount of life healed
      HealTarget
      
      //Do flashy effects      
      tmpargument = 1
      PlaySound      
    
    //Super potion
    tmpargument = 1
    IfArmorIs

      // Heal all damage
      tmpargument = targetmaxlife	//Amount of life healed
      HealTarget

      //Do flashy effects      
      tmpargument = 2
      PlaySound
      
    tmpargument = ACTIONMC		//Drink animation
    TargetDoAction
    tmpdistance = SPAWNORIGIN
    tmpargument = 1
    SpawnAttachedHolderParticle
  Else				//This makes them drop it if not set to use
    tmpx = selfx	//Where to spawn the object
    tmpy = selfy
    tmpturn = selfturn
    tmpdistance = 0	//Velocity speed of the spawned object
    SpawnCharacter	//Spawn a copy of the flask
      tmpargument = 1
      SetChildAmmo
      IfNameIsKnown
        SetChildState     //Remember that it is identified already

  //Use one "charge"
  CostAmmo
  IfAmmoOut
    GoPoof

  tmpargument = 0
  SetState				//Reset for next use

//Allow to become a super potion
tmpargument = 0
IfArmorIs
  IfOrdered
    tmpx = selforder
    tmpy = [ENCH]
    IfXIsEqualToY
      tmpargument = 1
      ChangeArmor
      tmpargument = RED
      SparkleIcon
      
//This make super potions sparkle
Else
  tmpx = rand & 2
  tmpy = 0
  IfXIsEqualToY
    tmpargument = 2
    tmpx = rand % 50 - 25
    tmpy = rand % 50 - 25
    tmpdistance = rand & 31
    SpawnParticle
  
// Finish up
End
