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

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

;; failed to figure out what this is:
(defpartgroup group-kermit-charging-up
  :id 298
  :bounds (static-bspherem 0 5 0 5)
  :parts ((sp-item 1359 :fade-after (meters 140) :falloff-to (meters 140) :binding 1356)
    (sp-item 1359 :fade-after (meters 140) :falloff-to (meters 140) :binding 1357)
    (sp-item 1359 :fade-after (meters 140) :falloff-to (meters 140) :binding 1358)
    (sp-item 1360)
    (sp-item 1361 :fade-after (meters 120) :falloff-to (meters 120))
    (sp-item 1362 :fade-after (meters 120) :falloff-to (meters 120))
    (sp-item 1363 :fade-after (meters 120) :falloff-to (meters 120))
    (sp-item 1358 :fade-after (meters 30) :falloff-to (meters 30) :flags (start-dead))
    (sp-item 1357 :fade-after (meters 60) :falloff-to (meters 60) :flags (start-dead))
    (sp-item 1356 :fade-after (meters 80) :falloff-to (meters 80) :flags (start-dead))
    (sp-item 1358 :fade-after (meters 90) :falloff-to (meters 90) :flags (start-dead))
    (sp-item 1357 :fade-after (meters 100) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 1356 :fade-after (meters 110) :falloff-to (meters 110) :flags (start-dead))
    (sp-item 1358 :fade-after (meters 120) :falloff-to (meters 120) :flags (start-dead))
    (sp-item 1357 :fade-after (meters 120) :falloff-to (meters 120) :flags (start-dead))
    )
  )

;; failed to figure out what this is:
(defpart 1360
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x4 :page #x2))
    (sp-rnd-flt spt-num 0.1 1.0 1.0)
    (sp-rnd-flt spt-x (meters -0.75) (meters 1.5) 1.0)
    (sp-flt spt-y (meters 0.5))
    (sp-rnd-flt spt-z (meters -0.75) (meters 1.5) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.4) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 32.0)
    (sp-flt spt-g 32.0)
    (sp-flt spt-b 192.0)
    (sp-flt spt-a 64.0)
    (sp-rnd-flt spt-vel-y (meters 0.016666668) (meters 0.016666668) 1.0)
    (sp-flt spt-fade-a -0.2)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 1359
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-rnd-flt spt-num 0.05 0.1 1.0)
    (sp-rnd-flt spt-x (meters -0.75) (meters 1.5) 1.0)
    (sp-flt spt-y (meters 0.5))
    (sp-rnd-flt spt-z (meters -0.75) (meters 1.5) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 0.4) 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 192.0)
    (sp-flt spt-a 96.0)
    (sp-rnd-flt spt-vel-y (meters 0.01) (meters 0.01) 1.0)
    (sp-flt spt-fade-a 0.0)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 1356
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1f :page #x2))
    (sp-flt spt-num 1.0)
    (sp-sound (static-sound-spec "eco-blue-spark1" :num 0.05 :volume 70.0))
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 1.5) 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 0.2) (meters 0.1) 1.0)
    (sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 90)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 10)
    (sp-launcher-by-id spt-next-launcher 1364)
    )
  )

;; failed to figure out what this is:
(defpart 1357
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x23 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-sound (static-sound-spec "eco-blue-spark2" :num 0.075 :volume 100.0))
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 1.5) 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 0.2) (meters 0.1) 1.0)
    (sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 90)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 10)
    (sp-launcher-by-id spt-next-launcher 1364)
    )
  )

;; failed to figure out what this is:
(defpart 1358
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x24 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-sound (static-sound-spec "eco-blue-spark3" :num 0.05 :volume 70.0))
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 1.5) 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 0.2) (meters 0.1) 1.0)
    (sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-flt spt-b 128.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 90)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 10)
    (sp-launcher-by-id spt-next-launcher 1364)
    )
  )

;; failed to figure out what this is:
(defpart 1361
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1f :page #x2))
    (sp-rnd-flt spt-num 0.1 0.5 1.0)
    (sp-rnd-flt spt-x (meters -0.5) (meters 1) 1.0)
    (sp-flt spt-y (meters 0.5))
    (sp-rnd-flt spt-z (meters -0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.5) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 10.0) (degrees 160.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 0.2) (meters 0.1) 1.0)
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 91)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 10)
    (sp-launcher-by-id spt-next-launcher 1364)
    )
  )

;; failed to figure out what this is:
(defpart 1362
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x23 :page #x2))
    (sp-rnd-flt spt-num 0.2 0.4 1.0)
    (sp-rnd-flt spt-x (meters -0.5) (meters 1) 1.0)
    (sp-flt spt-y (meters 0.5))
    (sp-rnd-flt spt-z (meters -0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.5) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 10.0) (degrees 160.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 0.2) (meters 0.1) 1.0)
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 91)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 10)
    (sp-launcher-by-id spt-next-launcher 1364)
    )
  )

;; failed to figure out what this is:
(defpart 1363
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x24 :page #x2))
    (sp-rnd-flt spt-num 0.3 0.1 1.0)
    (sp-rnd-flt spt-x (meters -0.5) (meters 1) 1.0)
    (sp-flt spt-y (meters 0.5))
    (sp-rnd-flt spt-z (meters -0.5) (meters 1) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.5) (meters 1.5) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 10.0) (degrees 160.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 0.2) (meters 0.1) 1.0)
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-fade-a -1.6)
    (sp-int spt-timer 91)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 10)
    (sp-launcher-by-id spt-next-launcher 1364)
    )
  )

;; failed to figure out what this is:
(defpart 1364
  :init-specs ((sp-flt spt-r 64.0)
    (sp-flt spt-g 64.0)
    (sp-flt spt-fade-r -1.0)
    (sp-flt spt-fade-g -1.0)
    (sp-flt spt-fade-a -2.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-kermit-charged-up
  :id 299
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 1365 :period 15 :length 5))
  )

