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

;; name: monster-frog.gc
;; name in dgo: monster-frog
;; dgos: TOA

;; DECOMP BEGINS

(defskelgroup skel-monster-frog monster-frog monster-frog-lod0-jg monster-frog-idle0-ja
              ((monster-frog-lod0-mg (meters 20)) (monster-frog-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 5)
              :shadow monster-frog-shadow-mg
              :origin-joint-index 12
              )

(deftype monster-frog (nav-enemy)
  ()
  (:state-methods
    (attack vector)
    attack-recover
    turn
    )
  )


(define *monster-frog-nav-enemy-info*
  (new 'static 'nav-enemy-info
    :use-die-falling #f
    :use-victory #f
    :use-jump-blocked #t
    :debug-draw-neck #f
    :jump-debug-draw #f
    :move-to-ground #t
    :hover-if-no-ground #f
    :idle-anim-script (new 'static 'array idle-control-frame 8
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x4 :param0 #x2 :param1 #x3)
      (new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
      (new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x2)
      (new 'static 'idle-control-frame)
      (new 'static 'idle-control-frame)
      (new 'static 'idle-control-frame)
      (new 'static 'idle-control-frame)
      )
    :idle-anim 4
    :notice-anim 8
    :hostile-anim 18
    :hit-anim 30
    :knocked-anim 30
    :knocked-land-anim 31
    :die-anim 4
    :die-falling-anim 4
    :victory-anim -1
    :jump-wind-up-anim -1
    :jump-in-air-anim -1
    :jump-land-anim -1
    :neck-joint 5
    :look-at-joint 5
    :bullseye-joint 4
    :sound-hit (static-sound-name "monster-frog-hi")
    :sound-die (static-sound-name "monster-frog-di")
    :notice-distance (meters 40)
    :notice-distance-delta (meters 10)
    :proximity-notice-distance (meters 40)
    :default-hit-points 1
    :gnd-collide-with (collide-spec backgnd)
    :overlaps-others-collide-with-filter (collide-spec jak bot player-list)
    :penetrate-knocked (penetrate
      generic-attack
      flop
      punch
      spin
      roll
      uppercut
      bonk
      tube
      vehicle
      flut-attack
      board
      mech-punch
      mech-bonk
      dark-skin
      dark-punch
      dark-bomb
      dark-giant
      shield
      explode
      jak-yellow-shot
      jak-red-shot
      jak-blue-shot
      jak-dark-shot
      enemy-yellow-shot
      enemy-dark-shot
      eco-yellow
      knocked
      )
    :movement-gravity (meters -100)
    :friction 0.8
    :attack-shove-back (meters 3)
    :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)
    :jump-height-min (meters 2.87)
    :jump-height-factor 0.1
    :knocked-seek-ry-clamp 4551.1113
    :knocked-soft-vxz-lo 75776.0
    :knocked-soft-vxz-hi 75776.0
    :knocked-soft-vy-lo 81920.0
    :knocked-soft-vy-hi 81920.0
    :knocked-medium-vxz-lo 147456.0
    :knocked-medium-vxz-hi 196608.0
    :knocked-medium-vy-lo 135168.0
    :knocked-medium-vy-hi 151552.0
    :knocked-hard-vxz-lo 79872.0
    :knocked-hard-vxz-hi 79872.0
    :knocked-hard-vy-lo 183500.8
    :knocked-hard-vy-hi 209715.2
    :knocked-huge-vxz-lo 164659.2
    :knocked-huge-vxz-hi 249036.8
    :knocked-huge-vy-lo 183500.8
    :knocked-huge-vy-hi 217907.2
    :knocked-yellow-vxz-lo 75776.0
    :knocked-yellow-vxz-hi 75776.0
    :knocked-yellow-vy-lo 81920.0
    :knocked-yellow-vy-hi 81920.0
    :knocked-red-vxz-lo 73728.0
    :knocked-red-vxz-hi 73728.0
    :knocked-red-vy-lo 96256.0
    :knocked-red-vy-hi 96256.0
    :knocked-blue-vxz-lo 40960.0
    :knocked-blue-vxz-hi 49152.0
    :knocked-blue-vy-lo 24576.0
    :knocked-blue-vy-hi 81920.0
    :shadow-size (meters 2)
    :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)
    :callback-info #f
    :use-momentum #f
    :use-frustration #t
    :use-stop-chase #f
    :use-circling #t
    :use-pacing #t
    :walk-anim 16
    :turn-anim 16
    :run-anim 18
    :taunt-anim -1
    :run-travel-speed (meters 18)
    :run-acceleration (meters 10)
    :run-turning-acceleration (meters 80)
    :walk-travel-speed (meters 11.44)
    :walk-acceleration (meters 5)
    :walk-turning-acceleration (meters 20)
    :maximum-rotation-rate (degrees 360)
    :notice-nav-radius (meters 1.5)
    :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! (-> *monster-frog-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)

;; WARN: new jak 2 until loop case, check carefully
(defbehavior monster-frog-hop-slow-code monster-frog ()
  (until #f
    (let ((v1-0 self))
      (set! (-> v1-0 enemy-flags) (the-as enemy-flag (logclear (-> v1-0 enemy-flags) (enemy-flag enemy-flag36))))
      (set! (-> v1-0 nav callback-info) *nav-enemy-null-callback-info*)
      )
    0
    (dotimes (gp-0 (rnd-int-range self 2 3))
      (cond
        ((zero? (rnd-int-count self 4))
         (let ((v1-7 (ja-group)))
           (if (not (and v1-7 (= v1-7 monster-frog-idle0-ja)))
               (ja-channel-push! 1 (seconds 0.1))
               )
           )
         (ja-no-eval :group! monster-frog-idle0-ja :num! (seek!) :frame-num 0.0)
         (until (ja-done? 0)
           (suspend)
           (ja :num! (seek!))
           )
         )
        (else
          (let ((v1-38 (ja-group)))
            (if (not (and v1-38 (= v1-38 monster-frog-idle1-ja)))
                (ja-channel-push! 1 (seconds 0.1))
                )
            )
          (ja-no-eval :group! monster-frog-idle1-ja :num! (seek!) :frame-num 0.0)
          (until (ja-done? 0)
            (suspend)
            (ja :num! (seek!))
            )
          )
        )
      )
    (let ((v1-71 self))
      (if (not (logtest? (enemy-flag enemy-flag36) (-> v1-71 enemy-flags)))
          (set! (-> v1-71 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-71 enemy-flags))))
          )
      (set! (-> v1-71 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-71 enemy-flags))))
      (set! (-> v1-71 nav callback-info) (-> v1-71 enemy-info callback-info))
      )
    0
    (ja-channel-push! 1 (seconds 0.035))
    (let ((v1-74 self))
      (set! (-> v1-74 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-74 enemy-flags))))
      )
    0
    (nav-enemy-method-165 self)
    (let ((v1-78 (-> self nav)))
      (set! (-> v1-78 target-speed) (* 1.4 (-> self enemy-info walk-travel-speed)))
      )
    0
    (let ((v1-80 self))
      (set! (-> v1-80 enemy-flags) (the-as enemy-flag (logclear (-> v1-80 enemy-flags) (enemy-flag enemy-flag37))))
      )
    0
    (ja-no-eval :group! monster-frog-hop-slow-start-ja :num! (seek! max 1.4) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek! max 1.4))
      )
    (nav-enemy-method-167 self)
    (ja-no-eval :group! monster-frog-hop-slow-end-ja :num! (seek! max 1.4) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek! max 1.4))
      )
    )
  #f
  )

