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

(import "goal_src/jak1/import/sack-ag.gc")
(import "goal_src/jak1/import/mistycannon-ag.gc")

;; definition of type angle-tracker
(deftype angle-tracker (structure)
  ((value float  :offset-assert   0)
   (min   float  :offset-assert   4)
   (range float  :offset-assert   8)
   (speed float  :offset-assert  12)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition for method 3 of type angle-tracker
(defmethod inspect angle-tracker ((obj angle-tracker))
  (format #t "[~8x] ~A~%" obj 'angle-tracker)
  (format #t "~Tvalue: ~f~%" (-> obj value))
  (format #t "~Tmin: ~f~%" (-> obj min))
  (format #t "~Trange: ~f~%" (-> obj range))
  (format #t "~Tspeed: ~f~%" (-> obj speed))
  obj
  )

;; definition for function angle-tracker-apply-move!
(defun angle-tracker-apply-move! ((arg0 angle-tracker) (arg1 float))
  (let* ((f0-2 (* arg1 (-> arg0 speed) (-> *display* seconds-per-frame)))
         (f0-3 (+ (-> arg0 value) f0-2))
         )
    (when (!= (-> arg0 range) 0.0)
      (if (< f0-3 0.0)
          (set! f0-3 0.0)
          )
      (if (< (-> arg0 range) f0-3)
          (set! f0-3 (-> arg0 range))
          )
      )
    (let ((f1-7 (- (-> arg0 value) f0-3)))
      (if (= (-> arg0 range) 0.0)
          (set! f0-3 (the float (sar (shl (the int f0-3) 48) 48)))
          )
      (set! (-> arg0 value) f0-3)
      f1-7
      )
    )
  )

;; definition for function angle-tracker-init-range!
;; INFO: Return type mismatch int vs none.
(defun angle-tracker-init-range! ((arg0 angle-tracker) (arg1 float) (arg2 float) (arg3 float))
  (set! (-> arg0 min) arg1)
  (set! (-> arg0 range) (the float (sar (shl (the int (- arg2 arg1)) 48) 48)))
  (if (< (-> arg0 range) 0.0)
      (set! (-> arg0 range) (+ 65536.0 (-> arg0 range)))
      )
  (set! (-> arg0 value) (* 0.5 (-> arg0 range)))
  (set! (-> arg0 speed) arg3)
  0
  (none)
  )

;; definition for function angle-tracker-get-value
(defun angle-tracker-get-value ((arg0 angle-tracker))
  (the float (sar (shl (the int (+ (-> arg0 min) (-> arg0 value))) 48) 48))
  )

;; definition for function angle-tracker-set-value
(defun angle-tracker-set-value ((arg0 angle-tracker) (arg1 float))
  (let ((v1-0 (- arg1 (-> arg0 min))))
    (when (!= (-> arg0 range) 0.0)
      (if (< v1-0 0.0)
          (set! v1-0 0.0)
          )
      (if (< (-> arg0 range) v1-0)
          (set! v1-0 (-> arg0 range))
          )
      )
    (set! (-> arg0 value) v1-0)
    (+ (-> arg0 min) v1-0)
    )
  )

;; definition for function angle-tracker-seek!
(defun angle-tracker-seek! ((arg0 angle-tracker) (arg1 float))
  (let* ((v1-0 arg0)
         (f1-1 (the float (sar (shl (the int (+ (-> v1-0 min) (-> v1-0 value))) 48) 48)))
         (f0-6 (* (-> arg0 speed) (-> *display* seconds-per-frame)))
         (v1-9 (the float (sar (shl (the int (- arg1 f1-1)) 48) 48)))
         )
    (when (< (fabs v1-9) f0-6)
      (let ((f0-8 (+ (-> arg0 value) v1-9)))
        (cond
          ((= (-> arg0 range) 0.0)
           (set! (-> arg0 value) (the float (sar (shl (the int f0-8) 48) 48)))
           (return #t)
           )
          (else
            (when (< f0-8 0.0)
              (set! (-> arg0 value) 0.0)
              (return #f)
              )
            (when (< (-> arg0 range) f0-8)
              (set! (-> arg0 value) (-> arg0 range))
              (return #f)
              )
            (set! (-> arg0 value) f0-8)
            (return #t)
            )
          )
        )
      (set! v1-9 (the-as float 0))
      )
    (cond
      ((< v1-9 0.0)
       (let ((f0-14 (- (-> arg0 value) f0-6)))
         (set! f0-14 (cond
                       ((= (-> arg0 range) 0.0)
                        (the float (sar (shl (the int f0-14) 48) 48))
                        )
                       (else
                         (if (< f0-14 0.0)
                             (set! f0-14 0.0)
                             )
                         f0-14
                         )
                       )
               )
         (set! (-> arg0 value) (the float (sar (shl (the int f0-14) 48) 48)))
         )
       )
      (else
        (let ((f0-20 (+ (-> arg0 value) f0-6)))
          (set! f0-20 (cond
                        ((= (-> arg0 range) 0.0)
                         (the float (sar (shl (the int f0-20) 48) 48))
                         )
                        (else
                          (if (< (-> arg0 range) f0-20)
                              (set! f0-20 (-> arg0 range))
                              )
                          f0-20
                          )
                        )
                )
          (set! (-> arg0 value) (the float (sar (shl (the int f0-20) 48) 48)))
          )
        )
      )
    )
  #f
  )

;; failed to figure out what this is:
(defpartgroup group-beach-sack-fuse
  :id 117
  :bounds (static-bspherem 0 0 0 1)
  :parts ((sp-item 517 :fade-after (meters 30))
    (sp-item 518 :fade-after (meters 120) :falloff-to (meters 120))
    (sp-item 519 :fade-after (meters 80) :falloff-to (meters 80))
    )
  )

;; failed to figure out what this is:
(defpart 517
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 4.0)
    (sp-flt spt-scale-x (meters 0.1))
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 192.0)
    (sp-flt spt-g 192.0)
    (sp-rnd-flt spt-b 64.0 128.0 1.0)
    (sp-rnd-flt spt-a 4.0 24.0 1.0)
    (sp-flt spt-vel-y (meters 0.013333334))
    (sp-rnd-flt spt-rotvel-z (degrees -0.15) (degrees 0.3) 1.0)
    (sp-flt spt-fade-a 2.1333334)
    (sp-flt spt-accel-y -0.4096)
    (sp-int-plain-rnd spt-timer 45 14 1)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 180.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 518
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.25) (meters 1) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 192.0)
    (sp-flt spt-g 192.0)
    (sp-rnd-flt spt-b 64.0 128.0 1.0)
    (sp-rnd-flt spt-a 48.0 48.0 1.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 519
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 4.0)
    (sp-flt spt-scale-x (meters 0.2))
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 32.0)
    (sp-flt spt-g 32.0)
    (sp-rnd-flt spt-b 8.0 24.0 1.0)
    (sp-rnd-flt spt-a 160.0 95.0 1.0)
    (sp-flt spt-scalevel-x (meters 0.016666668))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -8.366014)
    (sp-flt spt-accel-y -8.192)
    (sp-int spt-timer 15)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 180.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 0.6) (meters 0.2) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-beach-sack-explosion
  :id 118
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 16)
  :parts ((sp-item 520 :period 1200 :length 30)
    (sp-item 521 :fade-after (meters 60) :period 1200 :length 15)
    (sp-item 522 :period 1200 :length 15 :offset 15)
    (sp-item 523 :period 1200 :length 15)
    (sp-item 524 :fade-after (meters 80) :falloff-to (meters 80) :period 1200 :length 30 :binding 525)
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    (sp-item 525 :flags (start-dead))
    )
  )

;; failed to figure out what this is:
(defpart 520
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 1.5)
    (sp-rnd-flt spt-y (meters 0.5) (meters 0.5) 1.0)
    (sp-rnd-flt spt-scale-x (meters 2.5) (meters 1.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 70.0)
    (sp-flt spt-g 70.0)
    (sp-rnd-flt spt-b 70.0 16.0 1.0)
    (sp-flt spt-a 96.0)
    (sp-rnd-flt spt-vel-y (meters 0.006666667) (meters 0.033333335) 1.0)
    (sp-flt spt-scalevel-x (meters 0.006))
    (sp-rnd-flt spt-rotvel-z (degrees -0.2) (degrees 0.4) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-accel-y 0.2048)
    (sp-flt spt-friction 0.92)
    (sp-int spt-timer 900)
    (sp-cpuinfo-flags bit2 bit12 bit14)
    (sp-int-plain-rnd spt-next-time 30 299 1)
    (sp-launcher-by-id spt-next-launcher 526)
    (sp-rnd-flt spt-conerot-x (degrees 70.0) (degrees 20.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-conerot-radius (meters 2))
    )
  )

;; failed to figure out what this is:
(defpart 526
  :init-specs ((sp-flt spt-scalevel-x (meters 0)) (sp-copy-from-other spt-scalevel-y -4) (sp-flt spt-fade-a -0.32))
  )

;; failed to figure out what this is:
(defpart 521
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x2 :page #x2))
    (sp-flt spt-num 6.0)
    (sp-flt spt-y (meters 0.75))
    (sp-rnd-flt spt-scale-x (meters 8) (meters 8) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 1.2) (meters 3) 1.0)
    (sp-flt spt-r 192.0)
    (sp-flt spt-g 192.0)
    (sp-rnd-flt spt-b 64.0 128.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-scalevel-x (meters 0.009765625))
    (sp-rnd-flt spt-rotvel-z (degrees -0.15) (degrees 0.3) 1.0)
    (sp-flt spt-scalevel-y (meters 0.009765625))
    (sp-flt spt-fade-a 2.1333334)
    (sp-int spt-timer 30)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int spt-next-time 15)
    (sp-launcher-by-id spt-next-launcher 527)
    (sp-flt spt-rotate-y (degrees 0.0))
    )
  )

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

