//SPECIAL Abyss Module stuff
IfOrdered
  tmpx = selforder
  tmpy = [UNDO]
  IfXIsEqualToY
    SetTargetToSelf
    KillTarget

//-------------------------------------------------------------------------------------
//Drain Mana Power
IfScoredAHit
  SetTargetToWhoeverWasHit
  tmpx = targetmana
  tmpy = 200
  IfXIsMoreThanY
    tmpargument = 6
    PlaySound
    tmpargument = 50*selflevel + 1024	//Increases by level
    CostTargetMana
    tmpargument = 25*selflevel + 512
    HealSelf

//-------------------------------------------------------------------------------------
//Paralysis Power
IfScoredAHit
  SetTargetToWhoeverWasHit
  tmpargument = 10*selflevel + 75		//Duration increases by level
  SetTargetReloadTime
  tmpargument = 1
  SendMessageNear

//-------------------------------------------------------------------------------------
//Death stuff
IfKilled

  //Messaging
  tmpargument = 0			    
  SendMessageNear			    		

  //Make the body
  tmpargument = 40			  
  SetBumpSize				  
  tmpargument = 45			  
  SetBumpHeight
			
  // Drop money	  		
  tmpargument = 65535			  	
  DropMoney				  

  //Death sound
  tmpargument = 2			  			  
  PlaySound				  

  //Death effect
  GoPoof
  tmpargument = 7
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpturn = rand
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle

//-------------------------------------------------------------------------------------
//Counter attack
IfAttacked				
  SetTargetToWhoeverAttacked
    IfTargetIsOnHatedTeam    	      
      tmpargument = 1			      // Enter combat mode
      SetState
    Else
      SetTargetToOldTarget
  tmpargument = rand & 1		  //Ouch sound
  PlaySound


//-------------------------------------------------------------------------------------
IfTargetKilled				// Return to follow mode
  tmpargument = 0			  //
  SetState				  //		    

//-------------------------------------------------------------------------------------
// This is done every so often
IfTimeOut		
  SetTargetToWideEnemy		  // Look for enemies
    tmpargument = 1			  // Enter combat mode
    SetState				    

  // Play a random grunt?
  tmpx = rand & 255
  tmpy = 15
  IfXIsLessThanY			  
    tmpargument = rand & 1 + 3
    PlaySound

  //GUARD
  IfStateIs0
    tmpx = rand & 1023 - 512 + selfspawnx
    tmpy = rand & 1023 - 512 + selfspawny
    ClearWaypoints			  
    AddWaypoint

  //COMBAT
  IfStateIs1  
    tmpx = targetdistance
    tmpy = 150
    IfXIsLessThanY			//Close enough to attack?
      IfFacingTarget			//Facing the enemy?
        IfTargetIsOnHatedTeam		//Make sure its a enemy
          tmpargument = ACTIONUA
          DoAction			//Attack unarmed
    Else
      tmpx = targetx
      tmpy = targety
      tmpturn = targetturnto
      tmpdistance = 650
      Compass
      ClearWaypoints			  
      AddWaypoint

    //Enemy too far away?
    tmpx = targetdistance
    tmpy = 2000				    
    IfXIsMoreThanY			    
      tmpargument = 0			    //Yes, return to follow leader mode
      SetState				     
      tmpx = leaderx
      tmpy = leadery
      ClearWaypoints			  
      AddWaypoint
  tmpargument = rand & 15 + 10		  //Set timer
  SetTime				  
				  
//-------------------------------------------------------------------------------------
//Move out of friendlies and target enemy bumpers
IfBumped				
  SetTargetToWhoeverBumped		  
  IfTargetIsOnSameTeam
    tmpx = rand & 255 + targetx - 128	    
    tmpy = rand & 255 + targety - 128	    
    ClearWaypoints			    
    AddWaypoint				    
    SetTargetToOldTarget
  Else
    tmpargument = 1
    SetState

End					// Finished with this character