;; WARN: new jak 2 until loop case, check carefully
(defbehavior monster-frog-hop-fast-code monster-frog ()
  (until #f
    (nav-enemy-method-166 self)
    (ja-no-eval :group! monster-frog-hop-slow-start-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (nav-enemy-method-167 self)
    (ja-no-eval :group! monster-frog-hop-slow-end-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    )
  #f
  )

(defstate ambush (monster-frog)
  :virtual #t
  :enter (behavior ()
    (when (logtest? (-> self enemy-flags) (enemy-flag enable-on-notice))
      (logclear! (-> self enemy-flags) (enemy-flag enable-on-notice))
      (let ((gp-0 (-> self on-notice)))
        (if gp-0
            (script-eval gp-0 :vector (-> self root trans))
            )
        )
      )
    (let ((v1-12 (-> self root root-prim)))
      (set! (-> v1-12 prim-core collide-as) (collide-spec))
      (set! (-> v1-12 prim-core collide-with) (collide-spec))
      )
    0
    (logior! (-> self draw status) (draw-control-status no-draw))
    )
  :code (behavior ()
    (enemy-method-129 self)
    (let ((a0-2 (handle->process (-> self focus handle))))
      (when a0-2
        (let* ((gp-0 (-> self root))
               (s3-0
                 (vector-normalize!
                   (vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable a0-2) 0) (-> gp-0 trans))
                   1.0
                   )
                 )
               (f0-0 (deg-diff (quaternion-y-angle (-> gp-0 quat)) (vector-y-angle s3-0)))
               )
          (quaternion-rotate-y! (-> gp-0 quat) (-> gp-0 quat) f0-0)
          )
        )
      )
    (logclear! (-> self draw status) (draw-control-status no-draw))
    (ja-no-eval :group! monster-frog-popup0-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (let ((v1-37 (-> self root root-prim)))
      (set! (-> v1-37 prim-core collide-as) (-> self root backup-collide-as))
      (set! (-> v1-37 prim-core collide-with) (-> self root backup-collide-with))
      )
    (react-to-focus self)
    )
  :post nav-enemy-simple-post
  )

(defstate notice (monster-frog)
  :virtual #t
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.075))
    (let ((f30-0 (rnd-float-range self 0.8 1.2)))
      (new 'stack-no-clear 'vector)
      (ja-no-eval :group! monster-frog-notice0-ja :num! (seek! max f30-0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max f30-0))
        )
      (ja-no-eval :group! monster-frog-notice0-jump-ja :num! (seek! max f30-0) :frame-num 0.0)
      (until (ja-done? 0)
        (let ((a0-7 (handle->process (-> self focus handle))))
          (if a0-7
              (seek-to-point-toward-point!
                (-> self root)
                (get-trans (the-as process-focusable a0-7) 0)
                (* 98304.0 f30-0)
                (seconds 0.02)
                )
              )
          )
        (suspend)
        (ja :num! (seek! max f30-0))
        )
      (ja-no-eval :group! monster-frog-notice0-land-ja :num! (seek! max f30-0) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max f30-0))
        )
      )
    (react-to-focus self)
    )
  )