;; failed to figure out what this is:
(defpart 522
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-y (meters 1))
    (sp-rnd-flt spt-scale-x (meters 24) (meters 16) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 196.0)
    (sp-flt spt-g 196.0)
    (sp-flt spt-b 196.0)
    (sp-flt spt-a 64.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 523
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-y (meters 1))
    (sp-rnd-flt spt-scale-x (meters 24) (meters 16) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 196.0)
    (sp-flt spt-g 32.0)
    (sp-flt spt-b 32.0)
    (sp-flt spt-a 64.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 524
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 5.0 10.0 1.0)
    (sp-rnd-flt spt-x (meters -0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-y (meters 0.25) (meters 1.5) 1.0)
    (sp-rnd-flt spt-z (meters -0.5) (meters 1) 1.0)
    (sp-flt spt-scale-x (meters 0.5))
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 255.0)
    (sp-rnd-int spt-g 1123942400 1 127.0)
    (sp-flt spt-b 0.0)
    (sp-flt spt-a 127.0)
    (sp-rnd-flt spt-vel-y (meters 0.06666667) (meters 0.06666667) 1.0)
    (sp-flt spt-fade-g -4.266667)
    (sp-flt spt-fade-b -2.8444445)
    (sp-flt spt-accel-y -16.384)
    (sp-flt spt-friction 0.97)
    (sp-int spt-timer 90)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int-plain-rnd spt-next-time 5 38 1)
    (sp-launcher-by-id spt-next-launcher 528)
    (sp-rnd-flt spt-conerot-x (degrees 40.0) (degrees 30.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 528
  :init-specs ((sp-flt spt-scalevel-x (meters -0.0033333334))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-r -4.266667)
    (sp-flt spt-fade-g 0.7111111)
    (sp-flt spt-fade-b 1.4222223)
    (sp-flt spt-fade-a -2.8444445)
    )
  )

;; failed to figure out what this is:
(defpart 525
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 2.0)
    (sp-rnd-flt spt-x (meters -0.25) (meters 0.5) 1.0)
    (sp-rnd-flt spt-y (meters -0.25) (meters 0.5) 1.0)
    (sp-rnd-flt spt-z (meters -0.25) (meters 0.5) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 70.0)
    (sp-flt spt-g 70.0)
    (sp-rnd-flt spt-b 70.0 16.0 1.0)
    (sp-rnd-flt spt-a 20.0 8.0 1.0)
    (sp-flt spt-scalevel-x (meters 0.0033333334))
    (sp-rnd-flt spt-rotvel-z (degrees -0.3) (degrees 0.6) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.11666667)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit12 bit14)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-beach-cannon-fire
  :id 119
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 24)
  :parts ((sp-item 529 :fade-after (meters 200) :falloff-to (meters 200) :period 1200 :length 30)
    (sp-item 530 :fade-after (meters 100) :falloff-to (meters 100) :period 1200 :length 15)
    (sp-item 531 :fade-after (meters 40) :falloff-to (meters 40) :period 1200 :length 15)
    (sp-item 532 :period 1200 :length 15 :offset 15)
    (sp-item 533 :period 1200 :length 15)
    (sp-item 534 :fade-after (meters 40) :falloff-to (meters 40) :period 1200 :length 15 :binding 535)
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    (sp-item 535 :flags (start-dead))
    )
  )

;; failed to figure out what this is:
(defpart 529
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 6.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-rnd-flt spt-b 64.0 16.0 1.0)
    (sp-flt spt-a 48.0)
    (sp-rnd-flt spt-vel-y (meters 0.1) (meters 0.013333334) 1.0)
    (sp-flt spt-vel-z (meters -0.033333335))
    (sp-flt spt-scalevel-x (meters 0.016666668))
    (sp-rnd-flt spt-rotvel-z (degrees -0.2) (degrees 0.4) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-accel-y 0.27306667)
    (sp-flt spt-friction 0.92)
    (sp-int spt-timer 900)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-int-plain-rnd spt-next-time 30 299 1)
    (sp-launcher-by-id spt-next-launcher 536)
    (sp-flt spt-launchrot-x (degrees 90.0))
    (sp-rnd-flt spt-launchrot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-conerot-x (degrees 45.0))
    (sp-flt spt-conerot-radius (meters 2))
    (sp-flt spt-rotate-y (degrees 90.0))
    )
  )

;; failed to figure out what this is:
(defpart 536
  :init-specs ((sp-flt spt-scalevel-x (meters 0.006666667))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.16)
    )
  )

;; failed to figure out what this is:
(defpart 530
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 5.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-rnd-flt spt-b 64.0 16.0 1.0)
    (sp-flt spt-a 48.0)
    (sp-rnd-flt spt-vel-z (meters 0.3) (meters 0.06666667) 1.0)
    (sp-flt spt-scalevel-x (meters 0.026666667))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-accel-y -0.27306667)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 900)
    (sp-cpuinfo-flags bit2 bit12)
    (sp-int-plain-rnd spt-next-time 30 149 1)
    (sp-launcher-by-id spt-next-launcher 536)
    (sp-rnd-flt spt-launchrot-x (degrees -83.0) (degrees -7.0000005) 1.0)
    (sp-rnd-flt spt-launchrot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-conerot-x (degrees 45.0))
    (sp-flt spt-conerot-radius (meters 2))
    (sp-flt spt-rotate-y (degrees 90.0))
    )
  )

;; failed to figure out what this is:
(defpart 531
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x2 :page #x2))
    (sp-flt spt-num 6.0)
    (sp-flt spt-y (meters 0.75))
    (sp-rnd-flt spt-scale-x (meters 16) (meters 16) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 1.2) (meters 3) 1.0)
    (sp-flt spt-r 192.0)
    (sp-flt spt-g 192.0)
    (sp-rnd-flt spt-b 64.0 128.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-scalevel-x (meters 0.009765625))
    (sp-rnd-flt spt-rotvel-z (degrees -0.15) (degrees 0.3) 1.0)
    (sp-flt spt-scalevel-y (meters 0.009765625))
    (sp-flt spt-fade-a 2.1333334)
    (sp-int spt-timer 30)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 15)
    (sp-launcher-by-id spt-next-launcher 537)
    )
  )

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

;; failed to figure out what this is:
(defpart 532
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-y (meters 1))
    (sp-rnd-flt spt-scale-x (meters 24) (meters 16) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 196.0)
    (sp-flt spt-g 196.0)
    (sp-flt spt-b 196.0)
    (sp-flt spt-a 64.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 533
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-y (meters 1))
    (sp-rnd-flt spt-scale-x (meters 24) (meters 16) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 196.0)
    (sp-flt spt-g 32.0)
    (sp-flt spt-b 32.0)
    (sp-flt spt-a 64.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 534
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 5.0 10.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 255.0)
    (sp-flt spt-g 255.0)
    (sp-flt spt-b 0.0)
    (sp-flt spt-a 128.0)
    (sp-rnd-flt spt-vel-z (meters 0.16666667) (meters 0.16666667) 1.0)
    (sp-flt spt-fade-g -4.2222223)
    (sp-flt spt-fade-b -2.8)
    (sp-rnd-flt spt-accel-y -6.826667 -3.4133334 1.0)
    (sp-flt spt-friction 0.95)
    (sp-int spt-timer 600)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int-plain-rnd spt-next-time 10 89 1)
    (sp-launcher-by-id spt-next-launcher 538)
    (sp-rnd-flt spt-launchrot-x (degrees -60.0) (degrees -60.0) 1.0)
    (sp-rnd-flt spt-launchrot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-conerot-x (degrees 45.0))
    (sp-flt spt-rotate-y (degrees 90.0))
    )
  )

