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

;; name: powerups.gc
;; name in dgo: powerups
;; dgos: GAME

;; DECOMP BEGINS

;; WARN: Return type mismatch symbol vs none.
;; WARN: new jak 2 until loop case, check carefully
(defbehavior cloud-track process ((arg0 process-tree)
                        (arg1 process-tree)
                        (arg2 (function vector none))
                        (arg3 time-frame)
                        (arg4 time-frame)
                        (arg5 time-frame)
                        )
  (change-parent self arg0)
  (let ((s1-1 (process->handle arg0))
        (s2-1 (process->handle arg1))
        )
    (suspend-for (+ arg3 arg4)
      (let ((v1-8 (or (not (handle->process s1-1)) (not (handle->process s2-1)))))
        (if v1-8
            (deactivate self)
            )
        )
      (let* ((f0-1 (fmax 0.0 (fmin 1.0 (/ (- (the float (- (current-time) time)) (the float arg3)) (the float arg4)))))
             (a0-18 (process-drawable-pair-random-point!
                      (the-as process-drawable (-> s1-1 process 0))
                      (the-as process-drawable (-> s2-1 process 0))
                      (new-stack-vector0)
                      f0-1
                      )
                    )
             )
        (arg2 a0-18)
        )
      )
    (cond
      ((zero? arg5)
       (until #f
         (suspend)
         )
       #f
       )
      (else
        (suspend-for arg5
          (let ((a0-21 (process-drawable-random-point! (the-as process-drawable (-> s2-1 process 0)) (new-stack-vector0))))
            (arg2 a0-21)
            )
          )
        )
      )
    )
  (none)
  )

(defpart 784
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 64.0)
    (:g 64.0)
    (:b 192.0)
    (:a 64.0)
    (:fade-a -1.0666667)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 785
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 64.0)
    (:g 64.0)
    (:b 192.0)
    (:a 64.0)
    (:fade-a -1.0666667)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 786
  :init-specs ((:texture (common-white common))
    (:num 1.0 3.0)
    (:scale-x (meters 0.5) (meters 1.5))
    (:rot-x 4)
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.2) (meters 0.1))
    (:r 64.0)
    (:g 64.0)
    (:b 128.0)
    (:a 128.0)
    (:fade-a -1.6)
    (:timer (seconds 0.3))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:next-time (seconds 0.035))
    (:next-launcher 787)
    )
  )

(defpart 788
  :init-specs ((:texture (common-white common))
    (:num 0.0 3.0)
    (:scale-x (meters 1.5) (meters 1.5))
    (:rot-x 4)
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y (meters 0.2) (meters 0.1))
    (:r 128.0)
    (:g 128.0)
    (:b 255.0)
    (:a 128.0)
    (:fade-a -1.6)
    (:timer (seconds 0.305))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:next-time (seconds 0.035))
    (:next-launcher 787)
    )
  )

(defpart 787
  :init-specs ((:r 64.0) (:g 64.0) (:fade-r -1.0) (:fade-g -0.4) (:fade-a -2.0))
  )

(defpart 789
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 0.1) (meters 0.15))
    (:scale-y :copy scale-x)
    (:r 32.0)
    (:g 32.0 64.0)
    (:b 192.0 64.0)
    (:a 64.0 128.0)
    (:scalevel-x (meters -0.00033333333))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.2)
    (:accel-y (meters -0.000016666667))
    (:timer (seconds 1.5))
    (:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    )
  )

(defpartgroup group-blue-hit-ground-effect
  :id 194
  :duration (seconds 0.017)
  :linger-duration (seconds 1.5)
  :bounds (static-bspherem 0 0 0 2)
  :parts ((sp-item 790) (sp-item 791) (sp-item 792 :flags (is-3d)) (sp-item 793) (sp-item 794 :flags (is-3d)))
  )

(defpart 793
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 32.0)
    (:y (meters 0.5))
    (:scale-x (meters 1) (meters 3))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 32.0 32.0)
    (:b 192.0 63.0)
    (:a 0.0 63 1.0)
    (:vel-y (meters 0.093333334))
    (:rotvel-z (degrees -0.2) (degrees 0.4))
    (:timer (seconds 0.5))
    (:flags (sp-cpuinfo-flag-3))
    (:next-time (seconds 0.067) (seconds 0.065))
    (:next-launcher 795)
    (:conerot-x (degrees 90))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0))
    )
  )

(defpart 795
  :init-specs ((:r 0.0)
    (:g 32.0 32.0)
    (:b 192.0 63.0)
    (:a 0.0 63 1.0)
    (:next-time (seconds 0.067) (seconds 0.065))
    (:next-launcher 795)
    )
  )

(defpart 794
  :init-specs ((:texture (splash-foam level-default-sprite))
    (:num 1.0)
    (:y (meters 0.5))
    (:scale-x (meters 0))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 32.0 32.0)
    (:b 192.0 63.0)
    (:a 96.0 32.0)
    (:scalevel-x (meters 0.21333334))
    (:scalevel-y :copy scalevel-x)
    (:timer (seconds 0.4))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:next-time (seconds 0.2))
    (:next-launcher 796)
    )
  )