(defstate active (monster-frog)
  :virtual #t
  :code (behavior ()
    (let ((f30-0 (rnd-float-range self 0.9 1.1)))
      (until #f
        (nav-enemy-method-165 self)
        (ja-channel-push! 1 (seconds 0.2))
        (ja-no-eval :group! monster-frog-hop-slow-start-ja :num! (seek! max f30-0) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek! max f30-0))
          )
        (nav-enemy-method-167 self)
        (ja-no-eval :group! monster-frog-hop-slow-end-ja :num! (seek! max f30-0) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek! max f30-0))
          )
        (when (rnd-go-idle? self 0.2)
          (ja-no-eval :num! (loop!))
          (ja-channel-push! 1 (seconds 0.6))
          (let ((v1-57 self))
            (set! (-> v1-57 enemy-flags) (the-as enemy-flag (logclear (-> v1-57 enemy-flags) (enemy-flag enemy-flag36))))
            (set! (-> v1-57 nav callback-info) *nav-enemy-null-callback-info*)
            )
          0
          (nav-enemy-method-167 self)
          (ja-no-eval :group! (-> self draw art-group data (-> self enemy-info idle-anim))
                      :num! (seek! max f30-0)
                      :frame-num 0.0
                      )
          (until (ja-done? 0)
            (ja-blend-eval)
            (suspend)
            (ja :num! (seek! max f30-0))
            )
          (until (not (rnd-go-idle? self 0.2))
            (ja-no-eval :group! (-> self draw art-group data (-> self enemy-info idle-anim))
                        :num! (seek! max f30-0)
                        :frame-num 0.0
                        )
            (until (ja-done? 0)
              (suspend)
              (ja :num! (seek! max f30-0))
              )
            )
          (let ((v1-121 self))
            (if (not (logtest? (enemy-flag enemy-flag36) (-> v1-121 enemy-flags)))
                (set! (-> v1-121 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-121 enemy-flags))))
                )
            (set! (-> v1-121 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-121 enemy-flags))))
            (set! (-> v1-121 nav callback-info) (-> v1-121 enemy-info callback-info))
            )
          0
          (nav-enemy-method-165 self)
          (ja-no-eval :num! (loop!))
          (ja-channel-push! 1 (seconds 0.6))
          (ja-no-eval :group! (-> self draw art-group data (-> self enemy-info walk-anim))
                      :num! (seek! max f30-0)
                      :frame-num 0.0
                      )
          (until (ja-done? 0)
            (ja-blend-eval)
            (suspend)
            (ja :num! (seek! max f30-0))
            )
          )
        )
      )
    #f
    )
  )

