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

;; name: terraformer-drone.gc
;; name in dgo: terraformer-drone
;; dgos: DESW, DESBOSS1, DESBOSS2

(define-extern *range-terraformer-drone-explo-color* curve-color-fast)
(define-extern *range-terraformer-drone-explo-alpha* curve2d-fast)
(define-extern *range-terraformer-drone-explo-scale-x* curve2d-fast)
(define-extern *range-terraformer-drone-explo-scale-y* curve2d-fast)
(define-extern *curve-terraformer-drone-explo-alpha* curve2d-fast)
(define-extern *curve-terraformer-drone-explo-scale-x* curve2d-fast)
(define-extern *curve-terraformer-drone-explo-scale-y* curve2d-fast)

;; DECOMP BEGINS

(defpartgroup group-terraformer-drone-explosion
  :id 428
  :duration (seconds 4)
  :flags (sp0 sp5)
  :bounds (static-bspherem 0 0 0 15)
  :parts ((sp-item 1716 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1717 :fade-after (meters 400) :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1718 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 1719 :period (seconds 30) :length (seconds 0.167))
    (sp-item 1720 :period (seconds 30) :length (seconds 0.5))
    (sp-item 1721 :falloff-to (meters 400) :period (seconds 30) :length (seconds 0.035))
    (sp-item 1722 :falloff-to (meters 400) :period (seconds 30) :length (seconds 0.067))
    (sp-item 1723 :falloff-to (meters 400) :period (seconds 30) :length (seconds 0.167) :offset 100)
    )
  )

