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

;; name: merc-death.gc
;; name in dgo: merc-death
;; dgos: GAME

;; DECOMP BEGINS

(define *merc-death-globals* (new 'global 'vector))

(defun birth-func-death-sparks ()
  0
  (none)
  )

(define death-seed
  (new 'static 'death-info :vertex-skip #x8 :timer #xe0 :overlap #xff :effect #x34 :sound "temp-enemy-die")
  )

(defun start-seed-effect ((arg0 process-drawable) (arg1 vector) (arg2 cspace))
  (let ((v1-0 (-> arg0 draw))
        (a1-1 death-seed)
        )
    (set! (-> v1-0 death-vertex-skip) (-> a1-1 vertex-skip))
    (set! (-> v1-0 death-effect) (-> a1-1 effect))
    (set! (-> v1-0 death-timer) (+ (-> a1-1 timer) 1))
    (set! (-> v1-0 death-timer-org) (-> v1-0 death-timer))
    (set! (-> v1-0 death-draw-overlap) (-> a1-1 overlap))
    )
  (send-event
    arg0
    'trans-hook
    (lambda :behavior process-drawable () (let ((v0-0 200))
                                            (set! (-> self draw death-timer) (the-as uint v0-0))
                                            (the-as time-frame v0-0)
                                            )
                                       )
    )
  0
  (none)
  )

(defpart 52
  :init-specs ((:scale-x (meters 1))
    (:rot-x (degrees 2.25))
    (:scale-y :copy scale-x)
    (:r 64.0 196.0)
    (:g 196.0 64.0)
    (:b 0.0)
    (:a 4.0 2.0)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:func 'sparticle-texture-glow-soft)
    )
  )

(define death-default
  (new 'static 'death-info :vertex-skip #xa :timer #x4b :overlap #x4 :effect #x35 :sound "enemy-fizz")
  )

(define death-warp-in
  (new 'static 'death-info :vertex-skip #x96 :timer #x4b :effect #x36 :sound "warpgate-tele")
  )

(define death-warp-out
  (new 'static 'death-info :vertex-skip #x96 :timer #x96 :effect #x36 :sound "warpgate-tele")
  )

(defun sparticle-texture-glow-soft ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (particle-adgif-callback (-> arg1 adgif) (new 'static 'texture-id :index #xf :page #x4))
  (set! (-> arg1 sp-func) (the-as (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none) 0))
  0
  (none)
  )

(defpart 54
  :init-specs ((:scale-x (meters 0.5) (meters 0.5))
    (:scale-y :copy scale-x)
    (:r 32.0 32.0)
    (:g 32.0 64.0)
    (:b 128.0 128.0)
    (:a 128.0)
    (:scalevel-x (meters 0.02) (meters 0.02))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 0.0 -1.28)
    (:friction 0.92 0.02)
    (:timer (seconds 1.667))
    (:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-13))
    (:next-time (seconds 0.1) (seconds 0.065))
    (:next-launcher 55)
    )
  )

(defpart 55
  :init-specs ((:scale-x (meters 0.3) (meters 0.2))
    (:scale-y :copy scale-x)
    (:a 64.0 32.0)
    (:omega (degrees 0.045) (degrees 0.03375))
    (:vel-x (meters -0.053333335) (meters 0.10666667))
    (:vel-y (meters -0.026666667) (meters 0.093333334))
    (:vel-z (meters -0.053333335) (meters 0.10666667))
    (:scalevel-x (meters -0.001) (meters -0.008))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 0.0)
    (:func 'sparticle-motion-blur)
    )
  )

(defpart 53
  :init-specs ((:scale-x (meters 0.5) (meters 0.5))
    (:scale-y :copy scale-x)
    (:r 96.0 150.0)
    (:g 32.0 64.0)
    (:b 128.0 128.0)
    (:a 128.0)
    (:scalevel-x (meters 0.02) (meters 0.02))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 0.0 -1.28)
    (:friction 0.92 0.02)
    (:timer (seconds 1.667))
    (:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-13))
    (:next-time (seconds 0.1) (seconds 0.065))
    (:next-launcher 56)
    )
  )

(defpart 56
  :init-specs ((:scale-x (meters 0.3) (meters 0.2))
    (:scale-y :copy scale-x)
    (:a 64.0 32.0)
    (:omega (degrees 0.045) (degrees 0.03375))
    (:vel-x (meters -0.053333335) (meters 0.10666667))
    (:vel-y (meters -0.026666667) (meters 0.093333334))
    (:vel-z (meters -0.053333335) (meters 0.10666667))
    (:scalevel-x (meters -0.001) (meters -0.008))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 0.0)
    (:func 'sparticle-motion-blur)
    )
  )

(defun merc-death-spawn ((arg0 int) (arg1 vector) (arg2 vector))
  (let ((v1-2 (-> *part-id-table* arg0)))
    (if (and (nonzero? v1-2) (= (-> v1-2 type) sparticle-launcher))
        (sp-launch-particles-death *sp-particle-system-2d* v1-2 arg1)
        )
    )
  0
  (none)
  )
