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

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

;; failed to figure out what this is:
(defskelgroup *junglesnake-sg* junglesnake junglesnake-lod0-jg junglesnake-idle-ja
              ((junglesnake-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 14 0 18)
              :longest-edge (meters 2.5)
              )

;; failed to figure out what this is:
(defpartgroup group-junglesnake-dropping-down
  :id 173
  :flags (use-local-clock)
  :bounds (static-bspherem 0 -12 0 14)
  :parts ((sp-item 799 :period 300 :length 150))
  )

;; failed to figure out what this is:
(defpart 799
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-x (meters -9) (meters 18) 1.0)
    (sp-flt spt-y (meters -6))
    (sp-rnd-flt spt-z (meters -9) (meters 18) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 32.0 40.0 1.0)
    (sp-rnd-flt spt-g 32.0 40.0 1.0)
    (sp-rnd-flt spt-b 32.0 40.0 1.0)
    (sp-flt spt-a 128.0)
    (sp-rnd-flt spt-vel-y (meters 0) (meters -0.04) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -0.3) (degrees 0.6) 1.0)
    (sp-rnd-flt spt-accel-y -6.826667 -0.68266666 1.0)
    (sp-int spt-timer 390)
    (sp-cpuinfo-flags bit2)
    (sp-flt spt-userdata 0.0)
    (sp-func spt-func 'check-water-level-drop)
    )
  )

;; definition of type junglesnake-twist-joint
(deftype junglesnake-twist-joint (structure)
  ((joint-index   int32  :offset-assert   0)
   (ry            float  :offset-assert   4)
   (drag-delta-ry float  :offset-assert   8)
   )
  :allow-misaligned
  :method-count-assert 9
  :size-assert         #xc
  :flag-assert         #x90000000c
  )

