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

;; name: weather-part.gc
;; name in dgo: weather-part
;; dgos: ENGINE, GAME

;; DECOMP BEGINS

(defpartgroup group-rain-screend-drop-real
  :id 1
  :flags (screen-space)
  :bounds (static-bspherem 0 0 0 16)
  :parts ((sp-item 45 :binding 41)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 41 :flags (start-dead launch-asap) :binding 42)
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 42 :flags (start-dead launch-asap))
    (sp-item 46 :binding 43)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 43 :flags (start-dead launch-asap) :binding 44)
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    (sp-item 44 :flags (start-dead launch-asap))
    )
  )

(define group-rain-screend-drop (-> *part-group-id-table* 1))

(defpart 46
  :init-specs ((:texture (starflash effects))
    (:num 0.1)
    (:x (meters -4.5) (meters 9))
    (:y (meters -3) (meters 6))
    (:scale-x (meters 2.5))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 12.0)
    (:scalevel-x (meters 0.16666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.8)
    (:timer (seconds 0.035))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    )
  )

(defpart 43
  :init-specs ((:texture (lakedrop effects))
    (:num 1.0)
    (:scale-x (meters 1.5))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 255.0)
    (:a 20.0)
    (:scalevel-x (meters 0.033333335))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.8)
    (:accel-y (meters -0.00066666666))
    (:timer (seconds 0.9))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.05))
    (:next-launcher 47)
    )
  )

(defpart 47
  :init-specs ((:scalevel-x (meters 0.004166667)) (:scalevel-y :copy scalevel-x) (:fade-a -0.06666667))
  )

(defpart 44
  :init-specs ((:num 1.0)
    (:rot-x 12)
    (:r 4096.0)
    (:g 3276.8)
    (:b 3276.8)
    (:fade-r 6.068148)
    (:fade-g 68.26667)
    (:fade-b 3.034074)
    (:accel-y (meters -0.00066666666))
    (:timer (seconds 0.9))
    (:flags (distort))
    (:next-time (seconds 0.1))
    (:next-launcher 48)
    )
  )

(defpart 48
  :init-specs ((:fade-g -5.1200004))
  )

(defpart 45
  :init-specs ((:texture (starflash effects))
    (:num 0.1)
    (:x (meters -4.5) (meters 9))
    (:y (meters -3) (meters 6))
    (:scale-x (meters 4))
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 12.0)
    (:scalevel-x (meters 0.26666668))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.8)
    (:timer (seconds 0.035))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    )
  )

(defpart 41
  :init-specs ((:texture (lakedrop effects))
    (:num 1.0)
    (:scale-x (meters 2.6))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 255.0)
    (:a 20.0)
    (:scalevel-x (meters 0.06666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.8)
    (:accel-y (meters -0.00066666666))
    (:timer (seconds 0.9))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.05))
    (:next-launcher 49)
    )
  )

(defpart 49
  :init-specs ((:scalevel-x (meters 0.008333334)) (:scalevel-y :copy scalevel-x) (:fade-a -0.06666667))
  )

(defpart 42
  :init-specs ((:num 1.0)
    (:rot-x 24)
    (:r 12288.0)
    (:g 6553.6)
    (:b 6553.6)
    (:fade-r 12.136296)
    (:fade-g 136.53334)
    (:fade-b 6.068148)
    (:accel-y (meters -0.00066666666))
    (:timer (seconds 0.9))
    (:flags (distort))
    (:next-time (seconds 0.1))
    (:next-launcher 50)
    )
  )

(defpart 50
  :init-specs ((:fade-g -10.240001))
  )

(defpartgroup group-stars
  :id 2
  :flags (always-draw)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 51 :flags (bit6)) (sp-item 52 :flags (bit6)) (sp-item 53 :flags (bit6)))
  )

(defpart 51
  :init-specs ((:texture (hotdot effects))
    (:num 1.0)
    (:scale-x (meters 30) (meters 20))
    (:scale-y :copy scale-x)
    (:r 256.0)
    (:g 256.0)
    (:b 256.0)
    (:a 0.0)
    (:fade-a 0.42666668)
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.2) (seconds 0.797))
    (:next-launcher 54)
    (:conerot-x (degrees -89) (degrees 178))
    (:conerot-y (degrees 0) (degrees 1440))
    (:rotate-y (degrees 0) (degrees 3600))
    (:conerot-radius (meters 5000))
    )
  )

(defpart 54
  :init-specs ((:fade-a 0.0) (:next-time (seconds 99999)) (:next-launcher 55))
  )

