diff --git a/Taskfile.yml b/Taskfile.yml index 395d65a819..6ee85345d8 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -146,4 +146,4 @@ tasks: - task: offline-test-file type-test: cmds: - - cmd: '{{.GOALCTEST_BIN_RELEASE_DIR}}/goalc-test --gtest_brief=0 --gtest_break_on_failure --gtest_filter="*Jak2TypeConsistency*"' + - cmd: '{{.GOALCTEST_BIN_RELEASE_DIR}}/goalc-test --gtest_brief=0 --gtest_filter="*Jak2TypeConsistency*" --gtest_break_on_failure' diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 73aabd9ab9..6a51f021e2 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -12602,17 +12602,17 @@ ) (deftype continue-point (basic) - ((name string) ;; ? - (level symbol) ;; ? - (flags continue-flags) - (trans vector :inline) - (quat vector :inline) - (camera-trans vector :inline) - (camera-rot vector3s 3 :inline) - (on-goto pair) - (vis-nick symbol) - (want level-buffer-state 6 :inline) - (want-sound symbol 3) + ((name string :offset-assert 4) ;; ? + (level symbol :offset-assert 8) ;; ? + (flags continue-flags :offset-assert 12) + (trans vector :inline :offset-assert 16) + (quat vector :inline :offset-assert 32) + (camera-trans vector :inline :offset-assert 48) + (camera-rot vector3s 3 :inline :offset-assert 64) + (on-goto pair :offset-assert 100) + (vis-nick symbol :offset-assert 104) + (want level-buffer-state 6 :inline :offset-assert 108) + (want-sound symbol 3 :offset-assert 204) ) :method-count-assert 12 :size-assert #xd8 @@ -14398,7 +14398,7 @@ ;; Failed to read fields. (:methods (new (symbol type process pickup-type float) _type_ 0) - (drop-pickup (_type_ symbol process-tree fact-info int) (pointer process) 9) ;; (drop-pickup (_type_ symbol process-tree fact-info int) (pointer process) 9) + (drop-pickup (_type_ symbol process-tree fact-info int) (pointer process) 9) (reset! (_type_ symbol) none 10) (pickup-collectable! (_type_ pickup-type float handle) float 11) ) @@ -15059,6 +15059,7 @@ ) ) + (deftype scene (art-group) ((mask-to-clear uint32 :offset-assert 32) (entity string :offset-assert 36) @@ -16688,6 +16689,7 @@ (unknown-dword02 int64 :offset 4416) ;; logic-target::read-pad (unknown-vector16 vector :inline :offset 4432) ;; logic-target::target-real-post (unknown-float14 float :offset 4448) ;; logic-target::target-real-post + (unknown-floatiujh1bnb2n3i1 float :offset 4452) ;; target-death::velocity-set-to-target! (unknown-float15 float :offset 4456) ;; logic-target::target-real-post (unknown-word01 int32 :offset 4460) ;; logic-target::joint-points (unknown-vector17 vector :inline :offset 4464) ;; logic-target::pre-collide-setup @@ -16743,8 +16745,8 @@ (unknown-vector29 vector :inline :offset 5168) ;; logic-target::joint-points (unknown-vector30 vector :inline :offset 5184) ;; logic-target::joint-points (unknown-vector31 vector :inline :offset 5200) ;; logic-target::joint-points - (unknown-vector32 vector :inline :offset 5216) ;; logic-target::joint-points - (unknown-vector33 vector :inline :offset 5232) ;; logic-target::joint-points + (unknown-cspacei1un23i1 cspace :inline :offset 5216) ;; logic-target::joint-points + ;; (unknown-vector33 vector :inline :offset 5232) ;; logic-target::joint-points (unknown-symbol00 symbol :offset 5248) ;; (exit target-duck-stance) (unknown-float000 float :offset 5252) ;; target-gun::target-gun-end-mode (unknown-float31 float :offset 5256) ;; logic-target::joint-points @@ -16777,7 +16779,7 @@ (unknown-time-frame17 time-frame :offset 5712) ;; (trans target-board-halfpipe) (unknown-time-frame18 time-frame :offset 5720) ;; (code target-running-attack) (unknown-sound-id00 sound-id :offset 5776) ;; (enter target-board-flip) - (unknown-handle02 handle :offset 5792) ;; (event target-board-grenade) + (unknown-handle02 handle :offset 5792) ;; (event target-board-grenade) ;; TODO - make sure this is a handle (unknown-impact-control00 impact-control :inline :offset 5824) ;; logic-target::joint-points (unknown-word06 int32 :offset 5832) ;; (code target-running-attack) (unknown-vector41 vector :inline :offset 5888) ;; (code target-running-attack) @@ -17301,7 +17303,7 @@ :flag-assert #xf00000024 (:methods (new (symbol type process-drawable) _type_ 0) - (effect-control-method-9 () none 9) ;; (TODO-RENAME-9 (_type_) none 9) + (effect-control-method-9 (_type_) none 9) ;; (TODO-RENAME-9 (_type_) none 9) (effect-control-method-10 () none 10) ;; (dummy-10 (_type_ symbol float int) object 10) (effect-control-method-11 () none 11) ;; (dummy-11 (_type_ symbol float int basic pat-surface) none 11) (effect-control-method-12 (_type_ symbol float int basic sound-name) int 12) ;; (dummy-12 (_type_ symbol float int basic sound-name) int 12) @@ -17704,8 +17706,9 @@ (declare-type darkjak-info basic) (deftype target (process-focusable) - ((control control-info :offset 128 :score 200) ;; guessed by decompiler - (fact-info-override fact-info-target :offset 160 :score 100) + ((self-override target :offset 32 :score 100) + (control control-info :offset 128 :score 200) ;; guessed by decompiler + (fact-override fact-info-target :offset 160 :score 100) (skel2 joint-control :offset-assert 204) (shadow-backup shadow-geo :offset-assert 208) (target-flags uint32 :offset 188) @@ -17727,7 +17730,7 @@ (cam-user-mode symbol :offset-assert 300) ;; guessed by decompiler (sidekick (pointer sidekick) :offset-assert 304) ;; guessed by decompiler (manipy (pointer manipy) :offset-assert 308) ;; guessed by decompiler - (mirror (pointer process-drawable) :offset-assert 312) + (mirror (pointer process-drawable) :offset-assert 312) ;; hip-mirror? (attack-info attack-info :inline :offset-assert 320) (attack-info-rec attack-info :inline :offset-assert 480) (attack-info-old attack-info 8 :inline :offset-assert 640) @@ -17750,7 +17753,7 @@ (pre-joint-hook (function none :behavior target) :offset-assert 2112) (notify handle :offset-assert 2120) (mode-cache basic :offset-assert 2128) - (mode-param1 uint64 :offset-assert 2136) + (mode-param1 handle :offset-assert 2136) (mode-param2 uint64 :offset-assert 2144) (mode-param3 uint64 :offset-assert 2152) (tobot-state state :offset-assert 2160) @@ -17778,23 +17781,38 @@ (target-method-27 (_type_ collide-cache collide-edge-spec) none 27) (init-target (_type_ continue-point symbol) none :behavior target 28) ) + (:states + target-carry-drop + target-carry-stance + target-carry-walk + target-carry-falling + (target-carry-hit-ground symbol) + (target-carry-jump float float) + target-carry-throw + (target-warp-out vector vector target) ;; (define-extern target-warp-out state) ;; (state vector vector target) + (target-warp-in vector vector target) ;; (define-extern target-warp-in state) ;; (state vector vector target) + target-indax-start + ) ) (deftype sidekick (process-drawable) - ((control control-info :offset 128) ;; guessed by decompiler + ((parent-override (pointer target) :offset 16 :score 100 ) + (control control-info :offset 128) ;; guessed by decompiler (anim-seed uint64 :offset 208) ;; ?? (shadow-in-movie? symbol :offset-assert 216) ;; guessed by decompiler (special-anim-time time-frame :offset-assert 224) (special-anim-interp float :offset-assert 232) (special-anim-frame float :offset-assert 236) (offset transformq :inline :offset-assert 240) - (mirror uint32 :offset-assert 288) + (mirror (pointer process-drawable) :offset-assert 288) ;; hip-mirror? ) :method-count-assert 20 :size-assert #x124 :flag-assert #x1400b00124 (:methods ) + (:states + sidekick-clone) ) (define-extern *target* target) @@ -26628,7 +26646,7 @@ (function symbol matrix)) (define-extern matrix-world->local "Returns [[*math-camera*]]'s `camera-rot`" - (function matrix)) + (function symbol object matrix)) (define-extern *camera-dummy-vector* vector) (define-extern camera-pos "Returns the `trans` vector from whatever is first determined to exist: @@ -27276,7 +27294,7 @@ (define-extern ja-aframe-num (function int float :behavior process-drawable)) (define-extern ja-aframe (function float int float :behavior process-drawable)) ;; (define-extern ja-speed function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-step function) ;; (function int float :behavior process-drawable) +(define-extern ja-step (function int float :behavior process-drawable)) ;; (define-extern ja-channel-set! (function int int :behavior process-drawable)) (define-extern ja-channel-push! (function int time-frame int :behavior process-drawable)) ;; (define-extern ja-channel-float! function) @@ -28150,7 +28168,7 @@ ;; (define-extern birth-func-vector-orient function) ;; (function int sparticle-cpuinfo sparticle-launchinfo none) ;; (define-extern birth-func-set-alpha-from-userdata function) ;; (define-extern part-tracker-track-target-joint function) ;; (function int sparticle-cpuinfo sparticle-launchinfo none) -;; (define-extern process-drawable-burn-effect function) ;; (function time-frame none :behavior target) +(define-extern process-drawable-burn-effect (function time-frame none :behavior target)) ;; (define-extern lightning-probe-callback (function lightning-tracker none)) (define-extern process-drawable-shock-effect (function process-drawable lightning-spec (function lightning-tracker none) sparticle-launcher int int float object)) ;; guess (define-extern process-drawable-shock-wall-effect (function process-drawable lightning-spec (function lightning-tracker none) sparticle-launcher int int float none)) @@ -28239,10 +28257,9 @@ ;; sidekick ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *sidekick-remap* object) ;; pair -;; (define-extern cspace<-cspace+transformq! function) +(define-extern *sidekick-remap* pair) +(define-extern cspace<-cspace+transformq! (function cspace cspace transformq matrix)) (define-extern target-sidekick-setup (function symbol none :behavior target)) -;; (define-extern sidekick-clone state) ;; (state sidekick) (define-extern init-sidekick (function none :behavior sidekick)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -28577,18 +28594,11 @@ ;; target-carry ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *carry-walk-mods* surface) -;; (define-extern *carry-jump-mods* surface) -;; (define-extern target-carry-update function) -;; (define-extern target-carry-post function) +(define-extern *carry-walk-mods* surface) +(define-extern *carry-jump-mods* surface) +(define-extern target-carry-update (function none :behavior target)) +(define-extern target-carry-post (function none :behavior target)) (define-extern target-carry-pickup (state target)) -;; (define-extern target-carry-drop state) -;; (define-extern target-carry-stance state) -;; (define-extern target-carry-walk state) -;; (define-extern target-carry-falling state) -;; (define-extern target-carry-hit-ground state) -;; (define-extern target-carry-jump state) -;; (define-extern target-carry-throw state) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; target-darkjak ;; @@ -28612,37 +28622,35 @@ ;; target-death ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype kill-nearby-enemies-info (UNKNOWN) +(deftype kill-nearby-enemies-info (basic) ((dist float :offset-assert 4) (pos vector :inline :offset-assert 16) ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 ) -|# -;; (define-extern *auto-continue* object) ;; symbol -;; (define-extern next-continue function) +(define-extern *auto-continue* symbol) ;; +(define-extern next-continue (function continue-point continue-point)) (define-extern target-continue (state continue-point target)) (define-extern *smack-mods* surface) (define-extern *smack-up-mods* surface) -;; (define-extern velocity-set-to-target! function) ;; (function vector float attack-info vector :behavior target) +(define-extern velocity-set-to-target! (function vector float attack-info vector :behavior target)) ;; (define-extern target-hit-effect (function attack-info none :behavior target)) -;; (define-extern target-hit-push function) ;; (function vector matrix float float attack-info object :behavior target) +(define-extern target-hit-push (function vector matrix float float attack-info symbol :behavior target)) ;; (define-extern target-hit-orient (function attack-info vector symbol :behavior target)) -;; (define-extern target-hit-setup-anim function) ;; (function attack-info object :behavior target) +(define-extern target-hit-setup-anim (function attack-info none :behavior target)) ;; (define-extern target-hit-move (function attack-info symbol (function none :behavior target) float none :behavior target)) (define-extern target-hit (state symbol attack-info target)) -;; (define-extern *death-spool-array* array) ;; (array spool-anim) -;; (define-extern death-movie-remap function) ;; (function int int int) -;; (define-extern *kill-nearby-enemies-info* kill-nearby-enemies-info) -;; (define-extern kill-nearby-enemies function) -;; (define-extern target-death-anim-trans function) -;; (define-extern target-death-anim function) ;; (function spool-anim none :behavior target) -;; (define-extern target-death-main function) -;; (define-extern target-death-reset function) +(define-extern *death-spool-array* (array spool-anim)) ;; +(define-extern death-movie-remap (function int int int)) ;; +(define-extern *kill-nearby-enemies-info* kill-nearby-enemies-info) +(define-extern kill-nearby-enemies (function vector float object)) +(define-extern target-death-anim-trans (function none :behavior target)) +(define-extern target-death-anim (function spool-anim none :behavior target)) ;; +(define-extern target-death-main (function symbol none :behavior target)) +(define-extern target-death-reset (function symbol symbol none :behavior target)) (define-extern target-death (state symbol target)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -32831,7 +32839,7 @@ (define-extern *enemy-dummy-shadow-control* shadow-control) (define-extern get-penetrate-using-from-attack-event (function process-drawable event-message-block penetrate)) -(define-extern enemy-init-by-other (function none :behavior enemy)) +(define-extern enemy-init-by-other (function process-drawable transformq none :behavior enemy)) (define-extern enemy-event-handler (function process int symbol event-message-block object :behavior enemy)) (define-extern enemy-simple-post (function none :behavior enemy)) (define-extern enemy-falling-post (function none :behavior enemy)) @@ -33764,31 +33772,53 @@ ;; warp-gate ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype warp-gate (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ;; Failed to read fields. + +(deftype warp-gate (process-drawable) + ( + (root-override collide-shape :offset 128 :score 100) + (level-name uint32 :offset-assert 200) + (on-notice int32 :offset-assert 204) + (on-activate int32 :offset-assert 208) + (on-close int32 :offset-assert 212) + (wait-for pair :offset-assert 216) + (continue continue-point :offset-assert 220) + (distance meters :offset-assert 224) + (anim-speed float :offset-assert 228) + (test-time time-frame :offset-assert 232) + (center vector :inline :offset-assert 240) + ) + :method-count-assert 26 + :size-assert #x100 + :flag-assert #x1a00800100 + (:methods + (idle () _type_ :state 20) + (use (continue-point) _type_ :state 21) + (hidden () _type_ :state 22) + (warp-gate-method-23 (_type_) none 23) + (warp-gate-method-24 () none 24) + (warp-gate-method-25 (_type_) continue-point 25) + ) ) -|# -#| -(deftype air-train (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ;; Failed to read fields. +(deftype air-train (warp-gate) + "NOTE - I guess this is why sometimes the air-train makes the warp-gate sound" + ( + (part-exhaust-left sparticle-launch-control :offset-assert 256) + (part-exhaust-right sparticle-launch-control :offset-assert 260) + (part-dust sparticle-launch-control :offset-assert 264) + (dust-y float :offset-assert 268) + (hover-sound sound-id :offset-assert 272) + (base-pos vector :inline :offset-assert 288) + ) + :method-count-assert 26 + :size-assert #x130 + :flag-assert #x1a00b00130 ) -|# ;; (define-extern *kernel-packages* object) ;; pair -;; (define-extern warp-gate-init function) -;; (define-extern *warp-jump-mods* surface) ;; surface -;; (define-extern target-warp-out state) ;; (state vector vector target) -;; (define-extern target-warp-in state) ;; (state vector vector target) +(define-extern warp-gate-init (function entity-actor vector none :behavior warp-gate)) +(define-extern *warp-jump-mods* surface) ;; surface + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; guard-projectile ;; @@ -33980,14 +34010,13 @@ ;; battle ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype battle-info (basic) ((id int8 :offset-assert 4) (notice-spec uint64 :offset-assert 8) (pick-logic int8 :offset-assert 16) (notice-distance float :offset-assert 20) - (dont-spawn-initial-until-notice? basic :offset-assert 24) - (play-battle-music basic :offset-assert 28) + (dont-spawn-initial-until-notice? symbol :offset-assert 24) + (play-battle-music symbol :offset-assert 28) (min-battle-spawn-delay uint32 :offset-assert 32) (max-battle-spawn-delay uint32 :offset-assert 36) (min-spawner-notice-attack-delay uint32 :offset-assert 40) @@ -34003,65 +34032,49 @@ :size-assert #x48 :flag-assert #x900000048 ) -|# -#| (deftype battle-ally (structure) - ((entity basic :offset-assert 0) + ((entity entity-actor :offset-assert 0) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype battle-ally-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) - ) + ((data battle-ally :dynamic :inline :offset-assert 16)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype battle-breed (structure) - ((breed-type basic :offset-assert 0) + ((breed-type type :offset-assert 0) (percent float :offset-assert 4) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype battle-breed-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) - ) + ((data battle-breed :dynamic :inline :offset-assert 16)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype battle-spawner (structure) ((flags uint64 :offset-assert 0) - (entity basic :offset-assert 8) - (breeds basic :offset-assert 12) + (entity entity-actor :offset-assert 8) + (breeds battle-breed-array :offset-assert 12) (creature-index int8 :offset-assert 16) (ready-index int8 :offset-assert 17) (attack-index int8 :offset-assert 18) (mode uint8 :offset-assert 19) - (intro-path basic :offset-assert 20) + (intro-path path-control :offset-assert 20) ;; a guess (notice-attack-delay uint32 :offset-assert 24) - (creature uint64 :offset-assert 32) + (creature handle :offset-assert 32) (last-spawn-time time-frame :offset-assert 40) (noticed-attack-time time-frame :offset-assert 48) (attack-pos vector :inline :offset-assert 64) @@ -34070,37 +34083,30 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype battle-spawner-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) - ) + ((data battle-spawner :dynamic :inline :offset-assert 16)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype battle (process-drawable) - ((info basic :offset-assert 196) - (flags uint8 :offset-assert 200) - (spawn-initial-creatures? basic :offset-assert 204) - (next-spawn-delay uint32 :offset-assert 208) - (on-notice basic :offset-assert 212) - (on-hostile basic :offset-assert 216) - (on-beaten basic :offset-assert 220) - (max-count uint32 :offset-assert 224) - (count uint32 :offset-assert 228) - (die-count uint32 :offset-assert 232) - (stat-child-count uint16 :offset-assert 236) - (cant-spawn-time time-frame :offset-assert 244) - (jammed-starting-time time-frame :offset-assert 252) - (spawners basic :offset-assert 260) - (allies basic :offset-assert 264) + ((info battle-info :offset-assert 200) + (flags uint8 :offset-assert 204) + (spawn-initial-creatures? symbol :offset-assert 208) + (next-spawn-delay uint32 :offset-assert 212) + (on-notice basic :offset-assert 216) + (on-hostile basic :offset-assert 220) + (on-beaten basic :offset-assert 224) + (max-count uint32 :offset-assert 228) + (count uint32 :offset-assert 232) + (die-count uint32 :offset-assert 236) + (stat-child-count uint16 :offset-assert 240) + (cant-spawn-time time-frame :offset-assert 248) + (jammed-starting-time time-frame :offset-assert 256) + (spawners battle-spawner-array :offset-assert 264) + (allies battle-ally-array :offset-assert 268) ) :method-count-assert 53 :size-assert #x110 @@ -34112,40 +34118,39 @@ (notice () _type_ :state 22) (hostile () _type_ :state 23) (beaten () _type_ :state 24) - (battle-method-25 () none 25) - (battle-method-26 () none 26) - (battle-method-27 () none 27) - (battle-method-28 () none 28) - (battle-method-29 () none 29) - (battle-method-30 () none 30) - (battle-method-31 () none 31) - (battle-method-32 () none 32) - (battle-method-33 () none 33) - (battle-method-34 () none 34) - (battle-method-35 () none 35) - (battle-method-36 () none 36) - (battle-method-37 () none 37) - (battle-method-38 () none 38) - (battle-method-39 () none 39) - (battle-method-40 () none 40) - (battle-method-41 () none 41) - (battle-method-42 () none 42) - (battle-method-43 () none 43) - (battle-method-44 () none 44) - (battle-method-45 () none 45) - (battle-method-46 () none 46) - (battle-method-47 () none 47) - (battle-method-48 () none 48) - (battle-method-49 () none 49) - (battle-method-50 () none 50) - (battle-method-51 () none 51) - (battle-method-52 () none 52) - ) - ) -|# - -;; (define-extern *battles* array) -;; (define-extern battle-event-handler function) + (battle-method-25 (_type_ battle-spawner) symbol 25) + (battle-method-26 (_type_ battle-spawner) symbol 26) + (battle-method-27 (_type_) none 27) + (battle-method-28 (_type_) none 28) + (battle-method-29 (_type_ battle-spawner entity-actor) none 29) + (battle-method-30 (_type_ process) battle-spawner 30) + (battle-method-31 (_type_ battle-ally entity-actor) none 31) + (battle-method-32 (_type_ battle-spawner entity-actor) object 32) ;; TODO - gross return value... + (battle-method-33 (_type_) none 33) + (battle-method-34 (_type_) none 34) + (battle-method-35 (_type_) none 35) + (battle-method-36 (_type_) battle-spawner 36) + (battle-method-37 (_type_ battle-spawner) symbol 37) + (battle-method-38 (_type_ battle-breed transformq) handle 38) + (battle-method-39 (_type_ battle-spawner symbol) handle 39) + (battle-method-40 (_type_) none 40) + (battle-method-41 (_type_ battle-spawner) battle-breed 41) + (battle-method-42 (_type_ battle-spawner touch-tracker) symbol 42) ;; fma-sphere or touch-tracker? + (battle-method-43 (_type_ battle-spawner touch-tracker) symbol 43) ;; fma-sphere or touch-tracker? + (battle-method-44 (_type_ battle-spawner) none 44) + (battle-method-45 (_type_ battle-spawner touch-tracker) symbol 45) ;; fma-sphere or touch-tracker? + (battle-method-46 (_type_ battle-spawner) symbol 46) + (battle-method-47 (_type_) none 47) + (battle-method-48 (_type_) none 48) + (battle-method-49 (_type_) int :behavior battle 49) + (battle-method-50 (_type_) symbol 50) + (battle-method-51 (_type_ battle-spawner symbol) symbol :behavior battle 51) + (battle-method-52 (_type_) int 52) + ) + ) + +(define-extern *battles* (array battle-info)) +(define-extern battle-event-handler (function process int symbol event-message-block object :behavior battle)) ;; TODO - none required else state handling fails expression pass ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; elec-gate ;; @@ -44294,7 +44299,6 @@ ;; (define-extern target-indax-exit function) ;; (define-extern target-indax-real-post function) ;; (define-extern target-indax-post function) -;; (define-extern target-indax-start state) ;; (define-extern target-indax-stance state) ;; (define-extern target-indax-walk state) ;; (define-extern target-indax-falling state) @@ -48756,7 +48760,7 @@ ;; (define-extern *sig-recorder* object) ;; (define-extern *sigrec-out* object) ;; (define-extern sig-recorder-init-by-other function) -;; (define-extern start-sig-recorder function) +(define-extern start-sig-recorder (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ctyport-part ;; diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index f5112d6cc1..fb75c2a8f4 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -433,5 +433,23 @@ [92, "(function object nav-control none)"], [93, "(function object nav-control none)"] ], - "scene-actor": [[10, "(function process-taskable process)"]] + "scene-actor": [[10, "(function process-taskable process)"]], + "scene": [[4, "(function symbol :behavior scene-player)"]], + "sidekick": [ + [5, "(function object vector object string :behavior sidekick)"] + ], + "target-death": [ + [1, "(function symbol :behavior target)"], + [2, "(function symbol :behavior target)"], + [3, "(function none :behavior target)"], + [8, "(function none)"], + [12, "(function process entity-perm-status)"], + [23, "(function surface object object int float :behavior target)"], + [24, "(function surface object object int float :behavior target)"], + [26, "(function continue-point target)"] + ], + "warp-gate": [ + [8, "(function string none)"], + [12, "(function none :behavior target)"] + ] } diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index f27c6c1741..f0b61d0634 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -219,7 +219,10 @@ "(post play-anim scene-player)", "(method 25 scene-player)", "(method 25 scene-player)", - "scene-player-init" + "scene-player-init", + "next-continue", + "(method 25 warp-gate)", + "(code use warp-gate)" ], // If format is used with the wrong number of arguments, @@ -280,7 +283,6 @@ "(method 12 perf-stat)": [0], "(method 11 perf-stat)": [0], - "(method 22 gui-control)": [117, 121, 127, 128, 129, 139], "bsp-camera-asm": [1, 2, 3, 4, 6, 7], "(method 9 texture-page-dir)": [5, 6], "level-remap-texture": [2, 3, 4, 5, 6], @@ -343,7 +345,6 @@ "(method 11 sparticle-launch-control)": [ 18, 24, 25, 28, 29, 32, 33, 34, 36, 41, 55, 58, 93, 95 ], - "(method 22 gui-control)": [ 10, // goto L63 (B39) 16, // goto L58 (B27) @@ -361,10 +362,9 @@ 117, // goto L91 120 ], - "(anon-function 11 game-save)": [0, 3, 4, 5], - - "update-actor-hash": [0, 2, 4] + "update-actor-hash": [0, 2, 4], + "(code target-death)": [111, 140] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index c479c955db..984f50a10c 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -466,5 +466,24 @@ ["L132", "vector"], ["L131", "vector"], ["L130", "vector"] + ], + "sidekick": [["L71", "vector"]], + "target-death": [ + ["L441", "uint64", true], + ["L445", "uint64", true], + ["L447", "uint64", true], + ["L446", "uint64", true], + ["L440", "uint64", true], + ["L449", "uint64", true], + ["L459", "uint64", true], + ["L436", "vector"] + ], + "warp-gate": [ + ["L815", "vector"], + ["L1249", "uint64", true], + ["L1250", "uint64", true], + ["L1158", "vector"], + ["L1222", "uint64", true], + ["L1223", "uint64", true] ] } diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 191ff10b51..dbd50c0ce1 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -1097,5 +1097,10 @@ "(method 150 nav-enemy)": [[16, "vector"]], "(anon-function 88 nav-enemy)": [[16, "vector"]], "(anon-function 93 nav-enemy)": [[16, "vector"]], - "(method 54 rigid-body-platform)": [[16, "vector"]] + "(method 54 rigid-body-platform)": [[16, "vector"]], + "target-carry-update": [[560, ["inline-array", "sphere", 1]]], + "(code target-carry-drop)": [[672, ["inline-array", "sphere", 1]]], + "(code target-carry-throw)": [[640, ["inline-array", "sphere", 1]]], + "(code target-hit)": [[16, "vector"]], + "(method 39 battle)": [[64, "transformq"]] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index 272d639373..f64619586b 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -3485,7 +3485,7 @@ [30, "v1", "collide-shape-moving"] ], "(post fall crate)": [ - [4, "a0", "collide-shape-moving"], + [[4, 10], "a0", "collide-shape-moving"], [15, "v1", "collide-shape-moving"], [26, "v1", "collide-shape-moving"], [[34, 53], "gp", "collide-shape-moving"] @@ -3500,7 +3500,7 @@ [37, "a0", "collide-shape-moving"] ], "(enter fall crate)": [ - [35, "v0", "carry-info"], + [[35, 40], "a0", "carry-info"], [42, "v1", "collide-shape-moving"], [46, "v1", "collide-shape-moving"], [50, "a0", "collide-shape-moving"], @@ -3987,5 +3987,66 @@ "(method 25 remote)": [[[8, 12], "a0", "collide-shape"]], "(method 25 judge)": [[[8, 12], "a0", "collide-shape"]], "(event wait judge)": [[63, "gp", "process-focusable"]], - "(code idle judge)": [[39, "v0", "float"]] + "(code idle judge)": [[39, "v0", "float"]], + "(post sidekick-clone)": [[[474, 513], "gp", "(pointer process-drawable)"]], + "(code target-carry-pickup)": [ + [79, "v0", "carry-info"], + [290, "v0", "carry-info"] + ], + "(code target-carry-drop)": [ + [24, "v0", "carry-info"], + [92, "v1", "art-joint-anim"], + [158, "v0", "carry-info"], + [273, "v0", "carry-info"] + ], + "(code target-carry-throw)": [ + [51, "v0", "carry-info"], + [112, "v0", "carry-info"], + [194, "v0", "carry-info"] + ], + "next-continue": [ + [4, "a2", "symbol"], + [5, "a2", "level-load-info"], + [12, "a3", "continue-point"] + ], + "(code target-continue)": [[643, "s5", "handle"]], + "(code target-warp-in)": [[336, "v1", "art-joint-anim"]], + "target-hit-effect": [[39, "t4", "vector"]], + "target-hit-setup-anim": [ + [153, "v1", "art-joint-anim"], + [225, "v1", "art-joint-anim"] + ], + "(code target-hit)": [[576, "v1", "art-joint-anim"]], + "(anon-function 12 target-death)": [[[12, 19], "gp", "process-drawable"]], + "target-death-reset": [[21, "v1", "connection"]], + "(anon-function 3 target-death)": [[259, "v1", "art-joint-anim"]], + "(anon-function 2 target-death)": [ + [58, "v1", "art-joint-anim"], + [197, "v1", "art-joint-anim"], + [141, "v1", "art-joint-anim"] + ], + "(anon-function 1 target-death)": [[73, "v1", "art-joint-anim"]], + "(event target-continue)": [[18, "a0", "process"]], + "(method 30 battle)": [ + [7, "s5", "nav-enemy"], + [32, "a2", "nav-enemy"] + ], + "(method 7 battle)": [ + [15, "t9", "(function process-drawable int process-drawable)"] + ], + "(method 51 battle)": [[[38, 95], "s4", "touch-tracker"]], + "(method 26 battle)": [ + [35, "a0", "connection"], + [36, "a0", "collide-shape"], + [84, "a0", "connection"], + [85, "a0", "collide-shape"] + ], + "(method 28 battle)": [ + ["_stack_", 16, "res-tag"], + [[21, 31], "s5", "(pointer entity-actor)"] + ], + "(method 29 battle)": [ + ["_stack_", 16, "res-tag"], + ["_stack_", 32, "res-tag"] + ] } diff --git a/decompiler/config/jak2_ntsc_v1.jsonc b/decompiler/config/jak2_ntsc_v1.jsonc index a553e0fd63..ab2695a415 100644 --- a/decompiler/config/jak2_ntsc_v1.jsonc +++ b/decompiler/config/jak2_ntsc_v1.jsonc @@ -7,7 +7,7 @@ // if you want to filter to only some object names. // it will make the decompiler much faster. - "allowed_objects": ["nav-enemy"], + "allowed_objects": [], "banned_objects": ["effect-control", "ctywide-scenes", "texture-anim-tables", "traffic-engine"], //////////////////////////// diff --git a/goal_src/jak2/engine/ai/enemy-h.gc b/goal_src/jak2/engine/ai/enemy-h.gc index bac8fae6e1..80c481d98c 100644 --- a/goal_src/jak2/engine/ai/enemy-h.gc +++ b/goal_src/jak2/engine/ai/enemy-h.gc @@ -7,6 +7,10 @@ (define-extern get-penetrate-using-from-attack-event (function process-drawable event-message-block penetrate)) +;; NOTE - for battle +(declare-type enemy process-focusable) +(define-extern enemy-init-by-other (function process-drawable transformq none :behavior enemy)) + ;; +++enemy-flag (defenum enemy-flag :type int64 @@ -83,8 +87,6 @@ ) ;; ---knocked-type -(declare-type enemy process-focusable) - ;; DECOMP BEGINS (deftype enemy-focus (focus) diff --git a/goal_src/jak2/engine/camera/cam-interface.gc b/goal_src/jak2/engine/camera/cam-interface.gc index dfd7b76b22..3029b8fcb8 100644 --- a/goal_src/jak2/engine/camera/cam-interface.gc +++ b/goal_src/jak2/engine/camera/cam-interface.gc @@ -32,7 +32,7 @@ ) ) -(defun matrix-world->local () +(defun matrix-world->local ((arg0 symbol) (arg1 object)) "Returns [[*math-camera*]]'s `camera-rot`" (-> *math-camera* camera-rot) ) @@ -83,6 +83,7 @@ ) ) +;; WARN: Return type mismatch object vs none. (defbehavior camera-teleport-to-entity process ((arg0 entity-actor)) (let ((gp-0 (new 'stack 'transformq))) (set! (-> gp-0 trans quad) (-> arg0 extra trans quad)) @@ -92,7 +93,3 @@ ) (none) ) - - - - diff --git a/goal_src/jak2/engine/collide/collide-target-h.gc b/goal_src/jak2/engine/collide/collide-target-h.gc index d569057352..84f35238f0 100644 --- a/goal_src/jak2/engine/collide/collide-target-h.gc +++ b/goal_src/jak2/engine/collide/collide-target-h.gc @@ -63,6 +63,7 @@ (unknown-dword02 int64 :offset 4416) (unknown-vector16 vector :inline :offset 4432) (unknown-float14 float :offset 4448) + (unknown-floatiujh1bnb2n3i1 float :offset 4452) (unknown-float15 float :offset 4456) (unknown-word01 int32 :offset 4460) (unknown-vector17 vector :inline :offset 4464) @@ -118,8 +119,7 @@ (unknown-vector29 vector :inline :offset 5168) (unknown-vector30 vector :inline :offset 5184) (unknown-vector31 vector :inline :offset 5200) - (unknown-vector32 vector :inline :offset 5216) - (unknown-vector33 vector :inline :offset 5232) + (unknown-cspacei1un23i1 cspace :inline :offset 5216) (unknown-symbol00 symbol :offset 5248) (unknown-float000 float :offset 5252) (unknown-float31 float :offset 5256) diff --git a/goal_src/jak2/engine/common_objs/crates.gc b/goal_src/jak2/engine/common_objs/crates.gc index b3f255221d..a61c245381 100644 --- a/goal_src/jak2/engine/common_objs/crates.gc +++ b/goal_src/jak2/engine/common_objs/crates.gc @@ -631,7 +631,7 @@ (vector+! (-> self draw origin) (-> self root-override2 trans) (-> self draw bounds)) (set! (-> self draw origin w) (-> self draw bounds w)) (logior! (-> self draw status) (draw-control-status no-draw)) - (let ((v1-9 (-> self root-override2 root-prim))) + (let ((v1-9 (-> (the-as collide-shape-moving (-> self root-override2)) root-prim))) (set! (-> v1-9 prim-core collide-as) (collide-spec)) (set! (-> v1-9 prim-core collide-with) (collide-spec)) ) @@ -650,9 +650,13 @@ (suspend) ) (logclear! (-> self draw status) (draw-control-status no-draw)) - (let ((v1-29 (-> self root-override2 root-prim))) - (set! (-> v1-29 prim-core collide-as) (-> self root-override2 backup-collide-as)) - (set! (-> v1-29 prim-core collide-with) (-> self root-override2 backup-collide-with)) + (let ((v1-29 (-> (the-as collide-shape-moving (-> self root-override2)) root-prim))) + (set! (-> v1-29 prim-core collide-as) + (-> (the-as collide-shape-moving (-> self root-override2)) backup-collide-as) + ) + (set! (-> v1-29 prim-core collide-with) + (-> (the-as collide-shape-moving (-> self root-override2)) backup-collide-with) + ) ) (go-virtual idle) (none) @@ -664,7 +668,7 @@ :event crate-standard-event-handler :code (behavior () (suspend) - (collide-shape-method-46 (-> self root-override2)) + (collide-shape-method-46 (the-as collide-shape-moving (-> self root-override2))) (carry-info-method-9 (-> self carry)) (logior! (-> self mask) (process-mask sleep)) (until #f @@ -694,7 +698,7 @@ (ja-post) (carry-info-method-9 (-> self carry)) (carry-info-method-13 (-> self carry)) - (collide-shape-method-46 (-> self root-override2)) + (collide-shape-method-46 (the-as collide-shape-moving (-> self root-override2))) (none) ) ) @@ -731,16 +735,22 @@ (none) ) :trans (behavior () - (when (and (logtest? (-> self root-override2 status) (cshape-moving-flags on-surface)) - (< 0.8 (-> self root-override2 surface-angle)) + (when (and (logtest? (-> (the-as collide-shape-moving (-> self root-override2)) status) (cshape-moving-flags on-surface)) + (< 0.8 (-> (the-as collide-shape-moving (-> self root-override2)) surface-angle)) ) (vector-reset! (-> self root-override2 transv)) (when (= (vector-length (-> self root-override2 transv)) 0.0) - (set! (-> self root-override2 root-prim local-sphere w) (-> self carry backup-radius)) + (set! (-> (the-as collide-shape-moving (-> self root-override2)) root-prim local-sphere w) + (-> self carry backup-radius) + ) (set! (-> self base quad) (-> self root-override2 trans quad)) - (let ((v1-16 (-> self root-override2 root-prim))) - (set! (-> v1-16 prim-core collide-as) (-> self root-override2 backup-collide-as)) - (set! (-> v1-16 prim-core collide-with) (-> self root-override2 backup-collide-with)) + (let ((v1-16 (-> (the-as collide-shape-moving (-> self root-override2)) root-prim))) + (set! (-> v1-16 prim-core collide-as) + (-> (the-as collide-shape-moving (-> self root-override2)) backup-collide-as) + ) + (set! (-> v1-16 prim-core collide-with) + (-> (the-as collide-shape-moving (-> self root-override2)) backup-collide-with) + ) ) (go-virtual idle) ) @@ -751,10 +761,15 @@ :post (behavior () (vector-v++! (-> self root-override2 transv) - (compute-acc-due-to-gravity (-> self root-override2) (new-stack-vector0) 0.0) + (compute-acc-due-to-gravity (the-as collide-shape-moving (-> self root-override2)) (new-stack-vector0) 0.0) ) - (if (< (-> self root-override2 dynam gravity-max) (vector-length (-> self root-override2 transv))) - (vector-normalize! (-> self root-override2 transv) (-> self root-override2 dynam gravity-max)) + (if (< (-> (the-as collide-shape-moving (-> self root-override2)) dynam gravity-max) + (vector-length (-> self root-override2 transv)) + ) + (vector-normalize! + (-> self root-override2 transv) + (-> (the-as collide-shape-moving (-> self root-override2)) dynam gravity-max) + ) ) (let ((gp-1 (-> self root-override2))) (let ((a2-1 (new 'stack-no-clear 'collide-query))) @@ -814,13 +829,13 @@ ) (when v1-3 (let* ((gp-1 (-> (the-as process-drawable v1-3) root)) - (v1-4 (if (type? gp-1 collide-shape) + (v1-4 (if (type? (the-as collide-shape-moving gp-1) collide-shape) gp-1 ) ) ) (when v1-4 - (let* ((gp-2 (-> self root-override2 root-prim prim-core)) + (let* ((gp-2 (-> (the-as collide-shape-moving (-> self root-override2)) root-prim prim-core)) (a1-3 (-> (the-as collide-shape-moving v1-4) root-prim prim-core)) (f30-0 (vector-vector-distance (the-as vector gp-2) (the-as vector a1-3))) ) @@ -1142,7 +1157,7 @@ ) ) ) - (let ((v1-20 (-> self root-override2 root-prim))) + (let ((v1-20 (-> (the-as collide-shape-moving (-> self root-override2)) root-prim))) (set! (-> v1-20 prim-core collide-as) (collide-spec)) (set! (-> v1-20 prim-core collide-with) (collide-spec)) ) @@ -1284,7 +1299,7 @@ "Initialize the [[crate]]'s skeleton and other parameters based on the crate type." (case (-> obj look) (('iron) - (set! (-> obj root-override2 penetrated-by) + (set! (-> (the-as collide-shape-moving (-> obj root-override2)) penetrated-by) (penetrate flop uppercut tube vehicle flut-attack board dark-skin explode) ) (initialize-skeleton @@ -1294,7 +1309,9 @@ ) ) (('steel) - (set! (-> obj root-override2 penetrated-by) (penetrate tube vehicle flut-attack board dark-skin explode)) + (set! (-> (the-as collide-shape-moving (-> obj root-override2)) penetrated-by) + (penetrate tube vehicle flut-attack board dark-skin explode) + ) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-crate-krimson" (the-as (pointer uint32) #f))) diff --git a/goal_src/jak2/engine/common_objs/generic-obs.gc b/goal_src/jak2/engine/common_objs/generic-obs.gc index 22020aff83..094c9eccf4 100644 --- a/goal_src/jak2/engine/common_objs/generic-obs.gc +++ b/goal_src/jak2/engine/common_objs/generic-obs.gc @@ -64,7 +64,7 @@ (draw-control-method-14 (-> self draw) (-> self node-list) (-> self skel)) (let ((a0-22 (-> self skel effect))) (if a0-22 - ((method-of-object a0-22 effect-control-method-9)) + (effect-control-method-9 a0-22) ) ) (if (logtest? (-> self skel status) (joint-control-status blend-shape blend-shape-valid)) @@ -94,4 +94,4 @@ (logclear! (-> self skel status) (joint-control-status valid-spooled-frame)) 0 (none) - ) \ No newline at end of file + ) diff --git a/goal_src/jak2/engine/common_objs/voicebox.gc b/goal_src/jak2/engine/common_objs/voicebox.gc index e008dcf065..eceada6d3c 100644 --- a/goal_src/jak2/engine/common_objs/voicebox.gc +++ b/goal_src/jak2/engine/common_objs/voicebox.gc @@ -446,7 +446,7 @@ ) ) (if *target* - (set! (-> *game-info* score) (-> *target* fact-info-override trick-point)) + (set! (-> *game-info* score) (-> *target* fact-override trick-point)) ) (let ((v1-15 (the-as int (- (-> obj total-time) (- (-> *display* game-clock frame-counter) (-> obj start-time)))))) (if (< (the-as time-frame v1-15) 0) diff --git a/goal_src/jak2/engine/game/effect-control-h.gc b/goal_src/jak2/engine/game/effect-control-h.gc index 653b54b7b9..983205d3ce 100644 --- a/goal_src/jak2/engine/game/effect-control-h.gc +++ b/goal_src/jak2/engine/game/effect-control-h.gc @@ -59,7 +59,7 @@ :flag-assert #xf00000024 (:methods (new (symbol type process-drawable) _type_ 0) - (effect-control-method-9 () none 9) + (effect-control-method-9 (_type_) none 9) (effect-control-method-10 () none 10) (effect-control-method-11 () none 11) (effect-control-method-12 (_type_ symbol float int basic sound-name) int 12) @@ -68,6 +68,7 @@ ) ) + (defmethod new effect-control ((allocation symbol) (type-to-make type) (arg0 process-drawable)) (cond ((res-lump-struct (-> arg0 draw jgeo extra) 'effect-name structure) @@ -88,4 +89,3 @@ 0 (none) ) - diff --git a/goal_src/jak2/engine/game/fact-h.gc b/goal_src/jak2/engine/game/fact-h.gc index bfa1e2447f..17abfc46e9 100644 --- a/goal_src/jak2/engine/game/fact-h.gc +++ b/goal_src/jak2/engine/game/fact-h.gc @@ -197,7 +197,113 @@ ) (defun pickup-type->string ((arg0 pickup-type)) - (enum->string pickup-type arg0) + (case arg0 + (((pickup-type eco-pill-dark)) + "eco-pill-dark" + ) + (((pickup-type gun-blue)) + "gun-blue" + ) + (((pickup-type ammo-random)) + "ammo-random" + ) + (((pickup-type eco-blue)) + "eco-blue" + ) + (((pickup-type gun-red)) + "gun-red" + ) + (((pickup-type pass-red)) + "pass-red" + ) + (((pickup-type eco-pill-green)) + "eco-pill-green" + ) + (((pickup-type eco-red)) + "eco-red" + ) + (((pickup-type skill)) + "skill" + ) + (((pickup-type karma)) + "karma" + ) + (((pickup-type gun-dark)) + "gun-dark" + ) + (((pickup-type eco-dark)) + "eco-dark" + ) + (((pickup-type gem)) + "gem" + ) + (((pickup-type eco-green)) + "eco-green" + ) + (((pickup-type darkjak)) + "darkjak" + ) + (((pickup-type ammo-yellow)) + "ammo-yellow" + ) + (((pickup-type pass-blue)) + "pass-blue" + ) + (((pickup-type ammo-red)) + "ammo-red" + ) + (((pickup-type fuel-cell)) + "fuel-cell" + ) + (((pickup-type buzzer)) + "buzzer" + ) + (((pickup-type shield)) + "shield" + ) + (((pickup-type eco-pill-random)) + "eco-pill-random" + ) + (((pickup-type board)) + "board" + ) + (((pickup-type none)) + "none" + ) + (((pickup-type pass-green)) + "pass-green" + ) + (((pickup-type gun-yellow)) + "gun-yellow" + ) + (((pickup-type money)) + "money" + ) + (((pickup-type eco-yellow)) + "eco-yellow" + ) + (((pickup-type ammo-dark)) + "ammo-dark" + ) + (((pickup-type trick-judge)) + "trick-judge" + ) + (((pickup-type trick-point)) + "trick-point" + ) + (((pickup-type ammo-blue)) + "ammo-blue" + ) + (((pickup-type pass-yellow)) + "pass-yellow" + ) + (((pickup-type health)) + "health" + ) + (else + "*unknown*" + ) + ) ) (deftype fact-info (basic) diff --git a/goal_src/jak2/engine/game/game-save.gc b/goal_src/jak2/engine/game/game-save.gc index 84270c4f57..388543171f 100644 --- a/goal_src/jak2/engine/game/game-save.gc +++ b/goal_src/jak2/engine/game/game-save.gc @@ -5,6 +5,10 @@ ;; name in dgo: game-save ;; dgos: ENGINE, GAME +;; NOTE - for default-menu +(declare-type auto-save process) +(define-extern auto-save-command (function symbol int int process-tree symbol (pointer auto-save))) + (defenum game-save-elt :type uint16 (task-deaths 402) diff --git a/goal_src/jak2/engine/target/logic-target.gc b/goal_src/jak2/engine/target/logic-target.gc index d008f668cc..56c3165c4f 100644 --- a/goal_src/jak2/engine/target/logic-target.gc +++ b/goal_src/jak2/engine/target/logic-target.gc @@ -562,14 +562,7 @@ (defbehavior set-pad target ((arg0 vector)) (set! (-> self control unknown-float12) (vector-length arg0)) - (let ((s5-0 vector-matrix*!) - (s4-0 (-> self control unknown-vector12)) - (s3-0 arg0) - (t9-0 matrix-world->local) - ) - #t - (s5-0 s4-0 s3-0 (t9-0)) - ) + (vector-matrix*! (-> self control unknown-vector12) arg0 (matrix-world->local #t #f)) arg0 ) @@ -2495,7 +2488,10 @@ ) (vector-matrix*! (-> self control unknown-vector28) (-> *TARGET-bank* head-offset) a2-5) ) - (vector<-cspace! (-> self control unknown-vector33) (the-as cspace (-> self control unknown-vector32 x))) + (vector<-cspace! + (the-as vector (&-> (-> self control) unknown-cspacei1un23i1 bone)) + (-> self control unknown-cspacei1un23i1 parent) + ) (let ((gp-0 (new-stack-vector0)) (s5-0 (new-stack-vector0)) ) @@ -3283,7 +3279,7 @@ (set! (-> obj control unknown-vector29 x) (the-as float (-> obj node-list data 45))) (set! (-> obj control unknown-vector29 y) (the-as float (-> obj node-list data 55))) (set! (-> obj control unknown-vector29 y) (the-as float (-> obj node-list data 55))) - (set! (-> obj control unknown-vector32 x) (the-as float (-> obj node-list data 23))) + (set! (-> obj control unknown-cspacei1un23i1 parent) (-> obj node-list data 23)) (set! (-> obj neck) (new 'process 'joint-mod (joint-mod-mode look-at) obj 8)) (set! (-> obj neck parented-scale?) #t) (set! (-> obj neck base-joint) (the-as uint 6)) diff --git a/goal_src/jak2/engine/target/sidekick.gc b/goal_src/jak2/engine/target/sidekick.gc index 12ff893b20..cf111e7c1a 100644 --- a/goal_src/jak2/engine/target/sidekick.gc +++ b/goal_src/jak2/engine/target/sidekick.gc @@ -5,5 +5,510 @@ ;; name in dgo: sidekick ;; dgos: ENGINE, GAME +(declare-type sidekick process-drawable) +(define-extern init-sidekick (function none :behavior sidekick)) + ;; DECOMP BEGINS +(defskelgroup skel-sidekick daxter 0 -1 + ((1 (meters 999999))) + :bounds (static-spherem 0 0 0 3) + :longest-edge (meters 1) + :shadow 3 + :texture-level 6 + :sort 1 + :origin-joint-index 6 + :shadow-joint-index 6 + ) + +(defskelgroup skel-sidekick-highres daxter-highres 0 -1 + ((1 (meters 999999))) + :bounds (static-spherem 0 0 0 3) + :longest-edge (meters 1) + :shadow 2 + :sort 1 + :origin-joint-index 6 + :shadow-joint-index 6 + ) + +(define *sidekick-remap* + '(("run-to-stance-left" "run-to-stance") + ("run-to-stance-loop-left" "run-to-stance-loop") + ("stance-loop-left" "stance-loop") + ("run-to-stance-right" "run-to-stance") + ("run-to-stance-loop-right" "run-to-stance-loop") + ("stance-loop-right" "stance-loop") + ("run-to-stance-up" "run-to-stance") + ("run-to-stance-loop-up" "run-to-stance-loop") + ("stance-loop-up" "stance-loop") + ("run-to-stance-down" "run-to-stance") + ("run-to-stance-loop-down" "run-to-stance-loop") + ("stance-loop-down" "stance-loop") + ("run-right" "run") + ("run-left" "run") + ("walk-right" "walk") + ("walk-left" "walk") + ("gun-hit-elec" "hit-elec") + ("gun-attack-from-stance-end" + "gun-attack-from-stance-end" + "gun-attack-from-stance-end" + "gun-attack-from-stance-end" + "gun-attack-from-stance-end-alt1" + ) + ("gun-attack-butt-end" + "gun-attack-butt-end" + "gun-attack-butt-end" + "gun-attack-butt-end" + "gun-attack-butt-end" + "gun-attack-butt-end-alt1" + ) + ("pole-cycle" "pole-cycle" "pole-cycle2") + ("hit-from-front-alt1" "hit-from-front") + ("board-jump" + ,(lambda :behavior sidekick + ((arg0 object) (arg1 vector) (arg2 object)) + (let* ((v1-0 (-> self parent-override)) + (gp-0 (if v1-0 + (-> v1-0 0 self-override) + ) + ) + ) + (when (>= (- (-> self clock frame-counter) (-> self special-anim-time)) (seconds 1)) + (set! (-> self special-anim-interp) 0.0) + (set! (-> self special-anim-frame) 0.0) + ) + (cond + ((or (and (= (-> gp-0 control unknown-surface00 name) 'spin) (!= (-> gp-0 board trotyv) 0.0)) + (!= (-> self special-anim-interp) 0.0) + ) + (case arg2 + ((1) + (set! (-> self special-anim-time) (-> self clock frame-counter)) + (cond + ((= (-> gp-0 control unknown-surface00 name) 'spin) + (set! (-> arg1 z) + (* (lerp-scale 0.0 5.0 (fabs (-> gp-0 board trotyv)) 0.0 182044.44) (-> self special-anim-interp)) + ) + (set! (-> self special-anim-frame) (-> arg1 z)) + (seek! (-> self special-anim-interp) 1.0 (* 8.0 (-> self clock seconds-per-frame))) + ) + (else + (seek! (-> self special-anim-interp) 0.0 (* 4.0 (-> self clock seconds-per-frame))) + (set! (-> arg1 z) (* (-> self special-anim-frame) (-> self special-anim-interp))) + ) + ) + ) + ) + (if (>= (-> gp-0 board trotyv) 0.0) + "board-spin-ccw" + "board-spin-cw" + ) + ) + (else + "board-jump" + ) + ) + ) + ) + ) + ) + ) + +(defun cspace<-cspace+transformq! ((arg0 cspace) (arg1 cspace) (arg2 transformq)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (-> arg0 bone transform))) + (quaternion->matrix s4-0 (-> arg2 quat)) + (.lvf vf1 (&-> (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) quad)) + (.lvf vf2 (&-> (-> arg1 bone) transform trans quad)) + (.lvf vf6 (&-> arg2 trans quad)) + (.lvf vf3 (&-> s4-0 vector 0 quad)) + (.lvf vf4 (&-> s4-0 vector 1 quad)) + (.lvf vf5 (&-> s4-0 vector 2 quad)) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf vf2 vf2 Q :mask #b111) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.mul.x.vf acc vf3 vf6) + (.add.mul.y.vf acc vf4 vf6 acc) + (.add.mul.z.vf acc vf5 vf6 acc) + (.add.mul.w.vf vf2 vf2 vf0 acc :mask #b111) + (.svf (&-> s4-0 trans quad) vf2) + (.svf (&-> s4-0 vector 0 quad) vf3) + (.svf (&-> s4-0 vector 1 quad) vf4) + (.svf (&-> s4-0 vector 2 quad) vf5) + s4-0 + ) + ) + ) + +(defbehavior target-sidekick-setup target ((arg0 symbol)) + (if (zero? (-> self sidekick)) + (set! (-> self sidekick) (the-as (pointer sidekick) #f)) + ) + (cond + (arg0 + (if (not (-> self sidekick)) + (set! (-> self sidekick) (process-spawn sidekick :init init-sidekick :from *16k-dead-pool* :to self)) + ) + ) + ((-> self sidekick) + (deactivate (-> self sidekick 0)) + (set! (-> self sidekick) (the-as (pointer sidekick) #f)) + ) + ) + 0 + (none) + ) + +(defstate sidekick-clone (sidekick) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (local-vars (v0-0 object)) + (case event-type + (('matrix) + (case (-> event param 0) + (('play-anim) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace+transformq!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 node-list data)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) (the-as basic (-> self offset))) + ) + (('copy-parent) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 node-list data)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) #f) + ) + (('root) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace-normalized!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 node-list data)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) #f) + ) + (('indax) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-transformq+trans!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 control trans)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) + (the-as basic (-> self parent-override 0 control unknown-vector05)) + ) + ) + (('board) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace-normalized!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 node-list data 25)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) #f) + ) + (else + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace+transformq!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 control unknown-cspacei1un23i1 parent)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) (the-as basic (-> self offset))) + ) + ) + v0-0 + ) + (('shadow) + (set! v0-0 (-> event param 0)) + (set! (-> self shadow-in-movie?) (the-as symbol v0-0)) + v0-0 + ) + (('blend-shape) + (cond + ((-> event param 0) + (set! v0-0 (logior (-> self skel status) (joint-control-status blend-shape))) + (set! (-> self skel status) (the-as joint-control-status v0-0)) + ) + (else + (set! v0-0 (logclear (-> self skel status) (joint-control-status blend-shape))) + (set! (-> self skel status) (the-as joint-control-status v0-0)) + ) + ) + v0-0 + ) + ) + ) + :code (the-as (function none :behavior sidekick) looping-code) + :post (behavior () + (let ((v1-0 (-> self parent-override))) + (when (not (and (-> (if v1-0 + (-> v1-0 0 self-override) + ) + next-state + ) + (let ((v1-4 (-> self parent-override))) + (= (-> (if v1-4 + (-> v1-4 0 self-override) + ) + next-state + name + ) + 'process-drawable-art-error + ) + ) + ) + ) + (quaternion-rotate-y! + (-> self root quat) + (-> self parent-override 0 control quat) + (-> self parent-override 0 upper-body twist z) + ) + (set! (-> self anim-seed) (-> self parent-override 0 anim-seed)) + (set! (-> self draw status) (-> self parent-override 0 draw status)) + (logclear! (-> self draw status) (draw-control-status no-draw-bounds2)) + (let ((gp-0 0)) + (cond + ((and (not (logtest? (-> self parent-override 0 focus-status) (focus-status edge-grab))) + (> (-> self parent-override 0 skel float-channels) 0) + ) + (let ((gp-1 (-> self skel))) + (joint-control-copy! gp-1 (-> self parent-override 0 skel)) + (set! (-> gp-1 root-channel) + (the-as (inline-array joint-control-channel) (-> gp-1 channel (-> gp-1 active-channels))) + ) + (dotimes (s5-0 (the-as int (-> self parent-override 0 skel float-channels))) + (let ((s4-0 (-> gp-1 channel (+ s5-0 (-> gp-1 active-channels))))) + (mem-copy! + (the-as pointer s4-0) + (the-as + pointer + (-> self parent-override 0 skel channel (+ s5-0 (-> self parent-override 0 skel active-channels))) + ) + 64 + ) + (set! (-> s4-0 frame-interp 0) (-> s4-0 frame-interp 1)) + (set! (-> s4-0 command) (joint-control-command blend)) + ) + ) + (dotimes (v1-58 (the-as int (-> gp-1 allocated-length))) + (set! (-> gp-1 channel v1-58 parent) gp-1) + ) + (+! (-> gp-1 active-channels) (-> self parent-override 0 skel float-channels)) + (set! (-> gp-1 float-channels) (the-as uint 0)) + ) + (set! gp-0 1) + ) + (else + (joint-control-copy! (-> self skel) (-> self parent-override 0 skel)) + ) + ) + (joint-control-remap! + (-> self skel) + (-> self draw art-group) + (-> self parent-override 0 draw art-group) + *sidekick-remap* + (the-as int (-> self anim-seed)) + "" + ) + (cond + ((zero? gp-0) + (set! (-> self skel effect channel-offset) (-> self parent-override 0 skel effect channel-offset)) + ) + ((= gp-0 1) + (set! (-> self skel effect channel-offset) 0) + 0 + ) + ) + ) + (let ((v1-85 (-> self parent-override 0 draw color-mult quad))) + (set! (-> self draw color-mult quad) v1-85) + ) + (let ((v1-89 (-> self parent-override 0 draw color-emissive quad))) + (set! (-> self draw color-emissive quad) v1-89) + ) + (set! (-> self draw force-fade) (-> self parent-override 0 draw force-fade)) + (set! (-> self draw death-vertex-skip) (-> self parent-override 0 draw death-vertex-skip)) + (set! (-> self draw death-effect) (-> self parent-override 0 draw death-effect)) + (set! (-> self draw death-timer) (-> self parent-override 0 draw death-timer)) + (set! (-> self draw death-timer-org) (-> self parent-override 0 draw death-timer-org)) + (set! (-> self draw death-draw-overlap) (-> self parent-override 0 draw death-draw-overlap)) + (quaternion-copy! (-> self offset quat) (-> self root quat)) + (let ((f0-3 (* (-> self parent-override 0 darkjak-interp) (-> self parent-override 0 darkjak-giant-interp)))) + (set! (-> self offset trans x) (* 286.72 f0-3)) + (set! (-> self offset trans y) (* 204.8 f0-3)) + (set! (-> self offset trans z) (* 409.6 f0-3)) + ) + (joint-control-method-10 (-> self skel)) + (when *debug-segment* + (let ((gp-2 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-132 'target-post) + (s5-1 *profile-target-post-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-1 (-> gp-2 data (-> gp-2 count)))) + (let ((s3-0 (-> gp-2 base-time))) + (set! (-> s4-1 name) v1-132) + (set! (-> s4-1 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-1 depth) (the-as uint (-> gp-2 depth))) + (set! (-> s4-1 color) s5-1) + (set! (-> gp-2 segment (-> gp-2 depth)) s4-1) + ) + (+! (-> gp-2 count) 1) + (+! (-> gp-2 depth) 1) + (set! (-> gp-2 max-depth) (max (-> gp-2 max-depth) (-> gp-2 depth))) + ) + ) + 0 + ) + (draw-control-method-14 (-> self draw) (-> self node-list) (-> self skel)) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-158 (+ (-> gp-3 depth) -1)) + (s5-2 (-> gp-3 segment v1-158)) + (s4-2 (-> gp-3 base-time)) + ) + (when (>= v1-158 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-2)))) + (+! (-> gp-3 depth) -1) + ) + ) + ) + ) + 0 + ) + ) + ) + (when *display-sidekick-stats* + (format *stdcon* "~%") + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) + (add-debug-sphere + *display-sidekick-stats* + (bucket-id debug-no-zbuf1) + (-> self parent-override 0 control unknown-cspacei1un23i1 parent bone transform trans) + (meters 0.1) + (new 'static 'rgba :g #xff :a #x80) + ) + (add-debug-sphere + *display-sidekick-stats* + (bucket-id debug-no-zbuf1) + (-> self node-list data 3 bone transform trans) + (meters 0.1) + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + (add-debug-sphere + *display-sidekick-stats* + (bucket-id debug-no-zbuf1) + (-> self node-list data 0 bone transform trans) + (meters 0.1) + (new 'static 'rgba :r #xff :a #x80) + ) + (add-debug-matrix + *display-sidekick-stats* + (bucket-id debug-no-zbuf1) + (-> self node-list data 0 bone transform) + (meters 2) + ) + ) + (set! (-> self draw shadow) + (the-as shadow-geo (if (or (and (movie?) (-> self shadow-in-movie?)) + (logtest? (focus-status indax) (-> self parent-override 0 focus-status)) + ) + (-> self draw art-group data 3) + ) + ) + ) + (let ((a0-53 (-> self skel effect))) + (if a0-53 + (effect-control-method-9 a0-53) + ) + ) + (if (logtest? (-> self skel status) (joint-control-status blend-shape blend-shape-valid)) + (merc-blend-shape self) + ) + (if (logtest? (-> self skel status) (joint-control-status eye-anim-valid eye-anim)) + (merc-eye-anim self) + ) + (when (!= (not (-> *setting-control* user-current mirror)) (not (-> self mirror))) + (cond + ((-> self mirror) + (deactivate (-> self mirror 0)) + (set! (-> self mirror) (the-as (pointer process-drawable) #f)) + ) + (else + (let* ((s5-3 (get-process *default-dead-pool* manipy #x4000)) + (gp-4 + (when s5-3 + (let ((t9-22 (method-of-type manipy activate))) + (t9-22 (the-as manipy s5-3) self (symbol->string (-> manipy symbol)) (the-as pointer #x70004000)) + ) + (let ((gp-5 run-function-in-process) + (s4-3 s5-3) + (s3-1 manipy-init) + (s2-0 (-> self root trans)) + (s1-0 (-> self entity)) + (t0-4 (art-group-get-by-name *level* "skel-sidekick" (the-as (pointer uint32) #f))) + (t1-1 #f) + ) + 0 + ((the-as (function object object object object object object none) gp-5) s4-3 s3-1 s2-0 s1-0 t0-4 t1-1) + ) + (the-as (pointer process-drawable) (-> s5-3 ppointer)) + ) + ) + ) + (send-event (ppointer->process gp-4) 'anim-mode 'mirror) + (send-event (ppointer->process gp-4) 'mirror #t) + (set! (-> self mirror) gp-4) + (let ((v0-29 (-> gp-4 0 node-list data))) + (set! (-> v0-29 0 param0) cspace<-cspace!) + (set! (-> v0-29 0 param1) (the-as basic (-> self node-list data))) + (set! (-> v0-29 0 param2) #f) + ) + ) + ) + ) + ) + (none) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior init-sidekick sidekick () + (set! (-> self mask) (logior (process-mask sidekick) (-> self mask))) + (set! (-> self root) (new 'process 'trsqv)) + (vector-identity! (-> self root scale)) + (quaternion-identity! (-> self root quat)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-sidekick" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (set! (-> self draw shadow-ctrl) *target-shadow-control*) + (logior! (-> self skel status) (joint-control-status sync-math blend-shape eye-anim)) + (set! (-> self draw light-index) (the-as uint 30)) + (let ((v1-14 (-> self node-list data))) + (set! (-> v1-14 0 param0) cspace<-cspace+transformq!) + (set! (-> v1-14 0 param1) (the-as basic (-> self parent-override 0 control unknown-cspacei1un23i1 parent))) + (set! (-> v1-14 0 param2) (the-as basic (-> self offset))) + ) + (set! (-> self shadow-in-movie?) #t) + (set! (-> self mirror) (the-as (pointer process-drawable) #f)) + (go sidekick-clone) + (none) + ) diff --git a/goal_src/jak2/engine/target/target-carry.gc b/goal_src/jak2/engine/target/target-carry.gc index fa8d648a5b..985e5ba02d 100644 --- a/goal_src/jak2/engine/target/target-carry.gc +++ b/goal_src/jak2/engine/target/target-carry.gc @@ -7,3 +7,820 @@ ;; DECOMP BEGINS +(define *carry-walk-mods* (new 'static 'surface + :name 'run + :turnv 524288.0 + :turnvv 910222.25 + :tiltv 65536.0 + :tiltvv 262144.0 + :transv-max 24576.0 + :target-speed 24576.0 + :seek0 1.0 + :seek90 1.0 + :seek180 1.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 + :turnvf 30.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :flags (surface-flag look-around no-turn-around gun-off) + ) + ) + +(define *carry-jump-mods* (new 'static 'surface + :name 'jump + :turnv 524288.0 + :turnvv 910222.25 + :tiltv 65536.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 30.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :mode 'air + :flags (surface-flag air gun-off) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior target-carry-update target () + (carry-info-method-9 (-> self carry)) + (when (and (= (-> self control unknown-symbol00) 'carry) (< (-> self control unknown-float000) 1.0)) + (let ((gp-0 (new 'stack-no-clear 'collide-query)) + (s5-0 (new 'stack-no-clear 'inline-array 'sphere 1)) + ) + (dotimes (s4-0 1) + ((method-of-type sphere new) (the-as symbol (-> s5-0 s4-0)) sphere) + ) + (let ((f30-0 (seek (-> self control unknown-float000) 1.0 (* 0.1 (-> self clock time-adjust-ratio))))) + (set! (-> s5-0 0 quad) (-> self control unknown-sphere-array00 2 prim-core world-sphere quad)) + (set! (-> s5-0 0 r) (lerp-scale (-> *TARGET-bank* body-radius) 7372.8 f30-0 0.0 1.0)) + (let ((v1-17 gp-0)) + (set! (-> v1-17 spheres) 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! 'carry f30-0) + ) + ) + ) + ) + (send-event (handle->process (-> self carry other)) 'carry (-> self carry)) + (none) + ) + +;; WARN: Return type mismatch focus-status vs none. +(defbehavior target-carry-post target () + (target-post) + (target-carry-update) + (set! (-> self focus-status) (logior (focus-status carry) (-> self focus-status))) + (none) + ) + +(defstate target-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-standard-event-handler proc arg1 event-type event) + ) + ) + ) + (else + (target-standard-event-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control unknown-surface00) *walk-mods*) + (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) 12288.0) + (set! (-> self carry mode) (carry-mode carry)) + (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-carry-stance) + (= v1-3 'target-carry-walk) + (= v1-3 'target-carry-drop) + (= v1-3 'target-carry-throw) + (= v1-3 'target-carry-jump) + (= v1-3 'target-carry-falling) + (= v1-3 'target-carry-hit-ground) + (= v1-3 'target-carry-throw) + ) + ) + ) + ) + (logclear! (-> self focus-status) (focus-status carry)) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'normal 0.0) + (target-exit) + ) + (none) + ) + :code (behavior () + (let ((f30-0 0.0)) + (let ((f28-0 0.0)) + (ja-channel-push! 2 (seconds 0.1)) + (target-danger-set! 'carry? #f) + (ja :group! (-> self draw art-group data 319) :num! min) + (let ((a0-3 (-> self skel root-channel 1))) + (set! (-> a0-3 frame-interp 1) f30-0) + (set! (-> a0-3 frame-interp 0) f30-0) + (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> self draw art-group data 318))) + (set! (-> a0-3 param 0) 0.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim (-> self draw art-group data 318)) + num-func-chan + ) + ) + (suspend) + (format #t "carry picked ~A~%" (handle->process (-> self carry other))) + (let ((a1-5 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-5 from) (process->ppointer self)) + (set! (-> a1-5 num-params) 0) + (set! (-> a1-5 message) 'carry-info) + (let ((gp-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-5)))) + (when gp-1 + (let* ((s5-1 (vector-! (new 'stack-no-clear 'vector) (-> gp-1 point) (-> self control trans))) + (s4-0 (new-stack-vector0)) + (f26-0 (vector-dot (-> self control local-normal) s5-1)) + ) + 0.0 + (vector-! s4-0 s5-1 (vector-float*! s4-0 (-> self control local-normal) f26-0)) + (let* ((f24-0 (vector-length s4-0)) + (f22-0 f24-0) + ) + (set! f28-0 (lerp-scale 1.0 0.0 f26-0 1638.4 4505.6)) + (vector+! + s5-1 + (vector-float*! s5-1 (-> self control local-normal) f26-0) + (vector-float*! s4-0 s4-0 (/ f24-0 f22-0)) + ) + ) + ) + (forward-up-nopitch->quaternion + (-> self control dir-targ) + (vector-normalize! (vector-! (new-stack-vector0) (-> gp-1 point) (-> self control trans)) 1.0) + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + ) + (target-danger-set! 'harmless #f) + (ja-no-eval :num! (seek! (ja-aframe 5.0 0))) + (while (not (ja-done? 0)) + (set! f30-0 (seek f30-0 f28-0 (* 5.0 (-> self clock seconds-per-frame)))) + (let ((v1-45 (-> self skel root-channel 1))) + (set! (-> v1-45 frame-interp 1) f30-0) + (set! (-> v1-45 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + (when (send-event (handle->process (-> self carry other)) 'pickup (-> self carry)) + (target-collide-set! 'carry 0.0) + (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-70 (-> self skel root-channel 1))) + (set! (-> v1-70 frame-interp 1) f30-0) + (set! (-> v1-70 frame-interp 0) f30-0) + ) + (when (< 22.0 (ja-aframe-num 0)) + (let ((a1-22 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-22 from) (process->ppointer self)) + (set! (-> a1-22 num-params) 0) + (set! (-> a1-22 message) 'carry-info) + (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-22)))) + (if gp-4 + (seek! (-> gp-4 grab-trans-blend) 0.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + (go target-carry-stance) + ) + ) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (let ((v1-93 (-> self skel root-channel 1))) + (set! (-> v1-93 frame-interp 1) f30-0) + (set! (-> v1-93 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + ) + (go target-stance) + (none) + ) + :post (behavior () + (target-no-stick-post) + (carry-info-method-9 (-> self carry)) + (target-carry-update) + (none) + ) + ) + +(defstate target-carry-drop (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (none) + ) + :code (behavior () + (let ((f30-0 1.0)) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) (process->ppointer self)) + (set! (-> a1-0 num-params) 0) + (set! (-> a1-0 message) 'carry-info) + (let ((a0-5 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-0)))) + (when a0-5 + (let ((gp-0 (new 'stack-no-clear 'vector))) + (set! (-> gp-0 quad) (-> a0-5 point quad)) + (set! (-> gp-0 y) (- (-> gp-0 y) (-> a0-5 process 0 control root-prim prim-core world-sphere w))) + (let ((s5-0 (new-stack-vector0)) + (f28-0 (vector-dot (-> self control local-normal) gp-0)) + ) + 0.0 + (vector-! s5-0 gp-0 (vector-float*! s5-0 (-> self control local-normal) f28-0)) + (let* ((f26-0 (vector-length s5-0)) + (f24-0 f26-0) + ) + (set! f30-0 (lerp-scale 1.0 0.0 f28-0 1638.4 4505.6)) + (vector+! + gp-0 + (vector-float*! gp-0 (-> self control local-normal) f28-0) + (vector-float*! s5-0 s5-0 (/ f26-0 f24-0)) + ) + ) + ) + ) + ) + ) + ) + (ja-channel-push! 2 (seconds 0.1)) + (ja :group! (-> self draw art-group data 319) + :num! (identity (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 319)) frames num-frames) -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 frame-group) (the-as art-joint-anim (-> self draw art-group data 318))) + (set! (-> a0-16 param 0) 0.0) + (joint-control-channel-group-eval! + a0-16 + (the-as art-joint-anim (-> self draw art-group data 318)) + num-func-chan + ) + ) + ) + (suspend) + (ja-no-eval :num! (seek! (ja-aframe 5.0 0))) + (while (not (ja-done? 0)) + (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 ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-9)))) + (when gp-4 + (if (< 22.0 (ja-aframe-num 0)) + (seek! (-> gp-4 grab-trans-blend) 1.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + (let ((s4-0 (-> gp-4 process 0 control)) + (gp-5 (new 'stack-no-clear 'collide-query)) + ) + (let ((s5-1 (new 'stack-no-clear 'inline-array 'sphere 1))) + (dotimes (s3-0 1) + ((method-of-type sphere new) (the-as symbol (-> s5-1 s3-0)) sphere) + ) + (set! (-> s5-1 0 quad) (-> s4-0 root-prim prim-core world-sphere quad)) + (let ((v1-64 gp-5)) + (set! (-> v1-64 spheres) s5-1) + (set! (-> v1-64 num-spheres) (the-as uint 1)) + (set! (-> v1-64 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-64 ignore-process0) #f) + (set! (-> v1-64 ignore-process1) #f) + (set! (-> v1-64 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-64 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-64 action-mask) (collide-action solid)) + ) + ) + (when (fill-and-probe-using-spheres *collide-cache* gp-5) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (when (< 22.0 (ja-aframe-num 0)) + (let ((a1-14 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-14 from) (process->ppointer self)) + (set! (-> a1-14 num-params) 0) + (set! (-> a1-14 message) 'carry-info) + (let ((gp-6 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-14)))) + (if gp-6 + (seek! (-> gp-6 grab-trans-blend) 0.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + (go target-carry-stance) + ) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'normal 0.0) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-stance) + (none) + ) + :post (-> target-carry-pickup post) + ) + +(defstate target-carry-stance (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *carry-walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (behavior () + ((-> target-carry-pickup exit)) + (set! (-> self control unknown-float29) 0.0) + (target-state-hook-exit) + (none) + ) + :trans (behavior () + ((-> self state-hook)) + (when (move-legs?) + (set! (-> self control unknown-float29) 0.0) + (remove-exit) + (go target-carry-walk) + ) + (if (cpad-pressed? (-> self control unknown-cpad-info00 number) r1) + (go target-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-17 (-> *TARGET-bank* carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* carry-jump-height-max)) + ) + (go target-carry-jump a0-17 a1-2) + ) + ) + (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square) (can-hands? #t)) + (go target-carry-throw) + ) + (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 316)))) + (ja-channel-push! 1 (seconds 0.1)) + (ja :group! (-> self draw art-group data 316)) + ) + ) + (until #f + (suspend) + (ja :num! (loop!)) + ) + #f + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-walk (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control unknown-surface00) *carry-walk-mods*) + (none) + ) + :exit (behavior () + ((-> target-carry-pickup exit)) + (target-effect-exit) + (target-state-hook-exit) + (none) + ) + :trans (behavior () + ((-> self state-hook)) + (when (not (move-legs?)) + (target-effect-exit) + (remove-exit) + (go target-carry-stance) + ) + (if (cpad-pressed? (-> self control unknown-cpad-info00 number) r1) + (go target-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-17 (-> *TARGET-bank* carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* carry-jump-height-max)) + ) + (go target-carry-jump a0-17 a1-2) + ) + ) + (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square) (can-hands? #t)) + (go target-carry-throw) + ) + (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 317)))) + (ja-channel-push! 1 (seconds 0.1)) + (ja :group! (-> self draw art-group data 317) :dist (-> *TARGET-bank* walk-cycle-dist)) + ) + ) + (until #f + (suspend) + (let* ((f0-2 (* (current-cycle-distance (-> self skel)) (-> self control scale x))) + (f0-4 (/ (-> self control unknown-float05) (* 1.25 f0-2))) + ) + (ja :num! (loop! f0-4)) + ) + ) + #f + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-falling (target) + :event target-jump-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *carry-jump-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :trans (behavior () + (if (logtest? (-> self control status) (cshape-moving-flags on-surface)) + (go target-carry-hit-ground #f) + ) + (let* ((f0-0 (target-move-dist (-> *TARGET-bank* stuck-time))) + (v1-9 (ja-group)) + (v1-12 (if (and v1-9 (= v1-9 (-> self draw art-group data 322))) + 15 + -1 + ) + ) + ) + (when (if (and (< f0-0 (-> *TARGET-bank* stuck-distance)) + (and (>= v1-12 0) + (>= (- (-> self clock frame-counter) (-> self state-time)) v1-12) + (not (and *cheat-mode* (cpad-hold? (-> self control unknown-cpad-info00 number) r2))) + ) + ) + #t + ) + (logior! (-> self control status) (cshape-moving-flags on-surface)) + (go target-carry-hit-ground 'stuck) + ) + ) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (cond + ((and v1-2 (= v1-2 (-> self draw art-group data 322))) + ) + (else + (ja-channel-push! 1 (seconds 0.33)) + (ja :group! (-> self draw art-group data 322)) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (suspend) + ) + ) + ) + ) + (ja-no-eval :group! (-> self draw art-group data 322) :num! (loop!) :frame-num 0.0) + (until #f + (suspend) + (ja :group! (-> self draw art-group data 27) :num! (loop!)) + ) + #f + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-hit-ground (target) + :event target-walk-event-handler + :enter (behavior ((arg0 symbol)) + (case arg0 + (('stuck) + ) + (else + (target-land-effect) + ) + ) + (set! (-> self control unknown-time-frame11) 0) + (set! (-> self control unknown-time-frame12) 0) + (if (>= (-> self control ground-impact-vel) (-> *TARGET-bank* fall-stumble-threshold)) + (set-forward-vel 0.0) + ) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control unknown-surface00) *carry-walk-mods*) + (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)) + (none) + ) + :trans (behavior () + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-16 (-> *TARGET-bank* carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* carry-jump-height-max)) + ) + (go target-carry-jump a0-16 a1-2) + ) + ) + (if (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (go target-carry-walk) + ) + (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0) + (none) + ) + :code (behavior ((arg0 symbol)) + (let ((gp-0 target-hit-ground-anim) + (s5-0 #f) + ) + (are-still?) + (gp-0 s5-0) + ) + (go target-carry-stance) + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-jump (target) + :event target-jump-event-handler + :enter (behavior ((arg0 float) (arg1 float)) + (set! (-> self state-time) (-> self clock frame-counter)) + (sound-play "jump" :vol 70) + (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0) + (logclear! (-> self control status) (cshape-moving-flags on-surface on-ground t-surface)) + (set! (-> self control unknown-surface00) *carry-jump-mods*) + (set! (-> self control unknown-float36) + (fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control unknown-float05))))) + ) + (set! (-> self control unknown-float35) + (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float05))))) + ) + (none) + ) + :exit (behavior () + ((-> target-carry-pickup exit)) + (target-exit) + (none) + ) + :trans (behavior () + (set! (-> self control unknown-float36) + (fmax + (-> self control unknown-float36) + (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) abutton 6))) + ) + ) + ((-> target-carry-falling trans)) + (mod-var-jump #t #f (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv)) + (seek! + (-> self control unknown-float35) + (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float05))))) + (-> self clock seconds-per-frame) + ) + (none) + ) + :code (behavior ((arg0 float) (arg1 float)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> self draw art-group data 321) :num! min) + (suspend) + (ja :group! (-> self draw art-group data 321) :num! (+!)) + (suspend) + (until (ja-done? 0) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (f0-4 (- 6.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.0 + ) + ) + ) + (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (suspend) + ) + (go target-carry-falling) + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-throw (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (none) + ) + :code (behavior () + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 320) :num! (seek! (ja-aframe 19.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 19.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 'inline-array 'sphere 1))) + (dotimes (s3-0 1) + ((method-of-type sphere new) (the-as symbol (-> s5-0 s3-0)) sphere) + ) + (set! (-> s5-0 0 quad) (-> s4-0 root-prim prim-core world-sphere quad)) + (let ((v1-38 gp-3)) + (set! (-> v1-38 spheres) 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)) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) (process->ppointer self)) + (set! (-> a1-11 num-params) 0) + (set! (-> a1-11 message) 'carry-info) + (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-11)))) + (if gp-4 + (seek! (-> gp-4 grab-trans-blend) 0.0 (* 4.0 (-> self clock seconds-per-frame))) + ) + ) + ) + (suspend) + (ja-eval) + ) + (go target-carry-stance) + ) + ) + ) + ) + ) + (let ((v1-58 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 79764.13))) + (vector+float*! v1-58 v1-58 (-> self control unknown-matrix01 vector 2) 32768.0) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-58) + ) + (target-collide-set! 'normal 0.0) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-stance) + (none) + ) + :post (-> target-carry-pickup post) + ) diff --git a/goal_src/jak2/engine/target/target-h.gc b/goal_src/jak2/engine/target/target-h.gc index 4f0a777090..1fdfd43003 100644 --- a/goal_src/jak2/engine/target/target-h.gc +++ b/goal_src/jak2/engine/target/target-h.gc @@ -139,11 +139,14 @@ (define-extern target-pos (function int vector)) (define-extern stop (function symbol int)) +;; og:ignore-form:(new 'static 'boxed-array + ;; DECOMP BEGINS (deftype target (process-focusable) - ((control control-info :offset 128) - (fact-info-override fact-info-target :offset 160) + ((self-override target :offset 32) + (control control-info :offset 128) + (fact-override fact-info-target :offset 160) (skel2 joint-control :offset-assert 204) (shadow-backup shadow-geo :offset-assert 208) (target-flags uint32 :offset 188) @@ -188,7 +191,7 @@ (pre-joint-hook (function none :behavior target) :offset-assert 2112) (notify handle :offset-assert 2120) (mode-cache basic :offset-assert 2128) - (mode-param1 uint64 :offset-assert 2136) + (mode-param1 handle :offset-assert 2136) (mode-param2 uint64 :offset-assert 2144) (mode-param3 uint64 :offset-assert 2152) (tobot-state state :offset-assert 2160) @@ -216,29 +219,42 @@ (target-method-27 (_type_ collide-cache collide-edge-spec) none 27) (init-target (_type_ continue-point symbol) none :behavior target 28) ) + (:states + target-carry-drop + target-carry-falling + (target-carry-hit-ground symbol) + (target-carry-jump float float) + target-carry-stance + target-carry-throw + target-carry-walk + target-indax-start + (target-warp-in vector vector target) + (target-warp-out vector vector target) + ) ) (define-perm *target* target #f) (deftype sidekick (process-drawable) - ((control control-info :offset 128) - (anim-seed uint64 :offset 208) - (shadow-in-movie? symbol :offset-assert 216) - (special-anim-time time-frame :offset-assert 224) - (special-anim-interp float :offset-assert 232) - (special-anim-frame float :offset-assert 236) - (offset transformq :inline :offset-assert 240) - (mirror uint32 :offset-assert 288) + ((parent-override (pointer target) :offset 16) + (control control-info :offset 128) + (anim-seed uint64 :offset 208) + (shadow-in-movie? symbol :offset-assert 216) + (special-anim-time time-frame :offset-assert 224) + (special-anim-interp float :offset-assert 232) + (special-anim-frame float :offset-assert 236) + (offset transformq :inline :offset-assert 240) + (mirror (pointer process-drawable) :offset-assert 288) ) :heap-base #xb0 :method-count-assert 20 :size-assert #x124 :flag-assert #x1400b00124 + (:states + sidekick-clone + ) ) (define-perm *sidekick* sidekick #f) - -; what is this. -;(new 'static 'boxed-array :type type pilot-info mech-info turret-info indax-info tube-info) diff --git a/goal_src/jak2/levels/common/battle.gc b/goal_src/jak2/levels/common/battle.gc index c5ae9c0af4..904f0d6666 100644 --- a/goal_src/jak2/levels/common/battle.gc +++ b/goal_src/jak2/levels/common/battle.gc @@ -7,3 +7,1875 @@ ;; DECOMP BEGINS +(deftype battle-info (basic) + ((id int8 :offset-assert 4) + (notice-spec uint64 :offset-assert 8) + (pick-logic int8 :offset-assert 16) + (notice-distance float :offset-assert 20) + (dont-spawn-initial-until-notice? symbol :offset-assert 24) + (play-battle-music symbol :offset-assert 28) + (min-battle-spawn-delay uint32 :offset-assert 32) + (max-battle-spawn-delay uint32 :offset-assert 36) + (min-spawner-notice-attack-delay uint32 :offset-assert 40) + (max-spawner-notice-attack-delay uint32 :offset-assert 44) + (spawner-blocked-by-player-xz float :offset-assert 48) + (spawner-blocked-by-collide-radius float :offset-assert 52) + (pick-spawner-max-dist float :offset-assert 56) + (max-count uint32 :offset-assert 60) + (desired-alive-count uint8 :offset-assert 64) + (spawner-collide-with uint32 :offset-assert 68) + ) + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + ) + + +(deftype battle-ally (structure) + ((entity entity-actor :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + + +(deftype battle-ally-array (inline-array-class) + ((data battle-ally :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + + +(set! (-> battle-ally-array heap-base) (the-as uint 16)) + +(deftype battle-breed (structure) + ((breed-type type :offset-assert 0) + (percent float :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + + +(deftype battle-breed-array (inline-array-class) + ((data battle-breed :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + + +(set! (-> battle-breed-array heap-base) (the-as uint 16)) + +(deftype battle-spawner (structure) + ((flags uint64 :offset-assert 0) + (entity entity-actor :offset-assert 8) + (breeds battle-breed-array :offset-assert 12) + (creature-index int8 :offset-assert 16) + (ready-index int8 :offset-assert 17) + (attack-index int8 :offset-assert 18) + (mode uint8 :offset-assert 19) + (intro-path path-control :offset-assert 20) + (notice-attack-delay uint32 :offset-assert 24) + (creature handle :offset-assert 32) + (last-spawn-time time-frame :offset-assert 40) + (noticed-attack-time time-frame :offset-assert 48) + (attack-pos vector :inline :offset-assert 64) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + + +(deftype battle-spawner-array (inline-array-class) + ((data battle-spawner :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + + +(set! (-> battle-spawner-array heap-base) (the-as uint 80)) + +(deftype battle (process-drawable) + ((info battle-info :offset-assert 200) + (flags uint8 :offset-assert 204) + (spawn-initial-creatures? symbol :offset-assert 208) + (next-spawn-delay uint32 :offset-assert 212) + (on-notice basic :offset-assert 216) + (on-hostile basic :offset-assert 220) + (on-beaten basic :offset-assert 224) + (max-count uint32 :offset-assert 228) + (count uint32 :offset-assert 232) + (die-count uint32 :offset-assert 236) + (stat-child-count uint16 :offset-assert 240) + (cant-spawn-time time-frame :offset-assert 248) + (jammed-starting-time time-frame :offset-assert 256) + (spawners battle-spawner-array :offset-assert 264) + (allies battle-ally-array :offset-assert 268) + ) + :heap-base #x90 + :method-count-assert 53 + :size-assert #x110 + :flag-assert #x3500900110 + (:methods + (idle () _type_ :state 20) + (battle-method-21 () none 21) + (notice () _type_ :state 22) + (hostile () _type_ :state 23) + (beaten () _type_ :state 24) + (battle-method-25 (_type_ battle-spawner) symbol 25) + (battle-method-26 (_type_ battle-spawner) symbol 26) + (battle-method-27 (_type_) none 27) + (battle-method-28 (_type_) none 28) + (battle-method-29 (_type_ battle-spawner entity-actor) none 29) + (battle-method-30 (_type_ process) battle-spawner 30) + (battle-method-31 (_type_ battle-ally entity-actor) none 31) + (battle-method-32 (_type_ battle-spawner entity-actor) object 32) + (battle-method-33 (_type_) none 33) + (battle-method-34 (_type_) none 34) + (battle-method-35 (_type_) none 35) + (battle-method-36 (_type_) battle-spawner 36) + (battle-method-37 (_type_ battle-spawner) symbol 37) + (battle-method-38 (_type_ battle-breed transformq) handle 38) + (battle-method-39 (_type_ battle-spawner symbol) handle 39) + (battle-method-40 (_type_) none 40) + (battle-method-41 (_type_ battle-spawner) battle-breed 41) + (battle-method-42 (_type_ battle-spawner touch-tracker) symbol 42) + (battle-method-43 (_type_ battle-spawner touch-tracker) symbol 43) + (battle-method-44 (_type_ battle-spawner) none 44) + (battle-method-45 (_type_ battle-spawner touch-tracker) symbol 45) + (battle-method-46 (_type_ battle-spawner) symbol 46) + (battle-method-47 (_type_) none 47) + (battle-method-48 (_type_) none 48) + (battle-method-49 (_type_) int :behavior battle 49) + (battle-method-50 (_type_) symbol 50) + (battle-method-51 (_type_ battle-spawner symbol) symbol :behavior battle 51) + (battle-method-52 (_type_) int 52) + ) + ) + + +(define *battles* (new 'static 'boxed-array :type battle-info + (new 'static 'battle-info + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x96 + :max-battle-spawn-delay #x12c + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x14 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 2 + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 3 + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 5 + :notice-spec #x2 + :notice-distance 36864.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 1 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x79e + :max-battle-spawn-delay #xe10 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 4 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x6 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #xf + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x7 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x8 + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x9 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x258 + :max-battle-spawn-delay #x4b0 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xa + :notice-spec #x2 + :notice-distance 65536.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xb + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x258 + :max-battle-spawn-delay #x4b0 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xc + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xd + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xe + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xf + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x10 + :notice-spec #x2 + :notice-distance 204800.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x11 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x12 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x3c + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x7 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x13 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x14 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x15 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x16 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music 'danger9 + :min-battle-spawn-delay #x177 + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x10 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x17 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x18 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x8 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x19 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x1c2 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x28 + :desired-alive-count #x7 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1a + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x12c + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x6 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1b + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x12c + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x6 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1c + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x12c + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #xe + :desired-alive-count #x8 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1d + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x10 + :desired-alive-count #xa + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1e + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x12c + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x18 + :desired-alive-count #xc + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1f + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x384 + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :spawner-blocked-by-collide-radius 8192.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x20 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x79e + :max-battle-spawn-delay #xe10 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x21 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x22 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x4 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x23 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x24 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x4 + :spawner-collide-with #x220 + ) + ) + ) + +;; WARN: Return type mismatch none vs object. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 13] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 23] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 33] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 37] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 39] +;; WARN: disable def twice: 9. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: disable def twice: 19. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: disable def twice: 29. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 54] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 72] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 103] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 122] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 147] +(defbehavior battle-event-handler battle ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((v1-0 arg2)) + (the-as object (cond + ((= v1-0 'query) + (case (-> arg3 param 0) + (('beaten) + (and (-> self next-state) (= (-> self next-state name) 'beaten)) + ) + (('hostile) + (and (-> self next-state) (= (-> self next-state name) 'hostile)) + ) + (('idle) + (and (-> self next-state) (= (-> self next-state name) 'idle)) + ) + (('die-count) + (-> self die-count) + ) + (else + #f + ) + ) + ) + ((= v1-0 'child-die) + (+! (-> self die-count) 1) + (let ((v1-14 (battle-method-30 self arg0))) + (when v1-14 + (set! (-> v1-14 creature) (the-as handle #f)) + #f + ) + ) + ) + ((= v1-0 'child-hit) + (let ((a1-3 (battle-method-30 self arg0))) + (when a1-3 + (logior! (-> a1-3 flags) 1) + (battle-method-42 self a1-3 (the-as touch-tracker arg0)) + ) + ) + ) + ((= v1-0 'child-jumped) + (let ((a1-5 (battle-method-30 self arg0))) + (if a1-5 + (battle-method-44 self a1-5) + ) + ) + ) + ((= v1-0 'trigger) + (if (and (-> self next-state) (= (-> self next-state name) 'idle)) + (go-virtual notice) + ) + ) + ((= v1-0 'beaten) + (set! (-> self flags) (the-as uint (logior (the-as int (-> self flags)) 4))) + (if (and (-> self next-state) (= (-> self next-state name) 'idle)) + (go-virtual beaten) + ) + ) + ((= v1-0 'resume) + (set! (-> self flags) (the-as uint (logand -5 (-> self flags)))) + (process-entity-status! self (entity-perm-status subtask-complete) #f) + (if (and (-> self next-state) (= (-> self next-state name) 'beaten)) + (go-virtual hostile) + ) + ) + ) + ) + ) + ) + +(defmethod battle-method-27 battle ((obj battle)) + (local-vars (sv-16 string) (sv-32 string)) + (let ((s4-0 (-> obj root trans)) + (s5-0 (the-as int (-> obj max-count))) + ) + (if (= (the-as uint s5-0) #x20000000) + (set! s5-0 0) + ) + (add-debug-x #t (bucket-id debug-no-zbuf1) s4-0 (new 'static 'rgba :g #xff :b #xff :a #x80)) + (let ((s3-0 add-debug-text-3d) + (s2-0 #t) + (s1-0 318) + ) + (format + (clear *temp-string*) + "~%~S~%count ~d/~d~%child ~d~%ally ~d" + (-> obj name) + (-> obj count) + s5-0 + (-> obj stat-child-count) + (-> obj allies length) + ) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color gold-#ba9200) (the-as vector2h #f)) + ) + ) + (dotimes (s5-1 (-> obj spawners length)) + (let ((s4-1 (-> obj spawners data s5-1))) + (let ((a0-6 (-> s4-1 intro-path))) + (if a0-6 + (debug-draw a0-6) + ) + ) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> s4-1 entity extra trans) + (new 'static 'rgba :g #xff :b #xff :a #x80) + ) + (let ((s3-1 add-debug-text-3d) + (s2-1 #t) + (s1-1 318) + ) + (let ((s0-1 format)) + (set! sv-16 (clear *temp-string*)) + (set! sv-32 "~%spawner~%~S") + (let ((a2-5 (res-lump-struct (-> s4-1 entity) 'name structure))) + (s0-1 sv-16 sv-32 a2-5) + ) + ) + (s3-1 + s2-1 + (the-as bucket-id s1-1) + *temp-string* + (-> s4-1 entity extra trans) + (font-color yellow-#f3f300) + (the-as vector2h #f) + ) + ) + ) + 0 + ) + 0 + (none) + ) + +(defmethod battle-method-26 battle ((obj battle) (arg0 battle-spawner)) + (local-vars (a2-5 float) (a2-12 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (let ((gp-0 (new 'stack-no-clear 'vector)) + (f0-0 (-> obj info spawner-blocked-by-collide-radius)) + ) + (set! (-> gp-0 quad) (-> arg0 attack-pos quad)) + (set! (-> gp-0 w) f0-0) + (let ((s5-0 (-> obj info spawner-collide-with)) + (f30-0 (* f0-0 f0-0)) + ) + (set! *actor-list-length* 0) + (if (logtest? s5-0 512) + (set! *actor-list-length* (spatial-hash-method-36 *actor-hash* (the-as sphere gp-0) *actor-list* 256)) + ) + (when (logtest? s5-0 1024) + (let ((a0-2 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((v1-15 (-> a0-2 next0))) + (while (!= a0-2 (-> *collide-player-list* alive-list-end)) + (let* ((a0-3 (-> (the-as connection a0-2) param1)) + (a1-4 (-> (the-as collide-shape a0-3) root-prim)) + ) + (when (logtest? (the-as collide-spec s5-0) (-> a1-4 prim-core collide-as)) + (let ((a1-5 (-> a1-4 prim-core))) + (let ((a2-4 a1-5) + (a3-1 gp-0) + ) + (.lvf vf2 (&-> a2-4 world-sphere quad)) + (.lvf vf3 (&-> a3-1 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-5 vf1) + (let ((f0-2 a2-5) + (f1-1 (+ (-> a1-5 world-sphere w) (-> gp-0 w))) + ) + (when (< f0-2 (* f1-1 f1-1)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-3)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-2 v1-15) + *collide-player-list* + (set! v1-15 (-> v1-15 next0)) + ) + ) + ) + ) + (when (logtest? s5-0 256) + (let ((a0-5 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((v1-23 (-> a0-5 next0))) + (while (!= a0-5 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((a0-6 (-> (the-as connection a0-5) param1)) + (a1-16 (-> (the-as collide-shape a0-6) root-prim)) + ) + (when (logtest? (the-as collide-spec s5-0) (-> a1-16 prim-core collide-as)) + (let ((a1-17 (-> a1-16 prim-core))) + (let ((a2-11 a1-17) + (a3-2 gp-0) + ) + (.lvf vf2 (&-> a2-11 world-sphere quad)) + (.lvf vf3 (&-> a3-2 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-12 vf1) + (let ((f0-3 a2-12) + (f1-5 (+ (-> a1-17 world-sphere w) (-> gp-0 w))) + ) + (when (< f0-3 (* f1-5 f1-5)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-6)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-5 v1-23) + *collide-hit-by-player-list* + (set! v1-23 (-> v1-23 next0)) + ) + ) + ) + ) + (dotimes (s4-0 *actor-list-length*) + (let ((v1-28 (-> *actor-list* s4-0))) + (when (logtest? (the-as collide-spec s5-0) (-> v1-28 root-prim prim-core collide-as)) + (if (>= f30-0 (vector-vector-xz-distance-squared gp-0 (-> v1-28 trans))) + (return #t) + ) + ) + ) + ) + ) + ) + #f + ) + ) + +(defmethod battle-method-25 battle ((obj battle) (arg0 battle-spawner)) + (when (not (logtest? (the-as int (-> obj flags)) 8)) + (let ((f0-0 (-> obj info spawner-blocked-by-player-xz))) + (if (and (< 0.0 f0-0) (>= (* f0-0 f0-0) (vector-vector-xz-distance-squared (target-pos 0) (-> arg0 attack-pos)))) + (return #t) + ) + ) + (let ((f0-3 (-> obj info spawner-blocked-by-collide-radius))) + (if (and (< 0.0 f0-3) (battle-method-26 obj arg0)) + (return #t) + ) + ) + ) + #f + ) + +(defmethod battle-method-37 battle ((obj battle) (arg0 battle-spawner)) + (and (not (handle->process (-> arg0 creature))) + (or (>= (-> arg0 ready-index) 0) (not (battle-method-25 obj arg0))) + ) + ) + +(defmethod battle-method-36 battle ((obj battle)) + (let ((s5-0 (-> obj spawners length)) + (v1-2 (-> obj info pick-logic)) + ) + (if (not *target*) + (set! v1-2 0) + ) + (cond + ((zero? v1-2) + (let ((s3-0 (rand-vu-int-count s5-0))) + (dotimes (s4-0 s5-0) + (let ((s2-0 (-> obj spawners data s3-0))) + (if (battle-method-37 obj s2-0) + (return s2-0) + ) + ) + (set! s3-0 (mod (+ s3-0 1) s5-0)) + ) + ) + ) + ((= v1-2 1) + (let ((s4-1 0) + (f30-0 -1.0) + ) + (while (nonzero? s5-0) + (+! s5-0 -1) + (let ((s3-1 (-> obj spawners data s5-0))) + (when (battle-method-37 obj s3-1) + (let ((f0-0 (vector-vector-distance (target-pos 0) (-> s3-1 entity extra trans)))) + (when (and (>= (-> obj info pick-spawner-max-dist) f0-0) (or (< f30-0 0.0) (< f0-0 f30-0))) + (set! s4-1 s5-0) + (set! f30-0 f0-0) + ) + ) + ) + ) + ) + (if (< 0.0 f30-0) + (return (-> obj spawners data s4-1)) + ) + ) + ) + ) + ) + (the-as battle-spawner #f) + ) + +(defmethod battle-method-41 battle ((obj battle) (arg0 battle-spawner)) + (let ((f0-0 (rand-vu)) + (v1-0 0) + ) + (let ((a0-2 (-> arg0 breeds length))) + (dotimes (a1-1 a0-2) + (when (>= f0-0 0.0) + (set! f0-0 (- f0-0 (-> arg0 breeds data a1-1 percent))) + (if (< f0-0 0.0) + (set! v1-0 a1-1) + ) + ) + ) + ) + (-> arg0 breeds data v1-0) + ) + ) + +;; WARN: Return type mismatch int vs handle. +(defmethod battle-method-38 battle ((obj battle) (arg0 battle-breed) (arg1 transformq)) + (let* ((s3-0 (-> arg0 breed-type)) + (s4-0 (get-process *default-dead-pool* s3-0 #x4000)) + (v1-1 (when s4-0 + (let ((t9-1 (method-of-type process activate))) + (t9-1 s4-0 obj (symbol->string (-> s3-0 symbol)) (the-as pointer #x70004000)) + ) + (run-now-in-process s4-0 enemy-init-by-other obj arg1) + (-> s4-0 ppointer) + ) + ) + ) + (if (not v1-1) + (return (the-as handle #f)) + ) + (+! (-> obj count) 1) + (the-as handle (ppointer->handle v1-1)) + ) + ) + +(defmethod battle-method-39 battle ((obj battle) (arg0 battle-spawner) (arg1 symbol)) + (with-pp + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'quaternion)) + (s2-0 (-> arg0 intro-path)) + ) + (cond + (s2-0 + (let ((s1-0 0)) + (when arg1 + (set! s1-0 (-> arg0 ready-index)) + (set! s1-0 (cond + ((>= s1-0 0) + (empty) + s1-0 + ) + (else + (-> arg0 attack-index) + ) + ) + ) + ) + (set! (-> arg0 creature-index) s1-0) + (get-point-in-path! s2-0 s3-0 (the float s1-0) 'exact) + (let ((s0-0 (new 'stack-no-clear 'vector))) + (displacement-between-two-points-normalized! s2-0 s0-0 (the float s1-0)) + (set! (-> s0-0 y) 0.0) + (vector-normalize! s0-0 1.0) + (forward-up->quaternion s4-0 s0-0 *up-vector*) + ) + ) + ) + (else + (set! (-> arg0 creature-index) 0) + (let ((v1-7 (-> arg0 entity))) + (set! (-> s3-0 quad) (-> v1-7 extra trans quad)) + (quaternion-copy! s4-0 (-> v1-7 quat)) + ) + ) + ) + (let ((s1-1 (new 'stack-no-clear 'transformq)) + (s2-1 (!= s2-0 #f)) + (s0-1 (battle-method-41 obj arg0)) + ) + (set! (-> s1-1 trans quad) (-> s3-0 quad)) + (quaternion-copy! (-> s1-1 quat) s4-0) + (set! (-> s1-1 scale x) (the-as float (-> arg0 entity))) + (set! (-> s1-1 scale y) (the-as float #t)) + (set! (-> s1-1 scale z) (the-as float s2-1)) + (let ((v0-7 (battle-method-38 obj s0-1 s1-1))) + (when (handle->process v0-7) + (set! (-> arg0 creature) v0-7) + (set! (-> arg0 mode) (the-as uint 1)) + (set! (-> arg0 last-spawn-time) (-> pp clock frame-counter)) + ) + v0-7 + ) + ) + ) + ) + ) + +(defmethod battle-method-30 battle ((obj battle) (arg0 process)) + (let ((v1-0 (if (type? arg0 nav-enemy) + (the-as nav-enemy arg0) + ) + ) + ) + (when v1-0 + (dotimes (a0-3 (-> obj spawners length)) + (let* ((a1-5 (-> obj spawners data a0-3)) + (a2-2 (handle->process (-> a1-5 creature))) + ) + (when (and a2-2 (= a2-2 v1-0)) + (when (not (logtest? (enemy-flag alert) (-> (the-as nav-enemy a2-2) enemy-flags))) + (set! (-> a1-5 creature) (the-as handle #f)) + (set! a1-5 (the-as battle-spawner #f)) + ) + (return a1-5) + ) + ) + ) + ) + ) + (the-as battle-spawner #f) + ) + +(defmethod battle-method-51 battle ((obj battle) (arg0 battle-spawner) (arg1 symbol)) + (when (and (logtest? (the-as int (-> obj flags)) 2) (zero? (logand (the-as int (-> obj flags)) 4))) + (let ((v1-5 (-> arg0 noticed-attack-time))) + (cond + ((zero? v1-5) + (set! (-> arg0 noticed-attack-time) (-> self clock frame-counter)) + ) + (else + (if (>= (- (-> self clock frame-counter) v1-5) (the-as time-frame (-> arg0 notice-attack-delay))) + (logior! (-> arg0 flags) 1) + ) + ) + ) + ) + ) + (let ((s4-0 (handle->process (-> arg0 creature)))) + (when s4-0 + (when (not (logtest? (new 'static 'handle :process #x20000 :u64 #x20000) (-> (the-as touch-tracker s4-0) target))) + (set! (-> arg0 creature) (the-as handle #f)) + (return #f) + ) + (let ((v1-20 (-> arg0 mode))) + (cond + ((= v1-20 1) + (set! (-> arg0 mode) (the-as uint 0)) + 0 + ) + ((zero? v1-20) + (when (or (logtest? (new 'static 'handle :process #x40000 :u64 #x40000) (-> (the-as touch-tracker s4-0) target)) + (not arg1) + ) + (cond + ((battle-method-46 obj arg0) + (if (not (battle-method-43 obj arg0 (the-as touch-tracker s4-0))) + (return #t) + ) + ) + ((battle-method-45 obj arg0 (the-as touch-tracker s4-0)) + (battle-method-42 obj arg0 (the-as touch-tracker s4-0)) + ) + ) + ) + ) + ) + ) + ) + ) + #f + ) + +(defmethod battle-method-46 battle ((obj battle) (arg0 battle-spawner)) + (when (-> arg0 intro-path) + (let ((v1-1 (-> arg0 creature-index)) + (a0-1 (-> arg0 attack-index)) + ) + (or (< v1-1 (-> arg0 ready-index)) (and (< v1-1 a0-1) (logtest? (-> arg0 flags) 1))) + ) + ) + ) + +(defmethod battle-method-43 battle ((obj battle) (arg0 battle-spawner) (arg1 touch-tracker)) + (let ((s3-0 (+ (-> arg0 creature-index) 1)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (if (and (= s3-0 (-> arg0 attack-index)) (battle-method-25 obj arg0)) + (return #f) + ) + (get-point-in-path! (-> arg0 intro-path) s4-0 (the float s3-0) 'exact) + (let ((s3-1 (-> arg0 mode))) + (set! (-> arg0 mode) (the-as uint 2)) + (set! (-> arg1 target) + (the-as + handle + (logand (new 'static 'handle :process #xffffffff :pid #xfffffffb :u64 #xfffffffbffffffff) (-> arg1 target)) + ) + ) + (cond + ((send-event arg1 'jump 3 s4-0) + #t + ) + (else + (set! (-> arg0 mode) s3-1) + #f + ) + ) + ) + ) + ) + +(defmethod battle-method-45 battle ((obj battle) (arg0 battle-spawner) (arg1 touch-tracker)) + (when (logtest? (-> arg0 flags) 1) + (if (-> arg0 intro-path) + (>= (-> arg0 creature-index) (-> arg0 attack-index)) + #t + ) + ) + ) + +(defmethod battle-method-42 battle ((obj battle) (arg0 battle-spawner) (arg1 touch-tracker)) + (let ((s5-0 (-> arg0 creature))) + (set! (-> arg0 creature) (the-as handle #f)) + (cond + ((send-event arg1 'cue-chase) + #t + ) + (else + (set! (-> arg0 creature) s5-0) + #f + ) + ) + ) + ) + +(defmethod battle-method-44 battle ((obj battle) (arg0 battle-spawner)) + (when (= (-> arg0 mode) 2) + (+! (-> arg0 creature-index) 1) + (set! (-> arg0 mode) (the-as uint 0)) + (battle-method-51 obj arg0 #f) + ) + 0 + (none) + ) + +(defmethod battle-method-52 battle ((obj battle)) + (let ((gp-0 0)) + (dotimes (s4-0 (-> obj spawners length)) + (if (battle-method-51 obj (-> obj spawners data s4-0) #t) + (+! gp-0 1) + ) + ) + gp-0 + ) + ) + +(defmethod battle-method-40 battle ((obj battle)) + (set! (-> obj spawn-initial-creatures?) #f) + (let ((s5-0 (-> obj spawners))) + (dotimes (s4-0 (-> s5-0 length)) + (let ((s3-0 (-> s5-0 data s4-0))) + (when (battle-method-37 obj s3-0) + (let ((v1-7 (res-lump-value (-> s3-0 entity) 'enemy-options uint128 :time -1000000000.0))) + (when (logtest? #x100000 v1-7) + (battle-method-39 obj s3-0 #t) + (+! (-> obj stat-child-count) 1) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod battle-method-35 battle ((obj battle)) + (let ((v1-0 (-> obj info))) + (rand-vu-int-range + (the-as int (-> v1-0 min-battle-spawn-delay)) + (the-as int (-> v1-0 max-battle-spawn-delay)) + ) + ) + (none) + ) + +(defstate idle (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (if (and (-> self spawn-initial-creatures?) (not (-> self info dont-spawn-initial-until-notice?))) + (battle-method-40 self) + ) + (battle-method-48 self) + (none) + ) + :trans (behavior () + (let ((v1-1 (-> self info notice-spec))) + (when (not (logtest? v1-1 1)) + (let ((gp-0 #t)) + (if (and (logtest? v1-1 2) + (not (and *target* + (and (>= (-> self info notice-distance) (vector-vector-distance (-> self root trans) (-> *target* control trans))) + (zero? (logand (focus-status teleporting) (-> *target* focus-status))) + ) + ) + ) + ) + (set! gp-0 #f) + ) + (if gp-0 + (go-virtual notice) + ) + ) + ) + ) + (if *display-battle-marks* + (battle-method-27 self) + ) + (none) + ) + :code (the-as (function none :behavior battle) sleep-code) + ) + +(defstate notice (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (let ((gp-0 (-> self on-notice))) + (if gp-0 + (eval! + (new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root trans)) + (the-as pair gp-0) + ) + ) + ) + (battle-method-47 self) + (if (-> self spawn-initial-creatures?) + (battle-method-40 self) + ) + (if (logtest? (the-as int (-> self flags)) 1) + (go-virtual hostile) + ) + (set! (-> self flags) (the-as uint (logior (the-as int (-> self flags)) 1))) + (none) + ) + :trans (behavior () + (if *display-battle-marks* + (battle-method-27 self) + ) + (none) + ) + :code (behavior () + (go-virtual hostile) + (none) + ) + ) + +(defmethod battle-method-49 battle ((obj battle)) + (let ((v1-0 (-> obj allies)) + (gp-0 (-> obj allies length)) + ) + (when (> gp-0 0) + (let* ((a1-4 (mod (the-as int (-> self clock integral-frame-counter)) gp-0)) + (a3-0 (-> v1-0 data a1-4)) + ) + (when (logtest? (-> a3-0 entity extra perm status) (entity-perm-status dead)) + (+! (-> obj die-count) 1) + (+! gp-0 -1) + (set! (-> v1-0 length) gp-0) + (if (and (nonzero? gp-0) (!= a1-4 gp-0)) + (mem-copy! (the-as pointer a3-0) (the-as pointer (-> v1-0 data gp-0)) 4) + ) + ) + ) + ) + gp-0 + ) + ) + +(defmethod battle-method-50 battle ((obj battle)) + (with-pp + (let ((s5-0 (battle-method-52 obj)) + (v1-2 (battle-method-49 obj)) + (a1-0 (-> obj child)) + (a0-3 0) + ) + (while a1-0 + (+! a0-3 1) + (set! a1-0 (-> a1-0 0 brother)) + (nop!) + (nop!) + ) + (set! (-> obj stat-child-count) (the-as uint a0-3)) + (let ((a0-4 (+ v1-2 a0-3)) + (v1-4 (-> obj max-count)) + ) + (when (zero? a0-4) + (if (or (logtest? (the-as int (-> obj flags)) 4) (>= (-> obj die-count) v1-4)) + (return #t) + ) + ) + (set! (-> obj flags) (the-as uint (logand -9 (-> obj flags)))) + (cond + ((and (> s5-0 0) (>= s5-0 (the-as int (- v1-4 (-> obj die-count))))) + (let ((a1-14 (-> obj jammed-starting-time))) + (cond + ((zero? (-> obj jammed-starting-time)) + (set! (-> obj jammed-starting-time) (-> pp clock frame-counter)) + ) + (else + (if (>= (- (-> pp clock frame-counter) a1-14) (seconds 3.5)) + (set! (-> obj flags) (the-as uint (logior (the-as int (-> obj flags)) 8))) + ) + ) + ) + ) + ) + (else + (set! (-> obj jammed-starting-time) 0) + 0 + ) + ) + (cond + ((and (not (logtest? (the-as int (-> obj flags)) 4)) + (> (-> obj spawners length) 0) + (< a0-4 (the-as int (-> obj info desired-alive-count))) + (< (-> obj count) v1-4) + ) + (when (>= (- (-> pp clock frame-counter) (-> obj cant-spawn-time)) (the-as time-frame (-> obj next-spawn-delay))) + (let ((a1-29 (battle-method-36 obj))) + (cond + (a1-29 + (battle-method-39 obj a1-29 #f) + (set! (-> obj next-spawn-delay) (the-as uint (battle-method-35 obj))) + (set! (-> obj cant-spawn-time) (-> pp clock frame-counter)) + ) + (else + (set! (-> obj cant-spawn-time) (-> pp clock frame-counter)) + ) + ) + ) + ) + ) + (else + (set! (-> obj cant-spawn-time) (-> pp clock frame-counter)) + ) + ) + ) + ) + #f + ) + ) + +(defstate hostile (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self flags) (the-as uint (logior (the-as int (-> self flags)) 2))) + (set! (-> self flags) (the-as uint (logand -9 (-> self flags)))) + (set! (-> self jammed-starting-time) 0) + (set! (-> self cant-spawn-time) 0) + (set! (-> self next-spawn-delay) (the-as uint 0)) + (battle-method-47 self) + (let ((gp-0 (-> self on-hostile))) + (if gp-0 + (eval! + (new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root trans)) + (the-as pair gp-0) + ) + ) + ) + (none) + ) + :trans (behavior () + (if (battle-method-50 self) + (go-virtual beaten) + ) + (if *display-battle-marks* + (battle-method-27 self) + ) + (none) + ) + :code (the-as (function none :behavior battle) sleep-code) + ) + +(defstate beaten (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (process-entity-status! self (entity-perm-status subtask-complete) #t) + (let ((gp-0 (-> self on-beaten))) + (if gp-0 + (eval! + (new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root trans)) + (the-as pair gp-0) + ) + ) + ) + (battle-method-48 self) + (none) + ) + :code (the-as (function none :behavior battle) sleep-code) + ) + +;; WARN: Return type mismatch uint8 vs none. +(defmethod battle-method-47 battle ((obj battle)) + (let ((a3-0 (-> obj info play-battle-music))) + (when (and a3-0 (zero? (logand (the-as int (-> obj flags)) 16))) + (case a3-0 + (('sound-mode) + (set-setting! 'sound-mode #f 0 1) + ) + (else + (set-setting! 'music a3-0 0 0) + ) + ) + (set! (-> obj flags) (the-as uint (logior (the-as int (-> obj flags)) 16))) + ) + ) + (none) + ) + +(defmethod battle-method-48 battle ((obj battle)) + (when (logtest? (the-as int (-> obj flags)) 16) + (remove-setting! 'sound-mode) + (remove-setting! 'music) + ) + 0 + (none) + ) + +(defmethod relocate battle-spawner-array ((obj battle-spawner-array) (arg0 int)) + (dotimes (v1-0 (-> obj length)) + (let ((a2-3 (-> obj data v1-0))) + (&+! (-> a2-3 breeds) arg0) + (if (-> a2-3 intro-path) + (&+! (-> a2-3 intro-path) arg0) + ) + ) + ) + obj + ) + +;; WARN: Return type mismatch process-drawable vs battle. +(defmethod relocate battle ((obj battle) (arg0 int)) + (&+! (-> obj spawners) arg0) + (&+! (-> obj allies) arg0) + (the-as + battle + ((the-as (function process-drawable int process-drawable) (find-parent-method battle 7)) obj arg0) + ) + ) + +(defmethod battle-method-29 battle ((obj battle) (arg0 battle-spawner) (arg1 entity-actor)) + (local-vars (sv-16 res-tag) (sv-32 res-tag)) + (let ((s2-0 0) + (s5-0 0) + (s4-0 0) + ) + (set! sv-16 (new 'static 'res-tag)) + (let ((s1-0 (res-lump-data arg1 'spawn-types pointer :tag-ptr (& sv-16)))) + (dotimes (s0-0 2) + (set! s2-0 0) + (when s1-0 + (set! s4-0 (the-as int (-> sv-16 elt-count))) + (dotimes (v1-5 s4-0) + (let ((a0-4 (-> (the-as (pointer uint32) (&+ s1-0 (* v1-5 4)))))) + (when (nonzero? a0-4) + (set! s5-0 (logior s5-0 (ash 1 v1-5))) + (+! s2-0 1) + (when (= s0-0 1) + (let ((a1-10 (-> arg0 breeds data (+ s2-0 -1)))) + (set! (-> a1-10 breed-type) (the-as type a0-4)) + (set! (-> a1-10 percent) 1.0) + ) + ) + ) + ) + ) + ) + (if (zero? s0-0) + (set! (-> arg0 breeds) (new 'process 'battle-breed-array (max 1 s2-0))) + ) + ) + ) + (cond + ((zero? s2-0) + (let ((v1-15 (-> arg0 breeds data))) + (set! (-> v1-15 0 breed-type) (-> arg1 etype)) + (set! (-> v1-15 0 percent) 1.0) + ) + ) + (else + (set! sv-32 (new 'static 'res-tag)) + (let ((v1-18 (res-lump-data arg1 'spawn-percs pointer :tag-ptr (& sv-32)))) + (when v1-18 + (let ((a0-16 (min (the-as int (-> sv-32 elt-count)) s4-0)) + (a1-14 0) + (a2-7 (-> arg0 breeds)) + ) + (dotimes (a3-2 a0-16) + (when (logtest? s5-0 (ash 1 a3-2)) + (let ((t0-8 (-> a2-7 data a1-14))) + (set! (-> t0-8 percent) (-> (the-as (pointer float) (&+ v1-18 (* a3-2 4))))) + ) + (+! a1-14 1) + ) + ) + ) + ) + ) + (let ((f30-0 0.0) + (s5-1 (-> arg0 breeds)) + ) + (dotimes (v1-20 (-> s5-1 length)) + (+! f30-0 (-> s5-1 data v1-20 percent)) + ) + (when (!= f30-0 1.0) + (format + 0 + "WARNING: battle spawner ~A has spawn percents that don't sum to 1.0.~%" + (res-lump-struct (-> arg0 entity) 'name structure) + ) + (dotimes (v1-26 (-> s5-1 length)) + (let ((a0-27 (-> s5-1 data v1-26))) + (set! (-> a0-27 percent) (/ (-> a0-27 percent) f30-0)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod battle-method-32 battle ((obj battle) (arg0 battle-spawner) (arg1 entity-actor)) + (local-vars (v0-4 object)) + (set! (-> arg0 flags) (the-as uint 0)) + (set! (-> arg0 entity) arg1) + (set! (-> arg0 creature-index) 0) + (set! (-> arg0 ready-index) -1) + (set! (-> arg0 attack-index) 0) + (set! (-> arg0 intro-path) #f) + (set! (-> arg0 notice-attack-delay) + (the-as uint (rand-vu-int-range + (the-as int (-> obj info min-spawner-notice-attack-delay)) + (the-as int (-> obj info max-spawner-notice-attack-delay)) + ) + ) + ) + (set! (-> arg0 creature) (the-as handle #f)) + (set! (-> arg0 last-spawn-time) 0) + (set! (-> arg0 noticed-attack-time) 0) + (battle-method-29 obj arg0 arg1) + (let ((a0-4 (new 'process 'path-control obj 'intro 0.0 arg1 #t))) + (cond + ((nonzero? a0-4) + (set! (-> arg0 intro-path) a0-4) + (logior! (-> a0-4 flags) (path-control-flag display draw-line draw-point draw-text)) + (let ((s5-1 (-> a0-4 curve num-cverts))) + (let ((v1-9 (+ s5-1 -1))) + (set! (-> arg0 attack-index) v1-9) + (get-point-in-path! a0-4 (-> arg0 attack-pos) (the float v1-9) 'exact) + ) + (set! v0-4 -1) + (if (< 2 s5-1) + (set! v0-4 1) + ) + ) + (set! (-> arg0 ready-index) (the-as int v0-4)) + ) + (else + (set! v0-4 (-> arg0 attack-pos)) + (set! (-> (the-as vector v0-4) quad) (-> arg0 entity extra trans quad)) + ) + ) + ) + v0-4 + ) + +(defmethod battle-method-31 battle ((obj battle) (arg0 battle-ally) (arg1 entity-actor)) + (set! (-> arg0 entity) arg1) + 0 + (none) + ) + +(defmethod battle-method-28 battle ((obj battle)) + (local-vars (v0-4 battle-ally-array) (sv-16 res-tag) (sv-32 entity-actor)) + (set! sv-16 (new 'static 'res-tag)) + (let ((v0-0 (res-lump-data (-> obj entity) 'actor-groups pointer :tag-ptr (& sv-16)))) + (when (and v0-0 (nonzero? (-> sv-16 elt-count))) + (let* ((s5-0 (the-as (pointer entity-actor) (-> (the-as (pointer uint32) v0-0)))) + (s4-0 (-> s5-0 0)) + ) + (dotimes (s3-0 2) + (let ((s1-0 0) + (s2-0 0) + ) + (dotimes (s0-0 (the-as int s4-0)) + (set! sv-32 (-> (&+ s5-0 (* s0-0 8)) 3)) + (when sv-32 + (let ((v0-1 (res-lump-value sv-32 'enemy-options uint128 :time -1000000000.0))) + (cond + ((logtest? #x80000 v0-1) + (+! s1-0 1) + (cond + ((zero? s3-0) + 0 + ) + (else + (let ((a1-2 (-> obj spawners data (+ s1-0 -1)))) + (battle-method-32 obj a1-2 sv-32) + ) + ) + ) + ) + (else + (when (not (logtest? (-> sv-32 extra perm status) (entity-perm-status dead))) + (+! s2-0 1) + (cond + ((zero? s3-0) + 0 + ) + (else + (let ((a1-3 (-> obj allies data (+ s2-0 -1)))) + (battle-method-31 obj a1-3 sv-32) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! v0-4 (when (zero? s3-0) + (set! (-> obj spawners) (new 'process 'battle-spawner-array s1-0)) + (set! v0-4 (new 'process 'battle-ally-array s2-0)) + (set! (-> obj allies) v0-4) + v0-4 + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod battle-method-33 battle ((obj battle)) + (set! (-> obj spawn-initial-creatures?) #t) + (set! (-> obj count) (the-as uint 0)) + (set! (-> obj die-count) (the-as uint 0)) + (set! (-> obj stat-child-count) (the-as uint 0)) + (let ((v1-2 (res-lump-value (-> obj entity) 'extra-id uint128 :default (the-as uint128 -1) :time -1000000000.0)) + (a0-2 *battles*) + ) + (dotimes (a1-1 (-> a0-2 length)) + (let ((a2-3 (-> a0-2 a1-1))) + (when (= (the-as uint v1-2) (-> a2-3 id)) + (set! (-> obj info) a2-3) + (goto cfg-7) + ) + ) + ) + ) + (go process-drawable-art-error "bad battle id") + (label cfg-7) + (set! (-> obj on-notice) (res-lump-struct (-> obj entity) 'on-notice basic)) + (set! (-> obj on-hostile) (res-lump-struct (-> obj entity) 'on-hostile basic)) + (set! (-> obj on-beaten) (res-lump-struct (-> obj entity) 'on-beaten basic)) + (battle-method-28 obj) + (+! (-> obj count) (-> obj allies length)) + (let ((v1-16 (-> obj info max-count))) + (cond + ((and (= v1-16 #x20000000) (zero? (-> obj spawners length))) + (set! v1-16 (-> obj count)) + ) + ((< v1-16 (-> obj count)) + (set! v1-16 (-> obj count)) + ) + ) + (set! (-> obj max-count) v1-16) + ) + 0 + (none) + ) + +(defmethod battle-method-34 battle ((obj battle)) + (if (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status subtask-complete))) + (go (method-of-object obj beaten)) + (go (method-of-object obj idle)) + ) + 0 + (none) + ) + +(defmethod init-from-entity! battle ((obj battle) (arg0 entity-actor)) + (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask))) + (let ((s4-0 (new 'process 'trsqv))) + (set! (-> obj root) s4-0) + (set! (-> s4-0 trans quad) (-> arg0 extra trans quad)) + (quaternion-copy! (-> s4-0 quat) (-> arg0 quat)) + (vector-identity! (-> s4-0 scale)) + ) + (battle-method-33 obj) + (battle-method-34 obj) + (none) + ) diff --git a/lsp/main.cpp b/lsp/main.cpp index 7e4cce0e75..24424f82cd 100644 --- a/lsp/main.cpp +++ b/lsp/main.cpp @@ -34,7 +34,9 @@ */ void setup_logging(bool verbose, std::string log_file) { - lg::set_file(log_file); + if (!log_file.empty()) { + lg::set_file(log_file); + } if (verbose) { lg::set_file_level(lg::level::debug); lg::set_flush_level(lg::level::debug); @@ -66,9 +68,7 @@ int main(int argc, char** argv) { AppState appstate; LSPRouter lsp_router; appstate.verbose = verbose; - if (!logfile.empty()) { - setup_logging(appstate.verbose, logfile); - } + setup_logging(appstate.verbose, logfile); lsp_router.init_routes(); lg::info("OpenGOAL LSP Initialized, ready for requests"); diff --git a/test/decompiler/reference/jak2/engine/camera/cam-interface_REF.gc b/test/decompiler/reference/jak2/engine/camera/cam-interface_REF.gc index 1f1c0a99e3..ae1e98c00e 100644 --- a/test/decompiler/reference/jak2/engine/camera/cam-interface_REF.gc +++ b/test/decompiler/reference/jak2/engine/camera/cam-interface_REF.gc @@ -1,7 +1,5 @@ -;;-*-Lisp-*- (in-package goal) -;; definition for function position-in-front-of-camera! (defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float)) (vector-float*! arg0 (-> *math-camera* inv-camera-rot vector 2) arg1) (vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot vector 1) arg2) @@ -9,7 +7,6 @@ arg0 ) -;; definition for function position-in-front-of-screen! (defun position-in-front-of-screen! ((arg0 vector) (arg1 float) (arg2 vector)) (let ((a2-1 (vector-negate! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot vector 2))) (a1-3 (vector-float*! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot vector 2) arg1)) @@ -20,7 +17,6 @@ arg0 ) -;; definition for function matrix-local->world (defun matrix-local->world ((smooth? symbol)) "Returns [[*math-camera*]]'s `inv-camera-rot-smooth` if `smooth?` is true, else return `inv-camera-rot`" (if smooth? @@ -29,16 +25,13 @@ ) ) -;; definition for function matrix-world->local -(defun matrix-world->local () +(defun matrix-world->local ((arg0 symbol) (arg1 object)) "Returns [[*math-camera*]]'s `camera-rot`" (-> *math-camera* camera-rot) ) -;; definition (perm) for symbol *camera-dummy-vector*, type vector (define-perm *camera-dummy-vector* vector (vector-reset! (new 'global 'vector))) -;; definition for function camera-pos (defun camera-pos () "Returns the `trans` vector from whatever is first determined to exist: - [[*camera-combiner*]] @@ -57,13 +50,11 @@ ) ) -;; definition for function math-camera-pos (defun math-camera-pos () "Returns [[*math-camera*]]'s `trans`" (-> *math-camera* trans) ) -;; definition for function camera-matrix (defun camera-matrix () "If [[*camera-combiner*]] exists, return it's `inv-camera-rot`. Else, return [[*math-camera*]]'s" (if *camera-combiner* @@ -72,13 +63,11 @@ ) ) -;; definition for function math-camera-matrix (defun math-camera-matrix () "Returns [[*math-camera*]]'s `inv-camera-rot`" (-> *math-camera* inv-camera-rot) ) -;; definition for function camera-angle (defun camera-angle () (let ((f0-0 (-> *math-camera* camera-rot vector 0 x)) (f1-0 (-> *math-camera* camera-rot vector 0 z)) @@ -87,9 +76,6 @@ ) ) -;; definition for function camera-teleport-to-entity -;; INFO: Used lq/sq -;; WARN: Return type mismatch object vs none. (defbehavior camera-teleport-to-entity process ((arg0 entity-actor)) (let ((gp-0 (new 'stack 'transformq))) (set! (-> gp-0 trans quad) (-> arg0 extra trans quad)) diff --git a/test/decompiler/reference/jak2/engine/collide/collide-target-h_REF.gc b/test/decompiler/reference/jak2/engine/collide/collide-target-h_REF.gc index 9a17177e61..d36a28e14d 100644 --- a/test/decompiler/reference/jak2/engine/collide/collide-target-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/collide/collide-target-h_REF.gc @@ -1,7 +1,5 @@ -;;-*-Lisp-*- (in-package goal) -;; definition of type control-info (deftype control-info (collide-shape-moving) ((unknown-float00 float :offset 448) (unknown-float01 float :offset 452) @@ -58,6 +56,7 @@ (unknown-dword02 int64 :offset 4416) (unknown-vector16 vector :inline :offset 4432) (unknown-float14 float :offset 4448) + (unknown-floatiujh1bnb2n3i1 float :offset 4452) (unknown-float15 float :offset 4456) (unknown-word01 int32 :offset 4460) (unknown-vector17 vector :inline :offset 4464) @@ -113,8 +112,7 @@ (unknown-vector29 vector :inline :offset 5168) (unknown-vector30 vector :inline :offset 5184) (unknown-vector31 vector :inline :offset 5200) - (unknown-vector32 vector :inline :offset 5216) - (unknown-vector33 vector :inline :offset 5232) + (unknown-cspacei1un23i1 cspace :inline :offset 5216) (unknown-symbol00 symbol :offset 5248) (unknown-float000 float :offset 5252) (unknown-float31 float :offset 5256) @@ -211,5 +209,4 @@ :flag-assert #x4400001910 ) -;; failed to figure out what this is: 0 diff --git a/test/decompiler/reference/jak2/engine/common_objs/crates_REF.gc b/test/decompiler/reference/jak2/engine/common_objs/crates_REF.gc index fb05bd563f..365a056ab4 100644 --- a/test/decompiler/reference/jak2/engine/common_objs/crates_REF.gc +++ b/test/decompiler/reference/jak2/engine/common_objs/crates_REF.gc @@ -781,7 +781,7 @@ :post (behavior () (vector-v++! (-> self root-override2 transv) - (compute-acc-due-to-gravity (-> self root-override2) (new-stack-vector0) 0.0) + (compute-acc-due-to-gravity (the-as collide-shape-moving (-> self root-override2)) (new-stack-vector0) 0.0) ) (if (< (-> (the-as collide-shape-moving (-> self root-override2)) dynam gravity-max) (vector-length (-> self root-override2 transv)) diff --git a/test/decompiler/reference/jak2/engine/common_objs/voicebox_REF.gc b/test/decompiler/reference/jak2/engine/common_objs/voicebox_REF.gc index b900205aae..e21def6de3 100644 --- a/test/decompiler/reference/jak2/engine/common_objs/voicebox_REF.gc +++ b/test/decompiler/reference/jak2/engine/common_objs/voicebox_REF.gc @@ -493,7 +493,7 @@ ) ) (if *target* - (set! (-> *game-info* score) (-> *target* fact-info-override trick-point)) + (set! (-> *game-info* score) (-> *target* fact-override trick-point)) ) (let ((v1-15 (the-as int (- (-> obj total-time) (- (-> *display* game-clock frame-counter) (-> obj start-time)))))) (if (< (the-as time-frame v1-15) 0) diff --git a/test/decompiler/reference/jak2/engine/game/effect-control-h_REF.gc b/test/decompiler/reference/jak2/engine/game/effect-control-h_REF.gc index cd9e972586..cdb47ca65e 100644 --- a/test/decompiler/reference/jak2/engine/game/effect-control-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/effect-control-h_REF.gc @@ -1,7 +1,5 @@ -;;-*-Lisp-*- (in-package goal) -;; definition of type effect-control (deftype effect-control (basic) ((process process-drawable :offset-assert 4) (flags effect-control-flag :offset-assert 8) @@ -17,7 +15,7 @@ :flag-assert #xf00000024 (:methods (new (symbol type process-drawable) _type_ 0) - (effect-control-method-9 () none 9) + (effect-control-method-9 (_type_) none 9) (effect-control-method-10 () none 10) (effect-control-method-11 () none 11) (effect-control-method-12 (_type_ symbol float int basic sound-name) int 12) @@ -26,7 +24,6 @@ ) ) -;; definition for method 3 of type effect-control (defmethod inspect effect-control ((obj effect-control)) (when (not obj) (set! obj obj) @@ -45,7 +42,6 @@ obj ) -;; definition for method 0 of type effect-control (defmethod new effect-control ((allocation symbol) (type-to-make type) (arg0 process-drawable)) (cond ((res-lump-struct (-> arg0 draw jgeo extra) 'effect-name structure) @@ -61,13 +57,10 @@ ) ) -;; definition for method 13 of type effect-control -;; WARN: Return type mismatch int vs none. (defmethod set-channel-offset! effect-control ((obj effect-control) (arg0 int)) (set! (-> obj channel-offset) arg0) 0 (none) ) -;; failed to figure out what this is: 0 diff --git a/test/decompiler/reference/jak2/engine/target/board/board-states_REF.gc b/test/decompiler/reference/jak2/engine/target/board/board-states_REF.gc index 9eceaa424f..a0b56d69c3 100644 --- a/test/decompiler/reference/jak2/engine/target/board/board-states_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/board/board-states_REF.gc @@ -3110,7 +3110,7 @@ (when (= *cheat-mode* 'debug) (when (and (not *pause-lock*) (cpad-hold? (-> self control unknown-cpad-info00 number) r2)) (set! (-> self control unknown-time-frame30) (-> self clock frame-counter)) - (pickup-collectable! (-> self fact-info-override) (pickup-type health) 100.0 (the-as handle #f)) + (pickup-collectable! (-> self fact-override) (pickup-type health) 100.0 (the-as handle #f)) (go target-board-stance) ) ) @@ -3188,27 +3188,22 @@ (go target-stance) ) (else - (pickup-collectable! (-> self fact-info-override) (pickup-type health) -1000.0 (the-as handle #f)) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) (go target-death (-> gp-0 mode)) ) ) ) (('drown-death 'sharkey 'lava 'dark-eco-pool 'melt 'instant-death 'crush 'death 'grenade 'big-explosion 'bot) - (pickup-collectable! (-> self fact-info-override) (pickup-type health) -1000.0 (the-as handle #f)) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) (if (= (-> self game mode) 'play) (go target-death (-> gp-0 mode)) ) ) (('death) - (pickup-collectable! (-> self fact-info-override) (pickup-type health) -1000.0 (the-as handle #f)) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) ) (else - (pickup-collectable! - (-> self fact-info-override) - (pickup-type health) - (- (-> gp-0 damage)) - (the-as handle #f) - ) + (pickup-collectable! (-> self fact-override) (pickup-type health) (- (-> gp-0 damage)) (the-as handle #f)) ) ) (target-hit-effect gp-0) @@ -3221,9 +3216,7 @@ ) ) ) - (when (not (and (= (-> self game mode) 'play) - (>= 0.0 (-> (the-as fact-info-target (-> self fact-info-override)) health)) - ) + (when (not (and (= (-> self game mode) 'play) (>= 0.0 (-> (the-as fact-info-target (-> self fact-override)) health))) ) (when (= (-> gp-0 knock) 8) (set-quaternion! (-> self control) (-> self control dir-targ)) @@ -3251,9 +3244,7 @@ ) (target-hit-move gp-0 (target-hit-orient gp-0 s5-0) target-board-falling-anim-trans (-> gp-0 speed)) ) - (if (and (= (-> self game mode) 'play) - (>= 0.0 (-> (the-as fact-info-target (-> self fact-info-override)) health)) - ) + (if (and (= (-> self game mode) 'play) (>= 0.0 (-> (the-as fact-info-target (-> self fact-override)) health))) (go target-death (-> gp-0 mode)) ) ) diff --git a/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc b/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc index b04b08001a..f0f54b6047 100644 --- a/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc @@ -1,8 +1,5 @@ -;;-*-Lisp-*- (in-package goal) -;; definition for method 7 of type board -;; WARN: Return type mismatch process-drawable vs board. (defmethod relocate board ((obj board) (arg0 int)) (if (nonzero? (-> obj main)) (&+! (-> obj main) arg0) @@ -10,13 +7,10 @@ (the-as board ((method-of-type process-drawable relocate) obj arg0)) ) -;; definition for function board-post -;; INFO: Used lq/sq -;; WARN: Return type mismatch int vs none. (defbehavior board-post board () (let* ((a0-0 (-> self parent)) (v1-0 (if a0-0 - (the-as target (-> (the-as target (-> a0-0 0)) self)) + (-> (the-as target (-> a0-0 0)) self-override) ) ) ) @@ -57,7 +51,6 @@ (none) ) -;; failed to figure out what this is: (defstate hidden (board) :virtual #t :trans (behavior () @@ -86,7 +79,6 @@ ) ) -;; failed to figure out what this is: (defstate idle (board) :virtual #t :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) @@ -137,7 +129,6 @@ :post board-post ) -;; failed to figure out what this is: (defstate use (board) :virtual #t :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) @@ -200,9 +191,6 @@ :post board-post ) -;; definition for function board-init -;; INFO: Used lq/sq -;; WARN: Return type mismatch object vs none. (defbehavior board-init board () (set! (-> self root) (new 'process 'trsqv)) (initialize-skeleton diff --git a/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc b/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc index b5af106366..1847ae7741 100644 --- a/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc @@ -2635,12 +2635,12 @@ (send-event (handle->process (-> obj process 0 notify)) 'notify 'trick-point arg0) (when (and (< (-> obj trick-count) 16) (and (< 0.0 arg1) - (nonzero? (-> (the-as fact-info-target (-> obj process 0 fact-info-override)) trick-point-duration)) + (nonzero? (-> (the-as fact-info-target (-> obj process 0 fact-override)) trick-point-duration)) ) ) (let ((s4-0 0)) (when (>= (- (-> *display* game-clock frame-counter) - (-> (the-as fact-info-target (-> obj process 0 fact-info-override)) trick-point-pickup-time) + (-> (the-as fact-info-target (-> obj process 0 fact-override)) trick-point-pickup-time) ) (seconds 30) ) @@ -2752,25 +2752,43 @@ (defmethod flush-trick-list board-info ((obj board-info)) "Flush trick list and give out points." - (let ((f30-0 0.0)) - (dotimes (v1-0 (-> obj trick-count)) - (+! f30-0 (-> obj trick-points-array v1-0)) - ) - (when (< 0.0 f30-0) - (send-event - (handle->process (-> obj process 0 notify)) - 'notify - 'trick-flush - f30-0 - (-> obj trick-list) - (-> obj trick-count) + (with-pp + (let ((f30-0 0.0)) + (dotimes (v1-0 (-> obj trick-count)) + (+! f30-0 (-> obj trick-points-array v1-0)) + ) + (when (< 0.0 f30-0) + (send-event + (handle->process (-> obj process 0 notify)) + 'notify + 'trick-flush + f30-0 + (-> obj trick-list) + (-> obj trick-count) + ) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) (process->ppointer pp)) + (set! (-> a1-1 num-params) 2) + (set! (-> a1-1 message) 'get-pickup) + (set! (-> a1-1 param 0) (the-as uint 19)) + (set! (-> a1-1 param 1) (the-as uint f30-0)) + (let ((t9-1 send-event-function) + (v1-22 (-> obj process)) + ) + (t9-1 + (if v1-22 + (-> v1-22 0 self-override) + ) + a1-1 + ) + ) + ) + (sound-play "trick-score") ) - (send-event (ppointer->process (-> obj process)) 'get-pickup 19 f30-0) - (sound-play "trick-score") ) + (set! (-> obj trick-count) 0) + 0 + 0 + (none) ) - (set! (-> obj trick-count) 0) - 0 - 0 - (none) ) diff --git a/test/decompiler/reference/jak2/engine/target/logic-target_REF.gc b/test/decompiler/reference/jak2/engine/target/logic-target_REF.gc index bfc11dc543..e9775f1464 100644 --- a/test/decompiler/reference/jak2/engine/target/logic-target_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/logic-target_REF.gc @@ -6,8 +6,8 @@ (set! (-> self control unknown-time-frame02) (-> self clock frame-counter)) ) (surface-mult! (-> self control unknown-surface01) (-> self control unknown-surface00) (-> self control surf)) - (when (and (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 3) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 3) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (or (= (-> self control unknown-surface00 name) 'run) (= (-> self control unknown-surface00 name) 'jump)) ) @@ -530,14 +530,7 @@ (defbehavior set-pad target ((arg0 vector)) (set! (-> self control unknown-float12) (vector-length arg0)) - (let ((s5-0 vector-matrix*!) - (s4-0 (-> self control unknown-vector12)) - (s3-0 arg0) - (t9-0 matrix-world->local) - ) - #t - (s5-0 s4-0 s3-0 (t9-0)) - ) + (vector-matrix*! (-> self control unknown-vector12) arg0 (matrix-world->local #t #f)) arg0 ) @@ -2462,7 +2455,10 @@ ) (vector-matrix*! (-> self control unknown-vector28) (-> *TARGET-bank* head-offset) a2-5) ) - (vector<-cspace! (-> self control unknown-vector33) (the-as cspace (-> self control unknown-vector32 x))) + (vector<-cspace! + (the-as vector (&-> (-> self control) unknown-cspacei1un23i1 bone)) + (-> self control unknown-cspacei1un23i1 parent) + ) (let ((gp-0 (new-stack-vector0)) (s5-0 (new-stack-vector0)) ) @@ -3250,7 +3246,7 @@ (set! (-> obj control unknown-vector29 x) (the-as float (-> obj node-list data 45))) (set! (-> obj control unknown-vector29 y) (the-as float (-> obj node-list data 55))) (set! (-> obj control unknown-vector29 y) (the-as float (-> obj node-list data 55))) - (set! (-> obj control unknown-vector32 x) (the-as float (-> obj node-list data 23))) + (set! (-> obj control unknown-cspacei1un23i1 parent) (-> obj node-list data 23)) (set! (-> obj neck) (new 'process 'joint-mod (joint-mod-mode look-at) obj 8)) (set! (-> obj neck parented-scale?) #t) (set! (-> obj neck base-joint) (the-as uint 6)) @@ -3281,7 +3277,7 @@ (set! (-> obj leg-ik 1 elbow-rotation-axis) (the-as uint 0)) (set! (-> obj foot 0) (new 'process 'joint-mod (joint-mod-mode foot-rot) obj 29)) (set! (-> obj foot 1) (new 'process 'joint-mod (joint-mod-mode foot-rot) obj 36)) - (set! (-> obj fact-info-override) + (set! (-> obj fact-override) (new 'process 'fact-info-target obj (pickup-type eco-pill-random) (-> *FACT-bank* default-eco-pill-green-inc)) ) (target-gun-setup (logtest? (-> obj game features) (game-feature unk-game-feature-06))) diff --git a/test/decompiler/reference/jak2/engine/target/mech_suit/carry-h_REF.gc b/test/decompiler/reference/jak2/engine/target/mech_suit/carry-h_REF.gc index 860304a624..4d209756ad 100644 --- a/test/decompiler/reference/jak2/engine/target/mech_suit/carry-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/mech_suit/carry-h_REF.gc @@ -1,7 +1,5 @@ -;;-*-Lisp-*- (in-package goal) -;; definition of type carry-info (deftype carry-info (basic) ((process (pointer target) :offset-assert 4) (pickup-time time-frame :offset-assert 8) @@ -41,7 +39,6 @@ ) ) -;; definition for method 3 of type carry-info (defmethod inspect carry-info ((obj carry-info)) (when (not obj) (set! obj obj) @@ -85,8 +82,6 @@ obj ) -;; definition for method 0 of type carry-info -;; INFO: Used lq/sq (defmethod new carry-info ((allocation symbol) (type-to-make type) (arg0 process-drawable) @@ -129,8 +124,6 @@ ) ) -;; definition for method 9 of type carry-info -;; WARN: Return type mismatch int vs none. (defmethod carry-info-method-9 carry-info ((obj carry-info)) (let ((s5-0 (-> obj process 0 node-list data (-> obj joint) bone transform))) (vector-rotate*! (-> obj normal) (-> obj local-normal) s5-0) @@ -140,7 +133,6 @@ (none) ) -;; definition for method 10 of type carry-info (defmethod distance-from-destination carry-info ((obj carry-info) (arg0 carry-info)) "Returns the distance from the current `point` and the provided [[carry-info]]'s `point`. Returns `-1.0` if it exceeds the maximum allowed" @@ -214,9 +206,6 @@ ) ) -;; definition for method 11 of type carry-info -;; INFO: Used lq/sq -;; WARN: Return type mismatch int vs none. (defmethod drag! carry-info ((obj carry-info) (arg0 carry-info)) (let ((v1-0 (-> arg0 process))) (set! (-> obj other) (the-as handle (logior (if v1-0 @@ -286,25 +275,36 @@ (-> arg0 local-point z) ) ) - (change-parent (ppointer->process (-> arg0 process)) (ppointer->process (-> obj process))) - (let* ((v1-46 (-> arg0 process)) - (v1-49 - (-> (the-as collide-shape (-> (the-as process-drawable (if v1-46 - (the-as process-drawable (-> v1-46 0 self)) - ) - ) - root - ) - ) - root-prim - ) + (let* ((t9-13 change-parent) + (v1-42 (-> arg0 process)) + (a0-28 (if v1-42 + (-> v1-42 0 self-override) + ) + ) + (v1-44 (-> obj process)) + ) + (t9-13 a0-28 (if v1-44 + (-> v1-44 0 self-override) + ) ) + ) + (let* ((v1-46 (-> arg0 process)) + (v1-49 (-> (the-as collide-shape (-> (the-as process-drawable (if v1-46 + (-> v1-46 0 self-override) + ) + ) + root + ) + ) + root-prim + ) + ) ) (let ((a0-30 (-> v1-49 prim-core collide-as)) (a1-25 (-> arg0 process)) ) (set! (-> (the-as collide-shape (-> (the-as process-drawable (if a1-25 - (the-as process-drawable (-> a1-25 0 self)) + (-> a1-25 0 self-override) ) ) root @@ -319,7 +319,7 @@ (a0-31 (-> arg0 process)) ) (set! (-> (the-as collide-shape (-> (the-as process-drawable (if a0-31 - (the-as process-drawable (-> a0-31 0 self)) + (-> a0-31 0 self-override) ) ) root @@ -332,17 +332,16 @@ ) ) (let* ((v1-51 (-> arg0 process)) - (v1-54 - (-> (the-as collide-shape (-> (the-as process-drawable (if v1-51 - (the-as process-drawable (-> v1-51 0 self)) - ) - ) - root - ) - ) - root-prim - ) - ) + (v1-54 (-> (the-as collide-shape (-> (the-as process-drawable (if v1-51 + (-> v1-51 0 self-override) + ) + ) + root + ) + ) + root-prim + ) + ) ) (set! (-> v1-54 prim-core collide-as) (collide-spec)) (set! (-> v1-54 prim-core collide-with) (collide-spec)) @@ -352,8 +351,6 @@ (none) ) -;; definition for method 12 of type carry-info -;; WARN: Return type mismatch int vs none. (defmethod drop-impl! carry-info ((obj carry-info) (arg0 carry-info)) (let ((a1-2 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> arg0 process 0 control quat)))) (set! (-> a1-2 y) 0.0) @@ -371,24 +368,32 @@ ) (set! (-> obj other) (the-as handle #f)) (set! (-> arg0 other) (the-as handle #f)) - (change-parent (ppointer->process (-> arg0 process)) *entity-pool*) + (let ((t9-3 change-parent) + (v1-11 (-> arg0 process)) + ) + (t9-3 + (if v1-11 + (-> v1-11 0 self-override) + ) + *entity-pool* + ) + ) (let* ((v1-13 (-> arg0 process)) - (v1-16 - (-> (the-as collide-shape (-> (the-as process-drawable (if v1-13 - (the-as process-drawable (-> v1-13 0 self)) - ) - ) - root - ) - ) - root-prim - ) - ) + (v1-16 (-> (the-as collide-shape (-> (the-as process-drawable (if v1-13 + (-> v1-13 0 self-override) + ) + ) + root + ) + ) + root-prim + ) + ) ) (let ((a0-8 (-> arg0 process))) (set! (-> v1-16 prim-core collide-as) (-> (the-as collide-shape (-> (the-as process-drawable (if a0-8 - (the-as process-drawable (-> a0-8 0 self)) + (-> a0-8 0 self-override) ) ) root @@ -401,7 +406,7 @@ (let ((a0-12 (-> arg0 process))) (set! (-> v1-16 prim-core collide-with) (-> (the-as collide-shape (-> (the-as process-drawable (if a0-12 - (the-as process-drawable (-> a0-12 0 self)) + (-> a0-12 0 self-override) ) ) root @@ -416,8 +421,6 @@ (none) ) -;; definition for method 13 of type carry-info -;; INFO: Used lq/sq (defmethod carry-info-method-13 carry-info ((obj carry-info)) (let ((a1-0 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-0 from) (process->ppointer self)) @@ -484,9 +487,6 @@ ) ) -;; definition for method 14 of type carry-info -;; INFO: Used lq/sq -;; WARN: Return type mismatch vector vs none. (defmethod carry! carry-info ((obj carry-info) (arg0 carry-info) (arg1 vector) (arg2 vector)) (let ((v1-0 (-> arg0 process))) (set! (-> obj other) (the-as handle (logior (if v1-0 @@ -537,25 +537,36 @@ ) ) (vector+float*! arg1 (-> arg0 point) arg2 (- (-> arg0 carry-radius))) - (change-parent (ppointer->process (-> arg0 process)) (ppointer->process (-> obj process))) + (let* ((t9-7 change-parent) + (v1-42 (-> arg0 process)) + (a0-30 (if v1-42 + (-> v1-42 0 self-override) + ) + ) + (v1-44 (-> obj process)) + ) + (t9-7 a0-30 (if v1-44 + (-> v1-44 0 self-override) + ) + ) + ) (let* ((v1-46 (-> arg0 process)) - (v1-49 - (-> (the-as collide-shape (-> (the-as process-drawable (if v1-46 - (the-as process-drawable (-> v1-46 0 self)) - ) - ) - root - ) - ) - root-prim - ) - ) + (v1-49 (-> (the-as collide-shape (-> (the-as process-drawable (if v1-46 + (-> v1-46 0 self-override) + ) + ) + root + ) + ) + root-prim + ) + ) ) (let ((a0-32 (-> v1-49 prim-core collide-as)) (a1-7 (-> arg0 process)) ) (set! (-> (the-as collide-shape (-> (the-as process-drawable (if a1-7 - (the-as process-drawable (-> a1-7 0 self)) + (-> a1-7 0 self-override) ) ) root @@ -570,7 +581,7 @@ (a0-33 (-> arg0 process)) ) (set! (-> (the-as collide-shape (-> (the-as process-drawable (if a0-33 - (the-as process-drawable (-> a0-33 0 self)) + (-> a0-33 0 self-override) ) ) root @@ -583,17 +594,16 @@ ) ) (let* ((v1-51 (-> arg0 process)) - (v1-54 - (-> (the-as collide-shape (-> (the-as process-drawable (if v1-51 - (the-as process-drawable (-> v1-51 0 self)) - ) - ) - root - ) - ) - root-prim - ) - ) + (v1-54 (-> (the-as collide-shape (-> (the-as process-drawable (if v1-51 + (-> v1-51 0 self-override) + ) + ) + root + ) + ) + root-prim + ) + ) ) (set! (-> v1-54 prim-core collide-as) (collide-spec)) (set! (-> v1-54 prim-core collide-with) (collide-spec)) @@ -602,7 +612,6 @@ (none) ) -;; definition for method 16 of type carry-info (defmethod translate! carry-info ((obj carry-info)) (let ((a1-0 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-0 from) (process->ppointer self)) @@ -619,7 +628,6 @@ ) ) -;; definition for method 15 of type carry-info (defmethod drop! carry-info ((obj carry-info) (arg0 carry-info)) (drop-impl! obj arg0) (none) diff --git a/test/decompiler/reference/jak2/engine/target/target-carry_REF.gc b/test/decompiler/reference/jak2/engine/target/target-carry_REF.gc new file mode 100644 index 0000000000..4984b5e969 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/target/target-carry_REF.gc @@ -0,0 +1,817 @@ +(in-package goal) + +(define *carry-walk-mods* (new 'static 'surface + :name 'run + :turnv 524288.0 + :turnvv 910222.25 + :tiltv 65536.0 + :tiltvv 262144.0 + :transv-max 24576.0 + :target-speed 24576.0 + :seek0 1.0 + :seek90 1.0 + :seek180 1.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 + :turnvf 30.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :flags (surface-flag look-around no-turn-around gun-off) + ) + ) + +(define *carry-jump-mods* (new 'static 'surface + :name 'jump + :turnv 524288.0 + :turnvv 910222.25 + :tiltv 65536.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 30.0 + :turnvvf 30.0 + :tiltvf 150.0 + :tiltvvf 15.0 + :mode 'air + :flags (surface-flag air gun-off) + ) + ) + +(defbehavior target-carry-update target () + (carry-info-method-9 (-> self carry)) + (when (and (= (-> self control unknown-symbol00) 'carry) (< (-> self control unknown-float000) 1.0)) + (let ((gp-0 (new 'stack-no-clear 'collide-query)) + (s5-0 (new 'stack-no-clear 'inline-array 'sphere 1)) + ) + (dotimes (s4-0 1) + ((method-of-type sphere new) (the-as symbol (-> s5-0 s4-0)) sphere) + ) + (let ((f30-0 (seek (-> self control unknown-float000) 1.0 (* 0.1 (-> self clock time-adjust-ratio))))) + (set! (-> s5-0 0 quad) (-> self control unknown-sphere-array00 2 prim-core world-sphere quad)) + (set! (-> s5-0 0 r) (lerp-scale (-> *TARGET-bank* body-radius) 7372.8 f30-0 0.0 1.0)) + (let ((v1-17 gp-0)) + (set! (-> v1-17 spheres) 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! 'carry f30-0) + ) + ) + ) + ) + (send-event (handle->process (-> self carry other)) 'carry (-> self carry)) + (none) + ) + +(defbehavior target-carry-post target () + (target-post) + (target-carry-update) + (set! (-> self focus-status) (logior (focus-status carry) (-> self focus-status))) + (none) + ) + +(defstate target-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-standard-event-handler proc arg1 event-type event) + ) + ) + ) + (else + (target-standard-event-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self control unknown-surface00) *walk-mods*) + (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) 12288.0) + (set! (-> self carry mode) (carry-mode carry)) + (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-carry-stance) + (= v1-3 'target-carry-walk) + (= v1-3 'target-carry-drop) + (= v1-3 'target-carry-throw) + (= v1-3 'target-carry-jump) + (= v1-3 'target-carry-falling) + (= v1-3 'target-carry-hit-ground) + (= v1-3 'target-carry-throw) + ) + ) + ) + ) + (logclear! (-> self focus-status) (focus-status carry)) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'normal 0.0) + (target-exit) + ) + (none) + ) + :code (behavior () + (let ((f30-0 0.0)) + (let ((f28-0 0.0)) + (ja-channel-push! 2 (seconds 0.1)) + (target-danger-set! 'carry? #f) + (ja :group! (-> self draw art-group data 319) :num! min) + (let ((a0-3 (-> self skel root-channel 1))) + (set! (-> a0-3 frame-interp 1) f30-0) + (set! (-> a0-3 frame-interp 0) f30-0) + (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> self draw art-group data 318))) + (set! (-> a0-3 param 0) 0.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim (-> self draw art-group data 318)) + num-func-chan + ) + ) + (suspend) + (format #t "carry picked ~A~%" (handle->process (-> self carry other))) + (let ((a1-5 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-5 from) (process->ppointer self)) + (set! (-> a1-5 num-params) 0) + (set! (-> a1-5 message) 'carry-info) + (let ((gp-1 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-5)))) + (when gp-1 + (let* ((s5-1 (vector-! (new 'stack-no-clear 'vector) (-> gp-1 point) (-> self control trans))) + (s4-0 (new-stack-vector0)) + (f26-0 (vector-dot (-> self control local-normal) s5-1)) + ) + 0.0 + (vector-! s4-0 s5-1 (vector-float*! s4-0 (-> self control local-normal) f26-0)) + (let* ((f24-0 (vector-length s4-0)) + (f22-0 f24-0) + ) + (set! f28-0 (lerp-scale 1.0 0.0 f26-0 1638.4 4505.6)) + (vector+! + s5-1 + (vector-float*! s5-1 (-> self control local-normal) f26-0) + (vector-float*! s4-0 s4-0 (/ f24-0 f22-0)) + ) + ) + ) + (forward-up-nopitch->quaternion + (-> self control dir-targ) + (vector-normalize! (vector-! (new-stack-vector0) (-> gp-1 point) (-> self control trans)) 1.0) + (vector-y-quaternion! (new-stack-vector0) (-> self control dir-targ)) + ) + ) + ) + ) + (target-danger-set! 'harmless #f) + (ja-no-eval :num! (seek! (ja-aframe 5.0 0))) + (while (not (ja-done? 0)) + (set! f30-0 (seek f30-0 f28-0 (* 5.0 (-> self clock seconds-per-frame)))) + (let ((v1-45 (-> self skel root-channel 1))) + (set! (-> v1-45 frame-interp 1) f30-0) + (set! (-> v1-45 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + (when (send-event (handle->process (-> self carry other)) 'pickup (-> self carry)) + (target-collide-set! 'carry 0.0) + (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-70 (-> self skel root-channel 1))) + (set! (-> v1-70 frame-interp 1) f30-0) + (set! (-> v1-70 frame-interp 0) f30-0) + ) + (when (< 22.0 (ja-aframe-num 0)) + (let ((a1-22 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-22 from) (process->ppointer self)) + (set! (-> a1-22 num-params) 0) + (set! (-> a1-22 message) 'carry-info) + (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-22)))) + (if gp-4 + (seek! (-> gp-4 grab-trans-blend) 0.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + (go target-carry-stance) + ) + ) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (let ((v1-93 (-> self skel root-channel 1))) + (set! (-> v1-93 frame-interp 1) f30-0) + (set! (-> v1-93 frame-interp 0) f30-0) + ) + (suspend) + (ja-eval) + ) + ) + (go target-stance) + (none) + ) + :post (behavior () + (target-no-stick-post) + (carry-info-method-9 (-> self carry)) + (target-carry-update) + (none) + ) + ) + +(defstate target-carry-drop (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (none) + ) + :code (behavior () + (let ((f30-0 1.0)) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) (process->ppointer self)) + (set! (-> a1-0 num-params) 0) + (set! (-> a1-0 message) 'carry-info) + (let ((a0-5 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-0)))) + (when a0-5 + (let ((gp-0 (new 'stack-no-clear 'vector))) + (set! (-> gp-0 quad) (-> a0-5 point quad)) + (set! (-> gp-0 y) (- (-> gp-0 y) (-> a0-5 process 0 control root-prim prim-core world-sphere w))) + (let ((s5-0 (new-stack-vector0)) + (f28-0 (vector-dot (-> self control local-normal) gp-0)) + ) + 0.0 + (vector-! s5-0 gp-0 (vector-float*! s5-0 (-> self control local-normal) f28-0)) + (let* ((f26-0 (vector-length s5-0)) + (f24-0 f26-0) + ) + (set! f30-0 (lerp-scale 1.0 0.0 f28-0 1638.4 4505.6)) + (vector+! + gp-0 + (vector-float*! gp-0 (-> self control local-normal) f28-0) + (vector-float*! s5-0 s5-0 (/ f26-0 f24-0)) + ) + ) + ) + ) + ) + ) + ) + (ja-channel-push! 2 (seconds 0.1)) + (ja :group! (-> self draw art-group data 319) + :num! (identity (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 319)) frames num-frames) -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 frame-group) (the-as art-joint-anim (-> self draw art-group data 318))) + (set! (-> a0-16 param 0) 0.0) + (joint-control-channel-group-eval! + a0-16 + (the-as art-joint-anim (-> self draw art-group data 318)) + num-func-chan + ) + ) + ) + (suspend) + (ja-no-eval :num! (seek! (ja-aframe 5.0 0))) + (while (not (ja-done? 0)) + (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 ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-9)))) + (when gp-4 + (if (< 22.0 (ja-aframe-num 0)) + (seek! (-> gp-4 grab-trans-blend) 1.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + (let ((s4-0 (-> gp-4 process 0 control)) + (gp-5 (new 'stack-no-clear 'collide-query)) + ) + (let ((s5-1 (new 'stack-no-clear 'inline-array 'sphere 1))) + (dotimes (s3-0 1) + ((method-of-type sphere new) (the-as symbol (-> s5-1 s3-0)) sphere) + ) + (set! (-> s5-1 0 quad) (-> s4-0 root-prim prim-core world-sphere quad)) + (let ((v1-64 gp-5)) + (set! (-> v1-64 spheres) s5-1) + (set! (-> v1-64 num-spheres) (the-as uint 1)) + (set! (-> v1-64 collide-with) (-> self control root-prim prim-core collide-with)) + (set! (-> v1-64 ignore-process0) #f) + (set! (-> v1-64 ignore-process1) #f) + (set! (-> v1-64 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-64 best-my-prim) (the-as collide-shape-prim #t)) + (set! (-> v1-64 action-mask) (collide-action solid)) + ) + ) + (when (fill-and-probe-using-spheres *collide-cache* gp-5) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (when (< 22.0 (ja-aframe-num 0)) + (let ((a1-14 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-14 from) (process->ppointer self)) + (set! (-> a1-14 num-params) 0) + (set! (-> a1-14 message) 'carry-info) + (let ((gp-6 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-14)))) + (if gp-6 + (seek! (-> gp-6 grab-trans-blend) 0.0 (* 2.0 (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + (go target-carry-stance) + ) + ) + ) + ) + ) + (suspend) + (ja-eval) + ) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) *null-vector*) + (target-collide-set! 'normal 0.0) + (ja-no-eval :num! (seek! 0.0)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-stance) + (none) + ) + :post (-> target-carry-pickup post) + ) + +(defstate target-carry-stance (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *carry-walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (behavior () + ((-> target-carry-pickup exit)) + (set! (-> self control unknown-float29) 0.0) + (target-state-hook-exit) + (none) + ) + :trans (behavior () + ((-> self state-hook)) + (when (move-legs?) + (set! (-> self control unknown-float29) 0.0) + (remove-exit) + (go target-carry-walk) + ) + (if (cpad-pressed? (-> self control unknown-cpad-info00 number) r1) + (go target-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-17 (-> *TARGET-bank* carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* carry-jump-height-max)) + ) + (go target-carry-jump a0-17 a1-2) + ) + ) + (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square) (can-hands? #t)) + (go target-carry-throw) + ) + (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 316)))) + (ja-channel-push! 1 (seconds 0.1)) + (ja :group! (-> self draw art-group data 316)) + ) + ) + (until #f + (suspend) + (ja :num! (loop!)) + ) + #f + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-walk (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control unknown-surface00) *carry-walk-mods*) + (none) + ) + :exit (behavior () + ((-> target-carry-pickup exit)) + (target-effect-exit) + (target-state-hook-exit) + (none) + ) + :trans (behavior () + ((-> self state-hook)) + (when (not (move-legs?)) + (target-effect-exit) + (remove-exit) + (go target-carry-stance) + ) + (if (cpad-pressed? (-> self control unknown-cpad-info00 number) r1) + (go target-carry-drop) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-17 (-> *TARGET-bank* carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* carry-jump-height-max)) + ) + (go target-carry-jump a0-17 a1-2) + ) + ) + (if (and (cpad-pressed? (-> self control unknown-cpad-info00 number) square) (can-hands? #t)) + (go target-carry-throw) + ) + (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (when (not (and v1-2 (= v1-2 (-> self draw art-group data 317)))) + (ja-channel-push! 1 (seconds 0.1)) + (ja :group! (-> self draw art-group data 317) :dist (-> *TARGET-bank* walk-cycle-dist)) + ) + ) + (until #f + (suspend) + (let* ((f0-2 (* (current-cycle-distance (-> self skel)) (-> self control scale x))) + (f0-4 (/ (-> self control unknown-float05) (* 1.25 f0-2))) + ) + (ja :num! (loop! f0-4)) + ) + ) + #f + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-falling (target) + :event target-jump-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *carry-jump-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :trans (behavior () + (if (logtest? (-> self control status) (cshape-moving-flags on-surface)) + (go target-carry-hit-ground #f) + ) + (let* ((f0-0 (target-move-dist (-> *TARGET-bank* stuck-time))) + (v1-9 (ja-group)) + (v1-12 (if (and v1-9 (= v1-9 (-> self draw art-group data 322))) + 15 + -1 + ) + ) + ) + (when (if (and (< f0-0 (-> *TARGET-bank* stuck-distance)) + (and (>= v1-12 0) + (>= (- (-> self clock frame-counter) (-> self state-time)) v1-12) + (not (and *cheat-mode* (cpad-hold? (-> self control unknown-cpad-info00 number) r2))) + ) + ) + #t + ) + (logior! (-> self control status) (cshape-moving-flags on-surface)) + (go target-carry-hit-ground 'stuck) + ) + ) + (none) + ) + :code (behavior () + (let ((v1-2 (ja-group))) + (cond + ((and v1-2 (= v1-2 (-> self draw art-group data 322))) + ) + (else + (ja-channel-push! 1 (seconds 0.33)) + (ja :group! (-> self draw art-group data 322)) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (suspend) + ) + ) + ) + ) + (ja-no-eval :group! (-> self draw art-group data 322) :num! (loop!) :frame-num 0.0) + (until #f + (suspend) + (ja :group! (-> self draw art-group data 27) :num! (loop!)) + ) + #f + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-hit-ground (target) + :event target-walk-event-handler + :enter (behavior ((arg0 symbol)) + (case arg0 + (('stuck) + ) + (else + (target-land-effect) + ) + ) + (set! (-> self control unknown-time-frame11) 0) + (set! (-> self control unknown-time-frame12) 0) + (if (>= (-> self control ground-impact-vel) (-> *TARGET-bank* fall-stumble-threshold)) + (set-forward-vel 0.0) + ) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control unknown-surface00) *carry-walk-mods*) + (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)) + (none) + ) + :trans (behavior () + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + enter-state + (let ((a0-16 (-> *TARGET-bank* carry-jump-height-min)) + (a1-2 (-> *TARGET-bank* carry-jump-height-max)) + ) + (go target-carry-jump a0-16 a1-2) + ) + ) + (if (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (go target-carry-walk) + ) + (fall-test (the-as (state symbol target) target-carry-falling) -4096000.0) + (none) + ) + :code (behavior ((arg0 symbol)) + (let ((gp-0 target-hit-ground-anim) + (s5-0 #f) + ) + (are-still?) + (gp-0 s5-0) + ) + (go target-carry-stance) + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-jump (target) + :event target-jump-event-handler + :enter (behavior ((arg0 float) (arg1 float)) + (set! (-> self state-time) (-> self clock frame-counter)) + (sound-play "jump" :vol 70) + (init-var-jump arg0 arg1 #t #f (-> self control transv) 2.0) + (logclear! (-> self control status) (cshape-moving-flags on-surface on-ground t-surface)) + (set! (-> self control unknown-surface00) *carry-jump-mods*) + (set! (-> self control unknown-float36) + (fmax 0.0 (fmin 1.0 (* 0.00004359654 (+ -11468.8 (-> self control unknown-float05))))) + ) + (set! (-> self control unknown-float35) + (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float05))))) + ) + (none) + ) + :exit (behavior () + ((-> target-carry-pickup exit)) + (target-exit) + (none) + ) + :trans (behavior () + (set! (-> self control unknown-float36) + (fmax + (-> self control unknown-float36) + (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) abutton 6))) + ) + ) + ((-> target-carry-falling trans)) + (mod-var-jump #t #f (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv)) + (seek! + (-> self control unknown-float35) + (fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -10240.0 (-> self control unknown-float05))))) + (-> self clock seconds-per-frame) + ) + (none) + ) + :code (behavior ((arg0 float) (arg1 float)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> self draw art-group data 321) :num! min) + (suspend) + (ja :group! (-> self draw art-group data 321) :num! (+!)) + (suspend) + (until (ja-done? 0) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (f0-4 (- 6.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.0 + ) + ) + ) + (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (suspend) + ) + (go target-carry-falling) + (none) + ) + :post target-carry-post + ) + +(defstate target-carry-throw (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self state-time) (-> self clock frame-counter)) + (set-forward-vel 0.0) + (none) + ) + :code (behavior () + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 320) :num! (seek! (ja-aframe 19.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 19.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 'inline-array 'sphere 1))) + (dotimes (s3-0 1) + ((method-of-type sphere new) (the-as symbol (-> s5-0 s3-0)) sphere) + ) + (set! (-> s5-0 0 quad) (-> s4-0 root-prim prim-core world-sphere quad)) + (let ((v1-38 gp-3)) + (set! (-> v1-38 spheres) 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)) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) (process->ppointer self)) + (set! (-> a1-11 num-params) 0) + (set! (-> a1-11 message) 'carry-info) + (let ((gp-4 (the-as carry-info (send-event-function (handle->process (-> self carry other)) a1-11)))) + (if gp-4 + (seek! (-> gp-4 grab-trans-blend) 0.0 (* 4.0 (-> self clock seconds-per-frame))) + ) + ) + ) + (suspend) + (ja-eval) + ) + (go target-carry-stance) + ) + ) + ) + ) + ) + (let ((v1-58 (vector-float*! (new 'stack-no-clear 'vector) (-> self control local-normal) 79764.13))) + (vector+float*! v1-58 v1-58 (-> self control unknown-matrix01 vector 2) 32768.0) + (send-event (handle->process (-> self carry other)) 'drop (-> self carry) v1-58) + ) + (target-collide-set! 'normal 0.0) + (ja-no-eval :num! (seek!)) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (go target-stance) + (none) + ) + :post (-> target-carry-pickup post) + ) diff --git a/test/decompiler/reference/jak2/engine/target/target-darkjak_REF.gc b/test/decompiler/reference/jak2/engine/target/target-darkjak_REF.gc index 9f601a4ce9..9e0caedeac 100644 --- a/test/decompiler/reference/jak2/engine/target/target-darkjak_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-darkjak_REF.gc @@ -48,9 +48,7 @@ ) ) (or (and (not (and (logtest? (focus-status dark) (-> self focus-status)) (nonzero? (-> self darkjak)))) - (and (>= (- (-> self clock frame-counter) - (-> (the-as fact-info-target (-> self fact-info-override)) darkjak-start-time) - ) + (and (>= (- (-> self clock frame-counter) (-> (the-as fact-info-target (-> self fact-override)) darkjak-start-time)) (seconds 0.05) ) (>= (-> self game eco-pill-dark) (-> *FACT-bank* eco-pill-dark-max-default)) @@ -108,10 +106,8 @@ ) (target-danger-set! (-> self control unknown-symbol04) #f) (collide-shape-method-46 (-> self control)) - (if (and (or (>= (- (-> self clock frame-counter) - (-> (the-as fact-info-target (-> self fact-info-override)) darkjak-start-time) - ) - (-> (the-as fact-info-target (-> self fact-info-override)) darkjak-effect-time) + (if (and (or (>= (- (-> self clock frame-counter) (-> (the-as fact-info-target (-> self fact-override)) darkjak-start-time)) + (-> (the-as fact-info-target (-> self fact-override)) darkjak-effect-time) ) (not (-> *setting-control* user-current darkjak)) ) @@ -288,7 +284,7 @@ (persist-with-delay *setting-control* 'bg-a-speed (seconds 3) 'bg-a-speed 'abs 0.5 0) (if (not (and (-> self next-state) (= (-> self next-state name) 'target-darkjak-get-off))) (pickup-collectable! - (-> self fact-info-override) + (-> self fact-override) (pickup-type eco-pill-dark) (- (-> *FACT-bank* eco-pill-dark-max-default)) (the-as handle #f) @@ -319,10 +315,8 @@ (set! (-> self darkjak-giant-interp) 1.0) (set-setting! 'sound-flava #f #x41f00000 4) (set! (-> self focus-status) (logior (focus-status dark) (-> self focus-status))) - (set! (-> (the-as fact-info-target (-> self fact-info-override)) darkjak-start-time) - (-> self clock frame-counter) - ) - (set! (-> (the-as fact-info-target (-> self fact-info-override)) darkjak-effect-time) (seconds 20)) + (set! (-> (the-as fact-info-target (-> self fact-override)) darkjak-start-time) (-> self clock frame-counter)) + (set! (-> (the-as fact-info-target (-> self fact-override)) darkjak-effect-time) (seconds 20)) (if (logtest? (-> self darkjak stage) 16) (logior! (-> self state-flags) (state-flags sf4)) (logclear! (-> self state-flags) (state-flags sf4)) diff --git a/test/decompiler/reference/jak2/engine/target/target-gun_REF.gc b/test/decompiler/reference/jak2/engine/target/target-gun_REF.gc index 2dca952cec..eb811bc5a9 100644 --- a/test/decompiler/reference/jak2/engine/target/target-gun_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-gun_REF.gc @@ -2346,7 +2346,7 @@ (logtest? (state-flags sf16) (-> self state-flags)) (logtest? (-> self game secrets) (game-secrets endless-ammo)) ) - (pickup-collectable! (-> self fact-info-override) (the-as pickup-type a1-0) -1.0 (the-as handle #f)) + (pickup-collectable! (-> self fact-override) (the-as pickup-type a1-0) -1.0 (the-as handle #f)) (case (-> gp-0 gun-type) (((pickup-type eco-blue)) (cond diff --git a/test/decompiler/reference/jak2/engine/target/target-swim_REF.gc b/test/decompiler/reference/jak2/engine/target/target-swim_REF.gc index 1495476115..15e0abd394 100644 --- a/test/decompiler/reference/jak2/engine/target/target-swim_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-swim_REF.gc @@ -677,7 +677,7 @@ (set! (-> v1-1 mode) 'damage) ) (if (and (= (-> self game mode) 'play) - (>= 0.0 (- (-> (the-as fact-info-target (-> self fact-info-override)) health) (-> v1-1 damage))) + (>= 0.0 (- (-> (the-as fact-info-target (-> self fact-override)) health) (-> v1-1 damage))) ) (set! (-> v1-1 mode) 'drown-death) ) diff --git a/test/decompiler/reference/jak2/engine/target/target-util_REF.gc b/test/decompiler/reference/jak2/engine/target/target-util_REF.gc index 2b67b9cd92..626a7ce9de 100644 --- a/test/decompiler/reference/jak2/engine/target/target-util_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-util_REF.gc @@ -731,7 +731,7 @@ ) ) ) - (case (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) + (case (-> (the-as fact-info-target (-> self fact-override)) eco-type) ((1) (set! (-> self control penetrate-using) (logior (penetrate eco-yellow) (-> self control penetrate-using))) ) @@ -1433,8 +1433,8 @@ ) ) (>= (- (-> self clock frame-counter) (-> self control unknown-time-frame11)) - (the-as time-frame (if (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 1) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (the-as time-frame (if (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 1) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (-> *TARGET-bank* yellow-attack-timeout) (-> *TARGET-bank* attack-timeout) diff --git a/test/decompiler/reference/jak2/engine/target/target_REF.gc b/test/decompiler/reference/jak2/engine/target/target_REF.gc index d9254b6f7c..f684c80749 100644 --- a/test/decompiler/reference/jak2/engine/target/target_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target_REF.gc @@ -2235,8 +2235,8 @@ (until (ja-done? 0) (compute-alignment! (-> self align)) (align! (-> self align) (align-opts adjust-quat) 1.0 1.0 1.0) - (when (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (let ((s5-1 (method-of-object (-> self skel effect) effect-control-method-10))) 'group-red-eco-spinkick @@ -2568,8 +2568,8 @@ #f ) ) - (when (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (let ((s5-1 (method-of-object (-> self skel effect) effect-control-method-10))) 'group-red-eco-spinkick @@ -3023,8 +3023,8 @@ (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max)) (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length)) ) - (when (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (let ((s5-0 (method-of-object (-> self skel effect) effect-control-method-10))) 'group-red-eco-spinkick @@ -3325,8 +3325,8 @@ (go target-attack-air 'uppercut) ) (mod-var-jump #t #t (cpad-hold? (-> self control unknown-cpad-info00 number) x) (-> self control transv)) - (when (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (let ((s5-0 (method-of-object (-> self skel effect) effect-control-method-10))) 'group-red-eco-spinkick @@ -3450,8 +3450,8 @@ ) :enter (behavior ((arg0 float) (arg1 float) (arg2 float)) (cond - ((and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 1) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + ((and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 1) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (go target-yellow-jump-blast) ) @@ -3528,8 +3528,8 @@ ) (when gp-1 (logior! (-> self control status) (cshape-moving-flags on-surface)) - (when (or (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (or (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (and (logtest? (focus-status dark) (-> self focus-status)) (nonzero? (-> self darkjak)) @@ -3537,8 +3537,8 @@ ) ) (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 (seconds 0.5)) - (when (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (let ((s4-0 (method-of-object (-> self skel effect) effect-control-method-10))) 'group-red-eco-strike-ground @@ -3564,8 +3564,8 @@ (go target-flop-hit-ground gp-1) ) ) - (when (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (let* ((gp-2 (-> self skel effect)) (s5-2 (method-of-object gp-2 effect-control-method-10)) @@ -3785,8 +3785,8 @@ (go target-attack-air 'flop) ) ) - (when (and (and (= (-> (the-as fact-info-target (-> self fact-info-override)) eco-type) 2) - (>= (-> (the-as fact-info-target (-> self fact-info-override)) eco-level) 1.0) + (when (and (and (= (-> (the-as fact-info-target (-> self fact-override)) eco-type) 2) + (>= (-> (the-as fact-info-target (-> self fact-override)) eco-level) 1.0) ) (< (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.25)) ) diff --git a/test/decompiler/reference/jak2/levels/common/battle_REF.gc b/test/decompiler/reference/jak2/levels/common/battle_REF.gc new file mode 100644 index 0000000000..b2b69fb752 --- /dev/null +++ b/test/decompiler/reference/jak2/levels/common/battle_REF.gc @@ -0,0 +1,1987 @@ +(in-package goal) + +(deftype battle-info (basic) + ((id int8 :offset-assert 4) + (notice-spec uint64 :offset-assert 8) + (pick-logic int8 :offset-assert 16) + (notice-distance float :offset-assert 20) + (dont-spawn-initial-until-notice? symbol :offset-assert 24) + (play-battle-music symbol :offset-assert 28) + (min-battle-spawn-delay uint32 :offset-assert 32) + (max-battle-spawn-delay uint32 :offset-assert 36) + (min-spawner-notice-attack-delay uint32 :offset-assert 40) + (max-spawner-notice-attack-delay uint32 :offset-assert 44) + (spawner-blocked-by-player-xz float :offset-assert 48) + (spawner-blocked-by-collide-radius float :offset-assert 52) + (pick-spawner-max-dist float :offset-assert 56) + (max-count uint32 :offset-assert 60) + (desired-alive-count uint8 :offset-assert 64) + (spawner-collide-with uint32 :offset-assert 68) + ) + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + ) + +(defmethod inspect battle-info ((obj battle-info)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tid: ~D~%" (-> obj id)) + (format #t "~1Tnotice-spec: ~D~%" (-> obj notice-spec)) + (format #t "~1Tpick-logic: ~D~%" (-> obj pick-logic)) + (format #t "~1Tnotice-distance: ~f~%" (-> obj notice-distance)) + (format #t "~1Tdont-spawn-initial-until-notice?: ~A~%" (-> obj dont-spawn-initial-until-notice?)) + (format #t "~1Tplay-battle-music: ~A~%" (-> obj play-battle-music)) + (format #t "~1Tmin-battle-spawn-delay: ~D~%" (-> obj min-battle-spawn-delay)) + (format #t "~1Tmax-battle-spawn-delay: ~D~%" (-> obj max-battle-spawn-delay)) + (format #t "~1Tmin-spawner-notice-attack-delay: ~D~%" (-> obj min-spawner-notice-attack-delay)) + (format #t "~1Tmax-spawner-notice-attack-delay: ~D~%" (-> obj max-spawner-notice-attack-delay)) + (format #t "~1Tspawner-blocked-by-player-xz: ~f~%" (-> obj spawner-blocked-by-player-xz)) + (format #t "~1Tspawner-blocked-by-collide-radius: ~f~%" (-> obj spawner-blocked-by-collide-radius)) + (format #t "~1Tpick-spawner-max-dist: ~f~%" (-> obj pick-spawner-max-dist)) + (format #t "~1Tmax-count: ~D~%" (-> obj max-count)) + (format #t "~1Tdesired-alive-count: ~D~%" (-> obj desired-alive-count)) + (format #t "~1Tspawner-collide-with: ~D~%" (-> obj spawner-collide-with)) + (label cfg-4) + obj + ) + +(deftype battle-ally (structure) + ((entity entity-actor :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(defmethod inspect battle-ally ((obj battle-ally)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'battle-ally) + (format #t "~1Tentity: ~A~%" (-> obj entity)) + (label cfg-4) + obj + ) + +(deftype battle-ally-array (inline-array-class) + ((data battle-ally :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(defmethod inspect battle-ally-array ((obj battle-ally-array)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +(set! (-> battle-ally-array heap-base) (the-as uint 16)) + +(deftype battle-breed (structure) + ((breed-type type :offset-assert 0) + (percent float :offset-assert 4) + ) + :method-count-assert 9 + :size-assert #x8 + :flag-assert #x900000008 + ) + +(defmethod inspect battle-breed ((obj battle-breed)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'battle-breed) + (format #t "~1Tbreed-type: ~A~%" (-> obj breed-type)) + (format #t "~1Tpercent: ~f~%" (-> obj percent)) + (label cfg-4) + obj + ) + +(deftype battle-breed-array (inline-array-class) + ((data battle-breed :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(defmethod inspect battle-breed-array ((obj battle-breed-array)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +(set! (-> battle-breed-array heap-base) (the-as uint 16)) + +(deftype battle-spawner (structure) + ((flags uint64 :offset-assert 0) + (entity entity-actor :offset-assert 8) + (breeds battle-breed-array :offset-assert 12) + (creature-index int8 :offset-assert 16) + (ready-index int8 :offset-assert 17) + (attack-index int8 :offset-assert 18) + (mode uint8 :offset-assert 19) + (intro-path path-control :offset-assert 20) + (notice-attack-delay uint32 :offset-assert 24) + (creature handle :offset-assert 32) + (last-spawn-time time-frame :offset-assert 40) + (noticed-attack-time time-frame :offset-assert 48) + (attack-pos vector :inline :offset-assert 64) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + ) + +(defmethod inspect battle-spawner ((obj battle-spawner)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'battle-spawner) + (format #t "~1Tflags: ~D~%" (-> obj flags)) + (format #t "~1Tentity: ~A~%" (-> obj entity)) + (format #t "~1Tbreeds: ~A~%" (-> obj breeds)) + (format #t "~1Tcreature-index: ~D~%" (-> obj creature-index)) + (format #t "~1Tready-index: ~D~%" (-> obj ready-index)) + (format #t "~1Tattack-index: ~D~%" (-> obj attack-index)) + (format #t "~1Tmode: ~D~%" (-> obj mode)) + (format #t "~1Tintro-path: ~A~%" (-> obj intro-path)) + (format #t "~1Tnotice-attack-delay: ~D~%" (-> obj notice-attack-delay)) + (format #t "~1Tcreature: ~D~%" (-> obj creature)) + (format #t "~1Tlast-spawn-time: ~D~%" (-> obj last-spawn-time)) + (format #t "~1Tnoticed-attack-time: ~D~%" (-> obj noticed-attack-time)) + (format #t "~1Tattack-pos: #~%" (-> obj attack-pos)) + (label cfg-4) + obj + ) + +(deftype battle-spawner-array (inline-array-class) + ((data battle-spawner :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(defmethod inspect battle-spawner-array ((obj battle-spawner-array)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +(set! (-> battle-spawner-array heap-base) (the-as uint 80)) + +(deftype battle (process-drawable) + ((info battle-info :offset-assert 200) + (flags uint8 :offset-assert 204) + (spawn-initial-creatures? symbol :offset-assert 208) + (next-spawn-delay uint32 :offset-assert 212) + (on-notice basic :offset-assert 216) + (on-hostile basic :offset-assert 220) + (on-beaten basic :offset-assert 224) + (max-count uint32 :offset-assert 228) + (count uint32 :offset-assert 232) + (die-count uint32 :offset-assert 236) + (stat-child-count uint16 :offset-assert 240) + (cant-spawn-time time-frame :offset-assert 248) + (jammed-starting-time time-frame :offset-assert 256) + (spawners battle-spawner-array :offset-assert 264) + (allies battle-ally-array :offset-assert 268) + ) + :heap-base #x90 + :method-count-assert 53 + :size-assert #x110 + :flag-assert #x3500900110 + (:methods + (idle () _type_ :state 20) + (battle-method-21 () none 21) + (notice () _type_ :state 22) + (hostile () _type_ :state 23) + (beaten () _type_ :state 24) + (battle-method-25 (_type_ battle-spawner) symbol 25) + (battle-method-26 (_type_ battle-spawner) symbol 26) + (battle-method-27 (_type_) none 27) + (battle-method-28 (_type_) none 28) + (battle-method-29 (_type_ battle-spawner entity-actor) none 29) + (battle-method-30 (_type_ process) battle-spawner 30) + (battle-method-31 (_type_ battle-ally entity-actor) none 31) + (battle-method-32 (_type_ battle-spawner entity-actor) object 32) + (battle-method-33 (_type_) none 33) + (battle-method-34 (_type_) none 34) + (battle-method-35 (_type_) none 35) + (battle-method-36 (_type_) battle-spawner 36) + (battle-method-37 (_type_ battle-spawner) symbol 37) + (battle-method-38 (_type_ battle-breed transformq) handle 38) + (battle-method-39 (_type_ battle-spawner symbol) handle 39) + (battle-method-40 (_type_) none 40) + (battle-method-41 (_type_ battle-spawner) battle-breed 41) + (battle-method-42 (_type_ battle-spawner touch-tracker) symbol 42) + (battle-method-43 (_type_ battle-spawner touch-tracker) symbol 43) + (battle-method-44 (_type_ battle-spawner) none 44) + (battle-method-45 (_type_ battle-spawner touch-tracker) symbol 45) + (battle-method-46 (_type_ battle-spawner) symbol 46) + (battle-method-47 (_type_) none 47) + (battle-method-48 (_type_) none 48) + (battle-method-49 (_type_) int :behavior battle 49) + (battle-method-50 (_type_) symbol 50) + (battle-method-51 (_type_ battle-spawner symbol) symbol :behavior battle 51) + (battle-method-52 (_type_) int 52) + ) + ) + +(defmethod inspect battle ((obj battle)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format #t "~2Tinfo: ~A~%" (-> obj info)) + (format #t "~2Tflags: ~D~%" (-> obj flags)) + (format #t "~2Tspawn-initial-creatures?: ~A~%" (-> obj spawn-initial-creatures?)) + (format #t "~2Tnext-spawn-delay: ~D~%" (-> obj next-spawn-delay)) + (format #t "~2Ton-notice: ~A~%" (-> obj on-notice)) + (format #t "~2Ton-hostile: ~A~%" (-> obj on-hostile)) + (format #t "~2Ton-beaten: ~A~%" (-> obj on-beaten)) + (format #t "~2Tmax-count: ~D~%" (-> obj max-count)) + (format #t "~2Tcount: ~D~%" (-> obj count)) + (format #t "~2Tdie-count: ~D~%" (-> obj die-count)) + (format #t "~2Tstat-child-count: ~D~%" (-> obj stat-child-count)) + (format #t "~2Tcant-spawn-time: ~D~%" (-> obj cant-spawn-time)) + (format #t "~2Tjammed-starting-time: ~D~%" (-> obj jammed-starting-time)) + (format #t "~2Tspawners: ~A~%" (-> obj spawners)) + (format #t "~2Tallies: ~A~%" (-> obj allies)) + (label cfg-4) + obj + ) + +(define *battles* (new 'static 'boxed-array :type battle-info + (new 'static 'battle-info + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x96 + :max-battle-spawn-delay #x12c + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x14 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 2 + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 3 + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 5 + :notice-spec #x2 + :notice-distance 36864.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 1 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x79e + :max-battle-spawn-delay #xe10 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id 4 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x6 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #xf + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x7 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x8 + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x9 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x258 + :max-battle-spawn-delay #x4b0 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xa + :notice-spec #x2 + :notice-distance 65536.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xb + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x258 + :max-battle-spawn-delay #x4b0 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xc + :notice-spec #x2 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xd + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xe + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #xf + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x10 + :notice-spec #x2 + :notice-distance 204800.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x11 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x12 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x3c + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x7 + :desired-alive-count #x2 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x13 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x14 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x15 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x16 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music 'danger9 + :min-battle-spawn-delay #x177 + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x10 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x17 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x18 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x8 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x19 + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x1c2 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x28 + :desired-alive-count #x7 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1a + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x12c + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x6 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1b + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #t + :play-battle-music #f + :min-battle-spawn-delay #x12c + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x6 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1c + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x12c + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #xe + :desired-alive-count #x8 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1d + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x1e + :max-battle-spawn-delay #x258 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x10 + :desired-alive-count #xa + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1e + :notice-spec #x1 + :notice-distance 122880.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music 'sound-mode + :min-battle-spawn-delay #x12c + :max-battle-spawn-delay #x2ee + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 24576.0 + :pick-spawner-max-dist 163840.0 + :max-count #x18 + :desired-alive-count #xc + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x1f + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x384 + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :spawner-blocked-by-collide-radius 8192.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x20 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x79e + :max-battle-spawn-delay #xe10 + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x21 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x5 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x22 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x4 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x23 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x3 + :spawner-collide-with #x220 + ) + (new 'static 'battle-info + :id #x24 + :notice-spec #x2 + :pick-logic 1 + :notice-distance 819200.0 + :dont-spawn-initial-until-notice? #f + :play-battle-music #f + :min-battle-spawn-delay #x41a + :max-battle-spawn-delay #x5dc + :max-spawner-notice-attack-delay #x78 + :spawner-blocked-by-player-xz 65536.0 + :pick-spawner-max-dist 163840.0 + :max-count #x20000000 + :desired-alive-count #x4 + :spawner-collide-with #x220 + ) + ) + ) + +(defbehavior battle-event-handler battle ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((v1-0 arg2)) + (the-as object (cond + ((= v1-0 'query) + (case (-> arg3 param 0) + (('beaten) + (and (-> self next-state) (= (-> self next-state name) 'beaten)) + ) + (('hostile) + (and (-> self next-state) (= (-> self next-state name) 'hostile)) + ) + (('idle) + (and (-> self next-state) (= (-> self next-state name) 'idle)) + ) + (('die-count) + (-> self die-count) + ) + (else + #f + ) + ) + ) + ((= v1-0 'child-die) + (+! (-> self die-count) 1) + (let ((v1-14 (battle-method-30 self arg0))) + (when v1-14 + (set! (-> v1-14 creature) (the-as handle #f)) + #f + ) + ) + ) + ((= v1-0 'child-hit) + (let ((a1-3 (battle-method-30 self arg0))) + (when a1-3 + (logior! (-> a1-3 flags) 1) + (battle-method-42 self a1-3 (the-as touch-tracker arg0)) + ) + ) + ) + ((= v1-0 'child-jumped) + (let ((a1-5 (battle-method-30 self arg0))) + (if a1-5 + (battle-method-44 self a1-5) + ) + ) + ) + ((= v1-0 'trigger) + (if (and (-> self next-state) (= (-> self next-state name) 'idle)) + (go-virtual notice) + ) + ) + ((= v1-0 'beaten) + (set! (-> self flags) (the-as uint (logior (the-as int (-> self flags)) 4))) + (if (and (-> self next-state) (= (-> self next-state name) 'idle)) + (go-virtual beaten) + ) + ) + ((= v1-0 'resume) + (set! (-> self flags) (the-as uint (logand -5 (-> self flags)))) + (process-entity-status! self (entity-perm-status subtask-complete) #f) + (if (and (-> self next-state) (= (-> self next-state name) 'beaten)) + (go-virtual hostile) + ) + ) + ) + ) + ) + ) + +(defmethod battle-method-27 battle ((obj battle)) + (local-vars (sv-16 string) (sv-32 string)) + (let ((s4-0 (-> obj root trans)) + (s5-0 (the-as int (-> obj max-count))) + ) + (if (= (the-as uint s5-0) #x20000000) + (set! s5-0 0) + ) + (add-debug-x #t (bucket-id debug-no-zbuf1) s4-0 (new 'static 'rgba :g #xff :b #xff :a #x80)) + (let ((s3-0 add-debug-text-3d) + (s2-0 #t) + (s1-0 318) + ) + (format + (clear *temp-string*) + "~%~S~%count ~d/~d~%child ~d~%ally ~d" + (-> obj name) + (-> obj count) + s5-0 + (-> obj stat-child-count) + (-> obj allies length) + ) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color gold-#ba9200) (the-as vector2h #f)) + ) + ) + (dotimes (s5-1 (-> obj spawners length)) + (let ((s4-1 (-> obj spawners data s5-1))) + (let ((a0-6 (-> s4-1 intro-path))) + (if a0-6 + (debug-draw a0-6) + ) + ) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> s4-1 entity extra trans) + (new 'static 'rgba :g #xff :b #xff :a #x80) + ) + (let ((s3-1 add-debug-text-3d) + (s2-1 #t) + (s1-1 318) + ) + (let ((s0-1 format)) + (set! sv-16 (clear *temp-string*)) + (set! sv-32 "~%spawner~%~S") + (let ((a2-5 (res-lump-struct (-> s4-1 entity) 'name structure))) + (s0-1 sv-16 sv-32 a2-5) + ) + ) + (s3-1 + s2-1 + (the-as bucket-id s1-1) + *temp-string* + (-> s4-1 entity extra trans) + (font-color yellow-#f3f300) + (the-as vector2h #f) + ) + ) + ) + 0 + ) + 0 + (none) + ) + +(defmethod battle-method-26 battle ((obj battle) (arg0 battle-spawner)) + (local-vars (a2-5 float) (a2-12 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (let ((gp-0 (new 'stack-no-clear 'vector)) + (f0-0 (-> obj info spawner-blocked-by-collide-radius)) + ) + (set! (-> gp-0 quad) (-> arg0 attack-pos quad)) + (set! (-> gp-0 w) f0-0) + (let ((s5-0 (-> obj info spawner-collide-with)) + (f30-0 (* f0-0 f0-0)) + ) + (set! *actor-list-length* 0) + (if (logtest? s5-0 512) + (set! *actor-list-length* (spatial-hash-method-36 *actor-hash* (the-as sphere gp-0) *actor-list* 256)) + ) + (when (logtest? s5-0 1024) + (let ((a0-2 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((v1-15 (-> a0-2 next0))) + (while (!= a0-2 (-> *collide-player-list* alive-list-end)) + (let* ((a0-3 (-> (the-as connection a0-2) param1)) + (a1-4 (-> (the-as collide-shape a0-3) root-prim)) + ) + (when (logtest? (the-as collide-spec s5-0) (-> a1-4 prim-core collide-as)) + (let ((a1-5 (-> a1-4 prim-core))) + (let ((a2-4 a1-5) + (a3-1 gp-0) + ) + (.lvf vf2 (&-> a2-4 world-sphere quad)) + (.lvf vf3 (&-> a3-1 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-5 vf1) + (let ((f0-2 a2-5) + (f1-1 (+ (-> a1-5 world-sphere w) (-> gp-0 w))) + ) + (when (< f0-2 (* f1-1 f1-1)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-3)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-2 v1-15) + *collide-player-list* + (set! v1-15 (-> v1-15 next0)) + ) + ) + ) + ) + (when (logtest? s5-0 256) + (let ((a0-5 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((v1-23 (-> a0-5 next0))) + (while (!= a0-5 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((a0-6 (-> (the-as connection a0-5) param1)) + (a1-16 (-> (the-as collide-shape a0-6) root-prim)) + ) + (when (logtest? (the-as collide-spec s5-0) (-> a1-16 prim-core collide-as)) + (let ((a1-17 (-> a1-16 prim-core))) + (let ((a2-11 a1-17) + (a3-2 gp-0) + ) + (.lvf vf2 (&-> a2-11 world-sphere quad)) + (.lvf vf3 (&-> a3-2 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-12 vf1) + (let ((f0-3 a2-12) + (f1-5 (+ (-> a1-17 world-sphere w) (-> gp-0 w))) + ) + (when (< f0-3 (* f1-5 f1-5)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-6)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-5 v1-23) + *collide-hit-by-player-list* + (set! v1-23 (-> v1-23 next0)) + ) + ) + ) + ) + (dotimes (s4-0 *actor-list-length*) + (let ((v1-28 (-> *actor-list* s4-0))) + (when (logtest? (the-as collide-spec s5-0) (-> v1-28 root-prim prim-core collide-as)) + (if (>= f30-0 (vector-vector-xz-distance-squared gp-0 (-> v1-28 trans))) + (return #t) + ) + ) + ) + ) + ) + ) + #f + ) + ) + +(defmethod battle-method-25 battle ((obj battle) (arg0 battle-spawner)) + (when (not (logtest? (the-as int (-> obj flags)) 8)) + (let ((f0-0 (-> obj info spawner-blocked-by-player-xz))) + (if (and (< 0.0 f0-0) (>= (* f0-0 f0-0) (vector-vector-xz-distance-squared (target-pos 0) (-> arg0 attack-pos)))) + (return #t) + ) + ) + (let ((f0-3 (-> obj info spawner-blocked-by-collide-radius))) + (if (and (< 0.0 f0-3) (battle-method-26 obj arg0)) + (return #t) + ) + ) + ) + #f + ) + +(defmethod battle-method-37 battle ((obj battle) (arg0 battle-spawner)) + (and (not (handle->process (-> arg0 creature))) + (or (>= (-> arg0 ready-index) 0) (not (battle-method-25 obj arg0))) + ) + ) + +(defmethod battle-method-36 battle ((obj battle)) + (let ((s5-0 (-> obj spawners length)) + (v1-2 (-> obj info pick-logic)) + ) + (if (not *target*) + (set! v1-2 0) + ) + (cond + ((zero? v1-2) + (let ((s3-0 (rand-vu-int-count s5-0))) + (dotimes (s4-0 s5-0) + (let ((s2-0 (-> obj spawners data s3-0))) + (if (battle-method-37 obj s2-0) + (return s2-0) + ) + ) + (set! s3-0 (mod (+ s3-0 1) s5-0)) + ) + ) + ) + ((= v1-2 1) + (let ((s4-1 0) + (f30-0 -1.0) + ) + (while (nonzero? s5-0) + (+! s5-0 -1) + (let ((s3-1 (-> obj spawners data s5-0))) + (when (battle-method-37 obj s3-1) + (let ((f0-0 (vector-vector-distance (target-pos 0) (-> s3-1 entity extra trans)))) + (when (and (>= (-> obj info pick-spawner-max-dist) f0-0) (or (< f30-0 0.0) (< f0-0 f30-0))) + (set! s4-1 s5-0) + (set! f30-0 f0-0) + ) + ) + ) + ) + ) + (if (< 0.0 f30-0) + (return (-> obj spawners data s4-1)) + ) + ) + ) + ) + ) + (the-as battle-spawner #f) + ) + +(defmethod battle-method-41 battle ((obj battle) (arg0 battle-spawner)) + (let ((f0-0 (rand-vu)) + (v1-0 0) + ) + (let ((a0-2 (-> arg0 breeds length))) + (dotimes (a1-1 a0-2) + (when (>= f0-0 0.0) + (set! f0-0 (- f0-0 (-> arg0 breeds data a1-1 percent))) + (if (< f0-0 0.0) + (set! v1-0 a1-1) + ) + ) + ) + ) + (-> arg0 breeds data v1-0) + ) + ) + +(defmethod battle-method-38 battle ((obj battle) (arg0 battle-breed) (arg1 transformq)) + (let* ((s3-0 (-> arg0 breed-type)) + (s4-0 (get-process *default-dead-pool* s3-0 #x4000)) + (v1-1 (when s4-0 + (let ((t9-1 (method-of-type process activate))) + (t9-1 s4-0 obj (symbol->string (-> s3-0 symbol)) (the-as pointer #x70004000)) + ) + (run-now-in-process s4-0 enemy-init-by-other obj arg1) + (-> s4-0 ppointer) + ) + ) + ) + (if (not v1-1) + (return (the-as handle #f)) + ) + (+! (-> obj count) 1) + (the-as handle (ppointer->handle v1-1)) + ) + ) + +(defmethod battle-method-39 battle ((obj battle) (arg0 battle-spawner) (arg1 symbol)) + (with-pp + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'quaternion)) + (s2-0 (-> arg0 intro-path)) + ) + (cond + (s2-0 + (let ((s1-0 0)) + (when arg1 + (set! s1-0 (-> arg0 ready-index)) + (set! s1-0 (cond + ((>= s1-0 0) + (empty) + s1-0 + ) + (else + (-> arg0 attack-index) + ) + ) + ) + ) + (set! (-> arg0 creature-index) s1-0) + (get-point-in-path! s2-0 s3-0 (the float s1-0) 'exact) + (let ((s0-0 (new 'stack-no-clear 'vector))) + (displacement-between-two-points-normalized! s2-0 s0-0 (the float s1-0)) + (set! (-> s0-0 y) 0.0) + (vector-normalize! s0-0 1.0) + (forward-up->quaternion s4-0 s0-0 *up-vector*) + ) + ) + ) + (else + (set! (-> arg0 creature-index) 0) + (let ((v1-7 (-> arg0 entity))) + (set! (-> s3-0 quad) (-> v1-7 extra trans quad)) + (quaternion-copy! s4-0 (-> v1-7 quat)) + ) + ) + ) + (let ((s1-1 (new 'stack-no-clear 'transformq)) + (s2-1 (!= s2-0 #f)) + (s0-1 (battle-method-41 obj arg0)) + ) + (set! (-> s1-1 trans quad) (-> s3-0 quad)) + (quaternion-copy! (-> s1-1 quat) s4-0) + (set! (-> s1-1 scale x) (the-as float (-> arg0 entity))) + (set! (-> s1-1 scale y) (the-as float #t)) + (set! (-> s1-1 scale z) (the-as float s2-1)) + (let ((v0-7 (battle-method-38 obj s0-1 s1-1))) + (when (handle->process v0-7) + (set! (-> arg0 creature) v0-7) + (set! (-> arg0 mode) (the-as uint 1)) + (set! (-> arg0 last-spawn-time) (-> pp clock frame-counter)) + ) + v0-7 + ) + ) + ) + ) + ) + +(defmethod battle-method-30 battle ((obj battle) (arg0 process)) + (let ((v1-0 (if (type? arg0 nav-enemy) + (the-as nav-enemy arg0) + ) + ) + ) + (when v1-0 + (dotimes (a0-3 (-> obj spawners length)) + (let* ((a1-5 (-> obj spawners data a0-3)) + (a2-2 (handle->process (-> a1-5 creature))) + ) + (when (and a2-2 (= a2-2 v1-0)) + (when (not (logtest? (enemy-flag alert) (-> (the-as nav-enemy a2-2) enemy-flags))) + (set! (-> a1-5 creature) (the-as handle #f)) + (set! a1-5 (the-as battle-spawner #f)) + ) + (return a1-5) + ) + ) + ) + ) + ) + (the-as battle-spawner #f) + ) + +(defmethod battle-method-51 battle ((obj battle) (arg0 battle-spawner) (arg1 symbol)) + (when (and (logtest? (the-as int (-> obj flags)) 2) (zero? (logand (the-as int (-> obj flags)) 4))) + (let ((v1-5 (-> arg0 noticed-attack-time))) + (cond + ((zero? v1-5) + (set! (-> arg0 noticed-attack-time) (-> self clock frame-counter)) + ) + (else + (if (>= (- (-> self clock frame-counter) v1-5) (the-as time-frame (-> arg0 notice-attack-delay))) + (logior! (-> arg0 flags) 1) + ) + ) + ) + ) + ) + (let ((s4-0 (handle->process (-> arg0 creature)))) + (when s4-0 + (when (not (logtest? (new 'static 'handle :process #x20000 :u64 #x20000) (-> (the-as touch-tracker s4-0) target))) + (set! (-> arg0 creature) (the-as handle #f)) + (return #f) + ) + (let ((v1-20 (-> arg0 mode))) + (cond + ((= v1-20 1) + (set! (-> arg0 mode) (the-as uint 0)) + 0 + ) + ((zero? v1-20) + (when (or (logtest? (new 'static 'handle :process #x40000 :u64 #x40000) (-> (the-as touch-tracker s4-0) target)) + (not arg1) + ) + (cond + ((battle-method-46 obj arg0) + (if (not (battle-method-43 obj arg0 (the-as touch-tracker s4-0))) + (return #t) + ) + ) + ((battle-method-45 obj arg0 (the-as touch-tracker s4-0)) + (battle-method-42 obj arg0 (the-as touch-tracker s4-0)) + ) + ) + ) + ) + ) + ) + ) + ) + #f + ) + +(defmethod battle-method-46 battle ((obj battle) (arg0 battle-spawner)) + (when (-> arg0 intro-path) + (let ((v1-1 (-> arg0 creature-index)) + (a0-1 (-> arg0 attack-index)) + ) + (or (< v1-1 (-> arg0 ready-index)) (and (< v1-1 a0-1) (logtest? (-> arg0 flags) 1))) + ) + ) + ) + +(defmethod battle-method-43 battle ((obj battle) (arg0 battle-spawner) (arg1 touch-tracker)) + (let ((s3-0 (+ (-> arg0 creature-index) 1)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (if (and (= s3-0 (-> arg0 attack-index)) (battle-method-25 obj arg0)) + (return #f) + ) + (get-point-in-path! (-> arg0 intro-path) s4-0 (the float s3-0) 'exact) + (let ((s3-1 (-> arg0 mode))) + (set! (-> arg0 mode) (the-as uint 2)) + (set! (-> arg1 target) + (the-as + handle + (logand (new 'static 'handle :process #xffffffff :pid #xfffffffb :u64 #xfffffffbffffffff) (-> arg1 target)) + ) + ) + (cond + ((send-event arg1 'jump 3 s4-0) + #t + ) + (else + (set! (-> arg0 mode) s3-1) + #f + ) + ) + ) + ) + ) + +(defmethod battle-method-45 battle ((obj battle) (arg0 battle-spawner) (arg1 touch-tracker)) + (when (logtest? (-> arg0 flags) 1) + (if (-> arg0 intro-path) + (>= (-> arg0 creature-index) (-> arg0 attack-index)) + #t + ) + ) + ) + +(defmethod battle-method-42 battle ((obj battle) (arg0 battle-spawner) (arg1 touch-tracker)) + (let ((s5-0 (-> arg0 creature))) + (set! (-> arg0 creature) (the-as handle #f)) + (cond + ((send-event arg1 'cue-chase) + #t + ) + (else + (set! (-> arg0 creature) s5-0) + #f + ) + ) + ) + ) + +(defmethod battle-method-44 battle ((obj battle) (arg0 battle-spawner)) + (when (= (-> arg0 mode) 2) + (+! (-> arg0 creature-index) 1) + (set! (-> arg0 mode) (the-as uint 0)) + (battle-method-51 obj arg0 #f) + ) + 0 + (none) + ) + +(defmethod battle-method-52 battle ((obj battle)) + (let ((gp-0 0)) + (dotimes (s4-0 (-> obj spawners length)) + (if (battle-method-51 obj (-> obj spawners data s4-0) #t) + (+! gp-0 1) + ) + ) + gp-0 + ) + ) + +(defmethod battle-method-40 battle ((obj battle)) + (set! (-> obj spawn-initial-creatures?) #f) + (let ((s5-0 (-> obj spawners))) + (dotimes (s4-0 (-> s5-0 length)) + (let ((s3-0 (-> s5-0 data s4-0))) + (when (battle-method-37 obj s3-0) + (let ((v1-7 (res-lump-value (-> s3-0 entity) 'enemy-options uint128 :time -1000000000.0))) + (when (logtest? #x100000 v1-7) + (battle-method-39 obj s3-0 #t) + (+! (-> obj stat-child-count) 1) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod battle-method-35 battle ((obj battle)) + (let ((v1-0 (-> obj info))) + (rand-vu-int-range + (the-as int (-> v1-0 min-battle-spawn-delay)) + (the-as int (-> v1-0 max-battle-spawn-delay)) + ) + ) + (none) + ) + +(defstate idle (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (if (and (-> self spawn-initial-creatures?) (not (-> self info dont-spawn-initial-until-notice?))) + (battle-method-40 self) + ) + (battle-method-48 self) + (none) + ) + :trans (behavior () + (let ((v1-1 (-> self info notice-spec))) + (when (not (logtest? v1-1 1)) + (let ((gp-0 #t)) + (if (and (logtest? v1-1 2) + (not (and *target* + (and (>= (-> self info notice-distance) (vector-vector-distance (-> self root trans) (-> *target* control trans))) + (zero? (logand (focus-status teleporting) (-> *target* focus-status))) + ) + ) + ) + ) + (set! gp-0 #f) + ) + (if gp-0 + (go-virtual notice) + ) + ) + ) + ) + (if *display-battle-marks* + (battle-method-27 self) + ) + (none) + ) + :code (the-as (function none :behavior battle) sleep-code) + ) + +(defstate notice (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (let ((gp-0 (-> self on-notice))) + (if gp-0 + (eval! + (new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root trans)) + (the-as pair gp-0) + ) + ) + ) + (battle-method-47 self) + (if (-> self spawn-initial-creatures?) + (battle-method-40 self) + ) + (if (logtest? (the-as int (-> self flags)) 1) + (go-virtual hostile) + ) + (set! (-> self flags) (the-as uint (logior (the-as int (-> self flags)) 1))) + (none) + ) + :trans (behavior () + (if *display-battle-marks* + (battle-method-27 self) + ) + (none) + ) + :code (behavior () + (go-virtual hostile) + (none) + ) + ) + +(defmethod battle-method-49 battle ((obj battle)) + (let ((v1-0 (-> obj allies)) + (gp-0 (-> obj allies length)) + ) + (when (> gp-0 0) + (let* ((a1-4 (mod (the-as int (-> self clock integral-frame-counter)) gp-0)) + (a3-0 (-> v1-0 data a1-4)) + ) + (when (logtest? (-> a3-0 entity extra perm status) (entity-perm-status dead)) + (+! (-> obj die-count) 1) + (+! gp-0 -1) + (set! (-> v1-0 length) gp-0) + (if (and (nonzero? gp-0) (!= a1-4 gp-0)) + (mem-copy! (the-as pointer a3-0) (the-as pointer (-> v1-0 data gp-0)) 4) + ) + ) + ) + ) + gp-0 + ) + ) + +(defmethod battle-method-50 battle ((obj battle)) + (with-pp + (let ((s5-0 (battle-method-52 obj)) + (v1-2 (battle-method-49 obj)) + (a1-0 (-> obj child)) + (a0-3 0) + ) + (while a1-0 + (+! a0-3 1) + (set! a1-0 (-> a1-0 0 brother)) + (nop!) + (nop!) + ) + (set! (-> obj stat-child-count) (the-as uint a0-3)) + (let ((a0-4 (+ v1-2 a0-3)) + (v1-4 (-> obj max-count)) + ) + (when (zero? a0-4) + (if (or (logtest? (the-as int (-> obj flags)) 4) (>= (-> obj die-count) v1-4)) + (return #t) + ) + ) + (set! (-> obj flags) (the-as uint (logand -9 (-> obj flags)))) + (cond + ((and (> s5-0 0) (>= s5-0 (the-as int (- v1-4 (-> obj die-count))))) + (let ((a1-14 (-> obj jammed-starting-time))) + (cond + ((zero? (-> obj jammed-starting-time)) + (set! (-> obj jammed-starting-time) (-> pp clock frame-counter)) + ) + (else + (if (>= (- (-> pp clock frame-counter) a1-14) (seconds 3.5)) + (set! (-> obj flags) (the-as uint (logior (the-as int (-> obj flags)) 8))) + ) + ) + ) + ) + ) + (else + (set! (-> obj jammed-starting-time) 0) + 0 + ) + ) + (cond + ((and (not (logtest? (the-as int (-> obj flags)) 4)) + (> (-> obj spawners length) 0) + (< a0-4 (the-as int (-> obj info desired-alive-count))) + (< (-> obj count) v1-4) + ) + (when (>= (- (-> pp clock frame-counter) (-> obj cant-spawn-time)) (the-as time-frame (-> obj next-spawn-delay))) + (let ((a1-29 (battle-method-36 obj))) + (cond + (a1-29 + (battle-method-39 obj a1-29 #f) + (set! (-> obj next-spawn-delay) (the-as uint (battle-method-35 obj))) + (set! (-> obj cant-spawn-time) (-> pp clock frame-counter)) + ) + (else + (set! (-> obj cant-spawn-time) (-> pp clock frame-counter)) + ) + ) + ) + ) + ) + (else + (set! (-> obj cant-spawn-time) (-> pp clock frame-counter)) + ) + ) + ) + ) + #f + ) + ) + +(defstate hostile (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self flags) (the-as uint (logior (the-as int (-> self flags)) 2))) + (set! (-> self flags) (the-as uint (logand -9 (-> self flags)))) + (set! (-> self jammed-starting-time) 0) + (set! (-> self cant-spawn-time) 0) + (set! (-> self next-spawn-delay) (the-as uint 0)) + (battle-method-47 self) + (let ((gp-0 (-> self on-hostile))) + (if gp-0 + (eval! + (new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root trans)) + (the-as pair gp-0) + ) + ) + ) + (none) + ) + :trans (behavior () + (if (battle-method-50 self) + (go-virtual beaten) + ) + (if *display-battle-marks* + (battle-method-27 self) + ) + (none) + ) + :code (the-as (function none :behavior battle) sleep-code) + ) + +(defstate beaten (battle) + :virtual #t + :event battle-event-handler + :enter (behavior () + (process-entity-status! self (entity-perm-status subtask-complete) #t) + (let ((gp-0 (-> self on-beaten))) + (if gp-0 + (eval! + (new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root trans)) + (the-as pair gp-0) + ) + ) + ) + (battle-method-48 self) + (none) + ) + :code (the-as (function none :behavior battle) sleep-code) + ) + +(defmethod battle-method-47 battle ((obj battle)) + (let ((a3-0 (-> obj info play-battle-music))) + (when (and a3-0 (zero? (logand (the-as int (-> obj flags)) 16))) + (case a3-0 + (('sound-mode) + (set-setting! 'sound-mode #f 0 1) + ) + (else + (set-setting! 'music a3-0 0 0) + ) + ) + (set! (-> obj flags) (the-as uint (logior (the-as int (-> obj flags)) 16))) + ) + ) + (none) + ) + +(defmethod battle-method-48 battle ((obj battle)) + (when (logtest? (the-as int (-> obj flags)) 16) + (remove-setting! 'sound-mode) + (remove-setting! 'music) + ) + 0 + (none) + ) + +(defmethod relocate battle-spawner-array ((obj battle-spawner-array) (arg0 int)) + (dotimes (v1-0 (-> obj length)) + (let ((a2-3 (-> obj data v1-0))) + (&+! (-> a2-3 breeds) arg0) + (if (-> a2-3 intro-path) + (&+! (-> a2-3 intro-path) arg0) + ) + ) + ) + obj + ) + +(defmethod relocate battle ((obj battle) (arg0 int)) + (&+! (-> obj spawners) arg0) + (&+! (-> obj allies) arg0) + (the-as + battle + ((the-as (function process-drawable int process-drawable) (find-parent-method battle 7)) obj arg0) + ) + ) + +(defmethod battle-method-29 battle ((obj battle) (arg0 battle-spawner) (arg1 entity-actor)) + (local-vars (sv-16 res-tag) (sv-32 res-tag)) + (let ((s2-0 0) + (s5-0 0) + (s4-0 0) + ) + (set! sv-16 (new 'static 'res-tag)) + (let ((s1-0 (res-lump-data arg1 'spawn-types pointer :tag-ptr (& sv-16)))) + (dotimes (s0-0 2) + (set! s2-0 0) + (when s1-0 + (set! s4-0 (the-as int (-> sv-16 elt-count))) + (dotimes (v1-5 s4-0) + (let ((a0-4 (-> (the-as (pointer uint32) (&+ s1-0 (* v1-5 4)))))) + (when (nonzero? a0-4) + (set! s5-0 (logior s5-0 (ash 1 v1-5))) + (+! s2-0 1) + (when (= s0-0 1) + (let ((a1-10 (-> arg0 breeds data (+ s2-0 -1)))) + (set! (-> a1-10 breed-type) (the-as type a0-4)) + (set! (-> a1-10 percent) 1.0) + ) + ) + ) + ) + ) + ) + (if (zero? s0-0) + (set! (-> arg0 breeds) (new 'process 'battle-breed-array (max 1 s2-0))) + ) + ) + ) + (cond + ((zero? s2-0) + (let ((v1-15 (-> arg0 breeds data))) + (set! (-> v1-15 0 breed-type) (-> arg1 etype)) + (set! (-> v1-15 0 percent) 1.0) + ) + ) + (else + (set! sv-32 (new 'static 'res-tag)) + (let ((v1-18 (res-lump-data arg1 'spawn-percs pointer :tag-ptr (& sv-32)))) + (when v1-18 + (let ((a0-16 (min (the-as int (-> sv-32 elt-count)) s4-0)) + (a1-14 0) + (a2-7 (-> arg0 breeds)) + ) + (dotimes (a3-2 a0-16) + (when (logtest? s5-0 (ash 1 a3-2)) + (let ((t0-8 (-> a2-7 data a1-14))) + (set! (-> t0-8 percent) (-> (the-as (pointer float) (&+ v1-18 (* a3-2 4))))) + ) + (+! a1-14 1) + ) + ) + ) + ) + ) + (let ((f30-0 0.0) + (s5-1 (-> arg0 breeds)) + ) + (dotimes (v1-20 (-> s5-1 length)) + (+! f30-0 (-> s5-1 data v1-20 percent)) + ) + (when (!= f30-0 1.0) + (format + 0 + "WARNING: battle spawner ~A has spawn percents that don't sum to 1.0.~%" + (res-lump-struct (-> arg0 entity) 'name structure) + ) + (dotimes (v1-26 (-> s5-1 length)) + (let ((a0-27 (-> s5-1 data v1-26))) + (set! (-> a0-27 percent) (/ (-> a0-27 percent) f30-0)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod battle-method-32 battle ((obj battle) (arg0 battle-spawner) (arg1 entity-actor)) + (local-vars (v0-4 object)) + (set! (-> arg0 flags) (the-as uint 0)) + (set! (-> arg0 entity) arg1) + (set! (-> arg0 creature-index) 0) + (set! (-> arg0 ready-index) -1) + (set! (-> arg0 attack-index) 0) + (set! (-> arg0 intro-path) #f) + (set! (-> arg0 notice-attack-delay) + (the-as uint (rand-vu-int-range + (the-as int (-> obj info min-spawner-notice-attack-delay)) + (the-as int (-> obj info max-spawner-notice-attack-delay)) + ) + ) + ) + (set! (-> arg0 creature) (the-as handle #f)) + (set! (-> arg0 last-spawn-time) 0) + (set! (-> arg0 noticed-attack-time) 0) + (battle-method-29 obj arg0 arg1) + (let ((a0-4 (new 'process 'path-control obj 'intro 0.0 arg1 #t))) + (cond + ((nonzero? a0-4) + (set! (-> arg0 intro-path) a0-4) + (logior! (-> a0-4 flags) (path-control-flag display draw-line draw-point draw-text)) + (let ((s5-1 (-> a0-4 curve num-cverts))) + (let ((v1-9 (+ s5-1 -1))) + (set! (-> arg0 attack-index) v1-9) + (get-point-in-path! a0-4 (-> arg0 attack-pos) (the float v1-9) 'exact) + ) + (set! v0-4 -1) + (if (< 2 s5-1) + (set! v0-4 1) + ) + ) + (set! (-> arg0 ready-index) (the-as int v0-4)) + ) + (else + (set! v0-4 (-> arg0 attack-pos)) + (set! (-> (the-as vector v0-4) quad) (-> arg0 entity extra trans quad)) + ) + ) + ) + v0-4 + ) + +(defmethod battle-method-31 battle ((obj battle) (arg0 battle-ally) (arg1 entity-actor)) + (set! (-> arg0 entity) arg1) + 0 + (none) + ) + +(defmethod battle-method-28 battle ((obj battle)) + (local-vars (v0-4 battle-ally-array) (sv-16 res-tag) (sv-32 entity-actor)) + (set! sv-16 (new 'static 'res-tag)) + (let ((v0-0 (res-lump-data (-> obj entity) 'actor-groups pointer :tag-ptr (& sv-16)))) + (when (and v0-0 (nonzero? (-> sv-16 elt-count))) + (let* ((s5-0 (the-as (pointer entity-actor) (-> (the-as (pointer uint32) v0-0)))) + (s4-0 (-> s5-0 0)) + ) + (dotimes (s3-0 2) + (let ((s1-0 0) + (s2-0 0) + ) + (dotimes (s0-0 (the-as int s4-0)) + (set! sv-32 (-> (&+ s5-0 (* s0-0 8)) 3)) + (when sv-32 + (let ((v0-1 (res-lump-value sv-32 'enemy-options uint128 :time -1000000000.0))) + (cond + ((logtest? #x80000 v0-1) + (+! s1-0 1) + (cond + ((zero? s3-0) + 0 + ) + (else + (let ((a1-2 (-> obj spawners data (+ s1-0 -1)))) + (battle-method-32 obj a1-2 sv-32) + ) + ) + ) + ) + (else + (when (not (logtest? (-> sv-32 extra perm status) (entity-perm-status dead))) + (+! s2-0 1) + (cond + ((zero? s3-0) + 0 + ) + (else + (let ((a1-3 (-> obj allies data (+ s2-0 -1)))) + (battle-method-31 obj a1-3 sv-32) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! v0-4 (when (zero? s3-0) + (set! (-> obj spawners) (new 'process 'battle-spawner-array s1-0)) + (set! v0-4 (new 'process 'battle-ally-array s2-0)) + (set! (-> obj allies) v0-4) + v0-4 + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod battle-method-33 battle ((obj battle)) + (set! (-> obj spawn-initial-creatures?) #t) + (set! (-> obj count) (the-as uint 0)) + (set! (-> obj die-count) (the-as uint 0)) + (set! (-> obj stat-child-count) (the-as uint 0)) + (let ((v1-2 (res-lump-value (-> obj entity) 'extra-id uint128 :default (the-as uint128 -1) :time -1000000000.0)) + (a0-2 *battles*) + ) + (dotimes (a1-1 (-> a0-2 length)) + (let ((a2-3 (-> a0-2 a1-1))) + (when (= (the-as uint v1-2) (-> a2-3 id)) + (set! (-> obj info) a2-3) + (goto cfg-7) + ) + ) + ) + ) + (go process-drawable-art-error "bad battle id") + (label cfg-7) + (set! (-> obj on-notice) (res-lump-struct (-> obj entity) 'on-notice basic)) + (set! (-> obj on-hostile) (res-lump-struct (-> obj entity) 'on-hostile basic)) + (set! (-> obj on-beaten) (res-lump-struct (-> obj entity) 'on-beaten basic)) + (battle-method-28 obj) + (+! (-> obj count) (-> obj allies length)) + (let ((v1-16 (-> obj info max-count))) + (cond + ((and (= v1-16 #x20000000) (zero? (-> obj spawners length))) + (set! v1-16 (-> obj count)) + ) + ((< v1-16 (-> obj count)) + (set! v1-16 (-> obj count)) + ) + ) + (set! (-> obj max-count) v1-16) + ) + 0 + (none) + ) + +(defmethod battle-method-34 battle ((obj battle)) + (if (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status subtask-complete))) + (go (method-of-object obj beaten)) + (go (method-of-object obj idle)) + ) + 0 + (none) + ) + +(defmethod init-from-entity! battle ((obj battle) (arg0 entity-actor)) + (set! (-> obj mask) (logior (process-mask enemy) (-> obj mask))) + (let ((s4-0 (new 'process 'trsqv))) + (set! (-> obj root) s4-0) + (set! (-> s4-0 trans quad) (-> arg0 extra trans quad)) + (quaternion-copy! (-> s4-0 quat) (-> arg0 quat)) + (vector-identity! (-> s4-0 scale)) + ) + (battle-method-33 obj) + (battle-method-34 obj) + (none) + )