// Carlo in Castle
ON INIT {
 INVENTORY ADD_FROM_SCENE "KEY_CRYPT_0005"
 INVENTORY ADD_FROM_SCENE "KEY_BASE_0065"
// SET £type "human_guard_kingdom"
 SET £friend "kingdom"
 SET #carlo_rituals 0
 SET §hide 0
 ACCEPT
}

ON INITEND {
 SET_XP_VALUE 600
 SETGROUP STATUE_TOUCHED		// Felnor, King and Carlo.
 TWEAK HEAD "human_villager_head2"
 TWEAK LOWER "human_chainmail"
 TWEAK SKIN "npc_human_chainmail_body" "npc_human_armoredmail_guard_body"
 SETWEAPON SABRE
 OBJECT_HIDE SELF YES
 SET §reflection_mode 0
 SET_NPC_STAT damages 30
 SET_NPC_STAT aimtime 400
 SETNAME [description_carlo]
 SENDEVENT -ir DURABILITY 100 "95"
 ACCEPT
}

ON RELOAD {
 IF (#carlo_in_jail == 1) GOTO JAIL
 IF (§hide == 1) {
   TELEPORT MARKER_0411
   BEHAVIOR NONE
   SETTARGET NONE
   OBJECT_HIDE SELF YES
   SET §hide 2
   ACCEPT
 }
 ACCEPT
}

ON GAME_READY {
 IF (#carlo_in_jail > 0) ACCEPT
 IF (#PLAYER_ON_QUEST < 7) ACCEPT
 OBJECT_HIDE SELF YES
 ACCEPT
}

ON CHAT {
  IF (^SPEAKING == 1) ACCEPT
  IF (§chatpos == 99) {
    SPEAK -o [carlo_regret] NOP
    ACCEPT
  }
  IF (§chatpos == 0) {
    SPEAK [carlo_dont_know] SET §chatpos 1
    ACCEPT
  }
  IF (§chatpos == 1) {
    SPEAK [carlo_regret] SET §chatpos 0
    ACCEPT
  }
 ACCEPT
}

ON CHANGESTATUS {
  IF (^$PARAM1 == "5") {
    OBJECT_HIDE SELF NO
    TELEPORT MARKER_0312
    BEHAVIOR FRIENDLY
    SETTARGET HUMAN_BASE_0082 //king
    ACCEPT
  }
  IF (^$PARAM1 == "JAIL") {
>>JAIL
    TWEAK LOWER "human_chainmail"
    TWEAK SKIN "npc_human_chainmail_body" "npc_human_jailmail_guard_body"
	SET #carlo_in_jail 2
    SET §reflection_mode 1
    SET #QUEEN_QUEST 2
    OBJECT_HIDE SELF NO
    SETWEAPON NONE
    TELEPORT MARKER_0207
    BEHAVIOR FRIENDLY
    SETTARGET PLAYER
    SET §chatpos 99
    SENDEVENT CUSTOM LIGHT_DOOR_0025 "CARLO_LOCK"
    ACCEPT
  }
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == HUMAN_BASE_0082) {
    BEHAVIOR FRIENDLY
    SETTARGET HUMAN_BASE_0082
    ACCEPT
  }
  IF (^TARGET == MARKER_0556){
    BEHAVIOR FRIENDLY
    SETTARGET HUMAN_BASE_0082
    ACCEPT
  }
  IF (^TARGET == MARKER_0305){
    TELEPORT MARKER_0411
    BEHAVIOR NONE
    SETTARGET NONE
    OBJECT_HIDE SELF YES
    SET §hide 2
    ACCEPT
  }
  IF (^TARGET == MARKER_0098){
    SENDEVENT CUSTOM AKBAA_BLOOD_CHICKEN_0002 "SHOW"
    SENDEVENT CUSTOM AKBAA_BLOOD_0002 "SHOW"
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0305
    SETMOVEMODE RUN
    ACCEPT
  }
 ACCEPT
}

ON CUSTOM {
  IF (^$PARAM1 == "TALK") {
    IF (§chatpos == 0) {
      OBJECT_HIDE SELF NO
      BEHAVIOR MOVE_TO
      SETTARGET MARKER_0556
      SETMOVEMODE RUN
      TIMERdelay 1 1 GOTO BREAKIN
      SENDEVENT LOOKME HUMAN_BASE_0082 ""
      PLAYER_LOOKAT SELF
      SET #carlo_rituals 1
      SET §chatpos 1
      SPEAK -oa [Carlo_breaks_in1] SENDEVENT CUSTOM HUMAN_BASE_0082 "TALK"
      ACCEPT
    }
    IF (§chatpos == 1) {
      SET §chatpos 2
      SPEAK -oac CCCTALKER_L HUMAN_BASE_0082 90 100 [Carlo_breaks_in2] SENDEVENT CUSTOM HUMAN_BASE_0082 "TALK"
      ACCEPT
    }
    IF (§chatpos == 2) {
      SET §chatpos 3
      SPEAK -o [Carlo_breaks_in3] BEHAVIOR MOVE_TO SETTARGET MARKER_0098 SETMOVEMODE RUN
      TIMERgone -m 1 1500 SENDEVENT CUSTOM HUMAN_BASE_0082 "GONE"
      ACCEPT
    }
   ACCEPT
  }
  IF (^$PARAM1 == "TALK3") {
    SET §hide 1
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0305
    SETMOVEMODE RUN
    ACCEPT
  }
  IF (^$PARAM1 == "TALK_STATUE01") {
    PLAYERLOOKAT SELF
    SENDEVENT -g STATUE_TOUCHED LOOKME ""
    SPEAK [carlo_statue_guard_post_attack] SENDEVENT CINEMATIC CAMERA_0139 ""
    ACCEPT
  }
  IF (^$PARAM1 == "TALK_STATUE02") {
    PLAYERLOOKAT SELF
    SENDEVENT -g STATUE_TOUCHED LOOKME ""
    SETGROUP -r STATUE_TOUCHED
    SPEAK [carlo_statue_dont_know] SENDEVENT CUSTOM CAMERA_0139 "NEXT01"
    ACCEPT
  }
 ACCEPT
}

>>BREAKIN
 SENDEVENT LOOKME CAMERA_0098 "4000"
 TIMERpouet 1 1 SETMOVEMODE WALK
 ACCEPT

ON TREATOUT {
 REFUSE
}

ON COLLIDE_NPC {
 IF (§chatpos == 3) ACCEPT
 ACCEPT
}