;; failed to figure out what this is:
(defpart 1365
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-rnd-flt spt-num 1.0 1.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.3) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 70.0 16.0 1.0)
    (sp-rnd-flt spt-g 70.0 16.0 1.0)
    (sp-flt spt-b 70.0)
    (sp-flt spt-a 128.0)
    (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.04) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0)
    (sp-flt spt-accel-y -10.922667)
    (sp-flt spt-friction 0.99)
    (sp-int spt-timer 75)
    (sp-cpuinfo-flags bit2)
    (sp-flt spt-userdata 0.0)
    (sp-rnd-flt spt-conerot-x (degrees 20.0) (degrees 50.000004) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-kermit-pulse
  :id 300
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 1368 :flags (launch-asap) :binding 1366)
    (sp-item 1366 :flags (start-dead launch-asap) :binding 1367)
    (sp-item 1367 :flags (start-dead))
    (sp-item 1367 :flags (start-dead))
    )
  )

;; failed to figure out what this is:
(defpart 1368
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 3))
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 32.0 32.0 1.0)
    (sp-rnd-flt spt-g 96.0 32.0 1.0)
    (sp-rnd-flt spt-b 128.0 64.0 1.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 3000)
    (sp-cpuinfo-flags bit3)
    (sp-func spt-func 'sparticle-track-root)
    (sp-int spt-next-time 5)
    (sp-launcher-by-id spt-next-launcher 1369)
    )
  )

;; failed to figure out what this is:
(defpart 1369
  :init-specs ((sp-rnd-flt spt-scale-x (meters 2.5) (meters 1.5) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-a 100.0 28.0 1.0)
    (sp-int spt-next-time 5)
    (sp-launcher-by-id spt-next-launcher 1369)
    )
  )

;; failed to figure out what this is:
(defpart 1366
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 2.0)
    (sp-rnd-flt spt-y (meters 4) (meters 16) 1.0)
    (sp-flt spt-z (meters 0))
    (sp-flt spt-scale-x (meters 1.5))
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 32.0 32.0 1.0)
    (sp-rnd-flt spt-g 96.0 32.0 1.0)
    (sp-rnd-flt spt-b 128.0 64.0 1.0)
    (sp-flt spt-a 64.0)
    (sp-rnd-flt spt-omega 0.0 65536.0 1.0)
    (sp-flt spt-vel-x (meters 0.053333335))
    (sp-flt spt-vel-y (meters 0.053333335))
    (sp-flt spt-vel-z (meters 0.002))
    (sp-int spt-timer 3000)
    (sp-cpuinfo-flags bit2 bit3 bit7)
    (sp-int spt-next-time 300)
    (sp-launcher-by-id spt-next-launcher 1370)
    )
  )

;; failed to figure out what this is:
(defpart 1370
  :init-specs ((sp-flt spt-vel-z (meters 0)))
  )

;; failed to figure out what this is:
(defpart 1367
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 0.85))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 32.0)
    (sp-rnd-flt spt-g 96.0 32.0 1.0)
    (sp-rnd-flt spt-b 96.0 64.0 1.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-scalevel-x (meters -0.00075757573))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-g -0.16)
    (sp-flt spt-fade-a -0.14222223)
    (sp-int spt-timer 1500)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-kermit-pulse-impact
  :id 301
  :duration 5
  :bounds (static-bspherem 0 0 0 3)
  :parts ((sp-item 1371) (sp-item 1372))
  )

;; failed to figure out what this is:
(defpart 1371
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 8.0)
    (sp-rnd-flt spt-x (meters -0.1) (meters 0.2) 1.0)
    (sp-rnd-flt spt-y (meters -0.1) (meters 0.2) 1.0)
    (sp-rnd-flt spt-z (meters -0.1) (meters 0.2) 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.2) (meters 0.9) 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-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 64.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.011666667) (meters 0.00083333335) 1.0)
    (sp-flt spt-scalevel-x (meters 0.01))
    (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-fade-g -2.1333334)
    (sp-flt spt-fade-a -0.64)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 150)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 30)
    (sp-launcher-by-id spt-next-launcher 1373)
    (sp-rnd-flt spt-launchrot-x (degrees 0.0) (degrees 180.0) 1.0)
    (sp-rnd-flt spt-launchrot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-rotate-y (degrees 0.0))
    )
  )

;; failed to figure out what this is:
(defpart 1373
  :init-specs ((sp-flt spt-fade-r -3.2)
    (sp-flt spt-fade-g 1.0)
    (sp-flt spt-fade-b 1.0)
    (sp-int spt-next-time 30)
    (sp-launcher-by-id spt-next-launcher 1374)
    )
  )

;; failed to figure out what this is:
(defpart 1374
  :init-specs ((sp-flt spt-fade-r 0.0) (sp-flt spt-fade-g 0.0) (sp-flt spt-fade-b 0.0))
  )

;; failed to figure out what this is:
(defpart 1372
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x4 :page #x2))
    (sp-flt spt-num 32.0)
    (sp-rnd-flt spt-x (meters -0.1) (meters 0.2) 1.0)
    (sp-rnd-flt spt-y (meters -0.1) (meters 0.2) 1.0)
    (sp-rnd-flt spt-z (meters -0.1) (meters 0.2) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.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-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 64.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.006666667) (meters 0.06666667) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -1.9999999) (degrees 3.9999998) 1.0)
    (sp-flt spt-fade-g -2.1333334)
    (sp-flt spt-fade-a -1.4222223)
    (sp-flt spt-accel-y -2.7306666)
    (sp-flt spt-friction 0.93)
    (sp-int spt-timer 90)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 30)
    (sp-launcher-by-id spt-next-launcher 1373)
    (sp-rnd-flt spt-launchrot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-launchrot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-rotate-y (degrees 0.0))
    )
  )

