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

;; name: water.gc
;; name in dgo: water
;; dgos: ENGINE, GAME

;; DECOMP BEGINS

(defun check-water-level-drop ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (when (and (< (-> arg2 y) (-> arg1 user-float)) (< (-> arg1 vel-sxvel y) 0.0))
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (sp-kill-particle arg0 arg1)
      (set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
      (sound-play "water-drop" :position gp-0)
      (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 501) gp-0)
      )
    )
  0
  (none)
  )

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

(defun check-water-level-drop-and-die-motion ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (if (and (< (-> arg2 y) (-> arg1 user-float)) (< (-> arg1 vel-sxvel y) 0.0))
      (sp-kill-particle arg0 arg1)
      )
  (sparticle-motion-blur arg0 arg1 arg2)
  (none)
  )

;; WARN: Return type mismatch symbol vs none.
(defun check-water-level-above-and-die ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (if (or (>= (-> arg2 y) (-> arg1 user-float)) (and *target* (>= (-> arg2 y) (-> *target* water height))))
      (sp-kill-particle arg0 arg1)
      )
  (none)
  )

(defpart 502
  :init-specs ((:texture (lakedrop effects))
    (:num 9.0)
    (:x (meters -0.25) (meters 0.5))
    (:y (meters -0.05) (meters 0.1))
    (:z (meters -0.25) (meters 0.5))
    (:scale-x (meters 0.1) (meters 0.1))
    (:scale-y (meters 0.05) (meters 0.05))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 24.0 40.0)
    (:vel-y (meters 0) (meters 0.006666667))
    (:accel-y (meters 0.00016666666) (meters 0.00016666666))
    (:friction 0.96)
    (:timer (seconds 5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-above-and-die)
    (:conerot-x (degrees 90))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(defpart 503
  :init-specs ((:texture (lakedrop effects))
    (:num 0.1)
    (:x (meters -0.25) (meters 0.5))
    (:y (meters 0.15))
    (:z (meters -0.25) (meters 0.5))
    (:scale-x (meters 0.3) (meters 0.1))
    (:scale-y (meters 0.15) (meters 0.05))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 40.0 24.0)
    (:vel-y (meters 0) (meters 0.006666667))
    (:accel-y (meters 0.00033333333))
    (:friction 0.96)
    (:timer (seconds 5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-above-and-die)
    (:conerot-x (degrees 90))
    (:conerot-y (degrees 0) (degrees 360))
    )
  )

(defpart 504
  :init-specs ((:texture (water-ring effects))
    (:num 0.05)
    (:scale-x (meters 1.6) (meters 0.8))
    (:rot-y (degrees 0) (degrees 3600))
    (:scale-y (meters 1.6) (meters 0.8))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 32.0 16.0)
    (:scalevel-x (meters 0.004) (meters 0.0037333334))
    (:scalevel-y (meters 0.004) (meters 0.0037333334))
    (:timer (seconds 2.667))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:next-time (seconds 0.5) (seconds 0.997))
    (:next-launcher 505)
    )
  )

(defpart 506
  :init-specs ((:texture (water-wave effects))
    (:num 0.06)
    (:x (meters 10))
    (:scale-x (meters 0.75) (meters 1.5))
    (:rot-y (degrees 0))
    (:scale-y (meters 0.75) (meters 1.5))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 0.0)
    (:vel-x (meters 0.01) (meters 0.006666667))
    (:scalevel-x (meters 0.0033333334) (meters 0.004333333))
    (:scalevel-y (meters 0.0033333334) (meters 0.004333333))
    (:fade-a 0.7111111)
    (:friction 0.94)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:next-time (seconds 0.3))
    (:next-launcher 507)
    (:rotate-y (degrees 0))
    )
  )

(defpart 507
  :init-specs ((:fade-a 0.0) (:next-time (seconds 0.3) (seconds 0.397)) (:next-launcher 508))
  )

(defpart 508
  :init-specs ((:fade-a -0.21333334))
  )

(defpart 509
  :init-specs ((:texture (explosion-nebula effects))
    (:num 0.05 0.4)
    (:x (meters -0.75) (meters 1.5))
    (:z (meters -0.75) (meters 1.5))
    (:scale-x (meters 0.2) (meters 0.7))
    (:rot-y (degrees 0) (degrees 3600))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 0.0)
    (:scalevel-x (meters 0.0016666667) (meters 0.003))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 0.42666668)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:next-time (seconds 0.5))
    (:next-launcher 510)
    (:rotate-y (degrees 0))
    )
  )

(defpart 510
  :init-specs ((:fade-a 0.0) (:next-time (seconds 1.2)) (:next-launcher 511))
  )

(defpart 511
  :init-specs ((:fade-a -0.7111111))
  )

(defpartgroup group-part-water-splash
  :id 121
  :duration (seconds 3)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 -12 0 14)
  :parts ((sp-item 514 :flags (is-3d) :period (seconds 3) :length (seconds 0.21))
    (sp-item 515 :period (seconds 3) :length (seconds 0.05))
    (sp-item 516 :flags (is-3d) :period (seconds 3) :length (seconds 0.05))
    (sp-item 517 :period (seconds 3) :length (seconds 0.05) :binding 512)
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 518 :flags (is-3d) :period (seconds 3) :length (seconds 0.05) :offset 60)
    (sp-item 519 :flags (is-3d) :period (seconds 3) :length (seconds 0.2) :offset 60)
    (sp-item 520 :period (seconds 3) :length (seconds 0.035) :offset 60 :binding 513)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 513 :flags (start-dead) :period (seconds 3) :length (seconds 0.4) :offset 60)
    (sp-item 521 :period (seconds 3) :length (seconds 0.017))
    (sp-item 521 :period (seconds 3) :length (seconds 0.05))
    (sp-item 521 :period (seconds 3) :length (seconds 0.135))
    (sp-item 522 :flags (launch-asap) :period (seconds 3) :length (seconds 0.017))
    )
  )

(defpartgroup group-part-water-splash-small
  :id 122
  :duration (seconds 3)
  :flags (use-local-clock)
  :bounds (static-bspherem 0 -12 0 14)
  :parts ((sp-item 514 :flags (is-3d) :period (seconds 3) :length (seconds 0.21))
    (sp-item 515 :period (seconds 3) :length (seconds 0.05))
    (sp-item 516 :flags (is-3d) :period (seconds 3) :length (seconds 0.05))
    (sp-item 517 :period (seconds 3) :length (seconds 0.035) :binding 512)
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    (sp-item 512 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
    )
  )

(defpart 512
  :init-specs ((:texture (lakedrop effects))
    (:num 0.2)
    (:x (meters -0.2) (meters 0.4))
    (:y (meters -0.2) (meters 0.4))
    (:scale-x (meters 0.05) (meters 0.15))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 40.0 24.0)
    (:scalevel-x (meters 0.000033333334))
    (:scalevel-y :copy scalevel-x)
    (:accel-y (meters -0.00040000002) (meters -0.00020000001))
    (:timer (seconds 1.5))
    (:flags (sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-drop-and-die)
    )
  )

(defpart 513
  :init-specs ((:texture (lakedrop effects))
    (:num 0.2)
    (:x (meters -0.2) (meters 0.4))
    (:y (meters -0.2) (meters 0.4))
    (:scale-x (meters 0.05) (meters 0.15))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 40.0 24.0)
    (:scalevel-x (meters 0.000033333334))
    (:scalevel-y :copy scalevel-x)
    (:accel-y (meters -0.00040000002) (meters -0.00020000001))
    (:timer (seconds 1.5))
    (:flags (sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-drop-and-die)
    )
  )

(defpart 519
  :init-specs ((:texture (water-ring effects))
    (:num 0.05)
    (:scale-x (meters 0.080000006) (meters 0.32000002))
    (:rot-y (degrees 0) (degrees 360))
    (:scale-y (meters 0.080000006) (meters 0.32000002))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 0.0)
    (:scalevel-x (meters 0.004) (meters 0.0090666665))
    (:scalevel-y (meters 0.004) (meters 0.0090666665))
    (:fade-a 0.32)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:next-time (seconds 0.5))
    (:next-launcher 523)
    )
  )

