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

;; definition for function target-falling-anim
(defbehavior target-falling-anim target ((arg0 time-frame) (arg1 time-frame))
  (let ((v1-2 (ja-group)))
    (cond
      ((or (= v1-2 eichar-jump-loop-ja) (= v1-2 eichar-attack-uppercut-ja))
       )
      ((let ((v1-8 (ja-group)))
         (or (= v1-8 eichar-edge-grab-stance0-ja) (= v1-8 eichar-edge-grab-stance1-ja))
         )
       (ja-channel-push! 1 (seconds 0.15))
       (ja-no-eval :group! eichar-edge-grab-off-ja :num! (seek!) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       )
      ((ja-group? eichar-edge-grab-off-ja)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       (ja-channel-push! 1 (seconds 0.15))
       )
      ((ja-group? eichar-yellow-jumping-blast-ja)
       (ja-channel-push! 1 (seconds 0.15))
       (ja-no-eval :group! eichar-jump-ja :num! (seek!) :frame-num (ja-aframe (the-as float 20.0) 0))
       (until (ja-done? 0)
         (ja :num! (seek!))
         (suspend)
         )
       )
      (else
        (ja-channel-push! 1 arg1)
        (ja :group! eichar-jump-loop-ja)
        (while (!= (-> self skel root-channel 0) (-> self skel channel))
          (suspend)
          )
        )
      )
    )
  (ja-no-eval :group! eichar-jump-loop-ja :num! (loop!) :frame-num 0.0)
  (let ((s5-1 (-> *display* base-frame-counter)))
    (while (or (= arg0 -1) (< (- (-> *display* base-frame-counter) s5-1) arg0))
      (suspend)
      (ja :group! eichar-jump-loop-ja :num! (loop!))
      )
    )
  #f
  )

;; definition for function target-falling-anim-trans
;; INFO: Return type mismatch int vs none.
(defbehavior target-falling-anim-trans target ()
  (let ((v1-2 (ja-group)))
    (b! (or (= v1-2 eichar-jump-loop-ja) (= v1-2 eichar-jump-land-ja)) cfg-7 :delay (empty-form))
    )
  (ja-channel-push! 1 (seconds 0.33))
  (ja :group! eichar-jump-loop-ja)
  (b! #t cfg-23 :delay (nop!))
  (label cfg-7)
  (cond
    ((and (logtest? (-> self control status) (cshape-moving-flags onsurf)) (not (ja-group? eichar-jump-land-ja)))
     (ja-channel-push! 1 (seconds 0.02))
     (ja :group! eichar-jump-land-ja)
     )
    ((ja-group? eichar-jump-loop-ja)
     (ja :num! (loop!))
     )
    ((ja-group? eichar-jump-land-ja)
     (ja :num! (seek!))
     )
    )
  (label cfg-23)
  0
  (none)
  )

;; definition for function target-falling-trans
;; INFO: Return type mismatch int vs none.
(defbehavior target-falling-trans target ((arg0 basic) (arg1 time-frame))
  (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) circle) (can-feet?))
      (go target-attack-air #f)
      )
  (when (= arg0 'target-eco-powerup)
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons x)
                       )
             (zero? (logand (-> self water flags) (water-flags wt09)))
             (< (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
             (zero? (logand (-> self state-flags) (state-flags prevent-jump)))
             )
        (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
        )
    )
  (if (logtest? (-> self control status) (cshape-moving-flags onsurf))
      (go target-hit-ground #f)
      )
  (when (if (and (< (target-move-dist (-> *TARGET-bank* stuck-time)) (-> *TARGET-bank* stuck-distance))
                 (>= arg1 0)
                 (>= (- (-> *display* base-frame-counter) (-> self state-time)) arg1)
                 (not (and *cheat-mode* (cpad-hold? (-> self control unknown-cpad-info00 number) r2)))
                 )
            #t
            )
    (logior! (-> self control status) (cshape-moving-flags onsurf))
    (go target-hit-ground 'stuck)
    )
  (if (!= (-> self state-time) (-> *display* base-frame-counter))
      (slide-down-test)
      )
  0
  (none)
  )

;; definition for function target-hit-ground-anim
(defbehavior target-hit-ground-anim target ((arg0 symbol))
  (let ((v1-2 (ja-group)))
    (cond
      ((or (= v1-2 eichar-flop-down-ja)
           (= v1-2 eichar-flop-down-loop-ja)
           (= v1-2 eichar-moving-flop-down-ja)
           (= v1-2 eichar-moving-flop-down-loop-ja)
           )
       (let ((gp-0 (or (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
                       (< (-> self control unknown-float01) 61440.0)
                       )
                   )
             (f30-0 (the-as float (if (= arg0 'swim)
                                      0.4
                                      1.0
                                      )
                            )
                    )
             )
         (ja-channel-set! 1)
         (let ((s5-0 (-> self skel root-channel 0)))
           (set! (-> s5-0 frame-group) (the-as art-joint-anim (if gp-0
                                                                  eichar-flop-down-land-ja
                                                                  eichar-moving-flop-down-land-ja
                                                                  )
                                               )
                 )
           (set! (-> s5-0 param 0) (the float (+ (-> (the-as art-joint-anim (if gp-0
                                                                                eichar-flop-down-land-ja
                                                                                eichar-moving-flop-down-land-ja
                                                                                )
                                                             )
                                                     data
                                                     0
                                                     length
                                                     )
                                                 -1
                                                 )
                                        )
                 )
           (let ((f30-1 (seek f30-0 (the-as float 1.0) (* 0.5 (-> *display* seconds-per-frame)))))
             (set! (-> s5-0 param 1) f30-1)
             (set! (-> s5-0 frame-num) 0.0)
             (joint-control-channel-group!
               s5-0
               (the-as art-joint-anim (if gp-0
                                          eichar-flop-down-land-ja
                                          eichar-moving-flop-down-land-ja
                                          )
                       )
               num-func-seek!
               )
             (until (ja-done? 0)
               (compute-alignment! (-> self align))
               (align!
                 (-> self align)
                 (the-as align-opts (if gp-0
                                        2
                                        6
                                        )
                         )
                 (the-as float 1.0)
                 (the-as float 1.0)
                 (the-as float 1.5)
                 )
               (when (and (>= 25.0 (ja-aframe-num 0)) (and (>= (ja-aframe-num 0) 21.0)
                                                           (= (-> self next-state name) 'target-flop-hit-ground)
                                                           (!= (-> self control unknown-spoolanim00) 'stuck)
                                                           )
                          )
                 (set! (-> self event-hook) target-jump-event-handler)
                 (when (and (cpad-hold? (-> self control unknown-cpad-info00 number) x) (can-jump? #f))
                   (ja-channel-set! 0)
                   (go
                     target-high-jump
                     (-> *TARGET-bank* flop-jump-height-min)
                     (-> *TARGET-bank* flop-jump-height-max)
                     (if gp-0
                         'flop
                         'flop-forward
                         )
                     )
                   )
                 )
               (suspend)
               (let ((s5-1 (-> self skel root-channel 0)))
                 (set! (-> s5-1 param 0) (the float (+ (-> s5-1 frame-group data 0 length) -1)))
                 (set! f30-1 (seek f30-1 (the-as float 1.0) (* 0.5 (-> *display* seconds-per-frame))))
                 (set! (-> s5-1 param 1) f30-1)
                 (joint-control-channel-group-eval! s5-1 (the-as art-joint-anim #f) num-func-seek!)
                 )
               )
             )
           )
         )
       #f
       )
      ((and (= (-> self control ground-pat material) (pat-material ice))
            (< 16384.0 (-> self control unknown-float01))
            )
       #f
       )
      ((let ((v1-95 (ja-group)))
         (or (or (= v1-95 eichar-jump-loop-ja) (= v1-95 eichar-launch-jump-ja) (= v1-95 eichar-launch-jump-loop-ja))
             (and (ja-group? eichar-jump-ja) (>= (ja-aframe-num 0) 38.0))
             )
         )
       (ja-channel-push! 1 (seconds 0.02))
       (ja-no-eval :group! eichar-jump-land-ja :num! (seek!) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       #f
       )
      ((and (ja-group? eichar-jump-ja) (>= (ja-aframe-num 0) 35.0))
       (ja-channel-set! 1)
       (ja-no-eval :group! eichar-jump-short-land-ja :num! (seek!) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       (ja-no-eval :group! eichar-jump-land-ja :num! (seek!) :frame-num (ja-aframe (the-as float 50.0) 0))
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       #f
       )
      ((let ((v1-187 (ja-group)))
         (or (= v1-187 eichar-jump-ja) (= v1-187 eichar-duck-high-jump-ja))
         )
       (ja-channel-set! 1)
       (ja-no-eval :group! eichar-jump-short-land-ja :num! (seek!) :frame-num (ja-aframe (the-as float 38.0) 0))
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       (ja-no-eval :group! eichar-jump-land-ja :num! (seek!) :frame-num (ja-aframe (the-as float 50.0) 0))
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       #f
       )
      ((let ((v1-242 (ja-group)))
         (or (= v1-242 eichar-hit-from-front-ja) (= v1-242 eichar-hit-from-back-ja))
         )
       (let ((f30-2 (the-as float (if (ja-group? eichar-hit-from-back-ja)
                                      24576.0
                                      -24576.0
                                      )
                            )
                    )
             )
         (ja-channel-push! 1 (seconds 0.04))
         (ja-no-eval :group! eichar-jump-short-land-ja :num! (seek!) :frame-num (ja-aframe (the-as float 38.0) 0))
         (until (ja-done? 0)
           (set-forward-vel f30-2)
           (suspend)
           (ja :num! (seek!))
           )
         )
       (ja-no-eval :group! eichar-jump-land-ja :num! (seek!) :frame-num (ja-aframe (the-as float 50.0) 0))
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       #f
       )
      ((let ((v1-305 (ja-group)))
         (or (= v1-305 eichar-jump-ja)
             (= v1-305 eichar-attack-from-jump-ja)
             (= v1-305 eichar-attack-from-jump-loop-ja)
             (= v1-305 eichar-attack-from-jump-end-ja)
             (= v1-305 eichar-moving-flop-down-land-ja)
             (= v1-305 eichar-flop-down-land-ja)
             (= v1-305 eichar-attack-uppercut-ja)
             )
         )
       (ja-channel-push! 1 (seconds 0.04))
       (ja-no-eval :group! eichar-jump-land-ja :num! (seek!) :frame-num (ja-aframe (the-as float 42.0) 0))
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       #f
       )
      ((ja-group? eichar-jump-land-ja)
       (ja-no-eval :num! (seek!))
       (while (not (ja-done? 0))
         (suspend)
         (ja-eval)
         )
       #f
       )
      )
    )
  )

;; failed to figure out what this is:
(defstate target-startup (target)
  :event target-standard-event-handler
  :code (behavior ()
    (suspend)
    (suspend)
    (go target-stance)
    (none)
    )
  :post target-no-move-post
  )

;; failed to figure out what this is:
(defstate target-stance (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set! (-> self control unknown-surface00) *walk-mods*)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :exit (behavior ()
    (set! (-> self control unknown-float81) 0.0)
    (target-state-hook-exit)
    (none)
    )
  :trans (behavior ()
    ((-> self state-hook))
    (if (logtest? (-> self water flags) (water-flags wt10))
        (go target-wade-stance)
        )
    (when (= (-> self control ground-pat material) (pat-material ice))
      (set! (-> self control unknown-float81) 0.0)
      (remove-exit)
      (go target-ice-stance)
      )
    (when (move-legs?)
      (set! (-> self control unknown-float81) 0.0)
      (remove-exit)
      (go target-walk)
      )
    (when (and (cpad-hold? (-> self control unknown-cpad-info00 number) l1 r1) (can-duck?))
      (set! (-> self control unknown-float81) 0.0)
      (remove-exit)
      (go target-duck-stance)
      )
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons x)
                       )
             (can-jump? #f)
             )
        (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
        )
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons circle)
                       )
             (can-feet?)
             )
        (go target-attack)
        )
    (if (can-hands? #t)
        (go target-running-attack)
        )
    (slide-down-test)
    (fall-test)
    (none)
    )
  :code (behavior ()
    (let ((s5-0 22)
          (gp-0 (new 'stack 'ground-tween-info))
          )
      (let ((v1-3 (ja-group)))
        (cond
          ((or (= v1-3 eichar-wade-shallow-walk-ja) (= v1-3 eichar-wade-deep-walk-ja))
           (set! s5-0 45)
           )
          ((ja-group? eichar-wheel-flip-ja)
           (ja-no-eval :group! eichar-wheel-flip-land-ja :num! (seek!) :frame-num 0.0)
           (until (ja-done? 0)
             (suspend)
             (ja :num! (seek!))
             )
           )
          ((ja-group? eichar-attack-from-stance-ja)
           (cond
             ((rand-vu-percent? (the-as float 0.3))
              (ja-no-eval :group! eichar-attack-from-stance-alt-end-ja :num! (seek!) :frame-num 0.0)
              (until (ja-done? 0)
                (suspend)
                (ja :num! (seek!))
                )
              )
             (else
               (ja-no-eval :group! eichar-attack-from-stance-end-ja :num! (seek!) :frame-num 0.0)
               (until (ja-done? 0)
                 (suspend)
                 (ja :num! (seek!))
                 )
               )
             )
           )
          ((ja-group? eichar-smack-surface-ja)
           (ja-no-eval :group! eichar-smack-surface-end-ja :num! (seek!) :frame-num 0.0)
           (until (ja-done? 0)
             (suspend)
             (ja :num! (seek!))
             )
           )
          ((ja-group? eichar-yellow-running-blast-ja)
           (ja-no-eval :group! eichar-yellow-running-blast-end-ja :num! (seek!) :frame-num 0.0)
           (until (ja-done? 0)
             (suspend)
             (ja :num! (seek!))
             )
           (set! s5-0 0)
           )
          ((ja-group? eichar-attack-punch-ja)
           (set! (-> self control unknown-float81) (-> self control unknown-float80))
           (set! (-> self control unknown-surface00) *walk-no-turn-mods*)
           (ja-no-eval :group! (if (rand-vu-percent? (the-as float 0.3))
                                  eichar-attack-punch-alt-end-ja
                                  eichar-attack-punch-end-ja
                                  )
                       :num! (seek!)
                       :frame-num 0.0
                       )
           (until (ja-done? 0)
             (seek! (-> self control unknown-float81) (the-as float 0.0) (-> *display* seconds-per-frame))
             (suspend)
             (ja :num! (seek!))
             )
           (set! (-> self control unknown-surface00) *walk-mods*)
           (set! (-> self control unknown-float81) 0.0)
           (rot->dir-targ! (-> self control))
           )
          ((let ((v1-206 (ja-group)))
             (or (= v1-206 eichar-duck-stance-ja) (= v1-206 eichar-duck-walk-ja))
             )
           (ja-channel-push! 1 (seconds 0.04))
           (ja-no-eval :group! eichar-stance-to-duck-ja :num! (seek! 0.0 1.2) :frame-num max)
           (until (ja-done? 0)
             (suspend)
             (ja :num! (seek! 0.0 1.2))
             )
           (set! s5-0 12)
           )
          ((or (and (ja-group? eichar-walk-ja) (begin (set! s5-0 45) (< 0.5 (-> self skel root-channel 6 frame-interp))))
               (let ((v1-243 (ja-group)))
                 (or (= v1-243 eichar-run-squash-ja)
                     (= v1-243 eichar-run-squash-weak-ja)
                     (= v1-243 eichar-attack-from-stance-run-end-ja)
                     (= v1-243 eichar-attack-from-stance-run-alt-end-ja)
                     )
                 )
               )
           (let ((f30-1 (the-as float (cond
                                        ((ja-group? eichar-walk-ja)
                                         (let ((f0-57 (+ 50.0 (* 0.8333333 (+ -25.0 (ja-aframe-num 0))))))
                                           (- f0-57 (* (the float (the int (/ f0-57 50.0))) 50.0))
                                           )
                                         )
                                        (else
                                          0.0
                                          )
                                        )
                                )
                        )
                 )
             (set! s5-0 45)
             (ja-channel-push! 3 (the-as time-frame s5-0))
             (ground-tween-initialize
               gp-0
               (the-as uint 0)
               (the-as uint eichar-run-to-stance-loop-ja)
               (the-as uint eichar-run-to-stance-loop-up-ja)
               (the-as uint eichar-run-to-stance-loop-down-ja)
               (the-as uint eichar-run-to-stance-loop-left-ja)
               (the-as uint eichar-run-to-stance-loop-right-ja)
               )
             (ja :num-func num-func-identity :frame-num (ja-aframe f30-1 0))
             )
           (ja :chan 1 :num! (chan 0))
           (ja :chan 2 :num! (chan 0))
           (dotimes (s4-2 3)
             (until (ja-done? 0)
               (ground-tween-update gp-0 (-> self control unknown-float61) (-> self control unknown-float62))
               (suspend)
               (ja :num! (seek!))
               (ja :chan 1 :num! (chan 0))
               (ja :chan 2 :num! (chan 0))
               )
             (ja :num-func num-func-identity :frame-num 0.0)
             )
           (ground-tween-initialize
             gp-0
             (the-as uint 0)
             (the-as uint eichar-run-to-stance-ja)
             (the-as uint eichar-run-to-stance-up-ja)
             (the-as uint eichar-run-to-stance-down-ja)
             (the-as uint eichar-run-to-stance-left-ja)
             (the-as uint eichar-run-to-stance-right-ja)
             )
           (until (ja-done? 0)
             (ground-tween-update gp-0 (-> self control unknown-float61) (-> self control unknown-float62))
             (suspend)
             (ja :num! (seek!))
             (ja :chan 1 :num! (chan 0))
             (ja :chan 2 :num! (chan 0))
             )
           )
          ((and (ja-group? eichar-walk-ja) (>= (-> self control unknown-float01) 5734.4))
           (set! s5-0 45)
           )
          )
        )
      (if (not (and (ja-group? eichar-stance-loop-ja) (= (ja-group-size) 3)))
          (ja-channel-push! 3 (the-as time-frame s5-0))
          )
      (ground-tween-initialize
        gp-0
        (the-as uint 0)
        (the-as uint eichar-stance-loop-ja)
        (the-as uint eichar-stance-loop-up-ja)
        (the-as uint eichar-stance-loop-down-ja)
        (the-as uint eichar-stance-loop-left-ja)
        (the-as uint eichar-stance-loop-right-ja)
        )
      (loop
        (ground-tween-update gp-0 (-> self control unknown-float61) (-> self control unknown-float62))
        (suspend)
        (ja :num! (loop!))
        (ja :chan 1 :num! (chan 0))
        (ja :chan 2 :num! (chan 0))
        (if (can-play-stance-amibent?)
            (go target-stance-ambient)
            )
        )
      )
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-walk (target)
  :event target-walk-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self control unknown-surface00) *walk-mods*)
    (none)
    )
  :exit (behavior ()
    (target-effect-exit)
    (target-state-hook-exit)
    (none)
    )
  :trans (behavior ()
    ((-> self state-hook))
    (when (= (-> self control ground-pat material) (pat-material ice))
      (target-effect-exit)
      (remove-exit)
      (go target-ice-walk)
      )
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons l1 r1)
                       )
             (and (>= (- (-> *display* base-frame-counter) (-> *TARGET-bank* wheel-timeout)) (-> self control unknown-dword30))
                  (and (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) (can-wheel?))
                  )
             )
        (go target-wheel)
        )
    (when (and (cpad-hold? (-> self control unknown-cpad-info00 number) l1 r1) (can-duck?))
      (target-effect-exit)
      (remove-exit)
      (go target-duck-walk)
      )
    (when (not (move-legs?))
      (target-effect-exit)
      (remove-exit)
      (go target-stance)
      )
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons x)
                       )
             (can-jump? #f)
             )
        (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
        )
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons circle)
                       )
             (can-feet?)
             )
        (go target-attack)
        )
    (if (can-hands? #t)
        (go target-running-attack)
        )
    (when (and (turn-around?) (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.3)))
      (set! (-> self control transv quad)
            (-> self control unknown-vector-array10 (-> self control unknown-int10) quad)
            )
      (set! (-> self control transv w) 1.0)
      (go target-turn-around)
      )
    (slide-down-test)
    (fall-test)
    (none)
    )
  :code (behavior ()
    (let ((f28-0 0.0)
          (f30-0 (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01))))))
          (gp-0 #f)
          )
      (cond
        ((ja-group? eichar-turn-around-ja)
         (set! f30-0 1.0)
         (ja-channel-push! 7 (seconds 0.05))
         )
        ((ja-group? eichar-duck-roll-ja)
         (ja-channel-push! 7 (seconds 0.075))
         (set! f30-0 1.0)
         )
        ((ja-group? eichar-attack-from-stance-ja)
         (let ((f30-1 (fmax 0.8 (fmin 1.0 (* 0.000048828126 (-> self control unknown-float01))))))
           (cond
             ((and (rand-vu-percent? (the-as float 0.3)) (< 20480.0 (-> self control unknown-float01)))
              (ja-no-eval :group! eichar-attack-from-stance-alt-end-ja
                          :num! (seek! (ja-aframe (the-as float 29.0) 0) f30-1)
                          :frame-num 0.0
                          )
              (until (ja-done? 0)
                (suspend)
                (ja :num! (seek! (ja-aframe (the-as float 29.0) 0) f30-1))
                )
              (ja-no-eval :group! eichar-attack-from-stance-run-alt-end-ja :num! (seek! max f30-1) :frame-num 0.0)
              (until (ja-done? 0)
                (suspend)
                (ja :num! (seek! max f30-1))
                )
              )
             (else
               (ja-no-eval :group! eichar-attack-from-stance-end-ja
                           :num! (seek! (ja-aframe (the-as float 29.0) 0) f30-1)
                           :frame-num 0.0
                           )
               (until (ja-done? 0)
                 (suspend)
                 (ja :num! (seek! (ja-aframe (the-as float 29.0) 0) f30-1))
                 )
               (ja-no-eval :group! eichar-attack-from-stance-run-end-ja :num! (seek! max f30-1) :frame-num 0.0)
               (until (ja-done? 0)
                 (suspend)
                 (ja :num! (seek! max f30-1))
                 )
               )
             )
           )
         (ja-channel-push! 7 (seconds 0.05))
         (set! f30-0 1.0)
         (set! f28-0 30.0)
         )
        (else
          (let ((v1-108 (ja-group)))
            (cond
              ((or (= v1-108 eichar-attack-punch-ja) (= v1-108 eichar-attack-punch-end-ja))
               (set! f30-0 1.0)
               (set! f28-0 30.0)
               (ja-channel-push! 7 (seconds 0.15))
               )
              ((let ((v1-116 (ja-group)))
                 (or (= v1-116 eichar-yellow-running-blast-ja) (= v1-116 eichar-yellow-running-blast-end-ja))
                 )
               (set! f30-0 1.0)
               (set! f28-0 26.0)
               (ja-channel-push! 7 (seconds 0.1))
               )
              ((and (ja-group? eichar-walk-ja) (= (-> self skel root-channel 0) (-> self skel channel)))
               (set! f28-0 (ja-aframe-num 0))
               )
              ((ja-group? (-> self draw art-group data 102))
               (set! f28-0 (ja-aframe-num 0))
               (ja-channel-push! 7 (seconds 0.1))
               )
              ((ja-group? eichar-wade-shallow-walk-ja)
               (set! f28-0 (ja-aframe-num 0))
               (ja-channel-push! 7 (seconds 0.05))
               )
              ((let ((v1-146 (ja-group)))
                 (and (or (or (= v1-146 eichar-jump-loop-ja)
                              (= v1-146 eichar-wheel-flip-ja)
                              (= v1-146 eichar-attack-from-jump-end-ja)
                              (= v1-146 eichar-attack-uppercut-ja)
                              (= v1-146 eichar-flop-down-land-ja)
                              (= v1-146 eichar-moving-flop-down-land-ja)
                              )
                          (and (ja-group? eichar-jump-ja) (< 30.0 (ja-aframe-num 0)))
                          )
                      (< 12288.0 (-> self control unknown-float01))
                      )
                 )
               (let ((s5-4 (ja-group))
                     (f30-2 (-> self control ground-impact-vel))
                     )
                 (case (ja-group)
                   ((eichar-wheel-flip-ja eichar-attack-from-jump-end-ja)
                    (ja-channel-push! 1 (seconds 0.05))
                    )
                   (else
                     (ja-channel-set! 1)
                     )
                   )
                 (cond
                   ((< (the-as float (if (= s5-4 eichar-jump-ja)
                                         77824.0
                                         102400.0
                                         )
                               )
                       f30-2
                       )
                    (ja-no-eval :group! eichar-run-squash-ja
                                :num! (seek! (ja-aframe (the-as float 3.0) 0) 1.00001)
                                :frame-num 0.0
                                )
                    (until (ja-done? 0)
                      (suspend)
                      (ja :num! (seek! (ja-aframe (the-as float 3.0) 0) 1.00001))
                      )
                    )
                   ((< (the-as float (if (= s5-4 eichar-jump-ja)
                                         61440.0
                                         102400.0
                                         )
                               )
                       f30-2
                       )
                    (ja-no-eval :group! eichar-run-squash-ja
                                :num! (seek! (ja-aframe (the-as float 3.0) 0) 1.00001)
                                :frame-num (ja-aframe (the-as float -1.0) 0)
                                )
                    (until (ja-done? 0)
                      (suspend)
                      (ja :num! (seek! (ja-aframe (the-as float 3.0) 0) 1.00001))
                      )
                    )
                   (else
                     (ja-no-eval :group! eichar-run-squash-weak-ja
                                 :num! (seek! (ja-aframe (the-as float 4.0) 0) 1.00001)
                                 :frame-num 0.0
                                 )
                     (until (ja-done? 0)
                       (suspend)
                       (ja :num! (seek! (ja-aframe (the-as float 4.0) 0) 1.00001))
                       )
                     )
                   )
                 )
               (until (ja-done? 0)
                 (suspend)
                 (ja :num! (seek! max (/ (* (fmax 20480.0 (-> self control unknown-float01)) (-> *display* seconds-per-frame))
                                        (/ (-> *TARGET-bank* run-up-cycle-dist) (-> *TARGET-bank* run-cycle-length))
                                        )
                                 )
                     )
                 )
               (set! f28-0 30.0)
               (set! f30-0 1.0)
               (ja-channel-set! 7)
               )
              ((ja-group? eichar-jump-ja)
               (ja-channel-push! 7 (seconds 0.05))
               (set! gp-0 #t)
               )
              ((ja-group? eichar-smack-surface-ja)
               (ja-channel-push! 7 (seconds 0.15))
               )
              (else
                (ja-channel-push! 7 (seconds 0.05))
                )
              )
            )
          )
        )
      (set! (-> self skel root-channel 3 command) 'push)
      (set! (-> self skel root-channel 6 command) 'stack)
      (ja :group! eichar-walk-ja)
      (let ((f28-1 (ja-aframe f28-0 0)))
        (ja :group! eichar-walk-ja :num! (identity f28-1) :frame-interp 0.0 :dist (-> *TARGET-bank* walk-cycle-dist))
        (ja :chan 1
            :group! eichar-walk-down-ja
            :num! (identity f28-1)
            :frame-interp 0.0
            :dist (-> *TARGET-bank* walk-down-cycle-dist)
            )
        (ja :chan 2
            :group! eichar-walk-left-ja
            :num! (identity f28-1)
            :frame-interp 0.0
            :dist (-> *TARGET-bank* walk-side-cycle-dist)
            )
        (ja :chan 4
            :group! eichar-run-down-ja
            :num! (identity f28-1)
            :frame-interp 0.0
            :dist (-> *TARGET-bank* run-down-cycle-dist)
            )
        (ja :chan 5
            :group! eichar-run-left-ja
            :num! (identity f28-1)
            :frame-interp 0.0
            :dist (-> *TARGET-bank* run-side-cycle-dist)
            )
        (ja :chan 3
            :group! eichar-run-ja
            :num! (identity f28-1)
            :frame-interp 0.0
            :dist (-> *TARGET-bank* run-cycle-dist)
            )
        )
      (let ((f28-2 0.0)
            (f26-1 0.0)
            )
        (loop
          (let ((f22-0 (fmax -1.0 (fmin 1.0 (* 2.0 (-> self control unknown-float61)))))
                (f24-0 (fmax -1.0 (fmin 1.0 (* 1.6 (-> self control unknown-float62)))))
                )
            (set! f30-0 (seek
                          f30-0
                          (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01)))))
                          (* 2.0 (-> *display* seconds-per-frame))
                          )
                  )
            (let ((v1-317 (-> self skel effect)))
              (set! (-> v1-317 channel-offset) (if (< 0.5 f30-0)
                                                   3
                                                   0
                                                   )
                    )
              )
            0
            (let ((f0-64 (fabs (- f22-0 f28-2))))
              (set! f28-2 (seek f28-2 f22-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-64)))))
              )
            (let ((f0-69 (fabs (- f24-0 f26-1))))
              (set! f26-1 (seek f26-1 f24-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-69)))))
              )
            )
          (cond
            ((>= f28-2 0.0)
             (ja :chan 1 :group! eichar-walk-up-ja :frame-interp (fabs f28-2) :dist (-> *TARGET-bank* walk-up-cycle-dist))
             (ja :chan 4 :group! eichar-run-up-ja :frame-interp (fabs f28-2) :dist (-> *TARGET-bank* run-up-cycle-dist))
             )
            (else
              (ja :chan 1
                  :group! eichar-walk-down-ja
                  :frame-interp (fabs f28-2)
                  :dist (-> *TARGET-bank* walk-down-cycle-dist)
                  )
              (ja :chan 4
                  :group! eichar-run-down-ja
                  :frame-interp (fabs f28-2)
                  :dist (-> *TARGET-bank* run-down-cycle-dist)
                  )
              )
            )
          (cond
            ((>= f26-1 0.0)
             (ja :chan 2
                 :group! eichar-walk-right-ja
                 :frame-interp (fabs f26-1)
                 :dist (-> *TARGET-bank* walk-side-cycle-dist)
                 )
             (ja :chan 5
                 :group! eichar-run-right-ja
                 :frame-interp (fabs f26-1)
                 :dist (-> *TARGET-bank* run-side-cycle-dist)
                 )
             )
            (else
              (ja :chan 2
                  :group! eichar-walk-left-ja
                  :frame-interp (fabs f26-1)
                  :dist (-> *TARGET-bank* walk-side-cycle-dist)
                  )
              (ja :chan 5
                  :group! eichar-run-left-ja
                  :frame-interp (fabs f26-1)
                  :dist (-> *TARGET-bank* run-side-cycle-dist)
                  )
              )
            )
          (set! (-> self skel root-channel 6 frame-interp) f30-0)
          (let* ((f1-19 (current-cycle-distance (-> self skel)))
                 (f0-92 (/ (-> self control unknown-float01) (* 60.0 (/ f1-19 (-> *TARGET-bank* run-cycle-length)))))
                 )
            (ja :num! (loop! f0-92))
            )
          (ja :chan 1 :num! (chan 0))
          (ja :chan 2 :num! (chan 0))
          (ja :chan 3 :num! (chan 0))
          (ja :chan 4 :num! (chan 0))
          (ja :chan 5 :num! (chan 0))
          (if (and gp-0 (!= (-> self skel root-channel 0) (-> self skel channel)))
              (ja-blend-eval)
              )
          (suspend)
          )
        )
      )
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-turn-around (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (vector-turn-to (-> self control transv))
    (set! (-> self control unknown-surface00) *turn-around-mods*)
    (set! (-> self control unknown-float81) 1.0)
    (none)
    )
  :exit (behavior ()
    (target-state-hook-exit)
    (set-forward-vel (the-as float 0.0))
    (set! (-> self control unknown-float01) 0.0)
    (set-quaternion! (-> self control) (-> self control dir-targ))
    (set! (-> self control unknown-float81) 0.0)
    (none)
    )
  :trans (behavior ()
    ((-> self state-hook))
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons x)
                       )
             (can-jump? #f)
             )
        (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
        )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) circle) (can-feet?))
        (go target-attack)
        )
    (if (can-hands? #t)
        (go target-running-attack)
        )
    (if (and (zero? (logand (-> self control status) (cshape-moving-flags onsurf)))
             (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (seconds 0.08))
             )
        (go target-falling #f)
        )
    (slide-down-test)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.04))
    (ja :group! eichar-turn-around-ja :num! min)
    (quaternion-rotate-y! (-> self control dir-targ) (-> self control dir-targ) (the-as float 32768.0))
    (compute-alignment! (-> self align))
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek! max 2.0))
      (compute-alignment! (-> self align))
      (align! (-> self align) (align-opts adjust-quat) (the-as float 1.0) (the-as float 1.0) (the-as float 1.0))
      )
    (remove-exit)
    (set! (-> self control unknown-float81) 0.0)
    (set-forward-vel (the-as float 40960.0))
    (set! (-> self control unknown-float01) 40960.0)
    (target-state-hook-exit)
    (go target-walk)
    (none)
    )
  :post target-no-stick-post
  )

