       (log-render state "debug" "1-draw-player.xp")
       (draw-ranged-attack-line state player player-x player-y)
       (log-render state "debug" "2-draw-ranged-attack-line.xp")
-      (draw-npcs state current-time vx vy d)
+      (draw-npcs state player-pos current-time vx vy d)
       (log-render state "debug" "3-draw-npcs.xp")
       (render-hud state)
       (log-render state "debug" "4-render-hud.xp")

                                                            [(rutil/item->char (first cell-items))
                                                             (rutil/item->fg   (first cell-items))
                                                             :black])
                                                          (case (cell :type)
                                                           :floor           [\·]
                                                           :open-door       [\-  :brown  :black #{:bold}]
                                                           :close-door      [\+  :brown  :black #{:bold}]
                                                           :corridor        [\#] 
                                                           :down-stairs     [\>] 
                                                           :up-stairs       [\<] 
                                                           :fire            [\u2240 (if (= (cell :discovered) current-time)
                                                                                       :fire
                                                                                       :red) :black] ;; ≀ 
                                                           :water           [\u2248 (if (= (cell :discovered) current-time)
                                                                                       :water
                                                                                       :blue) :black] ;; ≈ 
                                                           :surf            [\~ (if (= (cell :discovered) current-time)
                                                                                   :surf
                                                                                   :light-blue) :black]
                                                           :shallow-water   [\~ (if (= (cell :discovered) current-time)
                                                                                   :shallow-water
                                                                                   :light-blue) :black]
                                                           :swamp           [\~ (if (= (cell :discovered) current-time)
                                                                                   :swamp
                                                                                   :light-blue) :black]
                                                           :lava            [\~ (if (= (cell :discovered) current-time)
                                                                                   :lava
                                                                                   :light-blue) :black]
                                                           :mountain        [\u2206 :gray :black] ;; ∆
                                                           :sand            [\·  :beige      :black]
                                                           :dirt            [\·  :brown      :black]
                                                           :dune            [\u1d16  :light-brown :black] ;; ᴖ
                                                           :rocky-shore     [\u1d16  :dark-gray  :black] ;; ᴖ
                                                           :gravel          [\·  :gray       :black]
                                                           :short-grass     [\·  :green      :black]
                                                           :tall-grass      [\" :dark-green :black]
                                                           :tree            [\T  :dark-green :black]
                                                           :bamboo          [\u01c1 :light-green :black] ;; ∥ 
                                                           :palisade        [\# :brown :black]
                                                           :ramada          [\# :beige :black]
                                                           :tarp-shelter    [\# :blue  :black]
                                                           :lean-to         [\# :light-green :black]
                                                           :campfire        [\^ :brown :black]
                                                           :bamboo-water-collector
                                                                            (if (< 10 (get cell :water 0))
                                                                              [\O :bamboo-water-collector :black]
                                                                              [\O])
                                                           :solar-still
                                                                            (if (< 10 (get cell :water 0))
                                                                              [\O :solar-still :black]
                                                                              [\O])
                                                           :palm-tree       [\7  :dark-green :black]
                                                           :fruit-tree      [\u2648  :light-green :black] ;; ♈
                                                           :freshwater-hole (if (< 10 (get cell :water 0))
                                                                              [\~ :freshwater-hole :black]
                                                                              [\O])
                                                           :saltwater-hole  (if (< 10 (get cell :water 0))
                                                                              [\~ :saltwater-hole :black]
                                                                              [\O])
                                                           :dry-hole        [\O]
                                                           ;; pirate ship cell types
                                                           :bulkhead        [\◘ :brown :black]
                                                           :wheel           [\○ :dark-brown :black]
                                                           :bulkhead2       [\◘ :brown :black]
                                                           :wooden-wall     [\# :ship-brown :black]
                                                           :railing         [\# :ship-brown :black]
                                                           :hammock-v       [\) :brown :black]
                                                           :hammock-h       [\- :brown :black]
                                                           :deck            [\· :dark-brown :black]
                                                           :canon-breach    [\║ :gray :dark-brown]
                                                           :tackle          [\º :brown :black]
                                                           :canon           [\║ :gray :black]
                                                           :grate           [\╬ :dark-beige :black]
                                                           :table           [\╤ :ship-light-brown :black]
                                                           :chair           [\╥ :ship-light-brown :black]
                                                           :mast            [\╨ :ship-light-brown :black]
                                                           :beam            [\═ :brown :black]
                                                           :canon-truck-1   [\▄ :dark-brown :black]
                                                           :locker          [\▌ :brown :black]
                                                           :locker2         [\▐ :brown :black]
                                                           :canon-truck-2   [\▀ :dark-brown :black]
                                                           :ships-wheel     [\Φ :brown :black]
                                                           :ladder          [\≡ :dark-beige :black]
                                                           :porthole        [\° :brown :black]
                                                           :chest           [\■ :ship-dark-brown :black]
                                                           :artifact-chest  [\■ :dark-beige :black]
                                                           ;; ruined temple cell types
                                                           :vertical-wall   [\║ :temple-beige :black]
                                                           :horizontal-wall [\═ :temple-beige :black]
                                                           :vertical-wall-alt [\° :white :black]
                                                           :horizontal-wall-alt [\° :white :black]
                                                           :upper-left-1    [\╔ :temple-beige :black]
                                                           :upper-right-1   [\╗ :temple-beige :black]
                                                           :bottom-left-1   [\╚ :temple-beige :black]
                                                           :bottom-right-1  [\╝ :temple-beige :black]
                                                           :upper-left-2    [\◙ :temple-beige :black]
                                                           :upper-right-2   [\◙ :temple-beige :black]
                                                           :bottom-left-2   [\◙ :temple-beige :black]
                                                           :bottom-right-2  [\◙ :temple-beige :black]
                                                           :altar           [\┬ :white :black]
                                                           :vine            [\⌠ :moss-green :black]
                                                           :moss-corridor   [\# :moss-green :black]
                                                           :moss-vertical-wall  [\║ :moss-green :black]
                                                           :moss-horizontal-wall [\═ :moss-green :black]
                                                           :moss-vertical-wall-alt [\° :white :black]
                                                           :moss-horizontal-wall-alt [\° :white :black]
                                                           :moss-upper-left-1 [\╔ :moss-green :black]
                                                           :moss-upper-right-1 [\╗ :moss-green :black]
                                                           :moss-bottom-left-1 [\╚ :moss-green :black]
                                                           :moss-bottom-right-1 [\╝ :moss-green :black]
                                                           :moss-upper-left-2 [\◙ :moss-green :black]
                                                           :moss-upper-right-2 [\◙ :moss-green :black]
                                                           :moss-bottom-left-2 [\◙ :moss-green :black]
                                                           :moss-bottom-right-2 [\◙ :moss-green :black]
                                                           :white-corridor  [\# :white :black]
                                                           :white-vertical-wall   [\║ :white :black]
                                                           :white-horizontal-wall [\═ :white :black]
                                                           :white-vertical-wall-alt [\° :white :black]
                                                           :white-horizontal-wall-alt [\° :white :black]
                                                           :white-upper-left-1 [\╔ :white :black]
                                                           :white-upper-right-1 [\╗ :white :black]
                                                           :white-bottom-left-1 [\╚ :white :black]
                                                           :white-bottom-right-1 [\╝ :white :black]
                                                           :white-upper-left-2 [\◙ :white :black]
                                                           :white-upper-right-2 [\◙ :white :black]
                                                           :white-bottom-left-2 [\◙ :white :black]
                                                           :white-bottom-right-2 [\◙ :white :black]
                                                           :empty                [\space :black :black]
                                                           :crushing-wall-trigger
                                                                             (if (get cell :trap-found)
                                                                               [\^]
                                                                               [\·])
                                                           :wall-darts-trigger
                                                                             (if (get cell :trap-found)
                                                                               [\^]
                                                                               [\·])
                                                           :poisonous-gas-trigger
                                                                             (if (get cell :trap-found)
                                                                               [\^]
                                                                               [\·])
                                                           :spike-pit
                                                                             (if (get cell :trap-found)
                                                                               [\^]
                                                                               [\·])
                                                           :snakes-trigger
                                                                             (if (get cell :trap-found)
                                                                               [\^]
                                                                               [\·])
                                              
                                                           (do (log/info (format "unknown type: %s %s" (str (get cell :type)) (str cell)))
                                                           [\?])))))
                                           ;; shade character based on visibility, harvestableness, raft
                                           shaded-out-char (cond
                                                             (not= (cell :discovered) current-time)

          :human           [\@ (class->rgb (get npc :class)) :black]
          [\@])) d) targeted?))

(defn draw-npcs [rstate state player-pos current-time vx vy d]
  {:pre [(not (nil? rstate))]
   :post [(comp nil? not)]}
  ;; draw npcs
  (let [place-npcs (npcs-in-viewport state)
        ;_ (log/debug "place-npcs" place-npcs)
        ;pos (-> state :world :player :pos)
        get-cell (memoize (fn [x y] (get-cell state x y)))
        place-id (rw/current-place-id state)]
    (put-chars rstate :features
