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

;; name: maker-projectile.gc
;; name in dgo: maker-projectile
;; dgos: WCB

(define-extern *curve-maker-linear-up-red* curve2d-piecewise)
(define-extern *trail-color-curve-maker-grenade* curve-color-fast)
(define-extern *curve-maker-grenade-linear-trail* curve2d-fast)
(define-extern *maker-grenade-trail* light-trail-composition)
(define-extern *range-maker-grenade-explo-dust-color* curve-color-fast)
(define-extern *range-maker-grenade-explo-dust-alpha* curve2d-fast)
(define-extern *range-maker-grenade-explo-dust-scale-x* curve2d-fast)
(define-extern *range-maker-grenade-explo-dust-scale-y* curve2d-fast)
(define-extern *curve-maker-grenade-explo-dust-alpha* curve2d-fast)
(define-extern *curve-maker-grenade-explo-dust-scale-x* curve2d-fast)
(define-extern *curve-maker-grenade-explo-dust-scale-y* curve2d-fast)
(define-extern *part-maker-grenade-explosion-dust-in-curve-settings* particle-curve-settings)
(define-extern *range-maker-grenade-explo-color* curve-color-fast)
(define-extern *range-maker-grenade-explo-alpha* curve2d-fast)
(define-extern *range-maker-grenade-explo-scale-x* curve2d-fast)
(define-extern *range-maker-grenade-explo-scale-y* curve2d-fast)
(define-extern *curve-maker-grenade-explo-alpha* curve2d-fast)
(define-extern *curve-maker-grenade-explo-scale-x* curve2d-fast)
(define-extern *curve-maker-grenade-explo-scale-y* curve2d-fast)

;; DECOMP BEGINS