;; definition for method 3 of type junglesnake-twist-joint
(defmethod inspect junglesnake-twist-joint ((obj junglesnake-twist-joint))
  (format #t "[~8x] ~A~%" obj 'junglesnake-twist-joint)
  (format #t "~Tjoint-index: ~D~%" (-> obj joint-index))
  (format #t "~Try: ~f~%" (-> obj ry))
  (format #t "~Tdrag-delta-ry: ~f~%" (-> obj drag-delta-ry))
  obj
  )

;; definition of type junglesnake-tilt-joint
(deftype junglesnake-tilt-joint (structure)
  ((joint-index int32   :offset-assert   0)
   (flip-it     symbol  :offset-assert   4)
   )
  :allow-misaligned
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for method 3 of type junglesnake-tilt-joint
(defmethod inspect junglesnake-tilt-joint ((obj junglesnake-tilt-joint))
  (format #t "[~8x] ~A~%" obj 'junglesnake-tilt-joint)
  (format #t "~Tjoint-index: ~D~%" (-> obj joint-index))
  (format #t "~Tflip-it: ~A~%" (-> obj flip-it))
  obj
  )

;; definition of type junglesnake
(deftype junglesnake (process-drawable)
  ((root-override     collide-shape                      :offset        112)
   (state-time2       time-frame                         :offset-assert 176)
   (hit-player        symbol                             :offset        184)
   (is-lethal?        symbol                             :offset-assert 188)
   (refractory-delay  int32                              :offset-assert 192)
   (ry                float                              :offset-assert 196)
   (des-ry            float                              :offset-assert 200)
   (tilt              float                              :offset-assert 204)
   (des-tilt          float                              :offset-assert 208)
   (track-player-ry   symbol                             :offset-assert 212)
   (track-player-tilt symbol                             :offset-assert 216)
   (twist-joints      junglesnake-twist-joint 24 :inline :offset        220)
   (tilt-joints       junglesnake-tilt-joint  3 :inline  :offset        604)
   )
  :heap-base #x220
  :method-count-assert 25
  :size-assert         #x28c
  :flag-assert         #x190220028c
  (:methods
    (dummy-20 (_type_) symbol 20)
    (dummy-21 (_type_) symbol 21)
    (dummy-22 (_type_ float) symbol 22)
    (dummy-23 (_type_) none 23)
    (dummy-24 (_type_) none 24)
    )
  (:states
    junglesnake-attack
    junglesnake-die
    junglesnake-give-up
    junglesnake-sleeping
    junglesnake-tracking
    junglesnake-wake
    )
  )

;; definition for method 3 of type junglesnake
(defmethod inspect junglesnake ((obj junglesnake))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tstate-time: ~D~%" (-> obj state-time))
  (format #t "~T~Thit-player: ~A~%" (-> obj hit-player))
  (format #t "~T~Tis-lethal?: ~A~%" (-> obj is-lethal?))
  (format #t "~T~Trefractory-delay: ~D~%" (-> obj refractory-delay))
  (format #t "~T~Try: ~f~%" (-> obj ry))
  (format #t "~T~Tdes-ry: ~f~%" (-> obj des-ry))
  (format #t "~T~Ttilt: ~f~%" (-> obj tilt))
  (format #t "~T~Tdes-tilt: ~f~%" (-> obj des-tilt))
  (format #t "~T~Ttrack-player-ry: ~A~%" (-> obj track-player-ry))
  (format #t "~T~Ttrack-player-tilt: ~A~%" (-> obj track-player-tilt))
  (format #t "~T~Ttwist-joints[24] @ #x~X~%" (-> obj twist-joints))
  (format #t "~T~Ttilt-joints[3] @ #x~X~%" (-> obj tilt-joints))
  obj
  )

;; definition for function junglesnake-default-event-handler
;; WARN: disable def twice: 39. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
(defbehavior junglesnake-default-event-handler junglesnake ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('touch)
     (when (and *target* ((method-of-type touching-shapes-entry prims-touching?)
                          (the-as touching-shapes-entry (-> arg3 param 0))
                          (the-as collide-shape-moving (-> self root-override))
                          (the-as uint 1)
                          )
                )
       (cond
         ((and (-> self is-lethal?)
               (zero? (logand (-> *target* state-flags)
                              (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)
                              )
                      )
               )
          (when (send-event arg0 'attack (-> arg3 param 0) (new 'static 'attack-info))
            (let ((v0-1 (the-as object #t)))
              (set! (-> self hit-player) (the-as symbol v0-1))
              v0-1
              )
            )
          )
         (else
           (do-push-aways! (-> self root-override))
           (send-event
             arg0
             'shove
             (-> arg3 param 0)
             (static-attack-info ((shove-back (meters 2)) (shove-up (meters 0.5))))
             )
           )
         )
       )
     )
    (('attack)
     (go junglesnake-die)
     )
    )
  )

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

;; definition for method 20 of type junglesnake
(defmethod dummy-20 junglesnake ((obj junglesnake))
  (when (and *target* (-> obj track-player-ry))
    (let ((v1-3 (target-pos 0)))
      (set! (-> obj des-ry)
            (atan (- (-> v1-3 x) (-> obj root-override trans x)) (- (-> v1-3 z) (-> obj root-override trans z)))
            )
      )
    )
  (let ((f0-7 (deg-diff (-> obj ry) (-> obj des-ry))))
    (+! (-> obj ry) (seek-with-smooth 0.0 f0-7 (* 655360.0 (-> *display* seconds-per-frame)) 0.125 0.001))
    )
  (let ((f30-1 (-> obj ry)))
    (dotimes (s5-0 24)
      (let ((s4-0 (-> obj twist-joints s5-0)))
        (let ((f28-0 (-> s4-0 drag-delta-ry)))
          (cond
            ((= f28-0 0.0)
             (set! (-> s4-0 ry) f30-1)
             )
            (else
              (let ((f26-0 (-> s4-0 ry)))
                (let ((f0-14 (deg-diff f30-1 (-> s4-0 ry))))
                  (if (< f28-0 (fabs f0-14))
                      (set! f26-0 (if (>= f0-14 0.0)
                                      (+ f30-1 f28-0)
                                      (- f30-1 f28-0)
                                      )
                            )
                      )
                  )
                (let ((f0-16 (deg-diff (-> s4-0 ry) f26-0)))
                  (+! (-> s4-0 ry) (seek-with-smooth 0.0 f0-16 (* 327680.0 (-> *display* seconds-per-frame)) 0.25 0.001))
                  )
                )
              )
            )
          )
        (set! f30-1 (-> s4-0 ry))
        )
      )
    )
  #f
  )

;; definition for function junglesnake-joint-callback
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun junglesnake-joint-callback ((arg0 junglesnake))
  (let ((s5-0 arg0))
    (let ((s4-0 (new 'stack-no-clear 'matrix))
          (s3-0 (new 'stack-no-clear 'matrix))
          (s2-0 (new 'stack-no-clear 'matrix))
          )
      (let ((s1-0 (new 'stack-no-clear 'vector)))
        (set-vector!
          s1-0
          (-> arg0 root-override trans x)
          (-> arg0 root-override trans y)
          (-> arg0 root-override trans z)
          1.0
          )
        (matrix-translate! s2-0 s1-0)
        (vector-negate! s1-0 s1-0)
        (matrix-translate! s3-0 s1-0)
        )
      (dotimes (s1-1 24)
        (let ((s0-0 (-> s5-0 twist-joints s1-1)))
          (matrix-rotate-y! s4-0 (-> s0-0 ry))
          (let ((s0-1 (-> arg0 node-list data (-> s0-0 joint-index) bone transform)))
            (matrix*! s0-1 s0-1 s3-0)
            (matrix*! s0-1 s0-1 s4-0)
            (matrix*! s0-1 s0-1 s2-0)
            )
          )
        )
      )
    (dotimes (s4-1 9)
      (let ((s3-1 (-> arg0 node-list data (+ s4-1 11) bone transform)))
        (let ((a0-14 (-> arg0 node-list data (+ s4-1 12) bone transform))
              (a1-7 (new 'stack-no-clear 'vector))
              )
          (vector-! a1-7 (-> a0-14 vector 3) (-> s3-1 vector 3))
          (vector-normalize-copy! (-> s3-1 vector 1) a1-7 1.0)
          )
        (set! (-> s3-1 vector 1 w) 0.0)
        (vector-normalize! (vector-cross! (-> s3-1 vector 2) (the-as vector (-> s3-1 vector)) (-> s3-1 vector 1)) 1.0)
        (vector-normalize! (vector-cross! (the-as vector (-> s3-1 vector)) (-> s3-1 vector 1) (-> s3-1 vector 2)) 1.0)
        )
      )
    (cond
      ((and (-> s5-0 track-player-tilt) *target*)
       (let ((s2-1 (-> arg0 node-list data 25 bone transform))
             (s4-2 (new 'stack-no-clear 'vector))
             )
         (vector-normalize-copy! s4-2 (-> s2-1 vector 1) 1.0)
         (set! (-> s4-2 w) 1.0)
         (let ((s1-2 (new 'stack-no-clear 'vector)))
           (vector-! s1-2 (target-pos 0) (-> s2-1 vector 3))
           (set! (-> s1-2 y) (+ 9011.2 (-> s1-2 y)))
           (vector-normalize! s1-2 1.0)
           (let ((s0-2 (new 'stack-no-clear 'vector))
                 (s3-4 (new 'stack-no-clear 'vector))
                 )
             (vector-normalize-copy! s0-2 (-> s2-1 vector 2) 1.0)
             (vector-flatten! s3-4 s1-2 s0-2)
             (vector-normalize! s3-4 1.0)
             (let ((f30-0 (acos (vector-dot s4-2 s3-4))))
               (if (< (-> s4-2 y) (-> s3-4 y))
                   (set! f30-0 (- f30-0))
                   )
               (cond
                 ((< 7281.778 f30-0)
                  (set! f30-0 7281.778)
                  )
                 ((< f30-0 -11650.845)
                  (set! f30-0 -11650.845)
                  )
                 )
               (let ((f0-16 (fabs (deg-diff (-> s5-0 ry) (-> s5-0 des-ry)))))
                 (if (>= f0-16 24576.0)
                     (set! f30-0 (* 0.00012207031 (- 32768.0 f0-16) f30-0))
                     )
                 )
               (set! (-> s5-0 des-tilt) f30-0)
               )
             )
           )
         )
       )
      (else
        (set! (-> s5-0 des-tilt) 0.0)
        )
      )
    (let* ((f30-1 (-> s5-0 tilt))
           (f0-21 (deg-diff f30-1 (-> s5-0 des-tilt)))
           (f28-0 (+ f30-1 (seek-with-smooth 0.0 f0-21 (* 65536.0 (-> *display* seconds-per-frame)) 0.2 0.001)))
           )
      (set! (-> s5-0 tilt) f28-0)
      (let ((f30-2 (cos f28-0))
            (f28-1 (sin f28-0))
            (s4-3 (new 'stack-no-clear 'matrix))
            (s3-5 (new 'stack-no-clear 'matrix))
            )
        (matrix-identity! s4-3)
        (set! (-> s4-3 vector 0 x) f30-2)
        (set! (-> s4-3 vector 0 y) f28-1)
        (set! (-> s4-3 vector 1 x) (- f28-1))
        (set! (-> s4-3 vector 1 y) f30-2)
        (let* ((a2-9 s3-5)
               (a3-1 s4-3)
               (v1-47 (-> a3-1 vector 0 quad))
               (a0-36 (-> a3-1 vector 1 quad))
               (a1-20 (-> a3-1 vector 2 quad))
               (a3-2 (-> a3-1 vector 3 quad))
               )
          (set! (-> a2-9 vector 0 quad) v1-47)
          (set! (-> a2-9 vector 1 quad) a0-36)
          (set! (-> a2-9 vector 2 quad) a1-20)
          (set! (-> a2-9 vector 3 quad) a3-2)
          )
        (set! (-> s3-5 vector 0 y) (- (-> s3-5 vector 0 y)))
        (set! (-> s3-5 vector 1 x) (- (-> s3-5 vector 1 x)))
        (dotimes (s2-2 3)
          (let* ((v1-50 (-> s5-0 tilt-joints s2-2))
                 (a2-10 (-> arg0 node-list data (-> v1-50 joint-index) bone transform))
                 )
            (if (-> v1-50 flip-it)
                (matrix*! a2-10 s3-5 a2-10)
                (matrix*! a2-10 s4-3 a2-10)
                )
            )
          )
        )
      )
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defstate junglesnake-sleeping (junglesnake)
  :event junglesnake-default-event-handler
  :enter (behavior ()
    (set! (-> self skel postbind-function) #f)
    (set! (-> self track-player-ry) #f)
    (set! (-> self track-player-tilt) #f)
    (set! (-> self des-ry) (-> self ry))
    (set! (-> self des-tilt) (-> self tilt))
    (logior! (-> self draw status) (draw-status hidden))
    (none)
    )
  :trans (behavior ()
    (when *target*
      (let* ((a0-1 (target-pos 0))
             (f0-1 (- (-> a0-1 y) (-> self root-override trans y)))
             )
        (if (and (>= 40960.0 f0-1) (>= 143360.0 (vector-vector-xz-distance a0-1 (-> self root-override trans))))
            (go junglesnake-wake)
            )
        )
      )
    (none)
    )
  :code (behavior ()
    (logior! (-> self mask) (process-mask sleep-code))
    (suspend)
    0
    (none)
    )
  )

;; failed to figure out what this is:
(defstate junglesnake-wake (junglesnake)
  :event junglesnake-default-event-handler
  :enter (behavior ()
    (logclear! (-> self draw status) (draw-status hidden))
    (set! (-> self track-player-ry) #f)
    (set! (-> self track-player-tilt) #f)
    (set! (-> self skel postbind-function) junglesnake-joint-callback)
    (set! (-> self refractory-delay) 0)
    0
    (none)
    )
  :trans (behavior ()
    (dummy-20 self)
    (when *target*
      (if *target*
          (look-at-enemy!
            (-> *target* neck)
            (the-as vector (-> (the-as collide-shape-prim-group (-> self root-override root-prim)) prims 0 prim-core))
            'attacking
            self
            )
          )
      )
    (none)
    )
  :code (behavior ()
    (ja-no-eval :group! junglesnake-drop-down-ja :num! (seek! max 0.85) :frame-num 0.5)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek! max 0.85))
      )
    (go junglesnake-tracking)
    (none)
    )
  :post (the-as (function none :behavior junglesnake) transform-post)
  )

;; failed to figure out what this is:
(defstate junglesnake-tracking (junglesnake)
  :event junglesnake-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self track-player-ry) #t)
    (set! (-> self track-player-tilt) #t)
    (none)
    )
  :trans (behavior ()
    (if (and (and *target* (>= 24576.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))))
             (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self refractory-delay))
             (zero? (logand (-> *target* state-flags)
                            (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)
                            )
                    )
             )
        (go junglesnake-attack)
        )
    (when *target*
      (let ((a0-8 (target-pos 0)))
        (if (or (>= (- (-> a0-8 y) (-> self root-override trans y)) 57344.0)
                (>= (vector-vector-xz-distance a0-8 (-> self root-override trans)) 163840.0)
                )
            (go junglesnake-give-up)
            )
        )
      )
    (dummy-20 self)
    (when *target*
      (if *target*
          (look-at-enemy!
            (-> *target* neck)
            (the-as vector (-> (the-as collide-shape-prim-group (-> self root-override root-prim)) prims 0 prim-core))
            'attacking
            self
            )
          )
      )
    (none)
    )
  :code (behavior ()
    (cond
      ((ja-group? junglesnake-idle-ja)
       (while (not (ja-done? 0))
         (suspend)
         (ja :num! (seek!))
         )
       )
      (else
        (ja-channel-push! 1 (seconds 0.15))
        )
      )
    (loop
      (ja-no-eval :group! junglesnake-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior junglesnake) transform-post)
  )

;; failed to figure out what this is:
(defstate junglesnake-attack (junglesnake)
  :event junglesnake-default-event-handler
  :enter (behavior ()
    (set! (-> self hit-player) #f)
    (none)
    )
  :exit (behavior ()
    (dummy-24 self)
    (none)
    )
  :trans (behavior ()
    (dummy-20 self)
    (when *target*
      (if *target*
          (look-at-enemy!
            (-> *target* neck)
            (the-as vector (-> (the-as collide-shape-prim-group (-> self root-override root-prim)) prims 0 prim-core))
            'attacking
            self
            )
          )
      )
    (none)
    )
  :code (behavior ()
    (set! (-> self track-player-ry) #t)
    (set! (-> self track-player-tilt) #t)
    (ja-channel-push! 2 (seconds 0.15))
    (dummy-23 self)
    (let ((f30-0 (lerp-scale 0.0 1.0 (vector-vector-distance (target-pos 0) (-> self root-override trans)) 0.0 24576.0))
          )
      (ja-no-eval :group! junglesnake-strike-close-ja :num! (seek! max 1.25) :frame-num 0.0)
      (ja-no-eval :chan 1 :group! junglesnake-strike-far-ja :num! (chan 0) :frame-interp f30-0 :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (set! f30-0
              (seek
                f30-0
                (lerp-scale 0.0 1.0 (vector-vector-distance (target-pos 0) (-> self root-override trans)) 0.0 24576.0)
                (* 2.0 (-> *display* seconds-per-frame))
                )
              )
        (ja :num! (seek! max 1.25))
        (ja :chan 1 :num! (chan 0) :frame-interp f30-0)
        (let ((f0-12 (ja-aframe-num 0)))
          (cond
            ((and (>= f0-12 22.0) (< f0-12 44.0))
             (if (not (-> self is-lethal?))
                 (dummy-23 self)
                 )
             )
            (else
              (if (-> self is-lethal?)
                  (dummy-24 self)
                  )
              )
            )
          )
        )
      )
    (if (-> self hit-player)
        (set! (-> self refractory-delay) (rand-vu-int-range 300 600))
        (set! (-> self refractory-delay) (rand-vu-int-range 150 300))
        )
    (go junglesnake-tracking)
    (none)
    )
  :post (the-as (function none :behavior junglesnake) transform-post)
  )

;; failed to figure out what this is:
(defstate junglesnake-give-up (junglesnake)
  :event junglesnake-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self track-player-ry) #f)
    (set! (-> self track-player-tilt) #f)
    (set! (-> self des-ry) (-> self ry))
    (set! (-> self des-tilt) (-> self tilt))
    (none)
    )
  :trans (behavior ()
    (dummy-20 self)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (let ((s5-0 (new 'stack-no-clear 'vector)))
        (set! (-> gp-0 quad) (-> self root-override trans quad))
        (set! (-> s5-0 quad) (-> gp-0 quad))
        (set! (-> s5-0 y) (+ 131072.0 (-> s5-0 y)))
        (ja-no-eval :group! junglesnake-give-up-ja :num! (seek! max 0.5) :frame-num 0.0)
        (until (ja-done? 0)
          (let* ((f0-6 (ja-frame-num 0))
                 (v1-18 (ja-group))
                 (f0-7 (/ f0-6 (the float (+ (-> v1-18 data 0 length) -1))))
                 (s4-0 (new 'stack-no-clear 'vector))
                 )
            (set-vector! (-> self root-override scale) 1.0 (- 1.0 f0-7) 1.0 1.0)
            (vector-lerp! s4-0 gp-0 s5-0 f0-7)
            (move-to-point! (-> self root-override) s4-0)
            )
          (suspend)
          (ja :num! (seek! max 0.5))
          )
        )
      (move-to-point! (-> self root-override) gp-0)
      )
    (set-vector! (-> self root-override scale) 1.0 1.0 1.0 1.0)
    (go junglesnake-sleeping)
    (none)
    )
  :post (the-as (function none :behavior junglesnake) transform-post)
  )

;; failed to figure out what this is:
(defstate junglesnake-die (junglesnake)
  :event (the-as
    (function process int symbol event-message-block object :behavior junglesnake)
    process-drawable-death-event-handler
    )
  :code (behavior ()
    (logclear! (-> self mask) (process-mask actor-pause))
    (clear-collide-with-as (-> self root-override))
    (ja-channel-push! 1 (seconds 0.15))
    (ja-no-eval :group! junglesnake-death-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (cleanup-for-death self)
    (none)
    )
  :post (the-as (function none :behavior junglesnake) ja-post)
  )

;; definition for method 23 of type junglesnake
;; INFO: Return type mismatch int vs none.
(defmethod dummy-23 junglesnake ((obj junglesnake))
  (when (not (-> obj is-lethal?))
    (set! (-> obj is-lethal?) #t)
    (let ((v1-5 (-> (the-as collide-shape-prim-group (-> obj root-override root-prim)) prims 0)))
      (logclear! (-> v1-5 prim-core action) (collide-action solid))
      )
    )
  0
  (none)
  )

;; definition for method 24 of type junglesnake
;; INFO: Return type mismatch int vs none.
(defmethod dummy-24 junglesnake ((obj junglesnake))
  (when (-> obj is-lethal?)
    (set! (-> obj is-lethal?) #f)
    (let ((v1-4 (-> (the-as collide-shape-prim-group (-> obj root-override root-prim)) prims 0)))
      (logior! (-> v1-4 prim-core action) (collide-action solid))
      )
    (do-push-aways! (-> obj root-override))
    )
  0
  (none)
  )

;; definition for symbol *junglesnake-twist-max-deltas*, type (pointer float)
(define *junglesnake-twist-max-deltas* (new 'static 'array float 28
                                         0.0
                                         0.0
                                         0.0
                                         0.0
                                         0.0
                                         0.0
                                         546.13336
                                         1092.2667
                                         1638.4
                                         2184.5334
                                         2730.6667
                                         3276.8
                                         3822.9333
                                         4369.067
                                         4915.2
                                         5461.3335
                                         6007.467
                                         6553.6
                                         7099.7334
                                         7645.8667
                                         8192.0
                                         8738.134
                                         9284.267
                                         9830.4
                                         10376.533
                                         0.0
                                         0.0
                                         0.0
                                         )
        )

;; definition for method 22 of type junglesnake
(defmethod dummy-22 junglesnake ((obj junglesnake) (arg0 float))
  (let ((f0-0 0.0))
    (dotimes (v1-0 24)
      (let ((a2-2 (-> obj twist-joints v1-0)))
        (set! (-> a2-2 ry) arg0)
        (set! (-> a2-2 joint-index) (- 26 v1-0))
        (let ((f1-1 (-> *junglesnake-twist-max-deltas* v1-0)))
          (set! (-> a2-2 drag-delta-ry) (- f1-1 f0-0))
          (set! f0-0 f1-1)
          )
        )
      )
    )
  #f
  )

;; definition for method 21 of type junglesnake
(defmethod dummy-21 junglesnake ((obj junglesnake))
  (dotimes (v1-0 3)
    (let ((a1-2 (-> obj tilt-joints v1-0)))
      (set! (-> a1-2 joint-index) (+ v1-0 23))
      (set! (-> a1-2 flip-it) #f)
      )
    )
  (let ((v1-3 (the-as object (&-> obj stack 524))))
    (set! (-> (the-as junglesnake-tilt-joint v1-3) flip-it) #t)
    )
  (let ((v1-4 (the-as object (&-> obj stack 476)))
        (v0-0 #t)
        )
    (set! (-> (the-as junglesnake-twist-joint v1-4) ry) (the-as float v0-0))
    v0-0
    )
  )

;; definition for method 11 of type junglesnake
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! junglesnake ((obj junglesnake) (arg0 entity-actor))
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum 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 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 16384.0 0.0 30720.0)
      (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 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 touch))
        (set! (-> s2-0 transform-index) 25)
        (set-vector! (-> s2-0 local-sphere) 0.0 2048.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 touch))
        (set! (-> s2-1 transform-index) 21)
        (set-vector! (-> s2-1 local-sphere) 0.0 0.0 0.0 3276.8)
        (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 touch))
        (set! (-> s2-2 transform-index) 20)
        (set-vector! (-> s2-2 local-sphere) 0.0 0.0 0.0 3276.8)
        (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 touch))
        (set! (-> s2-3 transform-index) 19)
        (set-vector! (-> s2-3 local-sphere) 0.0 0.0 0.0 3276.8)
        (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 touch))
        (set! (-> s2-4 transform-index) 18)
        (set-vector! (-> s2-4 local-sphere) 0.0 0.0 0.0 3276.8)
        (append-prim s3-0 s2-4)
        )
      (let ((s2-5 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-5 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-5 collide-with) (collide-kind target))
        (set! (-> s2-5 prim-core action) (collide-action solid))
        (set! (-> s2-5 prim-core offense) (collide-offense touch))
        (set! (-> s2-5 transform-index) 17)
        (set-vector! (-> s2-5 local-sphere) 0.0 0.0 0.0 3276.8)
        (append-prim s3-0 s2-5)
        )
      (let ((s2-6 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-6 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-6 collide-with) (collide-kind target))
        (set! (-> s2-6 prim-core action) (collide-action solid))
        (set! (-> s2-6 prim-core offense) (collide-offense touch))
        (set! (-> s2-6 transform-index) 16)
        (set-vector! (-> s2-6 local-sphere) 0.0 0.0 0.0 3276.8)
        (append-prim s3-0 s2-6)
        )
      (let ((s2-7 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-7 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-7 collide-with) (collide-kind target))
        (set! (-> s2-7 prim-core action) (collide-action solid))
        (set! (-> s2-7 prim-core offense) (collide-offense touch))
        (set! (-> s2-7 transform-index) 15)
        (set-vector! (-> s2-7 local-sphere) 0.0 0.0 0.0 3276.8)
        (append-prim s3-0 s2-7)
        )
      (let ((s2-8 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-8 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-8 collide-with) (collide-kind target))
        (set! (-> s2-8 prim-core action) (collide-action solid))
        (set! (-> s2-8 prim-core offense) (collide-offense touch))
        (set! (-> s2-8 transform-index) 14)
        (set-vector! (-> s2-8 local-sphere) 0.0 0.0 0.0 3276.8)
        (append-prim s3-0 s2-8)
        )
      )
    (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 *junglesnake-sg* '())
  (set! (-> obj fact)
        (new 'process 'fact-info-enemy obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
        )
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 173) obj))
  (set! (-> obj is-lethal?) #f)
  (set! (-> obj ry) (y-angle (-> obj root-override)))
  (set! (-> obj des-ry) (-> obj ry))
  (set! (-> obj tilt) 0.0)
  (set! (-> obj des-tilt) (-> obj tilt))
  (set! (-> obj track-player-ry) #f)
  (set! (-> obj track-player-tilt) #f)
  (quaternion-identity! (-> obj root-override quat))
  (dummy-22 obj (-> obj ry))
  (dummy-21 obj)
  (logior! (-> obj skel status) (janim-status inited))
  (go junglesnake-sleeping)
  (none)
  )