;; definition of type joint-mod-tracker
(deftype joint-mod-tracker (basic)
  ((target-pos               vector                   :inline :offset-assert  16)
   (target-pos-func          (function vector vector)         :offset-assert  32)
   (inv-forward-scale-factor float                            :offset-assert  36)
   (forward-scale-control    float                            :offset-assert  40)
   (forward-scale-max        float                            :offset-assert  44)
   (process                  kermit                           :offset-assert  48)
   (enable                   symbol                           :offset-assert  52)
   (up-axis                  int8                             :offset-assert  56)
   (forward-axis             int8                             :offset-assert  57)
   )
  :method-count-assert 9
  :size-assert         #x3a
  :flag-assert         #x90000003a
  (:methods
    (new (symbol type kermit int function int int) _type_ 0)
    )
  )

;; definition for method 3 of type joint-mod-tracker
(defmethod inspect joint-mod-tracker ((obj joint-mod-tracker))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Ttarget-pos: #<vector @ #x~X>~%" (-> obj target-pos))
  (format #t "~Ttarget-pos-func: ~A~%" (-> obj target-pos-func))
  (format #t "~Tinv-forward-scale-factor: ~f~%" (-> obj inv-forward-scale-factor))
  (format #t "~Tforward-scale-control: ~f~%" (-> obj forward-scale-control))
  (format #t "~Tforward-scale-max: ~f~%" (-> obj forward-scale-max))
  (format #t "~Tprocess: ~A~%" (-> obj process))
  (format #t "~Tenable: ~A~%" (-> obj enable))
  (format #t "~Tup-axis: ~D~%" (-> obj up-axis))
  (format #t "~Tforward-axis: ~D~%" (-> obj forward-axis))
  obj
  )

;; definition for method 7 of type joint-mod-tracker
(defmethod relocate joint-mod-tracker ((obj joint-mod-tracker) (arg0 int))
  (&+! (-> obj process) arg0)
  obj
  )

;; definition for function build-matrix-from-up-and-forward-axes!
;; INFO: Used lq/sq
(defun build-matrix-from-up-and-forward-axes! ((arg0 matrix) (arg1 vector) (arg2 int) (arg3 vector) (arg4 int))
  (let ((s1-0 (new 'stack-no-clear 'vector))
        (s5-0 (new 'stack-no-clear 'vector))
        )
    (let ((s3-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg3 1.0)))
      (vector-cross! s1-0 arg1 s3-0)
      (vector-normalize! s1-0 1.0)
      (vector-cross! s5-0 s3-0 s1-0)
      (if (!= (mod (+ arg2 1) 3) arg4)
          (vector-negate-in-place! s1-0)
          )
      (set! (-> arg0 vector 0 quad) (-> s1-0 quad))
      (set! (-> arg0 vector 1 quad) (-> s1-0 quad))
      (set! (-> arg0 vector 2 quad) (-> s1-0 quad))
      (set! (-> arg0 vector arg4 quad) (-> s3-0 quad))
      )
    (set! (-> arg0 vector arg2 quad) (-> s5-0 quad))
    )
  (set! (-> arg0 vector 0 w) 0.0)
  (set! (-> arg0 vector 1 w) 0.0)
  (set! (-> arg0 vector 2 w) 0.0)
  (set! (-> arg0 vector 3 quad) (-> *null-vector* quad))
  arg0
  )

;; definition for function joint-mod-tracker-callback
;; INFO: Used lq/sq
(defun joint-mod-tracker-callback ((arg0 cspace) (arg1 transformq))
  (let ((s4-0 (the-as joint-mod-tracker (-> arg0 param1))))
    (cond
      ((-> s4-0 enable)
       (let ((t9-0 (-> s4-0 target-pos-func)))
         (if t9-0
             (t9-0 (-> s4-0 target-pos))
             )
         )
       (let ((s3-0 (-> s4-0 target-pos))
             (s5-1 (vector-matrix*! (new 'stack-no-clear 'vector) (-> arg1 trans) (-> arg0 parent bone transform)))
             )
         (let* ((s2-1 (vector-! (new 'stack-no-clear 'vector) s3-0 s5-1))
                (f30-0 (vector-length s2-1))
                )
           (build-matrix-from-up-and-forward-axes!
             (-> arg0 bone transform)
             *y-vector*
             (-> s4-0 up-axis)
             s2-1
             (-> s4-0 forward-axis)
             )
           (let ((f0-3 (fmin
                         (* f30-0 (-> s4-0 inv-forward-scale-factor) (-> s4-0 forward-scale-control))
                         (-> s4-0 forward-scale-max)
                         )
                       )
                 (v1-10 (-> arg0 bone transform vector (-> s4-0 forward-axis)))
                 )
             (vector-float*! v1-10 v1-10 f0-3)
             (set! (-> v1-10 w) 0.0)
             )
           )
         (set! (-> arg0 bone transform vector 3 quad) (-> s5-1 quad))
         )
       (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0)
       )
      (else
        (set! (-> arg1 scale data (-> s4-0 forward-axis)) (-> s4-0 forward-scale-control))
        (cspace<-parented-transformq-joint! arg0 arg1)
        )
      )
    )
  (none)
  )

;; definition for method 0 of type joint-mod-tracker
(defmethod new joint-mod-tracker ((allocation symbol) (type-to-make type) (arg0 kermit) (arg1 int) (arg2 function) (arg3 int) (arg4 int))
  (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
    (set! (-> v0-0 process) arg0)
    (set! (-> v0-0 target-pos-func) (the-as (function vector vector) arg2))
    (set! (-> v0-0 up-axis) arg3)
    (set! (-> v0-0 forward-axis) arg4)
    (set! (-> v0-0 inv-forward-scale-factor) 0.0)
    (set! (-> v0-0 forward-scale-control) 1.0)
    (set! (-> v0-0 forward-scale-max) 1.0)
    (set! (-> v0-0 enable) #t)
    (let ((v1-5 (-> arg0 node-list data arg1)))
      (set! (-> v1-5 param0) joint-mod-tracker-callback)
      (set! (-> v1-5 param1) v0-0)
      )
    v0-0
    )
  )

;; definition of type kermit-pulse
(deftype kermit-pulse (process-drawable)
  ((parent-override (pointer kermit)      :offset         12)
   (self-override   kermit-pulse          :offset         28)
   (root-override   collide-shape-moving  :offset        112)
   (sound-id        sound-id              :offset-assert 176)
   )
  :heap-base #x50
  :method-count-assert 20
  :size-assert         #xb4
  :flag-assert         #x14005000b4
  (:states
    kermit-pulse-idle
    kermit-pulse-impact
    )
  )

;; definition for method 3 of type kermit-pulse
(defmethod inspect kermit-pulse ((obj kermit-pulse))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tsound-id: ~D~%" (-> obj sound-id))
  obj
  )

;; failed to figure out what this is:
(defstate kermit-pulse-idle (kermit-pulse)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touch 'attack)
       (send-event arg0 'attack (-> arg3 param 0) (new 'static 'attack-info))
       (go kermit-pulse-impact)
       )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :exit (behavior ()
    (sound-stop (-> self sound-id))
    (none)
    )
  :code (behavior ()
    (while (< (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 4))
      (sound-play "kermit-loop" :id (-> self sound-id) :position (the-as symbol (-> self root-override trans)))
      (spawn (-> self part) (-> self root-override trans))
      (find-ground-and-draw-shadow
        (-> self root-override trans)
        (the-as vector #f)
        8192.0
        (collide-kind background)
        (the-as process-drawable #f)
        0.0
        81920.0
        )
      (suspend)
      )
    (cleanup-for-death self)
    (none)
    )
  :post (behavior ()
    (update-transforms! (-> self root-override))
    (none)
    )
  )

;; failed to figure out what this is:
(defstate kermit-pulse-impact (kermit-pulse)
  :code (behavior ()
    (sound-play "get-shocked")
    (process-spawn
      part-tracker
      :init part-tracker-init
      (-> *part-group-id-table* 301)
      -1
      #f
      #f
      #f
      (-> self root-override trans)
      :to *entity-pool*
      )
    (cleanup-for-death self)
    (none)
    )
  )

;; definition for function kermit-pulse-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior kermit-pulse-init-by-other kermit-pulse ((arg0 vector) (arg1 entity-actor))
  (logclear! (-> self mask) (process-mask enemy attackable))
  (set! (-> self mask) (logior (process-mask projectile) (-> self mask)))
  (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) default-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 target))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 prim-core offense) (collide-offense indestructible))
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 2867.2)
      (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! (-> self root-override) s5-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 quad))
  (set! (-> self root-override quat vec quad) (-> self parent-override 0 collide-info quat vec quad))
  (vector-identity! (-> self root-override scale))
  (vector-reset! (-> self root-override transv))
  (set! (-> self sound-id) (new-sound-id))
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 300) self))
  (go kermit-pulse-idle)
  (none)
  )

