ON INIT {
 SET £friend "TAVERN"
 INVENTORY ADDMULTI "JEWELRY\\GOLD_COIN\\GOLD_COIN" 56
 SET #guitar_player_dead 0		// Used to check if player has killed npc in another level
 ACCEPT
}

ON INITEND {
 TWEAK HEAD "human_villager_head5"
 TWEAK TORSO "human_villager_chest1"
 TWEAK LEGS "human_villager_legs3"
 LOADANIM TALK_HAPPY "human_work_guitar_slow_toponly"
 SET_NPC_STAT life 50
 SET §tactic 2
 SET §flee 0
 OBJECT_HIDE -m SELF ON
 SET §reflection_mode 0
 ACCEPT
}

ON RELOAD {
  IF (#guitar_player_dead == 1) DESTROY SELF
  IF (#TROLL_QUEST > 2) {
    IF (§flee == 1) {
     SET §flee 0
     SETEVENT COLLIDE_NPC ON
     TELEPORT -i
    }
    OBJECT_HIDE SELF OFF
    ATTACH LUTH_0002 "luth_attach" SELF "primary_attach"
    SET £attached_object "LUTH_0002"
>>PLAY
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0548
    TIMERplay -i 0 15 GOTO PLAYING
    ACCEPT
  }
 ACCEPT
}

ON OUCH {
 TIMERplay OFF
 TIMERnextbis OFF
 TIMERnext OFF
 SET §enemy 1
 ACCEPT
}

>>PLAYING
 IF (^SPEAKING == 1) GOTO PLAY
 SPEAK -h [menestrel_melody] NOP
 ACCEPT

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0548) {
    BEHAVIOR WANDER_AROUND 400
    SETTARGET NONE
    TIMERnext -i 1 60 GOTO NEXT_POINT
    ACCEPT
  }
  IF (^TARGET == MARKER_0549) {
    BEHAVIOR WANDER_AROUND 200
    SETTARGET NONE
    TIMERnextbis -i 1 60 GOTO NEXT_POINT2
    ACCEPT
  }
 ACCEPT
}

ON CHAT {
 IF(^SPEAKING == 1) ACCEPT
 IF (§enemy == 1) ACCEPT
 SPEAK -h [menestrel_melody] GOTO STOP
 ACCEPT
}

>>NEXT_POINT
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0549
 ACCEPT

>>NEXT_POINT2
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0548
 ACCEPT

ON COMBINE {
  IF (§enemy == 1) ACCEPT
  IF (^SPEAKING == 1) {
    SPEAK -p [player_not_now] NOP
    ACCEPT
  }
  IF (^$PARAM1 ISCLASS BOTTLE_WINE) {
    SET §reflection_mode 0
    DESTROY ^SENDER
    SPEAK -h [menestrel_outtune] GOTO PLAY
    ACCEPT
  }
  IF (^$PARAM1 ISCLASS DIAMOND) {
    SET §reflection_mode 0
    DESTROY ^SENDER
    SPEAK -h [menestrel_uw1] GOTO PLAY
    ACCEPT
  }
  IF (^$PARAM1 ISCLASS EMERALD) {
    SET §reflection_mode 0
    DESTROY ^SENDER
    SPEAK -h [menestrel_uw2] GOTO PLAY
    ACCEPT
  }
 ACCEPT
}

ON DIE {
 SET #guitar_player_dead 1
 ACCEPT
}
ON CUSTOM {
 IF (^$PARAM1 == "FLEE") {
  IF (^DIST_PLAYER > 500) ACCEPT
  TIMERnext OFF
  TIMERnextbis OFF
  TIMERplay OFF
  SETEVENT COLLIDE_NPC OFF
  SET §flee 1
  BEHAVIOR FLEE 3000
  SETTARGET PLAYER
  ACCEPT
 }
 ACCEPT
}