// Ortiern in Caves

ON INIT {
 SET §dead 0
 SET §helped 0
 SET §debut 0		// Used to check if npc has more than 1 life point
 SET £friend "NONE"
 ACCEPT
}

ON INITEND {
 SET §reflection_mode 0
 LOADANIM ACTION2 "human_guard_wounded_cycle"
 TWEAK LOWER "human_chainmail"
 TWEAK SKIN "npc_human_chainmail_body" "npc_human_chainmail_guard_body_blood"
 TWEAK SKIN "npc_human_base_hero_head" "npc_human_base_Ortiern_head"
 SET_CONTROLLED_ZONE "ORTIERN_CAVE_ZONE"
 PHYSICAL OFF
 PLAYANIM -l ACTION2
 SET §frozen 1
 SET §cine 0
 ACCEPT
}

ON RELOAD {
  IF (#TALKED_2ORTIERN_POST == 1) {
    DESTROY SELF
    ACCEPT
  }
  IF (#TALKED_2ORTIERN_CAVE == 1) {
    DESTROY SELF
    ACCEPT
  }
  IF (#ORTIERN_DEAD_POST == 1) {
    DESTROY SELF
    ACCEPT
  }
  IF (#PLAYER_ON_QUEST > 0) {
    DESTROY SELF
    ACCEPT
  }
  IF (#PLAYER_ON_QUEST == 0) {
    IF (§cinematic_loaded == 1) ACCEPT
    SET_NPC_STAT life 1
    LOADANIM DIE "human_guard_wounded_die"
    SET §cinematic_loaded 1
    //CINE -p ylside
    ACCEPT
  }
 ACCEPT
}

ON GAME_READY {
 SETGORE OFF
 IF (#PLAYER_ON_QUEST > 0) ACCEPT
 IF (§cine == 1) ACCEPT
 CINE -p ylside
 ACCEPT
}

ON DIE {
 SET §dead 1
 SET #ORTIERN_DEAD_CAVE 1
 ACCEPT
}

ON OUCH {
 IF (§debut == 1) ACCEPT
 FORCEDEATH SELF
 ACCEPT
}

ON CONTROLLEDZONE_ENTER {
 IF (^$PARAM1 != PLAYER) ACCEPT
 UNSET_CONTROLLED_ZONE "ORTIERN_CAVE_ZONE"
 SET #SHUT_UP 1
 SET_PLAYER_CONTROLS OFF
 CINEMASCOPE -s ON
 PLAYER_INTERFACE -s HIDE
 TELEPORT -p MARKER_0856
 TIMERlookat -m 1 10 PLAYERLOOKAT MARKER_0857
 SETNAME [description_Ortiern]
 SPEAK -o [Ortiern_welcome_caves] GOTO SUITE
 ACCEPT
}

ON CHAT {
  IF (^SPEAKING == 1) ACCEPT
  IF (§enemy == 1) ACCEPT
  IF (§chatpos == 1) {
    SPEAK -o [Ortiern_repeat_briefing_caves] NOP
    ACCEPT
  }
 SENDEVENT CUSTOM MARKER_0858 "test"
 ACCEPT
}

ON COMBINE {
 IF (^$PARAM1 ISCLASS POTION_LIFE) {
  IF (§helped == 1) ACCEPT
  SENDEVENT EMPTY ^$PARAM1 ""
  SPELLCAST -msf 1 HEAL HUMAN_BASE_0030
  SET §helped 1
  SPEAK [Ortiern_misc_hi2] NOP
  ADD_XP 80
  ACCEPT
 }
 ACCEPT
}

>>SUITE
 SPEAK -p [Player_welcome_ortiern] GOTO SUITE2
 ACCEPT

>>SUITE2
 SPEAK -o [Ortiern_briefing1] GOTO SUITE3
 ACCEPT

>>SUITE3
 SPEAK -p [Player_ortiern1] GOTO SUITE4
 ACCEPT
 
>>SUITE4
 SET §cine 1
 WORLDFADE OUT 800 0 0 0
 TIMERcine -m 1 800 CINE ylside
 ACCEPT

ON CINE_END {
 WORLDFADE IN 800
 TIMERsuite -m 1 800 GOTO SUITE5
 ACCEPT
}

>>SUITE5
 SPEAK -p [Player_ortiern2] GOTO SUITE6
 ACCEPT

>>SUITE6
 SPEAK -o [Ortiern_briefing4] GOTO NEXT_STEP
 ACCEPT

>>NEXT_STEP
 WORLD_FADE IN 2000
 SET_PLAYER_CONTROLS ON
 CINEMASCOPE -s OFF
 PLAYER_INTERFACE -s SHOW
 PLAY "system"
 QUEST [system_Quest_log_message_ortiern]
 HEROSAY [system_questbook_updated]
 SET #TALKED_2ORTIERN_CAVE 1
 SET #SHUT_UP 0
 SET §chatpos 1
 ACCEPT