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

;; name: bombbot.gc
;; name in dgo: bombbot
;; dgos: LBLOWCST, FACD, LBOMBBOT, LCTYASS, LCTYPALT

;; DECOMP BEGINS

(define *bombbot-hint* (the-as sound-id 1))

(define *bombbot-hint-time* 0.0)

(deftype bombbot-hud (hud)
  ()
  )


(defmethod draw ((this bombbot-hud))
  (set-hud-piece-position! (-> this sprites 0) 256 (+ (the int (* 50.0 (-> this offset))) 376))
  (set! (-> this sprites 0 pos z) #xfffff0)
  (set-as-offset-from! (-> this sprites 1) (-> this sprites 0 pos) 62 -9)
  (set! (-> this sprites 1 pos z) #xfffff0)
  (let ((f0-4 (* 0.01 (the float (-> this values 0 current)))))
    (set! (-> this sprites 1 color x) 0)
    (set! (-> this sprites 1 color y) 0)
    (set! (-> this sprites 1 color z) 0)
    (set! (-> this sprites 1 scale-x) (* -30.5 (- 1.0 f0-4)))
    )
  (set! (-> this sprites 1 scale-y) 4.8)
  ((method-of-type hud draw) this)
  0
  (none)
  )

(defmethod update-values! ((this bombbot-hud))
  (set! (-> this values 0 target) (the int (-> *game-info* health-bar)))
  (logclear! (-> this flags) (hud-flags disable))
  ((method-of-type hud update-values!) this)
  0
  (none)
  )

(defmethod init-callback ((this bombbot-hud))
  (set! (-> this level) (level-get *level* 'lbombbot))
  (set! (-> this gui-id)
        (add-process *gui-control* this (gui-channel hud-upper-center-2) (gui-action hidden) (-> this name) 81920.0 0)
        )
  (logior! (-> this flags) (hud-flags show))
  (set! (-> this sprites 0 tid)
        (the-as texture-id (lookup-texture-by-id (new 'static 'texture-id :page #x950)))
        )
  (set! (-> this sprites 0 flags) (hud-sprite-flags hsf3))
  (set! (-> this sprites 0 scale-x) 1.2)
  (set! (-> this sprites 0 scale-y) 1.2)
  (set! (-> this sprites 1 tid) (the-as texture-id (get-texture common-white common)))
  (set! (-> this sprites 1 flags) (hud-sprite-flags))
  (set! (-> this sprites 1 scale-x) 0.0)
  (set! (-> this sprites 1 scale-y) 5.0)
  0
  (none)
  )

(define *bombbot-body-constants* (new 'static 'rigid-body-object-constants
                                   :info (new 'static 'rigid-body-info
                                     :mass 1.0
                                     :inv-mass 1.0
                                     :linear-damping 0.8
                                     :angular-damping 0.8
                                     :bounce-factor 0.5
                                     :friction-factor 0.1
                                     :cm-offset-joint (new 'static 'vector :w 1.0)
                                     :inertial-tensor-box (new 'static 'array meters 3 (meters 2) (meters 2) (meters 2))
                                     )
                                   :extra (new 'static 'rigid-body-object-extra-info
                                     :max-time-step 0.02
                                     :gravity (meters 10)
                                     :idle-distance (meters 200)
                                     :attack-force-scale 2.0
                                     )
                                   :name '*bombbot-body-constants*
                                   )
        )

(defpart 2055
  :init-specs ((:texture (glow-hotdot level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 4))
    (:scale-y :copy scale-x)
    (:r 196.0 128.0)
    (:g 196.0 128.0)
    (:b 196.0 128.0)
    (:a 128.0)
    (:rotvel-z (degrees 0.3))
    (:fade-g -1.0666667)
    (:fade-b -1.0666667)
    (:fade-a -8.533334)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    )
  )

(defpart 2056
  :init-specs ((:texture (pal-lightning level-default-sprite))
    (:birth-func 'birth-func-set-quat)
    (:num 1.0)
    (:scale-x (meters 2))
    (:scale-y (meters 40))
    (:r 128.0 64.0)
    (:g 128.0 64.0)
    (:b 128.0 64.0)
    (:a 128.0)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 left-multiply-quat))
    )
  )

(defpart 2057
  :init-specs ((:texture (glow-hotdot level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 4))
    (:scale-y :copy scale-x)
    (:r 128.0 64.0)
    (:g 128.0 64.0)
    (:b 128.0 64.0)
    (:a 128.0)
    (:rotvel-z (degrees 0.3))
    (:fade-g -1.0666667)
    (:fade-b -1.0666667)
    (:fade-a -8.533334)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    )
  )

(defpart 2058
  :init-specs ((:texture (glow-hotdot level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 2))
    (:scale-y :copy scale-x)
    (:r 128.0 64.0)
    (:g 128.0 64.0)
    (:b 128.0 64.0)
    (:a 128.0)
    (:rotvel-z (degrees 0.3))
    (:fade-g -1.0666667)
    (:fade-b -1.0666667)
    (:fade-a -8.533334)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14))
    )
  )

(defpart 2059
  :init-specs ((:texture (lasersmoke-00 level-default-sprite))
    (:birth-func 'birth-func-laser-pointer)
    (:num 1.0)
    (:scale-x (meters 0.15) (meters 0.1))
    (:scale-y (meters 40))
    (:r 0.0)
    (:g 0.0)
    (:b 255.0)
    (:a 64.0 32.0)
    (:fade-a -4.266667)
    (:timer (seconds 0.05))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 left-multiply-quat))
    (:userdata :data (new 'static 'boxed-array :type int32
                       10
                       1
                       0
                       #x401a00
                       #x401b00
                       #x401c00
                       #x401d00
                       #x401e00
                       #x401f00
                       #x402000
                       #x402100
                       #x402200
                       #x402300
                       #x402400
                       #x402500
                       #x402600
                       #x402700
                       #x402800
                       #x402900
                       #x402a00
                       #x402b00
                       #x402c00
                       #x402d00
                       #x402e00
                       #x402f00
                       #x403000
                       #x403100
                       #x403200
                       #x403300
                       #x403400
                       #x403500
                       #x403600
                       #x403700
                       #x403800
                       #x403900
                       )
               )
    (:func 'sparticle-texture-animate)
    )
  )

(defpart 2060
  :init-specs ((:texture (glow level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 0.2) (meters 0.05))
    (:rot-x (degrees 1.125))
    (:scale-y :copy scale-x)
    (:r 128.0)
    (:g 128.0 128.0)
    (:b 255.0)
    (:a 100.0 28.0)
    (:rotvel-z (degrees 0.3))
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-14 glow))
    (:userdata 1.0)
    )
  )

(defpart 2061
  :init-specs ((:texture (glow-hotdot level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 1.2) (meters 0.1))
    (:rot-x (degrees 1.125))
    (:scale-y :copy scale-x)
    (:r 0.0 32.0)
    (:g :copy r)
    (:b 32.0 32.0)
    (:a 32.0 32.0)
    (:rotvel-z (degrees 0.3))
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-14 glow))
    (:userdata 1.0)
    )
  )

(defpart 2062
  :init-specs ((:texture (glow-hotdot level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 0.4) (meters 0.1))
    (:rot-x (degrees 1.125))
    (:scale-y :copy scale-x)
    (:r 0.0)
    (:g :copy r)
    (:b 128.0 64.0)
    (:a 96.0 32.0)
    (:rotvel-z (degrees 0.3))
    (:fade-g -1.0666667)
    (:fade-b -1.0666667)
    (:fade-a -8.533334)
    (:timer (seconds 0.017))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-14 glow))
    (:userdata 1.0)
    )
  )

(defpartgroup group-bombbot-bomb-warning-glow
  :id 525
  :duration (seconds 0.017)
  :flags (sp0)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2063 :flags (sp6)) (sp-item 2064 :flags (sp6)))
  )

(defpart 2063
  :init-specs ((:texture (glow level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 1.5))
    (:rot-x (degrees 1.125))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 0.0)
    (:b 0.0)
    (:a 16.0)
    (:omega (degrees 1361.25))
    (:fade-a -0.32)
    (:timer (seconds 0.085))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:userdata 409.6)
    )
  )

(defpart 2064
  :init-specs ((:texture (glow level-default-sprite))
    (:num 1.0)
    (:scale-x (meters 0.5))
    (:rot-x (degrees 1.125))
    (:scale-y :copy scale-x)
    (:r 255.0)
    (:g 0.0)
    (:b 0.0)
    (:a 32.0)
    (:omega (degrees 1361.25))
    (:fade-a -0.64)
    (:timer (seconds 0.085))
    (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow))
    (:userdata 409.6)
    )
  )

