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

;; name: wasp.gc
;; name in dgo: wasp
;; dgos: FOR, DMI, FRA, STR, NEB, D3A, UNB

;; DECOMP BEGINS

(defpartgroup group-wasp-explosion
  :id 157
  :duration (seconds 2)
  :linger-duration (seconds 1)
  :flags (use-local-clock unk-5 unk-6 unk-7)
  :bounds (static-bspherem 0 0 0 15)
  :rotate ((degrees 0) (degrees 90) (degrees 0))
  :scale (0.25 0.25 0.25)
  :parts ((sp-item 726 :flags (bit6) :period (seconds 3) :length (seconds 0.017))
    (sp-item 727 :flags (bit6) :period (seconds 3) :length (seconds 0.017))
    (sp-item 728 :period (seconds 3) :length (seconds 0.05))
    (sp-item 729 :fade-after (meters 60) :period (seconds 3) :length (seconds 0.035) :offset 10)
    (sp-item 730 :fade-after (meters 60) :falloff-to (meters 60) :period (seconds 3) :length (seconds 0.167) :offset 20)
    (sp-item 731 :fade-after (meters 200) :falloff-to (meters 200) :period (seconds 3) :length (seconds 0.085) :offset 20)
    (sp-item 732 :fade-after (meters 150) :falloff-to (meters 150) :period (seconds 3) :length (seconds 0.067) :offset 30)
    )
  )

(defpart 727
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 2))
    (:rot-x (degrees 11.25))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 24.0)
    (:scalevel-x (meters 0.10666667))
    (:rotvel-z (degrees 0.3))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g -4.266667)
    (:fade-b -4.266667)
    (:fade-a 0.0)
    (:timer (seconds 0.5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    (:next-time (seconds 0.25))
    (:next-launcher 733)
    )
  )

(defpart 733
  :init-specs ((:scalevel-x (meters 0))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -0.85333335)
    (:fade-g -1.7066667)
    (:fade-b -1.7066667)
    (:fade-a -0.64)
    )
  )

(defpart 732
  :init-specs ((:texture (explosion-wave effects))
    (:num 2.0 0.2)
    (:scale-x (meters 1) (meters 1))
    (:rot-z (degrees 0) (degrees 3600) :store)
    (:scale-y (meters 0.8) (meters 0.2))
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 32.0 32.0)
    (:scalevel-x (meters 0.01) (meters 0.13333334))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g -0.36)
    (:fade-b -4.24)
    (:fade-a -0.22068965)
    (:friction 0.95)
    (:timer (seconds 3.335))
    (:flags (sp-cpuinfo-flag-2))
    (:next-time (seconds 0.085))
    (:next-launcher 734)
    (:conerot-x '*sp-temp*)
    (:conerot-y (degrees 0) (degrees 3600))
    )
  )

(defpart 731
  :init-specs ((:texture (explosion-nebula effects))
    (:birth-func 'birth-func-texture-group)
    (:num 3.0)
    (:scale-x (meters 1) (meters 1))
    (:rot-z (degrees 0))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 32.0 32.0)
    (:vel-y (meters 0.02) (meters 0.01))
    (:scalevel-x (meters 0.01) (meters 0.13333334))
    (:rotvel-z (degrees -0.12) (degrees 0.24))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g -0.36)
    (:fade-b -4.24)
    (:fade-a -0.22068965)
    (:friction 0.95)
    (:timer (seconds 3.335))
    (:flags (sp-cpuinfo-flag-2))
    (:userdata :data (new 'static 'boxed-array :type int32 40 1 0 #xc00000 #xc03300))
    (:next-time (seconds 0.085))
    (:next-launcher 734)
    (:conerot-x (degrees 0) (degrees 3600))
    (:conerot-y (degrees 0) (degrees 3600))
    )
  )

(defpart 734
  :init-specs ((:fade-r 0.0) (:fade-g 0.0) (:fade-b 0.0) (:next-time (seconds 0.017) (seconds 0.065)) (:next-launcher 735))
  )

(defpart 735
  :init-specs ((:scalevel-x (meters 0.016666668) (meters 0.016666668))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -0.44)
    (:fade-g -2.36)
    (:fade-b -2.64)
    (:next-time (seconds 0.117) (seconds 0.047))
    (:next-launcher 736)
    )
  )

(defpart 736
  :init-specs ((:scalevel-x (meters 0.008333334) (meters 0.008333334))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -1.2944444)
    (:fade-g -0.7111111)
    (:fade-b -0.094444446)
    (:fade-a -0.06545454 -0.06545454)
    (:next-time (seconds 0.5) (seconds 0.097))
    (:next-launcher 737)
    )
  )

(defpart 737
  :init-specs ((:fade-r 0.0) (:fade-g 0.0) (:fade-b 0.0) (:fade-a -0.1125))
  )

(defpart 726
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 5))
    (:rot-x (degrees 11.25))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 96.0)
    (:scalevel-x (meters 0.5))
    (:rotvel-z (degrees 0.3))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g -1.28)
    (:fade-b -5.1)
    (:fade-a 0.0)
    (:timer (seconds 0.217))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:next-time (seconds 0.1))
    (:next-launcher 738)
    )
  )

(defpart 738
  :init-specs ((:scalevel-x (meters -0.2857143))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g -3.6571429)
    (:fade-b 0.0)
    (:fade-a -2.7428572)
    )
  )

(defpart 730
  :init-specs ((:texture (specs effects))
    (:num 8.0 2.0)
    (:x (meters 0.25))
    (:scale-x (meters 1) (meters 0.25))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 16.0 48.0)
    (:vel-y (meters 0.083333336) (meters 0.083333336))
    (:scalevel-x (meters 0.006666667) (meters 0.0016666667))
    (:rotvel-z (degrees -0.12) (degrees 0.24))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g -0.18)
    (:fade-b -2.12)
    (:accel-y (meters -0.00016666666) (meters -0.00033333333))
    (:friction 0.87)
    (:timer (seconds 3.335))
    (:flags (sp-cpuinfo-flag-2))
    (:next-time (seconds 0.117) (seconds 0.047))
    (:next-launcher 739)
    (:conerot-x (degrees 0) (degrees 3600))
    (:conerot-y (degrees 0) (degrees 3600))
    )
  )

