Files
jak-project/goal_src/jak1/engine/target/target.gc
T
Hat Kid 122de4ecf5 jak1: clean up control-info names and other misc cleanup (#4295)
After spending the last month staring at and comparing Jak 3 and Jak 1
versions of a bunch of `target` code for my jetboard mod, I figured this
would be a good opportunity to revive this ancient PR #1714 along with
some other small misc fixes/improvements.

Instead of directly replacing the old fields, I decided to opt for using
overlay fields to maintain backwards compatibility with existing manual
patches, files without ref tests and mods that might use these fields.
2026-05-31 15:08:41 +02:00

1925 lines
101 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/target/target-handler.gc")
;; note: changed for high fps
;; TODO - almost all of these are in target-handler or target2, temporary
(define-extern target-state-hook-exit (function none :behavior target))
(define-extern target-effect-exit (function none :behavior target))
(define-extern target-post (function none :behavior target))
(define-extern target-walk-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-land-effect (function none :behavior target))
(define-extern target-dangerous-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-standard-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-jump-event-handler (function process int symbol event-message-block object :behavior target))
(define-extern target-shoved (function meters meters process (state object object target) object :behavior target))
(define-extern target-send-attack (function process uint touching-shapes-entry int int symbol :behavior target))
(define-extern target-bonk-event-handler (function process int symbol event-message-block object :behavior target))
;; DECOMP BEGINS
(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 (current-time)))
(while (or (= arg0 -1) (not (time-elapsed? s5-1 arg0)))
(suspend)
(ja :group! eichar-jump-loop-ja :num! (loop!))))
#f)
(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))
(defbehavior target-falling-trans target ((arg0 basic) (arg1 time-frame))
(if (and (cpad-pressed? (-> self control cpad number) circle) (can-feet?)) (go target-attack-air #f))
(when (= arg0 'target-eco-powerup)
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? x)
(not (logtest? (-> self water flags) (water-flags wt09)))
(not (time-elapsed? (-> self state-time) (seconds 3)))
(not (logtest? (-> 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)
(time-elapsed? (-> self state-time) arg1)
(not (and *cheat-mode* (cpad-hold? (-> self control cpad number) r2))))
#t)
(logior! (-> self control status) (cshape-moving-flags onsurf))
(go target-hit-ground 'stuck))
(if (!= (-> self state-time) (current-time)) (slide-down-test))
0
(none))
(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 cpad number) stick0-speed) 0.0) (< (-> self control ctrl-xz-vel) 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 (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)
(if gp-0 (align-opts adjust-y-vel) (align-opts adjust-y-vel adjust-xz-vel))
(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 cpad 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 (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 ctrl-xz-vel))) #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))))
(defstate target-startup (target)
:event target-standard-event-handler
:code
(behavior ()
(suspend)
(suspend)
(go target-stance))
:post target-no-move-post)
(defstate target-stance (target)
:event target-standard-event-handler
:enter
(behavior ()
(set! (-> self control mod-surface) *walk-mods*)
(set-time! (-> self state-time)))
:exit
(behavior ()
(set! (-> self control bend-target) 0.0)
(target-state-hook-exit))
:trans
(behavior ()
((-> self state-hook))
(if (logtest? (-> self water flag) (water-flag wading)) (go target-wade-stance))
(when (= (-> self control ground-pat material) (pat-material ice))
(set! (-> self control bend-target) 0.0)
(remove-exit)
(go target-ice-stance))
(when (move-legs?)
(set! (-> self control bend-target) 0.0)
(remove-exit)
(go target-walk))
(when (and (cpad-hold? (-> self control cpad number) l1 r1) (can-duck?))
(set! (-> self control bend-target) 0.0)
(remove-exit)
(go target-duck-stance))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? x) (can-jump? #f))
(go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? circle) (can-feet?)) (go target-attack))
(if (can-hands? #t) (go target-running-attack))
(slide-down-test)
(fall-test))
: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 bend-target) (-> self control bend-amount))
(set! (-> self control mod-surface) *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 bend-target) (the-as float 0.0) (seconds-per-frame))
(suspend)
(ja :num! (seek!)))
(set! (-> self control mod-surface) *walk-mods*)
(set! (-> self control bend-target) 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 local-slope-z) (-> self control local-slope-x))
(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 local-slope-z) (-> self control local-slope-x))
(suspend)
(ja :num! (seek!))
(ja :chan 1 :num! (chan 0))
(ja :chan 2 :num! (chan 0))))
((and (ja-group? eichar-walk-ja) (>= (-> self control ctrl-xz-vel) 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 local-slope-z) (-> self control local-slope-x))
(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)))))
:post target-post)
(defstate target-walk (target)
:event target-walk-event-handler
:enter
(behavior ()
(set-time! (-> self state-time))
(set! (-> self control mod-surface) *walk-mods*))
:exit
(behavior ()
(target-effect-exit)
(target-state-hook-exit))
:trans
(behavior ()
((-> self state-hook))
(when (= (-> self control ground-pat material) (pat-material ice))
(target-effect-exit)
(remove-exit)
(go target-ice-walk))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? l1 r1)
(and (time-elapsed? (-> *TARGET-bank* wheel-timeout) (-> self control unknown-dword30))
(and (!= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) (can-wheel?))))
(go target-wheel))
(when (and (cpad-hold? (-> self control cpad 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))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? x) (can-jump? #f))
(go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? circle) (can-feet?)) (go target-attack))
(if (can-hands? #t) (go target-running-attack))
(when (and (turn-around?) (time-elapsed? (-> self state-time) (seconds 0.3)))
(set! (-> self control transv quad) (-> self control transv-history (-> self control idx-of-fastest-xz-vel) quad))
(set! (-> self control transv w) 1.0)
(go target-turn-around))
(slide-down-test)
(fall-test))
:code
(behavior ()
(let ((f28-0 0.0)
(f30-0 (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -16384.0 (-> self control ctrl-xz-vel))))))
(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 (/ (-> self control ctrl-xz-vel) (meters 5))))))
(cond
((and (rand-vu-percent? (the-as float 0.3)) (< 20480.0 (-> self control ctrl-xz-vel)))
(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? eichar-ice-skate-ja) (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 ctrl-xz-vel))))
(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)
;; This controls the slow walk animation that occurs after landing from a jump. > 60fps was broken here so I think should not be tied to seconds-per-frame
;; unknown-float01 is the magnitude of xz velocity
(ja :num!
(seek! max
(/ (* (fmax 20480.0 (-> self control unknown-float01))
(if (= (-> *setting-control* current video-mode) 'custom) 0.016666668 (-> *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 local-slope-z)))))
(f24-0 (fmax -1.0 (fmin 1.0 (* 1.6 (-> self control local-slope-x))))))
(set! f30-0
(seek f30-0
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -16384.0 (-> self control ctrl-xz-vel)))))
(* 2.0 (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 (/ f0-64 4))))))
(let ((f0-69 (fabs (- f24-0 f26-1)))) (set! f26-1 (seek f26-1 f24-0 (fmax 0.05 (fmin 0.2 (/ f0-69 4)))))))
(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 ctrl-xz-vel) (* 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)))))
:post target-post)
(defstate target-turn-around (target)
:event target-standard-event-handler
:enter
(behavior ()
(vector-turn-to (-> self control transv))
(set! (-> self control mod-surface) *turn-around-mods*)
(set! (-> self control bend-target) 1.0))
:exit
(behavior ()
(target-state-hook-exit)
(set-forward-vel (the-as float 0.0))
(set! (-> self control ctrl-xz-vel) 0.0)
(set-quaternion! (-> self control) (-> self control dir-targ))
(set! (-> self control bend-target) 0.0))
:trans
(behavior ()
((-> self state-hook))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? 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 cpad number) circle) (can-feet?)) (go target-attack))
(if (can-hands? #t) (go target-running-attack))
(if (and (not (logtest? (-> self control status) (cshape-moving-flags onsurf)))
(time-elapsed? (-> self control last-time-on-surface) (seconds 0.08)))
(go target-falling #f))
(slide-down-test))
: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 bend-target) 0.0)
(set-forward-vel (the-as float 40960.0))
(set! (-> self control ctrl-xz-vel) 40960.0)
(target-state-hook-exit)
(go target-walk))
:post target-no-stick-post)
(defstate target-slide-down (target)
:event target-walk-event-handler
:enter
(behavior ()
(set! (-> self control mod-surface) *jump-mods*))
:exit
(behavior ()
(set-time! (-> self control unknown-dword35)))
: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)))
: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!)))))
:post target-post)
(defbehavior init-var-jump target ((arg0 float) (arg1 float) (arg2 vector) (arg3 vector) (arg4 vector))
(logclear! (-> self control status) (cshape-moving-flags t-ceil-sticky))
(delete-back-vel)
(when (not (time-elapsed? (-> 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 current-surface 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 did-move-to-pole-or-max-jump-height)
(the-as int (- arg1 (-> *TARGET-bank* jump-collide-offset)))))
(else
(set! (-> self control unknown-uint20) (the-as uint arg0))
(set! (-> self control did-move-to-pole-or-max-jump-height) (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))
(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 (- (current-time) (-> 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))
(defstate target-duck-stance (target)
:event target-standard-event-handler
:enter
(behavior ()
(set! (-> self control bend-target) 1.0)
(set! (-> self control mod-surface) *duck-mods*)
(target-collide-set! 'duck (the-as float 1.0)))
: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)))
:trans
(behavior ()
((-> self state-hook))
(if (and (or (not (cpad-hold? (-> self control cpad number) 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))
;; og:preserve-this - High FPS Fix
(when (and (recently-pressed? 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))
: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!)))))
:post target-post)
(defstate target-duck-walk (target)
:event target-standard-event-handler
:enter
(behavior ()
(set! (-> self control bend-target) 1.0)
(target-collide-set! 'duck (the-as float 1.0))
(if (not (ja-group? eichar-duck-roll-ja)) (set! (-> self control mod-surface) *duck-mods*)))
:exit
(-> target-duck-stance
exit)
:trans
(behavior ()
((-> self state-hook))
(if (and (or (not (cpad-hold? (-> self control cpad number) l1 r1))
(logtest? (-> self state-flags) (state-flags prevent-duck))
(and (logtest? (-> self water flag) (water-flag wading))
(>= (- (- (-> 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))
;; og:preserve-this - High FPS Fix
(when (and (recently-pressed? 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))
: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 mod-surface) *duck-mods*))
(ja :num!
(loop! (fmin 1.0
(/ (-> self control ctrl-xz-vel)
(* 60.0 (/ (-> *TARGET-bank* duck-walk-cycle-dist) (-> *TARGET-bank* run-cycle-length)))))))
(suspend)))
:post target-post)
(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 (text-id sidekick-launcher1) "sksp009d" (the-as entity #f) *entity-pool* (game-task none))
(level-hint-spawn (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 (text-id citadel-launcher2) "sksp0393" (the-as entity #f) *entity-pool* (game-task none))
(level-hint-spawn (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-time! (-> self state-time))
(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 mod-surface) arg2)
(set! (-> self control unknown-float123)
(fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control ctrl-xz-vel))))))
(set! (-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control ctrl-xz-vel)))))))
: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 (abutton-idx x)))))) ;; og:preserve-this abutton indexing
(target-falling-trans #f (the-as time-frame (if (ja-group? eichar-jump-loop-ja) 15 -1)))
(if (and (cpad-pressed? (-> self control cpad 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)))
(not (logtest? (-> self water flag) (water-flag touch-water)))
(not (logtest? (-> 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 cpad 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)))
(time-elapsed? (-> self control last-time-of-stuck) (the-as time-frame (-> *TARGET-bank* stuck-timeout)))
(not (logtest? (-> self state-flags) (state-flags prevent-attack)))
(not (logtest? (-> self control current-surface 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 cpad number) stick0-speed) 0.0) 0.0 68812.8))))
(mod-var-jump #t #t (cpad-hold? (-> self control cpad 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 ctrl-xz-vel)))))
(seconds-per-frame)))
: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)))
:post target-post)
(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 mod-surface) *forward-jump-mods*))
: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!))))
:post target-post)
(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-time! (-> self state-time))
(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 mod-surface) *double-jump-mods*))
: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 cpad 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)))
(time-elapsed? (-> self control last-time-of-stuck) (the-as time-frame (-> *TARGET-bank* stuck-timeout)))
(not (logtest? (-> self state-flags) (state-flags prevent-attack)))
(not (logtest? (-> self control current-surface 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 cpad number) stick0-speed) 0.0) 0.0 68812.8))))
(if (!= (-> self state-time) (current-time))
(mod-var-jump #t #t (cpad-hold? (-> self control cpad number) x) (-> self control transv)))
(seek! (-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control ctrl-xz-vel)))))
(seconds-per-frame)))
:code
(behavior ((arg0 float) (arg1 float))
(ja-channel-push! 2 (seconds 0.05))
(effect-control-method-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)))
:post target-post)
(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-time! (-> self state-time))
(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 mod-surface)
(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 ctrl-xz-vel)))))))
:exit target-exit
:trans
(behavior ()
(target-falling-trans #f (the-as time-frame (if (ja-group? eichar-jump-loop-ja) 15 -1)))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? 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)))
(time-elapsed? (-> self control last-time-of-stuck) (the-as time-frame (-> *TARGET-bank* stuck-timeout)))
(not (logtest? (-> self state-flags) (state-flags prevent-attack)))
(not (logtest? (-> self control current-surface 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 cpad number) stick0-speed) 0.0) 0.0 68812.8))))
(mod-var-jump #t #t (cpad-hold? (-> self control cpad number) x) (-> self control transv))
(seek! (-> self control unknown-float122)
(fmax 0.0 (fmin 1.0 (* 0.00012207031 (+ -2048.0 (-> self control ctrl-xz-vel)))))
(seconds-per-frame)))
:code
(-> target-jump
code)
:post target-post)
(defstate target-duck-high-jump (target)
:event target-standard-event-handler
:enter
(behavior ((arg0 float) (arg1 float) (arg2 symbol))
(set-time! (-> self state-time))
(logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
(set! (-> self control mod-surface) *turn-around-mods*))
: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)
;; og:preserve-this PAL patch here
(set! (-> self control unknown-soundid01) (sound-play "launch-fire"))
(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)
(let ((s3-2 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
(set! (-> s3-2 command) (sound-command set-param))
(set! (-> s3-2 id) (-> self control unknown-soundid01))
(let ((a1-5 (ear-trans)))
(let ((s2-1 self))
(when (= a1-5 #t)
(if (and s2-1 (type-type? (-> s2-1 type) process-drawable) (nonzero? (-> s2-1 control)))
(set! a1-5 (-> s2-1 control trans))
(set! a1-5 (the-as vector #f)))))
(sound-trans-convert (-> s3-2 parms trans) a1-5))
(set! (-> s3-2 parms mask) (sound-mask trans))
(-> s3-2 id))
(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))
:post target-post)
(defstate target-duck-high-jump-jump (target)
:event target-jump-event-handler
:enter
(behavior ((arg0 float) (arg1 float) (arg2 symbol))
(set-time! (-> self state-time))
(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 mod-surface) *launch-jump-mods*))
(else (set! (-> self control mod-surface) *high-jump-mods*))))
:exit target-exit
;; og:preserve-this PAL patch here
:trans
(behavior ()
((-> target-high-jump trans))
(case (-> self control unknown-int37)
(('launch)
(let ((gp-0 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
(set! (-> gp-0 command) (sound-command set-param))
(set! (-> gp-0 id) (-> self control unknown-soundid01))
(let ((a1-0 (ear-trans)))
(let ((s5-0 self))
(when (= a1-0 #t)
(if (and s5-0 (type-type? (-> s5-0 type) process-drawable) (nonzero? (-> s5-0 control)))
(set! a1-0 (-> s5-0 control trans))
(set! a1-0 (the-as vector #f)))))
(sound-trans-convert (-> gp-0 parms trans) a1-0))
(set! (-> gp-0 parms mask) (sound-mask trans))
(-> gp-0 id)))))
: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))
:post target-post)
(defstate target-falling (target)
:event target-jump-event-handler
:enter
(behavior ((arg0 symbol))
(set! (-> self control mod-surface) *jump-mods*)
(set! (-> self control unknown-uint20) (the-as uint arg0))
(set-time! (-> self state-time)))
: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)))))
:code
(behavior ((arg0 symbol))
(target-falling-anim -1 (seconds 0.33)))
:post target-post)
(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)))
(effect-control-method-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 last-trans-any-surf) (-> self control trans)))))
(if (and (< (-> *TARGET-bank* fall-far) f0-1) (not (logtest? (-> 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 last-attack-end-time) 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 mod-surface) *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))
:trans
(behavior ()
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? 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 cpad number) stick0-speed) 0.0)
(if (logtest? (-> self water flag) (water-flag wading)) (go target-wade-walk) (go target-walk)))
(if (and (or (cpad-hold? (-> self control cpad number) l1 r1) (not (can-exit-duck?))) (can-duck?)) (go target-duck-stance))
(if (and (cpad-pressed? (-> self control cpad number) circle) (can-feet?)) (go target-attack))
(if (can-hands? #t) (go target-running-attack))
(fall-test)
(slide-down-test))
:code
(behavior ((arg0 symbol))
(target-hit-ground-anim #f)
(go target-stance))
:post target-post)
(defstate target-attack (target)
:event target-dangerous-event-handler
:enter
(behavior ()
(set-time! (-> self state-time))
(target-start-attack)
(target-danger-set! 'spin #f)
(set! (-> self control mod-surface) *attack-mods*)
(set! (-> self water drip-mult) 4.0)
(set! (-> self neck flex-blend) 0.0))
:exit
(behavior ()
(set-time! (-> self control last-attack-end-time))
(target-exit))
:code
(behavior ()
(ja-channel-push! 1 (seconds 0.05))
(ja-no-eval :group!
eichar-attack-from-stance-ja
:num!
(seek! max (-> self control current-surface align-speed))
:frame-num 0.0)
(until (ja-done? 0)
(when (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(effect-control-method-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 (text-id misty-eco-red-first-use) "sksp0072" (the-as entity #f) *entity-pool* (game-task none)))
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? 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 current-surface align-speed))))
(go target-stance))
:post target-post)
(defstate target-running-attack (target)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touched)
(cond
(((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry (-> block param 0))
(-> self control)
(the-as uint 224))
(let ((gp-1 (target-send-attack proc
(the-as uint (-> self control danger-mode))
(the-as touching-shapes-entry (-> block param 0))
(-> self control target-attack-id)
(-> self control attack-count))))
(when gp-1
(set! (-> self control unknown-uint20) (the-as uint (current-time)))
(let ((v1-9 (if (and (nonzero? proc) (type-type? (-> proc type) process-drawable)) proc)))
(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 attackable))))
(set! (-> self control unknown-uint31) (the-as uint 1))))))
(when (or (= gp-1 'die) (= gp-1 'push))
(let ((v0-2 (the-as object (current-time))))
(set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int v0-2))
v0-2)))))
(else (target-dangerous-event-handler proc argc message block))))
(else (target-dangerous-event-handler proc argc message block))))
:enter
(behavior ()
(if (or (and (= (-> self fact eco-type) (pickup-type eco-yellow)) (>= (-> self fact eco-level) 1.0))
(not (time-elapsed? (-> self control unknown-dword82) (seconds 1.5))))
(go target-yellow-blast))
(set-time! (-> self state-time))
(set! (-> self control unknown-uint20) (the-as uint 0))
(set! (-> self control did-move-to-pole-or-max-jump-height) 0)
(set! (-> self control unknown-uint31) (the-as uint 0))
(set! (-> self control mod-surface) *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 local-slope-x)) 0.3) (< 0.3 (fabs (-> self control local-slope-z))))
(set! (-> self control bend-target) 1.0)))
:exit
(behavior ()
(set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max))
(set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length))
(set! (-> *run-attack-mods* turnv) 0.0)
(set! (-> *run-attack-mods* turnvv) 0.0)
(set-time! (-> self control unknown-dword31))
(target-exit))
:trans
(behavior ()
(when (!= (-> self state-time) (current-time))
(if (and (or (smack-surface? #t)
(and (>= (-> self control surface-slope-z) 0.7) (not (logtest? (-> self control status) (cshape-moving-flags t-act)))))
(begin
(set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int (current-time)))
(set! (-> self control bend-target) 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 (- (current-time) (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 cpad number) x)
(and (< 4096.0 (-> self control ctrl-xz-vel))
(or (time-elapsed? (-> self state-time) (seconds 0.1))
(not (logtest? (-> *cpad-list* cpads (-> self control cpad number) button0-abs 0) (pad-buttons square))))
(not (logtest? (-> self state-flags) (state-flags prevent-jump prevent-attack)))
(not (logtest? (-> self control current-surface 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 flag) (water-flag touch-water)) (zero? (mod (- (current-time) (-> self state-time)) 21)))
(create-splash (-> self water)
(the-as float 0.6)
(vector<-cspace! (new 'stack-no-clear 'vector) (joint-node eichar-lod0-jg mouth))
0
(-> self control transv)))
(when (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(effect-control-method-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 (text-id misty-eco-red-first-use) "sksp0072" (the-as entity #f) *entity-pool* (game-task none)))))
:code
(behavior ()
(if (logtest? (-> self water flag) (water-flag touch-water)) (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 (not (logtest? (-> self control status) (cshape-moving-flags onsurf)))
(time-elapsed? (-> self control last-time-on-surface) (-> *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 (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 12))))
(go target-falling #f))
((and (nonzero? (-> self control unknown-uint30))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint30)))) (the-as uint 12)))
(set-forward-vel (the-as float 0.0)))
((and (not (cpad-hold? (-> self control cpad number) square)) (time-elapsed? (-> 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 ctrl-xz-vel))))
(set-forward-vel (* 0.8 (-> self control ctrl-xz-vel)))))
((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 w-R-c))
(set! (-> s5-1 y) 0.0)
(vector-matrix*! (-> self control unknown-vector120) s5-1 (-> self control c-R-w)))
(suspend)
(ja :num! (seek! max (-> self control current-surface align-speed)))
(if (time-elapsed? (-> 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 (not (logtest? (-> self control status) (cshape-moving-flags onsurf)))
(time-elapsed? (-> self control last-time-on-surface) (-> *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))
:post target-post)
(defstate target-attack-air (target)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(let ((v0-0 (target-bonk-event-handler proc argc message block)))
(cond
(v0-0 (empty) v0-0)
(else (target-dangerous-event-handler proc argc message block)))))
:enter
(behavior ((arg0 symbol))
(set-time! (-> self state-time))
(logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
(target-start-attack)
(target-danger-set! 'spin-air #f)
(set! (-> self control mod-surface) *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) (seconds-per-frame))))
(f30-0 (* (/ f1-5 2) (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 last-trans-any-surf)))))))
(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 last-trans-any-surf quad) (-> self control trans quad)))
:exit
(behavior ()
(set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max))
(set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length))
((-> target-attack exit)))
: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 (time-elapsed? (-> self state-time) (seconds 0.5))
(seek! (-> self control dynam gravity-length)
(-> self control standard-dynamics gravity-length)
(* 245760.0 (seconds-per-frame))))
(when (and (time-elapsed? (-> self state-time) (seconds 0.05))
(< (vector-dot (-> self control dynam gravity-normal) (-> self control last-transv))
(vector-dot (-> self control dynam gravity-normal) (-> self control transv))))
(set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max))
(set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)))
(when (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(effect-control-method-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 (text-id misty-eco-red-first-use) "sksp0072" (the-as entity #f) *entity-pool* (game-task 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 (/ f1-1 300))) 150.0) (< f1-1 0.0)) (time-elapsed? (-> self state-time) (seconds 1.7))))
(quaternion-rotate-y! (-> self control quat-for-control)
(-> self control quat-for-control)
(* f30-0 (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 quat-for-control)
(-> self control quat-for-control)
(* f30-0 (seconds-per-frame))))
(else
(let ((f0-22 (deg-diff (quaternion-y-angle (-> self control quat-for-control)) (quaternion-y-angle (-> self control dir-targ)))))
(quaternion-rotate-y! (-> self control quat-for-control) (-> self control quat-for-control) (* 0.2 (fabs f0-22))))))
(suspend)
(ja :num! (seek!))))
(go target-falling #f))
:post target-post)
(defstate target-attack-uppercut (target)
:event target-dangerous-event-handler
:enter
(behavior ((arg0 float) (arg1 float))
(set-time! (-> self state-time))
(target-start-attack)
(target-danger-set! 'uppercut #f)
(set! (-> self control mod-surface) *turn-around-mods*))
: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))
:post target-post)
(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 ctrl-xz-vel)))
(set-forward-vel (the-as float 32768.0)))
(set-time! (-> self state-time))
(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 mod-surface) *uppercut-jump-mods*)
(target-start-attack)
(target-danger-set! 'uppercut #f))
: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 cpad 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)))
(time-elapsed? (-> self control last-time-of-stuck) (the-as time-frame (-> *TARGET-bank* stuck-timeout)))
(not (logtest? (-> self state-flags) (state-flags prevent-attack)))
(not (logtest? (-> self control current-surface 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 cpad number) stick0-speed) 0.0) 0.0 68812.8))))
(if (and (cpad-pressed? (-> self control cpad 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 cpad number) x) (-> self control transv))
(when (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(effect-control-method-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 danger-mode) 'uppercut)
(< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) -8192.0))
(target-danger-set! 'harmless #f))
(slide-down-test))
: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 mod-surface) *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))
:post target-post)
(defstate target-flop (target)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(let ((v0-0 (target-bonk-event-handler proc argc message block)))
(cond
(v0-0 (empty) v0-0)
((let ((v1-0 message)) (= v1-0 'swim))
(cond
((< 6144.0 (target-height-above-ground))
(effect-control-method-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 proc argc message block)))))
:enter
(behavior ((arg0 float) (arg1 float) (arg2 float))
(if (and (= (-> self fact eco-type) (pickup-type eco-yellow)) (>= (-> self fact eco-level) 1.0))
(go target-yellow-jump-blast))
(if (= arg2 0.0) (set-forward-vel arg2) (set-forward-vel (-> self control ctrl-xz-vel)))
(set-time! (-> self state-time))
(logclear! (-> self control status) (cshape-moving-flags onsurf onground tsurf))
(set! (-> self control mod-surface) *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))))))
:exit
(behavior ()
(target-danger-set! 'harmless #f)
(set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max))
(set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length))
(set! (-> self control dynam gravity quad) (-> self control standard-dynamics gravity quad)))
: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))))
;; og:preserve-this changed for high fps. This fixes the invisible wall when flopping
(when (and (or (< (target-move-dist (the time-frame (* (-> *display* time-adjust-ratio) (seconds 0.1))))
(* (-> *display* time-adjust-ratio) 1638.4))
(and (logtest? (-> self control status) (cshape-moving-flags twall)) (< 0.7 (-> self control poly-angle))))
(not (logtest? (-> self control status) (cshape-moving-flags t-act)))
(>= (-> self control unknown-uint20) (the-as uint 2)))
(set-time! (-> self control last-time-of-stuck))
(set! gp-1 'stuck)))
(when gp-1
(logior! (-> self control status) (cshape-moving-flags onsurf))
(when (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.5))
(effect-control-method-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_FPS_RATIO 0.016666668) ;; og:preserve-this changed for high fps
)))
(set! (-> arg0 control root-prim local-sphere w) f0-3)
f0-3)))))
(go target-flop-hit-ground gp-1)))
(when (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(effect-control-method-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 danger-mode)) (ja-group? eichar-flop-down-ja) (>= (ja-aframe-num 0) 8.0))
(target-start-attack)
(target-danger-set! 'flop #f)))
: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 ctrl-xz-vel)
(the-as float 0.0)
(the-as float 40960.0))))
(set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length))
(set! (-> self control dynam gravity quad) (-> self control standard-dynamics 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 ctrl-xz-vel)
(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 current-surface transv-max) f1-5) (set! f1-5 (-> self control current-surface 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 (time-elapsed? (-> self state-time) (-> *TARGET-bank* fall-timeout)) (go target-falling #f))
(if (and (= *cheat-mode* 'debug) (cpad-hold? (-> self control cpad number) r2) (not *pause-lock*)) (go target-falling #f))
(suspend))))
:post target-post)
(defstate target-flop-hit-ground (target)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('swim) #f)
(else (target-standard-event-handler proc argc message block))))
:enter
(behavior ((arg0 symbol))
(let ((f0-1 (vector-dot (-> self control dynam gravity-normal)
(vector-! (new 'stack-no-clear 'vector) (-> self control highest-jump-mark) (-> 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-time! (-> self state-time))
(set! (-> self control unknown-uint20) (the-as uint arg0))
(set-forward-vel (the-as float 0.0))
(set! (-> self control mod-surface) *flop-land-mods*)
(logclear! (-> *flop-land-mods* flags) (surface-flags allow-edge-grab))
(logior! (-> self state-flags) (state-flags flop-hit-ground)))
:exit target-exit
:trans
(behavior ()
(when (!= (-> self control unknown-spoolanim00) 'stuck)
(if (and (cpad-pressed? (-> self control cpad number) circle) (can-feet?)) (go target-attack-air 'flop)))
(when (and (and (= (-> self fact eco-type) (pickup-type eco-red)) (>= (-> self fact eco-level) 1.0))
(not (time-elapsed? (-> self state-time) (seconds 0.25))))
(effect-control-method-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))
:code
(behavior ((arg0 symbol))
(target-hit-ground-anim arg0)
(go target-falling #f))
:post target-post)
(defstate target-wheel (target)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(if (= message 'touched) (send-event proc 'roll))
(target-standard-event-handler proc argc message block))
:enter
(behavior ()
(set-time! (-> self state-time))
(set! (-> self control mod-surface) *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 local-slope-x)) 0.3) (< 0.3 (fabs (-> self control local-slope-z))))
(set! (-> self control bend-target) 1.0))
(set! (-> self control unknown-uint20) (the-as uint 0))
(set! (-> self control did-move-to-pole-or-max-jump-height) 0)
0)
:exit
(behavior ()
(when (!= (-> self next-state name) 'target-wheel)
(set! (-> self control unknown-int50) 0)
(set-time! (-> self control unknown-dword30)))
(target-exit))
: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 cpad number) x) (set! gp-0 (the-as int (current-time))))
(when (and (or (smack-surface? #f) (>= (-> self control surface-slope-z) 0.7))
(>= (the-as uint (- (current-time) (the-as int (-> self control unknown-uint20)))) (the-as uint 3))
(time-elapsed? (-> 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 (current-time)))))
(if (cpad-pressed? (-> self control cpad number) square) (current-time))
(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 w-R-c))
(set! (-> s4-1 y) 0.0)
(vector-matrix*! (-> self control unknown-vector120) s4-1 (-> self control c-R-w)))))
(suspend)
(ja :num! (seek!))
(set! f30-0 (* f30-0 (fmin 1.0 (-> self control unknown-float140))))))
(if (and (or (not (time-elapsed? (the-as time-frame gp-0) (-> *TARGET-bank* wheel-jump-pre-window)))
(cpad-pressed? (-> self control cpad number) x))
(can-jump? 'target-wheel-flip))
(go target-wheel-flip (-> *TARGET-bank* wheel-flip-height) (-> *TARGET-bank* wheel-flip-dist))))
(set-time! (-> self state-hook-time))
(set! (-> self state-hook)
(lambda :behavior target ()
(cond
((time-elapsed? (-> self state-hook-time) (-> *TARGET-bank* wheel-jump-post-window))
(set! (-> self state-hook) (the-as (function none :behavior target) nothing)))
(else
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? 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))
:post target-post)
(defstate target-wheel-flip (target)
:event target-standard-event-handler
:enter
(behavior ((arg0 float) (arg1 float))
(set! (-> self control mod-surface) *wheel-flip-mods*))
: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) (current-time)))
(target-shoved (-> *TARGET-bank* smack-surface-dist)
(-> *TARGET-bank* smack-surface-height)
(the-as process #f)
target-hit))
(if (and (cpad-pressed? (-> self control cpad number) circle)
(can-feet?)
(and (ja-group? eichar-jump-loop-ja) (= (-> self skel root-channel 0) (-> self skel channel))))
(go target-attack-air #f)))
: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 danger-mode)))
(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 w-R-c))
(set! (-> s4-1 y) 0.0)
(vector-matrix*! (-> self control unknown-vector120) s4-1 (-> self control c-R-w)))
(suspend)
(ja :num! (seek!))
(set! f30-0 (* f30-0 (fmin 1.0 (-> self control unknown-float140))))))
(set-time! (-> self state-time))
(while (not (logtest? (-> self control status) (cshape-moving-flags onsurf)))
(when (time-elapsed? (-> 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-time! (-> self state-hook-time))
(set! (-> self state-hook)
(lambda :behavior target ()
(cond
((time-elapsed? (-> self state-hook-time) (seconds 0.1))
(set! (-> self state-hook) (the-as (function none :behavior target) nothing)))
(else
;; og:preserve-this - High FPS Fix
(if (and (recently-pressed? 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)))
:post target-post)