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

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

;; definition of type lurkerworm
(deftype lurkerworm (process-drawable)
  ((root-override collide-shape-moving      :offset        112)
   (twister       twister                   :offset-assert 176)
   (head-tilt     float                     :offset-assert 180)
   (strike-count  int32                     :offset-assert 184)
   (angle         float                     :offset-assert 188)
   (vulnerable    symbol                    :offset-assert 192)
   (part2         sparticle-launch-control  :offset-assert 196)
   )
  :heap-base #x60
  :method-count-assert 22
  :size-assert         #xc8
  :flag-assert         #x16006000c8
  (:methods
    (TODO-RENAME-20 (_type_) none 20)
    (particle-effect (_type_) none 21)
    )
  (:states
    lurkerworm-die
    lurkerworm-idle
    lurkerworm-rest
    lurkerworm-rise
    lurkerworm-sink
    lurkerworm-spot
    lurkerworm-strike
    )
  )

;; definition for method 3 of type lurkerworm
(defmethod inspect lurkerworm ((obj lurkerworm))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Ttwister: ~A~%" (-> obj twister))
  (format #t "~T~Thead-tilt: ~f~%" (-> obj head-tilt))
  (format #t "~T~Tstrike-count: ~D~%" (-> obj strike-count))
  (format #t "~T~Tangle: ~f~%" (-> obj angle))
  (format #t "~T~Tvulnerable: ~A~%" (-> obj vulnerable))
  (format #t "~T~Tpart2: ~A~%" (-> obj part2))
  obj
  )

;; definition for method 7 of type lurkerworm
;; INFO: Return type mismatch process-drawable vs lurkerworm.
(defmethod relocate lurkerworm ((obj lurkerworm) (arg0 int))
  (if (nonzero? (-> obj part2))
      (&+! (-> obj part2) arg0)
      )
  (if (nonzero? (-> obj twister))
      (&+! (-> obj twister) arg0)
      )
  (the-as lurkerworm ((method-of-type process-drawable relocate) obj arg0))
  )

;; definition for method 10 of type lurkerworm
(defmethod deactivate lurkerworm ((obj lurkerworm))
  (if (nonzero? (-> obj part2))
      (kill-and-free-particles (-> obj part2))
      )
  ((method-of-type process-drawable deactivate) obj)
  (none)
  )

;; failed to figure out what this is:
(defskelgroup *lurkerworm-sg* lurkerworm lurkerworm-lod0-jg lurkerworm-idle-ja
              ((lurkerworm-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 2 0 6.5)
              :longest-edge (meters 1.5)
              )

;; failed to figure out what this is:
(defpartgroup group-beach-sandworm
  :id 157
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 656 :fade-after (meters 90) :period 900 :length 300)
    (sp-item 657 :fade-after (meters 100) :period 900 :length 390)
    (sp-item 658 :fade-after (meters 150) :period 900 :length 420 :offset 120)
    (sp-item 659 :fade-after (meters 60) :period 900 :length 420 :offset 120)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-beach-sandworm-norocks
  :id 158
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 656 :fade-after (meters 90) :period 900 :length 300)
    (sp-item 658 :fade-after (meters 150) :period 900 :length 420 :offset 120)
    (sp-item 659 :fade-after (meters 60) :period 900 :length 420 :offset 120)
    )
  )

;; failed to figure out what this is:
(defpart 656
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x19 :page #x2))
    (sp-flt spt-num 4.0)
    (sp-rnd-flt spt-x (meters 3) (meters 5) 1.0)
    (sp-flt spt-y (meters 1))
    (sp-rnd-flt spt-scale-x (meters 1) (meters 2) 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 130.0 20.0 1.0)
    (sp-rnd-flt spt-g 90.0 20.0 1.0)
    (sp-rnd-flt spt-b 50.0 8.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-vel-x (meters -0.02))
    (sp-flt spt-vel-y (meters -0.0033333334))
    (sp-rnd-flt spt-rotvel-z (degrees -0.15) (degrees 0.3) 1.0)
    (sp-flt spt-fade-a 0.21333334)
    (sp-int spt-timer 900)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-int-plain-rnd spt-next-time 90 59 1)
    (sp-launcher-by-id spt-next-launcher 660)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 660
  :init-specs ((sp-flt spt-fade-a -0.21333334))
  )

;; failed to figure out what this is:
(defpart 658
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x19 :page #x2))
    (sp-flt spt-num 0.4)
    (sp-rnd-flt spt-x (meters 0) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 2) (meters 1) 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 90.0 60.0 1.0)
    (sp-rnd-flt spt-g 90.0 10.0 1.0)
    (sp-rnd-flt spt-b 50.0 8.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-x (meters 0.0033333334) (meters 0.0033333334) 1.0)
    (sp-flt spt-vel-y (meters 0.026666667))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-flt spt-fade-a 0.32)
    (sp-flt spt-accel-y -4.096)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 659
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x19 :page #x2))
    (sp-flt spt-num 0.6)
    (sp-rnd-flt spt-x (meters 0) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1) (meters 1) 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 45.0 30.0 1.0)
    (sp-rnd-flt spt-g 45.0 5.0 1.0)
    (sp-rnd-flt spt-b 25.0 4.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-x (meters 0.0033333334) (meters 0.0033333334) 1.0)
    (sp-flt spt-vel-y (meters 0.026666667))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-flt spt-fade-a 0.42666668)
    (sp-flt spt-accel-y -4.096)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 657
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2))
    (sp-flt spt-num 0.5)
    (sp-rnd-flt spt-x (meters 0) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.05) (meters 0.4) 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 75.0 45.0 1.0)
    (sp-rnd-flt spt-g 75.0 10.0 1.0)
    (sp-rnd-flt spt-b 40.0 6.0 1.0)
    (sp-flt spt-a 96.0)
    (sp-rnd-flt spt-vel-x (meters 0.0033333334) (meters 0.0033333334) 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.013333334) (meters 0.026666667) 1.0)
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-flt spt-accel-y -4.096)
    (sp-int spt-timer 450)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 661
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x19 :page #x2))
    (sp-flt spt-num 0.1)
    (sp-rnd-flt spt-x (meters -0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-z (meters -0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 2) (meters 1) 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 90.0 60.0 1.0)
    (sp-rnd-flt spt-g 90.0 10.0 1.0)
    (sp-rnd-flt spt-b 50.0 8.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-x (meters 0.0033333334) (meters 0.00083333335) 1.0)
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-flt spt-fade-a 0.21333334)
    (sp-flt spt-accel-y -0.54613334)
    (sp-int spt-timer 600)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-int spt-next-time 150)
    (sp-launcher-by-id spt-next-launcher 662)
    )
  )

