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

;; name: des-beast.gc
;; name in dgo: des-beast
;; dgos: DESBATTL, DESHOVER

(define-extern *curve-beast-linear-up-red* curve2d-piecewise)
(define-extern *trail-color-curve-grenade* curve-color-fast)
(define-extern *curve-grenade-linear-trail* curve2d-fast)
(define-extern *beast-grenade-trail* light-trail-composition)
(define-extern *range-grenade-explo-dust-color* curve-color-fast)
(define-extern *range-grenade-explo-dust-alpha* curve2d-fast)
(define-extern *range-grenade-explo-dust-scale-x* curve2d-fast)
(define-extern *range-grenade-explo-dust-scale-y* curve2d-fast)
(define-extern *curve-grenade-explo-dust-alpha* curve2d-fast)
(define-extern *curve-grenade-explo-dust-scale-x* curve2d-fast)
(define-extern *curve-grenade-explo-dust-scale-y* curve2d-fast)
(define-extern *range-grenade-explo-color* curve-color-fast)
(define-extern *range-grenade-explo-alpha* curve2d-fast)
(define-extern *range-grenade-explo-scale-x* curve2d-fast)
(define-extern *range-grenade-explo-scale-y* curve2d-fast)
(define-extern *curve-grenade-explo-alpha* curve2d-fast)
(define-extern *curve-grenade-explo-scale-x* curve2d-fast)
(define-extern *curve-grenade-explo-scale-y* curve2d-fast)

;; DECOMP BEGINS

(when (or (zero? *curve-beast-linear-up-red*) (!= loading-level global))
  (set! *curve-beast-linear-up-red* (new 'loading-level 'curve2d-piecewise))
  (allocate! *curve-beast-linear-up-red* 2 'loading-level #f)
  )

(set! (-> *curve-beast-linear-up-red* pts data 0 first) 0.0)

(set! (-> *curve-beast-linear-up-red* pts data 0 second) 0.3)

(set! (-> *curve-beast-linear-up-red* pts data 1 first) 1.0)

(set! (-> *curve-beast-linear-up-red* pts data 1 second) 1.0)

(if #t
    (set! *trail-color-curve-grenade* (new 'static 'curve-color-fast
                                        :xs (new 'static 'vector :y -0.2 :z -1.0 :w -2.0)
                                        :ys (new 'static 'inline-array vector 4
                                          (new 'static 'vector :x 1.0 :y 0.5 :z 1.0 :w 128.0)
                                          (new 'static 'vector :x 0.7 :z 1.0 :w 128.0)
                                          (new 'static 'vector :x 0.7 :z 1.0 :w 128.0)
                                          (new 'static 'vector :x 0.7 :z 1.0 :w 128.0)
                                          )
                                        :one-over-x-deltas (new 'static 'vector :x 5.0 :y 1.25 :z 1.0 :w 1.0)
                                        )
          )
    )

(if #t
    (set! *curve-grenade-linear-trail* (new 'static 'curve2d-fast
                                         :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                         :ys (new 'static 'vector :x 0.3 :y 1.0 :z 2.0 :w 3.0)
                                         :one-over-x-deltas (new 'static 'vector :x 0.7 :y 1.0 :z 1.0 :w 1.0)
                                         )
          )
    )

(if (or (zero? *beast-grenade-trail*) (!= loading-level global))
    (set! *beast-grenade-trail* (new 'loading-level 'light-trail-composition))
    )

(set! (-> *beast-grenade-trail* color-mode) (the-as uint 0))

(set! (-> *beast-grenade-trail* color-repeat-dist) 40960.0)

(set! (-> *beast-grenade-trail* alpha-1-mode) (the-as uint 0))

(set! (-> *beast-grenade-trail* alpha-2-mode) (the-as uint 1))

(set! (-> *beast-grenade-trail* base-alpha) 0.5)

(set! (-> *beast-grenade-trail* alpha-repeat-dist) 6144.0)

(set! (-> *beast-grenade-trail* width-mode) (the-as uint 2))

(set! (-> *beast-grenade-trail* base-width) 8192.0)

(set! (-> *beast-grenade-trail* width-repeat-dist) 40960.0)

(set! (-> *beast-grenade-trail* uv-mode) (the-as uint 0))

(set! (-> *beast-grenade-trail* uv-repeat-dist) 16384000.0)

(set! (-> *beast-grenade-trail* lie-mode) (lie-mode appearance0))

(set! (-> *beast-grenade-trail* max-age) (seconds 0.5))

(if #f
    (set! (-> *beast-grenade-trail* tex-id) (lookup-texture-id-by-name (the-as string #f) (the-as string #f)))
    (set! (-> *beast-grenade-trail* tex-id) (new 'static 'texture-id :index #x3 :page #x1))
    )

(set! (-> *beast-grenade-trail* width-curve) (the-as curve2d-piecewise *curve-grenade-linear-trail*))

(set! (-> *beast-grenade-trail* color-curve) (the-as curve-color-piecewise *trail-color-curve-grenade*))

(set! (-> *beast-grenade-trail* alpha-curve-1) (the-as curve2d-piecewise *curve-linear-down*))

(set! (-> *beast-grenade-trail* alpha-curve-2) *curve-beast-linear-up-red*)

(set! (-> *beast-grenade-trail* zbuffer?) #f)

(vector-copy! (-> *beast-grenade-trail* lie-vector) *up-vector*)

(set! (-> *beast-grenade-trail* use-tape-mode?) #f)

(set! (-> *beast-grenade-trail* blend-mode) (the-as uint 1))

(set! (-> *beast-grenade-trail* frame-stagger) (the-as uint 1))

(defpartgroup group-grenade-shot-explode
  :id 411
  :duration (seconds 5)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 30)
  :parts ((sp-item 1661 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1662 :fade-after (meters 400) :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1663 :fade-after (meters 400) :period (seconds 30) :length (seconds 0.035))
    (sp-item 1664 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1665 :period (seconds 30) :length (seconds 0.167))
    (sp-item 1666 :period (seconds 30) :length (seconds 0.5))
    (sp-item 1667 :falloff-to (meters 400) :period (seconds 30) :length (seconds 0.035))
    )
  )

(defpartgroup group-grenade-shot-explode-in-air
  :id 412
  :duration (seconds 5)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 30)
  :parts ((sp-item 1661 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1662 :fade-after (meters 400) :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1664 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1665 :period (seconds 30) :length (seconds 0.167))
    (sp-item 1666 :period (seconds 30) :length (seconds 0.5))
    )
  )

(defpart 1661
  :init-specs ((:texture (glow-soft level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 20))
    (:rot-x (degrees 22.5))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 128.0)
    (:b 40.0)
    (:a 64.0)
    (:fade-a -0.21333334)
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    )
  )

;; WARN: Return type mismatch float vs none.
(defun spt-birth-func-brightness-grenade-bits ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sparticle-launchinfo) (arg3 object) (arg4 object))
  (let ((s5-0 (+ (mod (the-as int (rand-uint31-gen *random-generator*)) 51) 200))
        (s3-0 (logand 0 (rand-uint31-gen *random-generator*)))
        (s4-0 (+ (mod (the-as int (rand-uint31-gen *random-generator*)) 11) 20))
        (v1-6 (+ (mod (the-as int (rand-uint31-gen *random-generator*)) 11) 60))
        )
    (set! (-> arg2 rotate-x) (the float (- s5-0 (the-as int s3-0))))
    (set! (-> arg2 rotate-y) (the float (- s5-0 s4-0)))
    (set! (-> arg2 rotate-z) (the float (- s5-0 v1-6)))
    )
  (none)
  )

(defpart 1667
  :init-specs ((:texture (rockbit01 level-default-sprite))
    (:birth-func 'spt-birth-func-part-grenade-explosion-bits)
    (:num 60.0)
    (:x (meters 0) (meters 4))
    (:scale-x (meters 0.4) (meters 1))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.033333335) (meters 0.1))
    (:rotvel-z (degrees -3.0000002) (degrees 6.0000005))
    (:accel-y (meters -0.0013333333) (meters -0.00066666666))
    (:timer (seconds 4))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13 launch-along-z))
    (:userdata :data (new 'static 'boxed-array :type int32
                       10
                       1
                       0
                       #x408b00
                       #x408c00
                       #x40a100
                       #x40a200
                       #x40a300
                       #x40a400
                       #x40a500
                       #x40a600
                       #x40a700
                       #x40a800
                       #x40a900
                       #x40aa00
                       #x40ab00
                       #x40ac00
                       #x40ad00
                       #x40ae00
                       )
               )
    (:func 'sparticle-texture-animate)
    (:conerot-z (degrees 0) (degrees 40))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defun spt-birth-func-part-grenade-explosion-bits ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sparticle-launchinfo) (arg3 object) (arg4 object))
  (birth-func-texture-group-2d arg0 arg1 arg2 arg3 arg4)
  (spt-birth-func-brightness-grenade-bits arg0 arg1 arg2 arg3 arg4)
  (none)
  )

