ON INIT {
 SET_SCALE 70
 SET £type "human_female_base"
 SET £friend "kingdom"
 INVENTORY ADD_FROM_SCENE "KEY_BASE_0043"
 SET £key_carried "KEY_BASE_0043" 
 SET_SPEAK_PITCH 0.9
 ACCEPT
}

ON INITEND {
 LOADANIM ACTION2 "human_normal_sit_in"
 LOADANIM ACTION3 "human_normal_sit_cycle"
 LOADANIM ACTION4 "human_misc_cleanfloor_2cycle"
 TWEAK ALL "human_female_villager"
 TWEAK SKIN "npc_human_villager_female_anon1" "npc_human_villager_female_anon2"
 TWEAK SKIN "npc_human_villager_female_body" "npc_human_female_white_blue2"
 BEHAVIOR MOVE_TO				
 SETTARGET MARKER_0315			
 ACCEPT
}

ON LOAD {
 USEMESH "human_female_base\human_female_base.teo"
 ACCEPT
}

ON RELOAD {
  IF (#PLAYER_ON_QUEST > 3) {
    TELEPORT MARKER_0315
    BEHAVIOR NONE
    SETTARGET NONE
    SENDEVENT CUSTOM BUCKET_0027 "NOMORE"
    FORCE_ANGLE 270
    SET §frozen 1
    PLAYANIM -e ACTION2 PLAYANIM -l ACTION3
    ACCEPT
  }
  IF (#PLAYER_ON_QUEST > 2) {
	TELEPORT MARKER_0583
    BEHAVIOR NONE
    SETTARGET NONE
    SENDEVENT CUSTOM BUCKET_0027 "SHOW"
    SET §frozen 1
    PLAYANIM -l ACTION4
    ACCEPT
  }
  IF (#PLAYER_ON_QUEST > 1) {
    TELEPORT MARKER_0907
    PLAYANIM NONE
    BEHAVIOR WANDER_AROUND 400
    SETTARGET NONE
    ACCEPT
  }
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0315) {
    BEHAVIOR NONE
    SETTARGET NONE
    FORCE_ANGLE 270
    PLAYANIM -e ACTION2 PLAYANIM -l ACTION3
    SET §frozen 1
    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 -----------------------------------------------------------
// ---------------------------------------------------------------------------------

//#

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