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

(import "goal_src/jak1/import/swamp-bat-ag.gc")

;; definition of type swamp-bat-idle-path
(deftype swamp-bat-idle-path (structure)
  ((origin vector :inline :offset-assert   0)
   (x-axis vector :inline :offset-assert  16)
   (y-axis vector :inline :offset-assert  32)
   )
  :method-count-assert 10
  :size-assert         #x30
  :flag-assert         #xa00000030
  (:methods
    (TODO-RENAME-9 (_type_ vector float) vector 9)
    )
  )

;; definition for method 3 of type swamp-bat-idle-path
(defmethod inspect swamp-bat-idle-path ((obj swamp-bat-idle-path))
  (format #t "[~8x] ~A~%" obj 'swamp-bat-idle-path)
  (format #t "~Torigin: #<vector @ #x~X>~%" (-> obj origin))
  (format #t "~Tx-axis: #<vector @ #x~X>~%" (-> obj x-axis))
  (format #t "~Ty-axis: #<vector @ #x~X>~%" (-> obj y-axis))
  obj
  )

;; definition for method 9 of type swamp-bat-idle-path
;; INFO: Used lq/sq
(defmethod TODO-RENAME-9 swamp-bat-idle-path ((obj swamp-bat-idle-path) (arg0 vector) (arg1 float))
  (let ((f30-0 (* 65536.0 arg1)))
    (set! (-> arg0 quad) (-> obj origin quad))
    (vector+*! arg0 arg0 (-> obj x-axis) (cos f30-0))
    (vector+*! arg0 arg0 (-> obj y-axis) (sin f30-0))
    )
  arg0
  )

;; definition of type swamp-bat
(deftype swamp-bat (process-drawable)
  ((child-process       (pointer swamp-bat-slave)           :offset         20)
   (root-override       collide-shape                       :offset        112)
   (fact-override       fact-info-enemy                     :offset        144)
   (path-origin         vector                    :inline   :offset-assert 176)
   (idle-position-angle float                     8         :offset-assert 192)
   (path-select-plane   plane                     2 :inline :offset-assert 224)
   (path-list           curve-control             2         :offset-assert 256)
   (path-select         int8                                :offset-assert 264)
   (slave-count         int8                                :offset-assert 265)
   (path-count          int8                                :offset-assert 266)
   )
  :heap-base #xa0
  :method-count-assert 20
  :size-assert         #x10b
  :flag-assert         #x1400a0010b
  (:states
    swamp-bat-idle
    swamp-bat-launch-slaves
    )
  )

;; definition for method 3 of type swamp-bat
(defmethod inspect swamp-bat ((obj swamp-bat))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tpath-origin: #<vector @ #x~X>~%" (-> obj path-origin))
  (format #t "~T~Tidle-position-angle[8] @ #x~X~%" (-> obj idle-position-angle))
  (format #t "~T~Tpath-select-plane[2] @ #x~X~%" (-> obj path-select-plane))
  (format #t "~T~Tpath-list[2] @ #x~X~%" (-> obj path-list))
  (format #t "~T~Tpath-select: ~D~%" (-> obj path-select))
  (format #t "~T~Tslave-count: ~D~%" (-> obj slave-count))
  (format #t "~T~Tpath-count: ~D~%" (-> obj path-count))
  obj
  )

;; definition for method 7 of type swamp-bat
;; INFO: Return type mismatch process-drawable vs swamp-bat.
(defmethod relocate swamp-bat ((obj swamp-bat) (arg0 int))
  (dotimes (v1-0 2)
    (if (nonzero? (-> obj path-list v1-0))
        (&+! (-> obj path-list v1-0) arg0)
        )
    )
  (the-as
    swamp-bat
    ((the-as (function process-drawable int process-drawable) (find-parent-method swamp-bat 7)) obj arg0)
    )
  )

;; definition of type swamp-bat-slave
(deftype swamp-bat-slave (process-drawable)
  ((parent-process      (pointer swamp-bat)          :offset         12)
   (root-override       collide-shape-moving         :offset        112)
   (sync                sync-info            :inline :offset-assert 176)
   (idle-anim-speed     float                        :offset-assert 184)
   (strafe-envelope     float                        :offset-assert 188)
   (strafe-distance     float                        :offset-assert 192)
   (path-point-count    float                        :offset-assert 196)
   (idle-path           swamp-bat-idle-path  :inline :offset-assert 208)
   (idle-position       vector               :inline :offset-assert 256)
   (idle-position-index int8                         :offset-assert 272)
   (path-select         int8                         :offset-assert 273)
   (launch-ready        symbol                       :offset-assert 276)
   )
  :heap-base #xb0
  :method-count-assert 21
  :size-assert         #x118
  :flag-assert         #x1500b00118
  (:methods
    (dummy-20 (_type_) float 20)
    )
  (:states
    (swamp-bat-slave-die handle)
    swamp-bat-slave-idle
    swamp-bat-slave-launch
    swamp-bat-slave-return
    swamp-bat-slave-strafe
    swamp-bat-slave-swoop
    )
  )

;; definition for method 3 of type swamp-bat-slave
(defmethod inspect swamp-bat-slave ((obj swamp-bat-slave))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tsync: #<sync-info @ #x~X>~%" (-> obj sync))
  (format #t "~T~Tidle-anim-speed: ~f~%" (-> obj idle-anim-speed))
  (format #t "~T~Tstrafe-envelope: ~f~%" (-> obj strafe-envelope))
  (format #t "~T~Tstrafe-distance: ~f~%" (-> obj strafe-distance))
  (format #t "~T~Tpath-point-count: ~f~%" (-> obj path-point-count))
  (format #t "~T~Tidle-path: #<swamp-bat-idle-path @ #x~X>~%" (-> obj idle-path))
  (format #t "~T~Tidle-position: #<vector @ #x~X>~%" (-> obj idle-position))
  (format #t "~T~Tidle-position-index: ~D~%" (-> obj idle-position-index))
  (format #t "~T~Tpath-select: ~D~%" (-> obj path-select))
  (format #t "~T~Tlaunch-ready: ~A~%" (-> obj launch-ready))
  obj
  )

;; definition for function swamp-bat-slave-event-handler
(defbehavior swamp-bat-slave-event-handler swamp-bat-slave ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('attack)
     (logclear! (-> self mask) (process-mask actor-pause))
     (go swamp-bat-slave-die (process->handle arg0))
     )
    (('touch)
     (level-hint-spawn
       (game-text-id swamp-bat-duck-hint)
       "sksp0156"
       (the-as entity #f)
       *entity-pool*
       (game-task none)
       )
     (send-event arg0 'attack (-> arg3 param 0) (new 'static 'attack-info))
     )
    (('launch)
     (if (-> self launch-ready)
         (go swamp-bat-slave-launch)
         )
     )
    )
  )

;; failed to figure out what this is:
swamp-bat-slave-event-handler

;; definition for function swamp-bat-slave-post
(defbehavior swamp-bat-slave-post swamp-bat-slave ()
  (transform-post)
  )

;; definition for method 20 of type swamp-bat-slave
(defmethod dummy-20 swamp-bat-slave ((obj swamp-bat-slave))
  (* (get-current-phase (-> obj sync)) (-> obj path-point-count))
  )

;; definition for function swamp-bat-slave-path-post
;; INFO: Used lq/sq
(defbehavior swamp-bat-slave-path-post swamp-bat-slave ()
  (let ((s2-0 (-> self parent-process 0 path-list (-> self path-select)))
        (s5-0 (new-stack-vector0))
        (gp-0 (new-stack-vector0))
        (s4-0 (new-stack-vector0))
        (f30-0 (dummy-20 self))
        (s3-0 (new 'static 'vector :y 1.0 :w 1.0))
        )
    (eval-path-curve-div! s2-0 s5-0 f30-0 'interp)
    (TODO-RENAME-12 s2-0 gp-0 f30-0)
    (vector-cross! s4-0 gp-0 s3-0)
    (vector-normalize! s4-0 1.0)
    (let ((f0-4 (fmax
                  (fmin (- (vector-dot (target-pos 0) s4-0) (vector-dot s5-0 s4-0)) (-> self strafe-envelope))
                  (- (-> self strafe-envelope))
                  )
                )
          )
      (seek! (-> self strafe-distance) f0-4 (* 20480.0 (-> *display* seconds-per-frame)))
      )
    (vector-float*! s4-0 s4-0 (-> self strafe-distance))
    (vector+! (-> self root-override trans) s5-0 s4-0)
    (forward-up->quaternion (-> self root-override quat) gp-0 s3-0)
    )
  (swamp-bat-slave-post)
  )

;; failed to figure out what this is:
(defskelgroup *swamp-bat-slave-sg* swamp-bat swamp-bat-lod0-jg swamp-bat-idle-ja
              ((swamp-bat-lod0-mg (meters 20)) (swamp-bat-lod1-mg (meters 40)) (swamp-bat-lod2-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 2.5)
              )

;; definition for function swamp-bat-slave-get-new-path
;; INFO: Used lq/sq
(defbehavior swamp-bat-slave-get-new-path swamp-bat-slave ()
  (set! (-> self path-select) (-> self parent-process 0 path-select))
  (set! (-> self idle-path origin quad) (-> self parent-process 0 path-origin quad))
  (let* ((f28-0 (-> self parent-process 0 idle-position-angle (-> self idle-position-index)))
         (f30-0 (cos f28-0))
         (f26-0 (sin f28-0))
         (f28-1 (cos 8192.0))
         )
    (let ((f0-0 (sin 8192.0)))
      (set! (-> self idle-path x-axis x) (* 12288.0 f30-0))
      (set! (-> self idle-path x-axis y) 0.0)
      (set! (-> self idle-path x-axis z) (* 12288.0 f26-0))
      (set! (-> self idle-path x-axis w) 1.0)
      (set! (-> self idle-path y-axis x) (* -12288.0 f26-0 f28-1))
      (set! (-> self idle-path y-axis y) (* 12288.0 f0-0))
      )
    (set! (-> self idle-path y-axis z) (* 12288.0 f30-0 f28-1))
    )
  (set! (-> self idle-path y-axis w) 1.0)
  (vector+! (-> self idle-position) (the-as vector (-> self idle-path)) (-> self idle-path x-axis))
  (let ((f0-8 (the float (+ (-> self parent-process 0 path-list (-> self path-select) curve num-cverts) -1))))
    (set! (-> self path-point-count) f0-8)
    f0-8
    )
  )

;; failed to figure out what this is:
(defstate swamp-bat-slave-idle (swamp-bat-slave)
  :event swamp-bat-slave-event-handler
  :code (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self launch-ready) #f)
    (ja-channel-push! 1 (seconds 0.165))
    (ja :group! swamp-bat-idle-ja)
    (let ((s5-0 (new 'stack-no-clear 'vector)))
      (set! (-> s5-0 quad) (-> self root-override trans quad))
      (let ((s4-0 (quaternion-copy! (new 'stack-no-clear 'quaternion) (-> self root-override quat)))
            (gp-0 (new-stack-quaternion0))
            )
        (let ((s2-0
                (TODO-RENAME-12 (-> self parent-process 0 path-list (-> self path-select)) (new 'stack-no-clear 'vector) 0.1)
                )
              )
          0
          (let* ((f0-0 300.0)
                 (f1-0 32768.0)
                 (s3-0 (the int (* f0-0 (/ 1.0 f1-0) (vector-vector-distance s5-0 (-> self idle-position)))))
                 )
            (forward-up->quaternion gp-0 s2-0 (new 'static 'vector :y 1.0 :w 1.0))
            (loop
              (let ((v1-17 (- (-> *display* base-frame-counter) (-> self state-time))))
                (when (>= v1-17 s3-0)
                  0
                  (goto cfg-10)
                  )
                (let ((f30-1 (/ (the float v1-17) (the float s3-0))))
                  (when *run-time-assert-enable*
                    (set-pos *__private-assert-info* "swamp-bat" (the-as uint 283) (the-as uint 20))
                    (__assert (< f30-1 1.0) "(< interp 1.0)")
                    )
                  (vector-lerp! (-> self root-override trans) s5-0 (-> self idle-position) f30-1)
                  (quaternion-slerp! (-> self root-override quat) s4-0 gp-0 f30-1)
                  )
                )
              (ja :num! (loop! (-> self idle-anim-speed)))
              (suspend)
              0
              )
            )
          )
        (label cfg-10)
        (set! (-> self root-override trans quad) (-> self idle-position quad))
        (quaternion-copy! (-> self root-override quat) gp-0)
        )
      )
    (set! (-> self launch-ready) #t)
    (logior! (-> self mask) (process-mask actor-pause))
    (let ((f30-2 0.0))
      (loop
        (let ((f26-0 (cos f30-2))
              (f28-0 (sin f30-2))
              )
          (set! (-> self root-override trans quad) (-> self idle-path origin quad))
          (vector+*! (-> self root-override trans) (-> self root-override trans) (-> self idle-path x-axis) f26-0)
          (vector+*! (-> self root-override trans) (-> self root-override trans) (-> self idle-path y-axis) f28-0)
          )
        (ja :num! (loop! (-> self idle-anim-speed)))
        (suspend)
        (+! f30-2 (* 32768.0 (-> *display* seconds-per-frame) (-> self idle-anim-speed)))
        )
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-post)
  )

;; failed to figure out what this is:
(defstate swamp-bat-slave-launch (swamp-bat-slave)
  :event swamp-bat-slave-event-handler
  :code (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self launch-ready) #f)
    (ja-channel-push! 1 (seconds 0.1))
    (let ((gp-0 (new-stack-vector0)))
      (set! (-> gp-0 quad) (-> self root-override trans quad))
      (let ((s5-0 (new-stack-vector0)))
        (eval-path-curve-div! (-> self parent-process 0 path-list (-> self path-select)) s5-0 0.0 'interp)
        (ja :group! swamp-bat-idle-ja)
        (loop
          (let ((s4-0 (- (-> *display* base-frame-counter) (-> self state-time))))
            (if (>= s4-0 (seconds 0.3))
                (go swamp-bat-slave-swoop)
                )
            (let ((f0-1 (* 0.011111111 (the float s4-0))))
              (vector-lerp! (-> self root-override trans) gp-0 s5-0 f0-1)
              )
            )
          (ja :num! (loop! (-> self idle-anim-speed)))
          (suspend)
          0
          )
        )
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-post)
  )

;; failed to figure out what this is:
(defstate swamp-bat-slave-swoop (swamp-bat-slave)
  :event swamp-bat-slave-event-handler
  :code (behavior ()
    (set! (-> self strafe-envelope) 0.0)
    (ja-channel-push! 1 (seconds 0.1))
    (ja :group! swamp-bat-notice-ja :num! min)
    (until (ja-done? 0)
      (if (< (ja-aframe-num 0) 10.0)
          (sync-now! (-> self sync) 0.0)
          )
      (suspend)
      (ja :num! (seek!))
      )
    (set! (-> self strafe-envelope) 20480.0)
    (ja-channel-push! 1 (seconds 0.1))
    (ja :group! swamp-bat-swoop-ja)
    (loop
      (if (>= (dummy-20 self) 2.0)
          (go swamp-bat-slave-strafe)
          )
      (ja :num! (loop!))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-path-post)
  )

;; failed to figure out what this is:
(defstate swamp-bat-slave-strafe (swamp-bat-slave)
  :event swamp-bat-slave-event-handler
  :code (behavior ()
    (set! (-> self strafe-envelope) 20480.0)
    (ja-channel-push! 1 (seconds 0.1))
    (ja :group! swamp-bat-strafe-ja)
    (loop
      (if (>= (dummy-20 self) 6.0)
          (go swamp-bat-slave-return)
          )
      (ja :num! (loop!))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-path-post)
  )

;; failed to figure out what this is:
(defstate swamp-bat-slave-return (swamp-bat-slave)
  :event swamp-bat-slave-event-handler
  :code (behavior ()
    (set! (-> self strafe-envelope) 0.0)
    (ja-channel-push! 1 (seconds 0.075))
    (ja :group! swamp-bat-strafe-ja)
    (let ((f30-0 (+ -1.0 (-> self path-point-count)))
          (gp-0 #t)
          )
      (loop
        (let ((f28-0 (dummy-20 self)))
          (if (>= f28-0 f30-0)
              (go swamp-bat-slave-idle)
              )
          (when (and gp-0 (>= f28-0 7.0) (< f28-0 8.0))
            (set! gp-0 #f)
            (when (!= (-> self path-select) (-> self parent-process 0 path-select))
              (swamp-bat-slave-get-new-path)
              (go swamp-bat-slave-idle)
              )
            )
          )
        (ja :num! (loop!))
        (suspend)
        )
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-path-post)
  )

;; failed to figure out what this is:
(defstate swamp-bat-slave-die (swamp-bat-slave)
  :event (the-as
    (function process int symbol event-message-block object :behavior swamp-bat-slave)
    process-drawable-death-event-handler
    )
  :code (behavior ((arg0 handle))
    (ja-channel-push! 1 (seconds 0.07))
    (let ((gp-0 (new-stack-vector0)))
      (let ((v1-1 (handle->process arg0)))
        (if v1-1
            (vector-! gp-0 (-> self root-override trans) (-> (the-as swamp-bat v1-1) root-override trans))
            )
        )
      (set! (-> gp-0 y) (+ -6144.0 (-> gp-0 y)))
      (vector-normalize! gp-0 98304.0)
      (ja :group! swamp-bat-die-ja)
      (until (ja-done? 0)
        (vector-v++! (-> self root-override trans) gp-0)
        (ja :num! (seek! max 0.5))
        (suspend)
        )
      )
    (cleanup-for-death self)
    (none)
    )
  :post (the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-post)
  )

;; definition for function swamp-bat-slave-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior swamp-bat-slave-init-by-other swamp-bat-slave ((arg0 swamp-bat-slave) (arg1 int))
  (set! (-> self mask) (logior (process-mask enemy) (-> self mask)))
  (let ((s4-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
    (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s4-0 reaction) default-collision-reaction)
    (set! (-> s4-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 1) 0)))
      (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid))
      (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 6144.0)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core action) (collide-action solid))
        (set! (-> s2-0 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-0 transform-index) 3)
        (set-vector! (-> s2-0 local-sphere) 0.0 0.0 0.0 4096.0)
        (append-prim s3-0 s2-0)
        )
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> self root-override) s4-0)
    )
  (set! (-> self root-override trans quad) (-> arg0 root-override trans quad))
  (set! (-> self root-override quat vec quad) (-> arg0 root-override quat vec quad))
  (vector-float*! (-> self root-override scale) *identity-vector* 2.0)
  (set! (-> self root-override pause-adjust-distance) 286720.0)
  (set! (-> self fact)
        (new 'process 'fact-info-enemy self (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
        )
  (set! (-> self idle-anim-speed) (rand-vu-float-range 0.9 1.1))
  (set! (-> self strafe-distance) 0.0)
  (set! (-> self strafe-envelope) 0.0)
  (set! (-> self idle-position-index) arg1)
  (swamp-bat-slave-get-new-path)
  (set! (-> self root-override trans quad) (-> self idle-position quad))
  (setup-params! (-> self sync) (the-as uint 1200) 0.0 0.15 0.15)
  (initialize-skeleton self *swamp-bat-slave-sg* '())
  (logclear! (-> self mask) (process-mask actor-pause))
  (go swamp-bat-slave-idle)
  (none)
  )

;; definition for function swamp-bat-setup-new-path
(defbehavior swamp-bat-setup-new-path swamp-bat ((arg0 int))
  (when *run-time-assert-enable*
    (set-pos *__private-assert-info* "swamp-bat" (the-as uint 520) (the-as uint 2))
    (__assert-zero-lim-range-int arg0 (-> self path-count) "path-index" "(-> self path-count)")
    )
  (when (< 0.0 (the float (+ (-> self path-list arg0 curve num-cverts) -1)))
    (set! (-> self path-select) arg0)
    (let ((f30-0 0.0)
          (f28-0 (/ 65536.0 (the float (-> self slave-count))))
          )
      (eval-path-curve-div! (-> self path-list arg0) (-> self path-origin) 0.0 'interp)
      (dotimes (v1-16 (-> self slave-count))
        (set! (-> self idle-position-angle v1-16) f30-0)
        (+! f30-0 f28-0)
        )
      )
    #f
    )
  )

;; definition for function swamp-bat-make-path-select-plane
(defbehavior swamp-bat-make-path-select-plane swamp-bat ((arg0 int))
  (when *run-time-assert-enable*
    (set-pos *__private-assert-info* "swamp-bat" (the-as uint 538) (the-as uint 2))
    (__assert-zero-lim-range-int arg0 (-> self path-count) "path-index" "(-> self path-count)")
    )
  (let* ((s5-0 (-> self path-list arg0))
         (gp-1 (TODO-RENAME-12 s5-0 (-> self path-select-plane arg0) 5.0))
         (s5-1 (eval-path-curve-div! s5-0 (new 'stack-no-clear 'vector) 5.0 'interp))
         )
    (set! (-> gp-1 y) 0.0)
    (vector-normalize! gp-1 1.0)
    (let ((f0-3 (- (vector-dot s5-1 gp-1))))
      (set! (-> gp-1 w) f0-3)
      f0-3
      )
    )
  )

;; definition for function swamp-bat-update-path
;; INFO: Return type mismatch symbol vs none.
(defbehavior swamp-bat-update-path swamp-bat ()
  (dotimes (gp-0 (-> self path-count))
    (when (!= (-> self path-select) gp-0)
      (let* ((s5-0 (-> self path-select-plane gp-0))
             (f0-2 (+ (vector-dot (target-pos 0) (the-as vector s5-0)) (-> s5-0 w)))
             )
        (if (< 0.0 f0-2)
            (swamp-bat-setup-new-path gp-0)
            )
        )
      )
    )
  (none)
  )

;; definition for function swamp-bat-debug
;; INFO: Return type mismatch int vs none.
(defbehavior swamp-bat-debug swamp-bat ()
  0
  (none)
  )

;; definition for function swamp-bat-check-slave-paths-match?
(defbehavior swamp-bat-check-slave-paths-match? swamp-bat ((arg0 int))
  (let ((v1-0 (the-as (pointer process-tree) (-> self child-process))))
    (while v1-0
      (if (and (-> (the-as swamp-bat-slave (-> v1-0 0)) launch-ready)
               (!= (-> (the-as swamp-bat-slave (-> v1-0 0)) path-select) arg0)
               )
          (return #f)
          )
      (set! v1-0 (-> v1-0 0 brother))
      )
    )
  #t
  )

;; failed to figure out what this is:
(defstate swamp-bat-idle (swamp-bat)
  :trans swamp-bat-debug
  :code (behavior ()
    (when (zero? (-> self path-count))
      (process-entity-status! self (entity-perm-status dead) #t)
      (deactivate self)
      )
    (loop
      (when (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.2))
                 *target*
                 (>= (-> self fact-override idle-distance)
                     (vector-vector-distance (-> self root-override trans) (-> *target* control trans))
                     )
                 )
        (when (not (-> self child-process))
          (process-entity-status! self (entity-perm-status dead) #t)
          (deactivate self)
          )
        (swamp-bat-update-path)
        (if (or (dummy-10 (-> self vol) (target-pos 5)) (not (swamp-bat-check-slave-paths-match? (-> self path-select))))
            (go swamp-bat-launch-slaves)
            )
        )
      (let ((gp-1 (new 'static 'matrix)))
        (quaternion->matrix gp-1 (-> self root-override quat))
        (set! (-> gp-1 vector 3 quad) (-> self root-override trans quad))
        )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat) #f)
  )

;; definition for function swamp-bat-launch-slave
(defbehavior swamp-bat-launch-slave swamp-bat ()
  (let ((gp-0 (the-as (pointer process-tree) (-> self child-process)))
        (v0-0 (the-as object #f))
        )
    (while (and gp-0 (not v0-0))
      (let ((a1-0 (new 'stack-no-clear 'event-message-block)))
        (set! (-> a1-0 from) self)
        (set! (-> a1-0 num-params) 0)
        (set! (-> a1-0 message) 'launch)
        (set! v0-0 (send-event-function (ppointer->process gp-0) a1-0))
        )
      (set! gp-0 (-> gp-0 0 brother))
      )
    v0-0
    )
  )

;; failed to figure out what this is:
(defstate swamp-bat-launch-slaves (swamp-bat)
  :trans swamp-bat-debug
  :code (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (loop
      (swamp-bat-update-path)
      (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.5))
        (set! (-> self state-time) (-> *display* base-frame-counter))
        (if (not (swamp-bat-launch-slave))
            (go swamp-bat-idle)
            )
        )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior swamp-bat) #f)
  )

;; definition for method 11 of type swamp-bat
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! swamp-bat ((obj swamp-bat) (arg0 entity-actor))
  (let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player))))
    (let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
      (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 0.0)
      (set-root-prim! s4-0 s3-0)
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (logclear! (-> obj mask) (process-mask actor-pause))
  (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
  (set! (-> obj vol) (new 'process 'vol-control obj))
  (logior! (-> obj vol flags) 3)
  (set! (-> obj path-list 0) (new 'process 'curve-control obj 'path -1000000000.0))
  (set! (-> obj path-list 1) (new 'process 'curve-control obj 'pathb -1000000000.0))
  (logior! (-> obj path-list 0 flags) (path-control-flag display draw-line draw-point draw-text))
  (logior! (-> obj path-list 1 flags) (path-control-flag display draw-line draw-point draw-text))
  (set! (-> obj path-count) 0)
  (when (< 0.0 (the float (+ (-> obj path-list 0 curve num-cverts) -1)))
    (+! (-> obj path-count) 1)
    (swamp-bat-make-path-select-plane 0)
    )
  (when (< 0.0 (the float (+ (-> obj path-list 1 curve num-cverts) -1)))
    (+! (-> obj path-count) 1)
    (swamp-bat-make-path-select-plane 1)
    )
  (if (!= (-> obj path-count) 2)
      (go process-drawable-art-error "need 2 paths")
      )
  (set! (-> obj fact-override)
        (new 'process 'fact-info-enemy obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
        )
  (let ((a1-10 (res-lump-value arg0 'num-lurkers uint128 :default (the-as uint128 6))))
    (set! (-> obj slave-count) (max 2 (min 8 (the-as int a1-10))))
    )
  (swamp-bat-setup-new-path 0)
  (swamp-bat-update-path)
  (dotimes (s5-1 (-> obj slave-count))
    (process-spawn swamp-bat-slave obj s5-1 :to obj :stack-size 4512)
    )
  (go swamp-bat-idle)
  (none)
  )