(when (or (zero? *curve-maker-linear-up-red*) (!= loading-level global))
  (set! *curve-maker-linear-up-red* (new 'loading-level 'curve2d-piecewise))
  (allocate! *curve-maker-linear-up-red* 2 'loading-level #f)
  )

(set! (-> *curve-maker-linear-up-red* pts data 0 first) 0.0)

(set! (-> *curve-maker-linear-up-red* pts data 0 second) 0.3)

(set! (-> *curve-maker-linear-up-red* pts data 1 first) 1.0)

(set! (-> *curve-maker-linear-up-red* pts data 1 second) 1.0)

(if #t
    (set! *trail-color-curve-maker-grenade* (new 'static 'curve-color-fast
                                              :xs (new 'static 'vector :y -0.2 :z -1.0 :w -2.0)
                                              :ys (new 'static 'inline-array vector 4
                                                (new 'static 'vector :x 1.0 :y 0.5 :z 1.0 :w 128.0)
                                                (new 'static 'vector :x 0.7 :z 1.0 :w 128.0)
                                                (new 'static 'vector :x 0.7 :z 1.0 :w 128.0)
                                                (new 'static 'vector :x 0.7 :z 1.0 :w 128.0)
                                                )
                                              :one-over-x-deltas (new 'static 'vector :x 5.0 :y 1.25 :z 1.0 :w 1.0)
                                              )
          )
    )

(if #t
    (set! *curve-maker-grenade-linear-trail* (new 'static 'curve2d-fast
                                               :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                               :ys (new 'static 'vector :x 0.3 :y 1.0 :z 2.0 :w 3.0)
                                               :one-over-x-deltas (new 'static 'vector :x 0.7 :y 1.0 :z 1.0 :w 1.0)
                                               )
          )
    )

(if (or (zero? *maker-grenade-trail*) (!= loading-level global))
    (set! *maker-grenade-trail* (new 'loading-level 'light-trail-composition))
    )

(set! (-> *maker-grenade-trail* color-mode) (the-as uint 0))

(set! (-> *maker-grenade-trail* color-repeat-dist) 40960.0)

(set! (-> *maker-grenade-trail* alpha-1-mode) (the-as uint 0))

(set! (-> *maker-grenade-trail* alpha-2-mode) (the-as uint 1))

(set! (-> *maker-grenade-trail* base-alpha) 0.5)

(set! (-> *maker-grenade-trail* alpha-repeat-dist) 6144.0)

(set! (-> *maker-grenade-trail* width-mode) (the-as uint 2))

(set! (-> *maker-grenade-trail* base-width) 8192.0)

(set! (-> *maker-grenade-trail* width-repeat-dist) 40960.0)

(set! (-> *maker-grenade-trail* uv-mode) (the-as uint 0))

(set! (-> *maker-grenade-trail* uv-repeat-dist) 16384000.0)

(set! (-> *maker-grenade-trail* lie-mode) (lie-mode appearance0))

(set! (-> *maker-grenade-trail* max-age) (seconds 0.5))

(if #f
    (set! (-> *maker-grenade-trail* tex-id) (lookup-texture-id-by-name (the-as string #f) (the-as string #f)))
    (set! (-> *maker-grenade-trail* tex-id) (new 'static 'texture-id :index #x3 :page #x1))
    )

(set! (-> *maker-grenade-trail* width-curve) (the-as curve2d-piecewise *curve-maker-grenade-linear-trail*))

(set! (-> *maker-grenade-trail* color-curve) (the-as curve-color-piecewise *trail-color-curve-maker-grenade*))

(set! (-> *maker-grenade-trail* alpha-curve-1) (the-as curve2d-piecewise *curve-linear-down*))

(set! (-> *maker-grenade-trail* alpha-curve-2) *curve-maker-linear-up-red*)

(set! (-> *maker-grenade-trail* zbuffer?) #f)

(vector-copy! (-> *maker-grenade-trail* lie-vector) *up-vector*)

(set! (-> *maker-grenade-trail* use-tape-mode?) #f)

(set! (-> *maker-grenade-trail* blend-mode) (the-as uint 1))

(set! (-> *maker-grenade-trail* frame-stagger) (the-as uint 1))

(defpartgroup group-maker-grenade-glow
  :id 550
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 40)
  :parts ((sp-item 2164 :flags (sp6)) (sp-item 2165 :flags (sp6)) (sp-item 2166 :flags (sp6)))
  )

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

(defpart 2165
  :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 2166
  :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-maker-grenade-shot-explode-far
  :id 551
  :duration (seconds 5)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 30)
  :parts ((sp-item 2167 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 2168 :fade-after (meters 400) :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 2169 :flags (sp3) :period (seconds 30) :length (seconds 0.017))
    (sp-item 2170 :period (seconds 30) :length (seconds 0.167))
    (sp-item 2171 :period (seconds 30) :length (seconds 0.5))
    (sp-item 2172 :falloff-to (meters 400) :period (seconds 30) :length (seconds 0.035))
    )
  )

(defpartgroup group-maker-grenade-shot-explode
  :id 552
  :duration (seconds 5)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 30)
  :parts ((sp-item 2172 :falloff-to (meters 400) :period (seconds 30) :length (seconds 0.035)))
  )

(defpart 2167
  :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 2172
  :init-specs ((:texture (rockbit01 level-default-sprite))
    (:birth-func 'birth-func-texture-group)
    (:num 60.0)
    (:x (meters 0) (meters 4))
    (:scale-x (meters 0.4) (meters 1))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y :copy scale-x)
    (:r 100.0 100.0)
    (:g :copy r)
    (:b :copy r)
    (:a 128.0)
    (:vel-y (meters 0.033333335) (meters 0.1))
    (:rotvel-z (degrees -3.0000002) (degrees 6.0000005))
    (:fade-g -4.0)
    (:fade-b -9.0)
    (: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 20 1 0 #x408b00 #x40a200 #x40a600 #x40aa00))
    (:next-time (seconds 0.035))
    (:next-launcher 2173)
    (:conerot-z (degrees 0) (degrees 40))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 2173
  :init-specs ((:fade-g 0.0) (:fade-b 0.0))
  )

(defpart 2168
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 30.0)
    (:scale-x (meters 3) (meters 2))
    (: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.06666667))
    (:scalevel-x (meters 0.016666668))
    (: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 2174
  :init-specs ((:texture (edge-cloud level-default-sprite))
    (:birth-func 'birth-func-curve)
    (:num 30.0)
    (:scale-x (meters 1))
    (:rot-z (degrees -80) (degrees -20))
    (:scale-y :copy scale-x)
    (:r 1.0)
    (:g 1.0)
    (:b 128.0)
    (:a 128.0)
    (:vel-y (meters 0.05))
    (:rotvel-z (degrees -0.033333335) (degrees 0.06666667))
    (:friction 0.97)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-13 sp-cpuinfo-flag-14))
    (:userdata 0.0)
    (:func 'live-func-curve)
    (:conerot-x (degrees 0) (degrees 360))
    (:conerot-z (degrees 0) (degrees 360))
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(if #t
    (set! *range-maker-grenade-explo-dust-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 185.0 :y 160.0 :z 110.0 :w 128.0)
                                                     (new 'static 'vector :x 135.0 :y 110.0 :z 60.0 :w 128.0)
                                                     (new 'static 'vector :x 135.0 :y 110.0 :z 60.0 :w 128.0)
                                                     (new 'static 'vector :x 135.0 :y 110.0 :z 60.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-maker-grenade-explo-dust-alpha* (new 'static 'curve2d-fast
                                                   :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                                   :ys (new 'static 'vector :x 80.0 :y 64.0 :z 65.0 :w 66.0)
                                                   :one-over-x-deltas (new 'static 'vector :x -16.0 :y 1.0 :z 1.0 :w 1.0)
                                                   )
          )
    )

(if #t
    (set! *range-maker-grenade-explo-dust-scale-x* (new 'static 'curve2d-fast
                                                     :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                                     :ys (new 'static 'vector :x 8.0 :y 10.0 :z 11.0 :w 12.0)
                                                     :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                                     )
          )
    )

(if #t
    (set! *range-maker-grenade-explo-dust-scale-y* (new 'static 'curve2d-fast
                                                     :xs (new 'static 'vector :y -1.0 :z -2.0 :w -3.0)
                                                     :ys (new 'static 'vector :x 8.0 :y 10.0 :z 11.0 :w 12.0)
                                                     :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                                     )
          )
    )

(if #t
    (set! *curve-maker-grenade-explo-dust-alpha* (new 'static 'curve2d-fast
                                                   :xs (new 'static 'vector :y -0.7 :z -1.0 :w -2.0)
                                                   :ys (new 'static 'vector :y 1.0 :w 1.0)
                                                   :one-over-x-deltas (new 'static 'vector :x 1.4285715 :y -3.3333333 :z 1.0 :w 1.0)
                                                   )
          )
    )

(if #t
    (set! *curve-maker-grenade-explo-dust-scale-x* (new 'static 'curve2d-fast
                                                     :xs (new 'static 'vector :y -0.5 :z -1.0 :w -2.0)
                                                     :ys (new 'static 'vector :x 0.2 :y 1.0 :z 1.6 :w 2.6)
                                                     :one-over-x-deltas (new 'static 'vector :x 1.6 :y 1.2 :z 0.9999999 :w 1.0)
                                                     )
          )
    )

(if #t
    (set! *curve-maker-grenade-explo-dust-scale-y* (new 'static 'curve2d-fast
                                                     :xs (new 'static 'vector :y -0.5 :z -1.0 :w -2.0)
                                                     :ys (new 'static 'vector :x 0.2 :y 1.0 :z 1.6 :w 2.6)
                                                     :one-over-x-deltas (new 'static 'vector :x 1.6 :y 1.2 :z 0.9999999 :w 1.0)
                                                     )
          )
    )

(define *part-maker-grenade-explosion-dust-in-curve-settings* (new 'static 'particle-curve-settings
                                                                :lifetime-base (seconds 1.5)
                                                                :lifetime-offset (seconds 2)
                                                                :flags (particle-curve-flags pcf0)
                                                                )
        )

(set! (-> *part-id-table* 2174 init-specs 15 initial-valuef)
      (the-as float *part-maker-grenade-explosion-dust-in-curve-settings*)
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* color-start)
      *range-maker-grenade-explo-dust-color*
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* alpha-start)
      *range-maker-grenade-explo-dust-alpha*
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* scale-x-start)
      *range-maker-grenade-explo-dust-scale-x*
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* scale-y-start)
      *range-maker-grenade-explo-dust-scale-y*
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* r-scalar) #f)

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* g-scalar) #f)

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* b-scalar) #f)

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* a-scalar)
      *curve-maker-grenade-explo-dust-alpha*
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* scale-x-scalar)
      *curve-maker-grenade-explo-dust-scale-x*
      )