(defstate pacing (monster-frog)
  :virtual #t
  :code monster-frog-hop-slow-code
  )

(defstate circling (monster-frog)
  :virtual #t
  :code monster-frog-hop-slow-code
  )

(defstate stare (monster-frog)
  :virtual #t
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type nav-enemy stare) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (let ((v1-4 self))
      (set! (-> v1-4 enemy-flags) (the-as enemy-flag (logclear (-> v1-4 enemy-flags) (enemy-flag enemy-flag37))))
      )
    0
    )
  )

(defstate hostile (monster-frog)
  :virtual #t
  :enter (behavior ()
    (logclear! (-> self enemy-flags) (enemy-flag alert))
    (let ((t9-0 (-> (method-of-type nav-enemy hostile) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (let ((v1-6 self))
      (set! (-> v1-6 enemy-flags) (the-as enemy-flag (logclear (-> v1-6 enemy-flags) (enemy-flag enemy-flag37))))
      )
    0
    )
  :trans (behavior ()
    (nav-enemy-method-160 self)
    (if (and (logtest? (-> self enemy-flags) (enemy-flag victory)) (-> self enemy-info use-victory))
        (go-virtual victory)
        )
    (when (time-elapsed? (-> self state-time) (-> self reaction-time))
      (if (nav-enemy-method-163 self)
          (go-stare2 self)
          )
      (let ((gp-0 (-> self focus aware)))
        (cond
          ((>= 1 (the-as int gp-0))
           (if (-> self enemy-info use-stop-chase)
               (go-virtual stop-chase)
               (go-virtual active)
               )
           )
          ((or (>= 2 (the-as int gp-0)) (not (get-enemy-target self)))
           (go-stare self)
           )
          ((= gp-0 (enemy-aware unaware))
           (go-flee self)
           )
          )
        )
      (when (and (-> self enemy-info use-frustration) (logtest? (enemy-flag not-frustrated) (-> self enemy-flags)))
        (if (-> self enemy-info use-stop-chase)
            (go-virtual stop-chase)
            (go-stare self)
            )
        )
      )
    )
  :code (behavior ()
    (until #f
      (let* ((gp-0 (handle->process (-> self focus handle)))
             (a0-4 (if (type? gp-0 process-focusable)
                       gp-0
                       )
                   )
             )
        (cond
          (a0-4
            (let* ((s5-0 (get-trans (the-as process-focusable a0-4) 0))
                   (a1-4 (vector-! (new 'stack-no-clear 'vector) s5-0 (-> self root trans)))
                   (f30-0 (vector-length a1-4))
                   (gp-1 (-> self enemy-info))
                   )
              (let ((a1-5 (vector-normalize-copy! (new 'stack-no-clear 'vector) a1-4 1.0)))
                (if (not (enemy-method-94 self a1-5 6371.5557))
                    (go-virtual turn)
                    )
                )
              (if (< f30-0 32768.0)
                  (go-virtual attack s5-0)
                  )
              (let* ((f28-0 (fmax 0.0 (fmin 1.0 (* 0.000034877234 (+ -32768.0 f30-0)))))
                     (f26-0 (lerp 0.5 1.0 f28-0))
                     (f30-1 (lerp 0.0 1.0 f28-0))
                     (f28-1 (lerp 1.4 1.0 f28-0))
                     )
                (let ((v1-21 (-> self nav)))
                  (set! (-> v1-21 target-speed) (/ (* f26-0 (-> gp-1 run-travel-speed)) f28-1))
                  )
                0
                (let ((v1-23 (-> self nav)))
                  (set! (-> v1-23 acceleration) (-> gp-1 run-acceleration))
                  )
                0
                (let ((v1-25 (-> self nav)))
                  (set! (-> v1-25 turning-acceleration) (-> gp-1 run-turning-acceleration))
                  )
                0
                (ja-channel-push! 2 (seconds 0.01))
                (ja-no-eval :group! monster-frog-hop-small-start-ja :num! (seek! max f28-1) :frame-num 0.0)
                (ja-no-eval :chan 1
                            :group! monster-frog-hop-slow-start-ja
                            :num! (chan 0)
                            :frame-interp0 f30-1
                            :frame-interp1 f30-1
                            :frame-num 0.0
                            )
                (until (ja-done? 0)
                  (suspend)
                  (ja :num! (seek! max f28-1))
                  (ja :chan 1 :num! (chan 0) :frame-interp0 f30-1 :frame-interp1 f30-1)
                  )
                (nav-enemy-method-167 self)
                (ja-no-eval :group! monster-frog-hop-small-end-ja :num! (seek! max f28-1) :frame-num 0.0)
                (ja-no-eval :chan 1
                            :group! monster-frog-hop-slow-end-ja
                            :num! (chan 0)
                            :frame-interp0 f30-1
                            :frame-interp1 f30-1
                            :frame-num 0.0
                            )
                (until (ja-done? 0)
                  (suspend)
                  (ja :num! (seek! max f28-1))
                  (ja :chan 1 :num! (chan 0) :frame-interp0 f30-1 :frame-interp1 f30-1)
                  )
                )
              )
            )
          (else
            (suspend)
            0
            )
          )
        )
      )
    #f
    )
  )

(defstate turn (monster-frog)
  :virtual #t
  :event enemy-event-handler
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.1))
    (let ((v1-0 self))
      (set! (-> v1-0 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-0 enemy-flags))))
      )
    0
    (ja-no-eval :group! monster-frog-rotate-left-start-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (let ((v1-26 self))
      (set! (-> v1-26 enemy-flags) (the-as enemy-flag (logclear (-> v1-26 enemy-flags) (enemy-flag enemy-flag37))))
      )
    0
    (ja-no-eval :group! monster-frog-rotate-left-end-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (react-to-focus self)
    )
  :post (behavior ()
    (let ((a0-0 self))
      (when (logtest? (enemy-flag enemy-flag37) (-> a0-0 enemy-flags))
        (let ((a0-4 (handle->process (-> self focus handle))))
          (if a0-4
              (seek-to-point-toward-point!
                (-> self root)
                (get-trans (the-as process-focusable a0-4) 0)
                81920.0
                (seconds 0.02)
                )
              )
          )
        )
      )
    (nav-enemy-simple-post)
    )
  )

(defstate attack (monster-frog)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ((arg0 vector))
    (set-time! (-> self state-time))
    (let ((v1-2 self))
      (if (not (logtest? (enemy-flag enemy-flag36) (-> v1-2 enemy-flags)))
          (set! (-> v1-2 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-2 enemy-flags))))
          )
      (set! (-> v1-2 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-2 enemy-flags))))
      (set! (-> v1-2 nav callback-info) (-> v1-2 enemy-info callback-info))
      )
    0
    (let ((v1-5 self))
      (set! (-> v1-5 enemy-flags) (the-as enemy-flag (logclear (-> v1-5 enemy-flags) (enemy-flag enemy-flag37))))
      )
    0
    (logior! (-> self focus-status) (focus-status dangerous))
    (let* ((v1-9 *game-info*)
           (a1-15 (+ (-> v1-9 attack-id) 1))
           )
      (set! (-> v1-9 attack-id) a1-15)
      (set! (-> self attack-id) a1-15)
      )
    (let* ((gp-0 (-> self root trans))
           (s5-1 (vector-! (new 'stack-no-clear 'vector) arg0 gp-0))
           )
      (let ((f0-0 (vector-length s5-1)))
        (vector-normalize! s5-1 (fmin f0-0 (-> self enemy-info run-travel-speed)))
        )
      (let ((a0-3 (-> self nav state))
            (v1-17 (vector+! (new 'stack-no-clear 'vector) gp-0 s5-1))
            )
        (logclear! (-> a0-3 flags) (nav-state-flag directional-mode))
        (logior! (-> a0-3 flags) (nav-state-flag target-poly-dirty))
        (set! (-> a0-3 target-post quad) (-> v1-17 quad))
        )
      )
    0
    )
  :exit (behavior ()
    (if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
        (logior! (-> self focus-status) (focus-status dangerous))
        (logclear! (-> self focus-status) (focus-status dangerous))
        )
    )
  :code (behavior ((arg0 vector))
    (ja-channel-push! 1 (seconds 0.04))
    (nav-enemy-method-166 self)
    (ja-no-eval :group! monster-frog-attack0-start-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (nav-enemy-method-167 self)
    (if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
        (logior! (-> self focus-status) (focus-status dangerous))
        (logclear! (-> self focus-status) (focus-status dangerous))
        )
    (go-virtual attack-recover)
    )
  :post nav-enemy-travel-post
  )

