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

;; name: flitter.gc
;; name in dgo: flitter
;; dgos: GAME, COMMON

;; DECOMP BEGINS

(defpartgroup group-flitter-dust-puff
  :id 144
  :duration (seconds 0.017)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 641))
  )

(defpart 641
  :init-specs ((:texture (bigpuff effects))
    (:num 6.0)
    (:scale-x (meters 0.6) (meters 0.4))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 32.0 8.0)
    (:g 16.0 8.0)
    (:b 16.0 8.0)
    (:a 32.0 32.0)
    (:vel-y (meters 0.01) (meters 0.0026666666))
    (:scalevel-x (meters 0.0016666667))
    (:rotvel-z (degrees -0.2) (degrees 0.4))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -0.35555556)
    (:fade-g -0.35555556)
    (:fade-b -0.35555556)
    (:fade-a -0.30476192)
    (:accel-y (meters -0.00033333333))
    (:timer (seconds 0.4))
    (:flags (sp-cpuinfo-flag-2))
    (:next-time (seconds 0.2))
    (:next-launcher 642)
    (:conerot-x (degrees 60) (degrees 30))
    (:conerot-y (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 180))
    )
  )

(defpartgroup group-flitter-birth
  :id 145
  :duration (seconds 7.335)
  :linger-duration (seconds 4)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 3 0 8)
  :parts ((sp-item 645 :fade-after (meters 100) :falloff-to (meters 100) :period (seconds 7.335) :length (seconds 0.835) :binding 643)
    (sp-item 645 :fade-after (meters 100) :falloff-to (meters 100) :period (seconds 7.335) :length (seconds 0.667) :binding 643)
    (sp-item 645 :fade-after (meters 100) :falloff-to (meters 100) :period (seconds 7.335) :length (seconds 0.5) :binding 643)
    (sp-item 645 :fade-after (meters 100) :falloff-to (meters 100) :period (seconds 7.335) :length (seconds 0.335) :binding 643)
    (sp-item 646 :fade-after (meters 100) :falloff-to (meters 100) :period (seconds 7.335) :length (seconds 0.4) :binding 644)
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 644 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 643 :flags (bit1 start-dead))
    (sp-item 647 :fade-after (meters 100) :falloff-to (meters 100) :period (seconds 7.335) :length (seconds 1.067))
    )
  )

(defpart 647
  :init-specs ((:texture (bigpuff effects))
    (:num 1.0 1.0)
    (:scale-x (meters 1) (meters 0.5))
    (:scale-y (meters 1) (meters 0.5))
    (:r 160.0 16.0)
    (:g 130.0 32.0)
    (:b 110.0 16.0)
    (:a 16.0 48.0)
    (:vel-y (meters 0.026666667) (meters 0.026666667))
    (:scalevel-x (meters 0.006666667) (meters 0.0016666667))
    (:scalevel-y (meters 0.0033333334) (meters 0.0016666667))
    (:fade-a -0.053333335 -0.053333335)
    (:accel-y (meters 0) (meters 0.00033333333))
    (:friction 0.85 0.05)
    (:timer (seconds 8))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:conerot-x (degrees 0) (degrees 90))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0) (meters 0.5))
    )
  )

(defun check-drop-level-flitter-dirt-rubble ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (let ((f30-0 (-> arg1 key origin trans y)))
    (when (< (-> arg2 y) f30-0)
      (let ((gp-0 (new 'stack-no-clear 'vector)))
        (sp-kill-particle arg0 arg1)
        (set-vector! gp-0 (-> arg2 x) f30-0 (-> arg2 z) 1.0)
        (launch-particles (-> *part-id-table* 648) gp-0)
        (launch-particles (-> *part-id-table* 649) gp-0)
        (launch-particles (-> *part-id-table* 650) gp-0)
        )
      )
    )
  (none)
  )

(defpart 644
  :init-specs ((:texture (bigpuff effects))
    (:num 0.0 0.2)
    (:sound (static-sound-spec "debris-fall" :num 0.01 :volume 100.0))
    (:scale-x (meters 0.3) (meters 0.1))
    (:scale-y (meters 1) (meters 0.2))
    (:r 160.0 16.0)
    (:g 130.0 32.0)
    (:b 110.0 16.0)
    (:a 16.0 16.0)
    (:vel-y (meters 0) (meters -0.0033333334))
    (:scalevel-x (meters 0.0033333334) (meters 0.0016666667))
    (:scalevel-y (meters 0) (meters 0.00033333333))
    (:fade-a -0.042666666 -0.064)
    (:accel-y (meters -0.00033333333) (meters -0.00033333333))
    (:timer (seconds 0.835))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:func 'check-drop-group-center)
    (:rotate-y (degrees 0) (degrees 360))
    )
  )