(defpart 739
  :init-specs ((:scalevel-x (meters 0.0016666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 0.0)
    (:fade-g 0.02)
    (:fade-b 0.23555556)
    (:next-time (seconds 0.15) (seconds 0.047))
    (:next-launcher 740)
    )
  )

(defpart 740
  :init-specs ((:fade-r -0.5543478) (:fade-g -0.5543478) (:fade-a -0.13913043))
  )

(defpart 728
  :init-specs ((:texture (bigpuff effects))
    (:num 8.0 1.0)
    (:x (meters 0) (meters 0.6))
    (:scale-x (meters 2.5) (meters 2))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 70.0 20.0)
    (:g 70.0 20.0)
    (:b 70.0 20.0)
    (:a 0.0 40.0)
    (:vel-y (meters 0) (meters 0.1))
    (:scalevel-x (meters 0.033333335) (meters 0.02))
    (:rotvel-z (degrees -0.12) (degrees 0.24))
    (:scalevel-y :copy scalevel-x)
    (:fade-r 3.3)
    (:fade-g 3.12)
    (:fade-b 1.18)
    (:fade-a 1.76)
    (:friction 0.88)
    (:timer (seconds 2.367))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:next-time (seconds 0.117) (seconds 0.047))
    (:next-launcher 741)
    (:conerot-x (degrees 0) (degrees 3600))
    (:conerot-y (degrees 0) (degrees 3600))
    )
  )

(defpart 741
  :init-specs ((:scalevel-x (meters 0.0033333334))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -0.53333336)
    (:fade-g -1.9666667)
    (:fade-b -2.2)
    (:fade-a -0.41666666)
    (:next-time (seconds 0.15) (seconds 0.047))
    (:next-launcher 742)
    )
  )

(defpart 742
  :init-specs ((:scalevel-x (meters 0))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -0.38833332)
    (:fade-g -0.21333334)
    (:fade-b -0.028333334)
    (:fade-a -0.38833332)
    )
  )

(defpart 729
  :init-specs ((:texture (flamingstick effects))
    (:num 4.0 2.0)
    (:scale-x (meters 0.2) (meters 0.5))
    (:rot-x 4)
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.2) (meters 0.1))
    (:r 128.0 128.0)
    (:g 96.0)
    (:b 64.0)
    (:a 64.0 64.0)
    (:scalevel-x (meters 0.13333334) (meters 0.02))
    (:fade-g 1.6)
    (:fade-b 3.2)
    (:fade-a -1.6)
    (:timer (seconds 0.3))
    (:flags (sp-cpuinfo-flag-2))
    )
  )

(deftype wasp-shot (metalhead-shot)
  ()
  )


(defmethod play-impact-sound ((this wasp-shot) (arg0 projectile-options))
  (let ((v1-0 arg0))
    (cond
      ((zero? v1-0)
       (sound-play "wasp-shot-fire")
       )
      ((= v1-0 (projectile-options lose-altitude))
       (sound-play "wasp-shot-hit")
       )
      )
    )
  0
  (none)
  )

