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

(import "goal_src/jak1/import/mother-spider-ag.gc")

;; failed to figure out what this is:
(defskelgroup *mother-spider-sg* mother-spider mother-spider-lod0-jg -1
              ((mother-spider-lod0-mg (meters 20))
               (mother-spider-lod1-mg (meters 40))
               (mother-spider-lod2-mg (meters 999999))
               )
              :bounds (static-spherem 0 0 0 8)
              :shadow mother-spider-shadow-mg
              )

;; failed to figure out what this is:
(defskelgroup *mother-spider-leg-sg* mother-spider mother-spider-leg-lod0-jg -1
              ((mother-spider-leg-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 3)
              )

;; definition for symbol *mother-spider-threads*, type (inline-array mother-spider-thread)
(define *mother-spider-threads*
  (new 'static 'inline-array mother-spider-thread 9
    (new 'static 'mother-spider-thread :joint-index 27)
    (new 'static 'mother-spider-thread :trans-u (the-as float #x1a) :swing-arc-u 0.35)
    (new 'static 'mother-spider-thread :joint-index #x3dcccccd :swing-arc-u (the-as float #x19))
    (new 'static 'mother-spider-thread :joint-index #x3f19999a :trans-u 0.35)
    (new 'static 'mother-spider-thread :joint-index 24 :trans-u 0.8 :swing-arc-u 0.65)
    (new 'static 'mother-spider-thread :trans-u (the-as float #x17) :swing-arc-u 0.9)
    (new 'static 'mother-spider-thread :joint-index #x3f4ccccd :swing-arc-u (the-as float #x16))
    (new 'static 'mother-spider-thread :joint-index #x3f733333 :trans-u 0.95)
    (new 'static 'mother-spider-thread :joint-index 3 :trans-u 1.0 :swing-arc-u 1.0)
    )
  )

;; definition for symbol *mother-spider-leg-infos*, type (inline-array mother-spider-leg-info)
(define *mother-spider-leg-infos*
  (new 'static 'inline-array mother-spider-leg-info 8
    (new 'static 'mother-spider-leg-info :joint-index0 13 :joint-index1 14 :cprim-index 8)
    (new 'static 'mother-spider-leg-info :joint-index0 7 :joint-index1 8 :cprim-index 5)
    (new 'static 'mother-spider-leg-info :joint-index0 15 :joint-index1 16 :cprim-index 7)
    (new 'static 'mother-spider-leg-info :joint-index0 9 :joint-index1 10 :cprim-index 4)
    (new 'static 'mother-spider-leg-info :joint-index0 17 :joint-index1 18 :cprim-index 6)
    (new 'static 'mother-spider-leg-info :joint-index0 11 :joint-index1 12 :cprim-index 3)
    (new 'static 'mother-spider-leg-info :joint-index0 27)
    (new 'static 'mother-spider-leg-info :joint-index0 26 :joint-index1 #x3eb33333 :cprim-index #x3dcccccd)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-mother-spider-leg
  :id 614
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2477))
  )

;; failed to figure out what this is:
(defpart 2477
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x4 :page #x2))
    (sp-rnd-flt spt-num 0.0 1.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.35) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 64.0 128.0 1.0)
    (sp-flt spt-g 0.0)
    (sp-rnd-flt spt-b 96.0 128.0 1.0)
    (sp-rnd-flt spt-a 48.0 48.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0) (meters 0.006666667) 1.0)
    (sp-flt spt-scalevel-y (meters 0.002))
    (sp-flt spt-fade-a -0.4)
    (sp-rnd-flt spt-accel-y -1.3653333 -1.3653333 1.0)
    (sp-int spt-timer 210)
    (sp-cpuinfo-flags bit2)
    (sp-rnd-flt spt-conerot-x (degrees 90.0) (degrees 180.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defstate mother-spider-leg-flying (mother-spider-leg)
  :trans (behavior ()
    (local-vars (at-0 int))
    (rlet ((vf0 :class vf)
           (vf1 :class vf)
           (vf2 :class vf)
           )
      (init-vf0-vector)
      (+! (-> self transv y) (* (-> self gravity) (-> *display* seconds-per-frame)))
      (let ((gp-0 (new 'stack-no-clear 'collide-tri-result))
            (a2-0 (new 'stack-no-clear 'vector))
            )
        (let ((v1-1 a2-0))
          (.lvf vf1 (&-> (-> self transv) quad))
          (let ((f0-2 (-> *display* seconds-per-frame)))
            (.mov at-0 f0-2)
            )
          (.mov vf2 at-0)
          (.mov.vf vf1 vf0 :mask #b1000)
          (.mul.x.vf vf1 vf1 vf2 :mask #b111)
          (.svf (&-> v1-1 quad) vf1)
          )
        (when (>= (fill-and-probe-using-line-sphere
                    *collide-cache*
                    (-> self root trans)
                    a2-0
                    3276.8
                    (collide-kind background)
                    self
                    gp-0
                    (new 'static 'pat-surface :noentity #x1)
                    )
                  0.0
                  )
          (let ((f28-0 (vector-xz-length (-> self transv))))
            (vector-reflect! (-> self transv) (-> self transv) (-> gp-0 normal))
            (let ((f30-0 (-> self transv y)))
              (set! (-> self transv y) 0.0)
              (vector-normalize! (-> self transv) (* f28-0 (rand-vu-float-range 0.3 0.8)))
              (set! (-> self transv y) (* 0.7 f30-0))
              )
            )
          (set-vector!
            (-> self facing-rotv)
            (rand-vu-float-range 5461.3335 40049.777)
            0.0
            (rand-vu-float-range 16384.0 54613.332)
            1.0
            )
          )
        )
      (vector-v+! (-> self root trans) (-> self root trans) (-> self transv))
      (+! (-> self facing-rot x) (* (-> self facing-rotv x) (-> *display* seconds-per-frame)))
      (set! (-> self facing-rot z)
            (deg-seek (-> self facing-rot z) 16384.0 (* (-> self facing-rotv z) (-> *display* seconds-per-frame)))
            )
      (quaternion-zxy! (-> self root quat) (-> self facing-rot))
      (seek! (-> self root scale x) 0.0 (* 0.5 (-> *display* seconds-per-frame)))
      (set! (-> self root scale y) (-> self root scale x))
      (set! (-> self root scale z) (-> self root scale x))
      (none)
      )
    )
  :code (behavior ()
    (ja-channel-push! 1 0)
    (let ((f30-0 (rand-vu-float-range 0.2 0.7)))
      (dotimes (gp-0 3)
        (ja-no-eval :group! mother-spider-leg-twitching-ja :num! (seek! max f30-0) :frame-num 0.0)
        (until (ja-done? 0)
          (spawn (-> self part) (-> self root trans))
          (suspend)
          (ja :num! (seek! max f30-0))
          )
        )
      (ja-no-eval :group! mother-spider-leg-die-ja :num! (seek! max f30-0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max f30-0))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider-leg) ja-post)
  )

;; failed to figure out what this is:
(defstate wait-for-children (mother-spider)
  :code (behavior ()
    (logior! (-> self draw status) (draw-status hidden))
    (until (not (-> self child))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) ja-post)
  )

;; definition for function mother-spider-leg-init-by-other
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defbehavior mother-spider-leg-init-by-other mother-spider-leg ((arg0 mother-spider) (arg1 vector) (arg2 vector) (arg3 vector))
  (set! (-> self entity) (-> arg0 entity))
  (set! (-> self mask) (logior (process-mask enemy) (-> self mask)))
  (set! (-> self root) (new 'process 'trsqv))
  (set! (-> self root trans quad) (-> arg1 quad))
  (vector-identity! (-> self root scale))
  (set-heading-vec-clear-roll-pitch! (-> self root) arg2)
  (vector-float*! (-> self transv) arg3 (rand-vu-float-range 10240.0 30720.0))
  (rot-zxy-from-vector! (-> self facing-rot) arg2)
  (set-vector!
    (-> self facing-rotv)
    (rand-vu-float-range 5461.3335 16384.0)
    0.0
    (rand-vu-float-range 16384.0 36408.89)
    1.0
    )
  (set! (-> self gravity) (rand-vu-float-range -266240.0 -163840.0))
  (initialize-skeleton self *mother-spider-leg-sg* '())
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 614) self))
  (create-connection!
    *cavecrystal-light-control*
    self
    (-> self entity)
    (the-as (function object object object object object) cavecrystal-light-control-default-callback)
    -1
    4096.0
    )
  (go mother-spider-leg-flying)
  (none)
  )

;; failed to figure out what this is:
(defpartgroup group-mother-spider-leg-socket
  :id 618
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2498 :period 90 :length 30))
  )

;; failed to figure out what this is:
(defpart 2498
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x4 :page #x2))
    (sp-rnd-flt spt-num 1.0 2.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.35) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 64.0 128.0 1.0)
    (sp-flt spt-g 0.0)
    (sp-rnd-flt spt-b 96.0 128.0 1.0)
    (sp-rnd-flt spt-a 48.0 48.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.01) (meters 0.0033333334) 1.0)
    (sp-flt spt-scalevel-y (meters 0.002))
    (sp-flt spt-fade-a -0.4)
    (sp-flt spt-accel-y -2.7306666)
    (sp-int spt-timer 210)
    (sp-cpuinfo-flags bit2)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; definition for function mother-spider-default-event-handler
(defbehavior mother-spider-default-event-handler mother-spider ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('attack)
     (cond
       ((= (-> arg0 type) target)
        (let ((v1-2 (-> arg3 param 2)))
          (when (!= v1-2 (-> self player-attack-id))
            (set! (-> self player-attack-id) v1-2)
            (case (-> arg3 param 1)
              (('uppercut)
               (go mother-spider-die-from-uppercut)
               )
              (else
                (let ((gp-0 (new 'stack-no-clear 'vector)))
                  (let ((v1-5 (target-pos 0)))
                    (vector-! gp-0 (-> self root-override trans) v1-5)
                    )
                  (set! (-> gp-0 y) 0.0)
                  (vector-normalize! gp-0 1.0)
                  (set! (-> self thread-vel) (+ -40960.0 (-> self thread-vel)))
                  (if (TODO-RENAME-21 self gp-0 102400.0 #t)
                      (go mother-spider-die)
                      )
                  )
                )
              )
            )
          )
        )
       (else
         (let ((gp-1 (new 'stack-no-clear 'vector)))
           (let ((v1-10 (-> (the-as process-drawable arg0) root trans)))
             (vector-! gp-1 (-> self root-override trans) v1-10)
             )
           (set! (-> gp-1 y) 0.0)
           (vector-normalize! gp-1 1.0)
           (set! (-> self thread-vel) (+ -40960.0 (-> self thread-vel)))
           (if (TODO-RENAME-21 self gp-1 102400.0 #t)
               (go mother-spider-die)
               )
           )
         )
       )
     )
    (('touch)
     (when (= (-> arg0 type) target)
       (when (send-event
               arg0
               'attack
               (-> arg3 param 0)
               (static-attack-info ((shove-up (meters 0.5)) (shove-back (meters 2))))
               )
         (let ((gp-2 (new 'stack-no-clear 'vector)))
           (let ((v1-20 (target-pos 0)))
             (vector-! gp-2 (-> self root-override trans) v1-20)
             )
           (set! (-> gp-2 y) 0.0)
           (vector-normalize! gp-2 1.0)
           (set! (-> self thread-vel) (+ -8192.0 (-> self thread-vel)))
           (TODO-RENAME-21 self gp-2 40960.0 #f)
           )
         )
       )
     )
    (('trigger)
     (when (= (-> arg0 type) mother-spider-egg)
       (let ((gp-3 (new 'stack-no-clear 'vector))
             (s5-0 (-> (the-as process-drawable arg0) root trans))
             )
         (vector-! gp-3 (target-pos 0) s5-0)
         (set! (-> gp-3 y) 0.0)
         (vector-normalize! gp-3 1.0)
         (spawn-child self s5-0 gp-3 #t)
         )
       )
     )
    (('untrigger)
     (when (or (= (-> arg0 type) mother-spider-egg) (= (-> arg0 type) baby-spider))
       (let ((v0-0 (the-as object (+ (-> self baby-count) -1))))
         (set! (-> self baby-count) (the-as int v0-0))
         v0-0
         )
       )
     )
    )
  )

;; definition for function mother-spider-death-event-handler
(defbehavior mother-spider-death-event-handler mother-spider ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('trigger)
     (when (= (-> arg0 type) mother-spider-egg)
       (let ((gp-0 (new 'stack-no-clear 'vector))
             (s5-0 (-> (the-as process-drawable arg0) root trans))
             )
         (vector-! gp-0 (target-pos 0) s5-0)
         (set! (-> gp-0 y) 0.0)
         (vector-normalize! gp-0 1.0)
         (spawn-child self s5-0 gp-0 #t)
         )
       )
     )
    (('death-start)
     (drop-pickup (-> self fact) #t *entity-pool* (-> self fact) 0)
     )
    (('death-end)
     (let ((v0-0 (the-as object (logior (-> self draw status) (draw-status hidden)))))
       (set! (-> self draw status) (the-as draw-status v0-0))
       v0-0
       )
     )
    )
  )

;; definition for method 30 of type mother-spider
(defmethod spawn-child mother-spider ((obj mother-spider) (arg0 vector) (arg1 vector) (arg2 symbol))
  (let ((s3-0 (new 'stack-no-clear 'baby-spider-spawn-params)))
    (init! s3-0 arg2 #f #t #f 7 1 'untrigger)
    (set-delay! s3-0 (seconds 9))
    (process-spawn baby-spider obj arg0 arg1 s3-0 :to obj)
    )
  (let ((v0-5 (+ (-> obj baby-count) 1)))
    (set! (-> obj baby-count) v0-5)
    v0-5
    )
  )

;; definition for method 31 of type mother-spider
(defmethod is-player-stuck? mother-spider ((obj mother-spider))
  (when (and *target* (not (and (logtest? (-> *target* control unknown-surface00 flags) (surface-flags jump))
                                (zero? (logand (-> *target* control status) (cshape-moving-flags onsurf)))
                                )
                           )
             )
    (let* ((v1-10 (target-pos 0))
           (f0-1 (- (-> obj anchor-trans y) (-> v1-10 y)))
           (f1-2 (- (-> obj player-sticky-dist-from-anchor) f0-1))
           )
      (when (or (< 8192.0 f1-2) (< f1-2 -8192.0))
        (set! (-> obj player-sticky-dist-from-anchor) f0-1)
        (return #t)
        )
      )
    )
  #f
  )

;; definition for method 27 of type mother-spider
;; INFO: Return type mismatch symbol vs none.
(defmethod STUB-27 mother-spider ((obj mother-spider))
  (none)
  )

;; definition for method 28 of type mother-spider
;; INFO: Return type mismatch int vs none.
(defmethod STUB-28 mother-spider ((obj mother-spider))
  0
  (none)
  )

;; definition for method 24 of type mother-spider
;; Used lq/sq
(defmethod TODO-RENAME-24 mother-spider ((obj mother-spider))
  (cond
    ((and (-> obj draw shadow)
          (zero? (-> obj draw cur-lod))
          (logtest? (-> obj draw status) (draw-status was-drawn))
          )
     (let ((s5-0 (new 'stack-no-clear 'collide-tri-result))
           (a1-0 (new 'stack-no-clear 'vector))
           (a2-0 (new 'stack-no-clear 'vector))
           )
       (set! (-> a1-0 quad) (-> obj root-override trans quad))
       (set-vector! a2-0 0.0 -81920.0 0.0 1.0)
       (set! (-> a1-0 y) (+ -8192.0 (-> a1-0 y)))
       (cond
         ((>= (fill-and-probe-using-line-sphere
                *collide-cache*
                a1-0
                a2-0
                8192.0
                (collide-kind background)
                obj
                s5-0
                (new 'static 'pat-surface :noentity #x1)
                )
              0.0
              )
          (let ((v1-11 (-> obj draw shadow-ctrl)))
            (logclear! (-> v1-11 settings flags) (shadow-flags disable-draw))
            )
          0
          (let ((v1-14 (-> obj draw shadow-ctrl)))
            (set! (-> v1-14 settings bot-plane w) (- (+ -6144.0 (-> s5-0 intersect y))))
            )
          0
          (let ((v1-17 (-> obj draw shadow-ctrl)))
            (set! (-> v1-17 settings top-plane w) (- (+ 6144.0 (-> s5-0 intersect y))))
            )
          0
          (let* ((f3-0 (vector-vector-distance (-> s5-0 intersect) (-> obj root-override trans)))
                 (f0-14 (* 0.000030517578 (fmin 32768.0 (fmax 0.0 (+ -57344.0 f3-0)))))
                 (f0-15 (lerp 409600.0 40960.0 f0-14))
                 )
            (set! (-> obj draw shadow-ctrl settings shadow-dir w) f0-15)
            f0-15
            )
          )
         (else
           (let ((v1-23 (-> obj draw shadow-ctrl)))
             (logior! (-> v1-23 settings flags) (shadow-flags disable-draw))
             )
           0
           )
         )
       )
     )
    (else
      (let ((v1-25 (-> obj draw shadow-ctrl)))
        (logior! (-> v1-25 settings flags) (shadow-flags disable-draw))
        )
      0
      )
    )
  )

;; definition for method 26 of type mother-spider
(defmethod grab-player? mother-spider ((obj mother-spider))
  (when *target*
    (let ((s5-0 (target-pos 0)))
      (when (and (>= 40960.0 (- (-> obj thread-min-trans y) (-> s5-0 y)))
                 (>= (-> obj activate-xz-dist) (vector-vector-xz-distance (-> obj thread-min-trans) s5-0))
                 )
        (cond
          ((-> obj check-z-thresh?)
           (let ((f0-3 (- (-> s5-0 z) (-> obj root-override trans z))))
             (if (>= (-> obj activate-z-thresh) f0-3)
                 (return #t)
                 )
             )
           )
          (else
            (return #t)
            )
          )
        )
      )
    )
  #f
  )

;; definition for method 25 of type mother-spider
(defmethod letgo-player? mother-spider ((obj mother-spider))
  (if (not *target*)
      (return #t)
      )
  (let ((a1-0 (target-pos 0)))
    (when (-> obj check-z-thresh?)
      (if (>= (- (-> a1-0 z) (-> obj root-override trans z)) (-> obj deactivate-z-thresh))
          (return #t)
          )
      )
    (if (or (>= (- (-> obj thread-min-trans y) (-> a1-0 y)) 49152.0)
            (>= (vector-vector-xz-distance (-> obj thread-min-trans) a1-0) (-> obj deactivate-xz-dist))
            )
        (return #t)
        )
    )
  #f
  )

;; definition for method 21 of type mother-spider
;; Used lq/sq
(defmethod TODO-RENAME-21 mother-spider ((obj mother-spider) (arg0 vector) (arg1 float) (arg2 symbol))
  (local-vars (sv-112 process) (sv-128 vector) (sv-144 vector))
  (let ((f30-0 (vector-length (-> obj swing-pos))))
    (when (< 0.0 f30-0)
      (let ((s1-0 (new 'stack-no-clear 'vector))
            (s2-0 (new 'stack-no-clear 'vector))
            )
        (vector-normalize-copy! s1-0 (-> obj swing-pos) 1.0)
        (vector-rotate-around-y! s2-0 s1-0 16384.0)
        (if (< (vector-dot arg0 s2-0) 0.0)
            (vector-negate! s2-0 s2-0)
            )
        (let ((f0-4 (fmin 1.0 (/ f30-0 (-> obj max-swing-radius)))))
          (vector-lerp! arg0 arg0 s2-0 f0-4)
          )
        )
      (vector-normalize! arg0 1.0)
      )
    )
  (let ((s2-1 (new 'stack-no-clear 'vector)))
    (vector-float*! s2-1 arg0 arg1)
    (vector-flatten! (-> obj swing-vel) (-> obj swing-vel) arg0)
    (vector+! (-> obj swing-vel) (-> obj swing-vel) s2-1)
    )
  (set! (-> obj swing-vel y) 0.0)
  (when arg2
    (set! (-> obj hit?) #t)
    (set! (-> obj spin-vel) 131072.0)
    (set! (-> obj spin-time) (-> *display* base-frame-counter))
    (let ((s4-1 (-> obj damage))
          (s3-1 (-> obj root-override root-prim))
          )
      (dotimes (s2-2 2)
        (when (< (-> obj damage) 6)
          (+! (-> obj damage) 1)
          (logior! (-> obj leg-socket-part-mask) (ash 1 s4-1))
          (set! (-> obj leg-socket-part-time s4-1) (-> *display* base-frame-counter))
          (let ((s1-1 (-> *mother-spider-leg-infos* s4-1)))
            (let ((s0-0 (new 'stack-no-clear 'vector)))
              (set! sv-128 (new 'stack-no-clear 'vector))
              (set! sv-144 (new 'stack-no-clear 'vector))
              (vector<-cspace! s0-0 (-> obj node-list data (-> s1-1 joint-index0)))
              (vector<-cspace! sv-128 (-> obj node-list data (-> s1-1 joint-index1)))
              (vector-! sv-128 sv-128 s0-0)
              (vector-normalize! sv-128 1.0)
              (vector-lerp! sv-144 sv-128 arg0 0.6)
              (vector-normalize! sv-144 1.0)
              (+! (-> sv-144 y) (rand-vu-float-range 0.0 0.3))
              (vector-normalize! sv-144 1.0)
              (set! sv-112 (get-process *default-dead-pool* mother-spider-leg #x4000))
              (when sv-112
                (let ((t9-15 (method-of-type mother-spider-leg activate)))
                  (t9-15 (the-as mother-spider-leg sv-112) obj 'mother-spider-leg (the-as pointer #x70004000))
                  )
                (run-now-in-process sv-112 mother-spider-leg-init-by-other obj s0-0 sv-128 sv-144)
                (-> sv-112 ppointer)
                )
              )
            (let ((v1-43 (-> (the-as collide-shape-prim-group s3-1) prims (-> s1-1 cprim-index))))
              (set! (-> v1-43 collide-with) (collide-kind))
              (set! (-> v1-43 prim-core collide-as) (collide-kind))
              )
            )
          0
          (+! s4-1 1)
          )
        )
      )
    )
  (>= (-> obj damage) 6)
  )

;; definition for method 29 of type mother-spider
(defmethod TODO-RENAME-29 mother-spider ((obj mother-spider) (arg0 symbol) (arg1 symbol))
  (let ((v1-1 (-> *display* base-frame-counter)))
    (when (!= v1-1 (-> obj last-update-time))
      (set! (-> obj last-update-time) v1-1)
      (TODO-RENAME-23 obj)
      (let ((f0-1 (fmax 0.0 (- (-> obj dist-from-anchor) (-> obj idle-dist-from-anchor)))))
        (cond
          ((>= f0-1 20480.0)
           (vector-identity! (-> obj root-override scale))
           )
          (else
            (let ((f0-2 (* 0.000048828126 f0-1)))
              (set-vector! (-> obj root-override scale) f0-2 f0-2 f0-2 1.0)
              )
            )
          )
        )
      (if arg0
          (TODO-RENAME-24 obj)
          )
      (let ((s4-1 (-> obj leg-socket-part-mask)))
        (when (nonzero? s4-1)
          (dotimes (s3-0 6)
            (when (logtest? s4-1 1)
              (cond
                ((>= (+ (-> *display* base-frame-counter) (seconds -1)) (-> obj leg-socket-part-time s3-0))
                 (logxor! (-> obj leg-socket-part-mask) (ash 1 s3-0))
                 )
                (else
                  (let ((v1-20 (-> *mother-spider-leg-infos* s3-0))
                        (s2-0 (new 'stack-no-clear 'vector))
                        )
                    (vector<-cspace! s2-0 (-> obj node-list data (-> v1-20 joint-index0)))
                    (spawn (-> obj part) s2-0)
                    )
                  )
                )
              )
            (set! s4-1 (/ s4-1 2))
            )
          )
        )
      (when arg1
        (when *target*
          (case (-> obj mode)
            ((1 2)
             (if *target*
                 (look-at-enemy! (-> *target* neck) (the-as vector (-> obj root-override root-prim prim-core)) 'attacking obj)
                 )
             )
            )
          )
        (set-target! (-> obj neck) (target-pos 5))
        )
      )
    )
  (none)
  )

;; definition for method 23 of type mother-spider
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defmethod TODO-RENAME-23 mother-spider ((obj mother-spider))
  (local-vars (at-0 int))
  (rlet ((vf0 :class vf)
         (vf1 :class vf)
         (vf2 :class vf)
         )
    (init-vf0-vector)
    (let* ((f2-0 (-> obj dist-from-anchor))
           (f1-0 (- (-> obj targ-dist-from-anchor) f2-0))
           (f0-1 (-> obj thread-vel))
           )
      (when (or (!= f0-1 0.0) (!= f1-0 0.0))
        (let ((f0-2 (+ f0-1 (* 2.0 f1-0))))
          (let ((f3-4 (-> obj thread-speed)))
            (if (< f3-4 (fabs f0-2))
                (set! f0-2 (if (>= f0-2 0.0)
                               f3-4
                               (- f3-4)
                               )
                      )
                )
            )
          (let ((f2-1 (+ f2-0 (* f0-2 (-> *display* seconds-per-frame)))))
            (let ((f3-8 (- (-> obj targ-dist-from-anchor) f2-1)))
              (cond
                ((>= f1-0 0.0)
                 (if (>= 0.0 f3-8)
                     (set! f0-2 (- f0-2 (* 0.55 f0-2)))
                     )
                 )
                (else
                  (if (>= f3-8 0.0)
                      (set! f0-2 (- f0-2 (* 0.55 f0-2)))
                      )
                  )
                )
              )
            (set! (-> obj dist-from-anchor) (fmax 0.0 f2-1))
            )
          (set! (-> obj thread-vel) f0-2)
          )
        )
      )
    (let ((s5-0 (new 'stack-no-clear 'vector)))
      (vector-negate! s5-0 (-> obj swing-base-pos))
      (set! (-> s5-0 y) 0.0)
      (let ((f0-4 (vector-length s5-0)))
        (when (< 0.0 f0-4)
          (let ((f1-11 (* 61440.0 (-> *display* seconds-per-frame))))
            (if (< f1-11 f0-4)
                (vector-normalize! s5-0 f1-11)
                )
            )
          (vector+! (-> obj swing-vel) (-> obj swing-vel) s5-0)
          )
        )
      )
    (let ((f0-5 (vector-length (-> obj swing-vel))))
      (when (< 0.0 f0-5)
        (let ((f0-6 (* 0.995 f0-5)))
          (cond
            ((< 40.96 f0-6)
             (vector-normalize! (-> obj swing-vel) f0-6)
             (let ((s5-1 (new 'stack-no-clear 'event-message-block))
                   (s4-0 (new 'stack-no-clear 'vector))
                   (s3-0 (new 'stack-no-clear 'vector))
                   )
               (vector<-cspace! s4-0 (-> obj node-list data 6))
               (let ((v1-20 s3-0))
                 (.lvf vf1 (&-> (-> obj swing-vel) quad))
                 (let ((f0-7 (-> *display* seconds-per-frame)))
                   (.mov at-0 f0-7)
                   )
                 (.mov vf2 at-0)
                 (.mov.vf vf1 vf0 :mask #b1000)
                 (.mul.x.vf vf1 vf1 vf2 :mask #b111)
                 (.svf (&-> v1-20 quad) vf1)
                 )
               (when (>= (fill-and-probe-using-line-sphere
                           *collide-cache*
                           s4-0
                           s3-0
                           4915.2
                           (collide-kind background)
                           obj
                           (the-as collide-tri-result s5-1)
                           (new 'static 'pat-surface :noentity #x1)
                           )
                         0.0
                         )
                 (vector-reflect! (-> obj swing-vel) (-> obj swing-vel) (the-as vector (&-> s5-1 param 6)))
                 (set! (-> obj swing-vel y) 0.0)
                 (vector-normalize! (-> obj swing-vel) (* 0.5 (vector-length (-> obj swing-vel))))
                 (when (and (!= (-> obj spin-vel) 0.0) (>= (- (-> *display* base-frame-counter) (-> obj spin-time)) (seconds 0.5)))
                   (set! (-> obj spin-vel) (* 0.75 (- (-> obj spin-vel))))
                   (set! (-> obj spin-time) (-> *display* base-frame-counter))
                   )
                 )
               )
             (vector-v+! (-> obj swing-base-pos) (-> obj swing-base-pos) (-> obj swing-vel))
             0
             )
            (else
              (vector-reset! (-> obj swing-vel))
              )
            )
          )
        )
      )
    (set! (-> obj swing-pos quad) (-> obj swing-base-pos quad))
    (let ((f30-1 (the float (- (-> *display* base-frame-counter) (-> obj spawned-time)))))
      (+! (-> obj swing-pos x) (* 1024.0 (cos (* 54.613335 f30-1))))
      (+! (-> obj swing-pos z) (* 1024.0 (cos (* 81.817726 f30-1))))
      )
    (let ((f0-26 (vector-length (-> obj swing-pos))))
      (cond
        ((!= f0-26 0.0)
         (let* ((f30-2 (-> obj dist-from-anchor))
                (f28-2 (* 10430.379 (/ f0-26 f30-2)))
                )
           (set-vector! (-> obj root-override trans) 0.0 (* (cos f28-2) (- f30-2)) (* (sin f28-2) f30-2) 1.0)
           )
         (let ((f0-36 (atan (-> obj swing-pos x) (-> obj swing-pos z))))
           (vector-rotate-around-y! (-> obj root-override trans) (-> obj root-override trans) f0-36)
           )
         (vector+! (-> obj root-override trans) (-> obj root-override trans) (-> obj anchor-trans))
         )
        (else
          (set! (-> obj root-override trans quad) (-> obj anchor-trans quad))
          (set! (-> obj root-override trans y) (- (-> obj root-override trans y) (-> obj dist-from-anchor)))
          )
        )
      )
    (let ((v1-51 (-> obj draw bounds)))
      (vector+! v1-51 (-> obj root-override trans) (-> obj anchor-trans))
      (vector-float*! v1-51 v1-51 0.5)
      (vector-! v1-51 v1-51 (-> obj root-override trans))
      (set! (-> v1-51 w) (+ 28672.0 (* 0.5 (-> obj dist-from-anchor))))
      )
    (cond
      ((!= (-> obj spin-vel) 0.0)
       (let ((f0-44 (+ (-> obj orient-rot y) (* (-> obj spin-vel) (-> *display* seconds-per-frame)))))
         (set! (-> obj orient-rot y) (- f0-44 (* (the float (the int (/ f0-44 65536.0))) 65536.0)))
         )
       (seek! (-> obj spin-vel) 0.0 (* 91022.22 (-> *display* seconds-per-frame)))
       (when (< (fabs (-> obj spin-vel)) 69176.89)
         (if (>= (-> obj spin-vel) 0.0)
             (set! (-> obj spin-vel) 69176.89)
             (set! (-> obj spin-vel) -69176.89)
             )
         (cond
           (*target*
             (let* ((v1-59 (target-pos 0))
                    (f0-59 (atan (- (-> v1-59 x) (-> obj root-override trans x)) (- (-> v1-59 z) (-> obj root-override trans z))))
                    )
               (if (>= 3640.889 (fabs (deg- f0-59 (-> obj orient-rot y))))
                   (set! (-> obj spin-vel) 0.0)
                   )
               )
             )
           (else
             (set! (-> obj spin-vel) 0.0)
             )
           )
         )
       )
      (else
        (when *target*
          (let* ((v1-66 (target-pos 0))
                 (f0-69 (atan (- (-> v1-66 x) (-> obj root-override trans x)) (- (-> v1-66 z) (-> obj root-override trans z))))
                 )
            (set! (-> obj orient-rot y)
                  (deg-seek-smooth (-> obj orient-rot y) f0-69 (* 32768.0 (-> *display* seconds-per-frame)) 0.2)
                  )
            )
          )
        )
      )
    (quaternion-zxy! (-> obj root-override quat) (-> obj orient-rot))
    0
    (none)
    )
  )

;; failed to figure out what this is:
(defstate mother-spider-idle (mother-spider)
  :enter (behavior ()
    (let ((v1-1 (-> self draw shadow-ctrl)))
      (logior! (-> v1-1 settings flags) (shadow-flags disable-draw))
      )
    0
    (set! (-> self mode) (the-as uint 0))
    (set! (-> self skel postbind-function) (the-as (function process-drawable none) 0))
    (clear-collide-with-as (-> self root-override))
    (shut-down! (-> self neck))
    (logior! (-> self mask) (process-mask actor-pause))
    (logior! (-> self draw status) (draw-status hidden))
    (none)
    )
  :exit (behavior ()
    (restore-collide-with-as (-> self root-override))
    (set! (-> self skel postbind-function) mother-spider-full-joint-callback)
    (logclear! (-> self mask) (process-mask actor-pause))
    (logclear! (-> self draw status) (draw-status hidden))
    (none)
    )
  :trans (behavior ()
    (if (grab-player? self)
        (go mother-spider-traveling (the-as uint 1))
        )
    (none)
    )
  :code (behavior ()
    (loop
      (logior! (-> self mask) (process-mask sleep-code))
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate mother-spider-traveling (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ((arg0 uint))
    (is-player-stuck? self)
    (let ((v1-2 arg0))
      (cond
        ((zero? v1-2)
         (set! (-> self targ-dist-from-anchor) (-> self idle-dist-from-anchor))
         (set! (-> self thread-speed) 81920.0)
         )
        ((= v1-2 1)
         (set! (-> self targ-dist-from-anchor)
               (fmax
                 (fmin (+ -28672.0 (-> self player-sticky-dist-from-anchor)) (-> self max-dist-from-anchor))
                 (-> self idle-dist-from-anchor)
                 )
               )
         (if (zero? (-> self mode))
             (set! (-> self thread-speed) 327680.0)
             (set! (-> self thread-speed) 81920.0)
             )
         (set! (-> self spit-counter) 3)
         )
        ((= v1-2 2)
         (set! (-> self targ-dist-from-anchor)
               (fmax
                 (fmin (+ -43008.0 (-> self player-sticky-dist-from-anchor)) (-> self max-dist-from-anchor))
                 (-> self idle-dist-from-anchor)
                 )
               )
         (set! (-> self thread-speed) 28672.0)
         )
        )
      )
    (set! (-> self mode) arg0)
    (set! (-> self hit?) #f)
    (set! (-> self going-up?) (< (-> self targ-dist-from-anchor) (-> self dist-from-anchor)))
    (none)
    )
  :trans (behavior ()
    (let ((gp-0 (is-player-stuck? self))
          (v1-1 (-> self mode))
          )
      (cond
        ((zero? v1-1)
         (if (grab-player? self)
             (go mother-spider-traveling (the-as uint 1))
             )
         )
        ((= v1-1 1)
         (if (letgo-player? self)
             (go mother-spider-traveling (the-as uint 0))
             )
         (when gp-0
           (set! (-> self targ-dist-from-anchor)
                 (fmax
                   (fmin (+ -28672.0 (-> self player-sticky-dist-from-anchor)) (-> self max-dist-from-anchor))
                   (-> self idle-dist-from-anchor)
                   )
                 )
           (set! (-> self going-up?) (< (-> self targ-dist-from-anchor) (-> self dist-from-anchor)))
           )
         )
        ((= v1-1 2)
         (if (letgo-player? self)
             (go mother-spider-traveling (the-as uint 0))
             )
         (when gp-0
           (set! (-> self targ-dist-from-anchor)
                 (fmax
                   (fmin (+ -43008.0 (-> self player-sticky-dist-from-anchor)) (-> self max-dist-from-anchor))
                   (-> self idle-dist-from-anchor)
                   )
                 )
           (set! (-> self going-up?) (< (-> self targ-dist-from-anchor) (-> self dist-from-anchor)))
           )
         )
        )
      )
    (cond
      ((-> self going-up?)
       (if (>= (-> self targ-dist-from-anchor) (-> self dist-from-anchor))
           (go mother-spider-stop-traveling)
           )
       )
      (else
        (if (>= (-> self dist-from-anchor) (-> self targ-dist-from-anchor))
            (go mother-spider-stop-traveling)
            )
        )
      )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ((arg0 uint))
    (local-vars (v1-12 symbol) (v1-28 symbol))
    (ja-channel-push! 1 (seconds 0.1))
    (ja :group! mother-spider-lowering-ja :num! min)
    (loop
      (until v1-12
        (suspend)
        (ja :num! (seek!))
        (set! v1-12 (or (ja-done? 0) (-> self hit?)))
        )
      (when (-> self hit?)
        (until (not (-> self hit?))
          (set! (-> self hit?) #f)
          (ja-channel-push! 1 (seconds 0.2))
          (ja :group! mother-spider-takes-hit-ja :num! min)
          (until v1-28
            (suspend)
            (ja :num! (seek!))
            (set! v1-28 (or (ja-done? 0) (-> self hit?)))
            )
          )
        (ja-channel-push! 1 (seconds 0.2))
        )
      (ja :group! mother-spider-lowering-ja :num! min)
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-stop-traveling (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-tracking)
        )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (ja-no-eval :group! mother-spider-stopped-lowering-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (let ((v1-22 (-> self mode)))
      (cond
        ((zero? v1-22)
         (go mother-spider-idle)
         )
        ((= v1-22 1)
         (go mother-spider-tracking)
         )
        ((= v1-22 2)
         (set! (-> self started-birthing-time) (-> *display* base-frame-counter))
         (set! (-> self birthing-counter) (max 0 (- (-> self max-baby-count) (-> self baby-count))))
         (go mother-spider-birthing)
         )
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-tracking (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self last-player-in-air-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-tracking)
        )
    (if (letgo-player? self)
        (go mother-spider-traveling (the-as uint 0))
        )
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (vector<-cspace! gp-0 (-> self node-list data 6))
      (if (or (logtest? (-> *target* state-flags)
                        (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)
                        )
              (< (vector-vector-distance gp-0 (camera-pos)) 8192.0)
              )
          (go mother-spider-traveling (the-as uint 2))
          )
      )
    (when (is-player-stuck? self)
      (let ((f1-4 (fmax
                    (fmin (+ -28672.0 (-> self player-sticky-dist-from-anchor)) (-> self max-dist-from-anchor))
                    (-> self idle-dist-from-anchor)
                    )
                  )
            )
        (if (< 409.6 (fabs (- f1-4 (-> self dist-from-anchor))))
            (go mother-spider-traveling (the-as uint 1))
            )
        )
      )
    (if (or (not *target*) (and (logtest? (-> *target* control unknown-surface00 flags) (surface-flags jump))
                                (zero? (logand (-> *target* control status) (cshape-moving-flags onsurf)))
                                )
            )
        (set! (-> self last-player-in-air-time) (-> *display* base-frame-counter))
        )
    (when (and *target*
               (>= (- (-> *display* base-frame-counter) (-> self last-spit-time)) (seconds 3))
               (>= (- (-> *display* base-frame-counter) (-> self last-player-in-air-time)) (seconds 0.06))
               (>= (-> self max-spit-xz-dist) (vector-vector-xz-distance (-> self root-override trans) (target-pos 0)))
               )
      (let ((gp-2 (new 'stack-no-clear 'vector))
            (s5-2 (new 'stack-no-clear 'vector))
            )
        (set! (-> gp-2 quad) (-> self root-override trans quad))
        (set! (-> gp-2 w) 4096.0)
        (when (sphere-in-view-frustum? (the-as sphere gp-2))
          (vector<-cspace! gp-2 (-> self node-list data 21))
          (set! (-> s5-2 quad) (-> (target-pos 0) quad))
          (set! (-> s5-2 y) (+ 4915.2 (-> s5-2 y)))
          (cond
            ((< 24576.0 (vector-vector-distance gp-2 s5-2))
             (go mother-spider-spit)
             )
            (else
              (if (>= (- (-> *display* base-frame-counter) (-> self last-spit-time)) (seconds 5))
                  (go mother-spider-traveling (the-as uint 2))
                  )
              )
            )
          )
        )
      )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (cond
      ((ja-group? mother-spider-idle-ja)
       (ja-no-eval :num! (seek!))
       (while (not (ja-done? 0))
         (suspend)
         (ja-eval)
         )
       )
      (else
        (ja-channel-push! 1 (seconds 0.25))
        )
      )
    (loop
      (ja-no-eval :group! mother-spider-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-hit-while-tracking (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-tracking)
        )
    (when (= (-> self spin-vel) 0.0)
      (set! (-> self last-spit-time) 0)
      (go mother-spider-tracking)
      )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (ja-no-eval :group! mother-spider-takes-hit-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (ja-channel-push! 1 (seconds 0.1))
    (loop
      (ja-no-eval :group! mother-spider-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-spit (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-tracking)
        )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.25))
    (let ((gp-0 #f))
      (ja-no-eval :group! mother-spider-spit-ja :num! (seek! max 1.5) :frame-num 0.0)
      (until (ja-done? 0)
        (when (and (not gp-0) (>= (ja-aframe-num 0) 6.0) (>= 8.0 (ja-aframe-num 0)))
          (when *target*
            (let ((s4-0 (new 'stack-no-clear 'vector))
                  (s3-0 (new 'stack-no-clear 'vector))
                  (s5-0 (new 'stack-no-clear 'vector))
                  (s2-0 (new 'stack-no-clear 'vector))
                  )
              (vector<-cspace! s4-0 (-> self node-list data 21))
              (set! (-> s5-0 quad) (-> (target-pos 0) quad))
              (set! (-> s5-0 y) (+ 4915.2 (-> s5-0 y)))
              (when (< 24576.0 (vector-vector-distance s5-0 s4-0))
                (let ((a2-1 (-> self node-list data 19 bone transform)))
                  (set-vector! s2-0 0.0 0.0 1.0 1.0)
                  (vector-rotate*! s2-0 s2-0 a2-1)
                  )
                (set! (-> s2-0 w) 1.0)
                (vector-! s5-0 s5-0 s4-0)
                (vector-normalize! s5-0 1.0)
                (vector-deg-seek s5-0 s2-0 s5-0 6371.5557)
                (vector-normalize-copy! s3-0 s5-0 32768.0)
                (process-spawn
                  mother-spider-proj
                  :init projectile-init-by-other
                  (-> self entity)
                  s4-0
                  s3-0
                  0
                  (process->handle *target*)
                  :to self
                  )
                (set! gp-0 #t)
                (set! (-> self last-spit-time) (-> *display* base-frame-counter))
                (vector-negate! s5-0 s5-0)
                (TODO-RENAME-21 self s5-0 49152.0 #f)
                (when (nonzero? (-> self max-baby-count))
                  (+! (-> self spit-counter) -1)
                  (when (< (-> self spit-counter) 0)
                    (set! (-> self spit-counter) 0)
                    0
                    )
                  )
                )
              )
            )
          )
        (suspend)
        (ja :num! (seek! max 1.5))
        )
      )
    (if (> (-> self spit-counter) 0)
        (go mother-spider-tracking)
        (go mother-spider-traveling (the-as uint 2))
        )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-birthing (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-birthing)
        )
    (if (letgo-player? self)
        (go mother-spider-traveling (the-as uint 0))
        )
    (if (and (>= (- (-> *display* base-frame-counter) (-> self started-birthing-time)) (seconds 6))
             (zero? (logand (-> *target* state-flags)
                            (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)
                            )
                    )
             )
        (go mother-spider-traveling (the-as uint 1))
        )
    (if (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.25))
             (> (-> self birthing-counter) 0)
             (and (>= 49152.0 (- (-> self max-dist-from-anchor) (-> self dist-from-anchor)))
                  (zero? (logand (-> *target* state-flags)
                                 (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)
                                 )
                         )
                  (TODO-RENAME-21 (-> self nav) (-> self root-override trans))
                  )
             )
        (go mother-spider-birth-baby)
        )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (cond
      ((ja-group? mother-spider-idle-ja)
       (ja-no-eval :num! (seek!))
       (while (not (ja-done? 0))
         (suspend)
         (ja-eval)
         )
       )
      (else
        (ja-channel-push! 1 (seconds 0.25))
        )
      )
    (loop
      (ja-no-eval :group! mother-spider-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-birth-baby (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-birthing)
        )
    (if (letgo-player? self)
        (go mother-spider-traveling (the-as uint 0))
        )
    (if (not (TODO-RENAME-21 (-> self nav) (-> self root-override trans)))
        (go mother-spider-birthing)
        )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.25))
    (let ((gp-0 #f))
      (ja-no-eval :group! mother-spider-birth-ja :num! (seek! max 1.4) :frame-num 0.0)
      (until (ja-done? 0)
        (when (and (not gp-0) (>= (ja-aframe-num 0) 10.0))
          (set! gp-0 #t)
          (let ((s5-0 (new 'stack-no-clear 'vector))
                (s4-0 (new 'stack-no-clear 'vector))
                )
            (when (TODO-RENAME-20 self s5-0 s4-0)
              (process-spawn mother-spider-egg (-> self entity) (-> self root-override trans) s5-0 s4-0 :to self)
              (+! (-> self baby-count) 1)
              (+! (-> self birthing-counter) -1)
              (sound-play "lay-eggs")
              )
            )
          )
        (suspend)
        (ja :num! (seek! max 1.4))
        )
      )
    (go mother-spider-birthing)
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; definition for method 20 of type mother-spider
;; Used lq/sq
(defmethod TODO-RENAME-20 mother-spider ((obj mother-spider) (arg0 vector) (arg1 vector))
  (set! (-> obj nav nav-cull-radius) 40960.0)
  (set-current-poly! (-> obj nav) (dummy-16 (-> obj nav) (-> obj root-override trans)))
  (TODO-RENAME-28 (-> obj nav) (collide-kind
                                 background
                                 cak-1
                                 cak-2
                                 cak-3
                                 target
                                 water
                                 powerup
                                 crate
                                 enemy
                                 wall-object
                                 projectile
                                 ground-object
                                 target-attack
                                 mother-spider
                                 cak-14
                                 blue-eco-suck
                                 unknown-16
                                 unknown-17
                                 unknown-18
                                 unknown-19
                                 unknown-20
                                 unknown-21
                                 unknown-22
                                 unknown-23
                                 unknown-24
                                 unknown-25
                                 unknown-26
                                 unknown-27
                                 unknown-28
                                 unknown-29
                                 unknown-30
                                 unknown-31
                                 unknown-32
                                 unknown-33
                                 unknown-34
                                 unknown-35
                                 unknown-36
                                 unknown-37
                                 unknown-38
                                 unknown-39
                                 unknown-40
                                 unknown-41
                                 unknown-42
                                 unknown-43
                                 unknown-44
                                 unknown-45
                                 unknown-46
                                 unknown-47
                                 unknown-48
                                 unknown-49
                                 unknown-50
                                 unknown-51
                                 unknown-52
                                 unknown-53
                                 unknown-54
                                 unknown-55
                                 unknown-56
                                 unknown-57
                                 unknown-58
                                 unknown-59
                                 unknown-60
                                 unknown-61
                                 unknown-62
                                 unknown-63
                                 )
                  )
  (dotimes (s3-1 4)
    (let ((f28-0 (+ 32768.0 (-> obj orient-rot y)))
          (f30-0 (rand-vu-float-range 16384.0 40960.0))
          )
      (let ((s1-0 (new 'stack-no-clear 'vector))
            (s2-1 (new 'stack-no-clear 'vector))
            )
        (let ((f28-1 (+ f28-0 (rand-vu-float-range -9102.223 9102.223))))
          (set-vector! s1-0 (sin f28-1) 0.0 (cos f28-1) 1.0)
          )
        (vector-float*! s2-1 s1-0 f30-0)
        (dummy-35 (-> obj nav) (-> obj nav travel) (-> obj root-override trans) s2-1 s1-0 f30-0)
        )
      (dummy-24 (-> obj nav) f30-0 (the-as clip-travel-vector-to-mesh-return-info #f))
      )
    (cond
      ((>= (vector-xz-length (-> obj nav travel)) 4096.0)
       (vector+! arg0 (-> obj root-override trans) (-> obj nav travel))
       (let ((s2-2 (new 'stack-no-clear 'collide-tri-result)))
         (cond
           ((>= (fill-and-probe-using-line-sphere
                  *collide-cache*
                  arg0
                  (new 'static 'vector :y -69632.0 :w 1.0)
                  40.96
                  (collide-kind background)
                  obj
                  s2-2
                  (new 'static 'pat-surface :noentity #x1)
                  )
                0.0
                )
            (set! (-> arg0 y) (-> s2-2 intersect y))
            (set! (-> arg1 quad) (-> s2-2 normal quad))
            (return #t)
            )
           (else
             0
             )
           )
         )
       )
      (else
        0
        )
      )
    )
  (project-onto-nav-mesh (-> obj nav) arg0 (-> obj root-override trans))
  (let ((a1-12 (new 'stack-no-clear 'vector))
        (s3-2 (new 'stack-no-clear 'collide-tri-result))
        )
    (set! (-> a1-12 quad) (-> arg0 quad))
    (set! (-> a1-12 y) (+ 8192.0 (-> a1-12 y)))
    (cond
      ((>= (fill-and-probe-using-line-sphere
             *collide-cache*
             a1-12
             (new 'static 'vector :y -69632.0 :w 1.0)
             40.96
             (collide-kind background)
             obj
             s3-2
             (new 'static 'pat-surface :noentity #x1)
             )
           0.0
           )
       (set! (-> arg0 y) (-> s3-2 intersect y))
       (set! (-> arg1 quad) (-> s3-2 normal quad))
       (return #t)
       )
      (else
        0
        )
      )
    )
  #f
  )

;; failed to figure out what this is:
(defstate mother-spider-hit-while-birthing (mother-spider)
  :event mother-spider-default-event-handler
  :enter (behavior ()
    (set! (-> self hit?) #f)
    (none)
    )
  :trans (behavior ()
    (if (-> self hit?)
        (go mother-spider-hit-while-birthing)
        )
    (if (= (-> self spin-vel) 0.0)
        (go mother-spider-birthing)
        )
    (TODO-RENAME-29 self #t #t)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (ja-no-eval :group! mother-spider-takes-hit-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (ja-channel-push! 1 (seconds 0.1))
    (loop
      (ja-no-eval :group! mother-spider-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mother-spider) transform-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-die-from-uppercut (mother-spider)
  :event mother-spider-death-event-handler
  :enter (behavior ()
    (shut-down! (-> self neck))
    (set! (-> self thread-speed) 122880.0)
    (set! (-> self targ-dist-from-anchor) (+ -24576.0 (-> self dist-from-anchor)))
    (let ((gp-0 (- 6 (-> self damage)))
          (s5-0 (-> self damage))
          )
      (set! (-> self damage) 6)
      (when (> gp-0 0)
        (dotimes (s4-0 gp-0)
          (let ((s0-0 (-> *mother-spider-leg-infos* s5-0))
                (s3-0 (new 'stack-no-clear 'vector))
                (s2-0 (new 'stack-no-clear 'vector))
                (s1-0 (new 'stack-no-clear 'vector))
                )
            (vector<-cspace! s3-0 (-> self node-list data (-> s0-0 joint-index0)))
            (vector<-cspace! s2-0 (-> self node-list data (-> s0-0 joint-index1)))
            (vector-! s2-0 s2-0 s3-0)
            (vector-normalize! s2-0 1.0)
            (set! (-> s1-0 quad) (-> s2-0 quad))
            (set! (-> s1-0 y) (+ 0.3 (-> s1-0 y)))
            (vector-normalize! s1-0 1.0)
            (process-spawn mother-spider-leg self s3-0 s2-0 s1-0 :to self)
            )
          (+! s5-0 1)
          )
        )
      )
    (none)
    )
  :trans (behavior ()
    (TODO-RENAME-29 self #f #f)
    (none)
    )
  :code (behavior ()
    (let ((v1-2 (-> self entity extra perm)))
      (logior! (-> v1-2 status) (entity-perm-status user-set-from-cstage))
      (set! (-> v1-2 user-int8 0) 1)
      )
    (logclear! (-> self mask) (process-mask actor-pause))
    (ja-channel-push! 1 (seconds 0.1))
    (clear-collide-with-as (-> self root-override))
    (ja-no-eval :group! mother-spider-die-from-uppercut-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (go mother-spider-die-wait-for-children)
    (none)
    )
  :post (the-as (function none :behavior mother-spider) ja-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-die (mother-spider)
  :event mother-spider-death-event-handler
  :trans (behavior ()
    (TODO-RENAME-29 self #f #f)
    (none)
    )
  :code (behavior ()
    (let ((v1-2 (-> self entity extra perm)))
      (logior! (-> v1-2 status) (entity-perm-status user-set-from-cstage))
      (set! (-> v1-2 user-int8 0) 1)
      )
    (shut-down! (-> self neck))
    (logclear! (-> self mask) (process-mask actor-pause))
    (ja-channel-push! 1 (seconds 0.1))
    (clear-collide-with-as (-> self root-override))
    (ja-no-eval :group! mother-spider-die-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (go mother-spider-die-wait-for-children)
    (none)
    )
  :post (the-as (function none :behavior mother-spider) ja-post)
  )

;; failed to figure out what this is:
(defstate mother-spider-die-wait-for-children (mother-spider)
  :event mother-spider-death-event-handler
  :code (behavior ()
    (logclear! (-> self mask) (process-mask actor-pause))
    (clear-collide-with-as (-> self root-override))
    (set! (-> self skel postbind-function) #f)
    (logior! (-> self draw status) (draw-status hidden))
    (while (-> self child)
      (suspend)
      )
    (cleanup-for-death self)
    (none)
    )
  )

;; definition for function mother-spider-full-joint-callback
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun mother-spider-full-joint-callback ((arg0 mother-spider))
  (/ (-> arg0 dist-from-anchor) (-> arg0 max-dist-from-anchor))
  (let ((a1-0 (the-as matrix #f)))
    (dotimes (s5-0 7)
      (let* ((v1-1 (the-as mother-spider-thread (+ (the-as uint *mother-spider-threads*) (* s5-0 16))))
             (s4-0 (-> arg0 node-list data (-> v1-1 joint-index) bone transform))
             )
        (vector-! (-> s4-0 vector 3) (-> arg0 root-override trans) (-> arg0 anchor-trans))
        (vector-float*! (-> s4-0 vector 3) (-> s4-0 vector 3) (-> v1-1 trans-u))
        (vector+! (-> s4-0 vector 3) (-> s4-0 vector 3) (-> arg0 anchor-trans))
        (let ((f1-2 (- (-> s4-0 vector 3 x) (-> arg0 anchor-trans x)))
              (f0-5 (- (-> s4-0 vector 3 z) (-> arg0 anchor-trans z)))
              )
          (set! (-> s4-0 vector 3 x) (+ (-> arg0 anchor-trans x) (* f1-2 (-> v1-1 swing-arc-u))))
          (set! (-> s4-0 vector 3 z) (+ (-> arg0 anchor-trans z) (* f0-5 (-> v1-1 swing-arc-u))))
          )
        (if a1-0
            (dummy-22 arg0 a1-0 (-> s4-0 vector 3))
            )
        (set! a1-0 s4-0)
        )
      )
    (let ((a0-11 (-> arg0 node-list data 22 bone transform))
          (a2-7 (new 'stack-no-clear 'vector))
          )
      (vector-! a2-7 (-> arg0 root-override trans) (-> a0-11 vector 3))
      (vector+! a2-7 a2-7 (-> arg0 root-override trans))
      (dummy-22 arg0 a1-0 a2-7)
      )
    )
  (dotimes (v1-16 (-> arg0 damage))
    (let ((a0-17 (-> *mother-spider-leg-infos* v1-16)))
      (let ((a1-5 (-> arg0 node-list data (-> a0-17 joint-index0) bone transform)))
        (set! (-> a1-5 vector 0 quad) (the-as uint128 0))
        (set! (-> a1-5 vector 1 quad) (the-as uint128 0))
        (set! (-> a1-5 vector 2 quad) (the-as uint128 0))
        )
      0
      (let ((a0-22 (-> arg0 node-list data (-> a0-17 joint-index1) bone transform)))
        (set! (-> a0-22 vector 0 quad) (the-as uint128 0))
        (set! (-> a0-22 vector 1 quad) (the-as uint128 0))
        (set! (-> a0-22 vector 2 quad) (the-as uint128 0))
        )
      )
    0
    )
  0
  (none)
  )

;; definition for method 22 of type mother-spider
(defmethod dummy-22 mother-spider ((obj mother-spider) (arg0 matrix) (arg1 vector))
  (rlet ((vf0 :class vf))
    (init-vf0-vector)
    (vector-! (-> arg0 vector 2) arg1 (-> arg0 vector 3))
    (vector-normalize! (-> arg0 vector 2) 1.0)
    (.svf (&-> (-> arg0 vector) 0 quad) vf0)
    (cond
      ((and (= (-> arg0 vector 2 x) 0.0) (= (-> arg0 vector 2 y) 0.0))
       (set! (-> arg0 vector 0 x) (-> arg0 vector 2 z))
       )
      (else
        (set! (-> arg0 vector 0 x) (- (-> arg0 vector 2 y)))
        (set! (-> arg0 vector 0 y) (-> arg0 vector 2 x))
        )
      )
    (vector-cross! (-> arg0 vector 1) (the-as vector (-> arg0 vector)) (-> arg0 vector 2))
    (vector-normalize! (-> arg0 vector 1) 1.0)
    (set! (-> arg0 vector 0 w) 0.0)
    (set! (-> arg0 vector 1 w) 0.0)
    (let ((f0-8 0.0))
      (set! (-> arg0 vector 2 w) f0-8)
      f0-8
      )
    )
  )

;; definition for method 12 of type mother-spider
(defmethod run-logic? mother-spider ((obj mother-spider))
  (or (zero? (logand (-> obj mask) (process-mask actor-pause)))
      (or (< (vector-vector-xz-distance (-> obj root-override trans) (math-camera-pos)) (-> obj deactivate-xz-dist))
          (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 7 of type mother-spider
;; INFO: Return type mismatch process-drawable vs mother-spider.
(defmethod relocate mother-spider ((obj mother-spider) (arg0 int))
  (if (nonzero? (-> obj neck))
      (&+! (-> obj neck) arg0)
      )
  (the-as mother-spider ((method-of-type process-drawable relocate) obj arg0))
  )

;; definition for method 11 of type mother-spider
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defmethod init-from-entity! mother-spider ((obj mother-spider) (arg0 entity-actor))
  (local-vars (sv-16 res-tag) (sv-64 vector))
  (set! (-> obj baby-count) 0)
  (set! (-> obj spit-counter) 0)
  (set! (-> obj leg-socket-part-mask) 0)
  (set! (-> obj mode) (the-as uint 0))
  (set! (-> obj damage) 0)
  (set! (-> obj player-attack-id) (the-as uint 0))
  (set! (-> obj spin-vel) 0.0)
  (set! (-> obj thread-speed) 245760.0)
  (set! (-> obj thread-vel) 0.0)
  (set! (-> obj hit?) #f)
  (set! (-> obj last-update-time) 0)
  (set! (-> obj spawned-time) (-> *display* base-frame-counter))
  (set! (-> obj spin-time) (-> *display* base-frame-counter))
  (set! (-> obj last-spit-time) 0)
  (set! (-> obj started-birthing-time) 0)
  (set! (-> obj check-z-thresh?) #f)
  (set! (-> obj activate-z-thresh) 0.0)
  (set! (-> obj deactivate-z-thresh) 0.0)
  (vector-reset! (-> obj swing-pos))
  (vector-reset! (-> obj swing-base-pos))
  (vector-reset! (-> obj swing-vel))
  (when (name= (-> obj name) "mother-spider-7")
    (set! (-> obj check-z-thresh?) #t)
    (set! (-> obj activate-z-thresh) -12288.0)
    (set! (-> obj deactivate-z-thresh) 24985.6)
    )
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum usually-hit-by-player))))
    (let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 9) 0)))
      (set! (-> s3-0 prim-core collide-as) (collide-kind mother-spider))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 transform-index) 6)
      (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 12697.6)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-0 transform-index) 6)
        (set-vector! (-> s2-0 local-sphere) 0.0 0.0 0.0 4505.6)
        (append-prim s3-0 s2-0)
        )
      (let ((s2-1 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-1 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-1 collide-with) (collide-kind target))
        (set! (-> s2-1 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-1 transform-index) 5)
        (set-vector! (-> s2-1 local-sphere) 0.0 0.0 0.0 4505.6)
        (append-prim s3-0 s2-1)
        )
      (let ((s2-2 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-2 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-2 collide-with) (collide-kind target))
        (set! (-> s2-2 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-2 transform-index) 20)
        (set-vector! (-> s2-2 local-sphere) 0.0 -409.6 1228.8 2457.6)
        (append-prim s3-0 s2-2)
        )
      (let ((s2-3 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-3 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-3 collide-with) (collide-kind target))
        (set! (-> s2-3 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-3 transform-index) 12)
        (set-vector! (-> s2-3 local-sphere) 0.0 0.0 0.0 2048.0)
        (append-prim s3-0 s2-3)
        )
      (let ((s2-4 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-4 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-4 collide-with) (collide-kind target))
        (set! (-> s2-4 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-4 transform-index) 10)
        (set-vector! (-> s2-4 local-sphere) 0.0 0.0 0.0 2048.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 mother-spider))
        (set! (-> s2-5 collide-with) (collide-kind target))
        (set! (-> s2-5 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-5 transform-index) 8)
        (set-vector! (-> s2-5 local-sphere) 0.0 0.0 0.0 2048.0)
        (append-prim s3-0 s2-5)
        )
      (let ((s2-6 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-6 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-6 collide-with) (collide-kind target))
        (set! (-> s2-6 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-6 transform-index) 18)
        (set-vector! (-> s2-6 local-sphere) 0.0 0.0 0.0 2048.0)
        (append-prim s3-0 s2-6)
        )
      (let ((s2-7 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-7 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-7 collide-with) (collide-kind target))
        (set! (-> s2-7 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-7 transform-index) 16)
        (set-vector! (-> s2-7 local-sphere) 0.0 0.0 0.0 2048.0)
        (append-prim s3-0 s2-7)
        )
      (let ((s2-8 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-8 prim-core collide-as) (collide-kind mother-spider))
        (set! (-> s2-8 collide-with) (collide-kind target))
        (set! (-> s2-8 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-8 transform-index) 14)
        (set-vector! (-> s2-8 local-sphere) 0.0 0.0 0.0 2048.0)
        (append-prim s3-0 s2-8)
        )
      )
    (set! (-> s4-0 nav-radius) 4096.0)
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *mother-spider-sg* '())
  (set! (-> obj nav) (new 'process 'nav-control (-> obj root-override) 16 40960.0))
  (logior! (-> obj nav flags) (nav-control-flags display-marks navcf3 navcf5 navcf6 navcf7))
  (set! (-> obj nav nearest-y-threshold) 409600.0)
  (logclear! (-> obj root-override nav-flags) (nav-flags navf0))
  (logclear! (-> obj root-override nav-flags) (nav-flags navf1))
  (set! (-> obj path) (new 'process 'path-control obj 'path 0.0))
  (logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text))
  (set! (-> obj fact)
        (new 'process 'fact-info-enemy obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
        )
  (set! (-> obj draw shadow-ctrl) (new 'process 'shadow-control 0.0 0.0 4096000.0 (the-as float 60) 245760.0))
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 618) obj))
  (logior! (-> obj skel status) (janim-status inited))
  (let ((v0-30 (new 'process 'joint-mod (joint-mod-handler-mode reset) obj 19)))
    (set! (-> obj neck) v0-30)
    (set-vector! (-> obj neck twist-max) 8192.0 8192.0 0.0 1.0)
    (set! (-> v0-30 up) (the-as uint 1))
    (set! (-> v0-30 nose) (the-as uint 2))
    (set! (-> v0-30 ear) (the-as uint 0))
    (set! (-> v0-30 max-dist) 102400.0)
    (set! (-> v0-30 ignore-angle) 16384.0)
    )
  (set! (-> obj thread-min-trans quad) (-> obj root-override trans quad))
  (set! (-> obj anchor-trans quad) (-> obj root-override trans quad))
  (set! (-> obj max-swing-radius) 73728.0)
  (set! (-> obj max-baby-count) 4)
  (let ((s4-1 #f))
    (set! sv-16 (new 'static 'res-tag))
    (let ((v0-31 (res-lump-data arg0 'mother-spider pointer :tag-ptr (& sv-16))))
      (cond
        (v0-31
          (+! (-> obj thread-min-trans y) (-> (the-as (pointer float) v0-31) 0))
          (+! (-> obj anchor-trans y) (-> (the-as (pointer float) v0-31) 1))
          (set! (-> obj max-swing-radius) (-> (the-as (pointer float) v0-31) 2))
          (set! (-> obj max-baby-count) (the int (-> (the-as (pointer float) v0-31) 3)))
          (set! s4-1 (!= (-> (the-as (pointer float) v0-31) 4) 0.0))
          (set! (-> obj max-spit-xz-dist) (-> (the-as (pointer float) v0-31) 5))
          (set! (-> obj activate-xz-dist) (-> (the-as (pointer float) v0-31) 6))
          (set! (-> obj deactivate-xz-dist) (-> (the-as (pointer float) v0-31) 7))
          )
        (else
          (set! (-> obj thread-min-trans y) (+ 28672.0 (-> obj thread-min-trans y)))
          (set! (-> obj anchor-trans y) (+ 204800.0 (-> obj anchor-trans y)))
          (set! (-> obj max-spit-xz-dist) 81920.0)
          (set! (-> obj activate-xz-dist) 143360.0)
          (set! (-> obj deactivate-xz-dist) 163430.4)
          )
        )
      )
    (set! (-> obj thread-min-trans w) 1.0)
    (set! (-> obj anchor-trans w) 1.0)
    (set! (-> obj idle-dist-from-anchor) 16384.0)
    (set! (-> obj max-dist-from-anchor) (- (-> obj anchor-trans y) (-> obj thread-min-trans y)))
    (set! (-> obj player-sticky-dist-from-anchor) (-> obj max-dist-from-anchor))
    (set! (-> obj targ-dist-from-anchor) (-> obj idle-dist-from-anchor))
    (set! (-> obj root-override trans quad) (-> obj anchor-trans quad))
    (set! (-> obj root-override trans y) (- (-> obj root-override trans y) (-> obj idle-dist-from-anchor)))
    (set-vector! (-> obj orient-rot) 0.0 0.0 0.0 1.0)
    (quaternion-zxy! (-> obj root-override quat) (-> obj orient-rot))
    (ja-channel-push! 1 0)
    (let ((s5-1 (-> obj skel root-channel 0)))
      (joint-control-channel-group-eval!
        s5-1
        (the-as art-joint-anim (-> obj draw art-group data 5))
        num-func-identity
        )
      (set! (-> s5-1 frame-num) 0.0)
      )
    (transform-post)
    (create-connection!
      *cavecrystal-light-control*
      obj
      (-> obj entity)
      (the-as (function object object object object object) cavecrystal-light-control-default-callback)
      -1
      10240.0
      )
    (let ((v1-121 #f))
      (if (nonzero? (-> obj entity extra perm user-int8 0))
          (set! v1-121 #t)
          )
      (cond
        (v1-121
          (go mother-spider-die-wait-for-children)
          )
        (else
          (when s4-1
            (let ((s5-3 (max 0 (min (+ (-> obj path curve num-cverts) -1) (-> obj max-baby-count))))
                  (s4-2 (new 'stack-no-clear 'vector))
                  (s3-1 (new 'stack-no-clear 'vector))
                  )
              (dotimes (s2-9 s5-3)
                (eval-path-curve-div! (-> obj path) s4-2 (the float s2-9) 'interp)
                (vector-! s3-1 (target-pos 0) s4-2)
                (set! (-> s3-1 y) 0.0)
                (let ((s1-2 vector-rotate-around-y!)
                      (s0-0 s3-1)
                      )
                  (set! sv-64 s3-1)
                  (let ((a2-21 (rand-vu-float-range -7281.778 7281.778)))
                    (s1-2 s0-0 sv-64 a2-21)
                    )
                  )
                (vector-normalize! s3-1 1.0)
                (spawn-child obj s4-2 s3-1 #f)
                )
              )
            )
          (logclear! (-> obj mask) (process-mask actor-pause))
          (go mother-spider-idle)
          )
        )
      )
    )
  (none)
  )