(defpart 643
  :init-specs ((:texture (bigpuff effects))
    (:num 0.0 0.2)
    (:scale-x (meters 0.3) (meters 0.1))
    (:scale-y (meters 1) (meters 0.2))
    (:r 160.0 16.0)
    (:g 130.0 32.0)
    (:b 110.0 16.0)
    (:a 16.0 16.0)
    (:vel-y (meters 0) (meters -0.0033333334))
    (:scalevel-x (meters 0.0033333334) (meters 0.0016666667))
    (:scalevel-y (meters 0) (meters 0.00033333333))
    (:fade-a -0.042666666 -0.064)
    (:accel-y (meters -0.00033333333) (meters -0.00033333333))
    (:timer (seconds 2.5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:func 'check-drop-group-center)
    (:rotate-y (degrees 0) (degrees 360))
    )
  )

(defpart 646
  :init-specs ((:texture (pebble1-ruins ruins-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 0.5 0.5)
    (:x (meters 0) (meters 1))
    (:scale-x (meters 0.1) (meters 0.1))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.1) (meters 0.1))
    (:r 200.0 55.0)
    (:g :copy r)
    (:b :copy g)
    (:a 128.0)
    (:vel-y (meters 0.033333335) (meters 0.033333335))
    (:rotvel-z (degrees -1.2) (degrees 2.4))
    (:accel-y (meters -0.002) (meters -0.002))
    (:friction 0.98)
    (:timer (seconds 1.167))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:userdata
      :data (new 'static 'boxed-array :type int32 40 1 0 #x3e800700 #x3e800800 #x3e800900 #x3e800a00 #x3e800b00)
      )
    (:func 'check-drop-level-flitter-dirt-rubble)
    (:conerot-x (degrees 0) (degrees 45))
    (:conerot-y (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 645
  :init-specs ((:texture (pebble1-ruins ruins-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 0.1 0.5)
    (:x (meters 0) (meters 1))
    (:scale-x (meters 0.1) (meters 0.1))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.1) (meters 0.1))
    (:r 200.0 55.0)
    (:g :copy r)
    (:b :copy g)
    (:a 128.0)
    (:vel-y (meters 0.06666667) (meters 0.033333335))
    (:rotvel-z (degrees -1.2) (degrees 2.4))
    (:accel-y (meters -0.002) (meters -0.002))
    (:friction 0.98)
    (:timer (seconds 1.167))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:userdata
      :data (new 'static 'boxed-array :type int32 40 1 0 #x3e800700 #x3e800800 #x3e800900 #x3e800a00 #x3e800b00)
      )
    (:func 'check-drop-level-flitter-dirt-rubble-ruins)
    (:conerot-x (degrees 0) (degrees 15))
    (:conerot-y (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.1))
    )
  )

(defpart 648
  :init-specs ((:texture (pebble1-ruins ruins-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 1.0 2.0)
    (:scale-x (meters 0.05) (meters 0.15))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.05) (meters 0.15))
    (:r 200.0 55.0)
    (:g :copy r)
    (:b :copy g)
    (:a 128.0)
    (:vel-y (meters 0.006666667) (meters 0.026666667))
    (:rotvel-z (degrees -1.2) (degrees 2.4))
    (:fade-a -0.42666668 -0.85333335)
    (:accel-y (meters -0.00066666666))
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:userdata
      :data (new 'static 'boxed-array :type int32 40 1 0 #x3e800700 #x3e800800 #x3e800900 #x3e800a00 #x3e800b00)
      )
    (:conerot-x (degrees 10) (degrees 60))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(defpart 649
  :init-specs ((:texture (pebble1-ruins ruins-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 1.0 1.0)
    (:scale-x (meters 0.05) (meters 0.15))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.05) (meters 0.15))
    (:r 200.0 55.0)
    (:g :copy r)
    (:b :copy g)
    (:a 128.0)
    (:vel-y (meters 0) (meters 0.04))
    (:rotvel-z (degrees -1.2) (degrees 2.4))
    (:friction 0.94 0.02)
    (:timer (seconds 8))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:userdata
      :data (new 'static 'boxed-array :type int32 40 1 0 #x3e800700 #x3e800800 #x3e800900 #x3e800a00 #x3e800b00)
      )
    (:next-time (seconds 1.5) (seconds 0.497))
    (:next-launcher 651)
    (:conerot-x (degrees 90))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(defpart 651
  :init-specs ((:rotvel-z (degrees 0)) (:fade-a -0.10666667 -0.10666667))
  )

(defpart 650
  :init-specs ((:texture (bigpuff effects))
    (:num 1.0)
    (:sound (static-sound-spec "debris-ground" :num 0.01 :volume 100.0))
    (:scale-x (meters 1) (meters 0.5))
    (:scale-y (meters 0.5) (meters 0.5))
    (:r 160.0 16.0)
    (:g 130.0 32.0)
    (:b 110.0 16.0)
    (:a 16.0 32.0)
    (:vel-y (meters 0.013333334) (meters 0.026666667))
    (:scalevel-x (meters 0.0033333334) (meters 0.0016666667))
    (:scalevel-y (meters 0.0033333334) (meters 0.0016666667))
    (:fade-a -0.026666667 -0.026666667)
    (:accel-y (meters 0) (meters 0.00033333333))
    (:friction 0.9 0.05)
    (:timer (seconds 8))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12))
    (:conerot-x (degrees 70) (degrees 20))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(deftype flitter (nav-enemy)
  ((move-angle        float)
   (heading           basic)
   (change-dir-time   time-frame)
   (last-change-dir   uint64)
   (off-screen-timer  uint64)
   (amb-sound-timer   uint64)
   (attack-time       time-frame)
   (target-pos        vector  :inline)
   (attack-pos        vector  :inline)
   (base-height       float)
   (minimap           connection-minimap)
   )
  (:state-methods
    attack
    ambush-jumping
    )
  (:methods
    (flitter-method-180 (_type_) none)
    (flitter-method-181 (_type_) none)
    (flitter-method-182 (_type_ process-focusable) symbol)
    (flitter-method-183 (_type_) float)
    )
  )


(defskelgroup skel-flitter flitter flitter-lod0-jg -1
              ((flitter-lod0-mg (meters 20)) (flitter-lod1-mg (meters 40)) (flitter-lod2-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 5.5)
              :shadow flitter-shadow-mg
              :origin-joint-index 3
              )

(define *flitter-nav-enemy-info*
  (new 'static 'nav-enemy-info
    :use-die-falling #t
    :use-victory #f
    :use-jump-blocked #f
    :debug-draw-neck #f
    :jump-debug-draw #f
    :move-to-ground #t
    :hover-if-no-ground #f
    :idle-anim-script (new 'static 'array idle-control-frame 16
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x3 :param1 #x6)
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x6 :param0 #x1 :param1 #x1)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x7 :param0 #xf :param1 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x2 :param1 #x4)
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x8 :param0 #x1 :param1 #x1)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x9 :param0 #xa :param1 #x14)
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x2)
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x8 :param0 #x1 :param1 #x1)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x9 :param0 #xf :param1 #x1e)
      (new 'static 'idle-control-frame)
      )
    :idle-anim 5
    :notice-anim 12
    :hostile-anim 14
    :hit-anim 5
    :knocked-anim 20
    :knocked-land-anim 21
    :die-anim 19
    :die-falling-anim 18
    :victory-anim 5
    :jump-wind-up-anim 5
    :jump-in-air-anim 5
    :jump-land-anim 5
    :neck-joint -1
    :look-at-joint 28
    :bullseye-joint 3
    :sound-hit (static-sound-name "flitter-hit")
    :sound-die (static-sound-name "flitter-die")
    :notice-distance (meters 40)
    :notice-distance-delta (meters 10)
    :proximity-notice-distance (meters 20)
    :default-hit-points 1
    :gnd-collide-with (collide-spec backgnd)
    :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
    :penetrate-knocked (penetrate
      generic-attack
      flop
      punch
      spin
      roll
      uppercut
      bonk
      tube
      vehicle
      flut-attack
      board
      mech-punch
      mech-bonk
      dark-skin
      dark-punch
      dark-bomb
      dark-giant
      shield
      explode
      jak-yellow-shot
      jak-red-shot
      jak-blue-shot
      jak-dark-shot
      enemy-yellow-shot
      enemy-dark-shot
      eco-yellow
      knocked
      )
    :movement-gravity (meters -100)
    :friction 0.8
    :attack-shove-back (meters 6)
    :attack-shove-up (meters 3)
    :attack-mode 'generic
    :attack-damage 1
    :recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
    :jump-height-min (meters 3)
    :jump-height-factor 0.5
    :knocked-seek-ry-clamp 2730.6667
    :knocked-soft-vxz-lo 72089.6
    :knocked-soft-vxz-hi 108134.4
    :knocked-soft-vy-lo 81920.0
    :knocked-soft-vy-hi 122880.0
    :knocked-medium-vxz-lo 147456.0
    :knocked-medium-vxz-hi 196608.0
    :knocked-medium-vy-lo 135168.0
    :knocked-medium-vy-hi 151552.0
    :knocked-hard-vxz-lo 78643.2
    :knocked-hard-vxz-hi 117964.8
    :knocked-hard-vy-lo 183500.8
    :knocked-hard-vy-hi 275251.2
    :knocked-huge-vxz-lo 164659.2
    :knocked-huge-vxz-hi 249036.8
    :knocked-huge-vy-lo 183500.8
    :knocked-huge-vy-hi 217907.2
    :knocked-yellow-vxz-lo 40960.0
    :knocked-yellow-vxz-hi 49152.0
    :knocked-yellow-vy-lo 57344.0
    :knocked-yellow-vy-hi 81920.0
    :knocked-red-vxz-lo 24576.0
    :knocked-red-vxz-hi 196608.0
    :knocked-red-vy-lo 94208.0
    :knocked-red-vy-hi 151552.0
    :knocked-blue-vxz-lo 40960.0
    :knocked-blue-vxz-hi 49152.0
    :knocked-blue-vy-lo 24576.0
    :knocked-blue-vy-hi 81920.0
    :shadow-size (meters 2)
    :shadow-max-y (meters 1)
    :shadow-min-y (meters -1)
    :shadow-locus-dist (meters 150)
    :gem-joint 28
    :gem-seg #x2
    :gem-no-seg #x4
    :gem-offset (new 'static 'sphere :y 696.32 :z 1843.2 :r 163840.0)
    :callback-info #f
    :use-momentum #f
    :use-frustration #t
    :use-stop-chase #f
    :use-circling #t
    :use-pacing #t
    :walk-anim 13
    :turn-anim 15
    :run-anim 14
    :taunt-anim -1
    :run-travel-speed (meters 12)
    :run-acceleration (meters 8)
    :run-turning-acceleration (meters 120)
    :walk-travel-speed (meters 4)
    :walk-acceleration (meters 1)
    :walk-turning-acceleration (meters 5)
    :maximum-rotation-rate (degrees 720)
    :notice-nav-radius (meters 5)
    :frustration-distance (meters 12)
    :frustration-time (seconds 4)
    :blocked-time (seconds 0.3)
    :circle-dist-lo 20480.0
    :circle-dist-hi 61440.0
    :nav-mesh #f
    )
  )

(set! (-> *flitter-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

(defmethod flitter-method-182 ((this flitter) (arg0 process-focusable))
  (and (logtest? (-> this draw status) (draw-control-status on-screen))
       (let ((s4-0 (camera-matrix)))
         (camera-pos)
         (let* ((s3-0 (get-trans arg0 0))
                (s5-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> s4-0 vector 2) 1.0))
                (v1-7 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> this root trans) s3-0) 1.0))
                )
           (< 0.0 (vector-dot s5-1 v1-7))
           )
         )
       )
  )

(defmethod enemy-method-77 ((this flitter) (arg0 enemy-knocked-info))
  (case (-> this incoming knocked-type)
    (((knocked-type knocked-type-4))
     (let ((a0-2 (-> this skel root-channel 0)))
       (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> this draw art-group data 20)))
       (set! (-> a0-2 param 0)
             (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 20)) frames num-frames) -1))
             )
       (set! (-> a0-2 param 1) (-> arg0 anim-speed))
       (set! (-> a0-2 frame-num) 0.0)
       (joint-control-channel-group! a0-2 (the-as art-joint-anim (-> this draw art-group data 20)) num-func-seek!)
       )
     #t
     )
    (((knocked-type knocked-type-6))
     (let ((v1-17 (if (> (-> this skel active-channels) 0)
                      (-> this skel root-channel 0 frame-group)
                      )
                  )
           )
       (if (and v1-17 (= v1-17 (-> this draw art-group data 21)))
           (ja-channel-push! 1 (seconds 0.17))
           (ja-channel-push! 1 (seconds 0.02))
           )
       )
     (let ((a0-10 (-> this skel root-channel 0)))
       (set! (-> a0-10 frame-group) (the-as art-joint-anim (-> this draw art-group data 23)))
       (set! (-> a0-10 param 0)
             (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 23)) frames num-frames) -1))
             )
       (set! (-> a0-10 param 1) 1.0)
       (set! (-> a0-10 frame-num) 0.0)
       (joint-control-channel-group! a0-10 (the-as art-joint-anim (-> this draw art-group data 23)) num-func-seek!)
       )
     #t
     )
    (else
      ((method-of-type nav-enemy enemy-method-77) this arg0)
      )
    )
  )

