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

;; failed to figure out what this is:
(defpartgroup group-sequenceAV-splash
  :id 686
  :duration 900
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 64)
  :parts ((sp-item 2854 :period 900 :length 600))
  )

;; failed to figure out what this is:
(defpart 2854
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x9 :page #x2))
    (sp-flt spt-num 128.0)
    (sp-rnd-flt spt-x (meters -1) (meters 2) 1.0)
    (sp-rnd-flt spt-z (meters -1) (meters 2) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.025) (meters 0.125) 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 128.0 32.0 1.0)
    (sp-rnd-flt spt-g 96.0 64.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-rnd-flt spt-vel-y (meters 0.026666667) (meters 0.053333335) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0)
    (sp-rnd-flt spt-accel-y -2.7306666 -6.826667 1.0)
    (sp-int spt-timer 900)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees -30.0) (degrees 60.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 5000.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 0.3) (meters -0.5) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-sequenceAV-spit
  :id 687
  :duration 5
  :linger-duration 900
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 64)
  :parts ((sp-item 2855))
  )

;; failed to figure out what this is:
(defpart 2855
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x9 :page #x2))
    (sp-flt spt-num 5.0)
    (sp-rnd-flt spt-scale-x (meters 0.025) (meters 0.025) 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 128.0 32.0 1.0)
    (sp-rnd-flt spt-g 128.0 32.0 1.0)
    (sp-rnd-flt spt-b 128.0 32.0 1.0)
    (sp-rnd-flt spt-a 32.0 32.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.016666668) (meters 0.0033333334) 1.0)
    (sp-flt spt-scalevel-x (meters 0.00033333333))
    (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.21333334)
    (sp-rnd-flt spt-accel-y -1.3653333 -1.3653333 1.0)
    (sp-flt spt-friction 0.95)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees 106.0) (degrees 2.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 90.0) (degrees 2.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 0) (meters -0.15) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-sequenceAV-2d-intro-mist
  :id 688
  :flags (screen-space)
  :bounds (static-bspherem 0 0 0 2)
  :parts ((sp-item 2858 :period 300 :length 5 :binding 2856)
    (sp-item 2856 :flags (start-dead launch-asap) :binding 2857)
    (sp-item 2856 :flags (start-dead launch-asap) :binding 2857)
    (sp-item 2857 :flags (start-dead))
    (sp-item 2857 :flags (start-dead))
    (sp-item 2857 :flags (start-dead))
    (sp-item 2859)
    (sp-item 2860)
    )
  )

;; failed to figure out what this is:
(defpart 2858
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-x (meters -2.5) (meters 5) 1.0)
    (sp-rnd-flt spt-y (meters -1.5) (meters 3) 1.0)
    (sp-flt spt-scale-x (meters 0.1))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-g 128.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-vel-y (meters 0.0033333334) (meters 0.0033333334) 1.0)
    (sp-int spt-timer 600)
    (sp-cpuinfo-flags bit3)
    (sp-rnd-flt spt-conerot-z (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2856
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-x (meters 0) (meters 16) 1.0)
    (sp-rnd-flt spt-y (meters 0) (meters 16) 1.0)
    (sp-rnd-flt spt-z (meters 0.5) (meters 0.2) 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 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-flt spt-a 128.0)
    (sp-rnd-flt spt-omega 0.0 65536.0 1.0)
    (sp-rnd-int-flt spt-vel-x (meters -0.053333335) 1 436.90668)
    (sp-flt spt-scalevel-x (meters -0.0012121212))
    (sp-rnd-int-flt spt-rotvel-z (degrees -0.3) 1 109.22667)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-int spt-timer 600)
    (sp-cpuinfo-flags bit2 bit3 bit7)
    )
  )

;; failed to figure out what this is:
(defpart 2857
  :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.5) (meters 0.3) 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 64.0 64.0 1.0)
    (sp-flt spt-scalevel-x (meters -0.0010952381))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-rnd-flt spt-accel-y 0.0 -0.13653333 1.0)
    (sp-int-plain-rnd spt-timer 30 299 1)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int spt-next-time 240)
    (sp-launcher-by-id spt-next-launcher 198)
    )
  )

;; failed to figure out what this is:
(defpart 2860
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x36 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-z (meters -3.90625))
    (sp-flt spt-scale-x (meters 15))
    (sp-flt spt-scale-y (meters 12))
    (sp-flt spt-r 0.0)
    (sp-flt spt-g 0.0)
    (sp-flt spt-b 0.0)
    (sp-flt spt-a 128.0)
    (sp-int spt-timer 5)
    (sp-cpuinfo-flags bit2 bit13 bit14)
    )
  )

