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

(import "goal_src/jak1/import/darkecobomb-ag.gc")
(import "goal_src/jak1/import/greenshot-ag.gc")
(import "goal_src/jak1/import/redring-ag.gc")

;; definition of type torus
(deftype torus (structure)
  ((origin           vector :inline :offset-assert   0)
   (axis             vector :inline :offset-assert  16)
   (radius-primary   float          :offset-assert  32)
   (radius-secondary float          :offset-assert  36)
   )
  :method-count-assert 13
  :size-assert         #x28
  :flag-assert         #xd00000028
  (:methods
    (dummy-9 (_type_ vector) none 9)
    (TODO-RENAME-10 (_type_ collide-prim-core vector) symbol 10)
    (dummy-11 (_type_ vector) symbol 11)
    (dummy-12 (_type_ vector) vector 12)
    )
  )

;; definition for method 3 of type torus
(defmethod inspect torus ((obj torus))
  (format #t "[~8x] ~A~%" obj 'torus)
  (format #t "~Torigin: #<vector @ #x~X>~%" (-> obj origin))
  (format #t "~Taxis: #<vector @ #x~X>~%" (-> obj axis))
  (format #t "~Tradius-primary: ~f~%" (-> obj radius-primary))
  (format #t "~Tradius-secondary: ~f~%" (-> obj radius-secondary))
  obj
  )

;; definition for method 10 of type torus
(defmethod TODO-RENAME-10 torus ((obj torus) (arg0 collide-prim-core) (arg1 vector))
  (let ((gp-0 (new 'stack-no-clear 'vector))
        (s5-0 (new 'stack-no-clear 'vector))
        (f30-0 (+ (-> obj radius-secondary) (-> arg0 world-sphere w)))
        )
    (vector-! gp-0 (the-as vector arg0) (-> obj origin))
    (vector-flatten! s5-0 gp-0 (-> obj axis))
    (vector-normalize! s5-0 (-> obj radius-primary))
    (vector-! arg1 gp-0 s5-0)
    (< (vector-length-squared arg1) (* f30-0 f30-0))
    )
  )

;; definition for method 11 of type torus
(defmethod dummy-11 torus ((obj torus) (arg0 vector))
  (let ((s4-0 (the-as collide-shape-prim-group (-> *target* control root-prim))))
    (when (and (logtest? (-> s4-0 prim-core collide-as) (collide-kind target))
               (TODO-RENAME-10 obj (-> s4-0 prim-core) arg0)
               )
      (countdown (s3-0 (-> s4-0 num-prims))
        (let ((v1-9 (-> s4-0 prims s3-0)))
          (if (and (logtest? (-> v1-9 prim-core action) (collide-action solid))
                   (logtest? (-> v1-9 prim-core collide-as) (collide-kind target))
                   (TODO-RENAME-10 obj (-> v1-9 prim-core) arg0)
                   )
              (return #t)
              )
          )
        )
      )
    )
  #f
  )

;; definition of type torus-verts
(deftype torus-verts (structure)
  ((vert vector 8 :inline :offset-assert   0)
   )
  :method-count-assert 9
  :size-assert         #x80
  :flag-assert         #x900000080
  )

;; definition for method 3 of type torus-verts
(defmethod inspect torus-verts ((obj torus-verts))
  (format #t "[~8x] ~A~%" obj 'torus-verts)
  (format #t "~Tvert[8] @ #x~X~%" (-> obj vert))
  obj
  )

;; definition for method 9 of type torus
;; INFO: Used lq/sq
;; INFO: Return type mismatch int vs none.
(defmethod dummy-9 torus ((obj torus) (arg0 vector))
  (local-vars (sv-256 int) (sv-272 int) (sv-288 int))
  (let ((s0-0 (new 'stack-no-clear 'vector))
        (s4-0 (new 'stack-no-clear 'vector))
        (s3-0 (new 'stack-no-clear 'vector))
        (s2-0 (new 'stack-no-clear 'matrix))
        (s1-0 (new 'stack-no-clear 'inline-array 'vector 8))
        )
    (set-vector! s0-0 0.0 0.0 1.0 1.0)
    (vector-flatten! s0-0 s0-0 (-> obj axis))
    (if (= (vector-normalize-ret-len! s0-0 1.0) 0.0)
        (set-vector! s0-0 0.0 1.0 0.0 1.0)
        )
    (vector-cross! s4-0 s0-0 (-> obj axis))
    (matrix-axis-angle! s2-0 s4-0 8192.0)
    (vector-float*! (-> s1-0 0) s0-0 (-> obj radius-secondary))
    (set! sv-256 0)
    (while (< sv-256 7)
      (vector-matrix*! (-> s1-0 (+ sv-256 1)) (-> s1-0 sv-256) s2-0)
      (set! sv-256 (+ sv-256 1))
      )
    (vector-float*! s0-0 s0-0 (-> obj radius-primary))
    (dotimes (v1-21 8)
      (vector+! (-> s1-0 v1-21) (-> s1-0 v1-21) s0-0)
      )
    (matrix-axis-angle! s2-0 (-> obj axis) 4096.0)
    (dotimes (s0-1 16)
      (set! sv-272 0)
      (while (< sv-272 7)
        (vector+! s4-0 (-> s1-0 sv-272) (-> obj origin))
        (vector+! s3-0 (-> s1-0 (+ sv-272 1)) (-> obj origin))
        (camera-line s4-0 s3-0 (the-as vector4w arg0))
        (set! sv-272 (+ sv-272 1))
        )
      (vector+! s4-0 (-> s1-0 0) (-> obj origin))
      (camera-line s4-0 s3-0 (the-as vector4w arg0))
      (set! sv-288 0)
      (while (< sv-288 8)
        (vector+! s4-0 (-> s1-0 sv-288) (-> obj origin))
        (vector-matrix*! (-> s1-0 sv-288) (-> s1-0 sv-288) s2-0)
        (vector+! s3-0 (-> s1-0 sv-288) (-> obj origin))
        (camera-line s4-0 s3-0 (the-as vector4w arg0))
        (set! sv-288 (+ sv-288 1))
        )
      )
    )
  0
  (none)
  )

;; definition for method 12 of type torus
(defmethod dummy-12 torus ((obj torus) (arg0 vector))
  (let* ((f30-0 65536.0)
         (v1-1 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
         (v1-2 (the-as number (logior #x3f800000 v1-1)))
         (f30-1 (* f30-0 (+ -1.0 (the-as float v1-2))))
         )
    (set! (-> arg0 x) 0.0)
    (set! (-> arg0 y) (* (-> obj radius-secondary) (sin f30-1)))
    (set! (-> arg0 z) (* (-> obj radius-secondary) (cos f30-1)))
    )
  (+! (-> arg0 z) (-> obj radius-primary))
  (set! (-> arg0 w) 0.0)
  (let ((s2-0 (new 'stack-no-clear 'matrix)))
    (let* ((s4-0 matrix-rotate-y!)
           (s3-0 s2-0)
           (f30-2 65536.0)
           (v1-6 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
           (v1-7 (the-as number (logior #x3f800000 v1-6)))
           )
      (s4-0 s3-0 (* f30-2 (+ -1.0 (the-as float v1-7))))
      )
    (vector-matrix*! arg0 arg0 s2-0)
    (matrix-from-two-vectors! s2-0 (new 'static 'vector :y 1.0 :w 1.0) (-> obj axis))
    (vector-matrix*! arg0 arg0 s2-0)
    )
  (vector+! arg0 arg0 (-> obj origin))
  arg0
  )

;; definition of type arcing-shot
(deftype arcing-shot (process-drawable)
  ((root-override collide-shape-moving         :offset        112)
   (y-vel         float                        :offset-assert 176)
   (grav          float                        :offset-assert 180)
   (from          vector               :inline :offset-assert 192)
   (to            vector               :inline :offset-assert 208)
   )
  :heap-base #x70
  :method-count-assert 20
  :size-assert         #xe0
  :flag-assert         #x14007000e0
  (:states
    arcing-shot-debug-trajectory
    )
  )

;; definition for method 3 of type arcing-shot
(defmethod inspect arcing-shot ((obj arcing-shot))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Ty-vel: ~f~%" (-> obj y-vel))
  (format #t "~T~Tgrav: ~f~%" (-> obj grav))
  (format #t "~T~Tfrom: #<vector @ #x~X>~%" (-> obj from))
  (format #t "~T~Tto: #<vector @ #x~X>~%" (-> obj to))
  obj
  )

;; definition for function arcing-shot-setup
;; INFO: Used lq/sq
(defbehavior arcing-shot-setup arcing-shot ((arg0 vector) (arg1 vector) (arg2 float))
  (set! (-> self from quad) (-> arg0 quad))
  (set! (-> self to quad) (-> arg1 quad))
  (let ((v1-2 (fmax 1.0 arg2)))
    (if (< (-> arg0 y) (-> arg1 y))
        (set! v1-2 (+ v1-2 (- (-> arg1 y) (-> arg0 y))))
        )
    (let ((f0-6 (* -4.0 v1-2))
          (f3-1 (* 4.0 v1-2 (- (-> arg1 y) (-> arg0 y))))
          )
      (set! (-> self y-vel) (* 0.5 (- (sqrtf (- (* f0-6 f0-6) (* 4.0 f3-1))) f0-6)))
      )
    (let ((f0-12 (/ (- (* (-> self y-vel) (-> self y-vel))) (* 2.0 v1-2))))
      (set! (-> self grav) f0-12)
      f0-12
      )
    )
  )

;; definition for function arcing-shot-calculate
(defbehavior arcing-shot-calculate arcing-shot ((arg0 vector) (arg1 float))
  (let ((s5-0 (fmin 1.0 (fmax 0.0 arg1))))
    (vector-lerp! arg0 (-> self from) (-> self to) s5-0)
    (set! (-> arg0 y) (-> self from y))
    (+! (-> arg0 y) (* (-> self y-vel) s5-0))
    (let ((f0-6 (+ (-> arg0 y) (* 0.5 s5-0 s5-0 (-> self grav)))))
      (set! (-> arg0 y) f0-6)
      f0-6
      )
    )
  )

;; definition for function arcing-shot-draw
;; INFO: Used lq/sq
(defbehavior arcing-shot-draw arcing-shot ()
  (let ((gp-0 (new 'stack-no-clear 'vector))
        (s5-0 (new 'stack-no-clear 'vector))
        )
    (set! (-> s5-0 quad) (-> self from quad))
    (dotimes (s4-0 30)
      (arcing-shot-calculate gp-0 (* 0.033333335 (the float (+ s4-0 1))))
      (camera-line gp-0 s5-0 (new 'static 'vector4w :x #xff :y #xff :w #x80))
      (set! (-> s5-0 quad) (-> gp-0 quad))
      )
    )
  #f
  )

;; failed to figure out what this is:
(defstate arcing-shot-debug-trajectory (arcing-shot)
  :trans (behavior ()
    (arcing-shot-setup (camera-pos) (-> self entity extra trans) 40960.0)
    (arcing-shot-draw)
    (none)
    )
  :code (behavior ()
    (loop
      (format *stdcon* "debug trajectory~%")
      (suspend)
      )
    (none)
    )
  )

;; definition of type darkecobomb
(deftype darkecobomb (arcing-shot)
  ((flight-time    time-frame  :offset-assert 224)
   (countdown-time float       :offset-assert 232)
   (anim-speed     float       :offset-assert 236)
   (next-tick      float       :offset-assert 240)
   )
  :heap-base #x90
  :method-count-assert 20
  :size-assert         #xf4
  :flag-assert         #x14009000f4
  (:states
    darkecobomb-countdown
    (darkecobomb-explode symbol)
    darkecobomb-idle
    darkecobomb-land
    )
  )

;; definition for method 3 of type darkecobomb
(defmethod inspect darkecobomb ((obj darkecobomb))
  (let ((t9-0 (method-of-type arcing-shot inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tflight-time: ~D~%" (-> obj flight-time))
  (format #t "~T~Tcountdown-time: ~f~%" (-> obj countdown-time))
  (format #t "~T~Tanim-speed: ~f~%" (-> obj anim-speed))
  (format #t "~T~Tnext-tick: ~f~%" (-> obj next-tick))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *darkecobomb-sg* darkecobomb darkecobomb-lod0-jg darkecobomb-idle-ja
              ((darkecobomb-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 3.5 0 6)
              )

;; failed to figure out what this is:
(defstate darkecobomb-explode (darkecobomb)
  :code (behavior ((arg0 symbol))
    (send-event *target* 'reset-pickup 'eco)
    (sound-play "explod-bomb" :position #f)
    (activate! *camera-smush-control* 819.2 37 600 1.0 0.995)
    (send-event (ppointer->process (-> self parent)) 'flash 255.0)
    (process-spawn
      part-tracker
      :init part-tracker-init
      (-> *part-group-id-table* 619)
      900
      #f
      #f
      #f
      (-> self root-override trans)
      :to *entity-pool*
      )
    (logior! (-> self draw status) (draw-status hidden))
    (cond
      ((or arg0 (and *target* (< (-> (target-pos 0) y) (+ 40960.0 (-> self entity extra trans y)))))
       (if *target*
           (logior! (-> *target* mask) (process-mask sleep))
           )
       (send-event (ppointer->process (-> self parent)) 'bomb-going)
       (send-event *camera* 'change-to-entity-by-name "camera-402")
       (set! (-> self state-time) (-> *display* base-frame-counter))
       (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 2))
         (suspend)
         )
       (send-event *camera* 'force-blend 0)
       (send-event *camera* 'change-state *camera-base-mode*)
       (send-event *camera* 'clear-entity)
       (if *target*
           (logclear! (-> *target* mask) (process-mask sleep))
           )
       (send-event *target* 'attack-invinc #f (static-attack-info ((mode 'instant-death))))
       )
      (else
        (send-event (ppointer->process (-> self parent)) 'bomb-done)
        )
      )
    (deactivate self)
    (none)
    )
  :post (the-as (function none :behavior darkecobomb) ja-post)
  )

;; definition for function darkecobomb-handler
(defbehavior darkecobomb-handler darkecobomb ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('touch 'attack)
     (go darkecobomb-explode #t)
     )
    )
  )

;; definition for function darkecobomb-explode-if-player-high-enough
;; INFO: Return type mismatch object vs none.
(defbehavior darkecobomb-explode-if-player-high-enough darkecobomb ()
  (if (and (not (movie?)) *target* (< (+ 409600.0 (-> self entity extra trans y)) (-> (target-pos 0) y)))
      (go darkecobomb-explode #f)
      )
  (none)
  )

;; failed to figure out what this is:
(defstate darkecobomb-countdown (darkecobomb)
  :event darkecobomb-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (set! (-> self next-tick) 0.9)
    (none)
    )
  :exit (behavior ()
    (stop! (-> self sound))
    (none)
    )
  :trans (behavior ()
    (darkecobomb-explode-if-player-high-enough)
    (let ((f0-1
            (fmax
              0.0
              (/ (- (-> self countdown-time) (the float (- (-> *display* game-frame-counter) (-> self state-time))))
                 (-> self countdown-time)
                 )
              )
            )
          )
      (let ((f1-5 (* (- 1.0 f0-1) (- 1.0 f0-1))))
        (set! (-> self anim-speed) (+ 1.0 f1-5))
        )
      (when (< (cos (* 16384.0 (- 1.0 f0-1))) (-> self next-tick))
        (process-spawn
          part-tracker
          :init part-tracker-init
          (-> *part-group-id-table* 663)
          150
          #f
          #f
          #f
          (-> self root-override trans)
          :to *entity-pool*
          )
        (set! (-> self next-tick) (+ -0.06 (-> self next-tick)))
        (sound-play "robo-warning")
        )
      )
    (if (>= (- (-> *display* game-frame-counter) (-> self state-time)) (the int (-> self countdown-time)))
        (go darkecobomb-explode #f)
        )
    (when (ja-group? (-> self draw art-group data 5))
      (let ((gp-2 (new 'stack-no-clear 'vector)))
        (vector<-cspace! gp-2 (-> self node-list data 5))
        (spawn (-> self part) gp-2)
        )
      )
    (none)
    )
  :code (behavior ()
    (sound-play "bomb-open")
    (ja-no-eval :group! (-> self draw art-group data 4) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (loop
      (ja-no-eval :group! (-> self draw art-group data 5) :num! (seek! max (-> self anim-speed)) :frame-num 0.0)
      (until (ja-done? 0)
        (update! (-> self sound))
        (suspend)
        (ja :num! (seek! max (-> self anim-speed)))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior darkecobomb) transform-post)
  )

;; failed to figure out what this is:
(defstate darkecobomb-land (darkecobomb)
  :event darkecobomb-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    0
    (none)
    )
  :trans (behavior ()
    (darkecobomb-explode-if-player-high-enough)
    (if (>= (- (-> *display* game-frame-counter) (-> self state-time)) (seconds 0.5))
        (go darkecobomb-countdown)
        )
    (none)
    )
  :code (behavior ()
    (ja-no-eval :num! (seek!))
    (while (not (ja-done? 0))
      (suspend)
      (ja-eval)
      )
    (loop
      (ja-no-eval :group! (-> self draw art-group data 2) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior darkecobomb) transform-post)
  )

;; failed to figure out what this is:
(defstate darkecobomb-idle (darkecobomb)
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (none)
    )
  :trans (behavior ()
    (arcing-shot-calculate
      (-> self root-override trans)
      (/ (the float (- (-> *display* game-frame-counter) (-> self state-time))) (the float (-> self flight-time)))
      )
    (if (>= (- (-> *display* game-frame-counter) (-> self state-time)) (-> self flight-time))
        (go darkecobomb-land)
        )
    (none)
    )
  :code (behavior ()
    (ja-no-eval :group! (-> self draw art-group data 3) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (loop
      (ja-no-eval :group! (-> self draw art-group data 2) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior darkecobomb) transform-post)
  )

;; definition for function darkecobomb-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior darkecobomb-init-by-other darkecobomb ((arg0 vector) (arg1 vector) (arg2 float) (arg3 time-frame) (arg4 float))
  (let ((s1-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
    (set! (-> s1-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s1-0 reaction) default-collision-reaction)
    (set! (-> s1-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s0-0 (new 'process 'collide-shape-prim-sphere s1-0 (the-as uint 0))))
      (set! (-> s0-0 prim-core collide-as) (collide-kind wall-object))
      (set! (-> s0-0 collide-with) (collide-kind target))
      (set! (-> s0-0 prim-core action) (collide-action solid))
      (set! (-> s0-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s0-0 transform-index) 3)
      (set-vector! (-> s0-0 local-sphere) 0.0 0.0 0.0 16384.0)
      (set-root-prim! s1-0 s0-0)
      )
    (set! (-> s1-0 nav-radius) (* 0.75 (-> s1-0 root-prim local-sphere w)))
    (backup-collide-with-as s1-0)
    (set! (-> self root-override) s1-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 quad))
  (initialize-skeleton self *darkecobomb-sg* '())
  (logclear! (-> self mask) (process-mask actor-pause))
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 639) self))
  (arcing-shot-setup arg0 arg1 arg2)
  (set! (-> self countdown-time) arg4)
  (set! (-> self flight-time) arg3)
  (set! (-> self sound) (new 'process 'ambient-sound (static-sound-spec "bomb-spin" :fo-max 80) (-> self to)))
  (go darkecobomb-idle)
  (none)
  )

;; definition of type greenshot
(deftype greenshot (arcing-shot)
  ((flight-time time-frame  :offset-assert 224)
   )
  :heap-base #x80
  :method-count-assert 20
  :size-assert         #xe8
  :flag-assert         #x14008000e8
  (:states
    greenshot-idle
    )
  )

;; definition for method 3 of type greenshot
(defmethod inspect greenshot ((obj greenshot))
  (let ((t9-0 (method-of-type arcing-shot inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tflight-time: ~D~%" (-> obj flight-time))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *greenshot-sg* greenshot greenshot-lod0-jg greenshot-idle-ja
              ((greenshot-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 4)
              )

;; failed to figure out what this is:
(defstate greenshot-idle (greenshot)
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (none)
    )
  :trans (behavior ()
    (arcing-shot-calculate
      (-> self root-override trans)
      (/ (the float (- (-> *display* game-frame-counter) (-> self state-time))) (the float (-> self flight-time)))
      )
    (if (>= (- (-> *display* game-frame-counter) (-> self state-time)) (-> self flight-time))
        (deactivate self)
        )
    (spawn (-> self part) (-> self root-override trans))
    (none)
    )
  :code (behavior ()
    (loop
      (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior greenshot) transform-post)
  )

;; definition for function greenshot-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior greenshot-init-by-other greenshot ((arg0 vector) (arg1 vector) (arg2 float) (arg3 time-frame))
  (let ((s2-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
    (set! (-> s2-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s2-0 reaction) default-collision-reaction)
    (set! (-> s2-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s1-0 (new 'process 'collide-shape-prim-sphere s2-0 (the-as uint 0))))
      (set! (-> s1-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s1-0 collide-with) (collide-kind target))
      (set! (-> s1-0 prim-core offense) (collide-offense indestructible))
      (set-vector! (-> s1-0 local-sphere) 0.0 8192.0 0.0 8192.0)
      (set-root-prim! s2-0 s1-0)
      )
    (set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w)))
    (backup-collide-with-as s2-0)
    (set! (-> self root-override) s2-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 quad))
  (initialize-skeleton self *greenshot-sg* '())
  (logclear! (-> self mask) (process-mask actor-pause))
  (arcing-shot-setup arg0 arg1 arg2)
  (set! (-> self flight-time) arg3)
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 664) self))
  (logior! (-> self draw status) (draw-status hidden))
  (go greenshot-idle)
  (none)
  )

;; definition of type redshot
(deftype redshot (arcing-shot)
  ((flight-time     time-frame                       :offset-assert 224)
   (stall-time      time-frame                       :offset-assert 232)
   (ring            torus                    :inline :offset-assert 240)
   (rotation-offset int64                            :offset-assert 280)
   (part-track      handle                           :offset-assert 288)
   (shot-particle   sparticle-launch-control         :offset-assert 296)
   (test-particle   sparticle-launch-control         :offset-assert 300)
   )
  :heap-base #xc0
  :method-count-assert 20
  :size-assert         #x130
  :flag-assert         #x1400c00130
  (:states
    redshot-explode
    redshot-idle
    redshot-wait
    )
  )

;; definition for method 3 of type redshot
(defmethod inspect redshot ((obj redshot))
  (let ((t9-0 (method-of-type arcing-shot inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tflight-time: ~D~%" (-> obj flight-time))
  (format #t "~T~Tstall-time: ~D~%" (-> obj stall-time))
  (format #t "~T~Tring: #<torus @ #x~X>~%" (-> obj ring))
  (format #t "~T~Trotation-offset: ~D~%" (-> obj rotation-offset))
  (format #t "~T~Tpart-track: ~D~%" (-> obj part-track))
  (format #t "~T~Tshot-particle: ~A~%" (-> obj shot-particle))
  (format #t "~T~Ttest-particle: ~A~%" (-> obj test-particle))
  obj
  )

;; definition for method 7 of type redshot
;; INFO: Return type mismatch arcing-shot vs redshot.
(defmethod relocate redshot ((obj redshot) (arg0 int))
  (if (nonzero? (-> obj shot-particle))
      (&+! (-> obj shot-particle) arg0)
      )
  (if (nonzero? (-> obj test-particle))
      (&+! (-> obj test-particle) arg0)
      )
  (the-as redshot ((method-of-type arcing-shot relocate) obj arg0))
  )

;; definition for method 10 of type redshot
(defmethod deactivate redshot ((obj redshot))
  (if (nonzero? (-> obj shot-particle))
      (kill-and-free-particles (-> obj shot-particle))
      )
  (if (nonzero? (-> obj test-particle))
      (kill-and-free-particles (-> obj test-particle))
      )
  ((method-of-type arcing-shot deactivate) obj)
  (none)
  )

;; definition for function redshot-particle-callback
;; INFO: Return type mismatch int vs none.
(defun redshot-particle-callback ((arg0 part-tracker))
  (let ((v1-0 (the-as object (-> arg0 userdata))))
    (set! (-> *part-id-table* 2626 init-specs 2 initial-valuef)
          (* 2.25 (-> (the-as (pointer redshot) v1-0) 0 ring radius-primary))
          )
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defskelgroup *redring-sg* redring redring-lod0-jg redring-idle-ja
              ((redring-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 40)
              )

;; definition for function redshot-trans
;; INFO: Return type mismatch object vs none.
(defbehavior redshot-trans redshot ((arg0 time-frame))
  (let ((s5-0 (new 'stack-no-clear 'matrix)))
    0.0
    (matrix-rotate-yx!
      s5-0
      (* 436.90668 (the float (+ (-> self rotation-offset) (-> *display* game-frame-counter))))
      (* 291.27112 (the float (+ (-> self rotation-offset) (-> *display* game-frame-counter))))
      )
    (matrix->quaternion (-> self root-override quat) s5-0)
    )
  (if (< (* 0.006666667 (the float (min 150 arg0))) 1.0)
      (spawn (-> self part) (-> self root-override trans))
      )
  (none)
  )

;; failed to figure out what this is:
(defstate redshot-explode (redshot)
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (sound-play "red-explode")
    (logclear! (-> self draw status) (draw-status hidden))
    (quaternion-identity! (-> self root-override quat))
    (set! (-> self ring radius-secondary) 3072.0)
    (set! (-> self ring origin quad) (-> self root-override trans quad))
    (+! (-> self ring origin y) (-> self ring radius-secondary))
    (set-vector! (-> self ring axis) 0.0 1.0 0.0 1.0)
    (set! (-> self part-track) (ppointer->handle (process-spawn
                                                   part-tracker
                                                   :init part-tracker-init
                                                   (-> *part-group-id-table* 648)
                                                   -1
                                                   redshot-particle-callback
                                                   (-> self ppointer)
                                                   #f
                                                   (-> self root-override trans)
                                                   :to self
                                                   )
                                                 )
          )
    (none)
    )
  :trans (behavior ()
    (set! (-> self ring radius-primary)
          (* 204.8 (the float (- (-> *display* game-frame-counter) (-> self state-time))))
          )
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (when (dummy-11 (-> self ring) gp-0)
        (vector-normalize! gp-0 16384.0)
        (send-event *target* 'attack #f (static-attack-info ((vector gp-0))))
        (send-event (ppointer->process (-> self parent)) 'hit-jak)
        )
      )
    (dotimes (gp-1 5)
      (let ((s5-0 (new 'stack-no-clear 'vector)))
        (dummy-12 (-> self ring) s5-0)
        (spawn (-> self test-particle) s5-0)
        )
      )
    (let ((f0-3
            (fmin
              1.0
              (* 0.006666667 (the float (- (seconds 2) (- (-> *display* game-frame-counter) (-> self state-time)))))
              )
            )
          )
      (set-vector! (-> self draw color-mult) f0-3 f0-3 f0-3 0.75)
      )
    (when (>= (- (-> *display* game-frame-counter) (-> self state-time)) (seconds 2))
      (send-event (ppointer->process (-> self parent)) 'missed-jak)
      (deactivate self)
      )
    (none)
    )
  :code (behavior ()
    (loop
      (ja :num-func num-func-identity :frame-num (* 0.000016276043 (-> self ring radius-primary)))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior redshot) transform-post)
  )

;; definition for function redshot-handler
(defbehavior redshot-handler redshot ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('attack 'touch)
     (go redshot-explode)
     )
    )
  )

;; failed to figure out what this is:
(defstate redshot-wait (redshot)
  :event redshot-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (none)
    )
  :trans (behavior ()
    (redshot-trans (- (-> self stall-time) (- (-> *display* game-frame-counter) (-> self state-time))))
    (if (>= (- (-> *display* game-frame-counter) (-> self state-time)) (-> self stall-time))
        (go redshot-explode)
        )
    (spawn (-> self shot-particle) (-> self root-override trans))
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior redshot) transform-post)
  )

;; failed to figure out what this is:
(defstate redshot-idle (redshot)
  :event redshot-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (none)
    )
  :trans (behavior ()
    (redshot-trans (seconds 5))
    (arcing-shot-calculate
      (-> self root-override trans)
      (/ (the float (- (-> *display* game-frame-counter) (-> self state-time))) (the float (-> self flight-time)))
      )
    (if (>= (- (-> *display* game-frame-counter) (-> self state-time)) (-> self flight-time))
        (go redshot-wait)
        )
    (spawn (-> self shot-particle) (-> self root-override trans))
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior redshot) transform-post)
  )

;; definition for function redshot-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior redshot-init-by-other redshot ((arg0 vector) (arg1 vector) (arg2 float) (arg3 time-frame) (arg4 time-frame) (arg5 int))
  (local-vars (sv-16 collide-shape-prim-sphere))
  (let ((s0-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
    (set! (-> s0-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s0-0 reaction) default-collision-reaction)
    (set! (-> s0-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (set! sv-16 (new 'process 'collide-shape-prim-sphere s0-0 (the-as uint 0)))
    (set! (-> sv-16 prim-core collide-as) (collide-kind wall-object))
    (set! (-> sv-16 collide-with) (collide-kind target))
    (set! (-> sv-16 prim-core action) (collide-action solid))
    (set! (-> sv-16 prim-core offense) (collide-offense indestructible))
    (set! (-> sv-16 transform-index) 4)
    (set-vector! (-> sv-16 local-sphere) 0.0 0.0 0.0 12288.0)
    (set-root-prim! s0-0 sv-16)
    (set! (-> s0-0 nav-radius) (* 0.75 (-> s0-0 root-prim local-sphere w)))
    (backup-collide-with-as s0-0)
    (set! (-> self root-override) s0-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 quad))
  (initialize-skeleton self *redring-sg* '())
  (logclear! (-> self mask) (process-mask actor-pause))
  (arcing-shot-setup arg0 arg1 arg2)
  (set! (-> self flight-time) arg3)
  (set! (-> self stall-time) arg4)
  (set! (-> self rotation-offset) arg5)
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 647) self))
  (set! (-> self shot-particle) (create-launch-control (-> *part-group-id-table* 665) self))
  (set! (-> self test-particle) (create-launch-control (-> *part-group-id-table* 679) self))
  (logior! (-> self draw status) (draw-status hidden))
  (set! (-> self sound)
        (new 'process 'ambient-sound (static-sound-spec "red-fireball" :fo-max 80) (-> self root-override trans))
        )
  (go redshot-idle)
  (none)
  )

;; definition of type yellowshot
(deftype yellowshot (arcing-shot)
  ((flight-time time-frame  :offset-assert 224)
   )
  :heap-base #x80
  :method-count-assert 20
  :size-assert         #xe8
  :flag-assert         #x14008000e8
  (:states
    yellowshot-idle
    )
  )

;; definition for method 3 of type yellowshot
(defmethod inspect yellowshot ((obj yellowshot))
  (let ((t9-0 (method-of-type arcing-shot inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tflight-time: ~D~%" (-> obj flight-time))
  obj
  )

;; failed to figure out what this is:
(defstate yellowshot-idle (yellowshot)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touch 'attack)
       (when (= (-> arg0 type) target)
         (send-event *target* 'attack (-> arg3 param 0) (static-attack-info ((mode 'generic))))
         (send-event (ppointer->process (-> self parent)) 'hit-jak)
         )
       )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* game-frame-counter))
    (none)
    )
  :trans (behavior ()
    (arcing-shot-calculate
      (-> self root-override trans)
      (/ (the float (- (-> *display* game-frame-counter) (-> self state-time))) (the float (-> self flight-time)))
      )
    (spawn (-> self part) (-> self root-override trans))
    (when (>= (- (-> *display* game-frame-counter) (-> self state-time)) (-> self flight-time))
      (send-event (ppointer->process (-> self parent)) 'missed-jak)
      (deactivate self)
      )
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior yellowshot) transform-post)
  )

;; definition for function yellowshot-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior yellowshot-init-by-other yellowshot ((arg0 vector) (arg1 vector) (arg2 float) (arg3 time-frame))
  (let ((s2-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
    (set! (-> s2-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s2-0 reaction) default-collision-reaction)
    (set! (-> s2-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s1-0 (new 'process 'collide-shape-prim-sphere s2-0 (the-as uint 0))))
      (set! (-> s1-0 prim-core collide-as) (collide-kind wall-object))
      (set! (-> s1-0 collide-with) (collide-kind target))
      (set! (-> s1-0 prim-core action) (collide-action solid))
      (set! (-> s1-0 prim-core offense) (collide-offense indestructible))
      (set-vector! (-> s1-0 local-sphere) 0.0 0.0 0.0 12288.0)
      (set-root-prim! s2-0 s1-0)
      )
    (set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w)))
    (backup-collide-with-as s2-0)
    (set! (-> self root-override) s2-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 quad))
  (initialize-skeleton self *redring-sg* '())
  (logior! (-> self draw status) (draw-status hidden))
  (arcing-shot-setup arg0 arg1 arg2)
  (set! (-> self flight-time) arg3)
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 652) self))
  (go yellowshot-idle)
  (none)
  )
