// Sleeping Castle Guard
ON INIT {
 INVENTORY ADDMULTI "JEWELRY\\GOLD_COIN\\GOLD_COIN" 7
 SET £type "human_guard_kingdom"
 SET £friend "kingdom"
 SET £KEY_CARRIED "portcullis"
 SET £voice "_vc"
 SET_SPEAK_PITCH 0.9
 ACCEPT
}

ON INITEND {
 SENDEVENT -ir DURABILITY 100 "92"
 TELEPORT MARKER_0076
 PHYSICAL OFF
 COLLISION OFF
 BEHAVIOR NONE
 SETTARGET NONE
 SET §sleeping 1
 SET §reflection_mode 0
 SETEVENT CHAT OFF
 SET §frozen 1
 FORCE_ANGLE 180
 PLAYANIM -l ACTION3
 TWEAK SKIN "npc_human_chainmail_body" "npc_human_unarmormail_guard_body"
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == NONE) ACCEPT
  IF (^TARGET == MARKER_0076) {
    BEHAVIOR NONE
    SETTARGET NONE
    SET §sleeping 1
    SET §reflection_mode 0
    SETEVENT CHAT OFF
    SET §frozen 1
    PHYSICAL OFF
    COLLISION OFF
    FORCE_ANGLE 180
    PLAYANIM -e ACTION2 PLAYANIM -l ACTION3
    ACCEPT
  }
  IF (^TARGET == MARKER_0107) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol 1 2 GOTO NEXT_STEP
    ACCEPT
  }
  IF (^TARGET == MARKER_0339) {
    BEHAVIOR NONE
    SETTARGET NONE
    TIMERpatrol 1 2 GOTO NEXT_STEP01
    ACCEPT
  }
 ACCEPT
}

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

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

ON CINEMATIC {
  IF (§status == 5) {
    SET_PLAYER_CONTROLS OFF
    WORLDFADE OUT 1000 0 0 0
    TIMERgo 1 1 GOTO LA_SUITE
    ACCEPT
  }
 ACCEPT
}  

>>LA_SUITE
 CINEMASCOPE ON
 PLAYER_INTERFACE HIDE
 TELEPORT -p MARKER_0914
 PLAYERLOOKAT HUMAN_BASE_0043
 WORLDFADE IN 1200
 TIMERnow 1 1 SPEAK [guard_3_wake_up] SENDEVENT CUSTOM HUMAN_BASE_0039 "WAKE_UP"
 SET §status 6
 ACCEPT

ON CHANGESTATUS {
  IF (^$PARAM1 == "3") {
    IF (§enemy == 1) ACCEPT
    SET §up 1
    SET §status 3
    SET §frozen 0
    PLAYANIM NONE
    TELEPORT MARKER_0076
    SET §sleeping 1
    SET §reflection_mode 0
    SETEVENT CHAT OFF
    SET §frozen 1
    FORCE_ANGLE 180
    PLAYANIM -e ACTION2 PLAYANIM -l ACTION3
    ACCEPT
  }
  IF (^$PARAM1 == "5") {
    IF (§enemy == 1) ACCEPT
    SET §up 1
    PLAYANIM NONE
    SET §frozen 0
    SET §sleeping 0
    PHYSICAL ON
    COLLISION ON
    TELEPORT MARKER_0853    
    FORCE_ANGLE 270
    SET §status 5
    BEHAVIOR NONE
    SETTARGET NONE
    ACCEPT
  }
 ACCEPT
}

ON CUSTOM {
  IF (§enemy == 1) ACCEPT
  IF (^$PARAM1 == "TALK") {
    SPEAK [guard_sleep_4_goodnight] SENDEVENT CUSTOM HUMAN_BASE_0036 "TALK"
    ACCEPT
  }
  IF (^$PARAM1 == "WAKE_UP") {
    SPEAK [guard_3_calmdown] SENDEVENT CUSTOM HUMAN_BASE_0038 "WAKE_UP3"
    ACCEPT
  }
  IF (^$PARAM1 == "PATROL") {
    SETEVENT CHAT ON
    BEHAVIOR MOVE_TO
    SETTARGET -a MARKER_0107
    ACCEPT
  }
 ACCEPT
}