;; failed to figure out what this is:
(defpart 662
  :init-specs ((sp-flt spt-fade-a -0.10666667))
  )

;; definition for method 20 of type lurkerworm
;; INFO: Return type mismatch int vs none.
(defmethod TODO-RENAME-20 lurkerworm ((obj lurkerworm))
  (let ((s5-0 (new 'stack-no-clear 'vector)))
    (vector-! s5-0 (target-pos 0) (-> obj root-override trans))
    (set-target! (-> obj twister) (atan (-> s5-0 x) (-> s5-0 z)))
    (TODO-RENAME-11 (-> obj twister))
    (let* ((f0-5 (sqrtf (+ (* (-> s5-0 x) (-> s5-0 x)) (* (-> s5-0 z) (-> s5-0 z)))))
           (f0-6 (atan (-> s5-0 y) f0-5))
           )
      (seek! (-> obj head-tilt) f0-6 (* 5461.3335 (-> *display* seconds-per-frame)))
      )
    )
  (set! (-> obj head-tilt) (fmin 8192.0 (fmax -5461.3335 (-> obj head-tilt))))
  0
  (none)
  )

;; definition for function lurkerworm-prebind-function
;; INFO: Return type mismatch int vs none.
(defbehavior lurkerworm-prebind-function lurkerworm ((arg0 pointer) (arg1 int) (arg2 lurkerworm))
  (let ((v1-0 arg2)
        (s5-0 (new 'stack-no-clear 'quaternion))
        (gp-0 (&+ arg0 432))
        )
    (quaternion-axis-angle! s5-0 -1.0 0.0 0.0 (-> v1-0 head-tilt))
    (quaternion*! (the-as quaternion gp-0) (the-as quaternion gp-0) s5-0)
    )
  0
  (none)
  )

;; definition for function lurkerworm-joint-callback
;; INFO: Return type mismatch int vs none.
(defun lurkerworm-joint-callback ((arg0 lurkerworm))
  (let ((a1-0 arg0))
    (TODO-RENAME-12 (-> a1-0 twister) a1-0)
    )
  0
  (none)
  )

;; definition for method 21 of type lurkerworm
;; INFO: Return type mismatch int vs none.
(defmethod particle-effect lurkerworm ((obj lurkerworm))
  (let ((a2-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 5))))
    (sp-launch-particles-var
      *sp-particle-system-2d*
      (-> *part-id-table* 661)
      a2-0
      (the-as sparticle-launch-state #f)
      (the-as sparticle-launch-control #f)
      1.0
      )
    )
  (let ((a2-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 6))))
    (sp-launch-particles-var
      *sp-particle-system-2d*
      (-> *part-id-table* 661)
      a2-1
      (the-as sparticle-launch-state #f)
      (the-as sparticle-launch-control #f)
      1.0
      )
    )
  (let ((a2-2 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 7))))
    (sp-launch-particles-var
      *sp-particle-system-2d*
      (-> *part-id-table* 661)
      a2-2
      (the-as sparticle-launch-state #f)
      (the-as sparticle-launch-control #f)
      1.0
      )
    )
  (let ((a2-3 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 8))))
    (sp-launch-particles-var
      *sp-particle-system-2d*
      (-> *part-id-table* 661)
      a2-3
      (the-as sparticle-launch-state #f)
      (the-as sparticle-launch-control #f)
      1.0
      )
    )
  0
  (none)
  )

