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

;; definition of type dark-eco-pool
(deftype dark-eco-pool (water-anim)
  ()
  :heap-base #x70
  :method-count-assert 30
  :size-assert         #xdc
  :flag-assert         #x1e007000dc
  )

;; definition for method 3 of type dark-eco-pool
(defmethod inspect dark-eco-pool ((obj dark-eco-pool))
  (let ((t9-0 (method-of-type water-anim inspect)))
    (t9-0 obj)
    )
  obj
  )

;; definition for symbol ripple-for-misty-dark-eco-pool, type ripple-wave-set
(define ripple-for-misty-dark-eco-pool (new 'static 'ripple-wave-set
                                         :count 3
                                         :converted #f
                                         :normal-scale 3.0
                                         :wave (new 'static 'inline-array ripple-wave 4
                                           (new 'static 'ripple-wave :scale 40.0 :xdiv 2 :speed 0.5)
                                           (new 'static 'ripple-wave :scale 15.0 :xdiv -2 :zdiv 2 :speed 2.0)
                                           (new 'static 'ripple-wave :scale 3.0 :xdiv 5 :zdiv 3 :speed 2.0)
                                           (new 'static 'ripple-wave)
                                           )
                                         )
        )

;; definition for symbol ripple-for-maincave-dark-eco-pool, type ripple-wave-set
(define ripple-for-maincave-dark-eco-pool
  (new 'static 'ripple-wave-set
    :count 3
    :converted #f
    :normal-scale 8.57
    :wave (new 'static 'inline-array ripple-wave 4
      (new 'static 'ripple-wave :scale 14.0 :xdiv 1 :speed 1.0)
      (new 'static 'ripple-wave :scale 5.25 :xdiv -1 :zdiv 1 :speed 4.0)
      (new 'static 'ripple-wave :scale 0.7 :xdiv 5 :zdiv 3 :speed 2.0)
      (new 'static 'ripple-wave)
      )
    )
  )

;; definition for symbol ripple-for-finalboss-dark-eco-pool, type ripple-wave-set
(define ripple-for-finalboss-dark-eco-pool
  (new 'static 'ripple-wave-set
    :count 3
    :converted #f
    :normal-scale 4.0
    :wave (new 'static 'inline-array ripple-wave 4
      (new 'static 'ripple-wave :scale 25.0 :xdiv 2 :speed -2.0)
      (new 'static 'ripple-wave :scale 15.0 :xdiv -2 :zdiv 2 :speed 3.0)
      (new 'static 'ripple-wave :scale 4.0 :xdiv 5 :zdiv 3 :speed 4.0)
      (new 'static 'ripple-wave)
      )
    )
  )

;; definition for symbol ripple-for-dark-eco-pool, type ripple-wave-set
(define ripple-for-dark-eco-pool (new 'static 'ripple-wave-set
                                   :count 3
                                   :converted #f
                                   :normal-scale 3.0
                                   :wave (new 'static 'inline-array ripple-wave 4
                                     (new 'static 'ripple-wave :scale 40.0 :xdiv 1 :speed 1.0)
                                     (new 'static 'ripple-wave :scale 15.0 :xdiv -1 :zdiv 1 :speed 4.0)
                                     (new 'static 'ripple-wave :scale 2.0 :xdiv 5 :zdiv 3 :speed 2.0)
                                     (new 'static 'ripple-wave)
                                     )
                                   )
        )

;; definition for symbol ripple-for-sunken-dark-eco-helix-room, type ripple-wave-set
(define ripple-for-sunken-dark-eco-helix-room
  (new 'static 'ripple-wave-set
    :count 3
    :converted #f
    :normal-scale 8.0
    :wave (new 'static 'inline-array ripple-wave 4
      (new 'static 'ripple-wave :scale 15.0 :xdiv 1 :speed 1.0)
      (new 'static 'ripple-wave :scale 5.625 :xdiv -1 :zdiv 1 :speed 4.0)
      (new 'static 'ripple-wave :scale 0.75 :xdiv 5 :zdiv 3 :speed 2.0)
      (new 'static 'ripple-wave)
      )
    )
  )

