;;-*-Lisp-*-
(in-package goal)

(import "goal_src/jak1/import/sharkey-ag.gc")

;; failed to figure out what this is:
(defpartgroup group-sharkey-splash
  :id 106
  :duration 120
  :linger-duration 780
  :flags (use-local-clock)
  :bounds (static-bspherem 0 -12 0 14)
  :parts ((sp-item 124 :flags (is-3d) :period 900 :length 63)
    (sp-item 125 :period 900 :length 15)
    (sp-item 126 :flags (is-3d) :period 900 :length 15)
    (sp-item 127 :flags (is-3d) :period 900 :length 15)
    (sp-item 128 :period 900 :length 10 :binding 129)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    (sp-item 129 :flags (start-dead) :period 900 :length 120)
    )
  )

;; definition of type sharkey
(deftype sharkey (nav-enemy)
  ((dir               vector     :inline :offset-assert 400)
   (spawn-point       vector     :inline :offset-assert 416)
   (scale             float              :offset-assert 432)
   (anim-speed        float              :offset-assert 436)
   (y-max             meters             :offset-assert 440)
   (y-min             meters             :offset-assert 444)
   (attack-time       float              :offset-assert 448)
   (player-water-time time-frame         :offset-assert 456)
   (player-in-water   basic              :offset-assert 464)
   (last-y            float              :offset-assert 468)
   (spawn-distance    meters             :offset-assert 472)
   (chase-speed       meters             :offset-assert 476)
   (y-speed           meters             :offset-assert 480)
   (sound-id          sound-id           :offset-assert 484)
   (enable-patrol     basic              :offset-assert 488)
   )
  :heap-base #x180
  :method-count-assert 76
  :size-assert         #x1ec
  :flag-assert         #x4c018001ec
  )

