// NoMomJoke warden

ON INIT {
 SET £helping_buddy "GOBLIN_BASE_0050"
 SET £flee_marker "FLEE_MARKER_0048"
 SET §reflection_mode 0
 SET §no_time_for_joke 0
 SET §alert 0
 SET £key_carried "KEY_BASE_0005portcullis"
 ACCEPT
}

ON INITEND {
 TWEAK SKIN "npc_goblin_base_head" "npc_goblin_helm_mask"
 TWEAK SKIN "npc_Goblin_base_body" "npc_Goblin_rogue"
 SET_NPC_STAT life 10
 SET_NPC_STAT damages 4
 SETWEAPON DAGGER_IRON
 SENDEVENT -ir DURABILITY 100 "40"
 ACCEPT
}

ON RELOAD {
 SET §enemy 1
 SETEVENT HEAR ON
 ACCEPT
}

ON LOAD {
 USEMESH "GOBLIN_BASE\TWEAKS\GOBLIN_WEAKER.TEO"
 ACCEPT
}

ON DETECTPLAYER {
 IF (§enemy == 0) ACCEPT
 IF (§alert == 1) ACCEPT
 SET §no_time_for_joke 1
 SENDEVENT CUSTOM Goblin_base_0008 "ALERT"
 SET §alert 1
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0514) {
    BEHAVIOR WANDER_AROUND 200
    SETTARGET NONE 
    SET §care_about_mice 1
    ACCEPT
  }
 ACCEPT
}

ON CUSTOM {
  IF (§no_time_for_joke == 1) ACCEPT
  IF (^$PARAM1 == "ALERT" ) {
   SET §no_time_for_joke 1
   SPEAK [] NOP
   TIMER kill_local
   ACCEPT
  }
  IF (§fighting_mode != 0) ACCEPT
  IF (^$PARAM1 == "TALK" ) {
    IF (§chatpos == 0) {
      BEHAVIOR FRIENDLY
      SETTARGET GOBLIN_BASE_0008
      SPEAK [Goblin_you_lucky] SENDEVENT CUSTOM Goblin_base_0008 "TALK"
      SET §chatpos 1
      ACCEPT
    }
    IF (§chatpos == 1) {
      SPEAK [Goblin_likes_joke] SENDEVENT CUSTOM Goblin_base_0008 "TALK"
      SET §chatpos 2
      ACCEPT
    }
    IF (§chatpos == 2) {
      SPEAK [Goblin_grrr_no] SENDEVENT CUSTOM Goblin_base_0008 "TALK"
      SET §chatpos 3
      ACCEPT
    }
    IF (§chatpos == 3) {
      SPEAK [Goblin_not_really] SENDEVENT CUSTOM Goblin_base_0008 "TALK"
      SET §chatpos 4
      ACCEPT
    }
    IF (§chatpos == 4) {
      BEHAVIOR MOVE_TO
      SETTARGET MARKER_0514
      ACCEPT
    }
   ACCEPT
  }
 ACCEPT
}