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

;; definition of type mother-spider-proj
(deftype mother-spider-proj (projectile)
  ((parent-process (pointer projectile)         :offset         12)
   (facing-dir     vector               :inline :offset-assert 416)
   )
  :heap-base #x140
  :method-count-assert 29
  :size-assert         #x1b0
  :flag-assert         #x1d014001b0
  )

;; definition for method 3 of type mother-spider-proj
(defmethod inspect mother-spider-proj ((obj mother-spider-proj))
  (let ((t9-0 (method-of-type projectile inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tfacing-dir: #<vector @ #x~X>~%" (-> obj facing-dir))
  obj
  )

;; failed to figure out what this is:
(defpartgroup group-mother-spider-proj-fly
  :id 326
  :duration 300
  :bounds (static-bspherem 0 0 0 3)
  :parts ((sp-item 718 :flags (launch-asap) :binding 716)
    (sp-item 716 :flags (start-dead) :binding 717)
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    (sp-item 717 :flags (start-dead launch-asap))
    )
  )

;; failed to figure out what this is:
(defpart 718
  :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 0.01))
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-a 0.0)
    (sp-int spt-timer 1200)
    (sp-cpuinfo-flags bit3)
    (sp-func spt-func 'sparticle-track-root-prim)
    )
  )

;; failed to figure out what this is:
(defpart 716
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 1.0)
    (sp-flt spt-scale-x (meters 1))
    (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 96.0 64.0 1.0)
    (sp-rnd-flt spt-g 64.0 32.0 1.0)
    (sp-rnd-flt spt-b 96.0 64.0 1.0)
    (sp-flt spt-a 128.0)
    (sp-flt spt-scalevel-x (meters -0.006666667))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-r -1.0666667)
    (sp-flt spt-fade-g -1.0666667)
    (sp-flt spt-fade-b 0.0)
    (sp-int spt-timer 150)
    (sp-cpuinfo-flags bit2)
    (sp-int spt-next-time 81)
    (sp-launcher-by-id spt-next-launcher 720)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-conerot-radius (meters 0.1))
    )
  )

;; failed to figure out what this is:
(defpart 720
  :init-specs ((sp-flt spt-fade-r 0.0) (sp-flt spt-fade-g 0.0) (sp-flt spt-fade-b 0.0))
  )

;; failed to figure out what this is:
(defpart 717
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 1.0 5.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.2) (meters 0.1) 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 96.0 64.0 1.0)
    (sp-rnd-flt spt-g 64.0 32.0 1.0)
    (sp-rnd-flt spt-b 96.0 64.0 1.0)
    (sp-flt spt-a 128.0)
    (sp-rnd-flt spt-vel-y (meters 0.006666667) (meters 0.0033333334) 1.0)
    (sp-flt spt-scalevel-x (meters -0.0026666666))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-r -1.0666667)
    (sp-flt spt-fade-g -1.0666667)
    (sp-flt spt-fade-b 0.0)
    (sp-flt spt-accel-y -2.7306666)
    (sp-flt spt-friction 0.97)
    (sp-int-plain-rnd spt-timer 30 119 1)
    (sp-cpuinfo-flags bit2)
    (sp-int spt-next-time 60)
    (sp-launcher-by-id spt-next-launcher 720)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 0) (meters 0.4) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-mother-spider-proj-hit
  :id 327
  :duration 5
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 722) (sp-item 723) (sp-item 724))
  )