(defpart 796
  :init-specs ((:fade-a -2.1333334))
  )

(defpart 792
  :init-specs ((:texture (middot level-default-sprite))
    (:num 1.0)
    (:y (meters 0.5))
    (:scale-x (meters 0))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 32.0 32.0)
    (:b 192.0 63.0)
    (:a 32.0 32.0)
    (:scalevel-x (meters 0.22666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.7111111)
    (:timer (seconds 0.3))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:next-time (seconds 0.15))
    (:next-launcher 797)
    )
  )

(defpart 797
  :init-specs ((:fade-a -1.4222223))
  )

(defpart 790
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 32.0)
    (:scale-x (meters 1) (meters 1))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 32.0 32.0)
    (:b 192.0 63.0)
    (:a 16.0 32.0)
    (:vel-y (meters 0.053333335) (meters 0.026666667))
    (:scalevel-x (meters 0.0033333334))
    (:rotvel-z (degrees -0.2) (degrees 0.4))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.16)
    (:accel-y (meters -0.00033333333))
    (:friction 0.95)
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13))
    (:conerot-x (degrees 60) (degrees 30))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(defpart 791
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 12.0)
    (:scale-x (meters 0.5) (meters 0.25))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 32.0 32.0)
    (:b 192.0 63.0)
    (:a 16.0 16.0)
    (:vel-y (meters 0.10666667) (meters 0.053333335))
    (:scalevel-x (meters 0.0016666667))
    (:rotvel-z (degrees -0.2) (degrees 0.4))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.21333334)
    (:accel-y (meters -0.00033333333))
    (:friction 0.95)
    (:timer (seconds 0.5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-13))
    (:conerot-x (degrees 60) (degrees 30))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(defpart 798
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 92.0 32.0)
    (:g 32.0 92.0)
    (:b 0.0)
    (:a 64.0)
    (:fade-a -1.0)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 799
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 92.0 32.0)
    (:g 32.0 92.0)
    (:b 0.0)
    (:a 64.0)
    (:fade-a -1.0)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 800
  :init-specs ((:texture (hotdot level-default-sprite))
    (:num 0.5 2.0)
    (:y (meters -0.05))
    (:scale-x (meters 0.2) (meters 0.1))
    (:scale-y :copy scale-x)
    (:r 100.0 28.0)
    (:g 64.0 64.0)
    (:b 0.0)
    (:a 64.0 64.0)
    (:vel-y (meters 0.0023333333) (meters 0.0016666667))
    (:scalevel-x (meters -0.00083333335))
    (:scalevel-y :copy scalevel-x)
    (:fade-g -0.4)
    (:fade-a -0.024242423)
    (:accel-y (meters -0.000100000005) (meters -0.0003))
    (:friction 0.93)
    (:timer (seconds 0.1) (seconds 0.697))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:next-time (seconds 0.3))
    (:next-launcher 801)
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.05))
    )
  )

(defpart 801
  :init-specs ((:fade-r 0.0))
  )

(defpart 802
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 92.0 32.0)
    (:g 0.0)
    (:b 0.0)
    (:a 64.0)
    (:fade-a -1.0)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 803
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 92.0 32.0)
    (:g 0.0)
    (:b 0.0)
    (:a 64.0)
    (:fade-a -1.0)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 804
  :init-specs ((:texture (hotdot level-default-sprite))
    (:num 0.5 2.0)
    (:y (meters -0.05))
    (:scale-x (meters 0.2) (meters 0.1))
    (:scale-y :copy scale-x)
    (:r 100.0 28.0)
    (:g 0.0)
    (:b 0.0)
    (:a 64.0 64.0)
    (:vel-y (meters 0.0023333333) (meters 0.0016666667))
    (:scalevel-x (meters -0.00083333335))
    (:scalevel-y :copy scalevel-x)
    (:fade-g -0.4)
    (:fade-a -0.024242423)
    (:accel-y (meters -0.000100000005) (meters -0.0003))
    (:friction 0.93)
    (:timer (seconds 0.1) (seconds 0.697))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:next-time (seconds 0.3))
    (:next-launcher 805)
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.05))
    )
  )

(defpart 805
  :init-specs ((:fade-r 0.0))
  )

(defpart 806
  :init-specs ((:texture (starflash level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 92.0 32.0)
    (:b 0.0)
    (:a 64.0)
    (:fade-a -1.0)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 807
  :init-specs ((:texture (bigpuff level-default-sprite))
    (:num 1.0 1.0)
    (:scale-x (meters 1.5) (meters 0.4))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 92.0 32.0)
    (:b 0.0)
    (:a 64.0)
    (:fade-a -1.0)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.5))
    )
  )

