// Anatole, the quartermaster

ON INIT {
  IF (§dead == 2) {
    SET Łkey_carried "KEY_BASE_0005portcullis"
    SET Łtype "goblin_lord"
    SET §reflection_mode 1
    SET §enemy 1
    ACCEPT
  }
    INVENTORY ADD "PROVISIONS\\GARLIC\\GARLIC"
    INVENTORY ADD "PROVISIONS\\FOOD_FISH_COOKED\\FOOD_FISH_COOKED"
    INVENTORY ADD "JEWELRY\\GOLD_COIN\\GOLD_COIN"
 RANDOM 50 {
    INVENTORY ADD "JEWELRY\\GOLD_COIN\\GOLD_COIN"
}
 SET Łtype "goblin_lord"
 SET §pipo 0
 SET §reflection_mode 0
 SET Łkey_carried "KEY_BASE_0005portcullis"
 SET §dead 0
 ACCEPT
}

ON INITEND {
  SET_NPC_STAT life 20
  SET_NPC_STAT damages 9
  IF (§dead == 2) {
    SET_NPC_STAT life 25
    SET_NPC_STAT damages 10
    SET_NPC_STAT aimtime 700
    SET §sleeping 0
    SET §frozen 0 
    PLAYANIM WAIT
    COLLISION ON
    SETWEAPON SABRE
    SENDEVENT -ir DURABILITY 100 "63"
    TELEPORT MARKER_0847
    BEHAVIOR WANDER_AROUND 300
    SETTARGET NONE
    ACCEPT
  }
 LOADANIM ACTION2 "goblin_normal_lay_in"
 LOADANIM ACTION3 "goblin_normal_lay_cycle"
 LOADANIM ACTION4 "goblin_normal_lay_out"
 ACCEPT
}

ON GAME_READY {
 SET_NPC_STAT armor_class 10
 SET_NPC_STAT absorb 15
 IF (§dead == 2) TIMERsnoar OFF
 ACCEPT
} 

ON LOAD {
 USE_MESH "goblin_lord\goblin_lord.teo"
 ACCEPT
}

ON RELOAD {
  IF (#ANATOLE_IDed == 1) {
      SET #ANATOLE_IDed 2
	  SETNAME [description_anatole]
      ACCEPT
  }
  IF (#PLAYER_ON_QUEST > 2) {
	IF (§dead == 2) ACCEPT
    IF (§dead == 1) {
      SET §dead 2
	  SETNAME [description_goblin_lord]
      REVIVE
      ACCEPT
    }
   ACCEPT
  }
 IF (§sleeping == 1) REFUSE
 IF (§pipo == 1) ACCEPT
 ACCEPT
}

>>SNOAR
  IF (#SHUT_UP == 1) ACCEPT
  RANDOM 40 {
    SPEAK [guard_sleep_1_snoar] NOP
    ACCEPT
  }
  RANDOM 40 {
    SPEAK [guard_sleep_1_snoar2] NOP
    ACCEPT
  }
 SPEAK [guard_sleep_1_snoar3] NOP
 ACCEPT

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

ON CUSTOM {
  IF (^$PARAM1 == "PIPO") {
    SET §pipo 1
    PLAYANIM -l ACTION3
    SET §sleeping 1
    SET §frozen 1
    SET §enemy 1
    SETEVENT HEAR ON
    COLLISION OFF
    TIMERsnoar -i 0 6 GOTO SNOAR
    ACCEPT
  }
  IF (^$PARAM1 == "ANATOLE_IDed") {
   IF (#ANATOLE_IDed == 2) ACCEPT
   SETNAME [description_anatole]
   ACCEPT
  }
 ACCEPT
}