(defmethod init-proj-settings! ((this wasp-shot))
  "Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc"
  (set! (-> this tail-pos quad) (-> this root trans quad))
  (set! (-> this attack-mode) 'wasp-shot)
  (set! (-> this max-speed) 491520.0)
  (set! (-> this move) metalhead-shot-move)
  (set! (-> this timeout) (seconds 1.375))
  0
  (none)
  )

(defskelgroup skel-wasp wasp wasp-lod0-jg -1
              ((wasp-lod0-mg (meters 20)) (wasp-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 7.5)
              :shadow wasp-shadow-mg
              :origin-joint-index 3
              )

(defskelgroup skel-wasp-explode wasp wasp-explode-lod0-jg wasp-explode-idle-ja
              ((wasp-explode-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 7.5)
              :origin-joint-index 3
              )

(define *wasp-exploder-params*
  (new 'static 'joint-exploder-static-params
    :joints (new 'static 'boxed-array :type joint-exploder-static-joint-params
      (new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1)
      (new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1)
      )
    :collide-spec #x1
    )
  )

(define *wasp-enemy-info* (new 'static 'enemy-info
                            :use-die-falling #t
                            :use-victory #f
                            :use-jump-blocked #f
                            :debug-draw-neck #f
                            :jump-debug-draw #f
                            :move-to-ground #f
                            :hover-if-no-ground #f
                            :idle-anim-script #f
                            :idle-anim 4
                            :notice-anim 4
                            :hostile-anim 4
                            :hit-anim 12
                            :knocked-anim 10
                            :knocked-land-anim 11
                            :die-anim 14
                            :die-falling-anim 15
                            :victory-anim 4
                            :jump-wind-up-anim -1
                            :jump-in-air-anim -1
                            :jump-land-anim -1
                            :neck-joint 7
                            :look-at-joint 7
                            :bullseye-joint 4
                            :sound-hit (static-sound-name "wasp-hit")
                            :sound-die (static-sound-name "wasp-die")
                            :notice-distance (meters 70)
                            :notice-distance-delta (meters 10)
                            :proximity-notice-distance (meters 55)
                            :default-hit-points 6
                            :gnd-collide-with (collide-spec backgnd)
                            :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
                            :movement-gravity (meters -100)
                            :friction 0.8
                            :attack-shove-back (meters 3)
                            :attack-shove-up (meters 2)
                            :attack-mode 'generic
                            :attack-damage 2
                            :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 53248.0
                            :knocked-hard-vxz-hi 101580.8
                            :knocked-hard-vy-lo 60620.8
                            :knocked-hard-vy-hi 95027.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 10)
                            :shadow-min-y (meters -20)
                            :shadow-locus-dist (meters 150)
                            :gem-joint 7
                            :gem-offset (new 'static 'sphere :r 163840.0)
                            )
        )

(set! (-> *wasp-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

(defmethod general-event-handler ((this wasp) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  "Handles various events for the enemy
   @TODO - unsure if there is a pattern for the events and this should have a more specific name"
  (case arg2
    (('hit 'hit-knocked)
     (logclear! (-> this mask) (process-mask actor-pause))
     (logclear! (-> this focus-status) (focus-status dangerous))
     (logclear! (-> this enemy-flags) (enemy-flag use-notice-distance))
     (logior! (-> this enemy-flags) (enemy-flag alert))
     (logior! (-> this focus-status) (focus-status hit))
     (if (zero? (-> this hit-points))
         (logior! (-> this focus-status) (focus-status dead))
         )
     (logclear! (-> this enemy-flags) (enemy-flag lock-focus))
     (enemy-method-62 this)
     (logior! (-> this enemy-flags) (enemy-flag lock-focus))
     (process-contact-action arg0)
     (send-event arg0 'get-attack-count 1)
     (if (zero? (-> this hit-points))
         (go (method-of-object this die-explode))
         (go (method-of-object this knocked))
         )
     )
    (else
      ((method-of-type hover-enemy general-event-handler) this arg0 arg1 arg2 arg3)
      )
    )
  )

;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-52 ((this wasp) (arg0 vector))
  (let ((s4-0 (-> this root)))
    (case (-> this incoming knocked-type)
      (((knocked-type knocked-type-2))
       (let ((gp-1 (-> this root transv)))
         (let ((a1-1 (handle->process (-> this incoming attacker-handle))))
           (if a1-1
               (vector-! gp-1 (-> (the-as process-focusable a1-1) root trans) (-> this root trans))
               (vector-! gp-1 (-> this incoming attacker-pos) (-> this root trans))
               )
           )
         (set! (-> gp-1 y) 0.0)
         (vector-normalize! gp-1 1.0)
         (vector-rotate90-around-y! gp-1 gp-1)
         (if (< 0.0 (vector-dot
                      (vector-! (new 'stack-no-clear 'vector) (-> this incoming attacker-pos) (-> s4-0 trans))
                      (vector-x-quaternion! (new 'stack-no-clear 'vector) (-> s4-0 quat))
                      )
                )
             (vector-negate! gp-1 gp-1)
             )
         (let ((f30-1 (rnd-float-range this 0.0 1.0))
               (s5-1 (-> this enemy-info))
               )
           (vector-float*! gp-1 gp-1 (lerp (-> s5-1 knocked-hard-vxz-lo) (-> s5-1 knocked-hard-vxz-hi) f30-1))
           (set! (-> gp-1 y) (lerp (-> s5-1 knocked-hard-vy-lo) (-> s5-1 knocked-hard-vy-hi) f30-1))
           )
         )
       )
      (else
        (call-parent-method this arg0)
        )
      )
    )
  (none)
  )

;; WARN: Return type mismatch object vs none.
(defmethod go-idle ((this wasp))
  (cond
    ((logtest? (-> this fact enemy-options) (enemy-option user0))
     (go (method-of-object this shoot-bridge-wait))
     )
    ((logtest? (enemy-option ambush) (-> this fact enemy-options))
     (go (method-of-object this ambush))
     )
    (else
      (go (method-of-object this notice))
      )
    )
  (none)
  )

(defmethod go-hostile ((this wasp))
  (go (method-of-object this hostile))
  )

(defmethod react-to-focus ((this wasp))
  "@TODO - flesh out docs"
  (go-hostile this)
  )

;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-129 ((this wasp))
  (if (logtest? (-> this fact enemy-options) (enemy-option user0))
      (set! (-> this focus-pos quad) (-> this plat-pos quad))
      ((method-of-type hover-enemy enemy-method-129) this)
      )
  (none)
  )

(defmethod common-post ((this wasp))
  "Does a lot of various things relating to interacting with the target
   - tracks when the enemy was last drawn
   - looks at the target and handles attacking
   @TODO Not extremely well understood yet"
  (seek! (-> this gun-x-angle) (-> this gun-x-angle-final) (* 21845.334 (seconds-per-frame)))
  ((method-of-type hover-enemy common-post) this)
  (none)
  )

(defbehavior shoot-bridge-post wasp ()
  (get-point-at-percent-along-path! (-> self path) (-> self focus-pos) 0.5 'interp)
  (hover-nav-control-method-11 (-> self hover) (-> self focus-pos))
  (hover-enemy-dest-post)
  (none)
  )

(defstate dormant (wasp)
  :virtual #t
  :enter (behavior ()
    (if (logtest? (-> self fact enemy-options) (enemy-option user0))
        (go-virtual shoot-bridge-wait)
        )
    )
  )

(defstate ambush (wasp)
  :virtual #t
  :post (behavior ()
    (let ((t9-0 (-> (method-of-type hover-enemy ambush) post)))
      (if t9-0
          ((the-as (function none) t9-0))
          )
      )
    (set! (-> self last-fire-time) (+ (current-time) (seconds -1.5)))
    )
  )

(defstate notice (wasp)
  :virtual #t
  :post (behavior ()
    (let ((t9-0 (-> (method-of-type hover-enemy notice) post)))
      (if t9-0
          ((the-as (function none) t9-0))
          )
      )
    (set! (-> self last-fire-time) (+ (current-time) (seconds -1.5)))
    )
  )

(defstate shoot-bridge-wait (wasp)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('trigger)
       (go-virtual shoot-bridge-intro)
       )
      )
    )
  :enter (behavior ()
    (logior! (-> self enemy-flags) (enemy-flag cam-attack-mode))
    (hover-enemy-method-140 self #f)
    (if (logtest? (-> self path flags) (path-control-flag not-found))
        (go process-drawable-art-error "no path")
        )
    (hover-enemy-method-141 self 1.0)
    (hover-enemy-method-144 self)
    (let ((s5-0 (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 0.0 'interp))
          (s4-0 (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 1.0 'interp))
          (gp-0 (displacement-between-points-at-percent-normalized! (-> self path) (new 'stack-no-clear 'vector) 0.0))
          )
      (set! (-> self focus-pos quad) (-> s4-0 quad))
      (hover-nav-control-method-10 (-> self hover) s5-0 gp-0 (the-as vector #t))
      (set-vector! (-> self rotation-vec) 0.0 (vector-y-angle gp-0) 0.0 0.0)
      )
    (hover-enemy-method-146 self)
    (hover-nav-control-method-18 (-> self hover) (-> self path) -1 6)
    (set-time! (-> self last-fire-time))
    (set! (-> self bridge-index) 0)
    (logclear! (-> self enemy-flags) (enemy-flag vulnerable vulnerable-backup))
    (logclear! (-> self mask) (process-mask collectable))
    (logclear! (-> self enemy-flags) (enemy-flag attackable-backup))
    )
  :exit (behavior ()
    (let ((gp-0 (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 0.0 'interp))
          (v1-2 (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 1.0 'interp))
          )
      (hover-nav-control-method-10
        (-> self hover)
        gp-0
        (vector-normalize! (vector-! (new 'stack-no-clear 'vector) v1-2 gp-0) 1.0)
        (the-as vector #t)
        )
      )
    )
  :code sleep-code
  )

(defstate shoot-bridge-intro (wasp)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('shoot)
       (go-virtual shoot-bridge-hostile)
       )
      )
    )
  :enter (behavior ()
    (set! (-> self plat-pos quad) (-> self entity-group data 0 actor extra trans quad))
    )
  :trans (behavior ()
    (if (< (vector-vector-distance
             (-> self root trans)
             (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 6.0 'interp)
             )
           40960.0
           )
        (go-virtual shoot-bridge-hold)
        )
    )
  :code hover-enemy-fly-code
  :post (behavior ()
    (hover-nav-control-method-11 (-> self hover) (the-as vector #f))
    (hover-enemy-dest-post)
    )
  )

(defstate shoot-bridge-hold (wasp)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('shoot)
       (go-virtual shoot-bridge-hostile)
       )
      )
    )
  :code hover-enemy-fly-code
  :post (behavior ()
    (hover-nav-control-method-11 (-> self hover) (the-as vector #f))
    (hover-enemy-dest-post)
    )
  )

(defstate shoot-bridge-hostile (wasp)
  :virtual #t
  :exit (-> (method-of-type wasp ambush) exit)
  :trans (behavior ()
    (let ((v1-0 (-> self entity-group))
          (a0-0 (-> self bridge-index))
          )
      (cond
        ((< a0-0 (-> v1-0 length))
         (let ((a1-1 (-> v1-0 data a0-0 actor extra trans)))
           (set! (-> self plat-pos quad) (-> a1-1 quad))
           (+! (-> self plat-pos y) -8192.0)
           (set! (-> self focus-pos quad) (-> self plat-pos quad))
           (when (< (vector-vector-distance (-> self root trans) a1-1)
                    (- 327680.0 (* 81920.0 (the float (-> self bridge-index))))
                    )
             (+! (-> self bridge-index) 1)
             (go-virtual shoot-bridge-attack)
             )
           )
         )
        (else
          (go-virtual shoot-bridge-outro)
          )
        )
      )
    )
  :code hover-enemy-fly-code
  :post (behavior ()
    (let ((a1-0 (new 'stack-no-clear 'vector)))
      (set! (-> a1-0 quad) (-> self focus-pos quad))
      (+! (-> a1-0 z) 81920.0)
      (+! (-> a1-0 y) 40960.0)
      (hover-nav-control-method-11 (-> self hover) a1-0)
      )
    (hover-enemy-dest-post)
    )
  )

(defstate shoot-bridge-attack (wasp)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('event-attack)
       (let ((gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)))
         (set! (-> gp-0 ent) (-> self entity))
         (set! (-> gp-0 charge) 1.0)
         (set! (-> gp-0 options) (projectile-options))
         (set! (-> gp-0 notify-handle) (the-as handle #f))
         (set! (-> gp-0 owner-handle) (the-as handle #f))
         (set! (-> gp-0 ignore-handle) (process->handle self))
         (let* ((v1-6 *game-info*)
                (a0-6 (+ (-> v1-6 attack-id) 1))
                )
           (set! (-> v1-6 attack-id) a0-6)
           (set! (-> gp-0 attack-id) a0-6)
           )
         (set! (-> gp-0 timeout) (seconds 4))
         (spawn-wasp-shot self gp-0 19 0.000000000000000000000000000000000000000000024 -1.0)
         (spawn-wasp-shot self gp-0 23 0.00000000000000000000000000000000000000000003 1.0)
         )
       (sound-play "wasp-fire" :position (-> self root trans))
       )
      (else
        (enemy-event-handler proc argc message block)
        )
      )
    )
  :enter (behavior ()
    (set-time! (-> self state-time))
    (set! (-> self attack-miss-dist-curr) (-> self attack-miss-dist-min))
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.2))
    (sound-play "wasp-warn" :position (-> self root trans))
    (ja-no-eval :group! (-> self draw art-group data (-> self hover-info shoot-anim))
                :num! (seek!)
                :frame-num 0.0
                )
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (set-time! (-> self last-fire-time))
    (set! (-> self restart-fly-anims) #t)
    (go-virtual shoot-bridge-hostile)
    )
  :post (behavior ()
    (let* ((a1-0 (-> self node-list data (-> self hover-info gun-base)))
           (a0-2 (vector<-cspace! (new 'stack-no-clear 'vector) a1-0))
           (gp-0 (new 'stack-no-clear 'vector))
           )
      (let ((v1-4 (new 'stack-no-clear 'vector)))
        (set! (-> v1-4 quad) (-> self focus-pos quad))
        (+! (-> v1-4 y) (-> self attack-miss-dist-curr))
        (vector-! gp-0 v1-4 a0-2)
        )
      (vector-normalize! gp-0 1.0)
      (set! (-> self gun-x-angle-final) (- (vector-x-angle gp-0)))
      )
    (quaternion-vector-angle! (the-as quaternion (-> self gun-jmod target)) *x-vector* (-> self gun-x-angle))
    (seek!
      (-> self attack-miss-dist-curr)
      (-> self attack-miss-dist-max)
      (* 0.5 (seconds-per-frame) (- (-> self attack-miss-dist-max) (-> self attack-miss-dist-min)))
      )
    (let ((a1-8 (new 'stack-no-clear 'vector)))
      (set! (-> a1-8 quad) (-> self focus-pos quad))
      (+! (-> a1-8 z) 81920.0)
      (+! (-> a1-8 y) 40960.0)
      (hover-nav-control-method-11 (-> self hover) a1-8)
      )
    (hover-enemy-dest-post)
    )
  )

(defstate shoot-bridge-outro (wasp)
  :virtual #t
  :enter (behavior ()
    (let ((v1-1 (-> self root root-prim)))
      (set! (-> v1-1 prim-core collide-as) (collide-spec))
      (set! (-> v1-1 prim-core collide-with) (collide-spec))
      )
    0
    (hover-nav-control-method-18 (-> self hover) (-> self path) 7 -1)
    (let ((gp-0 (get-point-at-percent-along-path! (-> self path) (new 'stack-no-clear 'vector) 1.0 'interp))
          (v1-7 (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 8.0 'interp))
          )
      (set! (-> self focus-pos quad) (-> gp-0 quad))
      (hover-nav-control-method-10
        (-> self hover)
        v1-7
        (vector-normalize! (vector-! (new 'stack-no-clear 'vector) v1-7 (-> self root trans)) 1.0)
        (the-as vector #t)
        )
      )
    (set-time! (-> self state-time))
    )
  :trans (behavior ()
    (when (< (vector-vector-distance
               (-> self root trans)
               (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) (get-num-segments (-> self path)) 'interp)
               )
             8192.0
             )
      (cleanup-for-death self)
      (go empty-state)
      )
    )
  :code hover-enemy-fly-code
  :post (behavior ()
    (if (not (hover-nav-control-method-23 (-> self hover)))
        (hover-nav-control-method-11 (-> self hover) (the-as vector #f))
        (hover-nav-control-method-11
          (-> self hover)
          (get-point-at-percent-along-path! (-> self path) (new 'stack-no-clear 'vector) 1.0 'interp)
          )
        )
    (hover-enemy-dest-post)
    )
  )

(defstate hostile (wasp)
  :virtual #t
  :trans (behavior ()
    (let ((gp-0 (ja-group))
          (f0-0 (ja-aframe-num 0))
          )
      (when (and (= gp-0 wasp-idle-ja)
                 (or (and (>= f0-0 0.0) (>= 1.0 f0-0))
                     (and (>= f0-0 16.0)
                          (>= (the float (+ (-> (the-as art-joint-anim wasp-idle-ja) frames num-frames) -1)) (ja-frame-num 0))
                          )
                     )
                 )
        (if (and (time-elapsed?
                   (-> self last-fire-time)
                   (the int (* 300.0 (rand-vu-float-range (-> self attack-wait-min) (-> self attack-wait-max))))
                   )
                 (get-enemy-target self)
                 )
            (go-virtual attack)
            )
        )
      )
    )
  )

(defstate attack (wasp)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('event-attack)
       (let ((gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)))
         (set! (-> gp-0 ent) (-> self entity))
         (set! (-> gp-0 charge) 1.0)
         (set! (-> gp-0 options) (projectile-options))
         (set! (-> gp-0 notify-handle) (the-as handle #f))
         (set! (-> gp-0 owner-handle) (the-as handle #f))
         (set! (-> gp-0 ignore-handle) (process->handle self))
         (let* ((v1-6 *game-info*)
                (a0-6 (+ (-> v1-6 attack-id) 1))
                )
           (set! (-> v1-6 attack-id) a0-6)
           (set! (-> gp-0 attack-id) a0-6)
           )
         (set! (-> gp-0 timeout) (seconds 4))
         (spawn-wasp-shot self gp-0 19 0.000000000000000000000000000000000000000000024 -1.0)
         (spawn-wasp-shot self gp-0 23 0.00000000000000000000000000000000000000000003 1.0)
         )
       (sound-play "wasp-fire" :position (-> self root trans))
       )
      (else
        (enemy-event-handler proc argc message block)
        )
      )
    )
  :enter (behavior ()
    (set-time! (-> self state-time))
    (set! (-> self attack-miss-dist-curr) (-> self attack-miss-dist-min))
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.2))
    (sound-play "wasp-warn" :position (-> self root trans))
    (ja-no-eval :group! (-> self draw art-group data (-> self hover-info shoot-anim))
                :num! (seek!)
                :frame-num 0.0
                )
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (set-time! (-> self last-fire-time))
    (set! (-> self restart-fly-anims) #t)
    (go-hostile self)
    )
  :post (behavior ()
    (let* ((a1-0 (-> self node-list data (-> self hover-info gun-base)))
           (a0-2 (vector<-cspace! (new 'stack-no-clear 'vector) a1-0))
           (gp-0 (new 'stack-no-clear 'vector))
           )
      (let ((v1-4 (new 'stack-no-clear 'vector)))
        (set! (-> v1-4 quad) (-> self focus-pos quad))
        (+! (-> v1-4 y) (-> self attack-miss-dist-curr))
        (vector-! gp-0 v1-4 a0-2)
        )
      (vector-normalize! gp-0 1.0)
      (set! (-> self gun-x-angle-final) (- (vector-x-angle gp-0)))
      )
    (quaternion-vector-angle! (the-as quaternion (-> self gun-jmod target)) *x-vector* (-> self gun-x-angle))
    (seek!
      (-> self attack-miss-dist-curr)
      (-> self attack-miss-dist-max)
      (* 0.5 (seconds-per-frame) (- (-> self attack-miss-dist-max) (-> self attack-miss-dist-min)))
      )
    (hover-enemy-hostile-post)
    )
  )

(defstate knocked-recover (wasp)
  :virtual #t
  :event enemy-event-handler
  :code (behavior ()
    (local-vars (v1-35 enemy-flag) (v1-43 enemy-flag))
    (ja-channel-push! 1 (seconds 0.5))
    (ja-no-eval :group! (-> self draw art-group data (-> self knocked-recover-anim)) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (set! (-> self restart-fly-anims) #t)
    (if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
        (logior! (-> self focus-status) (focus-status dangerous))
        (logclear! (-> self focus-status) (focus-status dangerous))
        )
    (let ((v1-34 (-> self enemy-flags)))
      (if (logtest? v1-34 (enemy-flag vulnerable-backup))
          (set! v1-35 (logior v1-34 (enemy-flag vulnerable)))
          (set! v1-35 (logclear v1-34 (enemy-flag vulnerable)))
          )
      )
    (set! (-> self enemy-flags) v1-35)
    (if (logtest? (-> self enemy-flags) (enemy-flag attackable-backup))
        (logior! (-> self mask) (process-mask collectable))
        (logclear! (-> self mask) (process-mask collectable))
        )
    (let ((v1-42 (-> self enemy-flags)))
      (if (logtest? (enemy-flag trackable-backup) v1-42)
          (set! v1-43 (logior (enemy-flag trackable) v1-42))
          (set! v1-43 (logclear v1-42 (enemy-flag trackable)))
          )
      )
    (set! (-> self enemy-flags) v1-43)
    (logclear! (-> self enemy-flags) (enemy-flag lock-focus))
    (logclear! (-> self focus-status) (focus-status hit))
    (hover-nav-control-method-21 (-> self hover))
    (go-hostile self)
    )
  )

(defstate die-explode (wasp)
  :virtual #t
  :event enemy-event-handler
  :code (behavior ()
    (dying self)
    (set! (-> self hit-points) 0)
    (let ((v1-3 (-> self root root-prim)))
      (set! (-> v1-3 prim-core collide-as) (collide-spec))
      (set! (-> v1-3 prim-core collide-with) (collide-spec))
      )
    0
    (logior! (-> self draw status) (draw-control-status no-draw))
    (sound-stop (-> self sound-id))
    (sound-play "wasp-explode")
    (let ((gp-1 (new 'stack 'joint-exploder-tuning (the-as uint 0))))
      (process-spawn
        joint-exploder
        (art-group-get-by-name *level* "skel-wasp-explode" (the-as (pointer uint32) #f))
        22
        gp-1
        *wasp-exploder-params*
        :to self
        )
      )
    (let ((gp-2 (get-process *default-dead-pool* part-tracker #x4000)))
      (when gp-2
        (let ((t9-10 (method-of-type part-tracker activate)))
          (t9-10 (the-as part-tracker gp-2) self (symbol->string (-> part-tracker symbol)) (the-as pointer #x70004000))
          )
        (let ((t9-11 run-function-in-process)
              (a0-12 gp-2)
              (a1-8 part-tracker-init)
              (a2-12 (-> *part-group-id-table* 157))
              (a3-4 0)
              (t0-2 #f)
              (t1-2 #f)
              (t2-1 #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-11)
           a0-12
           a1-8
           a2-12
           a3-4
           t0-2
           t1-2
           t2-1
           t3-0
           )
          )
        (-> gp-2 ppointer)
        )
      )
    (while (-> self child)
      (suspend)
      )
    (cleanup-for-death self)
    )
  )

(defstate die-now (wasp)
  :virtual #t
  :event enemy-event-handler
  :code (behavior ()
    (dying self)
    (let ((v1-3 (-> self root root-prim)))
      (set! (-> v1-3 prim-core collide-as) (collide-spec))
      (set! (-> v1-3 prim-core collide-with) (collide-spec))
      )
    0
    (set! (-> self hit-points) 0)
    (do-effect (-> self skel effect) 'death-default 0.0 -1)
    (suspend-for (seconds 1)
      )
    (send-event self 'death-end)
    (cleanup-for-death self)
    )
  :post transform-post
  )

;; WARN: Return type mismatch process vs process-focusable.
(defmethod get-enemy-target ((this wasp))
  "@returns the [[process-focusable]] that the enemy is currently focusing on, or [[#f]] otherwise"
  (let ((s5-0 (handle->process (-> this focus handle))))
    (the-as
      process-focusable
      (when s5-0
        (let* ((a0-4 (-> this root))
               (s4-1 (vector+! (new 'stack-no-clear 'vector) (-> a0-4 trans) (-> a0-4 transv)))
               (s3-1 (vector-! (new 'stack-no-clear 'vector) s4-1 (-> this focus-pos)))
               (s2-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) (get-quat (the-as process-focusable s5-0) 0)))
               (s3-2 (vector-normalize-copy! (new 'stack-no-clear 'vector) s3-1 1.0))
               )
          (if (and (and s5-0
                        (not (logtest? (-> (the-as process-focusable s5-0) focus-status) (focus-status disable dead ignore grabbed)))
                        )
                   (< 0.0 (vector-dot s2-1 s3-2))
                   (< (vector-vector-distance s4-1 (-> this focus-pos)) 225280.0)
                   (and (< (fabs (vector-x-angle s3-2)) 3640.889) (enemy-method-95 this (-> this focus-pos) 5461.3335))
                   )
              s5-0
              )
          )
        )
      )
    )
  )

(defmethod enemy-method-77 ((this wasp) (arg0 enemy-knocked-info))
  (cond
    ((rnd-percent? this 0.5)
     (set! (-> this knocked-anim) 10)
     (set! (-> this knocked-recover-anim) 11)
     )
    (else
      (set! (-> this knocked-anim) 12)
      (set! (-> this knocked-recover-anim) 13)
      )
    )
  (ja-channel-push! 1 0)
  (let ((a1-3 (-> this draw art-group data (-> this knocked-anim)))
        (a0-5 (-> this skel root-channel 0))
        )
    (set! (-> a0-5 frame-group) (the-as art-joint-anim a1-3))
    (set! (-> a0-5 param 0) (the float (+ (-> (the-as art-joint-anim a1-3) frames num-frames) -1)))
    (set! (-> a0-5 param 1) (-> arg0 anim-speed))
    (set! (-> a0-5 frame-num) 0.0)
    (joint-control-channel-group! a0-5 (the-as art-joint-anim a1-3) num-func-seek!)
    )
  #t
  )

(defmethod enemy-method-78 ((this wasp) (arg0 enemy-knocked-info))
  (let ((v1-4 (-> this draw art-group data (-> this enemy-info knocked-land-anim)))
        (a0-3 (-> this skel root-channel 0))
        )
    (set! (-> a0-3 frame-group) (the-as art-joint-anim v1-4))
    (set! (-> a0-3 param 0) (the float (+ (-> (the-as art-joint-anim v1-4) frames num-frames) -1)))
    (set! (-> a0-3 param 1) (-> arg0 anim-speed))
    (set! (-> a0-3 frame-num) 0.0)
    (joint-control-channel-group! a0-3 (the-as art-joint-anim v1-4) num-func-seek!)
    )
  #t
  )

(defmethod enemy-method-80 ((this wasp) (arg0 enemy-knocked-info))
  (-> this root)
  (>= (-> arg0 on-surface-count) 1)
  )

(defmethod enemy-method-81 ((this wasp))
  #f
  )

(defmethod kill-prefer-falling ((this wasp))
  "If available in `enemy-info`, [[go]] to the [[die-falling]] state, if not, [[die]]"
  (cond
    ((and (-> this next-state) (= (-> this next-state name) 'knocked))
     (go (method-of-object this die-now))
     )
    ((-> this enemy-info use-die-falling)
     (go (method-of-object this die-falling))
     )
    (else
      (go (method-of-object this die))
      )
    )
  )

(defmethod spawn-wasp-shot ((this wasp) (arg0 projectile-init-by-other-params) (arg1 int) (arg2 float) (arg3 float))
  (vector<-cspace! (-> arg0 pos) (-> this node-list data arg1))
  (let ((s3-1 (quaternion-vector-angle!
                (new 'stack-no-clear 'quaternion)
                (vector-normalize-copy!
                  (new 'stack-no-clear 'vector)
                  (-> this node-list data arg1 bone transform vector 1)
                  1.0
                  )
                (* 273.06668 arg3)
                )
              )
        (a1-8 (vector-normalize-copy!
                (new 'stack-no-clear 'vector)
                (-> this node-list data arg1 bone transform vector 2)
                1.0
                )
              )
        )
    (vector-orient-by-quat! (-> arg0 vel) a1-8 s3-1)
    )
  (vector-normalize! (-> arg0 vel) 491520.0)
  (spawn-projectile wasp-shot arg0 this *default-dead-pool*)
  0
  (none)
  )

(defmethod hover-enemy-method-142 ((this wasp))
  (let ((s5-0 (-> this main-joint-acc))
        (s4-0 (-> this main-joint-vel))
        (gp-0
          (lambda ((arg0 wasp) (arg1 cspace) (arg2 float) (arg3 float) (arg4 vector) (arg5 vector) (arg6 int))
            (local-vars (sv-192 float) (sv-208 quaternion) (sv-224 vector))
            (set! sv-192 arg2)
            (let ((s0-0 arg3))
              (set! sv-224 arg4)
              (let ((s1-0 arg5)
                    (s3-0 arg6)
                    (s4-0 (vector<-cspace! (new 'stack-no-clear 'vector) arg1))
                    (s5-0 (new 'stack-no-clear 'matrix))
                    (a1-3 (matrix-with-scale->quaternion (new 'stack-no-clear 'quaternion) (-> arg1 bone transform)))
                    )
                (set! sv-208 (new 'stack-no-clear 'quaternion))
                (let ((s2-1 (new 'stack-no-clear 'vector)))
                  (-> arg0 scale)
                  (quaternion-rotate-local-z! sv-208 a1-3 sv-192)
                  (quaternion->matrix s5-0 sv-208)
                  (set! (-> s2-1 quad) (-> arg0 root scale quad))
                  (scale-matrix! s5-0 s2-1 s5-0)
                  (let* ((s1-1 (vector-inv-orient-by-quat! (new 'stack-no-clear 'vector) s1-0 (-> arg0 root quat)))
                         (t9-6 vector-inv-orient-by-quat!)
                         (a0-10 (new 'stack-no-clear 'vector))
                         (a2-4 (-> arg0 root quat))
                         (v0-6 (t9-6 a0-10 sv-224 a2-4))
                         (f30-0 (* 2457600.0 (seconds-per-frame)))
                         (f28-0
                           (seek
                             (-> arg0 thrust s3-0)
                             (+ (* 0.4 (fmax 0.0 (* (-> v0-6 x) s0-0)))
                                (fmax 0.0 (-> v0-6 y))
                                (fabs (/ (-> v0-6 z) 5))
                                (fmax 0.0 (-> s1-1 y))
                                )
                             (/ f30-0 5)
                             )
                           )
                         )
                    (let ((f20-0 (lerp-scale 819.2 4096.0 f28-0 1638.4 f30-0))
                          (f26-0 (lerp-scale 4915.2 11468.8 f28-0 1638.4 f30-0))
                          )
                      (lerp-scale 0.0 -4915.2 f28-0 1638.4 f30-0)
                      (let ((f22-0 (lerp-scale 0.5 1.5 f28-0 1638.4 f30-0))
                            (f24-0 (lerp-scale 0.1 1.0 f28-0 1638.4 f30-0))
                            )
                        (lerp-scale 0.1 1.0 f28-0 1638.4 f30-0)
                        (let ((f1-10 (lerp-scale 0.02 0.6 f28-0 1638.4 f30-0))
                              (f2-6 (fmin 1.0 (-> s2-1 x)))
                              (f0-15 (fmin 1.0 (-> s2-1 y)))
                              )
                          (set! (-> *part-id-table* 718 init-specs 4 initial-valuef) (* f20-0 f2-6))
                          (set! (-> *part-id-table* 718 init-specs 5 initial-valuef) (* f26-0 f0-15))
                          (set! (-> *part-id-table* 722 init-specs 3 initial-valuef) (* f22-0 f2-6))
                          (set! (-> *part-id-table* 719 init-specs 1 initial-valuef) (* f24-0 f0-15))
                          (set! (-> *part-id-table* 720 init-specs 1 initial-valuef) (* f1-10 f0-15))
                          (set! (-> *part-id-table* 721 init-specs 0 initial-valuef) (* f24-0 f0-15))
                          (set! (-> arg0 thrust s3-0) f28-0)
                          (let ((f0-16 (* f26-0 f0-15)))
                            (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> s5-0 vector 1) (/ f0-16 -2))
                            )
                          )
                        )
                      )
                    (set! (-> s5-0 trans quad) (-> s4-0 quad))
                    (spawn-with-matrix (-> arg0 engine-part) s5-0)
                    (let ((f0-18 (lerp-scale 0.75 1.0 f28-0 1638.4 f30-0)))
                      (sound-play-by-name
                        (static-sound-name "wasp-jets")
                        (-> arg0 sound-id)
                        (the int (* 1024.0 f0-18))
                        0
                        0
                        (sound-group sfx)
                        (-> arg0 root trans)
                        )
                      )
                    )
                  )
                )
              )
            0
            (none)
            )
          )
        )
    (gp-0
      this
      (-> this node-list data (-> this hover-info engine-left))
      (-> this hover-info thrust-rotate-left)
      -1.0
      s5-0
      s4-0
      0
      )
    (gp-0
      this
      (-> this node-list data (-> this hover-info engine-right))
      (-> this hover-info thrust-rotate-right)
      1.0
      s5-0
      s4-0
      1
      )
    )
  0
  (none)
  )

(defmethod init-enemy-collision! ((this wasp))
  "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)
          )
    (set! (-> s5-0 penetrated-by) (penetrate
                                    generic-attack
                                    lunge
                                    flop
                                    punch
                                    spin
                                    roll
                                    uppercut
                                    bonk
                                    tube
                                    vehicle
                                    flut-attack
                                    board
                                    mech-punch
                                    dark-punch
                                    dark-giant
                                    )
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 10) 0)))
      (set! (-> s5-0 total-prims) (the-as uint 11))
      (set! (-> s4-0 prim-core collide-as) (collide-spec enemy))
      (set! (-> s4-0 prim-core collide-with) (collide-spec backgnd))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 transform-index) 3)
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 15564.8)
      (set! (-> s5-0 root-prim) s4-0)
      )
    (let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-14 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-14 prim-core collide-with) (collide-spec backgnd))
      (set! (-> v1-14 prim-core action) (collide-action solid))
      (set! (-> v1-14 transform-index) 0)
      (set-vector! (-> v1-14 local-sphere) 0.0 5324.8 -2048.0 6144.0)
      )
    (let ((v1-16 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-16 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-16 prim-core collide-with) (collide-spec backgnd))
      (set! (-> v1-16 prim-core action) (collide-action solid))
      (set! (-> v1-16 transform-index) 0)
      (set-vector! (-> v1-16 local-sphere) 0.0 3276.8 -2048.0 4915.2)
      )
    (let ((v1-18 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-18 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-18 prim-core collide-with) (collide-spec backgnd))
      (set! (-> v1-18 prim-core action) (collide-action solid))
      (set! (-> v1-18 transform-index) 0)
      (set-vector! (-> v1-18 local-sphere) 0.0 7372.8 -2048.0 4915.2)
      )
    (let ((v1-20 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-20 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-20 prim-core action) (collide-action semi-solid))
      (set! (-> v1-20 transform-index) 3)
      (set-vector! (-> v1-20 local-sphere) 0.0 0.0 1228.8 3481.6)
      )
    (let ((v1-22 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-22 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-22 prim-core action) (collide-action semi-solid))
      (set! (-> v1-22 transform-index) 7)
      (set-vector! (-> v1-22 local-sphere) 0.0 0.0 0.0 3072.0)
      )
    (let ((v1-24 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-24 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-24 prim-core action) (collide-action semi-solid))
      (set! (-> v1-24 transform-index) 9)
      (set-vector! (-> v1-24 local-sphere) 0.0 1638.4 0.0 2048.0)
      )
    (let ((v1-26 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-26 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-26 prim-core action) (collide-action semi-solid))
      (set! (-> v1-26 transform-index) 10)
      (set-vector! (-> v1-26 local-sphere) -819.2 0.0 0.0 1638.4)
      )
    (let ((v1-28 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-28 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-28 prim-core action) (collide-action semi-solid))
      (set! (-> v1-28 transform-index) 12)
      (set-vector! (-> v1-28 local-sphere) 0.0 -1638.4 0.0 2048.0)
      )
    (let ((v1-30 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-30 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-30 prim-core action) (collide-action semi-solid))
      (set! (-> v1-30 transform-index) 13)
      (set-vector! (-> v1-30 local-sphere) 819.2 0.0 0.0 1638.4)
      )
    (let ((v1-32 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-32 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-32 prim-core action) (collide-action semi-solid))
      (set! (-> v1-32 transform-index) 15)
      (set-vector! (-> v1-32 local-sphere) 0.0 0.0 0.0 3072.0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (let ((v1-35 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-35 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-35 prim-core collide-with))
      )
    (set! (-> s5-0 max-iteration-count) (the-as uint 3))
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

(defmethod deactivate ((this wasp))
  "Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
  (if (nonzero? (-> this smoke-part))
      (kill-and-free-particles (-> this smoke-part))
      )
  (if (nonzero? (-> this engine-part))
      (kill-and-free-particles (-> this engine-part))
      )
  (sound-stop (-> this sound-id))
  ((method-of-type hover-enemy deactivate) this)
  (none)
  )

;; WARN: Return type mismatch hover-enemy vs wasp.
(defmethod relocate ((this wasp) (offset int))
  (if (nonzero? (-> this gun-jmod))
      (&+! (-> this gun-jmod) offset)
      )
  (if (nonzero? (-> this smoke-part))
      (&+! (-> this smoke-part) offset)
      )
  (if (nonzero? (-> this engine-part))
      (&+! (-> this engine-part) offset)
      )
  (the-as wasp ((method-of-type hover-enemy relocate) this offset))
  )

(defmethod hover-enemy-method-149 ((this wasp))
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-wasp" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  0
  (none)
  )

(defmethod hover-enemy-method-150 ((this wasp))
  *wasp-enemy-info*
  )

(defmethod hover-enemy-method-151 ((this wasp))
  (new 'static 'hover-enemy-info
    :fly-forward-anim 7
    :fly-backward-anim 8
    :fly-left-anim 6
    :fly-right-anim 5
    :shoot-anim 9
    :main-joint 3
    :gun-base 15
    :engine-left 10
    :engine-right 13
    :thrust-rotate-left 16384.0
    :thrust-rotate-right -16384.0
    )
  )

(defmethod hover-enemy-method-152 ((this wasp))
  (new 'static 'hover-nav-params :max-speed 73728.0 :max-acceleration 122880.0 :friction 0.05)
  )

(defmethod init-enemy! ((this wasp))
  "Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
  (local-vars (sv-16 res-tag) (sv-32 res-tag) (sv-48 res-tag) (sv-64 res-tag))
  (hover-enemy-method-149 this)
  (init-enemy-behaviour-and-stats! this (hover-enemy-method-150 this))
  (hover-enemy-method-155 this)
  (set! (-> this neck up) (the-as uint 1))
  (set! (-> this neck nose) (the-as uint 2))
  (set! (-> this neck ear) (the-as uint 0))
  (set! (-> this scale) (rnd-float-range this 0.9 1.3))
  (set! (-> this sound-id) (new-sound-id))
  (set! (-> this root dynam gravity y) 327680.0)
  (set! (-> this root dynam gravity-length) 327680.0)
  (set! (-> this root dynam gravity-max) 327680.0)
  (set! (-> this gun-jmod)
        (the-as joint-mod (new 'process 'joint-mod-rotate-local this (-> this hover-info gun-base) #t))
        )
  (set! (-> this gun-x-angle) 0.0)
  (set! (-> this gun-x-angle-final) 0.0)
  (logclear! (-> this mask) (process-mask actor-pause))
  (logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
  (set! sv-16 (new 'static 'res-tag))
  (let ((v1-28 (res-lump-data (-> this entity) 'actor-groups (pointer actor-group) :tag-ptr (& sv-16))))
    (if (and v1-28 (= (-> sv-16 elt-count) 1))
        (set! (-> this entity-group) (-> v1-28 0))
        (set! (-> this entity-group) #f)
        )
    )
  (set! sv-32 (new 'static 'res-tag))
  (let ((v1-32 (res-lump-data (-> this entity) 'timeout (pointer float) :tag-ptr (& sv-32))))
    (cond
      ((and v1-32 (= (-> sv-32 elt-count) 2))
       (set! (-> this attack-wait-min) (-> v1-32 0))
       (set! (-> this attack-wait-max) (-> v1-32 1))
       )
      (else
        (set! (-> this attack-wait-min) 1.0)
        (set! (-> this attack-wait-max) 3.0)
        )
      )
    )
  (let ((f30-0 4096.0))
    (set! sv-48 (new 'static 'res-tag))
    (let ((v1-39 (res-lump-data (-> this entity) 'min-max (pointer float) :tag-ptr (& sv-48))))
      (set! (-> this attack-miss-dist-min) (* f30-0 (if (and v1-39 (> (the-as int (-> sv-48 elt-count)) 0))
                                                        (-> v1-39 0)
                                                        -1.0
                                                        )
                                              )
            )
      )
    )
  (let ((f30-1 4096.0))
    (set! sv-64 (new 'static 'res-tag))
    (let ((v1-43 (res-lump-data (-> this entity) 'min-max (pointer float) :tag-ptr (& sv-64))))
      (set! (-> this attack-miss-dist-max) (* f30-1 (if (and v1-43 (< 1 (the-as int (-> sv-64 elt-count))))
                                                        (-> v1-43 1)
                                                        1.0
                                                        )
                                              )
            )
      )
    )
  (set! (-> this path) (new 'process 'path-control this 'intro 0.0 (-> this entity) #f))
  (set! (-> this path-u) 0.0)
  (logior! (-> this path flags) (path-control-flag display draw-line draw-point draw-text))
  (set! (-> this smoke-part) (create-launch-control (-> *part-group-id-table* 154) this))
  (set! (-> this engine-part) (create-launch-control (-> *part-group-id-table* 156) this))
  (add-connection
    *part-engine*
    this
    7
    this
    318
    (new 'static 'vector :x 1187.84 :y -3112.96 :z 1392.64 :w 163840.0)
    )
  (add-connection
    *part-engine*
    this
    7
    this
    318
    (new 'static 'vector :x -1187.84 :y -3112.96 :z 1392.64 :w 163840.0)
    )
  (add-connection *part-engine* this 7 this 743 (new 'static 'vector :y 1433.6 :z 1228.8 :w 163840.0))
  0
  (none)
  )