(defpart 1662
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 30.0)
    (:scale-x (meters 3) (meters 2))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 160.0)
    (:b 40.0)
    (:a 128.0)
    (:vel-y (meters 0) (meters 0.06666667))
    (:scalevel-x (meters 0.016666668))
    (:scalevel-y :copy scalevel-x)
    (:fade-g -0.13333334)
    (:fade-b -0.05)
    (:fade-a -0.21333334 -0.21333334)
    (:friction 0.93)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:conerot-x (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1663
  :init-specs ((:texture (edge-cloud level-default-sprite))
    (:birth-func 'birth-func-curve)
    (:num 30.0)
    (:scale-x (meters 1))
    (:rot-z (degrees -80) (degrees -20))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.05))
    (:rotvel-z (degrees -0.033333335) (degrees 0.06666667))
    (:friction 0.97)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-13 sp-cpuinfo-flag-14))
    (:userdata 0.0)
    (:func 'live-func-curve)
    (:conerot-x (degrees 0) (degrees 360))
    (:conerot-z (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(if #t
    (set! *range-grenade-explo-dust-color* (new 'static 'curve-color-fast
                                             :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                             :ys (new 'static 'inline-array vector 4
                                               (new 'static 'vector :x 170.0 :y 140.0 :z 110.0 :w 128.0)
                                               (new 'static 'vector :x 130.0 :y 110.0 :z 60.0 :w 128.0)
                                               (new 'static 'vector :x 130.0 :y 110.0 :z 60.0 :w 128.0)
                                               (new 'static 'vector :x 130.0 :y 110.0 :z 60.0 :w 128.0)
                                               )
                                             :one-over-x-deltas (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)
                                             )
          )
    )

(if #t
    (set! *range-grenade-explo-dust-alpha* (new 'static 'curve2d-fast
                                             :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                             :ys (new 'static 'vector :x 80.0 :y 64.0 :z 65.0 :w 66.0)
                                             :one-over-x-deltas (new 'static 'vector :x -16.0 :y 1.0 :z 1.0 :w 1.0)
                                             )
          )
    )

(if #t
    (set! *range-grenade-explo-dust-scale-x* (new 'static 'curve2d-fast
                                               :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                               :ys (new 'static 'vector :x 8.0 :y 10.0 :z 11.0 :w 12.0)
                                               :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                               )
          )
    )

(if #t
    (set! *range-grenade-explo-dust-scale-y* (new 'static 'curve2d-fast
                                               :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                               :ys (new 'static 'vector :x 8.0 :y 10.0 :z 11.0 :w 12.0)
                                               :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                               )
          )
    )

(if #t
    (set! *curve-grenade-explo-dust-alpha* (new 'static 'curve2d-fast
                                             :xs (new 'static 'vector :y -0.7 :z -1.0 :w -2.0)
                                             :ys (new 'static 'vector :y 1.0 :w 1.0)
                                             :one-over-x-deltas (new 'static 'vector :x 1.4285715 :y -3.3333333 :z 1.0 :w 1.0)
                                             )
          )
    )

(if #t
    (set! *curve-grenade-explo-dust-scale-x* (new 'static 'curve2d-fast
                                               :xs (new 'static 'vector :y -0.5 :z -1.0 :w -2.0)
                                               :ys (new 'static 'vector :x 0.2 :y 1.0 :z 1.6 :w 2.6)
                                               :one-over-x-deltas (new 'static 'vector :x 1.6 :y 1.2 :z 0.9999999 :w 1.0)
                                               )
          )
    )

(if #t
    (set! *curve-grenade-explo-dust-scale-y* (new 'static 'curve2d-fast
                                               :xs (new 'static 'vector :y -0.5 :z -1.0 :w -2.0)
                                               :ys (new 'static 'vector :x 0.2 :y 1.0 :z 1.6 :w 2.6)
                                               :one-over-x-deltas (new 'static 'vector :x 1.6 :y 1.2 :z 0.9999999 :w 1.0)
                                               )
          )
    )

(define *part-grenade-explosion-dust-in-curve-settings* (new 'static 'particle-curve-settings
                                                          :lifetime-base (seconds 1.5)
                                                          :lifetime-offset (seconds 2)
                                                          :flags (particle-curve-flags pcf0)
                                                          )
        )

(set! (-> *part-id-table* 1663 init-specs 15 initial-valuef)
      (the-as float *part-grenade-explosion-dust-in-curve-settings*)
      )

(set! (-> *part-grenade-explosion-dust-in-curve-settings* color-start) *range-grenade-explo-dust-color*)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* alpha-start) *range-grenade-explo-dust-alpha*)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* scale-x-start) *range-grenade-explo-dust-scale-x*)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* scale-y-start) *range-grenade-explo-dust-scale-y*)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* r-scalar) #f)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* g-scalar) #f)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* b-scalar) #f)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* a-scalar) *curve-grenade-explo-dust-alpha*)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* scale-x-scalar) *curve-grenade-explo-dust-scale-x*)

(set! (-> *part-grenade-explosion-dust-in-curve-settings* scale-y-scalar) *curve-grenade-explo-dust-scale-y*)

(defpart 1665
  :init-specs ((:texture (explosion-edge level-default-sprite))
    (:num 5.0)
    (:scale-x (meters 3) (meters 2))
    (:rot-y (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 80.0 20.0)
    (:b 30.0)
    (:a 128.0)
    (:vel-y (meters 0.33333334) (meters 0.13333334))
    (:scalevel-x (meters 0.033333335))
    (:scalevel-y :copy scalevel-x)
    (:fade-g -0.17777778)
    (:fade-b -0.06666667)
    (:fade-a -0.28444445 -0.28444445)
    (:friction 0.7)
    (:timer (seconds 1.5))
    (:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:func 'sparticle-2d-spline-align-instant)
    (:conerot-x (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1666
  :init-specs ((:texture (explo-texture level-default-sprite))
    (:birth-func 'birth-func-curve)
    (:num 8.0)
    (:x (meters -1) (meters 2))
    (:y (meters 0) (meters 2))
    (:scale-x (meters 1))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.06666667) (meters 0.033333335))
    (:friction 0.9)
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-14))
    (:userdata 0.0)
    (:func 'live-func-curve)
    (:conerot-x (degrees 20) (degrees 90))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(if #t
    (set! *range-grenade-explo-color* (new 'static 'curve-color-fast
                                        :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                        :ys (new 'static 'inline-array vector 4
                                          (new 'static 'vector :x 255.0 :y 255.0 :z 255.0 :w 128.0)
                                          (new 'static 'vector :x 255.0 :y 255.0 :z 255.0 :w 128.0)
                                          (new 'static 'vector :x 255.0 :y 255.0 :z 255.0 :w 128.0)
                                          (new 'static 'vector :x 255.0 :y 255.0 :z 255.0 :w 128.0)
                                          )
                                        :one-over-x-deltas (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)
                                        )
          )
    )

(if #t
    (set! *range-grenade-explo-alpha* (new 'static 'curve2d-fast
                                        :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                        :ys (new 'static 'vector :x 128.0 :y 128.0 :z 129.0 :w 130.0)
                                        :one-over-x-deltas (new 'static 'vector :y 1.0 :z 1.0 :w 1.0)
                                        )
          )
    )

(if #t
    (set! *range-grenade-explo-scale-x* (new 'static 'curve2d-fast
                                          :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                          :ys (new 'static 'vector :x 3.0 :y 5.0 :z 6.0 :w 7.0)
                                          :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                          )
          )
    )

(if #t
    (set! *range-grenade-explo-scale-y* (new 'static 'curve2d-fast
                                          :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                          :ys (new 'static 'vector :x 3.0 :y 5.0 :z 6.0 :w 7.0)
                                          :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                          )
          )
    )

(if #t
    (set! *curve-grenade-explo-alpha* (new 'static 'curve2d-fast
                                        :xs (new 'static 'vector :y -0.05 :z -0.7 :w -1.0)
                                        :ys (new 'static 'vector :y 1.0 :z 0.8)
                                        :one-over-x-deltas (new 'static 'vector :x 20.0 :y -0.3076923 :z -2.6666665 :w 1.0)
                                        )
          )
    )

(if #t
    (set! *curve-grenade-explo-scale-x* (new 'static 'curve2d-fast
                                          :xs (new 'static 'vector :y -0.8 :z -1.0 :w -2.0)
                                          :ys (new 'static 'vector :y 1.0 :z 1.5 :w 2.5)
                                          :one-over-x-deltas (new 'static 'vector :x 1.25 :y 2.5000002 :z 1.0 :w 1.0)
                                          )
          )
    )

(if #t
    (set! *curve-grenade-explo-scale-y* (new 'static 'curve2d-fast
                                          :xs (new 'static 'vector :y -0.8 :z -1.0 :w -2.0)
                                          :ys (new 'static 'vector :y 1.0 :z 1.5 :w 2.5)
                                          :one-over-x-deltas (new 'static 'vector :x 1.25 :y 2.5000002 :z 1.0 :w 1.0)
                                          )
          )
    )

(define *part-grenade-explosion-texture-curve-settings* (new 'static 'particle-curve-settings
                                                          :lifetime-base (seconds 0.1)
                                                          :lifetime-offset (seconds 0.6)
                                                          :flags (particle-curve-flags pcf0)
                                                          )
        )

(set! (-> *part-id-table* 1666 init-specs 16 initial-valuef)
      (the-as float *part-grenade-explosion-texture-curve-settings*)
      )

(set! (-> *part-grenade-explosion-texture-curve-settings* color-start) *range-grenade-explo-color*)

(set! (-> *part-grenade-explosion-texture-curve-settings* alpha-start) *range-grenade-explo-alpha*)

(set! (-> *part-grenade-explosion-texture-curve-settings* scale-x-start) *range-grenade-explo-scale-x*)

(set! (-> *part-grenade-explosion-texture-curve-settings* scale-y-start) *range-grenade-explo-scale-y*)

(set! (-> *part-grenade-explosion-texture-curve-settings* r-scalar) #f)

(set! (-> *part-grenade-explosion-texture-curve-settings* g-scalar) #f)

(set! (-> *part-grenade-explosion-texture-curve-settings* b-scalar) #f)

(set! (-> *part-grenade-explosion-texture-curve-settings* a-scalar) *curve-grenade-explo-alpha*)

(set! (-> *part-grenade-explosion-texture-curve-settings* scale-x-scalar) *curve-grenade-explo-scale-x*)

(set! (-> *part-grenade-explosion-texture-curve-settings* scale-y-scalar) *curve-grenade-explo-scale-y*)

(defpart 1664
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 20))
    (:rot-x (degrees 2.25))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 80.0)
    (:b 40.0)
    (:a 128.0)
    (:omega (degrees 6767.9995))
    (:scalevel-x (meters -0.33333334))
    (:scalevel-y :copy scalevel-x)
    (:timer (seconds 0.135))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:userdata 4096.0)
    )
  )

(defpartgroup group-beast-grenade-glow
  :id 413
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 40)
  :parts ((sp-item 1668 :flags (sp6)) (sp-item 1669 :flags (sp6)) (sp-item 1670 :flags (sp6)))
  )

(defpart 1668
  :init-specs ((:texture (glow-soft level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 2))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:timer (seconds 0.02))
    (:flags (sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    )
  )

(defpart 1669
  :init-specs ((:texture (middot level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 2))
    (:scale-y :copy scale-x)
    (:r 110.0)
    (:g 1.0)
    (:b 255.0)
    (:a 255.0)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-14))
    )
  )

(defpart 1670
  :init-specs ((:texture (glow-soft level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 8))
    (:scale-y :copy scale-x)
    (:r 110.0)
    (:g 1.0)
    (:b 255.0)
    (:a 32.0)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-3))
    )
  )

(defpartgroup group-beast-hit
  :id 414
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 1671 :period (seconds 0.017) :length (seconds 0.017))
    (sp-item 1672 :period (seconds 0.017) :length (seconds 0.017))
    (sp-item 1673 :period (seconds 0.017) :length (seconds 0.017))
    (sp-item 1674 :period (seconds 0.167) :length (seconds 0.167))
    )
  )

(defpart 1671
  :init-specs ((:texture (glow-soft level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 5))
    (:rot-x (degrees 22.5))
    (:scale-y :copy scale-x)
    (:r 64.0)
    (:g 32.0)
    (:b 255.0)
    (:a 64.0)
    (:fade-a -0.64)
    (:timer (seconds 0.335))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:userdata 4096.0)
    )
  )