(defpart 520
  :init-specs ((:texture (lakedrop effects))
    (:num 3.2)
    (:x (meters -0.2) (meters 0.4))
    (:y (meters -0.2) (meters 0.4))
    (:scale-x (meters 0.35) (meters 0.075))
    (:scale-y (meters 0.2) (meters 0.075))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 40.0 24.0)
    (:vel-x (meters -0.002) (meters 0.004))
    (:vel-y (meters 0.018666666) (meters 0.0053333333))
    (:vel-z (meters -0.002) (meters 0.004))
    (:scalevel-x (meters -0.00066666666))
    (:scalevel-y :copy scalevel-x)
    (:accel-y (meters -0.00080000004) (meters -0.00020000001))
    (:timer (seconds 3))
    (:flags (sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-drop)
    (:next-time (seconds 0.4))
    (:next-launcher 524)
    )
  )

(defpart 518
  :init-specs ((:texture (water-splash effects))
    (:num 1.0)
    (:scale-x (meters 0.24000001) (meters 0.71999997))
    (:rot-x (degrees 90))
    (:rot-y (degrees 0) (degrees 360))
    (:rot-z (degrees 0))
    (:scale-y (meters 0.8) (meters 1.7600001))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 32.0 32.0)
    (:scalevel-y (meters 0.053333335) (meters 0.013333334))
    (:timer (seconds 0.8))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat set-conerot))
    (:next-time (seconds 0.067) (seconds 0.065))
    (:next-launcher 525)
    )
  )

(defpart 525
  :init-specs ((:scalevel-y (meters 0.026666667)) (:next-time (seconds 0.067)) (:next-launcher 526))
  )

(defpart 526
  :init-specs ((:scalevel-y (meters 0)) (:fade-a -0.64) (:next-time (seconds 0.067)) (:next-launcher 527))
  )

(defpart 527
  :init-specs ((:scalevel-x (meters 0.0016666667))
    (:scalevel-y (meters -0.026666667))
    (:next-time (seconds 0.067))
    (:next-launcher 528)
    )
  )

(defpart 528
  :init-specs ((:scalevel-x (meters 0.0033333334)) (:scalevel-y (meters -0.053333335)))
  )

(defpart 516
  :init-specs ((:texture (hotdot effects))
    (:birth-func 'birth-func-texture-group)
    (:num 3.0)
    (:scale-x (meters 1.6) (meters 0.8))
    (:rot-y (degrees 0) (degrees 360))
    (:scale-y (meters 1.6) (meters 0.8))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 48.0 16.0)
    (:scalevel-x (meters 0.004) (meters 0.0037333334))
    (:scalevel-y (meters 0.004) (meters 0.0037333334))
    (:timer (seconds 2.667))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat))
    (:userdata :data (new 'static 'boxed-array :type int32 10 0 0 #xc0c900 #xc03300 #xc02c00))
    (:next-time (seconds 0.5) (seconds 0.997))
    (:next-launcher 505)
    )
  )

(defpart 505
  :init-specs ((:fade-a -0.21333334))
  )

(defpart 517
  :init-specs ((:texture (lakedrop effects))
    (:num 3.2)
    (:x (meters 0.96000004))
    (:scale-x (meters 0.35) (meters 0.075))
    (:scale-y (meters 0.2) (meters 0.075))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 40.0 24.0)
    (:vel-x (meters 0.0026666666) (meters 0.0053333333))
    (:vel-y (meters 0.016) (meters 0.0053333333))
    (:scalevel-x (meters -0.00066666666))
    (:scalevel-y :copy scalevel-x)
    (:accel-y (meters -0.00080000004) (meters -0.00020000001))
    (:timer (seconds 3))
    (:flags (sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-drop)
    (:next-time (seconds 0.4))
    (:next-launcher 524)
    (:rotate-y (degrees 0) (degrees 360))
    )
  )

(defpart 524
  :init-specs ((:scalevel-x (meters 0)) (:scalevel-y :copy scalevel-x))
  )

(defpart 515
  :init-specs ((:texture (lakedrop effects))
    (:num 8.0)
    (:x (meters 0.8))
    (:scale-x (meters 0.15) (meters 0.05))
    (:scale-y (meters 0.15) (meters 0.05))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 40.0 24.0)
    (:vel-x (meters 0.0026666666) (meters 0.0053333333))
    (:vel-y (meters 0.0053333333) (meters 0.0053333333))
    (:scalevel-x (meters -0.00033333333))
    (:scalevel-y (meters -0.00033333333))
    (:accel-y (meters -0.0005333334) (meters -0.00013333335))
    (:timer (seconds 1.25))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-drop-and-die)
    (:rotate-y (degrees 0) (degrees 360))
    )
  )

(defpart 514
  :init-specs ((:texture (water-splash effects))
    (:num 1.5)
    (:x (meters 0.16000001) (meters 0.16000001))
    (:scale-x (meters 0.32000002) (meters 0.96000004))
    (:rot-x (degrees 90))
    (:rot-y (degrees 90))
    (:rot-z (degrees 0))
    (:scale-y (meters 0.16000001) (meters 1.7600001))
    (:r 128.0)
    (:g 128.0)
    (:b 128.0)
    (:a 48.0 24.0)
    (:vel-x (meters 0.0026666666))
    (:scalevel-x (meters 0) (meters 0.0016666667))
    (:rotvel-x (degrees 0.2))
    (:scalevel-y (meters 0.04))
    (:timer (seconds 0.8))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 left-multiply-quat set-conerot))
    (:next-time (seconds 0.067) (seconds 0.065))
    (:next-launcher 529)
    (:rotate-y (degrees 0) (degrees 360))
    )
  )

(defpart 529
  :init-specs ((:scalevel-x (meters 0))
    (:rotvel-x (degrees 0.16666667))
    (:scalevel-y (meters 0.016666668))
    (:next-time (seconds 0.067))
    (:next-launcher 530)
    )
  )

(defpart 530
  :init-specs ((:rotvel-x (degrees 0.13333334))
    (:scalevel-y (meters 0))
    (:fade-a -0.64)
    (:next-time (seconds 0.067))
    (:next-launcher 531)
    )
  )

(defpart 531
  :init-specs ((:rotvel-x (degrees 0.1))
    (:scalevel-y (meters -0.016666668))
    (:next-time (seconds 0.067))
    (:next-launcher 532)
    )
  )

(defpart 532
  :init-specs ((:rotvel-x (degrees 0.06666667)) (:scalevel-y (meters -0.033333335)))
  )

(defpart 522
  :init-specs ((:texture (glow-soft effects))
    (:num 1.0)
    (:scale-x (meters 6) (meters 0.1))
    (:rot-x (degrees 11.25))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g :copy r)
    (:b 255.0)
    (:a 0.0)
    (:scalevel-x (meters 0.16))
    (:scalevel-y :copy scalevel-x)
    (:fade-a 1.0666667)
    (:timer (seconds 0.2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow sp-cpuinfo-flag-21))
    (:userdata 10240.0)
    (:next-time (seconds 0.05))
    (:next-launcher 533)
    (:rotate-y (degrees 0))
    )
  )

(defpart 533
  :init-specs ((:fade-a -0.64))
  )

(defpart 521
  :init-specs ((:texture (lakedrop effects))
    (:num 12.0)
    (:y (meters 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 128.0)
    (:omega (degrees 0.01575) (degrees 0.009))
    (:vel-y (meters 0.033333335) (meters 0.05))
    (:accel-y (meters -0.005) (meters -0.00066666666))
    (:friction 0.96 0.02)
    (:timer (seconds 1))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-21))
    (:userdata -208896.0)
    (:func 'check-water-level-drop-motion)
    (:next-time (seconds 0) (seconds 0.58))
    (:next-launcher 63)
    (:conerot-x (degrees 15) (degrees 65))
    (:conerot-y (degrees 0) (degrees 3600))
    (:rotate-y (degrees 0))
    (:conerot-radius (meters 0) (meters 1))
    )
  )

