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

(import "goal_src/jak1/import/green-eco-lurker-ag.gc")

;; definition of type green-eco-lurker
(deftype green-eco-lurker (nav-enemy)
  ((played-sound? symbol             :offset-assert 400)
   (sound-delay   int32              :offset-assert 404)
   (appear-dest   vector     :inline :offset-assert 416)
   (traj          trajectory :inline :offset-assert 432)
   )
  :heap-base #x170
  :method-count-assert 76
  :size-assert         #x1d8
  :flag-assert         #x4c017001d8
  (:methods
    (dummy-51 (_type_ vector) symbol :replace 51)
    )
  (:states
    green-eco-lurker-appear
    green-eco-lurker-appear-land
    green-eco-lurker-tune-spheres
    green-eco-lurker-wait-to-appear
    )
  )

;; definition for method 3 of type green-eco-lurker
(defmethod inspect green-eco-lurker ((obj green-eco-lurker))
  (let ((t9-0 (method-of-type nav-enemy inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tplayed-sound?: ~A~%" (-> obj played-sound?))
  (format #t "~T~Tsound-delay: ~D~%" (-> obj sound-delay))
  (format #t "~T~Tappear-dest: #<vector @ #x~X>~%" (-> obj appear-dest))
  (format #t "~T~Ttraj: #<trajectory @ #x~X>~%" (-> obj traj))
  obj
  )

;; definition of type green-eco-lurker-gen
(deftype green-eco-lurker-gen (process-drawable)
  ((num-to-spawn int32  :offset-assert 176)
   (num-spawned  int32  :offset-assert 180)
   (num-alive    int32  :offset-assert 184)
   )
  :heap-base #x50
  :method-count-assert 20
  :size-assert         #xbc
  :flag-assert         #x14005000bc
  (:states
    spawn-minions
    )
  )

;; definition for method 3 of type green-eco-lurker-gen
(defmethod inspect green-eco-lurker-gen ((obj green-eco-lurker-gen))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tnum-to-spawn: ~D~%" (-> obj num-to-spawn))
  (format #t "~T~Tnum-spawned: ~D~%" (-> obj num-spawned))
  (format #t "~T~Tnum-alive: ~D~%" (-> obj num-alive))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *green-eco-lurker-sg* green-eco-lurker green-eco-lurker-lod0-jg -1
              ((green-eco-lurker-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 5.95)
              :shadow green-eco-lurker-shadow-mg
              )

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

;; failed to figure out what this is:
(defpartgroup group-green-eco-lurker-death
  :id 643
  :duration 600
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 12)
  :parts ((sp-item 2585 :fade-after (meters 100) :period 600 :length 5 :binding 2583)
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2583 :flags (start-dead launch-asap) :binding 2584)
    (sp-item 2584 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2586 :period 600 :length 5)
    (sp-item 2587 :fade-after (meters 80) :falloff-to (meters 80) :period 600 :length 40)
    (sp-item 2588 :period 600 :length 20)
    (sp-item 2589 :fade-after (meters 120) :falloff-to (meters 120) :period 600 :length 20)
    )
  )

;; failed to figure out what this is:
(defpart 2587
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 6.0)
    (sp-rnd-flt spt-scale-x (meters 0.2) (meters 0.4) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 64.0 128.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 96.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 96.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.026666667) (meters 0.10666667) 1.0)
    (sp-flt spt-scalevel-x (meters -0.0016666667))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-rnd-flt spt-accel-y -0.68266666 -0.68266666 1.0)
    (sp-flt spt-friction 0.9)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit14)
    (sp-int-plain-rnd spt-next-time 30 29 1)
    (sp-launcher-by-id spt-next-launcher 2590)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 140.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 2) (meters 4) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2590
  :init-specs ((sp-flt spt-fade-r 0.0) (sp-flt spt-fade-g 0.0) (sp-flt spt-fade-b 0.0) (sp-flt spt-fade-a -1.4222223))
  )

;; failed to figure out what this is:
(defpart 2589
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 3.0)
    (sp-flt spt-scale-x (meters 0.2))
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 180.0) 1.0)
    (sp-flt spt-scale-y (meters 8))
    (sp-rnd-flt spt-r 64.0 192.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 128.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 64.0 1.0)
    (sp-flt spt-scalevel-y (meters 0.42666668))
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 60)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2586
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 16))
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 64.0 192.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 128.0 64.0 1.0)
    (sp-flt spt-a 96.0)
    (sp-flt spt-fade-a -1.7454545)
    (sp-int spt-timer 54)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2588
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 4.0)
    (sp-rnd-flt spt-scale-x (meters 2.5) (meters 1.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 96.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 64.0 32.0 1.0)
    (sp-rnd-flt spt-a 64.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.053333335) (meters 0.013333334) 1.0)
    (sp-flt spt-scalevel-x (meters 0.013333334))
    (sp-rnd-flt spt-rotvel-z (degrees -0.3) (degrees 0.6) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.42666668)
    (sp-rnd-flt spt-accel-y 0.68266666 0.68266666 1.0)
    (sp-flt spt-friction 0.8)
    (sp-int spt-timer 510)
    (sp-cpuinfo-flags bit2 bit14)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 110.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2585
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 16.0)
    (sp-flt spt-y (meters 1))
    (sp-flt spt-scale-x (meters 0.1))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-y (meters 0.053333335) (meters 0.026666667) 1.0)
    (sp-flt spt-accel-y -1.3653333)
    (sp-flt spt-friction 0.94)
    (sp-int spt-timer 240)
    (sp-cpuinfo-flags bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 140.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2583
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-y (meters 0) (meters 16) 1.0)
    (sp-rnd-flt spt-z (meters 0.3) (meters 0.3) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.3) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 96.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 64.0 32.0 1.0)
    (sp-rnd-flt spt-a 64.0 64.0 1.0)
    (sp-rnd-flt spt-omega 0.0 65536.0 1.0)
    (sp-rnd-flt spt-vel-x (meters 0.026666667) (meters 0.10666667) 1.0)
    (sp-flt spt-scalevel-x (meters -0.000909091))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-g -0.26666668)
    (sp-flt spt-fade-a -0.19393939)
    (sp-int-plain-rnd spt-timer 90 149 1)
    (sp-cpuinfo-flags bit2 bit3 bit7)
    )
  )