(defstate attack-recover (monster-frog)
  :virtual #t
  :event enemy-event-handler
  :enter (behavior ()
    (let ((v1-0 self))
      (set! (-> v1-0 enemy-flags) (the-as enemy-flag (logclear (-> v1-0 enemy-flags) (enemy-flag enemy-flag36))))
      (set! (-> v1-0 nav callback-info) *nav-enemy-null-callback-info*)
      )
    0
    (let ((v1-3 self))
      (set! (-> v1-3 enemy-flags) (the-as enemy-flag (logclear (-> v1-3 enemy-flags) (enemy-flag enemy-flag37))))
      )
    0
    )
  :code (behavior ()
    (ja-no-eval :group! monster-frog-attack0-end-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (cond
      ((zero? (rnd-int-count self 4))
       (let ((v1-28 (ja-group)))
         (if (not (and v1-28 (= v1-28 monster-frog-idle0-ja)))
             (ja-channel-push! 1 (seconds 0.1))
             )
         )
       (ja-no-eval :group! monster-frog-idle0-ja :num! (seek!) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       )
      (else
        (let ((v1-59 (ja-group)))
          (if (not (and v1-59 (= v1-59 monster-frog-idle1-ja)))
              (ja-channel-push! 1 (seconds 0.1))
              )
          )
        (ja-no-eval :group! monster-frog-idle1-ja :num! (seek!) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek!))
          )
        )
      )
    (react-to-focus self)
    )
  :post nav-enemy-simple-post
  )

