;;-*-Lisp-*-
(in-package goal)
(bundles "BEA.DGO")
(require "engine/gfx/sprite/sparticle/sparticle-launcher.gc")
(require "engine/common-obs/generic-obs-h.gc")

;; DECOMP BEGINS

(deftype beach-part (part-spawner) ()
  (:states
   beach-part-grotto-1))


(defpart 666
  :init-specs
  ((:texture (flare effects))
   (:num 0.01)
   (:y (meters 1))
   (:scale-x (meters 15) (meters 5))
   (:rot-x 4)
   (:rot-z (degrees -110) (degrees 20))
   (:scale-y (meters 5))
   (:r 192.0)
   (:g 192.0)
   (:b 128.0)
   (:a 0.0)
   (:scalevel-x (meters 0.0009765625))
   (:rotvel-z (degrees -0.0033333332) (degrees 0.0066666664))
   (:scalevel-y (meters 0.0009765625))
   (:fade-a 0.02)
   (:timer (seconds 8))
   (:flags (bit2 bit3 bit14))
   (:next-time (seconds 4))
   (:next-launcher 667)
   (:conerot-x (degrees 90))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 8))
   (:rotate-y (degrees 0))))

(defpart 667
  :init-specs ((:fade-a -0.02)))

(defpart 668
  :init-specs
  ((:texture (lakedrop effects))
   (:num 0.03 0.2)
   (:y (meters -4))
   (:scale-x (meters 0.18))
   (:scale-y :copy scale-x)
   (:r 192.0)
   (:g 192.0)
   (:b 128.0)
   (:a 0.0)
   (:fade-a 0.21333334)
   (:timer (seconds 2))
   (:flags (bit2 bit3))
   (:userdata 0.0)
   (:next-time (seconds 0.5))
   (:next-launcher 669)
   (:conerot-x (degrees 90))
   (:conerot-y (degrees 0) (degrees 360))
   (:conerot-radius (meters 8) (meters 5))))

(defpart 669
  :init-specs
  ((:scalevel-y (meters 0.0024414062))
   (:fade-a 0.0)
   (:accel-y (meters -0.002))
   (:next-time (seconds 0.7))
   (:next-launcher 670)))

