ON INIT {
 SET £helping_buddy "HUMAN_BASE_0050"
 SET £flee_marker "FLEE_MARKER_0011"
 SET §road 0				// Used to know which path npc has chosen
 SET £type "human_guard_kingdom"
 SET £friend "kingdom"
 SET £voice "_vb"
 SET §refuse 0
 SET_GROUP ANTI_THIEF
 ACCEPT
}

ON INITEND {
 SENDEVENT -ir DURABILITY 100 "81"
 TWEAK SKIN "npc_human_chainmail_guard_head" "npc_human_chainmail_guard_head3"
 TELEPORT MARKER_0883
 SET §refuse 1
 SETEVENT CHAT OFF
 BEHAVIOR FRIENDLY
 SETTARGET MARKER_0884
 TIMERwait 0 1 GOTO CHECK_DIST
 ACCEPT
}

ON _ELOAD {
  IF (#carlo_rituals == 1) {
    TIMERwait OFF
    SET §refuse 0
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0058
    ACCEPT
  }
 ACCEPT
}

ON COLLIDE_NPC {
 IF (§refuse == 1) REFUSE
 ACCEPT
}

>>CHECK_DIST
 IF (^DIST_PLAYER > 900) ACCEPT
 TIMERwait OFF
 SPEAK -a [guard_shany_beware] SENDEVENT CUSTOM HUMAN_BASE_0094 "DISPUTE"
 ACCEPT

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0058) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol01 1 2 GOTO NEXT_STEP
    ACCEPT
  }
  IF (^TARGET == MARKER_0060) {
    BEHAVIOR NONE
    SETTARGET NONE
    IF (§road == 1) GOTO DECISION
    SET §road 1
    TIMERpatrol02 1 2 GOTO NEXT_STEP01
    ACCEPT
  }  
  IF (^TARGET == MARKER_0372) {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0061
    ACCEPT
  }
  IF (^TARGET == MARKER_0061) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol03 1 2 GOTO NEXT_STEP02 
    ACCEPT
  }
  IF (^TARGET == MARKER_0062) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol04 1 2 GOTO NEXT_STEP03
    ACCEPT
  }
 ACCEPT
}

ON AGGRESSION {
 TIMERwait OFF
 ACCEPT
}

ON CUSTOM {
  IF (^$PARAM1 == "PATROL") {
    SET §refuse 0
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0058
    SETEVENT CHAT ON
    ACCEPT
  }
 ACCEPT
}

>>DECISION
 SET §road 2
 BEHAVIOR MOVE_TO 
 SETTARGET MARKER_0372
 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_0060
  }
 ACCEPT

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

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

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

ON RELOAD {
  IF (#carlo_rituals == 1) {
    TIMERwait OFF
    SET §refuse 0
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0058
    ACCEPT
 }
 IF (§enemy == 1) ACCEPT
 IF (#PLAYER_ON_QUEST == 6) ACCEPT
 IF (§refuse == 1) ACCEPT
 TIMERpatrol01 OFF
 TIMERpatrol02 OFF
 TELEPORT -i
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0058
 ACCEPT
}