//Different monster types determined by skin:
//0: Normal bat		(No special abillities)
//1: Vampyric bat	(Steals life)
//2: Undead bat		(Very tough, weak vs. holy)

//------------------------------------------------------------------------------
//Squeak if damaged
IfAttacked
  tmpargument = rand & 1 + 2		//Random ouch sound (sound 2 or 3)
  tmpdistance = rand % 3400 + 9000
  PlaySound
  GetDamageType
  tmpx = tmpargument
  tmpy = DAMAGEHOLY
  IfXIsEqualToY			//Holy damage is instant kill
    SetTargetToSelf
    KillTarget
    SetTargetToWhoeverAttacked
    tmpargument = 10		//Give some bonus xp
    tmpdistance = EXPREVENGE
    GiveExperienceToTarget
    tmpargument = 1		//Banishment sound
    tmpdistance = rand % 4600 + 11000
    PlaySound

//------------------------------------------------------------------------------
//Tell others its healed
IfHealed
  tmpargument = 2
  SendMessageNear

//------------------------------------------------------------------------------
//Handle death stuff
IfKilled
  SetTargetToWhoeverAttacked
  //Handle Messaging
  IfTargetIsOnSameTeam
    tmpargument = 1		//Killed self
  Else
    tmpargument = 0
    IfArmorIs
      tmpargument = 0		//Normal bat
    Else
      tmpargument = 1
      IfArmorIs
        tmpargument = 3		//Vampyric bat
      Else
        tmpargument = 4		//Killed normally
  SendMessageNear

  tmpargument = 1		//Bonus xp
  IfArmorIs
    tmpargument = 10
    GiveExperienceToTargetTeam

  tmpargument = 2		//Bonus xp
  IfArmorIs
    tmpargument = 25
    GiveExperienceToTargetTeam

  //Unbumpable body
  tmpargument = 0
  SetBumpHeight
  SetBumpSize

  //Death sound
  tmpargument = 0
  tmpdistance = rand % 3800 + 11000
  PlaySound

//------------------------------------------------------------------------------
//What to do if bumped
IfBumped
  SetTargetToWhoeverBumped
  IfTargetIsOnHatedTeam
    tmpargument = rand % 75 + 74
    SetTime
    tmpx = rand % 1500 + targetx - 750
    tmpy = rand % 1500 + targety - 750
    ClearWaypoints
    AddWaypoint

    //Bite the enemy				//Must look at him
    IfTargetIsAlive				//Cant attack dead ones
      tmpargument = rand & 255 + 348		//1.50-2.50 damage
      tmpdistance = DAMAGEPOKE
      DamageTarget
      tmpargument = 1
      IfArmorIs
        tmpargument = rand & 127 + 64		//Heal 0.25 - 0.60 life
        SetTargetToSelf
        HealTarget
        SetTargetToOldTarget

  //Move out of way of friends
  IfTargetIsOnSameTeam
    tmpx = rand & 511 - 256 + targetx
    tmpy = rand & 511 - 256 + targety
    ClearWaypoints
    AddWaypoint
    SetTargetToOldTarget
    tmpargument = rand % 20 + 20
    SetTime

//------------------------------------------------------------------------------
//Leader stuff
IfLeaderKilled
  BecomeLeader
IfSpawned
  BecomeLeader		//Always have at least 1 leader

//------------------------------------------------------------------------------
//What to do each round
IfTimeOut
  tmpargument = rand & 15 + 40
  SetTime
  SetTargetToWideEnemy				//Locate enemy
    tmpx = targetx
    tmpy = targety
    tmpturn = rand & 4095 - 2048 + targetturnto
    tmpdistance = 700
    Compass
  Else						//No enemies, flock around leader
    tmpx = rand % 1500 + selfspawnx - 750
    tmpy = rand % 1500 + selfspawny - 750
  tmpargument = 100				//Bats are fast
  SetSpeedPercent
  ClearWaypoints
  AddWaypoint

  //Random growl sound
  tmpx = rand % 900
  tmpy = 3
  IfXIsLessThanY
    tmpargument = 4
    tmpdistance = rand % 3000 + 14000
    PlaySound

//------------------------------------------------------------------------------
End					// Finished with this character
//------------------------------------------------------------------------------