(defpart 670
  :init-specs ((:fade-a -0.16) (:timer (seconds 0.5)) (:func 'check-water-level-drop)))

(defstate beach-part-grotto-1 (beach-part)
  :code
    (behavior ()
      (loop
        (when (is-visible? self)
          (let* ((gp-0 (camera-pos))
                 (f0-0 (vector-vector-distance (-> self root trans) gp-0)))
            (if (or (< (-> gp-0 y) (-> self root trans y)) (< 122880.0 f0-0))
              (launch-particles (-> *part-id-table* 666) (-> self root trans))))
          (launch-particles (-> *part-id-table* 668) (-> self root trans)))
        (suspend))))

(defpart 671
  :init-specs
  ((:texture (lakedrop effects))
   (:num 0.3 0.4)
   (:x (meters -23) (meters 55))
   (:z (meters 0.5))
   (:scale-x (meters 0.18))
   (:scale-y :copy scale-x)
   (:r 192.0)
   (:g 192.0)
   (:b 128.0)
   (:a 0.0)
   (:fade-a 0.10666667)
   (:timer (seconds 2))
   (:flags (bit2 bit3))
   (:userdata 0.0)
   (:next-time (seconds 1))
   (:next-launcher 669)
   (:conerot-x (degrees -40) (degrees 80))
   (:conerot-radius (meters 14.6))
   (:rotate-y (degrees 37))))

(defpartgroup group-beach-grotto-2
  :id 161
  :bounds (static-bspherem 0 -5 0 15)
  :parts ((sp-item 671 :fade-after (meters 80) :falloff-to (meters 80))))

(defpart 672
  :init-specs
  ((:texture (falls-particle effects))
   (:num 1.0 1.0)
   (:x (meters -10) (meters 4))
   (:y (meters 103))
   (:z (meters -8.5) (meters 16))
   (:scale-x (meters 2.4) (meters 1.6))
   (:scale-y (meters 1.2) (meters 0.8))
   (:r 192.0)
   (:g 192.0)
   (:b 192.0)
   (:a 24.0 16.0)
   (:vel-x (meters 0.06666667))
   (:vel-y (meters 0.013333334) (meters 0.013333334))
   (:vel-z (meters -0.0033333334) (meters 0.006666667))
   (:scalevel-x (meters 0.0073242188))
   (:scalevel-y (meters 0.029296875))
   (:accel-x (meters -0.00091074686))
   (:accel-y (meters -0.0036666668) (meters -0.00066666666))
   (:timer (seconds 1.65))
   (:flags (bit2 bit12 bit14))
   (:launchrot-x (degrees -15) (degrees 30))
   (:rotate-y (degrees -124.99999))))

(defpart 673
  :init-specs
  ((:texture (bigpuff effects))
   (:num 0.8 0.8)
   (:x (meters -9) (meters 3.5))
   (:y (meters 103))
   (:z (meters -8.5) (meters 16))
   (:scale-x (meters 1.2) (meters 0.8))
   (:rot-z (degrees 0) (degrees 180))
   (:scale-y (meters 1.2) (meters 0.8))
   (:r 192.0)
   (:g 192.0)
   (:b 192.0)
   (:a 16.0 20.0)
   (:vel-x (meters 0.038333334))
   (:vel-y (meters 0.0033333334) (meters 0.01))
   (:vel-z (meters -0.0033333334) (meters 0.006666667))
   (:scalevel-x (meters 0.0146484375))
   (:rotvel-z (degrees -0.6) (degrees 1.2))
   (:scalevel-y (meters 0.0146484375))
   (:accel-x (meters -0.00029040404))
   (:accel-y (meters -0.0011666666) (meters -0.00025))
   (:timer (seconds 2.85))
   (:flags (bit2 bit12 bit14))
   (:rotate-y (degrees -124.99999))))

(defpart 674
  :init-specs
  ((:texture (middot effects))
   (:num 0.9)
   (:x (meters -10) (meters 4))
   (:y (meters 103))
   (:z (meters -9.5) (meters 18))
   (:scale-x (meters 0.2) (meters 0.2))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:g 128.0)
   (:b 128.0)
   (:a 28.0)
   (:vel-x (meters 0.06) (meters 0.006666667))
   (:vel-y (meters 0.0033333334) (meters 0.02))
   (:vel-z (meters -0.006666667) (meters 0.013333334))
   (:scalevel-x (meters -0.00024414062))
   (:scalevel-y (meters 0.001953125))
   (:accel-x (meters -0.00062500004))
   (:accel-y (meters -0.0016666667) (meters -0.00083333335))
   (:timer (seconds 2.2))
   (:flags (bit2 bit3 bit12 bit14))
   (:launchrot-x (degrees -20) (degrees 40))
   (:rotate-y (degrees -124.99999))))

(defpart 675
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.04)
   (:x (meters 6) (meters 6))
   (:y (meters 6.5))
   (:z (meters -8.5) (meters 16))
   (:scale-x (meters 18))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:g 128.0)
   (:b 128.0)
   (:a 0.0 32.0)
   (:vel-x (meters -0.006666667) (meters 0.026666667))
   (:vel-y (meters 0.016666668) (meters 0.033333335))
   (:vel-z (meters -0.006666667) (meters 0.013333334))
   (:scalevel-x (meters 0.0044444446))
   (:rotvel-z (degrees -0.3) (degrees 0.6))
   (:scalevel-y :copy scalevel-x)
   (:fade-a 0.42666668)
   (:accel-y (meters 0.000033333334))
   (:friction 0.99)
   (:timer (seconds 3.5))
   (:flags (bit2 bit12 bit14))
   (:next-time (seconds 0.3) (seconds 0.197))
   (:next-launcher 676)
   (:rotate-y (degrees -124.99999))))

(defpart 676
  :init-specs ((:fade-a -0.14222223)))