(defpart 55
  :init-specs ((:fade-a -0.42666668))
  )

(defpart 52
  :init-specs ((:texture (hotdot effects))
    (:num 1.0)
    (:scale-x (meters 30) (meters 20))
    (:scale-y :copy scale-x)
    (:r 256.0)
    (:g 256.0)
    (:b 256.0)
    (:a 0.0)
    (:fade-a 0.42666668)
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.2) (seconds 0.797))
    (:next-launcher 54)
    (:conerot-x (degrees 30) (degrees 59))
    (:conerot-y (degrees 0) (degrees 2880))
    (:rotate-y (degrees 0) (degrees 3600))
    (:conerot-radius (meters 5000))
    )
  )

(defpart 53
  :init-specs ((:texture (hotdot effects))
    (:num 1.0)
    (:scale-x (meters 30) (meters 20))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 0.0)
    (:fade-a 0.42666668)
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.2) (seconds 0.797))
    (:next-launcher 54)
    (:conerot-x (degrees 60) (degrees 29))
    (:conerot-y (degrees 0) (degrees 5760))
    (:rotate-y (degrees 0) (degrees 3600))
    (:conerot-radius (meters 5000))
    )
  )

(defpart 56
  :init-specs ((:texture (hotdot effects))
    (:num 4.0)
    (:x (meters 10) (meters 10))
    (:y (meters 2) (meters 14))
    (:scale-x (meters 0.2) (meters 0.1))
    (:rot-x 4)
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 0.0)
    (:vel-y (meters -0.01) (meters -0.0033333334))
    (:rotvel-z (degrees -1.2) (degrees 2.4))
    (:fade-a 0.85333335)
    (:timer (seconds 5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.25) (seconds 0.247))
    (:next-launcher 57)
    (:rotate-y (degrees 0) (degrees 180))
    )
  )