;; failed to figure out what this is:
(defpart 2584
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.1) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 32.0 96.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 64.0 32.0 1.0)
    (sp-rnd-flt spt-a 32.0 32.0 1.0)
    (sp-flt spt-scalevel-x (meters -0.0006190476))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.01904762)
    (sp-rnd-flt spt-accel-y -0.40960002 -0.6144 1.0)
    (sp-int-plain-rnd spt-timer 30 299 1)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 240)
    (sp-launcher-by-id spt-next-launcher 198)
    )
  )

;; definition for method 43 of type green-eco-lurker
(defmethod dummy-43 green-eco-lurker ((obj green-eco-lurker) (arg0 process) (arg1 event-message-block))
  (cond
    ((= (-> arg0 type) target)
     (if (nav-enemy-send-attack arg0 (the-as touching-shapes-entry (-> arg1 param 0)) 'generic)
         (send-event (ppointer->process (-> obj parent)) 'blob-hit-jak)
         )
     #f
     )
    (else
      (nav-enemy-set-hit-from-direction arg0)
      ((method-of-type nav-enemy dummy-43) obj arg0 arg1)
      )
    )
  )

;; definition for method 73 of type green-eco-lurker
(defmethod nav-enemy-attack-handler green-eco-lurker ((obj green-eco-lurker) (arg0 process) (arg1 event-message-block))
  (cond
    ((= (-> arg0 type) target)
     (if (nav-enemy-send-attack arg0 (the-as touching-shapes-entry (-> arg1 param 0)) 'generic)
         (send-event (ppointer->process (-> obj parent)) 'blob-hit-jak)
         )
     #f
     )
    (else
      ((method-of-type nav-enemy nav-enemy-attack-handler) obj arg0 arg1)
      )
    )
  )

;; definition for method 44 of type green-eco-lurker
(defmethod dummy-44 green-eco-lurker ((obj green-eco-lurker) (arg0 process) (arg1 event-message-block))
  (when (and (logtest? (-> obj nav-enemy-flags) (nav-enemy-flags navenmf6))
             ((method-of-type touching-shapes-entry prims-touching?)
              (the-as touching-shapes-entry (-> arg1 param 0))
              (-> obj collide-info)
              (the-as uint 1)
              )
             )
    (if (nav-enemy-send-attack arg0 (the-as touching-shapes-entry (-> arg1 param 0)) 'generic)
        (send-event (ppointer->process (-> obj parent)) 'blob-hit-jak)
        )
    )
  )

;; definition for method 72 of type green-eco-lurker
(defmethod nav-enemy-touch-handler green-eco-lurker ((obj green-eco-lurker) (arg0 process) (arg1 event-message-block))
  (when (and (logtest? (-> obj nav-enemy-flags) (nav-enemy-flags navenmf6))
             ((method-of-type touching-shapes-entry prims-touching?)
              (the-as touching-shapes-entry (-> arg1 param 0))
              (-> obj collide-info)
              (the-as uint 1)
              )
             )
    (if (nav-enemy-send-attack arg0 (the-as touching-shapes-entry (-> arg1 param 0)) 'generic)
        (send-event (ppointer->process (-> obj parent)) 'blob-hit-jak)
        )
    )
  )

;; definition for method 51 of type green-eco-lurker
;; INFO: Used lq/sq
(defmethod dummy-51 green-eco-lurker ((obj green-eco-lurker) (arg0 vector))
  (when (or (not *target*) (>= (vector-vector-xz-distance arg0 (target-pos 0)) 36864.0))
    (let ((v1-3 (new 'stack-no-clear 'vector)))
      (set! (-> v1-3 quad) (-> arg0 quad))
      (set! (-> v1-3 w) (-> obj collide-info root-prim local-sphere w))
      )
    (if (not (TODO-RENAME-50 obj arg0))
        (return #t)
        )
    )
  #f
  )

;; definition for method 52 of type green-eco-lurker
(defmethod dummy-52 green-eco-lurker ((obj green-eco-lurker) (arg0 vector))
  (let ((s4-0 (-> obj path curve num-cverts)))
    (when (> s4-0 0)
      (let ((s2-0 (nav-enemy-rnd-int-count s4-0))
            (s3-0 s4-0)
            )
        (while (> s3-0 0)
          (eval-path-curve-div! (-> obj path) arg0 (the float s2-0) 'interp)
          (if (dummy-51 obj arg0)
              (return #t)
              )
          (set! s2-0 (mod (+ s2-0 1) s4-0))
          (+! s3-0 -1)
          )
        )
      )
    )
  #f
  )

;; failed to figure out what this is:
(defstate green-eco-lurker-tune-spheres (green-eco-lurker)
  :trans (behavior ()
    0
    (none)
    )
  :code (behavior ()
    0
    (none)
    )
  :post (the-as (function none :behavior green-eco-lurker) transform-post)
  )

;; failed to figure out what this is:
(defstate green-eco-lurker-wait-to-appear (green-eco-lurker)
  :enter (behavior ()
    (logior! (-> self draw status) (draw-status hidden))
    (clear-collide-with-as (-> self collide-info))
    (none)
    )
  :exit (behavior ()
    (logclear! (-> self draw status) (draw-status hidden))
    (restore-collide-with-as (-> self collide-info))
    (none)
    )
  :trans (behavior ()
    (if (dummy-52 self (-> self appear-dest))
        (go green-eco-lurker-appear)
        )
    (none)
    )
  :code (behavior ()
    (loop
      (logior! (-> self mask) (process-mask sleep-code))
      (suspend)
      )
    (none)
    )
  )

;; definition for method 53 of type green-eco-lurker
;; INFO: Return type mismatch int vs symbol.
(defmethod dummy-53 green-eco-lurker ((obj green-eco-lurker))
  (the-as symbol (cond
                   ((and (-> obj draw shadow)
                         (zero? (-> obj draw cur-lod))
                         (logtest? (-> obj draw status) (draw-status was-drawn))
                         )
                    (let ((f0-0 (-> obj appear-dest y))
                          (v1-7 (-> obj draw shadow-ctrl))
                          )
                      (let ((a0-1 v1-7))
                        (logclear! (-> a0-1 settings flags) (shadow-flags disable-draw))
                        )
                      0
                      (let ((a0-3 v1-7))
                        (set! (-> a0-3 settings bot-plane w) (- (+ -6144.0 f0-0)))
                        )
                      0
                      (set! (-> v1-7 settings top-plane w) (- (+ 6144.0 f0-0)))
                      )
                    0
                    )
                   (else
                     (let ((v1-9 (-> obj draw shadow-ctrl)))
                       (logior! (-> v1-9 settings flags) (shadow-flags disable-draw))
                       )
                     0
                     )
                   )
          )
  )

;; failed to figure out what this is:
(defstate green-eco-lurker-appear (green-eco-lurker)
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self played-sound?) #f)
    (set! (-> self sound-delay) (nav-enemy-rnd-int-range 30 150))
    (let ((f0-1 (- (-> self appear-dest x) (-> (the-as green-eco-lurker-gen (-> self parent 0)) root trans x))))
      (set! (-> self collide-info trans x)
            (+ (-> (the-as green-eco-lurker-gen (-> self parent 0)) root trans x) (fmax -32768.0 (fmin 32768.0 f0-1)))
            )
      )
    (logior! (-> self collide-info nav-flags) (nav-flags navf1))
    (set! (-> self nav extra-nav-sphere quad) (-> self appear-dest quad))
    (set! (-> self nav extra-nav-sphere w) 8192.0)
    (setup-from-to-duration! (-> self traj) (-> self collide-info trans) (-> self appear-dest) 225.0 -9.102222)
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (set! (-> gp-0 quad) (-> self collide-info trans quad))
      (set! (-> gp-0 y) (+ 8192.0 (-> gp-0 y)))
      (process-spawn
        part-tracker
        :init part-tracker-init
        (-> *part-group-id-table* 643)
        -1
        #f
        #f
        #f
        gp-0
        :to *entity-pool*
        )
      )
    (let ((gp-1 (new 'stack-no-clear 'vector)))
      (vector-! gp-1 (-> self appear-dest) (-> self collide-info trans))
      (set! (-> gp-1 y) 0.0)
      (vector-normalize! gp-1 1.0)
      (forward-up->quaternion (-> self collide-info quat) gp-1 *up-vector*)
      )
    (none)
    )
  :trans (behavior ()
    (let ((f30-0 (fmin (the float (- (-> *display* base-frame-counter) (-> self state-time))) (-> self traj time))))
      (eval-position! (-> self traj) f30-0 (-> self collide-info trans))
      (when (= f30-0 (-> self traj time))
        (logior! (-> self collide-info nav-flags) (nav-flags navf0))
        (logclear! (-> self collide-info nav-flags) (nav-flags navf1))
        (go green-eco-lurker-appear-land)
        )
      )
    (when (and (not (-> self played-sound?))
               (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self sound-delay))
               )
      (set! (-> self played-sound?) #t)
      (sound-play "blob-jump" :pitch (nav-enemy-rnd-float-range -0.5 0.5))
      )
    (dummy-53 self)
    0
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.2))
    (sound-play "blob-out" :pitch (nav-enemy-rnd-float-range -1.0 1.0))
    (cond
      ((zero? (nav-enemy-rnd-int-count 2))
       (ja-no-eval :group! green-eco-lurker-jump-with-flip-ja :num! (seek!) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       )
      (else
        (ja-no-eval :group! green-eco-lurker-jump-ja :num! (seek!) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek!))
          )
        )
      )
    (loop
      (logior! (-> self mask) (process-mask sleep-code))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior green-eco-lurker) transform-post)
  )

;; failed to figure out what this is:
(defstate green-eco-lurker-appear-land (green-eco-lurker)
  :event (the-as
    (function process int symbol event-message-block object :behavior green-eco-lurker)
    nav-enemy-default-event-handler
    )
  :code (behavior ()
    (activate! *camera-smush-control* 409.6 37 150 1.0 0.99)
    (sound-play "blob-land" :pitch (nav-enemy-rnd-float-range -1.0 1.0))
    (let ((v1-4 (-> self draw shadow-ctrl)))
      (let ((a0-4 v1-4))
        (set! (-> a0-4 settings bot-plane w) (- -7168.0))
        )
      0
      (let ((a0-6 v1-4))
        (set! (-> a0-6 settings top-plane w) (- 2048.0))
        )
      0
      (logclear! (-> v1-4 settings flags) (shadow-flags shdf03))
      (logclear! (-> v1-4 settings flags) (shadow-flags shdf02))
      (logclear! (-> v1-4 settings flags) (shadow-flags disable-draw))
      )
    0
    (ja-channel-push! 1 (seconds 0.2))
    (ja-no-eval :group! green-eco-lurker-jump-land-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (logior! (-> self nav-enemy-flags) (nav-enemy-flags navenmf1))
    (go-virtual nav-enemy-chase)
    (none)
    )
  :post (the-as (function none :behavior green-eco-lurker) transform-post)
  )

;; failed to figure out what this is:
(defstate nav-enemy-patrol (green-eco-lurker)
  :virtual #t
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.2))
    (let ((t9-1 (-> (method-of-type nav-enemy nav-enemy-patrol) code)))
      (if t9-1
          ((the-as (function none) t9-1))
          )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-chase (green-eco-lurker)
  :virtual #t
  :code (behavior ()
    (let ((f30-0 (nav-enemy-rnd-float-range 0.9 1.1)))
      (cond
        ((ja-group? green-eco-lurker-jump-land-ja)
         (ja-no-eval :num! (seek!))
         (ja-channel-push! 1 (seconds 0.2))
         (ja-no-eval :group! (-> self draw art-group data (-> self nav-info run-anim))
                     :num! (seek! max f30-0)
                     :frame-num 0.0
                     )
         (until (ja-done? 0)
           (ja-blend-eval)
           (suspend)
           (ja :num! (seek! max f30-0))
           )
         )
        (else
          (ja-channel-push! 1 (seconds 0.2))
          (ja :group! (-> self draw art-group data (-> self nav-info run-anim)))
          (ja :num-func num-func-identity :frame-num 0.0)
          )
        )
      (loop
        (suspend)
        (ja :num! (loop! f30-0))
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-jump-land (green-eco-lurker)
  :virtual #t
  :code (behavior ()
    (ja-no-eval :num! (seek!))
    (ja-channel-push! 1 (seconds 0.075))
    (ja-no-eval :group! (-> self draw art-group data (-> self nav-info jump-land-anim))
                :num! (seek! (ja-aframe 32.0 0) 0.5)
                :frame-num 0.0
                )
    (until (ja-done? 0)
      (ja-blend-eval)
      (suspend)
      (ja :num! (seek! (ja-aframe 32.0 0) 0.5))
      )
    (go-virtual nav-enemy-chase)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate nav-enemy-die (green-eco-lurker)
  :virtual #t
  :enter (behavior ()
    (send-event (ppointer->process (-> self parent)) 'blob-died)
    (process-spawn
      part-tracker
      :init part-tracker-init
      (-> *part-group-id-table* 643)
      -1
      #f
      #f
      #f
      (-> self collide-info trans)
      :to *entity-pool*
      )
    (sound-play "blob-explode")
    (activate! *camera-smush-control* 409.6 37 150 1.0 0.99)
    (let ((v1-14 (-> self draw shadow-ctrl)))
      (logior! (-> v1-14 settings flags) (shadow-flags disable-draw))
      )
    0
    (let ((t9-7 (-> (method-of-type nav-enemy nav-enemy-die) enter)))
      (if t9-7
          (t9-7)
          )
      )
    (none)
    )
  )

;; definition for method 47 of type green-eco-lurker
;; INFO: Return type mismatch int vs none.
(defmethod initialize-collision green-eco-lurker ((obj green-eco-lurker))
  (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) default-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 7) 0)))
      (set! (-> s4-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 transform-index) 4)
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 -4096.0 20480.0)
      (set-root-prim! s5-0 s4-0)
      (let ((s3-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
        (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-0 collide-with) (collide-kind target))
        (set! (-> s3-0 prim-core action) (collide-action solid))
        (set! (-> s3-0 prim-core offense) (collide-offense touch))
        (set-vector! (-> s3-0 local-sphere) 0.0 2785.28 0.0 3276.8)
        (append-prim s4-0 s3-0)
        )
      (let ((s3-1 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
        (set! (-> s3-1 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-1 collide-with) (collide-kind target))
        (set! (-> s3-1 prim-core action) (collide-action solid))
        (set! (-> s3-1 prim-core offense) (collide-offense touch))
        (set-vector! (-> s3-1 local-sphere) 0.0 6615.04 0.0 3276.8)
        (append-prim s4-0 s3-1)
        )
      (let ((s3-2 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
        (set! (-> s3-2 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-2 collide-with) (collide-kind target))
        (set! (-> s3-2 prim-core action) (collide-action solid))
        (set! (-> s3-2 prim-core offense) (collide-offense touch))
        (set-vector! (-> s3-2 local-sphere) 0.0 10444.8 0.0 3276.8)
        (append-prim s4-0 s3-2)
        )
      (let ((s3-3 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
        (set! (-> s3-3 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-3 collide-with) (collide-kind target))
        (set! (-> s3-3 prim-core offense) (collide-offense normal-attack))
        (set! (-> s3-3 transform-index) 6)
        (set-vector! (-> s3-3 local-sphere) 0.0 0.0 0.0 3276.8)
        (append-prim s4-0 s3-3)
        )
      (let ((s3-4 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
        (set! (-> s3-4 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-4 collide-with) (collide-kind target))
        (set! (-> s3-4 prim-core offense) (collide-offense normal-attack))
        (set! (-> s3-4 transform-index) 4)
        (set-vector! (-> s3-4 local-sphere) 0.0 -3276.8 -2048.0 5734.4)
        (append-prim s4-0 s3-4)
        )
      (let ((s3-5 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
        (set! (-> s3-5 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-5 collide-with) (collide-kind target))
        (set! (-> s3-5 prim-core offense) (collide-offense normal-attack))
        (set! (-> s3-5 transform-index) 12)
        (set-vector! (-> s3-5 local-sphere) 0.0 0.0 0.0 2457.6)
        (append-prim s4-0 s3-5)
        )
      (let ((s3-6 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
        (set! (-> s3-6 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-6 collide-with) (collide-kind target))
        (set! (-> s3-6 prim-core offense) (collide-offense normal-attack))
        (set! (-> s3-6 transform-index) 16)
        (set-vector! (-> s3-6 local-sphere) 0.0 0.0 0.0 2457.6)
        (append-prim s4-0 s3-6)
        )
      )
    (set! (-> s5-0 nav-radius) 8192.0)
    (backup-collide-with-as s5-0)
    (set! (-> s5-0 max-iteration-count) (the-as uint 2))
    (set! (-> obj collide-info) s5-0)
    )
  0
  (none)
  )

;; definition for method 48 of type green-eco-lurker
;; INFO: Return type mismatch int vs none.
(defmethod TODO-RENAME-48 green-eco-lurker ((obj green-eco-lurker))
  (initialize-skeleton obj *green-eco-lurker-sg* '())
  (set! (-> obj draw origin-joint-index) (the-as uint 3))
  (logclear! (-> obj collide-info nav-flags) (nav-flags navf0))
  (TODO-RENAME-45 obj *green-eco-lurker-nav-enemy-info*)
  (logior! (-> obj draw shadow-ctrl settings flags) (shadow-flags shdf02))
  (set! (-> obj neck up) (the-as uint 0))
  (set! (-> obj neck nose) (the-as uint 1))
  (set! (-> obj neck ear) (the-as uint 2))
  0
  (none)
  )

;; definition for function green-eco-lurker-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior green-eco-lurker-init-by-other green-eco-lurker ((arg0 entity-actor) (arg1 green-eco-lurker-gen) (arg2 vector))
  (initialize-collision self)
  (set! (-> self collide-info trans quad) (-> arg2 quad))
  (vector-identity! (-> self collide-info scale))
  (quaternion-identity! (-> self collide-info quat))
  (set! (-> self entity) (-> arg1 entity))
  (TODO-RENAME-48 self)
  (logclear! (-> self mask) (process-mask actor-pause))
  (go green-eco-lurker-wait-to-appear)
  (none)
  )

;; failed to figure out what this is:
(defstate spawn-minions (green-eco-lurker-gen)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('blob-died)
       (set! (-> self num-alive) (max 0 (+ (-> self num-alive) -1)))
       (send-event (ppointer->process (-> self parent)) 'blob-died)
       )
      (('blob-hit-jak)
       (send-event (ppointer->process (-> self parent)) 'blob-hit-jak)
       )
      )
    )
  :code (behavior ()
    (while (< (-> self num-spawned) (-> self num-to-spawn))
      (when (< (-> self num-alive) 3)
        (when (nonzero? (-> self num-spawned))
          (set! (-> self state-time) (-> *display* base-frame-counter))
          (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1))
            (suspend)
            )
          )
        (let ((gp-0 (new 'stack-no-clear 'vector)))
          (set! (-> gp-0 quad) (-> self root trans quad))
          (set! (-> gp-0 y) (+ -16384.0 (-> gp-0 y)))
          (process-spawn green-eco-lurker (-> self entity) self gp-0 :to self)
          )
        (+! (-> self num-spawned) 1)
        (+! (-> self num-alive) 1)
        )
      (suspend)
      )
    (while (> (-> self num-alive) 0)
      (suspend)
      )
    (send-event (ppointer->process (-> self parent)) 'trigger)
    (until (not (-> self child))
      (suspend)
      )
    (suspend)
    0
    (none)
    )
  )

;; definition for function green-eco-lurker-gen-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior green-eco-lurker-gen-init-by-other green-eco-lurker-gen ((arg0 entity-actor) (arg1 vector) (arg2 int))
  (set! (-> self num-to-spawn) arg2)
  (set! (-> self num-spawned) 0)
  (set! (-> self num-alive) 0)
  (set! (-> self entity) arg0)
  (set! (-> self root) (new 'process 'trsqv))
  (set! (-> self root trans quad) (-> arg1 quad))
  (vector-identity! (-> self root scale))
  (quaternion-identity! (-> self root quat))
  (logclear! (-> self mask) (process-mask actor-pause))
  (go spawn-minions)
  (none)
  )