(defpart 677
  :init-specs
  ((:texture (bigpuff-half effects))
   (:num 0.2)
   (:x (meters 2) (meters 10))
   (:y (meters 8))
   (:z (meters -10.5) (meters 20))
   (:scale-x (meters 18))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:g 150.0 42.0)
   (:b 192.0)
   (:a 32.0 32.0)
   (:vel-x (meters 0) (meters 0.06666667))
   (:vel-y (meters 0.008333334))
   (:vel-z (meters -0.006666667) (meters 0.013333334))
   (:scalevel-x (meters 0.01) (meters 0.01))
   (:scalevel-y (meters 0.006666667) (meters 0.006666667))
   (:fade-a 0.42666668)
   (:accel-y (meters 0.000033333334))
   (:friction 0.99)
   (:timer (seconds 3.5))
   (:flags (bit2 bit12 bit14))
   (:next-time (seconds 0.3) (seconds 0.197))
   (:next-launcher 676)
   (:rotate-y (degrees -124.99999))))

(defpartgroup group-beach-waterfall
  :id 162
  :flags (always-draw unknown-bit-01)
  :bounds (static-bspherem 0 55 0 55)
  :parts
  ((sp-item 677 :fade-after (meters 200) :falloff-to (meters 200))
   (sp-item 675)
   (sp-item 675 :fade-after (meters 200) :falloff-to (meters 200))
   (sp-item 672)
   (sp-item 672 :fade-after (meters 100) :falloff-to (meters 100))
   (sp-item 672 :fade-after (meters 160) :falloff-to (meters 160))
   (sp-item 673 :fade-after (meters 300) :falloff-to (meters 300))
   (sp-item 674 :fade-after (meters 90) :falloff-to (meters 90))))

(defpartgroup group-beach-24
  :id 163
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 678 :fade-after (meters 50) :period (seconds 8) :length (seconds 5) :offset 1200)))

(defpartgroup group-beach-23
  :id 164
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 679 :fade-after (meters 50) :period (seconds 8) :length (seconds 5) :offset 600)))

(defpartgroup group-beach-22
  :id 165
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 680 :fade-after (meters 80) :period (seconds 8) :length (seconds 5))))

(defpartgroup group-beach-18
  :id 166
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 681 :fade-after (meters 100) :period (seconds 8) :length (seconds 5) :offset 1200)))

(defpartgroup group-beach-17
  :id 167
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 682 :fade-after (meters 50) :period (seconds 8) :length (seconds 5) :offset 600)))

(defpartgroup group-beach-16
  :id 168
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 683 :fade-after (meters 50) :period (seconds 8) :length (seconds 5))))

(defpartgroup group-beach-15
  :id 169
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 684 :fade-after (meters 50) :period (seconds 8) :length (seconds 5) :offset 64936)))

(defpartgroup group-beach-14
  :id 170
  :bounds (static-bspherem 0 3 0 50)
  :parts ((sp-item 685 :fade-after (meters 50) :period (seconds 8) :length (seconds 5) :offset 64336)))

(defpart 678
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.01 0.01)
   (:x (meters -85) (meters 60))
   (:y (meters 13))
   (:z (meters -30) (meters 65))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.008888889)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 6))
   (:next-launcher 686)
   (:rotate-y (degrees 40))))

(defpart 686
  :init-specs ((:fade-a -0.07111111)))

(defpart 679
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.01 0.01)
   (:x (meters -65) (meters 60))
   (:y (meters 8))
   (:z (meters -30) (meters 50))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.02))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.008888889)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 6))
   (:next-launcher 687)
   (:rotate-y (degrees 40))))

(defpart 687
  :init-specs ((:fade-a -0.07111111)))

(defpart 680
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.01 0.01)
   (:x (meters -50) (meters 20))
   (:y (meters 0))
   (:z (meters -40) (meters 80))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:vel-z (meters 0.016666668))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.010666667)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 5))
   (:next-launcher 688)
   (:rotate-y (degrees 120))))

(defpart 688
  :init-specs ((:fade-a -0.08533333)))