;; failed to figure out what this is:
(defstate target-slide-down (target)
  :event target-walk-event-handler
  :enter (behavior ()
    (set! (-> self control unknown-surface00) *jump-mods*)
    (none)
    )
  :exit (behavior ()
    (set! (-> self control unknown-dword35) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (when (or (logtest? (-> self control status) (cshape-moving-flags onsurf))
              (if (< (target-move-dist (-> *TARGET-bank* stuck-time)) (-> *TARGET-bank* stuck-distance))
                  #t
                  )
              )
      (logior! (-> self control status) (cshape-moving-flags onsurf))
      (go target-duck-stance)
      )
    (none)
    )
  :code (behavior ()
    (if (not (ja-group? eichar-duck-stance-ja))
        (ja-channel-push! 1 (seconds 0.1))
        )
    (loop
      (ja-no-eval :group! eichar-duck-stance-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post target-post
  )

;; definition for function init-var-jump
;; INFO: Used lq/sq
(defbehavior init-var-jump target ((arg0 float) (arg1 float) (arg2 vector) (arg3 vector) (arg4 vector))
  (logclear! (-> self control status) (cshape-moving-flags csmf14))
  (delete-back-vel)
  (when (< (- (-> *display* base-frame-counter) (-> self control rider-time)) (seconds 0.05))
    (let ((f0-1
            (fmax
              0.0
              (fmin 28672.0 (* 0.5 (vector-dot (-> self control dynam gravity-normal) (-> self control rider-last-move))))
              )
            )
          )
      (set! arg0 (+ arg0 f0-1))
      (set! arg1 (+ arg1 f0-1))
      )
    (when (or (logtest? (-> self control unknown-surface01 flags) (surface-flags moving-ground))
              (= (-> self control poly-pat material) (pat-material rotate))
              )
      (+! (-> self control transv x) (-> self control rider-last-move x))
      (+! (-> self control transv z) (-> self control rider-last-move z))
      )
    )
  (set! (-> self control unknown-float123) 0.0)
  (set! (-> self control unknown-float124) 0.0)
  (cond
    (arg3
      (set! (-> self control unknown-uint20)
            (the-as uint (- arg0 (+ -409.6 (-> *TARGET-bank* jump-collide-offset))))
            )
      (set! (-> self control unknown-int21) (the-as int (- arg1 (-> *TARGET-bank* jump-collide-offset))))
      )
    (else
      (set! (-> self control unknown-uint20) (the-as uint arg0))
      (set! (-> self control unknown-int21) (the-as int arg1))
      )
    )
  (when arg2
    (let ((s4-1 (new-stack-vector0)))
      (let ((f0-16 (vector-dot (-> self control dynam gravity-normal) arg4)))
        0.0
        (vector-! s4-1 arg4 (vector-float*! s4-1 (-> self control dynam gravity-normal) f0-16))
        )
      (let* ((f0-17 (vector-length s4-1))
             (f1-11 f0-17)
             (f2-7
               (- (sqrtf (* 2.0 (-> self control dynam gravity-length) arg0))
                  (* 0.008333334 (- (-> self control dynam gravity-length)))
                  )
               )
             )
        (vector+!
          arg4
          (vector-float*! arg4 (-> self control dynam gravity-normal) f2-7)
          (vector-float*! s4-1 s4-1 (/ f0-17 f1-11))
          )
        )
      )
    )
  (let ((v0-2 (-> self control unknown-vector102)))
    (set! (-> v0-2 quad) (-> self control trans quad))
    v0-2
    )
  )

;; definition for function mod-var-jump
;; INFO: Used lq/sq
(defbehavior mod-var-jump target ((arg0 symbol) (arg1 symbol) (arg2 symbol) (arg3 vector))
  (local-vars (v0-2 vector))
  (let ((f30-0 (* 0.033333335 (the float (- (-> *display* base-frame-counter) (-> self state-time))))))
    (cond
      ((or (< 1.0 f30-0) (< (-> self control unknown-float123) 0.0) (not arg2))
       (set! (-> self control unknown-float123) -1.0)
       )
      (else
        (set! (-> self control unknown-float123) f30-0)
        (set! (-> self control unknown-float124) f30-0)
        (when arg0
          (let ((s3-1 (vector-! (new-stack-vector0) (-> self control trans) (-> self control unknown-vector102)))
                (s4-0 (new-stack-vector0))
                )
            (let ((f0-5 (vector-dot (-> self control dynam gravity-normal) arg3)))
              0.0
              (vector-! s4-0 arg3 (vector-float*! s4-0 (-> self control dynam gravity-normal) f0-5))
              )
            (let* ((f28-0 (vector-length s4-0))
                   (f26-0 f28-0)
                   (f0-13
                     (- (sqrtf
                          (* 2.0
                             (-> self control dynam gravity-length)
                             (- (lerp-scale
                                  (the-as float (-> self control unknown-uint20))
                                  (the-as float (-> self control unknown-uint30))
                                  f30-0
                                  (the-as float 0.0)
                                  (the-as float 1.0)
                                  )
                                (vector-dot (-> self control dynam gravity-normal) s3-1)
                                )
                             )
                          )
                        (* 0.008333334 (- (-> self control dynam gravity-length)))
                        )
                     )
                   )
              (vector+!
                arg3
                (vector-float*! arg3 (-> self control dynam gravity-normal) f0-13)
                (vector-float*! s4-0 s4-0 (/ f28-0 f26-0))
                )
              )
            )
          )
        )
      )
    )
  0
  (when (and arg1 (ja-group) (and (-> (ja-group) extra) #t))
    (let ((v1-57 (res-lump-struct (-> (ja-group) extra) 'collide-offset vector :time (ja-frame-num 0))))
      (cond
        (v1-57
          (set! v0-2 (-> self control unknown-vector13))
          (set! (-> v0-2 quad) (-> v1-57 quad))
          )
        (else
          (set! v0-2 (-> self control unknown-vector13))
          (set! (-> v0-2 quad) (the-as uint128 0))
          )
        )
      )
    v0-2
    )
  )

;; failed to figure out what this is:
(defstate target-duck-stance (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set! (-> self control unknown-float81) 1.0)
    (set! (-> self control unknown-surface00) *duck-mods*)
    (target-collide-set! 'duck (the-as float 1.0))
    (none)
    )
  :exit (behavior ()
    (if (not (or (= (-> self next-state name) 'target-duck-walk)
                 (= (-> self next-state name) 'target-duck-stance)
                 (= (-> self next-state name) 'target-walk)
                 (= (-> self next-state name) 'target-stance)
                 (= (-> self next-state name) 'target-stance-look-around)
                 )
             )
        (target-state-hook-exit)
        )
    (target-exit)
    (target-collide-set! 'normal (the-as float 0.0))
    (none)
    )
  :trans (behavior ()
    ((-> self state-hook))
    (if (and (or (zero? (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons l1 r1))
                        )
                 (logtest? (-> self state-flags) (state-flags prevent-duck))
                 )
             (let ((v1-13 (ja-group)))
               (and (not (or (= v1-13 eichar-duck-roll-end-ja) (= v1-13 eichar-duck-roll-ja))) (can-exit-duck?))
               )
             )
        (go target-stance)
        )
    (if (move-legs?)
        (go target-duck-walk)
        )
    (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                         (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                         )
                                 (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                                 )
                         (pad-buttons x)
                         )
               (can-jump? #f)
               )
      (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
          (go target-high-jump (-> *TARGET-bank* duck-jump-height-min) (-> *TARGET-bank* duck-jump-height-max) 'duck)
          (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
          )
      )
    (if (and (can-hands? #t) (can-exit-duck?))
        (go
          target-attack-uppercut
          (-> *TARGET-bank* attack-jump-height-min)
          (-> *TARGET-bank* attack-jump-height-max)
          )
        )
    (fall-test)
    (slide-down-test)
    (none)
    )
  :code (behavior ()
    (cond
      ((ja-group? eichar-duck-roll-ja)
       (ja-no-eval :group! eichar-duck-roll-end-ja :num! (seek!) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek!))
         )
       )
      ((and (ja-group? eichar-duck-stance-ja) (= (-> self skel root-channel 0) (-> self skel channel)))
       )
      ((ja-group? eichar-duck-walk-ja)
       (ja-channel-push! 1 (seconds 0.1))
       )
      (else
        (ja-channel-push! 1 (seconds 0.04))
        (ja-no-eval :group! eichar-stance-to-duck-ja :num! (seek!) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek!))
          )
        )
      )
    (loop
      (ja-no-eval :group! eichar-duck-stance-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-duck-walk (target)
  :event target-standard-event-handler
  :enter (behavior ()
    (set! (-> self control unknown-float81) 1.0)
    (target-collide-set! 'duck (the-as float 1.0))
    (if (not (ja-group? eichar-duck-roll-ja))
        (set! (-> self control unknown-surface00) *duck-mods*)
        )
    (none)
    )
  :exit (-> target-duck-stance exit)
  :trans (behavior ()
    ((-> self state-hook))
    (if (and (or (zero? (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons l1 r1))
                        )
                 (logtest? (-> self state-flags) (state-flags prevent-duck))
                 (and (logtest? (-> self water flags) (water-flags wt10))
                      (>= (- (- (-> self control trans y) (- (-> self water base-height) (-> self water wade-height)))) 2457.6)
                      )
                 )
             (can-exit-duck?)
             )
        (go target-walk)
        )
    (if (not (move-legs?))
        (go target-duck-stance)
        )
    (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                         (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                         )
                                 (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                                 )
                         (pad-buttons x)
                         )
               (can-jump? #f)
               )
      (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
          (go target-high-jump (-> *TARGET-bank* duck-jump-height-min) (-> *TARGET-bank* duck-jump-height-max) 'duck)
          (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
          )
      )
    (if (and (can-hands? #t) (can-exit-duck?))
        (go
          target-attack-uppercut
          (-> *TARGET-bank* attack-jump-height-min)
          (-> *TARGET-bank* attack-jump-height-max)
          )
        )
    (fall-test)
    (slide-down-test)
    (none)
    )
  :code (behavior ()
    (cond
      ((and (ja-group? eichar-duck-walk-ja) (= (-> self skel root-channel 0) (-> self skel channel)))
       )
      ((ja-group? eichar-duck-stance-ja)
       (ja-channel-push! 1 (seconds 0.45))
       (ja :group! eichar-duck-walk-ja :num! min)
       )
      (else
        (ja-channel-push! 1 (seconds 0.1))
        (ja :group! eichar-duck-walk-ja :num! min)
        )
      )
    (loop
      (if (= (-> self skel root-channel 0) (-> self skel channel))
          (set! (-> self control unknown-surface00) *duck-mods*)
          )
      (ja :num! (loop! (fmin 1.0 (/ (-> self control unknown-float01)
                                   (* 60.0 (/ (-> *TARGET-bank* duck-walk-cycle-dist) (-> *TARGET-bank* run-cycle-length)))
                                   )
                            )
                      )
          )
      (suspend)
      )
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-jump (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 float) (arg1 float) (arg2 surface))
    (when (= (-> self control unknown-symbol40) 'launch)
      (level-hint-spawn
        (game-text-id sidekick-launcher1)
        "sksp009d"
        (the-as entity #f)
        *entity-pool*
        (game-task none)
        )
      (level-hint-spawn
        (game-text-id sidekick-launcher2)
        "sksp009e"
        (the-as entity #f)
        *entity-pool*
        (game-task none)
        )
      (case (-> (level-get-target-inside *level*) name)
        (('citadel)
         (level-hint-spawn
           (game-text-id citadel-launcher2)
           "sksp0393"
           (the-as entity #f)
           *entity-pool*
           (game-task none)
           )
         (level-hint-spawn
           (game-text-id citadel-launcher)
           "sksp0388"
           (the-as entity #f)
           *entity-pool*
           (game-task none)
           )
         )
        )
      enter-state
      (let ((a0-9 (-> self control unknown-dword60))
            (a1-5 (-> self control unknown-dword61))
            (a2-5 (-> self control unknown-vector102))
            )
        (set! (-> a2-5 quad) (-> (the-as vector (-> self control unknown-dword62)) quad))
        (go target-launch (the-as float a0-9) (the-as symbol a1-5) a2-5 (-> self control unknown-dword63))
        )
      )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (sound-play "jump" :vol 70)
    (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #t) (-> self control transv))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (set! arg2 (cond
                 (arg2
                   (empty)
                   arg2
                   )
                 (else
                   *jump-mods*
                   )
                 )
          )
    (set! (-> self control unknown-surface00) arg2)
    (set! (-> self control unknown-float123)
          (fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control unknown-float01)))))
          )
    (set! (-> self control unknown-float122)
          (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
          )
    (none)
    )
  :exit target-exit
  :trans (behavior ()
    (set! (-> self control unknown-float123)
          (fmax
            (-> self control unknown-float123)
            (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) abutton 6)))
            )
          )
    (target-falling-trans #f (the-as time-frame (if (ja-group? eichar-jump-loop-ja)
                                                    15
                                                    -1
                                                    )
                                     )
                          )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) x)
             (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 12288.0)
             (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                  (zero? (logand (-> self water flags) (water-flags wt09)))
                  (zero? (logand (-> self state-flags) (state-flags prevent-jump)))
                  )
             )
        (go target-double-jump (-> *TARGET-bank* double-jump-height-min) (-> *TARGET-bank* double-jump-height-max))
        )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square)
             (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 26624.0)
             (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                  (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36))
                      (the-as time-frame (-> *TARGET-bank* stuck-timeout))
                      )
                  (zero? (logand (-> self state-flags) (state-flags prevent-attack)))
                  (zero? (logand (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf08))
                         )
                  )
             )
        (go
          target-flop
          (the-as float 65502.96)
          (the-as float -163840.0)
          (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
                            0.0
                            68812.8
                            )
                  )
          )
        )
    (mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
    (slide-down-test)
    (seek!
      (-> self control unknown-float122)
      (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
      (-> *display* seconds-per-frame)
      )
    (none)
    )
  :code (behavior ((arg0 float) (arg1 float) (arg2 surface))
    (ja-channel-push! 2 (seconds 0.05))
    (ja :group! eichar-jump-ja :num! min)
    (ja :chan 1 :group! eichar-jump-forward-ja :num! (chan 0) :frame-interp (-> self control unknown-float122))
    (suspend)
    (ja :group! eichar-jump-ja :num! (+!))
    (ja :chan 1 :group! eichar-jump-forward-ja :num! (chan 0) :frame-interp (-> self control unknown-float122))
    (suspend)
    (until (ja-done? 0)
      (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
            (f0-8 (- 20.0 (ja-aframe-num 0)))
            (gp-1 (-> self skel root-channel 0))
            )
        (set! (-> gp-1 param 0) (the float (+ (-> gp-1 frame-group data 0 length) -1)))
        (let ((v1-45 (and (< 0.0 f30-0) (< 0.0 f0-8))))
          (set! (-> gp-1 param 1)
                (the-as
                  float
                  (if v1-45
                      (fmin (fmin 3.0 f0-8) (/ (* 5.0 f0-8) (the float (time-to-apex f30-0 (the-as float -245760.0)))))
                      1.0
                      )
                  )
                )
          )
        (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!)
        )
      (ja :chan 1 :num! (chan 0) :frame-interp (-> self control unknown-float122))
      (suspend)
      )
    (target-falling-anim -1 (seconds 0.2))
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-jump-forward (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 float) (arg1 float))
    ((-> target-jump enter) arg0 arg1 (the-as surface #f))
    (set! (-> self control unknown-surface00) *forward-jump-mods*)
    (none)
    )
  :exit target-exit
  :trans (-> target-jump trans)
  :code (behavior ((arg0 float) (arg1 float))
    (ja-channel-set! 1)
    (ja-no-eval :group! eichar-jump-ja :num! (seek!) :frame-num (ja-aframe (the-as float 3.0) 0))
    (until (ja-done? 0)
      (set! (-> self control unknown-dword70) 0)
      (suspend)
      (ja :num! (seek!))
      )
    (ja-no-eval :group! eichar-jump-loop-ja :num! (loop!) :frame-num 0.0)
    (loop
      (suspend)
      (ja :group! eichar-jump-loop-ja :num! (loop!))
      )
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-double-jump (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 float) (arg1 float))
    (when (= (-> self control unknown-symbol40) 'launch)
      enter-state
      (let ((a0-3 (-> self control unknown-dword60))
            (a1-1 (-> self control unknown-dword61))
            (a2-0 (-> self control unknown-vector102))
            )
        (set! (-> a2-0 quad) (-> (the-as vector (-> self control unknown-dword62)) quad))
        (go target-launch (the-as float a0-3) (the-as symbol a1-1) a2-0 (-> self control unknown-dword63))
        )
      )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #t) (-> self control transv))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (set! (-> self control unknown-surface00) *double-jump-mods*)
    (none)
    )
  :exit target-exit
  :trans (behavior ()
    (target-falling-trans #f (the-as time-frame (if (ja-group? eichar-jump-loop-ja)
                                                    15
                                                    -1
                                                    )
                                     )
                          )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square)
             (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 22118.4)
             (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                  (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36))
                      (the-as time-frame (-> *TARGET-bank* stuck-timeout))
                      )
                  (zero? (logand (-> self state-flags) (state-flags prevent-attack)))
                  (zero? (logand (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf08))
                         )
                  )
             )
        (go
          target-flop
          (the-as float 33775.48)
          (the-as float -122880.0)
          (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
                            0.0
                            68812.8
                            )
                  )
          )
        )
    (if (!= (-> self state-time) (-> *display* base-frame-counter))
        (mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
        )
    (seek!
      (-> self control unknown-float122)
      (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01)))))
      (-> *display* seconds-per-frame)
      )
    (none)
    )
  :code (behavior ((arg0 float) (arg1 float))
    (ja-channel-push! 2 (seconds 0.05))
    (dummy-10 (-> self skel effect) 'jump-double (the-as float -1.0) -1)
    (ja-no-eval :group! eichar-jump-ja :num! (seek!) :frame-num (ja-aframe (the-as float 5.0) 0))
    (ja :chan 1 :group! eichar-jump-forward-ja :num! (chan 0))
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      (ja :chan 1 :num! (chan 0) :frame-interp (-> self control unknown-float122))
      )
    (target-falling-anim -1 (seconds 0.2))
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-high-jump (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 float) (arg1 float) (arg2 basic))
    (when (and (= (-> self control unknown-symbol40) 'launch) (!= arg2 'launch))
      enter-state
      (let ((a0-3 (-> self control unknown-dword60))
            (a1-1 (-> self control unknown-dword61))
            (a2-1 (-> self control unknown-vector102))
            )
        (set! (-> a2-1 quad) (-> (the-as vector (-> self control unknown-dword62)) quad))
        (go target-launch (the-as float a0-3) (the-as symbol a1-1) a2-1 (-> self control unknown-dword63))
        )
      )
    (set! (-> self control unknown-uint31) (the-as uint arg2))
    (if (or (= arg2 'duck) (= arg2 'launch))
        (go target-duck-high-jump arg0 arg1 (the-as symbol arg2))
        )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (sound-play "jump" :pitch 0.3)
    (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #t) (-> self control transv))
    (set! (-> self control unknown-surface00) (cond
                                                ((= arg2 'flip)
                                                 *flip-jump-mods*
                                                 )
                                                ((= arg2 'flop-forward)
                                                 *forward-high-jump-mods*
                                                 )
                                                (else
                                                  *high-jump-mods*
                                                  )
                                                )
          )
    (set! (-> self control unknown-float122)
          (fmax 0.0 (fmin 0.5 (* 0.00008138021 (+ -409.6 (-> self control unknown-float01)))))
          )
    (none)
    )
  :exit target-exit
  :trans (behavior ()
    (target-falling-trans #f (the-as time-frame (if (ja-group? eichar-jump-loop-ja)
                                                    15
                                                    -1
                                                    )
                                     )
                          )
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons square)
                       )
             (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 73728.0)
             (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                  (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36))
                      (the-as time-frame (-> *TARGET-bank* stuck-timeout))
                      )
                  (zero? (logand (-> self state-flags) (state-flags prevent-attack)))
                  (zero? (logand (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf08))
                         )
                  )
             )
        (go
          target-flop
          (the-as float 33775.48)
          (the-as float -122880.0)
          (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
                            0.0
                            68812.8
                            )
                  )
          )
        )
    (mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
    (seek!
      (-> self control unknown-float122)
      (fmax 0.0 (fmin 1.0 (* 0.00012207031 (+ -2048.0 (-> self control unknown-float01)))))
      (-> *display* seconds-per-frame)
      )
    (none)
    )
  :code (-> target-jump code)
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-duck-high-jump (target)
  :event target-standard-event-handler
  :enter (behavior ((arg0 float) (arg1 float) (arg2 symbol))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (set! (-> self control unknown-surface00) *turn-around-mods*)
    (none)
    )
  :exit target-exit
  :code (behavior ((arg0 float) (arg1 float) (arg2 symbol))
    (if (not (and (ja-group? eichar-duck-stance-ja) (= (-> self skel root-channel 0) (-> self skel channel))))
        (ja-channel-push! 1 (seconds 0.04))
        )
    (case arg2
      (('launch)
       (ja-no-eval :group! eichar-launch-jump-ja :num! (seek! (ja-aframe (the-as float 16.0) 0)) :frame-num 0.0)
       (until (ja-done? 0)
         (suspend)
         (ja :num! (seek! (ja-aframe (the-as float 16.0) 0)))
         )
       )
      (else
        (ja-no-eval :group! eichar-duck-high-jump-ja :num! (seek! (ja-aframe (the-as float 16.0) 0)) :frame-num 0.0)
        (until (ja-done? 0)
          (suspend)
          (ja :num! (seek! (ja-aframe (the-as float 16.0) 0)))
          )
        )
      )
    (go target-duck-high-jump-jump arg0 arg1 arg2)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-duck-high-jump-jump (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 float) (arg1 float) (arg2 symbol))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (sound-play "jump" :vol 80 :pitch -0.4)
    (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #f) (-> self control transv))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (cond
      ((= arg2 'launch)
       (set! (-> self neck flex-blend) 0.0)
       (set! (-> self control unknown-surface00) *launch-jump-mods*)
       )
      (else
        (set! (-> self control unknown-surface00) *high-jump-mods*)
        )
      )
    (none)
    )
  :exit target-exit
  :trans (-> target-high-jump trans)
  :code (behavior ((arg0 float) (arg1 float) (arg2 symbol))
    (let ((f30-0 (the-as float (if (= arg2 'launch)
                                   110.0
                                   35.0
                                   )
                         )
                 )
          (f28-0 1.0)
          )
      (until (ja-done? 0)
        (let* ((f24-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
               (f26-0 (- f30-0 (ja-aframe-num 0)))
               (f22-1 (fmin (fmin 3.0 f26-0) (/ (* 5.0 f26-0) (the float (time-to-apex f24-0 (the-as float -245760.0))))))
               (s5-0 (-> self skel root-channel 0))
               )
          (set! (-> s5-0 param 0) (the float (+ (-> s5-0 frame-group data 0 length) -1)))
          (let ((v1-26 (cond
                         ((and (< 0.0 f24-0) (< 0.0 f26-0))
                          (if (= arg2 'launch)
                              (set! f28-0 (lerp f28-0 (* 4.0 f22-1) (the-as float 0.25)))
                              )
                          f22-1
                          )
                         (else
                           f28-0
                           )
                         )
                       )
                )
            (set! (-> s5-0 param 1) v1-26)
            )
          (joint-control-channel-group-eval! s5-0 (the-as art-joint-anim #f) num-func-seek!)
          )
        (suspend)
        )
      (cond
        ((= arg2 'launch)
         (ja-no-eval :group! eichar-launch-jump-loop-ja :num! (loop! f28-0) :frame-num 0.0)
         (loop
           (suspend)
           (ja :group! eichar-launch-jump-loop-ja :num! (loop! f28-0))
           )
         )
        (else
          (ja-no-eval :group! eichar-jump-loop-ja :num! (loop!) :frame-num 0.0)
          (loop
            (suspend)
            (ja :group! eichar-jump-loop-ja :num! (loop!))
            )
          )
        )
      )
    (the-as none 0)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-falling (target)
  :event target-jump-event-handler
  :enter (behavior ((arg0 symbol))
    (set! (-> self control unknown-surface00) *jump-mods*)
    (set! (-> self control unknown-uint20) (the-as uint arg0))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (target-falling-trans
      (-> self control unknown-spoolanim00)
      (the-as time-frame (if (= (-> self control unknown-spoolanim00) #f)
                             0
                             (/ (the-as int (-> *TARGET-bank* stuck-time)) 2)
                             )
              )
      )
    (none)
    )
  :code (behavior ((arg0 symbol))
    (target-falling-anim -1 (seconds 0.33))
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-hit-ground (target)
  :event target-walk-event-handler
  :enter (behavior ((arg0 symbol))
    (cond
      ((= arg0 'stuck)
       )
      ((let ((v1-4 (ja-group)))
         (or (= v1-4 eichar-launch-jump-ja) (= v1-4 eichar-launch-jump-loop-ja))
         )
       (dummy-10 (-> self skel effect) 'group-blue-hit-ground-effect (the-as float 0.0) -1)
       (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.3))
       )
      (else
        (let ((f0-1 (vector-dot
                      (-> self control dynam gravity-normal)
                      (vector-! (new 'stack-no-clear 'vector) (-> self control unknown-vector52) (-> self control trans))
                      )
                    )
              )
          (if (and (< (-> *TARGET-bank* fall-far) f0-1)
                   (zero? (logand (-> self control status) (cshape-moving-flags on-water)))
                   )
              (go target-hit-ground-hard f0-1)
              )
          )
        )
      )
    (cond
      ((= arg0 'stuck)
       )
      (else
        (target-land-effect)
        )
      )
    (set! (-> self control unknown-dword31) 0)
    (set! (-> self control unknown-dword33) 0)
    (if (>= (-> self control ground-impact-vel) (-> *TARGET-bank* fall-stumble-threshold))
        (set-forward-vel (the-as float 0.0))
        )
    (if (!= (-> self control ground-pat material) (pat-material ice))
        (delete-back-vel)
        )
    (set! (-> self control unknown-surface00) *walk-mods*)
    (start-bobbing!
      (-> self water)
      (lerp-scale
        (the-as float 0.0)
        (the-as float 4096.0)
        (-> self control ground-impact-vel)
        (the-as float 40960.0)
        (the-as float 102400.0)
        )
      600
      1500
      )
    (none)
    )
  :trans (behavior ()
    (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                       (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                       )
                               (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                               )
                       (pad-buttons x)
                       )
             (can-jump? #f)
             )
        (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
        )
    (if (and (not (can-exit-duck?)) (can-duck?))
        (go target-duck-stance)
        )
    (when (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
      (if (logtest? (-> self water flags) (water-flags wt10))
          (go target-wade-walk)
          (go target-walk)
          )
      )
    (if (and (or (cpad-hold? (-> self control unknown-cpad-info00 number) l1 r1) (not (can-exit-duck?))) (can-duck?))
        (go target-duck-stance)
        )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) circle) (can-feet?))
        (go target-attack)
        )
    (if (can-hands? #t)
        (go target-running-attack)
        )
    (fall-test)
    (slide-down-test)
    (none)
    )
  :code (behavior ((arg0 symbol))
    (target-hit-ground-anim #f)
    (go target-stance)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-attack (target)
  :event target-dangerous-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (target-start-attack)
    (target-danger-set! 'spin #f)
    (set! (-> self control unknown-surface00) *attack-mods*)
    (set! (-> self water drip-mult) 4.0)
    (set! (-> self neck flex-blend) 0.0)
    (none)
    )
  :exit (behavior ()
    (set! (-> self control unknown-dword33) (-> *display* base-frame-counter))
    (target-exit)
    (none)
    )
  :code (behavior ()
    (ja-channel-push! 1 (seconds 0.05))
    (ja-no-eval :group! eichar-attack-from-stance-ja
                :num! (seek! max (-> self control unknown-surface01 align-speed))
                :frame-num 0.0
                )
    (until (ja-done? 0)
      (when (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
                 (>= (-> self fact-info-target eco-level) 1.0)
                 )
        (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 74)
        (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.1))
        (level-hint-spawn
          (game-text-id misty-eco-red-first-use)
          "sksp0072"
          (the-as entity #f)
          *entity-pool*
          (game-task none)
          )
        )
      (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                         (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                         )
                                 (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                                 )
                         (pad-buttons x)
                         )
               (can-jump? #f)
               )
          (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))
          )
      (suspend)
      (ja :num! (seek! max (-> self control unknown-surface01 align-speed)))
      )
    (go target-stance)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-running-attack (target)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touched)
       (cond
         (((method-of-type touching-shapes-entry prims-touching?)
           (the-as touching-shapes-entry (-> arg3 param 0))
           (-> self control)
           (the-as uint 224)
           )
          (let ((gp-1 (target-send-attack
                        arg0
                        (the-as uint (-> self control unknown-symbol30))
                        (-> arg3 param 0)
                        (-> self control unknown-dword50)
                        (-> self control unknown-dword51)
                        )
                      )
                )
            (when gp-1
              (set! (-> self control unknown-uint20) (the-as uint (-> *display* base-frame-counter)))
              (let ((v1-9 (if (and (nonzero? arg0) (type-type? (-> arg0 type) process-drawable))
                              arg0
                              )
                          )
                    )
                (when v1-9
                  (let* ((s5-1 (-> (the-as process-drawable v1-9) root))
                         (v1-11 (if (and (nonzero? s5-1) (type-type? (-> s5-1 type) collide-shape))
                                    (the-as collide-shape s5-1)
                                    )
                                )
                         )
                    (if (and v1-11 (or (logtest? (-> v1-11 root-prim prim-core collide-as) (collide-kind enemy))
                                       (logtest? (-> v1-11 root-prim prim-core action) (collide-action ca-10))
                                       )
                             )
                        (set! (-> self control unknown-uint31) (the-as uint 1))
                        )
                    )
                  )
                )
              (when (or (= gp-1 'die) (= gp-1 'push))
                (let ((v0-2 (the-as object (-> *display* base-frame-counter))))
                  (set! (-> self control unknown-int21) (the-as int v0-2))
                  v0-2
                  )
                )
              )
            )
          )
         (else
           (target-dangerous-event-handler arg0 arg1 arg2 arg3)
           )
         )
       )
      (else
        (target-dangerous-event-handler arg0 arg1 arg2 arg3)
        )
      )
    )
  :enter (behavior ()
    (if (or (and (= (-> self fact-info-target eco-type) (pickup-type eco-yellow))
                 (>= (-> self fact-info-target eco-level) 1.0)
                 )
            (< (- (-> *display* base-frame-counter) (-> self control unknown-dword82)) (seconds 1.5))
            )
        (go target-yellow-blast)
        )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self control unknown-uint20) (the-as uint 0))
    (set! (-> self control unknown-int21) 0)
    (set! (-> self control unknown-uint31) (the-as uint 0))
    (set! (-> self control unknown-surface00) *run-attack-mods*)
    (set! (-> *run-attack-mods* turnv) 655360.0)
    (set! (-> *run-attack-mods* turnvv) 655360.0)
    (target-start-attack)
    (target-danger-set! 'punch #f)
    (if (or (< (fabs (-> self control unknown-float62)) 0.3) (< 0.3 (fabs (-> self control unknown-float61))))
        (set! (-> self control unknown-float81) 1.0)
        )
    (none)
    )
  :exit (behavior ()
    (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max))
    (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length))
    (set! (-> *run-attack-mods* turnv) 0.0)
    (set! (-> *run-attack-mods* turnvv) 0.0)
    (set! (-> self control unknown-dword31) (-> *display* base-frame-counter))
    (target-exit)
    (none)
    )
  :trans (behavior ()
    (when (!= (-> self state-time) (-> *display* base-frame-counter))
      (if (and (or (smack-surface? #t)
                   (and (>= (-> self control unknown-float63) 0.7)
                        (zero? (logand (-> self control status) (cshape-moving-flags t-act)))
                        )
                   )
               (begin
                 (set! (-> self control unknown-int21) (the-as int (-> *display* base-frame-counter)))
                 (set! (-> self control unknown-float81) 0.0)
                 (let ((gp-0 (new-stack-vector0))
                       (f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                       )
                   0.0
                   (vector-! gp-0 (-> self control transv) (vector-float*! gp-0 (-> self control dynam gravity-normal) f30-0))
                   (let* ((f0-5 (vector-length gp-0))
                          (f1-1 f0-5)
                          (f2-1 (fmin 0.0 f30-0))
                          )
                     (vector+!
                       (-> self control transv)
                       (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-1)
                       (vector-float*! gp-0 gp-0 (/ f0-5 f1-1))
                       )
                     )
                   )
                 #t
                 )
               (or (zero? (-> self control unknown-uint20))
                   (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint20))))
                       (the-as uint 12)
                       )
                   )
               (!= (-> self control unknown-uint31) 1)
               )
          (target-shoved
            (-> *TARGET-bank* smack-surface-dist)
            (-> *TARGET-bank* smack-surface-height)
            (the-as process #f)
            target-hit
            )
          )
      (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) x)
               (and (< 4096.0 (-> self control unknown-float01))
                    (or (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.1))
                        (zero? (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0)
                                       (pad-buttons square)
                                       )
                               )
                        )
                    (zero? (logand (-> self state-flags) (state-flags prevent-jump prevent-attack)))
                    (zero? (logand (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump)))
                    )
               )
          (go
            target-attack-uppercut
            (-> *TARGET-bank* attack-jump-height-min)
            (-> *TARGET-bank* attack-jump-height-max)
            )
          )
      (if (and (logtest? (-> self water flags) (water-flags wt09))
               (zero? (mod (- (-> *display* base-frame-counter) (-> self state-time)) 21))
               )
          (dummy-13
            (-> self water)
            (the-as float 0.6)
            (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 37))
            0
            (-> self control transv)
            )
          )
      (when (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
                 (>= (-> self fact-info-target eco-level) 1.0)
                 )
        (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 23)
        (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.1))
        (level-hint-spawn
          (game-text-id misty-eco-red-first-use)
          "sksp0072"
          (the-as entity #f)
          *entity-pool*
          (game-task none)
          )
        )
      )
    (none)
    )
  :code (behavior ()
    (if (logtest? (-> self water flags) (water-flags wt09))
        (sound-play "swim-stroke")
        )
    (ja-channel-push! 1 (seconds 0.02))
    (ja :group! eichar-attack-punch-ja :num! min)
    (set! (-> self control dynam gravity-max) 368640.0)
    (set! (-> self control dynam gravity-length) 368640.0)
    (let ((f28-0 0.0)
          (f30-0 1.0)
          (gp-2 0)
          )
      (until (ja-done? 0)
        (compute-alignment! (-> self align))
        (when (not (ja-min? 0))
          (cond
            ((and (>= (ja-aframe-num 0) 20.0)
                  (and (and (zero? (logand (-> self control status) (cshape-moving-flags onsurf)))
                            (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (-> *TARGET-bank* ground-timeout))
                            (>= 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                            (let ((v1-39 (ja-group)))
                              (or (not (or (= v1-39 eichar-attack-punch-ja)
                                           (= v1-39 eichar-attack-punch-end-ja)
                                           (= v1-39 eichar-attack-punch-alt-end-ja)
                                           )
                                       )
                                  (< 4096.0 (target-height-above-ground))
                                  )
                              )
                            )
                       (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint20))))
                           (the-as uint 12)
                           )
                       )
                  )
             (go target-falling #f)
             )
            ((and (nonzero? (-> self control unknown-uint30))
                  (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint30))))
                      (the-as uint 12)
                      )
                  )
             (set-forward-vel (the-as float 0.0))
             )
            ((and (zero? (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0)
                                 (pad-buttons square)
                                 )
                         )
                  (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.05))
                  )
             (if (= (-> self control ground-pat material) (pat-material ice))
                 (set-forward-vel (fmax 32768.0 (* 0.8 (-> self control unknown-float01))))
                 (set-forward-vel (* 0.8 (-> self control unknown-float01)))
                 )
             )
            ((ja-done? 0)
             (set-forward-vel f28-0)
             )
            (else
              (set! f28-0
                    (* (target-align-vel-z-adjust (-> self align delta trans z)) (-> *display* frames-per-second) f30-0)
                    )
              (set-forward-vel f28-0)
              )
            )
          )
        (let ((s5-1 (new-stack-vector0)))
          (vector-matrix*! s5-1 (-> self control transv) (-> self control unknown-matrix00))
          (set! (-> s5-1 y) 0.0)
          (vector-matrix*! (-> self control unknown-vector120) s5-1 (-> self control unknown-matrix01))
          )
        (suspend)
        (ja :num! (seek! max (-> self control unknown-surface01 align-speed)))
        (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.1))
            (set! (-> *run-attack-mods* turnvv) 0.0)
            )
        (if (< 2 gp-2)
            (set! f30-0 (* f30-0 (fmin 1.0 (-> self control unknown-float140))))
            )
        (+! gp-2 1)
        )
      )
    (if (and (zero? (logand (-> self control status) (cshape-moving-flags onsurf)))
             (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) (-> *TARGET-bank* ground-timeout))
             (>= 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
             (let ((v1-121 (ja-group)))
               (or (not (or (= v1-121 eichar-attack-punch-ja)
                            (= v1-121 eichar-attack-punch-end-ja)
                            (= v1-121 eichar-attack-punch-alt-end-ja)
                            )
                        )
                   (< 4096.0 (target-height-above-ground))
                   )
               )
             )
        (go target-falling #f)
        )
    (go target-stance)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-attack-air (target)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3)))
      (cond
        (v0-0
          (empty)
          v0-0
          )
        (else
          (target-dangerous-event-handler arg0 arg1 arg2 arg3)
          )
        )
      )
    )
  :enter (behavior ((arg0 symbol))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (target-start-attack)
    (target-danger-set! 'spin-air #f)
    (set! (-> self control unknown-surface00) *jump-attack-mods*)
    (let ((f0-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))))
      (cond
        ((or (>= 0.0 f0-1) (= arg0 'flop))
         (let ((gp-1 (new-stack-vector0)))
           (let ((f0-3 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))))
             0.0
             (vector-! gp-1 (-> self control transv) (vector-float*! gp-1 (-> self control dynam gravity-normal) f0-3))
             )
           (let* ((f0-4 (vector-length gp-1))
                  (f1-2 f0-4)
                  (f2-0 33775.48)
                  )
             (vector+!
               (-> self control transv)
               (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-0)
               (vector-float*! gp-1 gp-1 (/ f0-4 f1-2))
               )
             )
           )
         )
        (else
          (let* ((f1-5 (/ f0-1 (* (-> self control dynam gravity-length) (-> *display* seconds-per-frame))))
                 (f30-0 (* 0.5 f1-5 (-> *display* seconds-per-frame) f0-1))
                 )
            (if (ja-group? eichar-attack-uppercut-ja)
                (set! f30-0
                      (fmax
                        0.0
                        (- (-> *TARGET-bank* attack-jump-height-max)
                           (vector-dot
                             (-> self control dynam gravity-normal)
                             (vector-! (new 'stack-no-clear 'vector) (-> self control trans) (-> self control unknown-vector52))
                             )
                           )
                        )
                      )
                )
            (let ((gp-2 (new-stack-vector0)))
              (let ((f0-8 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))))
                0.0
                (vector-! gp-2 (-> self control transv) (vector-float*! gp-2 (-> self control dynam gravity-normal) f0-8))
                )
              (let* ((f0-9 (vector-length gp-2))
                     (f1-11 f0-9)
                     (f2-7 (+ 1024.0 (sqrtf (* 245760.0 (+ 2048.0 f30-0)))))
                     )
                (vector+!
                  (-> self control transv)
                  (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-7)
                  (vector-float*! gp-2 gp-2 (/ f0-9 f1-11))
                  )
                )
              )
            )
          )
        )
      )
    (set! (-> self control dynam gravity-length) 122880.0)
    (set! (-> self control unknown-vector52 quad) (-> self control trans quad))
    (none)
    )
  :exit (behavior ()
    (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max))
    (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length))
    ((-> target-attack exit))
    (none)
    )
  :trans (behavior ()
    (when (logtest? (-> self control status) (cshape-moving-flags onsurf))
      (set-quaternion! (-> self control) (-> self control dir-targ))
      (go target-hit-ground #f)
      )
    (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.5))
        (seek!
          (-> self control dynam gravity-length)
          (-> self control unknown-dynamics00 gravity-length)
          (* 245760.0 (-> *display* seconds-per-frame))
          )
        )
    (when (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.05))
               (< (vector-dot (-> self control dynam gravity-normal) (-> self control unknown-vector10))
                  (vector-dot (-> self control dynam gravity-normal) (-> self control transv))
                  )
               )
      (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max))
      (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length))
      )
    (when (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
               (>= (-> self fact-info-target eco-level) 1.0)
               )
      (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 70)
      (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.1))
      (level-hint-spawn
        (game-text-id misty-eco-red-first-use)
        "sksp0072"
        (the-as entity #f)
        *entity-pool*
        (game-task none)
        )
      )
    (none)
    )
  :code (behavior ((arg0 symbol))
    (ja-channel-push! 1 (seconds 0.075))
    (ja-no-eval :group! eichar-attack-from-jump-ja :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (compute-alignment! (-> self align))
      (align! (-> self align) (align-opts adjust-quat) (the-as float 1.0) (the-as float 1.0) (the-as float 1.0))
      (suspend)
      (ja :num! (seek!))
      )
    (ja :group! eichar-attack-from-jump-loop-ja :num! min)
    (let ((f30-0 393216.0))
      (let ((f0-8 (target-height-above-ground))
            (f1-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
            )
        (while (not (or (and (< (fabs (/ f0-8 (* 0.0033333334 f1-1))) 150.0) (< f1-1 0.0))
                        (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 1.7))
                        )
                    )
          (quaternion-rotate-y!
            (-> self control unknown-quaternion00)
            (-> self control unknown-quaternion00)
            (* f30-0 (-> *display* seconds-per-frame))
            )
          (suspend)
          (ja :num! (loop!))
          (set! f0-8 (target-height-above-ground))
          (set! f1-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
          )
        )
      (ja-no-eval :group! eichar-attack-from-jump-end-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (cond
          ((< (ja-aframe-num 0) 32.0)
           (quaternion-rotate-y!
             (-> self control unknown-quaternion00)
             (-> self control unknown-quaternion00)
             (* f30-0 (-> *display* seconds-per-frame))
             )
           )
          (else
            (let ((f0-22
                    (deg-diff
                      (quaternion-y-angle (-> self control unknown-quaternion00))
                      (quaternion-y-angle (-> self control dir-targ))
                      )
                    )
                  )
              (quaternion-rotate-y!
                (-> self control unknown-quaternion00)
                (-> self control unknown-quaternion00)
                (* 0.2 (fabs f0-22))
                )
              )
            )
          )
        (suspend)
        (ja :num! (seek!))
        )
      )
    (go target-falling #f)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-attack-uppercut (target)
  :event target-dangerous-event-handler
  :enter (behavior ((arg0 float) (arg1 float))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (target-start-attack)
    (target-danger-set! 'uppercut #f)
    (set! (-> self control unknown-surface00) *turn-around-mods*)
    (none)
    )
  :exit target-exit
  :code (behavior ((arg0 float) (arg1 float))
    (let ((s3-0 (ja-group? eichar-duck-stance-ja)))
      (ja-no-eval :group! eichar-attack-uppercut-ja
                  :num! (seek! (ja-aframe (the-as float 7.0) 0))
                  :frame-num (the-as float (if s3-0
                                    (ja-aframe (the-as float 5.0) 0)
                                    0.0
                                    )
                          )
                  )
      )
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek! (ja-aframe (the-as float 7.0) 0)))
      )
    (go target-attack-uppercut-jump arg0 arg1)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-attack-uppercut-jump (target)
  :event target-dangerous-event-handler
  :enter (behavior ((arg0 float) (arg1 float))
    (if (and (= (-> self control ground-pat material) (pat-material ice))
             (< 32768.0 (-> self control unknown-float01))
             )
        (set-forward-vel (the-as float 32768.0))
        )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #f) (-> self control transv))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (set! (-> self control unknown-surface00) *uppercut-jump-mods*)
    (target-start-attack)
    (target-danger-set! 'uppercut #f)
    (none)
    )
  :exit target-exit
  :trans (behavior ()
    (if (logtest? (-> self control status) (cshape-moving-flags onsurf))
        (go target-hit-ground #f)
        )
    (when (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square)
               (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 22118.4)
               (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
                    (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36))
                        (the-as time-frame (-> *TARGET-bank* stuck-timeout))
                        )
                    (zero? (logand (-> self state-flags) (state-flags prevent-attack)))
                    (zero? (logand (-> self control unknown-surface01 flags) (surface-flags prevent-attacks-during-launch-jump surf08))
                           )
                    )
               )
      (set-quaternion! (-> self control) (-> self control dir-targ))
      (build-conversions (-> self control transv))
      (go
        target-flop
        (the-as float 65502.96)
        (the-as float -163840.0)
        (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0)
                          0.0
                          68812.8
                          )
                )
        )
      )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) circle)
             (can-feet?)
             (ja-group? eichar-attack-uppercut-ja)
             (>= (ja-aframe-num 0) 12.0)
             )
        (go target-attack-air 'uppercut)
        )
    (mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv))
    (when (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
               (>= (-> self fact-info-target eco-level) 1.0)
               )
      (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 23)
      (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.1))
      )
    (if (and (= (-> self control unknown-symbol30) 'uppercut)
             (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) -8192.0)
             )
        (target-danger-set! 'harmless #f)
        )
    (slide-down-test)
    (none)
    )
  :code (behavior ((arg0 float) (arg1 float))
    (compute-alignment! (-> self align))
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek! max 0.9))
      (compute-alignment! (-> self align))
      (let* ((gp-0 (-> self align))
             (s5-0 (method-of-object gp-0 align!))
             (a1-2 (cond
                     ((>= 30.0 (ja-aframe-num 0))
                      18
                      )
                     ((>= 43.0 (ja-aframe-num 0))
                      (set! (-> self control unknown-surface00) *double-jump-mods*)
                      2
                      )
                     (else
                       0
                       )
                     )
                   )
             )
        (s5-0 gp-0 (the-as align-opts a1-2) (the-as float 1.0) (the-as float 0.95) (the-as float 1.0))
        )
      )
    (go target-falling #f)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-flop (target)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3)))
      (cond
        (v0-0
          (empty)
          v0-0
          )
        ((let ((v1-0 arg2))
           (= v1-0 'swim)
           )
         (cond
           ((< 6144.0 (target-height-above-ground))
            (dummy-10 (-> self skel effect) 'swim-flop (the-as float -1.0) -1)
            (let ((t9-3 enter-state))
              (set! (-> self next-state) target-swim-down)
              ((the-as (function object :behavior target) t9-3))
              )
            )
           (else
             (let ((t9-4 enter-state)
                   (a0-4 'swim)
                   )
               (set! (-> self next-state) target-flop-hit-ground)
               ((the-as (function symbol object :behavior target) t9-4) a0-4)
               )
             )
           )
         )
        (else
          (target-dangerous-event-handler arg0 arg1 arg2 arg3)
          )
        )
      )
    )
  :enter (behavior ((arg0 float) (arg1 float) (arg2 float))
    (if (and (= (-> self fact-info-target eco-type) (pickup-type eco-yellow))
             (>= (-> self fact-info-target eco-level) 1.0)
             )
        (go target-yellow-jump-blast)
        )
    (if (= arg2 0.0)
        (set-forward-vel arg2)
        (set-forward-vel (-> self control unknown-float01))
        )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
    (set! (-> self control unknown-surface00) *flop-mods*)
    (set! (-> self control unknown-uint20) (the-as uint 0))
    (set! (-> self control dynam gravity-max) 245760.0)
    (set! (-> self control dynam gravity-length) 245760.0)
    (let ((gp-1 (new-stack-vector0)))
      (let ((f0-6 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))))
        0.0
        (vector-! gp-1 (-> self control transv) (vector-float*! gp-1 (-> self control dynam gravity-normal) f0-6))
        )
      (let* ((f0-7 (vector-length gp-1))
             (f1-3 f0-7)
             (f2-0 29491.2)
             )
        (vector+!
          (-> self control transv)
          (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-0)
          (vector-float*! gp-1 gp-1 (/ f0-7 f1-3))
          )
        )
      )
    (none)
    )
  :exit (behavior ()
    (target-danger-set! 'harmless #f)
    (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max))
    (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length))
    (set! (-> self control dynam gravity quad) (-> self control unknown-dynamics00 gravity quad))
    (none)
    )
  :trans (behavior ()
    (delete-back-vel)
    (let ((gp-1 (logtest? (-> self control status) (cshape-moving-flags onsurf))))
      (when (and (not gp-1) (let ((v1-6 (ja-group)))
                              (or (= v1-6 eichar-flop-down-loop-ja) (= v1-6 eichar-moving-flop-down-ja))
                              )
                 )
        (when (and (or (< (target-move-dist (seconds 0.1)) 1638.4)
                       (and (logtest? (-> self control status) (cshape-moving-flags twall)) (< 0.7 (-> self control poly-angle)))
                       )
                   (zero? (logand (-> self control status) (cshape-moving-flags t-act)))
                   (>= (-> self control unknown-uint20) (the-as uint 2))
                   )
          (set! (-> self control unknown-dword36) (-> *display* base-frame-counter))
          (set! gp-1 'stuck)
          )
        )
      (when gp-1
        (logior! (-> self control status) (cshape-moving-flags onsurf))
        (when (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
                   (>= (-> self fact-info-target eco-level) 1.0)
                   )
          (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.5))
          (dummy-10 (-> self skel effect) 'group-red-eco-strike-ground (ja-frame-num 0) 0)
          (let ((s5-1 (process-spawn touch-tracker :init touch-tracker-init (-> self control trans) 4096.0 30 :to self)))
            (send-event (ppointer->process s5-1) 'event 'attack 'flop)
            (send-event
              (ppointer->process s5-1)
              'function
              (lambda ((arg0 target)) (let ((f0-3 (seek
                                                    (-> arg0 control root-prim local-sphere w)
                                                    (the-as float 28672.0)
                                                    (* 286720.0 (-> *display* seconds-per-frame))
                                                    )
                                                  )
                                            )
                                        (set! (-> arg0 control root-prim local-sphere w) f0-3)
                                        f0-3
                                        )
                      )
              )
            )
          )
        (go target-flop-hit-ground gp-1)
        )
      )
    (when (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
               (>= (-> self fact-info-target eco-level) 1.0)
               )
      (dummy-10
        (-> self skel effect)
        'group-red-eco-spinkick
        (ja-frame-num 0)
        (if (rand-vu-percent? (the-as float 0.5))
            23
            17
            )
        )
      (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.1))
      )
    (when (and (not (-> self control unknown-symbol30)) (ja-group? eichar-flop-down-ja) (>= (ja-aframe-num 0) 8.0))
      (target-start-attack)
      (target-danger-set! 'flop #f)
      )
    (none)
    )
  :code (behavior ((arg0 float) (arg1 float) (arg2 float))
    (ja-channel-set! 2)
    (ja-no-eval :group! eichar-flop-down-ja :num! (seek!) :frame-num 0.0)
    (ja :chan 1 :group! eichar-moving-flop-down-ja :num! (chan 0) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      (ja :chan 1 :num! (seek!) :frame-interp (lerp-scale
                                                (the-as float 0.0)
                                                (the-as float 1.0)
                                                (-> self control unknown-float01)
                                                (the-as float 0.0)
                                                (the-as float 40960.0)
                                                )
          )
      )
    (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length))
    (set! (-> self control dynam gravity quad) (-> self control unknown-dynamics00 gravity quad))
    (target-danger-set! 'flop-down #f)
    (ja :group! eichar-flop-down-loop-ja :num! min)
    (ja :chan 1 :group! eichar-moving-flop-down-loop-ja :num! min)
    (let ((f30-0 1.0))
      (let ((gp-3 (new-stack-vector0)))
        (let ((f0-18 (vector-dot (-> self control dynam gravity-normal) (-> self control unknown-vector120))))
          0.0
          (vector-!
            gp-3
            (-> self control unknown-vector120)
            (vector-float*! gp-3 (-> self control dynam gravity-normal) f0-18)
            )
          )
        (let* ((f0-19 (vector-length gp-3))
               (f1-1 f0-19)
               (f2-0 -368640.0)
               )
          (vector+!
            (-> self control unknown-vector120)
            (vector-float*! (-> self control unknown-vector120) (-> self control dynam gravity-normal) f2-0)
            (vector-float*! gp-3 gp-3 (/ f0-19 f1-1))
            )
          )
        )
      (let ((gp-4 (new-stack-vector0)))
        (let ((f0-22 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))))
          0.0
          (vector-! gp-4 (-> self control transv) (vector-float*! gp-4 (-> self control dynam gravity-normal) f0-22))
          )
        (let* ((f0-23 (vector-length gp-4))
               (f1-3 f0-23)
               (f2-2 (* -368640.0 f30-0))
               )
          (vector+!
            (-> self control transv)
            (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-2)
            (vector-float*! gp-4 gp-4 (/ f0-23 f1-3))
            )
          )
        )
      (suspend)
      (loop
        (+! (-> self control unknown-uint20) 1)
        (ja :num! (+!))
        (ja :chan 1 :num! (chan 0) :frame-interp (lerp-scale
                                                   (the-as float 0.0)
                                                   (the-as float 1.0)
                                                   (-> self control unknown-float01)
                                                   (the-as float 0.0)
                                                   (the-as float 40960.0)
                                                   )
            )
        (set! f30-0 (* f30-0 (fmin 1.0 (-> self control unknown-float140))))
        (let ((gp-6 (new-stack-vector0))
              (f28-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
              )
          0.0
          (vector-! gp-6 (-> self control transv) (vector-float*! gp-6 (-> self control dynam gravity-normal) f28-0))
          (let* ((f1-5 (vector-length gp-6))
                 (f0-34 f1-5)
                 )
            (if (< (-> self control unknown-surface01 transv-max) f1-5)
                (set! f1-5 (-> self control unknown-surface01 transv-max))
                )
            (vector+!
              (-> self control transv)
              (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f28-0)
              (vector-float*! gp-6 gp-6 (/ f1-5 f0-34))
              )
            )
          )
        (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> *TARGET-bank* fall-timeout))
            (go target-falling #f)
            )
        (if (and (= *cheat-mode* 'debug) (cpad-hold? (-> self control unknown-cpad-info00 number) r2) (not *pause-lock*))
            (go target-falling #f)
            )
        (suspend)
        )
      )
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-flop-hit-ground (target)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('swim)
       #f
       )
      (else
        (target-standard-event-handler arg0 arg1 arg2 arg3)
        )
      )
    )
  :enter (behavior ((arg0 symbol))
    (let ((f0-1 (vector-dot
                  (-> self control dynam gravity-normal)
                  (vector-! (new 'stack-no-clear 'vector) (-> self control unknown-vector111) (-> self control trans))
                  )
                )
          )
      (if (< (-> *TARGET-bank* fall-far) f0-1)
          (go target-hit-ground-hard f0-1)
          )
      )
    (target-land-effect)
    (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.1))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self control unknown-uint20) (the-as uint arg0))
    (set-forward-vel (the-as float 0.0))
    (set! (-> self control unknown-surface00) *flop-land-mods*)
    (logclear! (-> *flop-land-mods* flags) (surface-flags allow-edge-grab))
    (set! (-> self state-flags) (logior (state-flags flop-hit-ground) (-> self state-flags)))
    (none)
    )
  :exit target-exit
  :trans (behavior ()
    (when (!= (-> self control unknown-spoolanim00) 'stuck)
      (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) circle) (can-feet?))
          (go target-attack-air 'flop)
          )
      )
    (when (and (and (= (-> self fact-info-target eco-type) (pickup-type eco-red))
                    (>= (-> self fact-info-target eco-level) 1.0)
                    )
               (< (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.25))
               )
      (dummy-10
        (-> self skel effect)
        'group-red-eco-spinkick
        (ja-frame-num 0)
        (if (rand-vu-percent? (the-as float 0.5))
            23
            17
            )
        )
      (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.1))
      )
    (let ((v1-33 (ja-group)))
      (if (and (or (= v1-33 eichar-flop-down-land-ja) (= v1-33 eichar-moving-flop-down-land-ja))
               (>= (ja-aframe-num 0) 28.0)
               )
          (logior! (-> *flop-land-mods* flags) (surface-flags allow-edge-grab))
          )
      )
    (slide-down-test)
    (none)
    )
  :code (behavior ((arg0 symbol))
    (target-hit-ground-anim arg0)
    (go target-falling #f)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-wheel (target)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (if (= arg2 'touched)
        (send-event arg0 'roll)
        )
    (target-standard-event-handler arg0 arg1 arg2 arg3)
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self control unknown-surface00) *wheel-mods*)
    (+! (-> self control unknown-int50) 1)
    (rot->dir-targ! (-> self control))
    (set-forward-vel (+ (-> *TARGET-bank* wheel-speed-min)
                        (* (-> *TARGET-bank* wheel-speed-inc) (the float (+ (-> self control unknown-int50) -1)))
                        )
                     )
    (if (or (< (fabs (-> self control unknown-float62)) 0.3) (< 0.3 (fabs (-> self control unknown-float61))))
        (set! (-> self control unknown-float81) 1.0)
        )
    (set! (-> self control unknown-uint20) (the-as uint 0))
    (set! (-> self control unknown-int21) 0)
    0
    (none)
    )
  :exit (behavior ()
    (when (!= (-> self next-state name) 'target-wheel)
      (set! (-> self control unknown-int50) 0)
      (set! (-> self control unknown-dword30) (-> *display* base-frame-counter))
      )
    (target-exit)
    (none)
    )
  :code (behavior ()
    (let ((gp-0 0))
      0
      (let ((s5-0 0)
            (f30-0 1.0)
            )
        (ja-channel-push! 1 (seconds 0.04))
        (ja :group! eichar-duck-roll-ja :num! min)
        (until (ja-done? 0)
          (if (cpad-pressed? (-> self control unknown-cpad-info00 number) x)
              (set! gp-0 (the-as int (-> *display* base-frame-counter)))
              )
          (when (and (or (smack-surface? #f) (>= (-> self control unknown-float63) 0.7))
                     (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint20))))
                         (the-as uint 3)
                         )
                     (>= (- (-> *display* base-frame-counter) (-> self state-time)) 1)
                     )
            (if (>= 6.0 (ja-aframe-num 0))
                (target-shoved
                  (-> *TARGET-bank* smack-surface-dist)
                  (-> *TARGET-bank* smack-surface-height)
                  (the-as process #f)
                  target-hit
                  )
                )
            (if (zero? s5-0)
                (set! s5-0 (the-as int (-> *display* base-frame-counter)))
                )
            )
          (if (cpad-pressed? (-> self control unknown-cpad-info00 number) square)
              (-> *display* base-frame-counter)
              )
          (compute-alignment! (-> self align))
          (cond
            ((nonzero? s5-0)
             )
            (else
              (align! (-> self align) (align-opts adjust-xz-vel) (the-as float 1.0) (the-as float 1.0) f30-0)
              (let ((s4-1 (new-stack-vector0)))
                (vector-matrix*! s4-1 (-> self control transv) (-> self control unknown-matrix00))
                (set! (-> s4-1 y) 0.0)
                (vector-matrix*! (-> self control unknown-vector120) s4-1 (-> self control unknown-matrix01))
                )
              )
            )
          (suspend)
          (ja :num! (seek!))
          (set! f30-0 (* f30-0 (fmin 1.0 (-> self control unknown-float140))))
          )
        )
      (if (and (or (< (- (-> *display* base-frame-counter) (the-as time-frame gp-0)) (-> *TARGET-bank* wheel-jump-pre-window))
                   (cpad-pressed? (-> self control unknown-cpad-info00 number) x)
                   )
               (can-jump? 'target-wheel-flip)
               )
          (go target-wheel-flip (-> *TARGET-bank* wheel-flip-height) (-> *TARGET-bank* wheel-flip-dist))
          )
      )
    (set! (-> self state-hook-time) (-> *display* base-frame-counter))
    (set! (-> self state-hook)
          (lambda :behavior target
            ()
            (cond
              ((>= (- (-> *display* base-frame-counter) (-> self state-hook-time)) (-> *TARGET-bank* wheel-jump-post-window))
               (set! (-> self state-hook) (the-as (function none :behavior target) nothing))
               )
              (else
                (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                                   (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                                   )
                                           (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                                           )
                                   (pad-buttons x)
                                   )
                         (can-jump? 'target-wheel-flip)
                         )
                    (go target-wheel-flip (-> *TARGET-bank* wheel-flip-height) (-> *TARGET-bank* wheel-flip-dist))
                    )
                )
              )
            (none)
            )
          )
    (go target-duck-stance)
    (none)
    )
  :post target-post
  )