;; failed to figure out what this is:
(defpart 538
  :init-specs ((sp-flt spt-scalevel-x (meters -0.0033333334))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-r -0.6)
    (sp-flt spt-fade-g -1.8)
    (sp-flt spt-fade-a -0.85333335)
    )
  )

;; failed to figure out what this is:
(defpart 535
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 0.5)
    (sp-rnd-flt spt-x (meters -0.25) (meters 0.5) 1.0)
    (sp-rnd-flt spt-y (meters -0.25) (meters 0.5) 1.0)
    (sp-rnd-flt spt-z (meters -0.25) (meters 0.5) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1) (meters 1) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-flt spt-b 64.0)
    (sp-rnd-flt spt-a 16.0 8.0 1.0)
    (sp-flt spt-scalevel-x (meters 0.006666667))
    (sp-rnd-flt spt-rotvel-z (degrees -0.6) (degrees 1.2) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.08)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit12)
    )
  )

;; definition of type mistycannon-missile
(deftype mistycannon-missile (process-drawable)
  ((root-override collide-shape-moving             :offset        112)
   (muzzle-time   float                            :offset-assert 176)
   (tumble-quat   quaternion               :inline :offset-assert 192)
   (blast-radius  float                            :offset-assert 208)
   (water-height  float                            :offset-assert 212)
   (sfx           uint32                           :offset-assert 216)
   (part2         sparticle-launch-control         :offset-assert 220)
   (ground-time   time-frame                       :offset-assert 224)
   )
  :heap-base #x80
  :method-count-assert 21
  :size-assert         #xe8
  :flag-assert         #x15008000e8
  (:methods
    (spawn-part (_type_) none 20)
    )
  (:states
    mistycannon-missile-explode
    mistycannon-missile-idle
    mistycannon-missile-in-water
    )
  )