(set! (-> *part-maker-grenade-explosion-dust-in-curve-settings* scale-y-scalar)
      *curve-maker-grenade-explo-dust-scale-y*
      )

(defpart 2170
  :init-specs ((:texture (explosion-edge level-default-sprite))
    (:num 5.0)
    (:scale-x (meters 3) (meters 2))
    (: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.33333334) (meters 0.13333334))
    (:scalevel-x (meters 0.033333335))
    (: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 2171
  :init-specs ((:texture (explo-texture level-default-sprite))
    (:birth-func 'birth-func-curve)
    (:num 8.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.06666667) (meters 0.033333335))
    (: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-maker-grenade-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-maker-grenade-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-maker-grenade-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 3.0 :y 5.0 :z 6.0 :w 7.0)
                                                :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                                )
          )
    )

(if #t
    (set! *range-maker-grenade-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 3.0 :y 5.0 :z 6.0 :w 7.0)
                                                :one-over-x-deltas (new 'static 'vector :x 2.0 :y 1.0 :z 1.0 :w 1.0)
                                                )
          )
    )

(if #t
    (set! *curve-maker-grenade-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-maker-grenade-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-maker-grenade-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-maker-grenade-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* 2171 init-specs 16 initial-valuef)
      (the-as float *part-maker-grenade-explosion-texture-curve-settings*)
      )

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

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

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

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

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

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

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

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

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

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