(defmethod enemy-method-78 ((this flitter) (arg0 enemy-knocked-info))
  (case (-> this incoming knocked-type)
    (((knocked-type knocked-type-6))
     (when (>= (-> this incoming blue-juggle-count) (the-as uint 2))
       (let ((v1-4 (-> this skel root-channel 0)))
         (set! (-> v1-4 frame-group) (the-as art-joint-anim (-> this draw art-group data 22)))
         (set! (-> v1-4 param 0)
               (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 22)) frames num-frames) -1))
               )
         (set! (-> v1-4 param 1) 1.0)
         (set! (-> v1-4 frame-num) 0.0)
         (joint-control-channel-group! v1-4 (the-as art-joint-anim (-> this draw art-group data 22)) num-func-seek!)
         )
       #t
       )
     )
    (else
      ((method-of-type nav-enemy enemy-method-78) this arg0)
      )
    )
  )

(defmethod go-stare2 ((this flitter))
  (if (and (= (-> this focus aware) (enemy-aware enemy-aware-2))
           (not (nav-enemy-method-163 this))
           (not (and (-> this next-state) (= (-> this next-state name) 'pacing)))
           )
      (go (method-of-object this pacing))
      (go (method-of-object this stare))
      )
  )

(defstate ambush (flitter)
  :virtual #t
  :enter (behavior ()
    (when (logtest? (-> self enemy-flags) (enemy-flag enable-on-notice))
      (logclear! (-> self enemy-flags) (enemy-flag enable-on-notice))
      (let ((gp-0 (-> self on-notice)))
        (if gp-0
            (script-eval gp-0 :vector (-> self root trans))
            )
        )
      )
    (set! (-> self base-height) (-> self root trans y))
    (let ((v1-13 (-> self root root-prim)))
      (set! (-> v1-13 prim-core collide-as) (collide-spec))
      (set! (-> v1-13 prim-core collide-with) (collide-spec))
      )
    0
    (logior! (-> self draw status) (draw-control-status no-draw))
    )
  :code (behavior ()
    (let ((gp-0 (get-process *default-dead-pool* part-tracker #x4000)))
      (when gp-0
        (let ((t9-1 (method-of-type part-tracker activate)))
          (t9-1
            (the-as part-tracker gp-0)
            *entity-pool*
            (symbol->string (-> part-tracker symbol))
            (the-as pointer #x70004000)
            )
          )
        (let ((t9-2 run-function-in-process)
              (a0-2 gp-0)
              (a1-2 part-tracker-init)
              (a2-4 (-> *part-group-id-table* 145))
              (a3-1 0)
              (t0-0 #f)
              (t1-0 #f)
              (t2-0 #f)
              (t3-0 *launch-matrix*)
              )
          (set! (-> t3-0 trans quad) (-> self root trans quad))
          ((the-as (function object object object object object object object object none) t9-2)
           a0-2
           a1-2
           a2-4
           a3-1
           t0-0
           t1-0
           t2-0
           t3-0
           )
          )
        (-> gp-0 ppointer)
        )
      )
    (suspend-for (seconds 0.6)
      )
    (+! (-> self root trans y) -8192.0)
    (enemy-method-129 self)
    (let ((a0-5 (handle->process (-> self focus handle))))
      (when a0-5
        (let* ((gp-2 (-> self root))
               (s3-0
                 (vector-normalize!
                   (vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable a0-5) 0) (-> gp-2 trans))
                   1.0
                   )
                 )
               (f0-2 (deg-diff (quaternion-y-angle (-> gp-2 quat)) (vector-y-angle s3-0)))
               )
          (quaternion-rotate-y! (-> gp-2 quat) (-> gp-2 quat) f0-2)
          )
        )
      )
    (suspend-for (the int (* 300.0 (rnd-float-range self 0.0 0.6)))
      )
    (logclear! (-> self draw status) (draw-control-status no-draw))
    (go-virtual ambush-jumping)
    )
  )

(defstate ambush-jumping (flitter)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (let ((v1-0 self))
      (if (not (logtest? (enemy-flag enemy-flag36) (-> v1-0 enemy-flags)))
          (set! (-> v1-0 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-0 enemy-flags))))
          )
      (set! (-> v1-0 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-0 enemy-flags))))
      (set! (-> v1-0 nav callback-info) (-> v1-0 enemy-info callback-info))
      )
    0
    (let ((v1-3 self))
      (set! (-> v1-3 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-3 enemy-flags))))
      )
    0
    (look-at-target! self (enemy-flag look-at-focus))
    (set-time! (-> self state-time))
    (let ((gp-0 (-> self root)))
      (vector-reset! (-> gp-0 transv))
      (set! (-> gp-0 transv y) (* 4096.0 (rnd-float-range self 34.0 38.0)))
      )
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (ja-no-eval :group! flitter-ambush-jump-ja :num! (seek!))
    (until #f
      (when (< (-> self base-height) (-> self root trans y))
        (let ((gp-0 (get-process *default-dead-pool* part-tracker #x4000)))
          (when gp-0
            (let ((t9-3 (method-of-type part-tracker activate)))
              (t9-3
                (the-as part-tracker gp-0)
                *entity-pool*
                (symbol->string (-> part-tracker symbol))
                (the-as pointer #x70004000)
                )
              )
            (let ((t9-4 run-function-in-process)
                  (a0-4 gp-0)
                  (a1-4 part-tracker-init)
                  (a2-5 (-> *part-group-id-table* 144))
                  (a3-1 0)
                  (t0-0 #f)
                  (t1-0 #f)
                  (t2-0 #f)
                  (t3-0 *launch-matrix*)
                  )
              (set! (-> t3-0 trans quad) (-> self root trans quad))
              ((the-as (function object object object object object object object object none) t9-4)
               a0-4
               a1-4
               a2-5
               a3-1
               t0-0
               t1-0
               t2-0
               t3-0
               )
              )
            (-> gp-0 ppointer)
            )
          )
        (goto cfg-10)
        )
      (suspend)
      (ja :num! (seek!))
      )
    #f
    (until #f
      (when (< (+ 204.8 (-> self base-height)) (-> self root trans y))
        (let ((v1-40 (-> self root root-prim)))
          (set! (-> v1-40 prim-core collide-as) (-> self root backup-collide-as))
          (set! (-> v1-40 prim-core collide-with) (-> self root backup-collide-with))
          )
        (goto cfg-11)
        )
      (label cfg-10)
      (suspend)
      (ja :num! (seek!))
      )
    #f
    (until #f
      (label cfg-11)
      (if (or (and (>= 0.0 (-> self root transv y)) (>= (+ 1638.4 (-> self base-height)) (-> self root trans y)))
              (logtest? (-> self root status) (collide-status on-ground))
              )
          (goto cfg-26)
          )
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek!))
          )
      )
    #f
    (label cfg-26)
    (ja-no-eval :group! flitter-ambush-land-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (until #f
      (if (logtest? (-> self root status) (collide-status on-ground))
          (goto cfg-33)
          )
      (suspend)
      )
    #f
    (label cfg-33)
    (go-virtual hostile)
    )
  :post nav-enemy-falling-post
  )

(defmethod enemy-method-99 ((this flitter) (arg0 process-focusable))
  (focus-test? arg0 mech)
  )

(defmethod flitter-method-180 ((this flitter))
  (let* ((s5-0 (handle->process (-> this focus handle)))
         (s3-0 (if (type? s5-0 process-focusable)
                   (the-as process-focusable s5-0)
                   )
               )
         )
    (when s3-0
      (let* ((s5-1 (get-trans s3-0 0))
             (s4-1 (vector-! (new 'stack-no-clear 'vector) s5-1 (-> this root trans)))
             (f30-0 (vector-length s4-1))
             )
        (cond
          ((enemy-method-99 this s3-0)
           (go-flee this)
           )
          ((and (< f30-0 32768.0) (not (flitter-method-182 this s3-0)))
           (go (method-of-object this circling))
           )
          ((< f30-0 (-> this enemy-info notice-nav-radius))
           (set! (-> this target-pos quad) (-> s5-1 quad))
           (let ((s3-1 (new 'stack-no-clear 'vector)))
             (set! (-> s3-1 quad) (-> s4-1 quad))
             (let ((s5-2 (new 'stack-no-clear 'vector)))
               (set! (-> s5-2 quad) (-> this root transv quad))
               (vector-normalize! s5-2 f30-0)
               (if (>= (vector-dot s3-1 s5-2) 0.98)
                   (go (method-of-object this attack))
                   )
               )
             )
           )
          ((< f30-0 32768.0)
           (set! (-> this target-pos quad) (-> s5-1 quad))
           )
          ((or (time-elapsed? (the-as int (-> this last-change-dir)) (-> this change-dir-time))
               (< (vector-vector-distance-squared (-> this root trans) (-> this target-pos)) 0.1)
               )
           (set! (-> this last-change-dir) (the-as uint (current-time)))
           (set! (-> this change-dir-time) (rand-vu-int-range (seconds 0.5) (seconds 0.7)))
           (let ((s3-2 (new 'stack-no-clear 'vector))
                 (f0-9 (* (/ f30-0 2) (tan (-> this move-angle))))
                 (s2-0 (new 'stack-no-clear 'vector))
                 )
             (if (-> this heading)
                 (set-vector! s3-2 (-> s4-1 z) (-> s4-1 y) (- (-> s4-1 x)) 1.0)
                 (set-vector! s3-2 (- (-> s4-1 z)) (-> s4-1 y) (-> s4-1 x) 1.0)
                 )
             (set! (-> this heading) (the-as basic (not (-> this heading))))
             (let ((f28-1 (rand-vu-float-range (* 0.75 f0-9) f0-9))
                   (s4-2 (vector-normalize-copy! (new 'stack-no-clear 'vector) s4-1 (* -0.6 f30-0)))
                   )
               (vector-normalize! s3-2 f28-1)
               (vector+! s3-2 s3-2 s4-2)
               )
             (clamp-vector-to-mesh-cross-gaps (-> this nav state) s3-2)
             (vector+! s2-0 s5-1 s3-2)
             (set! (-> this target-pos quad) (-> s2-0 quad))
             )
           )
          )
        )
      0
      )
    )
  0
  (none)
  )

;; WARN: Return type mismatch time-frame vs none.
(defmethod flitter-method-181 ((this flitter))
  (when (time-elapsed? (the-as int (-> this amb-sound-timer)) (the int (* 300.0 (rand-vu-float-range 1.5 3.0))))
    (sound-play "flitter-amb" :position (-> this root trans))
    (set! (-> this amb-sound-timer) (the-as uint (current-time)))
    )
  (none)
  )

(defbehavior flitter-fall-and-play-death-anim flitter ((arg0 art-joint-anim) (arg1 float) (arg2 time-frame))
  (local-vars (v1-29 symbol))
  (stop-looking-at-target! self)
  (set! (-> self skel root-channel 0 frame-group) arg0)
  (let ((s4-1 (enemy-method-50 self (new 'stack-no-clear 'vector)))
        (s3-0 (-> self root))
        )
    (when (if (type? s3-0 collide-shape-moving)
              s3-0
              )
      (set! (-> self root transv y) 33775.48)
      (ja :num-func num-func-identity :frame-num 0.0)
      (set-time! (-> self state-time))
      (logclear! (-> self root status) (collide-status on-surface on-ground touch-surface))
      (until v1-29
        (let ((f0-2 102400.0))
          (set! (-> self root transv x) (* (-> s4-1 x) f0-2))
          (set! (-> self root transv z) (* (-> s4-1 z) f0-2))
          )
        (suspend)
        (ja :num! (seek! max arg1))
        (set! v1-29 (or (ja-done? 0) (time-elapsed? (-> self state-time) arg2)))
        )
      )
    )
  0
  (none)
  )

(defstate active (flitter)
  :virtual #t
  :post (behavior ()
    (flitter-method-181 self)
    (let ((t9-1 (-> (method-of-type nav-enemy active) post)))
      (if t9-1
          ((the-as (function none) t9-1))
          )
      )
    )
  )

(defstate stare (flitter)
  :virtual #t
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (let ((f30-0 (rnd-float-range self 0.8 1.2)))
      (until #f
        (when (not (enemy-method-96 self 2730.6667 #t))
          (let ((v1-5 self))
            (set! (-> v1-5 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-5 enemy-flags))))
            )
          0
          (ja-no-eval :num! (loop!))
          (ja-channel-push! 1 (seconds 0.2))
          (ja :group! flitter-turn-ja)
          (ja :num-func num-func-identity :frame-num 0.0)
          (until (enemy-method-96 self 1820.4445 #t)
            (ja-blend-eval)
            (suspend)
            (ja :num! (loop! 0.75))
            )
          (let ((v1-25 self))
            (set! (-> v1-25 enemy-flags) (the-as enemy-flag (logclear (-> v1-25 enemy-flags) (enemy-flag enemy-flag37))))
            )
          0
          )
        (let ((v1-29 (ja-group)))
          (if (not (and v1-29 (= v1-29 (-> self draw art-group data (-> self enemy-info idle-anim)))))
              (ja-channel-push! 1 (seconds 0.2))
              )
          )
        (ja-no-eval :group! (-> self draw art-group data (-> self enemy-info idle-anim))
                    :num! (seek! max f30-0)
                    :frame-num 0.0
                    )
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek! max f30-0))
          )
        )
      )
    #f
    )
  :post (behavior ()
    (flitter-method-181 self)
    (let ((t9-1 (-> (method-of-type nav-enemy stare) post)))
      (if t9-1
          ((the-as (function none) t9-1))
          )
      )
    )
  )

(defstate circling (flitter)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy circling) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (set! (-> self off-screen-timer) (the-as uint (current-time)))
    )
  :trans (behavior ()
    (let ((gp-0 (handle->process (-> self focus handle))))
      (if gp-0
          (set! (-> self focus-pos quad) (-> (get-trans (the-as process-focusable gp-0) 0) quad))
          )
      (when (time-elapsed? (-> self state-time) (seconds 0.1))
        (let ((v1-11 (-> self focus aware)))
          (cond
            ((= v1-11 (enemy-aware enemy-aware-3))
             (cond
               ((when gp-0
                  (let* ((gp-1 self)
                         (s5-1 (method-of-object gp-1 flitter-method-182))
                         (s4-0 (handle->process (-> self focus handle)))
                         )
                    (s5-1 gp-1 (the-as process-focusable (if (type? s4-0 process-focusable)
                                                             s4-0
                                                             )
                                       )
                          )
                    )
                  )
                (if (and (get-enemy-target self) (time-elapsed? (the-as int (-> self off-screen-timer)) (seconds 0.3)))
                    (go-hostile self)
                    )
                )
               (else
                 (set! (-> self off-screen-timer) (the-as uint (current-time)))
                 )
               )
             )
            ((= v1-11 (enemy-aware enemy-aware-2))
             (go-stare self)
             )
            ((>= 1 (the-as int v1-11))
             (go-virtual active)
             )
            )
          )
        (if (or (nav-enemy-method-163 self) (logtest? (enemy-flag enemy-flag41) (-> self enemy-flags)))
            (go-stare2 self)
            )
        )
      )
    )
  :code (behavior ()
    (nav-enemy-method-166 self)
    (ja-channel-push! 1 (seconds 0.2))
    (until #f
      (ja-no-eval :group! (-> self draw art-group data (-> self enemy-info run-anim))
                  :num! (seek! max (rnd-float-range self 0.9 1.1))
                  :frame-num 0.0
                  )
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max (rnd-float-range self 0.9 1.1)))
        )
      )
    #f
    )
  )