(defpart 1722
  :init-specs ((:texture (water-drops level-default-sprite))
    (:num 20.0)
    (:x (meters 0) (meters 2))
    (:scale-x (meters 1) (meters 1))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 128.0)
    (:omega (degrees 0.225))
    (:vel-y (meters 0.033333335) (meters 0.13333334))
    (:scalevel-x (meters 0.0033333334) (meters 0.0016666667))
    (:scalevel-y :copy scalevel-x)
    (:accel-y (meters -0.0033333334))
    (:friction 0.99)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13))
    (:userdata :data (new 'static 'boxed-array :type int32 5 1 0 #x406500 #x404a00))
    (:func 'sparticle-motion-blur)
    (:next-time (seconds 0.4))
    (:next-launcher 1724)
    (:conerot-x (degrees 0) (degrees 20))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1724
  :init-specs ((:rotvel-z (degrees -0.2) (degrees 0.4)) (:fade-a -0.256) (:friction 0.95 0.04) (:func 'nothing))
  )

(defpart 1723
  :init-specs ((:texture (dirtpuff01 level-default-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 2.0)
    (:x (meters 0) (meters 5))
    (:y (meters 8) (meters 5))
    (:scale-x (meters 1) (meters 2))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 0.0)
    (:scalevel-x (meters 0.0033333334) (meters 0.006666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 0.16 0.16)
    (:accel-y (meters -0.001))
    (:friction 0.94 0.04)
    (:timer (seconds 4))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13))
    (:userdata :data (new 'static 'boxed-array :type int32 10 1 0 #x67500d00 #x405c00))
    (:next-time (seconds 0.5))
    (:next-launcher 1725)
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1725
  :init-specs ((:fade-a -0.03047619 -0.03047619))
  )

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(defpartgroup group-beast-terraformer-drone-glow
  :id 429
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 40)
  :parts ((sp-item 1726 :flags (sp6)))
  )

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

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

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

(defpartgroup group-terraformer-drone-dust-up
  :id 430
  :duration (seconds 0.017)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 12)
  :parts ((sp-item 1729 :falloff-to (meters 400) :flags (sp7)) (sp-item 1730 :falloff-to (meters 400) :flags (sp7)))
  )

(defpart 1729
  :init-specs ((:texture (rockbit01 level-default-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 2.0 1.0)
    (:scale-x (meters 0.5) (meters 0.2))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y (meters 0.5) (meters 0.2))
    (:r 64.0)
    (:g 40.0)
    (:b 20.0)
    (:a 128.0)
    (:vel-y (meters 0.016666668) (meters 0.16666667))
    (:rotvel-z (degrees -4) (degrees 8))
    (:accel-y (meters -0.0016666667) (meters -0.00033333333))
    (:timer (seconds 1.5))
    (:flags (sp-cpuinfo-flag-13 launch-along-z))
    (:userdata :data (new 'static 'boxed-array :type int32 20 1 0 #x408b00 #x40a200 #x40a600 #x40aa00))
    (:conerot-x (degrees 0) (degrees 20))
    (:rotate-z (degrees 0) (degrees 3600))
    )
  )

(defpart 1730
  :init-specs ((:texture (big-cloud level-default-sprite))
    (:num 0.4)
    (:scale-x (meters 1) (meters 2))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y :copy scale-x)
    (:r 140.0)
    (:g 120.0)
    (:b 90.0)
    (:a 64.0 64.0)
    (:vel-y (meters 0.033333335) (meters 0.06666667))
    (:scalevel-x (meters 0.016666668) (meters 0.033333335))
    (:rotvel-z (degrees -0.1) (degrees 0.2))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.17066666)
    (:friction 0.99)
    (:timer (seconds 2.5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13 launch-along-z))
    (:conerot-x (degrees 0) (degrees 40))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1731
  :init-specs ((:texture (redpuff level-default-sprite))
    (:num 3.0 5.0)
    (:scale-x (meters 2) (meters 2))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 128.0)
    (:b 0.0)
    (:a 32.0 32.0)
    (:vel-y (meters -0.006666667) (meters -0.006666667))
    (:scalevel-x (meters -0.006666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-r -3.2)
    (:fade-g -1.6)
    (:fade-b -3.2)
    (:accel-y (meters 0.0001) (meters 0.000033333334))
    (:friction 0.97)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2))
    (:next-time (seconds 0.267))
    (:next-launcher 1732)
    )
  )

(defpart 1732
  :init-specs ((:fade-r 0.0) (:fade-g 0.0) (:fade-b 0.0) (:fade-a -0.10666667 -0.10666667))
  )

(defpartgroup group-terraformer-drone-impact
  :id 431
  :flags (sp0 sp4)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 1733 :flags (sp7) :period (seconds 2) :length (seconds 0.017)))
  )

(defpart 1733
  :init-specs ((:texture (big-cloud level-default-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 10.0)
    (:scale-x (meters 1) (meters 0.25))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 64.0 128.0)
    (:g :copy r)
    (:b :copy r)
    (:a 32.0 32.0)
    (:vel-y (meters 0.016666668) (meters 0.006666667))
    (:scalevel-x (meters 0.06666667) (meters 0.06666667))
    (:rotvel-z (degrees -0.2) (degrees 0.4))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.053333335 -0.053333335)
    (:friction 0.95 0.04)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13))
    (:userdata :data (new 'static 'boxed-array :type int32 10 1 0 #x40a000 #x409b00))
    (:next-time (seconds 0.167))
    (:next-launcher 1734)
    (:conerot-x (degrees 80) (degrees 20))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 1734
  :init-specs ((:scalevel-x (meters 0.013333334) (meters 0.02)) (:scalevel-y :copy scalevel-x))
  )

(defskelgroup skel-terraformer-drone terraformer-drone terraformer-drone-lod0-jg terraformer-drone-idle-ja
              ((terraformer-drone-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 5)
              :origin-joint-index 3
              :global-effects 32
              )

(deftype terraformer-drone (nav-enemy)
  ((trail-part            sparticle-launch-control)
   (spinner-jm            joint-mod)
   (spinner-angle         float)
   (minimap               connection-minimap)
   (zigzag-counter        int8)
   (zigzag-timer          time-frame)
   (zigzag-target         vector  :inline)
   (floor                 float)
   (engine-sound          sound-id)
   (engine-sound-playing  symbol)
   )
  (:state-methods
    attack
    explode
    )
  )


(define *terraformer-drone-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 'inline-array idle-control-frame 3
      (new 'static 'idle-control-frame :command (idle-control-cmd push) :param0 30)
      (new 'static 'idle-control-frame
        :command (idle-control-cmd play)
        :anim #x2
        :param0 100
        :param1 100
        :param2 '((new 'static 'bfloat :data 1.0) (new 'static 'bfloat :data 1.0))
        )
      (new 'static 'idle-control-frame)
      )
    :idle-anim 4
    :notice-anim 4
    :hostile-anim 4
    :hit-anim 4
    :knocked-anim 4
    :knocked-land-anim 4
    :die-anim 4
    :die-falling-anim 4
    :victory-anim -1
    :jump-wind-up-anim 4
    :jump-in-air-anim 4
    :jump-land-anim 4
    :neck-joint -1
    :look-at-joint 3
    :bullseye-joint 3
    :sound-hit (static-sound-name "terraformer-dro")
    :sound-die (static-sound-name "terraformer-dro")
    :notice-distance (meters 2000)
    :notice-distance-delta (meters 10)
    :proximity-notice-distance (meters 2000)
    :default-hit-points 1.0
    :gnd-collide-with (collide-spec backgnd obstacle hit-by-others-list)
    :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
    :movement-gravity (meters -100)
    :friction 0.8
    :attack-shove-back (meters 3.5)
    :attack-shove-up (meters 2)
    :attack-mode 'generic
    :attack-damage 2
    :recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
    :knocked-can-land-timeout (seconds 0.1)
    :knocked-recover-timeout (seconds 2)
    :ragdoll-blend-out-time (seconds 0.25)
    :ragdoll-rotate-velocity-mult 1.0
    :jump-height-min (meters 3)
    :jump-height-factor 0.5
    :knocked-seek-ry-clamp 65536.0
    :knocked-soft-vxz-lo (meters 17.6)
    :knocked-soft-vxz-hi (meters 26.4)
    :knocked-soft-vy-lo (meters 20)
    :knocked-soft-vy-hi (meters 30)
    :knocked-medium-vxz-lo (meters 36)
    :knocked-medium-vxz-hi (meters 48)
    :knocked-medium-vy-lo (meters 33)
    :knocked-medium-vy-hi (meters 37)
    :knocked-hard-vxz-lo (meters 19.2)
    :knocked-hard-vxz-hi (meters 28.8)
    :knocked-hard-vy-lo (meters 44.8)
    :knocked-hard-vy-hi (meters 51.2)
    :knocked-huge-vxz-lo (meters 40.2)
    :knocked-huge-vxz-hi (meters 60.8)
    :knocked-huge-vy-lo (meters 44.8)
    :knocked-huge-vy-hi (meters 53.2)
    :knocked-yellow-vxz-lo (meters 10)
    :knocked-yellow-vxz-hi (meters 12)
    :knocked-yellow-vy-lo (meters 14)
    :knocked-yellow-vy-hi (meters 20)
    :knocked-red-vxz-lo (meters 6)
    :knocked-red-vxz-hi (meters 48)
    :knocked-red-vy-lo (meters 23)
    :knocked-red-vy-hi (meters 37)
    :knocked-blue-vxz-lo (meters 10)
    :knocked-blue-vxz-hi (meters 12)
    :knocked-blue-vy-lo (meters 6)
    :knocked-blue-vy-hi (meters 20)
    :ragdoll-info #f
    :shadow-size (meters 1)
    :shadow-max-y (meters 1)
    :shadow-min-y (meters -1)
    :shadow-locus-dist (meters 150)
    :gem-joint -1
    :gem-offset (new 'static 'sphere :r 163840.0)
    :knocked-off #t
    :callback-info #f
    :use-momentum #f
    :use-frustration #t
    :use-stop-chase #f
    :use-circling #f
    :use-pacing #f
    :walk-anim 4
    :turn-anim -1
    :run-anim 4
    :taunt-anim -1
    :run-travel-speed (meters 40)
    :run-acceleration (meters 32)
    :run-turning-acceleration (meters 400)
    :walk-travel-speed (meters 40)
    :walk-acceleration (meters 16)
    :walk-turning-acceleration (meters 400)
    :maximum-rotation-rate (degrees 360)
    :notice-nav-radius (meters 2)
    :frustration-distance (meters 8)
    :frustration-time (seconds 4)
    :blocked-time (seconds 0.3)
    :circle-dist-lo 20480.0
    :circle-dist-hi 61440.0
    :nav-mesh #f
    )
  )

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