(defmethod enemy-method-77 ((this monster-frog) (arg0 enemy-knocked-info))
  (case (-> this incoming knocked-type)
    (((knocked-type knocked-type-4))
     (ja-channel-push! 1 0)
     (let ((a0-3 (-> this skel root-channel 0)))
       (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> this draw art-group data 26)))
       (set! (-> a0-3 param 0)
             (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 26)) frames num-frames) -1))
             )
       (set! (-> a0-3 param 1) (-> arg0 anim-speed))
       (set! (-> a0-3 frame-num) 0.0)
       (joint-control-channel-group! a0-3 (the-as art-joint-anim (-> this draw art-group data 26)) num-func-seek!)
       )
     #t
     )
    (((knocked-type knocked-type-6))
     (ja-channel-push! 1 0)
     (let ((a0-6 (-> this skel root-channel 0)))
       (set! (-> a0-6 frame-group) (the-as art-joint-anim (-> this draw art-group data 22)))
       (set! (-> a0-6 param 0)
             (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 22)) frames num-frames) -1))
             )
       (set! (-> a0-6 param 1) (-> arg0 anim-speed))
       (set! (-> a0-6 frame-num) 0.0)
       (joint-control-channel-group! a0-6 (the-as art-joint-anim (-> this draw art-group data 22)) num-func-seek!)
       )
     #t
     )
    (else
      (cond
        ((= (-> this incoming knocked-type) (knocked-type knocked-type-0))
         (ja-channel-push! 1 0)
         (let ((a0-8 (-> this skel root-channel 0)))
           (set! (-> a0-8 frame-group) (the-as art-joint-anim (-> this draw art-group data 30)))
           (set! (-> a0-8 param 0)
                 (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 30)) frames num-frames) -1))
                 )
           (set! (-> a0-8 param 1) (-> arg0 anim-speed))
           (set! (-> a0-8 frame-num) 0.0)
           (joint-control-channel-group! a0-8 (the-as art-joint-anim (-> this draw art-group data 30)) num-func-seek!)
           )
         )
        (else
          (ja-channel-push! 1 0)
          (let ((a0-10 (-> this skel root-channel 0)))
            (set! (-> a0-10 frame-group) (the-as art-joint-anim (-> this draw art-group data 32)))
            (set! (-> a0-10 param 0)
                  (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 32)) frames num-frames) -1))
                  )
            (set! (-> a0-10 param 1) (-> arg0 anim-speed))
            (set! (-> a0-10 frame-num) 0.0)
            (joint-control-channel-group! a0-10 (the-as art-joint-anim (-> this draw art-group data 32)) num-func-seek!)
            )
          )
        )
      #t
      )
    )
  )