(defpart 63
  :init-specs ((:r 255.0) (:g 255.0) (:b 255.0) (:next-time (seconds 0.017)) (:next-launcher 534))
  )

(defpart 534
  :init-specs ((:r 32.0 32.0) (:g 32.0 32.0) (:b 64.0 32.0) (:next-time (seconds 0) (seconds 1.497)) (:next-launcher 535))
  )

(defpart 501
  :init-specs ((:texture (hotdot effects))
    (:num 0.3)
    (:scale-x (meters 0.5) (meters 0.25))
    (:rot-y (degrees 0) (degrees 360))
    (:scale-y :copy scale-x)
    (:r 32.0 32.0)
    (:g :copy r)
    (:b 64.0 32.0)
    (:a 64.0 32.0)
    (:scalevel-x (meters 0.006666667) (meters 0.006666667))
    (:scalevel-y :copy scalevel-x)
    (:fade-a -0.32 -0.32)
    (:timer (seconds 1.5))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-21))
    (:userdata :data (new 'static 'boxed-array :type int32 10 0 0 #xc0c900 #xc02600 #xc03300 #xc02c00))
    (:func 'sparticle-texture-animate)
    (:rotate-y (degrees 0))
    )
  )

(defpart 536
  :init-specs ((:texture (lakedrop effects))
    (:num 0.0 0.5)
    (: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 128.0)
    (:omega (degrees 0.01575) (degrees 0.009))
    (:vel-y (meters 0.026666667) (meters 0.05))
    (:accel-y (meters -0.005) (meters -0.00066666666))
    (:friction 0.95)
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-21))
    (:userdata -208896.0)
    (:func 'check-water-level-drop-and-die-motion)
    (:next-time (seconds 0) (seconds 0.33))
    (:next-launcher 63)
    (:conerot-x (degrees 30) (degrees 40))
    (:conerot-y (degrees 0) (degrees 3600))
    (:rotate-y (degrees 0))
    )
  )

(defun check-water-level-drop-motion ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (when (and (< (-> arg2 y) (-> arg1 user-float)) (< (-> arg1 vel-sxvel y) 0.0))
    (let ((s3-0 (new 'stack-no-clear 'vector)))
      (sp-kill-particle arg0 arg1)
      (set-vector! s3-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
      (sound-play "water-drop" :position s3-0)
      (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 501) s3-0)
      (set! (-> *part-id-table* 536 init-specs 15 initial-valuef) (-> s3-0 y))
      (launch-particles (-> *part-id-table* 536) s3-0)
      )
    )
  (sparticle-motion-blur arg0 arg1 arg2)
  (none)
  )