;; definition for method 25 of type dark-eco-pool
;; INFO: Return type mismatch object vs none.
(defmethod TODO-RENAME-25 dark-eco-pool ((obj dark-eco-pool))
  (let ((t9-0 (method-of-type water-anim TODO-RENAME-25)))
    (t9-0 obj)
    )
  (logclear! (-> obj flags) (water-flags wt23))
  (set! (-> obj flags) (logior (water-flags wt24) (-> obj flags)))
  (set! (-> obj attack-event)
        (the-as symbol ((the-as
                          (function res-lump symbol symbol float structure (pointer res-tag) pointer object)
                          (method-of-type res-lump get-property-struct)
                          )
                        (-> obj entity)
                        'attack-event
                        'interp
                        -1000000000.0
                        'dark-eco-pool
                        (the-as (pointer res-tag) #f)
                        *res-static-buf*
                        )
                )
        )
  (none)
  )

;; definition for method 22 of type dark-eco-pool
;; INFO: Return type mismatch ripple-wave-set vs none.
(defmethod TODO-RENAME-22 dark-eco-pool ((obj dark-eco-pool))
  (let ((t9-0 (method-of-type water-anim TODO-RENAME-22)))
    (t9-0 obj)
    )
  (let ((gp-0 (new 'process 'ripple-control)))
    (set! (-> obj draw ripple) gp-0)
    (set! (-> gp-0 global-scale) 3072.0)
    (set! (-> gp-0 close-fade-dist) 163840.0)
    (set! (-> gp-0 far-fade-dist) 245760.0)
    (set! (-> gp-0 waveform) ripple-for-dark-eco-pool)
    (set! (-> gp-0 query) (new 'process 'ripple-merc-query 100))
    (case (-> obj look)
      ((32)
       (set! (-> gp-0 waveform) ripple-for-misty-dark-eco-pool)
       )
      ((15 16 17 18 19 20)
       (set! (-> gp-0 waveform) ripple-for-maincave-dark-eco-pool)
       )
      ((40)
       (set! (-> gp-0 waveform) ripple-for-sunken-dark-eco-helix-room)
       )
      ((41)
       (set! (-> gp-0 waveform) ripple-for-finalboss-dark-eco-pool)
       )
      )
    )
  (none)
  )

;; failed to figure out what this is:
(defpartgroup group-dark-eco-nasty
  :id 444
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2020 :fade-after (meters 50)))
  )

;; failed to figure out what this is:
(defpart 2020
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-y (meters 0))
    (sp-rnd-flt spt-scale-x (meters 1) (meters 4) 1.0)
    (sp-flt spt-scale-y (meters 0.25))
    (sp-flt spt-r 255.0)
    (sp-flt spt-g 255.0)
    (sp-flt spt-b 255.0)
    (sp-rnd-flt spt-a 96.0 32.0 1.0)
    (sp-flt spt-scalevel-x (meters 0.1875))
    (sp-flt spt-scalevel-y (meters -0.001875))
    (sp-flt spt-fade-a -3.2)
    (sp-int spt-timer 10)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int spt-next-time 15)
    (sp-launcher-by-id spt-next-launcher 2021)
    )
  )

;; failed to figure out what this is:
(defpart 2021
  :init-specs ((sp-flt spt-r 255.0) (sp-rnd-flt spt-g 128.0 128.0 1.0) (sp-flt spt-b 0.0) (sp-flt spt-fade-a -1.28))
  )

;; failed to figure out what this is:
(defpartgroup group-dark-eco-pool-nasty
  :id 445
  :duration 600
  :linger-duration 600
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 12)
  :parts ((sp-item 2056 :fade-after (meters 100) :period 600 :length 5)
    (sp-item 2057 :fade-after (meters 100) :period 600 :length 5 :binding 2052)
    (sp-item 2052 :flags (start-dead launch-asap) :binding 2053)
    (sp-item 2053 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2052 :flags (start-dead launch-asap) :binding 2053)
    (sp-item 2053 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2052 :flags (start-dead launch-asap) :binding 2053)
    (sp-item 2053 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2052 :flags (start-dead launch-asap) :binding 2053)
    (sp-item 2053 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2058 :fade-after (meters 100) :period 600 :length 5 :binding 2054)
    (sp-item 2054 :flags (start-dead launch-asap) :binding 2055)
    (sp-item 2055 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2054 :flags (start-dead launch-asap) :binding 2055)
    (sp-item 2055 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2054 :flags (start-dead launch-asap) :binding 2055)
    (sp-item 2055 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    (sp-item 2054 :flags (start-dead launch-asap) :binding 2055)
    (sp-item 2055 :fade-after (meters 80) :falloff-to (meters 100) :flags (start-dead))
    )
  )