(defmethod enemy-method-78 ((this monster-frog) (arg0 enemy-knocked-info))
  (case (-> this incoming knocked-type)
    (((knocked-type knocked-type-4))
     (ja-channel-push! 1 (seconds 0.17))
     (let ((a0-3 (-> this skel root-channel 0)))
       (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> this draw art-group data 27)))
       (set! (-> a0-3 param 0)
             (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 27)) frames num-frames) -1))
             )
       (set! (-> a0-3 param 1) (-> arg0 anim-speed))
       (set! (-> a0-3 frame-num) 0.0)
       (joint-control-channel-group! a0-3 (the-as art-joint-anim (-> this draw art-group data 27)) num-func-seek!)
       )
     #t
     )
    (((knocked-type knocked-type-6))
     (ja-channel-push! 1 (seconds 0.17))
     (let ((a0-6 (-> this skel root-channel 0)))
       (set! (-> a0-6 frame-group) (the-as art-joint-anim (-> this draw art-group data 23)))
       (set! (-> a0-6 param 0)
             (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 23)) frames num-frames) -1))
             )
       (set! (-> a0-6 param 1) (-> arg0 anim-speed))
       (set! (-> a0-6 frame-num) 0.0)
       (joint-control-channel-group! a0-6 (the-as art-joint-anim (-> this draw art-group data 23)) num-func-seek!)
       )
     #t
     )
    (else
      (cond
        ((= (-> this incoming knocked-type) (knocked-type knocked-type-0))
         (ja-channel-push! 1 0)
         (let ((a0-8 (-> this skel root-channel 0)))
           (set! (-> a0-8 frame-group) (the-as art-joint-anim (-> this draw art-group data 31)))
           (set! (-> a0-8 param 0)
                 (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 31)) frames num-frames) -1))
                 )
           (set! (-> a0-8 param 1) (-> arg0 anim-speed))
           (set! (-> a0-8 frame-num) 0.0)
           (joint-control-channel-group! a0-8 (the-as art-joint-anim (-> this draw art-group data 31)) num-func-seek!)
           )
         )
        (else
          (ja-channel-push! 1 0)
          (let ((a0-10 (-> this skel root-channel 0)))
            (set! (-> a0-10 frame-group) (the-as art-joint-anim (-> this draw art-group data 33)))
            (set! (-> a0-10 param 0)
                  (the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 33)) frames num-frames) -1))
                  )
            (set! (-> a0-10 param 1) (-> arg0 anim-speed))
            (set! (-> a0-10 frame-num) 0.0)
            (joint-control-channel-group! a0-10 (the-as art-joint-anim (-> this draw art-group data 33)) num-func-seek!)
            )
          )
        )
      #t
      )
    )
  )