;; failed to figure out what this is:
(defpart 722
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 64.0)
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.2) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 192.0 32.0 1.0)
    (sp-rnd-flt spt-g 64.0 32.0 1.0)
    (sp-rnd-flt spt-b 96.0 64.0 1.0)
    (sp-flt spt-a 128.0)
    (sp-rnd-flt spt-vel-y (meters 0.10666667) (meters 0.10666667) 1.0)
    (sp-flt spt-scalevel-x (meters -0.006666667))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-r -0.7111111)
    (sp-flt spt-fade-g -0.7111111)
    (sp-flt spt-fade-b 0.0)
    (sp-flt spt-accel-y -0.68266666)
    (sp-rnd-flt spt-friction 0.85 0.05 1.0)
    (sp-int-plain-rnd spt-timer 30 119 1)
    (sp-cpuinfo-flags bit2)
    (sp-int spt-next-time 90)
    (sp-launcher-by-id spt-next-launcher 720)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 0) (meters 0.4) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 724
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-flt spt-num 6.0)
    (sp-rnd-flt spt-scale-x (meters 3) (meters 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 96.0 64.0 1.0)
    (sp-rnd-flt spt-g 64.0 32.0 1.0)
    (sp-rnd-flt spt-b 96.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 32.0 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -0.2) (degrees 0.4) 1.0)
    (sp-flt spt-fade-r -0.35555556)
    (sp-flt spt-fade-g -0.35555556)
    (sp-flt spt-fade-b 0.0)
    (sp-flt spt-fade-a -0.30476192)
    (sp-rnd-flt spt-accel-y -0.68266666 0.68266666 1.0)
    (sp-int spt-timer 210)
    (sp-cpuinfo-flags bit2)
    (sp-int spt-next-time 60)
    (sp-launcher-by-id spt-next-launcher 720)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 180.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 723
  :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 6) (meters 1) 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 64.0 32.0 1.0)
    (sp-rnd-flt spt-b 128.0 32.0 1.0)
    (sp-flt spt-a 96.0)
    (sp-flt spt-fade-a -4.8)
    (sp-int spt-timer 15)
    (sp-cpuinfo-flags bit2)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-mother-spider-proj-die
  :id 328
  :duration 5
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 722))
  )

;; definition for method 24 of type mother-spider-proj
(defmethod dummy-24 mother-spider-proj ((obj mother-spider-proj))
  (with-pp
    (spawn (-> obj part) (the-as vector (-> obj root-override root-prim prim-core)))
    (let ((s5-0 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
      (set! (-> s5-0 command) (sound-command set-param))
      (set! (-> s5-0 id) (-> obj sound-id))
      (let ((a1-1 (-> obj root-override trans)))
        (let ((s4-0 pp))
          (when (= a1-1 #t)
            (if (and s4-0 (type-type? (-> s4-0 type) process-drawable) (nonzero? (-> (the-as process-drawable s4-0) root)))
                (set! a1-1 (-> (the-as process-drawable s4-0) root trans))
                (set! a1-1 (the-as vector #f))
                )
            )
          )
        (sound-trans-convert (-> s5-0 parms trans) a1-1)
        )
      (set! (-> s5-0 parms mask) (sound-mask trans))
      (-> s5-0 id)
      )
    (let ((f0-5 (* 5120.0 (+ 0.9 (* 0.1 (cos (* 873.81335 (the float (mod (-> *display* base-frame-counter) 75)))))))))
      (find-ground-and-draw-shadow
        (-> obj root-override trans)
        (the-as vector #f)
        f0-5
        (collide-kind background)
        (the-as process-drawable #f)
        0.0
        81920.0
        )
      )
    (none)
    )
  )

;; definition for function mother-spider-proj-update-velocity
;; INFO: Return type mismatch int vs none.
(defun mother-spider-proj-update-velocity ((arg0 mother-spider-proj))
  (when (>= (vector-vector-xz-distance (-> arg0 parent-process 0 root-override trans) (-> arg0 target))
            (vector-vector-xz-distance (-> arg0 parent-process 0 root-override trans) (-> arg0 root-override trans))
            )
    (let ((s3-1 (vector-! (new 'stack-no-clear 'vector) (-> arg0 target) (-> arg0 root-override trans)))
          (s4-0 (new 'stack-no-clear 'vector))
          (s5-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 root-override transv) 1.0))
          )
      (if (logtest? (-> arg0 root-override status) (cshape-moving-flags tsurf))
          (vector-flatten! s3-1 s3-1 (-> arg0 root-override local-normal))
          )
      (vector-normalize-copy! s4-0 s3-1 1.0)
      (let ((s3-2 (new 'stack-no-clear 'matrix)))
        (matrix-from-two-vectors-max-angle-partial!
          s3-2
          s5-0
          s4-0
          (* (-> arg0 max-turn) (-> *display* seconds-per-frame))
          (-> arg0 tween)
          )
        (vector-matrix*! s5-0 s5-0 s3-2)
        )
      (vector-normalize! s5-0 1.0)
      (vector-float*! (-> arg0 root-override transv) s5-0 (-> arg0 max-speed))
      )
    )
  0
  (none)
  )

;; definition for method 26 of type mother-spider-proj
;; INFO: Return type mismatch int vs none.
(defmethod dummy-26 mother-spider-proj ((obj mother-spider-proj))
  (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) projectile-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind projectile))
      (set! (-> s4-0 collide-with)
            (collide-kind background cak-2 cak-3 target crate enemy wall-object ground-object)
            )
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 prim-core offense) (collide-offense strong-attack))
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 1228.8)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> s5-0 max-iteration-count) (the-as uint 2))
    (set! (-> s5-0 event-self) 'touched)
    (set! (-> obj root-override) s5-0)
    )
  (logclear! (-> obj mask) (process-mask enemy))
  (logclear! (-> obj mask) (process-mask crate))
  (logclear! (-> obj mask) (process-mask attackable))
  (set! (-> obj mask) (logior (process-mask projectile) (-> obj mask)))
  0
  (none)
  )

