;;-*-Lisp-*-
(in-package goal)
(bundles "FIN.DGO")
(require "levels/snow/snow-ram-boss.gc")

;; DECOMP BEGINS

(deftype green-eco-lurker (nav-enemy)
  ((played-sound? symbol)
   (sound-delay   int32)
   (appear-dest   vector :inline)
   (traj          trajectory :inline))
  (:methods
   (nav-enemy-method-51 (_type_ vector) symbol :replace))
  (:states
   green-eco-lurker-appear
   green-eco-lurker-appear-land
   green-eco-lurker-tune-spheres
   green-eco-lurker-wait-to-appear))


(deftype green-eco-lurker-gen (process-drawable)
  ((num-to-spawn int32)
   (num-spawned  int32)
   (num-alive    int32))
  (:states
   spawn-minions))


(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)

(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)
       :run-acceleration (meters 1)
       :run-turn-time (seconds 0.1)
       :walk-travel-speed (meters 3)
       :walk-rotate-speed (degrees 360)
       :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))

(defpartgroup group-green-eco-lurker-death
  :id 643
  :duration (seconds 2)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 12)
  :parts
  ((sp-item 2585 :fade-after (meters 100) :period (seconds 2) :length (seconds 0.017) :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 (seconds 2) :length (seconds 0.017))
   (sp-item 2587 :fade-after (meters 80) :falloff-to (meters 80) :period (seconds 2) :length (seconds 0.135))
   (sp-item 2588 :period (seconds 2) :length (seconds 0.067))
   (sp-item 2589 :fade-after (meters 120) :falloff-to (meters 120) :period (seconds 2) :length (seconds 0.067))))

(defpart 2587
  :init-specs
  ((:texture (hotdot effects))
   (:num 6.0)
   (:scale-x (meters 0.2) (meters 0.4))
   (:scale-y :copy scale-x)
   (:r 64.0 128.0)
   (:g 0.0 32.0)
   (:b 96.0 64.0)
   (:a 32.0 96.0)
   (:vel-y (meters 0.026666667) (meters 0.10666667))
   (:scalevel-x (meters -0.0016666667))
   (:scalevel-y :copy scalevel-x)
   (:accel-y (meters -0.00016666666) (meters -0.00016666666))
   (:friction 0.9)
   (:timer (seconds 1))
   (:flags (bit2 bit14))
   (:next-time (seconds 0.1) (seconds 0.097))
   (:next-launcher 2590)
   (:conerot-x (degrees 0) (degrees 140))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 2) (meters 4))))

(defpart 2590
  :init-specs ((:fade-r 0.0) (:fade-g 0.0) (:fade-b 0.0) (:fade-a -1.4222223)))

(defpart 2589
  :init-specs
  ((:texture (hotdot effects))
   (:num 3.0)
   (:scale-x (meters 0.2))
   (:rot-z (degrees 0) (degrees 180))
   (:scale-y (meters 8))
   (:r 64.0 192.0)
   (:g 0.0 32.0)
   (:b 128.0 64.0)
   (:a 32.0 64.0)
   (:scalevel-y (meters 0.42666668))
   (:fade-a -1.6)
   (:timer (seconds 0.2))
   (:flags (bit2 bit3 bit14))))

(defpart 2586
  :init-specs
  ((:texture (starflash effects))
   (:num 1.0)
   (:scale-x (meters 16))
   (:scale-y :copy scale-x)
   (:r 64.0 192.0)
   (:g 0.0 32.0)
   (:b 128.0 64.0)
   (:a 96.0)
   (:fade-a -1.7454545)
   (:timer (seconds 0.18))
   (:flags (bit2 bit3 bit14))))

