//-----------------------------------------------------------------------------
// Alchemy special abillity
SetTargetToSelf
IfTargetIsAlive
  SetTargetToTargetLeftHand	//Check left hand first
    tmpargument = [POTI]
    IfTargetHasID
      IdentifyTarget		//Identify potions
      SetTargetToSelf
    tmpargument = [FLAS]
    IfTargetHasID
      IdentifyTarget		//And flasks
  SetTargetToTargetRightHand	//Repeat with other hand
    tmpargument = [POTI]
    IfTargetHasID
      IdentifyTarget		//Identify potions
    tmpargument = [FLAS]
    IfTargetHasID
      IdentifyTarget		//And flasks

//-----------------------------------------------------------------------------
// ZZ> Gong sound
IfCleanedUp
  tmpargument = 2
  tmpdistance = 8000
  PlayFullSound


//------------------------------------------------------------------------------
// ZZ> Scream and shout
IfUsed
  tmpdistance = rand & 2047 + 15000
  tmpargument = 10
  PlaySound


//------------------------------------------------------------------------------
// ZZ> Handle being bored by cheering or sneezing
IfBored
  tmpargument = 7
  SendMessageNear
  tmpargument = 11
  tmpdistance = rand & 2047 + 15000
  PlaySound
  tmpargument = ACTIONMC
  DoAction



//------------------------------------------------------------------------------
// ZZ> Handle death by sending a message and other stuff
IfKilled
  // Sound
  IfTargetIsOnHatedTeam
    tmpargument = 4
  Else
    tmpargument = 3
  tmpdistance = rand & 2047 + 15000
  PlaySound


  // Message
  tmpargument = 3
  IfArmorIs
    tmpargument = MESSAGECOSTUME
  Else
    tmpargument = MESSAGEDEATH
  IfTargetIsOnSameTeam
    tmpargument = MESSAGEFRAG
    IfTargetIsSelf
      tmpargument = MESSAGEACCIDENT
  SendMessage


  // Drop goodies
  tmpargument = selflevel*selflevel*100		//The money loss formula
  DropMoney
  DropKeys


  // Make the character body
  tmpargument = 45
  SetBumpHeight

//------------------------------------------------------------------------------
// ZZ> For helper AIs
IfLeaderKilled
  BecomeLeader


//------------------------------------------------------------------------------
// ZZ> Handle being attacked by blocking or countering or running away
IfAttacked
  SetTargetToWhoeverAttacked
  IfTargetIsOnSameTeam
    tmpargument = 8
    tmpdistance = rand & 2047 + 15000
    PlaySound
    tmpargument = MESSAGEOUCH
    SendMessageNear
  Else
    tmpargument = rand & 1 + 5
    tmpdistance = rand & 2047 + 15000
    PlaySound


//------------------------------------------------------------------------------
// ZZ> Handle being healed by spitting out a message and stopping retreat
IfHealed
  tmpargument = 6
  SendMessageNear
  tmpargument = 9
  tmpdistance = rand & 2047 + 15000
  PlaySound


//------------------------------------------------------------------------------
// ZZ> Handle not being able to carry something
IfTooMuchBaggage
  tmpargument = 8
  SendMessageNear
  tmpargument = 7
  tmpdistance = rand & 2047 + 15000
  PlaySound

//------------------------------------------------------------------------------
//Invoke special power if enough xp gained
SetTargetToSelf
tmpx = targetexp
tmpy = 9998
IfXIsMoreThanY
  UndoEnchant		//Hinder looping of same enchant
  SetOwnerToTarget
  EnchantTarget		//Give the special bonus
  tmpargument = 2	//Spawn some fancy sparklies
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  SpawnExactParticle
Else
  UndoEnchant		//Remove if needed xp is lost
  
//------------------------------------------------------------------------------
End
//------------------------------------------------------------------------------