(defpart 681
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.03 0.04)
   (:x (meters -40) (meters 20))
   (:y (meters 1))
   (:z (meters -40) (meters 90))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:vel-z (meters -0.016666668))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.008888889)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 6))
   (:next-launcher 689)
   (:rotate-y (degrees -60))))

(defpart 689
  :init-specs ((:fade-a -0.07111111)))

(defpart 682
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.015 0.02)
   (:x (meters -10))
   (:y (meters 1))
   (:z (meters -10) (meters 22.5))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.017777778)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 3))
   (:next-launcher 690)
   (:rotate-y (degrees -15))))

(defpart 690
  :init-specs ((:fade-a -0.017777778)))

(defpart 683
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.015 0.02)
   (:x (meters -25))
   (:y (meters 1))
   (:z (meters -15) (meters 50))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.013333334)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 4))
   (:next-launcher 691)
   (:rotate-y (degrees 0))))

(defpart 691
  :init-specs ((:fade-a -0.013333334)))

(defpart 684
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.015 0.015)
   (:x (meters -35))
   (:y (meters 1))
   (:z (meters -35) (meters 60))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.016410256)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 3.25))
   (:next-launcher 692)
   (:rotate-y (degrees 45))))

(defpart 692
  :init-specs ((:fade-a -0.016410256)))

(defpart 685
  :init-specs
  ((:texture (falls-particle-02 effects))
   (:num 0.015 0.015)
   (:x (meters -25))
   (:y (meters 14))
   (:z (meters -15) (meters 70))
   (:scale-x (meters 10) (meters 20))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 130.0)
   (:g 100.0)
   (:b 54.0)
   (:a 0.0)
   (:vel-x (meters 0.026666667))
   (:rotvel-z (degrees -0.15))
   (:fade-a 0.014222222)
   (:timer (seconds 12))
   (:flags (bit2 bit12))
   (:next-time (seconds 3.75))
   (:next-launcher 693)
   (:rotate-y (degrees 0))))

(defpart 693
  :init-specs ((:fade-a -0.014222222)))

(define sound-beach-waterfall (static-sound-spec "waterfall"))

(defpartgroup group-beach-butterflies
  :id 171
  :bounds (static-bspherem 0 0 0 30)
  :parts
  ((sp-item 696
            :fade-after (meters 120)
            :period (seconds 16.345)
            :length (seconds 0.017)
            :hour-mask #b111111100000000000111111
            :binding 694)
   (sp-item 696
            :fade-after (meters 120)
            :period (seconds 22.125)
            :length (seconds 0.017)
            :hour-mask #b111111100000000000111111
            :binding 694)
   (sp-item 696
            :fade-after (meters 120)
            :period (seconds 32.82)
            :length (seconds 0.017)
            :hour-mask #b111111100000000000111111
            :binding 694)
   (sp-item 694 :flags (start-dead launch-asap) :binding 695)
   (sp-item 695 :flags (is-3d start-dead))
   (sp-item 694 :flags (start-dead launch-asap) :binding 695)
   (sp-item 695 :flags (is-3d start-dead))
   (sp-item 694 :flags (start-dead launch-asap) :binding 695)
   (sp-item 695 :flags (is-3d start-dead))
   (sp-item 694 :flags (start-dead launch-asap) :binding 695)
   (sp-item 695 :flags (is-3d start-dead))
   (sp-item 694 :flags (start-dead launch-asap) :binding 695)
   (sp-item 695 :flags (is-3d start-dead))))

(defpart 696
  :init-specs
  ((:texture (hotdot effects))
   (:num 1.0)
   (:x (meters 0) (meters 7.5))
   (:y (meters 14) (meters 3))
   (:scale-x (meters 1))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:a 0.0)
   (:vel-y (meters -0.036666665))
   (:accel-y (meters 0.00033333333))
   (:timer (seconds 20))
   (:flags (bit3))
   (:next-time (seconds 1.85))
   (:next-launcher 697)
   (:rotate-y (degrees 0) (degrees 360))))

(defpart 697
  :init-specs ((:accel-y (meters 0)) (:next-time (seconds 9) (seconds 4.997)) (:next-launcher 698)))