;; failed to figure out what this is:
(defpart 2056
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 8))
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 96.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 64.0 32.0 1.0)
    (sp-flt spt-a 64.0)
    (sp-flt spt-fade-a -1.8285716)
    (sp-int spt-timer 54)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2057
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-rnd-flt spt-num 1.0 6.0 1.0)
    (sp-flt spt-y (meters 1))
    (sp-flt spt-scale-x (meters 0.1))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.02) 1.0)
    (sp-flt spt-accel-y -3.4133334)
    (sp-flt spt-friction 0.94)
    (sp-int spt-timer 240)
    (sp-cpuinfo-flags bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 140.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2052
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-y (meters 0) (meters 16) 1.0)
    (sp-rnd-flt spt-z (meters 0.3) (meters 0.3) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.4) (meters 0.3) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 0.0 96.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 64.0 32.0 1.0)
    (sp-rnd-flt spt-a 64.0 64.0 1.0)
    (sp-rnd-flt spt-omega 0.0 65536.0 1.0)
    (sp-rnd-flt spt-vel-x (meters 0.026666667) (meters 0.10666667) 1.0)
    (sp-flt spt-scalevel-x (meters -0.000909091))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-g -0.26666668)
    (sp-flt spt-fade-a -0.19393939)
    (sp-int-plain-rnd spt-timer 60 179 1)
    (sp-cpuinfo-flags bit2 bit3 bit7 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2053
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.4) (meters 0.1) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 32.0 96.0 1.0)
    (sp-rnd-flt spt-g 0.0 32.0 1.0)
    (sp-rnd-flt spt-b 64.0 32.0 1.0)
    (sp-rnd-flt spt-a 32.0 32.0 1.0)
    (sp-flt spt-scalevel-x (meters -0.0006190476))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.01904762)
    (sp-rnd-flt spt-accel-y -0.40960002 -0.6144 1.0)
    (sp-int-plain-rnd spt-timer 30 239 1)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int spt-next-time 240)
    (sp-launcher-by-id spt-next-launcher 198)
    )
  )

;; failed to figure out what this is:
(defpart 2058
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-rnd-flt spt-num 1.0 6.0 1.0)
    (sp-flt spt-y (meters 1))
    (sp-flt spt-scale-x (meters 0.1))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.02) 1.0)
    (sp-flt spt-accel-y -3.4133334)
    (sp-flt spt-friction 0.94)
    (sp-int spt-timer 240)
    (sp-cpuinfo-flags bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 140.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2054
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-y (meters 0) (meters 16) 1.0)
    (sp-rnd-flt spt-z (meters 0.3) (meters 0.3) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.4) (meters 0.3) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 16.0 32.0 1.0)
    (sp-rnd-flt spt-g 0.0 16.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 64.0 64.0 1.0)
    (sp-rnd-flt spt-omega 0.0 65536.0 1.0)
    (sp-rnd-flt spt-vel-x (meters 0.026666667) (meters 0.10666667) 1.0)
    (sp-flt spt-scalevel-x (meters -0.000909091))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-g -0.26666668)
    (sp-flt spt-fade-a -0.19393939)
    (sp-int-plain-rnd spt-timer 60 179 1)
    (sp-cpuinfo-flags bit2 bit3 bit7 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2055
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.4) (meters 0.1) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 16.0 32.0 1.0)
    (sp-rnd-flt spt-g 0.0 16.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 32.0 1.0)
    (sp-flt spt-scalevel-x (meters -0.0006190476))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.01904762)
    (sp-rnd-flt spt-accel-y -0.40960002 -0.6144 1.0)
    (sp-int-plain-rnd spt-timer 30 239 1)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int spt-next-time 240)
    (sp-launcher-by-id spt-next-launcher 198)
    )
  )

;; failed to figure out what this is:
(defstate water-vol-idle (dark-eco-pool)
  :virtual #t
  :trans (behavior ()
    (let ((t9-0 (-> (method-of-type water-anim water-vol-idle) trans)))
      (if t9-0
          (t9-0)
          )
      )
    (let* ((gp-0 (-> self draw ripple))
           (f0-1 (the float (logand (-> *display* base-frame-counter) #xffff)))
           (f0-3 (cos (* 5.0 f0-1)))
           (f30-0 (* f0-3 f0-3))
           )
      (let ((s5-0 (-> self draw ripple query)))
        (set! (-> self draw ripple send-query) #t)
        (set! (-> s5-0 start-vertex) (rand-vu-int-range 0 255))
        (set! (-> s5-0 vertex-skip) 256)
        (when (zero? (rand-vu-int-range 0 15))
          (when (and (nonzero? (-> s5-0 vertex-count)) (< #x32000 (memory-free *nk-dead-pool*)))
            (let ((s3-0 (rand-vu-int-range 0 (+ (-> s5-0 vertex-count) -1))))
              (process-spawn
                part-tracker
                :init part-tracker-init
                (-> *part-group-id-table* 445)
                -1
                #f
                #f
                #f
                (-> s5-0 data s3-0)
                :to *entity-pool*
                )
              )
            )
          )
        )
      (case (-> self look)
        ((32)
         (set! (-> gp-0 global-scale) (* 4096.0 (* 1.5 (+ 1.0 f30-0))))
         (set! (-> gp-0 individual-normal-scale) (+ 0.5 (* 0.5 f30-0)))
         )
        (else
          (set! (-> gp-0 global-scale) (* 4096.0 (* 3.0 (+ 1.0 f30-0))))
          (set! (-> gp-0 individual-normal-scale) (+ 0.5 (* 0.5 f30-0)))
          )
        )
      )
    (none)
    )
  )