;; failed to figure out what this is:
(defpart 2859
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 0.3)
    (sp-rnd-flt spt-x (meters -4) (meters 8) 1.0)
    (sp-rnd-flt spt-y (meters -3) (meters 6) 1.0)
    (sp-rnd-flt spt-z (meters 0) (meters 3.4179688) 1.0)
    (sp-rnd-flt spt-scale-x (meters 6) (meters 8) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 6) (meters 8) 1.0)
    (sp-rnd-flt spt-r 16.0 80.0 1.0)
    (sp-rnd-flt spt-g 0.0 16.0 1.0)
    (sp-rnd-flt spt-b 16.0 150.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-scalevel-x (meters -0.0016666667) (meters 0.0033333334) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -0.075) (degrees 0.15) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a 0.21333334)
    (sp-int spt-timer 1500)
    (sp-cpuinfo-flags bit2 bit14)
    (sp-int-plain-rnd spt-next-time 150 149 1)
    (sp-launcher-by-id spt-next-launcher 2861)
    )
  )

;; failed to figure out what this is:
(defpart 2861
  :init-specs ((sp-flt spt-fade-a 0.0)
    (sp-int-plain-rnd spt-next-time 300 299 1)
    (sp-launcher-by-id spt-next-launcher 2862)
    )
  )

;; failed to figure out what this is:
(defpart 2862
  :init-specs ((sp-flt spt-fade-a -0.21333334))
  )

;; definition of type sequenceA-village1
(deftype sequenceA-village1 (process-taskable)
  ((boat handle  :offset-assert 384)
   (side handle  :offset-assert 392)
   )
  :heap-base #x120
  :method-count-assert 53
  :size-assert         #x190
  :flag-assert         #x3501200190
  )