;; definition for function lurkerworm-default-event-handler
(defbehavior lurkerworm-default-event-handler lurkerworm ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('attack)
     (-> arg3 param 1)
     (go lurkerworm-die)
     )
    (('touch)
     (if ((method-of-type touching-shapes-entry prims-touching?)
          (the-as touching-shapes-entry (-> arg3 param 0))
          (-> self root-override)
          (the-as uint 1)
          )
         (send-event arg0 'attack (-> arg3 param 0) (new 'static 'attack-info))
         )
     )
    )
  )

;; definition for function lurkerworm-default-post-behavior
;; INFO: Return type mismatch int vs none.
(defbehavior lurkerworm-default-post-behavior lurkerworm ()
  (TODO-RENAME-20 self)
  (transform-post)
  0
  (none)
  )

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

;; failed to figure out what this is:
lurkerworm-default-post-behavior

;; failed to figure out what this is:
(defstate lurkerworm-idle (lurkerworm)
  :event lurkerworm-default-event-handler
  :enter (behavior ()
    (ja-channel-set! 0)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :code (behavior ()
    (loop
      (if (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1))
               *target*
               (>= 81920.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans)))
               )
          (go lurkerworm-spot)
          )
      (suspend)
      )
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; failed to figure out what this is:
(defstate lurkerworm-spot (lurkerworm)
  :event lurkerworm-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (sound-play "worm-rise1")
    (none)
    )
  :code (behavior ()
    (set! (-> self part local-clock) 0)
    (loop
      (spawn (-> self part) (-> self root-override trans))
      (particle-effect self)
      (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1))
        (if (and *target* (>= 81920.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))))
            (go lurkerworm-rise)
            (go lurkerworm-idle)
            )
        )
      (suspend)
      )
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; failed to figure out what this is:
(defstate lurkerworm-rise (lurkerworm)
  :event lurkerworm-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :code (behavior ()
    (ja-channel-set! 1)
    (ja-no-eval :group! lurkerworm-rise-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (spawn (-> self part) (-> self root-override trans))
      (particle-effect self)
      (suspend)
      (ja :num! (seek!))
      )
    (set! (-> self strike-count) 3)
    (go lurkerworm-rest)
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; failed to figure out what this is:
(defstate lurkerworm-rest (lurkerworm)
  :event lurkerworm-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self vulnerable) #t)
    (none)
    )
  :exit (behavior ()
    (set! (-> self vulnerable) #f)
    (none)
    )
  :code (behavior ()
    (let* ((f30-0 10.0)
           (f28-0 100.0)
           (v1-1 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
           (v1-2 (the-as number (logior #x3f800000 v1-1)))
           (s5-0 (the int (+ f30-0 (* f28-0 (+ -1.0 (the-as float v1-2))))))
           (gp-1 (nonzero? (-> self strike-count)))
           )
      (if gp-1
          (+! (-> self strike-count) -1)
          )
      (ja-no-eval :group! lurkerworm-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (ja-blend-eval)
        (particle-effect self)
        (when gp-1
          (let* ((f0-13
                   (- 1.0 (* 0.00009765625
                             (+ -16384.0 (if *target*
                                             (vector-vector-distance (-> self root-override trans) (-> *target* control trans))
                                             4096000.0
                                             )
                                )
                             )
                      )
                   )
                 (f30-2 (* 0.2 f0-13))
                 )
            (if (< (rand-float-gen) f30-2)
                (go lurkerworm-strike)
                )
            )
          )
        (+! s5-0 -1)
        (when (zero? s5-0)
          (if gp-1
              (go lurkerworm-strike)
              (go lurkerworm-sink)
              )
          )
        (suspend)
        (ja :num! (seek!))
        )
      (if gp-1
          (go lurkerworm-strike)
          (go lurkerworm-sink)
          )
      )
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; failed to figure out what this is:
(defstate lurkerworm-strike (lurkerworm)
  :event lurkerworm-default-event-handler
  :code (behavior ()
    (ja-no-eval :num! (loop!))
    (ja-channel-push! 1 (seconds 0.135))
    (ja-no-eval :group! lurkerworm-chomp-ja :num! (seek! (ja-aframe 13.0 0)) :frame-num 0.0)
    (until (ja-done? 0)
      (ja-blend-eval)
      (particle-effect self)
      (suspend)
      (ja :num! (seek! (ja-aframe 13.0 0)))
      )
    (ja-no-eval :num! (seek!))
    (ja-channel-push! 1 (seconds 0.135))
    (go lurkerworm-rest)
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; failed to figure out what this is:
(defstate lurkerworm-sink (lurkerworm)
  :event lurkerworm-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :code (behavior ()
    (ja-no-eval :group! lurkerworm-sink-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (spawn (-> self part2) (-> self root-override trans))
      (particle-effect self)
      (suspend)
      (ja :num! (seek!))
      )
    (go lurkerworm-idle)
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; failed to figure out what this is:
(defstate lurkerworm-die (lurkerworm)
  :event (the-as
    (function process int symbol event-message-block object :behavior lurkerworm)
    process-drawable-death-event-handler
    )
  :code (behavior ()
    (logclear! (-> self mask) (process-mask actor-pause))
    (let ((v1-3 (-> self root-override root-prim)))
      (set! (-> v1-3 collide-with) (collide-kind))
      (set! (-> v1-3 prim-core collide-as) (collide-kind))
      )
    0
    (ja-no-eval :group! lurkerworm-die-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (cleanup-for-death self)
    (none)
    )
  :post lurkerworm-default-post-behavior
  )

;; definition for method 11 of type lurkerworm
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! lurkerworm ((obj lurkerworm) (arg0 entity-actor))
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-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-group s4-0 (the-as uint 6) 0)))
      (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-vector! (-> s3-0 local-sphere) 0.0 10240.0 0.0 24576.0)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core action) (collide-action solid))
        (set! (-> s2-0 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-0 transform-index) 3)
        (set-vector! (-> s2-0 local-sphere) 0.0 0.0 0.0 4096.0)
        (append-prim s3-0 s2-0)
        )
      (let ((s2-1 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-1 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-1 collide-with) (collide-kind target))
        (set! (-> s2-1 prim-core action) (collide-action solid))
        (set! (-> s2-1 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-1 transform-index) 5)
        (set-vector! (-> s2-1 local-sphere) 0.0 0.0 0.0 4096.0)
        (append-prim s3-0 s2-1)
        )
      (let ((s2-2 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-2 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-2 collide-with) (collide-kind target))
        (set! (-> s2-2 prim-core action) (collide-action solid))
        (set! (-> s2-2 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-2 transform-index) 6)
        (set-vector! (-> s2-2 local-sphere) 0.0 0.0 0.0 4096.0)
        (append-prim s3-0 s2-2)
        )
      (let ((s2-3 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-3 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-3 collide-with) (collide-kind target))
        (set! (-> s2-3 prim-core action) (collide-action solid))
        (set! (-> s2-3 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-3 transform-index) 7)
        (set-vector! (-> s2-3 local-sphere) 0.0 0.0 0.0 4096.0)
        (append-prim s3-0 s2-3)
        )
      (let ((s2-4 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-4 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-4 collide-with) (collide-kind target))
        (set! (-> s2-4 prim-core action) (collide-action solid))
        (set! (-> s2-4 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-4 transform-index) 8)
        (set-vector! (-> s2-4 local-sphere) 0.0 0.0 0.0 4096.0)
        (append-prim s3-0 s2-4)
        )
      (let ((s2-5 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-5 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-5 collide-with) (collide-kind target))
        (set! (-> s2-5 prim-core offense) (collide-offense normal-attack))
        (set! (-> s2-5 transform-index) 11)
        (set-vector! (-> s2-5 local-sphere) 0.0 0.0 0.0 6144.0)
        (append-prim s3-0 s2-5)
        )
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *lurkerworm-sg* '())
  (set! (-> obj fact)
        (new 'process 'fact-info-enemy obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
        )
  (set! (-> obj angle) 0.0)
  (set! (-> obj vulnerable) #f)
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 157) obj))
  (set! (-> obj part2) (create-launch-control (-> *part-group-id-table* 158) obj))
  (set! (-> obj twister) (new 'process 'twister 3 15 1092.2667 72.81778 0.25 0.001))
  (TODO-RENAME-9 (-> obj twister) 3 9 910.2222)
  (set! (-> obj head-tilt) 0.0)
  (set! (-> obj skel prebind-function) lurkerworm-prebind-function)
  (set! (-> obj skel postbind-function) lurkerworm-joint-callback)
  (set! (-> obj root-override nav-radius) 12288.0)
  (nav-mesh-connect obj (-> obj root-override) (the-as nav-control #f))
  (go lurkerworm-idle)
  (none)
  )