(defpart 537
  :init-specs ((:texture (lakedrop effects))
    (:num 1.0)
    (:scale-x (meters 0.15) (meters 0.05))
    (:rot-x 4)
    (:scale-y :copy scale-x)
    (:r 32.0 32.0)
    (:g :copy r)
    (:b 64.0 32.0)
    (:a 128.0)
    (:omega (degrees 0.0225) (degrees 0.0225))
    (:vel-x (meters -0.016666668) (meters 0.0016666667))
    (:vel-y (meters 0.016666668))
    (:vel-z (meters -0.016666668) (meters 0.0016666667))
    (:scalevel-x (meters -0.00016666666))
    (:scalevel-y :copy scalevel-x)
    (:accel-y (meters -0.001) (meters -0.00033333333))
    (:timer (seconds 2))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
    (:userdata 0.0)
    (:func 'check-water-level-drop-motion)
    (:next-time (seconds 2))
    (:next-launcher 538)
    )
  )

(defmethod water-control-method-9 ((this water-control))
  0
  (none)
  )

(defmethod water-control-method-10 ((this water-control))
  (local-vars
    (sv-272 (function vector entity-actor skeleton-group vector object none :behavior manipy))
    (sv-288 vector)
    (sv-304 entity-actor)
    )
  (with-pp
    (let ((s4-0 (-> this flags))
          (s5-0 (new 'stack-no-clear 'water-info))
          )
      (when (logtest? (water-flags find-water) (-> this flags))
        (water-info-init! (the-as collide-shape (-> this process control)) s5-0 (collide-action solid semi-solid))
        (set! (-> this flags)
              (logior (logclear
                        (-> this flags)
                        (water-flags active can-wade can-swim can-ground use-ocean tar mud use-water-anim swamp over-water)
                        )
                      (logclear (-> s5-0 flags) (water-flags touch-water))
                      )
              )
        (set! (-> this base-height) (-> s5-0 base-height))
        (set! (-> this base-ocean-offset) (- (-> s5-0 trans y) (-> s5-0 base-height)))
        )
      (cond
        ((not (logtest? (-> this flags) (water-flags active)))
         (logclear!
           (-> this flags)
           (water-flags under-water head-under-water bouncing wading swimming touch-water jump-out break-surface)
           )
         )
        ((and (logtest? (-> this flags) (water-flags no-grab-ground))
              (logtest? (-> this process focus-status) (focus-status grabbed))
              )
         (logior! (-> this flags) (water-flags jump-out))
         (logclear! (-> this flags) (water-flags break-surface))
         )
        ((begin
           (set! (-> this top 1 quad) (-> this top 0 quad))
           (vector<-cspace! (the-as vector (-> this top)) (-> this process node-list data (-> this joint-index)))
           (+! (-> this top 0 y) (-> this top-y-offset))
           (set! (-> this bottom 1 quad) (-> this bottom 0 quad))
           (set! (-> this bottom 0 quad) (-> this process control trans quad))
           (logclear! (-> this flags) (water-flags under-water head-under-water bouncing wading swimming break-surface))
           (set! (-> this bob-offset) (update! (-> this bob)))
           (cond
             ((logtest? (-> this flags) (water-flags use-ocean use-water-anim))
              (if (not (logtest? (water-flags touch-water) (-> this flags)))
                  (set! (-> this ocean-offset) (-> this base-ocean-offset))
                  (set! (-> this ocean-offset) (lerp (-> this ocean-offset) (-> this base-ocean-offset) 0.2))
                  )
              (set! (-> this base-ocean-offset) 0.0)
              )
             (else
               (set! (-> this base-ocean-offset) 0.0)
               (set! (-> this base-ocean-offset) 0.0)
               (set! (-> this ocean-offset) 0.0)
               )
             )
           (if (logtest? (focus-status board pilot) (-> this process focus-status))
               (set! (-> this bob-offset) 0.0)
               )
           (set! (-> this height)
                 (+ (-> this base-height) (-> this ocean-offset) (-> this bob-offset) (-> this align-offset))
                 )
           (set! (-> this surface-height) (+ (-> this base-height) (-> this base-ocean-offset)))
           (cond
             ((logtest? (focus-status board pilot) (-> this process focus-status))
              (set! (-> this collide-height) (+ -819.2 (-> this base-ocean-offset) (-> this base-height)))
              )
             ((logtest? (-> this flags) (water-flags swim-ground))
              (set! (-> this collide-height) (- (-> this height) (-> this swim-height)))
              )
             (else
               (set! (-> this collide-height) (- (-> this height) (-> this bottom-height)))
               )
             )
           (set! (-> this swim-depth)
                 (fmax 0.0 (- (- (-> this surface-height) (-> this swim-height)) (-> this bottom 0 y)))
                 )
           (and (>= (-> this height) (-> this bottom 0 y)) (logtest? (water-flags touch-water) (-> s5-0 flags)))
           )
         (if (logtest? (-> (the-as collide-shape-moving (-> this process control)) status) (collide-status on-water))
             (set-time! (-> this on-water-time))
             )
         (when (not (logtest? (-> this flags) (water-flags dark-eco lava)))
           (set! (-> this drip-wetness) 1.0)
           (set! (-> this drip-height) (fmax (- (-> this surface-height) (-> this bottom 0 y)) (-> this drip-height)))
           (set! (-> this drip-speed) 15.0)
           )
         (if (and (not (logtest? (water-flags touch-water) (-> this flags)))
                  (not (logtest? (-> this process focus-status) (focus-status touch-water)))
                  )
             (enter-water this)
             )
         (logior! (-> this flags) (water-flags touch-water))
         (cond
           ((>= (-> this top 0 y) (-> this height))
            (let ((s3-0 (new 'stack-no-clear 'vector)))
              (set! (-> s3-0 quad) (-> this bottom 0 quad))
              (let ((v1-79 (-> this process control transv)))
                (sqrtf (+ (* (-> v1-79 x) (-> v1-79 x)) (* (-> v1-79 z) (-> v1-79 z))))
                )
              (logior! (-> this flags) (water-flags break-surface))
              (set! (-> s3-0 y) (+ 40.96 (-> this surface-height)))
              (when (and (not (handle->process (-> this ripple)))
                         (>= (+ (current-time) (seconds -1.5)) (-> this enter-water-time))
                         )
                (let* ((s1-0 (get-process *default-dead-pool* manipy #x4000))
                       (s2-0
                         (when s1-0
                           (let ((t9-6 (method-of-type manipy activate)))
                             (t9-6 (the-as manipy s1-0) (-> this process) (symbol->string (-> manipy symbol)) (the-as pointer #x70004000))
                             )
                           (let ((s2-1 run-function-in-process)
                                 (s0-0 s1-0)
                                 )
                             (set! sv-272 manipy-init)
                             (set! sv-288 s3-0)
                             (set! sv-304 (-> this process entity))
                             (let ((t0-0 (art-group-get-by-name *level* "skel-generic-ripples" (the-as (pointer uint32) #f)))
                                   (t1-0 #f)
                                   (t2-0 0)
                                   )
                               ((the-as (function object object object object object object object none) s2-1)
                                s0-0
                                sv-272
                                sv-288
                                sv-304
                                t0-0
                                t1-0
                                t2-0
                                )
                               )
                             )
                           (-> s1-0 ppointer)
                           )
                         )
                       )
                  (set! (-> this ripple) (ppointer->handle s2-0))
                  (when s2-0
                    (send-event (ppointer->process s2-0) 'anim-mode 'loop)
                    (send-event (ppointer->process s2-0) 'art-joint-anim "generic-ripples-cycle" 0)
                    (set-vector! (-> (the-as process-drawable (-> s2-0 0)) root scale) 0.0 0.5 0.0 1.0)
                    (send-event
                      (ppointer->process s2-0)
                      'trans-hook
                      (lambda :behavior process-drawable
                        ()
                        (let ((s5-0 (ppointer->process (-> self parent)))
                              (gp-0 (new 'stack-no-clear 'vector))
                              )
                          (set! (-> gp-0 quad) (-> (the-as process-drawable s5-0) water bottom 0 quad))
                          (seek! (-> self root scale x) 2.0 (* 2.0 (seconds-per-frame)))
                          (set! (-> self root scale z) (-> self root scale x))
                          (set! (-> gp-0 y) (-> (the-as process-drawable s5-0) water surface-height))
                          (let ((v0-1 (-> self root trans)))
                            (set! (-> v0-1 quad) (-> gp-0 quad))
                            v0-1
                            )
                          )
                        )
                      )
                    )
                  )
                )
              (when (and (logtest? (-> this process draw status) (draw-control-status on-screen))
                         (zero? (-> this process draw cur-lod))
                         (logtest? (water-flags part-rings) (-> this flags))
                         (logtest? (water-flags part-water) (-> this flags))
                         )
                (let* ((f30-0 (y-angle (-> this process control)))
                       (v1-141 (-> this process control transv))
                       (f28-0 (sqrtf (+ (* (-> v1-141 x) (-> v1-141 x)) (* (-> v1-141 z) (-> v1-141 z)))))
                       )
                  (set! (-> *part-id-table* 506 init-specs 4 initial-valuef) (+ 24576.0 f30-0))
                  (set! (-> *part-id-table* 506 init-specs 19 initial-valuef) (+ 49152.0 f30-0))
                  (set! (-> *part-id-table* 506 init-specs 1 initial-valuef) (* 0.0000036621095 f28-0))
                  (set! (-> *part-id-table* 506 init-specs 2 initial-valuef) (/ f28-0 10))
                  (set! (-> *part-id-table* 506 init-specs 13 initial-valuef) 0.7111111)
                  (set! (-> *part-id-table* 506 init-specs 3 initial-valuef) (-> this wake-size))
                  (set! (-> *part-id-table* 506 init-specs 5 initial-valuef) (-> this wake-size))
                  (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 506) s3-0)
                  (set! (-> *part-id-table* 509 init-specs 1 initial-valuef) (* 0.000004150391 f28-0))
                  (set! (-> *part-id-table* 509 init-specs 18 initial-valuef) f30-0)
                  (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 509) s3-0)
                  (when (< f28-0 4096.0)
                    (set! (-> *part-id-table* 504 init-specs 2 random-rangef) (-> this ripple-size))
                    (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 504) s3-0)
                    )
                  )
                )
              (if (< (-> this top 1 y) (-> this height))
                  (spawn-ripples this 0.2 s3-0 1 (-> this process control transv) #t)
                  )
              )
            )
           (else
             (logior! (-> this flags) (water-flags head-under-water))
             )
           )
         (when (and (logtest? (water-flags part-splash) (-> this flags)) (logtest? (water-flags part-water) (-> this flags)))
           (cond
             ((logtest? (-> this flags) (water-flags lava))
              )
             ((logtest? (-> this flags) (water-flags dark-eco))
              )
             ((logtest? (focus-status mech) (-> this process focus-status))
              )
             (else
               (let* ((v0-17 (rand-vu-int-range 3 (+ (-> this process node-list length) -1)))
                      (s3-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this process node-list data v0-17)))
                      )
                 (when (< (-> s3-1 y) (-> this surface-height))
                   (set! (-> *part-id-table* 502 init-specs 16 initial-valuef) (-> this surface-height))
                   (let ((f0-72 (lerp-scale 12.0 0.4 (the float (- (current-time) (-> this enter-water-time))) 0.0 600.0))
                         (f1-26 0.00012207031)
                         (v1-222 (-> this process control transv))
                         )
                     (set! (-> *part-id-table* 502 init-specs 1 initial-valuef)
                           (+ f0-72 (* f1-26 (sqrtf (+ (* (-> v1-222 x) (-> v1-222 x)) (* (-> v1-222 z) (-> v1-222 z))))))
                           )
                     )
                   (launch-particles (-> *part-id-table* 502) s3-1)
                   (set! (-> *part-id-table* 503 init-specs 16 initial-valuef) (-> this surface-height))
                   (launch-particles (-> *part-id-table* 503) s3-1)
                   )
                 )
               )
             )
           )
         (let ((f30-1 (- (+ (-> this base-height) (-> this ocean-offset) (-> this bob-offset) (-> this align-offset))
                         (-> this swim-height)
                         )
                      )
               )
           (let* ((s3-2 (-> this process control))
                  (v1-236 (if (type? s3-2 control-info)
                              s3-2
                              )
                          )
                  (v1-237 (and v1-236 (not (time-elapsed? (-> v1-236 last-time-on-surface) (seconds 0.5)))))
                  )
             (if (and (logtest? (-> this flags) (water-flags swim-ground))
                      (and v1-237
                           (not (logtest? (-> (the-as collide-shape-moving (-> this process control)) status) (collide-status on-water)))
                           )
                      )
                 (set! (-> this bob amp) (* 0.8 (-> this bob amp)))
                 )
             (cond
               ((and (logtest? (-> this flags) (water-flags can-swim))
                     (or (logtest? (-> (the-as collide-shape-moving (-> this process control)) status) (collide-status on-water))
                         (>= f30-1 (-> this bottom 0 y))
                         (and (logtest? (water-flags swimming) s4-0)
                              (logtest? (-> (the-as collide-shape-moving (-> this process control)) status) (collide-status touch-surface))
                              (not (logtest? (-> (the-as collide-shape-moving (-> this process control)) status) (collide-status on-surface))
                                   )
                              (>= (+ 204.8 f30-1) (-> this bottom 0 y))
                              )
                         )
                     (or (logtest? (water-flags swimming) s4-0)
                         (let ((f0-84 12288.0)
                               (a0-112 (-> this process control transv))
                               )
                           (< f0-84 (sqrtf (+ (* (-> a0-112 x) (-> a0-112 x)) (* (-> a0-112 z) (-> a0-112 z)))))
                           )
                         (< (+ (current-time) (seconds -0.2)) (-> this enter-water-time))
                         (or (>= (+ (- 204.8 (fmin 6144.0 (+ (-> this ocean-offset) (-> this bob-offset) (-> this align-offset)))) f30-1)
                                 (-> this bottom 0 y)
                                 )
                             (and (-> this process next-state) (= (-> this process next-state name) 'target-hit-ground))
                             )
                         )
                     )
                (set-time! (-> this swim-time))
                (send-event (-> this process) 'swim)
                (logior! (-> this flags) (water-flags swimming))
                (if (not (logtest? (water-flags swimming) s4-0))
                    (set-time! (-> this enter-swim-time))
                    )
                (cond
                  ((and (logtest? (-> this flags) (water-flags swim-ground))
                        (logtest? (-> (the-as collide-shape-moving (-> this process control)) status) (collide-status touch-surface))
                        (not (logtest? (water-flags jump-out) (-> this flags)))
                        )
                   (let ((v1-260 (new 'stack-no-clear 'vector)))
                     (set! (-> v1-260 quad) (-> this bottom 0 quad))
                     (set! (-> v1-260 y) (- (-> this height) (-> this swim-height)))
                     (let ((s3-3 (the-as collide-shape-moving (-> this process control))))
                       (when (and (not (logtest? (-> s3-3 status) (collide-status touch-background)))
                                  (logtest? (water-flags swimming) (-> this flags))
                                  (not (logtest? (focus-status board pilot) (-> this process focus-status)))
                                  )
                         (let ((a1-42 (vector-! (new 'stack-no-clear 'vector) v1-260 (-> (the-as control-info s3-3) trans))))
                           (vector-float*! a1-42 a1-42 (-> pp clock frames-per-second))
                           (integrate-and-collide! s3-3 a1-42)
                           )
                         (set! (-> (the-as control-info s3-3) status)
                               (logior (-> s3-3 status) (collide-status on-surface on-ground touch-surface on-water))
                               )
                         )
                       )
                     )
                   )
                  ((and (< (-> this bottom 0 y) f30-1) (not (logtest? (water-flags jump-out) (-> this flags))))
                   (logior! (-> this flags) (water-flags under-water))
                   )
                  )
                )
               ((begin
                  (set! v1-237 (and (logtest? (-> this flags) (water-flags can-wade))
                                    (or (not (!= (-> this bob amp) 0.0)) (time-elapsed? (-> this swim-time) (seconds 0.05)))
                                    (and (>= (- (-> this height) (-> this wade-height)) (-> this bottom 0 y)) v1-237)
                                    )
                        )
                  v1-237
                  )
                (set-time! (-> this wade-time))
                (send-event (-> this process) 'wade)
                (logior! (-> this flags) (water-flags wading))
                )
               ((and (< (-> this bottom 0 y) f30-1) (not (logtest? (water-flags jump-out) (-> this flags))))
                (logior! (-> this flags) (water-flags under-water))
                )
               )
             )
           (when (and (logtest? (-> this flags) (water-flags can-swim))
                      (< (-> this bottom 1 y) f30-1)
                      (and (< f30-1 (-> this bottom 0 y)) (logtest? s4-0 (water-flags under-water)))
                      )
             (logior! (-> this flags) (water-flags swimming))
             (let ((a1-47 (new 'stack-no-clear 'vector)))
               (set! (-> a1-47 quad) (-> this bottom 0 quad))
               (let ((s4-1 (the-as collide-shape-moving (-> this process control))))
                 (set! (-> a1-47 y) f30-1)
                 (when (not (logtest? (focus-status board pilot) (-> this process focus-status)))
                   (let ((f30-2 (-> s4-1 ground-impact-vel)))
                     (move-to-ground-point s4-1 a1-47 (-> (the-as control-info s4-1) transv) *up-vector*)
                     (set! (-> (the-as control-info s4-1) status) (logior (-> s4-1 status) (collide-status on-water)))
                     (set! (-> (the-as control-info s4-1) ground-impact-vel) f30-2)
                     )
                   )
                 )
               )
             )
           )
         (when (= (-> this process type) target)
           (cond
             ((logtest? (-> this flags) (water-flags tar))
              (when (and (logtest? (-> (the-as collide-shape-moving (-> this process control)) status)
                                   (collide-status on-surface on-water)
                                   )
                         (not (logtest? (focus-status board pilot) (-> this process focus-status)))
                         )
                (when (< (-> this process control trans y) (+ -1228.8 (-> this base-height)))
                  (send-event (-> this process) 'no-look-around (seconds 1.5))
                  (if (not (logtest? (-> this process focus-status) (focus-status flut)))
                      (send-event
                        (-> this process)
                        'attack
                        #f
                        (static-attack-info ((id (-> this attack-id)) (shove-up (meters 0.5)) (shove-back (meters 0)) (mode 'tar)))
                        )
                      )
                  (let ((v1-329 (-> this process)))
                    (set! (-> v1-329 control surf) *tar-surface*)
                    (set! (-> v1-329 control ground-pat)
                          (copy-and-set-field (-> (the-as collide-shape-moving (-> v1-329 control)) ground-pat) material 4)
                          )
                    )
                  )
                (set! (-> this swim-height) (lerp (-> this swim-height) 7372.8 0.05))
                )
              )
             ((logtest? (-> this flags) (water-flags lava))
              (when (logtest? (-> (the-as collide-shape-moving (-> this process control)) status)
                              (collide-status on-surface on-water)
                              )
                (when (< (-> this process control trans y) (+ -204.8 (-> this base-height)))
                  (send-event (-> this process) 'no-look-around (seconds 1.5))
                  (send-event (-> this process) 'attack #f (static-attack-info ((id (the-as uint 2))
                                                                                (shove-up (meters 0.5))
                                                                                (shove-back (meters 0))
                                                                                (mode 'melt)
                                                                                (intersection (-> s5-0 trans))
                                                                                )
                                                                               )
                              )
                  )
                (set! (-> this swim-height) (lerp (-> this swim-height) 7372.8 0.05))
                )
              )
             ((and (logtest? (focus-status dark) (-> this process focus-status))
                   (nonzero? (-> this process darkjak))
                   (logtest? (-> this process darkjak stage) (darkjak-stage giant))
                   )
              (set! (-> this swim-height) 16384.0)
              )
             (else
               (set! (-> this swim-height) 8192.0)
               )
             )
           )
         )
        (else
          (if (logtest? (water-flags touch-water) (-> this flags))
              (water-control-method-16 this)
              )
          )
        )
      )
    (when (not (or (not (logtest? (water-flags part-drip) (-> this flags)))
                   (not (logtest? (water-flags part-water) (-> this flags)))
                   (= (-> this drip-wetness) 0.0)
                   )
               )
      (cond
        ((logtest? (water-flags spawn-drip) (-> this flags))
         (let ((v0-34
                 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this process node-list data (-> this drip-joint-index)))
                 )
               )
           (set! (-> *part-id-table* 537 init-specs 18 initial-valuef) (-> this surface-height))
           (set! (-> *part-id-table* 537 init-specs 10 initial-valuef)
                 (* 0.05 (- (-> v0-34 x) (-> this drip-old-pos x)))
                 )
           (set! (-> *part-id-table* 537 init-specs 11 initial-valuef)
                 (* 0.05 (- (-> v0-34 y) (-> this drip-old-pos y)))
                 )
           (set! (-> *part-id-table* 537 init-specs 12 initial-valuef)
                 (* 0.05 (- (-> v0-34 z) (-> this drip-old-pos z)))
                 )
           (launch-particles (-> *part-id-table* 537) v0-34)
           )
         (set-time! (-> this drip-time))
         (logclear! (-> this flags) (water-flags spawn-drip))
         (seek! (-> this drip-wetness) 0.0 (/ (-> this drip-speed) 1000))
         (set! (-> this drip-speed) (* 1.05 (-> this drip-speed)))
         (if (= (-> this drip-wetness) 0.0)
             (set! (-> this drip-height) 0.0)
             )
         )
        ((time-elapsed?
           (the-as time-frame (the int (/ (the float (-> this drip-time)) (-> this drip-mult))))
           (the int (-> this drip-speed))
           )
         (let* ((s5-1 (rand-vu-int-range 3 (+ (-> this process node-list length) -1)))
                (v0-38 (vector<-cspace! (new 'stack-no-clear 'vector) (-> this process node-list data s5-1)))
                )
           (when (and (< (- (-> v0-38 y) (-> this process control trans y)) (-> this drip-height))
                      (< (-> this height) (-> v0-38 y))
                      )
             (set! (-> this drip-joint-index) s5-1)
             (set! (-> this drip-old-pos quad) (-> v0-38 quad))
             (logior! (-> this flags) (water-flags spawn-drip))
             )
           )
         )
        )
      )
    (if (and (not (logtest? (water-flags break-surface) (-> this flags))) (handle->process (-> this ripple)))
        (send-event (handle->process (-> this ripple)) 'die)
        )
    0
    (none)
    )
  )

(defmethod start-bobbing! ((this water-control) (arg0 float) (arg1 int) (arg2 int))
  (with-pp
    (activate! (-> this bob) (- arg0) arg1 arg2 0.9 1.0 (-> pp clock))
    0
    (none)
    )
  )

(defun part-water-splash-callback ((arg0 part-tracker))
  (let ((f1-0 (-> arg0 root trans y))
        (f0-0 (the-as float (-> arg0 userdata)))
        )
    (set! (-> *part-id-table* 521 init-specs 16 initial-valuef) f1-0)
    (set! (-> *part-id-table* 521 init-specs 1 initial-valuef) (* 12.0 f0-0))
    (set! (-> *part-id-table* 517 init-specs 16 initial-valuef) f1-0)
    (set! (-> *part-id-table* 520 init-specs 18 initial-valuef) f1-0)
    (set! (-> *part-id-table* 515 init-specs 16 initial-valuef) f1-0)
    (set! (-> *part-id-table* 512 init-specs 15 initial-valuef) f1-0)
    (set! (-> *part-id-table* 513 init-specs 15 initial-valuef) f1-0)
    (set! (-> *part-id-table* 512 init-specs 12 initial-valuef) (* 13.653334 (* -0.15 f0-0)))
    (set! (-> *part-id-table* 512 init-specs 12 random-rangef) (* 13.653334 (* -0.075 f0-0)))
    (set! (-> *part-id-table* 513 init-specs 12 initial-valuef) (* 13.653334 (* -0.15 f0-0)))
    (set! (-> *part-id-table* 513 init-specs 12 random-rangef) (* 13.653334 (* -0.075 f0-0)))
    (set! (-> *part-id-table* 519 init-specs 2 initial-valuef) (* 4096.0 (/ f0-0 10)))
    (set! (-> *part-id-table* 519 init-specs 2 random-rangef) (* 4096.0 (* 0.4 f0-0)))
    (set! (-> *part-id-table* 519 init-specs 4 initial-valuef) (* 4096.0 (/ f0-0 10)))
    (set! (-> *part-id-table* 519 init-specs 4 random-rangef) (* 4096.0 (* 0.4 f0-0)))
    (set! (-> *part-id-table* 519 init-specs 9 initial-valuef) (* 13.653334 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 519 init-specs 9 random-rangef) (* 13.653334 (* 3.4 f0-0)))
    (set! (-> *part-id-table* 519 init-specs 10 initial-valuef) (* 13.653334 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 519 init-specs 10 random-rangef) (* 13.653334 (* 3.4 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 3 initial-valuef) (* 4096.0 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 3 random-rangef) (* 4096.0 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 5 initial-valuef) (* 4096.0 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 5 random-rangef) (* 4096.0 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 10 initial-valuef) (* 13.653334 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 10 random-rangef) (* 13.653334 (* 2.4 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 11 initial-valuef) (* 13.653334 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 516 init-specs 11 random-rangef) (* 13.653334 (* 2.4 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 1 initial-valuef) (/ f0-0 2))
    (set! (-> *part-id-table* 520 init-specs 2 initial-valuef) (* 4096.0 (/ f0-0 -4)))
    (set! (-> *part-id-table* 520 init-specs 2 random-rangef) (* 4096.0 (/ f0-0 2)))
    (set! (-> *part-id-table* 520 init-specs 3 initial-valuef) (* 4096.0 (/ f0-0 -4)))
    (set! (-> *part-id-table* 520 init-specs 3 random-rangef) (* 4096.0 (/ f0-0 2)))
    (set! (-> *part-id-table* 520 init-specs 10 initial-valuef) (* 13.653334 (* -0.75 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 10 random-rangef) (* 13.653334 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 12 initial-valuef) (* 13.653334 (* -0.75 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 12 random-rangef) (* 13.653334 (* 1.5 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 11 initial-valuef) (* 13.653334 (* 7.0 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 11 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 15 initial-valuef) (* 13.653334 (* -0.3 f0-0)))
    (set! (-> *part-id-table* 520 init-specs 15 random-rangef) (* 13.653334 (* -0.075 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 1 initial-valuef) (/ f0-0 2))
    (set! (-> *part-id-table* 517 init-specs 2 initial-valuef) (* 1.2 f0-0))
    (set! (-> *part-id-table* 517 init-specs 9 initial-valuef) (* 13.653334 f0-0))
    (set! (-> *part-id-table* 517 init-specs 9 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 10 initial-valuef) (* 13.653334 (* 6.0 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 10 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 13 initial-valuef) (* 13.653334 (* -0.3 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 13 random-rangef) (* 13.653334 (* -0.075 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 9 initial-valuef) (* 13.653334 f0-0))
    (set! (-> *part-id-table* 517 init-specs 9 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 10 initial-valuef) (* 13.653334 (* 6.0 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 10 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 13 initial-valuef) (* 13.653334 (* -0.3 f0-0)))
    (set! (-> *part-id-table* 517 init-specs 13 random-rangef) (* 13.653334 (* -0.075 f0-0)))
    (set! (-> *part-id-table* 515 init-specs 1 initial-valuef) (* 4.0 f0-0))
    (set! (-> *part-id-table* 515 init-specs 2 initial-valuef) (* 4096.0 f0-0))
    (set! (-> *part-id-table* 515 init-specs 9 initial-valuef) (* 13.653334 f0-0))
    (set! (-> *part-id-table* 515 init-specs 9 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 515 init-specs 10 initial-valuef) (* 13.653334 (* 6.0 f0-0)))
    (set! (-> *part-id-table* 515 init-specs 10 random-rangef) (* 13.653334 (* 2.0 f0-0)))
    (set! (-> *part-id-table* 515 init-specs 13 initial-valuef) (* 13.653334 (* -0.3 f0-0)))
    (set! (-> *part-id-table* 515 init-specs 13 random-rangef) (* 13.653334 (* -0.075 f0-0)))
    (set! (-> *part-id-table* 514 init-specs 2 initial-valuef) (* 4096.0 (* 1.2 f0-0)))
    (set! (-> *part-id-table* 514 init-specs 2 random-rangef) (* 4096.0 (/ f0-0 5)))
    (set! (-> *part-id-table* 514 init-specs 3 initial-valuef) (* 4096.0 (* 0.4 f0-0)))
    (set! (-> *part-id-table* 514 init-specs 3 random-rangef) (* 4096.0 (* 1.2 f0-0)))
    (set! (-> *part-id-table* 514 init-specs 7 initial-valuef) (* 4096.0 (/ f0-0 5)))
    (set! (-> *part-id-table* 514 init-specs 7 random-rangef) (* 4096.0 (* 2.2 f0-0)))
    (set! (-> *part-id-table* 518 init-specs 2 initial-valuef) (* 4096.0 (* 0.3 f0-0)))
    (set! (-> *part-id-table* 518 init-specs 2 random-rangef) (* 4096.0 (* 0.9 f0-0)))
    (set! (-> *part-id-table* 518 init-specs 6 initial-valuef) (* 4096.0 f0-0))
    (set! (-> *part-id-table* 518 init-specs 6 random-rangef) (* 4096.0 (* 2.2 f0-0)))
    )
  0
  (none)
  )

(defmethod enter-water ((this water-control))
  (with-pp
    (logior! (-> this flags) (water-flags touch-water))
    (logclear! (-> this flags) (water-flags jump-out))
    (set-time! (-> this enter-water-time))
    (set-vector! (-> this enter-water-pos) (-> this bottom 0 x) (-> this surface-height) (-> this bottom 0 z) 1.0)
    (when (and (logtest? (water-flags part-splash) (-> this flags)) (logtest? (water-flags part-water) (-> this flags)))
      (let ((a1-1 (new 'stack-no-clear 'event-message-block)))
        (set! (-> a1-1 from) (process->ppointer pp))
        (set! (-> a1-1 num-params) 1)
        (set! (-> a1-1 message) 'query)
        (set! (-> a1-1 param 0) (the-as uint 'ground-height))
        (let* ((f0-4 (the-as float (send-event-function (-> this process) a1-1)))
               (f30-0 (lerp-scale 0.3 1.0 f0-4 2048.0 24576.0))
               )
          (when (not (logtest? (-> this flags) (water-flags dark-eco lava)))
            (if (nonzero? (-> this process skel effect))
                (sound-play "swim-enter")
                )
            (spawn-ripples this f30-0 (-> this enter-water-pos) 1 (-> this process control transv) #t)
            )
          )
        )
      )
    (if (logtest? (-> this flags) (water-flags tar lava))
        (set! (-> this swim-height) 2867.2)
        )
    0
    (none)
    )
  )

(defmethod water-control-method-16 ((this water-control))
  (logclear! (-> this flags) (water-flags touch-water))
  (set-zero! (-> this bob))
  (if (logtest? (-> this flags) (water-flags tar lava))
      (set! (-> this swim-height) 2867.2)
      )
  0
  (none)
  )

(defun splash-spawn ((arg0 float) (arg1 vector) (arg2 int))
  (let ((s5-0 (get-process *default-dead-pool* part-tracker #x4000)))
    (when s5-0
      (let ((t9-1 (method-of-type part-tracker activate)))
        (t9-1
          (the-as part-tracker s5-0)
          *entity-pool*
          (symbol->string (-> part-tracker symbol))
          (the-as pointer #x70004000)
          )
        )
      (let ((t9-2 run-function-in-process)
            (a0-3 s5-0)
            (a1-3 part-tracker-init)
            (a2-5 (if (zero? arg2)
                      (-> *part-group-id-table* 122)
                      (-> *part-group-id-table* 121)
                      )
                  )
            (a3-1 0)
            (t0-0 part-water-splash-callback)
            (t2-0 #f)
            (t3-0 *launch-matrix*)
            )
        (set! (-> t3-0 trans quad) (-> arg1 quad))
        ((the-as (function object object object object object object object object none) t9-2)
         a0-3
         a1-3
         a2-5
         a3-1
         t0-0
         arg0
         t2-0
         t3-0
         )
        )
      (-> s5-0 ppointer)
      )
    )
  0
  (none)
  )

(defun rings-water-spawn ((arg0 float) (arg1 vector) (arg2 vector) (arg3 float) (arg4 float))
  (let* ((v1-0 arg2)
         (f30-0 (sqrtf (+ (* (-> v1-0 x) (-> v1-0 x)) (* (-> v1-0 z) (-> v1-0 z)))))
         )
    (set! (-> *part-id-table* 506 init-specs 4 initial-valuef) (+ 24576.0 arg0))
    (set! (-> *part-id-table* 506 init-specs 19 initial-valuef) (+ 49152.0 arg0))
    (set! (-> *part-id-table* 506 init-specs 1 initial-valuef) (* 0.0000036621095 f30-0))
    (set! (-> *part-id-table* 506 init-specs 2 initial-valuef) (/ f30-0 10))
    (set! (-> *part-id-table* 506 init-specs 13 initial-valuef) 0.7111111)
    (set! (-> *part-id-table* 506 init-specs 3 initial-valuef) arg3)
    (set! (-> *part-id-table* 506 init-specs 5 initial-valuef) arg3)
    (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 506) arg1)
    (set! (-> *part-id-table* 509 init-specs 1 initial-valuef) (* 0.000004150391 f30-0))
    (set! (-> *part-id-table* 509 init-specs 18 initial-valuef) arg0)
    (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 509) arg1)
    (when (< f30-0 4096.0)
      (set! (-> *part-id-table* 504 init-specs 2 random-rangef) arg4)
      (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 504) arg1)
      )
    )
  0
  (none)
  )

(defmethod spawn-ripples ((this water-control) (arg0 float) (arg1 vector) (arg2 int) (arg3 vector) (arg4 symbol))
  (when (and (logtest? (water-flags part-splash) (-> this flags)) (logtest? (water-flags part-water) (-> this flags)))
    (let ((s4-1 (vector+float*! (new 'stack-no-clear 'vector) arg1 arg3 0.05)))
      (set! (-> s4-1 y) (+ 40.96 (-> this surface-height)))
      (if (time-elapsed? (-> this distort-time) (seconds 0.1))
          (splash-spawn arg0 s4-1 arg2)
          )
      (when (and arg4 (time-elapsed? (-> this distort-time) (seconds 0.3)))
        (set-time! (-> this distort-time))
        (let ((s3-1 (process-spawn
                      manipy
                      :init manipy-init
                      s4-1
                      (-> this process entity)
                      (art-group-get-by-name *level* "skel-generic-ripples" (the-as (pointer uint32) #f))
                      #f
                      0
                      :to (-> this process)
                      )
                    )
              )
          (when s3-1
            (send-event (ppointer->process s3-1) 'anim-mode 'play1)
            (send-event (ppointer->process s3-1) 'anim "idle")
            (let ((f0-4 (fmax 0.6 (fmin 1.0 (* 2.0 arg0)))))
              (set-vector! (-> (the-as process-drawable (-> s3-1 0)) root scale) f0-4 0.5 f0-4 1.0)
              )
            )
          )
        )
      )
    )
  0
  (none)
  )

(defun water-info<-region ((arg0 water-info) (arg1 drawable-region-prim) (arg2 collide-shape) (arg3 collide-action))
  (set! (-> arg0 flags) (water-flags))
  (set! (-> arg0 handle) (the-as handle #f))
  (set! (-> arg0 depth) 0.0)
  (let ((s2-0 (the-as object (-> arg1 region on-inside))))
    (set! s2-0 (cond
                 ((= (the-as symbol (-> (the-as pair s2-0) car)) 'water)
                  (empty)
                  s2-0
                  )
                 (else
                   (script-eval (the-as pair s2-0))
                   )
                 )
          )
    (let ((a0-4 (-> arg2 root-prim)))
      (when s2-0
        (set! (-> arg0 trans quad) (-> a0-4 prim-core world-sphere quad))
        (set-vector! (-> arg0 normal) 0.0 1.0 0.0 1.0)
        (set! (-> arg0 prim) arg1)
        (case (-> (the-as pair (-> (the-as pair s2-0) cdr)) car)
          (('height)
           (set! (-> arg0 flags) (water-flags active))
           (set! (-> arg0 trans y)
                 (* 4096.0 (command-get-float (-> (the-as pair (-> (the-as pair (-> (the-as pair s2-0) cdr)) cdr)) car) 0.0))
                 )
           (set! (-> arg0 base-height) (-> arg0 trans y))
           )
          (('ocean)
           (set! (-> arg0 flags) (water-flags active use-ocean))
           (set! (-> arg0 trans y) (get-height *ocean* (-> arg0 trans) #f))
           (set! (-> arg0 base-height) (get-base-height *ocean-map*))
           (when (= (-> arg0 trans y) 4095996000.0)
             (set! (-> arg0 flags) (water-flags))
             0
             )
           )
          (('water-anim)
           (let* ((s0-0 (command-get-process
                          (-> (the-as pair (-> (the-as pair (-> (the-as pair s2-0) cdr)) cdr)) car)
                          (the-as process #f)
                          )
                        )
                  (s1-0 (if (type? s0-0 process-drawable)
                            s0-0
                            )
                        )
                  )
             (cond
               (s1-0
                 (set! (-> arg0 flags) (water-flags active use-water-anim))
                 (set! (-> arg0 trans y) (ripple-find-height (the-as process-drawable s1-0) 0 (-> arg0 trans)))
                 (set! (-> arg0 handle) (process->handle s1-0))
                 (set! (-> arg0 base-height) (-> (the-as process-drawable s1-0) root trans y))
                 )
               (else
                 (set! (-> arg0 flags) (water-flags))
                 0
                 )
               )
             )
           )
          )
        (when (logtest? (-> arg0 flags) (water-flags active))
          (let* ((s2-1 (-> (the-as pair (-> (the-as pair (-> (the-as pair (-> (the-as pair s2-0) cdr)) cdr)) cdr)) car))
                 (v1-39 (-> (the-as pair s2-1) car))
                 )
            (while (not (null? s2-1))
              (cond
                ((= v1-39 'swim)
                 (logior! (-> arg0 flags) (water-flags can-swim can-ground))
                 )
                ((= v1-39 'wade)
                 (logior! (-> arg0 flags) (water-flags can-wade can-ground))
                 )
                ((= v1-39 'event)
                 (logior! (-> arg0 flags) (water-flags event))
                 )
                ((= v1-39 'tar)
                 (logior! (-> arg0 flags) (water-flags tar))
                 )
                ((= v1-39 'darkeco)
                 (logior! (-> arg0 flags) (water-flags dark-eco))
                 )
                ((= v1-39 'lava)
                 (logior! (-> arg0 flags) (water-flags lava))
                 )
                ((= v1-39 'mech)
                 (let* ((s1-1 (-> arg2 process))
                        (a0-39 (if (type? s1-1 process-focusable)
                                   s1-1
                                   )
                               )
                        )
                   (when (and a0-39 (not (logtest? (focus-status mech) (-> (the-as process-focusable a0-39) focus-status))))
                     (set! (-> arg0 flags) (water-flags))
                     0
                     )
                   )
                 (logior! (-> arg0 extra-flags) 1)
                 )
                )
              (set! s2-1 (-> (the-as pair s2-1) cdr))
              (set! v1-39 (-> (the-as pair s2-1) car))
              )
            )
          (let ((s2-2 (-> arg2 root-prim)))
            (countdown (s1-2 (-> arg2 total-prims))
              (when (and (nonzero? (-> s2-2 prim-core prim-type))
                         (logtest? (-> s2-2 prim-core action) arg3)
                         (nonzero? (-> s2-2 prim-core collide-with))
                         )
                ;; og:preserve-this scratchpad
                (set! (-> (scratchpad-object region-prim-area) pos quad) (-> s2-2 prim-core world-sphere quad))
                (if (and (within-area? arg1 (scratchpad-object region-prim-area))
                         (begin
                           (logior! (-> arg0 flags) (water-flags over-water))
                           (>= (-> arg0 trans y) (- (-> s2-2 prim-core world-sphere y) (-> s2-2 prim-core world-sphere w)))
                           )
                         )
                    (logior! (-> arg0 flags) (water-flags touch-water))
                    )
                )
              (&+! s2-2 80)
              )
            )
          (if (and (logtest? (water-flags event) (-> arg0 flags)) (logtest? (water-flags touch-water) (-> arg0 flags)))
              (send-event (handle->process (-> arg0 handle)) 'water arg0 (-> arg2 process))
              )
          )
        )
      )
    )
  arg0
  )

(defmethod water-info-init! ((this collide-shape) (arg0 water-info) (arg1 collide-action))
  "Initialize a [[water-info]] with the currently loaded regions."
  (local-vars (sv-80 int))
  (let ((s3-0 (new 'stack 'water-info)))
    (set! (-> s3-0 flags) (water-flags))
    (set! (-> s3-0 handle) (the-as handle #f))
    (set! (-> arg0 flags) (water-flags))
    (set! (-> arg0 handle) (the-as handle #f))
    (set! (-> s3-0 extra-flags) (the-as uint 0))
    ;; og:preserve-this scratchpad
    (set! (-> (scratchpad-object region-prim-area) region-prim-list num-items) 0)
    (set! (-> (scratchpad-object region-prim-area) region-inside-count) 0)
    (set! (-> (scratchpad-object region-prim-area) pos quad) (-> this root-prim prim-core world-sphere quad))
    (dotimes (s2-0 (-> *level* length))
      (let ((v1-8 (-> *level* level s2-0)))
        (when (= (-> v1-8 status) 'active)
          (let ((s1-0 (-> v1-8 bsp region-trees)))
            (when (nonzero? s1-0)
              (let ((s0-0 (-> s1-0 length)))
                (set! sv-80 0)
                (let ((a0-10 (-> s1-0 sv-80)))
                  (while (< sv-80 s0-0)
                    (if (= (-> a0-10 name) 'water)
                        ;; og:preserve-this scratchpad
                        (collect-regions
                          a0-10
                          (the-as sphere (-> (scratchpad-object region-prim-area) pos))
                          0
                          (-> (scratchpad-object region-prim-area) region-prim-list)
                          )
                        )
                    (set! sv-80 (+ sv-80 1))
                    (set! a0-10 (-> s1-0 sv-80))
                    )
                  )
                )
              )
            )
          )
        )
      )
    ;; og:preserve-this scratchpad
    (countdown (s2-1 (-> (scratchpad-object region-prim-area) region-prim-list num-items))
      (water-info<-region s3-0 (-> (scratchpad-object region-prim-area) region-prim-list items s2-1) this arg1)
      (when (and (logtest? (-> s3-0 flags) (water-flags active))
                 (logtest? (water-flags touch-water) (-> s3-0 flags))
                 (not (logtest? (-> s3-0 extra-flags) 1))
                 )
        (mem-copy! (the-as pointer arg0) (the-as pointer s3-0) 60)
        (set! arg0 arg0)
        (goto cfg-27)
        )
      (if (and (logtest? (-> s3-0 flags) (water-flags active))
               (logtest? (water-flags touch-water over-water) (-> s3-0 flags))
               )
          (mem-copy! (the-as pointer arg0) (the-as pointer s3-0) 60)
          )
      )
    )
  (label cfg-27)
  arg0
  )