(defpart 1672
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 0.0 10.0)
    (:scale-x (meters 1) (meters 2))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 120.0)
    (:g 40.0)
    (:b 255.0)
    (:a 128.0)
    (:vel-y (meters 0) (meters 0.06666667))
    (:scalevel-x (meters 0.0033333334))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -1.2)
    (:fade-g -0.4)
    (:fade-a -1.28 -1.28)
    (:friction 0.93)
    (:timer (seconds 0.335))
    (:flags (sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:conerot-x (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1673
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 3) (meters 2))
    (:rot-x (degrees 2.25))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 60.0)
    (:g 40.0)
    (:b 128.0)
    (:a 128.0)
    (:omega (degrees 6767.9995))
    (:scalevel-x (meters -0.33333334))
    (:scalevel-y :copy scalevel-x)
    (:timer (seconds 0.135))
    (:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 glow))
    (:userdata 4096.0)
    )
  )

(defpart 1674
  :init-specs ((:texture (explosion-edge level-default-sprite))
    (:num 20.0)
    (:scale-x (meters 1) (meters 0.5))
    (:rot-y (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 80.0 20.0)
    (:g 30.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.033333335) (meters 0.016666668))
    (:scalevel-x (meters 0.026666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -0.8)
    (:fade-g -0.3)
    (:fade-a -1.28 -1.28)
    (:friction 0.99)
    (:timer (seconds 0.335))
    (:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-3))
    (:func 'sparticle-2d-spline-align-instant)
    (:conerot-x (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpartgroup group-beast-fall-dust
  :id 415
  :flags (sp0 sp4)
  :bounds (static-bspherem 0 0 0 20)
  :parts ((sp-item 1675 :flags (sp7)) (sp-item 1676 :flags (sp7)))
  )

(defpart 1675
  :init-specs ((:texture (rockbit01 level-default-sprite))
    (:birth-func 'spt-birth-func-part-beast-fall-bits)
    (:num 10.0)
    (:scale-x (meters 0.2) (meters 0.2))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.2) (meters 0.2))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.016666668) (meters 0.06666667))
    (:rotvel-z (degrees -3.0000002) (degrees 6.0000005))
    (:accel-y (meters -0.0016666667))
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-13 launch-along-z left-multiply-quat))
    (:userdata :data (new 'static 'boxed-array :type int32
                       10
                       1
                       0
                       #x408b00
                       #x408c00
                       #x40a100
                       #x40a200
                       #x40a300
                       #x40a400
                       #x40a500
                       #x40a600
                       #x40a700
                       #x40a800
                       #x40a900
                       #x40aa00
                       #x40ab00
                       #x40ac00
                       #x40ad00
                       #x40ae00
                       )
               )
    (:func 'sparticle-texture-animate)
    (:conerot-x (degrees 0) (degrees 90))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defun spt-birth-func-part-beast-fall-bits ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sparticle-launchinfo) (arg3 object) (arg4 object))
  (birth-func-texture-group-2d arg0 arg1 arg2 arg3 arg4)
  (spt-birth-func-brightness-grenade-bits arg0 arg1 arg2 arg3 arg4)
  (none)
  )

(defpart 1676
  :init-specs ((:texture (edge-cloud level-default-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 2.0 2.0)
    (:scale-x (meters 6) (meters 3))
    (:rot-z (degrees -90))
    (:scale-y :copy scale-x)
    (:r 190.0)
    (:g 150.0)
    (:b 90.0)
    (:a 64.0)
    (:vel-y (meters 0.016666668) (meters 0.06666667))
    (:scalevel-x (meters 0.01) (meters 0.01))
    (:scalevel-y (meters 0.0033333334))
    (:fade-a -0.10666667)
    (:accel-y (meters 0) (meters 0.00033333333))
    (:friction 0.95)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-13 launch-along-z left-multiply-quat))
    (:userdata :data (new 'static 'boxed-array :type int32 20 1 0 #x409b00 #x405c00))
    (:conerot-x (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpartgroup group-beast-foot-dust
  :id 416
  :flags (sp0 sp4)
  :bounds (static-bspherem 0 0 0 20)
  :parts ((sp-item 1677 :flags (sp7)) (sp-item 1678 :flags (sp7)))
  )

(defpart 1677
  :init-specs ((:texture (rockbit01 level-default-sprite))
    (:birth-func 'spt-birth-func-part-beast-foot-bits)
    (:num 10.0)
    (:scale-x (meters 0.1) (meters 0.1))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.1) (meters 0.1))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.016666668) (meters 0.016666668))
    (:rotvel-z (degrees -3.0000002) (degrees 6.0000005))
    (:accel-y (meters -0.0016666667))
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-13 launch-along-z left-multiply-quat))
    (:userdata :data (new 'static 'boxed-array :type int32
                       10
                       1
                       0
                       #x408b00
                       #x408c00
                       #x40a100
                       #x40a200
                       #x40a300
                       #x40a400
                       #x40a500
                       #x40a600
                       #x40a700
                       #x40a800
                       #x40a900
                       #x40aa00
                       #x40ab00
                       #x40ac00
                       #x40ad00
                       #x40ae00
                       )
               )
    (:func 'sparticle-texture-animate)
    (:conerot-x (degrees 0) (degrees 90))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defun spt-birth-func-part-beast-foot-bits ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sparticle-launchinfo) (arg3 object) (arg4 object))
  (birth-func-texture-group-2d arg0 arg1 arg2 arg3 arg4)
  (spt-birth-func-brightness-grenade-bits arg0 arg1 arg2 arg3 arg4)
  (none)
  )

(defpart 1678
  :init-specs ((:texture (dirtpuff01 level-default-sprite))
    (:num 10.0)
    (:scale-x (meters 3) (meters 3))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 190.0)
    (:g 150.0)
    (:b 90.0)
    (:a 64.0)
    (:vel-z (meters 0.016666668) (meters 0.016666668))
    (:scalevel-x (meters 0.01) (meters 0.01))
    (:rotvel-z (degrees -0.3) (degrees 0.6))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.10666667)
    (:accel-y (meters 0) (meters 0.00066666666))
    (:friction 0.95)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-13 launch-along-z left-multiply-quat))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(deftype beast-grenade (projectile-bounce)
  ((blast-radius  float)
   )
  (:methods
    (beast-grenade-method-44 (_type_) none)
    )
  )


(defskelgroup skel-des-beast-grenade gun gun-grenade-lod0-jg gun-grenade-idle-ja
              ((gun-grenade-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 2)
              :texture-level 10
              )

(defmethod play-impact-sound ((this beast-grenade) (arg0 projectile-options))
  (let ((v1-0 arg0))
    (cond
      ((zero? v1-0)
       (sound-play "ball-launch")
       )
      ((= v1-0 (projectile-options po0))
       (sound-play "ball-explode")
       )
      )
    )
  0
  (none)
  )

(defmethod setup-collision! ((this beast-grenade))
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) projectile-bounce-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> s5-0 penetrate-using) (penetrate explode))
    (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-7 prim-core action) (collide-action solid))
      (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 819.2)
      (set! (-> s5-0 total-prims) (the-as uint 1))
      (set! (-> s5-0 root-prim) v1-7)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (let ((v1-10 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with))
      )
    (set! (-> s5-0 max-iteration-count) (the-as uint 2))
    (set! (-> s5-0 event-self) 'touched)
    (set! (-> this root) s5-0)
    )
  (set-collide-with!
    (-> this root)
    (collide-spec
      backgnd
      jak
      crate
      civilian
      enemy
      obstacle
      vehicle-sphere
      hit-by-others-list
      player-list
      pusher
      shield
      )
    )
  (set-collide-as! (-> this root) (collide-spec enemy))
  (set! (-> this root pat-ignore-mask)
        (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1)
        )
  (none)
  )

