//Setup
IfSpawned
  tmpargument = 6
  SetContent

//Found the sister?
IfOrdered
  tmpx = selforder
  tmpy = [FORT]
  IfXIsEqualToY
    tmpargument = 4     //Do nothing anymore
    SetState

//Handle talking
IfBumped
  SetTargetToWhoeverBumped
  IfTargetIsAPlayer
    IfTargetIsOnSameTeam
      tmpargument = [FORT]
      tmpdistance = 0          //Reset the quest level first
      IfTargetHasQuest
        DoNothing
      tmpturn = 1
      IfDistanceIsMoreThanTurn  //They have done the quest
        IfStateIs0
          tmpargument = 11
          IfContentIs
            DoNothing           //Play the "another time" voice
          Else
            tmpargument = 11
            SetContent
            tmpargument = 6     //Say hello there
          PlayFullSound
          SendMessage
          tmpargument = 2
          SetState                    //Wait before talking

      Else
        IfStateIs0                    //Standing at spawn point
          GetContent
          PlayFullSound
          SendMessage
          tmpargument = 2
          SetState                    //Wait before talking
          tmpargument = 150
          SetTime
          GetContent
          tmpargument = tmpargument + 1
          SetContent

          //All done talking! Follow player
          tmpx = 11
          tmpy = tmpargument
          IfXIsEqualToY
            SetOwnerToTarget
            tmpargument = 3
            SetState              //Follow
            tmpargument = [BSPK]            //This tells meena we are looking for her
            IssueOrder
            tmpargument = [FORT]        //Add the quest to the log
            tmpdistance = 0
            AddQuestAllPlayers

//become bad
IfCalledForHelp
  JoinEvilTeam
  tmpargument = 1               //Combat
  SetState

//Ouch
IfAttacked
  SetTargetToWhoeverAttacked
  IfTargetIsOnSameTeam
    tmpargument = 3
  Else
    tmpargument = 4
  PlaySound

//Yah!
IfUsed
  tmpargument = 5
  PlaySound

//Death stuff
IfKilled
  tmpargument = selfmoney
  DropMoney

  //Sound
  tmpargument = 1
  PlaySound

  //Message
  IfTargetIsSelf
    tmpargument = 0
  Else
    tmpargument = 1
  SendMessage

//Use shield and attack
IfTargetIsOnHatedTeam
  IfFacingTarget
    tmpx = targetdistance
    tmpy = 130
    IfXIsLessThanY
      IfHoldingMeleeWeapon
        PressLatchButton
      IfTargetIsAttacking
        tmpargument = [SHIE]
        IfHoldingItemID
          PressLatchButton


//Main AI loop
IfTimeOut
  tmpargument = rand & 31 + 15
  SetTime

  tmpx = selflife
  tmpy = 1500           //Less than 6 hp
  IfXIsLessThanY
    tmpargument = 1
  Else
    tmpargument = 0
  ChangeArmor

  //Standing at spawn
  IfStateIs0
    SetTurnModeToVelocity
    SetTargetToWideEnemy
      tmpargument = 1
      SetState
    tmpx = selfspawnx
    tmpy = selfspawny
    ClearWaypoints
    AddWaypoint

  //Combat
  IfStateIs1
    SetTargetToWideEnemy
      tmpx = targetx
      tmpy = targety
      tmpdistance = 1500
      tmpturn = targetturnto
      ClearWaypoints
      AddWaypoint
    Else
      tmpargument = 0
      SetState                  //No enemies around anymore

  //Resume talking
  IfStateIs2
    tmpargument = 0
    SetState

  //Follow player
  IfStateIs3
    SetTargetToOwner
    tmpx = targetdistance
    tmpy = 250
    IfXIsLessThanY
      tmpargument = 65
      SetTime
      tmpx = rand & 1023 + targetx - 512
      tmpy = rand & 1023 + targety - 512
    Else
      tmpx = ownerx
      tmpy = ownery
      tmpturn = targetturnto
      tmpdistance = 500
      Compass
    ClearWaypoints
    AddWaypoint

End