(defpart 2588
  :init-specs
  ((:texture (bigpuff effects))
   (:num 4.0)
   (:scale-x (meters 2.5) (meters 1.5))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 0.0 96.0)
   (:g 0.0 32.0)
   (:b 64.0 32.0)
   (:a 64.0 64.0)
   (:vel-y (meters 0.053333335) (meters 0.013333334))
   (:scalevel-x (meters 0.013333334))
   (:rotvel-z (degrees -0.3) (degrees 0.6))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.42666668)
   (:accel-y (meters 0.00016666666) (meters 0.00016666666))
   (:friction 0.8)
   (:timer (seconds 1.7))
   (:flags (bit2 bit14))
   (:conerot-x (degrees 0) (degrees 110))
   (:conerot-y (degrees 0) (degrees 360))))

(defpart 2585
  :init-specs
  ((:texture (starflash effects))
   (:num 16.0)
   (:y (meters 1))
   (:scale-x (meters 0.1))
   (:scale-y :copy scale-x)
   (:a 0.0)
   (:vel-y (meters 0.053333335) (meters 0.026666667))
   (:accel-y (meters -0.00033333333))
   (:friction 0.94)
   (:timer (seconds 0.8))
   (:flags (bit3))
   (:conerot-x (degrees 0) (degrees 140))
   (:conerot-y (degrees 0) (degrees 360))))

(defpart 2583
  :init-specs
  ((:texture (hotdot effects))
   (:num 1.0)
   (:y (meters 0) (meters 16))
   (:z (meters 0.3) (meters 0.3))
   (:scale-x (meters 0.3) (meters 0.3))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 0.0 96.0)
   (:g 0.0 32.0)
   (:b 64.0 32.0)
   (:a 64.0 64.0)
   (:omega 0.0 65536.0)
   (:vel-x (meters 0.026666667) (meters 0.10666667))
   (:scalevel-x (meters -0.000909091))
   (:rotvel-z (degrees -0.3) 1 (degrees 0.6))
   (:scalevel-y :copy scalevel-x)
   (:fade-g -0.26666668)
   (:fade-a -0.19393939)
   (:timer (seconds 0.3) (seconds 0.497))
   (:flags (bit2 bit3 bit7))))

(defpart 2584
  :init-specs
  ((:texture (hotdot effects))
   (:num 1.0)
   (:scale-x (meters 0.3) (meters 0.1))
   (:scale-y :copy scale-x)
   (:r 32.0 96.0)
   (:g 0.0 32.0)
   (:b 64.0 32.0)
   (:a 32.0 32.0)
   (:scalevel-x (meters -0.0006190476))
   (:scalevel-y :copy scalevel-x)
   (:fade-a -0.01904762)
   (:accel-y (meters -0.000100000005) (meters -0.00015))
   (:timer (seconds 0.1) (seconds 0.997))
   (:flags (bit2 bit3))
   (:next-time (seconds 0.8))
   (:next-launcher 198)))

(defmethod attack-handler ((this 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 (-> this parent)) 'blob-hit-jak))
     #f)
    (else (nav-enemy-set-hit-from-direction arg0) ((method-of-type nav-enemy attack-handler) this arg0 arg1))))

(defmethod nav-enemy-attack-handler ((this 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 (-> this parent)) 'blob-hit-jak))
     #f)
    (else ((method-of-type nav-enemy nav-enemy-attack-handler) this arg0 arg1))))