(defmethod init-proj-settings! ((this beast-grenade))
  (set! (-> this attack-mode) 'eco-dark)
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-des-beast-grenade" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (let ((t9-2 (method-of-type projectile-bounce init-proj-settings!)))
    (t9-2 this)
    )
  (set! (-> this part) (create-launch-control group-beast-grenade-glow this))
  (set! (-> this blast-radius) 40960.0)
  (set! (-> this max-speed) 90112.0)
  (set! (-> this timeout) (seconds 4))
  (let ((s5-1 (new 'stack-no-clear 'light-trail-tracker-spawn-params)))
    (set! (-> s5-1 tracked-obj) (process->handle this))
    (set! (-> s5-1 appearance) *beast-grenade-trail*)
    (set! (-> s5-1 max-num-crumbs) (the int (* 0.5 (the float (-> s5-1 appearance max-age)))))
    (set! (-> s5-1 track-immediately?) #t)
    (let* ((v1-22 (estimate-light-trail-mem-usage
                    (the-as uint (-> s5-1 max-num-crumbs))
                    (the-as uint (= (-> s5-1 appearance lie-mode) (lie-mode use-two-strips)))
                    )
                  )
           (s4-1 (get-process *default-dead-pool* light-trail-tracker-projectile (+ v1-22 8192) 1))
           )
      (when s4-1
        (let ((t9-6 (method-of-type process activate)))
          (t9-6 s4-1 this "light-trail" (the-as pointer #x70004000))
          )
        (run-now-in-process s4-1 light-trail-tracker-init-by-other s5-1)
        (-> s4-1 ppointer)
        )
      )
    )
  (let ((v1-26 (new 'stack-no-clear 'vector)))
    (set! (-> v1-26 x) 8.0)
    (set! (-> v1-26 y) 8.0)
    (set! (-> v1-26 z) 8.0)
    (set! (-> v1-26 w) 1.0)
    (vector-copy! (-> this root scale) v1-26)
    )
  0
  (none)
  )

(defmethod projectile-method-25 ((this beast-grenade))
  (spawn (-> this part) (-> this root trans))
  (ja-post)
  0
  (none)
  )

;; WARN: Return type mismatch object vs none.
(defmethod go-impact! ((this beast-grenade))
  (go (method-of-object this impact))
  (none)
  )

(defmethod projectile-bounce-method-42 ((this beast-grenade))
  0
  (none)
  )

;; WARN: Return type mismatch sound-id vs none.
(defmethod projectile-method-39 ((this beast-grenade))
  (let* ((s4-0 (-> this root))
         (s5-0 (-> s4-0 status))
         )
    (when (logtest? s5-0 (collide-status touch-surface))
      (go-impact! this)
      (vector-float*! (-> s4-0 transv) (-> s4-0 transv) 0.2)
      )
    (when (and (logtest? s5-0 (collide-status impact-surface))
               (time-elapsed? (-> this played-bounce-time) (seconds 0.3))
               )
      (set-time! (-> this played-bounce-time))
      (sound-play "grenade-bounce")
      )
    )
  (none)
  )

(defstate impact (beast-grenade)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('touched)
       (if (send-event
             proc
             'attack
             (-> block param 0)
             (static-attack-info :mask (vehicle-impulse-factor) ((id (-> self attack-id))
                                                                 (damage 2.0)
                                                                 (vehicle-damage-factor 1.0)
                                                                 (vehicle-impulse-factor 1.0)
                                                                 (mode 'explode)
                                                                 )
                                 )
             )
           #t
           )
       )
      )
    )
  :code (behavior ()
    (let ((gp-0 (new 'stack-no-clear 'explosion-init-params)))
      (vector-copy! (-> gp-0 spawn-point) (-> self root trans))
      (quaternion-identity! (-> gp-0 spawn-quat))
      (set! (-> gp-0 radius) (-> self blast-radius))
      (set! (-> gp-0 scale) 1.0)
      (set! (-> gp-0 group) group-grenade-shot-explode)
      (set! (-> gp-0 collide-with)
            (collide-spec backgnd jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> gp-0 damage) 2.0)
      (set! (-> gp-0 damage-scale) 1.0)
      (set! (-> gp-0 vehicle-damage-factor) 1.0)
      (set! (-> gp-0 vehicle-impulse-factor) 1.0)
      (set! (-> gp-0 ignore-proc) (process->handle #f))
      (explosion-spawn gp-0 (the-as process-drawable *default-pool*))
      )
    (let ((f0-6 (lerp-scale 3276.8 0.0 (vector-vector-distance (camera-pos) (-> self root trans)) 40960.0 163840.0)))
      (if (!= f0-6 0.0)
          (activate! *camera-smush-control* f0-6 37 600 1.0 0.1 (-> self clock))
          )
      )
    (logior! (-> self draw status) (draw-control-status no-draw))
    (let ((v1-21 (-> self root root-prim)))
      (set! (-> v1-21 prim-core collide-as) (collide-spec))
      (set! (-> v1-21 prim-core collide-with) (collide-spec))
      )
    0
    (deactivate self)
    )
  )

(deftype beast-rider (enemy)
  ()
  )


(defskelgroup skel-beast-rider beast-rider beast-rider-lod0-jg beast-rider-idle-ja
              ((beast-rider-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 4)
              :shadow beast-rider-shadow-mg
              )

(define *beast-rider-enemy-info* (new 'static 'enemy-info
                                   :use-die-falling #f
                                   :use-victory #f
                                   :use-jump-blocked #f
                                   :debug-draw-neck #f
                                   :jump-debug-draw #f
                                   :move-to-ground #f
                                   :hover-if-no-ground #f
                                   :idle-anim-script #f
                                   :idle-anim -1
                                   :notice-anim -1
                                   :hostile-anim -1
                                   :hit-anim -1
                                   :knocked-anim -1
                                   :knocked-land-anim -1
                                   :die-anim -1
                                   :die-falling-anim -1
                                   :victory-anim -1
                                   :jump-wind-up-anim -1
                                   :jump-in-air-anim -1
                                   :jump-land-anim -1
                                   :neck-joint 7
                                   :look-at-joint 8
                                   :bullseye-joint 19
                                   :notice-distance (meters 30)
                                   :notice-distance-delta (meters 10)
                                   :default-hit-points 1.0
                                   :gnd-collide-with (collide-spec backgnd)
                                   :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
                                   :movement-gravity (meters -100)
                                   :friction 0.8
                                   :attack-shove-back (meters 3)
                                   :attack-shove-up (meters 2)
                                   :attack-mode 'generic
                                   :attack-damage 2
                                   :recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
                                   :knocked-can-land-timeout (seconds 0.1)
                                   :knocked-recover-timeout (seconds 2)
                                   :ragdoll-blend-out-time (seconds 0.25)
                                   :ragdoll-rotate-velocity-mult 1.0
                                   :jump-height-min (meters 3)
                                   :jump-height-factor 0.5
                                   :knocked-seek-ry-clamp 2730.6667
                                   :knocked-soft-vxz-lo (meters 17.6)
                                   :knocked-soft-vxz-hi (meters 26.4)
                                   :knocked-soft-vy-lo (meters 20)
                                   :knocked-soft-vy-hi (meters 30)
                                   :knocked-medium-vxz-lo (meters 36)
                                   :knocked-medium-vxz-hi (meters 48)
                                   :knocked-medium-vy-lo (meters 33)
                                   :knocked-medium-vy-hi (meters 37)
                                   :knocked-hard-vxz-lo (meters 19.2)
                                   :knocked-hard-vxz-hi (meters 28.8)
                                   :knocked-hard-vy-lo (meters 44.8)
                                   :knocked-hard-vy-hi (meters 51.2)
                                   :knocked-huge-vxz-lo (meters 40.2)
                                   :knocked-huge-vxz-hi (meters 60.8)
                                   :knocked-huge-vy-lo (meters 44.8)
                                   :knocked-huge-vy-hi (meters 53.2)
                                   :knocked-yellow-vxz-lo (meters 10)
                                   :knocked-yellow-vxz-hi (meters 12)
                                   :knocked-yellow-vy-lo (meters 14)
                                   :knocked-yellow-vy-hi (meters 20)
                                   :knocked-red-vxz-lo (meters 6)
                                   :knocked-red-vxz-hi (meters 48)
                                   :knocked-red-vy-lo (meters 23)
                                   :knocked-red-vy-hi (meters 37)
                                   :knocked-blue-vxz-lo (meters 10)
                                   :knocked-blue-vxz-hi (meters 12)
                                   :knocked-blue-vy-lo (meters 6)
                                   :knocked-blue-vy-hi (meters 20)
                                   :ragdoll-info #f
                                   :shadow-size (meters 1)
                                   :shadow-max-y (meters 1)
                                   :shadow-min-y (meters -1)
                                   :shadow-locus-dist (meters 150)
                                   :gem-joint -1
                                   :gem-offset (new 'static 'sphere :r 163840.0)
                                   :knocked-off #t
                                   )
        )

(set! (-> *beast-rider-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

(defskelgroup skel-des-beast des-beast des-beast-lod0-jg des-beast-idle-ja
              ((des-beast-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 7 0 24)
              :shadow des-beast-shadow-mg
              :origin-joint-index 3
              )

(define *des-beast-enemy-info* (new 'static 'enemy-info
                                 :use-die-falling #f
                                 :use-victory #f
                                 :use-jump-blocked #f
                                 :debug-draw-neck #f
                                 :jump-debug-draw #f
                                 :move-to-ground #f
                                 :hover-if-no-ground #f
                                 :idle-anim-script #f
                                 :idle-anim -1
                                 :notice-anim -1
                                 :hostile-anim -1
                                 :hit-anim -1
                                 :knocked-anim -1
                                 :knocked-land-anim -1
                                 :die-anim -1
                                 :die-falling-anim -1
                                 :victory-anim -1
                                 :jump-wind-up-anim -1
                                 :jump-in-air-anim -1
                                 :jump-land-anim -1
                                 :neck-joint 6
                                 :look-at-joint 7
                                 :bullseye-joint 24
                                 :notice-distance (meters 30)
                                 :notice-distance-delta (meters 10)
                                 :default-hit-points 1.0
                                 :gnd-collide-with (collide-spec backgnd)
                                 :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
                                 :movement-gravity (meters -100)
                                 :friction 0.8
                                 :attack-shove-back (meters 3)
                                 :attack-shove-up (meters 2)
                                 :attack-mode 'generic
                                 :attack-damage 2
                                 :recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
                                 :knocked-can-land-timeout (seconds 0.1)
                                 :knocked-recover-timeout (seconds 2)
                                 :ragdoll-blend-out-time (seconds 0.25)
                                 :ragdoll-rotate-velocity-mult 1.0
                                 :jump-height-min (meters 3)
                                 :jump-height-factor 0.5
                                 :knocked-seek-ry-clamp 2730.6667
                                 :knocked-soft-vxz-lo (meters 17.6)
                                 :knocked-soft-vxz-hi (meters 26.4)
                                 :knocked-soft-vy-lo (meters 20)
                                 :knocked-soft-vy-hi (meters 30)
                                 :knocked-medium-vxz-lo (meters 36)
                                 :knocked-medium-vxz-hi (meters 48)
                                 :knocked-medium-vy-lo (meters 33)
                                 :knocked-medium-vy-hi (meters 37)
                                 :knocked-hard-vxz-lo (meters 19.2)
                                 :knocked-hard-vxz-hi (meters 28.8)
                                 :knocked-hard-vy-lo (meters 44.8)
                                 :knocked-hard-vy-hi (meters 51.2)
                                 :knocked-huge-vxz-lo (meters 40.2)
                                 :knocked-huge-vxz-hi (meters 60.8)
                                 :knocked-huge-vy-lo (meters 44.8)
                                 :knocked-huge-vy-hi (meters 53.2)
                                 :knocked-yellow-vxz-lo (meters 10)
                                 :knocked-yellow-vxz-hi (meters 12)
                                 :knocked-yellow-vy-lo (meters 14)
                                 :knocked-yellow-vy-hi (meters 20)
                                 :knocked-red-vxz-lo (meters 6)
                                 :knocked-red-vxz-hi (meters 48)
                                 :knocked-red-vy-lo (meters 23)
                                 :knocked-red-vy-hi (meters 37)
                                 :knocked-blue-vxz-lo (meters 10)
                                 :knocked-blue-vxz-hi (meters 12)
                                 :knocked-blue-vy-lo (meters 6)
                                 :knocked-blue-vy-hi (meters 20)
                                 :ragdoll-info #f
                                 :shadow-size (meters 1)
                                 :shadow-max-y (meters 10)
                                 :shadow-min-y (meters -10)
                                 :shadow-locus-dist (meters 150)
                                 :gem-joint -1
                                 :gem-offset (new 'static 'sphere :r 163840.0)
                                 :knocked-off #t
                                 )
        )

(set! (-> *des-beast-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

(defstate idle (beast-rider)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (set-time! (-> self state-time))
    )
  :exit (behavior ()
    '()
    )
  :trans (behavior ()
    (let ((v1-2 (as-type (ppointer->process (-> self parent)) process-focusable)))
      (when v1-2
        (let ((t9-1 vector-matrix*!)
              (a0-2 (-> self root trans))
              (a1-1 (new 'stack-no-clear 'vector))
              )
          (set! (-> a1-1 x) 0.0)
          (set! (-> a1-1 y) 4096.0)
          (set! (-> a1-1 z) 0.0)
          (set! (-> a1-1 w) 1.0)
          (t9-1 a0-2 a1-1 (-> (the-as process-drawable v1-2) node-list data 21 bone transform))
          )
        )
      )
    )
  :code (behavior ()
    (until #f
      (ja-no-eval :group! beast-rider-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post (behavior ()
    (transform-post)
    )
  )

(defbehavior beast-rider-init-by-other beast-rider ()
  (let ((gp-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
    (set! (-> gp-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> gp-0 reaction) cshape-reaction-default)
    (set! (-> gp-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> gp-0 penetrated-by)
          (penetrate
            generic-attack
            lunge
            flop
            punch
            spin
            roll
            uppercut
            bonk
            tube
            flut-attack
            board
            mech-punch
            dark-punch
            dark-smack
            flut
            )
          )
    (let ((s5-0 (new 'process 'collide-shape-prim-group gp-0 (the-as uint 1) 0)))
      (set! (-> gp-0 total-prims) (the-as uint 2))
      (set! (-> s5-0 prim-core collide-as) (collide-spec enemy obstacle camera-blocker))
      (set! (-> s5-0 prim-core collide-with)
            (collide-spec backgnd jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> s5-0 prim-core action) (collide-action solid deadly no-standon))
      (set-vector! (-> s5-0 local-sphere) 0.0 16384.0 0.0 114688.0)
      (set! (-> gp-0 root-prim) s5-0)
      )
    (let ((v1-13 (new 'process 'collide-shape-prim-sphere gp-0 (the-as uint 0))))
      (set! (-> v1-13 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-13 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-13 prim-core action) (collide-action solid))
      (set! (-> v1-13 transform-index) 4)
      (set-vector! (-> v1-13 local-sphere) 0.0 0.0 0.0 1638.4)
      )
    (set! (-> gp-0 nav-radius) 8192.0)
    (let ((v1-15 (-> gp-0 root-prim)))
      (set! (-> gp-0 backup-collide-as) (-> v1-15 prim-core collide-as))
      (set! (-> gp-0 backup-collide-with) (-> v1-15 prim-core collide-with))
      )
    (set! (-> gp-0 max-iteration-count) (the-as uint 3))
    (set! (-> self root) gp-0)
    )
  (vector-identity! (-> self root scale))
  (initialize-skeleton
    self
    (the-as skeleton-group (art-group-get-by-name *level* "skel-beast-rider" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (set! (-> self enemy-info) *beast-rider-enemy-info*)
  (logior! (-> self mask) (process-mask enemy))
  (go-virtual idle)
  )

(deftype des-beast (enemy)
  ((path-pos                float)
   (path-pos-speed          float)
   (speed-factor            float)
   (main-speed-factor       float)
   (main-speed-factor-dest  float)
   (des-path                desbeast-path)
   (angle-turret            float   :offset 580)
   (angle-gun               float)
   (run-start-frame         float)
   (can-turn?               symbol)
   (behind-time             time-frame)
   (target-gun-pos          vector  :inline)
   (incoming-attack-id      uint32)
   (hit-points2             float   :offset 632)
   (angry                   float)
   (attack-next?            symbol)
   (minimap                 connection-minimap)
   (s-clock                 float)
   (attack-id-time          time-frame)
   (oomass                  float)
   (jitter                  float)
   (next-shoot              time-frame)
   (shoot-delay             time-frame)
   (manager                 handle)
   (hit-part                sparticle-launch-control)
   )
  (:state-methods
    turn-back
    falling
    down
    get-up
    die-run
    )
  (:methods
    (debug-draw-path (_type_) none)
    (get-linear-vel! (_type_ vector) vector)
    (des-beast-method-162 (_type_) none)
    (des-beast-method-163 (_type_) none)
    (des-beast-method-164 (_type_) none)
    (des-beast-method-165 (_type_) none)
    (des-beast-method-166 (_type_) none)
    (des-beast-method-167 (_type_ vector) symbol)
    )
  )


(define *beast-camera-slow-motion* (new 'static 'vector))

(defbehavior des-beast-active-post des-beast ()
  (let ((s5-0 *target*)
        (s4-0 (new 'stack-no-clear 'vector))
        (gp-0 (new 'stack-no-clear 'vector))
        )
    (when s5-0
      (vector-! s4-0 (-> self root trans) (get-trans s5-0 0))
      (vector-normalize! s4-0 1.0)
      (vector-rotate90-around-y! gp-0 s4-0)
      (vector+*! (-> self target-gun-pos) (get-trans s5-0 0) s4-0 (* 0.5 (vector-length (get-transv s5-0))))
      (vector+*!
        (-> self target-gun-pos)
        (-> self target-gun-pos)
        gp-0
        (* 0.2 (vector-length (get-transv s5-0)) (rand-vu-float-range -1.0 1.0))
        )
      )
    )
  (enemy-common-post self)
  0
  (none)
  )

(defstate idle (des-beast)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (if (!= (-> self run-start-frame) 0.0)
        (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) 32768.0)
        )
    (set! (-> self oomass) 1.0)
    (set-time! (-> self next-shoot))
    (set-time! (-> self state-time))
    )
  :exit (behavior ()
    '()
    )
  :trans (behavior ()
    (if (and (!= (-> self s-clock) 1.0) *camera*)
        (vector-copy! (-> *camera* slave 0 trans) *beast-camera-slow-motion*)
        )
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (let* ((a1-0 (the int (the float (the int (-> self path-pos)))))
             (v1-9 (+ a1-0 1))
             (f0-6 (-> self path-pos))
             (f0-8 (- f0-6 (the float (the int f0-6))))
             )
        (if (= v1-9 (-> self des-path node-count))
            (set! v1-9 0)
            )
        (vector-lerp! gp-0 (-> self des-path node a1-0 position) (-> self des-path node v1-9 position) f0-8)
        )
      (seek-toward-heading-vec!
        (-> self root)
        (vector-! (new 'stack-no-clear 'vector) gp-0 (-> self root trans))
        14563.556
        (seconds 0.1)
        )
      (when (< (vector-vector-distance (-> self root trans) gp-0) 204800.0)
        (+! (-> self path-pos) (* 10.0 (seconds-per-frame) (-> self path-pos-speed)))
        (des-beast-method-163 self)
        )
      (let ((s4-1 (vector-! (new 'stack-no-clear 'vector) gp-0 (-> self root trans)))
            (gp-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self root quat)))
            (s5-1 (vector-! (new 'stack-no-clear 'vector) (-> self root trans) (target-pos 0)))
            )
        (set! (-> s4-1 y) 0.0)
        (vector-normalize! s4-1 1.0)
        (set! (-> gp-1 y) 0.0)
        (vector-normalize! gp-1 1.0)
        (if (< 0.98 (vector-dot s4-1 gp-1))
            (set! (-> self can-turn?) #t)
            )
        (set! (-> s5-1 y) 0.0)
        (vector-normalize! s5-1 1.0)
        (let ((s4-3 (vector-! (new 'stack-no-clear 'vector) (-> self root trans) (camera-pos)))
              (s3-2 (new 'stack-no-clear 'vector))
              )
          (set! (-> s4-3 y) 0.0)
          (vector-normalize! s4-3 1.0)
          (vector-rotate-around-y! s3-2 *z-vector* (camera-angle))
          (cond
            ((and (< 0.9 (vector-dot s4-3 s3-2)) (< 0.8 (vector-dot s5-1 gp-1)))
             )
            (else
              (set-time! (-> self behind-time))
              )
            )
          )
        )
      )
    (when (nonzero? (-> self shoot-delay))
      (when (time-elapsed? (-> self next-shoot) (-> self shoot-delay))
        (set-time! (-> self next-shoot))
        (if (< (vector-vector-distance (-> self root trans) (target-pos 0)) 614400.0)
            (des-beast-method-164 self)
            )
        )
      )
    )
  :code (behavior ()
    (local-vars (f30-0 float))
    (ja-channel-push! 1 0)
    (until #f
      (cond
        ((and (= (-> self run-start-frame) 0.0)
              (or (-> self attack-next?) (< (vector-vector-distance (-> self root trans) (target-pos 0)) 204800.0))
              )
         (set! (-> self attack-next?) #f)
         (ja :group! des-beast-run-attack-ja :num! (identity (-> self run-start-frame)))
         )
        (else
          (if (!= (-> self run-start-frame) 0.0)
              (set! (-> self attack-next?) #t)
              )
          (if (< 30.0 (-> self hit-points))
              (ja :group! des-beast-run1-ja :num! (identity (-> self run-start-frame)))
              (ja :group! des-beast-run-limp0-ja :num! (identity (-> self run-start-frame)))
              )
          )
        )
      (set! (-> self run-start-frame) 0.0)
      (ja-frame-num 0)
      (until (< (ja-frame-num 0) f30-0)
        (set! f30-0 (ja-frame-num 0))
        (ja :num! (loop! (* (-> self main-speed-factor) (-> self speed-factor))))
        (des-beast-method-162 self)
        (suspend)
        )
      (cond
        ((< (-> self hit-points) 0.0)
         (if (and (< 0.0 (-> self hit-points2)) (zero? (+ (-> self shoot-delay) (seconds -2))))
             (go-virtual falling)
             (go-virtual die-run)
             )
         )
        (else
          (let ((a1-6 (new 'stack-no-clear 'vector)))
            (vector-copy! a1-6 (-> self root trans))
            (set! (-> a1-6 w) 409600.0)
            (if (or (des-beast-method-167 self a1-6) (and (-> self can-turn?)
                                                          (time-elapsed? (-> self state-time) (seconds 6))
                                                          (>= (+ (current-time) (seconds -0.1)) (-> self behind-time))
                                                          (< 15.0 (-> self hit-points))
                                                          )
                    )
                (go-virtual turn-back)
                )
            )
          )
        )
      )
    #f
    )
  :post des-beast-active-post
  )

(defstate turn-back (des-beast)
  :virtual #t
  :event enemy-event-handler
  :trans (behavior ()
    '()
    )
  :code (behavior ()
    (ja-channel-push! 1 0)
    (ja :group! des-beast-turn180-ja)
    (until (ja-done? 0)
      (ja :num! (seek! max (* (-> self main-speed-factor) (-> self speed-factor))))
      (des-beast-method-162 self)
      (suspend)
      )
    (set! (-> self path-pos) (- (-> self path-pos) (-> self path-pos-speed)))
    (des-beast-method-163 self)
    (set! (-> self main-speed-factor) 0.9)
    (set! (-> self main-speed-factor-dest) 0.9)
    (set! (-> self path-pos-speed) (- (-> self path-pos-speed)))
    (set! (-> self run-start-frame) 18.0)
    (go-virtual idle)
    )
  :post des-beast-active-post
  )

(defstate falling (des-beast)
  :virtual #t
  :event enemy-event-handler
  :code (behavior ()
    (ja-channel-push! 1 0)
    (ja :group! des-beast-fall-forward-ja)
    (set! (-> self main-speed-factor-dest) 0.7)
    (until (ja-done? 0)
      (ja :num! (seek! max (* (-> self main-speed-factor) (-> self speed-factor))))
      (des-beast-method-162 self)
      (suspend)
      )
    (go-virtual down)
    )
  :post (behavior ()
    (enemy-common-post self)
    )
  )

(defstate die-run (des-beast)
  :virtual #t
  :event enemy-event-handler
  :code (behavior ()
    (set! (-> self oomass) 0.001)
    (set! (-> self root penetrated-by) (penetrate))
    (process-entity-status! self (entity-perm-status dead) #t)
    (sound-play "desbeast-death")
    (ja-channel-push! 1 (seconds 0.2))
    (ja :group! des-beast-death1-ja)
    (set! (-> self main-speed-factor-dest) 1.0)
    (until (ja-done? 0)
      (ja :num! (seek! max (* (-> self main-speed-factor) (-> self speed-factor))))
      (des-beast-method-162 self)
      (suspend)
      )
    (when (-> self minimap)
      (logior! (-> self minimap flags) (minimap-flag fade-out))
      (set! (-> self minimap) #f)
      )
    (until #f
      (suspend)
      )
    #f
    )
  :post (behavior ()
    (enemy-common-post self)
    )
  )

(defstate down (des-beast)
  :virtual #t
  :event enemy-event-handler
  :exit (behavior ()
    (set! (-> self hit-points) 75.0)
    (set! (-> self hit-points2) -1.0)
    )
  :code (behavior ()
    (local-vars (v1-25 symbol))
    (set! (-> self angry) 0.0)
    (ja-channel-push! 1 0)
    (set! (-> self jitter) 0.0)
    1.0
    0.0
    0
    (ja-no-eval :group! des-beast-down-idle1-ja :num! (seek! max 0.5) :frame-num 0.0)
    (until (or v1-25 (ja-done? 0))
      (suspend)
      (ja :num! (seek! max 0.5))
      (set! v1-25 (!= (-> self jitter) 0.0))
      )
    (go-virtual get-up)
    )
  :post (behavior ()
    (enemy-common-post self)
    )
  )

(defstate get-up (des-beast)
  :virtual #t
  :event enemy-event-handler
  :exit (behavior ()
    '()
    )
  :code (behavior ()
    (ja-channel-push! 1 0)
    (ja :group! des-beast-get-up-ja)
    (until (ja-done? 0)
      (ja :num! (seek! max (-> self speed-factor)))
      (des-beast-method-162 self)
      (suspend)
      )
    (set! (-> self path-pos) (- (-> self path-pos) (-> self path-pos-speed)))
    (des-beast-method-163 self)
    (set! (-> self main-speed-factor) 0.8)
    (set! (-> self main-speed-factor-dest) 0.8)
    (set! (-> self path-pos-speed) (- (-> self path-pos-speed)))
    (set! (-> self run-start-frame) 18.0)
    (go-virtual idle)
    )
  :post des-beast-active-post
  )

(defstate die (des-beast)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    '()
    )
  :exit (behavior ()
    '()
    )
  :code (behavior ()
    (ja-channel-push! 1 0)
    (ja :group! des-beast-get-up-ja)
    (until (ja-done? 0)
      (ja :num! (seek! (ja-aframe 226.0 0) (-> self speed-factor)))
      (des-beast-method-162 self)
      (suspend)
      )
    (ja-channel-push! 1 0)
    (ja :group! des-beast-death0-ja)
    (until (ja-done? 0)
      (ja :num! (seek! max (-> self speed-factor)))
      (des-beast-method-162 self)
      (suspend)
      )
    (when (-> self minimap)
      (logior! (-> self minimap flags) (minimap-flag fade-out))
      (set! (-> self minimap) #f)
      )
    (if (logtest? (-> *part-group-id-table* 417 flags) (sp-group-flag sp13))
        (part-tracker-spawn
          part-tracker-subsampler
          :to self
          :group (-> *part-group-id-table* 417)
          :target self
          :mat-joint 3
          )
        (part-tracker-spawn part-tracker :to self :group (-> *part-group-id-table* 417) :target self :mat-joint 3)
        )
    (logior! (-> self draw status) (draw-control-status no-draw))
    (let ((v1-60 (-> self root root-prim)))
      (set! (-> v1-60 prim-core collide-as) (collide-spec))
      (set! (-> v1-60 prim-core collide-with) (collide-spec))
      )
    0
    (process-entity-status! self (entity-perm-status dead) #t)
    (until #f
      (suspend)
      )
    #f
    )
  :post (behavior ()
    (enemy-common-post self)
    )
  )

(defmethod event-handler ((this des-beast) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  "Commmon handler for events."
  (case arg2
    (('touch)
     #f
     )
    (('shoot-delay)
     (let ((v0-0 (the-as object (-> arg3 param 0))))
       (set! (-> this shoot-delay) (the-as time-frame v0-0))
       v0-0
       )
     )
    (('impact-impulse)
     #f
     )
    (('touched)
     (enemy-touched-handler this arg0 arg3)
     )
    (('attack)
     (let ((s5-0 (the-as attack-info (-> arg3 param 1))))
       (cond
         ((!= (-> s5-0 id) (-> this incoming-attack-id))
          (set! (-> this incoming-attack-id) (-> s5-0 id))
          (cond
            ((not (logtest? (-> this entity extra perm status) (entity-perm-status dead)))
             (sound-play "desbeast-gethit")
             (set! (-> this jitter) 1.0)
             (when (and (-> this next-state) (let ((v1-13 (-> this next-state name)))
                                               (or (= v1-13 'idle) (= v1-13 'hostile))
                                               )
                        )
               (set! (-> this hit-points) (- (-> this hit-points) (-> s5-0 damage)))
               (+! (-> this angry) (-> s5-0 damage))
               )
             (when (and (-> this next-state) (= (-> this next-state name) 'down))
               (set! (-> this hit-points2) (- (-> this hit-points2) (-> s5-0 damage)))
               (+! (-> this angry) (-> s5-0 damage))
               )
             )
            (else
              (return #t)
              )
            )
          )
         (else
           (return #f)
           )
         )
       )
     'no-impact
     )
    (('event-foot)
     (sound-play "desbeast-step")
     (let ((f30-0 (lerp-scale 3276.8 0.0 (vector-vector-distance (camera-pos) (-> this root trans)) 81920.0 573440.0)))
       (when (!= f30-0 0.0)
         (activate! *camera-smush-control* f30-0 37 600 1.0 0.1 (-> *display* camera-clock))
         (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 (the int (* 255.0 (/ f30-0 METER_LENGTH))) (seconds 0.2))
         )
       )
     )
    )
  )

(defmethod des-beast-method-167 ((this des-beast) (arg0 vector))
  ;; og:preserve-this
  ; (gpr->fpr #x7f800000)
  (let ((s5-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> this root quat))))
    (set! (-> s5-0 y) 0.0)
    (let ((s4-0 (new 'stack-no-clear 'array 'collide-shape 64)))
      (countdown (s3-1 (fill-actor-list-for-box *actor-hash* arg0 s4-0 64))
        (let ((a0-4 (as-type (-> s4-0 s3-1) collide-shape)))
          (when a0-4
            (let ((s1-0 (as-type (-> a0-4 process) process-focusable))
                  (s2-2 (new 'stack-no-clear 'vector))
                  )
              (when (and s1-0 (and (!= this s1-0) (as-type s1-0 des-beast)))
                (vector-! s2-2 (-> s1-0 root trans) (-> this root trans))
                (set! (-> s2-2 y) 0.0)
                (if (< 0.0 (vector-dot s2-2 s5-0))
                    (return #t)
                    )
                )
              )
            )
          )
        )
      )
    )
  #f
  )

(defmethod enemy-touched-handler ((this des-beast) (arg0 process) (arg1 event-message-block))
  "General handler for when anything touches an enemy (automatic response)."
  (cond
    ((= (-> arg0 type) target)
     (let ((s4-0 (-> arg1 param 0)))
       (let ((s3-1 arg0))
         (if (type? s3-1 process-drawable)
             (empty)
             )
         )
       (when (not (logtest? (-> this entity extra perm status) (entity-perm-status dead)))
         (if (send-event
               arg0
               'attack
               s4-0
               (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id))
                                                                   (damage 2.0)
                                                                   (vehicle-damage-factor 1.0)
                                                                   (vehicle-impulse-factor 1.0)
                                                                   (shove-back (meters 10))
                                                                   (shove-up (meters 8))
                                                                   )
                                   )
               )
             #f
             )
         )
       )
     )
    (else
      (let ((s4-1 (the-as object (-> arg1 param 0)))
            (s1-0 (as-type arg0 process-drawable))
            )
        (when s1-0
          (cond
            ((and (nonzero? (-> this attack-id))
                  (logtest? (process-mask vehicle) (-> arg0 mask))
                  (not (logtest? (-> this entity extra perm status) (entity-perm-status dead)))
                  )
             (let ((s2-1 (new 'stack-no-clear 'vector)))
               (vector-copy! s2-1 (-> this root transv))
               (if (< (vector-length s2-1) 40960.0)
                   (vector-normalize! s2-1 40960.0)
                   )
               (- 1.0
                  (vector-dot
                    (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> (the-as process-drawable s1-0) root transv) 1.0)
                    (vector-normalize-copy! (new 'stack-no-clear 'vector) s2-1 1.0)
                    )
                  )
               (vector-length (vector-! (new 'stack-no-clear 'vector) (-> (the-as process-drawable s1-0) root transv) s2-1))
               (vector-dot (-> (the-as process-drawable s1-0) root transv) s2-1)
               (let ((s3-4
                       (vector-! (new 'stack-no-clear 'vector) (-> (the-as process-drawable s1-0) root trans) (-> this root trans))
                       )
                     )
                 (new 'stack-no-clear 'vector)
                 0.0
                 (vector-normalize! s3-4 1.0)
                 (+! (-> s3-4 y) 0.25)
                 (let ((f30-2 (* (vector-length s2-1)
                                 (+ 1.0 (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) s2-1 1.0) s3-4))
                                 )
                              )
                       )
                   (when (send-event
                           arg0
                           'attack
                           (the-as uint s4-1)
                           (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id))
                                                                               (damage 2.0)
                                                                               (vehicle-damage-factor 0.01)
                                                                               (vehicle-impulse-factor (/ f30-2 (meters 2)))
                                                                               (attacker-velocity s3-4)
                                                                               )
                                               )
                           )
                     (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.5))
                     (when (< 204800.0 f30-2)
                       (add-process *gui-control* this (gui-channel beast) (gui-action play) "bstpitch" -99.0 0)
                       (persist-with-delay *setting-control* 'mode-name (seconds 3) 'mode-name 'cam-no-trans 0.0 0)
                       (persist-with-delay *setting-control* 'interp-time (seconds 4) 'interp-time 'abs 300.0 0)
                       (persist-with-delay *setting-control* 'music-volume (seconds 3) 'music-volume 'abs 0.0 0)
                       (let ((s5-1 (new 'stack-no-clear 'collide-query)))
                         (vector-copy! (-> s5-1 start-pos) (-> this root trans))
                         (vector-float*! (-> s5-1 move-dist) s3-4 f30-2)
                         (let ((v1-64 s5-1))
                           (set! (-> v1-64 radius) 12288.0)
                           (set! (-> v1-64 collide-with) (collide-spec backgnd))
                           (set! (-> v1-64 ignore-process0) #f)
                           (set! (-> v1-64 ignore-process1) #f)
                           (set! (-> v1-64 ignore-pat)
                                 (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
                                 )
                           (set! (-> v1-64 action-mask) (collide-action solid))
                           )
                         (let ((f0-24 (fill-and-probe-using-line-sphere *collide-cache* s5-1)))
                           (if (>= f0-24 0.0)
                               (vector-float*! (-> s5-1 move-dist) (-> s5-1 move-dist) f0-24)
                               )
                           )
                         (vector+! *beast-camera-slow-motion* (-> s5-1 start-pos) (-> s5-1 move-dist))
                         )
                       (vector-copy! (-> *camera* slave 0 trans) *beast-camera-slow-motion*)
                       (set! (-> this s-clock) 0.25)
                       )
                     )
                   )
                 )
               )
             (set! (-> this attack-id) (the-as uint 0))
             0
             )
            ((logtest? (process-mask projectile) (-> arg0 mask))
             (let ((s2-2 (-> (the-as touching-shapes-entry s4-1) head))
                   (s3-5 (new 'stack-no-clear 'vector))
                   )
               (let ((f30-3 2.0))
                 (while s2-2
                   (let ((s1-1 (get-touched-prim
                                 s2-2
                                 (the-as collide-shape (-> (the-as process-drawable arg0) root))
                                 (the-as touching-shapes-entry s4-1)
                                 )
                               )
                         )
                     (get-touched-prim s2-2 (-> this root) (the-as touching-shapes-entry s4-1))
                     (when (logtest? (-> s1-1 prim-core action) (collide-action solid semi-solid deadly))
                       (when (< (-> s2-2 u) f30-3)
                         (set! f30-3 (-> s2-2 u))
                         (get-intersect-point s3-5 s2-2 (-> this root) (the-as touching-shapes-entry s4-1))
                         )
                       )
                     )
                   (set! s2-2 (-> s2-2 next))
                   )
                 )
               (spawn (-> this hit-part) s3-5)
               )
             (sound-play "flesh-impact")
             )
            (else
              (send-event arg0 'touch (-> arg1 param 0))
              )
            )
          )
        )
      )
    )
  )

(defmethod des-beast-method-163 ((this des-beast))
  (while (< (the float (-> this des-path node-count)) (-> this path-pos))
    (set! (-> this path-pos) (- (-> this path-pos) (the float (-> this des-path node-count))))
    )
  (while (< (-> this path-pos) 0.0)
    (+! (-> this path-pos) (the float (-> this des-path node-count)))
    )
  0
  (none)
  )

(defmethod get-linear-vel! ((this des-beast) (arg0 vector))
  (vector-copy! arg0 (ja-linear-vel 0))
  arg0
  )

(defmethod des-beast-method-162 ((this des-beast))
  (let ((a1-0 (new 'stack-no-clear 'collide-query)))
    (find-ground (-> this root) a1-0 (collide-spec backgnd) 8192.0 81920.0 1024.0 (the-as process #f))
    )
  (set! (-> this root trans y) (-> this root gspot-pos y))
  (let ((s5-0 (get-linear-vel! this (new 'stack-no-clear 'vector))))
    (vector-orient-by-quat! s5-0 s5-0 (-> this root quat))
    (vector-float*! (-> this root transv) s5-0 1.0)
    )
  (vector-v++! (-> this root trans) (-> this root transv))
  (let ((s5-1 (vector-y-quaternion! (new 'stack-no-clear 'vector) (-> this root quat)))
        (s4-0 (new 'stack-no-clear 'vector))
        )
    (vector-copy! s4-0 (-> this root gspot-normal))
    (vector-cross! (new 'stack-no-clear 'vector) s5-1 s4-0)
    (let ((f0-2 (vector-vector-angle-safe s5-1 s4-0)))
      (when (< 1.8204443 f0-2)
        (let ((a1-9 (quaternion-from-two-vectors-max-angle!
                      (new 'stack-no-clear 'quaternion)
                      s5-1
                      s4-0
                      (* 5461.3335 (seconds-per-frame))
                      )
                    )
              )
          (quaternion*! (-> this root quat) a1-9 (-> this root quat))
          )
        )
      )
    )
  (let ((a1-11 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> this root quat)))
        (v1-25 (new 'stack-no-clear 'vector))
        )
    (vector-copy! v1-25 *up-vector*)
    (seek! (-> this speed-factor) (- 1.0 (* 0.25 (vector-dot a1-11 v1-25))) (seconds-per-frame))
    )
  (seek! (-> this main-speed-factor) (-> this main-speed-factor-dest) (seconds-per-frame))
  0
  (none)
  )

(defmethod des-beast-method-164 ((this des-beast))
  (let ((s4-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this node-list data 21)))
        (s5-0 (new 'stack-no-clear 'vector))
        )
    (vector-copy! s5-0 (-> this node-list data 21 bone transform fvec))
    (new 'stack-no-clear 'vector)
    (new 'stack-no-clear 'vector)
    (vector-normalize! s5-0 81920.0)
    (let ((a1-2 (new 'stack-no-clear 'projectile-init-by-other-params)))
      (set! (-> a1-2 ent) (-> this entity))
      (set! (-> a1-2 charge) 1.0)
      (set! (-> a1-2 options) (projectile-options))
      (logclear! (-> a1-2 options) (projectile-options po14 po15 po16))
      (vector-copy! (-> a1-2 pos) s4-0)
      (vector-copy! (-> a1-2 vel) s5-0)
      (set! (-> a1-2 notify-handle) (the-as handle #f))
      (set! (-> a1-2 owner-handle) (process->handle this))
      (set! (-> a1-2 target-handle) (the-as handle #f))
      (set! (-> a1-2 target-pos quad) (the-as uint128 0))
      (set! (-> a1-2 ignore-handle) (process->handle this))
      (let* ((v1-20 *game-info*)
             (a0-15 (+ (-> v1-20 attack-id) 1))
             )
        (set! (-> v1-20 attack-id) a0-15)
        (set! (-> a1-2 attack-id) a0-15)
        )
      (set! (-> a1-2 timeout) (seconds 4))
      (spawn-projectile beast-grenade a1-2 this *default-dead-pool*)
      )
    )
  0
  (none)
  )

;; WARN: Return type mismatch float vs none.
(defmethod enemy-common-post ((this des-beast))
  "Common implementation of post. Runs ja-post."
  (when (>= (+ (current-time) (seconds -2)) (-> this attack-id-time))
    (let* ((v1-4 *game-info*)
           (a0-3 (+ (-> v1-4 attack-id) 1))
           )
      (set! (-> v1-4 attack-id) a0-3)
      (set! (-> this attack-id) a0-3)
      )
    (set-time! (-> this attack-id-time))
    )
  (transform-post)
  (let ((a1-0 (new 'stack-no-clear 'overlaps-others-params)))
    (set! (-> a1-0 options) (overlaps-others-options oo2))
    (set! (-> a1-0 collide-with-filter) (the-as collide-spec -1))
    (set! (-> a1-0 tlist) *touching-list*)
    (find-overlapping-shapes (-> this root) a1-0)
    )
  (seek! (-> this angry) 0.0 (* 5.0 (seconds-per-frame)))
  (debug-draw-path this)
  (when (!= (-> this s-clock) 1.0)
    (seek! (-> this s-clock) 1.0 (* 0.5 (seconds-per-frame)))
    (update-rates! (-> *display* entity-clock) (-> this s-clock))
    (update-rates! (-> *display* target-clock) (-> this s-clock))
    )
  (none)
  )

(defmethod debug-draw-path ((this des-beast))
  (when *display-path-marks*
    (dotimes (s5-0 (the-as int (+ (-> this des-path node-count) -1)))
      (add-debug-line
        #t
        (bucket-id debug-no-zbuf1)
        (-> this des-path node s5-0 position)
        (-> this des-path node (+ s5-0 1) position)
        *color-red*
        #f
        (the-as rgba -1)
        )
      )
    )
  0
  (none)
  )

(defun des-beast-gun-swivel-callback ((arg0 cspace) (arg1 transformq))
  (local-vars (sv-128 vector) (sv-144 vector) (sv-160 vector))
  (rlet ((vf0 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         (vf6 :class vf)
         )
    (init-vf0-vector)
    (cspace<-parented-transformq-joint! arg0 arg1)
    (let ((s3-0 (-> arg0 param1)))
      (set! sv-160 (new 'stack-no-clear 'vector))
      (let ((s4-0 (new 'stack-no-clear 'quaternion))
            (s0-0 (new 'stack-no-clear 'vector))
            (s1-0 (new 'stack-no-clear 'vector))
            (s2-0 (new 'stack-no-clear 'vector))
            (s5-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector)))
            )
        (set! sv-144 sv-160)
        (set! sv-128 (-> (the-as des-beast s3-0) target-gun-pos))
        (let ((v0-2 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))))
          (.lvf vf4 (&-> sv-128 quad))
          (.lvf vf5 (&-> v0-2 quad))
          )
        (.mov.vf.w vf6 vf0)
        (.sub.vf.xyz vf6 vf4 vf5)
        (.svf (&-> sv-144 quad) vf6)
        (rot-zxy-from-vector! s0-0 (-> arg0 bone transform fvec))
        (rot-zxy-from-vector! s1-0 sv-160)
        (set! (-> s2-0 x) (deg- (-> s1-0 x) (-> s0-0 x)))
        (set! (-> s2-0 y) (deg- (-> s1-0 y) (-> s0-0 y)))
        (set! (-> s2-0 y) (deg- (-> s1-0 y) 0.0))
        (set! (-> (the-as des-beast s3-0) angle-turret)
              (deg-seek (-> (the-as des-beast s3-0) angle-turret) (-> s2-0 y) (* 7281.778 (seconds-per-frame)))
              )
        (quaternion-vector-angle! s4-0 *up-vector* (-> (the-as des-beast s3-0) angle-turret))
        (quaternion->matrix (-> arg0 bone transform) s4-0)
        (vector-copy! (-> arg0 bone transform trans) s5-0)
        )
      )
    0
    (none)
    )
  )

(defun des-beast-gun-callback ((arg0 cspace) (arg1 transformq))
  (local-vars (sv-112 vector) (sv-128 vector))
  (rlet ((vf0 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         (vf6 :class vf)
         )
    (init-vf0-vector)
    (cspace<-parented-transformq-joint! arg0 arg1)
    (let ((s4-0 (-> arg0 param1)))
      (let ((s0-0 (new 'stack-no-clear 'vector)))
        (new 'stack-no-clear 'vector)
        (let ((s2-0 (new 'stack-no-clear 'vector))
              (s1-0 (new 'stack-no-clear 'vector))
              (s3-0 (new 'stack-no-clear 'vector))
              )
          (set! sv-128 s0-0)
          (set! sv-112 (-> (the-as des-beast s4-0) target-gun-pos))
          (let ((v0-1 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))))
            (.lvf vf4 (&-> sv-112 quad))
            (.lvf vf5 (&-> v0-1 quad))
            )
          (.mov.vf.w vf6 vf0)
          (.sub.vf.xyz vf6 vf4 vf5)
          (.svf (&-> sv-128 quad) vf6)
          (rot-zxy-from-vector! s2-0 (-> arg0 bone transform fvec))
          (rot-zxy-from-vector! s1-0 s0-0)
          (set! (-> s3-0 x) (fmax -5461.3335 (fmin -5461.3335 (deg- (-> s1-0 x) (-> s2-0 x)))))
          (set! (-> s3-0 y) (deg- (-> s1-0 y) (-> s2-0 y)))
          (set! (-> (the-as des-beast s4-0) angle-gun)
                (deg-seek (-> (the-as des-beast s4-0) angle-gun) (-> s3-0 x) (* 1820.4445 (seconds-per-frame)))
                )
          )
        )
      (quaternion-vector-angle! (-> arg1 quat) *x-vector* (-> (the-as des-beast s4-0) angle-gun))
      )
    (cspace<-parented-transformq-joint! arg0 arg1)
    0
    (none)
    )
  )

(defmethod go-fallback-init ((this des-beast))
  "If there's no specific settings for initial state, go to this state after spawning."
  (go (method-of-object this idle))
  )

(defmethod des-beast-method-165 ((this des-beast))
  (when (zero? (-> this des-path))
    (let ((v1-3 (res-lump-value (-> this entity) 'extra-id uint128 :time -1000000000.0)))
      (cond
        ((= (the-as uint v1-3) 1)
         (set! (-> this des-path) (-> *desbeast-path-table* 0))
         )
        ((= (the-as uint v1-3) 2)
         (set! (-> this des-path) (-> *desbeast-path-table* 1))
         )
        ((= (the-as uint v1-3) 3)
         (set! (-> this des-path) (-> *desbeast-path-table* 2))
         )
        ((= (the-as uint v1-3) 4)
         (set! (-> this des-path) (-> *desbeast-path-table* 3))
         )
        (else
          (go process-drawable-art-error "no-path")
          )
        )
      )
    )
  0
  (none)
  )

(defmethod init-enemy-collision! ((this des-beast))
  "Typical place to construct collision shapes"
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) cshape-reaction-default)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> s5-0 penetrated-by) (penetrate))
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 14) 0)))
      (set! (-> s5-0 total-prims) (the-as uint 15))
      (set! (-> s4-0 prim-core collide-as) (collide-spec enemy obstacle camera-blocker))
      (set! (-> s4-0 prim-core collide-with)
            (collide-spec backgnd jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> s4-0 prim-core action) (collide-action solid deadly no-standon))
      (set-vector! (-> s4-0 local-sphere) 0.0 16384.0 0.0 114688.0)
      (set! (-> s5-0 root-prim) s4-0)
      )
    (let ((v1-12 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-12 prim-core collide-as) (collide-spec camera-blocker))
      (set! (-> v1-12 prim-core collide-with) (collide-spec player-list))
      (set! (-> v1-12 prim-core action) (collide-action solid))
      (set-vector! (-> v1-12 local-sphere) 0.0 32768.0 0.0 61440.0)
      )
    (let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-14 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-14 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-14 prim-core action) (collide-action solid))
      (set! (-> v1-14 transform-index) 4)
      (set-vector! (-> v1-14 local-sphere) 0.0 0.0 0.0 24576.0)
      )
    (let ((v1-16 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-16 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-16 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-16 prim-core action) (collide-action solid))
      (set! (-> v1-16 transform-index) 6)
      (set-vector! (-> v1-16 local-sphere) 0.0 0.0 4096.0 16384.0)
      )
    (let ((v1-18 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-18 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-18 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-18 prim-core action) (collide-action solid))
      (set! (-> v1-18 transform-index) 7)
      (set-vector! (-> v1-18 local-sphere) 0.0 0.0 -6144.0 16384.0)
      )
    (let ((v1-20 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-20 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-20 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-20 prim-core action) (collide-action solid))
      (set! (-> v1-20 transform-index) 24)
      (set-vector! (-> v1-20 local-sphere) 0.0 0.0 0.0 24576.0)
      )
    (let ((v1-22 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-22 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-22 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-22 prim-core action) (collide-action solid))
      (set! (-> v1-22 transform-index) 27)
      (set-vector! (-> v1-22 local-sphere) 0.0 0.0 0.0 14336.0)
      )
    (let ((v1-24 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-24 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-24 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-24 prim-core action) (collide-action solid))
      (set! (-> v1-24 transform-index) 28)
      (set-vector! (-> v1-24 local-sphere) 0.0 0.0 0.0 10240.0)
      )
    (let ((v1-26 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-26 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-26 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-26 prim-core action) (collide-action solid))
      (set! (-> v1-26 transform-index) 29)
      (set-vector! (-> v1-26 local-sphere) 0.0 0.0 0.0 6144.0)
      )
    (let ((v1-28 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-28 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-28 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-28 prim-core action) (collide-action solid))
      (set! (-> v1-28 transform-index) 43)
      (set-vector! (-> v1-28 local-sphere) 0.0 0.0 -4096.0 12288.0)
      )
    (let ((v1-30 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-30 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-30 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-30 prim-core action) (collide-action solid))
      (set! (-> v1-30 transform-index) 44)
      (set-vector! (-> v1-30 local-sphere) 0.0 0.0 -4096.0 12288.0)
      )
    (let ((v1-32 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-32 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-32 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-32 prim-core action) (collide-action solid))
      (set! (-> v1-32 transform-index) 45)
      (set-vector! (-> v1-32 local-sphere) 0.0 0.0 0.0 14336.0)
      )
    (let ((v1-34 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-34 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-34 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-34 prim-core action) (collide-action solid))
      (set! (-> v1-34 transform-index) 34)
      (set-vector! (-> v1-34 local-sphere) 0.0 0.0 -4096.0 12288.0)
      )
    (let ((v1-36 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-36 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-36 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-36 prim-core action) (collide-action solid))
      (set! (-> v1-36 transform-index) 35)
      (set-vector! (-> v1-36 local-sphere) 0.0 -4096.0 0.0 12288.0)
      )
    (let ((v1-38 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-38 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-38 prim-core collide-with)
            (collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> v1-38 prim-core action) (collide-action solid))
      (set! (-> v1-38 transform-index) 36)
      (set-vector! (-> v1-38 local-sphere) 0.0 0.0 0.0 14336.0)
      )
    (set! (-> s5-0 nav-radius) 8192.0)
    (let ((v1-40 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-40 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-40 prim-core collide-with))
      )
    (set! (-> s5-0 max-iteration-count) (the-as uint 3))
    (set! (-> s5-0 event-self) 'touched)
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

;; WARN: Return type mismatch cspace vs none.
(defmethod init-enemy! ((this des-beast))
  "Typical place for shared init code. Runs from entity or process style init."
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-des-beast" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (setup-enemy! this *des-beast-enemy-info*)
  (set! (-> this event-hook) enemy-event-handler)
  (logclear! (-> this mask) (process-mask actor-pause))
  (logior! (-> this mask) (process-mask enemy))
  (set-vector! (-> this root scale) 2.0 2.0 2.0 1.0)
  (set! (-> this draw shadow-ctrl settings fade-dist) 942080.0)
  (set! (-> this path-pos) 0.0)
  (set! (-> this path-pos-speed) 1.0)
  (set! (-> this run-start-frame) 0.0)
  (set! (-> this main-speed-factor) 0.0)
  (set! (-> this main-speed-factor-dest) 1.0)
  (set! (-> this can-turn?) #f)
  (cond
    ((kiosk?)
     (set! (-> this hit-points) 110.0)
     (set! (-> this hit-points2) 35.0)
     )
    (else
      (set! (-> this hit-points) (- 225.0 (* 70.0 (you-suck-scale *game-info* #f 0))))
      (set! (-> this hit-points2) 50.0)
      )
    )
  (set! (-> this angry) 0.0)
  (set! (-> this attack-next?) #f)
  (set! (-> this s-clock) 1.0)
  (set! (-> this attack-id) (the-as uint 0))
  (set! (-> this attack-id-time) 0)
  (set! (-> this oomass) 1.0)
  (set! (-> this jitter) 0.0)
  (set! (-> this shoot-delay) (seconds 4))
  (update-rates! (-> *display* entity-clock) (-> this s-clock))
  (update-rates! (-> *display* target-clock) (-> this s-clock))
  (des-beast-method-165 this)
  (let ((a0-14 (-> this node-list data 20)))
    (set! (-> a0-14 param0) des-beast-gun-swivel-callback)
    (set! (-> a0-14 param1) this)
    )
  (let ((v0-8 (-> this node-list data 21)))
    (set! (-> v0-8 param0) des-beast-gun-callback)
    (set! (-> v0-8 param1) this)
    )
  (none)
  )

(defmethod des-beast-method-166 ((this des-beast))
  (set! (-> this minimap) (add-icon! *minimap* this (the-as uint 13) (the-as int #f) (the-as vector #t) 0))
  0
  (none)
  )

(defmethod relocate ((this des-beast) (offset int))
  (if (nonzero? (-> this hit-part))
      (&+! (-> this hit-part) offset)
      )
  (call-parent-method this offset)
  )

(defmethod deactivate ((this des-beast))
  "Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
  (if (nonzero? (-> this hit-part))
      (kill-particles (-> this hit-part))
      )
  (update-rates! (-> *display* entity-clock) 1.0)
  (update-rates! (-> *display* target-clock) 1.0)
  (call-parent-method this)
  (none)
  )

(defmethod init-from-entity! ((this des-beast) (arg0 entity-actor))
  "Set up a newly created process from the entity that created it."
  (init-enemy-collision! this)
  (process-drawable-from-entity! this arg0)
  (set! (-> this manager) (the-as handle #f))
  (init-enemy! this)
  (vector-copy! (-> this root trans) (-> this des-path node 0 position))
  (set! (-> this hit-part) (create-launch-control group-beast-hit this))
  (des-beast-method-166 this)
  (go-fallback-init this)
  )

(defbehavior des-beast-init-by-other des-beast ((arg0 level) (arg1 entity-actor) (arg2 desbeast-path) (arg3 quaternion) (arg4 handle))
  (set! (-> self level) arg0)
  (set! (-> self entity) arg1)
  (set! (-> self manager) arg4)
  (init-enemy-collision! self)
  (vector-copy! (-> self root trans) (-> arg2 node 0 position))
  (quaternion-copy! (-> self root quat) arg3)
  (set! (-> self des-path) arg2)
  (set! (-> self hit-part) (create-launch-control group-beast-hit self))
  (init-enemy! self)
  (des-beast-method-166 self)
  (go-fallback-init self)
  )
