//This adds to the amount of spells the dracolich can use
IfSpawned
  JoinEvilTeam

IfDropped
  GoPoof

IfUsed
  SetTargetToNearestEnemy
  IfStateIs0
    tmpx = rand & 1           //Reduce disenchant by 50%
    tmpy = 0
    IfXIsEqualToY
      tmpargument = rand % 3 + 1      //Disallow disenchant
    Else
      tmpargument = rand & 3 + 1      //Allow disenchant
    SetState

  //Death Cloud
  IfStateIs1
    GetContent
    tmpx = tmpargument
    tmpy = 150			//3 seconds
    IfXIsMoreThanY
      tmpx = selfx
      tmpy = selfy
      GetContent
      tmpdistance = tmpargument
      tmpturn = selfturn
      Compass
      tmpargument = 1
      tmpdistance = selfz
      SpawnExactParticle
      SpawnExactParticle
      SpawnExactParticle
      SpawnExactParticle
      SpawnExactParticle		//8 clouds
      SpawnExactParticle
      SpawnExactParticle
      SpawnExactParticle

      //Sound effect
      tmpargument = 0
      PlaySound

      //Animation
      tmpargument = ACTIONMD  // Must be an A...  ZA, BA, CA, DA, etc...
      SetTargetToWhoeverIsHolding
      TargetDoAction

      //Now reset
      tmpargument = 0
      SetState
      SetContent
    Else
      tmpargument = tmpargument + 1
      SetContent

      //The charge particle
      tmpturn = tmpargument < 8 + 10000
      tmpargument = 0
      tmpdistance = SPAWNORIGIN
      SpawnAttachedSizedParticle

      //Targeting cursor
      tmpx = selfx
      tmpy = selfy
      GetContent
      tmpdistance = tmpargument * 3
      tmpturn = selfturn
      Compass
      tmpargument = 2
      tmpdistance = selfz
      SpawnExactParticle

  //Lightning bolt
  IfStateIs2
    tmpdistance = 0
    tmpargument = 0		//Cast once at first second
    IfContentIs
      tmpdistance = 1
    tmpargument = 50		//Cast once at second second
    IfContentIs
      tmpdistance = 1
    tmpargument = 100		//Cast once at third second
    IfContentIs
      tmpdistance = 1

    tmpturn = 0
    IfDistanceIsMoreThanTurn	//If tmpdistance = 1 then cast lighting
      tmpargument = 3
      tmpx = selfx
      tmpy = selfy
      tmpdistance = selfz - 128
      SpawnExactParticle

      //Animation
      tmpargument = ACTIONTA  // Must be an A...  ZA, BA, CA, DA, etc...
      CorrectActionForHand
      SetTargetToWhoeverIsHolding
      TargetDoAction

    //Increase timer
    GetContent
    tmpargument = tmpargument + 1
    SetContent

  //Ice attack
  IfStateIs3
    GetContent
    tmpx = tmpargument * 3
    tmpy = 100			//2 seconds
    IfXIsMoreThanY
      tmpargument = 50
      SetReloadTime

      //Cone of cold
      tmpargument = 6
      tmpx = selfx
      tmpy = selfy
      tmpdistance = selfz - 128
      SpawnExactParticle

      //Animation
      tmpargument = ACTIONTA  // Must be an A...  ZA, BA, CA, DA, etc...
      CorrectActionForHand
      SetTargetToWhoeverIsHolding
      TargetDoAction
    Else
      //Increase timer
      GetContent
      tmpargument = tmpargument + 1
      SetContent

      //The charge particle
      tmpturn = tmpargument < 8 + 10000
      tmpargument = 9
      tmpdistance = SPAWNORIGIN
      SpawnAttachedSizedParticle

  //Disenchant
  IfStateIs4
    tmpx = selfcontent
    tmpy = 150			//3 seconds
    IfXIsMoreThanY
      tmpargument = [DISP]
      DispelTargetEnchantID

      //Sound effect
      tmpargument = 3
      PlaySound

      tmpargument = 0
      SendMessage

      //Animation
      tmpargument = ACTIONMD  // Must be an A...  ZA, BA, CA, DA, etc...
      SetTargetToWhoeverIsHolding
      TargetDoAction

      //Now reset
      tmpargument = 0
      SetState
      SetContent
    Else
      tmpargument = tmpargument + 1
      SetContent

      //The charge particle
      tmpturn = tmpargument < 8 + 10000
      tmpargument = 0
      tmpdistance = SPAWNORIGIN
      SpawnAttachedSizedParticle

      //Targeting circle
      tmpx = targetx
      tmpy = targety
      tmpargument = 10
      tmpdistance = targetz
      SpawnExactParticle


//Holder aborted casting
Else
  tmpargument = 0
  SetState
  SetContent

End					// All done
