ON INIT {
 SET §refuse 0
 INVENTORY ADDMULTI "JEWELRY\\GOLD_COIN\\GOLD_COIN" 10
 SET £type "human_guard_kingdom"
 SET £friend "kingdom"
 SET £KEY_CARRIED "portcullis"
 SET £voice "_vb"
 SET_SPEAK_PITCH 0.9
 SET §withking 0		// Used to enable speaking while in throne room.
 SET §torchoff 0		// Used to know if torch is turned off
 ACCEPT
}

ON INITEND {
 TWEAK SKIN "npc_human_chainmail_body" "npc_human_armoredmail_guard_body"
 TWEAK SKIN "npc_human_chainmail_hero_head" "npc_human_chainmail_guard_head2"
 BEHAVIOR FRIENDLY
 SETTARGET LIGHT_DOOR_0117
 SET £initmarker "MARKER_0313"
 SENDEVENT -ir DURABILITY 100 "90"
 ACCEPT
}

ON RELOAD {
  IF (§withking == 1) {
    TELEPORT MARKER_0313
    GOTO GUARDFIRST
    ACCEPT
  }
 ACCEPT
}

ON CHANGESTATUS {
  IF (^$PARAM1 == "1") {
    SET §refuse 1
    TELEPORT MARKER_0093
    SET §withking 1
    SETEVENT CHAT OFF
    BEHAVIOR FRIENDLY
    SETTARGET HUMAN_BASE_0082 //king
    ACCEPT
  }
  IF (^$PARAM1 == "4") {
    SET §reflection_mode 0
    BEHAVIOR FRIENDLY
    SETTARGET HUMAN_BASE_0082 //king
    ACCEPT
  }
  IF (^$PARAM1 == "4end") {
    SET §reflection_mode 1
    BEHAVIOR FRIENDLY
    SETTARGET LIGHT_DOOR_0117
    ACCEPT
  }
 ACCEPT
}

ON TALK {
  IF (^$PARAM1 == "status1_1") {
    SPEAK [guard_king_warmeet1] GOTO LEAVE 
    ACCEPT
  }
 ACCEPT
}

>>LEAVE
 SETEVENT CHAT ON
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0313
 ACCEPT

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0313) { // after status 1 mini cinematic
>>GUARDFIRST
    SET §withking 0
    SET §refuse 0
    FORCE_ANGLE 180
    BEHAVIOR FRIENDLY
    SETTARGET LIGHT_DOOR_0117
    IF (§torchoff == 1) {
      BEHAVIOR FRIENDLY
      SETTARGET MARKER_0735
      SPELLCAST -SMF 1 IGNIT MARKER_0735 
      TIMERguard 1 1 GOTO GUARD
      ACCEPT
    }
   ACCEPT
  }
 ACCEPT
}

>>GUARD
 FORCE_ANGLE 0
 BEHAVIOR FRIENDLY
 SETTARGET LIGHT_DOOR_0117
 ACCEPT

ON CHAT {
 IF (§withking == 1) ACCEPT
 ACCEPT
}

ON CUSTOM {
  IF (^$PARAM1 == "LIGHT_FIRE") {
    SET §torchoff 1
    IF (§withking == 1) ACCEPT
    TIMERtorch 1 1 GOTO LIGHT_FIRE
    ACCEPT
  }
 ACCEPT
}

>>LIGHT_FIRE
 IF (§enemy == 1) ACCEPT
 BEHAVIOR FRIENDLY
 SETTARGET MARKER_0735
 SPELLCAST -SMF 1 IGNIT MARKER_0735
 TIMERrot 1 1 GOTO LIGHT_FIRE2
 ACCEPT

>>LIGHT_FIRE2
 BEHAVIOR FRIENDLY
 SETTARGET LIGHT_DOOR_0117
 BEHAVIOR FRIENDLY
 TIMERlook 1 2 SETTARGET LIGHT_DOOR_0117
 ACCEPT

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