;; definition for method 3 of type sequenceA-village1
(defmethod inspect sequenceA-village1 ((obj sequenceA-village1))
  (let ((t9-0 (method-of-type process-taskable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tboat: ~D~%" (-> obj boat))
  (format #t "~T~Tside: ~D~%" (-> obj side))
  obj
  )

;; definition for method 32 of type sequenceA-village1
;; INFO: Return type mismatch spool-anim vs basic.
(defmethod play-anim! sequenceA-village1 ((obj sequenceA-village1) (arg0 symbol))
  (when arg0
    (set! (-> *time-of-day-proc* 0 time-ratio) 0.0)
    (set! (-> *time-of-day-proc* 0 hour) 23)
    (send-event *camera* 'no-intro)
    (send-event *camera* 'clear-entity)
    (send-event *camera* 'force-blend 0)
    (send-event *camera* 'change-state cam-fixed 0)
    (send-event *target* 'sidekick #f)
    (set! (-> obj boat)
          (ppointer->handle (manipy-spawn (-> obj root-override trans) (-> obj entity) *fishermans-boat-sg* #f :to obj))
          )
    (send-event (handle->process (-> obj boat)) 'anim-mode 'clone-anim)
    (send-event (handle->process (-> obj boat)) 'origin-joint-index 3)
    )
  (the-as basic (new 'static 'spool-anim
                  :name "sage-intro-sequence-a"
                  :index 17
                  :parts 22
                  :command-list '((0 blackout 0)
                    (0 want-levels village1 misty)
                    (1210 display-level misty display)
                    (1210 want-vis mis)
                    (1210 want-force-vis misty #t)
                    (1230 send-event self sidekick-human)
                    (1239 joint "cameraB")
                    (1480 joint "camera")
                    (1480 setting-reset ocean-off near)
                    (1613 joint "cameraB")
                    (1796 joint "camera")
                    (1843 joint "cameraB")
                    (2145 joint "camera")
                    (2274 joint "cameraB")
                    (2439 joint "camera")
                    (2450 want-force-vis misty #f)
                    (2490 joint "cameraB")
                    (2570 alive "sequenceB-1")
                    (2569 save)
                    (2569 setting-unset ocean-off)
                    )
                  )
          )
  )

;; definition for method 31 of type sequenceA-village1
(defmethod get-art-elem sequenceA-village1 ((obj sequenceA-village1))
  (-> obj draw art-group data 3)
  )

;; failed to figure out what this is:
(defstate play-anim (sequenceA-village1)
  :virtual #t
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('sidekick-human)
       (format 0 "got sidekick-human~%")
       (when (= (level-status *level* 'misty) 'active)
         (let ((gp-1 (entity-by-name "sequenceA-1")))
           (when gp-1
             (format 0 "found entity for sidekick-human~%")
             (set! (-> self side)
                   (ppointer->handle (manipy-spawn (-> self root-override trans) gp-1 *sidekick-human-sg* #f :to self))
                   )
             (send-event (handle->process (-> self side)) 'anim-mode 'clone-anim)
             (send-event (handle->process (-> self side)) 'center-joint 3)
             (send-event (handle->process (-> self side)) 'blend-shape #t)
             )
           )
         )
       )
      )
    )
  :exit (behavior ()
    (send-event *target* 'sidekick #t)
    (let ((a0-2 (handle->process (-> self boat))))
      (if a0-2
          (deactivate a0-2)
          )
      )
    (let ((a0-6 (handle->process (-> self side))))
      (if a0-6
          (deactivate a0-6)
          )
      )
    ((-> (method-of-type process-taskable play-anim) exit))
    (let ((gp-0 (entity-by-name "sequenceB-1")))
      (set-blackout-frames (seconds 20))
      (send-event *camera* 'clear-entity)
      (entity-birth-no-kill gp-0)
      (send-event
        (if gp-0
            (-> gp-0 extra process)
            )
        'play-anim
        )
      )
    (none)
    )
  :trans (behavior ()
    (spool-push *art-control* "sage-intro-sequence-b" 0 self -1.0)
    ((-> (method-of-type process-taskable play-anim) trans))
    (none)
    )
  )

;; definition for method 39 of type sequenceA-village1
(defmethod should-display? sequenceA-village1 ((obj sequenceA-village1))
  #f
  )

;; definition for function sequenceA-village1-trans-hook
;; INFO: Return type mismatch int vs none.
(defbehavior sequenceA-village1-trans-hook sequenceA-village1 ()
  (when (>= 1000.0 (ja-aframe-num 0))
    (hide-hud-quick)
    (if (> (-> self part matrix) 0)
        (set-vector!
          (sprite-get-user-hvdf (-> self part matrix))
          2048.0
          2048.0
          (+ -1024.0 (-> *math-camera* hvdf-off z))
          (-> *math-camera* hvdf-off w)
          )
        )
    (let ((f0-9 (fmin 1.0 (* 0.008333334 (- 1000.0 (ja-aframe-num 0))))))
      (set! (-> *part-id-table* 2860 init-specs 8 initial-valuef) (* 128.0 f0-9))
      (cond
        ((< f0-9 1.0)
         (set! (-> *part-id-table* 2858 init-specs 1 initial-valuef) 0.0)
         (set! (-> *part-id-table* 2859 init-specs 1 initial-valuef) 0.0)
         )
        (else
          (set! (-> *part-id-table* 2858 init-specs 1 initial-valuef) 1.0)
          (set! (-> *part-id-table* 2859 init-specs 1 initial-valuef) 0.3)
          )
        )
      )
    (spawn (-> self part) *zero-vector*)
    (draw-title-credits (* 0.001 (ja-aframe-num 0)))
    )
  0
  (none)
  )

;; definition for function sequenceA-village1-init-by-other
;; INFO: Return type mismatch object vs none.
(defbehavior sequenceA-village1-init-by-other sequenceA-village1 ((arg0 entity-actor))
  (set! (-> self entity) arg0)
  (dummy-40 self arg0 *sage-sg* 3 40 (new 'static 'vector :w 4096.0) 5)
  (set! (-> self tasks) (get-task-control (game-task intro)))
  (set! (-> self boat) (the-as handle #f))
  (set! (-> self side) (the-as handle #f))
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 688) self))
  (set! (-> self part matrix) (sprite-allocate-user-hvdf))
  (set! (-> self cur-trans-hook) sequenceA-village1-trans-hook)
  (logclear! (-> self mask) (process-mask pause actor-pause))
  (set! (-> self been-kicked) #t)
  (set-setting! 'music-volume-movie 'abs 0.0 0)
  (set-setting! 'sfx-volume-movie 'abs 0.0 0)
  (set-setting! 'ambient-volume-movie 'abs 0.0 0)
  (go-virtual hidden)
  (none)
  )

;; definition for function start-sequence-a
;; INFO: Return type mismatch int vs none.
(defun start-sequence-a ()
  (set-blackout-frames (seconds 100))
  (process-spawn sequenceA-village1 (entity-by-name "sage-23") :to *entity-pool*)
  0
  (none)
  )