;; definition for method 27 of type mother-spider-proj
;; INFO: Used lq/sq
;; INFO: Return type mismatch sound-id vs none.
(defmethod dummy-27 mother-spider-proj ((obj mother-spider-proj))
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 326) obj))
  (set! (-> obj max-speed) 32768.0)
  (set! (-> obj update-velocity) mother-spider-proj-update-velocity)
  (set! (-> obj max-turn) 5916.4443)
  (set! (-> obj tween) 0.02)
  (set! (-> obj attack-mode) 'mother-spider-proj)
  (set! (-> obj timeout) (seconds 4))
  (set! (-> obj target quad) (-> (target-pos 0) quad))
  (set! (-> obj target y) (+ 4915.2 (-> obj target y)))
  (set! (-> obj target-base quad) (-> obj target quad))
  (set! (-> obj sound-id) (sound-play "mother-track"))
  (sound-play "mother-fire")
  (none)
  )

;; definition for method 28 of type mother-spider-proj
;; INFO: Used lq/sq
;; INFO: Return type mismatch vector vs none.
(defmethod dummy-28 mother-spider-proj ((obj mother-spider-proj))
  (when (and *target*
             (zero? (logand (-> *target* state-flags)
                            (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)
                            )
                    )
             )
    (let ((gp-0 (-> obj target)))
      (set! (-> gp-0 quad) (-> (target-pos 0) quad))
      (set! (-> gp-0 y) (+ 4915.2 (-> gp-0 y)))
      (let ((f0-2 (vector-vector-distance gp-0 (-> obj root-override trans)))
            (a2-0 (new 'stack-no-clear 'vector))
            )
        (if (>= 0.0 f0-2)
            (set! f0-2 409.6)
            )
        (set! (-> a2-0 quad) (-> *target* control transv quad))
        (set! (-> a2-0 y) 0.0)
        (let ((f0-3 (/ f0-2 (* 32768.0 (-> *display* seconds-per-frame)))))
          (vector+float*! gp-0 gp-0 a2-0 (* f0-3 (-> *display* seconds-per-frame)))
          )
        )
      )
    )
  (none)
  )

;; failed to figure out what this is:
(defstate projectile-impact (mother-spider-proj)
  :virtual #t
  :code (behavior ()
    (process-spawn
      part-tracker
      :init part-tracker-init
      (-> *part-group-id-table* 327)
      -1
      #f
      #f
      #f
      (-> self root-override trans)
      :to *entity-pool*
      )
    (if (nonzero? (-> self sound-id))
        (sound-stop (-> self sound-id))
        )
    (sound-play "mother-hit")
    (suspend)
    (go-virtual projectile-die)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate projectile-dissipate (mother-spider-proj)
  :virtual #t
  :code (behavior ()
    (process-spawn
      part-tracker
      :init part-tracker-init
      (-> *part-group-id-table* 328)
      -1
      #f
      #f
      #f
      (-> self root-override trans)
      :to *entity-pool*
      )
    (if (nonzero? (-> self sound-id))
        (sound-stop (-> self sound-id))
        )
    (suspend)
    (go-virtual projectile-die)
    (none)
    )
  )
