ON INIT {
 LOADANIM ACTION1 "Troll_work_pick"
 ACCEPT
}
ON INITEND {
 BEHAVIOR Wander_around 200
 SETTARGET NONE
 TELEPORT MARKER_0804
 INVENTORY ADDMULTI "JEWELRY\\GOLD_COIN\\GOLD_COIN" 2
 ACCEPT
}

ON CUSTOM {
 IF (^$PARAM1 == "STRIKE_OVER") {
  ATTACH pick_axe_0013 "Attach" SELF "primary_attach"
  SET §attached_object "pick_axe_0013"
  TELEPORT -i
  BEHAVIOR MOVE_TO
  SETTARGET MARKER_0349
  ACCEPT
 }
 ACCEPT
}
ON PLAYER_ENEMY {
  (IF #TROLL_QUEST == 2) DETACH pick_axe_0013 SELF
 ACCEPT
}
ON REACHEDTARGET {
 IF (^TARGET == Marker_0349) {
  PLAYANIM -l ACTION1
  SET §frozen 1
  TIMERchang 1 8 GOTO CHANGE1
  ACCEPT
 }
 IF (^TARGET == Marker_0350) {
  PLAYANIM -l ACTION1
  SET §frozen 1 
  TIMERchang 1 3 GOTO CHANGE2
  ACCEPT
 }
 IF (^TARGET == Marker_0351) {
  PLAYANIM -l ACTION1
  SET §frozen 1
  TIMERchang 1 8 GOTO CHANGE3
  ACCEPT
 }
 ACCEPT
}

>>CHANGE1
PLAYANIM NONE
SET §frozen 0
BEHAVIOR MOVE_TO
SETTARGET MARKER_0350
ACCEPT

>>CHANGE2
PLAYANIM NONE
SET §frozen 0
BEHAVIOR MOVE_TO
SETTARGET MARKER_0351
ACCEPT

>>CHANGE3
PLAYANIM NONE
SET §frozen 0
BEHAVIOR MOVE_TO
SETTARGET MARKER_0349
ACCEPT

ON CHAT {
  IF (#troll_enemy == 1) ACCEPT
  IF (^SPEAKING == 1) ACCEPT
  IF (§chatpos == 0) {
    IF (#TROLLHERO == 1) {
      GOSUB START_CHAT
      SPEAK [troll_greetings_friend] GOSUB END_CHAT
      ACCEPT
    }
    GOSUB START_CHAT
    SPEAK [troll_greetings] GOSUB END_CHAT
    ACCEPT
  }
 ACCEPT
 }

//#behavior

// ---------------------------------------------------------------------------------
// BEHAVIOR INCLUDE START ----------------------------------------------------------
// ---------------------------------------------------------------------------------
>>CLEAR_MICE_TARGET
 // if we care about mice : clear current mice target and listen to other mice
 IF ( §care_about_mice == 1 )
 {
  SET £targeted_mice "NOMOUSE"
  SETGROUP MICECARE // listen to other mice
 }
RETURN

>>SAVE_BEHAVIOR
 TIMERcolplayer OFF 
// to avoid TIMERcolplayer to restore the behavior 1 sec later
 IF (§main_behavior_stacked == 0) 
 {
  IF (§frozen == 1)
  { 
// frozen anim -> wake up !
    SET §frozen 0
    PLAYANIM NONE
    PLAYANIM -2 NONE
    PHYSICAL ON
    COLLISION ON
    BEHAVIOR FRIENDLY
    SETTARGET PLAYER
  }
  SET §main_behavior_stacked 1
  HEROSAY -d "STACK"
  BEHAVIOR STACK
 }
 ELSE
 { // behavior already saved : clear mice target if one
  GOSUB CLEAR_MICE_TARGET
 }
RETURN

>>RESTORE_BEHAVIOR
 IF (§main_behavior_stacked == 1) 
 {
  GOSUB CLEAR_MICE_TARGET
  HEROSAY -d "UNSTACK"
  BEHAVIOR UNSTACK
  SET §main_behavior_stacked 0
  RETURN
 }
IF (£init_marker != "NONE")
  { 
   BEHAVIOR MOVE_TO
   SETTARGET -a ~£init_marker~
   SETMOVEMODE WALK
   RETURN
  }
HEROSAY -d "go_home"
BEHAVIOR GO_HOME
SETTARGET PLAYER
RETURN

// ---------------------------------------------------------------------------------
// BEHAVIOR INCLUDE END ------------------------------------------------------------
// ---------------------------------------------------------------------------------

//#
//#LocalChat
// ---------------------------------------------------------------------------------
// LocalChat INCLUDE START ---------------------------------------------------------
// ---------------------------------------------------------------------------------
>>START_CHAT
 // save misc reflection mode
 SET §saved_reflection §reflection_mode
 // no more stupid reflections !
 SET §reflection_mode 0
 // fo not change behavior if frozen
 IF ( §frozen == 1 ) RETURN
 // save behavior (if not saved)
 GOSUB SAVE_BEHAVIOR
 // look at player
 BEHAVIOR FRIENDLY
 SETTARGET PLAYER
RETURN

>>END_CHAT
 SET_EVENT COLLIDE_NPC ON
 SET §collided_player 0
 // restor behavior only if not in fighting mode
 IF ( §fighting_mode == 0 )
 {
  // restore misc reflection mode
  SET §reflection_mode §saved_reflection
  // if frozen : don't restore behavior
  IF ( §frozen == 1 ) RETURN
  // restore behavior
  GOSUB RESTORE_BEHAVIOR
 }
RETURN
// ---------------------------------------------------------------------------------
// LocalChat INCLUDE END -----------------------------------------------------------
// ---------------------------------------------------------------------------------

//#