(defstate hostile (flitter)
  :virtual #t
  :enter (behavior ()
    (set! (-> self last-change-dir) (the-as uint (current-time)))
    (set! (-> self change-dir-time) 0)
    (set! (-> self attack-time) (+ (current-time) (seconds 0.35)))
    (let ((t9-0 (-> (method-of-type nav-enemy hostile) enter)))
      (if t9-0
          (t9-0)
          )
      )
    )
  :trans (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy hostile) trans)))
      (if t9-0
          (t9-0)
          )
      )
    (flitter-method-180 self)
    )
  :post (behavior ()
    (let ((a0-0 (-> self nav state))
          (v1-1 (-> self target-pos))
          )
      (logclear! (-> a0-0 flags) (nav-state-flag directional-mode))
      (logior! (-> a0-0 flags) (nav-state-flag target-poly-dirty))
      (set! (-> a0-0 target-post quad) (-> v1-1 quad))
      )
    0
    (nav-enemy-travel-post)
    )
  )

(defstate die (flitter)
  :virtual #t
  :enter (behavior ()
    (sound-play "flitter-die")
    (let ((t9-2 (-> (method-of-type nav-enemy die) enter)))
      (if t9-2
          (t9-2)
          )
      )
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.2))
    (flitter-fall-and-play-death-anim
      (the-as art-joint-anim (-> self draw art-group data (-> self enemy-info die-anim)))
      1.0
      (seconds 2)
      )
    (send-event self 'death-end)
    (cleanup-for-death self)
    )
  )