(defpart 2169
  :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)
    )
  )

(defskelgroup skel-maker-grenade gun gun-grenade-lod0-jg gun-grenade-idle-ja
              ((gun-grenade-lod0-mg (meters 20)) (gun-grenade-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 2)
              :texture-level 10
              )

(defmethod play-impact-sound ((this maker-grenade) (arg0 projectile-options))
  (let ((v1-0 arg0))
    (cond
      ((= v1-0 (projectile-options po0 po1))
       (when (nonzero? (-> this sound-id))
         (let ((f0-0 (vector-vector-distance (target-pos 0) (-> this root trans))))
           (if (= 0.0 (-> this initial-dist))
               (set! (-> this initial-dist) f0-0)
               )
           (if (!= 0.0 f0-0)
               (set! f0-0 (+ 0.2 (/ f0-0 (-> this initial-dist))))
               )
           (sound-play-by-name
             (static-sound-name "ball-streak")
             (-> this sound-id)
             1024
             (the int (* 1524.0 f0-0))
             0
             (sound-group)
             (-> this root trans)
             )
           )
         )
       )
      ((zero? v1-0)
       (sound-play "ball-launch")
       )
      ((= v1-0 (projectile-options po0))
       )
      )
    )
  0
  (none)
  )

(defmethod projectile-method-25 ((this maker-grenade))
  (spawn (-> this part) (-> this root trans))
  (ja-post)
  0
  (none)
  )

(defmethod deactivate ((this maker-grenade))
  "Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
  (set! *maker-num-grenades* (+ *maker-num-grenades* 1))
  (call-parent-method this)
  0
  (none)
  )

;; WARN: Return type mismatch object vs none.
(defmethod go-impact! ((this maker-grenade))
  (go (method-of-object this impact))
  (none)
  )

;; WARN: Return type mismatch sound-id vs none.
(defmethod projectile-method-39 ((this maker-grenade))
  (let* ((s4-0 (-> this root))
         (s5-0 (-> s4-0 status))
         )
    (when (logtest? s5-0 (collide-status touch-surface))
      (go-impact! this)
      (vector-float*! (-> s4-0 transv) (-> s4-0 transv) 0.2)
      )
    (wascity-turret-add-radar (-> this root trans))
    (when (and (logtest? s5-0 (collide-status impact-surface))
               (time-elapsed? (-> this played-bounce-time) (seconds 0.3))
               )
      (set-time! (-> this played-bounce-time))
      (sound-play "grenade-bounce")
      )
    )
  (none)
  )

(defstate moving (maker-grenade)
  :virtual #t
  :post (behavior ()
    (transform-post)
    )
  )

(defun maker-projectile-bounce-move ((arg0 maker-grenade))
  (let ((s5-0 (new 'stack-no-clear 'quaternion)))
    (quaternion-identity! s5-0)
    (quaternion-slerp! (-> arg0 tumble-quat) (-> arg0 tumble-quat) s5-0 (* 0.2 (seconds-per-frame)))
    )
  (quaternion-normalize! (-> arg0 tumble-quat))
  (quaternion*! (-> arg0 root quat) (-> arg0 root quat) (-> arg0 tumble-quat))
  (projectile-move-fill-all-dirs arg0)
  (none)
  )

(defstate impact (maker-grenade)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('touched)
       (send-event
         proc
         'attack
         (-> block param 0)
         (static-attack-info :mask (vehicle-impulse-factor) ((id (-> self attack-id))
                                                             (damage 2.0)
                                                             (vehicle-damage-factor 2.0)
                                                             (vehicle-impulse-factor 1.0)
                                                             (mode 'explode)
                                                             )
                             )
         )
       #t
       )
      )
    )
  :enter (behavior ()
    (call-parent-state-handler enter)
    (when (-> self minimap)
      (logior! (-> self minimap flags) (minimap-flag fade-out))
      (set! (-> self minimap) #f)
      )
    )
  :code (behavior ()
    (let ((gp-0 (new 'stack-no-clear 'matrix)))
      (let ((s5-0 (new 'stack-no-clear 'explosion-init-params)))
        (vector-copy! (-> s5-0 spawn-point) (-> self root trans))
        (quaternion-identity! (-> s5-0 spawn-quat))
        (set! (-> s5-0 radius) (-> self blast-radius))
        (set! (-> s5-0 scale) 1.0)
        (set! (-> s5-0 group) #f)
        (set! (-> s5-0 collide-with)
              (collide-spec backgnd jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
              )
        (set! (-> s5-0 damage) 2.0)
        (set! (-> s5-0 damage-scale) 1.0)
        (set! (-> s5-0 vehicle-damage-factor) 1.0)
        (set! (-> s5-0 vehicle-impulse-factor) 1.0)
        (set! (-> s5-0 ignore-proc) (process->handle #f))
        (explosion-spawn s5-0 (the-as process-drawable *default-pool*))
        )
      (let ((f0-6 81920.0))
        (cond
          ((< (* f0-6 f0-6) (vector-vector-distance-squared (-> self root trans) (target-pos 0)))
           (forward-up->inv-matrix gp-0 (-> self pre-move-transv) *up-vector*)
           (vector-copy! (-> gp-0 trans) (-> self root trans))
           (if (logtest? (-> *part-group-id-table* 539 flags) (sp-group-flag sp13))
               (part-tracker-spawn
                 part-tracker-subsampler
                 :to *entity-pool*
                 :group (-> *part-group-id-table* 539)
                 :mat-joint gp-0
                 )
               (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 539) :mat-joint gp-0)
               )
           (sound-play "ball-explode")
           )
          (else
            (quaternion->matrix gp-0 (-> *target* control quat))
            (vector-copy! (-> gp-0 trans) (-> *target* control trans))
            (if (logtest? (-> *part-group-id-table* 541 flags) (sp-group-flag sp13))
                (part-tracker-spawn
                  part-tracker-subsampler
                  :to *entity-pool*
                  :group (-> *part-group-id-table* 541)
                  :mat-joint gp-0
                  )
                (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 541) :mat-joint gp-0)
                )
            (sound-play "ball-hit-turret")
            )
          )
        )
      )
    (let ((f0-11 (lerp-scale 3276.8 0.0 (vector-vector-distance (camera-pos) (-> self root trans)) 40960.0 163840.0)))
      (if (!= f0-11 0.0)
          (activate! *camera-smush-control* f0-11 37 600 1.0 0.1 (-> self clock))
          )
      )
    (logior! (-> self draw status) (draw-control-status no-draw))
    (let ((v1-85 (-> self root root-prim)))
      (set! (-> v1-85 prim-core collide-as) (collide-spec))
      (set! (-> v1-85 prim-core collide-with) (collide-spec))
      )
    0
    (suspend-for (seconds 3)
      (suspend)
      )
    )
  )

(defmethod handle-proj-hit! ((this maker-grenade) (arg0 process) (arg1 event-message-block))
  (let ((t9-0 (method-of-type projectile-bounce handle-proj-hit!)))
    (when (not (t9-0 this arg0 arg1))
      (when (type? arg0 wascity-turret-shot)
        (vector-copy! (-> this pre-move-transv) (-> (the-as wascity-turret-shot arg0) pre-move-transv))
        (go (method-of-object this impact))
        )
      )
    )
  )

(defmethod setup-collision! ((this maker-grenade))
  (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) projectile-bounce-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> s5-0 penetrate-using) (penetrate explode))
    (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 action) (collide-action solid))
      (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 16384.0)
      (set! (-> s5-0 total-prims) (the-as uint 1))
      (set! (-> s5-0 root-prim) v1-7)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (let ((v1-10 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with))
      )
    (set! (-> s5-0 max-iteration-count) (the-as uint 2))
    (set! (-> s5-0 event-self) 'touched)
    (set! (-> this root) s5-0)
    )
  (set-collide-with!
    (-> this root)
    (collide-spec
      backgnd
      jak
      crate
      civilian
      enemy
      obstacle
      vehicle-sphere
      hit-by-others-list
      player-list
      pusher
      shield
      )
    )
  (set-collide-as! (-> this root) (collide-spec enemy))
  (set! (-> this root pat-ignore-mask)
        (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1)
        )
  (none)
  )

