IfBumped
  SetTargetToWhoeverBumped
  IfTargetIsOnHatedTeam
    DoNothing
  Else
    tmpargument = [KEYI]
    IfTargetHasItemID			//brought back the idol
      CostTargetItemID
      EnableExport
      BeatModule
      tmpargument = [BEAT]
      AddIDSZ
      tmpargument = 125
      tmpdistance = EXPQUEST
      GiveExperienceToTargetTeam
      tmpargument = 3
      SetState
      tmpargument = 1
      SendMessageNear
      
      //End text
      ClearEndMessage
      tmpargument = 2
      AddEndMessage
      tmpargument = 3
      AddEndMessage
      tmpargument = 4
      AddEndMessage
      tmpargument = 5
      AddEndMessage
      tmpargument = 6
      AddEndMessage
      
    IfStateIs0
      tmpargument = 2
      PlaySound
      tmpargument = 0
      SendMessageNear
      tmpargument = 1
      SetState
      tmpargument = 100
      SetTime
    IfStateIs2
      tmpargument = 3
      PlaySound
      tmpargument = 1
      SendMessageNear
      tmpargument = 3
      SetState
      tmpargument = 100
      SetTime

//Return to greeting mode
IfTimeOut
  IfStateIs1
    tmpargument = 0
    SetState
  IfStateIs3
    tmpargument = 2
    SetState

// If we are attacked, set our team to something that can attack!
// Choose either "Good" or "Evil" depending on the attacker
IfAttacked
  SetTargetToWhoeverAttacked
  IfTargetIsOnHatedTeam
    DoNothing
  Else
    JoinEvilTeam
      IfTargetIsOnHatedTeam
        DoNothing
      Else
        JoinGoodTeam    

IfTimeOut
  tmpargument = 10
  SetTime
  SetTargetToWideEnemy
    tmpx = targetx
    tmpy = targety
    tmpdistance = 1500
    tmpturn = targetturnto
    Compass
    ClearWaypoints
    AddWaypoint
    IfFacingTarget
      tmpx = targetdistance
      tmpy = 200
      IfXIsLessThanY
        tmpargument = LATCHRIGHT
        PressLatchButton

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