;; definition for method 3 of type mistycannon-missile
(defmethod inspect mistycannon-missile ((obj mistycannon-missile))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tmuzzle-time: ~f~%" (-> obj muzzle-time))
  (format #t "~T~Ttumble-quat: #<quaternion @ #x~X>~%" (-> obj tumble-quat))
  (format #t "~T~Tblast-radius: ~f~%" (-> obj blast-radius))
  (format #t "~T~Twater-height: ~f~%" (-> obj water-height))
  (format #t "~T~Tsfx: ~D~%" (-> obj sfx))
  (format #t "~T~Tpart2: ~A~%" (-> obj part2))
  (format #t "~T~Tground-time: ~D~%" (-> obj ground-time))
  obj
  )

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

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

;; failed to figure out what this is:
(defskelgroup *mistycannon-missile-sg* sack sack-lod0-jg sack-idle-ja
              ((sack-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 4)
              )

;; definition for method 20 of type mistycannon-missile
;; INFO: Return type mismatch int vs none.
(defmethod spawn-part mistycannon-missile ((obj mistycannon-missile))
  (let ((gp-0 (-> obj part))
        (a1-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 7)))
        )
    (spawn gp-0 a1-1)
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defstate mistycannon-missile-idle (mistycannon-missile)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('attack)
       (go mistycannon-missile-explode)
       )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self sfx) (the-as uint 0))
    0
    (none)
    )
  :trans (behavior ()
    (if (< (-> self root-override trans y) (-> self water-height))
        (go mistycannon-missile-in-water)
        )
    (none)
    )
  :code (behavior ()
    (clear-collide-with-as (-> self root-override))
    (while (< (- (-> *display* base-frame-counter) (-> self state-time)) (the int (* 300.0 (-> self muzzle-time))))
      (quaternion*! (-> self root-override quat) (-> self root-override quat) (-> self tumble-quat))
      (suspend)
      (let ((f0-1 (fmin 1.0 (/ (the float (- (-> *display* base-frame-counter) (-> self state-time)))
                               (the float (the int (* 300.0 (-> self muzzle-time))))
                               )
                        )
                  )
            )
        (set! (-> self root-override scale x) (* 0.6 f0-1))
        (set! (-> self root-override scale y) (* 0.6 f0-1))
        (set! (-> self root-override scale z) (* 0.6 f0-1))
        )
      )
    (restore-collide-with-as (-> self root-override))
    (set-vector! (-> self root-override scale) 0.6 0.6 0.6 1.0)
    (while (zero? (logand (-> self root-override status) (cshape-moving-flags onsurf)))
      (if (and (zero? (-> self sfx))
               (< (if *target*
                      (vector-vector-distance (-> self root-override trans) (-> *target* control trans))
                      4096000.0
                      )
                  409600.0
                  )
               )
          (set! (-> self sfx)
                (the-as uint (sound-play "sack-incoming" :position (the-as symbol (-> self root-override trans))))
                )
          )
      (when (nonzero? (-> self sfx))
        (let ((gp-1 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
          (set! (-> gp-1 command) (sound-command set-param))
          (set! (-> gp-1 id) (the-as sound-id (-> self sfx)))
          (let ((a1-3 (-> self root-override trans)))
            (let ((s5-1 self))
              (when (= a1-3 #t)
                (if (and s5-1 (type-type? (-> s5-1 type) process-drawable) (nonzero? (-> s5-1 root-override)))
                    (set! a1-3 (-> s5-1 root-override trans))
                    (set! a1-3 (the-as vector #f))
                    )
                )
              )
            (sound-trans-convert (-> gp-1 parms trans) a1-3)
            )
          (set! (-> gp-1 parms mask) (sound-mask trans))
          (-> gp-1 id)
          )
        )
      (quaternion*! (-> self root-override quat) (-> self root-override quat) (-> self tumble-quat))
      (suspend)
      )
    (quaternion-set! (-> self root-override quat) 0.0 0.0 0.0 1.0)
    (update-transforms! (-> self root-override))
    (when (nonzero? (-> self sfx))
      (sound-stop (the-as sound-id (-> self sfx)))
      (set! (-> self sfx) (the-as uint 0))
      0
      )
    (set! (-> self ground-time) (-> *display* base-frame-counter))
    (sound-play "sack-land" :position (the-as symbol (-> self root-override trans)))
    (ja-no-eval :group! sack-hit-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (ja-no-eval :group! sack-fuse-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (go mistycannon-missile-explode)
    (none)
    )
  :post (behavior ()
    (vector-v++!
      (-> self root-override transv)
      (compute-acc-due-to-gravity (-> self root-override) (new-stack-vector0) 1.0)
      )
    (set! (-> self root-override root-prim prim-core offense) (collide-offense touch))
    (fill-cache-integrate-and-collide!
      (-> self root-override)
      (-> self root-override transv)
      (-> self root-override root-prim collide-with)
      )
    (set! (-> self root-override root-prim prim-core offense) (collide-offense indestructible))
    (spawn-part self)
    (when (and (zero? (-> self draw cur-lod)) (logtest? (-> self draw status) (draw-status was-drawn)))
      (if (logtest? (-> self root-override status) (cshape-moving-flags onsurf))
          (draw-shadow
            (-> self root-override shadow-pos)
            (-> self root-override shadow-pos)
            (-> self root-override ground-poly-normal)
            8192.0
            4096.0
            (the-as float 0)
            )
          (find-ground-and-draw-shadow
            (-> self root-override trans)
            (-> self root-override shadow-pos)
            8192.0
            (collide-kind background)
            (the-as process-drawable #f)
            0.0
            81920.0
            )
          )
      )
    (ja-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate mistycannon-missile-in-water (mistycannon-missile)
  :code (behavior ()
    (when (nonzero? (-> self sfx))
      (sound-stop (the-as sound-id (-> self sfx)))
      (set! (-> self sfx) (the-as uint 0))
      0
      )
    (let ((a1-0 (new-stack-vector0)))
      (set! (-> a1-0 x) (-> self root-override trans x))
      (set! (-> a1-0 y) (-> self water-height))
      (set! (-> a1-0 z) (-> self root-override trans z))
      (set! (-> a1-0 w) 1.0)
      (splash-spawn (the-as basic 1.0) (the-as basic a1-0) 1)
      )
    (label cfg-3)
    (vector-v++!
      (-> self root-override transv)
      (compute-acc-due-to-gravity (-> self root-override) (new-stack-vector0) 1.0)
      )
    (vector-float*! (-> self root-override transv) (-> self root-override transv) 0.5)
    (update-transforms! (-> self root-override))
    (fill-cache-integrate-and-collide!
      (-> self root-override)
      (-> self root-override transv)
      (-> self root-override root-prim collide-with)
      )
    (seek! (-> self root-override scale x) 0.0 (* 0.01 (-> *display* time-adjust-ratio)))
    (seek! (-> self root-override scale y) 0.0 (* 0.01 (-> *display* time-adjust-ratio)))
    (seek! (-> self root-override scale z) 0.0 (* 0.01 (-> *display* time-adjust-ratio)))
    (when (< 0.05 (-> self root-override scale x))
      (suspend)
      (goto cfg-3)
      )
    (ja-channel-set! 0)
    (none)
    )
  :post (the-as (function none :behavior mistycannon-missile) ja-post)
  )

;; failed to figure out what this is:
(defstate mistycannon-missile-explode (mistycannon-missile)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touched)
       (let* ((s4-0 arg0)
              (v1-2 (if (and (nonzero? s4-0) (type-type? (-> s4-0 type) process-drawable))
                        s4-0
                        )
                    )
              )
         (when v1-2
           (let* ((v1-3 (-> (the-as mistycannon-missile v1-2) root-override))
                  (a1-2 (-> self root-override root-prim prim-core))
                  (v1-5 (-> v1-3 root-prim prim-core))
                  (a2-1 (new 'stack-no-clear 'vector))
                  (t2-0 (new 'stack-no-clear 'collide-tri-result))
                  )
             0.0
             (vector-! a2-1 (the-as vector v1-5) (the-as vector a1-2))
             (when (< (fill-and-probe-using-line-sphere
                        *collide-cache*
                        (the-as vector a1-2)
                        a2-1
                        40.96
                        (collide-kind background)
                        self
                        t2-0
                        (new 'static 'pat-surface :noentity #x1)
                        )
                      0.0
                      )
               (cond
                 ((= (-> arg0 type) target)
                  (send-event arg0 'attack (-> arg3 param 0) (static-attack-info ((mode 'explode))))
                  )
                 (else
                   (let ((a1-4 (new 'stack-no-clear 'event-message-block)))
                     (set! (-> a1-4 from) self)
                     (set! (-> a1-4 num-params) 4)
                     (set! (-> a1-4 message) 'attack)
                     (set! (-> a1-4 param 0) (-> arg3 param 0))
                     (set! (-> a1-4 param 1) (the-as uint 'explode))
                     (let ((v1-18 (+ *global-attack-id* 1)))
                       (set! *global-attack-id* v1-18)
                       (set! (-> a1-4 param 2) (the-as uint v1-18))
                       )
                     (set! (-> a1-4 param 3) (the-as uint 0))
                     (send-event-function arg0 a1-4)
                     )
                   )
                 )
               )
             )
           )
         )
       )
      )
    )
  :code (behavior ()
    (if (and *target* (= (-> *target* next-state name) 'target-periscope))
        (sound-play-by-spec (static-sound-spec "explosion" :fo-min 200 :fo-max 400) (new-sound-id) (the-as vector #t))
        (sound-play-by-spec (static-sound-spec "explosion") (new-sound-id) (the-as vector #t))
        )
    (spawn (-> self part2) (-> self root-override trans))
    (ja-channel-set! 0)
    (let ((v1-11 (-> self root-override root-prim)))
      (set! (-> v1-11 local-sphere w) (-> self blast-radius))
      (set! (-> v1-11 prim-core world-sphere w) (-> self blast-radius))
      (set! (-> v1-11 collide-with) (collide-kind cak-2 cak-3 target crate enemy wall-object))
      (set! (-> v1-11 prim-core collide-as) (collide-kind enemy))
      )
    (update-transforms! (-> self root-override))
    (let ((a1-3 (new 'stack-no-clear 'overlaps-others-params)))
      (set! (-> a1-3 options) (the-as uint 0))
      (set! (-> a1-3 tlist) *touching-list*)
      (find-overlapping-shapes (-> self root-override) a1-3)
      )
    (suspend)
    (clear-collide-with-as (-> self root-override))
    (let ((gp-2 (-> *display* base-frame-counter)))
      (until (>= (- (-> *display* base-frame-counter) gp-2) (seconds 3))
        (spawn (-> self part2) (-> self root-override trans))
        (suspend)
        )
      )
    (kill-and-free-particles (-> self part2))
    (deactivate self)
    (none)
    )
  :post (the-as (function none :behavior mistycannon-missile) ja-post)
  )

;; definition for function mistycannon-collision-reaction
;; INFO: Return type mismatch int vs cshape-moving-flags.
(defun mistycannon-collision-reaction ((arg0 collide-shape-moving) (arg1 collide-shape-intersect) (arg2 vector) (arg3 vector))
  (let ((s5-0 0))
    (let ((a1-1 (new 'stack-no-clear 'vector)))
      (vector-float*! a1-1 (-> arg1 move-vec) (-> arg1 best-u))
      (move-by-vector! arg0 a1-1)
      )
    (let ((f0-2 (vector-dot (-> arg0 transv) (-> arg1 best-tri normal)))
          (v1-6 (new 'stack-no-clear 'vector))
          )
      (vector-float*! v1-6 (-> arg1 best-tri normal) (* 2.0 f0-2))
      (vector-! (-> arg0 transv) (-> arg0 transv) v1-6)
      )
    (vector-float*! (-> arg0 transv) (-> arg0 transv) 0.15)
    (let ((v0-1 (logior s5-0 7)))
      (logior! (-> arg0 status) v0-1)
      (the-as cshape-moving-flags v0-1)
      )
    )
  )

;; definition of type mistycannon-init-data
(deftype mistycannon-init-data (structure)
  ((pos          vector  :offset-assert   0)
   (vel          vector  :offset-assert   4)
   (rotate       float   :offset-assert   8)
   (flight-time  float   :offset-assert  12)
   (muzzle-time  float   :offset-assert  16)
   (blast-radius float   :offset-assert  20)
   )
  :method-count-assert 9
  :size-assert         #x18
  :flag-assert         #x900000018
  )

;; definition for method 3 of type mistycannon-init-data
(defmethod inspect mistycannon-init-data ((obj mistycannon-init-data))
  (format #t "[~8x] ~A~%" obj 'mistycannon-init-data)
  (format #t "~Tpos: #<vector @ #x~X>~%" (-> obj pos))
  (format #t "~Tvel: #<vector @ #x~X>~%" (-> obj vel))
  (format #t "~Trotate: ~f~%" (-> obj rotate))
  (format #t "~Tflight-time: ~f~%" (-> obj flight-time))
  (format #t "~Tmuzzle-time: ~f~%" (-> obj muzzle-time))
  (format #t "~Tblast-radius: ~f~%" (-> obj blast-radius))
  obj
  )

;; definition for function mistycannon-missile-init-by-other
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defbehavior mistycannon-missile-init-by-other mistycannon-missile ((arg0 mistycannon-init-data) (arg1 entity-actor))
  (set! (-> self mask) (logior (process-mask projectile) (-> self mask)))
  (logclear! (-> self mask) (process-mask actor-pause))
  (set! (-> self entity) arg1)
  (let ((s5-0 (new 'process 'collide-shape-moving self (collide-list-enum hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) mistycannon-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s4-0 collide-with) (collide-kind background cak-2 cak-3 target crate enemy wall-object))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 prim-core offense) (collide-offense touch))
      (set! (-> s4-0 transform-index) 0)
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 1720.3201)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> s5-0 event-self) 'touched)
    (set! (-> s5-0 max-iteration-count) (the-as uint 4))
    (set! (-> self root-override) s5-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 pos quad))
  (set-vector! (-> self root-override scale) 0.0 0.0 0.0 1.0)
  (set! (-> self muzzle-time) (-> arg0 muzzle-time))
  (quaternion-axis-angle! (-> self root-override quat) 0.0 1.0 0.0 (-> arg0 rotate))
  (let ((f0-13 (/ 655360.0 (the float (the int (* 300.0 (-> arg0 flight-time)))))))
    (quaternion-axis-angle! (-> self tumble-quat) 1.0 0.0 0.0 f0-13)
    )
  (initialize-skeleton self *mistycannon-missile-sg* '())
  (set! (-> self root-override transv quad) (-> arg0 vel quad))
  (set! (-> self blast-radius) (-> arg0 blast-radius))
  (set! (-> self water-height) (res-lump-float (-> self entity) 'water-height :default -4096000.0))
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 117) self))
  (set! (-> self part2) (create-launch-control (-> *part-group-id-table* 118) self))
  (go mistycannon-missile-idle)
  (none)
  )

;; definition for function spawn-mistycannon-missile
;; INFO: Return type mismatch int vs none.
(defun spawn-mistycannon-missile ((arg0 process-tree)
                         (arg1 vector)
                         (arg2 vector)
                         (arg3 float)
                         (arg4 float)
                         (arg5 float)
                         (arg6 float)
                         (arg7 entity)
                         )
  (let ((s5-0 (new 'stack-no-clear 'mistycannon-init-data)))
    (set! (-> s5-0 pos) arg1)
    (set! (-> s5-0 vel) arg2)
    (set! (-> s5-0 rotate) arg3)
    (set! (-> s5-0 flight-time) arg4)
    (set! (-> s5-0 muzzle-time) arg5)
    (set! (-> s5-0 blast-radius) arg6)
    (process-spawn mistycannon-missile s5-0 arg7 :to arg0)
    )
  0
  (none)
  )

;; definition of type mistycannon
(deftype mistycannon (process-drawable)
  ((root-override          collide-shape-moving         :offset        112)
   (rotate                 angle-tracker        :inline :offset-assert 176)
   (fact-info-override     fact-info-enemy              :offset        144)
   (tilt                   angle-tracker        :inline :offset-assert 192)
   (front-wheel            float                        :offset-assert 208)
   (rear-wheel             float                        :offset-assert 212)
   (last-known-rotation    float                        :offset-assert 216)
   (part-timer             time-frame                   :offset-assert 224)
   (hellmouth              vector               :inline :offset-assert 240)
   (postbindinfo-ok        symbol                       :offset-assert 256)
   (launch-origin          vector               :inline :offset-assert 272)
   (goggles                vector               :inline :offset-assert 288)
   (avoid-entity           entity-actor                 :offset-assert 304)
   (center-point           vector               :inline :offset-assert 320)
   (at-point               vector               :inline :offset-assert 336)
   (accuracy-range         float                        :offset-assert 352)
   (target-theta           float                        :offset-assert 356)
   (sound-id               sound-id                     :offset-assert 360)
   (aim-sound-id           sound-id                     :offset-assert 364)
   (player-touching-grips? symbol                       :offset-assert 368)
   )
  :heap-base #x110
  :method-count-assert 24
  :size-assert         #x174
  :flag-assert         #x1801100174
  (:methods
    (rotate! (_type_ float) none 20)
    (tilt! (_type_ float) none 21)
    (dummy-22 (_type_ float float float) none 22)
    (dummy-23 (_type_) none 23)
    )
  (:states
    mistycannon-aim-at-player
    mistycannon-idle
    mistycannon-player-control
    mistycannon-waiting-for-player
    mistycannon-waiting-for-player-to-fuck-off
    )
  )

;; definition for method 3 of type mistycannon
(defmethod inspect mistycannon ((obj mistycannon))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Trotate: #<angle-tracker @ #x~X>~%" (-> obj rotate))
  (format #t "~T~Ttilt: #<angle-tracker @ #x~X>~%" (-> obj tilt))
  (format #t "~T~Tfront-wheel: ~f~%" (-> obj front-wheel))
  (format #t "~T~Trear-wheel: ~f~%" (-> obj rear-wheel))
  (format #t "~T~Tlast-known-rotation: ~f~%" (-> obj last-known-rotation))
  (format #t "~T~Tpart-timer: ~D~%" (-> obj part-timer))
  (format #t "~T~Thellmouth: #<vector @ #x~X>~%" (-> obj hellmouth))
  (format #t "~T~Tpostbindinfo-ok: ~A~%" (-> obj postbindinfo-ok))
  (format #t "~T~Tlaunch-origin: #<vector @ #x~X>~%" (-> obj launch-origin))
  (format #t "~T~Tgoggles: #<vector @ #x~X>~%" (-> obj goggles))
  (format #t "~T~Tavoid-entity: ~A~%" (-> obj avoid-entity))
  (format #t "~T~Tcenter-point: #<vector @ #x~X>~%" (-> obj center-point))
  (format #t "~T~Tat-point: #<vector @ #x~X>~%" (-> obj at-point))
  (format #t "~T~Taccuracy-range: ~f~%" (-> obj accuracy-range))
  (format #t "~T~Ttarget-theta: ~f~%" (-> obj target-theta))
  (format #t "~T~Tsound-id: ~D~%" (-> obj sound-id))
  (format #t "~T~Taim-sound-id: ~D~%" (-> obj aim-sound-id))
  (format #t "~T~Tplayer-touching-grips?: ~A~%" (-> obj player-touching-grips?))
  obj
  )

;; definition for function mistycannon-pick-random-target-point
;; INFO: Return type mismatch float vs none.
(defbehavior mistycannon-pick-random-target-point mistycannon ()
  (let ((f30-0 (* (sqrtf (rand-vu)) (-> self center-point w)))
        (f28-1 (* 65536.0 (rand-vu)))
        )
    (set! (-> self at-point x) (+ (-> self center-point x) (* f30-0 (cos f28-1))))
    (set! (-> self at-point y) (-> self center-point y))
    (set! (-> self at-point z) (+ (-> self center-point z) (* f30-0 (sin f28-1))))
    )
  (set! (-> self at-point w) 1.0)
  (set! (-> self target-theta) (rand-vu-float-range 2730.6667 12743.111))
  (none)
  )

;; definition for method 20 of type mistycannon
;; INFO: Return type mismatch int vs none.
(defmethod rotate! mistycannon ((obj mistycannon) (arg0 float))
  (angle-tracker-apply-move! (-> obj rotate) arg0)
  0
  (none)
  )

;; definition for method 21 of type mistycannon
;; INFO: Return type mismatch int vs none.
(defmethod tilt! mistycannon ((obj mistycannon) (arg0 float))
  (angle-tracker-apply-move! (-> obj tilt) arg0)
  0
  (none)
  )

;; definition for method 22 of type mistycannon
;; INFO: Return type mismatch int vs none.
;; WARN: Expression building failed: Function (method 22 mistycannon) has a return type of none, but the expression builder found a return statement.
(defmethod dummy-22 mistycannon ((obj mistycannon) (arg0 float) (arg1 float) (arg2 float))
  (if (not (-> obj postbindinfo-ok))
      (return #f)
      )
  (let* ((s3-0 (-> obj launch-origin))
         (s2-0 (new 'stack-no-clear 'vector))
         (v1-3 (-> obj rotate))
         (f30-0 (the float (sar (shl (the int (+ (-> v1-3 min) (-> v1-3 value))) 48) 48)))
         (v1-8 (-> obj tilt))
         (f26-0 (the float (sar (shl (the int (+ (-> v1-8 min) (-> v1-8 value))) 48) 48)))
         (f28-0 (/ 24576.0 arg0))
         )
    (let ((f24-0 (cos f26-0)))
      (set! (-> s2-0 x) (* arg0 f24-0 (sin f30-0)))
      (set! (-> s2-0 z) (* arg0 f24-0 (cos f30-0)))
      )
    (set! (-> s2-0 y) (* arg0 (sin f26-0)))
    (vector-float*! (-> obj hellmouth) s2-0 f28-0)
    (vector+! (-> obj hellmouth) (-> obj hellmouth) s3-0)
    (spawn-mistycannon-missile obj s3-0 s2-0 f30-0 arg1 f28-0 arg2 (-> obj entity))
    )
  (sound-play "cannon-shot")
  (set! (-> obj part local-clock) 0)
  (set! (-> obj part-timer) (-> *display* base-frame-counter))
  (mistycannon-pick-random-target-point)
  0
  (none)
  )

;; definition for method 23 of type mistycannon
;; INFO: Return type mismatch int vs none.
(defmethod dummy-23 mistycannon ((obj mistycannon))
  (when (< (- (-> *display* base-frame-counter) (-> obj part-timer)) (seconds 3))
    (let ((v1-4 (-> obj rotate)))
      (set! (-> *part-id-table* 529 init-specs 24 initial-valuef)
            (the float (sar (shl (the int (+ (-> v1-4 min) (-> v1-4 value))) 48) 48))
            )
      )
    (let ((v1-12 (-> obj rotate)))
      (set! (-> *part-id-table* 530 init-specs 23 initial-valuef)
            (the float (sar (shl (the int (+ (-> v1-12 min) (-> v1-12 value))) 48) 48))
            )
      )
    (let ((v1-20 (-> obj rotate)))
      (set! (-> *part-id-table* 534 init-specs 21 initial-valuef)
            (the float (sar (shl (the int (+ (-> v1-20 min) (-> v1-20 value))) 48) 48))
            )
      )
    (let ((f0-18 16384.0)
          (v1-28 (-> obj tilt))
          )
      (set! (-> *part-id-table* 529 init-specs 22 initial-valuef)
            (- f0-18 (the float (sar (shl (the int (+ (-> v1-28 min) (-> v1-28 value))) 48) 48)))
            )
      )
    (let ((f0-20 16384.0)
          (v1-36 (-> obj tilt))
          )
      (set! (-> *part-id-table* 530 init-specs 21 initial-valuef)
            (- f0-20 (the float (sar (shl (the int (+ (-> v1-36 min) (-> v1-36 value))) 48) 48)))
            )
      )
    (let ((f0-22 16384.0)
          (v1-44 (-> obj tilt))
          )
      (set! (-> *part-id-table* 534 init-specs 20 initial-valuef)
            (- f0-22 (the float (sar (shl (the int (+ (-> v1-44 min) (-> v1-44 value))) 48) 48)))
            )
      )
    (spawn (-> obj part) (-> obj hellmouth))
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defskelgroup *mistycannon-sg* mistycannon mistycannon-lod0-jg mistycannon-idle-ja
              ((mistycannon-lod0-mg (meters 20)) (mistycannon-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 5 0 9)
              :longest-edge (meters 4)
              )

;; definition for function mistycannon-prebind-function
;; INFO: Return type mismatch int vs none.
(defun mistycannon-prebind-function ((arg0 pointer) (arg1 int) (arg2 mistycannon))
  (let ((t9-0 quaternion-axis-angle!)
        (a0-1 (&+ arg0 144))
        (a1-1 0.0)
        (a2-1 1.0)
        (a3-0 0.0)
        (v1-0 (-> arg2 rotate))
        )
    (t9-0
      (the-as quaternion a0-1)
      a1-1
      a2-1
      a3-0
      (the float (sar (shl (the int (+ (-> v1-0 min) (-> v1-0 value))) 48) 48))
      )
    )
  (let ((t9-1 quaternion-axis-angle!)
        (a0-2 (&+ arg0 192))
        (a1-2 -1.0)
        (a2-2 0.0)
        (a3-1 0.0)
        (v1-4 (-> arg2 tilt))
        )
    (t9-1
      (the-as quaternion a0-2)
      a1-2
      a2-2
      a3-1
      (the float (sar (shl (the int (+ (-> v1-4 min) (-> v1-4 value))) 48) 48))
      )
    )
  (let* ((v1-8 (-> arg2 rotate))
         (f0-16
           (- (the float (sar (shl (the int (+ (-> v1-8 min) (-> v1-8 value))) 48) 48)) (-> arg2 last-known-rotation))
           )
         )
    (set! (-> arg2 front-wheel) (the float (sar (shl (the int (+ (-> arg2 front-wheel) (* 5.0 f0-16))) 48) 48)))
    (set! (-> arg2 rear-wheel) (the float (sar (shl (the int (+ (-> arg2 rear-wheel) (* 3.0 f0-16))) 48) 48)))
    )
  (let ((v1-19 (-> arg2 rotate)))
    (set! (-> arg2 last-known-rotation)
          (the float (sar (shl (the int (+ (-> v1-19 min) (-> v1-19 value))) 48) 48))
          )
    )
  (quaternion-axis-angle! (the-as quaternion (&+ arg0 432)) -1.0 0.0 0.0 (-> arg2 front-wheel))
  (quaternion-axis-angle! (the-as quaternion (&+ arg0 384)) 1.0 0.0 0.0 (-> arg2 front-wheel))
  (quaternion-axis-angle! (the-as quaternion (&+ arg0 288)) -1.0 0.0 0.0 (-> arg2 rear-wheel))
  (quaternion-axis-angle! (the-as quaternion (&+ arg0 336)) 1.0 0.0 0.0 (-> arg2 rear-wheel))
  0
  (none)
  )

;; definition for function mistycannon-postbind-function
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun mistycannon-postbind-function ((arg0 mistycannon))
  (set! (-> arg0 launch-origin quad) (-> arg0 node-list data 4 bone transform vector 3 quad))
  (let ((s5-0 (new 'stack-no-clear 'vector)))
    (set-vector! s5-0 0.0 53248.0 -4096.0 1.0)
    (vector-matrix*! s5-0 s5-0 (-> arg0 node-list data 3 bone transform))
    (set! (-> arg0 goggles quad) (-> s5-0 quad))
    )
  (set! (-> arg0 postbindinfo-ok) #t)
  0
  (none)
  )

;; failed to figure out what this is:
(defstate mistycannon-idle (mistycannon)
  :trans (behavior ()
    (if (not (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))))
        (go mistycannon-waiting-for-player)
        )
    (if (and (-> self postbindinfo-ok)
             *target*
             (>= (-> self fact-info-override idle-distance)
                 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))
                 )
             )
        (go mistycannon-aim-at-player)
        )
    (rider-trans)
    (none)
    )
  :code (behavior ()
    (loop
      (dummy-23 self)
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior mistycannon) rider-post)
  )

;; definition of type quadratic-solution
(deftype quadratic-solution (structure)
  ((s1 float  :offset-assert   0)
   (s2 float  :offset-assert   4)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for method 3 of type quadratic-solution
(defmethod inspect quadratic-solution ((obj quadratic-solution))
  (format #t "[~8x] ~A~%" obj 'quadratic-solution)
  (format #t "~Ts1: ~f~%" (-> obj s1))
  (format #t "~Ts2: ~f~%" (-> obj s2))
  obj
  )

;; definition for function solve-missile-tilt
(defun solve-missile-tilt ((arg0 quadratic-solution) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
  (let* ((f1-3 (* 0.5 arg2 arg2 arg4))
         (f0-3 f1-3)
         (f30-0 (- (* arg2 arg1 arg1)))
         (f2-6 (+ f1-3 (* arg1 arg1 arg3)))
         (f1-5 (- (* f30-0 f30-0) (* 4.0 f2-6 f0-3)))
         (f28-0 (/ 0.5 f0-3))
         )
    (if (< f1-5 0.0)
        (return #f)
        )
    (let ((f26-0 (sqrtf f1-5)))
      (set! (-> arg0 s1) (atan (* (+ (- f30-0) f26-0) f28-0) 1.0))
      (set! (-> arg0 s2) (atan (* (- (- f30-0) f26-0) f28-0) 1.0))
      )
    )
  #t
  )

;; definition of type trajectory-params
(deftype trajectory-params (structure)
  ((x       float  :offset-assert   0)
   (y       float  :offset-assert   4)
   (gravity float  :offset-assert   8)
   (theta   float  :offset-assert  12)
   (speed   float  :offset-assert  16)
   (time    float  :offset-assert  20)
   )
  :method-count-assert 9
  :size-assert         #x18
  :flag-assert         #x900000018
  )

;; definition for method 3 of type trajectory-params
(defmethod inspect trajectory-params ((obj trajectory-params))
  (format #t "[~8x] ~A~%" obj 'trajectory-params)
  (format #t "~Tx: ~f~%" (-> obj x))
  (format #t "~Ty: ~f~%" (-> obj y))
  (format #t "~Tgravity: ~f~%" (-> obj gravity))
  (format #t "~Ttheta: ~f~%" (-> obj theta))
  (format #t "~Tspeed: ~f~%" (-> obj speed))
  (format #t "~Ttime: ~f~%" (-> obj time))
  obj
  )

;; definition for function solve-missile-velocity
;; INFO: Return type mismatch int vs none.
(defun solve-missile-velocity ((arg0 trajectory-params) (arg1 float))
  (set! (-> arg0 theta) arg1)
  (let ((f0-4 (* (- (* (-> arg0 x) (tan arg1)) (-> arg0 y)) (/ 2.0 (-> arg0 gravity)))))
    (when (< 0.0 f0-4)
      (set! (-> arg0 time) (sqrtf f0-4))
      (set! (-> arg0 speed) (/ (-> arg0 x) (* (-> arg0 time) (cos arg1))))
      )
    )
  0
  (none)
  )

;; definition for function mistycannon-find-best-solution
(defbehavior mistycannon-find-best-solution mistycannon ((arg0 quadratic-solution))
  (let ((v1-0 #t)
        (a1-0 #t)
        (v0-0 -1)
        )
    (let ((f1-0 (-> self tilt min))
          (f0-1 (+ (-> self tilt range) (-> self tilt min)))
          )
      (if (< (-> arg0 s1) f1-0)
          (set! v1-0 #f)
          )
      (if (< f0-1 (-> arg0 s1))
          (set! v1-0 #f)
          )
      (if (< (-> arg0 s2) f1-0)
          (set! a1-0 #f)
          )
      (if (< f0-1 (-> arg0 s2))
          (set! a1-0 #f)
          )
      )
    (if v1-0
        (set! v0-0 0)
        )
    (if a1-0
        (set! v0-0 1)
        )
    (set! a1-0 (and v1-0 a1-0))
    (when a1-0
      (if (< (-> arg0 s1) (-> arg0 s2))
          (set! v0-0 0)
          (set! v0-0 1)
          )
      )
    v0-0
    )
  )

;; definition for function mistycannon-find-trajectory
(defbehavior mistycannon-find-trajectory mistycannon ((arg0 trajectory-params))
  (set! (-> arg0 time) 0.0)
  (solve-missile-velocity arg0 (-> arg0 theta))
  (none)
  )

;; definition for function mistycannon-do-aim
;; INFO: Return type mismatch int vs none.
;; WARN: Expression building failed: Function mistycannon-do-aim has a return type of none, but the expression builder found a return statement.
(defbehavior mistycannon-do-aim mistycannon ((arg0 vector) (arg1 vector))
  (if (not (-> self postbindinfo-ok))
      (return #f)
      )
  (when (-> self avoid-entity)
    (let ((a1-1 (-> self avoid-entity extra trans)))
      (if (< (vector-vector-distance arg0 a1-1) 122880.0)
          (return #f)
          )
      )
    )
  (let ((gp-0 (new 'stack-no-clear 'trajectory-params)))
    (let ((s4-0 (new 'stack-no-clear 'vector)))
      (vector-! s4-0 arg0 (-> self launch-origin))
      (set! (-> gp-0 x) (vector-xz-length s4-0))
      (set! (-> gp-0 y) (-> s4-0 y))
      )
    (set! (-> gp-0 gravity) (-> *standard-dynamics* gravity-length))
    (set! (-> gp-0 speed) 409600.0)
    (set! (-> gp-0 theta) (-> self target-theta))
    (mistycannon-find-trajectory gp-0)
    (let ((v1-12 (new 'stack-no-clear 'vector))
          (s4-1 (new 'stack-no-clear 'vector))
          )
      (vector-float*! v1-12 arg1 (* 0.4 (+ 2.0 (-> gp-0 time))))
      (vector+! s4-1 arg0 v1-12)
      (let ((f30-0 (* (sqrtf (rand-vu)) (-> self accuracy-range)))
            (f28-1 (* 65536.0 (rand-vu)))
            )
        (+! (-> s4-1 x) (* f30-0 (cos f28-1)))
        (+! (-> s4-1 z) (* f30-0 (sin f28-1)))
        )
      (let ((s5-1 (new 'stack-no-clear 'vector)))
        (vector-! s5-1 s4-1 (-> self launch-origin))
        (let ((f0-19 (atan (-> s5-1 x) (-> s5-1 z))))
          (angle-tracker-seek! (-> self rotate) f0-19)
          )
        (set! (-> gp-0 x) (vector-xz-length s5-1))
        (set! (-> gp-0 y) (-> s5-1 y))
        )
      )
    (mistycannon-find-trajectory gp-0)
    (when (= (-> gp-0 time) 0.0)
      (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
        (dummy-22 self 409600.0 2.0 20480.0)
        (set! (-> self state-time) (-> *display* base-frame-counter))
        )
      (return #f)
      )
    (when (angle-tracker-seek! (-> self tilt) (-> gp-0 theta))
      (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
        (dummy-22 self (fmax 163840.0 (fmin 409600.0 (-> gp-0 speed))) (-> gp-0 time) 20480.0)
        (set! (-> self state-time) (-> *display* base-frame-counter))
        )
      )
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defstate mistycannon-aim-at-player (mistycannon)
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (if (not (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))))
        (go mistycannon-waiting-for-player)
        )
    (if (not (and *target* (>= (-> self fact-info-override idle-distance)
                               (vector-vector-distance (-> self root-override trans) (-> *target* control trans))
                               )
                  )
             )
        (go mistycannon-idle)
        )
    (rider-trans)
    (none)
    )
  :code (behavior ()
    (loop
      (if (< (vector-vector-xz-distance (target-pos 0) (-> self center-point)) (-> self center-point w))
          (mistycannon-do-aim (-> *target* control trans) (-> *target* control transv))
          (mistycannon-do-aim (-> self at-point) (new-stack-vector0))
          )
      (dummy-23 self)
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior mistycannon) rider-post)
  )

;; failed to figure out what this is:
(defstate mistycannon-waiting-for-player (mistycannon)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touch)
       (when ((method-of-type touching-shapes-entry prims-touching?)
              (the-as touching-shapes-entry (-> arg3 param 0))
              (-> self root-override)
              (the-as uint 1)
              )
         (let ((v0-1 (the-as object #t)))
           (set! (-> self player-touching-grips?) (the-as symbol v0-1))
           v0-1
           )
         )
       )
      (('change-mode)
       (go mistycannon-player-control)
       )
      )
    )
  :trans (behavior ()
    (if (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete)))
        (go mistycannon-aim-at-player)
        )
    (rider-trans)
    (none)
    )
  :code (behavior ()
    (set! (-> self player-touching-grips?) #f)
    (loop
      (let ((f0-0 2730.6667)
            (v1-0 (-> self tilt))
            )
        (if (< f0-0 (the float (sar (shl (the int (+ (-> v1-0 min) (-> v1-0 value))) 48) 48)))
            (angle-tracker-seek! (-> self tilt) 2730.6667)
            )
        )
      (dummy-23 self)
      (when (and (-> self player-touching-grips?) (not (level-hint-displayed?)))
        (set! (-> self player-touching-grips?) #f)
        (hide-hud)
        (level-hint-surpress!)
        (kill-current-level-hint '() '(sidekick voicebox) 'exit)
        (when (and (hud-hidden?) (can-grab-display? self))
          (let ((gp-0
                  (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning))
                  )
                )
            (let ((v1-15 gp-0))
              (set! (-> v1-15 width) (the float 440))
              )
            (let ((v1-16 gp-0))
              (set! (-> v1-16 height) (the float 80))
              )
            (set! (-> gp-0 flags) (font-flags shadow kerning large))
            (print-game-text (lookup-text! *common-text* (game-text-id press-to-use) #f) gp-0 #f 128 22)
            )
          (when (cpad-pressed? 0 circle)
            (loop
              (send-event *target* 'change-mode 'periscope self)
              (suspend)
              (suspend)
              )
            )
          )
        )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior mistycannon) rider-post)
  )

;; failed to figure out what this is:
(defstate cam-mistycannon (camera-slave)
  :event cam-standard-event-handler
  :enter (behavior ()
    (when (not (-> self enter-has-run))
      (set! (-> self blend-from-type) (the-as uint 1))
      (set! (-> self blend-to-type) (the-as uint 1))
      )
    (none)
    )
  :trans (behavior ()
    (if (zero? (logand (-> *camera* master-options) 2))
        (cam-slave-go cam-free-floating)
        )
    (none)
    )
  :code (behavior ()
    (loop
      (let ((v1-0 (-> self change-event-from)))
        (set! (-> self trans quad) (-> (the-as mistycannon (-> v1-0 0)) goggles quad))
        (let ((t9-0 matrix-rotate-yx!)
              (a0-1 (-> self tracking))
              (v1-2 (-> (the-as mistycannon (-> v1-0 0)) rotate))
              )
          (t9-0 (the-as matrix a0-1) (the float (sar (shl (the int (+ (-> v1-2 min) (-> v1-2 value))) 48) 48)) 3640.889)
          )
        )
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate mistycannon-player-control (mistycannon)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('change-mode)
       (send-event *camera* 'change-state cam-mistycannon 0)
       )
      )
    )
  :exit (behavior ()
    (sound-stop (-> self sound-id))
    (sound-stop (-> self aim-sound-id))
    (none)
    )
  :trans (behavior ()
    (dummy-23 self)
    (rider-trans)
    (none)
    )
  :code (behavior ()
    (send-event *camera* 'change-state cam-mistycannon 0)
    (suspend)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (let ((gp-0 0)
          (s5-0 0)
          )
      (loop
        (when *camera-read-analog*
          (let ((f30-0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0))
                (f28-0 (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0))
                )
            (rotate! self f30-0)
            (tilt! self (- f28-0))
            (if (or (!= f30-0 0.0) (!= f28-0 0.0))
                (sound-play "telescope" :id (-> self aim-sound-id))
                (sound-stop (-> self aim-sound-id))
                )
            )
          )
        (when (cpad-pressed? 0 triangle)
          (process-entity-status! self (entity-perm-status bit-3) #t)
          (sound-stop (-> self sound-id))
          (send-event *camera* 'change-to-entity-by-name "camera-111")
          (suspend)
          (loop
            (when (send-event *target* 'end-mode)
              (send-event *camera* 'change-state *camera-base-mode* 0)
              (process-entity-status! self (entity-perm-status bit-3) #f)
              (go mistycannon-waiting-for-player-to-fuck-off)
              )
            (suspend)
            )
          )
        (let ((v1-45 (and (cpad-hold? 0 x) (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1)))))
          (when (zero? s5-0)
            (when v1-45
              (set! gp-0
                    (seekl gp-0 300 (the-as int (- (-> *display* base-frame-counter) (-> *display* old-base-frame-counter))))
                    )
              (sound-play "cannon-charge" :id (-> self sound-id) :pitch (* 0.008 (the float gp-0)))
              )
            (when (or (= gp-0 300)
                      (and (zero? (logand (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons x))) (nonzero? gp-0))
                      )
              (let ((gp-1 (+ 50 (the int (* 0.16666667 (the float gp-0))))))
                (level-hint-spawn
                  (game-text-id sidekick-mistycannon)
                  "sksp009f"
                  (the-as entity #f)
                  *entity-pool*
                  (game-task none)
                  )
                (dummy-22 self (* 4096.0 (the float gp-1)) 2.0 40960.0)
                )
              (set! (-> self state-time) (-> *display* base-frame-counter))
              (set! gp-0 0)
              (set! s5-0 1)
              (sound-stop (-> self sound-id))
              )
            (if (nonzero? gp-0)
                (debug-percent-bar
                  #t
                  (bucket-id debug)
                  192
                  160
                  (* 0.0033333334 (the float gp-0))
                  (new 'static 'rgba :r #xff :a #x80)
                  )
                )
            )
          )
        (if (zero? (logand (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons x)))
            (set! s5-0 0)
            )
        (suspend)
        )
      )
    (none)
    )
  :post (the-as (function none :behavior mistycannon) rider-post)
  )

;; failed to figure out what this is:
(defstate mistycannon-waiting-for-player-to-fuck-off (mistycannon)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (when (= v1-0 'touch)
                       (when ((method-of-type touching-shapes-entry prims-touching?)
                              (the-as touching-shapes-entry (-> arg3 param 0))
                              (-> self root-override)
                              (the-as uint 1)
                              )
                         (let ((v0-0 (-> *display* base-frame-counter)))
                           (set! (-> self state-time) v0-0)
                           v0-0
                           )
                         )
                       )
              )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (the-as (function none :behavior mistycannon) rider-trans)
  :code (behavior ()
    (loop
      (suspend)
      (dummy-23 self)
      (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1))
          (go mistycannon-waiting-for-player)
          )
      )
    (none)
    )
  :post (the-as (function none :behavior mistycannon) rider-post)
  )

;; definition for method 11 of type mistycannon
;; INFO: Return type mismatch object vs none.
;; Used lq/sq
(defmethod init-from-entity! mistycannon ((obj mistycannon) (arg0 entity-actor))
  (local-vars (sv-16 res-tag) (sv-32 res-tag) (sv-48 res-tag))
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-others))))
    (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s4-0 reaction) default-collision-reaction)
    (set! (-> s4-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (alloc-riders s4-0 1)
    (let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 2) 0)))
      (set! (-> s3-0 prim-core collide-as) (collide-kind ground-object))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid ca-1))
      (set! (-> s3-0 transform-index) 3)
      (set-vector! (-> s3-0 local-sphere) 0.0 20480.0 0.0 40960.0)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind ground-object))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core action) (collide-action solid ca-1))
        (set! (-> s2-0 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-0 transform-index) 3)
        (set-vector! (-> s2-0 local-sphere) 0.0 20480.0 0.0 40960.0)
        (append-prim s3-0 s2-0)
        )
      (let ((s2-1 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-1 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-1 collide-with) (collide-kind target))
        (set! (-> s2-1 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-1 transform-index) 3)
        (set-vector! (-> s2-1 local-sphere) 0.0 28672.0 -8192.0 4096.0)
        (append-prim s3-0 s2-1)
        )
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (quaternion-identity! (-> obj root-override quat))
  (initialize-skeleton obj *mistycannon-sg* '())
  (logior! (-> obj skel status) (janim-status inited))
  (update-transforms! (-> obj root-override))
  (set! (-> obj skel prebind-function) mistycannon-prebind-function)
  (set! (-> obj skel postbind-function) mistycannon-postbind-function)
  (set! (-> obj fact-info-override)
        (new 'process 'fact-info-enemy obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
        )
  (logclear! (-> obj mask) (process-mask actor-pause))
  (let ((f30-0 (res-lump-float arg0 'rotmin :default 16384.0))
        (f28-0 (res-lump-float arg0 'rotmax :default 32768.0))
        (f0-15 (res-lump-float arg0 'rotspeed :default 3640.889))
        )
    (angle-tracker-init-range! (-> obj rotate) f30-0 f28-0 f0-15)
    )
  (let ((f30-1 (res-lump-float arg0 'tiltmin :default -1820.4445))
        (f28-1 (res-lump-float arg0 'tiltmax :default 12743.111))
        (f0-16 (res-lump-float arg0 'tiltspeed :default 3640.889))
        )
    (angle-tracker-init-range! (-> obj tilt) f30-1 f28-1 f0-16)
    )
  (set! (-> obj avoid-entity) (entity-actor-lookup (-> obj entity) 'alt-actor 0))
  (set! (-> obj center-point w) (res-lump-float arg0 'center-radius))
  (cond
    ((= (-> obj center-point w) 0.0)
     (set! (-> obj center-point quad) (-> obj root-override trans quad))
     (set! (-> obj center-point w) (-> obj fact-info-override idle-distance))
     )
    (else
      (set! sv-16 (new 'static 'res-tag))
      (let ((v1-64 (res-lump-data arg0 'center-point pointer :tag-ptr (& sv-16))))
        (set! (-> obj center-point x) (if (and v1-64 (< 0.0 (the float (-> sv-16 elt-count))))
                                          (-> (the-as (pointer float) v1-64))
                                          0.0
                                          )
              )
        )
      (set! sv-32 (new 'static 'res-tag))
      (let ((v1-67 (res-lump-data arg0 'center-point (pointer float) :tag-ptr (& sv-32))))
        (set! (-> obj center-point y) (if (and v1-67 (< 1.0 (the float (-> sv-32 elt-count))))
                                          (-> v1-67 1)
                                          0.0
                                          )
              )
        )
      (set! sv-48 (new 'static 'res-tag))
      (let ((v1-70 (res-lump-data arg0 'center-point (pointer float) :tag-ptr (& sv-48))))
        (set! (-> obj center-point z) (if (and v1-70 (< 2.0 (the float (-> sv-48 elt-count))))
                                          (-> v1-70 2)
                                          0.0
                                          )
              )
        )
      )
    )
  (set! (-> obj accuracy-range) 16384.0)
  (mistycannon-pick-random-target-point)
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 119) obj))
  (set! (-> obj part-timer) (+ (-> *display* base-frame-counter) (seconds -10)))
  (set! (-> obj postbindinfo-ok) #f)
  (let ((v1-79 (-> obj rotate)))
    (set! (-> obj last-known-rotation)
          (the float (sar (shl (the int (+ (-> v1-79 min) (-> v1-79 value))) 48) 48))
          )
    )
  (set! (-> obj sound-id) (new-sound-id))
  (set! (-> obj aim-sound-id) (new-sound-id))
  (if (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete)))
      (go mistycannon-idle)
      (go mistycannon-waiting-for-player)
      )
  (none)
  )
