// Fisher outside goblin city
ON INIT {
 SET §spotted 0
 SET §chatpos 4
 SET §epok 0
 SET §fish 0
 SET £friend "goblin_castle"
 SETEVENT CHAT OFF
 LOADANIM ACTION1 "Goblin_misc_fishing"
 SET £key_carried "Portcullis"
 ACCEPT
}

ON INITEND {
 SET §reflection_mode 0
 LOADANIM ACTION3 "Goblin_normal_sit_cycle"
 SET §frozen 1
 //TWEAK SKIN "npc_goblin_base_body" "npc_goblin_grey_body"
 //TWEAK SKIN "npc_goblin_base_head" "npc_goblin_grey_head"
 PHYSICAL OFF
 BEHAVIOR -a FRIENDLY
 SETTARGET GOBLIN_BASE_0024
 INVENTORY ADD "PROVISIONS\\BREAD_HALF\\BREAD_HALF"
 SET £flee_marker "FLEE_MARKER_0035"
 SET £helping_buddy "GOBLIN_BASE_0035"
 SENDEVENT -ir DURABILITY 100 "27"
 PLAYANIM -L ACTION3
 ACCEPT
}
ON RELOAD {
 IF (§enemy == 1) ACCEPT
 IF (#troll_quest == 2) {
  RANDOM 50 {
   GOTO FISH
   ACCEPT
  }
  RANDOM 50 {
   GOTO SIT
   ACCEPT
  }
  ACCEPT
 }
 ACCEPT
}
>>SPEECH
 IF (§enemy == 1) ACCEPT
 IF (§epok == 1) ACCEPT
 IF (§spotted == 0) {
  SET §spotted 1
  SENDEVENT CUSTOM GOBLIN_BASE_0024 "HERE_HE_COMES"
  ACCEPT
  }
ACCEPT

ON CHAT {
 IF (§enemy == 1) ACCEPT
 IF (^SPEAKING == 1) ACCEPT
 IF (§chatpos == 4) {
  GOSUB START_CHAT
  SPEAK [Goblin_generic] GOSUB END_CHAT
 ACCEPT
}

ON CUSTOM {
 IF (^$PARAM1 == "Go") GOTO SPEECH
 IF (^$PARAM1 == "STOP" ) {
  IF (^SPEAKING == 1) ACCEPT
  IF (#shut_up == 1) SENDEVENT CUSTOM GOBLIN_BASE_0016 "HERE_HE_COMES" ACCEPT
  SPEAK [goblin_herehecomes] SENDEVENT CUSTOM GOBLIN_BASE_0016 "HERE_HE_COMES"
  SETEVENT CHAT ON
  ACCEPT
 }
 IF (^$PARAM1 == "LAUGH" ) {
  IF (^SPEAKING == 1) ACCEPT
  IF (#shut_up == 1) { 
   SET §reflection_mode 1
   ACCEPT
  }
  TIMERlaugh 1 1 SPEAK [goblin_laugh] SET §reflection_mode 1
  ACCEPT
 }
 IF (^$PARAM1 == "epok") {
  SETEVENT CHAT ON
  SET §epok 1
  PLAYANIM NONE
>>FISH
  PLAYANIM -l ACTION1
  SET §reflection_mode 1
  TELEPORT Marker_0428 
  SET §frozen 1
  PHYSICAL OFF
  IF (§fish == 0) {
   SET §fish 1
   SENDEVENT CUSTOM Food_fish_0146 "appear"
   SENDEVENT CUSTOM Food_fish_0147 "appear"
   SENDEVENT CUSTOM Food_fish_0148 "appear"
   SENDEVENT CUSTOM Bucket_0013 "appear"   
   SENDEVENT CUSTOM pole_0012 "appear"   
   SENDEVENT CUSTOM L2_Gobel_chair_01_0003 "INTERACT"   
   ATTACH Pole_0012 "action point" SELF "primary_attach"
   SET £attached_object "Pole_0012"
   ACCEPT
  }
  ACCEPT
 }
 IF (^$PARAM1 == "THIEF") {
  SETGROUP -r £friend
  SET £friend "NONE"
  SPEAK [Goblin_thief] NOP
  SENDEVENT ATTACK_PLAYER SELF ""
  ACCEPT
 }
 ACCEPT
}

>>SIT
 TELEPORT -i
 BEHAVIOR FRIENDLY 
 SETTARGET MARKER_0431
 PLAYANIM -L ACTION3
 SET §frozen 1
 PHYSICAL OFF
 IF (§fish == 1) {
  SET §fish 0
  SENDEVENT CUSTOM Food_fish_0148 "Disappear"
  SENDEVENT CUSTOM Food_fish_0147 "Disappear"
  SENDEVENT CUSTOM Food_fish_0146 "Disappear"
  SENDEVENT CUSTOM Bucket_0013 "Disappear"
  DETACH Pole_0012 SELF
  SET £attached_object "NONE"
  SENDEVENT CUSTOM pole_0012 "Disappear"
  SENDEVENT CUSTOM L2_Gobel_chair_01_0003 "RESET"
  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 -----------------------------------------------------------
// ---------------------------------------------------------------------------------

//#