//------------------------------------------------------------------------------
//Make wings stop flapping
IfOrdered
  tmpx = selforder
  tmpy = [DEAD]
  IfXIsEqualToY
    tmpargument = ACTIONDA
    DoActionOverride
    KeepAction
    SetTargetToWhoeverIsHolding
    tmpargument = 0
    tmpx = targetx
    tmpy = targety
    tmpdistance = targetz
    SpawnExactParticle
    PoofTarget
    GoPoof
    SendMessageNear
    tmpargument = [UNDO]
    IssueOrder

  tmpy = [WAND]
  IfXIsEqualToY			//Master is wandering
    tmpargument = 0
    SetState

  tmpy = [COMB]
  IfXIsEqualToY			//Master is in combat
    tmpargument = 1
    SetState

//Summoning AI
IfTimeOut			//Every so often
  tmpargument = 150
  SetTime
  IfStateIs1			//Only if leader is in combat
    tmpx = selfmorale
    tmpy = 8
    IfXIsLessThanY		//Max 6 monsters at the time -2 for each of the wings
      tmpx = rand & 100
      GetContent		//More monsters reduces chance for summoning even more
      tmpy = 16 - selfmorale *2 //Reduce with 2% for each monster summoned
      IfXIsLessThanY		//14% base chance if no monsters are summoned
        SetTargetToNearestEnemy
        tmpx = rand & 255 + targetx - 128
        tmpy = rand & 255 + targety - 128
        tmpdistance = rand & 100 + selfz + 25
        tmpturn = rand
        tmpargument = rand % 3	//Randomize monster type
        SetState
        IfStateIs0
          tmpargument = 45	//Eyeball
        IfStateIs1
          tmpargument = 62	//Demon
        IfStateIs2
          tmpargument = 98	//Ghuul
        SpawnExactCharacterXYZ
          tmpargument = 6	//Spell effect
          SpawnExactParticle
          tmpargument = 896	//Costs 3.5 mana points
          CostTargetMana
          tmpargument = 1
          SendMessageNear
        tmpargument = 1		//Return to combat state
        SetState

//------------------------------------------------------------------------------
End
//------------------------------------------------------------------------------