(defskelgroup skel-bombbot-bomb bombbot-bomb bombbot-bomb-lod0-jg bombbot-bomb-idle-ja
              ((bombbot-bomb-lod0-mg (meters 20)) (bombbot-bomb-lod1-mg (meters 40)) (bombbot-bomb-lod2-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 2)
              :shadow bombbot-bomb-shadow-mg
              )

(deftype bombbot-bomb (process-focusable)
  ((parent               (pointer process-focusable) :override)
   (root                 collide-shape-moving        :override)
   (explode-part         sparticle-launch-control)
   (rot-axis             vector                       :inline)
   (rot-angle            float)
   (warning-glow-part    sparticle-launch-control)
   (next-countdown-tick  time-frame)
   (fizzle-timer         time-frame)
   )
  (:state-methods
    idle
    smoke
    explode
    back
    )
  (:methods
    (bombbot-bomb-method-32 (_type_) none)
    (bombbot-bomb-method-33 (_type_) none)
    )
  )


(defmethod bombbot-bomb-method-32 ((this bombbot-bomb))
  (local-vars (at-0 int))
  (rlet ((vf0 :class vf)
         (vf1 :class vf)
         (vf2 :class vf)
         )
    (init-vf0-vector)
    (let ((s5-0 (-> this root)))
      (let ((a1-0 (new 'stack-no-clear 'collide-query)))
        (let ((v1-0 (-> s5-0 root-prim)))
          (vector-copy! (-> a1-0 start-pos) (-> s5-0 trans))
          (let ((a0-2 (-> a1-0 move-dist)))
            (.lvf vf1 (&-> (-> s5-0 transv) quad))
            (let ((f0-0 (seconds-per-frame)))
              (.mov at-0 f0-0)
              )
            (.mov vf2 at-0)
            (.mov.vf.w vf1 vf0)
            (.mul.x.vf.xyz vf1 vf1 vf2)
            (.svf (&-> a0-2 quad) vf1)
            )
          (let ((a0-3 a1-0))
            (set! (-> a0-3 radius) (-> v1-0 prim-core world-sphere w))
            (set! (-> a0-3 collide-with) (-> v1-0 prim-core collide-with))
            (set! (-> a0-3 ignore-process0) this)
            (set! (-> a0-3 ignore-process1) #f)
            (set! (-> a0-3 ignore-pat) (-> s5-0 pat-ignore-mask))
            (set! (-> a0-3 action-mask) (collide-action solid))
            )
          )
        (fill-using-line-sphere *collide-cache* a1-0)
        )
      (integrate-and-collide! s5-0 (-> s5-0 transv))
      )
    (let ((s5-1 (new 'stack-no-clear 'vector)))
      (vector-cross! s5-1 (-> this root transv) *y-vector*)
      (vector-normalize! s5-1 1.0)
      (vector-copy! (-> this rot-axis) s5-1)
      )
    (let ((s5-2 (new 'stack-no-clear 'quaternion)))
      (new 'stack-no-clear 'vector)
      (quaternion-vector-angle! s5-2 (-> this rot-axis) (* (-> this rot-angle) (seconds-per-frame)))
      (quaternion-normalize! s5-2)
      (quaternion*! (-> this root quat) s5-2 (-> this root quat))
      )
    (quaternion-normalize! (-> this root quat))
    (let ((a1-6 (-> this root)))
      (when (logtest? (-> a1-6 status) (collide-status touch-surface))
        (vector+*! (-> a1-6 transv) (-> a1-6 transv) (-> a1-6 transv) (* -15.0 (seconds-per-frame)))
        (set! (-> this rot-angle) (* -4.0 (vector-length (-> this root transv))))
        )
      )
    0
    (none)
    )
  )

(defmethod bombbot-bomb-method-33 ((this bombbot-bomb))
  (let ((s5-0 (- (current-time) (-> this state-time))))
    (when (< (seconds 7) s5-0)
      (let ((f0-0 (rand-vu-float-range 0.5 0.8)))
        (set-vector! (-> this root scale) f0-0 f0-0 f0-0 1.0)
        )
      )
    (if (< (seconds 9) s5-0)
        (go (method-of-object this explode))
        )
    (let* ((v1-11 (* s5-0 s5-0))
           (a0-4 2700)
           (v1-12 (- (* a0-4 a0-4) v1-11))
           )
      (when (< v1-12 (-> this next-countdown-tick))
        (let ((a0-8 540))
          (set! (-> this next-countdown-tick) (the-as time-frame (- v1-12 (mod v1-12 (* a0-8 a0-8)))))
          )
        (let ((s5-1 (new 'stack-no-clear 'vector)))
          (vector<-cspace! s5-1 (-> this node-list data 7))
          (spawn (-> this warning-glow-part) s5-1)
          (vector<-cspace! s5-1 (-> this node-list data 6))
          (spawn (-> this warning-glow-part) s5-1)
          (vector<-cspace! s5-1 (-> this node-list data 5))
          (spawn (-> this warning-glow-part) s5-1)
          (vector<-cspace! s5-1 (-> this node-list data 4))
          (spawn (-> this warning-glow-part) s5-1)
          )
        (sound-play "grenade-timer")
        )
      )
    )
  0
  (none)
  )

(defbehavior bombbot-bomb-handler bombbot-bomb ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('attack)
     (cond
       ((= (-> arg0 type) target)
        (let ((s3-0 (as-type (ppointer->process (-> self parent)) process-focusable))
              (s5-0 (new 'stack-no-clear 'traj3d-params))
              (gp-1 (new 'stack-no-clear 'vector))
              (s4-0 (new 'stack-no-clear 'vector))
              )
          (when s3-0
            (vector-rotate-around-y! gp-1 *x-vector* (* 182.04445 (rand-vu-float-range 0.0 360.0)))
            (vector+*! (-> s5-0 dest) (get-trans s3-0 3) gp-1 8192.0)
            (vector+*! (-> s5-0 dest) (-> s5-0 dest) (get-transv s3-0) 2.0)
            (vector-copy! (-> s5-0 src) (-> self root trans))
            (set! (-> s5-0 initial-tilt) (* 182.04445 (rand-vu-float-range 30.0 50.0)))
            (set! (-> s5-0 gravity) 184320.0)
            (when (traj3d-calc-initial-velocity-using-tilt s5-0)
              (vector-! gp-1 (-> self root trans) (target-pos 0))
              (set! (-> gp-1 y) 0.0)
              (vector-normalize! gp-1 1.0)
              (vector-copy! s4-0 (-> s5-0 initial-velocity))
              (set! (-> s4-0 y) 0.0)
              (vector-normalize! s4-0 1.0)
              (cond
                ((< 0.7 (vector-dot gp-1 s4-0))
                 (vector-copy! (-> self root transv) (-> s5-0 initial-velocity))
                 )
                (else
                  (let ((t9-10 vector-normalize!)
                        (a0-21 gp-1)
                        (v1-20 (-> s5-0 initial-velocity))
                        )
                    (t9-10 a0-21 (sqrtf (+ (* (-> v1-20 x) (-> v1-20 x)) (* (-> v1-20 z) (-> v1-20 z)))))
                    )
                  (set! (-> gp-1 y) (-> s5-0 initial-velocity y))
                  (vector-copy! (-> self root transv) gp-1)
                  )
                )
              (go-virtual back)
              )
            )
          )
        )
       (else
         #f
         )
       )
     )
    )
  )

(defstate back (bombbot-bomb)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('touch)
       (let ((s3-0 (as-type proc process-drawable)))
         (when s3-0
           (let ((a0-3 (-> (the-as process-focusable s3-0) root))
                 (a1-2 (new 'stack-no-clear 'collide-query))
                 )
             (let ((v1-4 (-> self root root-prim prim-core))
                   (a0-5 (-> a0-3 root-prim prim-core))
                   )
               0.0
               (vector-copy! (-> a1-2 start-pos) (-> v1-4 world-sphere))
               (vector-! (-> a1-2 move-dist) (-> a0-5 world-sphere) (-> v1-4 world-sphere))
               )
             (let ((v1-5 a1-2))
               (set! (-> v1-5 radius) 40.96)
               (set! (-> v1-5 collide-with) (collide-spec backgnd))
               (set! (-> v1-5 ignore-process0) #f)
               (set! (-> v1-5 ignore-process1) #f)
               (set! (-> v1-5 ignore-pat)
                     (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
                     )
               (set! (-> v1-5 action-mask) (collide-action solid))
               )
             (when (< (fill-and-probe-using-line-sphere *collide-cache* a1-2) 0.0)
               (cond
                 ((logtest? (process-mask vehicle) (-> (the-as process-focusable s3-0) mask))
                  (let ((s4-2
                          (vector-! (new 'stack-no-clear 'vector) (-> (the-as process-focusable s3-0) root trans) (-> self root trans))
                          )
                        )
                    0.0
                    (let ((f30-0 (-> self root root-prim local-sphere w)))
                      (vector-normalize! s4-2 1.0)
                      (+! (-> s4-2 y) 0.25)
                      (if (< 0.0 f30-0)
                          (send-event
                            proc
                            'attack
                            (-> block param 0)
                            (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id))
                                                                                (damage 20.0)
                                                                                (vehicle-damage-factor 1.0)
                                                                                (vehicle-impulse-factor (/ f30-0 (meters 20)))
                                                                                (attacker-velocity s4-2)
                                                                                )
                                                )
                            )
                          )
                      )
                    )
                  )
                 (else
                   (send-event
                     proc
                     'attack
                     (-> block param 0)
                     (static-attack-info
                       :mask (vehicle-impulse-factor)
                       ((id (new-attack-id)) (damage 2.0) (vehicle-damage-factor 1.0) (vehicle-impulse-factor 1.0) (mode 'explode))
                       )
                     )
                   )
                 )
               )
             )
           )
         )
       (go-virtual explode)
       )
      (else
        #f
        )
      )
    )
  :enter (behavior ()
    (set-time! (-> self state-time))
    (let ((v1-3 (-> self root root-prim)))
      (logior! (-> v1-3 prim-core collide-with) (collide-spec enemy))
      (logclear! (-> v1-3 prim-core collide-with) (collide-spec jak))
      )
    )
  :exit (behavior ()
    '()
    )
  :trans (behavior ()
    (set! (-> self root transv y) (- (-> self root transv y) (* 184320.0 (seconds-per-frame))))
    (bombbot-bomb-method-32 self)
    (if (time-elapsed? (-> self state-time) (seconds 5))
        (go-virtual explode)
        )
    (ja :num! (loop!))
    )
  :code sleep-code
  :post (behavior ()
    (transform-post)
    (if (logtest? (-> self root status) (collide-status touch-surface))
        (go-virtual explode)
        )
    )
  )

(defstate explode (bombbot-bomb)
  :virtual #t
  :enter (behavior ()
    (ja-channel-set! 0)
    (let ((v1-1 (-> self root root-prim)))
      (set! (-> v1-1 prim-core collide-as) (collide-spec))
      (set! (-> v1-1 prim-core collide-with) (collide-spec))
      )
    0
    (sound-play "grenade-explode")
    (let ((gp-1 (new 'stack-no-clear 'explosion-init-params)))
      (vector-copy! (-> gp-1 spawn-point) (-> self root trans))
      (quaternion-identity! (-> gp-1 spawn-quat))
      (set! (-> gp-1 radius) 12288.0)
      (set! (-> gp-1 scale) 1.0)
      (set! (-> gp-1 group) (-> *part-group-id-table* 219))
      (set! (-> gp-1 collide-with)
            (collide-spec backgnd jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
            )
      (set! (-> gp-1 damage) 2.0)
      (set! (-> gp-1 damage-scale) 1.0)
      (set! (-> gp-1 vehicle-damage-factor) 1.0)
      (set! (-> gp-1 vehicle-impulse-factor) 1.0)
      (set! (-> gp-1 ignore-proc) (process->handle #f))
      (explosion-spawn gp-1 self)
      )
    (set-time! (-> self state-time))
    )
  :trans (behavior ()
    (cond
      ((not (time-elapsed? (-> self state-time) (seconds 2)))
       (let ((a1-0 (new 'stack-no-clear 'vector)))
         (vector-copy! a1-0 (-> self root trans))
         (+! (-> a1-0 y) 2048.0)
         (spawn (-> self explode-part) a1-0)
         )
       )
      ((not (-> self child))
       (deactivate self)
       )
      )
    )
  :code sleep-code
  :post ja-post
  )

(define *daxter-speech* 0)

(defstate smoke (bombbot-bomb)
  :virtual #t
  :event bombbot-bomb-handler
  :enter (behavior ()
    (let* ((v1-0 2700)
           (v1-1 (* v1-0 v1-0))
           (a0-0 540)
           )
      (set! (-> self next-countdown-tick) (the-as time-frame (- v1-1 (mod v1-1 (* a0-0 a0-0)))))
      )
    (set-time! (-> self state-time))
    (when (and (logtest? (-> self draw status) (draw-control-status on-screen))
               (= *bombbot-hint* 1)
               (< (the int *bombbot-hint-time*) (current-time))
               (< (vector-vector-distance (-> self root trans) (camera-pos)) 204800.0)
               )
      (set! *bombbot-hint-time* (the float (+ (current-time) (seconds 40))))
      (let ((v1-18 *daxter-speech*))
        (cond
          ((zero? v1-18)
           (talker-spawn-func (-> *talker-speech* 168) *entity-pool* (target-pos 0) (the-as region #f))
           )
          ((= v1-18 1)
           (talker-spawn-func (-> *talker-speech* 166) *entity-pool* (target-pos 0) (the-as region #f))
           )
          ((= v1-18 2)
           (talker-spawn-func (-> *talker-speech* 167) *entity-pool* (target-pos 0) (the-as region #f))
           )
          )
        )
      (set! *daxter-speech* (+ *daxter-speech* 1))
      (when (= *daxter-speech* 3)
        (set! *daxter-speech* 0)
        0
        )
      )
    )
  :exit (behavior ()
    '()
    )
  :trans (behavior ()
    (bombbot-bomb-method-33 self)
    (ja :num! (loop!))
    )
  :code sleep-code
  :post ja-post
  )

(defstate idle (bombbot-bomb)
  :virtual #t
  :event bombbot-bomb-handler
  :enter (behavior ()
    (set-time! (-> self state-time))
    )
  :exit (behavior ()
    '()
    )
  :trans (behavior ()
    (set! (-> self root transv y) (- (-> self root transv y) (* 184320.0 (seconds-per-frame))))
    (bombbot-bomb-method-32 self)
    (if (time-elapsed? (-> self state-time) (seconds 5))
        (go-virtual explode)
        )
    (if (< (vector-length (-> self root transv)) 2048.0)
        (go-virtual smoke)
        )
    (ja :num! (loop!))
    )
  :code sleep-code
  :post (behavior ()
    (transform-post)
    )
  )

(defmethod deactivate ((this bombbot-bomb))
  "Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
  (if (nonzero? (-> this explode-part))
      (kill-particles (-> this explode-part))
      )
  (if (nonzero? (-> this warning-glow-part))
      (kill-particles (-> this warning-glow-part))
      )
  ((method-of-type process-focusable deactivate) this)
  (none)
  )

;; WARN: Return type mismatch process-focusable vs bombbot-bomb.
(defmethod relocate ((this bombbot-bomb) (offset int))
  (if (nonzero? (-> this explode-part))
      (&+! (-> this explode-part) offset)
      )
  (if (nonzero? (-> this warning-glow-part))
      (&+! (-> this warning-glow-part) offset)
      )
  (the-as bombbot-bomb ((method-of-type process-focusable relocate) this offset))
  )

(defun bombbot-bomb-reaction ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector))
  (cshape-reaction-update-state arg0 arg1 arg3)
  (let ((f0-0 (rand-vu-float-range 1.2 1.4)))
    (vector--float*! arg2 arg3 (-> arg0 surface-normal) (* (vector-dot arg3 (-> arg0 surface-normal)) f0-0))
    )
  (-> arg0 status)
  )

(defbehavior bombbot-bomb-init-by-other bombbot-bomb ((arg0 vector) (arg1 vector))
  (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) bombbot-bomb-reaction)
    (set! (-> s4-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (let ((v1-6 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
      (set! (-> v1-6 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-6 prim-core collide-with)
            (collide-spec backgnd jak bot enemy vehicle-sphere hit-by-others-list player-list)
            )
      (set! (-> v1-6 prim-core action) (collide-action solid))
      (set! (-> v1-6 transform-index) 3)
      (set-vector! (-> v1-6 local-sphere) 0.0 0.0 0.0 2048.0)
      (set! (-> s4-0 total-prims) (the-as uint 1))
      (set! (-> s4-0 root-prim) v1-6)
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (let ((v1-9 (-> s4-0 root-prim)))
      (set! (-> s4-0 backup-collide-as) (-> v1-9 prim-core collide-as))
      (set! (-> s4-0 backup-collide-with) (-> v1-9 prim-core collide-with))
      )
    (set! (-> s4-0 max-iteration-count) (the-as uint 8))
    (set! (-> s4-0 event-self) 'touched)
    (set! (-> self root) s4-0)
    )
  (vector-copy! (-> self root trans) arg0)
  (initialize-skeleton
    self
    (the-as skeleton-group (art-group-get-by-name *level* "skel-bombbot-bomb" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (set-vector! (-> self root scale) 0.5 0.5 0.5 1.0)
  (quaternion-set! (-> self root quat) 0.0 0.0 0.0 1.0)
  (vector-copy! (-> self root transv) arg1)
  (set! (-> self draw light-index) (the-as uint 10))
  (set! (-> self root dynam gravity y) 184320.0)
  (set! (-> self root dynam gravity-length) 184320.0)
  (set! (-> self root dynam gravity-max) 184320.0)
  (let ((s5-2 (new 'stack-no-clear 'vector)))
    (vector-cross! s5-2 arg1 *z-vector*)
    (vector-normalize! s5-2 1.0)
    (vector-copy! (-> self rot-axis) s5-2)
    )
  (set! (-> self rot-angle) 65536.0)
  (set! (-> self explode-part) (create-launch-control (-> *part-group-id-table* 219) self))
  (set! (-> self warning-glow-part) (create-launch-control (-> *part-group-id-table* 525) self))
  (logclear! (-> self mask) (process-mask actor-pause))
  (go-virtual idle)
  )

(defskelgroup skel-bombbot bombbot bombbot-lod0-jg bombbot-idle-ja
              ((bombbot-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 12)
              :shadow bombbot-shadow-mg
              )

(deftype bombbot-foot (structure)
  ((pos-offset     vector  :inline)
   (joint-index    uint32)
   (offset         float)
   (position       vector  :inline)
   (next-position  vector  :inline)
   (real-position  vector  :inline)
   (speed          vector  :inline)
   (moving         symbol)
   (main-y         float)
   (delta-y        float)
   )
  )


(deftype bombbot (nav-enemy)
  ((joint-ik                joint-mod-ik  4)
   (feet                    bombbot-foot  4 :inline)
   (legs-strength           float         4)
   (last-trans              vector        :inline)
   (linear-speed            vector        :inline)
   (last-quat               quaternion    :inline)
   (y-angular-velocity      float)
   (main-quat               quaternion    :inline)
   (main-spd-y              float)
   (main-pos-y              float)
   (main-pos                vector        :inline)
   (city-path               bombbot-path)
   (current-node            uint32)
   (shot-count              uint32)
   (next-shoot              time-frame)
   (stop-shoot              time-frame)
   (next-target             time-frame)
   (start-target            time-frame)
   (beep-time               time-frame)
   (target-pos              vector        :inline)
   (start-target-pos        vector        :inline)
   (start-target-vel        vector        :inline)
   (target-delta            vector        :inline)
   (top-quat                quaternion    :inline)
   (gun-swivel-quat         quaternion    :inline)
   (gun-quat                quaternion    :inline)
   (angle-turret            float)
   (angle-gun               float)
   (extra-angle-gun         float)
   (drop-angle              float)
   (drop-num                uint32)
   (hit-axis                vector        :inline)
   (rigidbody               rigid-body-control)
   (info                    rigid-body-object-constants)
   (explosing               symbol)
   (minimap                 connection-minimap)
   (head-sound              sound-id)
   (cannon-sound            sound-id)
   (last-head-roty-speed    float)
   (head-roty-speed         float)
   (last-cannon-roty-speed  float)
   (cannon-roty-speed       float)
   (shoot-duration          float)
   (y-angle                 float)
   (gun-rotation-speed      float)
   (gun-type                uint32)
   (drop-mask               uint32)
   (attacker-info           city-attacker-info)
   (mission-squad           mission-squad-control)
   (max-hit-points          float)
   )
  (:state-methods
    explode
    blow-wall
    undefined
    drop-bombs
    )
  (:methods
    (bombbot-method-194 (_type_) none)
    (bombbot-method-195 (_type_) none)
    (bombbot-method-196 (_type_ vector) none)
    (bombbot-method-197 (_type_) none)
    (bombbot-method-198 (_type_) none)
    (bombbot-method-199 (_type_) none)
    (toggle-cspec-deadly (_type_ symbol int) none)
    (valid-target? (_type_ process-focusable) object)
    (bombbot-method-202 (_type_) none)
    (bombbot-method-203 (_type_) none)
    (bombbot-method-204 (_type_) none)
    (bombbot-method-205 (_type_) none)
    (fire-shot (_type_ vector vector) (pointer projectile))
    (bombbot-method-207 (_type_) symbol)
    (bombbot-method-208 (_type_ vector vector) vector)
    )
  )


(define *bombbot-nav-enemy-info*
  (new 'static 'nav-enemy-info
    :use-die-falling #f
    :use-victory #f
    :use-jump-blocked #f
    :debug-draw-neck #f
    :jump-debug-draw #f
    :move-to-ground #t
    :hover-if-no-ground #f
    :idle-anim-script (new 'static 'inline-array idle-control-frame 3
      (new 'static 'idle-control-frame :command (idle-control-cmd push) :param0 30)
      (new 'static 'idle-control-frame
        :command (idle-control-cmd play)
        :anim #x3
        :param0 100
        :param1 100
        :param2 '((new 'static 'bfloat :data 1.0) (new 'static 'bfloat :data 1.0))
        )
      (new 'static 'idle-control-frame)
      )
    :idle-anim 3
    :notice-anim 3
    :hostile-anim 3
    :hit-anim 3
    :knocked-anim 3
    :knocked-land-anim 3
    :die-anim 3
    :die-falling-anim 3
    :victory-anim -1
    :jump-wind-up-anim 3
    :jump-in-air-anim 3
    :jump-land-anim 3
    :neck-joint -1
    :look-at-joint 4
    :bullseye-joint 4
    :sound-hit (static-sound-name "bb-impact")
    :sound-die (static-sound-name "bombbot-die")
    :notice-distance (meters 20)
    :notice-distance-delta (meters 10)
    :proximity-notice-distance (meters 20)
    :default-hit-points 100.0
    :gnd-collide-with (collide-spec backgnd obstacle hit-by-others-list)
    :movement-gravity (meters -100)
    :friction 0.8
    :attack-shove-back (meters 3.5)
    :attack-shove-up (meters 2)
    :attack-mode 'generic
    :attack-damage 2
    :recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
    :knocked-can-land-timeout (seconds 0.1)
    :knocked-recover-timeout (seconds 2)
    :ragdoll-blend-out-time (seconds 0.25)
    :ragdoll-rotate-velocity-mult 1.0
    :jump-height-min (meters 3)
    :jump-height-factor 0.5
    :knocked-seek-ry-clamp 6371.5557
    :knocked-soft-vxz-lo (meters 17.6)
    :knocked-soft-vxz-hi (meters 26.4)
    :knocked-soft-vy-lo (meters 20)
    :knocked-soft-vy-hi (meters 30)
    :knocked-medium-vxz-lo (meters 36)
    :knocked-medium-vxz-hi (meters 48)
    :knocked-medium-vy-lo (meters 33)
    :knocked-medium-vy-hi (meters 37)
    :knocked-hard-vxz-lo (meters 19.2)
    :knocked-hard-vxz-hi (meters 28.8)
    :knocked-hard-vy-lo (meters 44.8)
    :knocked-hard-vy-hi (meters 51.2)
    :knocked-huge-vxz-lo (meters 40.2)
    :knocked-huge-vxz-hi (meters 60.8)
    :knocked-huge-vy-lo (meters 44.8)
    :knocked-huge-vy-hi (meters 53.2)
    :knocked-yellow-vxz-lo (meters 10)
    :knocked-yellow-vxz-hi (meters 12)
    :knocked-yellow-vy-lo (meters 14)
    :knocked-yellow-vy-hi (meters 20)
    :knocked-red-vxz-lo (meters 6)
    :knocked-red-vxz-hi (meters 48)
    :knocked-red-vy-lo (meters 23)
    :knocked-red-vy-hi (meters 37)
    :knocked-blue-vxz-lo (meters 10)
    :knocked-blue-vxz-hi (meters 12)
    :knocked-blue-vy-lo (meters 6)
    :knocked-blue-vy-hi (meters 20)
    :ragdoll-info #f
    :shadow-size (meters 1)
    :shadow-max-y (meters 1)
    :shadow-min-y (meters -1)
    :shadow-locus-dist (meters 150)
    :gem-joint -1
    :gem-offset (new 'static 'sphere :r 163840.0)
    :knocked-off #t
    :callback-info #f
    :use-momentum #t
    :use-frustration #t
    :use-stop-chase #f
    :use-circling #t
    :use-pacing #f
    :walk-anim 3
    :turn-anim -1
    :run-anim 3
    :taunt-anim -1
    :run-travel-speed (meters 8)
    :run-acceleration (meters 8)
    :run-turning-acceleration (meters 400)
    :walk-travel-speed (meters 4)
    :walk-acceleration (meters 16)
    :walk-turning-acceleration (meters 400)
    :maximum-rotation-rate (degrees 720)
    :notice-nav-radius (meters 2)
    :frustration-distance (meters 8)
    :frustration-time (seconds 4)
    :blocked-time (seconds 0.3)
    :circle-dist-lo 20480.0
    :circle-dist-hi 61440.0
    :nav-mesh #f
    )
  )

(set! (-> *bombbot-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

(set! (-> *bombbot-nav-enemy-info* nav-mesh) *default-nav-mesh*)

(define *bombbot-ik-limb-setup* (new 'static 'boxed-array :type ik-limb-setup
                                  (new 'static 'ik-limb-setup :elbow-index 19 :hand-dist 14880.768)
                                  (new 'static 'ik-limb-setup :elbow-index 13 :hand-dist -14880.768)
                                  (new 'static 'ik-limb-setup :elbow-index 15 :hand-dist 14880.768)
                                  (new 'static 'ik-limb-setup :elbow-index 17 :hand-dist -14880.768)
                                  )
        )

(defun bombbot-do-spline ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 vector) (arg5 float))
  (let* ((f1-1 (* arg5 arg5))
         (f0-2 (* arg5 f1-1))
         )
    (let ((f2-3 (- (+ 1.0 (* -3.0 arg5) (* 3.0 f1-1)) f0-2))
          (f3-7 (+ (* 3.0 f0-2) (* -6.0 f1-1) (* 3.0 arg5)))
          (f1-3 (+ (* -3.0 f0-2) (* 3.0 f1-1)))
          )
      (vector-float*! arg0 arg1 f2-3)
      (vector+*! arg0 arg0 (vector+! (new 'stack-no-clear 'vector) arg1 arg2) f3-7)
      (vector+*! arg0 arg0 (vector+! (new 'stack-no-clear 'vector) arg3 arg4) f1-3)
      )
    (vector+*! arg0 arg0 arg3 f0-2)
    )
  )

(defmethod toggle-cspec-deadly ((this bombbot) (arg0 symbol) (arg1 int))
  (let ((v1-1 (-> this root root-prim)))
    (dotimes (a0-1 (the-as int (-> v1-1 specific 0)))
      (let ((a3-1 (-> (the-as collide-shape-prim-group v1-1) child a0-1)))
        (when (= (-> a3-1 prim-id) arg1)
          (cond
            (arg0
              (logior! (-> a3-1 prim-core action) (collide-action deadly))
              (set! (-> a3-1 prim-core collide-as) (collide-spec enemy))
              (set! (-> a3-1 prim-core collide-with)
                    (collide-spec jak civilian enemy vehicle-sphere hit-by-others-list player-list)
                    )
              )
            (else
              (logclear! (-> a3-1 prim-core action) (collide-action deadly))
              (set! (-> a3-1 prim-core collide-as) (collide-spec enemy))
              (set! (-> a3-1 prim-core collide-with)
                    (collide-spec jak civilian enemy vehicle-sphere hit-by-others-list player-list)
                    )
              )
            )
          )
        )
      )
    )
  0
  (none)
  )

(defmethod bombbot-method-204 ((this bombbot))
  (let ((s1-0 (matrix-copy! (new 'stack-no-clear 'matrix) (-> this node-list data 6 bone transform))))
    (new 'stack-no-clear 'vector)
    (let ((s3-0 (new 'stack-no-clear 'collide-query))
          (s5-0 (new 'stack-no-clear 'vector))
          (gp-0 (new 'stack-no-clear 'vector))
          )
      (let ((s4-0 (new 'stack-no-clear 'vector))
            (f30-0 (lerp-scale 1.0 0.0 (* 0.0033333334 (the float (- (-> this next-target) (current-time)))) 2.5 3.5))
            )
        (if (= (-> this focus handle) #f)
            (set! f30-0 0.0)
            )
        (matrix->trans s1-0 gp-0)
        (vector+*! gp-0 gp-0 (-> s1-0 fvec) 8192.0)
        (vector-normalize-copy! s5-0 (-> s1-0 fvec) 819200.0)
        (vector-copy! (-> s3-0 start-pos) gp-0)
        (vector-copy! (-> s3-0 move-dist) s5-0)
        (let ((v1-13 s3-0))
          (set! (-> v1-13 radius) 40.96)
          (set! (-> v1-13 collide-with) (collide-spec backgnd enemy hit-by-others-list))
          (set! (-> v1-13 ignore-process0) this)
          (set! (-> v1-13 ignore-process1) #f)
          (set! (-> v1-13 ignore-pat)
                (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
                )
          (set! (-> v1-13 action-mask) (collide-action solid))
          )
        (let ((f0-4 (fill-and-probe-using-line-sphere *collide-cache* s3-0)))
          (when (>= f0-4 0.0)
            (vector+float*! s4-0 (-> s3-0 start-pos) (-> s3-0 move-dist) f0-4)
            (vector-float*! s5-0 s5-0 f0-4)
            (let ((s2-1 (as-type (-> s3-0 best-other-tri collide-ptr) collide-shape-prim))
                  (v1-22 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> s3-0 start-pos) s4-0) 1638.4))
                  (s3-1 (new 'stack-no-clear 'vector))
                  )
              (vector-copy! s3-1 s4-0)
              (vector+! s3-1 s3-1 v1-22)
              (cond
                (s2-1
                  (launch-particles (-> *part-id-table* 2061) s3-1)
                  (launch-particles (-> *part-id-table* 2060) s3-1)
                  )
                (else
                  (launch-particles (-> *part-id-table* 2062) s3-1)
                  )
                )
              )
            )
          )
        (set! (-> *part-id-table* 2059 init-specs 5 initial-valuef) (* 255.0 f30-0))
        (set! (-> *part-id-table* 2059 init-specs 7 initial-valuef) (* 255.0 (- 1.0 f30-0)))
        )
      (draw-beam (-> *part-id-table* 2059) gp-0 s5-0 #t)
      )
    )
  0
  (none)
  )

(defmethod valid-target? ((this bombbot) (arg0 process-focusable))
  (and arg0
       (!= this arg0)
       (not (focus-test? arg0 inactive))
       (not (focus-test? arg0 disable))
       (not (focus-test? arg0 dead))
       (not (logtest? (process-mask crate) (-> arg0 mask)))
       arg0
       (not (logtest? (-> arg0 focus-status) (focus-status disable dead ignore grabbed)))
       )
  )

(defmethod bombbot-method-207 ((this bombbot))
  #t
  )

(defmethod bombbot-method-202 ((this bombbot))
  (set! (-> this last-head-roty-speed) (-> this head-roty-speed))
  (set! (-> this head-roty-speed) (vector-y-angle (-> this node-list data 4 bone transform fvec)))
  (set! (-> this last-cannon-roty-speed) (-> this cannon-roty-speed))
  (set! (-> this cannon-roty-speed) (vector-y-angle (-> this node-list data 6 bone transform fvec)))
  (let ((f0-6 (deg- (-> this last-head-roty-speed) (-> this head-roty-speed))))
    (cond
      ((< 364.0889 (fabs f0-6))
       (when (zero? (-> this head-sound))
         (let ((s5-0 sound-play-by-spec)
               (s4-0 (static-sound-spec "bb-turret-loop" :group 0 :volume 0.0 :mask (pitch)))
               )
           (set! (-> s4-0 volume) 1024)
           (set! (-> s4-0 pitch-mod) 0)
           (set! (-> this head-sound) (s5-0 s4-0 (new-sound-id) (-> this root trans)))
           )
         )
       )
      (else
        (when (nonzero? (-> this head-sound))
          (sound-play "bb-turret-end")
          (sound-stop (-> this head-sound))
          (set! (-> this head-sound) (new 'static 'sound-id))
          0
          )
        )
      )
    )
  (let ((f0-10 (deg- (-> this last-cannon-roty-speed) (-> this cannon-roty-speed))))
    (cond
      ((< 364.0889 (fabs f0-10))
       (when (zero? (-> this cannon-sound))
         (let ((s5-2 sound-play-by-spec)
               (s4-2 (static-sound-spec "bb-laser-loop" :group 0 :volume 0.0 :mask (pitch)))
               )
           (set! (-> s4-2 volume) 1024)
           (set! (-> s4-2 pitch-mod) 0)
           (set! (-> this cannon-sound) (s5-2 s4-2 (new-sound-id) (-> this root trans)))
           )
         )
       )
      (else
        (when (nonzero? (-> this cannon-sound))
          (sound-stop (-> this cannon-sound))
          (sound-play "bb-laser-end")
          (set! (-> this cannon-sound) (new 'static 'sound-id))
          0
          )
        )
      )
    )
  (none)
  )

(defmethod bombbot-method-195 ((this bombbot))
  (let ((a1-0 (new 'stack-no-clear 'traffic-danger-info)))
    (set! (-> a1-0 sphere quad) (-> this root trans quad))
    (set! (-> a1-0 sphere r) 40960.0)
    (vector-copy! (-> a1-0 velocity) (-> this root transv))
    (vector-reset! (-> a1-0 velocity))
    (set! (-> a1-0 notify-radius) 122880.0)
    (set! (-> a1-0 danger-level) 1.0)
    (set! (-> a1-0 decay-rate) 0.0)
    (set! (-> a1-0 flags) (the-as uint 1))
    (set! (-> a1-0 danger-type) (the-as uint 0))
    (add-danger *traffic-engine* a1-0)
    )
  (none)
  )

;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 896 mismatch: defined as size 4, got size 16
;; ERROR: Stack slot load at 912 mismatch: defined as size 4, got size 16
(defmethod bombbot-method-194 ((this bombbot))
  (local-vars
    (at-0 int)
    (sv-864 vector)
    (sv-880 vector)
    (sv-896 float)
    (sv-912 float)
    (sv-928 (function vector vector float))
    (sv-944 uint)
    (sv-960 uint)
    )
  (with-pp
    (rlet ((acc :class vf)
           (vf0 :class vf)
           (vf1 :class vf)
           (vf2 :class vf)
           (vf3 :class vf)
           )
      (init-vf0-vector)
      (let ((s5-0 (new 'stack-no-clear 'collide-query)))
        (let ((v1-0 (-> s5-0 bbox))
              (a0-2 (-> this root trans))
              (a1-0 (new 'stack-no-clear 'vector))
              )
          (set! (-> a1-0 x) 24576.0)
          (set! (-> a1-0 y) 22528.0)
          (set! (-> a1-0 z) 24576.0)
          (set! (-> a1-0 w) 1.0)
          (vector-! (-> v1-0 min) a0-2 a1-0)
          )
        (let ((v1-2 (-> s5-0 bbox max))
              (a0-4 (-> this root trans))
              (a1-1 (new 'stack-no-clear 'vector))
              )
          (set! (-> a1-1 x) 24576.0)
          (set! (-> a1-1 y) 22528.0)
          (set! (-> a1-1 z) 24576.0)
          (set! (-> a1-1 w) 1.0)
          (vector+! v1-2 a0-4 a1-1)
          )
        (set! (-> s5-0 collide-with) (collide-spec backgnd))
        (set! (-> s5-0 ignore-process0) #f)
        (set! (-> s5-0 ignore-process1) #f)
        (set! (-> s5-0 ignore-pat)
              (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
              )
        (fill-using-bounding-box *collide-cache* s5-0)
        (dotimes (s4-0 4)
          (-> this joint-ik s4-0 shoulder-matrix-no-ik)
          (-> this joint-ik s4-0 elbow-matrix-no-ik)
          (new 'stack-no-clear 'vector)
          (let ((s2-0 (new 'stack-no-clear 'vector)))
            (vector-copy! s2-0 (-> this node-list data 3 bone transform uvec))
            (new 'stack-no-clear 'vector)
            (let ((s3-0 (new 'stack-no-clear 'vector)))
              (let ((f30-0 0.4))
                (vector-normalize! s2-0 1.0)
                (let ((s1-0 (-> this feet s4-0)))
                  (let* ((f0-10 (+ (* 0.004166667 (the float (mod (current-time) 240))) (-> s1-0 offset)))
                         (f28-0 (- f0-10 (* (the float (the int (/ f0-10 1.0))) 1.0)))
                         (s0-0 (new 'stack-no-clear 'vector))
                         )
                    (cond
                      ((>= f30-0 f28-0)
                       (toggle-cspec-deadly this #t (+ s4-0 1))
                       (vector-orient-by-quat! s3-0 (-> s1-0 pos-offset) (-> this root quat))
                       (let ((f26-0 (- f30-0 f28-0)))
                         (set! sv-880 s0-0)
                         (set! sv-864 (new 'stack-no-clear 'vector))
                         (set! (-> sv-864 x) 0.0)
                         (set! (-> sv-864 y) (sin (* (-> this y-angular-velocity) (-> pp clock frames-per-second))))
                         (set! (-> sv-864 z) 0.0)
                         (set! (-> sv-864 w) 1.0)
                         (let ((v1-40 s3-0))
                           (.lvf vf1 (&-> sv-864 quad))
                           (.lvf vf2 (&-> v1-40 quad))
                           )
                         (.outer.product.a.vf acc vf1 vf2)
                         (.outer.product.b.vf vf3 vf2 vf1 acc)
                         (.svf (&-> sv-880 quad) vf3)
                         (let ((a1-6 s0-0)
                               (v1-42 s0-0)
                               (a0-12 (new 'stack-no-clear 'vector))
                               )
                           (.lvf vf1 (&-> (-> this linear-speed) quad))
                           (let ((f0-17 (-> pp clock frames-per-second)))
                             (.mov at-0 f0-17)
                             )
                           (.mov vf2 at-0)
                           (.mov.vf.w vf1 vf0)
                           (.mul.x.vf.xyz vf1 vf1 vf2)
                           (.svf (&-> a0-12 quad) vf1)
                           (vector+! a1-6 v1-42 a0-12)
                           )
                         (vector+*!
                           (-> s1-0 speed)
                           (-> s1-0 speed)
                           (vector-! (new 'stack-no-clear 'vector) s0-0 (-> s1-0 speed))
                           (* 4.0 (seconds-per-frame))
                           )
                         (vector+*! s3-0 s3-0 (-> s1-0 speed) (+ 0.2 f26-0))
                         )
                       (vector+! s3-0 s3-0 (-> this root trans))
                       (vector+*! (-> s5-0 start-pos) s3-0 s2-0 24576.0)
                       (vector-float*! (-> s5-0 move-dist) s2-0 -49152.0)
                       (let ((v1-49 s5-0))
                         (set! (-> v1-49 radius) 40.96)
                         (set! (-> v1-49 collide-with) (collide-spec backgnd))
                         (set! (-> v1-49 ignore-process0) #f)
                         (set! (-> v1-49 ignore-process1) #f)
                         (set! (-> v1-49 ignore-pat)
                               (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
                               )
                         (set! (-> v1-49 action-mask) (collide-action solid))
                         )
                       (let ((f0-25 (probe-using-line-sphere *collide-cache* s5-0)))
                         (when (>= f0-25 0.0)
                           (let ((v1-52 (vector+*! (new 'stack-no-clear 'vector) (-> s5-0 start-pos) (-> s5-0 move-dist) f0-25)))
                             (- (-> s3-0 y) (-> v1-52 y))
                             (vector-copy! s3-0 v1-52)
                             )
                           )
                         )
                       (vector-copy! (-> s1-0 next-position) s3-0)
                       (set! (-> s1-0 moving) #t)
                       (vector+*!
                         s3-0
                         (-> s1-0 position)
                         (vector-! (new 'stack-no-clear 'vector) (-> s1-0 next-position) (-> s1-0 position))
                         (/ f28-0 f30-0)
                         )
                       (let ((t9-6 bombbot-do-spline)
                             (a0-32 (new 'stack-no-clear 'vector))
                             (a1-21 (new 'stack-no-clear 'vector))
                             )
                         (set! (-> a1-21 x) 0.0)
                         (set! (-> a1-21 y) 0.0)
                         (set! (-> a1-21 z) 0.0)
                         (set! (-> a1-21 w) 1.0)
                         (let ((a2-18 (new 'stack-no-clear 'vector)))
                           (set! (-> a2-18 x) 0.0)
                           (set! (-> a2-18 y) 0.0)
                           (set! (-> a2-18 z) 0.5)
                           (set! (-> a2-18 w) 1.0)
                           (let ((a3-1 (new 'stack-no-clear 'vector)))
                             (set! (-> a3-1 x) 0.0)
                             (set! (-> a3-1 y) 0.0)
                             (set! (-> a3-1 z) 1.0)
                             (set! (-> a3-1 w) 1.0)
                             (let ((t0-0 (new 'stack-no-clear 'vector)))
                               (set! (-> t0-0 x) 0.0)
                               (set! (-> t0-0 y) 4.0)
                               (set! (-> t0-0 z) 0.0)
                               (set! (-> t0-0 w) 1.0)
                               (let ((v0-6 (t9-6 a0-32 a1-21 a2-18 a3-1 t0-0 (/ f28-0 f30-0))))
                                 (set! (-> s1-0 delta-y) (* (/ (-> v0-6 y) 20) (vector-length (-> s1-0 speed))))
                                 )
                               )
                             )
                           )
                         )
                       (+! (-> s3-0 y) (-> s1-0 delta-y))
                       )
                      (else
                        (toggle-cspec-deadly this #f (+ s4-0 1))
                        (when (-> s1-0 moving)
                          (vector-copy! (-> s1-0 position) (-> s1-0 next-position))
                          (set! (-> s1-0 moving) #f)
                          (let ((s0-1 lerp-scale))
                            (set! sv-896 (the-as float 819.2))
                            (set! sv-912 (the-as float 0.0))
                            (set! sv-928 vector-vector-distance)
                            (let* ((a0-36 (camera-pos))
                                   (a1-23 (-> s1-0 position))
                                   (a2-20 (sv-928 a0-36 a1-23))
                                   (a3-2 40960.0)
                                   (t0-1 409600.0)
                                   (f30-1 (s0-1 sv-896 sv-912 a2-20 a3-2 t0-1))
                                   )
                              (when (and (!= f30-1 0.0) (< 16384.0 (vector-length (-> s1-0 speed))))
                                (if (bombbot-method-207 this)
                                    (activate! *camera-smush-control* f30-1 37 600 1.0 0.1 (-> pp clock))
                                    )
                                (cond
                                  ((logtest? (-> *part-group-id-table* 23 flags) (sp-group-flag sp13))
                                   (vector-copy! (-> *launch-matrix* trans) (-> s1-0 position))
                                   (part-tracker-spawn part-tracker-subsampler :to this :group (-> *part-group-id-table* 23))
                                   )
                                  (else
                                    (vector-copy! (-> *launch-matrix* trans) (-> s1-0 position))
                                    (part-tracker-spawn part-tracker :to this :group (-> *part-group-id-table* 23))
                                    )
                                  )
                                (when (or (zero? s4-0) (= s4-0 1))
                                  (cond
                                    ((and *target* (focus-test? *target* grabbed))
                                     (let ((s0-4 sound-play-by-name))
                                       (set! sv-944 (make-u128 #x6d6163 (the-as uint #x2d6b6c61772d6262)))
                                       (let ((a1-32 (new-sound-id))
                                             (a2-32 1024)
                                             (a3-8 0)
                                             (t0-3 0)
                                             (t1-2 0)
                                             (t2-1 (-> s1-0 position))
                                             )
                                         (s0-4 (the-as sound-name sv-944) a1-32 a2-32 a3-8 t0-3 (the-as sound-group t1-2) t2-1)
                                         )
                                       )
                                     )
                                    (else
                                      (let ((s0-5 sound-play-by-name))
                                        (set! sv-960 (make-u128 0 (the-as uint #x6b6c61772d6262)))
                                        (let ((a1-33 (new-sound-id))
                                              (a2-33 1024)
                                              (a3-9 0)
                                              (t0-4 0)
                                              (t1-3 0)
                                              (t2-2 (-> s1-0 position))
                                              )
                                          (s0-5 (the-as sound-name sv-960) a1-33 a2-33 a3-9 t0-4 (the-as sound-group t1-3) t2-2)
                                          )
                                        )
                                      )
                                    )
                                  (if (bombbot-method-207 this)
                                      (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 (the int (* 255.0 (* 0.00061035156 f30-1))) (seconds 0.2))
                                      )
                                  )
                                )
                              )
                            )
                          )
                        (set! (-> s1-0 delta-y) 0.0)
                        (vector-copy! s3-0 (-> s1-0 position))
                        )
                      )
                    )
                  (vector+*! (-> s5-0 start-pos) s3-0 s2-0 12288.0)
                  (vector-float*! (-> s5-0 move-dist) s2-0 -24576.0)
                  (let ((v1-137 s5-0))
                    (set! (-> v1-137 radius) 40.96)
                    (set! (-> v1-137 collide-with) (collide-spec backgnd))
                    (set! (-> v1-137 ignore-process0) #f)
                    (set! (-> v1-137 ignore-process1) #f)
                    (set! (-> v1-137 ignore-pat)
                          (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
                          )
                    (set! (-> v1-137 action-mask) (collide-action solid))
                    )
                  (let ((f0-63 (probe-using-line-sphere *collide-cache* s5-0)))
                    (when (>= f0-63 0.0)
                      (let ((s0-7 (vector+*! (new 'stack-no-clear 'vector) (-> s5-0 start-pos) (-> s5-0 move-dist) f0-63)))
                        (let ((f0-65 (- (-> s3-0 y) (-> s0-7 y))))
                          (lerp-scale 1.0 0.0 f0-65 0.0 8192.0)
                          )
                        (- (-> s0-7 y) (-> this root trans y))
                        (vector-dot s2-0 (vector-! (new 'stack-no-clear 'vector) s0-7 (-> this root trans)))
                        )
                      )
                    )
                  (vector-copy! (-> s1-0 real-position) s3-0)
                  )
                )
              (set-ik-target! (-> this joint-ik s4-0) s3-0)
              )
            )
          )
        )
      0
      (none)
      )
    )
  )

(defmethod enemy-common-post ((this bombbot))
  "Common implementation of post. Runs ja-post."
  (local-vars (sv-48 sparticle-launcher) (sv-52 sparticle-launcher))
  (let ((t9-0 (method-of-type nav-enemy enemy-common-post)))
    (t9-0 this)
    )
  (let ((a1-0 (new 'stack-no-clear 'overlaps-others-params)))
    (set! (-> a1-0 options) (overlaps-others-options))
    (set! (-> a1-0 collide-with-filter)
          (collide-spec jak civilian enemy vehicle-sphere hit-by-others-list player-list)
          )
    (set! (-> a1-0 tlist) *touching-list*)
    (find-overlapping-shapes (-> this root) a1-0)
    )
  (cond
    ((= (-> this nav state mesh) *default-nav-mesh*)
     (dotimes (s5-0 4)
       (enable-set! (-> this joint-ik s5-0) #f)
       )
     )
    (else
      (bombbot-method-194 this)
      (dotimes (s5-1 4)
        (enable-set! (-> this joint-ik s5-1) #t)
        )
      )
    )
  (vector-! (-> this linear-speed) (-> this root trans) (-> this last-trans))
  (vector-copy! (-> this last-trans) (-> this root trans))
  (set! (-> this y-angular-velocity)
        (deg- (quaternion-y-angle (-> this root quat)) (quaternion-y-angle (-> this last-quat)))
        )
  (quaternion-copy! (-> this last-quat) (-> this root quat))
  (set! (-> this rigidbody force-callback)
        (the-as (function rigid-body-object float none) (method-of-object this bombbot-method-198))
        )
  (bombbot-method-199 this)
  (set! sv-48 (the-as sparticle-launcher #f))
  (set! sv-52 (the-as sparticle-launcher #f))
  (cond
    ((< (-> this hit-points) (* 0.33 (-> this max-hit-points)))
     (set! sv-48 (-> *part-id-table* 925))
     (set! sv-52 (-> *part-id-table* 921))
     )
    ((< (-> this hit-points) (* 0.66 (-> this max-hit-points)))
     (set! sv-48 (-> *part-id-table* 928))
     )
    (else
      (if (< (rand-vu) 0.05)
          (set! sv-48 (-> *part-id-table* 930))
          )
      )
    )
  (when sv-48
    (let ((gp-1 (-> this node-list data 4 bone transform))
          (s5-3 (new 'stack-no-clear 'vector))
          )
      (dotimes (s4-1 2)
        (vector-matrix*!
          s5-3
          (vector-rotate-around-y! (new 'stack-no-clear 'vector) (new 'static 'vector :z 6144.0 :w 1.0) (if (< s4-1 1)
                                                                                                            5461.3335
                                                                                                            38229.332
                                                                                                            )
                                   )
          gp-1
          )
        (vector-! *particle-vel* s5-3 (matrix->trans gp-1 (new 'stack-no-clear 'vector)))
        (+! (-> *particle-vel* y) 4096.0)
        (vector-float*! *particle-vel* *particle-vel* 0.0033333334)
        (when (and sv-52 (< (rand-vu) 0.005))
          (let ((t9-15 sp-launch-particles-var)
                (a0-23 *sp-particle-system-2d*)
                (a1-10 sv-48)
                (a2-2 *launch-matrix*)
                )
            (vector-copy! (-> a2-2 trans) s5-3)
            (t9-15 a0-23 a1-10 a2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
            )
          )
        (let ((t9-16 sp-launch-particles-var)
              (a0-24 *sp-particle-system-2d*)
              (a1-11 sv-48)
              (a2-3 *launch-matrix*)
              )
          (vector-copy! (-> a2-3 trans) s5-3)
          (t9-16 a0-24 a1-11 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
          )
        )
      )
    )
  0
  (none)
  )

(defmethod run-logic? ((this bombbot))
  "Should this process be run? Checked by execute-process-tree."
  #t
  )

(defmethod get-trans ((this bombbot) (arg0 int))
  "Get the `trans` for this process."
  (if (= arg0 4)
      (vector+*! (new 'static 'vector) (-> this root trans) *y-vector* 12288.0)
      ((method-of-type nav-enemy get-trans) this arg0)
      )
  )

(defmethod msg-for-incoming-attack ((this bombbot) (arg0 process) (arg1 event-message-block) (arg2 float))
  "Given an attack message, what do we do next? Returns a message name that should be sent to self."
  ((method-of-type nav-enemy msg-for-incoming-attack) this arg0 arg1 arg2)
  'hit-flinch
  )

(defmethod get-damage-from-attack ((this bombbot) (arg0 object) (arg1 event-message-block))
  "Compute hit point damage for an attack message."
  (-> arg1 param 1)
  (let* ((t9-0 (method-of-type nav-enemy get-damage-from-attack))
         (f30-0 (t9-0 this arg0 arg1))
         )
    (cond
      ((as-type arg0 bombbot-bomb)
       (set! *bombbot-hint* (new 'static 'sound-id))
       (if (rand-vu-percent? 0.1)
           (talker-spawn-func (-> *talker-speech* 169) *entity-pool* (target-pos 0) (the-as region #f))
           )
       (* 15.0 f30-0)
       )
      ((logtest? (penetrate dark-punch) (-> this incoming penetrate-using))
       (* 2.0 f30-0)
       )
      (else
        f30-0
        )
      )
    )
  )

(defmethod event-handler ((this bombbot) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  "Commmon handler for events."
  (case arg2
    (('nav-mesh-kill)
     (change-to *default-nav-mesh* this)
     #t
     )
    (('hit-flinch)
     (cond
       ((= (-> this hit-points) 0.0)
        (if (not (and (-> this next-state) (= (-> this next-state name) 'die)))
            (go-die this)
            )
        )
       (else
         (let ((a1-2 (-> arg3 param 1)))
           (when arg0
             (let ((v1-8 (find-offending-process-focusable arg0 (the-as attack-info a1-2))))
               (when v1-8
                 (let ((s5-1 (new 'stack-no-clear 'vector)))
                   (let ((s4-1 (new 'stack-no-clear 'vector)))
                     (vector-copy! s4-1 (-> v1-8 root trans))
                     (let ((s3-1 (matrix->trans (-> this node-list data 3 bone transform) (new 'stack-no-clear 'vector))))
                       (+! (-> s4-1 x) (* 4096.0 (rand-vu-float-range -20.0 20.0)))
                       (+! (-> s4-1 y) (* 4096.0 (rand-vu-float-range -20.0 20.0)))
                       (+! (-> s4-1 z) (* 4096.0 (rand-vu-float-range -20.0 20.0)))
                       (vector-! s5-1 s3-1 s4-1)
                       )
                     )
                   (vector-normalize! s5-1 4096000.0)
                   (vector-inv-orient-by-quat! s5-1 s5-1 (-> this root quat))
                   (apply-impact!
                     (-> this rigidbody)
                     (rigid-body-control-method-25 (-> this rigidbody) (new 'stack-no-clear 'vector))
                     s5-1
                     )
                   )
                 )
               )
             )
           )
         (play-damage-sound this 0)
         'back
         )
       )
     )
    (('explode)
     (if (not (and (-> this next-state) (= (-> this next-state name) 'explode)))
         (go (method-of-object this explode))
         )
     )
    (('blow-wall)
     (go (method-of-object this blow-wall))
     )
    (('touched 'touch 'attack)
     (if (logtest? (process-mask vehicle) (-> arg0 mask))
         (send-event
           arg0
           'attack
           (-> arg3 param 0)
           (static-attack-info
             :mask (vehicle-impulse-factor)
             ((id (new-attack-id)) (damage 2.0) (vehicle-damage-factor 1.0) (vehicle-impulse-factor 1.0) (mode 'mine))
             )
           )
         )
     ((method-of-type nav-enemy event-handler) this arg0 arg1 arg2 arg3)
     )
    (else
      ((method-of-type nav-enemy event-handler) this arg0 arg1 arg2 arg3)
      )
    )
  )

(defstate notice (bombbot)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy notice) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (go-state-for-focused self)
    )
  )

(defmethod bombbot-method-196 ((this bombbot) (arg0 vector))
  (let ((gp-0 (the-as process-drawable #f)))
    (let ((f30-0 (the-as float #x7f800000))
          (s3-0 (new 'stack-no-clear 'array 'collide-shape 64))
          )
      (countdown (s2-0 (fill-actor-list-for-box *actor-hash* arg0 s3-0 64))
        (let ((a0-3 (as-type (-> s3-0 s2-0) collide-shape)))
          (when a0-3
            (let ((s1-1 (as-type (-> a0-3 process) process-focusable)))
              (when (and s1-1
                         (!= this s1-1)
                         (not (focus-test? this inactive))
                         (not (focus-test? this disable))
                         (not (focus-test? this dead))
                         (not (logtest? (process-mask guard) (-> s1-1 mask)))
                         (not (logtest? (process-mask crate) (-> s1-1 mask)))
                         (logtest? (process-mask guard vehicle) (-> s1-1 mask))
                         s1-1
                         (not (logtest? (-> (the-as process-focusable s1-1) focus-status) (focus-status disable dead ignore grabbed)))
                         )
                (let ((f0-0 (vector-vector-xz-distance (-> this root trans) (-> (the-as process-focusable s1-1) root trans))))
                  (when (or (not gp-0) (< f0-0 f30-0))
                    (set! gp-0 s1-1)
                    (set! f30-0 f0-0)
                    )
                  )
                )
              )
            )
          )
        )
      )
    (if (and *target* (< (vector-vector-distance (target-pos 0) arg0) (-> arg0 w)))
        (set! gp-0 *target*)
        )
    (cond
      (gp-0
        (vector-copy! (-> this target-pos) (get-trans (the-as process-focusable gp-0) 3))
        (vector+*! (-> this target-pos) (-> gp-0 root trans) (-> gp-0 root transv) 0.0)
        (vector-copy! (-> this start-target-pos) (-> gp-0 root trans))
        (vector-copy! (-> this start-target-vel) (-> gp-0 root transv))
        (focus-on! (-> this focus) (the-as process-focusable gp-0) this)
        )
      (else
        (clear-focused (-> this focus))
        )
      )
    )
  0
  (none)
  )

(defmethod bombbot-method-208 ((this bombbot) (arg0 vector) (arg1 vector))
  (vector-copy! arg1 (-> this target-pos))
  arg1
  )

(defmethod bombbot-method-203 ((this bombbot))
  (let ((s4-0 (matrix-copy! (new 'stack-no-clear 'matrix) (-> this node-list data 6 bone transform))))
    (new 'stack-no-clear 'vector)
    (let ((s2-0 (new 'stack-no-clear 'vector))
          (s3-0 (new 'stack-no-clear 'vector))
          )
      (new 'stack-no-clear 'vector)
      (let ((s5-0 (new 'stack-no-clear 'traj3d-params)))
        (matrix->trans s4-0 s3-0)
        (vector+*! s3-0 s3-0 (-> s4-0 fvec) 8192.0)
        (vector-normalize-copy! s2-0 (-> s4-0 fvec) 819200.0)
        (vector-copy! (-> s5-0 dest) (bombbot-method-208 this s3-0 (new 'stack-no-clear 'vector)))
        (vector-copy! (-> s5-0 src) s3-0)
        (set! (-> s5-0 initial-tilt) (+ 3640.889 (-> this angle-gun)))
        (set! (-> s5-0 gravity) 184320.0)
        (when (traj3d-calc-initial-velocity-using-tilt s5-0)
          (new 'stack-no-clear 'vector)
          (sound-play "bb-fire-grenade")
          (process-spawn bombbot-bomb (-> s5-0 src) (-> s5-0 initial-velocity) :name "bombbot-bomb" :to this)
          (let ((s4-4 (new 'stack-no-clear 'vector)))
            (vector-copy! s4-4 (-> s5-0 initial-velocity))
            (vector-normalize! s4-4 -2048000.0)
            (vector-inv-orient-by-quat! s4-4 s4-4 (-> this root quat))
            (apply-impact!
              (-> this rigidbody)
              (rigid-body-control-method-25 (-> this rigidbody) (new 'stack-no-clear 'vector))
              s4-4
              )
            )
          )
        )
      )
    )
  0
  (none)
  )

(deftype bombbot-shot (guard-shot)
  ()
  )


(defmethod projectile-method-24 ((this bombbot-shot))
  0
  (none)
  )

(set! (-> *lightning-spec-id-table* 24) (new 'static 'lightning-spec
                                          :name "bombbot-lightning-shock"
                                          :flags (lightning-spec-flags lsf0)
                                          :start-color (new 'static 'rgba :r #x80 :b #x40 :a #x80)
                                          :end-color (new 'static 'rgba :r #x80 :b #x40 :a #x80)
                                          :fade-to-color (new 'static 'rgba :r #xbf :b #x8f :a #x5)
                                          :fade-start-factor 0.2
                                          :texture (new 'static 'texture-id :index #x3f :page #x4)
                                          :reduction 0.42
                                          :num-points 16
                                          :box-size 16384.0
                                          :merge-factor 0.5
                                          :merge-count 2
                                          :radius 2048.0
                                          :duration 30.0
                                          :sound (static-sound-spec "shock" :group 0)
                                          )
      )

(defmethod projectile-method-25 ((this bombbot-shot))
  (let* ((v1-1 (-> this root trans))
         (a1-0 (-> this tail-pos))
         (a2-1 (vector-! (new 'stack-no-clear 'vector) v1-1 a1-0))
         )
    (vector-length a2-1)
    (vector+*! (new 'stack-no-clear 'vector) a1-0 a2-1 0.8)
    (let ((f30-0 (-> *part-id-table* 2056 init-specs 4 initial-valuef)))
      (set! (-> *part-id-table* 2056 init-specs 4 initial-valuef) (* 2.0 (vector-length a2-1)))
      (draw-beam (-> *part-id-table* 2056) a1-0 a2-1 #f)
      (set! (-> *part-id-table* 2056 init-specs 4 initial-valuef) f30-0)
      )
    )
  0
  (none)
  )

(defmethod projectile-method-26 ((this bombbot-shot))
  (dotimes (s5-0 5)
    (process-drawable-shock-effect
      this
      (-> *lightning-spec-id-table* 1)
      lightning-probe-callback
      (-> *part-id-table* 160)
      256
      0
      40960.0
      )
    )
  0
  (none)
  )

(defstate impact (bombbot-shot)
  :virtual #t
  :code (behavior ()
    (while (-> self child)
      (suspend)
      )
    (go-virtual die)
    )
  )

(defmethod play-impact-sound ((this bombbot-shot) (arg0 projectile-options))
  (let ((v1-0 arg0))
    (cond
      ((zero? v1-0)
       (sound-play "bb-fire")
       )
      ((= v1-0 (projectile-options po0))
       (sound-play "bb-shot-hit")
       )
      )
    )
  0
  (none)
  )

(defmethod init-proj-settings! ((this bombbot-shot))
  (set! (-> this hit-actor?) #f)
  (vector-copy! (-> this tail-pos) (-> this root trans))
  (set! (-> this attack-mode) 'guard-shot)
  (set! (-> this max-speed) 819200.0)
  (set! (-> this move) guard-shot-move)
  (set! (-> this update-velocity) projectile-update-velocity-space-wars)
  (set! (-> this timeout) (seconds 0.5))
  (logior! (-> this options) (projectile-options po13))
  (set-gravity-length (-> this root dynam) 573440.0)
  (none)
  )

;; WARN: Return type mismatch (pointer process) vs (pointer bombbot-shot).
(defun spawn-bombbot-projectile ((arg0 bombbot) (arg1 vector) (arg2 vector) (arg3 float) (arg4 vector) (arg5 float))
  (let ((gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)))
    (let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg2 arg1)))
      (set! (-> gp-0 ent) (-> arg0 entity))
      (set! (-> gp-0 charge) 1.0)
      (set! (-> gp-0 options) (projectile-options))
      (logclear! (-> gp-0 options) (projectile-options po14 po15 po16))
      (set! (-> gp-0 notify-handle) (process->handle arg0))
      (set! (-> gp-0 owner-handle) (the-as handle #f))
      (set! (-> gp-0 target-handle) (the-as handle #f))
      (set! (-> gp-0 target-pos quad) (the-as uint128 0))
      (set! (-> gp-0 ignore-handle) (process->handle arg0))
      (let* ((a0-13 *game-info*)
             (a2-12 (+ (-> a0-13 attack-id) 1))
             )
        (set! (-> a0-13 attack-id) a2-12)
        (set! (-> gp-0 attack-id) a2-12)
        )
      (set! (-> gp-0 timeout) (seconds 4))
      (set! (-> gp-0 damage) arg5)
      (logior! (-> gp-0 options) (projectile-options po14))
      (if arg4
          (vector-copy! (-> gp-0 pos) arg4)
          (vector-copy! (-> gp-0 pos) arg1)
          )
      (vector-normalize-copy! (-> gp-0 vel) v1-1 1.0)
      )
    (the-as (pointer bombbot-shot) (spawn-projectile bombbot-shot gp-0 arg0 *default-dead-pool*))
    )
  )

;; WARN: Return type mismatch (pointer bombbot-shot) vs (pointer projectile).
(defmethod fire-shot ((this bombbot) (arg0 vector) (arg1 vector))
  (the-as (pointer projectile) (spawn-bombbot-projectile this arg0 arg1 819200.0 (the-as vector #f) 2.0))
  )

(defmethod bombbot-method-197 ((this bombbot))
  (handle->process (-> this focus handle))
  (cond
    ((nonzero? (-> this gun-type))
     (when (>= (+ (current-time) (seconds -1)) (-> this next-shoot))
       (set-time! (-> this next-shoot))
       (bombbot-method-203 this)
       )
     )
    (else
      (when (>= (+ (current-time) (seconds -0.2)) (-> this next-shoot))
        (set-time! (-> this next-shoot))
        (handle->process (-> this focus handle))
        (let ((s5-0 (matrix-copy! (new 'stack-no-clear 'matrix) (-> this node-list data 6 bone transform))))
          (new 'stack-no-clear 'matrix)
          (new 'stack-no-clear 'vector)
          (let ((s4-0 (new 'stack-no-clear 'vector)))
            (let ((s3-0 (new 'stack-no-clear 'vector)))
              (new 'stack-no-clear 'vector)
              (new 'stack-no-clear 'vector)
              (matrix->trans s5-0 s3-0)
              (vector+*! s3-0 s3-0 (-> s5-0 fvec) 8192.0)
              (vector-normalize-copy! s4-0 (-> s5-0 fvec) 819200.0)
              (fire-shot this s3-0 (vector+! (new 'stack-no-clear 'vector) s3-0 s4-0))
              )
            (let ((s5-1 (new 'stack-no-clear 'vector)))
              (vector-copy! s5-1 s4-0)
              (vector-normalize! s5-1 -2048000.0)
              (vector-inv-orient-by-quat! s5-1 s5-1 (-> this root quat))
              (apply-impact!
                (-> this rigidbody)
                (rigid-body-control-method-25 (-> this rigidbody) (new 'stack-no-clear 'vector))
                s5-1
                )
              )
            )
          )
        )
      )
    )
  0
  (none)
  )

(defmethod normalize-heading! ((this bombbot) (arg0 nav-control))
  (let ((a0-1 (new 'stack-no-clear 'vector)))
    (new 'stack-no-clear 'vector)
    (let ((a2-0 (-> this nav state)))
      (vector-copy! a0-1 (-> a2-0 heading))
      )
    (let ((f0-1 (deg-diff (-> this y-angle) (vector-y-angle a0-1))))
      (let ((f1-0 7281.778))
        (while (< 8192.0 f0-1)
          (set! f0-1 (+ -16384.0 f0-1))
          )
        (while (< f0-1 -8192.0)
          (set! f0-1 (+ 16384.0 f0-1))
          )
        (cond
          ((< f1-0 f0-1)
           (set! f0-1 f1-0)
           )
          ((< f0-1 (- f1-0))
           (set! f0-1 (- f1-0))
           )
          )
        )
      (+! (-> this y-angle) (* f0-1 (seconds-per-frame)))
      )
    )
  (quaternion-vector-angle! (-> this root quat) *y-vector* (-> this y-angle))
  0
  (none)
  )

(defmethod nav-enemy-method-176 ((this bombbot))
  (let ((t9-0 (method-of-type nav-enemy nav-enemy-method-176)))
    (t9-0 this)
    )
  (logclear! (-> this nav state nav flags) (nav-control-flag update-heading-from-facing))
  0
  (none)
  )

(defmethod nav-enemy-method-177 ((this bombbot))
  (let ((t9-0 (method-of-type nav-enemy nav-enemy-method-177)))
    (t9-0 this)
    )
  (logclear! (-> this nav state nav flags) (nav-control-flag update-heading-from-facing))
  0
  (none)
  )

(defmethod bombbot-method-205 ((this bombbot))
  (when (= (-> this nav state mesh) *default-nav-mesh*)
    (let ((a0-4 (find-nearest-nav-mesh (-> this root trans) 0.0)))
      (when a0-4
        (change-to a0-4 this)
        (dotimes (s5-0 4)
          (let ((s4-0 (-> this feet s5-0)))
            (let ((s3-0 (new 'stack-no-clear 'vector)))
              (vector-orient-by-quat! s3-0 (-> s4-0 pos-offset) (-> this root quat))
              (vector+! s3-0 s3-0 (-> this root trans))
              (vector-copy! (-> s4-0 next-position) s3-0)
              (vector-copy! (-> s4-0 position) s3-0)
              )
            (set! (-> s4-0 delta-y) 0.0)
            )
          (set! (-> this legs-strength s5-0) 1.0)
          )
        )
      )
    )
  0
  (none)
  )

(defstate hostile (bombbot)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy hostile) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (logior! (-> self enemy-flags) (enemy-flag lock-focus))
    (logior! (-> self focus-status) (focus-status dangerous))
    (let ((v1-11 (-> (the-as collide-shape-prim-group (-> self root root-prim)) child 0)))
      (set! (-> v1-11 prim-core collide-as) (collide-spec))
      (set! (-> v1-11 prim-core collide-with) (collide-spec))
      )
    0
    (set! (-> self next-shoot) 0)
    0
    )
  :trans (behavior ()
    (if (>= (+ (current-time) (seconds -13)) (-> self stop-shoot))
        (go-virtual drop-bombs)
        )
    (when (< (-> self next-target) (current-time))
      (let ((a1-0 (new 'stack-no-clear 'vector)))
        (vector-copy! a1-0 (-> self root trans))
        (set! (-> a1-0 w) 204800.0)
        (bombbot-method-196 self a1-0)
        )
      (set! (-> self next-target) (+ (current-time) (seconds 5)))
      (set! (-> self gun-type) (the-as uint 0))
      0
      )
    (let ((v1-19 (the-as process-focusable (handle->process (-> self focus handle)))))
      (when v1-19
        (when (< (current-time) (+ (-> self next-target) (seconds -3.5)))
          (set-time! (-> self start-target))
          (vector-copy! (-> self start-target-pos) (-> v1-19 root trans))
          (vector-copy! (-> self start-target-vel) (-> v1-19 root transv))
          (vector-! (-> self target-delta) (-> v1-19 root trans) (-> self root trans))
          )
        (vector+*!
          (-> self target-pos)
          (-> self start-target-pos)
          (-> self start-target-vel)
          (* 0.0033333334 (the float (- (current-time) (-> self start-target))))
          )
        (if (= (-> v1-19 type) target)
            (vector-copy! (-> self target-pos) (-> self start-target-pos))
            )
        (if (< (+ (-> self next-target) (seconds -1)) (current-time))
            (bombbot-method-197 self)
            (bombbot-method-204 self)
            )
        )
      )
    (bombbot-method-205 self)
    (new 'stack-no-clear 'vector)
    (let ((f0-4 (* 0.25 (+ (-> self feet 0 next-position y)
                           (-> self feet 1 next-position y)
                           (-> self feet 2 next-position y)
                           (-> self feet 3 next-position y)
                           )
                   )
                )
          )
      (if (!= (-> self nav state mesh) *default-nav-mesh*)
          (+! (-> self root trans y) (* 4.0 (seconds-per-frame) (- f0-4 (-> self root trans y))))
          )
      )
    (if (= (vector-length (-> self root transv)) 0.0)
        (set-time! (-> self state-time))
        )
    (bombbot-method-202 self)
    (bombbot-method-195 self)
    )
  :code (behavior ()
    (until #f
      (ja-no-eval :group! bombbot-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post (behavior ()
    (-> self current-node)
    (let ((gp-1 (min (the-as int (+ (-> self current-node) 1)) (the-as int (+ (-> self city-path node-count) -1)))))
      (cond
        ((= (-> self nav state mesh) *default-nav-mesh*)
         (vector-v+!
           (-> self root trans)
           (-> self root trans)
           (vector-normalize!
             (vector-! (new 'stack-no-clear 'vector) (-> self city-path node gp-1 position) (-> self root trans))
             (-> *bombbot-nav-enemy-info* run-travel-speed)
             )
           )
         (seek! (-> self root trans y) (-> self city-path node gp-1 position y) (* 16384.0 (seconds-per-frame)))
         (enemy-common-post self)
         (update-transforms (-> self root))
         )
        (else
          (let ((v1-25 (-> self nav state))
                (a0-10 (-> self city-path node gp-1))
                )
            (logclear! (-> v1-25 flags) (nav-state-flag directional-mode))
            (logior! (-> v1-25 flags) (nav-state-flag target-poly-dirty))
            (vector-copy! (-> v1-25 target-pos) (-> a0-10 position))
            )
          0
          (nav-enemy-method-187 self)
          )
        )
      (if (< (vector-vector-xz-distance (-> self root trans) (-> self city-path node gp-1 position)) 32768.0)
          (set! (-> self current-node)
                (the-as
                  uint
                  (min (the-as int (+ (-> self current-node) 1)) (the-as int (+ (-> self city-path node-count) -1)))
                  )
                )
          )
      )
    )
  )

(defstate drop-bombs (bombbot)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (logior! (-> self enemy-flags) (enemy-flag lock-focus))
    (logior! (-> self focus-status) (focus-status dangerous))
    (set-time! (-> self start-target))
    (set! (-> self next-target) 0)
    (nav-enemy-method-178 self)
    (set! (-> self drop-mask) (the-as uint 0))
    (set! (-> self drop-angle) (rotate-y<-vector+vector
                                 (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (-> self root trans))
                                 *x-vector*
                                 )
          )
    (set! (-> self drop-num) (the-as uint 5))
    )
  :exit (behavior ()
    (set-time! (-> self stop-shoot))
    )
  :trans (behavior ()
    (when (and (nonzero? (-> self drop-num)) (< (-> self next-target) (current-time)))
      (let ((v1-5 (rnd-int-excluding-masked self 5 (the-as int (-> self drop-mask)))))
        (logior! (-> self drop-mask) (ash 1 v1-5))
        (set! (-> self next-shoot) (+ (current-time) (seconds 0.8)))
        (set! (-> self next-target) (+ (current-time) (seconds 1)))
        (set! (-> self gun-type) (the-as uint 1))
        (vector+*!
          (-> self target-pos)
          (-> self root trans)
          (vector-rotate-around-y!
            (new 'stack-no-clear 'vector)
            *x-vector*
            (+ 16384.0 (* 3640.889 (the float (+ v1-5 -2))) (-> self drop-angle))
            )
          61440.0
          )
        )
      (+! (-> self drop-num) -1)
      )
    (when (< (-> self next-shoot) (current-time))
      (set! (-> self next-shoot) (+ (current-time) (seconds 10)))
      (bombbot-method-203 self)
      )
    (if (>= (+ (current-time) (seconds -12)) (-> self start-target))
        (go-virtual hostile)
        )
    (bombbot-method-205 self)
    (new 'stack-no-clear 'vector)
    (let ((f0-5 (* 0.25 (+ (-> self feet 0 next-position y)
                           (-> self feet 1 next-position y)
                           (-> self feet 2 next-position y)
                           (-> self feet 3 next-position y)
                           )
                   )
                )
          )
      (if (!= (-> self nav state mesh) *default-nav-mesh*)
          (+! (-> self root trans y) (* 4.0 (seconds-per-frame) (- f0-5 (-> self root trans y))))
          )
      )
    (if (= (vector-length (-> self root transv)) 0.0)
        (set-time! (-> self state-time))
        )
    (bombbot-method-202 self)
    (bombbot-method-195 self)
    )
  :code (behavior ()
    (until #f
      (ja-no-eval :group! bombbot-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post (behavior ()
    (cond
      ((= (-> self nav state mesh) *default-nav-mesh*)
       (enemy-common-post self)
       (update-transforms (-> self root))
       )
      (else
        (nav-enemy-method-187 self)
        )
      )
    )
  )

(defstate blow-wall (bombbot)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (let ((a1-0 (new 'stack-no-clear 'array 'symbol 10)))
      (set! (-> a1-0 9) #f)
      (set! (-> a1-0 8) #f)
      (set! (-> a1-0 7) #f)
      (set! (-> a1-0 6) #f)
      (set! (-> a1-0 5) #f)
      (set! (-> a1-0 4) #f)
      (set! (-> a1-0 3) #f)
      (set! (-> a1-0 2) 'hiphog)
      (set! (-> a1-0 1) 'ctyindb)
      (set! (-> a1-0 0) 'ctywide-kg)
      (want-levels *load-state* a1-0)
      )
    )
  :exit (behavior ()
    (sound-stop (-> self head-sound))
    (sound-stop (-> self cannon-sound))
    )
  :trans (behavior ()
    (bombbot-method-202 self)
    )
  :code (behavior ()
    (until #f
      (ja-no-eval :group! bombbot-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post (behavior ()
    (set! (-> self root transv y) 0.0)
    (let ((v1-2 (-> self nav state))
          (a0-0 (new 'static 'vector :x 4290273.5 :y 29286.4 :z 1817763.9 :w 1.0))
          )
      (logclear! (-> v1-2 flags) (nav-state-flag directional-mode))
      (logior! (-> v1-2 flags) (nav-state-flag target-poly-dirty))
      (vector-copy! (-> v1-2 target-pos) a0-0)
      )
    0
    (when (logtest? (-> self nav state flags) (nav-state-flag at-target))
      (sound-play "bb-explode")
      (go-virtual explode)
      )
    (let ((v1-13 (-> self nav)))
      (set! (-> v1-13 target-speed) (-> self enemy-info run-travel-speed))
      )
    0
    (nav-enemy-method-187 self)
    )
  )

(defstate die (bombbot)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (when (-> self minimap)
      (logior! (-> self minimap flags) (minimap-flag fade-out))
      (set! (-> self minimap) #f)
      )
    (set! (-> self explosing) #f)
    (set! (-> self beep-time) 0)
    (set-time! (-> self state-time))
    )
  :trans (behavior ()
    (let ((v1-0 (-> self nav)))
      (set! (-> v1-0 target-speed)
            (- (-> self nav target-speed) (* 0.4 (seconds-per-frame) (-> self nav target-speed)))
            )
      )
    0
    (if (>= (- (current-time) (-> self state-time)) 0)
        (seek! (-> self legs-strength 0) 0.8 (* 10.0 (seconds-per-frame)))
        )
    (if (time-elapsed? (-> self state-time) (seconds 0.8))
        (seek! (-> self legs-strength 3) 0.4 (* 10.0 (seconds-per-frame)))
        )
    (if (time-elapsed? (-> self state-time) (seconds 1.6))
        (seek! (-> self legs-strength 1) 0.0 (* 10.0 (seconds-per-frame)))
        )
    (if (time-elapsed? (-> self state-time) (seconds 2.4))
        (seek! (-> self legs-strength 2) 0.5 (* 10.0 (seconds-per-frame)))
        )
    (when (time-elapsed? (-> self state-time) (seconds 2.8))
      (sound-play "bb-explode")
      (go-virtual explode)
      )
    (when (< (-> self beep-time) (current-time))
      (sound-play "bb-beep")
      (set! (-> self beep-time)
            (+ (current-time) (the int (* 0.2 (the float (- (seconds 2.8) (- (current-time) (-> self state-time)))))))
            )
      )
    )
  :code (behavior ()
    (until #f
      (suspend)
      (ja-no-eval :group! bombbot-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post (behavior ()
    (set! (-> self root transv y) 0.0)
    (nav-enemy-method-187 self)
    )
  )

(define *bombbot-debris-params*
  (new 'static 'debris-static-params
    :joints (new 'static 'boxed-array :type debris-static-joint-params
      (new 'static 'debris-static-joint-params :parent-joint-index 4 :group "skel-kg-debris-a")
      (new 'static 'debris-static-joint-params :parent-joint-index 5 :group "skel-kg-debris-b")
      (new 'static 'debris-static-joint-params :parent-joint-index 6 :group "skel-kg-debris-c")
      (new 'static 'debris-static-joint-params :parent-joint-index 7 :group "skel-kg-debris-d")
      (new 'static 'debris-static-joint-params :parent-joint-index 8 :group "skel-kg-debris-a")
      (new 'static 'debris-static-joint-params :parent-joint-index 9 :group "skel-kg-debris-b")
      (new 'static 'debris-static-joint-params :parent-joint-index 10 :group "skel-kg-debris-c")
      (new 'static 'debris-static-joint-params :parent-joint-index 11 :group "skel-kg-debris-d")
      (new 'static 'debris-static-joint-params :parent-joint-index 12 :group "skel-kg-debris-a")
      (new 'static 'debris-static-joint-params :parent-joint-index 13 :group "skel-kg-debris-b")
      (new 'static 'debris-static-joint-params :parent-joint-index 14 :group "skel-kg-debris-c")
      (new 'static 'debris-static-joint-params :parent-joint-index 15 :group "skel-kg-debris-d")
      (new 'static 'debris-static-joint-params :parent-joint-index 18 :group "skel-kg-debris-a")
      (new 'static 'debris-static-joint-params :parent-joint-index 19 :group "skel-kg-debris-b")
      (new 'static 'debris-static-joint-params :parent-joint-index 16 :group "skel-kg-debris-c")
      (new 'static 'debris-static-joint-params :parent-joint-index 17 :group "skel-kg-debris-d")
      )
    :collide-spec (collide-spec backgnd)
    :sound-hit (static-sound-name "kg-debris")
    )
  )

(defstate explode (bombbot)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (when (-> self minimap)
      (logior! (-> self minimap flags) (minimap-flag fade-out))
      (set! (-> self minimap) #f)
      )
    (set! (-> self explosing) #f)
    (set-time! (-> self state-time))
    (let ((a1-1 (new 'stack 'debris-tuning (the-as uint 1))))
      (set! (-> a1-1 duration) (seconds 3))
      (set! (-> a1-1 gravity) -163840.0)
      (set! (-> a1-1 scale-rand-lo) 1.0)
      (set! (-> a1-1 scale-rand-hi) 3.0)
      (vector-copy! (-> a1-1 fountain-rand-transv-lo) (-> self root trans))
      (debris-spawn self a1-1 *bombbot-debris-params* (the-as process-drawable #f))
      )
    (let ((v1-15 (new 'stack-no-clear 'vector)))
      (vector-copy! v1-15 (-> self root trans))
      (+! (-> v1-15 y) 2048.0)
      )
    (let ((s5-0 (new 'stack-no-clear 'vector)))
      (vector-copy! s5-0 (-> self node-list data 3 bone transform trans))
      (new 'stack-no-clear 'vector)
      4.0
      (+! (-> s5-0 y) 8192.0)
      (activate! *camera-smush-control* 1024.0 37 210 1.0 0.995 (-> self clock))
      (let ((gp-0 (new 'stack-no-clear 'explosion-init-params)))
        (vector-copy! (-> gp-0 spawn-point) s5-0)
        (quaternion-identity! (-> gp-0 spawn-quat))
        (set! (-> gp-0 radius) 61440.0)
        (set! (-> gp-0 scale) 1.0)
        (set! (-> gp-0 group) (-> *part-group-id-table* 217))
        (set! (-> gp-0 collide-with)
              (collide-spec backgnd jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
              )
        (set! (-> gp-0 damage) 2.0)
        (set! (-> gp-0 damage-scale) 1.0)
        (set! (-> gp-0 vehicle-damage-factor) 1.0)
        (set! (-> gp-0 vehicle-impulse-factor) 1.0)
        (set! (-> gp-0 ignore-proc) (process->handle #f))
        (explosion-spawn gp-0 self)
        )
      )
    (dotimes (gp-1 4)
      (let ((s4-0 (new 'stack-no-clear 'vector))
            (s5-1 (new 'stack-no-clear 'vector))
            )
        (let ((f30-0 (* 16384.0 (the float gp-1))))
          (set-vector! s4-0 (cos f30-0) 0.0 (sin f30-0) 1.0)
          )
        (vector-float*! s4-0 s4-0 (* 4096.0 (+ 2.0 (* 2.0 (rand-vu)))))
        (vector-copy! s5-1 (-> self root trans))
        (vector+! (-> self root trans) (-> self root trans) s4-0)
        (set! (-> self fact pickup-type) (pickup-type ammo-random))
        (set! (-> self fact pickup-amount) 10.0)
        (set! (-> self fact pickup-spawn-amount) 2.0)
        (drop-pickup (-> self fact) #t *entity-pool* (-> self fact) 0 #f)
        (vector-copy! (-> self root trans) s5-1)
        )
      )
    (set! (-> self explosing) #t)
    (set! (-> self root nav-flags) (nav-flags))
    (let ((v1-62 (-> self root root-prim)))
      (set! (-> v1-62 prim-core collide-as) (collide-spec))
      (set! (-> v1-62 prim-core collide-with) (collide-spec))
      )
    0
    (ja-channel-set! 0)
    (ja-post)
    )
  :code (behavior ()
    (while (-> self child)
      (suspend)
      )
    (cleanup-for-death self)
    )
  )

(defmethod relocate ((this bombbot) (offset int))
  (dotimes (v1-0 4)
    (if (nonzero? (-> this joint-ik v1-0))
        (&+! (-> this joint-ik v1-0) offset)
        )
    )
  (if (nonzero? (-> this rigidbody))
      (&+! (-> this rigidbody) offset)
      )
  (call-parent-method this offset)
  )

(defmethod init-enemy-collision! ((this bombbot))
  "Typical place to construct collision shapes"
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) cshape-reaction-default)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (set! (-> s5-0 penetrated-by) (penetrate))
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 34) 0)))
      (set! (-> s5-0 total-prims) (the-as uint 35))
      (set! (-> s4-0 prim-core collide-as) (collide-spec bot enemy))
      (set! (-> s4-0 prim-core collide-with)
            (collide-spec backgnd jak civilian enemy vehicle-sphere hit-by-others-list player-list)
            )
      (set! (-> s4-0 prim-core action) (collide-action solid deadly no-standon))
      (set-vector! (-> s4-0 local-sphere) 0.0 12288.0 0.0 32768.0)
      (set! (-> s5-0 root-prim) s4-0)
      )
    (let ((v1-12 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-12 prim-core collide-as) (collide-spec bot enemy))
      (set! (-> v1-12 prim-core collide-with) (collide-spec backgnd))
      (set! (-> v1-12 prim-core action) (collide-action solid))
      (set-vector! (-> v1-12 local-sphere) 0.0 20480.0 0.0 20480.0)
      )
    (let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-14 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-14 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-14 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-14 transform-index) 3)
      (set-vector! (-> v1-14 local-sphere) 0.0 1638.4 0.0 8192.0)
      )
    (let ((v1-16 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-16 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-16 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-16 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-16 transform-index) 19)
      (set-vector! (-> v1-16 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-18 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-18 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-18 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-18 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-18 transform-index) 19)
      (set-vector! (-> v1-18 local-sphere) 0.0 4096.0 0.0 2867.2)
      )
    (let ((v1-20 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-20 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-20 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-20 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-20 transform-index) 19)
      (set-vector! (-> v1-20 local-sphere) 0.0 8192.0 0.0 2867.2)
      )
    (let ((v1-22 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-22 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-22 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-22 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-22 transform-index) 19)
      (set-vector! (-> v1-22 local-sphere) 0.0 12288.0 0.0 2867.2)
      )
    (let ((v1-24 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-24 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-24 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-24 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-24 transform-index) 18)
      (set-vector! (-> v1-24 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-26 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-26 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-26 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-26 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-26 transform-index) 18)
      (set-vector! (-> v1-26 local-sphere) 0.0 4096.0 0.0 2867.2)
      )
    (let ((v1-28 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-28 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-28 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-28 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-28 transform-index) 18)
      (set-vector! (-> v1-28 local-sphere) 0.0 8192.0 0.0 2867.2)
      )
    (let ((v1-30 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
      (set! (-> v1-30 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-30 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-30 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-30 transform-index) 18)
      (set-vector! (-> v1-30 local-sphere) 0.0 12288.0 0.0 2867.2)
      )
    (let ((v1-32 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-32 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-32 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-32 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-32 transform-index) 13)
      (set-vector! (-> v1-32 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-34 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-34 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-34 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-34 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-34 transform-index) 13)
      (set-vector! (-> v1-34 local-sphere) 0.0 -4096.0 0.0 2867.2)
      )
    (let ((v1-36 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-36 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-36 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-36 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-36 transform-index) 13)
      (set-vector! (-> v1-36 local-sphere) 0.0 -8192.0 0.0 2867.2)
      )
    (let ((v1-38 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-38 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-38 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-38 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-38 transform-index) 13)
      (set-vector! (-> v1-38 local-sphere) 0.0 -12288.0 0.0 2867.2)
      )
    (let ((v1-40 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-40 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-40 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-40 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-40 transform-index) 12)
      (set-vector! (-> v1-40 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-42 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-42 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-42 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-42 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-42 transform-index) 12)
      (set-vector! (-> v1-42 local-sphere) 0.0 -4096.0 0.0 2867.2)
      )
    (let ((v1-44 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-44 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-44 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-44 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-44 transform-index) 12)
      (set-vector! (-> v1-44 local-sphere) 0.0 -8192.0 0.0 2867.2)
      )
    (let ((v1-46 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
      (set! (-> v1-46 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-46 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-46 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-46 transform-index) 12)
      (set-vector! (-> v1-46 local-sphere) 0.0 -12288.0 0.0 2867.2)
      )
    (let ((v1-48 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-48 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-48 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-48 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-48 transform-index) 17)
      (set-vector! (-> v1-48 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-50 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-50 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-50 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-50 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-50 transform-index) 17)
      (set-vector! (-> v1-50 local-sphere) 0.0 -4096.0 0.0 2867.2)
      )
    (let ((v1-52 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-52 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-52 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-52 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-52 transform-index) 17)
      (set-vector! (-> v1-52 local-sphere) 0.0 -8192.0 0.0 2867.2)
      )
    (let ((v1-54 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-54 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-54 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-54 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-54 transform-index) 17)
      (set-vector! (-> v1-54 local-sphere) 0.0 -12288.0 0.0 2867.2)
      )
    (let ((v1-56 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-56 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-56 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-56 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-56 transform-index) 16)
      (set-vector! (-> v1-56 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-58 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-58 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-58 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-58 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-58 transform-index) 16)
      (set-vector! (-> v1-58 local-sphere) 0.0 -4096.0 0.0 2867.2)
      )
    (let ((v1-60 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-60 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-60 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-60 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-60 transform-index) 16)
      (set-vector! (-> v1-60 local-sphere) 0.0 -8192.0 0.0 2867.2)
      )
    (let ((v1-62 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4))))
      (set! (-> v1-62 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-62 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-62 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-62 transform-index) 16)
      (set-vector! (-> v1-62 local-sphere) 0.0 -12288.0 0.0 2867.2)
      )
    (let ((v1-64 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-64 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-64 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-64 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-64 transform-index) 15)
      (set-vector! (-> v1-64 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-66 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-66 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-66 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-66 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-66 transform-index) 15)
      (set-vector! (-> v1-66 local-sphere) 0.0 4096.0 0.0 2867.2)
      )
    (let ((v1-68 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-68 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-68 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-68 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-68 transform-index) 15)
      (set-vector! (-> v1-68 local-sphere) 0.0 8192.0 0.0 2867.2)
      )
    (let ((v1-70 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-70 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-70 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-70 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-70 transform-index) 15)
      (set-vector! (-> v1-70 local-sphere) 0.0 12288.0 0.0 2867.2)
      )
    (let ((v1-72 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-72 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-72 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-72 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-72 transform-index) 14)
      (set-vector! (-> v1-72 local-sphere) 0.0 0.0 0.0 2867.2)
      )
    (let ((v1-74 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-74 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-74 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-74 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-74 transform-index) 14)
      (set-vector! (-> v1-74 local-sphere) 0.0 4096.0 0.0 2867.2)
      )
    (let ((v1-76 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-76 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-76 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-76 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-76 transform-index) 14)
      (set-vector! (-> v1-76 local-sphere) 0.0 8192.0 0.0 2867.2)
      )
    (let ((v1-78 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
      (set! (-> v1-78 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-78 prim-core collide-with) (collide-spec jak vehicle-sphere hit-by-others-list player-list))
      (set! (-> v1-78 prim-core action) (collide-action solid no-standon))
      (set! (-> v1-78 transform-index) 14)
      (set-vector! (-> v1-78 local-sphere) 0.0 12288.0 0.0 2867.2)
      )
    (set! (-> s5-0 nav-radius) 22528.0)
    (let ((v1-80 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-80 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-80 prim-core collide-with))
      )
    (set! (-> s5-0 event-priority) (the-as uint 8))
    (set! (-> this root) s5-0)
    )
  (set! (-> this root max-iteration-count) (the-as uint 8))
  0
  (none)
  )

(defmethod coin-flip? ((this bombbot))
  "Return #t half the time, #f the other."
  #f
  )

(defun bombbot-callback ((arg0 cspace) (arg1 transformq))
  (local-vars
    (sv-176 (function quaternion quaternion quaternion quaternion))
    (sv-192 quaternion)
    (sv-208 quaternion)
    (sv-224 vector)
    (sv-240 vector)
    )
  (rlet ((acc :class vf)
         (vf1 :class vf)
         (vf2 :class vf)
         (vf3 :class vf)
         )
    (let ((s4-0 (the-as bombbot (-> arg0 param1))))
      (let ((s1-0 (new 'stack-no-clear 'vector))
            (s3-0 (quaternion-copy! (new 'stack-no-clear 'quaternion) *unity-quaternion*))
            )
        (let ((f30-0 0.0)
              (s2-0 (vector-reset! (new 'stack-no-clear 'vector)))
              )
          (dotimes (s0-0 4)
            (let ((v1-3 (-> s4-0 feet s0-0)))
              (vector+*! s2-0 s2-0 (the-as vector (+ (the-as uint (-> s4-0 feet 0 real-position)) (* 112 s0-0))) 0.25)
              (set! (-> v1-3 main-y) (- (-> s4-0 feet s0-0 real-position y) (-> s4-0 root trans y)))
              (set! (-> v1-3 main-y) (-> v1-3 delta-y))
              (+! f30-0 (/ (-> v1-3 main-y) 4))
              (vector-copy! s1-0 (-> v1-3 pos-offset))
              (set! (-> s1-0 y) (* -2.0 (-> v1-3 main-y)))
              (new 'stack-no-clear 'vector)
              (set! sv-224 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> v1-3 pos-offset) 1.0))
              )
            (set! sv-240 (vector-normalize-copy! (new 'stack-no-clear 'vector) s1-0 1.0))
            (let ((f0-8 (vector-vector-angle-safe sv-224 sv-240)))
              (when (!= f0-8 0.0)
                (set! sv-176 quaternion*!)
                (set! sv-192 s3-0)
                (set! sv-208 s3-0)
                (let ((t9-4 quaternion-vector-angle!)
                      (a0-14 (new 'stack-no-clear 'quaternion))
                      (a1-9 (new 'stack-no-clear 'vector))
                      )
                  (.lvf vf1 (&-> sv-224 quad))
                  (.lvf vf2 (&-> sv-240 quad))
                  (.outer.product.a.vf acc vf1 vf2)
                  (.outer.product.b.vf vf3 vf2 vf1 acc)
                  (.svf (&-> a1-9 quad) vf3)
                  (let ((a2-5 (t9-4 a0-14 a1-9 f0-8)))
                    (sv-176 sv-192 sv-208 a2-5)
                    )
                  )
                )
              )
            )
          (let* ((f0-9 0.0)
                 (f0-10 (+ -16384.0 f0-9))
                 (f2-0 (- f30-0 (-> s4-0 main-pos-y)))
                 (f1-7 (- (-> s4-0 main-spd-y)))
                 (f0-12 (+ f0-10 (* 60.0 f2-0) (* 10.0 f1-7)))
                 )
            (+! (-> s4-0 main-spd-y) (* f0-12 (seconds-per-frame)))
            )
          (+! (-> s4-0 main-pos-y) (* (-> s4-0 main-spd-y) (seconds-per-frame)))
          (vector-! s2-0 s2-0 (-> s4-0 root trans))
          (vector-inv-orient-by-quat! s2-0 s2-0 (-> s4-0 root quat))
          (vector+*!
            (-> s4-0 main-pos)
            (-> s4-0 main-pos)
            (vector-! (new 'stack-no-clear 'vector) s2-0 (-> s4-0 main-pos))
            (* 4.0 (seconds-per-frame))
            )
          )
        (quaternion-slerp! (-> s4-0 main-quat) (-> s4-0 main-quat) s3-0 0.8)
        )
      (quaternion-copy! (-> arg1 quat) (-> s4-0 main-quat))
      (vector-copy! (-> arg1 trans) (-> s4-0 main-pos))
      (set! (-> arg1 trans y) (+ 16384.0 (-> s4-0 main-pos-y)))
      (quaternion-copy! (-> arg1 quat) (the-as quaternion (-> s4-0 rigidbody rot)))
      (vector-copy!
        (-> arg1 trans)
        (rigid-body-control-method-25 (-> s4-0 rigidbody) (new 'stack-no-clear 'vector))
        )
      )
    (cspace<-parented-transformq-joint! arg0 arg1)
    0
    (none)
    )
  )

(defun bombbot-head-callback ((arg0 cspace) (arg1 transformq))
  (let ((s4-0 (the-as bombbot (-> arg0 param1))))
    (let ((s2-0 (new 'stack-no-clear 'vector))
          (s3-0 (new 'stack-no-clear 'quaternion))
          )
      (let ((a1-1 (-> s4-0 nav state)))
        (vector-copy! s2-0 (-> a1-1 target-pos))
        )
      (vector-! s2-0 s2-0 (-> s4-0 root trans))
      (set! (-> s2-0 y) 0.0)
      (let ((a1-6 (-> s4-0 nav state)))
        (vector-copy! s2-0 (-> a1-6 heading))
        )
      (vector-normalize! s2-0 1.0)
      (quaternion-from-two-vectors!
        s3-0
        (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> s4-0 root quat))
        s2-0
        )
      (quaternion-smooth-seek! (-> s4-0 top-quat) (-> s4-0 top-quat) s3-0 (* 4.0 (seconds-per-frame)))
      )
    (quaternion-copy! (-> arg1 quat) (-> s4-0 top-quat))
    )
  (cspace<-parented-transformq-joint! arg0 arg1)
  0
  (none)
  )

(defun bombbot-gun-swivel-callback ((arg0 cspace) (arg1 transformq))
  (local-vars (sv-128 vector) (sv-144 vector) (sv-160 vector))
  (rlet ((vf0 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         (vf6 :class vf)
         )
    (init-vf0-vector)
    (cspace<-parented-transformq-joint! arg0 arg1)
    (let ((s3-0 (the-as bombbot (-> arg0 param1))))
      (set! sv-160 (new 'stack-no-clear 'vector))
      (let ((s4-0 (new 'stack-no-clear 'quaternion))
            (s0-0 (new 'stack-no-clear 'vector))
            (s1-0 (new 'stack-no-clear 'vector))
            (s2-0 (new 'stack-no-clear 'vector))
            (s5-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector)))
            )
        (set! sv-144 sv-160)
        (set! sv-128 (-> s3-0 target-pos))
        (let ((v0-2 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))))
          (.lvf vf4 (&-> sv-128 quad))
          (.lvf vf5 (&-> v0-2 quad))
          )
        (.mov.vf.w vf6 vf0)
        (.sub.vf.xyz vf6 vf4 vf5)
        (.svf (&-> sv-144 quad) vf6)
        (rot-zxy-from-vector! s0-0 (-> arg0 bone transform fvec))
        (rot-zxy-from-vector! s0-0 *z-vector*)
        (rot-zxy-from-vector! s1-0 sv-160)
        (set! (-> s2-0 x) (deg- (-> s1-0 x) (-> s0-0 x)))
        (set! (-> s2-0 y) (deg- (-> s1-0 y) (-> s0-0 y)))
        (set! (-> s2-0 y) (deg- (-> s1-0 y) 0.0))
        (set! (-> s3-0 angle-turret) (deg-seek (-> s3-0 angle-turret) (-> s2-0 y) (* 36408.89 (seconds-per-frame))))
        (quaternion-vector-angle! s4-0 *up-vector* (-> s3-0 angle-turret))
        (quaternion->matrix (-> arg0 bone transform) s4-0)
        (vector-copy! (-> arg0 bone transform trans) s5-0)
        )
      )
    0
    (none)
    )
  )

(defun bombbot-gun-callback ((arg0 cspace) (arg1 transformq))
  (local-vars (sv-112 vector) (sv-128 vector))
  (rlet ((vf0 :class vf)
         (vf4 :class vf)
         (vf5 :class vf)
         (vf6 :class vf)
         )
    (init-vf0-vector)
    (cspace<-parented-transformq-joint! arg0 arg1)
    (let ((s4-0 (the-as bombbot (-> arg0 param1))))
      (let ((s0-0 (new 'stack-no-clear 'vector)))
        (new 'stack-no-clear 'vector)
        (let ((s2-0 (new 'stack-no-clear 'vector))
              (s1-0 (new 'stack-no-clear 'vector))
              (s3-0 (new 'stack-no-clear 'vector))
              )
          (set! sv-128 s0-0)
          (set! sv-112 (-> s4-0 target-pos))
          (let ((v0-1 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))))
            (.lvf vf4 (&-> sv-112 quad))
            (.lvf vf5 (&-> v0-1 quad))
            )
          (.mov.vf.w vf6 vf0)
          (.sub.vf.xyz vf6 vf4 vf5)
          (.svf (&-> sv-128 quad) vf6)
          (rot-zxy-from-vector! s2-0 (-> arg0 bone transform fvec))
          (rot-zxy-from-vector! s1-0 s0-0)
          (set! (-> s3-0 x) (fmax -4551.1113 (fmin 4551.1113 (deg- (-> s1-0 x) (-> s2-0 x)))))
          (set! (-> s3-0 y) (deg- (-> s1-0 y) (-> s2-0 y)))
          (set! (-> s4-0 angle-gun)
                (deg-seek (-> s4-0 angle-gun) (-> s3-0 x) (* (-> s4-0 gun-rotation-speed) (seconds-per-frame)))
                )
          )
        )
      (quaternion-vector-angle! (-> arg1 quat) *x-vector* (+ (-> s4-0 angle-gun) (-> s4-0 extra-angle-gun)))
      )
    (cspace<-parented-transformq-joint! arg0 arg1)
    0
    (none)
    )
  )

(deftype spring-setup (structure)
  ((bpos1  vector)
   (wpos2  vector)
   )
  )


(define *bombbot-spring-setup* (new 'static 'boxed-array :type spring-setup
                                 (new 'static 'spring-setup
                                   :bpos1 (new 'static 'vector :x 4096.0 :y -4096.0 :z 4096.0 :w 1.0)
                                   :wpos2 (new 'static 'vector :x 6144.0 :y 14336.0 :z 6144.0 :w 1.0)
                                   )
                                 (new 'static 'spring-setup
                                   :bpos1 (new 'static 'vector :x 4096.0 :y -4096.0 :z -4096.0 :w 1.0)
                                   :wpos2 (new 'static 'vector :x 6144.0 :y 14336.0 :z -6144.0 :w 1.0)
                                   )
                                 (new 'static 'spring-setup
                                   :bpos1 (new 'static 'vector :x -4096.0 :y -4096.0 :z -4096.0 :w 1.0)
                                   :wpos2 (new 'static 'vector :x -6144.0 :y 14336.0 :z -6144.0 :w 1.0)
                                   )
                                 (new 'static 'spring-setup
                                   :bpos1 (new 'static 'vector :x -4096.0 :y -4096.0 :z 4096.0 :w 1.0)
                                   :wpos2 (new 'static 'vector :x -6144.0 :y 14336.0 :z 6144.0 :w 1.0)
                                   )
                                 )
        )

(defmethod bombbot-method-198 ((this bombbot))
  (local-vars (at-0 int) (sv-160 vector) (sv-176 vector))
  (with-pp
    (rlet ((vf0 :class vf)
           (vf1 :class vf)
           (vf2 :class vf)
           (vf4 :class vf)
           (vf5 :class vf)
           (vf6 :class vf)
           )
      (init-vf0-vector)
      (let ((a1-0 (new 'stack-no-clear 'vector)))
        (vector-reset! a1-0)
        (set! (-> a1-0 y) (* -1.0 (-> this info extra gravity) (-> this rigidbody info mass)))
        (add-force! (-> this rigidbody) a1-0)
        )
      (rigid-body-control-method-26 (-> this rigidbody))
      (logclear! (-> this rigidbody flags) (rigid-body-flag active))
      (dotimes (s5-0 4)
        (let ((s4-0 (vector-matrix*!
                      (new 'stack-no-clear 'vector)
                      (-> *bombbot-spring-setup* s5-0 bpos1)
                      (-> this rigidbody matrix)
                      )
                    )
              )
          (set! sv-160 (new 'stack-no-clear 'vector))
          (let ((v1-19 (-> *bombbot-spring-setup* s5-0 wpos2 quad)))
            (set! (-> sv-160 quad) v1-19)
            )
          (set! sv-176 (new 'stack-no-clear 'vector))
          (let ((s0-0 (new 'stack-no-clear 'vector))
                (s2-0 (new 'stack-no-clear 'vector))
                (s1-0 (new 'stack-no-clear 'vector))
                (s3-0 (new 'stack-no-clear 'vector))
                )
            (set! (-> sv-160 y) (* (-> this legs-strength s5-0) (-> sv-160 y)))
            (+! (-> sv-160 y) (-> this feet s5-0 main-y))
            0.0
            0.0
            0.0
            (rigid-body-control-method-23 (-> this rigidbody) s4-0 sv-176)
            (let ((v1-31 s0-0))
              (.lvf vf4 (&-> s4-0 quad))
              (.lvf vf5 (&-> sv-160 quad))
              (.mov.vf.w vf6 vf0)
              (.sub.vf.xyz vf6 vf4 vf5)
              (.svf (&-> v1-31 quad) vf6)
              )
            (let ((a1-4 s1-0)
                  (v1-32 *null-vector*)
                  )
              (vector-! a1-4 sv-176 v1-32)
              )
            (let ((f0-10 (vector-length s0-0)))
              (vector-float*! s2-0 s0-0 (/ 1.0 f0-10))
              (let ((f0-12 (* 60.0 (+ -40.96 f0-10)))
                    (f1-8 (* 0.8 (vector-dot s1-0 s2-0)))
                    )
                (vector-float*! s3-0 s2-0 (- (+ f0-12 f1-8)))
                )
              )
            (apply-impact! (-> this rigidbody) s4-0 s3-0)
            )
          )
        )
      (let ((v1-48 (new 'stack-no-clear 'vector)))
        (.lvf vf1 (&-> (-> this linear-speed) quad))
        (let ((f0-15 (-> pp clock frames-per-second)))
          (.mov at-0 f0-15)
          )
        (.mov vf2 at-0)
        (.mov.vf.w vf1 vf0)
        (.mul.x.vf.xyz vf1 vf1 vf2)
        (.svf (&-> v1-48 quad) vf1)
        )
      0
      (none)
      )
    )
  )

(defmethod bombbot-method-199 ((this bombbot))
  (rigid-body-control-method-10
    (-> this rigidbody)
    (the-as rigid-body-object this)
    (seconds-per-frame)
    0.033333335
    )
  0
  (none)
  )

(defmethod init-enemy! ((this bombbot))
  "Typical place for shared init code. Runs from entity or process style init."
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-bombbot" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (setup-enemy! this *bombbot-nav-enemy-info*)
  (set-vector! (-> this root scale) 1.0 1.0 1.0 1.0)
  (let ((v1-7 (-> this nav)))
    (set! (-> v1-7 speed-scale) 1.0)
    )
  0
  (set-gravity-length (-> this root dynam) 573440.0)
  (logior! (-> this nav flags) (nav-control-flag momentum-ignore-heading))
  (dotimes (s5-1 4)
    (set! (-> this joint-ik s5-1)
          (new
            'process
            'joint-mod-ik
            this
            (-> *bombbot-ik-limb-setup* s5-1 elbow-index)
            (-> *bombbot-ik-limb-setup* s5-1 hand-dist)
            )
          )
    (set! (-> this joint-ik s5-1 elbow-pole-vector-axis) (the-as uint 2))
    (set! (-> this joint-ik s5-1 elbow-rotation-axis) (the-as uint 0))
    )
  (logior! (-> this joint-ik 1 flags) (joint-mod-ik-flags elbow-trans-neg))
  (logior! (-> this joint-ik 3 flags) (joint-mod-ik-flags elbow-trans-neg))
  (logior! (-> this joint-ik 0 flags) (joint-mod-ik-flags elbow-rot-neg))
  (logior! (-> this joint-ik 1 flags) (joint-mod-ik-flags elbow-rot-neg))
  (logior! (-> this joint-ik 2 flags) (joint-mod-ik-flags elbow-rot-neg))
  (logior! (-> this joint-ik 3 flags) (joint-mod-ik-flags elbow-rot-neg))
  (let ((f1-0 11878.4)
        (f0-6 10240.0)
        )
    (let ((f2-0 -10240.0))
      (let ((v1-51 (-> this feet)))
        (set! (-> v1-51 0 pos-offset x) f1-0)
        (set! (-> v1-51 0 pos-offset y) 0.0)
        (set! (-> v1-51 0 pos-offset z) f0-6)
        (set! (-> v1-51 0 pos-offset w) 1.0)
        )
      (set! (-> this feet 0 offset) 0.0)
      (let ((v1-52 (-> this feet 1)))
        (set! (-> v1-52 pos-offset x) f1-0)
        (set! (-> v1-52 pos-offset y) 0.0)
        (set! (-> v1-52 pos-offset z) f2-0)
        (set! (-> v1-52 pos-offset w) 1.0)
        )
      (set! (-> this feet 1 offset) 0.5)
      (let ((v1-54 (-> this feet 2)))
        (set! (-> v1-54 pos-offset x) (- f1-0))
        (set! (-> v1-54 pos-offset y) 0.0)
        (set! (-> v1-54 pos-offset z) f2-0)
        (set! (-> v1-54 pos-offset w) 1.0)
        )
      )
    (set! (-> this feet 2 offset) 0.1)
    (let ((v1-56 (-> this feet 3)))
      (set! (-> v1-56 pos-offset x) (- f1-0))
      (set! (-> v1-56 pos-offset y) 0.0)
      (set! (-> v1-56 pos-offset z) f0-6)
      (set! (-> v1-56 pos-offset w) 1.0)
      )
    )
  (set! (-> this feet 3 offset) 0.6)
  (quaternion-copy! (-> this last-quat) (-> this root quat))
  (quaternion-copy! (-> this main-quat) *unity-quaternion*)
  (let ((v1-60 (-> this nav)))
    (set! (-> v1-60 sphere-mask) (the-as uint 68))
    )
  0
  (let ((a0-28 (-> this node-list data 3)))
    (set! (-> a0-28 param0) bombbot-callback)
    (set! (-> a0-28 param1) this)
    )
  (let ((a0-29 (-> this node-list data 4)))
    (set! (-> a0-29 param0) bombbot-head-callback)
    (set! (-> a0-29 param1) this)
    )
  (let ((a0-30 (-> this node-list data 5)))
    (set! (-> a0-30 param0) bombbot-gun-swivel-callback)
    (set! (-> a0-30 param1) this)
    )
  (let ((a0-31 (-> this node-list data 6)))
    (set! (-> a0-31 param0) bombbot-gun-callback)
    (set! (-> a0-31 param1) this)
    )
  (set! (-> this rigidbody) (new 'process 'rigid-body-control this))
  (set! (-> this info) *bombbot-body-constants*)
  (init!
    (-> this rigidbody)
    (-> this info info)
    *null-vector*
    *unity-quaternion*
    (the-as (function rigid-body-object float) (method-of-object this bombbot-method-198))
    )
  (set! (-> this head-sound) (new 'static 'sound-id))
  (set! (-> this cannon-sound) (new 'static 'sound-id))
  (set! (-> this gun-rotation-speed) 7281.778)
  (set! (-> this extra-angle-gun) 0.0)
  (transform-post)
  (dotimes (s5-2 4)
    (let ((s4-1 (-> this feet s5-2)))
      (let ((s3-0 (new 'stack-no-clear 'vector)))
        (vector-orient-by-quat! s3-0 (-> s4-1 pos-offset) (-> this root quat))
        (vector+! s3-0 s3-0 (-> this root trans))
        (vector-copy! (-> s4-1 next-position) s3-0)
        (vector-copy! (-> s4-1 position) s3-0)
        )
      (set! (-> s4-1 delta-y) 0.0)
      )
    (set! (-> this legs-strength s5-2) 1.0)
    )
  (set! (-> this draw light-index) (the-as uint 10))
  (logclear! (-> this nav flags) (nav-control-flag update-heading-from-facing))
  (set! (-> this enemy-flags) (the-as enemy-flag (logclear (-> this enemy-flags) (enemy-flag ef44))))
  (let ((s5-3 (new 'stack-no-clear 'vector)))
    (vector-z-quaternion! s5-3 (-> this root quat))
    (set! (-> this y-angle) (vector-y-angle s5-3))
    (vector-copy! (-> this nav state heading) s5-3)
    )
  0
  (set! (-> this max-hit-points) (-> this hit-points))
  0
  (none)
  )

(deftype bombbot-spawn-params (structure)
  ((position     vector      :inline)
   (quat         quaternion  :inline)
   (nav-mesh     nav-mesh)
   (path         bombbot-path)
   (first-node   uint32)
   (stop-offset  float)
   )
  )


(defbehavior bombbot-init-by-other bombbot ((arg0 bombbot-spawn-params))
  (stack-size-set! (-> self main-thread) 512)
  (set! (-> self city-path) (-> arg0 path))
  (set! (-> self current-node) (-> arg0 first-node))
  (init-enemy-collision! self)
  (vector-copy! (-> self root trans) (-> self city-path node (-> self current-node) position))
  (quaternion-copy! (-> self root quat) (-> arg0 quat))
  (vector-identity! (-> self root scale))
  (-> arg0 nav-mesh)
  (set! (-> *bombbot-nav-enemy-info* nav-mesh) *default-nav-mesh*)
  (init-enemy! self)
  (set! (-> self shot-count) (the-as uint 5))
  (vector-copy! (-> self last-trans) (-> self root trans))
  (logior! (-> self mask) (process-mask kg-robot))
  (set! (-> self minimap) #f)
  (set! (-> self minimap) (add-icon! *minimap* self (the-as uint 12) (the-as int #f) (the-as vector #t) 0))
  (logior! (-> self mask) (process-mask enemy))
  (set! (-> self stop-shoot) (+ (current-time) (the int (-> arg0 stop-offset))))
  (set! (-> self shoot-duration) 1.0)
  (set! (-> self draw light-index) (the-as uint 10))
  (go-virtual hostile)
  )

(defmethod enemy-touched-handler ((this bombbot) (arg0 process) (arg1 event-message-block))
  "General handler for when anything touches an enemy (automatic response)."
  (when (!= (-> arg0 type) target)
    (let ((s3-0 (-> arg1 param 0))
          (v1-1 (as-type arg0 process-focusable))
          )
      (cond
        ((and (focus-test? this dangerous)
              (logtest? (process-mask guard vehicle civilian kg-robot metalhead) (-> arg0 mask))
              (and v1-1
                   (not (logtest? (-> (the-as process-focusable v1-1) focus-status) (focus-status disable dead ignore grabbed)))
                   )
              ((method-of-type touching-shapes-entry prims-touching-action?)
               (the-as touching-shapes-entry s3-0)
               (-> this root)
               (collide-action deadly)
               (collide-action)
               )
              )
         (let ((a3-2 (if ((method-of-type touching-shapes-entry prims-touching-action?)
                          (the-as touching-shapes-entry s3-0)
                          (-> this root)
                          (collide-action persistent-attack)
                          (collide-action)
                          )
                         (-> this persistent-attack-id)
                         (-> this attack-id)
                         )
                     )
               )
           (send-attack-from-tshape this arg0 (the-as touching-shapes-entry s3-0) a3-2)
           )
         )
        (else
          (send-event arg0 'touch (-> arg1 param 0))
          )
        )
      )
    )
  )

(deftype bomb-bot (bombbot)
  ()
  )


(defmethod bombbot-method-196 ((this bomb-bot) (arg0 vector))
  (let ((gp-0 (the-as process-focusable #f)))
    (let ((f30-0 (the-as float #x7f800000))
          (s4-0 (new 'stack-no-clear 'array 'collide-shape 64))
          )
      (countdown (s3-0 (fill-actor-list-for-box *actor-hash* arg0 s4-0 64))
        (let ((a0-3 (as-type (-> s4-0 s3-0) collide-shape)))
          (when a0-3
            (let ((s2-1 (as-type (-> a0-3 process) process-focusable)))
              (when (and (the-as process-focusable s2-1)
                         (and (!= this (the-as process-focusable s2-1))
                              (not (focus-test? this inactive))
                              (not (focus-test? this disable))
                              (not (focus-test? this dead))
                              (and (as-type (the-as process-focusable s2-1) bombbot)
                                   (the-as process-focusable s2-1)
                                   (not (logtest? (-> (the-as process-focusable s2-1) focus-status) (focus-status disable dead ignore grabbed)))
                                   )
                              )
                         )
                (let ((f0-0 (vector-vector-xz-distance (-> this root trans) (-> (the-as process-focusable s2-1) root trans))))
                  (when (or (not gp-0) (< f0-0 f30-0))
                    (set! gp-0 (the-as process-focusable s2-1))
                    (set! f30-0 f0-0)
                    )
                  )
                )
              )
            )
          )
        )
      )
    (cond
      (gp-0
        (vector-copy! (-> this target-pos) (get-trans gp-0 3))
        (vector+*! (-> this target-pos) (-> gp-0 root trans) (-> gp-0 root transv) 0.0)
        (vector-copy! (-> this start-target-pos) (-> this target-pos))
        (vector-copy! (-> this start-target-vel) (-> gp-0 root transv))
        (focus-on! (-> this focus) gp-0 this)
        )
      (else
        (clear-focused (-> this focus))
        )
      )
    )
  0
  (none)
  )

(defmethod go-fallback-init ((this bomb-bot))
  "If there's no specific settings for initial state, go to this state after spawning."
  (go (method-of-object this hostile))
  )

(defstate hostile (bomb-bot)
  :virtual #t
  :trans (behavior ()
    (when (< (-> self next-target) (current-time))
      (let ((a1-0 (new 'stack-no-clear 'vector)))
        (vector-copy! a1-0 (-> self root trans))
        (set! (-> a1-0 w) 409600.0)
        (bombbot-method-196 self a1-0)
        )
      (set! (-> self next-target) (+ (current-time) (seconds 4)))
      (set! (-> self gun-type) (the-as uint 0))
      0
      )
    (let ((gp-0 (the-as process-focusable (handle->process (-> self focus handle)))))
      (when gp-0
        (when (< (current-time) (+ (-> self next-target) (seconds -2)))
          (set-time! (-> self start-target))
          (vector-copy! (-> self start-target-pos) (get-trans gp-0 3))
          (vector-copy! (-> self start-target-vel) (-> gp-0 root transv))
          (vector-! (-> self target-delta) (-> gp-0 root trans) (-> self root trans))
          )
        (vector+*!
          (-> self target-pos)
          (-> self start-target-pos)
          (-> self start-target-vel)
          (* 0.0033333334 (the float (- (current-time) (-> self start-target))))
          )
        (vector-copy! (-> self target-pos) (-> self start-target-pos))
        (if (< (+ (-> self next-target) (seconds -1)) (current-time))
            (bombbot-method-197 self)
            (bombbot-method-204 self)
            )
        )
      )
    (bombbot-method-205 self)
    (new 'stack-no-clear 'vector)
    (let ((f0-4 (* 0.25 (+ (-> self feet 0 next-position y)
                           (-> self feet 1 next-position y)
                           (-> self feet 2 next-position y)
                           (-> self feet 3 next-position y)
                           )
                   )
                )
          )
      (if (!= (-> self nav state mesh) *default-nav-mesh*)
          (+! (-> self root trans y) (* 4.0 (seconds-per-frame) (- f0-4 (-> self root trans y))))
          )
      )
    (if (= (vector-length (-> self root transv)) 0.0)
        (set-time! (-> self state-time))
        )
    (bombbot-method-202 self)
    (bombbot-method-195 self)
    )
  :post (behavior ()
    (cond
      ((= (-> self nav state mesh) *default-nav-mesh*)
       (enemy-common-post self)
       (update-transforms (-> self root))
       )
      (else
        (if (logtest? (-> self nav state flags) (nav-state-flag at-target))
            (nav-enemy-method-164 self)
            )
        (vector-copy! (new 'stack-no-clear 'vector) (-> self nav state target-pos))
        (nav-enemy-method-187 self)
        )
      )
    )
  )

(defmethod init-from-entity! ((this bomb-bot) (arg0 entity-actor))
  "Set up a newly created process from the entity that created it."
  (stack-size-set! (-> this main-thread) 512)
  (init-enemy-collision! this)
  (process-drawable-from-entity! this arg0)
  (set! (-> *bombbot-nav-enemy-info* nav-mesh) *default-nav-mesh*)
  (init-enemy! this)
  (set! (-> this shot-count) (the-as uint 5))
  (vector-copy! (-> this last-trans) (-> this root trans))
  (logior! (-> this mask) (process-mask kg-robot))
  (set! (-> this minimap) #f)
  (logior! (-> this mask) (process-mask enemy))
  (set-time! (-> this stop-shoot))
  (set! (-> this shoot-duration) 1.0)
  (set! (-> this draw light-index) (the-as uint 10))
  (set! (-> this hit-points) 35.0)
  (let ((v1-19 (-> this nav state))
        (a0-13 (-> this root trans))
        )
    (logclear! (-> v1-19 flags) (nav-state-flag directional-mode))
    (logior! (-> v1-19 flags) (nav-state-flag target-poly-dirty))
    (vector-copy! (-> v1-19 target-pos) a0-13)
    )
  0
  (set! (-> this max-hit-points) (-> this hit-points))
  (go (method-of-object this hostile))
  )

(deftype bombbot-player (bombbot)
  ((camera-x-angle  float)
   (hold-fire       symbol)
   (hold-fire-time  time-frame)
   (health-hud      handle)
   )
  (:state-methods
    done
    )
  )


(defmethod move-above-ground! ((this bombbot-player) (arg0 vector) (arg1 move-above-ground-params))
  "Move the enemy. May keep the enemy snapped to the ground depending on flags."
  (let ((a1-1 (new 'stack-no-clear 'collide-query)))
    (find-ground
      (-> this root)
      a1-1
      (-> this enemy-info gnd-collide-with)
      16384.0
      81920.0
      1024.0
      (the-as process #f)
      )
    )
  (-> *math-camera* inv-camera-rot)
  (vector-copy! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot fvec))
  (new 'stack-no-clear 'vector)
  (new 'stack-no-clear 'vector)
  (new 'stack-no-clear 'vector)
  (let ((a1-2 (new 'stack-no-clear 'collide-query)))
    (new 'stack-no-clear 'vector)
    (let ((v1-10 (-> a1-2 bbox))
          (a0-6 (-> this root trans))
          (a2-2 (new 'stack-no-clear 'vector))
          )
      (set! (-> a2-2 x) 40960.0)
      (set! (-> a2-2 y) -8192.0)
      (set! (-> a2-2 z) 40960.0)
      (set! (-> a2-2 w) 1.0)
      (vector-! (-> v1-10 min) a0-6 a2-2)
      )
    (let ((v1-12 (-> a1-2 bbox max))
          (a0-8 (-> this root trans))
          (a2-3 (new 'stack-no-clear 'vector))
          )
      (set! (-> a2-3 x) 40960.0)
      (set! (-> a2-3 y) 32768.0)
      (set! (-> a2-3 z) 40960.0)
      (set! (-> a2-3 w) 1.0)
      (vector+! v1-12 a0-8 a2-3)
      )
    (set! (-> a1-2 collide-with) (collide-spec backgnd))
    (set! (-> a1-2 ignore-process0) #f)
    (set! (-> a1-2 ignore-process1) #f)
    (set! (-> a1-2 ignore-pat)
          (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
          )
    (fill-using-bounding-box *collide-cache* a1-2)
    )
  (dotimes (s4-0 (-> *collide-cache* num-tris))
    (let ((a0-11 (-> *collide-cache* tris s4-0)))
      (when (!= (-> a0-11 pat mode) (pat-mode wall))
        (mem-copy!
          (the-as pointer (-> *collide-cache* tris s4-0))
          (the-as pointer (-> *collide-cache* tris (+ (-> *collide-cache* num-tris) -1)))
          64
          )
        (+! (-> *collide-cache* num-tris) -1)
        (+! (-> *collide-cache* prims 0 num-tris) -1)
        (+! s4-0 -1)
        )
      )
    )
  (let ((v1-40 (new 'stack-no-clear 'collide-query))
        (a0-19 (-> this root))
        )
    (set! (-> v1-40 collide-with) (collide-spec backgnd))
    (set! (-> v1-40 ignore-process0) this)
    (set! (-> v1-40 ignore-process1) #f)
    (set! (-> v1-40 ignore-pat)
          (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
          )
    (set! (-> v1-40 action-mask) (collide-action solid))
    (integrate-and-collide! a0-19 arg0)
    )
  (none)
  )

;; WARN: Return type mismatch float vs none.
(defmethod enemy-common-post ((this bombbot-player))
  "Common implementation of post. Runs ja-post."
  (let ((t9-0 (method-of-type bombbot enemy-common-post)))
    (t9-0 this)
    )
  (set! (-> *game-info* health-bar) (* 100.0 (/ (-> this hit-points) (-> this max-hit-points))))
  (let ((f0-3 (* 0.25 (+ (-> this feet 0 next-position y)
                         (-> this feet 1 next-position y)
                         (-> this feet 2 next-position y)
                         (-> this feet 3 next-position y)
                         )
                 )
              )
        )
    (when (!= (-> this nav state mesh) *default-nav-mesh*)
      (+! (-> this root trans y) (* 4.0 (seconds-per-frame) (- f0-3 (-> this root trans y))))
      (if (< (-> this root trans y) (+ -12288.0 (-> this root gspot-pos y)))
          (set! (-> this root trans y) (+ -12288.0 (-> this root gspot-pos y)))
          )
      )
    )
  (none)
  )

(defmethod get-trans ((this bombbot-player) (arg0 int))
  "Get the `trans` for this process."
  (local-vars (gp-1 vector))
  (cond
    ((= arg0 4)
     (set! gp-1 (vector+*! (new 'static 'vector) (-> this root trans) *y-vector* 12288.0))
     (vector+*! gp-1 gp-1 (-> (camera-matrix) rvec) 0.0)
     )
    (else
      (set! gp-1 ((method-of-type nav-enemy get-trans) this arg0))
      )
    )
  gp-1
  )

(defmethod bombbot-method-196 ((this bombbot-player) (arg0 vector))
  (local-vars
    (sv-864 process-drawable)
    (sv-868 number)
    (sv-872 vector)
    (sv-876 vector)
    (sv-880 collide-query)
    (sv-884 (pointer collide-shape))
    (sv-888 vector)
    (sv-896 int)
    )
  (set! sv-864 (the-as process-drawable #f))
  ;; og:preserve-this
  (set! sv-868 (the-as float #x7f800000))
  (set! sv-872 (new 'stack-no-clear 'vector))
  (set! sv-876 (new 'stack-no-clear 'vector))
  (set! sv-880 (new 'stack-no-clear 'collide-query))
  (set! sv-884 (new 'stack-no-clear 'array 'collide-shape 64))
  (let ((s5-0 (new 'stack-no-clear 'vector)))
    (vector-copy! s5-0 (-> (camera-matrix) fvec))
    (set! sv-888 s5-0)
    )
  (set! sv-896 0)
  (set! (-> sv-888 y) 0.0)
  (vector-normalize! sv-888 1.0)
  (vector+*! sv-876 (camera-pos) sv-888 40960.0)
  (vector-copy! sv-876 (get-trans this 4))
  (matrix->trans (-> this node-list data 6 bone transform) sv-872)
  (set! (-> sv-876 y) (-> sv-872 y))
  (vector-normalize-copy! sv-872 sv-888 204800.0)
  (vector-copy! (-> sv-880 start-pos) sv-876)
  (vector-copy! (-> sv-880 move-dist) sv-872)
  (let ((v1-20 sv-880))
    (set! (-> v1-20 radius) 40.96)
    (set! (-> v1-20 collide-with) (collide-spec backgnd))
    (set! (-> v1-20 ignore-process0) this)
    (set! (-> v1-20 ignore-process1) #f)
    (set! (-> v1-20 ignore-pat)
          (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1)
          )
    (set! (-> v1-20 action-mask) (collide-action solid))
    )
  (let ((f0-5 (fill-and-probe-using-line-sphere *collide-cache* sv-880)))
    (if (>= f0-5 0.0)
        (vector-float*! sv-872 sv-872 f0-5)
        )
    )
  (set! sv-896 (fill-actor-list-for-sphere *actor-hash* sv-876 sv-872 40960.0 sv-884 64 -1))
  (countdown (s5-4 sv-896)
    (let ((a0-19 (as-type (-> sv-884 s5-4) collide-shape)))
      (when a0-19
        (let ((s4-1 (as-type (-> a0-19 process) process-focusable))
              (s3-1 (new 'stack-no-clear 'vector))
              )
          (when (and s4-1
                     (valid-target? this (the-as process-focusable s4-1))
                     (not (logtest? (process-mask guard) (-> s4-1 mask)))
                     (not (logtest? (process-mask civilian) (-> s4-1 mask)))
                     (not (logtest? (process-mask vehicle) (-> s4-1 mask)))
                     )
            (vector-! s3-1 (-> s4-1 root trans) (-> this root trans))
            (set! (-> s3-1 y) 0.0)
            (vector-normalize! s3-1 1.0)
            (when (< (cos 2730.6667) (vector-dot s3-1 sv-888))
              (let ((f0-8 (vector-vector-xz-distance (-> this root trans) (-> s4-1 root trans))))
                (when (and (or (not sv-864) (< f0-8 (the-as float sv-868)))
                           (< (-> s4-1 root trans y) (+ 61440.0 (-> this root trans y)))
                           )
                  (set! sv-864 s4-1)
                  (set! sv-868 f0-8)
                  )
                )
              )
            )
          )
        )
      )
    (cond
      (sv-864
        (vector-copy! (-> this target-pos) (get-trans (the-as process-focusable sv-864) 3))
        (vector-copy! (-> this start-target-pos) (-> sv-864 root trans))
        (vector-copy! (-> this start-target-vel) (-> sv-864 root transv))
        (focus-on! (-> this focus) (the-as process-focusable sv-864) this)
        )
      (else
        (vector+! (-> this target-pos) sv-876 sv-872)
        (clear-focused (-> this focus))
        )
      )
    )
  0
  (none)
  )

(defmethod bombbot-method-197 ((this bombbot-player))
  (handle->process (-> this focus handle))
  (let ((s5-0 (matrix-copy! (new 'stack-no-clear 'matrix) (-> this node-list data 6 bone transform))))
    (new 'stack-no-clear 'matrix)
    (new 'stack-no-clear 'vector)
    (let ((s4-0 (new 'stack-no-clear 'vector)))
      (let ((s3-0 (new 'stack-no-clear 'vector)))
        (new 'stack-no-clear 'vector)
        (new 'stack-no-clear 'vector)
        (matrix->trans s5-0 s3-0)
        (vector+*! s3-0 s3-0 (-> s5-0 fvec) 8192.0)
        (vector-normalize-copy! s4-0 (-> s5-0 fvec) 614400.0)
        (spawn-bombbot-projectile
          this
          s3-0
          (vector+! (new 'stack-no-clear 'vector) s3-0 s4-0)
          819200.0
          (the-as vector #f)
          3.0
          )
        (launch-particles (-> *part-id-table* 2055) s3-0)
        )
      (let ((s5-1 (new 'stack-no-clear 'vector)))
        (vector-copy! s5-1 s4-0)
        (vector-normalize! s5-1 -2048000.0)
        (vector-inv-orient-by-quat! s5-1 s5-1 (-> this root quat))
        (apply-impact!
          (-> this rigidbody)
          (rigid-body-control-method-25 (-> this rigidbody) (new 'stack-no-clear 'vector))
          s5-1
          )
        )
      )
    )
  0
  (none)
  )

(defstate hostile (bombbot-player)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy hostile) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (logior! (-> self enemy-flags) (enemy-flag lock-focus))
    (set! (-> self camera-x-angle) 25.0)
    (let ((f30-0 (* 182.04445 (-> self camera-x-angle))))
      (set-setting! 'string-min-height 'abs (+ -4096.0 (* 61440.0 (sin f30-0))) 0)
      (set-setting! 'string-max-height 'abs (+ 4096.0 (* 61440.0 (sin f30-0))) 0)
      (set-setting! 'string-min-length 'abs (+ -4096.0 (* 61440.0 (cos f30-0))) 0)
      (set-setting! 'string-max-length 'abs (+ 4096.0 (* 61440.0 (cos f30-0))) 0)
      )
    (set-setting! 'immediate-string-min-max #f 0.0 0)
    (logior! (-> self focus-status) (focus-status dangerous))
    )
  :exit (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy hostile) exit)))
      (if t9-0
          (t9-0)
          )
      )
    (sound-stop (-> self head-sound))
    (sound-stop (-> self cannon-sound))
    )
  :trans (behavior ()
    (let ((f0-1 (the float (+ (-> *cpad-list* cpads 0 righty) -128))))
      (when (< 32.0 (fabs f0-1))
        (set! (-> self camera-x-angle) (- (-> self camera-x-angle) (* 0.3 (seconds-per-frame) f0-1)))
        (if (< 25.0 (-> self camera-x-angle))
            (set! (-> self camera-x-angle) 25.0)
            )
        (if (< (-> self camera-x-angle) -4.0)
            (set! (-> self camera-x-angle) -4.0)
            )
        )
      )
    (let ((f30-0 (* 182.04445 (-> self camera-x-angle))))
      (set-setting! 'string-min-height 'abs (+ -4096.0 (* 61440.0 (sin f30-0))) 0)
      (set-setting! 'string-max-height 'abs (+ 4096.0 (* 61440.0 (sin f30-0))) 0)
      (set-setting! 'string-min-length 'abs (+ -4096.0 (* 61440.0 (cos f30-0))) 0)
      (set-setting! 'string-max-length 'abs (+ 4096.0 (* 61440.0 (cos f30-0))) 0)
      (set-setting! 'slave-options 'set 0.0 (cam-slave-options BOMBBOT))
      (if *camera*
          (vector-normalize! (-> *camera* slave 0 view-flat) (+ 4096.0 (* 61440.0 (cos f30-0))))
          )
      )
    (set-setting! 'immediate-string-min-max #f 0.0 0)
    (let* ((v1-45 *game-info*)
           (a0-13 (+ (-> v1-45 attack-id) 1))
           )
      (set! (-> v1-45 attack-id) a0-13)
      (set! (-> self attack-id) a0-13)
      )
    (vector+*! (-> self target-pos) (camera-pos) (-> (camera-matrix) fvec) 204800.0)
    (let ((a1-7 (new 'stack-no-clear 'vector)))
      (vector-copy! a1-7 (-> self root trans))
      (set! (-> a1-7 w) 204800.0)
      (bombbot-method-196 self a1-7)
      )
    (set! (-> self next-target) (+ (current-time) (seconds 2)))
    (set-time! (-> self start-target))
    (cond
      ((and (-> self hold-fire) (>= (+ (current-time) (seconds -0.3)) (-> self hold-fire-time)))
       (+! (-> self extra-angle-gun) (* -8192.0 (seconds-per-frame)))
       (if (< (-> self extra-angle-gun) -3640.889)
           (set! (-> self extra-angle-gun) -3640.889)
           )
       )
      (else
        (+! (-> self extra-angle-gun) (* 18204.445 (seconds-per-frame)))
        (if (< 0.0 (-> self extra-angle-gun))
            (set! (-> self extra-angle-gun) 0.0)
            )
        (bombbot-method-204 self)
        )
      )
    (when (handle->process (-> self focus handle))
      )
    (when (and (cpad-pressed? 0 r1) (>= (+ (current-time) (seconds -0.02)) (-> self next-shoot)))
      (set-time! (-> self next-shoot))
      (bombbot-method-197 self)
      )
    (bombbot-method-205 self)
    (if (= (vector-length (-> self root transv)) 0.0)
        (set-time! (-> self state-time))
        )
    (bombbot-method-202 self)
    (bombbot-method-195 self)
    (send-event *camera* 'change-target self)
    )
  :code (behavior ()
    (local-vars (v1-1 object))
    (until v1-1
      (suspend)
      (set! v1-1
            (and *target* (not (focus-test? *target* teleporting)) (send-event *target* 'change-mode 'grab-ride #t))
            )
      )
    (until #f
      (ja-no-eval :group! (-> self draw art-group data 3) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post (behavior ()
    (new 'stack-no-clear 'vector)
    (-> self root)
    (cond
      ((= (-> self nav state mesh) *default-nav-mesh*)
       (enemy-common-post self)
       (update-transforms (-> self root))
       )
      (else
        (-> *math-camera* inv-camera-rot)
        (let ((gp-0 (new 'stack-no-clear 'vector)))
          (vector-copy! gp-0 (-> *math-camera* inv-camera-rot fvec))
          (let ((s5-0 (new 'stack-no-clear 'vector)))
            (new 'stack-no-clear 'vector)
            (let ((s4-0 (new 'stack-no-clear 'vector)))
              (set! (-> gp-0 y) 0.0)
              (vector-normalize! gp-0 1.0)
              (vector-rotate90-around-y! s4-0 gp-0)
              (vector-cross! gp-0 (-> self root gspot-normal) s4-0)
              )
            (vector-rotate-around-y! gp-0 gp-0 (-> *cpad-list* cpads 0 stick0-dir))
            (vector+*! s5-0 (-> self root trans) gp-0 (* 12288.0 (-> *cpad-list* cpads 0 stick0-speed)))
            (set! (-> self root transv y) 0.0)
            (when (< 0.4 (-> *cpad-list* cpads 0 stick0-speed))
              (let ((v1-25 (-> self nav state)))
                (logclear! (-> v1-25 flags) (nav-state-flag directional-mode))
                (logior! (-> v1-25 flags) (nav-state-flag target-poly-dirty))
                (vector-copy! (-> v1-25 target-pos) s5-0)
                )
              0
              (when *target*
                (quaternion-look-at! (-> *target* control dir-targ) gp-0 *up-vector*)
                (quaternion-look-at! (-> *target* control quat) gp-0 *up-vector*)
                )
              )
            )
          )
        (let ((v1-35 (-> self nav)))
          (set! (-> v1-35 target-speed) (* 49152.0 (-> *cpad-list* cpads 0 stick0-speed)))
          )
        0
        (nav-enemy-method-187 self)
        )
      )
    )
  )

(defstate explode (bombbot-player)
  :virtual #t
  :code (behavior ()
    (send-event (handle->process (-> self health-hud)) 'hide-and-die)
    (while (-> self child)
      (suspend)
      )
    (cleanup-for-death self)
    )
  )

(defstate done (bombbot-player)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('dead)
       #t
       )
      )
    )
  :code sleep-code
  )

;; WARN: Return type mismatch none vs sound-id.
(defmethod play-damage-sound ((this bombbot-player) (arg0 int))
  "Pick and play the damage/death sound."
  ((method-of-type bombbot play-damage-sound) this arg0)
  (the-as sound-id (if (zero? arg0)
                       (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.3))
                       )
          )
  )

(defbehavior bombbot-player-init-by-other bombbot-player ((arg0 bombbot-spawn-params))
  (stack-size-set! (-> self main-thread) 512)
  (set! (-> self city-path) (-> arg0 path))
  (set! (-> self current-node) (the-as uint 0))
  (init-enemy-collision! self)
  (vector-copy! (-> self root trans) (-> arg0 position))
  (quaternion-copy! (-> self root quat) (-> arg0 quat))
  (vector-identity! (-> self root scale))
  (-> arg0 nav-mesh)
  (set! (-> *bombbot-nav-enemy-info* nav-mesh) *default-nav-mesh*)
  (init-enemy! self)
  (set! (-> self gun-rotation-speed) 7281.778)
  (set! (-> self shot-count) (the-as uint 5))
  (vector-copy! (-> self last-trans) (-> self root trans))
  (set! (-> self minimap) #f)
  (logior! (-> self mask) (process-mask enemy guard))
  (send-event *camera* 'change-target self)
  (send-event
    *camera*
    'teleport-to-vector-start-string
    (vector+*! (new 'stack-no-clear 'vector) (-> arg0 position) *z-vector* 40960.0)
    )
  (set! (-> self shoot-duration) 1.0)
  (set! (-> self hold-fire) #f)
  (set! (-> self draw light-index) (the-as uint 10))
  (set! (-> self max-hit-points) (the float (+ (* 50 (the int (you-suck-scale *game-info* #f 0))) 50)))
  (set! (-> self hit-points) (-> self max-hit-points))
  (set! (-> self health-hud)
        (ppointer->handle (process-spawn bombbot-hud :init hud-init-by-other :name "bombbot-hud" :to self))
        )
  (set! (-> self mission-squad) *cty-attack-controller*)
  (when (-> self mission-squad)
    (set! (-> self attacker-info) (allocate-attacker (-> self mission-squad)))
    (init! (-> self attacker-info) self 13)
    (set! (-> self attacker-info max-num-attackers) (the-as uint 16))
    (logior! (-> self attacker-info flags) (city-attacker-info-flag cai1 cai4))
    )
  (go-virtual hostile)
  )

(deftype task-manager-blow-barricade (task-manager)
  ((check-timer        time-frame)
   (bombbot-h          handle)
   (actor-group        (pointer actor-group))
   (actor-group-count  int32)
   (done?              int32)
   (minimap            connection-minimap)
   (wall-h             handle)
   (start-point        vector  :inline)
   )
  (:methods
    (task-manager-blow-barricade-method-32 (_type_) none)
    )
  )


(defstate active (task-manager-blow-barricade)
  :virtual #t
  :parent (task-manager-blow-barricade active)
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('checkpoint)
       #f
       )
      (else
        (task-manager-event-handler proc argc message block)
        )
      )
    )
  :enter (behavior ()
    (set-time! (-> self state-time))
    )
  :exit (behavior ()
    (remove-setting! 'entity-name)
    )
  :trans (behavior ()
    (let ((gp-0 (entity-by-name "krimson-wall-6")))
      (when gp-0
        (if (not (-> self wall-h))
            (set! (-> self wall-h)
                  (ppointer->handle
                    (process-spawn krimson-wall-break gp-0 'lbombbot :name "krimson-wall-break" :to *entity-pool*)
                    )
                  )
            )
        )
      )
    (if (and (zero? (-> self done?)) (not (handle->process (-> self bombbot-h))))
        (send-event self 'fail)
        )
    (let ((s3-0 (new 'static 'vector :x 4199997.5 :y 30146.56 :z 1763819.5 :w 1.0))
          (s4-0 (new 'stack-no-clear 'vector))
          (gp-1 (new 'stack-no-clear 'vector))
          (s5-1 (new 'stack-no-clear 'vector))
          )
      (vector-copy! s5-1 (target-pos 0))
      (if (and (< 4096000.0 (vector-vector-distance s5-1 s3-0))
               (< 819200.0 (vector-vector-distance s5-1 (-> self start-point)))
               )
          (send-event self 'fail)
          )
      (vector+! s4-0 s3-0 (new 'static 'vector :z -163840.0 :w 1.0))
      (vector+! gp-1 s3-0 (new 'static 'vector :x 102400.0 :z 163840.0 :w 1.0))
      (when (and (zero? (-> self done?))
                 (< (-> s4-0 x) (-> s5-1 x))
                 (< (-> s4-0 z) (-> s5-1 z))
                 (< (-> s5-1 x) (-> gp-1 x))
                 (< (-> s5-1 z) (-> gp-1 z))
                 )
        (set! (-> self done?) 1)
        (set-setting! 'entity-name "camera-305" 0.0 0)
        (send-event (handle->process (-> self bombbot-h)) 'blow-wall)
        )
      )
    (when (= (-> self done?) 1)
      (let ((v1-48 (handle->process (-> self bombbot-h))))
        (when (and v1-48 (-> v1-48 next-state) (= (-> v1-48 next-state name) 'explode))
          (set! (-> self done?) 2)
          (let ((v1-55 (entity-by-name "krimson-wall-6")))
            (if v1-55
                (send-event (-> v1-55 extra process) 'break)
                )
            )
          (send-event (handle->process (-> self wall-h)) 'break)
          )
        )
      )
    (when (= (-> self done?) 2)
      (when (send-event (handle->process (-> self wall-h)) 'done)
        (when (process-release? *target*)
          (send-event *target* 'continue (get-continue-by-name *game-info* "hiphog-start"))
          (send-event self 'complete)
          )
        )
      )
    )
  :code sleep-code
  )

(defmethod task-manager-blow-barricade-method-32 ((this task-manager-blow-barricade))
  0
  (none)
  )

(define *blow-barricade-kg-squad-member-settings* (new 'static 'inline-array kg-squad-member-settings 4
                                                    (new 'static 'kg-squad-member-settings
                                                      :object-type (traffic-type roboguard)
                                                      :max-target-count #x7f
                                                      :target-count 3
                                                      :enemy-type (traffic-type guard-a)
                                                      )
                                                    (new 'static 'kg-squad-member-settings
                                                      :object-type (traffic-type roboguard)
                                                      :max-target-count #x7f
                                                      :enemy-type (traffic-type guard-b)
                                                      )
                                                    (new 'static 'kg-squad-member-settings
                                                      :object-type (traffic-type flying-turret)
                                                      :max-target-count #x7f
                                                      :target-count 3
                                                      :enemy-type (traffic-type metalhead-grunt)
                                                      )
                                                    (new 'static 'kg-squad-member-settings
                                                      :object-type (traffic-type spydroid)
                                                      :max-target-count #x7f
                                                      :target-count 3
                                                      :enemy-type (traffic-type metalhead-flitter)
                                                      )
                                                    )
        )

;; WARN: Return type mismatch connection vs none.
(defmethod set-time-limit ((this task-manager-blow-barricade))
  (let ((t9-0 (method-of-type task-manager set-time-limit)))
    (t9-0 this)
    )
  (set! (-> this wall-h) (the-as handle #f))
  (set-setting! 'music 'blowbarr 0.0 0)
  (set! (-> this minimap) (add-icon!
                            *minimap*
                            this
                            (the-as uint 12)
                            (the-as int #f)
                            (new 'static 'vector :x 4199997.5 :y 30146.56 :z 1763819.5 :w 1.0)
                            0
                            )
        )
  (set-setting! 'airlock #f 0.0 0)
  (set-setting! 'city-sound '(citybbf) 0.0 2)
  (set-setting! 'disable-parking-spots? #t 0.0 0)
  (when *cty-attack-controller*
    (let ((s5-0 (push-back-hatred *cty-attack-controller*)))
      (set! (-> s5-0 hatred) 0.6)
      (set! (-> s5-0 hatred-dist) 245760.0)
      (set! (-> s5-0 dist-scale) 0.5)
      (set! (-> s5-0 attacker-scale) 0.01)
      (set! (-> s5-0 max-consider-dist) 614400.0)
      (set-hatred-indices-for-all *cty-attack-controller* 0 (get-hatred-at-idx *cty-attack-controller* 9 0) s5-0 13)
      )
    )
  (set-vector! (-> this start-point) 2538700.8 31539.2 6048399.5 1.0)
  (when (or (zero? (-> this bombbot-h)) (not (handle->process (-> this bombbot-h))))
    (let ((s5-1 (new 'stack 'bombbot-spawn-params)))
      (set! (-> s5-1 nav-mesh) (get-nav-mesh (the-as actor-id #x48e9)))
      (vector-copy! (-> s5-1 position) (-> this start-point))
      (vector-copy! (-> s5-1 position) (target-pos 0))
      (quaternion-copy! (-> s5-1 quat) (new 'static 'quaternion :y 0.841 :w 0.5409))
      (set! (-> this bombbot-h)
            (ppointer->handle (process-spawn bombbot-player s5-1 :name "bombbot-player" :to this))
            )
      )
    )
  (set! (-> this done?) 0)
  (set-setting! 'pickups #f 0.0 0)
  (none)
  )

(deftype task-manager-port-fight (task-manager)
  ((check-timer         time-frame)
   (bombbot-h           handle  4)
   (actor-group         (pointer actor-group))
   (actor-group-count   int32)
   (done?               int32)
   (minimap             connection-minimap)
   (min-time            uint32)
   (intro-state         int32   :offset 312)
   (target-far-enough?  symbol  :offset 328)
   )
  (:state-methods
    fail-screen
    )
  (:methods
    (add-danger (_type_) none)
    )
  )


;; WARN: Return type mismatch object vs none.
(defmethod task-manager-method-26 ((this task-manager-port-fight))
  (if (not (-> this target-far-enough?))
      (add-danger this)
      )
  (cond
    ((zero? (-> this intro-state))
     (set! (-> this intro-time) (+ (current-time) (seconds 2)))
     (+! (-> this intro-state) 1)
     )
    ((= (-> this intro-state) 1)
     (if (< (-> this intro-time) (current-time))
         (+! (-> this intro-state) 1)
         )
     )
    ((= (-> this intro-state) 2)
     (set-setting! 'mode-name 'cam-really-fixed 0.0 0)
     (set-setting! 'interp-time 'abs 0.0 0)
     (if (process-grab? *target* #f)
         (+! (-> this intro-state) 1)
         )
     )
    ((= (-> this intro-state) 3)
     (set-setting! 'interp-time 'abs 150.0 0)
     (+! (-> this intro-state) 1)
     )
    ((= (-> this intro-state) 4)
     (send-event *camera* 'change-target (handle->process (-> this bombbot-h 1)))
     (+! (-> this intro-state) 1)
     (set! (-> this intro-time) (+ (current-time) (seconds 3)))
     (sound-play "bb-cam-out")
     (persist-with-delay *setting-control* 'blur-a (seconds 1) 'blur-a 'abs 0.5 0)
     )
    ((= (-> this intro-state) 5)
     (remove-setting! 'mode-name)
     (when (< (-> this intro-time) (current-time))
       (remove-setting! 'interp-time)
       (set-setting! 'mode-name 'cam-really-fixed 0.0 0)
       (set-setting! 'interp-time 'abs 0.0 0)
       (+! (-> this intro-state) 1)
       )
     )
    ((= (-> this intro-state) 6)
     (set-setting! 'interp-time 'abs 150.0 0)
     (+! (-> this intro-state) 1)
     )
    ((= (-> this intro-state) 7)
     (send-event *camera* 'change-target *target*)
     (+! (-> this intro-state) 1)
     (sound-play "bb-cam-in")
     (persist-with-delay *setting-control* 'blur-a (seconds 1) 'blur-a 'abs 0.5 0)
     )
    ((= (-> this intro-state) 8)
     (remove-setting! 'mode-name)
     (when (< (-> this intro-time) (current-time))
       (remove-setting! 'interp-time)
       (if (process-release? *target*)
           (+! (-> this intro-state) 1)
           )
       )
     )
    )
  (when (and (-> this next-state) (= (-> this next-state name) 'active))
    (let ((s5-2 0))
      (let ((s4-2 10000))
        (dotimes (s3-0 3)
          (when (-> this bombbot-h s3-0)
            (let ((s2-0 (as-type (handle->process (-> this bombbot-h s3-0)) bombbot)))
              (when s2-0
                (+! s5-2 1)
                (let ((v1-114
                        (the int (* 0.000030517578 (vector-vector-xz-distance
                                                     (-> s2-0 root trans)
                                                     (-> s2-0 city-path node (+ (-> s2-0 city-path node-count) -1) position)
                                                     )
                                    )
                             )
                        )
                      )
                  (if (< v1-114 s4-2)
                      (set! s4-2 v1-114)
                      )
                  )
                (when (= (-> s2-0 current-node) (+ (-> s2-0 city-path node-count) -1))
                  )
                )
              )
            )
          )
        (set! (-> this min-time) (the-as uint s4-2))
        (cond
          ((< s4-2 10)
           (set! (-> *game-info* timer) (the-as time-frame (the int (* 300.0 (the float s4-2)))))
           (if (not (-> this hud-timer))
               (set! (-> this hud-timer)
                     (ppointer->handle (process-spawn hud-timer :init hud-init-by-other :name "hud-timer" :to this))
                     )
               )
           (if (zero? s4-2)
               (go (method-of-object this fail-screen))
               )
           )
          (else
            (when (handle->process (-> this hud-timer))
              (send-event (handle->process (-> this hud-timer)) 'hide-and-die)
              (set! (-> this hud-timer) (the-as handle #f))
              )
            )
          )
        )
      (if (zero? s5-2)
          (send-event this 'complete)
          )
      )
    )
  (none)
  )

(defstate active (task-manager-port-fight)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type task-manager active) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (let ((gp-0 (new 'stack 'bombbot-spawn-params)))
      (quaternion-copy! (-> gp-0 quat) (new 'static 'quaternion :y 0.841 :w 0.5409))
      (set! (-> gp-0 path) *bombbot-path-1*)
      (set! (-> gp-0 first-node) (the-as uint 4))
      (set! (-> gp-0 stop-offset) 1500.0)
      (set! (-> self bombbot-h 0) (ppointer->handle (process-spawn bombbot gp-0 :name "bombbot" :to self)))
      (set! (-> gp-0 path) *bombbot-path-2*)
      (set! (-> gp-0 first-node) (the-as uint 0))
      (set! (-> gp-0 stop-offset) 1500.0)
      (set! (-> self bombbot-h 1) (ppointer->handle (process-spawn bombbot gp-0 :name "bombbot" :to self)))
      (set! (-> gp-0 path) *bombbot-path-3*)
      (set! (-> gp-0 first-node) (the-as uint 0))
      (set! (-> gp-0 stop-offset) 2100.0)
      (set! (-> self bombbot-h 2) (ppointer->handle (process-spawn bombbot gp-0 :name "bombbot" :to self)))
      )
    )
  )

(defstate fail-screen (task-manager-port-fight)
  :virtual #t
  :parent (task-manager-port-fight active)
  :code (behavior ()
    (when (and *target* (not (logtest? (-> *target* focus-status) (focus-status dead))))
      (cond
        ((= (level-status? *level* 'ctyport #f) 'active)
         (set-setting! 'entity-name "camera-321" 0.0 0)
         (set-setting! 'minimap 'clear 0.0 (minimap-flag minimap))
         (set-time! (-> self state-time))
         (while (not (time-elapsed? (-> self state-time) (seconds 2)))
           (suspend)
           )
         (add-process *gui-control* self (gui-channel sig) (gui-action play) "bbotxplo" -99.0 0)
         (dotimes (gp-1 3)
           (let ((s5-0 (handle->process (-> self bombbot-h gp-1))))
             (when s5-0
               (if (type? s5-0 bombbot)
                   (send-event s5-0 'explode)
                   )
               )
             )
           )
         (set-time! (-> self state-time))
         (while (not (time-elapsed? (-> self state-time) (seconds 0.3)))
           (suspend)
           )
         (setup
           *screen-filter*
           (new 'static 'vector :x 255.0 :y 255.0 :z 255.0)
           (new 'static 'vector :x 255.0 :y 255.0 :z 255.0 :w 128.0)
           (seconds-per-frame)
           (bucket-id tex-hud-hud-alpha)
           #x3fffff
           #x33001
           #t
           )
         (while (not (time-elapsed? (-> self state-time) (seconds 1)))
           (suspend)
           )
         (set-setting! 'interp-time 'abs 0.0 0)
         (remove-setting! 'entity-name)
         )
        (else
          )
        )
      )
    (send-event self 'fail)
    (sleep-code)
    )
  )

;; WARN: Return type mismatch symbol vs none.
(defmethod task-manager-method-25 ((this task-manager-port-fight))
  (let ((t9-0 (method-of-type task-manager task-manager-method-25)))
    (t9-0 this)
    )
  (disable *screen-filter*)
  (when (-> this hud-timer)
    (send-event (handle->process (-> this hud-timer)) 'hide-and-die)
    (set! (-> this hud-timer) (the-as handle #f))
    )
  (none)
  )

(defmethod add-danger ((this task-manager-port-fight))
  (when *traffic-engine*
    (let ((gp-0 (new 'stack-no-clear 'traffic-danger-info)))
      (set! (-> gp-0 sphere quad) (-> (new 'static 'vector :x -242360.31 :y 31621.12 :z 5512233.0 :w 1.0) quad))
      (if (< 614400.0 (vector-vector-xz-distance (target-pos 0) (-> gp-0 sphere)))
          (set! (-> this target-far-enough?) #t)
          )
      (set! (-> gp-0 sphere r) 819200.0)
      (vector-reset! (-> gp-0 velocity))
      (set! (-> gp-0 notify-radius) 819200.0)
      (set! (-> gp-0 danger-level) 1.0)
      (set! (-> gp-0 decay-rate) 0.0)
      (set! (-> gp-0 flags) (the-as uint 1))
      (set! (-> gp-0 danger-type) (the-as uint 0))
      (add-danger *traffic-engine* gp-0)
      )
    )
  0
  (none)
  )

(defstate wait (task-manager-port-fight)
  :virtual #t
  :code (behavior ()
    (while (or (not *target*) (not *spawn-actors*))
      (suspend)
      )
    (set-time-limit self)
    (while (or (not (level-get-target-inside *level*)) (!= (-> (level-get-target-inside *level*) name) 'ctyport))
      (suspend)
      )
    (set-setting! 'airlock #f 0.0 0)
    (go-virtual active)
    )
  )

(defmethod set-time-limit ((this task-manager-port-fight))
  (let ((t9-0 (method-of-type task-manager set-time-limit)))
    (t9-0 this)
    )
  (set! *bombbot-hint* (the-as sound-id 1))
  (set! *bombbot-hint-time* 0.0)
  (set! (-> this bombbot-h 0) (the-as handle #f))
  (set! (-> this bombbot-h 1) (the-as handle #f))
  (set! (-> this bombbot-h 2) (the-as handle #f))
  (set! (-> this bombbot-h 3) (the-as handle #f))
  (set-setting! 'city-sound '(citybbh) 0.0 2)
  (set-setting! 'music 'cityfi 0.0 0)
  (set! (-> this hud-timer) (the-as handle #f))
  (set! (-> this target-far-enough?) #f)
  (add-danger this)
  (set! (-> this done?) 0)
  0
  (none)
  )