(defpart 808
  :init-specs ((:texture (hotdot level-default-sprite))
    (:num 0.5 2.0)
    (:y (meters -0.05))
    (:scale-x (meters 0.2) (meters 0.1))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g 100.0 28.0)
    (:b 0.0)
    (:a 64.0 64.0)
    (:vel-y (meters 0.0023333333) (meters 0.0016666667))
    (:scalevel-x (meters -0.00083333335))
    (:scalevel-y :copy scalevel-x)
    (:fade-g -0.4)
    (:fade-a -0.024242423)
    (:accel-y (meters -0.000100000005) (meters -0.0003))
    (:friction 0.93)
    (:timer (seconds 0.1) (seconds 0.697))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:next-time (seconds 0.3))
    (:next-launcher 809)
    (:conerot-x (degrees 0) (degrees 180))
    (:conerot-y (degrees 0) (degrees 360))
    (:conerot-radius (meters 0.05))
    )
  )

(defpart 809
  :init-specs ((:fade-g 0.0))
  )

(defun eco-blue-glow ((arg0 vector))
  (launch-particles (-> *part-id-table* 784) arg0)
  (if (rand-vu-percent? 0.5)
      (launch-particles (-> *part-id-table* 786) arg0)
      )
  0
  (none)
  )

(defbehavior target-eco-process target ()
  (when (and (!= (-> self fact eco-level) 0.0)
             (>= (- (-> *display* game-clock frame-counter) (-> self fact eco-pickup-time))
                 (the-as time-frame (-> self fact eco-timeout))
                 )
             )
    (set! (-> self fact eco-level) 0.0)
    (set! (-> self fact eco-timeout) 0)
    (logclear! (-> self target-flags) (target-flags tf4))
    (send-event self 'reset-collide)
    (stop! (-> self sound))
    )
  (if (logtest? (game-secrets endless-dark) (-> self game secrets))
      (set! (-> self game eco-pill-dark) (-> *FACT-bank* eco-pill-dark-max-default))
      )
  (if (logtest? (game-secrets endless-light) (-> self game secrets))
      (set! (-> self game eco-pill-light) (-> *FACT-bank* eco-pill-light-max-default))
      )
  (when (and (< 0.0 (-> self fact eco-level))
             (not (focus-test? self in-head))
             (not (logtest? (-> self draw status) (draw-control-status no-draw no-draw-temp)))
             (not (movie?))
             (rand-vu-percent?
               (lerp-scale
                 0.0
                 1.0
                 (the float (- (-> self fact eco-timeout)
                               (the-as uint (- (-> *display* game-clock frame-counter) (-> self fact eco-pickup-time)))
                               )
                      )
                 0.0
                 900.0
                 )
               )
             )
    (case (-> self fact eco-type)
      ((1)
       (change-sound! (-> self sound) (static-sound-name "yel-eco-jak"))
       (let ((s1-0 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
             (gp-1 sp-launch-particles-var)
             (s5-0 *sp-particle-system-2d*)
             (s4-0 (-> *part-id-table* (if (rand-vu-percent? 0.5)
                                           798
                                           799
                                           )
                       )
                   )
             (s2-0 *launch-matrix*)
             )
         (vector-copy! (-> s2-0 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s1-0)))
         (gp-1 s5-0 s4-0 s2-0 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
         )
       (dotimes (gp-2 2)
         (let ((v1-58 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
               (s5-1 sp-launch-particles-var)
               (s4-1 *sp-particle-system-2d*)
               (s3-1 (-> *part-id-table* 800))
               (s1-1 *launch-matrix*)
               )
           (vector-copy! (-> s1-1 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-58)))
           (s5-1 s4-1 s3-1 s1-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
           )
         )
       )
      ((2)
       (target-danger-set! (-> self control danger-mode) 'eco-red)
       (update-transforms (-> self control))
       (let ((a1-13 (new 'stack-no-clear 'overlaps-others-params)))
         (set! (-> a1-13 options) (overlaps-others-options))
         (set! (-> a1-13 collide-with-filter) (the-as collide-spec -1))
         (set! (-> a1-13 tlist) *touching-list*)
         (find-overlapping-shapes (-> self control) a1-13)
         )
       (target-danger-set! (-> self control danger-mode) #f)
       (update-transforms (-> self control))
       (change-sound! (-> self sound) (static-sound-name "red-eco-jak"))
       (let ((s1-2 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
             (gp-3 sp-launch-particles-var)
             (s5-2 *sp-particle-system-2d*)
             (s4-2 (-> *part-id-table* (if (rand-vu-percent? 0.5)
                                           802
                                           803
                                           )
                       )
                   )
             (s2-2 *launch-matrix*)
             )
         (vector-copy! (-> s2-2 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s1-2)))
         (gp-3 s5-2 s4-2 s2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
         )
       (dotimes (gp-4 2)
         (let ((v1-91 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
               (s5-3 sp-launch-particles-var)
               (s4-3 *sp-particle-system-2d*)
               (s3-3 (-> *part-id-table* 804))
               (s1-3 *launch-matrix*)
               )
           (vector-copy! (-> s1-3 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-91)))
           (s5-3 s4-3 s3-3 s1-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
           )
         )
       )
      ((3)
       (change-sound! (-> self sound) (static-sound-name "blue-eco-jak"))
       (let ((v1-104 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
         (cond
           ((and (logtest? (-> self control mod-surface flags) (surface-flag air))
                 (not (logtest? (-> self control status) (collide-status on-surface)))
                 )
            (set! (-> *part-id-table* 788 init-specs 4 initial-valuef) 0.0)
            (set! (-> *part-id-table* 788 init-specs 4 random-rangef) 65536.0)
            )
           (else
             (set! (-> *part-id-table* 788 init-specs 4 initial-valuef) 40960.0)
             (set! (-> *part-id-table* 788 init-specs 4 random-rangef) 16384.0)
             )
           )
         (launch-particles
           (-> *part-id-table* 788)
           (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-104))
           )
         )
       (let ((gp-6 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
         (launch-particles
           (-> *part-id-table* (if (rand-vu-percent? 0.5)
                                   784
                                   785
                                   )
               )
           (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data gp-6))
           )
         (if (rand-vu-percent? 0.5)
             (launch-particles
               (-> *part-id-table* 786)
               (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data gp-6))
               )
             )
         )
       (let ((v1-128 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
             (gp-7 sp-launch-particles-var)
             (s5-7 *sp-particle-system-2d*)
             (s4-7 (-> *part-id-table* 789))
             (s2-7 *launch-matrix*)
             )
         (vector-copy! (-> s2-7 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-128)))
         (gp-7 s5-7 s4-7 s2-7 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
         )
       (cpad-set-buzz! (-> *cpad-list* cpads 0) 0 1 (seconds 0.1))
       )
      ((5)
       (change-sound! (-> self sound) (static-sound-name "green-eco-jak"))
       (let ((s1-6 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
             (gp-8 sp-launch-particles-var)
             (s5-8 *sp-particle-system-2d*)
             (s4-8 (-> *part-id-table* (if (rand-vu-percent? 0.5)
                                           806
                                           807
                                           )
                       )
                   )
             (s2-8 *launch-matrix*)
             )
         (vector-copy! (-> s2-8 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s1-6)))
         (gp-8 s5-8 s4-8 s2-8 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
         )
       (dotimes (gp-9 2)
         (let ((v1-152 (rand-vu-int-range 3 (+ (-> self node-list length) -1)))
               (s5-9 sp-launch-particles-var)
               (s4-9 *sp-particle-system-2d*)
               (s3-9 (-> *part-id-table* 808))
               (s1-7 *launch-matrix*)
               )
           (vector-copy! (-> s1-7 trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-152)))
           (s5-9 s4-9 s3-9 s1-7 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
           )
         )
       )
      )
    (update-trans! (-> self sound) (-> self control trans))
    (update! (-> self sound))
    )
  0
  (none)
  )

(defbehavior target-color-effect-process target ()
  (when (and (-> self color-effect) (time-elapsed? (-> self color-effect-start-time) (-> self color-effect-duration)))
    (set! (-> self color-effect) #f)
    (set-vector! (-> self draw color-mult) 1.0 1.0 1.0 1.0)
    (set! (-> self draw color-emissive quad) (the-as uint128 0))
    )
  (case (-> self color-effect)
    (('shock)
     (let ((f0-4 (rand-vu-float-range 0.5 2.0)))
       (set-vector! (-> self draw color-mult) f0-4 f0-4 (+ 0.5 f0-4) 1.0)
       )
     )
    (('eco-pill-dark)
     (let ((f30-0 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 1.0 f30-0) (lerp 1.0 0.0 f30-0) (lerp 1.0 1.0 f30-0) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 0.3 f30-0) (lerp 0.0 0.0 f30-0) (lerp 0.0 0.3 f30-0) 1.0)
       )
     )
    (('eco-pill-light)
     (let ((f30-1 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 5.0 f30-1) (lerp 1.0 5.0 f30-1) (lerp 1.0 5.0 f30-1) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 2.0 f30-1) (lerp 0.0 2.0 f30-1) (lerp 0.0 2.0 f30-1) 1.0)
       )
     )
    (('ammo-yellow)
     (let ((f30-2 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 1.0 f30-2) (lerp 1.0 1.0 f30-2) (lerp 1.0 0.0 f30-2) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 0.3 f30-2) (lerp 0.0 0.3 f30-2) (lerp 0.0 0.0 f30-2) 1.0)
       )
     )
    (('ammo-red)
     (let ((f30-3 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 1.0 f30-3) (lerp 1.0 0.6 f30-3) (lerp 1.0 0.6 f30-3) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 0.3 f30-3) (lerp 0.0 0.0 f30-3) (lerp 0.0 0.0 f30-3) 1.0)
       )
     )
    (('ammo-blue)
     (let ((f30-4 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 0.6 f30-4) (lerp 1.0 0.8 f30-4) (lerp 1.0 1.0 f30-4) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 0.0 f30-4) (lerp 0.0 0.1 f30-4) (lerp 0.0 0.3 f30-4) 1.0)
       )
     )
    (('ammo-dark)
     (let ((f30-5 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 1.0 f30-5) (lerp 1.0 0.7 f30-5) (lerp 1.0 0.8 f30-5) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 0.2 f30-5) (lerp 0.0 0.0 f30-5) (lerp 0.0 0.1 f30-5) 1.0)
       )
     )
    (('health 'eco-green)
     (let ((f30-6 (lerp-scale
                    1.0
                    0.0
                    (the float (- (current-time) (-> self color-effect-start-time)))
                    (* 0.25 (the float (-> self color-effect-duration)))
                    (the float (-> self color-effect-duration))
                    )
                  )
           )
       (set-vector! (-> self draw color-mult) (lerp 1.0 0.5 f30-6) (lerp 1.0 1.0 f30-6) (lerp 1.0 0.5 f30-6) 1.0)
       (set-vector! (-> self draw color-emissive) (lerp 0.0 0.0 f30-6) (lerp 0.0 0.5 f30-6) (lerp 0.0 0.0 f30-6) 1.0)
       )
     )
    )
  0
  (none)
  )

(defun target-update-segs ((arg0 process-drawable))
  (let ((f30-0 (-> *FACT-bank* health-max-default)))
    (let ((s5-0 (-> *game-info* features)))
      (when (!= (-> arg0 type) target)
        (if (-> *setting-control* user-current beard)
            (setup-masks (-> arg0 draw) 4 0)
            (setup-masks (-> arg0 draw) 0 4)
            )
        (setup-masks (-> arg0 draw) 32 64)
        )
      (cond
        ((logtest? (game-feature armor0) s5-0)
         (set! f30-0 (+ 2.0 f30-0))
         (setup-masks (-> arg0 draw) 2 0)
         )
        (else
          (setup-masks (-> arg0 draw) 0 2)
          )
        )
      (cond
        ((logtest? (game-feature armor1) s5-0)
         (set! f30-0 (+ 2.0 f30-0))
         (setup-masks (-> arg0 draw) 16 0)
         )
        (else
          (setup-masks (-> arg0 draw) 0 16)
          )
        )
      (cond
        ((logtest? (game-feature armor2) s5-0)
         (set! f30-0 (+ 2.0 f30-0))
         (setup-masks (-> arg0 draw) 128 0)
         )
        (else
          (setup-masks (-> arg0 draw) 0 128)
          )
        )
      (cond
        ((logtest? (game-feature armor3) s5-0)
         (set! f30-0 (+ 2.0 f30-0))
         (setup-masks (-> arg0 draw) 512 256)
         )
        (else
          (setup-masks (-> arg0 draw) 256 512)
          )
        )
      )
    (if (not (-> *setting-control* user-current armor))
        (setup-masks (-> arg0 draw) 256 658)
        )
    f30-0
    )
  )

(defbehavior target-draw-process target ()
  (let ((gp-0 (the-as uint (-> self game features))))
    (if (not (-> *setting-control* user-current armor))
        (set! gp-0 (logand (the-as uint #xff0fffffffffffff) (the-as game-feature gp-0)))
        )
    (when (or (!= (-> self game old-features) gp-0) (not (time-elapsed? (-> self init-time) (seconds 0.5))))
      (let ((f30-0 (-> self fact health-max))
            (f0-0 (target-update-segs self))
            )
        (if (!= f30-0 f0-0)
            (pickup-collectable! (-> self fact) (pickup-type health-max) (- f0-0 f30-0) (the-as handle #f))
            )
        )
      (set! (-> self game old-features) (the-as game-feature gp-0))
      )
    )
  (+! (-> self scarf-interp) (* 0.2 (- (-> self scarf-interp-targ) (-> self scarf-interp))))
  (seek! (-> self scarf-interp) (-> self scarf-interp-targ) (seconds-per-frame))
  (+! (-> self goggles-interp) (* 0.2 (- (-> self goggles-interp-targ) (-> self goggles-interp))))
  (seek! (-> self goggles-interp) (-> self goggles-interp-targ) (seconds-per-frame))
  (let ((f30-1 (-> self scarf-interp))
        (f28-0 (-> self goggles-interp))
        (f26-0 (-> self darkjak-interp))
        (f24-0 (-> self lightjak-interp))
        )
    (when (or (!= (-> self scarf-interp-old) f30-1)
              (!= (-> self goggles-interp-old) f28-0)
              (!= (-> self darkjak-interp-old) f26-0)
              (or (!= (-> self lightjak-interp-old) f24-0) (not (time-elapsed? (-> self teleport-time) (seconds 0.6))))
              )
      (if (>= (-> self scarf-interp) 1.0)
          (setup-masks (-> self draw) 64 32)
          (setup-masks (-> self draw) 32 64)
          )
      (cond
        ((and (= f30-1 0.0)
              (= f28-0 0.0)
              (= f26-0 0.0)
              (and (= f24-0 0.0) (not (time-elapsed? (-> self teleport-time) (seconds 0.5))))
              )
         (set! (-> self skel override 0) 0.00001)
         (set! (-> self skel override 41) 1.0)
         (set! (-> self skel override 46) 1.0)
         (set! (-> self skel override 52) 1.0)
         )
        ((and (= f30-1 0.0) (= f28-0 0.0) (= f26-0 0.0) (= f24-0 0.0))
         (set! (-> self skel override 0) 0.0)
         (set! (-> self skel override 41) 0.0)
         (set! (-> self scarf-interp-old) f30-1)
         (set! (-> self goggles-interp-old) f28-0)
         (set! (-> self darkjak-interp-old) f26-0)
         (set! (-> self lightjak-interp-old) f24-0)
         )
        (else
          (set! (-> self skel override 0) 1.0)
          (set! (-> self skel override 8) f30-1)
          (set! (-> self skel override 5) f28-0)
          (set! (-> self skel override 2) f26-0)
          (set! (-> self skel override 6) f26-0)
          (set! (-> self skel override 7) f26-0)
          (set! (-> self skel override 4) f26-0)
          (cond
            ((!= f26-0 0.0)
             (set! (-> self skel override 41) 1.0)
             (set! (-> self skel override 46) 2.0)
             (set! (-> self skel override 52) 2.0)
             )
            ((!= f24-0 0.0)
             (set! (-> self skel override 41) 1.0)
             (set! (-> self skel override 46) 0.0)
             (set! (-> self skel override 52) 0.0)
             )
            (else
              (set! (-> self skel override 41) 0.0)
              )
            )
          (set! (-> self scarf-interp-old) f30-1)
          (set! (-> self goggles-interp-old) f28-0)
          (set! (-> self darkjak-interp-old) f26-0)
          (set! (-> self lightjak-interp-old) f24-0)
          )
        )
      )
    )
  (when (!= (-> self cloth) (-> *setting-control* user-current cloth))
    (process-drawable-show-all-cloth self (-> *setting-control* user-current cloth))
    (set! (-> self cloth) (-> *setting-control* user-current cloth))
    )
  0
  (none)
  )

(defbehavior target-powerup-process target ()
  (target-draw-process)
  (let ((gp-0 (-> self ext-anim-control)))
    (when (!= (-> self ext-anim) (-> self pending-ext-anim))
      (when (not (or (= (-> gp-0 status) 'initialize) (= (-> self ext-anim) (target-anim unknown))))
        (when (joint-control-cleanup (-> self skel) (-> gp-0 heap) (the-as art-joint-anim jakb-stance-loop-ja))
          (target-gun-end-mode 'fast-exit)
          (set! (-> self skel float-channels) (the-as uint 0))
          (reset (-> self skel top-anim))
          )
        (send-event (ppointer->process (-> self sidekick)) 'cleanup)
        (unload-from-heap *anim-manager* (-> gp-0 heap))
        (unlink-shaders-in-heap *texture-page-dir* (-> gp-0 heap))
        )
      (case (-> self pending-ext-anim)
        (((target-anim default) (target-anim board) (target-anim dark) (target-anim light))
         (set-pending-file gp-0 "jak-external" (the-as int (-> self pending-ext-anim)) (process->handle self) 0.0)
         )
        (else
          (set-pending-file gp-0 (the-as string #f) 0 (process->handle self) 0.0)
          )
        )
      )
    (if (= (-> gp-0 status) 'active)
        (set! (-> self ext-anim) (the-as target-anim (-> gp-0 load-file-part)))
        (set! (-> self ext-anim) (target-anim unknown))
        )
    )
  (let ((f30-0 (-> self control collision-spheres 0 prim-core world-sphere w)))
    (if (focus-test? self board)
        (+! (-> self control collision-spheres 0 prim-core world-sphere w) 4096.0)
        )
    (water-control-method-10 (-> self water))
    (set! (-> self control collision-spheres 0 prim-core world-sphere w) f30-0)
    )
  (if (and (logtest? (-> self water flags) (water-flag under-water))
           (not (logtest? (-> self water flags) (water-flag swim-ground)))
           )
      (set-time! (-> self control unknown-time-frame26))
      (set-time! (-> self control unknown-time-frame27))
      )
  (cond
    ((and (= (-> self control ground-pat material) (pat-material ice))
          (and (>= (-> self control ctrl-xz-vel) 204.8)
               (not (time-elapsed? (-> self control last-time-on-surface) (seconds 0.05)))
               )
          )
     (let ((gp-1 (vector<-cspace! (new 'stack-no-clear 'vector) (joint-node jakb-lod0-jg RbigToe))))
       (if (and (< (fabs (vector-dot
                           (-> self control dynam gravity-normal)
                           (vector-! (new 'stack-no-clear 'vector) gp-1 (-> self control trans))
                           )
                         )
                   819.2
                   )
                (rand-vu-percent? 0.5)
                )
           (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 159) gp-1)
           )
       )
     (let ((gp-2 (vector<-cspace! (new 'stack-no-clear 'vector) (joint-node jakb-lod0-jg LbigToe))))
       (if (and (< (fabs (vector-dot
                           (-> self control dynam gravity-normal)
                           (vector-! (new 'stack-no-clear 'vector) gp-2 (-> self control trans))
                           )
                         )
                   819.2
                   )
                (rand-vu-percent? 0.5)
                )
           (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 159) gp-2)
           )
       )
     (let ((f0-10 (lerp-scale 0.8 1.0 (-> self control ctrl-xz-vel) 0.0 81920.0)))
       (let ((v1-100 (ja-group)))
         (if (not (and v1-100 (= v1-100 jakb-ice-stance-ja)))
             (set! f0-10 (* 0.8 f0-10))
             )
         )
       (seek! (-> self control unknown-float45) f0-10 (seconds-per-frame))
       )
     (let ((f30-1 (-> self control unknown-float45))
           (f0-14 (lerp-scale -0.3 0.3 (-> self control ctrl-xz-vel) 0.0 81920.0))
           )
       (sound-play-by-name
         (static-sound-name "ice-loop")
         (-> self control unknown-sound-id04)
         (the int (* 1024.0 f30-1))
         (the int (* 1524.0 f0-14))
         0
         (sound-group)
         (-> self control trans)
         )
       )
     )
    ((< 0.0 (-> self control unknown-float45))
     (set! (-> self control unknown-float45) 0.0)
     (let ((v1-121 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
       (set! (-> v1-121 command) (sound-command set-param))
       (set! (-> v1-121 id) (-> self control unknown-sound-id04))
       (set! (-> v1-121 params volume) -4)
       (set! (-> v1-121 auto-time) 48)
       (set! (-> v1-121 auto-from) 2)
       (set! (-> v1-121 params mask) (the-as uint 17))
       (-> v1-121 id)
       )
     )
    )
  (target-darkjak-process)
  (target-lightjak-process)
  (target-invisible-process)
  (when (nonzero? (-> self fact trick-point-duration))
    (when (>= (- (-> *display* game-clock frame-counter) (-> self fact trick-point-start-time))
              (-> self fact trick-point-duration)
              )
      (format #t "------------> ~,,f total points~%" (-> self fact trick-point))
      (send-event (handle->process (-> self notify)) 'notify 'trick-judge (-> self fact trick-point))
      (reset! (-> self fact) 'trick-judge)
      )
    )
  (cond
    ((logtest? (-> self game features) (game-feature feature0))
     (cond
       ((< (current-time) (-> self fact stop-time-timeout))
        (set-setting! 'bg-a 'abs 0.3 0)
        (set-setting! 'bg-r 'abs 1.0 0)
        (update-rates! (-> *display* entity-clock) 0.0)
        (if (zero? (mod (-> *display* base-clock integral-frame-counter) 60))
            (sound-play "stopwatch")
            )
        )
       ((nonzero? (-> self fact stop-time-timeout))
        (remove-setting! 'bg-a)
        (remove-setting! 'bg-r)
        (update-rates! (-> *display* entity-clock) 1.0)
        (set! (-> self fact stop-time-timeout) 0)
        0
        )
       ((cpad-pressed? (-> self control cpad number) r1)
        (set! (-> self fact stop-time-timeout) (+ (current-time) (seconds 5)))
        )
       )
     )
    ((logtest? (-> self game features) (game-feature feature2))
     (when *time-of-day-fast*
       (set! *time-of-day-fast* #f)
       (send-event (ppointer->process *time-of-day*) 'change 'ratio 1.0)
       )
     (cond
       ((cpad-hold? (-> self control cpad number) r1)
        (update-rates!
          (-> *display* entity-clock)
          (seek (-> *display* entity-clock clock-ratio) 60.0 (* 120.0 (seconds-per-frame)))
          )
        (update-rates! (-> *display* bg-clock) (-> *display* entity-clock clock-ratio))
        (update-rates!
          (-> *display* target-clock)
          (seek (-> *display* target-clock clock-ratio) 2.0 (* 120.0 (seconds-per-frame)))
          )
        )
       ((or (!= (-> *display* entity-clock clock-ratio) 2.0) (!= (-> *display* target-clock clock-ratio) 1.0))
        (update-rates!
          (-> *display* entity-clock)
          (seek (-> *display* entity-clock clock-ratio) 2.0 (* 120.0 (seconds-per-frame)))
          )
        (update-rates! (-> *display* bg-clock) (-> *display* entity-clock clock-ratio))
        (update-rates!
          (-> *display* target-clock)
          (seek (-> *display* target-clock clock-ratio) 1.0 (* 120.0 (seconds-per-frame)))
          )
        )
       )
     )
    ((logtest? (-> self game features) (game-feature feature4))
     (when *time-of-day-fast*
       (set! *time-of-day-fast* #f)
       (send-event (ppointer->process *time-of-day*) 'change 'ratio 1.0)
       )
     (cond
       ((cpad-hold? (-> self control cpad number) r1)
        (update-rates!
          (-> *display* entity-clock)
          (seek (-> *display* entity-clock clock-ratio) 0.3 (* 30.0 (seconds-per-frame)))
          )
        (update-rates! (-> *display* bg-clock) (-> *display* entity-clock clock-ratio))
        (update-rates!
          (-> *display* target-clock)
          (seek (-> *display* target-clock clock-ratio) 0.5 (* 30.0 (seconds-per-frame)))
          )
        )
       ((or (!= (-> *display* entity-clock clock-ratio) 1.0) (!= (-> *display* target-clock clock-ratio) 1.0))
        (update-rates!
          (-> *display* entity-clock)
          (seek (-> *display* entity-clock clock-ratio) 1.0 (* 30.0 (seconds-per-frame)))
          )
        (update-rates! (-> *display* bg-clock) (-> *display* entity-clock clock-ratio))
        (update-rates!
          (-> *display* target-clock)
          (seek (-> *display* target-clock clock-ratio) 1.0 (* 30.0 (seconds-per-frame)))
          )
        )
       )
     )
    )
  (target-eco-process)
  (target-color-effect-process)
  (if (logtest? (-> self target-effect) (target-effect te0 te1 te2))
      (logior! (-> self draw global-effect) (draw-control-global-effect no-textures))
      (logclear! (-> self draw global-effect) (draw-control-global-effect no-textures))
      )
  (if (logtest? (-> self target-effect) (target-effect te3 te4 te5))
      (logior! (-> self draw global-effect) (draw-control-global-effect rim-lights))
      (logclear! (-> self draw global-effect) (draw-control-global-effect rim-lights))
      )
  (logclear! (-> self focus-status) (focus-status super))
  (if (or (focus-test? self dead hit)
          (or (logtest? (target-flags tf2 tinvuln1 tf5 tinvuln2 invisible) (-> self target-flags))
              (-> *setting-control* user-current ignore-target)
              )
          )
      (logior! (-> self focus-status) (focus-status ignore))
      (logclear! (-> self focus-status) (focus-status ignore))
      )
  (cond
    ((or (and (logtest? (-> self control mod-surface flags) (surface-flag air))
              (not (logtest? (-> self control status) (collide-status on-surface)))
              )
         (and (focus-test? self board) (not (time-elapsed? (-> self board last-jump-time) (seconds 0.1))))
         )
     (logior! (-> self focus-status) (focus-status in-air))
     (if (logtest? (surface-flag super) (-> self control current-surface flags))
         (logior! (-> self focus-status) (focus-status super))
         )
     )
    (else
      (logclear! (-> self focus-status) (focus-status in-air))
      )
    )
  (if (using-gun? self)
      (logior! (-> self focus-status) (focus-status gun))
      (logclear! (-> self focus-status) (focus-status gun))
      )
  (if (or (logtest? (water-flag touch-water) (-> self water flags))
          (logtest? (-> self control status) (collide-status on-water))
          )
      (logior! (-> self focus-status) (focus-status touch-water))
      (logclear! (-> self focus-status) (focus-status touch-water))
      )
  (if (logtest? (-> self control status) (collide-status on-water))
      (logior! (-> self focus-status) (focus-status on-water))
      (logclear! (-> self focus-status) (focus-status on-water))
      )
  (if (and (logtest? (-> self water flags) (water-flag under-water))
           (not (logtest? (-> self water flags) (water-flag swim-ground)))
           )
      (logior! (-> self focus-status) (focus-status under-water))
      (logclear! (-> self focus-status) (focus-status under-water))
      )
  (if (not (time-elapsed? (-> self gun fire-time) (seconds 0.1)))
      (logior! (-> self focus-status) (focus-status shooting))
      (logclear! (-> self focus-status) (focus-status shooting))
      )
  0
  (none)
  )

(defbehavior target-powerup-effect target ((arg0 symbol))
  (case arg0
    (('eco-blue)
     (let ((v1-4 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
       (eco-blue-glow (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-4)))
       )
     )
    )
  0
  (none)
  )

(defbehavior process-contact-action target ((arg0 process))
  (when (logtest? (-> *game-info* features) (game-feature feature0))
    (cond
      (arg0
        (+! (-> self clock ref-count) -1)
        (+! (-> arg0 clock ref-count) 1)
        (set! (-> self clock) (-> arg0 clock))
        )
      (else
        (+! (-> self clock ref-count) -1)
        (+! (-> *display* base-clock ref-count) 1)
        (set! (-> self clock) (-> *display* base-clock))
        )
      )
    )
  0
  (none)
  )