(defmethod touch-handler ((this green-eco-lurker) (arg0 process) (arg1 event-message-block))
  (when (and (logtest? (-> this nav-enemy-flags) (nav-enemy-flags navenmf6))
             ((method-of-type touching-shapes-entry prims-touching?)
              (the-as touching-shapes-entry (-> arg1 param 0))
              (-> this 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 (-> this parent)) 'blob-hit-jak))))

(defmethod nav-enemy-touch-handler ((this green-eco-lurker) (arg0 process) (arg1 event-message-block))
  (when (and (logtest? (-> this nav-enemy-flags) (nav-enemy-flags navenmf6))
             ((method-of-type touching-shapes-entry prims-touching?)
              (the-as touching-shapes-entry (-> arg1 param 0))
              (-> this 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 (-> this parent)) 'blob-hit-jak))))

(defmethod nav-enemy-method-51 ((this 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) (-> this collide-info root-prim local-sphere w)))
    (if (not (nav-enemy-method-50 this arg0)) (return #t)))
  #f)

(defmethod nav-enemy-method-52 ((this green-eco-lurker) (arg0 vector))
  (let ((s4-0 (-> this 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! (-> this path) arg0 (the float s2-0) 'interp)
          (if (nav-enemy-method-51 this arg0) (return #t))
          (set! s2-0 (mod (+ s2-0 1) s4-0))
          (+! s3-0 -1)))))
  #f)

(defstate green-eco-lurker-tune-spheres (green-eco-lurker)
  :trans
    (behavior ()
      0)
  :code
    (behavior ()
      0)
  :post transform-post)

(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)))
  :exit
    (behavior ()
      (logclear! (-> self draw status) (draw-status hidden))
      (restore-collide-with-as (-> self collide-info)))
  :trans
    (behavior ()
      (if (nav-enemy-method-52 self (-> self appear-dest)) (go green-eco-lurker-appear)))
  :code
    (behavior ()
      (loop
        (logior! (-> self mask) (process-mask sleep-code))
        (suspend))))

(defmethod nav-enemy-method-53 ((this green-eco-lurker))
  (the-as symbol
          (cond
            ((and (-> this draw shadow) (zero? (-> this draw cur-lod)) (logtest? (-> this draw status) (draw-status was-drawn)))
             (let ((f0-0 (-> this appear-dest y))
                   (v1-7 (-> this 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 (-> this draw shadow-ctrl))) (logior! (-> v1-9 settings flags) (shadow-flags disable-draw))) 0))))

(defstate green-eco-lurker-appear (green-eco-lurker)
  :enter
    (behavior ()
      (set-time! (-> self state-time))
      (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))
        (+! (-> gp-0 y) 8192.0)
        (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*)))
  :trans
    (behavior ()
      (let ((f30-0 (fmin (the float (- (current-time) (-> 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?)) (time-elapsed? (-> 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)))
      (nav-enemy-method-53 self)
      0)
  :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)))
  :post transform-post)

(defstate green-eco-lurker-appear-land (green-eco-lurker)
  :event 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))
  :post transform-post)

(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))))))

(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))))))

(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)))

(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)))))

(defmethod initialize-collision ((this green-eco-lurker))
  (let ((s5-0 (new 'process 'collide-shape-moving this (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! (-> this collide-info) s5-0))
  0
  (none))

(defmethod nav-enemy-method-48 ((this green-eco-lurker))
  (initialize-skeleton this *green-eco-lurker-sg* '())
  (set! (-> this draw origin-joint-index) (the-as uint 3))
  (logclear! (-> this collide-info nav-flags) (nav-flags navf0))
  (init-defaults! this *green-eco-lurker-nav-enemy-info*)
  (logior! (-> this draw shadow-ctrl settings flags) (shadow-flags shdf02))
  (set! (-> this neck up) (the-as uint 0))
  (set! (-> this neck nose) (the-as uint 1))
  (set! (-> this neck ear) (the-as uint 2))
  0
  (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))
  (nav-enemy-method-48 self)
  (logclear! (-> self mask) (process-mask actor-pause))
  (go green-eco-lurker-wait-to-appear)
  (none))

(defstate spawn-minions (green-eco-lurker-gen)
  :event
    (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
      (case message
        (('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-time! (-> self state-time))
            (until (time-elapsed? (-> self state-time) (seconds 1))
              (suspend)))
          (let ((gp-0 (new 'stack-no-clear 'vector)))
            (set! (-> gp-0 quad) (-> self root trans quad))
            (+! (-> gp-0 y) -16384.0)
            (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))

(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))
