diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 34b3e7005..fb5e11409 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -44291,13 +44291,12 @@ (:methods (wait-for-start () _type_ :state 20) (idle () _type_ :state 21) - (pickup () _type_ :state 22) + (pickup ((state mech)) _type_ :state 22) (wait-for-return () _type_ :state 23) - (mech-method-24 () none 24) + (mech-method-24 (_type_) none 24) ) ) -#| (deftype mech-target (process-drawable) () :method-count-assert 22 @@ -44308,71 +44307,70 @@ (active () _type_ :state 21) ) ) -|# ;; (define-extern *kernel-packages* object) ;; pair (define-extern mech-init (function entity-actor matrix3 handle float none :behavior mech)) -;; (define-extern mech-target-init function) -;; (define-extern mech-target-spawn function) +(define-extern mech-target-init (function vector quaternion entity-actor none :behavior mech)) +(define-extern mech-target-spawn (function vector target quaternion entity-actor (pointer mech-target))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; target-mech ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *mech-stance-mods* surface) -;; (define-extern *mech-walk-mods* surface) -;; (define-extern *mech-jump-mods* surface) -;; (define-extern *mech-punch-mods* surface) -;; (define-extern *mech-pickup-mods* surface) -;; (define-extern *mech-carry-walk-mods* surface) -;; (define-extern *mech-carry-drag-mods* surface) -;; (define-extern *mech-carry-jump-mods* surface) -;; (define-extern target-mech-falling-anim-trans function) -;; (define-extern target-mech-mech-effect function) -;; (define-extern mech-on-ground? function) -;; (define-extern target-mech-get-off? function) -;; (define-extern target-mech-handler function) -;; (define-extern target-mech-bonk-event-handler function) -;; (define-extern mech-leg-ik-callback function) -;; (define-extern mech-update-ik function) -;; (define-extern target-mech-init function) -;; (define-extern target-mech-exit function) -;; (define-extern target-mech-effect function) -;; (define-extern target-mech-add-thrust function) -;; (define-extern target-mech-collision function) -;; (define-extern target-mech-real-post function) -;; (define-extern target-mech-post function) +(define-extern *mech-stance-mods* surface) +(define-extern *mech-walk-mods* surface) +(define-extern *mech-jump-mods* surface) +(define-extern *mech-punch-mods* surface) +(define-extern *mech-pickup-mods* surface) +(define-extern *mech-carry-walk-mods* surface) +(define-extern *mech-carry-drag-mods* surface) +(define-extern *mech-carry-jump-mods* surface) +(define-extern target-mech-falling-anim-trans (function none :behavior target)) +(define-extern target-mech-mech-effect (function target none :behavior mech)) +(define-extern mech-on-ground? (function symbol :behavior target)) +(define-extern target-mech-get-off? (function symbol :behavior target)) +(define-extern target-mech-handler (function process int symbol event-message-block object :behavior target)) +(define-extern target-mech-bonk-event-handler (function process int symbol event-message-block object :behavior target)) +(define-extern mech-leg-ik-callback (function joint-mod-ik matrix matrix vector object :behavior target)) +(define-extern mech-update-ik (function none :behavior target)) +(define-extern target-mech-init (function handle float symbol none :behavior target)) +(define-extern target-mech-exit (function none :behavior target)) +(define-extern target-mech-effect (function none :behavior target)) +(define-extern target-mech-add-thrust (function none :behavior target)) +(define-extern target-mech-collision (function none :behavior target)) +(define-extern target-mech-real-post (function none :behavior target)) +(define-extern target-mech-post (function none :behavior target)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mech-states ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *mech-exploder-params* joint-exploder-static-params) +(define-extern *mech-exploder-params* joint-exploder-static-params) (define-extern target-mech-start (state handle target)) -;; (define-extern target-mech-stance state) -;; (define-extern target-mech-walk state) -;; (define-extern target-mech-punch-pick function) -;; (define-extern target-mech-punch state) -;; (define-extern target-mech-falling state) -;; (define-extern target-mech-jump state) -;; (define-extern target-mech-hit-ground state) -;; (define-extern target-mech-hit state) -;; (define-extern target-mech-death state) -;; (define-extern target-mech-carry-update function) -;; (define-extern target-mech-carry-post function) -;; (define-extern target-mech-carry-pickup state) -;; (define-extern target-mech-carry-drop state) -;; (define-extern target-mech-carry-stance state) -;; (define-extern target-mech-carry-walk state) -;; (define-extern target-mech-carry-drag state) -;; (define-extern target-mech-carry-falling state) -;; (define-extern target-mech-carry-hit-ground state) -;; (define-extern target-mech-carry-jump state) -;; (define-extern target-mech-carry-throw state) -;; (define-extern target-mech-get-on state) -;; (define-extern target-mech-get-off state) -;; (define-extern target-mech-grab state) -;; (define-extern target-mech-clone-anim state) +(define-extern target-mech-stance (state target)) +(define-extern target-mech-walk (state target)) +(define-extern target-mech-punch-pick (function symbol int :behavior target)) +(define-extern target-mech-punch (state target)) +(define-extern target-mech-falling (state symbol target)) +(define-extern target-mech-jump (state float float surface target)) +(define-extern target-mech-hit-ground (state symbol target)) +(define-extern target-mech-hit (state symbol attack-info target)) +(define-extern target-mech-death (state symbol target)) +(define-extern target-mech-carry-update (function none :behavior target)) +(define-extern target-mech-carry-post (function none :behavior target)) +(define-extern target-mech-carry-pickup (state target)) +(define-extern target-mech-carry-drop (state target)) +(define-extern target-mech-carry-stance (state target)) +(define-extern target-mech-carry-walk (state target)) +(define-extern target-mech-carry-drag (state target)) +(define-extern target-mech-carry-falling (state target)) +(define-extern target-mech-carry-hit-ground (state symbol target)) +(define-extern target-mech-carry-jump (state float float target)) +(define-extern target-mech-carry-throw (state target)) +(define-extern target-mech-get-on (state handle target)) +(define-extern target-mech-get-off (state target)) +(define-extern target-mech-grab (state target)) +(define-extern target-mech-clone-anim (state handle target)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; grunt-mech ;; diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index 168ff8037..ebd76f0d7 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -650,5 +650,13 @@ [1, "(function float)"], [3, "(function none :behavior scene-player)"] ], - "collectables": [[69, "(function part-tracker vector)"]] + "collectables": [[69, "(function part-tracker vector)"]], + "mech-states": [[50, "(function none :behavior target)"]], + "target-mech": [ + [7, "(function none :behavior target)"], + [8, "(function none :behavior mech)"], + [9, "(function none :behavior target)"], + [18, "(function surface object surface int none :behavior target)"], + [19, "(function surface object surface int none :behavior target)"] + ] } diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index f6cd352fc..450a57e08 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -802,5 +802,32 @@ ["L802", "uint64", true], ["L803", "uint64", true] ], - "hud": [["L217", "vector"]] + "hud": [["L217", "vector"]], + "mech-states": [ + ["L601", "uint64", true], + ["L602", "uint64", true], + ["L603", "uint64", true], + ["L604", "uint64", true], + ["L605", "uint64", true], + ["L606", "uint64", true], + ["L607", "uint64", true], + ["L608", "uint64", true], + ["L609", "uint64", true], + ["L610", "uint64", true], + ["L611", "uint64", true], + ["L612", "uint64", true], + ["L613", "uint64", true], + ["L614", "uint64", true], + ["L615", "uint64", true], + ["L616", "uint64", true], + ["L617", "uint64", true], + ["L618", "uint64", true], + ["L619", "uint64", true], + ["L620", "uint64", true], + ["L621", "uint64", true], + ["L622", "uint64", true], + ["L578", "attack-info"] + ], + "mech": [["L106", "attack-info"]], + "target-mech": [["L210", "attack-info"]] } diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index d5f1e51bd..3bb64ef67 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -1274,5 +1274,33 @@ "(post idle gun-dummy)": [[16, "event-message-block"]], "(method 23 training-manager)": [[16, "vector"]], "birth-pickup-at-point": [[16, "vector"]], - "(code notice fodder)": [[112, "vector"]] + "(code notice fodder)": [[112, "vector"]], + "target-mech-collision": [ + [704, "vector"], + [16, "vector"], + [32, "vector"], + [48, "event-message-block"], + [144, "vector"], + [160, "collide-query"], + [128, "vector"] + ], + "target-mech-add-thrust": [[16, "vector"]], + "target-mech-get-off?": [[560, "sphere"]], + "mech-update-ik": [ + [16, "collide-query"], + [592, "vector"], + [608, "vector"], + [624, "vector"], + [624, "vector"], + [640, "vector"], + [656, "vector"] + ], + "target-mech-carry-update": [[560, "sphere"]], + "(code target-mech-carry-throw)": [[640, "sphere"]], + "(code target-mech-carry-drop)": [ + [96, "vector"], + [672, "sphere"] + ], + "(code target-mech-carry-pickup)": [[16, "event-message-block"]], + "(trans target-mech-carry-drag)": [[560, "sphere"]] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index 86ee25fdc..5b1968f55 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -3711,7 +3711,11 @@ "connection-list-validate": [[5, "gp", "connection"]], "point-poly-distance-min": [[94, "f0", "float"]], "(method 26 nav-mesh)": [[[23, 78], "s4", "nav-engine"]], - "compute-dir-parm": [[10, "v1", "float"]], + "compute-dir-parm": [ + [18, "f0", "float"], + [8, "a2", "uint"], + [10, "v1", "float"] + ], "(trans idle fma-sphere)": [[39, "a2", "process-drawable"]], "(method 10 talker)": [[29, "t9", "(function process none)"]], "(exit active talker)": [[19, "s5", "process-drawable"]], @@ -5412,11 +5416,6 @@ [90, "v1", "collide-shape-prim-group"], [110, "s2", "collide-shape-prim-sphere"] ], - "compute-dir-parm": [ - [18, "f0", "float"], - [8, "a2", "uint"], - [10, "v1", "float"] - ], "(method 11 nav-state)": [[37, "v1", "float"]], "(method 18 nav-control)": [[252, "a2", "float"]], "(method 23 nav-mesh)": [["_stack_", 16, "res-tag"]], @@ -5617,5 +5616,105 @@ [[9, 13], "a0", "hud"] ], "(method 15 hud-dark-eco-symbol)": [[[9, 14], "v1", "hud-health"]], - "(method 15 hud-gun)": [[[251, 256], "v1", "dma-packet"]] + "(method 15 hud-gun)": [[[251, 256], "v1", "dma-packet"]], + "target-mech-collision": [[108, "v0", "carry-info"]], + "target-mech-exit": [[[235, 242], "v1", "handle"]], + "mech-update-ik": [ + [3, "v1", "process-drawable"], + [36, "s5", "collide-shape-moving"], + [41, "s5", "collide-shape-moving"], + [55, "s3", "joint-mod-ik"], + [72, "s3", "joint-mod-ik"], + [85, "s5", "collide-shape-moving"], + [93, "s3", "joint-mod-ik"], + [104, "s3", "joint-mod-ik"], + [52, "v1", "(array joint-mod-ik)"] + ], + "target-mech-punch-pick": [ + [29, "v0", "process-focusable"], + [222, "s5", "art-joint-anim"], + [241, "s5", "art-joint-anim"] + ], + "(code target-mech-walk)": [[91, "f0", "float"]], + "(code target-mech-punch)": [ + [107, "v1", "art-joint-anim"], + [135, "v1", "art-joint-anim"], + [163, "v1", "art-joint-anim"], + [191, "v1", "art-joint-anim"], + [231, "v1", "art-joint-anim"], + [259, "v1", "art-joint-anim"], + [287, "v1", "art-joint-anim"], + [315, "v1", "art-joint-anim"] + ], + "(code target-mech-jump)": [[26, "t9", "(function none)"]], + "(code target-mech-death)": [ + [379, "gp", "art-joint-anim"], + [643, "v1", "art-joint-anim"] + ], + "(code target-mech-get-off)": [[67, "v1", "art-joint-anim"]], + "(code target-mech-get-on)": [ + [74, "v1", "process-drawable"], + [80, "v1", "process-drawable"], + [115, "v1", "art-joint-anim"] + ], + "(code target-mech-carry-throw)": [ + [51, "v0", "carry-info"], + [112, "v0", "carry-info"], + [135, "v1", "sphere"] + ], + "(code target-mech-carry-drop)": [ + [42, "v0", "carry-info"], + [110, "v1", "art-joint-anim"], + [176, "v0", "carry-info"], + [262, "v0", "sound-rpc-set-param"], + [295, "v0", "sound-rpc-set-param"], + [220, "v1", "sphere"] + ], + "(code target-mech-carry-pickup)": [ + [137, "v0", "carry-info"], + [377, "v1", "art-joint-anim"], + [541, "v0", "carry-info"], + [574, "f0", "float"] + ], + "(code target-mech-carry-walk)": [[80, "f0", "float"]], + "(event target-mech-punch)": [ + [45, "gp", "collide-query"], + [51, "s5", "collide-shape-prim"], + [68, "s5", "process-focusable"], + [95, "gp", "collide-query"], + [128, "s5", "process-focusable"], + [180, "gp", "collide-query"] + ], + "(exit idle mech)": [[[9, 17], "v1", "handle"]], + "(anon-function 8 target-mech)": [ + [4, "gp", "target"], + [10, "gp", "target"], + [14, "gp", "target"] + ], + "(anon-function 9 target-mech)": [ + [[3, 33], "v1", "target"], + [43, "a0", "joint-mod-ik"], + [42, "v1", "(array joint-mod-ik)"] + ], + "target-mech-handler": [ + [91, "a0", "process"], + [213, "a3", "vector"], + [225, "s2", "vector"], + [305, "a3", "vector"], + [317, "s2", "vector"], + [164, "v0", "attack-info"] + ], + "(enter target-mech-carry-hit-ground)": [[3, "v0", "sound-rpc-set-param"]], + "(event target-mech-grab)": [[24, "a0", "process"]], + "(anon-function 7 target-mech)": [ + [32, "a0", "joint-mod-ik"], + [26, "a0", "(array joint-mod-ik)"] + ], + "(enter target-mech-hit-ground)": [[3, "v0", "sound-rpc-set-param"]], + "(exit target-mech-carry-drag)": [ + [11, "v0", "sound-rpc-set-param"], + [28, "v0", "sound-rpc-set-param"] + ], + "(trans target-mech-carry-drag)": [[73, "v1", "sphere"]], + "target-mech-carry-update": [[50, "v1", "sphere"]] } diff --git a/goal_src/jak2/engine/target/mech_suit/mech-states.gc b/goal_src/jak2/engine/target/mech_suit/mech-states.gc index 5d24dc5c2..c8e2bef9f 100644 --- a/goal_src/jak2/engine/target/mech_suit/mech-states.gc +++ b/goal_src/jak2/engine/target/mech_suit/mech-states.gc @@ -7,3 +7,2840 @@ ;; DECOMP BEGINS +(define *mech-exploder-params* + (new 'static 'joint-exploder-static-params + :joints (new 'static 'boxed-array :type joint-exploder-static-joint-params + (new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 12 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 13 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 14 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 15 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 16 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 17 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 18 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 19 :parent-joint-index -1) + ) + :collide-spec #x1 + ) + ) + +(defstate target-mech-start (target) + :event target-mech-handler + :exit target-mech-exit + :code (the-as (function handle none :behavior target) target-mech-init) + :post target-post + ) + +(defstate target-mech-stance (target) + :event target-mech-handler + :enter (behavior () + (set! (-> self control mod-surface) *mech-stance-mods*) + (set! (-> self control mod-surface turnvv) 40049.777) + (set! (-> self control did-move-to-pole-or-max-jump-height) 0.0) + (rot->dir-targ! (-> self control)) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (none) + ) + :exit (behavior () + (target-effect-exit) + (target-mech-exit) + (rot->dir-targ! (-> self control)) + (none) + ) + :trans (behavior () + (if (and (move-legs?) + (and (< (fabs + (deg-diff (quaternion-y-angle (-> self control dir-targ)) (vector-y-angle (-> self control to-target-pt-xz))) + ) + 1820.4445 + ) + (>= (- (-> self clock frame-counter) (-> self control time-of-last-zero-input)) (seconds 0.05)) + ) + ) + (go target-mech-walk) + ) + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-punch) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + (if (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons r1) + ) + (go target-mech-carry-pickup) + ) + (if (and (or (cpad-pressed? (-> self control cpad number) triangle) (not (-> *setting-control* user-current pilot))) + (target-mech-get-off?) + ) + (go target-mech-get-off) + ) + (fall-test target-mech-falling (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 327)))) + (let ((v1-8 (ja-group))) + (if (and v1-8 (= v1-8 (-> self draw art-group data 326))) + (sound-play "mech-stop") + ) + ) + (ja-channel-push! 3 (seconds 0.2)) + (ja :group! (-> self draw art-group data 327) :dist 16384.0) + (ja :chan 1 :group! (-> self draw art-group data 332) :dist 3640.889) + (ja :chan 2 :group! (-> self draw art-group data 324) :dist 0.0) + ) + ) + (let ((f28-0 0.0) + (f30-0 0.0) + (gp-1 #f) + ) + (until #f + (let ((f26-0 (y-angle (-> self control)))) + (deg-diff f26-0 (quaternion-y-angle (-> self control dir-targ))) + (suspend) + (let ((f26-1 (* (deg-diff f26-0 (y-angle (-> self control))) (-> self clock frames-per-second)))) + (cond + ((< 910.2222 (fabs f26-1)) + (set! f28-0 (seek f28-0 1.0 (* 16.0 (-> self clock seconds-per-frame)))) + (set! gp-1 #t) + ) + (else + (set! f28-0 (seek f28-0 0.0 (* 6.0 (-> self clock seconds-per-frame)))) + (when (and gp-1 (= f28-0 0.0)) + (set! gp-1 #f) + (sound-play "mech-twitch") + ) + ) + ) + (set! f30-0 + (seek f30-0 (lerp-scale 1.0 0.0 (fabs f26-1) 3640.889 16384.0) (* 10.0 (-> self clock seconds-per-frame))) + ) + (let ((v1-41 (-> self skel effect))) + (set! (-> v1-41 channel-offset) (cond + ((< 0.8 (- 1.0 f28-0)) + 2 + ) + ((< 0.5 f30-0) + 1 + ) + (else + 0 + ) + ) + ) + ) + 0 + (ja :num! (loop! (/ f26-1 (current-cycle-distance (-> self skel))))) + (let ((a0-41 (-> self skel root-channel 1))) + (set! (-> a0-41 frame-interp 1) f30-0) + (set! (-> a0-41 frame-interp 0) f30-0) + (set! (-> a0-41 param 0) 0.0) + (joint-control-channel-group-eval! a0-41 (the-as art-joint-anim #f) num-func-chan) + ) + (ja-no-eval :chan 1 :num! (loop! (/ f26-1 (current-cycle-distance (-> self skel))))) + ) + ) + (let ((a0-44 (-> self skel root-channel 2))) + (let ((f0-22 (- 1.0 f28-0))) + (set! (-> a0-44 frame-interp 1) f0-22) + (set! (-> a0-44 frame-interp 0) f0-22) + ) + (set! (-> a0-44 param 0) 1.0) + (joint-control-channel-group-eval! a0-44 (the-as art-joint-anim #f) num-func-loop!) + ) + (can-play-stance-amibent?) + ) + ) + #f + (none) + ) + :post target-mech-post + ) + +(defstate target-mech-walk (target) + :event target-mech-handler + :enter (behavior () + (set! (-> self control mod-surface) *mech-walk-mods*) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control unknown-word04) (the-as uint 0.0)) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (none) + ) + :exit (behavior () + (target-effect-exit) + (target-mech-exit) + (none) + ) + :trans (behavior () + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-punch) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + (let ((gp-0 (ja-group)) + (f0-2 (ja-aframe-num 0)) + ) + (when (if (or (and (= gp-0 (-> self draw art-group data 326)) (>= f0-2 5.5) (>= 9.5 f0-2)) + (and (= gp-0 (-> self draw art-group data 326)) (>= f0-2 20.5) (>= 24.5 f0-2)) + ) + #t + ) + (case (-> self control unknown-spool-anim00) + (('punch) + (go target-mech-punch) + ) + (('jump) + (if (can-jump? #f) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ) + ) + (when (and (< 5.0 (the-as float (-> self control unknown-word04))) + (= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + ) + (set-forward-vel 0.0) + (go target-mech-stance) + ) + (if (and (or (cpad-pressed? (-> self control cpad number) triangle) (not (-> *setting-control* user-current pilot))) + (target-mech-get-off?) + ) + (go target-mech-get-off) + ) + ) + ) + (if (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons r1) + ) + (go target-mech-carry-pickup) + ) + (fall-test target-mech-falling (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((f30-0 0.0) + (f28-0 0.0) + ) + (let ((f26-0 (cond + ((zero? (-> self mech walk-anim-leg)) + (set! (-> self mech walk-anim-leg) 1) + 7.0 + ) + (else + (set! (-> self mech walk-anim-leg) 0) + 22.0 + ) + ) + ) + (v1-7 (ja-group)) + ) + (when (not (and v1-7 (= v1-7 (-> self draw art-group data 326)))) + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 326) + :num! (identity (ja-aframe f26-0 0)) + :dist (-> *TARGET-bank* mech-walk-cycle-dist) + ) + (ja :chan 1 :group! (-> self draw art-group data 325) :dist (-> *TARGET-bank* mech-run-cycle-dist)) + (ja :chan 2 :group! (-> self draw art-group data 324) :dist 0.0) + ) + ) + (until #f + (if (< (-> self control ctrl-xz-vel) 8192.0) + (set-forward-vel 8192.0) + ) + (suspend) + (let* ((f0-5 (current-cycle-distance (-> self skel))) + (f26-1 (/ (-> self control ctrl-xz-vel) f0-5)) + ) + (set! (-> self control unknown-word04) + (the-as uint (+ (the-as float (-> self control unknown-word04)) f26-1)) + ) + (set! f30-0 (seek + f30-0 + (lerp-scale 0.0 1.0 (-> self control ctrl-xz-vel) 16384.0 32768.0) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (set! f28-0 (seek + f28-0 + (lerp-scale 1.0 0.0 (-> self control ctrl-xz-vel) 0.0 12288.0) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (let ((v1-39 (-> self skel effect))) + (set! (-> v1-39 channel-offset) (if (< 0.5 f30-0) + 1 + 0 + ) + ) + ) + 0 + (ja :num! (loop! f26-1)) + ) + (let ((a0-24 (-> self skel root-channel 1))) + (set! (-> a0-24 frame-interp 1) f30-0) + (set! (-> a0-24 frame-interp 0) f30-0) + (set! (-> a0-24 param 0) 0.0) + (joint-control-channel-group-eval! a0-24 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-25 (-> self skel root-channel 2))) + (set! (-> a0-25 frame-interp 1) f28-0) + (set! (-> a0-25 frame-interp 0) f28-0) + (set! (-> a0-25 param 0) 0.0) + (joint-control-channel-group-eval! a0-25 (the-as art-joint-anim #f) num-func-chan) + ) + ) + ) + #f + (none) + ) + :post target-mech-post + ) + +(defbehavior target-mech-punch-pick target ((arg0 symbol)) + (local-vars (sv-64 float)) + (combo-tracker-method-12 + (-> self control unknown-combo-tracker00) + *null-vector* + *null-vector* + (the-as process #f) + (-> self clock frame-counter) + ) + (let* ((s4-0 (get-trans self 3)) + (a0-4 (the-as process-focusable (combo-tracker-method-13 + (-> self control unknown-combo-tracker00) + (-> self control send-attack-dest) + s4-0 + 32768.0 + (-> self control c-R-w vector 2) + 65536.0 + ) + ) + ) + (s5-0 (the-as art-element #f)) + ) + (when a0-4 + (let ((s3-0 (get-trans a0-4 3))) + (let ((s0-0 (-> self control)) + (s1-0 s3-0) + (s2-0 deg-diff) + ) + (set! sv-64 (y-angle s0-0)) + (let* ((a1-4 (vector-y-angle (vector-! (new 'stack-no-clear 'vector) s1-0 (-> s0-0 trans)))) + (f0-0 (s2-0 sv-64 a1-4)) + ) + (cond + ((< (+ 12288.0 (-> s4-0 y)) (-> s3-0 y)) + (set! (-> self mech walk-anim-leg) 3) + ) + ((>= f0-0 5461.3335) + (set! (-> self mech walk-anim-leg) 0) + 0 + ) + ((>= -5461.3335 f0-0) + (set! (-> self mech walk-anim-leg) 1) + ) + (else + (set! (-> self mech walk-anim-leg) 2) + ) + ) + ) + ) + (if (< (vector-vector-distance s3-0 s4-0) 32768.0) + (forward-up-nopitch->quaternion + (-> self control dir-targ) + (vector-normalize! (vector-! (new 'stack-no-clear 'vector) s3-0 s4-0) 1.0) + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + ) + (let ((v1-26 (-> self mech walk-anim-leg))) + (cond + ((zero? v1-26) + (set! (-> self mech walk-anim-leg) 1) + (set! s5-0 (-> self draw art-group data 333)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 7 + 6963.2 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ((= v1-26 1) + (set! (-> self mech walk-anim-leg) 0) + (set! s5-0 (-> self draw art-group data 334)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 17 + 6963.2 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ((= v1-26 2) + (set! (-> self mech walk-anim-leg) 0) + (set! s5-0 (-> self draw art-group data 335)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 39 + 11141.12 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ((= v1-26 3) + (set! (-> self mech walk-anim-leg) 0) + (set! s5-0 (-> self draw art-group data 353)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 39 + 11141.12 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (if (zero? arg0) + (ja-no-eval :group! s5-0 :num! (seek! (the float (+ (-> (the-as art-joint-anim s5-0) frames num-frames) -1)))) + (ja-no-eval :group! s5-0 + :num! (seek! (the float (+ (-> (the-as art-joint-anim s5-0) frames num-frames) -1))) + :frame-num (ja-aframe 10.0 0) + ) + ) + ) + (-> self mech walk-anim-leg) + ) + +(defstate target-mech-punch (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (cond + ((logtest? (-> self focus-status) (focus-status dangerous)) + (case event-type + (('touched) + (if ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> event param 0)) + (-> self control) + (the-as uint 1920) + ) + (target-send-attack + proc + (-> self control danger-mode) + (the-as touching-shapes-entry (-> event param 0)) + (the-as int (-> self control target-attack-id)) + (the-as int (-> self control attack-count)) + (-> self control penetrate-using) + ) + (target-mech-handler proc arg1 event-type event) + ) + ) + (('impact-control) + (when (-> self control danger-mode) + (-> event param 1) + (let* ((gp-1 (the-as object (-> event param 3))) + (s5-1 (-> (the-as collide-query gp-1) best-other-tri collide-ptr)) + (s4-1 (if (type? s5-1 collide-shape-prim) + (the-as collide-shape-prim s5-1) + ) + ) + (s3-1 (if s4-1 + (-> s4-1 cshape process) + (the-as process-drawable #f) + ) + ) + (s5-2 (if (type? s3-1 process-focusable) + s3-1 + ) + ) + ) + (if (and s4-1 + (and (or (and s5-2 (logtest? (-> (the-as process-focusable s5-2) focus-status) (focus-status dead))) + (let ((a1-6 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-6 from) (process->ppointer self)) + (set! (-> a1-6 num-params) 2) + (set! (-> a1-6 message) 'attack) + (set! (-> a1-6 param 0) (the-as uint #f)) + (let ((v1-20 (new 'static 'attack-info :mask (attack-info-mask intersection mode id count penetrate-using)))) + (set! (-> v1-20 id) (-> self control target-attack-id)) + (set! (-> v1-20 mode) (-> self control danger-mode)) + (set! (-> v1-20 count) (-> self control attack-count)) + (set! (-> v1-20 penetrate-using) (penetrate touch punch mech mech-punch)) + (set! (-> v1-20 intersection quad) (-> (the-as collide-query gp-1) best-other-tri intersect quad)) + (set! (-> a1-6 param 1) (the-as uint v1-20)) + ) + (when (send-event-function (-> s4-1 cshape process) a1-6) + (set! (-> self control send-attack-dest) (process->handle s5-2)) + (set! (-> self control send-attack-time) (-> self clock frame-counter)) + #t + ) + ) + ) + s5-2 + (logtest? (-> (the-as process-focusable s5-2) focus-status) (focus-status dead)) + ) + ) + (set! (-> self mech forward-vel) 0.0) + (set! (-> self mech forward-vel) -40960.0) + ) + (when (or (not s5-2) (= (-> self control send-attack-time) (-> self clock frame-counter))) + (let ((s5-3 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-3 + (let ((t9-7 (method-of-type part-tracker activate))) + (t9-7 (the-as part-tracker s5-3) self (symbol->string (-> part-tracker symbol)) (the-as pointer #x70004000)) + ) + (let ((t9-8 run-function-in-process) + (a0-33 s5-3) + (a1-9 part-tracker-init) + (a2-8 (-> *part-group-id-table* 11)) + (a3-4 0) + (t0-1 #f) + (t1-1 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> (the-as collide-query gp-1) best-other-tri intersect quad)) + ((the-as (function object object object object object object object object none) t9-8) + a0-33 + a1-9 + a2-8 + a3-4 + t0-1 + t1-1 + t2-0 + t3-0 + ) + ) + (-> s5-3 ppointer) + ) + ) + (sound-play "mech-punch-hit" :position (+ (the-as uint gp-1) 48)) + (activate! *camera-smush-control* 1638.4 15 75 1.0 0.9 (-> *display* camera-clock)) + ) + ) + ) + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *mech-punch-mods*) + (set! (-> self mech state-impact? 0) #f) + (rot->dir-targ! (-> self control)) + (none) + ) + :exit (behavior () + (set! (-> *mech-punch-mods* turnvv) 0.0) + (set! (-> self mech state-impact? 0) #f) + (set! (-> self control last-running-attack-end-time) (-> self clock frame-counter)) + (target-exit) + (target-mech-exit) + (none) + ) + :code (behavior () + (set! (-> self mech forward-vel) (-> self control ctrl-xz-vel)) + 1.0 + (let ((s5-0 #f) + (gp-0 0) + (s4-0 30) + ) + (target-mech-punch-pick (the-as symbol gp-0)) + (until (ja-done? 0) + (compute-alignment! (-> self align)) + (when (and (not (logtest? (-> self focus-status) (focus-status dangerous))) + (let ((v1-10 (ja-group))) + (and v1-10 (or (= v1-10 (-> self draw art-group data 333)) + (= v1-10 (-> self draw art-group data 334)) + (= v1-10 (-> self draw art-group data 335)) + (= v1-10 (-> self draw art-group data 353)) + ) + ) + ) + (>= (ja-aframe-num 0) 12.0) + ) + (target-start-attack) + (target-danger-set! 'mech-punch #f) + ) + (when (and (cpad-pressed? (-> self control cpad number) circle square) (< gp-0 2)) + (let ((s3-0 (ja-group)) + (f30-0 (ja-aframe-num 0)) + ) + (if (or (and (= s3-0 (-> self draw art-group data 333)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 333)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-0 (-> self draw art-group data 334)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 334)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-0 (-> self draw art-group data 335)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 335)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-0 (-> self draw art-group data 353)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 353)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + ) + (set! s5-0 #t) + ) + ) + ) + (when s5-0 + (let ((s3-1 (ja-group)) + (f30-2 (ja-aframe-num 0)) + ) + (when (or (and (= s3-1 (-> self draw art-group data 333)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 333)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-1 (-> self draw art-group data 334)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 334)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-1 (-> self draw art-group data 335)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 335)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-1 (-> self draw art-group data 353)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 353)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + ) + (+! gp-0 1) + (target-mech-punch-pick (the-as symbol gp-0)) + (set! (-> self state-time) (+ (-> self clock frame-counter) (seconds -0.465))) + (set! (-> self mech forward-vel) (fmax 0.0 (-> self mech forward-vel))) + (set! s4-0 159) + (set! s5-0 #f) + ) + ) + ) + (let ((v1-142 (- (-> self clock frame-counter) (-> self state-time))) + (s3-2 #t) + (f30-4 1.0) + ) + (cond + ((< (-> self mech forward-vel) 0.0) + (seek! (-> self mech forward-vel) -0.04096 (* 122880.0 (-> self clock seconds-per-frame))) + ) + ((let ((a0-43 (ja-group))) + (and a0-43 (or (= a0-43 (-> self draw art-group data 335)) (= a0-43 (-> self draw art-group data 353)))) + ) + (cond + ((< v1-142 (seconds 0.465)) + (set! s3-2 #f) + ) + ((< v1-142 (seconds 0.53)) + (set! (-> self mech forward-vel) (lerp-scale 40960.0 81920.0 (the float v1-142) 139.8 159.98999)) + ) + (else + (set! (-> self mech forward-vel) (lerp-scale 81920.0 0.0 (the float v1-142) 159.98999 300.0)) + ) + ) + ) + (else + (let ((a0-50 (ja-group))) + (cond + ((and a0-50 (= a0-50 (-> self draw art-group data 333))) + (cond + ((< v1-142 (seconds 0.465)) + (seek! (-> self mech forward-vel) 0.0 (* 20480.0 (-> self clock seconds-per-frame))) + (set! s3-2 #f) + ) + ((< v1-142 (seconds 0.53)) + (set! (-> self mech forward-vel) (lerp-scale 20480.0 40960.0 (the float v1-142) 139.8 159.98999)) + ) + (else + (set! (-> self mech forward-vel) (lerp-scale 40960.0 0.0 (the float v1-142) 159.98999 300.0)) + ) + ) + ) + ((< v1-142 (seconds 0.465)) + (seek! (-> self mech forward-vel) 0.0 (* 20480.0 (-> self clock seconds-per-frame))) + (set! s3-2 #f) + ) + ((< v1-142 (seconds 0.53)) + (set! (-> self mech forward-vel) (lerp-scale 20480.0 40960.0 (the float v1-142) 139.8 159.98999)) + ) + (else + (set! (-> self mech forward-vel) (lerp-scale 40960.0 0.0 (the float v1-142) 159.98999 300.0)) + ) + ) + ) + ) + ) + (set! s3-2 (and (>= (- (-> self clock frame-counter) (-> self state-time)) s4-0) + (and (>= (-> self mech forward-vel) 0.0) s3-2) + ) + ) + (set! (-> self mech state-impact? 0) s3-2) + (set-forward-vel (-> self mech forward-vel)) + (when (< 20480.0 (vector-length (-> self control transv))) + (do-effect (-> self skel effect) 'effect-slide-poof (ja-frame-num 0) 38) + (do-effect (-> self skel effect) 'effect-slide-poof (ja-frame-num 0) 31) + ) + (suspend) + (ja :num! (seek! max (* (-> self control current-surface align-speed) f30-4))) + ) + ) + ) + (go target-mech-stance) + (none) + ) + :post target-mech-post + ) + +(defstate target-mech-falling (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (let ((v0-0 (target-mech-bonk-event-handler proc arg1 event-type event))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + ) + :enter (behavior ((arg0 symbol)) + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *mech-jump-mods*) + (set! (-> self mech jump-thrust) 0.0) + (let* ((v1-4 *game-info*) + (v0-0 (+ (-> v1-4 attack-id) 1)) + ) + (set! (-> v1-4 attack-id) v0-0) + (set! (-> self control target-attack-id) v0-0) + ) + (none) + ) + :exit (behavior () + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + (target-exit) + (target-mech-exit) + (none) + ) + :trans (behavior () + (local-vars (a0-0 none)) + (if (logtest? (-> self control status) (collide-status on-surface)) + (go target-mech-hit-ground (the-as symbol a0-0)) + ) + (let ((f0-0 (target-move-dist (-> *TARGET-bank* stuck-time))) + (v1-9 (ja-group)) + ) + (when (if (and (and v1-9 (= v1-9 (-> self draw art-group data 330))) + (< f0-0 (-> *TARGET-bank* stuck-distance)) + (and (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 2)) + (not (and *cheat-mode* (cpad-hold? (-> self control cpad number) r2))) + ) + ) + #t + ) + (logior! (-> self control status) (collide-status on-surface)) + (go target-mech-hit-ground 'stuck) + ) + ) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + (let ((f0-2 (-> self mech jump-thrust-fuel))) + (cond + ((cpad-hold? (-> self control cpad number) x) + (cond + ((= f0-2 0.0) + (seek! (-> self mech jump-thrust) 0.0 (* 245760.0 (-> self clock seconds-per-frame))) + ) + ((!= f0-2 (-> *TARGET-bank* mech-jump-thrust-fuel)) + (let ((f26-0 + (lerp-scale 122880.0 8192.0 (-> self mech jump-thrust-fuel) 600.0 (-> *TARGET-bank* mech-jump-thrust-fuel)) + ) + (f28-0 + (lerp-scale 409.6 8192.0 (-> self mech jump-thrust-fuel) 600.0 (-> *TARGET-bank* mech-jump-thrust-fuel)) + ) + ) + (seek! + (-> self mech jump-thrust) + (- (- (-> self control dynam gravity-length) f30-0) f26-0) + (* 8192000.0 (-> self clock seconds-per-frame)) + ) + (set! (-> self mech thruster-flame-width) (* 0.75 f28-0)) + (set! (-> self mech thruster-flame-length) f28-0) + ) + ) + (else + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 12288.0) + (set! (-> self mech thruster-flame-length) 20480.0) + ) + ) + (seek! + (-> self mech jump-thrust-fuel) + 0.0 + (the float (- (-> self clock frame-counter) (-> self clock old-frame-counter))) + ) + ) + (else + (seek! (-> self mech jump-thrust) 0.0 (* 491520.0 (-> self clock seconds-per-frame))) + (set! (-> self mech thruster-flame-width) (* 0.021428572 (-> self mech jump-thrust))) + (set! (-> self mech thruster-flame-length) (* 0.028571429 (-> self mech jump-thrust))) + ) + ) + ) + (let ((v1-85 (new-stack-vector0))) + (let ((f0-36 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-85 (-> self control transv) (vector-float*! v1-85 (-> self control dynam gravity-normal) f0-36)) + ) + (let* ((f0-37 (vector-length v1-85)) + (f1-9 f0-37) + (f2-2 (+ f30-0 (* (-> self mech jump-thrust) (-> self clock seconds-per-frame)))) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-2) + (vector-float*! v1-85 v1-85 (/ f0-37 f1-9)) + ) + ) + ) + ) + (none) + ) + :code (behavior ((arg0 symbol)) + (until #f + (cond + ((< 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (let ((v1-7 (ja-group))) + (when (not (and v1-7 (= v1-7 (-> self draw art-group data 329)))) + (ja-channel-push! 1 (seconds 0.1)) + (ja :group! (-> self draw art-group data 329) :num! min) + ) + ) + (suspend) + (ja :num! (loop! 0.75)) + ) + (else + (let ((v1-22 (ja-group))) + (when (not (and v1-22 (= v1-22 (-> self draw art-group data 330)))) + (ja-channel-push! 1 (seconds 0.5)) + (ja :group! (-> self draw art-group data 330) :num! min) + ) + ) + (suspend) + (ja :num! (loop!)) + ) + ) + ) + #f + (none) + ) + :post target-mech-post + ) + +(defstate target-mech-jump (target) + :event (-> target-mech-falling event) + :enter (behavior ((arg0 float) (arg1 float) (arg2 surface)) + (set! (-> self state-time) (-> self clock frame-counter)) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (let* ((v1-4 *game-info*) + (a2-5 (+ (-> v1-4 attack-id) 1)) + ) + (set! (-> v1-4 attack-id) a2-5) + (set! (-> self control target-attack-id) a2-5) + ) + (set! (-> self mech jump-thrust) 0.0) + (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0) + (set! (-> self control unknown-symbol03) (the-as float arg2)) + (set! (-> self control mod-surface) *mech-jump-mods*) + (none) + ) + :exit (-> target-mech-falling exit) + :trans (-> target-mech-falling trans) + :code (behavior ((arg0 float) (arg1 float) (arg2 surface)) + (let ((v1-2 (ja-group))) + (if (and v1-2 (= v1-2 (-> self draw art-group data 331))) + (ja-channel-push! 1 (seconds 0.5)) + (ja-channel-push! 1 (seconds 0.05)) + ) + ) + ((the-as (function none) (-> target-mech-falling code))) + (none) + ) + :post target-mech-post + ) + +(defstate target-mech-hit-ground (target) + :event target-mech-handler + :enter (behavior ((arg0 symbol)) + (let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-param)) + (set! (-> v1-0 id) (the-as sound-id (-> self mech thrust-sound-id))) + (set! (-> v1-0 params volume) -4) + (set! (-> v1-0 auto-time) 48) + (set! (-> v1-0 auto-from) 2) + (set! (-> v1-0 params mask) (the-as uint 17)) + (-> v1-0 id) + ) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (set! (-> self state-time) (-> self clock frame-counter)) + (cond + ((= arg0 'stuck) + ) + (else + (target-land-effect) + ) + ) + (set! (-> self control last-running-attack-end-time) 0) + (set! (-> self control last-attack-end-time) 0) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control mod-surface) *mech-stance-mods*) + (start-bobbing! + (-> self water) + (lerp-scale 0.0 4096.0 (-> self control ground-impact-vel) 40960.0 102400.0) + 600 + 1500 + ) + (activate! *camera-smush-control* 1638.4 15 75 1.0 0.9 (-> *display* camera-clock)) + (none) + ) + :exit (behavior () + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (target-mech-exit) + (none) + ) + :trans (behavior () + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-punch) + ) + (when (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.25)) + (if (move-legs?) + (go target-mech-walk) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + (if (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons r1) + ) + (go target-mech-carry-pickup) + ) + ) + (set-forward-vel 0.0) + (none) + ) + :code (behavior ((arg0 symbol)) + (target-hit-ground-anim #f (are-still?)) + (go target-mech-stance) + (none) + ) + :post target-mech-post + ) + +(defstate target-mech-hit (target) + :event target-mech-handler + :exit (behavior () + ((-> target-hit exit)) + (target-mech-exit) + (none) + ) + :trans (behavior () + (when (= *cheat-mode* 'debug) + (when (and (not *pause-lock*) (cpad-hold? (-> self control cpad number) r2)) + (set! (-> self control time-of-last-debug-heal) (-> self clock frame-counter)) + (pickup-collectable! (-> self fact-override) (pickup-type health) 100.0 (the-as handle #f)) + (go target-mech-stance) + ) + ) + (none) + ) + :code (behavior ((arg0 symbol) (arg1 attack-info)) + (logclear! (-> self water flags) (water-flags jump-out)) + (set! (-> self state-time) (-> self clock frame-counter)) + (let ((gp-0 (-> self attack-info)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((v1-4 gp-0)) + (set! (-> v1-4 attacker) (the-as handle #f)) + (set! (-> v1-4 mode) 'generic) + (set! (-> v1-4 shove-back) 10240.0) + (set! (-> v1-4 shove-up) 6144.0) + (set! (-> v1-4 angle) #f) + (set! (-> v1-4 trans quad) (-> self control trans quad)) + (set! (-> v1-4 control) 0.0) + (set! (-> v1-4 invinc-time) (the-as time-frame (-> *TARGET-bank* hit-invulnerable-timeout))) + ) + (case arg0 + (('shove) + (let ((v1-7 gp-0)) + (set! (-> v1-7 shove-back) (-> *TARGET-bank* smack-surface-dist)) + (set! (-> v1-7 shove-up) (-> *TARGET-bank* smack-surface-height)) + (set! (-> v1-7 angle) 'shove) + ) + ) + ) + (combine! gp-0 arg1 self) + (when (not (logtest? (-> gp-0 mask) (attack-info-mask vector))) + (vector-z-quaternion! (-> gp-0 vector) (-> self control quat-for-control)) + (vector-xz-normalize! (-> gp-0 vector) (- (fabs (-> gp-0 shove-back)))) + (set! (-> gp-0 vector y) (-> gp-0 shove-up)) + ) + (set! (-> s5-0 quad) (-> gp-0 vector quad)) + (let ((f0-10 (vector-dot + (vector-normalize-copy! (new 'stack-no-clear 'vector) s5-0 1.0) + (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self control quat-for-control)) + ) + ) + ) + (if (not (-> self attack-info angle)) + (set! (-> self attack-info angle) (if (>= 0.0 f0-10) + 'front + 'back + ) + ) + ) + ) + (cond + ((= arg0 'attack) + (logior! (-> self focus-status) (focus-status hit)) + (set! (-> self game hit-time) (-> self clock frame-counter)) + (case (-> gp-0 mode) + (('endlessfall) + (cond + ((= (-> self game mode) 'debug) + (let ((s4-1 (new-stack-vector0))) + (set! (-> s4-1 quad) (-> self control last-trans-on-ground quad)) + (ja-channel-set! 0) + (let ((s3-1 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s3-1) (seconds 1)) + (suspend) + ) + ) + (move-to-point! (-> self control) s4-1) + ) + (set! (-> self control camera-pos quad) (-> self control trans quad)) + (send-event *camera* 'teleport) + (go target-mech-stance) + ) + (else + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) + (go target-mech-death (-> gp-0 mode)) + ) + ) + ) + ) + (target-hit-effect gp-0) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) + (go target-mech-death (-> gp-0 mode)) + ) + (else + (case (-> gp-0 mode) + (('burn 'burnup) + (sound-play "get-burned") + ) + ) + ) + ) + (set! (-> self control mod-surface) *smack-mods*) + (let ((v1-63 (ja-group))) + (when (not (and v1-63 (= v1-63 (-> self draw art-group data 348)))) + (ja-channel-push! 1 (seconds 0.075)) + (ja :group! (-> self draw art-group data 348) :num! min) + ) + ) + (target-hit-move gp-0 (target-hit-orient gp-0 s5-0) target-mech-falling-anim-trans 1.0) + ) + (go target-mech-hit-ground #f) + (none) + ) + :post (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)) + (vector-float*! + (-> self control dynam gravity) + (-> self control dynam gravity-normal) + (the-as float (-> self control dynam gravity-length)) + ) + (target-mech-post) + (none) + ) + ) + +(defstate target-mech-death (target) + :event (-> target-death event) + :exit (behavior () + (set! (-> self mech stick-off) #f) + (target-mech-exit) + ((-> target-death exit)) + (none) + ) + :trans (-> target-mech-hit trans) + :code (behavior ((arg0 symbol)) + (set! (-> self mech stick-off) (the-as basic #t)) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control did-move-to-pole-or-max-jump-height) + (the-as float (send-event (handle->process (-> self attack-info attacker)) 'target 'die arg0)) + ) + (set! (-> self neck flex-blend) 0.0) + (target-timed-invulnerable-off self 0) + (target-timed-invulnerable-off self 0) + (set-setting! 'process-mask 'set 0 (process-mask platform projectile death)) + (apply-settings *setting-control*) + (set! (-> self control transv quad) (the-as uint128 0)) + (logior! (-> self focus-status) (focus-status dead)) + (cond + ((or (= arg0 'none) (= arg0 'instant-death) (= arg0 'bot) (= arg0 'big-explosion)) + ) + ((= arg0 'grenade) + (sound-play "explosion") + ) + ((= arg0 'endlessfall) + (sound-play "mech-death-fall") + (set! (-> self control unknown-sound-id00) + (add-process *gui-control* *target* (gui-channel daxter) (gui-action play) "jakfall" -99.0 0) + ) + (set-falloff! *gui-control* (-> self control unknown-sound-id00) #t -1 100 2) + (set-setting! 'mode-name 'cam-endlessfall 0 0) + (set! (-> self control pat-ignore-mask) + (logior (new 'static 'pat-surface :noendlessfall #x1) (-> self control pat-ignore-mask)) + ) + (logclear! (-> self water flags) (water-flags swim-ground)) + (let ((f0-2 (fmin -4096.0 (- (-> self control ground-impact-vel))))) + (set! (-> self control unknown-word04) (the-as uint f0-2)) + (let ((v1-45 (new-stack-vector0))) + (let ((f1-3 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-45 (-> self control transv) (vector-float*! v1-45 (-> self control dynam gravity-normal) f1-3)) + ) + (let* ((f1-4 (vector-length v1-45)) + (f2-1 f1-4) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f0-2) + (vector-float*! v1-45 v1-45 (/ f1-4 f2-1)) + ) + ) + ) + ) + (set! (-> self trans-hook) + (lambda :behavior target + () + (vector-seek! (-> self draw color-mult) *zero-vector* (-> self clock seconds-per-frame)) + (let ((v1-2 (new-stack-vector0)) + (f0-2 (the-as number (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + ) + 0.0 + (vector-! + v1-2 + (-> self control transv) + (vector-float*! v1-2 (-> self control dynam gravity-normal) (the-as float f0-2)) + ) + (let* ((f1-2 (vector-length v1-2)) + (f2-0 f1-2) + ) + (if (< (the-as float (-> self control unknown-word04)) (the-as float f0-2)) + (set! f0-2 (-> self control unknown-word04)) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) (the-as float f0-2)) + (vector-float*! v1-2 v1-2 (/ f1-2 f2-0)) + ) + ) + ) + ((-> target-mech-hit trans)) + (none) + ) + ) + (ja-channel-push! 1 (seconds 0.3)) + (ja-no-eval :group! (-> self draw art-group data 330) :num! (loop! 0.5) :frame-num 0.0) + (let ((gp-3 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) gp-3) (seconds 0.8)) + (ja :group! (-> self draw art-group data 330) :num! (loop! 0.5)) + (suspend) + ) + ) + (remove-setting! 'mode-name) + ) + (else + (set! (-> self control mod-surface) *empty-mods*) + (rot->dir-targ! (-> self control)) + (remove-setting! 'slave-options) + (remove-setting! 'fov) + (remove-setting! 'head-offset) + (send-event *camera* 'set-dist #f #f) + (set! (-> self burn-proc) + (ppointer->handle + (process-spawn-function process process-drawable-burn-effect 1200 :to (ppointer->process (-> self manipy))) + ) + ) + (let ((gp-5 (if (zero? (rand-vu-int-count 2)) + (-> self draw art-group data 351) + (-> self draw art-group data 352) + ) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (let ((f30-0 (if (logtest? (-> self water flags) (water-flags under-water)) + 0.55 + 1.0 + ) + ) + ) + (ja-no-eval :group! gp-5 + :num! (seek! (the float (+ (-> (the-as art-joint-anim gp-5) frames num-frames) -1)) f30-0) + :frame-num 0.0 + ) + (until (ja-done? 0) + (when (>= (- (-> *display* game-clock frame-counter) (-> self shock-effect-time)) (seconds 0.03)) + (set! (-> self shock-effect-time) (-> *display* game-clock frame-counter)) + (process-drawable-shock-effect + (the-as process-drawable (ppointer->process (-> self manipy))) + (-> *lightning-spec-id-table* 1) + lightning-probe-callback + (-> *part-id-table* 166) + 0 + 0 + 40960.0 + ) + ) + (suspend) + (ja :num! (seek! max f30-0)) + ) + ) + ) + (sound-play "mech-eject") + (let ((gp-7 (get-process *default-dead-pool* part-tracker #x4000))) + (when gp-7 + (let ((t9-33 (method-of-type part-tracker activate))) + (t9-33 (the-as part-tracker gp-7) self (symbol->string (-> part-tracker symbol)) (the-as pointer #x70004000)) + ) + (let ((t9-34 run-function-in-process) + (a0-72 gp-7) + (a1-35 part-tracker-init) + (a2-31 (-> *part-group-id-table* 202)) + (a3-13 0) + (t0-8 #f) + (t1-8 #f) + (t2-5 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-34) + a0-72 + a1-35 + a2-31 + a3-13 + t0-8 + t1-8 + t2-5 + t3-0 + ) + ) + (-> gp-7 ppointer) + ) + ) + (rot->dir-targ! (-> self control)) + (ja-post) + (let ((gp-8 (new 'stack 'joint-exploder-tuning (the-as uint 0)))) + (cond + ((logtest? (-> self water flags) (water-flags under-water)) + (set! (-> gp-8 duration) (seconds 8)) + (set! (-> gp-8 gravity) -20480.0) + (set! (-> gp-8 rot-speed) 4.2) + (set-vector! (-> gp-8 fountain-rand-transv-lo) -20480.0 12288.0 -20480.0 1.0) + (set-vector! (-> gp-8 fountain-rand-transv-hi) 20480.0 24576.0 20480.0 1.0) + ) + (else + (set! (-> gp-8 gravity) -204800.0) + (set-vector! (-> gp-8 fountain-rand-transv-lo) -61440.0 12288.0 -61440.0 1.0) + (set-vector! (-> gp-8 fountain-rand-transv-hi) 61440.0 49152.0 61440.0 1.0) + ) + ) + (process-spawn + joint-exploder + (art-group-get-by-name *level* "skel-mech-explode" (the-as (pointer uint32) #f)) + 41 + gp-8 + *mech-exploder-params* + :to (ppointer->process (-> self manipy)) + ) + ) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (logior! (-> self state-flags) (state-flags sf6)) + (set! (-> self alt-cam-pos quad) (-> self control trans quad)) + (set! (-> self post-hook) target-no-move-post) + (ja-channel-set! 1) + (ja-no-eval :group! (-> self draw art-group data 70) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 70)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (set! (-> self control transv quad) (the-as uint128 0)) + (vector-seek! + (-> self draw color-mult) + (new 'static 'vector :x 0.5 :y 0.5 :z 0.5 :w 1.0) + (* 5.0 (-> self clock seconds-per-frame)) + ) + (suspend) + (ja :num! (seek!)) + ) + (let ((gp-9 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) gp-9) (seconds 2)) + (suspend) + ) + ) + ) + ) + (set! (-> self control transv quad) (the-as uint128 0)) + (initialize! (-> self game) 'life (the-as game-save #f) (the-as string #f)) + (if (!= (-> self game mode) 'play) + (go target-jump 16384.0 16384.0 (the-as surface #f)) + ) + (set! (-> self state-time) (-> self clock frame-counter)) + (sleep-code) + (none) + ) + :post target-mech-post + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior target-mech-carry-update target () + (carry-info-method-9 (-> self carry)) + (when (and (= (-> self control collide-mode) 'mech-carry) (< (-> self control collide-mode-transition) 1.0)) + (let ((gp-0 (new 'stack-no-clear 'collide-query)) + (s5-0 (new 'stack-no-clear 'sphere)) + ) + (dotimes (s4-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s5-0) (* s4-0 16))) sphere) + ) + (let ((f30-0 (seek (-> self control collide-mode-transition) 1.0 (* 0.1 (-> self clock time-adjust-ratio))))) + (set! (-> (the-as sphere (&-> s5-0 x)) quad) + (-> self control collision-spheres 2 prim-core world-sphere quad) + ) + (set! (-> s5-0 r) (lerp-scale (-> *TARGET-bank* body-radius) 11468.8 f30-0 0.0 1.0)) + (let ((v1-17 gp-0)) + (set! (-> v1-17 best-dist) (the-as float s5-0)) + (set! (-> v1-17 num-spheres) (the-as uint 1)) + (set! (-> v1-17 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-17 ignore-process0) #f) + (set! (-> v1-17 ignore-process1) #f) + (set! (-> v1-17 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-17 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-17 action-mask) (collide-action solid)) + ) + (if (not (fill-and-probe-using-spheres *collide-cache* gp-0)) + (target-collide-set! 'mech-carry f30-0) + ) + ) + ) + ) + (send-event (handle->process (-> self carry other)) 'carry (-> self carry)) + (none) + ) + +(defbehavior target-mech-carry-post target () + (set! (-> self focus-status) (logior (focus-status carry) (-> self focus-status))) + (target-mech-post) + (target-mech-carry-update) + (none) + ) + +(defstate target-mech-carry-pickup (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('touched) + (cond + (((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> event param 0)) + (-> self control) + (the-as uint 1920) + ) + (let ((a1-2 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-2 from) (process->ppointer self)) + (set! (-> a1-2 num-params) 0) + (set! (-> a1-2 message) 'carry?) + (let ((a1-3 (send-event-function proc a1-2))) + (when a1-3 + (let ((f0-0 (distance-from-destination (-> self carry) (the-as carry-info a1-3)))) + (when (and (>= f0-0 0.0) (< f0-0 (-> self carry other-value))) + (set! (-> self carry other) (process->handle proc)) + (set! (-> self carry other-value) f0-0) + ) + ) + ) + ) + ) + #f + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + (('change-mode 'end-mode) + #f + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-pickup-mods*) + (set! (-> self mech stick-off) (the-as basic #t)) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (set! (-> self carry other) (the-as handle #f)) + (set! (-> self carry other-value) 100000000000.0) + (set! (-> self carry max-distance) 32768.0) + (set! (-> self carry mode) (carry-mode carry mech-carry mech-drag)) + (carry-info-method-9 (-> self carry)) + (none) + ) + :exit (behavior () + (when (not (and (-> self next-state) (let ((v1-3 (-> self next-state name))) + (or (= v1-3 'target-mech-carry-stance) + (= v1-3 'target-mech-carry-walk) + (= v1-3 'target-mech-carry-drop) + (= v1-3 'target-mech-carry-throw) + (= v1-3 'target-mech-carry-jump) + (= v1-3 'target-mech-carry-falling) + (= v1-3 'target-mech-carry-hit-ground) + (= v1-3 'target-mech-carry-throw) + (= v1-3 'target-mech-carry-drag) + ) + ) + ) + ) + (logclear! (-> self focus-status) (focus-status carry)) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'mech 0.0) + (target-exit) + ) + (set! (-> self mech stick-off) #f) + (target-mech-exit) + (none) + ) + :code (behavior () + (let ((f30-0 0.0) + (f28-0 0.0) + (gp-0 #f) + ) + (ja-channel-push! 2 1) + (ja :group! (-> self draw art-group data 337) :num! min) + (let ((a0-2 (-> self skel root-channel 1))) + (set! (-> a0-2 frame-interp 1) f30-0) + (set! (-> a0-2 frame-interp 0) f30-0) + (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 336))) + (set! (-> a0-2 param 0) 0.0) + (joint-control-channel-group-eval! + a0-2 + (the-as art-joint-anim (-> self draw art-group data 336)) + num-func-chan + ) + ) + (suspend) + (ja :num! (seek!)) + (ja :chan 1 :num! (chan 0)) + (target-danger-set! 'carry? #f) + (suspend) + (ja :num! (seek!)) + (ja :chan 1 :num! (chan 0)) + (format #t "carry picked ~A~%" (handle->process (-> self carry other))) + (let ((a1-9 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-9 from) (process->ppointer self)) + (set! (-> a1-9 num-params) 0) + (set! (-> a1-9 message) 'carry-info) + (let ((s5-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-9)))) + (cond + (s5-1 + (let* ((s4-1 (vector-! (new 'stack-no-clear 'vector) (-> s5-1 point) (-> self control trans))) + (s3-0 (new-stack-vector0)) + (f26-0 (vector-dot (-> self control local-normal) s4-1)) + ) + 0.0 + (vector-! s3-0 s4-1 (vector-float*! s3-0 (-> self control local-normal) f26-0)) + (let* ((f24-0 (vector-length s3-0)) + (f22-0 f24-0) + ) + (set! f28-0 (lerp-scale 1.0 0.0 f26-0 3072.0 7168.0)) + (vector+! + s4-1 + (vector-float*! s4-1 (-> self control local-normal) f26-0) + (vector-float*! s3-0 s3-0 (/ f24-0 f22-0)) + ) + ) + ) + (cond + ((logtest? (-> s5-1 mode) (carry-mode mech-drag)) + (sound-play "mech-drag-pikup") + (let ((s4-5 (vector-! (new 'stack-no-clear 'vector) (-> self carry point) (-> s5-1 point)))) + (set! gp-0 #t) + (vector-xz-normalize! s4-5 (-> s5-1 max-pull)) + (vector+! s4-5 s4-5 (-> s5-1 point)) + ) + (let* ((f26-1 (y-angle (-> s5-1 process 0 control))) + (f0-15 (vector-y-angle (vector-! (new 'stack-no-clear 'vector) (-> s5-1 point) (-> self carry point)))) + (f0-21 (the float (the int (* 0.000061035156 (+ 73728.0 (deg- f0-15 f26-1)))))) + (s5-2 (new 'stack-no-clear 'vector)) + ) + (set! (-> self carry face-dir) (the int f0-21)) + (let ((f24-2 (the float (sar (shl (the int (* 16384.0 f0-21)) 48) 48)))) + (set! (-> self control unknown-word04) (the-as uint (+ f26-1 f24-2))) + (set-vector! s5-2 (sin (+ f26-1 f24-2)) 0.0 (cos (+ f26-1 f24-2)) 1.0) + ) + (forward-up-nopitch->quaternion + (-> self control dir-targ) + s5-2 + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + (else + (sound-play "mech-drag-pikup") + (forward-up-nopitch->quaternion + (-> self control dir-targ) + (vector-normalize! (vector-! (new-stack-vector0) (-> s5-1 point) (-> self control trans)) 1.0) + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + ) + (else + (sound-play "mech-pickup-1") + ) + ) + ) + ) + (target-danger-set! 'harmless #f) + (cond + (gp-0 + (ja-channel-push! 1 (seconds 0.01)) + (ja-no-eval :group! (-> self draw art-group data 347) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 347)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :num! (seek! (ja-aframe 8.0 0))) + (while (not (ja-done? 0)) + (set! f30-0 (seek f30-0 f28-0 (* 5.0 (-> self clock seconds-per-frame)))) + (let ((v1-120 (-> self skel root-channel 1))) + (set! (-> v1-120 frame-interp 1) f30-0) + (set! (-> v1-120 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + ) + ) + (let ((s4-11 (new 'stack-no-clear 'vector)) + (s5-6 (new 'stack-no-clear 'vector)) + ) + (when (send-event (handle->process (-> self carry other)) 'pickup (-> self carry) s4-11 s5-6) + (target-collide-set! 'mech-carry 0.0) + (when gp-0 + (sound-play "mech-drag-grab") + (let ((s3-6 (vector-! (new 'stack-no-clear 'vector) s4-11 (-> self control trans))) + (a1-37 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-37 from) (process->ppointer self)) + (set! (-> a1-37 num-params) 0) + (set! (-> a1-37 message) 'carry-info) + (let ((s4-12 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-37)))) + (vector-flatten! s3-6 s3-6 s5-6) + (let ((f0-43 (vector-length s3-6))) + (when (< 1228.8 f0-43) + (vector-normalize! s3-6 (+ -1228.8 f0-43)) + (move-by-vector! (-> self control) s3-6) + (vector+! (-> s4-12 hold-trans) (-> s4-12 hold-trans) s3-6) + ) + ) + ) + ) + (set-yaw-angle-clear-roll-pitch! (-> self control) (the-as float (-> self control unknown-word04))) + (rot->dir-targ! (-> self control)) + (go target-mech-carry-drag) + ) + (sound-play "mech-servo-up") + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (set! f30-0 (seek f30-0 f28-0 (* 5.0 (-> self clock seconds-per-frame)))) + (let ((v1-174 (-> self skel root-channel 1))) + (set! (-> v1-174 frame-interp 1) f30-0) + (set! (-> v1-174 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + (go target-mech-carry-stance) + ) + ) + (cond + (gp-0 + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + ) + (else + (ja-no-eval :num! (seek! (ja-aframe 11.0 0))) + (while (not (ja-done? 0)) + (let ((v1-190 (-> self skel root-channel 1))) + (set! (-> v1-190 frame-interp 1) f30-0) + (set! (-> v1-190 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + (suspend) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (let ((v1-199 (-> self skel root-channel 1))) + (set! (-> v1-199 frame-interp 1) f30-0) + (set! (-> v1-199 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + ) + ) + ) + (go target-mech-stance) + (none) + ) + :post (behavior () + (target-mech-post) + (carry-info-method-9 (-> self carry)) + (target-mech-carry-update) + (none) + ) + ) + +(defstate target-mech-carry-drop (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('change-mode 'end-mode) + #f + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (set! (-> self mech stick-off) (the-as basic #t)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :code (behavior () + (let ((f30-0 1.0) + (gp-1 (sound-play "mech-servo-down")) + ) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) (process->ppointer self)) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'carry-info) + (let ((a0-8 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-1)))) + (when a0-8 + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> a0-8 point quad)) + (set! (-> s5-1 y) (- (-> s5-1 y) (-> a0-8 process 0 control root-prim prim-core world-sphere w))) + (let ((s4-0 (new-stack-vector0)) + (f28-0 (vector-dot (-> self control local-normal) s5-1)) + ) + 0.0 + (vector-! s4-0 s5-1 (vector-float*! s4-0 (-> self control local-normal) f28-0)) + (let* ((f26-0 (vector-length s4-0)) + (f24-0 f26-0) + ) + (set! f30-0 (lerp-scale 1.0 0.0 f28-0 3072.0 7168.0)) + (vector+! + s5-1 + (vector-float*! s5-1 (-> self control local-normal) f28-0) + (vector-float*! s4-0 s4-0 (/ f26-0 f24-0)) + ) + ) + ) + ) + ) + ) + ) + (ja-channel-push! 2 (seconds 0.1)) + (ja :group! (-> self draw art-group data 337) + :num! (identity (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 337)) frames num-frames) -1))) + ) + (let ((a0-19 (-> self skel root-channel 1))) + (set! (-> a0-19 frame-interp 1) f30-0) + (set! (-> a0-19 frame-interp 0) f30-0) + (set! (-> a0-19 frame-group) (the-as art-joint-anim (-> self draw art-group data 336))) + (set! (-> a0-19 param 0) 0.0) + (joint-control-channel-group-eval! + a0-19 + (the-as art-joint-anim (-> self draw art-group data 336)) + num-func-chan + ) + ) + (suspend) + (ja-no-eval :num! (seek! (ja-aframe 8.0 0))) + (while (not (ja-done? 0)) + (let ((a1-10 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-10 from) (process->ppointer self)) + (set! (-> a1-10 num-params) 0) + (set! (-> a1-10 message) 'carry-info) + (let ((s5-5 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-10)))) + (when s5-5 + (if (< 20.0 (ja-aframe-num 0)) + (seek! (-> s5-5 grab-trans-blend) 1.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + (let ((s3-0 (-> s5-5 process 0 control)) + (s5-6 (new 'stack-no-clear 'collide-query)) + ) + (let ((s4-1 (new 'stack-no-clear 'sphere))) + (dotimes (s2-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s4-1) (* s2-0 16))) sphere) + ) + (set! (-> (the-as sphere (&-> s4-1 x)) quad) (-> s3-0 root-prim prim-core world-sphere quad)) + (let ((v1-66 s5-6)) + (set! (-> v1-66 best-dist) (the-as float s4-1)) + (set! (-> v1-66 num-spheres) (the-as uint 1)) + (set! (-> v1-66 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-66 ignore-process0) #f) + (set! (-> v1-66 ignore-process1) #f) + (set! (-> v1-66 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-66 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-66 action-mask) (collide-action solid)) + ) + ) + (when (fill-and-probe-using-spheres *collide-cache* s5-6) + (sound-play "mech-setdown") + (let ((v1-71 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-71 command) (sound-command set-param)) + (set! (-> v1-71 id) gp-1) + (set! (-> v1-71 params volume) -4) + (set! (-> v1-71 auto-time) 48) + (set! (-> v1-71 auto-from) 2) + (set! (-> v1-71 params mask) (the-as uint 17)) + (-> v1-71 id) + ) + (set! gp-1 (sound-play "mech-servo-up")) + (let ((v1-75 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-75 command) (sound-command set-param)) + (set! (-> v1-75 id) gp-1) + (set! (-> v1-75 params volume) -4) + (set! (-> v1-75 auto-time) 192) + (set! (-> v1-75 auto-from) 2) + (set! (-> v1-75 params mask) (the-as uint 17)) + (-> v1-75 id) + ) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-carry-stance) + ) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + ) + (sound-play "mech-setdown") + (let ((v1-91 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 0.0))) + (vector+float*! v1-91 v1-91 (-> self control c-R-w vector 2) 20480.0) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-91) + ) + (target-collide-set! 'mech 0.0) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-stance) + (none) + ) + :post (-> target-mech-carry-pickup post) + ) + +(defstate target-mech-carry-stance (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('change-mode) + (case (-> event param 0) + (('falling) + (if (and (-> self next-state) (= (-> self next-state name) 'target-mech-carry-drag)) + #f + (go target-mech-carry-falling) + ) + ) + (('grab) + (if (not (-> event param 1)) + #t + (go target-mech-grab) + ) + ) + ) + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-stance-mods*) + (set! (-> self control mod-surface turnvv) 20024.889) + (set! (-> self control did-move-to-pole-or-max-jump-height) 0.0) + (rot->dir-targ! (-> self control)) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (behavior () + ((-> target-mech-carry-pickup exit)) + (rot->dir-targ! (-> self control)) + (none) + ) + :trans (behavior () + (if (and (move-legs?) + (and (< (fabs + (deg-diff (quaternion-y-angle (-> self control dir-targ)) (vector-y-angle (-> self control to-target-pt-xz))) + ) + 1820.4445 + ) + (>= (- (-> self clock frame-counter) (-> self control time-of-last-zero-input)) (seconds 0.05)) + ) + ) + (go target-mech-carry-walk) + ) + (if (and (cpad-pressed? (-> self control cpad number) r1) + (>= (- (-> self clock frame-counter) (-> self carry pickup-time)) (seconds 0.1)) + ) + (go target-mech-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-24 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-3 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-24 a1-3) + ) + ) + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-carry-throw) + ) + (fall-test (the-as (state symbol target) target-mech-carry-falling) (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 344)))) + (ja-channel-push! 2 (seconds 0.2)) + (ja :group! (-> self draw art-group data 344) :dist 8192.0) + (ja :chan 1 :group! (-> self draw art-group data 338) :dist 0.0) + ) + ) + (let ((f30-0 0.0)) + (until #f + (let ((f28-0 (y-angle (-> self control)))) + (deg-diff f28-0 (quaternion-y-angle (-> self control dir-targ))) + (suspend) + (let ((f28-1 (* (deg-diff f28-0 (y-angle (-> self control))) (-> self clock frames-per-second)))) + (set! f30-0 (if (< 910.2222 (fabs f28-1)) + (seek f30-0 1.0 (* 16.0 (-> self clock seconds-per-frame))) + (seek f30-0 0.0 (* 6.0 (-> self clock seconds-per-frame))) + ) + ) + (let* ((f0-9 (current-cycle-distance (-> self skel))) + (v1-26 (if (= f0-9 0.0) + 0.0 + (/ f28-1 f0-9) + ) + ) + (f0-11 v1-26) + ) + (ja :num! (loop! f0-11)) + ) + ) + ) + (let ((v1-32 (-> self skel root-channel 1)) + (f0-13 (- 1.0 f30-0)) + ) + (set! (-> v1-32 frame-interp 1) f0-13) + (set! (-> v1-32 frame-interp 0) f0-13) + ) + ) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +(defstate target-mech-carry-walk (target) + :event (-> target-mech-carry-stance event) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *mech-carry-walk-mods*) + (set! (-> self control unknown-word04) (the-as uint 0.0)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :trans (behavior () + (let ((gp-0 (ja-group)) + (f0-0 (ja-aframe-num 0)) + ) + (when (if (or (and (= gp-0 (-> self draw art-group data 339)) (>= f0-0 5.5) (>= 9.5 f0-0)) + (and (= gp-0 (-> self draw art-group data 339)) (>= f0-0 20.5) (>= 24.5 f0-0)) + ) + #t + ) + (when (and (< 5.0 (the-as float (-> self control unknown-word04))) + (= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + ) + (set-forward-vel 0.0) + (go target-mech-carry-stance) + ) + ) + ) + (if (and (cpad-pressed? (-> self control cpad number) r1) + (>= (- (-> self clock frame-counter) (-> self carry pickup-time)) (seconds 0.1)) + ) + (go target-mech-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-24 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-24 a1-2) + ) + ) + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-carry-throw) + ) + (fall-test (the-as (state symbol target) target-mech-carry-falling) (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((f30-0 0.0)) + (let ((f28-0 (cond + ((zero? (-> self mech walk-anim-leg)) + (set! (-> self mech walk-anim-leg) 1) + 7.0 + ) + (else + (set! (-> self mech walk-anim-leg) 0) + 22.0 + ) + ) + ) + (v1-7 (ja-group)) + ) + (when (not (and v1-7 (= v1-7 (-> self draw art-group data 339)))) + (ja-channel-push! 2 (seconds 0.1)) + (ja :group! (-> self draw art-group data 339) + :num! (identity (ja-aframe f28-0 0)) + :dist (-> *TARGET-bank* mech-walk-cycle-dist) + ) + (ja :chan 1 :group! (-> self draw art-group data 338) :dist 0.0) + ) + ) + (until #f + (if (< (-> self control ctrl-xz-vel) 4096.0) + (set-forward-vel 4096.0) + ) + (suspend) + (let* ((f0-4 (current-cycle-distance (-> self skel))) + (f28-1 (/ (-> self control ctrl-xz-vel) f0-4)) + ) + (set! (-> self control unknown-word04) + (the-as uint (+ (the-as float (-> self control unknown-word04)) f28-1)) + ) + (set! f30-0 (seek + f30-0 + (lerp-scale 1.0 0.0 (-> self control ctrl-xz-vel) 0.0 8192.0) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (ja :num! (loop! f28-1)) + ) + (let ((a0-16 (-> self skel root-channel 1))) + (set! (-> a0-16 frame-interp 1) f30-0) + (set! (-> a0-16 frame-interp 0) f30-0) + (set! (-> a0-16 param 0) 0.0) + (joint-control-channel-group-eval! a0-16 (the-as art-joint-anim #f) num-func-chan) + ) + ) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +(defstate target-mech-carry-drag (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('push) + (when (zero? (-> self control sliding-start-time)) + (set! (-> self control sliding-start-time) + (+ (-> self clock frame-counter) (the-as time-frame (-> event param 0))) + ) + (let ((v0-0 (the-as object #t))) + (set! (-> self control unknown-word04) (the-as uint v0-0)) + v0-0 + ) + ) + ) + (('drop) + (logclear! (-> *cpad-list* cpads (-> self control cpad number) button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) (pad-buttons r1)) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'mech 0.0) + (go target-mech-stance) + ) + (else + ((-> target-mech-carry-stance event) proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control sliding-start-time) 0) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control mod-surface) *mech-carry-drag-mods*) + (set-forward-vel 0.0) + (none) + ) + :exit (behavior () + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + (let ((v1-3 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-3 command) (sound-command set-param)) + (set! (-> v1-3 id) (the-as sound-id (-> self mech thrust-sound-id))) + (set! (-> v1-3 params volume) -4) + (set! (-> v1-3 auto-time) 48) + (set! (-> v1-3 auto-from) 2) + (set! (-> v1-3 params mask) (the-as uint 17)) + (-> v1-3 id) + ) + (let ((v1-5 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-5 command) (sound-command set-param)) + (set! (-> v1-5 id) (the-as sound-id (-> self mech drag-sound-id))) + (set! (-> v1-5 params volume) -4) + (set! (-> v1-5 auto-time) 48) + (set! (-> v1-5 auto-from) 2) + (set! (-> v1-5 params mask) (the-as uint 17)) + (-> v1-5 id) + ) + ((-> target-mech-carry-pickup exit)) + (none) + ) + :trans (behavior () + (when (and (not (cpad-hold? (-> self control cpad number) r1)) + (>= (- (-> self clock frame-counter) (-> self carry pickup-time)) (seconds 0.5)) + ) + (sound-play "mech-drag-off") + (if (or (and (>= (-> self mech back-touch-time) (-> self state-time)) + (< (vector-vector-distance (-> self control trans) (-> self mech back-touch-trans)) 4096.0) + ) + (let ((gp-1 (new 'stack-no-clear 'collide-query))) + (let ((s5-1 (new 'stack-no-clear 'sphere))) + (dotimes (s4-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s5-1) (* s4-0 16))) sphere) + ) + (set! (-> (the-as sphere (&-> s5-1 x)) quad) + (-> self control collision-spheres 0 prim-core world-sphere quad) + ) + (vector+float*! + (the-as vector (&-> s5-1 x)) + (the-as vector (&-> s5-1 x)) + (-> self control c-R-w vector 2) + -4096.0 + ) + (set! (-> s5-1 r) (-> self control collision-spheres 0 prim-core world-sphere w)) + (let ((v1-30 gp-1)) + (set! (-> v1-30 best-dist) (the-as float s5-1)) + (set! (-> v1-30 num-spheres) (the-as uint 1)) + (set! (-> v1-30 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-30 ignore-process0) #f) + (set! (-> v1-30 ignore-process1) #f) + (set! (-> v1-30 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-30 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-30 action-mask) (collide-action solid)) + ) + ) + (fill-and-probe-using-spheres *collide-cache* gp-1) + ) + ) + (send-event self 'push 150) + (send-event self 'drop) + ) + ) + (none) + ) + :code (behavior () + (let ((f28-0 0.0) + (f30-0 0.0) + ) + (until #f + (let ((f0-2 + (* (vector-dot (-> self control to-target-pt-xz) (-> self control c-R-w vector 2)) + (-> self control turn-to-magnitude) + ) + ) + (f26-0 0.0) + ) + (if (and (nonzero? (-> self control sliding-start-time)) + (< (-> self control sliding-start-time) (-> self clock frame-counter)) + ) + (send-event self 'drop) + (set! f28-0 + (cond + ((nonzero? (-> self control sliding-start-time)) + (let ((v1-17 (ja-group))) + (when (not (and v1-17 (= v1-17 (-> self draw art-group data 345)))) + (let ((v1-23 (ja-group))) + (if (and v1-23 (= v1-23 (-> self draw art-group data 346))) + (set! f26-0 (ja-aframe-num 0)) + ) + ) + (sound-play "mech-drag-push") + (ja-channel-push! 1 (seconds 0.3)) + (ja :group! (-> self draw art-group data 345) :num! (identity (ja-aframe f26-0 0)) :dist 16384.0) + ) + ) + (when (-> self control unknown-spool-anim00) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! f28-0 32768.0) + ) + (seek f28-0 0.0 (* 65536.0 (-> self clock seconds-per-frame))) + ) + ((< 0.0 f0-2) + (let ((v1-47 (ja-group))) + (when (not (and v1-47 (= v1-47 (-> self draw art-group data 345)))) + (let ((v1-53 (ja-group))) + (if (and v1-53 (= v1-53 (-> self draw art-group data 346))) + (set! f26-0 (ja-aframe-num 0)) + ) + ) + (sound-play "mech-drag-push") + (ja-channel-push! 1 (seconds 0.3)) + (ja :group! (-> self draw art-group data 345) :num! (identity (ja-aframe f26-0 0)) :dist 16384.0) + ) + ) + (seek f28-0 49152.0 (* 24576.0 (-> self clock seconds-per-frame))) + ) + ((< f0-2 0.0) + (let ((v1-71 (ja-group))) + (when (not (and v1-71 (= v1-71 (-> self draw art-group data 346)))) + (let ((v1-77 (ja-group))) + (if (and v1-77 (= v1-77 (-> self draw art-group data 345))) + (set! f26-0 (ja-aframe-num 0)) + ) + ) + (sound-play "mech-drag-pull") + (ja-channel-push! 1 (seconds 0.3)) + (ja :group! (-> self draw art-group data 346) :num! (identity (ja-aframe f26-0 0)) :dist 16384.0) + ) + ) + (seek f28-0 -49152.0 (* 24576.0 (-> self clock seconds-per-frame))) + ) + (else + (seek f28-0 0.0 (* 32768.0 (-> self clock seconds-per-frame))) + ) + ) + ) + ) + ) + (set! f30-0 + (seek + f30-0 + (lerp-scale + 0.0 + 1.0 + (* (vector-vector-distance (-> self control trans) (-> self control trans-old-old)) + (-> self clock frames-per-second) + ) + 0.0 + 49152.0 + ) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (sound-play-by-name + (static-sound-name "mech-drag-grind") + (the-as sound-id (-> self mech drag-sound-id)) + (the int (* 1024.0 f30-0)) + 0 + 0 + (sound-group sfx) + #t + ) + (set-forward-vel f28-0) + (let* ((f0-24 (current-cycle-distance (-> self skel))) + (f26-1 (/ f28-0 (* 2.0 f0-24))) + ) + (seek! + (-> self mech jump-thrust) + (lerp-scale 0.0 245760.0 (fabs f28-0) 0.0 49152.0) + (* 491520.0 (-> self clock seconds-per-frame)) + ) + (set! (-> self mech thruster-flame-width) (* 0.021428572 (-> self mech jump-thrust))) + (set! (-> self mech thruster-flame-length) (* 0.028571429 (-> self mech jump-thrust))) + (let ((v1-120 (ja-group))) + (if (and v1-120 (or (= v1-120 (-> self draw art-group data 345)) (= v1-120 (-> self draw art-group data 346)))) + (ja :num! (loop! f26-1)) + ) + ) + ) + (suspend) + 0 + ) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +(defstate target-mech-carry-falling (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (let ((v0-0 (target-mech-bonk-event-handler proc arg1 event-type event))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + ((-> target-mech-carry-stance event) proc arg1 event-type event) + ) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-carry-jump-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :trans (behavior () + (if (logtest? (-> self control status) (collide-status on-surface)) + (go target-mech-carry-hit-ground #f) + ) + (when (if (and (< (target-move-dist (-> *TARGET-bank* stuck-time)) (-> *TARGET-bank* stuck-distance)) + (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.05)) + (not (and *cheat-mode* (cpad-hold? (-> self control cpad number) r2))) + ) + #t + ) + (logior! (-> self control status) (collide-status on-surface)) + (go target-mech-carry-hit-ground 'stuck) + ) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (cond + ((and v1-2 (= v1-2 (-> self draw art-group data 341))) + ) + (else + (ja-channel-push! 1 (seconds 0.33)) + (ja :group! (-> self draw art-group data 341)) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (suspend) + ) + ) + ) + ) + (ja-no-eval :group! (-> self draw art-group data 341) :num! (loop!) :frame-num 0.0) + (until #f + (suspend) + (ja :group! (-> self draw art-group data 341) :num! (loop!)) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +(defstate target-mech-carry-hit-ground (target) + :event (-> target-mech-carry-falling event) + :enter (behavior ((arg0 symbol)) + (let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-param)) + (set! (-> v1-0 id) (the-as sound-id (-> self mech thrust-sound-id))) + (set! (-> v1-0 params volume) -4) + (set! (-> v1-0 auto-time) 48) + (set! (-> v1-0 auto-from) 2) + (set! (-> v1-0 params mask) (the-as uint 17)) + (-> v1-0 id) + ) + (rot->dir-targ! (-> self control)) + (cond + ((= arg0 'stuck) + ) + (else + (target-land-effect) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.3)) + ) + ) + (set! (-> self control last-running-attack-end-time) 0) + (set! (-> self control last-attack-end-time) 0) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control mod-surface) *mech-stance-mods*) + (set! (-> self control mod-surface turnvv) 0.0) + (start-bobbing! + (-> self water) + (lerp-scale 0.0 4096.0 (-> self control ground-impact-vel) 40960.0 102400.0) + 600 + 1500 + ) + (none) + ) + :exit (behavior () + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + ((-> target-mech-carry-pickup exit)) + (none) + ) + :trans (behavior () + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-16 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-16 a1-2) + ) + ) + (if (and (!= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + (let ((v1-26 (ja-group))) + (and (and v1-26 (= v1-26 (-> self draw art-group data 342))) (>= (ja-aframe-num 0) 30.0)) + ) + ) + (go target-mech-carry-walk) + ) + (fall-test (the-as (state symbol target) target-mech-carry-falling) (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior ((arg0 symbol)) + (target-hit-ground-anim #f (are-still?)) + (go target-mech-carry-stance) + (none) + ) + :post target-mech-carry-post + ) + +(defstate target-mech-carry-jump (target) + :event (-> target-mech-carry-falling event) + :enter (behavior ((arg0 float) (arg1 float)) + (set! (-> self state-time) (-> self clock frame-counter)) + (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (set! (-> self control mod-surface) *mech-carry-jump-mods*) + (set! (-> self control unknown-float36) + (fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control ctrl-xz-vel))))) + ) + (none) + ) + :exit (behavior () + (rot->dir-targ! (-> self control)) + ((-> target-mech-carry-pickup exit)) + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + (target-exit) + (none) + ) + :trans (behavior () + (set! (-> self control unknown-float36) + (fmax + (-> self control unknown-float36) + (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control cpad number) abutton 6))) + ) + ) + ((-> target-mech-carry-falling trans)) + (mod-var-jump #t #f (cpad-hold? (-> self control cpad number) x) (-> self control transv)) + (cond + ((>= (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 0.0) + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 2048.0) + (set! (-> self mech thruster-flame-length) 6144.0) + ) + (else + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + ) + ) + (none) + ) + :code (behavior ((arg0 float) (arg1 float)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> self draw art-group data 340) :num! min) + (suspend) + (ja :group! (-> self draw art-group data 340) :num! (+!)) + (suspend) + (until (ja-done? 0) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (f0-4 (- 10.0 (ja-aframe-num 0))) + (gp-1 (-> self skel root-channel 0)) + ) + (set! (-> gp-1 param 0) (the float (+ (-> gp-1 frame-group frames num-frames) -1))) + (let ((v1-27 (and (< 0.0 f30-0) (< 0.0 f0-4)))) + (set! (-> gp-1 param 1) + (if v1-27 + (fmin (fmin 3.0 f0-4) (/ (* 5.0 f0-4) (the float (time-to-apex f30-0 -245760.0)))) + 1.8 + ) + ) + ) + (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (suspend) + ) + (go target-mech-carry-falling) + (none) + ) + :post target-mech-carry-post + ) + +(defstate target-mech-carry-throw (target) + :event (-> target-mech-carry-drop event) + :enter (behavior () + (set! (-> self control mod-surface) *mech-walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (set! (-> self mech stick-off) (the-as basic #t)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :code (behavior () + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 343) :num! (seek! (ja-aframe 16.0 0)) :frame-num 0.0) + (until (ja-done? 0) + (let ((a1-3 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-3 from) (process->ppointer self)) + (set! (-> a1-3 num-params) 0) + (set! (-> a1-3 message) 'carry-info) + (let ((gp-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-3)))) + (if gp-1 + (seek! (-> gp-1 grab-trans-blend) 1.0 (* 4.0 (-> self clock seconds-per-frame))) + ) + ) + ) + (suspend) + (ja :num! (seek! (ja-aframe 16.0 0))) + ) + (let ((a1-7 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-7 from) (process->ppointer self)) + (set! (-> a1-7 num-params) 0) + (set! (-> a1-7 message) 'carry-info) + (let ((v1-30 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-7)))) + (when v1-30 + (let ((s4-0 (-> v1-30 process 0 control)) + (gp-3 (new 'stack-no-clear 'collide-query)) + ) + (let ((s5-0 (new 'stack-no-clear 'sphere))) + (dotimes (s3-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s5-0) (* s3-0 16))) sphere) + ) + (set! (-> (the-as sphere (&-> s5-0 x)) quad) (-> s4-0 root-prim prim-core world-sphere quad)) + (let ((v1-38 gp-3)) + (set! (-> v1-38 best-dist) (the-as float s5-0)) + (set! (-> v1-38 num-spheres) (the-as uint 1)) + (set! (-> v1-38 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-38 ignore-process0) #f) + (set! (-> v1-38 ignore-process1) #f) + (set! (-> v1-38 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-38 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-38 action-mask) (collide-action solid)) + ) + ) + (when (fill-and-probe-using-spheres *collide-cache* gp-3) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-carry-stance) + ) + ) + ) + ) + ) + (let ((v1-48 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 2048.0))) + (vector+float*! v1-48 v1-48 (-> self control c-R-w vector 2) 131072.0) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-48) + ) + (target-collide-set! 'normal 0.0) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-stance) + (none) + ) + :post (-> target-mech-carry-pickup post) + ) + +(defstate target-mech-get-on (target) + :event target-generic-event-handler + :exit (behavior () + (target-mech-exit) + (set! (-> self mech stick-off) #f) + (set! (-> self neck flex-blend) 1.0) + (logclear! (-> self state-flags) (state-flags sf5)) + (none) + ) + :code (behavior ((arg0 handle)) + (logior! (-> self state-flags) (state-flags sf5)) + (ja-channel-set! 1) + (set! (-> self control mod-surface) *empty-mods*) + (send-event (ppointer->process (-> self manipy)) 'draw #t) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control unknown-vector37 quad) (-> self control trans quad)) + (set! (-> self control unknown-vector38 quad) (-> self control trans quad)) + (set! (-> self control unknown-vector39 quad) (-> self control quat quad)) + (set! (-> self control unknown-vector40 quad) (-> self control quat quad)) + (let* ((gp-1 (handle->process arg0)) + (v1-23 (if (type? gp-1 process-drawable) + gp-1 + ) + ) + ) + (when v1-23 + (set! (-> self control unknown-vector38 quad) (-> (the-as process-drawable v1-23) root trans quad)) + (set! (-> self control unknown-vector40 quad) (-> (the-as process-drawable v1-23) root quat quad)) + ) + ) + (set! (-> self mech mech-trans quad) (-> self control unknown-vector38 quad)) + (quaternion-copy! + (the-as quaternion (-> self mech mech-quat)) + (the-as quaternion (-> self control unknown-vector40)) + ) + (set! (-> self mech mech-scale quad) (-> self control scale quad)) + (set! (-> self mech stick-off) (the-as basic #t)) + (ja-no-eval :group! (-> self draw art-group data 350) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 350)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (let ((f30-0 (sin (lerp-scale 0.0 16384.0 (ja-aframe-num 0) 70.0 80.0)))) + (let ((f28-0 (lerp-scale 0.0 1.0 (ja-aframe-num 0) 70.0 80.0))) + (vector-lerp! + (-> self control trans) + (-> self control unknown-vector37) + (-> self control unknown-vector38) + f30-0 + ) + (set! (-> self control trans y) + (lerp (-> self control unknown-vector37 y) (-> self control unknown-vector38 y) f28-0) + ) + ) + (quaternion-slerp! + (-> self control quat-for-control) + (the-as quaternion (-> self control unknown-vector39)) + (the-as quaternion (-> self control unknown-vector40)) + f30-0 + ) + ) + (rot->dir-targ! (-> self control)) + (set! (-> self alt-cam-pos quad) (-> self control camera-pos quad)) + (suspend) + (ja :num! (seek!)) + ) + (go target-mech-stance) + (none) + ) + :post (behavior () + (target-no-move-post) + (target-mech-effect) + (none) + ) + ) + +(defstate target-mech-get-off (target) + :event target-generic-event-handler + :exit (behavior () + ((-> target-mech-start exit)) + (logclear! (-> self state-flags) (state-flags sf5)) + (none) + ) + :code (behavior () + (logior! (-> self state-flags) (state-flags sf5)) + (set! (-> self control mod-surface) *empty-mods*) + (rot->dir-targ! (-> self control)) + (set-setting! 'slave-options 'clear 0 8192) + (remove-setting! 'fov) + (remove-setting! 'head-offset) + (send-event *camera* 'set-dist #f #f) + (set! (-> self neck flex-blend) 0.0) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 349) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 349)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (when (< 51.0 (ja-aframe-num 0)) + (logior! (-> self state-flags) (state-flags sf6)) + (vector<-cspace! (-> self alt-cam-pos) (-> self node-list data 36)) + ) + (suspend) + (ja :num! (seek!)) + ) + (process-spawn + mech + :init mech-init + (-> self mech entity) + (-> self control trans) + (process->handle self) + (-> self mech shield-value) + :to self + ) + (rot->dir-targ! (-> self control)) + (ja-post) + (let ((gp-1 (new 'stack-no-clear 'vector))) + (vector<-cspace! gp-1 (-> self node-list data 3)) + (set! (-> gp-1 y) (+ -9011.2 (-> gp-1 y))) + (move-to-point! (-> self control) gp-1) + ) + (send-event *camera* 'ease-in) + (ja-channel-set! 0) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (let ((v1-68 (new-stack-vector0))) + (let ((f0-13 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-68 (-> self control transv) (vector-float*! v1-68 (-> self control dynam gravity-normal) f0-13)) + ) + (let* ((f0-14 (vector-length v1-68)) + (f1-2 f0-14) + (f2-0 -49152.0) + (a0-36 (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-0) + (vector-float*! v1-68 v1-68 (/ f0-14 f1-2)) + ) + ) + ) + (go target-falling (the-as symbol a0-36)) + ) + ) + (none) + ) + :post (-> target-mech-get-on post) + ) + +(defstate target-mech-grab (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (cond + ((and (= event-type 'query) (= (-> event param 0) 'mode)) + (-> self state name) + ) + (else + (case event-type + (('end-mode) + (go target-mech-stance) + ) + (('clone-anim) + (go target-mech-clone-anim (process->handle (the-as process (-> event param 0)))) + ) + (else + (target-generic-event-handler proc arg1 event-type event) + ) + ) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *grab-mods*) + (set! (-> self neck flex-blend) 0.0) + (logior! (-> self state-flags) (state-flags sf2)) + (logior! (-> self focus-status) (focus-status grabbed)) + (set! (-> self mech stick-off) (the-as basic #t)) + (sound-stop (the-as sound-id (-> self mech engine-sound-id))) + (sound-stop (the-as sound-id (-> self mech thrust-sound-id))) + (sound-stop (the-as sound-id (-> self mech drag-sound-id))) + (sound-stop (the-as sound-id (-> self mech whine-sound-id))) + (none) + ) + :exit (behavior () + (set! (-> self mech stick-off) #f) + (logclear! (-> self state-flags) (state-flags sf2)) + (logclear! (-> self focus-status) (focus-status grabbed)) + (logclear! (-> self water flags) (water-flags jump-out)) + ((-> target-mech-start exit)) + (none) + ) + :code (-> target-mech-stance code) + :post target-mech-post + ) + +(defstate target-mech-clone-anim (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (if (and (= event-type 'trans) (= (-> event param 0) 'restore)) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ((-> target-mech-grab event) proc arg1 event-type event) + ) + :enter (-> target-clone-anim enter) + :exit (behavior () + (set! (-> self control draw-offset y) (the-as float (-> self control unknown-word04))) + (set! (-> self control cspace-offset y) (-> self control draw-offset y)) + (send-event (ppointer->process (-> self sidekick)) 'matrix #f) + ((-> target-clone-anim exit)) + ((-> target-mech-start exit)) + (vector-reset! (-> self control transv)) + (none) + ) + :code (behavior ((arg0 handle)) + (set! (-> self control unknown-word04) (the-as uint (-> self control draw-offset y))) + (set! (-> self control draw-offset y) 0.0) + (send-event (ppointer->process (-> self sidekick)) 'matrix 'play-anim) + (clone-anim arg0 #t "") + (go target-mech-stance) + (none) + ) + :post (behavior () + (vector+! (-> self mech mech-trans) (-> self control trans) (-> self control cspace-offset)) + (quaternion-copy! (the-as quaternion (-> self mech mech-quat)) (-> self control quat)) + (set! (-> self mech mech-scale quad) (-> self control scale quad)) + (target-no-ja-move-post) + (none) + ) + ) diff --git a/goal_src/jak2/engine/target/mech_suit/mech.gc b/goal_src/jak2/engine/target/mech_suit/mech.gc index 0912205ef..093538434 100644 --- a/goal_src/jak2/engine/target/mech_suit/mech.gc +++ b/goal_src/jak2/engine/target/mech_suit/mech.gc @@ -10,24 +10,513 @@ ;; DECOMP BEGINS +(if (not (nmember "mechp" *kernel-packages*)) + (set! *kernel-packages* (cons "mechp" *kernel-packages*)) + ) + (deftype mech (process-drawable) - ((root-override collide-shape-moving :offset 128 :score 1) - (extra-trans vector :inline :offset-assert 208) - (condition int32 :offset-assert 224) - (shadow-backup basic :offset-assert 228) - (rider uint64 :offset-assert 232) - (shield-value float :offset-assert 240) - (nav-sphere-handle uint64 :offset-assert 248) - (probe-time time-frame :offset-assert 256) + ((root-override collide-shape-moving :offset 128) + (extra-trans vector :inline :offset-assert 208) + (condition int32 :offset-assert 224) + (shadow-backup basic :offset-assert 228) + (rider uint64 :offset-assert 232) + (shield-value float :offset-assert 240) + (nav-sphere-handle uint64 :offset-assert 248) + (probe-time time-frame :offset-assert 256) ) + :heap-base #x90 :method-count-assert 25 :size-assert #x108 :flag-assert #x1900900108 (:methods (wait-for-start () _type_ :state 20) (idle () _type_ :state 21) - (pickup () _type_ :state 22) + (pickup ((state mech)) _type_ :state 22) (wait-for-return () _type_ :state 23) - (mech-method-24 () none 24) + (mech-method-24 (_type_) none 24) ) ) + + +(defmethod mech-method-24 mech ((obj mech)) + (if (nonzero? (-> obj part)) + (spawn (-> obj part) (-> obj root-override trans)) + ) + (update! (-> obj sound)) + 0 + (none) + ) + +(defstate wait-for-start (mech) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (the-as + object + (case event-type + (('attack 'bonk) + (send-event proc 'target-mech-get-off 90) + (let ((a1-3 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-3 from) (process->ppointer self)) + (set! (-> a1-3 num-params) 2) + (set! (-> a1-3 message) 'shove) + (set! (-> a1-3 param 0) (the-as uint #f)) + (let ((v1-9 (new 'static 'attack-info :mask (attack-info-mask shove-back shove-up id)))) + (let* ((a0-8 *game-info*) + (a2-2 (+ (-> a0-8 attack-id) 1)) + ) + (set! (-> a0-8 attack-id) a2-2) + (set! (-> v1-9 id) a2-2) + ) + (set! (-> v1-9 shove-back) 12288.0) + (set! (-> v1-9 shove-up) 4096.0) + (set! (-> a1-3 param 1) (the-as uint v1-9)) + ) + (send-event-function proc a1-3) + ) + (the-as structure #f) + ) + (('touch) + (send-event proc 'target-mech-get-off 90) + (send-shoves + (-> self root-override) + proc + (the-as touching-shapes-entry (-> event param 0)) + 0.7 + 6144.0 + 16384.0 + ) + (the-as structure #f) + ) + (('trans) + (vector+! (the-as vector (-> event param 0)) (-> self root-override trans) (-> self extra-trans)) + ) + (('shadow) + (cond + ((-> event param 0) + (let ((v0-2 (the-as structure (-> self shadow-backup)))) + (set! (-> self draw shadow) (the-as shadow-geo v0-2)) + v0-2 + ) + ) + (else + (set! (-> self draw shadow) #f) + (the-as structure #f) + ) + ) + ) + ) + ) + ) + :exit (behavior () + (set! (-> self root-override root-prim prim-core action) (collide-action)) + (set! (-> self root-override penetrated-by) (the-as penetrate -1)) + (none) + ) + :code (behavior () + (go-virtual idle) + (none) + ) + ) + +(defstate idle (mech) + :virtual #t + :event (-> (method-of-type mech wait-for-start) event) + :enter (behavior () + (set! (-> self nav-sphere-handle) (the-as uint #f)) + (let ((s5-0 (find-nearest-nav-mesh (-> self root-override trans) 8192.0))) + (when s5-0 + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-z-quaternion! gp-0 (-> self root-override quat)) + (vector-normalize! gp-0 5120.0) + (vector+! gp-0 gp-0 (-> self root-override trans)) + (set! (-> self nav-sphere-handle) + (the-as uint (ppointer->handle (process-spawn simple-nav-sphere #x46266666 gp-0 s5-0 -1 :to self))) + ) + ) + ) + ) + (none) + ) + :exit (behavior () + (send-event (handle->process (-> self nav-sphere-handle)) 'die-fast) + ((-> (method-of-type mech wait-for-start) exit)) + (none) + ) + :code (behavior () + (change-parent self *entity-pool*) + (ja-channel-set! 1) + (ja :group! mech-mech-idle-ja) + (set! (-> self root-override root-prim prim-core action) (collide-action solid can-ride no-standon)) + (set! (-> self root-override penetrated-by) (penetrate)) + 0.0 + (let ((f30-0 20480.0)) + (until #f + (when (and (logtest? (-> self draw status) (draw-control-status on-screen)) + (>= (- (-> self clock frame-counter) (-> self probe-time)) (seconds 1)) + ) + (move-to-ground + (-> self root-override) + 8192.0 + 40960.0 + #t + (collide-spec backgnd obstacle hit-by-player-list hit-by-others-list pusher) + ) + (set! (-> self probe-time) (-> self clock frame-counter)) + ) + (when (and (and *target* + (and (>= f30-0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))) + (zero? (logand (focus-status teleporting) (-> *target* focus-status))) + ) + ) + (not (logtest? (focus-status in-head pole board mech dark) (-> *target* focus-status))) + (can-display-query? self (the-as string #f) -99.0) + (-> *setting-control* user-current pilot) + ) + (let ((gp-0 (new + 'stack + 'font-context + *font-default-matrix* + 32 + 320 + 0.0 + (font-color default-#cddbcd) + (font-flags shadow kerning) + ) + ) + ) + (let ((v1-31 gp-0)) + (set! (-> v1-31 width) (the float 340)) + ) + (let ((v1-32 gp-0)) + (set! (-> v1-32 height) (the float 80)) + ) + (let ((v1-33 gp-0)) + (set! (-> v1-33 scale) 0.9) + ) + (set! (-> gp-0 flags) (font-flags shadow kerning large)) + (print-game-text (lookup-text! *common-text* (game-text-id text-x182) #f) gp-0 #f 44 (bucket-id progress)) + ) + (if (and (cpad-pressed? 0 triangle) (send-event *target* 'change-mode 'mech self (-> self shield-value))) + (go-virtual pickup (method-of-object self wait-for-return)) + ) + ) + (if *target* + (look-at! + (-> *target* neck) + (vector+! + (new 'stack-no-clear 'vector) + (the-as vector (-> self root-override root-prim prim-core)) + (new 'static 'vector :y 2048.0 :w 1.0) + ) + 'nothing-special + self + ) + ) + (mech-method-24 self) + (suspend) + ) + ) + #f + (none) + ) + :post (the-as (function none :behavior mech) ja-post) + ) + +(defstate pickup (mech) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('draw) + (ja-channel-set! 1) + (ja :group! mech-mech-idle-ja) + (set! (-> self root-override root-prim prim-core action) (collide-action solid can-ride no-standon)) + (set! (-> self root-override penetrated-by) (penetrate)) + (transform-post) + ) + (('trans) + (vector+! (the-as vector (-> event param 0)) (-> self root-override trans) (-> self extra-trans)) + ) + (('touch 'attack 'bonk) + #f + ) + (('shadow) + (cond + ((-> event param 0) + (let ((v0-1 (the-as object (-> self shadow-backup)))) + (set! (-> self draw shadow) (the-as shadow-geo v0-1)) + v0-1 + ) + ) + (else + (set! (-> self draw shadow) #f) + #f + ) + ) + ) + ) + ) + :enter (behavior ((arg0 (state mech))) + (let ((t9-0 (-> arg0 enter))) + (if t9-0 + (t9-0) + ) + ) + (none) + ) + :code (behavior ((arg0 (state mech))) + (ja-channel-set! 0) + (ja-post) + (while (zero? (ja-group-size)) + (if (or (not *target*) + (or (< 24576.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))) + (logtest? (focus-status teleporting) (-> *target* focus-status)) + ) + ) + (go arg0) + ) + (mech-method-24 self) + (suspend) + ) + (while (and *target* (logtest? (focus-status mech) (-> *target* focus-status))) + (mech-method-24 self) + (suspend) + ) + (let ((s5-0 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-0) (seconds 1)) + (mech-method-24 self) + (suspend) + ) + ) + (go arg0) + (none) + ) + ) + +(defstate wait-for-return (mech) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (the-as + object + (case event-type + (('trans) + (vector+! (the-as vector (-> event param 0)) (-> self root-override trans) (-> self extra-trans)) + ) + (('shadow) + (cond + ((-> event param 0) + (let ((v0-1 (the-as structure (-> self shadow-backup)))) + (set! (-> self draw shadow) (the-as shadow-geo v0-1)) + v0-1 + ) + ) + (else + (set! (-> self draw shadow) #f) + (the-as structure #f) + ) + ) + ) + ) + ) + ) + :code (behavior () + (ja-channel-set! 0) + (ja-post) + (cleanup-for-death self) + (none) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior mech-init mech ((arg0 entity-actor) (arg1 matrix3) (arg2 handle) (arg3 float)) + (let ((s2-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player)))) + (set! (-> s2-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s2-0 reaction) cshape-reaction-default) + (set! (-> s2-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (let ((v1-6 (new 'process 'collide-shape-prim-sphere s2-0 (the-as uint 0)))) + (set! (-> v1-6 prim-core collide-as) (collide-spec obstacle obstacle-for-jak)) + (set! (-> v1-6 prim-core collide-with) (collide-spec jak player-list)) + (set! (-> v1-6 prim-core action) (collide-action solid can-ride no-standon)) + (set! (-> v1-6 transform-index) 0) + (set-vector! (-> v1-6 local-sphere) 0.0 6553.6 5324.8 6553.6) + (set! (-> s2-0 total-prims) (the-as uint 1)) + (set! (-> s2-0 root-prim) v1-6) + ) + (set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w))) + (let ((v1-9 (-> s2-0 root-prim))) + (set! (-> s2-0 backup-collide-as) (-> v1-9 prim-core collide-as)) + (set! (-> s2-0 backup-collide-with) (-> v1-9 prim-core collide-with)) + ) + (set! (-> self root-override) s2-0) + ) + (set! (-> self rider) (the-as uint arg2)) + (when arg0 + (process-entity-set! self arg0) + (process-drawable-from-entity! self arg0) + (set-yaw-angle-clear-roll-pitch! (-> self root-override) (res-lump-float arg0 'rotoffset)) + ) + (when arg1 + (set! (-> self root-override trans quad) (-> arg1 vector 0 quad)) + (quaternion-copy! (-> self root-override quat) (the-as quaternion (-> arg1 vector 1))) + ) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-mech" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (set! (-> self shadow-backup) (-> self draw shadow)) + (set! (-> self draw shadow-ctrl) *mech-shadow-control*) + (let ((v1-27 (-> self node-list data))) + (set! (-> v1-27 0 param0) (the-as (function cspace matrix none) cspace<-transformq+trans!)) + (set! (-> v1-27 0 param1) (the-as basic (-> self root-override trans))) + (set! (-> v1-27 0 param2) (the-as basic (-> self extra-trans))) + ) + (set! (-> self condition) (res-lump-value arg0 'index int :time -1000000000.0)) + (set! (-> self fact) + (new 'process 'fact-info self (pickup-type eco-pill-random) (-> *FACT-bank* default-eco-pill-green-inc)) + ) + (set! (-> self shield-value) arg3) + (set! (-> self nav-sphere-handle) (the-as uint #f)) + (if (-> self entity) + (move-to-ground + (-> self root-override) + 8192.0 + 40960.0 + #t + (collide-spec backgnd obstacle hit-by-player-list hit-by-others-list pusher) + ) + ) + (set! (-> self sound) + (new 'process 'ambient-sound (static-sound-spec "zoom-teleport" :fo-max 30) (-> self root-override trans)) + ) + (set! (-> self draw light-index) (the-as uint 30)) + (if (handle->process arg2) + (go-virtual idle) + (go-virtual wait-for-start) + ) + (none) + ) + +(defmethod init-from-entity! mech ((obj mech) (arg0 entity-actor)) + (mech-init arg0 (the-as matrix3 #f) (the-as handle #f) 100.0) + (none) + ) + +(deftype mech-target (process-drawable) + () + :heap-base #x50 + :method-count-assert 22 + :size-assert #xc8 + :flag-assert #x16005000c8 + (:methods + (idle () _type_ :state 20) + (active () _type_ :state 21) + ) + ) + + +(defskelgroup skel-mech-target mech mech-target-lod0-jg mech-target-idle-ja + ((mech-target-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 4) + ) + +(defstate idle (mech-target) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('look-at-point) + (set! (-> self state-time) (-> self clock frame-counter)) + (go-virtual active) + ) + ) + ) + :trans (behavior () + (if (and (and *target* (and (>= 98304.0 (vector-vector-distance (-> self root trans) (-> *target* control trans))) + (zero? (logand (focus-status teleporting) (-> *target* focus-status))) + ) + ) + (logtest? (focus-status mech) (-> *target* focus-status)) + ) + (go-virtual active) + ) + (none) + ) + :code (behavior () + (while (< 0.0 (-> self root scale x)) + (seek! (-> self root scale x) 0.0 (* 8.0 (-> self clock seconds-per-frame))) + (set! (-> self root scale y) (-> self root scale x)) + (ja-post) + (suspend) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (ja-post) + (sleep-code) + (none) + ) + ) + +(defstate active (mech-target) + :virtual #t + :event (-> (method-of-type mech-target idle) event) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :trans (behavior () + (if (and (or (or (not *target*) (or (< 106496.0 (vector-vector-distance (-> self root trans) (-> *target* control trans))) + (logtest? (focus-status teleporting) (-> *target* focus-status)) + ) + ) + (zero? (logand (focus-status mech) (-> *target* focus-status))) + ) + (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 10)) + ) + (go-virtual idle) + ) + (none) + ) + :code (behavior () + (sound-play "mech-target") + (let ((f30-0 0.0)) + (logclear! (-> self draw status) (draw-control-status no-draw)) + (while (< (-> self root scale x) 1.0) + (seek! (-> self root scale x) 1.0 (* 8.0 (-> self clock seconds-per-frame))) + (set! (-> self root scale y) (-> self root scale x)) + (set! f30-0 (seek f30-0 1.0 (* 2.0 (-> self clock seconds-per-frame)))) + (ja :num! (loop! f30-0)) + (ja-post) + (suspend) + ) + (until #f + (set! f30-0 (seek f30-0 1.0 (* 0.25 (-> self clock seconds-per-frame)))) + (ja :num! (loop! f30-0)) + (ja-post) + (suspend) + ) + ) + #f + (none) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior mech-target-init mech ((arg0 vector) (arg1 quaternion) (arg2 entity-actor)) + (process-entity-set! self arg2) + (set! (-> self root-override) (the-as collide-shape-moving (new 'process 'trsqv))) + (set! (-> self root-override trans quad) (-> arg0 quad)) + (quaternion-copy! (-> self root-override quat) arg1) + (set! (-> self root-override scale x) 0.0) + (set! (-> self root-override scale y) 0.0) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-mech-target" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (go-virtual wait-for-start) + (none) + ) + +(defun mech-target-spawn ((arg0 vector) (arg1 target) (arg2 quaternion) (arg3 entity-actor)) + (process-spawn mech-target :init mech-target-init arg0 arg2 arg3 :to arg1) + ) diff --git a/goal_src/jak2/engine/target/mech_suit/target-mech.gc b/goal_src/jak2/engine/target/mech_suit/target-mech.gc index da3e41d0d..400846f5d 100644 --- a/goal_src/jak2/engine/target/mech_suit/target-mech.gc +++ b/goal_src/jak2/engine/target/mech_suit/target-mech.gc @@ -5,5 +5,1776 @@ ;; name in dgo: target-mech ;; dgos: DRILLMTN, UNB, RUI +(define-extern target-mech-start (state handle target)) +(define-extern target-mech-stance (state target)) +(define-extern target-mech-walk (state target)) +(define-extern target-mech-punch-pick (function symbol int :behavior target)) +(define-extern target-mech-punch (state target)) +(define-extern target-mech-falling (state symbol target)) +(define-extern target-mech-jump (state float float surface target)) +(define-extern target-mech-hit-ground (state symbol target)) +(define-extern target-mech-hit (state symbol attack-info target)) +(define-extern target-mech-death (state symbol target)) +(define-extern target-mech-carry-update (function none :behavior target)) +(define-extern target-mech-carry-post (function none :behavior target)) +(define-extern target-mech-carry-pickup (state target)) +(define-extern target-mech-carry-drop (state target)) +(define-extern target-mech-carry-stance (state target)) +(define-extern target-mech-carry-walk (state target)) +(define-extern target-mech-carry-drag (state target)) +(define-extern target-mech-carry-falling (state target)) +(define-extern target-mech-carry-hit-ground (state symbol target)) +(define-extern target-mech-carry-jump (state float float target)) +(define-extern target-mech-carry-throw (state target)) +(define-extern target-mech-get-on (state handle target)) +(define-extern target-mech-get-off (state target)) +(define-extern target-mech-grab (state target)) +(define-extern target-mech-clone-anim (state handle target)) + ;; DECOMP BEGINS +(format 0 "SKIP: mech-update-ik in target-mech") + +(defmethod draw hud-heatmeter ((obj hud-heatmeter)) + (set-hud-piece-position! + (the-as hud-sprite (-> obj sprites)) + 256 + (the int (+ 25.0 (* -100.0 (-> obj offset)))) + ) + (set! (-> obj sprites 0 pos z) #xfffff0) + (set-as-offset-from! + (-> obj sprites 1) + (the-as vector4w (-> obj sprites)) + (+ (the int (* 0.128 (the float (-> obj values 0 current)))) -63) + 1 + ) + (set! (-> obj sprites 1 pos z) #xfffff0) + ((method-of-type hud draw) obj) + 0 + (none) + ) + +(defmethod update-values hud-heatmeter ((obj hud-heatmeter)) + (set! (-> obj values 0 target) (the int (* 1000.0 (-> *game-info* distance)))) + (logclear! (-> obj flags) (hud-flags disable)) + ((method-of-type hud update-values) obj) + 0 + (none) + ) + +(defmethod init-callback hud-heatmeter ((obj hud-heatmeter)) + (set! (-> obj gui-id) + (add-process *gui-control* obj (gui-channel hud-upper-center-2) (gui-action hidden) (-> obj name) 81920.0 0) + ) + (logior! (-> obj flags) (hud-flags show)) + (set! (-> obj sprites 0 tex) (lookup-texture-by-id (new 'static 'texture-id :index #x43 :page #x67a))) + (set! (-> obj sprites 0 flags) (the-as uint 8)) + (set! (-> obj sprites 0 scale-x) 1.2) + (set! (-> obj sprites 0 scale-y) 1.2) + (set! (-> obj sprites 1 tex) (lookup-texture-by-id (new 'static 'texture-id :index #x34 :page #x67a))) + (set! (-> obj sprites 1 flags) (the-as uint 8)) + (set! (-> obj sprites 1 scale-x) 1.8) + (set! (-> obj sprites 1 scale-y) 1.8) + 0 + (none) + ) + +(define *mech-stance-mods* + (new 'static 'surface + :name 'run + :turnv 18204262.0 + :turnvv 40049.777 + :tiltv 65536.0 + :tiltvv 262144.0 + :fric 0.3 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 4.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :slope-up-traction 1.0 + :turnvf 0.03 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :mult-hook (lambda :behavior target + ((arg0 surface) (arg1 object) (arg2 surface) (arg3 int)) + (case arg3 + ((1) + (if (= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + (seek! + (-> self control did-move-to-pole-or-max-jump-height) + 0.0 + (* 127431.11 (-> self clock seconds-per-frame)) + ) + (seek! + (-> self control did-move-to-pole-or-max-jump-height) + (* (-> self control turn-to-magnitude) (-> arg0 turnvv)) + (* 127431.11 (-> self clock seconds-per-frame)) + ) + ) + (set! (-> arg0 turnvv) (-> self control did-move-to-pole-or-max-jump-height)) + (when (= (-> arg2 name) '*edge-surface*) + (set! (-> arg0 target-speed) 32768.0) + (set! (-> arg0 transv-max) 32768.0) + (set! (-> arg0 seek0) (* 1.6666 (-> arg2 seek0))) + (set! (-> arg0 seek90) (* 1.6666 (-> arg2 seek90))) + (set! (-> arg0 seek180) (* 1.6666 (-> arg2 seek180))) + ) + ) + ) + (none) + ) + :flags (surface-flag look-around no-turn-around) + ) + ) + +(define *mech-walk-mods* + (new 'static 'surface + :name 'run + :turnv 32768.0 + :turnvv 524288.0 + :tiltv 65536.0 + :tiltvv 262144.0 + :transv-max 32768.0 + :target-speed 32768.0 + :seek0 1.6666 + :seek90 1.6666 + :seek180 1.0 + :fric 0.1 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :turnvf 120.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :vel-turn -1.0 + :mult-hook (lambda :behavior target + ((arg0 surface) (arg1 object) (arg2 surface) (arg3 int)) + (case arg3 + ((1) + (when (= (-> arg2 name) '*edge-surface*) + (let ((v1-5 + (vector-flatten! + (new 'stack-no-clear 'vector) + (vector-negate! (new-stack-vector0) (-> self control dynam gravity-normal)) + (-> self control local-normal) + ) + ) + ) + (set! (-> arg0 vel-turn) 0.0) + (vector+float*! + (-> self control transv) + (-> self control transv) + v1-5 + (* 409600.0 (-> self clock seconds-per-frame)) + ) + ) + ) + ) + ) + (none) + ) + :flags (surface-flag look-around no-turn-around) + ) + ) + +(define *mech-jump-mods* (new 'static 'surface + :name 'jump + :turnv 131072.0 + :turnvv 18204.445 + :tiltv 32768.0 + :tiltvv 262144.0 + :transv-max 32768.0 + :target-speed 32768.0 + :seek0 0.3 + :seek90 0.3 + :seek180 0.3 + :fric 0.2 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :turnvf 90.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :mode 'air + :flags (surface-flag no-turn-around air) + ) + ) + +(define *mech-punch-mods* (new 'static 'surface + :name 'punch + :turnv 131072.0 + :tiltv 32768.0 + :tiltvv 262144.0 + :transv-max 91750.4 + :target-speed 122880.0 + :seek90 0.5 + :seek180 0.15 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 0.25 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :mode 'attack + :flags (surface-flag no-turn-around turn-to-pad attack) + ) + ) + +(define *mech-pickup-mods* (new 'static 'surface + :name 'run + :turnv 16384.0 + :tiltv 65536.0 + :tiltvv 262144.0 + :transv-max 12288.0 + :target-speed 12288.0 + :seek0 1.0 + :seek90 1.0 + :seek180 1.0 + :fric 0.5 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :turnvf 240.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :vel-turn -1.0 + :flags (surface-flag look-around no-turn-around) + ) + ) + +(define *mech-carry-walk-mods* (new 'static 'surface + :name 'run + :turnv 16384.0 + :turnvv 524288.0 + :tiltv 65536.0 + :tiltvv 262144.0 + :transv-max 12288.0 + :target-speed 12288.0 + :seek0 1.0 + :seek90 1.0 + :seek180 1.0 + :fric 0.5 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :turnvf 240.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :vel-turn -1.0 + :flags (surface-flag look-around no-turn-around) + ) + ) + +(set! (-> *mech-carry-walk-mods* mult-hook) (-> *mech-walk-mods* mult-hook)) + +(define *mech-carry-drag-mods* (new 'static 'surface + :name 'run + :tiltv 65536.0 + :tiltvv 262144.0 + :transv-max 12288.0 + :fric 1.0 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :flags (surface-flag look-around no-turn-around) + ) + ) + +(define *mech-carry-jump-mods* (new 'static 'surface + :name 'jump + :turnv 131072.0 + :turnvv 18204.445 + :tiltv 32768.0 + :tiltvv 262144.0 + :transv-max 24576.0 + :target-speed 24576.0 + :seek0 0.3 + :seek90 0.3 + :seek180 0.3 + :fric 0.2 + :nonlin-fric-dist 1.0 + :slip-factor 1.0 + :slide-factor 1.0 + :slope-up-factor 1.0 + :slope-down-factor 1.0 + :slope-slip-angle 1.0 + :impact-fric 1.0 + :bend-factor 1.0 + :bend-speed 1.0 + :alignv 1.0 + :slope-up-traction 1.0 + :align-speed 1.0 + :turnvf 90.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :mode 'air + :flags (surface-flag air) + ) + ) + +(defbehavior target-mech-falling-anim-trans target () + 0 + (none) + ) + +(defbehavior target-mech-mech-effect mech ((arg0 target)) + (when (!= (-> arg0 mech thruster-flame-length) 0.0) + (let ((f30-0 0.0)) + (if (!= (-> *setting-control* user-current under-water-pitch-mod) 0.0) + (set! f30-0 -2.0) + ) + (sound-play-by-name + (static-sound-name "mech-thrust") + (the-as sound-id (-> arg0 mech thrust-sound-id)) + (the int (* 1024.0 (lerp-scale 0.3 1.0 (-> arg0 mech thruster-flame-length) 0.0 4096.0))) + (the int (* 1524.0 f30-0)) + 0 + (sound-group sfx) + #t + ) + ) + (dotimes (s5-1 2) + (let* ((s3-1 (-> self node-list data (if (zero? s5-1) + 37 + 38 + ) + ) + ) + (s4-1 (vector<-cspace! (new 'stack-no-clear 'vector) s3-1)) + (a2-2 (vector-negate! (new 'stack-no-clear 'vector) (-> s3-1 bone transform vector 1))) + ) + (mech-spawn-thruster + (-> arg0 mech) + s4-1 + a2-2 + (-> arg0 mech thruster-flame-width) + (-> arg0 mech thruster-flame-length) + ) + ) + ) + ) + (when (logtest? (water-flags touch-water) (-> arg0 water flags)) + (let ((f30-1 (-> arg0 water height))) + (let ((s5-2 (-> *part-id-table* 947))) + (let ((v1-28 (get-field-spec-by-id s5-2 (sp-field-id spt-userdata)))) + (if v1-28 + (set! (-> v1-28 initial-valuef) f30-1) + ) + ) + (let ((t9-6 sp-launch-particles-var) + (a0-12 *sp-particle-system-2d*) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> self root-override trans quad)) + (t9-6 a0-12 s5-2 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (let ((s5-3 (-> *part-id-table* 950))) + (let ((v1-34 (get-field-spec-by-id s5-3 (sp-field-id spt-userdata)))) + (if v1-34 + (set! (-> v1-34 initial-valuef) f30-1) + ) + ) + (let ((t9-8 sp-launch-particles-var) + (a0-15 *sp-particle-system-2d*) + (a2-4 *launch-matrix*) + ) + (set! (-> a2-4 trans quad) (-> self root-override trans quad)) + (t9-8 a0-15 s5-3 a2-4 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (let* ((s5-4 (-> *part-id-table* 953)) + (v1-40 (get-field-spec-by-id s5-4 (sp-field-id spt-userdata))) + (s4-2 (new 'stack-no-clear 'vector)) + ) + (if v1-40 + (set! (-> v1-40 initial-valuef) f30-1) + ) + (let ((s3-2 (get-field-spec-by-id s5-4 (sp-field-id spt-num)))) + (if s3-2 + (set! (-> s3-2 initial-valuef) (lerp-scale 0.1 2.0 (-> arg0 control ctrl-xz-vel) 0.0 40960.0)) + ) + ) + (process-drawable-random-point! self s4-2) + (let ((t9-13 sp-launch-particles-var) + (a0-21 *sp-particle-system-2d*) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> s4-2 quad)) + (t9-13 a0-21 s5-4 a2-6 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + 0 + (none) + ) + +(defbehavior mech-on-ground? target () + (logtest? (-> self control status) (collide-status on-surface)) + ) + +(defbehavior target-mech-get-off? target () + (when (and (mech-on-ground?) + (< (-> self mech no-get-off-time) (-> self clock frame-counter)) + (-> *setting-control* user-current pilot-exit) + ) + (let ((gp-0 (new 'stack-no-clear 'collide-query)) + (s4-0 (new 'stack-no-clear 'sphere)) + ) + (dotimes (s5-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s4-0) (* s5-0 16))) sphere) + ) + (let ((s5-1 (-> self node-list data 0 bone transform))) + (vector-matrix*! (the-as vector (&-> s4-0 x)) (new 'static 'vector :y 14336.0 :z 12288.0 :w 1.0) s5-1) + (set! (-> s4-0 r) 10240.0) + (let ((v1-11 gp-0)) + (set! (-> v1-11 best-dist) (the-as float s4-0)) + (set! (-> v1-11 num-spheres) (the-as uint 1)) + (set! (-> v1-11 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-11 ignore-process0) #f) + (set! (-> v1-11 ignore-process1) #f) + (set! (-> v1-11 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-11 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-11 action-mask) (collide-action solid)) + ) + (let ((s4-1 (fill-and-probe-using-spheres *collide-cache* gp-0))) + (when (not s4-1) + (vector-matrix*! (-> gp-0 start-pos) (new 'static 'vector :y 8192.0 :z 4096.0 :w 1.0) s5-1) + (set-vector! (-> gp-0 move-dist) 0.0 -40960.0 0.0 0.0) + (let ((v1-15 gp-0)) + (set! (-> v1-15 radius) 409.6) + (set! (-> v1-15 collide-with) (collide-spec backgnd obstacle hit-by-others-list pusher)) + (set! (-> v1-15 ignore-process0) self) + (set! (-> v1-15 ignore-process1) #f) + (set! (-> v1-15 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-15 action-mask) (collide-action solid)) + ) + (set! s4-1 (< (fill-and-probe-using-line-sphere *collide-cache* gp-0) 0.0)) + ) + (if (and s4-1 (-> *setting-control* user-current pilot)) + (talker-spawn-func (-> *talker-speech* 460) *entity-pool* (target-pos 0) (the-as region #f)) + ) + (not s4-1) + ) + ) + ) + ) + ) + +(defbehavior target-mech-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (local-vars (v0-0 object) (a0-18 symbol) (sv-96 target) (sv-112 process)) + (cond + ((and (= arg2 'query) (= (-> arg3 param 0) 'mode)) + 'mech + ) + (else + (case arg2 + (('end-mode) + enter-state + (process->handle arg0) + (go target-mech-get-off) + ) + (('change-mode) + (let ((v1-7 (-> arg3 param 0))) + (cond + ((= v1-7 'grab) + (when (not (logtest? (-> self focus-status) (focus-status dead))) + (if (not (-> arg3 param 1)) + #t + (go target-mech-grab) + ) + ) + ) + ((= v1-7 'normal) + enter-state + (process->handle arg0) + (go target-mech-get-off) + ) + ((begin (set! a0-18 'falling) (= v1-7 a0-18)) + (go target-mech-falling a0-18) + ) + ) + ) + ) + (('swim 'slide 'edge-grab) + #f + ) + (('clone-anim) + (go target-mech-clone-anim (process->handle (the-as process (-> arg3 param 0)))) + ) + (('touched) + (cond + ((logtest? (process-mask crate) (-> arg0 mask)) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) (process->ppointer self)) + (set! (-> a1-1 num-params) 2) + (set! (-> a1-1 message) 'attack) + (set! (-> a1-1 param 0) (-> arg3 param 0)) + (let ((v1-25 (new 'static 'attack-info :mask (attack-info-mask mode id penetrate-using)))) + (set! (-> v1-25 id) (-> self mech attack-id)) + (set! (-> v1-25 mode) 'mech) + (set! (-> v1-25 penetrate-using) (-> self control penetrate-using)) + (set! (-> a1-1 param 1) (the-as uint v1-25)) + ) + (set! v0-0 (send-event-function arg0 a1-1)) + ) + (when v0-0 + (let* ((v1-27 (-> self game)) + (a0-39 (+ (-> v1-27 attack-id) 1)) + ) + (set! (-> v1-27 attack-id) a0-39) + (set! (-> self mech attack-id) a0-39) + ) + ) + v0-0 + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + (('attack 'attack-or-shove 'attack-invinc) + (let ((s3-0 (the-as + attack-info + (mem-copy! (the-as pointer (-> self attack-info-rec)) (the-as pointer (-> arg3 param 1)) 160) + ) + ) + ) + (let ((s2-0 s3-0) + (s1-0 (method-of-type attack-info compute-intersect-info)) + (s0-0 (-> arg3 param 1)) + ) + (set! sv-96 self) + (set! sv-112 arg0) + (let ((a3-2 (if (type? sv-112 process-drawable) + sv-112 + ) + ) + (t0-0 (-> arg3 param 0)) + ) + (s1-0 s2-0 s0-0 sv-96 a3-2 (the-as touching-shapes-entry t0-0)) + ) + ) + (let* ((v1-30 (-> s3-0 mode)) + (f30-0 + (cond + ((= v1-30 'tar) + (set! (-> s3-0 id) (the-as uint 2)) + (* 100.0 (-> self clock seconds-per-frame)) + ) + ((= v1-30 'melt) + (set! (-> s3-0 id) (the-as uint 2)) + (let ((s2-1 (if (logtest? (-> s3-0 mask) (attack-info-mask intersection)) + (-> s3-0 intersection) + (-> self control trans) + ) + ) + ) + (let ((t9-10 sp-launch-particles-var) + (a0-50 *sp-particle-system-2d*) + (a1-5 (-> *part-id-table* 955)) + (a2-8 *launch-matrix*) + ) + (set! (-> a2-8 trans quad) (-> s2-1 quad)) + (t9-10 a0-50 a1-5 a2-8 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-11 sp-launch-particles-var) + (a0-51 *sp-particle-system-2d*) + (a1-6 (-> *part-id-table* 957)) + (a2-9 *launch-matrix*) + ) + (set! (-> a2-9 trans quad) (-> s2-1 quad)) + (t9-11 a0-51 a1-6 a2-9 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (* 100.0 (-> self clock seconds-per-frame)) + ) + ((or (= v1-30 'burn) (= v1-30 'burnup)) + (set! (-> s3-0 id) (the-as uint 2)) + (if (logtest? (-> s3-0 mask) (attack-info-mask intersection)) + (-> s3-0 intersection) + (-> self control trans) + ) + (let ((t9-12 sp-launch-particles-var) + (a0-55 *sp-particle-system-2d*) + (a1-8 (-> *part-id-table* 955)) + (a2-10 *launch-matrix*) + ) + (set! (-> a2-10 trans quad) (-> self control trans quad)) + (t9-12 a0-55 a1-8 a2-10 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-13 sp-launch-particles-var) + (a0-56 *sp-particle-system-2d*) + (a1-9 (-> *part-id-table* 957)) + (a2-11 *launch-matrix*) + ) + (set! (-> a2-11 trans quad) (-> self control trans quad)) + (t9-13 a0-56 a1-9 a2-11 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (* 20.0 (-> self clock seconds-per-frame)) + ) + ((= v1-30 'shock) + (let ((s2-2 (if (logtest? (-> s3-0 mask) (attack-info-mask intersection)) + (-> s3-0 intersection) + (-> self control trans) + ) + ) + ) + (let ((t9-14 sp-launch-particles-var) + (a0-58 *sp-particle-system-2d*) + (a1-10 (-> *part-id-table* 959)) + (a2-12 *launch-matrix*) + ) + (set! (-> a2-12 trans quad) (-> s2-2 quad)) + (t9-14 a0-58 a1-10 a2-12 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-15 sp-launch-particles-var) + (a0-59 *sp-particle-system-2d*) + (a1-11 (-> *part-id-table* 960)) + (a2-13 *launch-matrix*) + ) + (set! (-> a2-13 trans quad) (-> s2-2 quad)) + (t9-15 a0-59 a1-11 a2-13 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (set! (-> s3-0 id) (the-as uint 2)) + (* 20.0 (-> self clock seconds-per-frame)) + ) + ((= v1-30 'explode) + 20.0 + ) + ((= v1-30 'grunt) + 1.0 + ) + ((= v1-30 'air) + 100.0 + ) + ((or (= v1-30 'endlessfall) (= v1-30 'crush) (= v1-30 'instant-death)) + 100.0 + ) + (else + 3.0 + ) + ) + ) + ) + (when (target-log-attack s3-0 'background) + (case arg2 + (('attack 'attack-or-shove 'attack-invinc) + (if (not (or (logtest? (-> self state-flags) (state-flags sf2)) + (logtest? (-> self game secrets) (game-secrets invulnerable)) + ) + ) + (seek! (-> self mech shield-value) 0.0 f30-0) + ) + ) + ) + (if (and (= arg2 'attack-or-shove) (< 0.0 (-> self mech shield-value))) + (set! arg2 'shove) + ) + (if (= arg2 'attack-invinc) + (set! (-> self mech shield-value) 0.0) + ) + (if (or (= (-> self mech shield-value) 0.0) (= arg2 'shove)) + (target-attacked arg2 s3-0 arg0 (the-as touching-shapes-entry (-> arg3 param 0)) target-mech-hit) + 'block + ) + ) + ) + ) + ) + (('shove) + (when (not (logtest? (-> self focus-status) (focus-status dead hit))) + (mem-copy! (the-as pointer (-> self attack-info-rec)) (the-as pointer (-> arg3 param 1)) 160) + (when (not (logtest? (-> self attack-info-rec mask) (attack-info-mask attacker))) + (set! (-> self attack-info-rec attacker) (process->handle arg0)) + (logior! (-> self attack-info-rec mask) (attack-info-mask attacker)) + ) + (go target-mech-hit 'shove (-> self attack-info-rec)) + ) + ) + (('effect-control) + (case (-> arg3 param 0) + (('target-mech-walk) + (sound-play-by-name + (static-sound-name "mech-walk") + (new-sound-id) + 1024 + (the int (* 1524.0 (lerp-scale -0.2 0.0 (-> self control ctrl-xz-vel) 12288.0 32768.0))) + 0 + (sound-group sfx) + #t + ) + ) + ) + ) + (('target-mech-get-off) + (set! v0-0 (+ (-> self clock frame-counter) (the-as time-frame (-> arg3 param 0)))) + (set! (-> self mech no-get-off-time) (the-as time-frame v0-0)) + v0-0 + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch symbol vs object. +(defbehavior target-mech-bonk-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (the-as + object + (when (and (= arg2 'touched) + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> arg3 param 0)) + (-> self control) + (the-as uint 6) + ) + (>= 409.6 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (begin + (vector-normalize! + (vector-! + s4-0 + (the-as vector (-> self control collision-spheres 0 prim-core)) + (-> self control actor-contact-pt) + ) + 1.0 + ) + (< 0.01 (-> s4-0 y)) + ) + ) + (if (< 0.75 (-> s4-0 y)) + (send-event + arg0 + 'bonk + (-> arg3 param 0) + (fmax + (-> self control ground-impact-vel) + (- (vector-dot (-> self control transv) (-> self control dynam gravity-normal))) + ) + ) + ) + (when (and (= (target-send-attack + arg0 + 'bonk + (the-as touching-shapes-entry (-> arg3 param 0)) + (the-as int (-> self control target-attack-id)) + (the-as int (-> self control attack-count)) + (penetrate touch bonk mech-bonk) + ) + 'bounce + ) + (zero? (logand (-> self focus-status) (focus-status dead hit))) + ) + (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)) + (target-timed-invulnerable (seconds 0.1) self 1) + (cond + ((logtest? (focus-status carry) (-> self focus-status)) + enter-state + (let ((a0-19 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-8 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-19 a1-8) + ) + ) + (else + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + ) + ) + #f + ) + ) + ) + ) + +;; WARN: Return type mismatch none vs object. +(defbehavior mech-leg-ik-callback target ((arg0 joint-mod-ik) (arg1 matrix) (arg2 matrix) (arg3 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> arg3 quad)) + (let ((f0-1 (- (-> arg3 y) (-> (target-pos 0) y)))) + (if (< 6144.0 f0-1) + (set! f0-1 6144.0) + ) + (if (< f0-1 -6144.0) + (set! f0-1 -6144.0) + ) + (+! (-> arg0 user-position y) f0-1) + ) + (let ((f0-4 (- (-> arg3 y) (-> arg0 user-position y)))) + (seek! (-> arg0 user-float) f0-4 (* 40960.0 (-> self clock seconds-per-frame))) + ) + (let* ((f28-0 (-> arg0 user-float)) + (f30-1 (lerp-scale 1.0 0.0 f28-0 0.0 12288.0)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((v1-12 s5-0)) + (let ((a0-4 *up-vector*)) + (let ((a1-4 8192.0)) + (.mov vf7 a1-4) + ) + (.lvf vf5 (&-> a0-4 quad)) + ) + (.lvf vf4 (&-> v1-12 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> s3-0 quad) vf6) + (vector-float*! (new 'stack-no-clear 'vector) *up-vector* -16384.0) + (let ((s2-0 (new 'stack-no-clear 'vector))) + 0.0 + (let ((f0-11 (intersect-ray-plane s3-0 *up-vector* (-> arg0 user-position) *up-vector*)) + (a0-7 s2-0) + ) + (let ((v1-15 *up-vector*)) + (let ((a1-7 f0-11)) + (.mov vf7 a1-7) + ) + (.lvf vf5 (&-> v1-15 quad)) + ) + (.lvf vf4 (&-> s3-0 quad)) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a0-7 quad) vf6) + ) + (let ((a0-8 s2-0)) + (let ((v1-16 *up-vector*)) + (let ((a1-8 (- f28-0))) + (.mov vf7 a1-8) + ) + (.lvf vf5 (&-> v1-16 quad)) + ) + (.lvf vf4 (&-> arg3 quad)) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a0-8 quad) vf6) + ) + (let ((a1-9 s5-0)) + (let ((v1-17 s5-0)) + (let ((a0-10 (vector-! (new 'stack-no-clear 'vector) s2-0 s5-0))) + (let ((a2-6 (fmin 1.0 (* (-> arg0 user-blend) f30-1)))) + (.mov vf7 a2-6) + ) + (.lvf vf5 (&-> a0-10 quad)) + ) + (.lvf vf4 (&-> v1-17 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-9 quad) vf6) + ) + ) + ) + (the-as object (handle-copy! arg0 s5-0)) + ) + ) + ) + +(defbehavior mech-update-ik target () + (local-vars (sv-720 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'collide-query)) + (s5-0 (-> (the-as process-drawable (-> self parent 0)) root)) + ) + (let ((a1-0 (-> gp-0 bbox)) + (v1-2 (-> s5-0 trans)) + (a0-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> a0-0 x) 10240.0) + (set! (-> a0-0 y) 10240.0) + (set! (-> a0-0 z) 10240.0) + (set! (-> a0-0 w) 1.0) + (vector-! (the-as vector a1-0) v1-2 a0-0) + ) + (let ((a1-2 (-> gp-0 bbox max)) + (v1-3 (-> s5-0 trans)) + (a0-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a0-1 x) 10240.0) + (set! (-> a0-1 y) 10240.0) + (set! (-> a0-1 z) 10240.0) + (set! (-> a0-1 w) 1.0) + (vector+! a1-2 v1-3 a0-1) + ) + (set! (-> gp-0 collide-with) (-> (the-as collide-shape-moving s5-0) root-prim prim-core collide-with)) + (set! (-> gp-0 ignore-process0) #f) + (set! (-> gp-0 ignore-process1) #f) + (set! (-> gp-0 ignore-pat) (-> (the-as collide-shape-moving s5-0) pat-ignore-mask)) + (fill-using-bounding-box *collide-cache* gp-0) + (dotimes (s4-0 2) + (let ((s3-0 (-> (the-as (array joint-mod-ik) (+ (* s4-0 4) (the-as int self))) 64))) + #t + (set! (-> s3-0 callback) mech-leg-ik-callback) + (-> s3-0 shoulder-matrix-no-ik) + (let ((v1-13 (-> s3-0 elbow-matrix-no-ik)) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-720 (new 'stack-no-clear 'vector)) + (let ((a0-5 (-> *y-vector* quad))) + (set! (-> sv-720 quad) a0-5) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (new 'stack-no-clear 'vector) + (new 'stack-no-clear 'vector) + (let ((s1-0 (new 'stack-no-clear 'vector))) + (let ((a1-6 s0-0)) + (let ((a0-8 (-> v1-13 trans))) + (let ((v1-14 (-> v1-13 vector 1))) + (let ((a2-8 (-> s3-0 hand-dist))) + (.mov vf7 a2-8) + ) + (.lvf vf5 (&-> v1-14 quad)) + ) + (.lvf vf4 (&-> a0-8 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-6 quad) vf6) + ) + (let ((f0-11 + (lerp-scale 1.0 0.0 (- (-> s0-0 y) (-> (the-as collide-shape-moving s5-0) gspot-pos y)) 2048.0 12288.0) + ) + ) + (seek! (-> s3-0 user-blend) f0-11 (* 4.0 (-> self clock seconds-per-frame))) + ) + (let ((a1-9 (-> gp-0 start-pos))) + (let ((v1-18 s0-0)) + (let ((a0-11 sv-720)) + (let ((a2-12 6144.0)) + (.mov vf7 a2-12) + ) + (.lvf vf5 (&-> a0-11 quad)) + ) + (.lvf vf4 (&-> v1-18 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-9 quad) vf6) + ) + (let ((v1-19 (-> gp-0 move-dist)) + (f0-16 -20480.0) + ) + (vector-float*! v1-19 sv-720 f0-16) + ) + (let ((v1-21 gp-0)) + (set! (-> v1-21 radius) 4.096) + (set! (-> v1-21 collide-with) (-> gp-0 collide-with)) + (set! (-> v1-21 ignore-process0) #f) + (set! (-> v1-21 ignore-process1) #f) + (set! (-> v1-21 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-21 action-mask) (collide-action solid)) + ) + (let ((f30-0 (probe-using-line-sphere *collide-cache* gp-0))) + (cond + ((>= f30-0 0.0) + (set! (-> s1-0 quad) (-> gp-0 best-other-tri normal quad)) + (when (< 8192.0 (vector-vector-angle-safe *y-vector* s1-0)) + (let* ((a1-14 (vector-normalize! (vector-cross! (new 'stack-no-clear 'vector) *y-vector* s1-0) 1.0)) + (a2-14 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) a1-14 8192.0)) + ) + (vector-orient-by-quat! s1-0 *y-vector* a2-14) + ) + ) + (let ((a1-16 s2-0)) + (let ((v1-28 (-> gp-0 start-pos))) + (let ((a0-26 (-> gp-0 move-dist))) + (let ((a2-15 f30-0)) + (.mov vf7 a2-15) + ) + (.lvf vf5 (&-> a0-26 quad)) + ) + (.lvf vf4 (&-> v1-28 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-16 quad) vf6) + ) + (set! (-> s3-0 user-position quad) (-> s2-0 quad)) + (set! (-> s3-0 user-normal quad) (-> s1-0 quad)) + ) + (else + (set! (-> s0-0 y) (-> (target-pos 0) y)) + (set! (-> s3-0 user-position quad) (-> s0-0 quad)) + (set! (-> s3-0 user-normal quad) (-> *y-vector* quad)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior target-mech-init target ((arg0 handle) (arg1 float) (arg2 symbol)) + (local-vars + (sv-96 (function vector entity-actor skeleton-group vector object none :behavior manipy)) + (sv-112 vector) + (sv-128 entity-actor) + ) + (target-gun-end-mode #f) + (target-exit) + (when (zero? (-> self mech)) + (set! (-> self mech) (new 'process 'mech-info)) + (set! (-> self mech hud 0) (the-as uint #f)) + (set! (-> self mech engine-sound-id) (the-as uint (new-sound-id))) + (set! (-> self mech thrust-sound-id) (the-as uint (new-sound-id))) + (set! (-> self mech drag-sound-id) (the-as uint (new-sound-id))) + (set! (-> self mech whine-sound-id) (the-as uint (new-sound-id))) + ) + (set! (-> self board latch?) #f) + (set! (-> self mech stick-lock) #f) + (set! (-> self mech stick-off) #f) + (set! (-> self mech unstuck-time) (-> self clock frame-counter)) + (set! (-> self mech stuck-count) 0) + (set! (-> self mech mech-start-time) (-> self clock frame-counter)) + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (set! (-> self mech state-impact? 0) #f) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + self + -1 + 0.0 + (collide-spec) + ) + (set! (-> self mech shield-max) 100.0) + (set! (-> self mech shield-value) arg1) + (set! (-> self mech entity) #f) + (let ((v1-27 (handle->process arg0))) + (if v1-27 + (set! (-> self mech entity) (-> v1-27 entity)) + ) + ) + (let ((v1-30 (-> self mech))) + (set! (-> v1-30 particle-system-2d) *sp-particle-system-2d*) + (set! (-> v1-30 particle-system-3d) *sp-particle-system-3d*) + (set! (-> v1-30 part-quat) *particle-quat*) + (set! (-> v1-30 part-vel) *particle-vel*) + (set! (-> v1-30 part-thruster) (-> *part-id-table* 939)) + (set! (-> v1-30 part-thruster-scale-x) (-> *part-id-table* 939 init-specs 4)) + (set! (-> v1-30 part-thruster-scale-y) (-> *part-id-table* 939 init-specs 5)) + (set! (-> v1-30 thruster-flame-width) 0.0) + (set! (-> v1-30 thruster-flame-length) 0.0) + ) + (set! (-> self control reaction) target-collision-reaction) + (set! (-> self control transv quad) (the-as uint128 0)) + (set! (-> self control ctrl-xz-vel) 0.0) + (set! (-> self focus-status) (logior (focus-status mech) (-> self focus-status))) + (set! (-> self control bend-target) 0.0) + (let ((v1-40 (-> self node-list data))) + (set! (-> v1-40 0 param0) (the-as (function cspace matrix none) cspace<-transformq+world-trans!)) + (set! (-> v1-40 0 param1) (the-as basic (-> self control trans))) + (set! (-> v1-40 0 param2) (the-as basic (-> self control cspace-offset))) + ) + (target-collide-set! 'mech 0.0) + (set! (-> self control pat-ignore-mask) (new 'static 'pat-surface :noentity #x1 :nomech #x1)) + (set! (-> self draw shadow) #f) + (let ((s4-1 (-> self entity)) + (s3-0 (-> self level)) + ) + (process-entity-set! self (the-as entity-actor (-> self mech entity))) + (let ((s2-0 (get-process *16k-dead-pool* manipy #x4000))) + (set! (-> self manipy) + (the-as + (pointer manipy) + (when s2-0 + (let ((t9-11 (method-of-type manipy activate))) + (t9-11 (the-as manipy s2-0) self (symbol->string (-> manipy symbol)) (the-as pointer #x70004000)) + ) + (let ((s1-0 run-function-in-process) + (s0-0 s2-0) + ) + (set! sv-96 manipy-init) + (set! sv-112 (-> self control trans)) + (set! sv-128 (-> self entity)) + (let ((t0-1 (art-group-get-by-name *level* "skel-mech" (the-as (pointer uint32) #f))) + (t1-0 #f) + (t2-0 0) + ) + ((the-as (function object object object object object object object none) s1-0) + s0-0 + sv-96 + sv-112 + sv-128 + t0-1 + t1-0 + t2-0 + ) + ) + ) + (-> s2-0 ppointer) + ) + ) + ) + ) + (set! (-> self entity) s4-1) + (set! (-> self level) s3-0) + ) + (when (-> self manipy) + (send-event + (ppointer->process (-> self manipy)) + 'trans-hook + (lambda :behavior target + () + (let* ((a0-0 (-> self parent)) + (v1-0 (if a0-0 + (-> (the-as target (-> a0-0 0)) self-override) + ) + ) + ) + (set! (-> self control trans quad) (-> v1-0 mech mech-trans quad)) + (let ((a0-4 (-> v1-0 mech mech-quat quad))) + (set! (-> self control quat quad) a0-4) + ) + (set! (-> self control scale quad) (-> v1-0 mech mech-scale quad)) + (set! (-> self draw light-index) (-> v1-0 draw light-index)) + (let ((a0-10 (-> v1-0 draw color-mult quad))) + (set! (-> self draw color-mult quad) a0-10) + ) + (let ((a0-12 (-> v1-0 draw color-emissive quad))) + (set! (-> self draw color-emissive quad) a0-12) + ) + (let ((v1-4 (-> v1-0 draw shadow-ctrl settings shadow-dir quad))) + (set! (-> self draw shadow-ctrl settings shadow-dir quad) v1-4) + ) + ) + ;; (dotimes (gp-0 2) + ;; (enable-set! (-> (the-as (array joint-mod-ik) (+ (* gp-0 4) (the-as int self))) 64) #t) + ;; ) + (none) + ) + ) + (send-event + (ppointer->process (-> self manipy)) + 'post-hook + (lambda :behavior mech + () + (let ((gp-0 (ppointer->process (-> self parent)))) + ((method-of-type impact-control update-from-cspace) + (the-as impact-control (-> (the-as target gp-0) mech state-impact)) + ) + (when (-> (the-as target gp-0) mech state-impact? 0) + (let ((a1-0 (new 'stack-no-clear 'collide-query))) + ((method-of-type impact-control impact-control-method-11) + (the-as impact-control (-> (the-as target gp-0) mech state-impact)) + a1-0 + (the-as process gp-0) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1) + ) + ) + ) + ;; (mech-update-ik) + (target-mech-mech-effect (the-as target gp-0)) + ) + (none) + ) + ) + (send-event (ppointer->process (-> self manipy)) 'anim-mode 'clone-anim) + (send-event (ppointer->process (-> self manipy)) 'sync #t) + (send-event + (ppointer->process (-> self manipy)) + 'eval + (lambda :behavior target + () + (set! (-> self state-hook) #f) + (set! (-> self draw shadow-ctrl) *mech-shadow-control*) + ;; (let ((v0-0 (new 'process 'joint-mod-ik self 27 5283.84))) + ;; (s.w! (+ self 268) v0-0) + ;; ) + ;; (let ((v0-1 (new 'process 'joint-mod-ik self 33 5283.84))) + ;; (s.w! (+ self 272) v0-1) + ;; ) + ;; (dotimes (v1-3 2) + ;; (let ((a0-5 (-> (the-as (array joint-mod-ik) (+ (* v1-3 4) (the-as int self))) 64))) + ;; (set! (-> a0-5 elbow-pole-vector-axis) (the-as uint 2)) + ;; (set! (-> a0-5 elbow-rotation-axis) (the-as uint 0)) + ;; (set! (-> a0-5 callback) mech-leg-ik-callback) + ;; (logior! (-> a0-5 flags) (joint-mod-ik-flags elbow-trans-neg)) + ;; ) + ;; ) + (none) + ) + ) + ) + (logior! (-> self state-flags) (state-flags sf6)) + (set-setting! 'string-max-length 'low #x46e00000 0) + (set-setting! 'string-min-length 'low #x46800000 0) + (set-setting! 'string-max-height 'low #x46a00000 0) + (set-setting! 'string-min-height 'low #x46600000 0) + (set-setting! 'fov 'abs #x46555555 0) + (set-setting! 'head-offset 'abs #x46900000 0) + (set-setting! 'mode-sound-bank 'mech 0 0) + (set-setting! 'sound-flava #f #x41f00000 3) + (set! (-> self mech hud 0) + (the-as uint (ppointer->handle (process-spawn hud-heatmeter :init hud-init-by-other :to self))) + ) + (remove-exit) + (if arg2 + (go target-mech-stance) + (go target-mech-get-on arg0) + ) + (none) + ) + +(defbehavior target-mech-exit target () + (when (not (and (-> self next-state) (let ((v1-3 (-> self next-state name))) + (or (= v1-3 'target-mech-stance) + (= v1-3 'target-mech-walk) + (= v1-3 'target-mech-jump) + (= v1-3 'target-mech-jump-jump) + (= v1-3 'target-mech-falling) + (= v1-3 'target-mech-hit-ground) + (= v1-3 'target-mech-punch) + (= v1-3 'target-mech-hit) + (= v1-3 'target-mech-death) + (= v1-3 'target-mech-carry-drag) + (= v1-3 'target-mech-carry-pickup) + (= v1-3 'target-mech-carry-drop) + (= v1-3 'target-mech-carry-stance) + (= v1-3 'target-mech-carry-walk) + (= v1-3 'target-mech-carry-jump) + (= v1-3 'target-mech-carry-falling) + (= v1-3 'target-mech-carry-hit-ground) + (= v1-3 'target-mech-carry-throw) + (= v1-3 'target-mech-get-off) + (= v1-3 'target-mech-get-off-jump) + (= v1-3 'target-mech-grab) + (= v1-3 'target-mech-clone-anim) + ) + ) + ) + ) + (let ((v1-4 (-> self manipy))) + (when v1-4 + (deactivate (-> v1-4 0)) + (set! (-> self manipy) (the-as (pointer manipy) #f)) + ) + ) + (logclear! (-> self focus-status) (focus-status mech)) + (logclear! (-> self control root-prim prim-core action) (collide-action stuck-wall-escape)) + (set! (-> self control mod-surface) *walk-mods*) + (logclear! (-> self state-flags) (state-flags sf6)) + (remove-setting! 'string-max-length) + (remove-setting! 'string-min-length) + (remove-setting! 'string-max-height) + (remove-setting! 'string-min-height) + (remove-setting! 'fov) + (remove-setting! 'head-offset) + (remove-setting! 'mode-sound-bank) + (remove-setting! 'sound-flava) + (set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) + (let ((v1-39 (-> self node-list data))) + (set! (-> v1-39 0 param0) (the-as (function cspace matrix none) cspace<-transformq+trans!)) + (set! (-> v1-39 0 param1) (the-as basic (-> self control trans))) + (set! (-> v1-39 0 param2) (the-as basic (-> self control cspace-offset))) + ) + (target-collide-set! 'normal 0.0) + (set! (-> self control reaction) target-collision-reaction) + (set! (-> self control pat-ignore-mask) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1)) + (sound-stop (the-as sound-id (-> self mech engine-sound-id))) + (sound-stop (the-as sound-id (-> self mech thrust-sound-id))) + (sound-stop (the-as sound-id (-> self mech drag-sound-id))) + (sound-stop (the-as sound-id (-> self mech whine-sound-id))) + (send-event (handle->process (-> self mech hud 0)) 'hide-and-die) + (set! (-> self draw shadow) (-> self shadow-backup)) + (set! (-> self control cspace-offset quad) (the-as uint128 0)) + (remove-setting! 'sound-flava) + (target-exit) + ) + (none) + ) + +(defbehavior target-mech-effect target () + (sound-play "mech-pulse" :id (the-as sound-id (-> self mech engine-sound-id))) + (set! (-> self game distance) (/ (-> self mech shield-value) (-> self mech shield-max))) + 0 + (none) + ) + +(defbehavior target-mech-add-thrust target () + (let ((s5-0 (-> self control target-transv)) + (gp-0 (-> self control transv-ctrl)) + ) + (set! (-> (new 'stack-no-clear 'vector) quad) (-> self control target-transv quad)) + (target-bend-vel-turn gp-0) + (target-add-slide-factor s5-0) + (let ((t9-2 vector-xz-normalize!) + (a0-5 (new-stack-vector0)) + ) + (set! (-> a0-5 quad) (-> s5-0 quad)) + (let ((s4-0 (t9-2 a0-5 1.0))) + (let ((t9-3 vector-xz-normalize!) + (a0-6 (new-stack-vector0)) + ) + (set! (-> a0-6 quad) (-> gp-0 quad)) + (let ((v1-7 (t9-3 a0-6 1.0))) + (set! (-> s4-0 y) 0.0) + (set! (-> v1-7 y) 0.0) + ) + ) + (let* ((f0-2 (-> s4-0 z)) + (v1-8 gp-0) + (f1-4 (sqrtf (+ (* (-> v1-8 x) (-> v1-8 x)) (* (-> v1-8 z) (-> v1-8 z))))) + (v1-10 s5-0) + (f0-11 + (cond + ((>= f1-4 (sqrtf (+ (* (-> v1-10 x) (-> v1-10 x)) (* (-> v1-10 z) (-> v1-10 z))))) + (let ((f0-3 (-> self control current-surface fric)) + (f1-5 1.0) + (v1-15 gp-0) + ) + (* f0-3 (fmax f1-5 (/ (sqrtf (+ (* (-> v1-15 x) (-> v1-15 x)) (* (-> v1-15 z) (-> v1-15 z)))) + (-> self control current-surface nonlin-fric-dist) + ) + ) + ) + ) + ) + ((>= f0-2 0.0) + (+ (* f0-2 (-> self control current-surface seek0)) (* (- 1.0 f0-2) (-> self control current-surface seek90))) + ) + (else + (+ (* (fabs f0-2) (-> self control current-surface seek180)) + (* (+ 1.0 f0-2) (-> self control current-surface seek90)) + ) + ) + ) + ) + (s4-1 vector-xz-normalize!) + (s3-0 gp-0) + (t9-4 seek) + (v1-30 gp-0) + ) + (s4-1 s3-0 (t9-4 + (sqrtf (+ (* (-> v1-30 x) (-> v1-30 x)) (* (-> v1-30 z) (-> v1-30 z)))) + (sqrtf (+ (* (-> s5-0 x) (-> s5-0 x)) (* (-> s5-0 z) (-> s5-0 z)))) + (* f0-11 (-> self clock seconds-per-frame)) + ) + ) + ) + ) + ) + (set! (-> self control velocity-after-thrust) (vector-length gp-0)) + ) + (let ((gp-1 (new-stack-vector0))) + (vector-matrix*! gp-1 (-> self control transv-ctrl) (-> self control c-R-w)) + (vector-float*! gp-1 gp-1 0.5) + (vector+! gp-1 gp-1 (-> self control trans)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id debug-no-zbuf1) + gp-1 + (meters 0.2) + "ltransv" + (new 'static 'rgba :g #xff :a #x80) + ) + ) + (none) + ) + +(defbehavior target-mech-collision target () + (cond + ((and (-> self next-state) (= (-> self next-state name) 'target-mech-carry-drag)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) (process->ppointer self)) + (set! (-> a1-0 num-params) 2) + (set! (-> a1-0 message) 'move) + (set! (-> a1-0 param 0) (the-as uint (-> self control transv))) + (set! (-> a1-0 param 1) (the-as uint s5-0)) + (let ((s3-0 (send-event-function (handle->process (-> self carry other)) a1-0)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-0 quad) (-> self control trans quad)) + (set! (-> (new 'stack-no-clear 'vector) quad) (-> self control transv quad)) + (let ((a2-1 (new 'stack-no-clear 'collide-query)) + (v1-18 (-> self control)) + ) + (set! (-> a2-1 collide-with) (-> v1-18 root-prim prim-core collide-with)) + (set! (-> a2-1 ignore-process0) self) + (set! (-> a2-1 ignore-process1) #f) + (set! (-> a2-1 ignore-pat) (-> v1-18 pat-ignore-mask)) + (set! (-> a2-1 action-mask) (collide-action solid)) + (fill-cache-integrate-and-collide v1-18 (-> v1-18 transv) a2-1 (meters 1)) + ) + (vector-! gp-0 (-> self control trans) s4-0) + (let* ((s2-0 (-> self control dynam gravity-normal)) + (f30-0 (- (vector-dot s2-0 gp-0) (vector-dot s2-0 s5-0))) + (a1-4 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-4 from) (process->ppointer self)) + (set! (-> a1-4 num-params) 0) + (set! (-> a1-4 message) 'carry-info) + (let* ((s1-0 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-4))) + (f0-2 (distance-from-destination (-> self carry) s1-0)) + ) + (cond + ((not s3-0) + ) + ((>= f0-2 0.0) + (let ((v1-38 (vector-float*! (new 'stack-no-clear 'vector) s2-0 f30-0))) + (vector+! (-> s1-0 hold-trans) (-> s1-0 hold-trans) v1-38) + ) + (let ((v1-39 (new-stack-vector0))) + (let ((f0-4 (vector-dot (-> self control dynam gravity-normal) s5-0))) + 0.0 + (vector-! v1-39 s5-0 (vector-float*! v1-39 (-> self control dynam gravity-normal) f0-4)) + ) + (let ((f0-5 (vector-length v1-39))) + f0-5 + (let ((f0-6 f0-5) + (v1-42 (new-stack-vector0)) + ) + (let ((f1-6 (vector-dot (-> self control dynam gravity-normal) gp-0))) + 0.0 + (vector-! v1-42 gp-0 (vector-float*! v1-42 (-> self control dynam gravity-normal) f1-6)) + ) + (let ((f1-7 (vector-length v1-42))) + f1-7 + (when (< f0-6 f1-7) + (let ((v1-46 (new-stack-vector0)) + (f0-8 (vector-dot (-> self control dynam gravity-normal) gp-0)) + ) + 0.0 + (vector-! v1-46 gp-0 (vector-float*! v1-46 (-> self control dynam gravity-normal) f0-8)) + (let ((f1-11 (vector-length v1-46)) + (a0-43 (new-stack-vector0)) + ) + (let ((f2-3 (vector-dot (-> self control dynam gravity-normal) s5-0))) + 0.0 + (vector-! a0-43 s5-0 (vector-float*! a0-43 (-> self control dynam gravity-normal) f2-3)) + ) + (let ((f2-4 (vector-length a0-43))) + f2-4 + (let ((f2-5 f2-4)) + (vector+! + gp-0 + (vector-float*! gp-0 (-> self control dynam gravity-normal) f0-8) + (vector-float*! v1-46 v1-46 (/ f2-5 f1-11)) + ) + ) + ) + ) + ) + (let ((a1-25 (vector+! (new 'stack-no-clear 'vector) s4-0 gp-0))) + (move-to-point! (-> self control) a1-25) + ) + ) + ) + ) + ) + ) + ) + (else + (send-event self 'drop 150) + ) + ) + ) + ) + ) + ) + ) + ) + (else + (when *debug-segment* + (let ((gp-1 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-61 'target) + (s5-1 *profile-target-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-1 (-> gp-1 data (-> gp-1 count)))) + (let ((s3-1 (-> gp-1 base-time))) + (set! (-> s4-1 name) v1-61) + (set! (-> s4-1 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + ) + (set! (-> s4-1 depth) (the-as uint (-> gp-1 depth))) + (set! (-> s4-1 color) s5-1) + (set! (-> gp-1 segment (-> gp-1 depth)) s4-1) + ) + (+! (-> gp-1 count) 1) + (+! (-> gp-1 depth) 1) + (set! (-> gp-1 max-depth) (max (-> gp-1 max-depth) (-> gp-1 depth))) + ) + ) + 0 + ) + (let ((a2-17 (new 'stack-no-clear 'collide-query)) + (v1-74 (-> self control)) + ) + (set! (-> a2-17 collide-with) (-> v1-74 root-prim prim-core collide-with)) + (set! (-> a2-17 ignore-process0) self) + (set! (-> a2-17 ignore-process1) #f) + (set! (-> a2-17 ignore-pat) (-> v1-74 pat-ignore-mask)) + (set! (-> a2-17 action-mask) (collide-action solid)) + (fill-cache-integrate-and-collide v1-74 (-> v1-74 transv) a2-17 (meters 1)) + ) + (when *debug-segment* + (let ((gp-2 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-87 (+ (-> gp-2 depth) -1)) + (s5-2 (-> gp-2 segment v1-87)) + (s4-2 (-> gp-2 base-time)) + ) + (when (>= v1-87 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-2)))) + (+! (-> gp-2 depth) -1) + ) + ) + ) + ) + 0 + ) + ) + ) + (when (logtest? (-> self control status) (collide-status touch-wall)) + (let ((v1-98 (vector-! (new 'stack-no-clear 'vector) (-> self control wall-contact-pt) (-> self control trans)))) + (set! (-> v1-98 y) 0.0) + (when (< (vector-dot v1-98 (-> self control c-R-w vector 2)) 0.0) + (set! (-> self mech back-touch-time) (-> self clock frame-counter)) + (set! (-> self mech back-touch-point quad) (-> self control wall-contact-pt quad)) + (set! (-> self mech back-touch-trans quad) (-> self control trans quad)) + ) + ) + ) + 0 + (none) + ) + +(defbehavior target-mech-real-post target () + (let ((f30-0 (-> self clock clock-ratio))) + (let ((gp-1 (max 1 (the int (-> self clock time-adjust-ratio))))) + (update-rates! (-> self clock) (/ f30-0 (the float gp-1))) + (while (nonzero? gp-1) + (+! gp-1 -1) + (set! (-> self control remaining-ctrl-iterations) gp-1) + (flag-setup) + (if (< (-> self control force-turn-to-strength) 0.0) + (set! (-> self control force-turn-to-strength) (- 1.0 (-> self control cpad stick0-speed))) + ) + (build-conversions (-> self control transv)) + (do-rotations1) + (let ((s5-0 (new-stack-vector0))) + (read-pad s5-0) + (let ((f28-0 (-> self control pad-magnitude))) + (if (or (and (< 0.0 f28-0) + (< 0.3 (-> self control pad-magnitude)) + (< (vector-dot (-> self control pad-xz-dir) (-> self control last-pad-xz-dir)) 0.2) + (< f28-0 0.7) + ) + (-> self mech stick-off) + ) + (set! f28-0 0.0) + ) + (when (!= (-> self control force-turn-to-strength) 0.0) + (let ((f0-15 (fmin 1.0 (-> self control force-turn-to-strength)))) + (set! (-> self control force-turn-to-strength) f0-15) + (let ((a1-2 (vector-float*! + (new 'stack-no-clear 'vector) + (if (= f28-0 0.0) + *zero-vector* + s5-0 + ) + f28-0 + ) + ) + (a2-1 (vector-float*! + (new 'stack-no-clear 'vector) + (-> self control force-turn-to-direction) + (-> self control force-turn-to-speed) + ) + ) + ) + (vector-lerp! s5-0 a1-2 a2-1 f0-15) + ) + ) + (set! f28-0 (vector-length s5-0)) + (vector-normalize! s5-0 1.0) + ) + (turn-to-vector s5-0 f28-0) + ) + ) + (cond + ((and (logtest? (-> self control mod-surface flags) (surface-flag air)) + (zero? (logand (-> self control status) (collide-status on-surface))) + ) + (add-thrust) + ) + (else + (let* ((v1-51 (-> self control target-transv)) + (f0-20 (sqrtf (+ (* (-> v1-51 x) (-> v1-51 x)) (* (-> v1-51 z) (-> v1-51 z))))) + ) + (set-vector! (-> self control target-transv) 0.0 0.0 f0-20 1.0) + ) + (target-mech-add-thrust) + ) + ) + (add-gravity) + (do-rotations2) + (reverse-conversions (-> self control transv)) + (pre-collide-setup) + (target-mech-collision) + (bend-gravity) + (post-flag-setup) + ) + ) + (update-rates! (-> self clock) f30-0) + ) + (when *debug-segment* + (let ((gp-2 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-68 'target-post) + (s5-1 *profile-target-post-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-2 data (-> gp-2 count)))) + (let ((s3-0 (-> gp-2 base-time))) + (set! (-> s4-0 name) v1-68) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-2 depth))) + (set! (-> s4-0 color) s5-1) + (set! (-> gp-2 segment (-> gp-2 depth)) s4-0) + ) + (+! (-> gp-2 count) 1) + (+! (-> gp-2 depth) 1) + (set! (-> gp-2 max-depth) (max (-> gp-2 max-depth) (-> gp-2 depth))) + ) + ) + 0 + ) + (ja-post) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-92 (+ (-> gp-3 depth) -1)) + (s5-2 (-> gp-3 segment v1-92)) + (s4-1 (-> gp-3 base-time)) + ) + (when (>= v1-92 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-3 depth) -1) + ) + ) + ) + ) + 0 + ) + (joint-points) + (do-target-gspot) + (target-powerup-process) + (vector+! (-> self mech mech-trans) (-> self control trans) (-> self control cspace-offset)) + (quaternion-copy! (the-as quaternion (-> self mech mech-quat)) (-> self control quat)) + (set! (-> self mech mech-scale quad) (-> self control scale quad)) + (vector+! (-> self alt-cam-pos) (-> self control camera-pos) (new 'static 'vector :y 4096.0 :w 1.0)) + (set! (-> self mech mech-time) (-> self clock frame-counter)) + (target-mech-effect) + 0 + (none) + ) + +(defbehavior target-mech-post target () + (target-mech-real-post) + (none) + ) diff --git a/test/decompiler/reference/jak2/engine/target/mech_suit/mech-states_REF.gc b/test/decompiler/reference/jak2/engine/target/mech_suit/mech-states_REF.gc new file mode 100644 index 000000000..e4533214a --- /dev/null +++ b/test/decompiler/reference/jak2/engine/target/mech_suit/mech-states_REF.gc @@ -0,0 +1,2872 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *mech-exploder-params*, type joint-exploder-static-params +(define *mech-exploder-params* + (new 'static 'joint-exploder-static-params + :joints (new 'static 'boxed-array :type joint-exploder-static-joint-params + (new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 12 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 13 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 14 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 15 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 16 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 17 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 18 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 19 :parent-joint-index -1) + ) + :collide-spec #x1 + ) + ) + +;; failed to figure out what this is: +(defstate target-mech-start (target) + :event target-mech-handler + :exit target-mech-exit + :code (the-as (function handle none :behavior target) target-mech-init) + :post target-post + ) + +;; failed to figure out what this is: +(defstate target-mech-stance (target) + :event target-mech-handler + :enter (behavior () + (set! (-> self control mod-surface) *mech-stance-mods*) + (set! (-> self control mod-surface turnvv) 40049.777) + (set! (-> self control did-move-to-pole-or-max-jump-height) 0.0) + (rot->dir-targ! (-> self control)) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (none) + ) + :exit (behavior () + (target-effect-exit) + (target-mech-exit) + (rot->dir-targ! (-> self control)) + (none) + ) + :trans (behavior () + (if (and (move-legs?) + (and (< (fabs + (deg-diff (quaternion-y-angle (-> self control dir-targ)) (vector-y-angle (-> self control to-target-pt-xz))) + ) + 1820.4445 + ) + (>= (- (-> self clock frame-counter) (-> self control time-of-last-zero-input)) (seconds 0.05)) + ) + ) + (go target-mech-walk) + ) + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-punch) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + (if (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons r1) + ) + (go target-mech-carry-pickup) + ) + (if (and (or (cpad-pressed? (-> self control cpad number) triangle) (not (-> *setting-control* user-current pilot))) + (target-mech-get-off?) + ) + (go target-mech-get-off) + ) + (fall-test target-mech-falling (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 327)))) + (let ((v1-8 (ja-group))) + (if (and v1-8 (= v1-8 (-> self draw art-group data 326))) + (sound-play "mech-stop") + ) + ) + (ja-channel-push! 3 (seconds 0.2)) + (ja :group! (-> self draw art-group data 327) :dist 16384.0) + (ja :chan 1 :group! (-> self draw art-group data 332) :dist 3640.889) + (ja :chan 2 :group! (-> self draw art-group data 324) :dist 0.0) + ) + ) + (let ((f28-0 0.0) + (f30-0 0.0) + (gp-1 #f) + ) + (until #f + (let ((f26-0 (y-angle (-> self control)))) + (deg-diff f26-0 (quaternion-y-angle (-> self control dir-targ))) + (suspend) + (let ((f26-1 (* (deg-diff f26-0 (y-angle (-> self control))) (-> self clock frames-per-second)))) + (cond + ((< 910.2222 (fabs f26-1)) + (set! f28-0 (seek f28-0 1.0 (* 16.0 (-> self clock seconds-per-frame)))) + (set! gp-1 #t) + ) + (else + (set! f28-0 (seek f28-0 0.0 (* 6.0 (-> self clock seconds-per-frame)))) + (when (and gp-1 (= f28-0 0.0)) + (set! gp-1 #f) + (sound-play "mech-twitch") + ) + ) + ) + (set! f30-0 + (seek f30-0 (lerp-scale 1.0 0.0 (fabs f26-1) 3640.889 16384.0) (* 10.0 (-> self clock seconds-per-frame))) + ) + (let ((v1-41 (-> self skel effect))) + (set! (-> v1-41 channel-offset) (cond + ((< 0.8 (- 1.0 f28-0)) + 2 + ) + ((< 0.5 f30-0) + 1 + ) + (else + 0 + ) + ) + ) + ) + 0 + (ja :num! (loop! (/ f26-1 (current-cycle-distance (-> self skel))))) + (let ((a0-41 (-> self skel root-channel 1))) + (set! (-> a0-41 frame-interp 1) f30-0) + (set! (-> a0-41 frame-interp 0) f30-0) + (set! (-> a0-41 param 0) 0.0) + (joint-control-channel-group-eval! a0-41 (the-as art-joint-anim #f) num-func-chan) + ) + (ja-no-eval :chan 1 :num! (loop! (/ f26-1 (current-cycle-distance (-> self skel))))) + ) + ) + (let ((a0-44 (-> self skel root-channel 2))) + (let ((f0-22 (- 1.0 f28-0))) + (set! (-> a0-44 frame-interp 1) f0-22) + (set! (-> a0-44 frame-interp 0) f0-22) + ) + (set! (-> a0-44 param 0) 1.0) + (joint-control-channel-group-eval! a0-44 (the-as art-joint-anim #f) num-func-loop!) + ) + (can-play-stance-amibent?) + ) + ) + #f + (none) + ) + :post target-mech-post + ) + +;; failed to figure out what this is: +(defstate target-mech-walk (target) + :event target-mech-handler + :enter (behavior () + (set! (-> self control mod-surface) *mech-walk-mods*) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control unknown-word04) (the-as uint 0.0)) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (none) + ) + :exit (behavior () + (target-effect-exit) + (target-mech-exit) + (none) + ) + :trans (behavior () + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-punch) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + (let ((gp-0 (ja-group)) + (f0-2 (ja-aframe-num 0)) + ) + (when (if (or (and (= gp-0 (-> self draw art-group data 326)) (>= f0-2 5.5) (>= 9.5 f0-2)) + (and (= gp-0 (-> self draw art-group data 326)) (>= f0-2 20.5) (>= 24.5 f0-2)) + ) + #t + ) + (case (-> self control unknown-spool-anim00) + (('punch) + (go target-mech-punch) + ) + (('jump) + (if (can-jump? #f) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ) + ) + (when (and (< 5.0 (the-as float (-> self control unknown-word04))) + (= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + ) + (set-forward-vel 0.0) + (go target-mech-stance) + ) + (if (and (or (cpad-pressed? (-> self control cpad number) triangle) (not (-> *setting-control* user-current pilot))) + (target-mech-get-off?) + ) + (go target-mech-get-off) + ) + ) + ) + (if (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons r1) + ) + (go target-mech-carry-pickup) + ) + (fall-test target-mech-falling (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((f30-0 0.0) + (f28-0 0.0) + ) + (let ((f26-0 (cond + ((zero? (-> self mech walk-anim-leg)) + (set! (-> self mech walk-anim-leg) 1) + 7.0 + ) + (else + (set! (-> self mech walk-anim-leg) 0) + 22.0 + ) + ) + ) + (v1-7 (ja-group)) + ) + (when (not (and v1-7 (= v1-7 (-> self draw art-group data 326)))) + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 326) + :num! (identity (ja-aframe f26-0 0)) + :dist (-> *TARGET-bank* mech-walk-cycle-dist) + ) + (ja :chan 1 :group! (-> self draw art-group data 325) :dist (-> *TARGET-bank* mech-run-cycle-dist)) + (ja :chan 2 :group! (-> self draw art-group data 324) :dist 0.0) + ) + ) + (until #f + (if (< (-> self control ctrl-xz-vel) 8192.0) + (set-forward-vel 8192.0) + ) + (suspend) + (let* ((f0-5 (current-cycle-distance (-> self skel))) + (f26-1 (/ (-> self control ctrl-xz-vel) f0-5)) + ) + (set! (-> self control unknown-word04) + (the-as uint (+ (the-as float (-> self control unknown-word04)) f26-1)) + ) + (set! f30-0 (seek + f30-0 + (lerp-scale 0.0 1.0 (-> self control ctrl-xz-vel) 16384.0 32768.0) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (set! f28-0 (seek + f28-0 + (lerp-scale 1.0 0.0 (-> self control ctrl-xz-vel) 0.0 12288.0) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (let ((v1-39 (-> self skel effect))) + (set! (-> v1-39 channel-offset) (if (< 0.5 f30-0) + 1 + 0 + ) + ) + ) + 0 + (ja :num! (loop! f26-1)) + ) + (let ((a0-24 (-> self skel root-channel 1))) + (set! (-> a0-24 frame-interp 1) f30-0) + (set! (-> a0-24 frame-interp 0) f30-0) + (set! (-> a0-24 param 0) 0.0) + (joint-control-channel-group-eval! a0-24 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-25 (-> self skel root-channel 2))) + (set! (-> a0-25 frame-interp 1) f28-0) + (set! (-> a0-25 frame-interp 0) f28-0) + (set! (-> a0-25 param 0) 0.0) + (joint-control-channel-group-eval! a0-25 (the-as art-joint-anim #f) num-func-chan) + ) + ) + ) + #f + (none) + ) + :post target-mech-post + ) + +;; definition for function target-mech-punch-pick +;; INFO: Used lq/sq +(defbehavior target-mech-punch-pick target ((arg0 symbol)) + (local-vars (sv-64 float)) + (combo-tracker-method-12 + (-> self control unknown-combo-tracker00) + *null-vector* + *null-vector* + (the-as process #f) + (-> self clock frame-counter) + ) + (let* ((s4-0 (get-trans self 3)) + (a0-4 (the-as process-focusable (combo-tracker-method-13 + (-> self control unknown-combo-tracker00) + (-> self control send-attack-dest) + s4-0 + 32768.0 + (-> self control c-R-w vector 2) + 65536.0 + ) + ) + ) + (s5-0 (the-as art-element #f)) + ) + (when a0-4 + (let ((s3-0 (get-trans a0-4 3))) + (let ((s0-0 (-> self control)) + (s1-0 s3-0) + (s2-0 deg-diff) + ) + (set! sv-64 (y-angle s0-0)) + (let* ((a1-4 (vector-y-angle (vector-! (new 'stack-no-clear 'vector) s1-0 (-> s0-0 trans)))) + (f0-0 (s2-0 sv-64 a1-4)) + ) + (cond + ((< (+ 12288.0 (-> s4-0 y)) (-> s3-0 y)) + (set! (-> self mech walk-anim-leg) 3) + ) + ((>= f0-0 5461.3335) + (set! (-> self mech walk-anim-leg) 0) + 0 + ) + ((>= -5461.3335 f0-0) + (set! (-> self mech walk-anim-leg) 1) + ) + (else + (set! (-> self mech walk-anim-leg) 2) + ) + ) + ) + ) + (if (< (vector-vector-distance s3-0 s4-0) 32768.0) + (forward-up-nopitch->quaternion + (-> self control dir-targ) + (vector-normalize! (vector-! (new 'stack-no-clear 'vector) s3-0 s4-0) 1.0) + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + ) + (let ((v1-26 (-> self mech walk-anim-leg))) + (cond + ((zero? v1-26) + (set! (-> self mech walk-anim-leg) 1) + (set! s5-0 (-> self draw art-group data 333)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 7 + 6963.2 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ((= v1-26 1) + (set! (-> self mech walk-anim-leg) 0) + (set! s5-0 (-> self draw art-group data 334)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 17 + 6963.2 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ((= v1-26 2) + (set! (-> self mech walk-anim-leg) 0) + (set! s5-0 (-> self draw art-group data 335)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 39 + 11141.12 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ((= v1-26 3) + (set! (-> self mech walk-anim-leg) 0) + (set! s5-0 (-> self draw art-group data 353)) + ((method-of-type impact-control initialize) + (the-as impact-control (-> self mech state-impact)) + (the-as process-drawable (ppointer->process (-> self manipy))) + 39 + 11141.12 + (logior (collide-spec mech-punch) (-> self control root-prim prim-core collide-with)) + ) + ) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (if (zero? arg0) + (ja-no-eval :group! s5-0 :num! (seek! (the float (+ (-> (the-as art-joint-anim s5-0) frames num-frames) -1)))) + (ja-no-eval :group! s5-0 + :num! (seek! (the float (+ (-> (the-as art-joint-anim s5-0) frames num-frames) -1))) + :frame-num (ja-aframe 10.0 0) + ) + ) + ) + (-> self mech walk-anim-leg) + ) + +;; failed to figure out what this is: +(defstate target-mech-punch (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (cond + ((logtest? (-> self focus-status) (focus-status dangerous)) + (case event-type + (('touched) + (if ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> event param 0)) + (-> self control) + (the-as uint 1920) + ) + (target-send-attack + proc + (-> self control danger-mode) + (the-as touching-shapes-entry (-> event param 0)) + (the-as int (-> self control target-attack-id)) + (the-as int (-> self control attack-count)) + (-> self control penetrate-using) + ) + (target-mech-handler proc arg1 event-type event) + ) + ) + (('impact-control) + (when (-> self control danger-mode) + (-> event param 1) + (let* ((gp-1 (the-as object (-> event param 3))) + (s5-1 (-> (the-as collide-query gp-1) best-other-tri collide-ptr)) + (s4-1 (if (type? s5-1 collide-shape-prim) + (the-as collide-shape-prim s5-1) + ) + ) + (s3-1 (if s4-1 + (-> s4-1 cshape process) + (the-as process-drawable #f) + ) + ) + (s5-2 (if (type? s3-1 process-focusable) + s3-1 + ) + ) + ) + (if (and s4-1 + (and (or (and s5-2 (logtest? (-> (the-as process-focusable s5-2) focus-status) (focus-status dead))) + (let ((a1-6 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-6 from) (process->ppointer self)) + (set! (-> a1-6 num-params) 2) + (set! (-> a1-6 message) 'attack) + (set! (-> a1-6 param 0) (the-as uint #f)) + (let ((v1-20 (new 'static 'attack-info :mask (attack-info-mask intersection mode id count penetrate-using)))) + (set! (-> v1-20 id) (-> self control target-attack-id)) + (set! (-> v1-20 mode) (-> self control danger-mode)) + (set! (-> v1-20 count) (-> self control attack-count)) + (set! (-> v1-20 penetrate-using) (penetrate touch punch mech mech-punch)) + (set! (-> v1-20 intersection quad) (-> (the-as collide-query gp-1) best-other-tri intersect quad)) + (set! (-> a1-6 param 1) (the-as uint v1-20)) + ) + (when (send-event-function (-> s4-1 cshape process) a1-6) + (set! (-> self control send-attack-dest) (process->handle s5-2)) + (set! (-> self control send-attack-time) (-> self clock frame-counter)) + #t + ) + ) + ) + s5-2 + (logtest? (-> (the-as process-focusable s5-2) focus-status) (focus-status dead)) + ) + ) + (set! (-> self mech forward-vel) 0.0) + (set! (-> self mech forward-vel) -40960.0) + ) + (when (or (not s5-2) (= (-> self control send-attack-time) (-> self clock frame-counter))) + (let ((s5-3 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-3 + (let ((t9-7 (method-of-type part-tracker activate))) + (t9-7 (the-as part-tracker s5-3) self (symbol->string (-> part-tracker symbol)) (the-as pointer #x70004000)) + ) + (let ((t9-8 run-function-in-process) + (a0-33 s5-3) + (a1-9 part-tracker-init) + (a2-8 (-> *part-group-id-table* 11)) + (a3-4 0) + (t0-1 #f) + (t1-1 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> (the-as collide-query gp-1) best-other-tri intersect quad)) + ((the-as (function object object object object object object object object none) t9-8) + a0-33 + a1-9 + a2-8 + a3-4 + t0-1 + t1-1 + t2-0 + t3-0 + ) + ) + (-> s5-3 ppointer) + ) + ) + (sound-play "mech-punch-hit" :position (+ (the-as uint gp-1) 48)) + (activate! *camera-smush-control* 1638.4 15 75 1.0 0.9 (-> *display* camera-clock)) + ) + ) + ) + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *mech-punch-mods*) + (set! (-> self mech state-impact? 0) #f) + (rot->dir-targ! (-> self control)) + (none) + ) + :exit (behavior () + (set! (-> *mech-punch-mods* turnvv) 0.0) + (set! (-> self mech state-impact? 0) #f) + (set! (-> self control last-running-attack-end-time) (-> self clock frame-counter)) + (target-exit) + (target-mech-exit) + (none) + ) + :code (behavior () + (set! (-> self mech forward-vel) (-> self control ctrl-xz-vel)) + 1.0 + (let ((s5-0 #f) + (gp-0 0) + (s4-0 30) + ) + (target-mech-punch-pick (the-as symbol gp-0)) + (until (ja-done? 0) + (compute-alignment! (-> self align)) + (when (and (not (logtest? (-> self focus-status) (focus-status dangerous))) + (let ((v1-10 (ja-group))) + (and v1-10 (or (= v1-10 (-> self draw art-group data 333)) + (= v1-10 (-> self draw art-group data 334)) + (= v1-10 (-> self draw art-group data 335)) + (= v1-10 (-> self draw art-group data 353)) + ) + ) + ) + (>= (ja-aframe-num 0) 12.0) + ) + (target-start-attack) + (target-danger-set! 'mech-punch #f) + ) + (when (and (cpad-pressed? (-> self control cpad number) circle square) (< gp-0 2)) + (let ((s3-0 (ja-group)) + (f30-0 (ja-aframe-num 0)) + ) + (if (or (and (= s3-0 (-> self draw art-group data 333)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 333)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-0 (-> self draw art-group data 334)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 334)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-0 (-> self draw art-group data 335)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 335)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-0 (-> self draw art-group data 353)) + (>= f30-0 2.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 353)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + ) + (set! s5-0 #t) + ) + ) + ) + (when s5-0 + (let ((s3-1 (ja-group)) + (f30-2 (ja-aframe-num 0)) + ) + (when (or (and (= s3-1 (-> self draw art-group data 333)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 333)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-1 (-> self draw art-group data 334)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 334)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-1 (-> self draw art-group data 335)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 335)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + (and (= s3-1 (-> self draw art-group data 353)) + (>= f30-2 21.0) + (>= (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 353)) frames num-frames) -1)) + (ja-frame-num 0) + ) + ) + ) + (+! gp-0 1) + (target-mech-punch-pick (the-as symbol gp-0)) + (set! (-> self state-time) (+ (-> self clock frame-counter) (seconds -0.465))) + (set! (-> self mech forward-vel) (fmax 0.0 (-> self mech forward-vel))) + (set! s4-0 159) + (set! s5-0 #f) + ) + ) + ) + (let ((v1-142 (- (-> self clock frame-counter) (-> self state-time))) + (s3-2 #t) + (f30-4 1.0) + ) + (cond + ((< (-> self mech forward-vel) 0.0) + (seek! (-> self mech forward-vel) -0.04096 (* 122880.0 (-> self clock seconds-per-frame))) + ) + ((let ((a0-43 (ja-group))) + (and a0-43 (or (= a0-43 (-> self draw art-group data 335)) (= a0-43 (-> self draw art-group data 353)))) + ) + (cond + ((< v1-142 (seconds 0.465)) + (set! s3-2 #f) + ) + ((< v1-142 (seconds 0.53)) + (set! (-> self mech forward-vel) (lerp-scale 40960.0 81920.0 (the float v1-142) 139.8 159.98999)) + ) + (else + (set! (-> self mech forward-vel) (lerp-scale 81920.0 0.0 (the float v1-142) 159.98999 300.0)) + ) + ) + ) + (else + (let ((a0-50 (ja-group))) + (cond + ((and a0-50 (= a0-50 (-> self draw art-group data 333))) + (cond + ((< v1-142 (seconds 0.465)) + (seek! (-> self mech forward-vel) 0.0 (* 20480.0 (-> self clock seconds-per-frame))) + (set! s3-2 #f) + ) + ((< v1-142 (seconds 0.53)) + (set! (-> self mech forward-vel) (lerp-scale 20480.0 40960.0 (the float v1-142) 139.8 159.98999)) + ) + (else + (set! (-> self mech forward-vel) (lerp-scale 40960.0 0.0 (the float v1-142) 159.98999 300.0)) + ) + ) + ) + ((< v1-142 (seconds 0.465)) + (seek! (-> self mech forward-vel) 0.0 (* 20480.0 (-> self clock seconds-per-frame))) + (set! s3-2 #f) + ) + ((< v1-142 (seconds 0.53)) + (set! (-> self mech forward-vel) (lerp-scale 20480.0 40960.0 (the float v1-142) 139.8 159.98999)) + ) + (else + (set! (-> self mech forward-vel) (lerp-scale 40960.0 0.0 (the float v1-142) 159.98999 300.0)) + ) + ) + ) + ) + ) + (set! s3-2 (and (>= (- (-> self clock frame-counter) (-> self state-time)) s4-0) + (and (>= (-> self mech forward-vel) 0.0) s3-2) + ) + ) + (set! (-> self mech state-impact? 0) s3-2) + (set-forward-vel (-> self mech forward-vel)) + (when (< 20480.0 (vector-length (-> self control transv))) + (do-effect (-> self skel effect) 'effect-slide-poof (ja-frame-num 0) 38) + (do-effect (-> self skel effect) 'effect-slide-poof (ja-frame-num 0) 31) + ) + (suspend) + (ja :num! (seek! max (* (-> self control current-surface align-speed) f30-4))) + ) + ) + ) + (go target-mech-stance) + (none) + ) + :post target-mech-post + ) + +;; failed to figure out what this is: +(defstate target-mech-falling (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (let ((v0-0 (target-mech-bonk-event-handler proc arg1 event-type event))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + ) + :enter (behavior ((arg0 symbol)) + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *mech-jump-mods*) + (set! (-> self mech jump-thrust) 0.0) + (let* ((v1-4 *game-info*) + (v0-0 (+ (-> v1-4 attack-id) 1)) + ) + (set! (-> v1-4 attack-id) v0-0) + (set! (-> self control target-attack-id) v0-0) + ) + (none) + ) + :exit (behavior () + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + (target-exit) + (target-mech-exit) + (none) + ) + :trans (behavior () + (local-vars (a0-0 none)) + (if (logtest? (-> self control status) (collide-status on-surface)) + (go target-mech-hit-ground (the-as symbol a0-0)) + ) + (let ((f0-0 (target-move-dist (-> *TARGET-bank* stuck-time))) + (v1-9 (ja-group)) + ) + (when (if (and (and v1-9 (= v1-9 (-> self draw art-group data 330))) + (< f0-0 (-> *TARGET-bank* stuck-distance)) + (and (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 2)) + (not (and *cheat-mode* (cpad-hold? (-> self control cpad number) r2))) + ) + ) + #t + ) + (logior! (-> self control status) (collide-status on-surface)) + (go target-mech-hit-ground 'stuck) + ) + ) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + (let ((f0-2 (-> self mech jump-thrust-fuel))) + (cond + ((cpad-hold? (-> self control cpad number) x) + (cond + ((= f0-2 0.0) + (seek! (-> self mech jump-thrust) 0.0 (* 245760.0 (-> self clock seconds-per-frame))) + ) + ((!= f0-2 (-> *TARGET-bank* mech-jump-thrust-fuel)) + (let ((f26-0 + (lerp-scale 122880.0 8192.0 (-> self mech jump-thrust-fuel) 600.0 (-> *TARGET-bank* mech-jump-thrust-fuel)) + ) + (f28-0 + (lerp-scale 409.6 8192.0 (-> self mech jump-thrust-fuel) 600.0 (-> *TARGET-bank* mech-jump-thrust-fuel)) + ) + ) + (seek! + (-> self mech jump-thrust) + (- (- (-> self control dynam gravity-length) f30-0) f26-0) + (* 8192000.0 (-> self clock seconds-per-frame)) + ) + (set! (-> self mech thruster-flame-width) (* 0.75 f28-0)) + (set! (-> self mech thruster-flame-length) f28-0) + ) + ) + (else + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 12288.0) + (set! (-> self mech thruster-flame-length) 20480.0) + ) + ) + (seek! + (-> self mech jump-thrust-fuel) + 0.0 + (the float (- (-> self clock frame-counter) (-> self clock old-frame-counter))) + ) + ) + (else + (seek! (-> self mech jump-thrust) 0.0 (* 491520.0 (-> self clock seconds-per-frame))) + (set! (-> self mech thruster-flame-width) (* 0.021428572 (-> self mech jump-thrust))) + (set! (-> self mech thruster-flame-length) (* 0.028571429 (-> self mech jump-thrust))) + ) + ) + ) + (let ((v1-85 (new-stack-vector0))) + (let ((f0-36 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-85 (-> self control transv) (vector-float*! v1-85 (-> self control dynam gravity-normal) f0-36)) + ) + (let* ((f0-37 (vector-length v1-85)) + (f1-9 f0-37) + (f2-2 (+ f30-0 (* (-> self mech jump-thrust) (-> self clock seconds-per-frame)))) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-2) + (vector-float*! v1-85 v1-85 (/ f0-37 f1-9)) + ) + ) + ) + ) + (none) + ) + :code (behavior ((arg0 symbol)) + (until #f + (cond + ((< 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (let ((v1-7 (ja-group))) + (when (not (and v1-7 (= v1-7 (-> self draw art-group data 329)))) + (ja-channel-push! 1 (seconds 0.1)) + (ja :group! (-> self draw art-group data 329) :num! min) + ) + ) + (suspend) + (ja :num! (loop! 0.75)) + ) + (else + (let ((v1-22 (ja-group))) + (when (not (and v1-22 (= v1-22 (-> self draw art-group data 330)))) + (ja-channel-push! 1 (seconds 0.5)) + (ja :group! (-> self draw art-group data 330) :num! min) + ) + ) + (suspend) + (ja :num! (loop!)) + ) + ) + ) + #f + (none) + ) + :post target-mech-post + ) + +;; failed to figure out what this is: +(defstate target-mech-jump (target) + :event (-> target-mech-falling event) + :enter (behavior ((arg0 float) (arg1 float) (arg2 surface)) + (set! (-> self state-time) (-> self clock frame-counter)) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (let* ((v1-4 *game-info*) + (a2-5 (+ (-> v1-4 attack-id) 1)) + ) + (set! (-> v1-4 attack-id) a2-5) + (set! (-> self control target-attack-id) a2-5) + ) + (set! (-> self mech jump-thrust) 0.0) + (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0) + (set! (-> self control unknown-symbol03) (the-as float arg2)) + (set! (-> self control mod-surface) *mech-jump-mods*) + (none) + ) + :exit (-> target-mech-falling exit) + :trans (-> target-mech-falling trans) + :code (behavior ((arg0 float) (arg1 float) (arg2 surface)) + (let ((v1-2 (ja-group))) + (if (and v1-2 (= v1-2 (-> self draw art-group data 331))) + (ja-channel-push! 1 (seconds 0.5)) + (ja-channel-push! 1 (seconds 0.05)) + ) + ) + ((the-as (function none) (-> target-mech-falling code))) + (none) + ) + :post target-mech-post + ) + +;; failed to figure out what this is: +(defstate target-mech-hit-ground (target) + :event target-mech-handler + :enter (behavior ((arg0 symbol)) + (let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-param)) + (set! (-> v1-0 id) (the-as sound-id (-> self mech thrust-sound-id))) + (set! (-> v1-0 params volume) -4) + (set! (-> v1-0 auto-time) 48) + (set! (-> v1-0 auto-from) 2) + (set! (-> v1-0 params mask) (the-as uint 17)) + (-> v1-0 id) + ) + (set! (-> self mech jump-thrust-fuel) (-> *TARGET-bank* mech-jump-thrust-fuel)) + (set! (-> self state-time) (-> self clock frame-counter)) + (cond + ((= arg0 'stuck) + ) + (else + (target-land-effect) + ) + ) + (set! (-> self control last-running-attack-end-time) 0) + (set! (-> self control last-attack-end-time) 0) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control mod-surface) *mech-stance-mods*) + (start-bobbing! + (-> self water) + (lerp-scale 0.0 4096.0 (-> self control ground-impact-vel) 40960.0 102400.0) + 600 + 1500 + ) + (activate! *camera-smush-control* 1638.4 15 75 1.0 0.9 (-> *display* camera-clock)) + (none) + ) + :exit (behavior () + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (target-mech-exit) + (none) + ) + :trans (behavior () + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-punch) + ) + (when (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.25)) + (if (move-legs?) + (go target-mech-walk) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go + target-mech-jump + (-> *TARGET-bank* mech-jump-height-min) + (-> *TARGET-bank* mech-jump-height-max) + (the-as surface #f) + ) + ) + (if (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons r1) + ) + (go target-mech-carry-pickup) + ) + ) + (set-forward-vel 0.0) + (none) + ) + :code (behavior ((arg0 symbol)) + (target-hit-ground-anim #f (are-still?)) + (go target-mech-stance) + (none) + ) + :post target-mech-post + ) + +;; failed to figure out what this is: +(defstate target-mech-hit (target) + :event target-mech-handler + :exit (behavior () + ((-> target-hit exit)) + (target-mech-exit) + (none) + ) + :trans (behavior () + (when (= *cheat-mode* 'debug) + (when (and (not *pause-lock*) (cpad-hold? (-> self control cpad number) r2)) + (set! (-> self control time-of-last-debug-heal) (-> self clock frame-counter)) + (pickup-collectable! (-> self fact-override) (pickup-type health) 100.0 (the-as handle #f)) + (go target-mech-stance) + ) + ) + (none) + ) + :code (behavior ((arg0 symbol) (arg1 attack-info)) + (logclear! (-> self water flags) (water-flags jump-out)) + (set! (-> self state-time) (-> self clock frame-counter)) + (let ((gp-0 (-> self attack-info)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((v1-4 gp-0)) + (set! (-> v1-4 attacker) (the-as handle #f)) + (set! (-> v1-4 mode) 'generic) + (set! (-> v1-4 shove-back) 10240.0) + (set! (-> v1-4 shove-up) 6144.0) + (set! (-> v1-4 angle) #f) + (set! (-> v1-4 trans quad) (-> self control trans quad)) + (set! (-> v1-4 control) 0.0) + (set! (-> v1-4 invinc-time) (the-as time-frame (-> *TARGET-bank* hit-invulnerable-timeout))) + ) + (case arg0 + (('shove) + (let ((v1-7 gp-0)) + (set! (-> v1-7 shove-back) (-> *TARGET-bank* smack-surface-dist)) + (set! (-> v1-7 shove-up) (-> *TARGET-bank* smack-surface-height)) + (set! (-> v1-7 angle) 'shove) + ) + ) + ) + (combine! gp-0 arg1 self) + (when (not (logtest? (-> gp-0 mask) (attack-info-mask vector))) + (vector-z-quaternion! (-> gp-0 vector) (-> self control quat-for-control)) + (vector-xz-normalize! (-> gp-0 vector) (- (fabs (-> gp-0 shove-back)))) + (set! (-> gp-0 vector y) (-> gp-0 shove-up)) + ) + (set! (-> s5-0 quad) (-> gp-0 vector quad)) + (let ((f0-10 (vector-dot + (vector-normalize-copy! (new 'stack-no-clear 'vector) s5-0 1.0) + (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self control quat-for-control)) + ) + ) + ) + (if (not (-> self attack-info angle)) + (set! (-> self attack-info angle) (if (>= 0.0 f0-10) + 'front + 'back + ) + ) + ) + ) + (cond + ((= arg0 'attack) + (logior! (-> self focus-status) (focus-status hit)) + (set! (-> self game hit-time) (-> self clock frame-counter)) + (case (-> gp-0 mode) + (('endlessfall) + (cond + ((= (-> self game mode) 'debug) + (let ((s4-1 (new-stack-vector0))) + (set! (-> s4-1 quad) (-> self control last-trans-on-ground quad)) + (ja-channel-set! 0) + (let ((s3-1 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s3-1) (seconds 1)) + (suspend) + ) + ) + (move-to-point! (-> self control) s4-1) + ) + (set! (-> self control camera-pos quad) (-> self control trans quad)) + (send-event *camera* 'teleport) + (go target-mech-stance) + ) + (else + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) + (go target-mech-death (-> gp-0 mode)) + ) + ) + ) + ) + (target-hit-effect gp-0) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) + (go target-mech-death (-> gp-0 mode)) + ) + (else + (case (-> gp-0 mode) + (('burn 'burnup) + (sound-play "get-burned") + ) + ) + ) + ) + (set! (-> self control mod-surface) *smack-mods*) + (let ((v1-63 (ja-group))) + (when (not (and v1-63 (= v1-63 (-> self draw art-group data 348)))) + (ja-channel-push! 1 (seconds 0.075)) + (ja :group! (-> self draw art-group data 348) :num! min) + ) + ) + (target-hit-move gp-0 (target-hit-orient gp-0 s5-0) target-mech-falling-anim-trans 1.0) + ) + (go target-mech-hit-ground #f) + (none) + ) + :post (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)) + (vector-float*! + (-> self control dynam gravity) + (-> self control dynam gravity-normal) + (the-as float (-> self control dynam gravity-length)) + ) + (target-mech-post) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate target-mech-death (target) + :event (-> target-death event) + :exit (behavior () + (set! (-> self mech stick-off) #f) + (target-mech-exit) + ((-> target-death exit)) + (none) + ) + :trans (-> target-mech-hit trans) + :code (behavior ((arg0 symbol)) + (set! (-> self mech stick-off) (the-as basic #t)) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control did-move-to-pole-or-max-jump-height) + (the-as float (send-event (handle->process (-> self attack-info attacker)) 'target 'die arg0)) + ) + (set! (-> self neck flex-blend) 0.0) + (target-timed-invulnerable-off self 0) + (target-timed-invulnerable-off self 0) + (set-setting! 'process-mask 'set 0 (process-mask platform projectile death)) + (apply-settings *setting-control*) + (set! (-> self control transv quad) (the-as uint128 0)) + (logior! (-> self focus-status) (focus-status dead)) + (cond + ((or (= arg0 'none) (= arg0 'instant-death) (= arg0 'bot) (= arg0 'big-explosion)) + ) + ((= arg0 'grenade) + (sound-play "explosion") + ) + ((= arg0 'endlessfall) + (sound-play "mech-death-fall") + (set! (-> self control unknown-sound-id00) + (add-process *gui-control* *target* (gui-channel daxter) (gui-action play) "jakfall" -99.0 0) + ) + (set-falloff! *gui-control* (-> self control unknown-sound-id00) #t -1 100 2) + (set-setting! 'mode-name 'cam-endlessfall 0 0) + (set! (-> self control pat-ignore-mask) + (logior (new 'static 'pat-surface :noendlessfall #x1) (-> self control pat-ignore-mask)) + ) + (logclear! (-> self water flags) (water-flags swim-ground)) + (let ((f0-2 (fmin -4096.0 (- (-> self control ground-impact-vel))))) + (set! (-> self control unknown-word04) (the-as uint f0-2)) + (let ((v1-45 (new-stack-vector0))) + (let ((f1-3 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-45 (-> self control transv) (vector-float*! v1-45 (-> self control dynam gravity-normal) f1-3)) + ) + (let* ((f1-4 (vector-length v1-45)) + (f2-1 f1-4) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f0-2) + (vector-float*! v1-45 v1-45 (/ f1-4 f2-1)) + ) + ) + ) + ) + (set! (-> self trans-hook) + (lambda :behavior target + () + (vector-seek! (-> self draw color-mult) *zero-vector* (-> self clock seconds-per-frame)) + (let ((v1-2 (new-stack-vector0)) + (f0-2 (the-as number (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + ) + 0.0 + (vector-! + v1-2 + (-> self control transv) + (vector-float*! v1-2 (-> self control dynam gravity-normal) (the-as float f0-2)) + ) + (let* ((f1-2 (vector-length v1-2)) + (f2-0 f1-2) + ) + (if (< (the-as float (-> self control unknown-word04)) (the-as float f0-2)) + (set! f0-2 (-> self control unknown-word04)) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) (the-as float f0-2)) + (vector-float*! v1-2 v1-2 (/ f1-2 f2-0)) + ) + ) + ) + ((-> target-mech-hit trans)) + (none) + ) + ) + (ja-channel-push! 1 (seconds 0.3)) + (ja-no-eval :group! (-> self draw art-group data 330) :num! (loop! 0.5) :frame-num 0.0) + (let ((gp-3 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) gp-3) (seconds 0.8)) + (ja :group! (-> self draw art-group data 330) :num! (loop! 0.5)) + (suspend) + ) + ) + (remove-setting! 'mode-name) + ) + (else + (set! (-> self control mod-surface) *empty-mods*) + (rot->dir-targ! (-> self control)) + (remove-setting! 'slave-options) + (remove-setting! 'fov) + (remove-setting! 'head-offset) + (send-event *camera* 'set-dist #f #f) + (set! (-> self burn-proc) + (ppointer->handle + (process-spawn-function process process-drawable-burn-effect 1200 :to (ppointer->process (-> self manipy))) + ) + ) + (let ((gp-5 (if (zero? (rand-vu-int-count 2)) + (-> self draw art-group data 351) + (-> self draw art-group data 352) + ) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (let ((f30-0 (if (logtest? (-> self water flags) (water-flags under-water)) + 0.55 + 1.0 + ) + ) + ) + (ja-no-eval :group! gp-5 + :num! (seek! (the float (+ (-> (the-as art-joint-anim gp-5) frames num-frames) -1)) f30-0) + :frame-num 0.0 + ) + (until (ja-done? 0) + (when (>= (- (-> *display* game-clock frame-counter) (-> self shock-effect-time)) (seconds 0.03)) + (set! (-> self shock-effect-time) (-> *display* game-clock frame-counter)) + (process-drawable-shock-effect + (the-as process-drawable (ppointer->process (-> self manipy))) + (-> *lightning-spec-id-table* 1) + lightning-probe-callback + (-> *part-id-table* 166) + 0 + 0 + 40960.0 + ) + ) + (suspend) + (ja :num! (seek! max f30-0)) + ) + ) + ) + (sound-play "mech-eject") + (let ((gp-7 (get-process *default-dead-pool* part-tracker #x4000))) + (when gp-7 + (let ((t9-33 (method-of-type part-tracker activate))) + (t9-33 (the-as part-tracker gp-7) self (symbol->string (-> part-tracker symbol)) (the-as pointer #x70004000)) + ) + (let ((t9-34 run-function-in-process) + (a0-72 gp-7) + (a1-35 part-tracker-init) + (a2-31 (-> *part-group-id-table* 202)) + (a3-13 0) + (t0-8 #f) + (t1-8 #f) + (t2-5 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-34) + a0-72 + a1-35 + a2-31 + a3-13 + t0-8 + t1-8 + t2-5 + t3-0 + ) + ) + (-> gp-7 ppointer) + ) + ) + (rot->dir-targ! (-> self control)) + (ja-post) + (let ((gp-8 (new 'stack 'joint-exploder-tuning (the-as uint 0)))) + (cond + ((logtest? (-> self water flags) (water-flags under-water)) + (set! (-> gp-8 duration) (seconds 8)) + (set! (-> gp-8 gravity) -20480.0) + (set! (-> gp-8 rot-speed) 4.2) + (set-vector! (-> gp-8 fountain-rand-transv-lo) -20480.0 12288.0 -20480.0 1.0) + (set-vector! (-> gp-8 fountain-rand-transv-hi) 20480.0 24576.0 20480.0 1.0) + ) + (else + (set! (-> gp-8 gravity) -204800.0) + (set-vector! (-> gp-8 fountain-rand-transv-lo) -61440.0 12288.0 -61440.0 1.0) + (set-vector! (-> gp-8 fountain-rand-transv-hi) 61440.0 49152.0 61440.0 1.0) + ) + ) + (process-spawn + joint-exploder + (art-group-get-by-name *level* "skel-mech-explode" (the-as (pointer uint32) #f)) + 41 + gp-8 + *mech-exploder-params* + :to (ppointer->process (-> self manipy)) + ) + ) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (logior! (-> self state-flags) (state-flags sf6)) + (set! (-> self alt-cam-pos quad) (-> self control trans quad)) + (set! (-> self post-hook) target-no-move-post) + (ja-channel-set! 1) + (ja-no-eval :group! (-> self draw art-group data 70) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 70)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (set! (-> self control transv quad) (the-as uint128 0)) + (vector-seek! + (-> self draw color-mult) + (new 'static 'vector :x 0.5 :y 0.5 :z 0.5 :w 1.0) + (* 5.0 (-> self clock seconds-per-frame)) + ) + (suspend) + (ja :num! (seek!)) + ) + (let ((gp-9 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) gp-9) (seconds 2)) + (suspend) + ) + ) + ) + ) + (set! (-> self control transv quad) (the-as uint128 0)) + (initialize! (-> self game) 'life (the-as game-save #f) (the-as string #f)) + (if (!= (-> self game mode) 'play) + (go target-jump 16384.0 16384.0 (the-as surface #f)) + ) + (set! (-> self state-time) (-> self clock frame-counter)) + (sleep-code) + (none) + ) + :post target-mech-post + ) + +;; definition for function target-mech-carry-update +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior target-mech-carry-update target () + (carry-info-method-9 (-> self carry)) + (when (and (= (-> self control collide-mode) 'mech-carry) (< (-> self control collide-mode-transition) 1.0)) + (let ((gp-0 (new 'stack-no-clear 'collide-query)) + (s5-0 (new 'stack-no-clear 'sphere)) + ) + (dotimes (s4-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s5-0) (* s4-0 16))) sphere) + ) + (let ((f30-0 (seek (-> self control collide-mode-transition) 1.0 (* 0.1 (-> self clock time-adjust-ratio))))) + (set! (-> (the-as sphere (&-> s5-0 x)) quad) + (-> self control collision-spheres 2 prim-core world-sphere quad) + ) + (set! (-> s5-0 r) (lerp-scale (-> *TARGET-bank* body-radius) 11468.8 f30-0 0.0 1.0)) + (let ((v1-17 gp-0)) + (set! (-> v1-17 best-dist) (the-as float s5-0)) + (set! (-> v1-17 num-spheres) (the-as uint 1)) + (set! (-> v1-17 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-17 ignore-process0) #f) + (set! (-> v1-17 ignore-process1) #f) + (set! (-> v1-17 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-17 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-17 action-mask) (collide-action solid)) + ) + (if (not (fill-and-probe-using-spheres *collide-cache* gp-0)) + (target-collide-set! 'mech-carry f30-0) + ) + ) + ) + ) + (send-event (handle->process (-> self carry other)) 'carry (-> self carry)) + (none) + ) + +;; definition for function target-mech-carry-post +(defbehavior target-mech-carry-post target () + (set! (-> self focus-status) (logior (focus-status carry) (-> self focus-status))) + (target-mech-post) + (target-mech-carry-update) + (none) + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-pickup (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('touched) + (cond + (((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> event param 0)) + (-> self control) + (the-as uint 1920) + ) + (let ((a1-2 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-2 from) (process->ppointer self)) + (set! (-> a1-2 num-params) 0) + (set! (-> a1-2 message) 'carry?) + (let ((a1-3 (send-event-function proc a1-2))) + (when a1-3 + (let ((f0-0 (distance-from-destination (-> self carry) (the-as carry-info a1-3)))) + (when (and (>= f0-0 0.0) (< f0-0 (-> self carry other-value))) + (set! (-> self carry other) (process->handle proc)) + (set! (-> self carry other-value) f0-0) + ) + ) + ) + ) + ) + #f + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + (('change-mode 'end-mode) + #f + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-pickup-mods*) + (set! (-> self mech stick-off) (the-as basic #t)) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (set! (-> self carry other) (the-as handle #f)) + (set! (-> self carry other-value) 100000000000.0) + (set! (-> self carry max-distance) 32768.0) + (set! (-> self carry mode) (carry-mode carry mech-carry mech-drag)) + (carry-info-method-9 (-> self carry)) + (none) + ) + :exit (behavior () + (when (not (and (-> self next-state) (let ((v1-3 (-> self next-state name))) + (or (= v1-3 'target-mech-carry-stance) + (= v1-3 'target-mech-carry-walk) + (= v1-3 'target-mech-carry-drop) + (= v1-3 'target-mech-carry-throw) + (= v1-3 'target-mech-carry-jump) + (= v1-3 'target-mech-carry-falling) + (= v1-3 'target-mech-carry-hit-ground) + (= v1-3 'target-mech-carry-throw) + (= v1-3 'target-mech-carry-drag) + ) + ) + ) + ) + (logclear! (-> self focus-status) (focus-status carry)) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'mech 0.0) + (target-exit) + ) + (set! (-> self mech stick-off) #f) + (target-mech-exit) + (none) + ) + :code (behavior () + (let ((f30-0 0.0) + (f28-0 0.0) + (gp-0 #f) + ) + (ja-channel-push! 2 1) + (ja :group! (-> self draw art-group data 337) :num! min) + (let ((a0-2 (-> self skel root-channel 1))) + (set! (-> a0-2 frame-interp 1) f30-0) + (set! (-> a0-2 frame-interp 0) f30-0) + (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 336))) + (set! (-> a0-2 param 0) 0.0) + (joint-control-channel-group-eval! + a0-2 + (the-as art-joint-anim (-> self draw art-group data 336)) + num-func-chan + ) + ) + (suspend) + (ja :num! (seek!)) + (ja :chan 1 :num! (chan 0)) + (target-danger-set! 'carry? #f) + (suspend) + (ja :num! (seek!)) + (ja :chan 1 :num! (chan 0)) + (format #t "carry picked ~A~%" (handle->process (-> self carry other))) + (let ((a1-9 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-9 from) (process->ppointer self)) + (set! (-> a1-9 num-params) 0) + (set! (-> a1-9 message) 'carry-info) + (let ((s5-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-9)))) + (cond + (s5-1 + (let* ((s4-1 (vector-! (new 'stack-no-clear 'vector) (-> s5-1 point) (-> self control trans))) + (s3-0 (new-stack-vector0)) + (f26-0 (vector-dot (-> self control local-normal) s4-1)) + ) + 0.0 + (vector-! s3-0 s4-1 (vector-float*! s3-0 (-> self control local-normal) f26-0)) + (let* ((f24-0 (vector-length s3-0)) + (f22-0 f24-0) + ) + (set! f28-0 (lerp-scale 1.0 0.0 f26-0 3072.0 7168.0)) + (vector+! + s4-1 + (vector-float*! s4-1 (-> self control local-normal) f26-0) + (vector-float*! s3-0 s3-0 (/ f24-0 f22-0)) + ) + ) + ) + (cond + ((logtest? (-> s5-1 mode) (carry-mode mech-drag)) + (sound-play "mech-drag-pikup") + (let ((s4-5 (vector-! (new 'stack-no-clear 'vector) (-> self carry point) (-> s5-1 point)))) + (set! gp-0 #t) + (vector-xz-normalize! s4-5 (-> s5-1 max-pull)) + (vector+! s4-5 s4-5 (-> s5-1 point)) + ) + (let* ((f26-1 (y-angle (-> s5-1 process 0 control))) + (f0-15 (vector-y-angle (vector-! (new 'stack-no-clear 'vector) (-> s5-1 point) (-> self carry point)))) + (f0-21 (the float (the int (* 0.000061035156 (+ 73728.0 (deg- f0-15 f26-1)))))) + (s5-2 (new 'stack-no-clear 'vector)) + ) + (set! (-> self carry face-dir) (the int f0-21)) + (let ((f24-2 (the float (sar (shl (the int (* 16384.0 f0-21)) 48) 48)))) + (set! (-> self control unknown-word04) (the-as uint (+ f26-1 f24-2))) + (set-vector! s5-2 (sin (+ f26-1 f24-2)) 0.0 (cos (+ f26-1 f24-2)) 1.0) + ) + (forward-up-nopitch->quaternion + (-> self control dir-targ) + s5-2 + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + (else + (sound-play "mech-drag-pikup") + (forward-up-nopitch->quaternion + (-> self control dir-targ) + (vector-normalize! (vector-! (new-stack-vector0) (-> s5-1 point) (-> self control trans)) 1.0) + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + ) + (else + (sound-play "mech-pickup-1") + ) + ) + ) + ) + (target-danger-set! 'harmless #f) + (cond + (gp-0 + (ja-channel-push! 1 (seconds 0.01)) + (ja-no-eval :group! (-> self draw art-group data 347) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 347)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :num! (seek! (ja-aframe 8.0 0))) + (while (not (ja-done? 0)) + (set! f30-0 (seek f30-0 f28-0 (* 5.0 (-> self clock seconds-per-frame)))) + (let ((v1-120 (-> self skel root-channel 1))) + (set! (-> v1-120 frame-interp 1) f30-0) + (set! (-> v1-120 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + ) + ) + (let ((s4-11 (new 'stack-no-clear 'vector)) + (s5-6 (new 'stack-no-clear 'vector)) + ) + (when (send-event (handle->process (-> self carry other)) 'pickup (-> self carry) s4-11 s5-6) + (target-collide-set! 'mech-carry 0.0) + (when gp-0 + (sound-play "mech-drag-grab") + (let ((s3-6 (vector-! (new 'stack-no-clear 'vector) s4-11 (-> self control trans))) + (a1-37 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-37 from) (process->ppointer self)) + (set! (-> a1-37 num-params) 0) + (set! (-> a1-37 message) 'carry-info) + (let ((s4-12 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-37)))) + (vector-flatten! s3-6 s3-6 s5-6) + (let ((f0-43 (vector-length s3-6))) + (when (< 1228.8 f0-43) + (vector-normalize! s3-6 (+ -1228.8 f0-43)) + (move-by-vector! (-> self control) s3-6) + (vector+! (-> s4-12 hold-trans) (-> s4-12 hold-trans) s3-6) + ) + ) + ) + ) + (set-yaw-angle-clear-roll-pitch! (-> self control) (the-as float (-> self control unknown-word04))) + (rot->dir-targ! (-> self control)) + (go target-mech-carry-drag) + ) + (sound-play "mech-servo-up") + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (set! f30-0 (seek f30-0 f28-0 (* 5.0 (-> self clock seconds-per-frame)))) + (let ((v1-174 (-> self skel root-channel 1))) + (set! (-> v1-174 frame-interp 1) f30-0) + (set! (-> v1-174 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + (go target-mech-carry-stance) + ) + ) + (cond + (gp-0 + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + ) + (else + (ja-no-eval :num! (seek! (ja-aframe 11.0 0))) + (while (not (ja-done? 0)) + (let ((v1-190 (-> self skel root-channel 1))) + (set! (-> v1-190 frame-interp 1) f30-0) + (set! (-> v1-190 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + (suspend) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (let ((v1-199 (-> self skel root-channel 1))) + (set! (-> v1-199 frame-interp 1) f30-0) + (set! (-> v1-199 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + ) + ) + ) + (go target-mech-stance) + (none) + ) + :post (behavior () + (target-mech-post) + (carry-info-method-9 (-> self carry)) + (target-mech-carry-update) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-drop (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('change-mode 'end-mode) + #f + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (set! (-> self mech stick-off) (the-as basic #t)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :code (behavior () + (let ((f30-0 1.0) + (gp-1 (sound-play "mech-servo-down")) + ) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) (process->ppointer self)) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'carry-info) + (let ((a0-8 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-1)))) + (when a0-8 + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> a0-8 point quad)) + (set! (-> s5-1 y) (- (-> s5-1 y) (-> a0-8 process 0 control root-prim prim-core world-sphere w))) + (let ((s4-0 (new-stack-vector0)) + (f28-0 (vector-dot (-> self control local-normal) s5-1)) + ) + 0.0 + (vector-! s4-0 s5-1 (vector-float*! s4-0 (-> self control local-normal) f28-0)) + (let* ((f26-0 (vector-length s4-0)) + (f24-0 f26-0) + ) + (set! f30-0 (lerp-scale 1.0 0.0 f28-0 3072.0 7168.0)) + (vector+! + s5-1 + (vector-float*! s5-1 (-> self control local-normal) f28-0) + (vector-float*! s4-0 s4-0 (/ f26-0 f24-0)) + ) + ) + ) + ) + ) + ) + ) + (ja-channel-push! 2 (seconds 0.1)) + (ja :group! (-> self draw art-group data 337) + :num! (identity (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 337)) frames num-frames) -1))) + ) + (let ((a0-19 (-> self skel root-channel 1))) + (set! (-> a0-19 frame-interp 1) f30-0) + (set! (-> a0-19 frame-interp 0) f30-0) + (set! (-> a0-19 frame-group) (the-as art-joint-anim (-> self draw art-group data 336))) + (set! (-> a0-19 param 0) 0.0) + (joint-control-channel-group-eval! + a0-19 + (the-as art-joint-anim (-> self draw art-group data 336)) + num-func-chan + ) + ) + (suspend) + (ja-no-eval :num! (seek! (ja-aframe 8.0 0))) + (while (not (ja-done? 0)) + (let ((a1-10 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-10 from) (process->ppointer self)) + (set! (-> a1-10 num-params) 0) + (set! (-> a1-10 message) 'carry-info) + (let ((s5-5 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-10)))) + (when s5-5 + (if (< 20.0 (ja-aframe-num 0)) + (seek! (-> s5-5 grab-trans-blend) 1.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + (let ((s3-0 (-> s5-5 process 0 control)) + (s5-6 (new 'stack-no-clear 'collide-query)) + ) + (let ((s4-1 (new 'stack-no-clear 'sphere))) + (dotimes (s2-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s4-1) (* s2-0 16))) sphere) + ) + (set! (-> (the-as sphere (&-> s4-1 x)) quad) (-> s3-0 root-prim prim-core world-sphere quad)) + (let ((v1-66 s5-6)) + (set! (-> v1-66 best-dist) (the-as float s4-1)) + (set! (-> v1-66 num-spheres) (the-as uint 1)) + (set! (-> v1-66 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-66 ignore-process0) #f) + (set! (-> v1-66 ignore-process1) #f) + (set! (-> v1-66 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-66 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-66 action-mask) (collide-action solid)) + ) + ) + (when (fill-and-probe-using-spheres *collide-cache* s5-6) + (sound-play "mech-setdown") + (let ((v1-71 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-71 command) (sound-command set-param)) + (set! (-> v1-71 id) gp-1) + (set! (-> v1-71 params volume) -4) + (set! (-> v1-71 auto-time) 48) + (set! (-> v1-71 auto-from) 2) + (set! (-> v1-71 params mask) (the-as uint 17)) + (-> v1-71 id) + ) + (set! gp-1 (sound-play "mech-servo-up")) + (let ((v1-75 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-75 command) (sound-command set-param)) + (set! (-> v1-75 id) gp-1) + (set! (-> v1-75 params volume) -4) + (set! (-> v1-75 auto-time) 192) + (set! (-> v1-75 auto-from) 2) + (set! (-> v1-75 params mask) (the-as uint 17)) + (-> v1-75 id) + ) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-carry-stance) + ) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + ) + (sound-play "mech-setdown") + (let ((v1-91 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 0.0))) + (vector+float*! v1-91 v1-91 (-> self control c-R-w vector 2) 20480.0) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-91) + ) + (target-collide-set! 'mech 0.0) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-stance) + (none) + ) + :post (-> target-mech-carry-pickup post) + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-stance (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('change-mode) + (case (-> event param 0) + (('falling) + (if (and (-> self next-state) (= (-> self next-state name) 'target-mech-carry-drag)) + #f + (go target-mech-carry-falling) + ) + ) + (('grab) + (if (not (-> event param 1)) + #t + (go target-mech-grab) + ) + ) + ) + ) + (else + (target-mech-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-stance-mods*) + (set! (-> self control mod-surface turnvv) 20024.889) + (set! (-> self control did-move-to-pole-or-max-jump-height) 0.0) + (rot->dir-targ! (-> self control)) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (behavior () + ((-> target-mech-carry-pickup exit)) + (rot->dir-targ! (-> self control)) + (none) + ) + :trans (behavior () + (if (and (move-legs?) + (and (< (fabs + (deg-diff (quaternion-y-angle (-> self control dir-targ)) (vector-y-angle (-> self control to-target-pt-xz))) + ) + 1820.4445 + ) + (>= (- (-> self clock frame-counter) (-> self control time-of-last-zero-input)) (seconds 0.05)) + ) + ) + (go target-mech-carry-walk) + ) + (if (and (cpad-pressed? (-> self control cpad number) r1) + (>= (- (-> self clock frame-counter) (-> self carry pickup-time)) (seconds 0.1)) + ) + (go target-mech-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-24 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-3 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-24 a1-3) + ) + ) + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-carry-throw) + ) + (fall-test (the-as (state symbol target) target-mech-carry-falling) (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 344)))) + (ja-channel-push! 2 (seconds 0.2)) + (ja :group! (-> self draw art-group data 344) :dist 8192.0) + (ja :chan 1 :group! (-> self draw art-group data 338) :dist 0.0) + ) + ) + (let ((f30-0 0.0)) + (until #f + (let ((f28-0 (y-angle (-> self control)))) + (deg-diff f28-0 (quaternion-y-angle (-> self control dir-targ))) + (suspend) + (let ((f28-1 (* (deg-diff f28-0 (y-angle (-> self control))) (-> self clock frames-per-second)))) + (set! f30-0 (if (< 910.2222 (fabs f28-1)) + (seek f30-0 1.0 (* 16.0 (-> self clock seconds-per-frame))) + (seek f30-0 0.0 (* 6.0 (-> self clock seconds-per-frame))) + ) + ) + (let* ((f0-9 (current-cycle-distance (-> self skel))) + (v1-26 (if (= f0-9 0.0) + 0.0 + (/ f28-1 f0-9) + ) + ) + (f0-11 v1-26) + ) + (ja :num! (loop! f0-11)) + ) + ) + ) + (let ((v1-32 (-> self skel root-channel 1)) + (f0-13 (- 1.0 f30-0)) + ) + (set! (-> v1-32 frame-interp 1) f0-13) + (set! (-> v1-32 frame-interp 0) f0-13) + ) + ) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-walk (target) + :event (-> target-mech-carry-stance event) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *mech-carry-walk-mods*) + (set! (-> self control unknown-word04) (the-as uint 0.0)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :trans (behavior () + (let ((gp-0 (ja-group)) + (f0-0 (ja-aframe-num 0)) + ) + (when (if (or (and (= gp-0 (-> self draw art-group data 339)) (>= f0-0 5.5) (>= 9.5 f0-0)) + (and (= gp-0 (-> self draw art-group data 339)) (>= f0-0 20.5) (>= 24.5 f0-0)) + ) + #t + ) + (when (and (< 5.0 (the-as float (-> self control unknown-word04))) + (= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + ) + (set-forward-vel 0.0) + (go target-mech-carry-stance) + ) + ) + ) + (if (and (cpad-pressed? (-> self control cpad number) r1) + (>= (- (-> self clock frame-counter) (-> self carry pickup-time)) (seconds 0.1)) + ) + (go target-mech-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-24 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-24 a1-2) + ) + ) + (if (and (cpad-pressed? (-> self control cpad number) circle square) (can-hands? #t)) + (go target-mech-carry-throw) + ) + (fall-test (the-as (state symbol target) target-mech-carry-falling) (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior () + (let ((f30-0 0.0)) + (let ((f28-0 (cond + ((zero? (-> self mech walk-anim-leg)) + (set! (-> self mech walk-anim-leg) 1) + 7.0 + ) + (else + (set! (-> self mech walk-anim-leg) 0) + 22.0 + ) + ) + ) + (v1-7 (ja-group)) + ) + (when (not (and v1-7 (= v1-7 (-> self draw art-group data 339)))) + (ja-channel-push! 2 (seconds 0.1)) + (ja :group! (-> self draw art-group data 339) + :num! (identity (ja-aframe f28-0 0)) + :dist (-> *TARGET-bank* mech-walk-cycle-dist) + ) + (ja :chan 1 :group! (-> self draw art-group data 338) :dist 0.0) + ) + ) + (until #f + (if (< (-> self control ctrl-xz-vel) 4096.0) + (set-forward-vel 4096.0) + ) + (suspend) + (let* ((f0-4 (current-cycle-distance (-> self skel))) + (f28-1 (/ (-> self control ctrl-xz-vel) f0-4)) + ) + (set! (-> self control unknown-word04) + (the-as uint (+ (the-as float (-> self control unknown-word04)) f28-1)) + ) + (set! f30-0 (seek + f30-0 + (lerp-scale 1.0 0.0 (-> self control ctrl-xz-vel) 0.0 8192.0) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (ja :num! (loop! f28-1)) + ) + (let ((a0-16 (-> self skel root-channel 1))) + (set! (-> a0-16 frame-interp 1) f30-0) + (set! (-> a0-16 frame-interp 0) f30-0) + (set! (-> a0-16 param 0) 0.0) + (joint-control-channel-group-eval! a0-16 (the-as art-joint-anim #f) num-func-chan) + ) + ) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-drag (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('push) + (when (zero? (-> self control sliding-start-time)) + (set! (-> self control sliding-start-time) + (+ (-> self clock frame-counter) (the-as time-frame (-> event param 0))) + ) + (let ((v0-0 (the-as object #t))) + (set! (-> self control unknown-word04) (the-as uint v0-0)) + v0-0 + ) + ) + ) + (('drop) + (logclear! (-> *cpad-list* cpads (-> self control cpad number) button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) (pad-buttons r1)) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'mech 0.0) + (go target-mech-stance) + ) + (else + ((-> target-mech-carry-stance event) proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control sliding-start-time) 0) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control mod-surface) *mech-carry-drag-mods*) + (set-forward-vel 0.0) + (none) + ) + :exit (behavior () + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + (let ((v1-3 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-3 command) (sound-command set-param)) + (set! (-> v1-3 id) (the-as sound-id (-> self mech thrust-sound-id))) + (set! (-> v1-3 params volume) -4) + (set! (-> v1-3 auto-time) 48) + (set! (-> v1-3 auto-from) 2) + (set! (-> v1-3 params mask) (the-as uint 17)) + (-> v1-3 id) + ) + (let ((v1-5 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-5 command) (sound-command set-param)) + (set! (-> v1-5 id) (the-as sound-id (-> self mech drag-sound-id))) + (set! (-> v1-5 params volume) -4) + (set! (-> v1-5 auto-time) 48) + (set! (-> v1-5 auto-from) 2) + (set! (-> v1-5 params mask) (the-as uint 17)) + (-> v1-5 id) + ) + ((-> target-mech-carry-pickup exit)) + (none) + ) + :trans (behavior () + (when (and (not (cpad-hold? (-> self control cpad number) r1)) + (>= (- (-> self clock frame-counter) (-> self carry pickup-time)) (seconds 0.5)) + ) + (sound-play "mech-drag-off") + (if (or (and (>= (-> self mech back-touch-time) (-> self state-time)) + (< (vector-vector-distance (-> self control trans) (-> self mech back-touch-trans)) 4096.0) + ) + (let ((gp-1 (new 'stack-no-clear 'collide-query))) + (let ((s5-1 (new 'stack-no-clear 'sphere))) + (dotimes (s4-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s5-1) (* s4-0 16))) sphere) + ) + (set! (-> (the-as sphere (&-> s5-1 x)) quad) + (-> self control collision-spheres 0 prim-core world-sphere quad) + ) + (vector+float*! + (the-as vector (&-> s5-1 x)) + (the-as vector (&-> s5-1 x)) + (-> self control c-R-w vector 2) + -4096.0 + ) + (set! (-> s5-1 r) (-> self control collision-spheres 0 prim-core world-sphere w)) + (let ((v1-30 gp-1)) + (set! (-> v1-30 best-dist) (the-as float s5-1)) + (set! (-> v1-30 num-spheres) (the-as uint 1)) + (set! (-> v1-30 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-30 ignore-process0) #f) + (set! (-> v1-30 ignore-process1) #f) + (set! (-> v1-30 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-30 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-30 action-mask) (collide-action solid)) + ) + ) + (fill-and-probe-using-spheres *collide-cache* gp-1) + ) + ) + (send-event self 'push 150) + (send-event self 'drop) + ) + ) + (none) + ) + :code (behavior () + (let ((f28-0 0.0) + (f30-0 0.0) + ) + (until #f + (let ((f0-2 + (* (vector-dot (-> self control to-target-pt-xz) (-> self control c-R-w vector 2)) + (-> self control turn-to-magnitude) + ) + ) + (f26-0 0.0) + ) + (if (and (nonzero? (-> self control sliding-start-time)) + (< (-> self control sliding-start-time) (-> self clock frame-counter)) + ) + (send-event self 'drop) + (set! f28-0 + (cond + ((nonzero? (-> self control sliding-start-time)) + (let ((v1-17 (ja-group))) + (when (not (and v1-17 (= v1-17 (-> self draw art-group data 345)))) + (let ((v1-23 (ja-group))) + (if (and v1-23 (= v1-23 (-> self draw art-group data 346))) + (set! f26-0 (ja-aframe-num 0)) + ) + ) + (sound-play "mech-drag-push") + (ja-channel-push! 1 (seconds 0.3)) + (ja :group! (-> self draw art-group data 345) :num! (identity (ja-aframe f26-0 0)) :dist 16384.0) + ) + ) + (when (-> self control unknown-spool-anim00) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! f28-0 32768.0) + ) + (seek f28-0 0.0 (* 65536.0 (-> self clock seconds-per-frame))) + ) + ((< 0.0 f0-2) + (let ((v1-47 (ja-group))) + (when (not (and v1-47 (= v1-47 (-> self draw art-group data 345)))) + (let ((v1-53 (ja-group))) + (if (and v1-53 (= v1-53 (-> self draw art-group data 346))) + (set! f26-0 (ja-aframe-num 0)) + ) + ) + (sound-play "mech-drag-push") + (ja-channel-push! 1 (seconds 0.3)) + (ja :group! (-> self draw art-group data 345) :num! (identity (ja-aframe f26-0 0)) :dist 16384.0) + ) + ) + (seek f28-0 49152.0 (* 24576.0 (-> self clock seconds-per-frame))) + ) + ((< f0-2 0.0) + (let ((v1-71 (ja-group))) + (when (not (and v1-71 (= v1-71 (-> self draw art-group data 346)))) + (let ((v1-77 (ja-group))) + (if (and v1-77 (= v1-77 (-> self draw art-group data 345))) + (set! f26-0 (ja-aframe-num 0)) + ) + ) + (sound-play "mech-drag-pull") + (ja-channel-push! 1 (seconds 0.3)) + (ja :group! (-> self draw art-group data 346) :num! (identity (ja-aframe f26-0 0)) :dist 16384.0) + ) + ) + (seek f28-0 -49152.0 (* 24576.0 (-> self clock seconds-per-frame))) + ) + (else + (seek f28-0 0.0 (* 32768.0 (-> self clock seconds-per-frame))) + ) + ) + ) + ) + ) + (set! f30-0 + (seek + f30-0 + (lerp-scale + 0.0 + 1.0 + (* (vector-vector-distance (-> self control trans) (-> self control trans-old-old)) + (-> self clock frames-per-second) + ) + 0.0 + 49152.0 + ) + (* 2.0 (-> self clock seconds-per-frame)) + ) + ) + (sound-play-by-name + (static-sound-name "mech-drag-grind") + (the-as sound-id (-> self mech drag-sound-id)) + (the int (* 1024.0 f30-0)) + 0 + 0 + (sound-group sfx) + #t + ) + (set-forward-vel f28-0) + (let* ((f0-24 (current-cycle-distance (-> self skel))) + (f26-1 (/ f28-0 (* 2.0 f0-24))) + ) + (seek! + (-> self mech jump-thrust) + (lerp-scale 0.0 245760.0 (fabs f28-0) 0.0 49152.0) + (* 491520.0 (-> self clock seconds-per-frame)) + ) + (set! (-> self mech thruster-flame-width) (* 0.021428572 (-> self mech jump-thrust))) + (set! (-> self mech thruster-flame-length) (* 0.028571429 (-> self mech jump-thrust))) + (let ((v1-120 (ja-group))) + (if (and v1-120 (or (= v1-120 (-> self draw art-group data 345)) (= v1-120 (-> self draw art-group data 346)))) + (ja :num! (loop! f26-1)) + ) + ) + ) + (suspend) + 0 + ) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-falling (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (let ((v0-0 (target-mech-bonk-event-handler proc arg1 event-type event))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + ((-> target-mech-carry-stance event) proc arg1 event-type event) + ) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *mech-carry-jump-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :trans (behavior () + (if (logtest? (-> self control status) (collide-status on-surface)) + (go target-mech-carry-hit-ground #f) + ) + (when (if (and (< (target-move-dist (-> *TARGET-bank* stuck-time)) (-> *TARGET-bank* stuck-distance)) + (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.05)) + (not (and *cheat-mode* (cpad-hold? (-> self control cpad number) r2))) + ) + #t + ) + (logior! (-> self control status) (collide-status on-surface)) + (go target-mech-carry-hit-ground 'stuck) + ) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (cond + ((and v1-2 (= v1-2 (-> self draw art-group data 341))) + ) + (else + (ja-channel-push! 1 (seconds 0.33)) + (ja :group! (-> self draw art-group data 341)) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (suspend) + ) + ) + ) + ) + (ja-no-eval :group! (-> self draw art-group data 341) :num! (loop!) :frame-num 0.0) + (until #f + (suspend) + (ja :group! (-> self draw art-group data 341) :num! (loop!)) + ) + #f + (none) + ) + :post target-mech-carry-post + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-hit-ground (target) + :event (-> target-mech-carry-falling event) + :enter (behavior ((arg0 symbol)) + (let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-0 command) (sound-command set-param)) + (set! (-> v1-0 id) (the-as sound-id (-> self mech thrust-sound-id))) + (set! (-> v1-0 params volume) -4) + (set! (-> v1-0 auto-time) 48) + (set! (-> v1-0 auto-from) 2) + (set! (-> v1-0 params mask) (the-as uint 17)) + (-> v1-0 id) + ) + (rot->dir-targ! (-> self control)) + (cond + ((= arg0 'stuck) + ) + (else + (target-land-effect) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.3)) + ) + ) + (set! (-> self control last-running-attack-end-time) 0) + (set! (-> self control last-attack-end-time) 0) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control mod-surface) *mech-stance-mods*) + (set! (-> self control mod-surface turnvv) 0.0) + (start-bobbing! + (-> self water) + (lerp-scale 0.0 4096.0 (-> self control ground-impact-vel) 40960.0 102400.0) + 600 + 1500 + ) + (none) + ) + :exit (behavior () + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + ((-> target-mech-carry-pickup exit)) + (none) + ) + :trans (behavior () + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-16 (-> *TARGET-bank* mech-carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* mech-carry-jump-height-max)) + ) + (go target-mech-carry-jump a0-16 a1-2) + ) + ) + (if (and (!= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) + (let ((v1-26 (ja-group))) + (and (and v1-26 (= v1-26 (-> self draw art-group data 342))) (>= (ja-aframe-num 0) 30.0)) + ) + ) + (go target-mech-carry-walk) + ) + (fall-test (the-as (state symbol target) target-mech-carry-falling) (-> *TARGET-bank* fall-height)) + (none) + ) + :code (behavior ((arg0 symbol)) + (target-hit-ground-anim #f (are-still?)) + (go target-mech-carry-stance) + (none) + ) + :post target-mech-carry-post + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-jump (target) + :event (-> target-mech-carry-falling event) + :enter (behavior ((arg0 float) (arg1 float)) + (set! (-> self state-time) (-> self clock frame-counter)) + (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (set! (-> self control mod-surface) *mech-carry-jump-mods*) + (set! (-> self control unknown-float36) + (fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control ctrl-xz-vel))))) + ) + (none) + ) + :exit (behavior () + (rot->dir-targ! (-> self control)) + ((-> target-mech-carry-pickup exit)) + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + (target-exit) + (none) + ) + :trans (behavior () + (set! (-> self control unknown-float36) + (fmax + (-> self control unknown-float36) + (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control cpad number) abutton 6))) + ) + ) + ((-> target-mech-carry-falling trans)) + (mod-var-jump #t #f (cpad-hold? (-> self control cpad number) x) (-> self control transv)) + (cond + ((>= (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 0.0) + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 2048.0) + (set! (-> self mech thruster-flame-length) 6144.0) + ) + (else + (set! (-> self mech jump-thrust) 0.0) + (set! (-> self mech thruster-flame-width) 0.0) + (set! (-> self mech thruster-flame-length) 0.0) + ) + ) + (none) + ) + :code (behavior ((arg0 float) (arg1 float)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> self draw art-group data 340) :num! min) + (suspend) + (ja :group! (-> self draw art-group data 340) :num! (+!)) + (suspend) + (until (ja-done? 0) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (f0-4 (- 10.0 (ja-aframe-num 0))) + (gp-1 (-> self skel root-channel 0)) + ) + (set! (-> gp-1 param 0) (the float (+ (-> gp-1 frame-group frames num-frames) -1))) + (let ((v1-27 (and (< 0.0 f30-0) (< 0.0 f0-4)))) + (set! (-> gp-1 param 1) + (if v1-27 + (fmin (fmin 3.0 f0-4) (/ (* 5.0 f0-4) (the float (time-to-apex f30-0 -245760.0)))) + 1.8 + ) + ) + ) + (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (suspend) + ) + (go target-mech-carry-falling) + (none) + ) + :post target-mech-carry-post + ) + +;; failed to figure out what this is: +(defstate target-mech-carry-throw (target) + :event (-> target-mech-carry-drop event) + :enter (behavior () + (set! (-> self control mod-surface) *mech-walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (set! (-> self mech stick-off) (the-as basic #t)) + (none) + ) + :exit (-> target-mech-carry-pickup exit) + :code (behavior () + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 343) :num! (seek! (ja-aframe 16.0 0)) :frame-num 0.0) + (until (ja-done? 0) + (let ((a1-3 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-3 from) (process->ppointer self)) + (set! (-> a1-3 num-params) 0) + (set! (-> a1-3 message) 'carry-info) + (let ((gp-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-3)))) + (if gp-1 + (seek! (-> gp-1 grab-trans-blend) 1.0 (* 4.0 (-> self clock seconds-per-frame))) + ) + ) + ) + (suspend) + (ja :num! (seek! (ja-aframe 16.0 0))) + ) + (let ((a1-7 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-7 from) (process->ppointer self)) + (set! (-> a1-7 num-params) 0) + (set! (-> a1-7 message) 'carry-info) + (let ((v1-30 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-7)))) + (when v1-30 + (let ((s4-0 (-> v1-30 process 0 control)) + (gp-3 (new 'stack-no-clear 'collide-query)) + ) + (let ((s5-0 (new 'stack-no-clear 'sphere))) + (dotimes (s3-0 1) + ((method-of-type sphere new) (the-as symbol (+ (the-as uint s5-0) (* s3-0 16))) sphere) + ) + (set! (-> (the-as sphere (&-> s5-0 x)) quad) (-> s4-0 root-prim prim-core world-sphere quad)) + (let ((v1-38 gp-3)) + (set! (-> v1-38 best-dist) (the-as float s5-0)) + (set! (-> v1-38 num-spheres) (the-as uint 1)) + (set! (-> v1-38 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-38 ignore-process0) #f) + (set! (-> v1-38 ignore-process1) #f) + (set! (-> v1-38 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-38 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-38 action-mask) (collide-action solid)) + ) + ) + (when (fill-and-probe-using-spheres *collide-cache* gp-3) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-carry-stance) + ) + ) + ) + ) + ) + (let ((v1-48 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 2048.0))) + (vector+float*! v1-48 v1-48 (-> self control c-R-w vector 2) 131072.0) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-48) + ) + (target-collide-set! 'normal 0.0) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-mech-stance) + (none) + ) + :post (-> target-mech-carry-pickup post) + ) + +;; failed to figure out what this is: +(defstate target-mech-get-on (target) + :event target-generic-event-handler + :exit (behavior () + (target-mech-exit) + (set! (-> self mech stick-off) #f) + (set! (-> self neck flex-blend) 1.0) + (logclear! (-> self state-flags) (state-flags sf5)) + (none) + ) + :code (behavior ((arg0 handle)) + (logior! (-> self state-flags) (state-flags sf5)) + (ja-channel-set! 1) + (set! (-> self control mod-surface) *empty-mods*) + (send-event (ppointer->process (-> self manipy)) 'draw #t) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control unknown-vector37 quad) (-> self control trans quad)) + (set! (-> self control unknown-vector38 quad) (-> self control trans quad)) + (set! (-> self control unknown-vector39 quad) (-> self control quat quad)) + (set! (-> self control unknown-vector40 quad) (-> self control quat quad)) + (let* ((gp-1 (handle->process arg0)) + (v1-23 (if (type? gp-1 process-drawable) + gp-1 + ) + ) + ) + (when v1-23 + (set! (-> self control unknown-vector38 quad) (-> (the-as process-drawable v1-23) root trans quad)) + (set! (-> self control unknown-vector40 quad) (-> (the-as process-drawable v1-23) root quat quad)) + ) + ) + (set! (-> self mech mech-trans quad) (-> self control unknown-vector38 quad)) + (quaternion-copy! + (the-as quaternion (-> self mech mech-quat)) + (the-as quaternion (-> self control unknown-vector40)) + ) + (set! (-> self mech mech-scale quad) (-> self control scale quad)) + (set! (-> self mech stick-off) (the-as basic #t)) + (ja-no-eval :group! (-> self draw art-group data 350) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 350)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (let ((f30-0 (sin (lerp-scale 0.0 16384.0 (ja-aframe-num 0) 70.0 80.0)))) + (let ((f28-0 (lerp-scale 0.0 1.0 (ja-aframe-num 0) 70.0 80.0))) + (vector-lerp! + (-> self control trans) + (-> self control unknown-vector37) + (-> self control unknown-vector38) + f30-0 + ) + (set! (-> self control trans y) + (lerp (-> self control unknown-vector37 y) (-> self control unknown-vector38 y) f28-0) + ) + ) + (quaternion-slerp! + (-> self control quat-for-control) + (the-as quaternion (-> self control unknown-vector39)) + (the-as quaternion (-> self control unknown-vector40)) + f30-0 + ) + ) + (rot->dir-targ! (-> self control)) + (set! (-> self alt-cam-pos quad) (-> self control camera-pos quad)) + (suspend) + (ja :num! (seek!)) + ) + (go target-mech-stance) + (none) + ) + :post (behavior () + (target-no-move-post) + (target-mech-effect) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate target-mech-get-off (target) + :event target-generic-event-handler + :exit (behavior () + ((-> target-mech-start exit)) + (logclear! (-> self state-flags) (state-flags sf5)) + (none) + ) + :code (behavior () + (logior! (-> self state-flags) (state-flags sf5)) + (set! (-> self control mod-surface) *empty-mods*) + (rot->dir-targ! (-> self control)) + (set-setting! 'slave-options 'clear 0 8192) + (remove-setting! 'fov) + (remove-setting! 'head-offset) + (send-event *camera* 'set-dist #f #f) + (set! (-> self neck flex-blend) 0.0) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 349) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 349)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (when (< 51.0 (ja-aframe-num 0)) + (logior! (-> self state-flags) (state-flags sf6)) + (vector<-cspace! (-> self alt-cam-pos) (-> self node-list data 36)) + ) + (suspend) + (ja :num! (seek!)) + ) + (process-spawn + mech + :init mech-init + (-> self mech entity) + (-> self control trans) + (process->handle self) + (-> self mech shield-value) + :to self + ) + (rot->dir-targ! (-> self control)) + (ja-post) + (let ((gp-1 (new 'stack-no-clear 'vector))) + (vector<-cspace! gp-1 (-> self node-list data 3)) + (set! (-> gp-1 y) (+ -9011.2 (-> gp-1 y))) + (move-to-point! (-> self control) gp-1) + ) + (send-event *camera* 'ease-in) + (ja-channel-set! 0) + (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) + (let ((v1-68 (new-stack-vector0))) + (let ((f0-13 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-68 (-> self control transv) (vector-float*! v1-68 (-> self control dynam gravity-normal) f0-13)) + ) + (let* ((f0-14 (vector-length v1-68)) + (f1-2 f0-14) + (f2-0 -49152.0) + (a0-36 (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-0) + (vector-float*! v1-68 v1-68 (/ f0-14 f1-2)) + ) + ) + ) + (go target-falling (the-as symbol a0-36)) + ) + ) + (none) + ) + :post (-> target-mech-get-on post) + ) + +;; failed to figure out what this is: +(defstate target-mech-grab (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (cond + ((and (= event-type 'query) (= (-> event param 0) 'mode)) + (-> self state name) + ) + (else + (case event-type + (('end-mode) + (go target-mech-stance) + ) + (('clone-anim) + (go target-mech-clone-anim (process->handle (the-as process (-> event param 0)))) + ) + (else + (target-generic-event-handler proc arg1 event-type event) + ) + ) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *grab-mods*) + (set! (-> self neck flex-blend) 0.0) + (logior! (-> self state-flags) (state-flags sf2)) + (logior! (-> self focus-status) (focus-status grabbed)) + (set! (-> self mech stick-off) (the-as basic #t)) + (sound-stop (the-as sound-id (-> self mech engine-sound-id))) + (sound-stop (the-as sound-id (-> self mech thrust-sound-id))) + (sound-stop (the-as sound-id (-> self mech drag-sound-id))) + (sound-stop (the-as sound-id (-> self mech whine-sound-id))) + (none) + ) + :exit (behavior () + (set! (-> self mech stick-off) #f) + (logclear! (-> self state-flags) (state-flags sf2)) + (logclear! (-> self focus-status) (focus-status grabbed)) + (logclear! (-> self water flags) (water-flags jump-out)) + ((-> target-mech-start exit)) + (none) + ) + :code (-> target-mech-stance code) + :post target-mech-post + ) + +;; failed to figure out what this is: +(defstate target-mech-clone-anim (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (if (and (= event-type 'trans) (= (-> event param 0) 'restore)) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ((-> target-mech-grab event) proc arg1 event-type event) + ) + :enter (-> target-clone-anim enter) + :exit (behavior () + (set! (-> self control draw-offset y) (the-as float (-> self control unknown-word04))) + (set! (-> self control cspace-offset y) (-> self control draw-offset y)) + (send-event (ppointer->process (-> self sidekick)) 'matrix #f) + ((-> target-clone-anim exit)) + ((-> target-mech-start exit)) + (vector-reset! (-> self control transv)) + (none) + ) + :code (behavior ((arg0 handle)) + (set! (-> self control unknown-word04) (the-as uint (-> self control draw-offset y))) + (set! (-> self control draw-offset y) 0.0) + (send-event (ppointer->process (-> self sidekick)) 'matrix 'play-anim) + (clone-anim arg0 #t "") + (go target-mech-stance) + (none) + ) + :post (behavior () + (vector+! (-> self mech mech-trans) (-> self control trans) (-> self control cspace-offset)) + (quaternion-copy! (the-as quaternion (-> self mech mech-quat)) (-> self control quat)) + (set! (-> self mech mech-scale quad) (-> self control scale quad)) + (target-no-ja-move-post) + (none) + ) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc b/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc new file mode 100644 index 000000000..032f621c0 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/target/mech_suit/mech_REF.gc @@ -0,0 +1,564 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(if (not (nmember "mechp" *kernel-packages*)) + (set! *kernel-packages* (cons "mechp" *kernel-packages*)) + ) + +;; definition of type mech +(deftype mech (process-drawable) + ((root-override collide-shape-moving :offset 128) + (extra-trans vector :inline :offset-assert 208) + (condition int32 :offset-assert 224) + (shadow-backup basic :offset-assert 228) + (rider uint64 :offset-assert 232) + (shield-value float :offset-assert 240) + (nav-sphere-handle uint64 :offset-assert 248) + (probe-time time-frame :offset-assert 256) + ) + :heap-base #x90 + :method-count-assert 25 + :size-assert #x108 + :flag-assert #x1900900108 + (:methods + (wait-for-start () _type_ :state 20) + (idle () _type_ :state 21) + (pickup ((state mech)) _type_ :state 22) + (wait-for-return () _type_ :state 23) + (mech-method-24 (_type_) none 24) + ) + ) + +;; definition for method 3 of type mech +(defmethod inspect mech ((obj mech)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format #t "~2Textra-trans: ~`vector`P~%" (-> obj extra-trans)) + (format #t "~2Tcondition: ~D~%" (-> obj condition)) + (format #t "~2Tshadow-backup: ~A~%" (-> obj shadow-backup)) + (format #t "~2Trider: ~D~%" (-> obj rider)) + (format #t "~2Tshield-value: ~f~%" (-> obj shield-value)) + (format #t "~2Tnav-sphere-handle: ~D~%" (-> obj nav-sphere-handle)) + (format #t "~2Tprobe-time: ~D~%" (-> obj probe-time)) + (label cfg-4) + obj + ) + +;; definition for method 24 of type mech +;; WARN: Return type mismatch int vs none. +(defmethod mech-method-24 mech ((obj mech)) + (if (nonzero? (-> obj part)) + (spawn (-> obj part) (-> obj root-override trans)) + ) + (update! (-> obj sound)) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate wait-for-start (mech) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (the-as + object + (case event-type + (('attack 'bonk) + (send-event proc 'target-mech-get-off 90) + (let ((a1-3 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-3 from) (process->ppointer self)) + (set! (-> a1-3 num-params) 2) + (set! (-> a1-3 message) 'shove) + (set! (-> a1-3 param 0) (the-as uint #f)) + (let ((v1-9 (new 'static 'attack-info :mask (attack-info-mask shove-back shove-up id)))) + (let* ((a0-8 *game-info*) + (a2-2 (+ (-> a0-8 attack-id) 1)) + ) + (set! (-> a0-8 attack-id) a2-2) + (set! (-> v1-9 id) a2-2) + ) + (set! (-> v1-9 shove-back) 12288.0) + (set! (-> v1-9 shove-up) 4096.0) + (set! (-> a1-3 param 1) (the-as uint v1-9)) + ) + (send-event-function proc a1-3) + ) + (the-as structure #f) + ) + (('touch) + (send-event proc 'target-mech-get-off 90) + (send-shoves + (-> self root-override) + proc + (the-as touching-shapes-entry (-> event param 0)) + 0.7 + 6144.0 + 16384.0 + ) + (the-as structure #f) + ) + (('trans) + (vector+! (the-as vector (-> event param 0)) (-> self root-override trans) (-> self extra-trans)) + ) + (('shadow) + (cond + ((-> event param 0) + (let ((v0-2 (the-as structure (-> self shadow-backup)))) + (set! (-> self draw shadow) (the-as shadow-geo v0-2)) + v0-2 + ) + ) + (else + (set! (-> self draw shadow) #f) + (the-as structure #f) + ) + ) + ) + ) + ) + ) + :exit (behavior () + (set! (-> self root-override root-prim prim-core action) (collide-action)) + (set! (-> self root-override penetrated-by) (the-as penetrate -1)) + (none) + ) + :code (behavior () + (go-virtual idle) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate idle (mech) + :virtual #t + :event (-> (method-of-type mech wait-for-start) event) + :enter (behavior () + (set! (-> self nav-sphere-handle) (the-as uint #f)) + (let ((s5-0 (find-nearest-nav-mesh (-> self root-override trans) 8192.0))) + (when s5-0 + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-z-quaternion! gp-0 (-> self root-override quat)) + (vector-normalize! gp-0 5120.0) + (vector+! gp-0 gp-0 (-> self root-override trans)) + (set! (-> self nav-sphere-handle) + (the-as uint (ppointer->handle (process-spawn simple-nav-sphere #x46266666 gp-0 s5-0 -1 :to self))) + ) + ) + ) + ) + (none) + ) + :exit (behavior () + (send-event (handle->process (-> self nav-sphere-handle)) 'die-fast) + ((-> (method-of-type mech wait-for-start) exit)) + (none) + ) + :code (behavior () + (change-parent self *entity-pool*) + (ja-channel-set! 1) + (ja :group! (-> self draw art-group data 3)) + (set! (-> self root-override root-prim prim-core action) (collide-action solid can-ride no-standon)) + (set! (-> self root-override penetrated-by) (penetrate)) + 0.0 + (let ((f30-0 20480.0)) + (until #f + (when (and (logtest? (-> self draw status) (draw-control-status on-screen)) + (>= (- (-> self clock frame-counter) (-> self probe-time)) (seconds 1)) + ) + (move-to-ground + (-> self root-override) + 8192.0 + 40960.0 + #t + (collide-spec backgnd obstacle hit-by-player-list hit-by-others-list pusher) + ) + (set! (-> self probe-time) (-> self clock frame-counter)) + ) + (when (and (and *target* + (and (>= f30-0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))) + (zero? (logand (focus-status teleporting) (-> *target* focus-status))) + ) + ) + (not (logtest? (focus-status in-head pole board mech dark) (-> *target* focus-status))) + (can-display-query? self (the-as string #f) -99.0) + (-> *setting-control* user-current pilot) + ) + (let ((gp-0 (new + 'stack + 'font-context + *font-default-matrix* + 32 + 320 + 0.0 + (font-color default-#cddbcd) + (font-flags shadow kerning) + ) + ) + ) + (let ((v1-31 gp-0)) + (set! (-> v1-31 width) (the float 340)) + ) + (let ((v1-32 gp-0)) + (set! (-> v1-32 height) (the float 80)) + ) + (let ((v1-33 gp-0)) + (set! (-> v1-33 scale) 0.9) + ) + (set! (-> gp-0 flags) (font-flags shadow kerning large)) + (print-game-text (lookup-text! *common-text* (game-text-id text-x182) #f) gp-0 #f 44 (bucket-id progress)) + ) + (if (and (cpad-pressed? 0 triangle) (send-event *target* 'change-mode 'mech self (-> self shield-value))) + (go-virtual pickup (method-of-object self wait-for-return)) + ) + ) + (if *target* + (look-at! + (-> *target* neck) + (vector+! + (new 'stack-no-clear 'vector) + (the-as vector (-> self root-override root-prim prim-core)) + (new 'static 'vector :y 2048.0 :w 1.0) + ) + 'nothing-special + self + ) + ) + (mech-method-24 self) + (suspend) + ) + ) + #f + (none) + ) + :post (the-as (function none :behavior mech) ja-post) + ) + +;; failed to figure out what this is: +(defstate pickup (mech) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('draw) + (ja-channel-set! 1) + (ja :group! (-> self draw art-group data 3)) + (set! (-> self root-override root-prim prim-core action) (collide-action solid can-ride no-standon)) + (set! (-> self root-override penetrated-by) (penetrate)) + (transform-post) + ) + (('trans) + (vector+! (the-as vector (-> event param 0)) (-> self root-override trans) (-> self extra-trans)) + ) + (('touch 'attack 'bonk) + #f + ) + (('shadow) + (cond + ((-> event param 0) + (let ((v0-1 (the-as object (-> self shadow-backup)))) + (set! (-> self draw shadow) (the-as shadow-geo v0-1)) + v0-1 + ) + ) + (else + (set! (-> self draw shadow) #f) + #f + ) + ) + ) + ) + ) + :enter (behavior ((arg0 (state mech))) + (let ((t9-0 (-> arg0 enter))) + (if t9-0 + (t9-0) + ) + ) + (none) + ) + :code (behavior ((arg0 (state mech))) + (ja-channel-set! 0) + (ja-post) + (while (zero? (ja-group-size)) + (if (or (not *target*) + (or (< 24576.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))) + (logtest? (focus-status teleporting) (-> *target* focus-status)) + ) + ) + (go arg0) + ) + (mech-method-24 self) + (suspend) + ) + (while (and *target* (logtest? (focus-status mech) (-> *target* focus-status))) + (mech-method-24 self) + (suspend) + ) + (let ((s5-0 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-0) (seconds 1)) + (mech-method-24 self) + (suspend) + ) + ) + (go arg0) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate wait-for-return (mech) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (the-as + object + (case event-type + (('trans) + (vector+! (the-as vector (-> event param 0)) (-> self root-override trans) (-> self extra-trans)) + ) + (('shadow) + (cond + ((-> event param 0) + (let ((v0-1 (the-as structure (-> self shadow-backup)))) + (set! (-> self draw shadow) (the-as shadow-geo v0-1)) + v0-1 + ) + ) + (else + (set! (-> self draw shadow) #f) + (the-as structure #f) + ) + ) + ) + ) + ) + ) + :code (behavior () + (ja-channel-set! 0) + (ja-post) + (cleanup-for-death self) + (none) + ) + ) + +;; definition for function mech-init +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior mech-init mech ((arg0 entity-actor) (arg1 matrix3) (arg2 handle) (arg3 float)) + (let ((s2-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player)))) + (set! (-> s2-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s2-0 reaction) cshape-reaction-default) + (set! (-> s2-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (let ((v1-6 (new 'process 'collide-shape-prim-sphere s2-0 (the-as uint 0)))) + (set! (-> v1-6 prim-core collide-as) (collide-spec obstacle obstacle-for-jak)) + (set! (-> v1-6 prim-core collide-with) (collide-spec jak player-list)) + (set! (-> v1-6 prim-core action) (collide-action solid can-ride no-standon)) + (set! (-> v1-6 transform-index) 0) + (set-vector! (-> v1-6 local-sphere) 0.0 6553.6 5324.8 6553.6) + (set! (-> s2-0 total-prims) (the-as uint 1)) + (set! (-> s2-0 root-prim) v1-6) + ) + (set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w))) + (let ((v1-9 (-> s2-0 root-prim))) + (set! (-> s2-0 backup-collide-as) (-> v1-9 prim-core collide-as)) + (set! (-> s2-0 backup-collide-with) (-> v1-9 prim-core collide-with)) + ) + (set! (-> self root-override) s2-0) + ) + (set! (-> self rider) (the-as uint arg2)) + (when arg0 + (process-entity-set! self arg0) + (process-drawable-from-entity! self arg0) + (set-yaw-angle-clear-roll-pitch! (-> self root-override) (res-lump-float arg0 'rotoffset)) + ) + (when arg1 + (set! (-> self root-override trans quad) (-> arg1 vector 0 quad)) + (quaternion-copy! (-> self root-override quat) (the-as quaternion (-> arg1 vector 1))) + ) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-mech" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (set! (-> self shadow-backup) (-> self draw shadow)) + (set! (-> self draw shadow-ctrl) *mech-shadow-control*) + (let ((v1-27 (-> self node-list data))) + (set! (-> v1-27 0 param0) (the-as (function cspace matrix none) cspace<-transformq+trans!)) + (set! (-> v1-27 0 param1) (the-as basic (-> self root-override trans))) + (set! (-> v1-27 0 param2) (the-as basic (-> self extra-trans))) + ) + (set! (-> self condition) (res-lump-value arg0 'index int :time -1000000000.0)) + (set! (-> self fact) + (new 'process 'fact-info self (pickup-type eco-pill-random) (-> *FACT-bank* default-eco-pill-green-inc)) + ) + (set! (-> self shield-value) arg3) + (set! (-> self nav-sphere-handle) (the-as uint #f)) + (if (-> self entity) + (move-to-ground + (-> self root-override) + 8192.0 + 40960.0 + #t + (collide-spec backgnd obstacle hit-by-player-list hit-by-others-list pusher) + ) + ) + (set! (-> self sound) + (new 'process 'ambient-sound (static-sound-spec "zoom-teleport" :fo-max 30) (-> self root-override trans)) + ) + (set! (-> self draw light-index) (the-as uint 30)) + (if (handle->process arg2) + (go-virtual idle) + (go-virtual wait-for-start) + ) + (none) + ) + +;; definition for method 11 of type mech +(defmethod init-from-entity! mech ((obj mech) (arg0 entity-actor)) + (mech-init arg0 (the-as matrix3 #f) (the-as handle #f) 100.0) + (none) + ) + +;; definition of type mech-target +(deftype mech-target (process-drawable) + () + :heap-base #x50 + :method-count-assert 22 + :size-assert #xc8 + :flag-assert #x16005000c8 + (:methods + (idle () _type_ :state 20) + (active () _type_ :state 21) + ) + ) + +;; definition for method 3 of type mech-target +(defmethod inspect mech-target ((obj mech-target)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (label cfg-4) + obj + ) + +;; failed to figure out what this is: +(defskelgroup skel-mech-target mech 42 44 ((43 (meters 999999))) :bounds (static-spherem 0 0 0 4)) + +;; failed to figure out what this is: +(defstate idle (mech-target) + :virtual #t + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('look-at-point) + (set! (-> self state-time) (-> self clock frame-counter)) + (go-virtual active) + ) + ) + ) + :trans (behavior () + (if (and (and *target* (and (>= 98304.0 (vector-vector-distance (-> self root trans) (-> *target* control trans))) + (zero? (logand (focus-status teleporting) (-> *target* focus-status))) + ) + ) + (logtest? (focus-status mech) (-> *target* focus-status)) + ) + (go-virtual active) + ) + (none) + ) + :code (behavior () + (while (< 0.0 (-> self root scale x)) + (seek! (-> self root scale x) 0.0 (* 8.0 (-> self clock seconds-per-frame))) + (set! (-> self root scale y) (-> self root scale x)) + (ja-post) + (suspend) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (ja-post) + (sleep-code) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate active (mech-target) + :virtual #t + :event (-> (method-of-type mech-target idle) event) + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :trans (behavior () + (if (and (or (or (not *target*) (or (< 106496.0 (vector-vector-distance (-> self root trans) (-> *target* control trans))) + (logtest? (focus-status teleporting) (-> *target* focus-status)) + ) + ) + (zero? (logand (focus-status mech) (-> *target* focus-status))) + ) + (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 10)) + ) + (go-virtual idle) + ) + (none) + ) + :code (behavior () + (sound-play "mech-target") + (let ((f30-0 0.0)) + (logclear! (-> self draw status) (draw-control-status no-draw)) + (while (< (-> self root scale x) 1.0) + (seek! (-> self root scale x) 1.0 (* 8.0 (-> self clock seconds-per-frame))) + (set! (-> self root scale y) (-> self root scale x)) + (set! f30-0 (seek f30-0 1.0 (* 2.0 (-> self clock seconds-per-frame)))) + (ja :num! (loop! f30-0)) + (ja-post) + (suspend) + ) + (until #f + (set! f30-0 (seek f30-0 1.0 (* 0.25 (-> self clock seconds-per-frame)))) + (ja :num! (loop! f30-0)) + (ja-post) + (suspend) + ) + ) + #f + (none) + ) + ) + +;; definition for function mech-target-init +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior mech-target-init mech ((arg0 vector) (arg1 quaternion) (arg2 entity-actor)) + (process-entity-set! self arg2) + (set! (-> self root-override) (the-as collide-shape-moving (new 'process 'trsqv))) + (set! (-> self root-override trans quad) (-> arg0 quad)) + (quaternion-copy! (-> self root-override quat) arg1) + (set! (-> self root-override scale x) 0.0) + (set! (-> self root-override scale y) 0.0) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-mech-target" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (go-virtual wait-for-start) + (none) + ) + +;; definition for function mech-target-spawn +;; WARN: Return type mismatch (pointer process) vs (pointer mech-target). +(defun mech-target-spawn ((arg0 vector) (arg1 target) (arg2 quaternion) (arg3 entity-actor)) + (process-spawn mech-target :init mech-target-init arg0 arg2 arg3 :to arg1) + ) + + + +