//------------------------------------------------------------------------------
// ZZ> Death and let the player team win
IfKilled
  tmpargument = 35
  SetBumpHeight
  IfTargetIsOnHatedTeam
    tmpargument = 0
    SendMessageNear

  // Award quest experience
  tmpargument = 100
  tmpdistance = EXPQUEST
  GiveExperienceToTargetTeam

  //Mim survived
  tmpargument = [HEAL]
  SetTargetToWideBlahID
    tmpargument = 50
    GiveExperienceToTargetTeam

  //Brom survived
  tmpargument = [SOLD]
  SetTargetToWideBlahID
    tmpargument = 50
    GiveExperienceToTargetTeam


  // Finish it up
  BeatModule
  EnableExport

  // Mark this module as beaten, hidden modules may open up
  tmpargument = [BEAT]
  AddIDSZ

  // Fix the end text
  ClearEndMessage
  tmpargument = 2
  AddEndMessage
  tmpargument = 3
  AddEndMessage
  tmpargument = 4
  AddEndMessage
  tmpargument = 5
  AddEndMessage

  //Victory tune
  tmpargument = 14		//Music track
  tmpdistance = 0		//Fade in time
  PlayMusic

//------------------------------------------------------------------------------
// ZZ> Make the GrubMum do the decoy dance at the beginning of the module.
//     This lets the players know what the target of the quest is.
IfSpawned
  DisableExport
  ClearWaypoints
  tmpx = 2112
  tmpy = 6208
  AddWaypoint
//  tmpx = 2624        //This extra corner turn isn't really needed
//  tmpy = 6336
//  AddWaypoint
  tmpx = 4032
  tmpy = 6080
  AddWaypoint
  tmpx = 4032
  tmpy = 5668
  AddWaypoint

  CleanUp

//------------------------------------------------------------------------------
tmpargument = 1
IfStateIsNot
  // Teleport from the waterway to the boss room
  IfAtLastWaypoint
    IfSpawned
      DoNothing
    Else
      tmpx = 1280
      tmpy = 1280
      tmpargument = 1
      SendMessageNear
      Teleport
        ClearWaypoints
        AddWaypoint

        Sneak
        tmpargument = 1
        SetState

        ShowMap
        ShowYouAreHere

//------------------------------------------------------------------------------
// ZZ> Handle wandering around
IfTimeOut
  IfStateIs1
    // Wander around the boss room
    IfAtWaypoint
      tmpx = rand % 1332 + 508
      tmpy = rand % 1594 + 462
      ClearWaypoints
      AddWaypoint

     //Play dramatic boss music
    SetTargetToWideEnemy
      tmpargument = 6		//Music track
      tmpdistance = 0		//Fade in time
      PlayMusic

  //Ready next attack again
  CleanUp
  tmpargument = 0
  SetContent
  tmpargument = 50
  SetTime
  
//------------------------------------------------------------------------------
// Damage anyone that touches the Mum
IfBumped
  tmpargument = 0
  IfContentIs
    SetTargetToWhoeverBumped
    IfTargetIsOnHatedTeam
      tmpargument = rand & 511 + 512           //2-4 damage
      tmpdistance = DAMAGEPOKE
      DamageTarget
      tmpargument = 1
      SetContent

//------------------------------------------------------------------------------
//Let the characters know where she is...
tmpx = selfx
tmpy = selfy
tmpargument = GREEN
ShowBlipXY

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