ON INIT {
 SET £helping_buddy "HUMAN_BASE_0037"
 SET £flee_marker "FLEE_MARKER_0010"
 SET §road 0				// Used to know which path the npc has chosen
 SET £type "human_guard_kingdom"
 SET £friend "kingdom"
 SET £voice "_vc"
 SET_GROUP ANTI_THIEF
 SET_SPEAK_PITCH 0.9
 ACCEPT
} 

ON INITEND {
 SENDEVENT -ir DURABILITY 100 "86"
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0056
 ACCEPT
}

ON CUSTOM {
  IF (^$PARAM1 == "NOMOVE") {
    TELEPORT MARKER_0054
    BEHAVIOR FRIENDLY
    SETTARGET PLAYER
    ACCEPT
  }
  IF (^$PARAM1 == "MOVE") {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0056
    ACCEPT
  }
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0056) {
    BEHAVIOR NONE
    SETTARGET NONE
>>DECISION
    RANDOM 50 {
      IF (§road == 1) GOTO DECISION
      SET §road 1
      TIMERpatrol01 1 2 GOTO NEXT_STEP 
      ACCEPT
    }  
    RANDOM 50 {
      IF (§road == 2) GOTO DECISION
      SET §road 2
      BEHAVIOR MOVE_TO 
      SETTARGET MARKER_0061
      ACCEPT
    }  
   GOTO DECISION
   ACCEPT
  }
  IF (^TARGET == MARKER_0061) {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0054
    ACCEPT
  }
  IF (^TARGET == MARKER_0936) {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0054
    ACCEPT
  }
  IF (^TARGET == MARKER_0054) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol02 1 2 GOTO NEXT_STEP01
    ACCEPT
  }
  IF (^TARGET == MARKER_0925) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol03 1 2 GOTO NEXT_STEP02
    ACCEPT
  }
 ACCEPT
}

ON PLAYER_IN_SHOP {
 IF (§player_in_sight == 0) ACCEPT
 SPEAK -a ~£thief~ NOP
 SENDEVENT ATTACK_PLAYER SELF ""
 ACCEPT
}

>>NEXT_STEP
  IF (§main_behavior_stacked != 0) {
    TIMERpatrol01 1 2 GOTO NEXT_STEP
  }
  ELSE {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0925
  }
 ACCEPT

>>NEXT_STEP01
  IF (§main_behavior_stacked != 0) {
    TIMERpatrol02 1 2 GOTO NEXT_STEP01
  }
  ELSE {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0936
  }
 ACCEPT

>>NEXT_STEP02
  IF (§main_behavior_stacked != 0) {
    TIMERpatrol03 1 2 GOTO NEXT_STEP02
  }
  ELSE {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0056
  }
 ACCEPT

ON RELOAD {
 IF (§enemy == 1) ACCEPT
 IF (#PLAYER_ON_QUEST == 6) ACCEPT 
 TIMERpatrol01 OFF
 TIMERpatrol02 OFF
 TIMERpatrol03 OFF
 TELEPORT -i
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0056
 ACCEPT
}