;; definition for function spawn-kermit-pulse
;; INFO: Return type mismatch int vs none.
(defun spawn-kermit-pulse ((arg0 kermit) (arg1 vector) (arg2 entity))
  (process-spawn kermit-pulse arg1 arg2 :to arg0)
  0
  (none)
  )

;; definition of type kermit
(deftype kermit (nav-enemy)
  ((child-override   (pointer kermit-pulse)           :offset         20)
   (rotate-dir       vector                   :inline :offset-assert 400)
   (charging-part    sparticle-launch-control         :offset-assert 416)
   (airborne         symbol                           :offset-assert 420)
   (tongue-control   joint-mod-tracker                :offset-assert 424)
   (tongue-pulse-pos float                            :offset-assert 428)
   (miss-count       int8                             :offset-assert 432)
   (charged-up       symbol                           :offset-assert 436)
   (sound-id         sound-id                         :offset-assert 440)
   )
  :heap-base #x150
  :method-count-assert 76
  :size-assert         #x1bc
  :flag-assert         #x4c015001bc
  (:states
    kermit-attack
    kermit-chase
    kermit-chase-new-position
    kermit-give-up
    kermit-idle
    kermit-notice
    kermit-patrol
    kermit-retract-tongue
    kermit-tongue-stuck
    )
  )