(defmethod common-post ((this monster-frog))
  "Does a lot of various things relating to interacting with the target
- tracks when the enemy was last drawn
- looks at the target and handles attacking
@TODO Not extremely well understood yet"
  (water-control-method-10 (-> this water))
  ((method-of-type nav-enemy common-post) this)
  (none)
  )

(defmethod init-enemy-collision! ((this monster-frog))
  "Initializes the [[collide-shape-moving]] and any ancillary tasks to make the enemy collide properly"
  (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
                                    generic-attack
                                    lunge
                                    flop
                                    punch
                                    spin
                                    roll
                                    uppercut
                                    bonk
                                    tube
                                    vehicle
                                    flut-attack
                                    board
                                    mech-punch
                                    dark-punch
                                    dark-giant
                                    )
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
      (set! (-> s5-0 total-prims) (the-as uint 3))
      (set! (-> s4-0 prim-core collide-as) (collide-spec enemy))
      (set! (-> s4-0 prim-core collide-with)
            (collide-spec backgnd jak bot crate obstacle 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 4096.0 0.0 8192.0)
      (set! (-> s5-0 root-prim) s4-0)
      )
    (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-13 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-13 prim-core collide-with)
            (collide-spec backgnd jak bot crate obstacle hit-by-others-list player-list)
            )
      (set! (-> v1-13 prim-core action) (collide-action solid deadly no-standon))
      (set-vector! (-> v1-13 local-sphere) 0.0 4096.0 1638.4 3276.8)
      )
    (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
      (set! (-> v1-15 prim-core collide-as) (collide-spec enemy))
      (set! (-> v1-15 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> v1-15 prim-core action) (collide-action deadly))
      (set! (-> v1-15 transform-index) 5)
      (set-vector! (-> v1-15 local-sphere) 0.0 0.0 2048.0 2662.4)
      )
    (set! (-> s5-0 nav-radius) 4915.2)
    (let ((v1-17 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-17 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-17 prim-core collide-with))
      )
    (set! (-> s5-0 max-iteration-count) (the-as uint 3))
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

(defmethod init-enemy! ((this monster-frog))
  "Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-monster-frog" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  (init-enemy-behaviour-and-stats! this *monster-frog-nav-enemy-info*)
  (set! (-> this water) (new 'process 'water-control this 5 0.0 8192.0 2048.0))
  (set! (-> this water flags)
        (water-flags active use-water-anim touch-water part-splash part-drip part-rings part-water find-water)
        )
  (set! (-> this water height) (res-lump-float (-> this entity) 'water-height))
  (set! (-> this water ripple-size) 12288.0)
  (set! (-> this water wake-size) 6144.0)
  0
  (none)
  )