(defmethod enemy-common-post ((this terraformer-drone))
  "Common implementation of post. Runs ja-post."
  (with-pp
    (let ((t9-0 (method-of-type nav-enemy enemy-common-post)))
      (t9-0 this)
      )
    (when (not (and (-> this next-state) (= (-> this next-state name) 'explode)))
      (let ((f0-0 (doppler-pitch-shift (-> this root trans) (-> this root transv)))
            (a0-4 (static-sound-spec "drone-steady" :group 0 :volume 0.0 :mask (pitch reg0)))
            )
        (set! (-> a0-4 volume) 1024)
        (set! (-> a0-4 pitch-mod) (the int (* 1524.0 f0-0)))
        (sound-play-by-spec a0-4 (-> this engine-sound) (-> this root trans))
        )
      (set! (-> this engine-sound-playing) #t)
      )
    (let ((a0-6 (handle->process (-> this focus handle))))
      (when a0-6
        (let ((f0-3 (vector-vector-distance-squared (-> this root trans) (get-trans (the-as process-focusable a0-6) 0)))
              (f1-2 (* 18432.0 (-> this root scale x)))
              )
          (if (< f0-3 (* f1-2 f1-2))
              (go (method-of-object this explode))
              )
          )
        )
      )
    (cond
      ((and (-> this next-state) (= (-> this next-state name) 'jump))
       )
      (else
        (+! (-> this spinner-angle) (* 1820.4445 (-> pp clock time-adjust-ratio)))
        (if (< 65536.0 (-> this spinner-angle))
            (+! (-> this spinner-angle) -65536.0)
            )
        (quaternion-set!
          (-> this spinner-jm quat)
          0.0
          (sin (-> this spinner-angle))
          0.0
          (cos (-> this spinner-angle))
          )
        )
      )
    0
    (none)
    )
  )

(defmethod event-handler ((this terraformer-drone) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  "Commmon handler for events."
  (case arg2
    (('explode)
     (go (method-of-object this explode))
     )
    (('touch 'bonk 'attack)
     (go (method-of-object this explode))
     )
    (('jump)
     (set! (-> this floor) (-> (the-as vector (-> arg3 param 1)) y))
     ((method-of-type nav-enemy event-handler) this arg0 arg1 arg2 arg3)
     )
    (else
      ((method-of-type nav-enemy event-handler) this arg0 arg1 arg2 arg3)
      )
    )
  )

(defmethod setup-jump-trajectory! ((this terraformer-drone) (arg0 enemy-jump-info))
  "Compute jump trajectory."
  (if (< (-> this root scale x) 1.0)
      (setup-from-to-duration-and-height! (-> arg0 traj) (-> arg0 start-pos) (-> arg0 dest-pos) 120.0 61440.0)
      (setup-from-to-duration-and-height! (-> arg0 traj) (-> arg0 start-pos) (-> arg0 dest-pos) 120.0 40960.0)
      )
  (none)
  )

(defstate explode (terraformer-drone)
  :virtual #t
  :enter (behavior ()
    (set-time! (-> self state-time))
    (when (-> self engine-sound-playing)
      (sound-stop (-> self engine-sound))
      (set! (-> self engine-sound-playing) #f)
      )
    (when (-> self minimap)
      (kill-callback (-> *minimap* engine) (-> self minimap))
      (set! (-> self minimap) #f)
      )
    (let ((v1-12 (-> self root root-prim)))
      (set! (-> v1-12 prim-core collide-as) (collide-spec))
      (set! (-> v1-12 prim-core collide-with) (collide-spec))
      )
    0
    (logior! (-> self draw status) (draw-control-status no-draw))
    (activate! *camera-smush-control* 819.2 60 300 0.995 0.9 (-> *display* camera-clock))
    (sound-play "drone-blow" :position (-> self root trans))
    (let ((gp-1 (new 'stack-no-clear 'explosion-init-params)))
      (vector-copy! (-> gp-1 spawn-point) (-> self root trans))
      (quaternion-identity! (-> gp-1 spawn-quat))
      (set! (-> gp-1 radius) 40960.0)
      (set! (-> gp-1 scale) 1.0)
      (set! (-> gp-1 group) (-> *part-group-id-table* 428))
      (set! (-> gp-1 collide-with)
            (collide-spec backgnd jak crate enemy obstacle vehicle-sphere hit-by-others-list player-list pusher shield)
            )
      (set! (-> gp-1 damage) 3.0)
      (set! (-> gp-1 damage-scale) 1.0)
      (set! (-> gp-1 vehicle-damage-factor) 0.333)
      (set! (-> gp-1 vehicle-impulse-factor) 1.0)
      (set! (-> gp-1 ignore-proc) (process->handle #f))
      (explosion-spawn gp-1 (the-as process-drawable (ppointer->process (-> self parent))))
      )
    )
  :trans (behavior ()
    (if (time-elapsed? (-> self state-time) (seconds 5))
        (deactivate self)
        )
    )
  :code sleep-code
  )

;; WARN: Return type mismatch vector vs none.
(defmethod move-along-ballistic-trajectory-for-jump ((this terraformer-drone) (arg0 jump-stage) (arg1 enemy-jump-info))
  "Adjust trans, transv for the jump, if we're airborne."
  (case arg0
    (((jump-stage takeoff) (jump-stage in-air))
     (let ((f30-0 (fmin (the float (-> arg1 hang-time)) (-> arg1 traj time))))
       (let ((a1-3 (compute-trans-at-time (-> arg1 traj) f30-0 (new 'stack-no-clear 'vector))))
         (move-to-point! (-> this root) a1-3)
         )
       (let ((s5-1 (-> this root transv)))
         (compute-transv-at-time (-> arg1 traj) f30-0 s5-1)
         (vector-float*! s5-1 s5-1 300.0)
         )
       )
     )
    )
  (none)
  )

(defmethod landed-jump-yet? ((this terraformer-drone) (arg0 enemy-jump-info))
  "Is this on, or close to, the ground?"
  (>= (the float (-> arg0 hang-time)) (-> arg0 traj time))
  )

;; WARN: Return type mismatch vector vs float.
(defmethod move-to-gspot! ((this terraformer-drone))
  "Snap the enemy down onto the cached ground spot (gspot)."
  (the-as float (vector-reset! (-> this root transv)))
  )

(defmethod nav-enemy-method-176 ((this terraformer-drone))
  (cond
    ((< (-> this root scale x) 1.0)
     (let ((f0-1 (-> this root scale x)))
       (let ((v1-3 (-> this nav)))
         (set! (-> v1-3 target-speed) (* f0-1 (-> this enemy-info run-travel-speed)))
         )
       0
       (let ((v1-5 (-> this nav)))
         (set! (-> v1-5 acceleration) (* f0-1 (-> this enemy-info run-acceleration)))
         )
       )
     0
     (let ((v1-7 (-> this nav)))
       (set! (-> v1-7 turning-acceleration) (-> this enemy-info run-turning-acceleration))
       )
     0
     )
    (else
      (let ((v1-9 (-> this nav)))
        (set! (-> v1-9 target-speed) (-> this enemy-info walk-travel-speed))
        )
      0
      (let ((v1-11 (-> this nav)))
        (set! (-> v1-11 acceleration) (-> this enemy-info walk-acceleration))
        )
      0
      (let ((v1-13 (-> this nav)))
        (set! (-> v1-13 turning-acceleration) (-> this enemy-info walk-turning-acceleration))
        )
      0
      )
    )
  0
  (none)
  )

(defmethod nav-enemy-method-177 ((this terraformer-drone))
  (cond
    ((< (-> this root scale x) 1.0)
     (let ((f0-1 (-> this root scale x)))
       (let ((v1-3 (-> this nav)))
         (set! (-> v1-3 target-speed) (* f0-1 (-> this enemy-info run-travel-speed)))
         )
       0
       (let ((v1-5 (-> this nav)))
         (set! (-> v1-5 acceleration) (* f0-1 (-> this enemy-info run-acceleration)))
         )
       )
     0
     (let ((v1-7 (-> this nav)))
       (set! (-> v1-7 turning-acceleration) (-> this enemy-info run-turning-acceleration))
       )
     0
     )
    (else
      (let ((v1-9 (-> this nav)))
        (set! (-> v1-9 target-speed) (-> this enemy-info run-travel-speed))
        )
      0
      (let ((v1-11 (-> this nav)))
        (set! (-> v1-11 acceleration) (-> this enemy-info run-acceleration))
        )
      0
      (let ((v1-13 (-> this nav)))
        (set! (-> v1-13 turning-acceleration) (-> this enemy-info run-turning-acceleration))
        )
      0
      )
    )
  0
  (none)
  )

(defstate jump (terraformer-drone)
  :virtual #t
  :exit (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy jump) exit)))
      (if t9-0
          (t9-0)
          )
      )
    (let ((gp-0 (new 'stack-no-clear 'matrix)))
      (format 0 "spawning impact part~%")
      (matrix-identity! gp-0)
      (vector-copy! (-> gp-0 trans) (-> self root trans))
      (if (logtest? (-> *part-group-id-table* 431 flags) (sp-group-flag sp13))
          (part-tracker-spawn
            part-tracker-subsampler
            :to *entity-pool*
            :group (-> *part-group-id-table* 431)
            :duration (seconds 1)
            :mat-joint gp-0
            )
          (part-tracker-spawn
            part-tracker
            :to *entity-pool*
            :group (-> *part-group-id-table* 431)
            :duration (seconds 1)
            :mat-joint gp-0
            )
          )
      )
    )
  :trans (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy jump) trans)))
      (if t9-0
          (t9-0)
          )
      )
    (if (nonzero? (-> self trail-part))
        (push-back (-> self trail-part) (-> self root trans))
        )
    (if (< (-> self root trans y) (+ -204800.0 (-> self floor)))
        (go-virtual explode)
        )
    )
  )

(defstate stare (terraformer-drone)
  :virtual #t
  :enter (behavior ()
    (go-virtual attack)
    )
  )

(defstate notice (terraformer-drone)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy notice) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (go-state-for-focused self)
    )
  )

(defstate attack (terraformer-drone)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (set-time! (-> self state-time))
    (set-look-at-mode! self 1)
    (logior! (-> self enemy-flags) (enemy-flag cam-attack-mode))
    (logclear! (-> self enemy-flags) (enemy-flag chase-startup))
    (logclear! (-> self mask) (process-mask actor-pause))
    (when (logtest? (enemy-flag enable-on-hostile) (-> self enemy-flags))
      (logclear! (-> self enemy-flags) (enemy-flag enable-on-hostile))
      (let ((gp-0 (-> self on-hostile)))
        (if gp-0
            (script-eval gp-0 :vector (-> self root trans))
            )
        )
      )
    (logior! (-> self enemy-flags) (enemy-flag lock-focus))
    (nav-enemy-method-177 self)
    (let ((v1-25 self))
      (if (not (logtest? (enemy-flag ef37) (-> v1-25 enemy-flags)))
          (set! (-> v1-25 enemy-flags) (the-as enemy-flag (logior (enemy-flag ef39) (-> v1-25 enemy-flags))))
          )
      (set! (-> v1-25 enemy-flags) (the-as enemy-flag (logior (enemy-flag ef37) (-> v1-25 enemy-flags))))
      (set! (-> v1-25 nav callback-info) (-> v1-25 enemy-info callback-info))
      )
    0
    (let ((v1-28 self))
      (set! (-> v1-28 enemy-flags) (the-as enemy-flag (logior (enemy-flag ef38) (-> v1-28 enemy-flags))))
      )
    0
    (let ((v1-31 (-> self nav state)))
      (set! (-> v1-31 speed) (-> self nav target-speed))
      )
    0
    (logior! (-> self focus-status) (focus-status dangerous))
    (ja :group! terraformer-drone-spin-ja :num! min)
    (set! (-> self zigzag-counter) -1)
    (set! (-> self zigzag-timer) 0)
    0
    )
  :trans (behavior ()
    (ja :num! (loop!))
    (if (nonzero? (-> self part))
        (spawn (-> self part) (-> self root trans))
        )
    )
  :code sleep-code
  :post (behavior ()
    (let ((a0-1 (handle->process (-> self focus handle))))
      (when a0-1
        (let ((gp-0 (new 'stack-no-clear 'vector)))
          (vector-copy! gp-0 (get-trans (the-as process-focusable a0-1) 0))
          (let ((s5-0 3))
            (if (< (-> self root scale x) 1.0)
                (set! s5-0 6)
                )
            (cond
              ((>= (-> self zigzag-counter) s5-0)
               (let ((v1-14 (-> self nav state)))
                 (logclear! (-> v1-14 flags) (nav-state-flag directional-mode))
                 (logior! (-> v1-14 flags) (nav-state-flag target-poly-dirty))
                 (vector-copy! (-> v1-14 target-pos) gp-0)
                 )
               0
               )
              ((>= (- (current-time) (-> self zigzag-timer)) 0)
               (set-time! (-> self zigzag-timer))
               (+! (-> self zigzag-counter) 1)
               (let ((v1-24 (-> self zigzag-counter)))
                 (if (or (zero? v1-24) (= v1-24 2))
                     (+! (-> self zigzag-timer) (seconds 1.5))
                     (+! (-> self zigzag-timer) (seconds 3))
                     )
                 )
               (let ((s4-0 (new 'stack-no-clear 'vector)))
                 (let ((s3-0 (new 'stack-no-clear 'vector)))
                   (vector-! s4-0 (-> self root trans) gp-0)
                   (set! (-> s4-0 y) 0.0)
                   (set-vector! s3-0 (-> s4-0 z) 0.0 (- (-> s4-0 x)) 1.0)
                   (vector-normalize! s4-0 (fmax 81920.0 (+ -61440.0 (vector-length s4-0))))
                   (vector-normalize! s3-0 81920.0)
                   (let ((v1-37 (-> self zigzag-counter)))
                     (cond
                       ((= v1-37 s5-0)
                        )
                       ((or (= v1-37 1) (= v1-37 3) (= v1-37 5))
                        (vector+! s4-0 s4-0 s3-0)
                        )
                       ((or (zero? v1-37) (= v1-37 2) (= v1-37 4))
                        (vector-! s4-0 s4-0 s3-0)
                        )
                       )
                     )
                   )
                 (vector+! (-> self zigzag-target) s4-0 gp-0)
                 )
               (let ((a0-26 (-> self nav state))
                     (v1-48 (-> self zigzag-target))
                     )
                 (logclear! (-> a0-26 flags) (nav-state-flag directional-mode))
                 (logior! (-> a0-26 flags) (nav-state-flag target-poly-dirty))
                 (vector-copy! (-> a0-26 target-pos) v1-48)
                 )
               0
               )
              (else
                (let ((f0-9 (vector-vector-xz-distance-squared (-> self zigzag-target) (-> self root trans)))
                      (f1-3 40960.0)
                      )
                  (cond
                    ((< f0-9 (* f1-3 f1-3))
                     (set! (-> self zigzag-timer) 0)
                     0
                     )
                    (else
                      )
                    )
                  )
                )
              )
            )
          )
        )
      )
    (nav-enemy-method-187 self)
    )
  )

(defstate hostile (terraformer-drone)
  :virtual #t
  :enter (behavior ()
    (go-virtual attack)
    )
  )

(defmethod init-enemy-collision! ((this terraformer-drone))
  "Typical place to construct collision shapes"
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) cshape-reaction-default)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> s5-0 penetrated-by) (penetrate
                                    generic-attack
                                    lunge
                                    flop
                                    punch
                                    spin
                                    roll
                                    uppercut
                                    bonk
                                    tube
                                    flut-attack
                                    board
                                    mech-punch
                                    dark-punch
                                    dark-smack
                                    flut
                                    )
          )
    (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-7 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-7 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> v1-7 prim-core action) (collide-action deadly))
      (set! (-> v1-7 transform-index) 3)
      (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 12288.0)
      (set! (-> s5-0 total-prims) (the-as uint 1))
      (set! (-> s5-0 root-prim) v1-7)
      )
    (set! (-> s5-0 nav-radius) 12288.0)
    (let ((v1-9 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-9 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-9 prim-core collide-with))
      )
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