;; definition for method 3 of type kermit
(defmethod inspect kermit ((obj kermit))
  (let ((t9-0 (method-of-type nav-enemy inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Trotate-dir: #<vector @ #x~X>~%" (-> obj rotate-dir))
  (format #t "~T~Tcharging-part: ~A~%" (-> obj charging-part))
  (format #t "~T~Tairborne: ~A~%" (-> obj airborne))
  (format #t "~T~Ttongue-control: ~A~%" (-> obj tongue-control))
  (format #t "~T~Ttongue-pulse-pos: ~f~%" (-> obj tongue-pulse-pos))
  (format #t "~T~Tmiss-count: ~D~%" (-> obj miss-count))
  (format #t "~T~Tcharged-up: ~A~%" (-> obj charged-up))
  (format #t "~T~Tsound-id: ~D~%" (-> obj sound-id))
  obj
  )

;; definition for method 7 of type kermit
;; INFO: Return type mismatch nav-enemy vs kermit.
(defmethod relocate kermit ((obj kermit) (arg0 int))
  (if (nonzero? (-> obj tongue-control))
      (&+! (-> obj tongue-control) arg0)
      )
  (if (nonzero? (-> obj charging-part))
      (&+! (-> obj charging-part) arg0)
      )
  (the-as kermit ((method-of-type nav-enemy relocate) obj arg0))
  )

;; definition for method 10 of type kermit
(defmethod deactivate kermit ((obj kermit))
  (if (nonzero? (-> obj charging-part))
      (kill-and-free-particles (-> obj charging-part))
      )
  ((method-of-type nav-enemy deactivate) obj)
  (none)
  )

;; failed to figure out what this is:
(defskelgroup *kermit-sg* kermit kermit-lod0-jg kermit-idle-ja
              ((kermit-lod0-mg (meters 20)) (kermit-lod1-mg (meters 40)) (kermit-lod2-mg (meters 999999)))
              :bounds (static-spherem 0 -1 0 3)
              :longest-edge (meters 2)
              )

;; definition for function kermit-enable-tongue
;; INFO: Return type mismatch int vs none.
(defbehavior kermit-enable-tongue kermit ()
  (set! (-> self tongue-control enable) #t)
  (set! (-> self draw bounds w) 81920.0)
  0
  (none)
  )

;; definition for function kermit-disable-tongue
;; INFO: Return type mismatch int vs none.
(defbehavior kermit-disable-tongue kermit ()
  (set! (-> self tongue-control enable) #f)
  (set! (-> self draw bounds w) 12288.0)
  0
  (none)
  )

;; definition for function kermit-tongue-pos
(defun kermit-tongue-pos ((arg0 kermit))
  (-> arg0 node-list data 24 bone transform vector 3)
  )

;; definition for function kermit-get-head-dir-xz
;; INFO: Used lq/sq
(defun kermit-get-head-dir-xz ((arg0 kermit) (arg1 vector))
  (set! (-> arg1 quad) (-> arg0 node-list data 8 bone transform vector 2 quad))
  (set! (-> arg1 y) 0.0)
  (vector-xz-normalize! arg1 1.0)
  )

;; definition for function kermit-get-head-dir
;; INFO: Used lq/sq
(defun kermit-get-head-dir ((arg0 kermit) (arg1 vector))
  (set! (-> arg1 quad) (-> arg0 node-list data 8 bone transform vector 2 quad))
  (vector-normalize! arg1 1.0)
  )

;; definition for function kermit-player-target-pos
(defun kermit-player-target-pos ()
  (target-pos 26)
  )

;; definition for function kermit-get-tongue-target-callback
;; INFO: Used lq/sq
(defun kermit-get-tongue-target-callback ((arg0 vector))
  (set! (-> arg0 quad) (-> (kermit-player-target-pos) quad))
  arg0
  )

;; definition for function kermit-check-tongue-is-clear?
(defbehavior kermit-check-tongue-is-clear? kermit ()
  (let* ((gp-0 (kermit-tongue-pos self))
         (v1-1 (-> self tongue-control target-pos))
         (s5-1 (vector-! (new 'stack-no-clear 'vector) v1-1 gp-0))
         (t2-0 (new 'stack 'collide-tri-result))
         (f30-0
           (fill-and-probe-using-line-sphere
             *collide-cache*
             gp-0
             s5-1
             409.6
             (collide-kind background cak-2 crate enemy wall-object projectile ground-object)
             self
             t2-0
             (new 'static 'pat-surface :noentity #x1)
             )
           )
         (gp-1 (< f30-0 0.0))
         )
    (set! (-> self tongue-control forward-scale-max)
          (if gp-1
              2.0
              (* (vector-length s5-1) f30-0 (-> self tongue-control inv-forward-scale-factor))
              )
          )
    gp-1
    )
  )

;; definition for function kermit-check-to-hit-player?
(defbehavior kermit-check-to-hit-player? kermit ((arg0 float))
  (let* ((s5-0 (kermit-tongue-pos self))
         (v1-0 (kermit-player-target-pos))
         (s4-1 (vector-! (new 'stack-no-clear 'vector) v1-0 s5-0))
         (f30-0 (vector-length s4-1))
         (s5-1 (new 'stack-no-clear 'vector))
         (f0-0 f30-0)
         (s5-2 (vector-float*! s5-1 s4-1 (/ 1.0 f0-0)))
         (v0-5 (>= (vector-dot (kermit-get-head-dir-xz self (new 'stack-no-clear 'vector)) s5-2) (cos arg0)))
         )
    (and (< f30-0 49152.0) v0-5)
    )
  )

;; definition for function kermit-set-nav-mesh-target
;; INFO: Used lq/sq
(defbehavior kermit-set-nav-mesh-target kermit ((arg0 vector))
  (let* ((gp-0 (target-pos 0))
         (s5-1 (vector-! (new 'stack-no-clear 'vector) arg0 gp-0))
         )
    (vector-length s5-1)
    (let* ((a0-4 (vector-normalize-copy! (new 'stack-no-clear 'vector) s5-1 40960.0))
           (v1-2 (vector+! (new 'stack-no-clear 'vector) gp-0 a0-4))
           (v0-3 (-> self nav target-pos))
           )
      (set! (-> v0-3 quad) (-> v1-2 quad))
      v0-3
      )
    )
  )

;; definition for function kermit-short-hop
(defbehavior kermit-short-hop kermit ()
  (ja-no-eval :group! kermit-hop-ja :num! (seek!) :frame-num 0.0)
  (until (ja-done? 0)
    (let ((f0-4 (ja-aframe-num 0)))
      (if (>= f0-4 4.0)
          (set! (-> self airborne) #t)
          )
      (if (>= f0-4 14.0)
          (set! (-> self airborne) #f)
          )
      )
    (suspend)
    (ja :num! (seek!))
    )
  #f
  )

;; definition for function kermit-long-hop
(defbehavior kermit-long-hop kermit ()
  (ja-no-eval :group! kermit-longhop-ja :num! (seek!) :frame-num 0.0)
  (until (ja-done? 0)
    (let ((f0-4 (ja-aframe-num 0)))
      (if (>= f0-4 7.0)
          (set! (-> self airborne) #t)
          )
      (if (>= f0-4 29.0)
          (set! (-> self airborne) #f)
          )
      )
    (suspend)
    (ja :num! (seek!))
    )
  #f
  )

;; definition for function kermit-hop
(defbehavior kermit-hop kermit ((arg0 float))
  (ja-channel-push! 1 (seconds 0.1))
  (set! (-> self rotate-speed) 1820444.5)
  (let ((f0-2 (fmin arg0 (vector-vector-distance (-> self collide-info trans) (-> self nav target-pos)))))
    (cond
      ((< 16384.0 f0-2)
       (set! (-> self target-speed) (* 0.045454547 (-> *display* frames-per-second) f0-2))
       (kermit-long-hop)
       )
      (else
        (set! (-> self target-speed) (* 0.1 (-> *display* frames-per-second) f0-2))
        (kermit-short-hop)
        )
      )
    )
  (set! (-> self airborne) #f)
  #f
  )

;; definition for function kermit-set-rotate-dir-to-nav-target
;; INFO: Used lq/sq
(defbehavior kermit-set-rotate-dir-to-nav-target kermit ()
  (cond
    ((logtest? (nav-control-flags navcf19) (-> self nav flags))
     (vector-! (-> self rotate-dir) (-> self nav target-pos) (-> self collide-info trans))
     )
    (else
      (let ((v0-1 (-> self rotate-dir)))
        (set! (-> v0-1 quad) (-> self nav travel quad))
        v0-1
        )
      )
    )
  )

;; definition for function kermit-set-rotate-dir-to-player
(defbehavior kermit-set-rotate-dir-to-player kermit ()
  (vector-! (-> self rotate-dir) (target-pos 0) (-> self nav target-pos))
  )

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

;; definition for method 39 of type kermit
;; INFO: Return type mismatch int vs none.
(defmethod common-post kermit ((obj kermit))
  ((the-as (function nav-enemy none) (find-parent-method kermit 39)) obj)
  (when (-> obj charged-up)
    )
  0
  (none)
  )

;; definition for function kermit-simple-post
(defbehavior kermit-simple-post kermit ()
  (nav-enemy-simple-post)
  (none)
  )

;; definition for function kermit-post
;; INFO: Used lq/sq
(defbehavior kermit-post kermit ()
  (cond
    ((-> self airborne)
     (dummy-11 (-> self nav) (-> self nav target-pos))
     (set! (-> self collide-info transv x) (-> self nav travel x))
     (set! (-> self collide-info transv y) 0.0)
     (set! (-> self collide-info transv z) (-> self nav travel z))
     (let ((f0-5
             (fmin
               (-> self target-speed)
               (* (vector-xz-length (-> self collide-info transv)) (-> *display* frames-per-second))
               )
             )
           )
       (vector-xz-normalize! (-> self collide-info transv) f0-5)
       )
     (seek-toward-heading-vec! (-> self collide-info) (-> self rotate-dir) (-> self rotate-speed) (seconds 0.05))
     (vector-v++!
       (-> self collide-info transv)
       (compute-acc-due-to-gravity (-> self collide-info) (new-stack-vector0) 0.0)
       )
     (integrate-for-enemy-with-move-to-ground!
       (-> self collide-info)
       (-> self collide-info transv)
       (collide-kind background)
       8192.0
       #t
       #f
       #f
       )
     (nav-enemy-common-post)
     )
    (else
      (set! (-> self collide-info transv quad) (-> *null-vector* quad))
      (kermit-simple-post)
      )
    )
  (none)
  )

;; definition for function kermit-get-new-patrol-point
;; INFO: Used lq/sq
(defbehavior kermit-get-new-patrol-point kermit ()
  (nav-enemy-get-new-patrol-point)
  (let ((v0-1 (-> self nav target-pos)))
    (set! (-> v0-1 quad) (-> self nav destination-pos quad))
    v0-1
    )
  )

;; failed to figure out what this is:
(defstate kermit-idle (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self notice-time) 0)
    0
    (none)
    )
  :trans (behavior ()
    (if (and *target* (>= (-> self enemy-info idle-distance)
                          (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))
                          )
             )
        (go kermit-patrol)
        )
    (none)
    )
  :code (behavior ()
    (kermit-disable-tongue)
    (ja :group! kermit-idle-ja :num! min)
    (loop
      (ja :num! (loop!))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior kermit) ja-post)
  )

;; failed to figure out what this is:
(defstate kermit-patrol (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set-mode! (-> self neck) (joint-mod-handler-mode flex-blend))
    (kermit-get-new-patrol-point)
    (dummy-11 (-> self nav) (-> self nav target-pos))
    (none)
    )
  :trans (behavior ()
    (if (and (or (not *target*) (< (-> self enemy-info idle-distance)
                                   (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))
                                   )
                 )
             (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1))
             )
        (go kermit-idle)
        )
    (kermit-set-rotate-dir-to-nav-target)
    (if (and (not (-> self airborne)) (nav-enemy-test-point-in-nav-mesh? (target-pos 0)))
        (go kermit-notice)
        )
    (if (logtest? (nav-control-flags navcf19) (-> self nav flags))
        (kermit-get-new-patrol-point)
        )
    (none)
    )
  :code (behavior ()
    (loop
      (ja-no-eval :group! kermit-idle-ja :num! (seek! max 3.0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max 3.0))
        )
      (kermit-hop 20480.0)
      )
    (none)
    )
  :post kermit-post
  )

;; failed to figure out what this is:
(defstate kermit-notice (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set-mode! (-> self neck) (joint-mod-handler-mode look-at))
    (none)
    )
  :trans (behavior ()
    (kermit-set-rotate-dir-to-player)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (set-mode! (-> self neck) (joint-mod-handler-mode look-at))
    (kermit-hop 0.0)
    (go kermit-chase)
    (none)
    )
  :post kermit-post
  )

;; failed to figure out what this is:
(defstate kermit-give-up (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set-mode! (-> self neck) (joint-mod-handler-mode flex-blend))
    (none)
    )
  :code (behavior ()
    (go kermit-patrol)
    (none)
    )
  :post kermit-simple-post
  )

;; failed to figure out what this is:
(defstate kermit-chase-new-position (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self miss-count) 0)
    (let* ((a1-1 (kermit-get-head-dir-xz self (new 'stack-no-clear 'vector)))
           (gp-0 (vector-rotate-around-y! (new 'stack-no-clear 'vector) a1-1 16384.0))
           (s5-0 (new 'stack-no-clear 'vector))
           (v1-2 #f)
           )
      (let ((s4-0 0))
        (while (and (not v1-2) (< s4-0 4))
          (let ((f0-0 (rand-vu-float-range -40960.0 40960.0)))
            (vector+*! s5-0 (-> self collide-info trans) gp-0 f0-0)
            )
          (kermit-set-nav-mesh-target s5-0)
          (set! v1-2 (nav-enemy-test-point-in-nav-mesh? (-> self nav target-pos)))
          (+! s4-0 1)
          )
        )
      (if (not v1-2)
          (kermit-set-nav-mesh-target (-> self collide-info trans))
          )
      )
    (dummy-11 (-> self nav) (-> self nav target-pos))
    (none)
    )
  :trans (behavior ()
    (when (not (-> self airborne))
      (if (or (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
              (and (logtest? (nav-control-flags navcf19) (-> self nav flags))
                   (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.5))
                   )
              )
          (go kermit-chase)
          )
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.17))
    (dotimes (gp-0 3)
      (ja-no-eval :group! kermit-idle-ja :num! (seek! max 4.0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max 4.0))
        )
      )
    (loop
      (kermit-hop 81920.0)
      (nop!)
      )
    (none)
    )
  :post kermit-post
  )

;; failed to figure out what this is:
(defstate kermit-chase (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set-mode! (-> self neck) (joint-mod-handler-mode look-at))
    (kermit-set-nav-mesh-target (-> self collide-info trans))
    (dummy-11 (-> self nav) (-> self nav target-pos))
    (none)
    )
  :trans (behavior ()
    (kermit-set-nav-mesh-target (-> self collide-info trans))
    (kermit-set-rotate-dir-to-player)
    (if (nav-enemy-test-point-in-nav-mesh? (target-pos 0))
        (set! (-> self state-time) (-> *display* base-frame-counter))
        )
    (kermit-tongue-pos self)
    (let ((v1-5 (kermit-player-target-pos)))
      (set! (-> self tongue-control target-pos quad) (-> v1-5 quad))
      )
    (when (not (-> self airborne))
      (if (or (not *target*) (< (-> self enemy-info idle-distance)
                                (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))
                                )
              )
          (go kermit-patrol)
          )
      (let ((gp-1 (kermit-check-to-hit-player? 3640.889))
            (v1-17 (kermit-check-tongue-is-clear?))
            )
        (when gp-1
          (if v1-17
              (go kermit-attack)
              (go kermit-chase-new-position)
              )
          )
        )
      (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
          (go kermit-give-up)
          )
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.17))
    (loop
      (ja-no-eval :group! kermit-idle-ja :num! (seek! max 3.0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max 3.0))
        )
      (if (not (kermit-check-to-hit-player? 3640.889))
          (kermit-hop 81920.0)
          )
      )
    (none)
    )
  :post kermit-post
  )

;; failed to figure out what this is:
(defstate kermit-attack (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.17))
    (set! (-> self tongue-control forward-scale-control) 0.0)
    (kermit-enable-tongue)
    (let ((s5-0 #f)
          (gp-0 #f)
          )
      (let ((f30-0 1.0))
        (ja-no-eval :group! kermit-lash-ja :num! (seek!) :frame-num 0.0)
        (until (ja-done? 0)
          (set! (-> self tongue-control target-pos quad) (-> (kermit-player-target-pos) quad))
          (when (and (not s5-0) (>= (ja-aframe-num 0) 14.0))
            (set! s5-0 #t)
            (set! gp-0 (kermit-check-to-hit-player? 3640.889))
            (if (not gp-0)
                (set! f30-0 0.8)
                )
            )
          (when s5-0
            (if (and (not gp-0) (= (-> self tongue-control forward-scale-control) f30-0))
                (go kermit-retract-tongue)
                )
            (seek! (-> self tongue-control forward-scale-control) f30-0 0.25)
            )
          (suspend)
          (ja :num! (seek!))
          )
        )
      (cond
        (gp-0
          (level-hint-spawn
            (game-text-id swamp-kermit-tongue-hint)
            "sksp0143"
            (the-as entity #f)
            *entity-pool*
            (game-task none)
            )
          (level-hint-spawn
            (game-text-id swamp-kermit-flee)
            "sksp0151"
            (the-as entity #f)
            *entity-pool*
            (game-task none)
            )
          (go kermit-tongue-stuck)
          )
        (else
          (go kermit-retract-tongue)
          )
        )
      )
    (none)
    )
  :post kermit-simple-post
  )

;; failed to figure out what this is:
(defstate kermit-tongue-stuck (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self miss-count) 0)
    (set! (-> self tongue-control forward-scale-control) 1.0)
    (kermit-enable-tongue)
    (set! (-> self tongue-pulse-pos) 0.0)
    (spawn-kermit-pulse self (kermit-tongue-pos self) (-> self entity))
    (none)
    )
  :exit (behavior ()
    (sound-stop (-> self sound-id))
    (let ((v1-0 (-> self child-override)))
      (if v1-0
          (deactivate (-> v1-0 0))
          )
      )
    (none)
    )
  :trans (behavior ()
    (let ((s5-0 (kermit-player-target-pos))
          (gp-0 (kermit-tongue-pos self))
          )
      (if (or (< 73728.0 (vector-vector-distance s5-0 gp-0))
              (or (not (kermit-check-tongue-is-clear?)) (not (-> self child-override)))
              )
          (go kermit-retract-tongue)
          )
      (seek! (-> self tongue-pulse-pos) 1.0 (* 0.3 (-> *display* seconds-per-frame)))
      (when (and (-> self child-override) (let ((v1-9 (-> self child-override)))
                                            (= (-> (if v1-9
                                                       (-> v1-9 0 self-override)
                                                       )
                                                   type
                                                   )
                                               kermit-pulse
                                               )
                                            )
                 )
        (let* ((v1-13 (-> self child-override))
               (s4-0 (if v1-13
                         (-> v1-13 0 self-override)
                         )
                     )
               (v1-15 (vector-lerp! (new 'stack-no-clear 'vector) gp-0 s5-0 (-> self tongue-pulse-pos)))
               )
          (set! (-> s4-0 root-override trans quad) (-> v1-15 quad))
          )
        )
      (send-event *target* 'tongue gp-0)
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (loop
      (ja-no-eval :group! kermit-turn-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (sound-play "kermit-stretch" :id (-> self sound-id) :position (the-as symbol (-> self collide-info trans)))
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (behavior ()
    (seek-to-point-toward-point! (-> self collide-info) (target-pos 0) (-> self rotate-speed) (seconds 0.05))
    (kermit-simple-post)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate kermit-retract-tongue (kermit)
  :event (the-as
    (function process int symbol event-message-block object :behavior kermit)
    nav-enemy-default-event-handler
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self charged-up) #f)
    (+! (-> self miss-count) 1)
    (none)
    )
  :exit (behavior ()
    (set! (-> self tongue-control forward-scale-control) 0.0)
    (kermit-disable-tongue)
    (none)
    )
  :trans (behavior ()
    (kermit-set-nav-mesh-target (-> self collide-info trans))
    (kermit-set-rotate-dir-to-player)
    (when (not (-> self airborne))
      (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 2.5))
        (kill-and-free-particles (-> self charging-part))
        (set! (-> self charged-up) #t)
        (go kermit-chase)
        )
      )
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (ja-no-eval :group! kermit-miss-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (if (>= (ja-aframe-num 0) 3.0)
          (seek! (-> self tongue-control forward-scale-control) 0.0 0.125)
          )
      (suspend)
      (ja :num! (seek!))
      )
    (set! (-> self tongue-control forward-scale-control) 0.0)
    (kermit-disable-tongue)
    (loop
      (ja-channel-push! 1 (seconds 0.1))
      (ja-no-eval :group! kermit-idle-ja :num! (seek! max 4.0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max 4.0))
        )
      (kermit-hop 0.0)
      )
    (none)
    )
  :post kermit-post
  )

;; definition for symbol *kermit-nav-enemy-info*, type nav-enemy-info
(define *kermit-nav-enemy-info* (new 'static 'nav-enemy-info
                                  :idle-anim 4
                                  :walk-anim -1
                                  :turn-anim -1
                                  :notice-anim -1
                                  :run-anim -1
                                  :jump-anim 6
                                  :jump-land-anim -1
                                  :victory-anim -1
                                  :taunt-anim -1
                                  :die-anim 11
                                  :neck-joint 8
                                  :player-look-at-joint 5
                                  :run-travel-speed (meters 6)
                                  :run-rotate-speed (degrees 10000.0)
                                  :run-acceleration (meters 1)
                                  :run-turn-time (seconds 0.05)
                                  :walk-travel-speed (meters 3)
                                  :walk-rotate-speed (degrees 10000.0)
                                  :walk-acceleration (meters 1)
                                  :walk-turn-time (seconds 0.05)
                                  :attack-shove-back (meters 3)
                                  :attack-shove-up (meters 2)
                                  :shadow-size (meters 2)
                                  :notice-nav-radius (meters 10)
                                  :nav-nearest-y-threshold (meters 10)
                                  :notice-distance (meters 30)
                                  :stop-chase-distance (meters 40)
                                  :frustration-distance (meters 8)
                                  :frustration-time (seconds 4)
                                  :die-anim-hold-frame 10000000000.0
                                  :jump-land-anim-end-frame 10000000000.0
                                  :jump-height-min (meters 1)
                                  :jump-height-factor 0.5
                                  :jump-start-anim-speed 1.0
                                  :shadow-max-y (meters 1)
                                  :shadow-min-y (meters -1)
                                  :shadow-locus-dist (meters 150)
                                  :use-align #f
                                  :draw-shadow #t
                                  :move-to-ground #f
                                  :hover-if-no-ground #f
                                  :use-momentum #f
                                  :use-flee #f
                                  :use-proximity-notice #f
                                  :use-jump-blocked #f
                                  :use-jump-patrol #f
                                  :gnd-collide-with (collide-kind background)
                                  :debug-draw-neck #f
                                  :debug-draw-jump #f
                                  )
        )

;; definition for method 11 of type kermit
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! kermit ((obj kermit) (arg0 entity-actor))
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player))))
    (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s4-0 reaction) default-collision-reaction)
    (set! (-> s4-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 1) 0)))
      (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid))
      (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 16384.0)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 3))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core action) (collide-action solid))
        (set! (-> s2-0 prim-core offense) (collide-offense touch))
        (set! (-> s2-0 transform-index) 3)
        (set-vector! (-> s2-0 local-sphere) 0.0 0.0 0.0 3072.0)
        (append-prim s3-0 s2-0)
        )
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj collide-info) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *kermit-sg* '())
  (set! (-> obj draw origin-joint-index) (the-as uint 3))
  (set! (-> obj airborne) #f)
  (TODO-RENAME-45 obj *kermit-nav-enemy-info*)
  (set-vector! (-> obj neck twist-max) 3640.889 3640.889 0.0 1.0)
  (set! (-> obj neck up) (the-as uint 1))
  (set! (-> obj neck nose) (the-as uint 2))
  (set! (-> obj neck ear) (the-as uint 0))
  (set! (-> obj neck max-dist) 102400.0)
  (set! (-> obj neck ignore-angle) 16384.0)
  (set! (-> obj miss-count) 0)
  (set! (-> obj tongue-control) (new 'process 'joint-mod-tracker obj 24 kermit-get-tongue-target-callback 1 2))
  (let ((f0-16 49152.0))
    (set! (-> obj tongue-control inv-forward-scale-factor) (/ 1.0 f0-16))
    )
  (set! (-> obj tongue-control forward-scale-control) 0.0)
  (set! (-> obj tongue-control forward-scale-max) 2.0)
  (set! (-> obj tongue-control enable) #f)
  (set! (-> obj charged-up) #t)
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 299) obj))
  (set! (-> obj charging-part) (create-launch-control (-> *part-group-id-table* 298) obj))
  (set! (-> obj sound-id) (new-sound-id))
  (go kermit-idle)
  (none)
  )