;; failed to figure out what this is:
(defstate target-wheel-flip (target)
  :event target-standard-event-handler
  :enter (behavior ((arg0 float) (arg1 float))
    (set! (-> self control unknown-surface00) *wheel-flip-mods*)
    (none)
    )
  :exit target-exit
  :trans (behavior ()
    (if (and (or (smack-surface? #f)
                 (< (target-move-dist (-> *TARGET-bank* stuck-time)) (-> *TARGET-bank* stuck-distance))
                 )
             (!= (-> self state-time) (-> *display* base-frame-counter))
             )
        (target-shoved
          (-> *TARGET-bank* smack-surface-dist)
          (-> *TARGET-bank* smack-surface-height)
          (the-as process #f)
          target-hit
          )
        )
    (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) circle)
             (can-feet?)
             (and (ja-group? eichar-jump-loop-ja) (= (-> self skel root-channel 0) (-> self skel channel)))
             )
        (go target-attack-air #f)
        )
    (none)
    )
  :code (behavior ((arg0 float) (arg1 float))
    (ja-channel-push! 1 (seconds 0.04))
    (ja :group! eichar-wheel-flip-ja :num! min)
    (let ((f30-0 1.0))
      (until (or (ja-max? 0)
                 (and (>= (ja-aframe-num 0) 4.0) (logtest? (-> self control status) (cshape-moving-flags onsurf)))
                 )
        (when (and (>= (ja-aframe-num 0) 3.0) (not (-> self control unknown-symbol30)))
          (set! (-> self event-hook) target-dangerous-event-handler)
          (target-start-attack)
          (target-danger-set! 'flip #f)
          )
        (compute-alignment! (-> self align))
        (if (not (ja-max? 0))
            (align!
              (-> self align)
              (align-opts adjust-y-vel adjust-xz-vel)
              (the-as float 1.0)
              (/ arg0 (-> *TARGET-bank* wheel-flip-art-height))
              (* f30-0 (/ arg1 (-> *TARGET-bank* wheel-flip-art-dist)))
              )
            (align!
              (-> self align)
              (align-opts adjust-xz-vel)
              (the-as float 1.0)
              (the-as float 1.0)
              (* f30-0 (/ arg1 (-> *TARGET-bank* wheel-flip-art-dist)))
              )
            )
        (let ((s4-1 (new-stack-vector0)))
          (vector-matrix*! s4-1 (-> self control transv) (-> self control unknown-matrix00))
          (set! (-> s4-1 y) 0.0)
          (vector-matrix*! (-> self control unknown-vector120) s4-1 (-> self control unknown-matrix01))
          )
        (suspend)
        (ja :num! (seek!))
        (set! f30-0 (* f30-0 (fmin 1.0 (-> self control unknown-float140))))
        )
      )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (while (zero? (logand (-> self control status) (cshape-moving-flags onsurf)))
      (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.01))
        (when (not (ja-group? eichar-jump-loop-ja))
          (ja-channel-push! 1 (seconds 0.1))
          (ja :group! eichar-jump-loop-ja :num! min)
          )
        )
      (let ((gp-2 (new-stack-vector0))
            (f30-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))
            )
        0.0
        (vector-! gp-2 (-> self control transv) (vector-float*! gp-2 (-> self control dynam gravity-normal) f30-1))
        (let* ((f1-6 (vector-length gp-2))
               (f0-21 f1-6)
               (f1-7 (* 0.9 f1-6))
               )
          (vector+!
            (-> self control transv)
            (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f30-1)
            (vector-float*! gp-2 gp-2 (/ f1-7 f0-21))
            )
          )
        )
      (suspend)
      (if (ja-group? eichar-jump-loop-ja)
          (ja :num! (loop!))
          (ja :num-func num-func-identity :frame-num max)
          )
      )
    (target-land-effect)
    (set! (-> self state-hook-time) (-> *display* base-frame-counter))
    (set! (-> self state-hook)
          (lambda :behavior target
            ()
            (cond
              ((>= (- (-> *display* base-frame-counter) (-> self state-hook-time)) (seconds 0.1))
               (set! (-> self state-hook) (the-as (function none :behavior target) nothing))
               )
              (else
                (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0)
                                                   (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1)
                                                   )
                                           (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2)
                                           )
                                   (pad-buttons x)
                                   )
                         (can-jump? #f)
                         )
                    (go target-high-jump (-> *TARGET-bank* flip-jump-height-min) (-> *TARGET-bank* flip-jump-height-max) 'flip)
                    )
                )
              )
            (none)
            )
          )
    (if (ja-group? eichar-jump-loop-ja)
        (go target-hit-ground #f)
        (go target-stance)
        )
    (none)
    )
  :post target-post
  )