(defpart 58
  :init-specs ((:texture (hotdot effects))
    (:num 0.0)
    (:x (meters 0) (meters 20))
    (:y (meters 16))
    (:scale-x (meters 0.2) (meters 0.1))
    (:rot-x 4)
    (:rot-z (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 255.0)
    (:b 255.0)
    (:a 0.0)
    (:vel-y (meters -0.01) (meters -0.0033333334))
    (:rotvel-z (degrees -1.2) (degrees 2.4))
    (:fade-a 0.85333335)
    (:timer (seconds 5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-12 sp-cpuinfo-flag-14))
    (:next-time (seconds 0.25) (seconds 0.247))
    (:next-launcher 57)
    (:rotate-y (degrees 0) (degrees 360))
    )
  )

(defpart 57
  :init-specs ((:fade-a 0.0) (:next-time (seconds 4)) (:next-launcher 59))
  )

(defpart 59
  :init-specs ((:fade-a -0.85333335))
  )

(defun update-snow ((arg0 float) (arg1 vector) (arg2 vector))
  (let ((f0-0 (lerp-scale 0.0 1.0 (vector-length arg2) 2048.0 40960.0)))
    (set! (-> *part-id-table* 58 init-specs 1 initial-valuef) (- 1.0 f0-0))
    (set! (-> *part-id-table* 56 init-specs 1 initial-valuef) (* 4.0 f0-0))
    )
  (set! (-> *part-id-table* 56 init-specs 19 initial-valuef) (+ 32768.0 (vector-y-angle arg2)))
  (launch-particles (-> *part-id-table* 58) arg1)
  (launch-particles (-> *part-id-table* 56) arg1)
  0
  (none)
  )

(defpart 60
  :init-specs ((:texture (lakedrop effects))
    (:birth-func 'birth-func-rain)
    (:num 1.0)
    (:x (meters -20) (meters 40))
    (:y (meters 30))
    (:scale-x (meters 0.03) (meters 0.03))
    (:scale-y (meters 0.5) (meters 0.5))
    (:r 32.0 32.0)
    (:g :copy r)
    (:b 64.0 32.0)
    (:a 32.0 64.0)
    (:vel-y (meters -0.1) (meters -0.2))
    (:timer (seconds 3))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:userdata 0.0)
    (:func 'check-drop-level-rain)
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 61
  :init-specs ((:texture (lakedrop effects))
    (:birth-func 'birth-func-rain)
    (:num 4.0)
    (:x (meters -20) (meters 40))
    (:y (meters 30))
    (:scale-x (meters 0.03) (meters 0.03))
    (:scale-y (meters 0.5) (meters 0.5))
    (:r 32.0 32.0)
    (:g :copy r)
    (:b 64.0 32.0)
    (:a 32.0 64.0)
    (:vel-y (meters -0.06666667) (meters -0.033333335))
    (:timer (seconds 3))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:userdata 0.0)
    (:func 'check-drop-level-rain2)
    (:rotate-y (degrees 0) (degrees 3600))
    )
  )

(defpart 62
  :init-specs ((:texture (lakedrop effects))
    (:num 1.0 3.0)
    (:scale-x (meters 0.08) (meters 0.03))
    (:rot-x 4)
    (:scale-y :copy scale-x)
    (:r 32.0 32.0)
    (:g :copy r)
    (:b 64.0 32.0)
    (:a 64.0 64.0)
    (:omega (degrees 0.01575) (degrees 0.009))
    (:vel-y (meters 0.033333335) (meters 0.06666667))
    (:fade-a -0.21333334 -0.21333334)
    (:accel-y (meters -0.005) (meters -0.00066666666))
    (:friction 0.98)
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 use-global-acc))
    (:userdata 0.0)
    (:func 'check-drop-level-splash)
    (:next-time (seconds 0) (seconds 0.33))
    (:next-launcher 63)
    (:conerot-x (degrees 0) (degrees 50.000004))
    (:conerot-y (degrees 0) (degrees 3600))
    (:rotate-x (degrees 0))
    (:rotate-y (degrees 0))
    )
  )

(defpart 64
  :init-specs ((:texture (hotdot effects))
    (:birth-func 'birth-func-omega-normal-orient)
    (:num 1.0)
    (:y (meters 0.2))
    (:scale-x (meters 0.5) (meters 0.25))
    (:scale-y :copy scale-x)
    (:r 32.0 32.0)
    (:g :copy r)
    (:b 64.0 32.0)
    (:a 64.0 32.0)
    (:omega (degrees 0))
    (:scalevel-x (meters 0.006666667) (meters 0.006666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -1.2)
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    (:userdata :data (new 'static 'boxed-array :type int32 10 0 0 #xc0c900 #xc02600 #xc03300 #xc02c00))
    (:func 'sparticle-texture-animate)
    )
  )

(defpart 65
  :init-specs ((:texture (motion-blur-part effects))
    (:num 2.0 4.0)
    (:scale-x (meters 2.5))
    (:rot-x 4)
    (:scale-y (meters 0.06) (meters 0.03))
    (:r 255.0)
    (:g 128.0 128.0)
    (:b 0.0 128.0)
    (:a 128.0)
    (:omega (degrees 0.018) (degrees 0.01125))
    (:vel-y (meters 0.1) (meters 0.06666667))
    (:fade-g -2.55 -2.55)
    (:fade-b -8.0)
    (:fade-a -0.32 -0.64)
    (:friction 0.8 0.02)
    (:timer (seconds 0.335) (seconds 0.33))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:func 'sparticle-motion-blur)
    (:conerot-x (degrees 0) (degrees 80))
    (:conerot-y (degrees 0) (degrees 3600))
    )
  )

(defpart 66
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 0.25))
    (:rot-x (degrees 0.225))
    (:rot-z (degrees 0) (degrees 3600))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 196.0 128.0)
    (:b 128.0 64.0)
    (:a 96.0 16.0)
    (:omega (degrees 3608.9998))
    (:scalevel-x (meters 0.08))
    (:scalevel-y :copy scalevel-x)
    (:fade-g -6.375)
    (:fade-b -13.066667)
    (:fade-a -2.8)
    (:timer (seconds 0.05) (seconds 0.03))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:userdata 2048.0)
    )
  )

(defun birth-func-omega-normal-orient ((arg0 sparticle-system)
                              (arg1 sparticle-cpuinfo)
                              (arg2 sprite-vec-data-3d)
                              (arg3 sparticle-launcher)
                              (arg4 sparticle-launch-state)
                              )
  (local-vars (v1-6 float) (v1-7 float))
  (rlet ((vf0 :class vf)
         (vf1 :class vf)
         (vf2 :class vf)
         )
    (init-vf0-vector)
    (let ((s4-0 (new 'stack-no-clear 'vector))
          (gp-0 (new 'stack-no-clear 'quaternion))
          )
      (set! (-> s4-0 x) (* 0.007874016 (the float (-> arg1 datab 2))))
      (set! (-> s4-0 y) 0.0)
      (set! (-> s4-0 z) (* -0.007874016 (the float (-> arg1 datab 0))))
      (vector-normalize! s4-0 1.0)
      (quaternion-vector-angle! gp-0 s4-0 (acos (* 0.007874016 (the float (-> arg1 datab 1)))))
      (cond
        ((< (-> gp-0 w) 0.0)
         (.lvf vf1 (&-> arg2 qx-qy-qz-sy quad))
         (.lvf vf2 (&-> gp-0 quad))
         (.sub.vf.xyz vf1 vf0 vf2)
         (.svf (&-> arg2 qx-qy-qz-sy quad) vf1)
         (.mov v1-6 vf1)
         )
        (else
          (.lvf vf1 (&-> arg2 qx-qy-qz-sy quad))
          (.lvf vf2 (&-> gp-0 quad))
          (.add.vf.xyz vf1 vf0 vf2)
          (.svf (&-> arg2 qx-qy-qz-sy quad) vf1)
          (.mov v1-7 vf1)
          )
        )
      )
    0
    (none)
    )
  )

(defun birth-func-rain ((arg0 sparticle-system)
               (arg1 sparticle-cpuinfo)
               (arg2 sprite-vec-data-3d)
               (arg3 sparticle-launcher)
               (arg4 sparticle-launch-state)
               )
  (let ((s4-0 (new 'stack-no-clear 'collide-query)))
    (set! (-> s4-0 start-pos quad) (-> arg2 x-y-z-sx quad))
    (set-vector! (-> s4-0 move-dist) 0.0 -163840.0 0.0 1.0)
    (let ((v1-2 s4-0))
      (set! (-> v1-2 radius) 40.96)
      (set! (-> v1-2 collide-with) (collide-spec backgnd))
      (set! (-> v1-2 ignore-process0) #f)
      (set! (-> v1-2 ignore-process1) #f)
      (set! (-> v1-2 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
      (set! (-> v1-2 action-mask) (collide-action solid))
      )
    (fill-using-line-sphere *collide-cache* s4-0)
    (cond
      ((>= (probe-using-line-sphere *collide-cache* s4-0) 0.0)
       (set! (-> arg1 user-float) (-> s4-0 best-other-tri intersect y))
       (let ((f0-8 (+ 65536.0 (-> *math-camera* trans y))))
         (if (< (-> arg1 user-float) f0-8)
             (set! (-> arg2 x-y-z-sx y) f0-8)
             )
         )
       (set! (-> arg1 datab 0) (the int (* 127.0 (-> s4-0 best-other-tri normal x))))
       (set! (-> arg1 datab 1) (the int (* 127.0 (-> s4-0 best-other-tri normal y))))
       (set! (-> arg1 datab 2) (the int (* 127.0 (-> s4-0 best-other-tri normal z))))
       (set! (-> arg1 datab 3) (the-as int (-> s4-0 best-other-tri pat event)))
       )
      (else
        (set! (-> arg1 omega) 65280.0)
        (set! (-> arg1 user-float) (+ -204800.0 (-> arg2 x-y-z-sx y)))
        )
      )
    )
  (let ((f0-21 (get-height *ocean* (-> arg2 x-y-z-sx) #f)))
    (when (!= f0-21 4095996000.0)
      (when (< (-> arg1 user-float) f0-21)
        (set! (-> arg1 user-float) f0-21)
        (set! (-> arg1 datab 0) 0)
        (set! (-> arg1 datab 1) 127)
        (set! (-> arg1 datab 2) 0)
        (set! (-> arg1 datab 3) 0)
        0
        )
      )
    )
  0
  (none)
  )

(defun check-drop-level-rain ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (when (< (-> arg2 y) (-> arg1 user-float))
    (let ((s4-0 (new 'stack-no-clear 'vector))
          (gp-0 (new 'stack-no-clear 'matrix))
          )
      (let ((f30-0 (-> arg1 user-float)))
        (sp-kill-particle arg0 arg1)
        (set-vector! s4-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
        (-> arg1 omega)
        (set-vector!
          (-> gp-0 vector 1)
          (* 0.007874016 (the float (-> arg1 datab 0)))
          (* 0.007874016 (the float (-> arg1 datab 1)))
          (* 0.007874016 (the float (-> arg1 datab 2)))
          0.0
          )
        (set-vector! (-> gp-0 vector 2) 0.0 0.0 1.0 0.0)
        (vector-cross! (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1) (-> gp-0 vector 2))
        (set! (-> gp-0 trans quad) (-> s4-0 quad))
        (set! (-> *part-id-table* 62 init-specs 23 initial-valuef) (vector-y-angle (-> gp-0 vector 1)))
        (set! (-> *part-id-table* 62 init-specs 22 initial-valuef) (- 16384.0 (vector-x-angle (-> gp-0 vector 1))))
        (set! (-> *part-id-table* 62 init-specs 16 initial-valuef) f30-0)
        )
      (launch-particles (-> *part-id-table* 62) gp-0 :origin-is-matrix #t)
      (case (-> arg1 datab 3)
        ((11 10)
         (sound-play "sizzle-drips")
         (launch-particles (-> *part-id-table* 66) gp-0 :origin-is-matrix #t)
         (launch-particles (-> *part-id-table* 65) gp-0 :origin-is-matrix #t)
         )
        (else
          (sound-play "dry-drips")
          (set! (-> *part-id-table* 64 init-specs 10 initial-valuef) (-> arg1 omega))
          (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 64) gp-0 :origin-is-matrix #t)
          )
        )
      )
    )
  (none)
  )

;; WARN: Return type mismatch symbol vs none.
(defun check-drop-level-rain2 ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (if (< (-> arg2 y) (-> arg1 user-float))
      (sp-kill-particle arg0 arg1)
      )
  (none)
  )

;; WARN: Return type mismatch symbol vs none.
(defun check-drop-level-splash ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (sparticle-motion-blur arg0 arg1 arg2)
  (if (< (-> arg2 y) (-> arg1 user-float))
      (sp-kill-particle arg0 arg1)
      )
  (none)
  )

(defun update-rain ((arg0 float) (arg1 vector) (arg2 vector))
  (let ((v1-0 (new 'stack-no-clear 'vector)))
    (set! (-> v1-0 x) (-> arg2 x))
    (set! (-> v1-0 y) 0.0)
    (set! (-> v1-0 z) (-> arg2 z))
    (set! (-> v1-0 w) 1.0)
    (let ((gp-1 (vector+float*! (new 'stack-no-clear 'vector) arg1 v1-0 0.0)))
      (let* ((s4-0 (matrix-local->world #f #f))
             (f28-0 (lerp-scale 122.88 245.76 (fabs (-> s4-0 vector 2 y)) 0.0 0.7))
             (f30-0 (lerp-scale 2048.0 245.76 (fabs (-> s4-0 vector 2 y)) 0.0 0.7))
             )
        (let ((f26-0 (lerp-scale 0.0 0.1 (-> s4-0 vector 2 y) 0.3 0.7))
              (f0-11 (lerp-scale 1.0 0.1 (-> s4-0 vector 2 y) 0.3 0.7))
              )
          (if (< 0.0 f26-0)
              (send-event *camera* 'part-water-drip f26-0 f0-11)
              )
          )
        (set! (-> *part-id-table* 60 init-specs 5 initial-valuef) f28-0)
        (set! (-> *part-id-table* 60 init-specs 5 random-rangef) f28-0)
        (set! (-> *part-id-table* 61 init-specs 5 initial-valuef) f28-0)
        (set! (-> *part-id-table* 61 init-specs 5 random-rangef) f28-0)
        (set! (-> *part-id-table* 60 init-specs 6 initial-valuef) f30-0)
        (set! (-> *part-id-table* 60 init-specs 6 random-rangef) f30-0)
        (set! (-> *part-id-table* 61 init-specs 6 initial-valuef) f30-0)
        (set! (-> *part-id-table* 61 init-specs 6 random-rangef) f30-0)
        )
      (set! (-> *part-id-table* 60 init-specs 2 initial-valuef) arg0)
      (set! (-> *part-id-table* 61 init-specs 2 initial-valuef) (* 4.0 arg0))
      (launch-particles (-> *part-id-table* 60) gp-1)
      (launch-particles (-> *part-id-table* 61) gp-1)
      )
    )
  0
  (none)
  )

(defbehavior cam-master-effect camera-master ()
  (when (not (or (movie?) (>= (+ (current-time) (seconds -10)) (-> self water-drip-time))))
    (set! (-> *part-id-table* 46 init-specs 1 initial-valuef) (-> self water-drip-mult))
    (set! (-> *part-id-table* 45 init-specs 1 initial-valuef) (* 0.9 (-> self water-drip-mult)))
    (set! (-> *part-id-table* 43 init-specs 11 initial-valuef) (* -2.7306666 (-> self water-drip-speed)))
    (set! (-> *part-id-table* 44 init-specs 8 initial-valuef) (* -2.7306666 (-> self water-drip-speed)))
    (set! (-> *part-id-table* 41 init-specs 11 initial-valuef) (* -2.7306666 (-> self water-drip-speed)))
    (set! (-> *part-id-table* 42 init-specs 8 initial-valuef) (* -2.7306666 (-> self water-drip-speed)))
    (spawn (-> self water-drip) *zero-vector*)
    )
  0
  (none)
  )

(defun sparticle-track-sun ((arg0 int) (arg1 sparticle-cpuinfo) (arg2 matrix))
  (-> arg1 key)
  (let* ((s3-0 (the int (-> arg1 user-float)))
         (s5-0 (math-camera-pos))
         (s4-0 (+ (the-as uint (-> *sky-work* upload-data)) (* (/ s3-0 4) 64)))
         )
    (let ((v1-3 (/ s3-0 4)))
      (cond
        ((zero? v1-3)
         (set! (-> arg2 vector 1 z) (+ 8192.0 (* 0.5 (vector-y-angle (-> (math-camera-matrix) vector 2)))))
         )
        ((= v1-3 1)
         (set! (-> arg2 vector 1 z) (+ -8192.0 (* 0.5 (vector-y-angle (-> (math-camera-matrix) vector 2)))))
         )
        )
      )
    (let ((v1-12 (vector+float*! (new 'stack-no-clear 'vector) s5-0 (the-as vector s4-0) 4096.0)))
      (set! (-> arg2 vector 0 x) (-> v1-12 x))
      (set! (-> arg2 vector 0 y) (-> v1-12 y))
      (set! (-> arg2 vector 0 z) (-> v1-12 z))
      )
    )
  0
  (none)
  )

(defpartgroup group-sun
  :id 3
  :flags (always-draw)
  :bounds (static-bspherem 0 0 0 70)
  :parts ((sp-item 67 :flags (bit6)) (sp-item 68 :flags (bit6)))
  )

(defpart 67
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 2550))
    (:rot-x (degrees 1687.5))
    (:rot-z (degrees 30))
    (:scale-y (meters 2550))
    (:r 64.0)
    (:g 64.0)
    (:b 16.0)
    (:a 70.0)
    (:omega (degrees 0))
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    (:userdata 1.0)
    (:func 'sparticle-track-sun)
    )
  )

(defpart 68
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 12000))
    (:rot-x (degrees 1687.5))
    (:rot-z (degrees 30))
    (:scale-y (meters 12000))
    (:r 64.0)
    (:g 32.0)
    (:b 0.0)
    (:a 80.0)
    (:omega (degrees 0))
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    (:userdata 1.0)
    (:func 'sparticle-track-sun)
    )
  )

(defpartgroup group-green-sun
  :id 4
  :flags (always-draw)
  :bounds (static-bspherem 0 0 0 70)
  :parts ((sp-item 69 :flags (bit6)) (sp-item 70 :flags (bit6)))
  )

(defpart 69
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 1500))
    (:rot-x (degrees 1125))
    (:rot-z (degrees 30))
    (:scale-y (meters 1500))
    (:r 16.0)
    (:g 64.0)
    (:b 32.0)
    (:a 64.0)
    (:omega (degrees 0))
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    (:userdata 4.0)
    (:func 'sparticle-track-sun)
    )
  )

(defpart 70
  :init-specs ((:texture (glow effects))
    (:num 1.0)
    (:scale-x (meters 3000))
    (:rot-x (degrees 1125))
    (:rot-z (degrees 30))
    (:scale-y (meters 3000))
    (:r 0.0)
    (:g 43.0)
    (:b 8.0)
    (:a 64.0)
    (:omega (degrees 0))
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    (:userdata 4.0)
    (:func 'sparticle-track-sun)
    )
  )

(defpartgroup group-moon
  :id 5
  :flags (always-draw)
  :bounds (static-bspherem 0 0 0 70)
  :parts ((sp-item 71 :flags (bit6)))
  )

(defpart 71
  :init-specs ((:texture (glow-soft effects))
    (:num 1.0)
    (:scale-x (meters 6000))
    (:rot-x (degrees 2992.5))
    (:rot-z (degrees 30))
    (:scale-y (meters 6000))
    (:r 16.0)
    (:g 32.0)
    (:b 64.0)
    (:a 64.0)
    (:omega (degrees 0))
    (:timer (seconds -0.005))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow))
    (:userdata 8.0)
    (:func 'sparticle-track-sun)
    )
  )