;; definition for method 3 of type sharkey
(defmethod inspect sharkey ((obj sharkey))
  (let ((t9-0 (method-of-type nav-enemy inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tdir: #<vector @ #x~X>~%" (-> obj dir))
  (format #t "~T~Tspawn-point: #<vector @ #x~X>~%" (-> obj spawn-point))
  (format #t "~T~Tscale: ~f~%" (-> obj scale))
  (format #t "~T~Tanim-speed: ~f~%" (-> obj anim-speed))
  (format #t "~T~Ty-max: (meters ~m)~%" (-> obj y-max))
  (format #t "~T~Ty-min: (meters ~m)~%" (-> obj y-min))
  (format #t "~T~Tattack-time: ~f~%" (-> obj attack-time))
  (format #t "~T~Tplayer-water-time: ~D~%" (-> obj player-water-time))
  (format #t "~T~Tplayer-in-water: ~A~%" (-> obj player-in-water))
  (format #t "~T~Tlast-y: ~f~%" (-> obj last-y))
  (format #t "~T~Tspawn-distance: (meters ~m)~%" (-> obj spawn-distance))
  (format #t "~T~Tchase-speed: (meters ~m)~%" (-> obj chase-speed))
  (format #t "~T~Ty-speed: (meters ~m)~%" (-> obj y-speed))
  (format #t "~T~Tsound-id: ~D~%" (-> obj sound-id))
  (format #t "~T~Tenable-patrol: ~A~%" (-> obj enable-patrol))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *sharkey-sg* sharkey sharkey-lod0-jg sharkey-idle-ja
              ((sharkey-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 6)
              )

;; definition for method 44 of type sharkey
;; INFO: Return type mismatch symbol vs object.
(defmethod dummy-44 sharkey ((obj sharkey) (arg0 process) (arg1 event-message-block))
  (the-as object #t)
  )

;; definition for method 43 of type sharkey
;; INFO: Return type mismatch symbol vs object.
(defmethod dummy-43 sharkey ((obj sharkey) (arg0 process) (arg1 event-message-block))
  (the-as object #t)
  )

;; failed to figure out what this is:
nav-enemy-default-event-handler

;; definition for method 12 of type sharkey
(defmethod run-logic? sharkey ((obj sharkey))
  (or (zero? (logand (-> obj mask) (process-mask actor-pause)))
      (or (>= (+ (-> *ACTOR-bank* pause-dist) (-> obj collide-info pause-adjust-distance))
              (vector-vector-distance (-> obj collide-info trans) (math-camera-pos))
              )
          (and (nonzero? (-> obj skel)) (!= (-> obj skel root-channel 0) (-> obj skel channel)))
          (and (nonzero? (-> obj draw)) (logtest? (-> obj draw status) (draw-status no-skeleton-update)))
          )
      )
  )

;; definition for method 40 of type sharkey
;; INFO: Return type mismatch int vs none.
(defmethod dummy-40 sharkey ((obj sharkey))
  (dummy-11 (-> obj nav) (-> obj nav target-pos))
  (let* ((f0-0 (vector-vector-xz-distance (-> obj collide-info trans) (-> obj nav target-pos)))
         (f30-0 (/ (- (fmin (-> obj y-max) (-> obj nav target-pos y)) (-> obj collide-info trans y)) f0-0))
         )
    (set! (-> obj nav travel y) (* 4.0 (vector-length (-> obj nav travel)) f30-0))
    )
  0
  (none)
  )

;; definition for method 37 of type sharkey
;; INFO: Return type mismatch int vs none.
(defmethod TODO-RENAME-37 sharkey ((obj sharkey))
  (let ((s5-0 (new 'stack-no-clear 'vector)))
    (when (< 8192.0 (vector-length (-> obj nav travel)))
      (vector-normalize-copy! s5-0 (-> obj nav travel) 1.0)
      (vector-deg-seek (-> obj dir) (-> obj dir) s5-0 (* 65536.0 (-> *display* seconds-per-frame)))
      (vector-normalize! (-> obj dir) 1.0)
      (forward-up->quaternion (-> obj collide-info quat) (-> obj dir) *up-vector*)
      )
    )
  0
  (none)
  )

;; definition for method 41 of type sharkey
;; INFO: Return type mismatch int vs none.
(defmethod dummy-41 sharkey ((obj sharkey))
  (let* ((f0-1 (- (-> obj target-speed) (-> obj momentum-speed)))
         (f1-3 (fmin (* (-> obj acceleration) (-> *display* seconds-per-frame)) (fabs f0-1)))
         )
    (if (< f0-1 0.0)
        (set! (-> obj momentum-speed) (- (-> obj momentum-speed) f1-3))
        (+! (-> obj momentum-speed) f1-3)
        )
    )
  (let ((f0-9 (fmin
                (* (-> obj speed-scale) (-> obj momentum-speed))
                (* (vector-length (-> obj nav travel)) (-> *display* frames-per-second))
                )
              )
        )
    (vector-normalize-copy! (-> obj collide-info transv) (-> obj nav travel) f0-9)
    )
  0
  (none)
  )

;; definition for method 39 of type sharkey
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defmethod common-post sharkey ((obj sharkey))
  (let ((f30-0 (-> obj water height))
        (s5-0 (new 'stack-no-clear 'vector))
        )
    (let* ((f3-0 (- -36864.0 (-> obj collide-info trans y)))
           (f0-2 (fmax 0.0 (fmin 1.0 (- 1.0 (* 0.00008138021 f3-0)))))
           )
      (set-vector! (-> obj draw color-mult) f0-2 f0-2 f0-2 1.0)
      )
    (dummy-10 (-> obj water))
    (let ((f28-0 (-> obj collide-info trans y)))
      (when (or (and (< f30-0 f28-0) (>= f30-0 (-> obj last-y))) (and (>= f30-0 f28-0) (< f30-0 (-> obj last-y))))
        (set! (-> s5-0 quad) (-> obj collide-info trans quad))
        (set! (-> s5-0 y) f30-0)
        (dummy-13 (-> obj water) 1.0 s5-0 1 (-> obj collide-info transv))
        )
      (set! (-> obj last-y) f28-0)
      )
    )
  ((the-as (function nav-enemy none) (find-parent-method sharkey 39)) obj)
  0
  (none)
  )

;; definition for function sharkey-notice-player?
(defbehavior sharkey-notice-player? sharkey ()
  (if *target*
      (and (< (- (-> *target* control trans y) (-> self y-max)) 0.0)
           (let ((gp-0 'racer))
             (!= gp-0 (send-event *target* 'query 'mode))
             )
           (nav-enemy-test-point-near-nav-mesh? (-> *target* control shadow-pos))
           )
      )
  )

;; definition for function sharkey-get-player-position
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun sharkey-get-player-position ((arg0 vector))
  (set! (-> arg0 quad) (-> (target-pos 5) quad))
  0
  (none)
  )

;; definition for function sharkey-reset-position
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defbehavior sharkey-reset-position sharkey ()
  (set! (-> self collide-info trans quad) (-> self entity extra trans quad))
  0
  (none)
  )

;; definition for function sharkey-move-to-attack-position
;; Used lq/sq
(defbehavior sharkey-move-to-attack-position sharkey ()
  (let ((s5-0 (new 'stack-no-clear 'vector))
        (s3-0 (new 'stack-no-clear 'vector))
        (gp-0 (new 'stack-no-clear 'vector))
        )
    (let ((s4-0 (-> *target* control trans)))
      (let ((f30-0 4096000.0))
        (set! (-> s3-0 quad) (-> self entity extra trans quad))
        (set! (-> s5-0 quad) (-> self collide-info trans quad))
        (dotimes (s2-0 (-> self path curve num-cverts))
          (eval-path-curve-div! (-> self path) s3-0 (the float s2-0) 'interp)
          (let ((f0-2 (vector-vector-xz-distance s4-0 s3-0)))
            (when (< f0-2 f30-0)
              (set! f30-0 f0-2)
              (set! (-> s5-0 quad) (-> s3-0 quad))
              )
            )
          )
        )
      (vector-! (-> self dir) s4-0 s5-0)
      (vector-normalize! (-> self dir) 1.0)
      (vector+*! gp-0 s4-0 (-> self dir) (- (-> self spawn-distance)))
      )
    (project-onto-nav-mesh (-> self nav) gp-0 gp-0)
    (set! (-> gp-0 y) (-> self y-min))
    (set! (-> self spawn-point quad) (-> gp-0 quad))
    )
  (set! (-> self collide-info trans quad) (-> self spawn-point quad))
  (forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*)
  (let ((f0-6 0.0))
    (set! (-> self momentum-speed) f0-6)
    f0-6
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-idle (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self nav-enemy-flags) (nav-enemy-flags navenmf0))
    (none)
    )
  :exit (behavior ()
    (logclear! (-> self draw status) (draw-status hidden))
    (none)
    )
  :trans (behavior ()
    (cond
      ((-> self enable-patrol)
       (if (and (and *target* (>= (-> self enemy-info idle-distance)
                                  (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))
                                  )
                     )
                (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout))
                )
           (go-virtual nav-enemy-patrol)
           )
       )
      ((sharkey-notice-player?)
       (when (zero? (logand (-> self nav-enemy-flags) (nav-enemy-flags navenmf0)))
         (logior! (-> self nav-enemy-flags) (nav-enemy-flags navenmf0))
         (set! (-> self notice-time) (-> *display* base-frame-counter))
         )
       (let ((a0-4 (dummy-16 (-> self nav) (-> *target* control trans))))
         (when (or (and a0-4 (logtest? (-> a0-4 pat) 2))
                   (and (logtest? (-> self draw status) (draw-status hidden))
                        (>= (- (-> *display* base-frame-counter) (-> self notice-time)) (-> self reaction-time))
                        )
                   )
           (sharkey-move-to-attack-position)
           (set! (-> self player-in-water) #t)
           (go-virtual nav-enemy-chase)
           )
         )
       )
      (else
        (if (>= (- (-> *display* base-frame-counter) (-> self notice-time)) (seconds 10))
            (logclear! (-> self nav-enemy-flags) (nav-enemy-flags navenmf0))
            )
        )
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (ja :group! (-> self draw art-group data (-> self nav-info idle-anim)))
    (ja :num-func num-func-identity :frame-num 0.0)
    (until (= (-> self collide-info trans y) (-> self y-min))
      (ja :num! (loop! (-> self anim-speed)))
      (seek! (-> self anim-speed) 1.0 0.05)
      (seek! (-> self collide-info trans y) (-> self y-min) (* (-> self y-speed) (-> *display* seconds-per-frame)))
      (dummy-10 (-> self water))
      (ja-post)
      (suspend)
      )
    (logior! (-> self draw status) (draw-status hidden))
    (anim-loop)
    (none)
    )
  :post (the-as (function none :behavior sharkey) #f)
  )

;; failed to figure out what this is:
(defstate nav-enemy-patrol (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :trans (behavior ()
    (if (sharkey-notice-player?)
        (go-virtual nav-enemy-chase)
        )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (set! (-> self nav target-pos quad) (-> self spawn-point quad))
    (loop
      (ja-no-eval :group! (-> self draw art-group data (-> self nav-info walk-anim))
                  :num! (seek! max (-> self anim-speed))
                  :frame-num 0.0
                  )
      (until (ja-done? 0)
        (seek! (-> self anim-speed) 1.0 0.05)
        (cond
          ((-> self enable-patrol)
           (seek! (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (-> *display* seconds-per-frame)))
           )
          (else
            (if (< (- (-> self collide-info trans y) (-> self y-min)) 409.6)
                (go-virtual nav-enemy-idle)
                )
            )
          )
        (suspend)
        (ja :num! (seek! max (-> self anim-speed)))
        )
      )
    (none)
    )
  :post (behavior ()
    (nav-enemy-travel-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-notice (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (go-virtual nav-enemy-chase)
    (none)
    )
  :code (behavior ()
    (go-virtual nav-enemy-chase)
    (none)
    )
  )

;; definition for function sharkey-follow-trajectory
(defbehavior sharkey-follow-trajectory sharkey ((arg0 float))
  (let ((gp-0 (-> self jump-trajectory)))
    (eval-position! gp-0 arg0 (-> self collide-info trans))
    (eval-velocity! gp-0 arg0 (-> self collide-info transv))
    )
  (vector-normalize-copy! (-> self dir) (-> self collide-info transv) 1.0)
  (forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*)
  )

;; failed to figure out what this is:
(defstate nav-enemy-attack (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :code (behavior ()
    (let ((gp-0 (new 'stack-no-clear 'vector))
          (s5-0 (new 'stack-no-clear 'vector))
          )
      (-> *display* base-frame-counter)
      (sound-play "bigshark-bite")
      (set! (-> self state-time) (-> *display* base-frame-counter))
      (set! (-> gp-0 quad) (-> self collide-info trans quad))
      (ja-channel-push! 1 (seconds 0.1))
      (ja-no-eval :group! sharkey-chomp-ja :num! (seek! (ja-aframe 3.0 0) 2.0) :frame-num 0.0)
      (until (ja-done? 0)
        (sharkey-get-player-position s5-0)
        (setup-from-to-duration! (-> self jump-trajectory) gp-0 s5-0 3.0 -291.27112)
        (set! (-> self attack-time) (ja-aframe-num 0))
        (sharkey-follow-trajectory (-> self attack-time))
        (suspend)
        (ja :num! (seek! (ja-aframe 3.0 0) 2.0))
        )
      )
    (when (send-event *target* 'attack-invinc #f (static-attack-info ((mode 'sharkey))))
      (logclear! (-> self mask) (process-mask enemy))
      (vector-float*! (-> self collide-info transv) (-> self collide-info transv) 8.0)
      (set! (-> self state-time) (-> *display* base-frame-counter))
      (let ((f30-0 -409600.0)
            (f28-0 (-> self collide-info transv y))
            (f26-0 (-> self collide-info trans y))
            )
        (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
          (ja-no-eval :group! sharkey-chomp-ja :num! (seek!) :frame-num (ja-aframe 3.0 0))
          (until (ja-done? 0)
            (+! f28-0 (* f30-0 (-> *display* seconds-per-frame)))
            (+! f26-0 (* f28-0 (-> *display* seconds-per-frame)))
            (set! (-> self collide-info transv y) f28-0)
            (when (< (-> self collide-info trans y) (-> self water height))
              (set! f28-0 (* 0.9 f28-0))
              (vector-float*! (-> self collide-info transv) (-> self collide-info transv) 0.9)
              )
            (vector-normalize-copy! (-> self dir) (-> self collide-info transv) 1.0)
            (forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*)
            (integrate-for-enemy-with-move-to-ground!
              (-> self collide-info)
              (-> self collide-info transv)
              (collide-kind background)
              8192.0
              #t
              #f
              #f
              )
            (set! (-> self collide-info trans y) f26-0)
            (suspend)
            (ja :num! (seek!))
            )
          )
        )
      (send-event *target* 'end-mode)
      (set! (-> self mask) (logior (process-mask enemy) (-> self mask)))
      )
    (sharkey-reset-position)
    (logior! (-> self draw status) (draw-status hidden))
    (go-virtual nav-enemy-idle)
    (none)
    )
  :post (behavior ()
    (nav-enemy-simple-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-chase (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :exit (behavior ()
    (sound-stop (-> self sound-id))
    (none)
    )
  :trans (behavior ()
    (if (not *target*)
        (go-virtual nav-enemy-patrol)
        )
    (let ((gp-0 (-> *target* control trans)))
      (let ((s5-0 (nav-enemy-test-point-near-nav-mesh? (-> *target* control shadow-pos)))
            (s4-0 'racer)
            (a1-0 (new 'stack-no-clear 'event-message-block))
            )
        (set! (-> a1-0 from) self)
        (set! (-> a1-0 num-params) 1)
        (set! (-> a1-0 message) 'query)
        (set! (-> a1-0 param 0) (the-as uint 'mode))
        (if (or (= s4-0 (send-event-function *target* a1-0)) (not s5-0))
            (go-virtual nav-enemy-patrol)
            )
        )
      (when (logtest? (-> *target* control status) (cshape-moving-flags onground))
        (set! (-> self player-in-water) (logtest? (-> *target* control status) (cshape-moving-flags on-water)))
        (if (-> self player-in-water)
            (set! (-> self player-water-time) (-> *display* base-frame-counter))
            )
        )
      (if (and *target* (>= 8192.0 (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))))
          (go-virtual nav-enemy-attack)
          )
      (cond
        ((-> self player-in-water)
         (set! (-> self free-time) (-> *display* base-frame-counter))
         (if (and (< (fabs (- (-> gp-0 y) (-> self collide-info trans y))) 40960.0)
                  (< (vector-vector-xz-distance gp-0 (-> self collide-info trans)) 24576.0)
                  )
             (go-virtual nav-enemy-attack)
             )
         )
        (else
          (if (>= (- (-> *display* base-frame-counter) (-> self free-time)) (seconds 3))
              (go-virtual nav-enemy-patrol)
              )
          )
        )
      )
    (let ((a0-10 (-> self nav target-poly)))
      (if (and a0-10 (logtest? (-> a0-10 pat) 2))
          (set! (-> self target-speed) (* 2.0 (-> self chase-speed)))
          (set! (-> self target-speed) (-> self chase-speed))
          )
      )
    (none)
    )
  :code (behavior ()
    (set! (-> self player-water-time) (-> *display* base-frame-counter))
    (ja-channel-push! 1 (seconds 0.17))
    (sound-play "bigshark-idle")
    (loop
      (ja-no-eval :group! (-> self draw art-group data (-> self nav-info run-anim))
                  :num! (seek! max (-> self anim-speed))
                  :frame-num 0.0
                  )
      (until (ja-done? 0)
        (seek! (-> self anim-speed) 1.0 (* 3.0 (-> *display* seconds-per-frame)))
        (suspend)
        (ja :num! (seek! max (-> self anim-speed)))
        )
      )
    (none)
    )
  :post (behavior ()
    (sharkey-get-player-position (-> self nav target-pos))
    (nav-enemy-travel-post)
    (let* ((f3-0 (vector-vector-distance (-> self collide-info trans) (-> self nav target-pos)))
           (f1-2 (fmax 0.0 (fmin 1.0 (- 1.0 (/ (+ -24576.0 f3-0) (+ -24576.0 (-> self spawn-distance)))))))
           (f0-2 (+ 0.5 (* 1.5 f1-2)))
           )
      (sound-play
        "bigshark-alert"
        :id (-> self sound-id)
        :pitch f0-2
        :position (the-as symbol (-> self collide-info trans))
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-stop-chase (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.17))
    (loop
      (ja-no-eval :group! (-> self draw art-group data (-> self nav-info walk-anim))
                  :num! (seek! max (-> self anim-speed))
                  :frame-num 0.0
                  )
      (until (ja-done? 0)
        (seek! (-> self anim-speed) 1.0 0.05)
        (seek! (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (-> *display* seconds-per-frame)))
        (suspend)
        (ja :num! (seek! max (-> self anim-speed)))
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-stare (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :trans (behavior ()
    (if (TODO-RENAME-46 self (-> self nav-info notice-distance))
        (go-virtual nav-enemy-chase)
        )
    (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout))
        (go-virtual nav-enemy-patrol)
        )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.17))
    (ja :group! (-> self draw art-group data (-> self nav-info idle-anim)))
    (ja :num-func num-func-identity :frame-num 0.0)
    (loop
      (ja :num! (loop! (-> self anim-speed)))
      (seek! (-> self anim-speed) 1.0 0.05)
      (seek! (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (-> *display* seconds-per-frame)))
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-victory (sharkey)
  :virtual #t
  :event (the-as
    (function process int symbol event-message-block object :behavior sharkey)
    nav-enemy-default-event-handler
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (dotimes (gp-0 3)
      (ja-no-eval :group! (-> self draw art-group data (-> self nav-info victory-anim))
                  :num! (seek! max (-> self anim-speed))
                  :frame-num 0.0
                  )
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max (-> self anim-speed)))
        )
      )
    (go-virtual nav-enemy-stare)
    (none)
    )
  )

;; definition for symbol *sharkey-nav-enemy-info*, type nav-enemy-info
(define *sharkey-nav-enemy-info* (new 'static 'nav-enemy-info
                                   :idle-anim 2
                                   :walk-anim 2
                                   :turn-anim -1
                                   :notice-anim 2
                                   :run-anim 2
                                   :jump-anim -1
                                   :jump-land-anim -1
                                   :victory-anim 2
                                   :taunt-anim 2
                                   :die-anim 2
                                   :neck-joint -1
                                   :player-look-at-joint 5
                                   :run-travel-speed (meters 12)
                                   :run-rotate-speed (degrees 1999.9999)
                                   :run-acceleration (meters 6)
                                   :run-turn-time (seconds 0.5)
                                   :walk-travel-speed (meters 6)
                                   :walk-rotate-speed (degrees 1999.9999)
                                   :walk-acceleration (meters 6)
                                   :walk-turn-time (seconds 0.5)
                                   :attack-shove-back (meters 1)
                                   :attack-shove-up (meters 0.5)
                                   :shadow-size (meters 2)
                                   :notice-nav-radius (meters 3)
                                   :nav-nearest-y-threshold (meters 10)
                                   :notice-distance (meters 500)
                                   :stop-chase-distance (meters 510)
                                   :frustration-distance (meters 8)
                                   :frustration-time (seconds 4)
                                   :die-anim-hold-frame 10000000000.0
                                   :jump-land-anim-end-frame 10000000000.0
                                   :jump-height-min (meters 1)
                                   :jump-height-factor 0.5
                                   :jump-start-anim-speed 1.0
                                   :shadow-max-y (meters 1)
                                   :shadow-min-y (meters -1)
                                   :shadow-locus-dist (meters 150)
                                   :use-align #f
                                   :draw-shadow #f
                                   :move-to-ground #f
                                   :hover-if-no-ground #f
                                   :use-momentum #t
                                   :use-flee #f
                                   :use-proximity-notice #f
                                   :use-jump-blocked #f
                                   :use-jump-patrol #f
                                   :gnd-collide-with (collide-kind background)
                                   :debug-draw-neck #f
                                   :debug-draw-jump #f
                                   )
        )

;; definition for method 11 of type sharkey
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defmethod init-from-entity! sharkey ((obj sharkey) (arg0 entity-actor))
  (set! (-> obj scale) (res-lump-float arg0 'scale :default 1.0))
  (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
    (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s4-0 reaction) default-collision-reaction)
    (set! (-> s4-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
      (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core offense) (collide-offense normal-attack))
      (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 (* 6144.0 (-> obj scale)))
      (set-root-prim! s4-0 s3-0)
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj collide-info) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *sharkey-sg* '())
  (TODO-RENAME-45 obj *sharkey-nav-enemy-info*)
  (logclear! (-> obj mask) (process-mask actor-pause))
  (set! (-> obj water) (new 'process 'water-control obj 3 12288.0 8192.0 2048.0))
  (set! (-> obj water flags) (water-flags wt01 wt22 wt23))
  (set! (-> obj water height) (res-lump-float (-> obj entity) 'water-height))
  (set! (-> obj water ripple-size) 20480.0)
  (set! (-> obj spawn-point quad) (-> obj collide-info trans quad))
  (set! (-> obj collide-info nav-radius) 8192.0)
  (set! (-> obj nav nearest-y-threshold) 4096000.0)
  (set! (-> obj y-max) (- (-> obj water height) (* 2048.0 (-> obj scale))))
  (set! (-> obj y-min) (+ -49152.0 (-> obj y-max)))
  (set! (-> obj collide-info trans y) (-> obj y-min))
  (set! (-> obj anim-speed) 1.0)
  (set-vector! (-> obj collide-info scale) (-> obj scale) (-> obj scale) (-> obj scale) 1.0)
  (set! (-> obj reaction-time)
        (the-as time-frame (the int (* 300.0 (res-lump-float (-> obj entity) 'delay :default 1.0))))
        )
  (set! (-> obj spawn-distance) (res-lump-float (-> obj entity) 'distance :default 122880.0))
  (set! (-> obj chase-speed) (res-lump-float (-> obj entity) 'speed :default 49152.0))
  (set! (-> obj y-speed) (-> obj chase-speed))
  (set! (-> obj enable-patrol) #f)
  (set! (-> obj sound-id) (new-sound-id))
  (set! (-> obj enemy-info cam-vert) 49152.0)
  (go (method-of-object obj nav-enemy-idle))
  (none)
  )