(defmethod flitter-method-183 ((this flitter))
  (lerp-scale 0.0 1.0 (- (-> this attack-pos y) (-> this root trans y)) 13926.4 25600.0)
  )

(defstate attack (flitter)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (set-time! (-> self state-time))
    (let ((v1-2 self))
      (if (not (logtest? (enemy-flag enemy-flag36) (-> v1-2 enemy-flags)))
          (set! (-> v1-2 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-2 enemy-flags))))
          )
      (set! (-> v1-2 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-2 enemy-flags))))
      (set! (-> v1-2 nav callback-info) (-> v1-2 enemy-info callback-info))
      )
    0
    (sound-play "flitter-attack")
    (set! (-> self amb-sound-timer) (the-as uint 0))
    (logior! (-> self focus-status) (focus-status dangerous))
    (let* ((v1-8 *game-info*)
           (v0-2 (+ (-> v1-8 attack-id) 1))
           )
      (set! (-> v1-8 attack-id) v0-2)
      (set! (-> self attack-id) v0-2)
      )
    )
  :exit (behavior ()
    (if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
        (logior! (-> self focus-status) (focus-status dangerous))
        (logclear! (-> self focus-status) (focus-status dangerous))
        )
    )
  :trans (behavior ()
    (local-vars (s5-2 object))
    (let* ((s5-0 (handle->process (-> self focus handle)))
           (gp-0 (if (type? s5-0 process-focusable)
                     (the-as process-focusable s5-0)
                     )
                 )
           )
      (set! s5-2 (cond
                   ((and gp-0
                         (not (time-elapsed? (-> self state-time) (seconds 1.5)))
                         gp-0
                         (not (logtest? (-> gp-0 focus-status) (focus-status disable dead ignore grabbed)))
                         )
                    (let ((s5-1 (-> self nav state))
                          (v1-10 (get-trans gp-0 0))
                          )
                      (logclear! (-> s5-1 flags) (nav-state-flag directional-mode))
                      (logior! (-> s5-1 flags) (nav-state-flag target-poly-dirty))
                      (set! (-> s5-1 target-post quad) (-> v1-10 quad))
                      )
                    0
                    (set! s5-2 (-> self attack-pos))
                    (set! (-> (the-as vector s5-2) quad) (-> (get-trans gp-0 3) quad))
                    s5-2
                    )
                   (else
                     (go-stare self)
                     )
                   )
            )
      )
    )
  :code (behavior ()
    (ja-channel-push! 2 (seconds 0.1))
    (let ((f30-0 (flitter-method-183 self)))
      (ja-no-eval :group! flitter-attack-ja :num! (seek! max 0.8) :frame-num 0.0)
      (ja-no-eval :chan 1
                  :group! flitter-attack-high-ja
                  :num! (chan 0)
                  :frame-interp0 f30-0
                  :frame-interp1 f30-0
                  :frame-num 0.0
                  )
      (until (ja-done? 0)
        (suspend)
        (set! f30-0 (seek f30-0 (flitter-method-183 self) (* 0.2 (seconds-per-frame))))
        (ja :num! (seek! max 0.8))
        (ja :chan 1 :num! (chan 0) :frame-interp0 f30-0 :frame-interp1 f30-0)
        )
      )
    (let ((v1-40 self))
      (set! (-> v1-40 enemy-flags) (the-as enemy-flag (logclear (-> v1-40 enemy-flags) (enemy-flag enemy-flag36))))
      (set! (-> v1-40 nav callback-info) *nav-enemy-null-callback-info*)
      )
    0
    (ja-channel-push! 1 (seconds 0.1))
    (if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
        (logior! (-> self focus-status) (focus-status dangerous))
        (logclear! (-> self focus-status) (focus-status dangerous))
        )
    (dotimes (gp-1 (rnd-int-count self 3))
      (ja-no-eval :group! flitter-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (react-to-focus self)
    )
  :post nav-enemy-travel-post
  )

(defstate victory (flitter)
  :virtual #t
  :post (behavior ()
    (flitter-method-181 self)
    (nav-enemy-simple-post)
    )
  )

(defmethod dying ((this flitter))
  "Cleans-up the enemy and any associated resources. Potentially spawns skull gems"
  (when (-> this minimap)
    (logior! (-> this minimap flags) (minimap-flag fade-out))
    (set! (-> this minimap) #f)
    )
  (call-parent-method this)
  (none)
  )

(defmethod init-enemy-collision! ((this flitter))
  "Initializes the [[collide-shape-moving]] and any ancillary tasks to make the enemy collide properly"
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) cshape-reaction-default)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 3) 0)))
      (set! (-> s5-0 total-prims) (the-as uint 4))
      (set! (-> s4-0 prim-core collide-as) (collide-spec enemy))
      (set! (-> s4-0 prim-core collide-with)
            (collide-spec backgnd jak bot crate obstacle hit-by-others-list player-list)
            )
      (set! (-> s4-0 prim-core action) (collide-action solid can-ride deadly no-standon))
      (set-vector! (-> s4-0 local-sphere) 0.0 10240.0 0.0 15360.0)
      (set! (-> s5-0 root-prim) s4-0)
      )
    (let ((v1-12 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-12 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-12 prim-core collide-with)
            (collide-spec backgnd jak bot crate obstacle hit-by-others-list player-list)
            )
      (set! (-> v1-12 prim-core action) (collide-action solid can-ride deadly no-standon))
      (set-vector! (-> v1-12 local-sphere) 0.0 5734.4 0.0 5734.4)
      )
    (let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-14 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-14 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> v1-14 prim-core action) (collide-action deadly))
      (set! (-> v1-14 transform-index) 34)
      (set-vector! (-> v1-14 local-sphere) 0.0 0.0 0.0 3481.6)
      )
    (let ((v1-16 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-16 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-16 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> v1-16 prim-core action) (collide-action deadly))
      (set! (-> v1-16 transform-index) 35)
      (set-vector! (-> v1-16 local-sphere) 0.0 0.0 0.0 3481.6)
      )
    (set! (-> s5-0 nav-radius) 3686.4)
    (let ((v1-18 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-18 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-18 prim-core collide-with))
      )
    (set! (-> s5-0 max-iteration-count) (the-as uint 3))
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