(defmethod coin-flip? ((this terraformer-drone))
  "Return #t half the time, #f the other."
  #f
  )

(defmethod deactivate ((this terraformer-drone))
  "Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
  (when (-> this engine-sound-playing)
    (sound-stop (-> this engine-sound))
    (set! (-> this engine-sound-playing) #f)
    )
  (call-parent-method this)
  (none)
  )

;; WARN: Return type mismatch nav-enemy vs terraformer-drone.
(defmethod relocate ((this terraformer-drone) (offset int))
  (if (nonzero? (-> this spinner-jm))
      (&+! (-> this spinner-jm) offset)
      )
  (if (nonzero? (-> this trail-part))
      (&+! (-> this trail-part) offset)
      )
  (the-as terraformer-drone ((method-of-type nav-enemy relocate) this offset))
  )

(defmethod init-enemy! ((this terraformer-drone))
  "Typical place for shared init code. Runs from entity or process style init."
  (with-pp
    (initialize-skeleton
      this
      (the-as skeleton-group (art-group-get-by-name *level* "skel-terraformer-drone" (the-as (pointer level) #f)))
      (the-as pair 0)
      )
    (setup-enemy! this *terraformer-drone-nav-enemy-info*)
    (let ((v1-5 (-> this nav)))
      (set! (-> v1-5 speed-scale) 1.0)
      )
    0
    (set-gravity-length (-> this root dynam) 573440.0)
    (logior! (-> this nav flags) (nav-control-flag momentum-ignore-heading))
    (set! (-> this part) (create-launch-control (-> *part-group-id-table* 430) this))
    pp
    (set! (-> this trail-part)
          (the-as
            sparticle-launch-control
            (new 'process 'sparticle-subsampler *sp-particle-system-2d* (-> *part-id-table* 1731) 10.0)
            )
          )
    (logclear! (-> this mask) (process-mask actor-pause))
    (logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
    (set! (-> this spinner-jm) (new 'process 'joint-mod (joint-mod-mode joint-set*) this 10))
    (set! (-> this spinner-angle) 0.0)
    (set! (-> this minimap) (add-icon! *minimap* this (the-as uint 130) (the-as int #f) (the-as vector #t) 0))
    (set! (-> this floor) -40960000.0)
    (set-vector! (-> this root scale) 2.0 2.0 2.0 1.0)
    (set! (-> this engine-sound) (new-sound-id))
    (set! (-> this engine-sound-playing) #f)
    0
    (none)
    )
  )

(deftype terraformer-drone-small (terraformer-drone)
  ()
  )


;; WARN: Return type mismatch vector vs none.
(defmethod init-enemy! ((this terraformer-drone-small))
  "Typical place for shared init code. Runs from entity or process style init."
  (let ((t9-0 (method-of-type terraformer-drone init-enemy!)))
    (t9-0 this)
    )
  (set-vector! (-> this root scale) 0.95 0.95 0.95 1.0)
  (none)
  )
