// Kitchen Lady

ON INIT {
 INVENTORY ADD "PROVISIONS\\GARLIC\\GARLIC"
 SET £key_carried "KEY_BASE_0024"
 SET £friend "kingdom"
 SET £type "human_female_base"
 SET §care_about_mice 1
 ACCEPT
}

ON INITEND {
 LOADANIM ACTION2 "human_work_herbalist"
 LOADANIM ACTION3 "human_misc_cleanfloor_1down"
 LOADANIM ACTION4 "human_misc_cleanfloor_2cycle"
 LOADANIM ACTION5 "human_misc_cleanfloor_3up.tea"
 TWEAK SKIN "npc_human_villager_female_anon1" "npc_human_villager_female_maria"
 TWEAK SKIN "npc_human_villager_female_body" "npc_human_villager_female_body4"
 SET §frozen 1   
 PLAYANIM -l ACTION2  
 TIMERwork 1 40 GOTO WORK_PATH
 PHYSICAL RADIUS 10
 ACCEPT
}

ON LOAD {
 USE_MESH "HUMAN_FEMALE_BASE\TWEAKS\human_female_villager.TEO"
 ACCEPT
}

ON RELOAD {
  IF (#PLAYER_ON_QUEST > 4) {
    TELEPORT MARKER_0411
    SENDEVENT CUSTOM BUCKET_0026 "NOMORE"
    SENDEVENT CUSTOM LIGHT_DOOR_0079 "LOCK"
    SENDEVENT CUSTOM LIGHT_DOOR_0080 "LOCK"
    SET §frozen 1
    PLAYANIM -e ACTION3 PLAYANIM -l ACTION4
    TIMERout 1 45 GOTO KITCHEN
    ACCEPT
  }
  IF (#PLAYER_ON_QUEST > 2) {
    TELEPORT MARKER_0422
    SENDEVENT CUSTOM LIGHT_DOOR_0079 "LOCK"
    SENDEVENT CUSTOM LIGHT_DOOR_0080 "UNLOCK"
    SENDEVENT CUSTOM BUCKET_0026 "SHOW"
    SET §frozen 1
    PLAYANIM -e ACTION3 PLAYANIM -l ACTION4
    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 (§enemy ==1) ACCEPT
 IF (^SPEAKING == 1) ACCEPT
 GOSUB START_CHAT
 SPEAK [Human_female_misc] GOSUB END_CHAT
 ACCEPT
}
ON CONTROLLEDZONE_ENTER {
 IF (^$PARAM1 != PLAYER) ACCEPT
 UNSET_CONTROLLED_ZONE "FORBIDEN2_IN"
 PLAYANIM ACTION5
 PLAYANIM NONE
 SET §frozen 0
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0318
 SENDEVENT CUSTOM LIGHT_DOOR_0079 "UNLOCK"
 ACCEPT
}
ON REACHEDTARGET {
  IF (^TARGET == MARKER_0318) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0066
    ACCEPT
  }
  IF (^TARGET == MARKER_0066) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_00098
    ACCEPT
  }
  IF (^TARGET == MARKER_0098) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0328
    ACCEPT
  }
  IF (^TARGET == MARKER_0328) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0106
    ACCEPT
  }
  IF (^TARGET == MARKER_0106) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0105
    ACCEPT
  }
  IF (^TARGET == MARKER_0105) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0574
    ACCEPT
  }
  IF (^TARGET == MARKER_0574) {
    BEHAVIOR NONE
    SETTARGET NONE
    SET §frozen 1
    PLAYANIM -e ACTION3 PLAYANIM -l ACTION4 
    TIMERcook 1 60 GOTO KITCHEN
    ACCEPT
  }
  IF (^TARGET == MARKER_0070) {
    FORCE_ANGLE 270
    BEHAVIOR NONE
    SETTARGET NONE
    SET §frozen 1
    PLAYANIM -l ACTION2
    TIMERwork2 1 40 GOTO WORK_PATH 
    ACCEPT
  }
  IF (^TARGET == MARKER_0071) {
    FORCE_ANGLE 90
    BEHAVIOR NONE
    SETTARGET NONE
    SET §frozen 1
    PLAYANIM -l ACTION2
    TIMERwork2 1 40 GOTO WORK_PATH2 
    ACCEPT
  }
  IF (^TARGET == MARKER_0301) {
    FORCE_ANGLE 270
    BEHAVIOR NONE
    SETTARGET NONE
    SET §frozen 1
    PLAYANIM -l ACTION2
    TIMERwork2 1 40 GOTO WORK_PATH3
    ACCEPT
  }
  IF (^TARGET == MARKER_0302) {
    BEHAVIOR NONE
    SETTARGET NONE
    BEHAVIOR WANDER_AROUND 200
    SETTARGET NONE
    TIMERwork2 1 40 GOTO WORK_PATH4
    ACCEPT
  }
 ACCEPT
}
>>KITCHEN
 PLAYANIM ACTION5
 PLAYANIM NONE
 SET §frozen 0
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0070
 ACCEPT

ON CUSTOM {
  IF (^$PARAM1 == "thief") {
    IF (§player_in_sight == 0) ACCEPT
	SENDEVENT CUSTOM HUMAN_0171 "ATTACK"
    SPEAK -o [human_female_thief] SENDEVENT ATTACK_PLAYER SELF ""
    ACCEPT
  }
  IF (^$PARAM1 == "TAKE_CONTROL") {
    SET_CONTROLLED_ZONE "FORBIDEN2_IN"
    ACCEPT
  }
 ACCEPT
}
>>WORK_PATH
 PLAYANIM NONE
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0071
 SET §frozen 0
 ACCEPT
>>WORK_PATH2
 PLAYANIM NONE
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0301
 SET §frozen 0
 ACCEPT
>>WORK_PATH3
 PLAYANIM NONE
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0302
 SET §frozen 0
 ACCEPT
>>WORK_PATH4
 PLAYANIM NONE
 BEHAVIOR MOVE_TO
 SETTARGET MARKER_0070
 SET §frozen 0
 ACCEPT