(defpart 698
  :init-specs ((:accel-y (meters 0.00033333333))))

(defpart 694
  :init-specs
  ((:texture (hotdot effects))
   (:num 1.0)
   (:x (meters 0) (meters 16))
   (:y (meters 0) (meters 16))
   (:z (meters 3) (meters 1))
   (:scale-x (meters 0.1))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:g 0.0 256.0)
   (:b 128.0 1 128.0)
   (:a 0.0)
   (:omega 0.0 65536.0)
   (:vel-x (meters -0.017777778) (meters 0.035555556))
   (:vel-y (meters -0.0074074077) (meters 0.0148148155))
   (:vel-z (meters 0))
   (:timer (seconds 20))
   (:flags (bit3 bit7))
   (:next-time (seconds 0.5) (seconds 1.497))
   (:next-launcher 699)))

(defpart 699
  :init-specs
  ((:vel-x (meters -0.017777778) (meters 0.035555556))
   (:vel-y (meters -0.0074074077) (meters 0.0148148155))
   (:rotvel-z (degrees -0.2) (degrees 0.4))
   (:next-time (seconds 0.5) (seconds 1.497))
   (:next-launcher 699)))

(defpart 695
  :init-specs
  ((:texture (butterfly-wing effects))
   (:birth-func 'birth-func-copy-rot-color)
   (:num 2.0)
   (:scale-x (meters 0.9))
   (:rot-x (degrees -60) (degrees 300))
   (:scale-y (meters 1.3))
   (:r 255.0)
   (:g 255.0)
   (:b 255.0)
   (:a 128.0)
   (:fade-a -8.0)
   (:timer (seconds 0.035))
   (:flags (bit2 bit9 bit12))))

(defpartgroup group-beach-moth
  :id 172
  :bounds (static-bspherem 0 0 0 3)
  :parts
  ((sp-item 702
            :fade-after (meters 120)
            :flags (bit1)
            :period (seconds 60.1)
            :length (seconds 0.017)
            :hour-mask #b1111111110000000
            :binding 700)
   (sp-item 700 :flags (start-dead launch-asap) :binding 701)
   (sp-item 701 :flags (is-3d start-dead))))

(defpart 702
  :init-specs
  ((:texture (hotdot effects))
   (:num 1.0)
   (:scale-x (meters 0.1))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:a 0.0)
   (:timer (seconds 60))
   (:flags (bit3))
   (:rotate-y (degrees 0) (degrees 360))))

(defpart 700
  :init-specs
  ((:texture (hotdot effects))
   (:num 1.0)
   (:y (meters 0) (meters 16))
   (:z (meters 1.5))
   (:scale-x (meters 0.1))
   (:rot-z (degrees 0) (degrees 360))
   (:scale-y :copy scale-x)
   (:r 128.0)
   (:g 128.0)
   (:b 128.0)
   (:a 0.0)
   (:omega 0.0 65536.0)
   (:vel-x (meters 0.0044444446) (meters 0.0044444446))
   (:vel-y (meters 0.008888889) (meters 0.008888889))
   (:vel-z (meters 0))
   (:timer (seconds 60))
   (:flags (bit3 bit7))
   (:next-time (seconds 0.5) (seconds 1.497))
   (:next-launcher 703)))

(defpart 703
  :init-specs
  ((:vel-x (meters -0.035555556) (meters 0.07111111))
   (:vel-y (meters -0.0148148155) (meters 0.029629631))
   (:rotvel-z (degrees -0.4) (degrees 0.8))
   (:next-time (seconds 0.5) (seconds 1.497))
   (:next-launcher 703)))

(defpart 701
  :init-specs
  ((:texture (butterfly-wing effects))
   (:birth-func 'birth-func-copy-rot-color)
   (:num 2.0)
   (:scale-x (meters 0.4))
   (:rot-x (degrees -60) (degrees 300))
   (:scale-y (meters 0.4))
   (:r 128.0)
   (:g 128.0)
   (:b 128.0)
   (:a 128.0)
   (:timer (seconds 0.017))
   (:flags (bit2 bit3 bit9 bit12))))
