// Outpost Guard (Survivor)

ON INIT {
  IF (§res == 1) {
    SET £type "human_guard_kingdom"						//attention : feinte de pute...
    SET §refuse 0
    ACCEPT
  }
 SET §dead 0
 SET §saved 0
 SET §debut 0						// Used to check if npc has more than 1 life point
 SET £type "human_guard_kingdom"
 SET §player_warned 0
 SET £voice "_vb"
 SET_SPEAK_PITCH 1.1
 SET §chatpos 1
 ACCEPT
}

ON INITEND {
  IF (§res == 1) {					//attention : feinte de pute...
>>FEINTE
    PHYSICAL ON
    SETEVENT CHAT ON
    SET §dead 0
    SET §frozen 0
    LOADANIM DIE "Human_death"
	PLAYANIM NONE
    SETWEAPON LONG_SWORD
    DESTROY SEAT_STOOL1_0007
    SET_NPC_STAT life 25
    SET §debut 1
    SET §res 2
    SET §reflection_mode 1
    TELEPORT MARKER_0839
    BEHAVIOR WANDER_AROUND 300
    SETTARGET NONE
    IF (£friend != "NONE") SETGROUP -r £friend
    SET £friend "human_kingdom"
    SET_GROUP £friend
    SET §chatpos 0
    UNSET_CONTROLLED_ZONE INTRODUCE
    ACCEPT
  }
 TWEAK SKIN "npc_human_chainmail_body" "npc_human_chainmail_guard_body_dirty"
 IF (£friend != "NONE") SETGROUP -r £friend
 SET £friend "NONE"
 SETWEAPON NONE
 ACCEPT
}

ON GAME_READY {
 SETGORE OFF
 ACCEPT
}

ON RELOAD {
  IF (#PLAYER_ON_QUEST > 4) {
    IF (§dead == 1) ACCEPT
    IF (£friend != "NONE") SETGROUP -r £friend
    SET £friend "NONE"
    DESTROY SELF
    ACCEPT
  }
  IF (#TROLL_QUEST > 1) {
    IF (§dead == 1) REVIVE
	GOTO FEINTE
    SET §res 1
    ACCEPT
  }
  IF (#TALKED_2ORTIERN_POST == 1) {
    IF (§saved == 0) ACCEPT
	SET §res 1
	SET §chatpos 3
    ACCEPT
 }
  IF (#TALKED_2ORTIERN_POST == 1) {
    IF (§saved == 1) ACCEPT
	SET §res 1
	FORCEDEATH SELF
    ACCEPT
 }
  IF (#TALKED_2ORTIERN_CAVE == 1) {
	SET §res 1
	SET §saved 1
	SET §chatpos 3
	UNSET_CONTROLLED_ZONE INTRODUCE
	LOADANIM WALK "human_kultar_walk_wounded"
    LOADANIM WAIT "human_kultar_wait_wounded"
    ACCEPT
  }
  IF (#PLAYER_ON_QUEST == 0) {
    IF (§dead == 1) ACCEPT
    SET_NPC_STAT life 1
    SET §reflection_mode 0
    LOADANIM ACTION2 "human_guard_wounded_cycle"
    LOADANIM DIE "human_guard_wounded_die"
    PHYSICAL OFF
    PLAYANIM -l ACTION2
    SET §frozen 1
    IF (§player_warned == 0) SET_CONTROLLED_ZONE INTRODUCE
    ACCEPT
  }
 ACCEPT
}

ON CONTROLLEDZONE_ENTER {
 IF (^$PARAM1 != PLAYER) ACCEPT
 IF (§enemy == 1) ACCEPT
 SET §player_warned 1
 UNSET_CONTROLLED_ZONE INTRODUCE
 SPEAK [human_guard_guardpost_wounded] NOP
 ACCEPT
}

ON CHAT {
  IF (^SPEAKING == 1) ACCEPT
  IF (§chatpos == 3) {
    SPEAK [Human_guard_wounded_vb] NOP
    ACCEPT
  }
  IF (§chatpos == 2) {
    SPEAK [Human_guard_misc_vb11] NOP
    ACCEPT
  }
  IF (§chatpos == 1) {
    SPEAK [human_guard_guardpost_wounded_insist] NOP
    ACCEPT
  }
 ACCEPT
}

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

ON URDEAD {
 IF (§saved == 1) {
    SET §res 1
    ACCEPT
 }
 SET §res 1
 FORCEDEATH SELF
 ACCEPT
}

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

ON CUSTOM {
  IF (^$PARAM1 == "ATTACK_YLSIDE") {
    SET §refuse 1
    SETEVENT CHAT OFF
    WEAPON ON
    BEHAVIOR -f MOVE_TO
    SETTARGET -a HUMAN_BASE_0069
    SETMOVEMODE RUN
    ACCEPT
  }
 ACCEPT
}

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

ON TARGET_DEATH {
  IF (^SENDER == "HUMAN_BASE_0069") {
    SET §refuse 0
    SETEVENT CHAT ON
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0839
    ACCEPT
  }
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0839) {
    BEHAVIOR WANDER_AROUND 300
    SETTARGET NONE
    ACCEPT
  }
 ACCEPT
}

ON DIE {
 IF (§res == 2) ACCEPT
 SET §dead 1
 SET §res 1
 ACCEPT
}