;; WARN: Return type mismatch connection-minimap vs none.
(defmethod init-enemy! ((this flitter))
  "Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-flitter" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  (init-enemy-behaviour-and-stats! this *flitter-nav-enemy-info*)
  (set! (-> this move-angle) 10922.667)
  (set! (-> this heading) (the-as basic (if (= (rand-vu-int-range 0 1) 1)
                                            #t
                                            #f
                                            )
                                  )
        )
  (set! (-> this change-dir-time) 0)
  (set! (-> this off-screen-timer) (the-as uint 0))
  (set! (-> this amb-sound-timer) (the-as uint 0))
  (add-connection
    *part-engine*
    this
    28
    this
    318
    (new 'static 'vector :x 942.08 :y -860.16 :z 1269.76 :w 163840.0)
    )
  (add-connection
    *part-engine*
    this
    28
    this
    318
    (new 'static 'vector :x -942.08 :y -860.16 :z 1269.76 :w 163840.0)
    )
  (set-gravity-length (-> this root dynam) 491520.0)
  (let* ((s4-1 "pebble1-ruins")
         (v1-15 (-> this level name))
         (s5-2
           (cond
             ((= v1-15 'strip)
              (set! s4-1 "pebble1-strip")
              (new 'static 'boxed-array :type int32 40 1 0 #x4f800500 #x4f800600 #x4f800700 #x4f800800 #x4f800900)
              )
             ((= v1-15 'dig3a)
              (set! s4-1 "pebble1-dig")
              (new 'static 'boxed-array :type int32 40 1 0 -1377828352 -1377828096 -1377827840 -1377827584 -1377827328)
              )
             ((= v1-15 'stadblmp)
              (set! s4-1 "pebble1-dig")
              (new 'static 'boxed-array :type int32 40 1 0 -670040064 -670039808 -670039552 -670039296 -670039040)
              )
             (else
               (new 'static 'boxed-array :type int32 40 1 0 #x3e800700 #x3e800800 #x3e800900 #x3e800a00 #x3e800b00)
               )
             )
           )
         )
    (setup-user-array (-> *part-id-table* 646) s4-1)
    (setup-user-array (-> *part-id-table* 645) s4-1)
    (setup-user-array (-> *part-id-table* 648) s4-1)
    (setup-user-array (-> *part-id-table* 649) s4-1)
    (set! (-> (get-field-spec-by-id (-> *part-id-table* 646) (sp-field-id spt-userdata)) initial-valuef)
          (the-as float s5-2)
          )
    (set! (-> (get-field-spec-by-id (-> *part-id-table* 645) (sp-field-id spt-userdata)) initial-valuef)
          (the-as float s5-2)
          )
    (set! (-> (get-field-spec-by-id (-> *part-id-table* 648) (sp-field-id spt-userdata)) initial-valuef)
          (the-as float s5-2)
          )
    (set! (-> (get-field-spec-by-id (-> *part-id-table* 649) (sp-field-id spt-userdata)) initial-valuef)
          (the-as float s5-2)
          )
    )
  (set! (-> this minimap) (add-icon! *minimap* this (the-as uint 70) (the-as int #f) (the-as vector #t) 0))
  (none)
  )