(defmethod init-proj-settings! ((this maker-grenade))
  (set! (-> this attack-mode) 'eco-dark)
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-maker-grenade" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (let ((t9-2 (method-of-type projectile-bounce init-proj-settings!)))
    (t9-2 this)
    )
  (set! (-> this move) maker-projectile-bounce-move)
  (set! (-> this initial-dist) 0.0)
  (set! (-> this sound-id) (new-sound-id))
  (let ((f30-1 (/ 655360.0 (the float (rand-vu-int-range 150 600))))
        (s5-1 (new 'stack-no-clear 'vector))
        )
    (rand-vu-sphere-point-uniform! s5-1 1.0)
    (vector-normalize! s5-1 1.0)
    (quaternion-axis-angle! (-> this tumble-quat) (-> s5-1 x) (-> s5-1 y) (-> s5-1 z) f30-1)
    )
  (set! (-> this draw lod-set lod 0 dist) 696320.0)
  (set! (-> this draw lod-set lod 1 dist) 7372800.0)
  (set! (-> this draw lod-set lod 2 dist) 7372800.0)
  (set! (-> this part) (create-launch-control (-> *part-group-id-table* 550) this))
  (set! (-> this blast-radius) 122880.0)
  (set! (-> this max-speed) 450560.0)
  (set! (-> this timeout) (seconds 12))
  (set! (-> this gravity) 40960.0)
  (let ((s5-2 (new 'stack-no-clear 'light-trail-tracker-spawn-params)))
    (set! (-> s5-2 tracked-obj) (process->handle this))
    (set! (-> s5-2 appearance) *maker-grenade-trail*)
    (set! (-> s5-2 max-num-crumbs) (the int (* 0.5 (the float (-> s5-2 appearance max-age)))))
    (set! (-> s5-2 track-immediately?) #t)
    (let* ((v1-32 (estimate-light-trail-mem-usage
                    (the-as uint (-> s5-2 max-num-crumbs))
                    (the-as uint (= (-> s5-2 appearance lie-mode) (lie-mode use-two-strips)))
                    )
                  )
           (s4-1 (get-process *default-dead-pool* light-trail-tracker-projectile (+ v1-32 8192) 1))
           )
      (when s4-1
        (let ((t9-11 (method-of-type process activate)))
          (t9-11 s4-1 this "light-trail" (the-as pointer #x70004000))
          )
        (run-now-in-process s4-1 light-trail-tracker-init-by-other s5-2)
        (-> s4-1 ppointer)
        )
      )
    )
  (set-vector! (-> this root scale) 16.0 16.0 16.0 1.0)
  (set! (-> this minimap) #f)
  0
  (none)
  )
