diff --git a/decompiler/analysis/cfg_builder.cpp b/decompiler/analysis/cfg_builder.cpp index a4b2c7b233..829b5c7b30 100644 --- a/decompiler/analysis/cfg_builder.cpp +++ b/decompiler/analysis/cfg_builder.cpp @@ -574,7 +574,8 @@ bool try_splitting_nested_sc(FormPool& pool, Function& func, ShortCircuitElement ASSERT(ir->entries.at(i).branch_delay.has_value()); bool is_and = delay_slot_sets_false(branch.first, *ir->entries.at(i).branch_delay); bool is_or = delay_slot_sets_truthy(branch.first, *ir->entries.at(i).branch_delay); - ASSERT_MSG(is_and != is_or, fmt::format("bad nested sc in {}", func.name())); + ASSERT_MSG(is_and != is_or, + fmt::format("bad nested sc in {}: {}", func.name(), ir->to_string(func.ir2.env))); if (first_different == -1) { // haven't seen a change yet. diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index b77f707066..451f23a35e 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -123,7 +123,6 @@ "vehicle-explode-post", "(method 158 vehicle-guard)", "(method 207 metalhead-predator)", - "(anon-function 4 gun-states)", "(anon-function 28 grenadier)", "(anon-function 24 grenadier)", "test-to-from-spr", @@ -461,7 +460,8 @@ 115, // goto L55 121, 131 - ] + ], + "(anon-function 4 gun-states)": [94, 96, 98] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index f88e53d378..eee132bd6b 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -5366,5 +5366,12 @@ [33, "t9", "(function mood-context none)"], [53, "t9", "(function mood-context none)"], [73, "t9", "(function mood-context none)"] + ], + "(code target-gun-stance)": [ + [598, "v1", "art-joint-anim"], + [152, "v1", "art-joint-anim"], + [248, "v1", "art-joint-anim"], + [345, "v1", "art-joint-anim"], + [442, "v1", "art-joint-anim"] ] } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 1e1e9497ec..8808af9bb2 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1600,6 +1600,14 @@ goos::Object decompile_pair_elt(const LinkedWord& word, (int)word.kind(), word.data)); } } + +bool is_pointer_to_pair(const LinkedWord& word, const std::vector& labels) { + if (word.kind() != LinkedWord::PTR) { + return false; + } + auto& dest_label = labels.at(word.label_id()); + return (dest_label.offset % 8) == 2; +} } // namespace goos::Object decompile_pair(const DecompilerLabel& label, @@ -1649,7 +1657,7 @@ goos::Object decompile_pair(const DecompilerLabel& label, } } // if pointer - if (cdr_word.kind() == LinkedWord::PTR) { + if (is_pointer_to_pair(cdr_word, labels)) { to_print = labels.at(cdr_word.label_id()); continue; } @@ -1662,21 +1670,8 @@ goos::Object decompile_pair(const DecompilerLabel& label, return pretty_print::build_list(list_tokens); } } else { - if ((to_print.offset % 4) != 0) { - throw std::runtime_error( - fmt::format("Invalid alignment for pair {}\n", to_print.offset % 16)); - } else { - // improper - list_tokens.push_back(pretty_print::to_symbol(".")); - list_tokens.push_back( - decompile_pair_elt(words.at(to_print.target_segment).at(to_print.offset / 4), labels, - words, ts, file, version)); - if (add_quote) { - return pretty_print::build_list("quote", pretty_print::build_list(list_tokens)); - } else { - return pretty_print::build_list(list_tokens); - } - } + throw std::runtime_error( + fmt::format("Invalid alignment for pair {}\n", to_print.offset % 16)); } } } diff --git a/goal_src/jak2/engine/anim/joint.gc b/goal_src/jak2/engine/anim/joint.gc index a20f33c42d..da3988a11a 100644 --- a/goal_src/jak2/engine/anim/joint.gc +++ b/goal_src/jak2/engine/anim/joint.gc @@ -1538,7 +1538,8 @@ (flatten-joint-control-to-spr arg2) (make-joint-jump-tables) (calc-animation-from-spr arg0 arg1) - (format 0 "create-interpolated2-joint-animation-frame: untested copy~%") + ;; happens during gun stuff, seems to work. + ; (format 0 "create-interpolated2-joint-animation-frame: untested copy~%") (ultimate-memcpy (the-as pointer *gsf-buffer*) (the-as pointer arg0) (the-as uint (+ (* 48 arg1) 128))) ; (dma-send-from-spr-no-flush ; (the-as uint *gsf-buffer*) diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index c8771aebcc..acdc54057f 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -7,6 +7,10 @@ ;; DECOMP BEGINS +;; hack +(defun prototypes-game-visible-set! ((a0-0 pair) (a1-0 symbol)) + 1) + ;; TODO (defmacro spr-work () @@ -1186,7 +1190,7 @@ (service-cpads) (service-mouse) - ; (execute-connections *pad-engine* #f) + (execute-connections *pad-engine* #f) (none) ) diff --git a/goal_src/jak2/engine/target/gun/gun-blue-shot.gc b/goal_src/jak2/engine/target/gun/gun-blue-shot.gc index b017e5081a..a0b9a690d3 100644 --- a/goal_src/jak2/engine/target/gun/gun-blue-shot.gc +++ b/goal_src/jak2/engine/target/gun/gun-blue-shot.gc @@ -6,3 +6,332 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS + +(defbehavior target-gun-fire-blue target () + (let ((gp-0 (-> self gun)) + (s4-0 (-> self gun fire-dir-out)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((s3-0 (new 'stack-no-clear 'quaternion))) + (quaternion-vector-angle! s3-0 s4-0 (* 182.04445 (rand-vu-float-range 0.0 360.0))) + (vector-rotate-y! s5-0 s4-0 (* 182.04445 (rand-vu-float-range 0.0 1.1))) + (vector-orient-by-quat! s5-0 s5-0 s3-0) + ) + (let ((s4-1 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> s4-1 ent) (-> self entity)) + (set! (-> s4-1 charge) 1.0) + (set! (-> s4-1 options) (projectile-options account-for-target-velocity deal-damage proj-options-8000)) + (set! (-> s4-1 pos quad) (-> gp-0 fire-point quad)) + (set! (-> s4-1 vel quad) (-> s5-0 quad)) + (set! (-> s4-1 notify-handle) (the-as handle #f)) + (set! (-> s4-1 owner-handle) (the-as handle #f)) + (set! (-> s4-1 ignore-handle) (process->handle (the-as process (send-event self 'get-vehicle)))) + (let* ((v1-13 *game-info*) + (a0-15 (+ (-> v1-13 attack-id) 1)) + ) + (set! (-> v1-13 attack-id) a0-15) + (set! (-> s4-1 attack-id) a0-15) + ) + (set! (-> s4-1 timeout) (new 'static 'handle :process #x4b0 :u64 #x4b0)) + (spawn-projectile gun-blue-shot s4-1 (ppointer->process (-> gp-0 gun)) *default-dead-pool*) + ) + ) + ) + +(deftype gun-blue-shot (projectile) + ((init-pos vector :inline :offset-assert 480) + (init-dir vector :inline :offset-assert 496) + (collide-normal vector :inline :offset-assert 512) + ) + :heap-base #x190 + :method-count-assert 40 + :size-assert #x210 + :flag-assert #x2801900210 + ) + + +(defmethod draw-laser-sight gun-blue-shot ((obj gun-blue-shot)) + "TODO - confirm If applicable, draw the laser sight particles + :virtual" + (let* ((s5-0 (ppointer->process (-> obj parent))) + (s4-0 (-> *part-id-table* 196)) + (s3-0 (get-field-spec-by-id s4-0 (sp-field-id spt-omega))) + (s5-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> (the-as projectile s5-0) node-list data 16))) + ) + (when s3-0 + (let ((s1-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> obj starting-dir) 1.0)) + (s2-0 (new 'stack-no-clear 'collide-query)) + ) + (vector-rotate-y! s1-0 s1-0 16384.0) + (vector+float*! s1-0 s5-1 s1-0 -8806.4) + (set! (-> s2-0 start-pos quad) (-> s1-0 quad)) + (vector-float*! (-> s2-0 move-dist) (-> obj root-override dynam gravity-normal) -81920.0) + (let ((v1-11 s2-0)) + (set! (-> v1-11 radius) 1228.8) + (set! (-> v1-11 collide-with) (collide-spec backgnd obstacle hit-by-player-list hit-by-others-list)) + (set! (-> v1-11 ignore-process0) obj) + (set! (-> v1-11 ignore-process1) (ppointer->process (-> obj parent))) + (set! (-> v1-11 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-11 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s2-0) 0.0) + (set! (-> s3-0 initial-valuef) + (fmin (+ 1638.4 (-> s2-0 best-other-tri intersect y)) (+ -1228.8 (-> obj starting-pos y))) + ) + (set! (-> s3-0 initial-valuef) (+ -81920.0 (-> obj starting-pos y))) + ) + ) + ) + (let ((s4-1 (get-field-spec-by-id s4-0 (sp-field-id spt-rotate-y)))) + (if s4-1 + (set! (-> s4-1 initial-valuef) (y-angle (-> obj root-override))) + ) + ) + (let ((t9-7 sp-launch-particles-var) + (a0-19 *sp-particle-system-2d*) + (a1-9 (-> *part-id-table* 196)) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> s5-1 quad)) + (t9-7 a0-19 a1-9 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((s4-2 (get-field-spec-by-id (-> *part-id-table* 195) (sp-field-id spt-rotate-y)))) + (if s4-2 + (set! (-> s4-2 initial-valuef) (y-angle (-> obj root-override))) + ) + ) + (let ((t9-10 sp-launch-particles-var) + (a0-22 *sp-particle-system-2d*) + (a1-11 (-> *part-id-table* 195)) + (a2-4 *launch-matrix*) + ) + (set! (-> a2-4 trans quad) (-> s5-1 quad)) + (t9-10 a0-22 a1-11 a2-4 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + 0 + (none) + ) + +(defmethod spawn-shell-particles gun-blue-shot ((obj gun-blue-shot)) + "TODO - confirm" + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s3-1 (vector-! (new 'stack-no-clear 'vector) (-> obj root-override trans) (-> obj init-pos)))) + (draw-beam (-> *part-id-table* 191) (-> obj init-pos) s3-1 #t #t) + (draw-beam (-> *part-id-table* 194) (-> obj init-pos) (-> obj starting-dir) #f #t) + (let ((s5-0 (-> *part-id-table* 206)) + (s4-0 (-> *part-id-table* 205)) + ) + (new 'stack-no-clear 'vector) + (let ((s2-0 (vector-reflect! (new 'stack-no-clear 'vector) s3-1 (-> obj collide-normal)))) + (vector-normalize! s2-0 1.0) + (get-field-spec-by-id s5-0 (sp-field-id spt-conerot-x)) + (get-field-spec-by-id s5-0 (sp-field-id spt-conerot-y)) + (get-field-spec-by-id s5-0 (sp-field-id spt-conerot-z)) + (let ((a1-7 (new 'stack-no-clear 'matrix)) + (s1-0 (new 'stack-no-clear 'vector)) + (s3-2 (new 'stack-no-clear 'vector)) + ) + (vector-cross! (the-as vector (-> a1-7 vector)) *y-vector* s2-0) + (vector-cross! (-> a1-7 vector 1) s2-0 (the-as vector (-> a1-7 vector))) + (set! (-> a1-7 vector 2 quad) (-> s2-0 quad)) + (matrix->eul (the-as euler-angles s1-0) a1-7 21) + (vector-negate! s3-2 s1-0) + (let ((a0-14 s3-2)) + (let ((v1-16 s3-2)) + (let ((a1-10 -3640.889)) + (.mov vf6 a1-10) + ) + (.lvf vf4 (&-> v1-16 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-14 quad) vf5) + ) + (sparticle-set-conerot s5-0 s3-2) + (sparticle-set-conerot s4-0 s3-2) + ) + ) + ) + ) + (let ((s5-1 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-1 + (let ((t9-12 (method-of-type part-tracker activate))) + (t9-12 + (the-as part-tracker s5-1) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-13 run-function-in-process) + (a0-19 s5-1) + (a1-15 part-tracker-init) + (a2-12 (-> *part-group-id-table* 68)) + (a3-3 0) + (t0-2 #f) + (t1-0 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> obj root-override trans quad)) + ((the-as (function object object object object object object object object none) t9-13) + a0-19 + a1-15 + a2-12 + a3-3 + t0-2 + t1-0 + t2-0 + t3-0 + ) + ) + (-> s5-1 ppointer) + ) + ) + 0 + (none) + ) + ) + +(defmethod unknown-particles gun-blue-shot ((obj gun-blue-shot)) + "TODO - confirm" + (draw-beam (-> *part-id-table* 191) (-> obj init-pos) (-> obj init-dir) #f #t) + (draw-beam (-> *part-id-table* 194) (-> obj init-pos) (-> obj starting-dir) #f #t) + 0 + (none) + ) + +(defmethod play-impact-sound gun-blue-shot ((obj gun-blue-shot) (arg0 projectile-options)) + (let ((v1-0 arg0)) + (cond + ((zero? v1-0) + (sound-play "blue-shot-fire") + ) + ((= v1-0 (projectile-options lose-altitude)) + (sound-play "blue-shot-hit") + ) + ) + ) + ) + +(defmethod made-impact? gun-blue-shot ((obj gun-blue-shot)) + "TODO - queries the collision cache, return true/false" + (let ((v1-0 (-> obj root-override)) + (t1-0 (new 'stack-no-clear 'collide-query)) + ) + (let ((a1-0 t1-0)) + (set! (-> a1-0 radius) (-> v1-0 root-prim prim-core world-sphere w)) + (set! (-> a1-0 collide-with) (-> v1-0 root-prim prim-core collide-with)) + (set! (-> a1-0 ignore-process0) obj) + (set! (-> a1-0 ignore-process1) (ppointer->process (-> obj parent))) + (set! (-> a1-0 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> a1-0 action-mask) (collide-action solid)) + ) + (fill-and-try-snap-to-surface v1-0 (-> v1-0 transv) -12288.0 12697.6 -2048.0 t1-0) + ) + ) + +(defun gun-blue-shot-move ((arg0 gun-blue-shot)) + (projectile-move-fill-line-sphere arg0) + (if (logtest? (-> arg0 root-override status) (collide-status touch-surface)) + (go (method-of-object arg0 impact)) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch int vs collide-status. +(defun cshape-reaction-blue-shot ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector)) + (vector-reset! arg2) + (let ((a1-1 (new 'stack-no-clear 'vector))) + (vector-float*! a1-1 (-> arg1 move-dist) (-> arg1 best-dist)) + (move-by-vector! arg0 a1-1) + ) + (set! (-> (the-as gun-blue-shot (-> arg0 process)) collide-normal quad) (-> arg1 best-other-tri normal quad)) + (let ((v0-1 4)) + (logior! (-> arg0 status) v0-1) + (the-as collide-status v0-1) + ) + ) + +(defmethod init-collision! gun-blue-shot ((obj gun-blue-shot)) + "Init the [[projectile]]'s [[collide-shape]]" + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-blue-shot) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate jak-blue-shot)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0))) + (set! (-> s5-0 total-prims) (the-as uint 3)) + (set! (-> s4-0 prim-core collide-as) (collide-spec projectile)) + (set! (-> s4-0 prim-core collide-with) + (collide-spec backgnd bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher) + ) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 1228.8) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-13 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-13 prim-core collide-with) (collide-spec backgnd obstacle pusher)) + (set! (-> v1-13 prim-core action) (collide-action solid)) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 0.0 819.2) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-15 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-15 prim-core collide-with) + (collide-spec bot crate civilian enemy vehicle-sphere hit-by-others-list player-list) + ) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set-vector! (-> v1-15 local-sphere) 0.0 0.0 0.0 4096.0) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-18 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-18 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-18 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> obj root-override) s5-0) + ) + (set! (-> obj root-override pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1) + ) + 0 + (none) + ) + +(defmethod init-proj-settings! gun-blue-shot ((obj gun-blue-shot)) + "Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc + :virtual" + (with-pp + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (set! (-> obj init-pos quad) (-> obj root-override trans quad)) + (set! (-> obj init-dir quad) (-> obj starting-dir quad)) + (vector-normalize-copy! + (-> obj root-override transv) + (-> obj init-dir) + (* 327680.0 (-> pp clock frames-per-second)) + ) + (set! (-> obj attack-mode) 'eco-blue) + (set! (-> obj max-speed) (* 327680.0 (-> pp clock frames-per-second))) + (set! (-> obj timeout) 1) + (set! (-> obj move) gun-blue-shot-move) + (vector-reset! (-> obj collide-normal)) + (set! (-> obj damage) (if (logtest? (game-feature gun-upgrade-damage) (-> *game-info* features)) + 4.0 + 2.0 + ) + ) + 0 + (none) + ) + ) diff --git a/goal_src/jak2/engine/target/gun/gun-dark-shot.gc b/goal_src/jak2/engine/target/gun/gun-dark-shot.gc index 95feb2bfc4..ca5909c946 100644 --- a/goal_src/jak2/engine/target/gun/gun-dark-shot.gc +++ b/goal_src/jak2/engine/target/gun/gun-dark-shot.gc @@ -5,5 +5,891 @@ ;; name in dgo: gun-dark-shot ;; dgos: ENGINE, GAME +(define-extern market-object type) +(define-extern fruit-stand type) +(define-extern crate type) + ;; DECOMP BEGINS +(set! (-> *lightning-spec-id-table* 11) (new 'static 'lightning-spec + :name "lightning-dark-shot-attack" + :flags (lightning-spec-flags lsf0) + :start-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :end-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :fade-to-color (new 'static 'rgba :r #xbf :b #x8f :a #x5) + :fade-start-factor 0.2 + :texture (new 'static 'texture-id :index #x83 :page #xc) + :reduction 0.42 + :num-points 16 + :box-size 8192.0 + :merge-factor 0.6 + :merge-count 2 + :radius 3276.8 + :duration 45.0 + :duration-rand 60.0 + :sound (static-sound-spec "stretched-zap") + ) + ) + +(set! (-> *lightning-spec-id-table* 12) (new 'static 'lightning-spec + :name "lightning-dark-shot-attack-thick" + :flags (lightning-spec-flags lsf0) + :start-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :end-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :fade-to-color (new 'static 'rgba :r #xbf :b #x8f :a #x5) + :fade-start-factor 0.2 + :texture (new 'static 'texture-id :index #x83 :page #xc) + :reduction 0.42 + :num-points 32 + :box-size 12288.0 + :merge-factor 0.6 + :merge-count 2 + :radius 12288.0 + :duration 60.0 + :sound (static-sound-spec "stretched-zap") + ) + ) + +(defpart 429 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0) + (sp-flt spt-rot-x 2048.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 0.0 64.0 1.0) + (sp-rnd-flt spt-g 64.0 64.0 1.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 48.0) + (sp-int spt-timer 5) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-flt spt-userdata 4096.0) + ) + ) + +(defpart 430 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbc :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 1) (meters 4) 1.0) + (sp-flt spt-rot-x 2048.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 0.0 64.0 1.0) + (sp-rnd-flt spt-g 64.0 64.0 1.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 128.0) + (sp-int spt-timer 5) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-flt spt-userdata 4096.0) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 3600.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-rnd-flt spt-conerot-z (degrees 0.0) (degrees 3600.0) 1.0) + (sp-rnd-flt spt-conerot-radius (meters -0.1) (meters 0.5) 1.0) + ) + ) + +(deftype gun-dark-shot (projectile) + ((blast-radius float :offset-assert 472) + (core-position vector :inline :offset-assert 480) + (core-velocity vector :inline :offset-assert 496) + (spin-vector vector :inline :offset-assert 512) + (track-target handle :offset-assert 528) + (size-t float :offset-assert 536) + (result-array handle 16 :offset-assert 544) + (charge-sound uint32 :offset-assert 672) + (fire-sound uint32 :offset-assert 676) + (trail-sound uint32 :offset-assert 680) + (explode-sound uint32 :offset-assert 684) + (start-pilot? basic :offset-assert 688) + ) + :heap-base #x240 + :method-count-assert 42 + :size-assert #x2b4 + :flag-assert #x2a024002b4 + (:methods + (startup () _type_ :state 40) + (fizzle () _type_ :state 41) + ) + ) + + +(defbehavior target-gun-fire-dark target () + (let ((s5-0 (-> self gun)) + (gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)) + ) + (set! (-> gp-0 ent) (-> self entity)) + (set! (-> gp-0 charge) (-> s5-0 fire-charge)) + (set! (-> gp-0 options) (projectile-options)) + (set! (-> gp-0 pos quad) (-> s5-0 fire-point quad)) + (set! (-> gp-0 vel quad) (-> s5-0 fire-dir-out quad)) + (set! (-> gp-0 notify-handle) (the-as handle #f)) + (set! (-> gp-0 owner-handle) (the-as handle #f)) + (set! (-> gp-0 ignore-handle) (process->handle (the-as process (send-event self 'get-vehicle)))) + (let* ((v1-8 *game-info*) + (a0-11 (+ (-> v1-8 attack-id) 1)) + ) + (set! (-> v1-8 attack-id) a0-11) + (set! (-> gp-0 attack-id) a0-11) + ) + (set! (-> gp-0 timeout) (new 'static 'handle :process #x4b0 :u64 #x4b0)) + (let ((v0-1 (spawn-projectile gun-dark-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*))) + (when v0-1 + (set! (-> (the-as gun-dark-shot (-> v0-1 0)) track-target) (-> self gun track-target 0 handle)) + (set! (-> self gun charge-active?) (ppointer->handle v0-1)) + ) + v0-1 + ) + ) + ) + +(defmethod init-proj-settings! gun-dark-shot ((obj gun-dark-shot)) + "Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc + :virtual" + (set! (-> obj attack-mode) 'eco-dark) + (vector-normalize! (-> obj root-override transv) (+ 225280.0 (* 225280.0 (-> obj charge-level)))) + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 72) obj)) + (set! (-> obj blast-radius) 40960.0) + (set! (-> obj size-t) 0.0) + (set! (-> obj charge-sound) (the-as uint (new-sound-id))) + (set! (-> obj fire-sound) (the-as uint (new-sound-id))) + (set! (-> obj trail-sound) (the-as uint (new-sound-id))) + (set! (-> obj explode-sound) + (the-as + uint + (gui-control-method-9 *gui-control* obj (gui-channel background) (gui-action queue) "pmkrxplo" -99.0 0) + ) + ) + (gui-control-method-20 *gui-control* (the-as sound-id (-> obj explode-sound)) #t 50 150 11) + (set! (-> obj start-pilot?) + (the-as basic (and *target* (logtest? (focus-status pilot) (-> *target* focus-status)))) + ) + ((method-of-type projectile init-proj-settings!) obj) + 0 + (none) + ) + +(defmethod spawn-impact-particles gun-dark-shot ((obj gun-dark-shot)) + "Spawns associated particles with the projectile if applicable" + (cond + ((and (and (-> obj next-state) (= (-> obj next-state name) 'startup)) + (and *target* (logtest? (-> *target* focus-status) (focus-status in-head))) + ) + (kill-and-free-particles (-> obj part)) + ) + (else + (set! (-> *part-id-table* 219 init-specs 2 initial-valuef) (lerp 409.6 9216.0 (-> obj size-t))) + (set! (-> *part-id-table* 219 init-specs 8 initial-valuef) (lerp 0.0 32.0 (-> obj size-t))) + (set! (-> *part-id-table* 220 init-specs 2 initial-valuef) (lerp 409.6 32768.0 (-> obj size-t))) + (set! (-> *part-id-table* 220 init-specs 8 initial-valuef) (lerp 0.0 16.0 (-> obj size-t))) + (set! (-> *part-id-table* 218 init-specs 2 initial-valuef) (lerp 409.6 8192.0 (-> obj size-t))) + (set! (-> *part-id-table* 217 init-specs 1 initial-valuef) (lerp 0.1 1.0 (-> obj size-t))) + (set! (-> *part-id-table* 217 init-specs 2 initial-valuef) (lerp 409.6 3686.4 (-> obj size-t))) + (spawn (-> obj part) (-> obj root-override trans)) + ) + ) + (ja-post) + (none) + ) + +(defmethod go-moving! gun-dark-shot ((obj gun-dark-shot)) + (go (method-of-object obj startup)) + 0 + (none) + ) + +(defstate startup (gun-dark-shot) + :virtual #t + :exit (behavior () + (send-event (ppointer->process (-> self parent)) 'release) + (set! (-> self size-t) 1.0) + (let ((v1-6 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-6 command) (sound-command set-param)) + (set! (-> v1-6 id) (the-as sound-id (-> self charge-sound))) + (set! (-> v1-6 params volume) -4) + (set! (-> v1-6 auto-time) 24) + (set! (-> v1-6 auto-from) 2) + (set! (-> v1-6 params mask) (the-as uint 17)) + (-> v1-6 id) + ) + (none) + ) + :code (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (until #f + (cond + ((or (and *target* + (logtest? (focus-status dead grabbed under-water pole flut board mech dark carry indax teleporting) + (-> *target* focus-status) + ) + ) + (and *target* (zero? (logand (focus-status in-head gun) (-> *target* focus-status)))) + (and *target* (not (-> self start-pilot?)) (logtest? (focus-status pilot) (-> *target* focus-status))) + ) + (go-virtual dissipate) + ) + ((or (< (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.3)) (cpad-hold? 0 r1)) + (set! (-> self size-t) + (fmin 1.0 (* 0.016666668 (the float (- (-> self clock frame-counter) (-> self state-time))))) + ) + (let ((t9-1 vector<-cspace!) + (a0-13 (-> self root-override trans)) + (v1-26 (-> self parent)) + ) + (t9-1 a0-13 (-> (the-as process-drawable (if v1-26 + (the-as process-drawable (-> v1-26 0 self)) + ) + ) + node-list + data + 13 + ) + ) + ) + ) + ((and (logtest? (-> self options) (projectile-options proj-options-8000)) (made-impact? self)) + (go-virtual impact) + ) + (else + (go-virtual moving) + ) + ) + (suspend) + ) + #f + (none) + ) + :post (behavior () + (sound-play + "pmkr-charge" + :id (the-as sound-id (-> self charge-sound)) + :position (-> self root-override trans) + ) + (spawn-impact-particles self) + (none) + ) + ) + +(defstate moving (gun-dark-shot) + :virtual #t + :enter (behavior () + (let ((t9-0 (-> (method-of-type projectile moving) enter))) + (if t9-0 + (t9-0) + ) + ) + (set! (-> self core-position quad) (-> self root-override trans quad)) + (let ((v1-5 (-> self core-velocity)) + (a0-3 (-> self parent)) + ) + (set! (-> v1-5 quad) (-> (the-as process-drawable (if a0-3 + (the-as process-drawable (-> a0-3 0 self)) + ) + ) + node-list + data + 13 + bone + transform + vector + 2 + quad + ) + ) + ) + (when (and *target* (logtest? (-> *target* focus-status) (focus-status in-head))) + (set! (-> self core-position quad) (-> (camera-pos) quad)) + (set! (-> self core-velocity quad) (-> (camera-matrix) vector 2 quad)) + ) + (set-vector! (-> self spin-vector) (-> self core-velocity z) 0.0 (- (-> self core-velocity x)) 1.0) + (let ((f0-5 (vector-length (-> self spin-vector)))) + (if (< f0-5 1.0) + (set-vector! (-> self spin-vector) 1.0 0.0 0.0 1.0) + (vector-float*! (-> self spin-vector) (-> self spin-vector) (/ 1.0 f0-5)) + ) + ) + (set! (-> self state-time) (-> self clock frame-counter)) + (let ((gp-2 (get-process *default-dead-pool* part-tracker #x4000))) + (when gp-2 + (let ((t9-4 (method-of-type part-tracker activate))) + (t9-4 + (the-as part-tracker gp-2) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-5 run-function-in-process) + (a0-18 gp-2) + (a1-4 part-tracker-init) + (a2-4 (-> *part-group-id-table* 70)) + (a3-1 0) + (t0-0 #f) + (t1-0 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self root-override trans quad)) + ((the-as (function object object object object object object object object none) t9-5) + a0-18 + a1-4 + a2-4 + a3-1 + t0-0 + t1-0 + t2-0 + t3-0 + ) + ) + (-> gp-2 ppointer) + ) + ) + (draw-beam (-> *part-id-table* 210) (-> self root-override trans) (-> self core-velocity) #f #t) + (none) + ) + :trans (behavior () + (local-vars (at-0 int)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-normalize-copy! s4-0 (-> self core-velocity) 1.0) + (let* ((s3-0 (handle->process (-> self track-target))) + (v1-3 (if (type? s3-0 process-drawable) + (the-as process-drawable s3-0) + ) + ) + ) + (when v1-3 + (let* ((s3-2 (vector-! (new 'stack-no-clear 'vector) (-> v1-3 root trans) (-> self core-position))) + (f0-0 (vector-normalize-ret-len! s3-2 1.0)) + (f0-1 (lerp-scale 182.04445 8192.0 f0-0 61440.0 4096.0)) + (s2-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-from-two-vectors-max-angle! s2-0 s4-0 s3-2 f0-1) + (vector-matrix*! (-> self core-velocity) (-> self core-velocity) s2-0) + ) + ) + ) + (+! (-> self spin-vector x) (-> s4-0 z)) + (set! (-> self spin-vector z) (- (-> self spin-vector z) (-> s4-0 x))) + (vector-flatten! (-> self spin-vector) (-> self spin-vector) s4-0) + (matrix-axis-angle! s5-0 s4-0 (* 2002.4889 (-> self clock time-adjust-ratio))) + (vector-matrix*! (-> self spin-vector) (-> self spin-vector) s5-0) + (let ((f0-9 (the float (- (-> self clock frame-counter) (-> self state-time)))) + (f30-0 0.0) + ) + (cond + ((< 450.0 f0-9) + (go-virtual impact) + ) + ((< f0-9 90.0) + (set! f30-0 (lerp-scale 0.0 4096.0 f0-9 0.0 90.0)) + ) + (else + (set! f30-0 (lerp-scale 4096.0 1228.8 f0-9 30.0 300.0)) + ) + ) + (vector-normalize! (-> self spin-vector) f30-0) + (vector-normalize! (-> self core-velocity) 7372.8) + (set! (-> s5-0 vector 2 quad) (-> s4-0 quad)) + (set! (-> s5-0 vector 1 quad) (-> self spin-vector quad)) + (vector-float*! (-> s5-0 vector 1) (-> s5-0 vector 1) (/ 1.0 f30-0)) + ) + ) + (vector-cross! (the-as vector (-> s5-0 vector)) (-> s5-0 vector 1) (-> s5-0 vector 2)) + (matrix->quaternion (-> self root-override quat) s5-0) + ) + (vector+! (-> self core-position) (-> self core-position) (-> self core-velocity)) + (vector+! gp-0 (-> self core-position) (-> self spin-vector)) + (vector-! (-> self root-override transv) gp-0 (-> self root-override trans)) + ) + (let ((v1-31 (-> self root-override transv))) + (.lvf vf1 (&-> (-> self root-override transv) quad)) + (let ((f0-12 (-> self clock frames-per-second))) + (.mov at-0 f0-12) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-31 quad) vf1) + ) + (projectile-move-fill-line-sphere self) + (if (logtest? (-> self root-override status) (collide-status touch-surface)) + (go-virtual impact) + ) + (sound-play "pmkr-fire" :id (the-as sound-id (-> self fire-sound)) :position (-> self root-override trans)) + (sound-play "pmkr-trail" :id (the-as sound-id (-> self trail-sound)) :position (-> self root-override trans)) + (none) + ) + ) + ) + +;; WARN: Check prologue - tricky store of a0 +(defun process-drawable-shock-effect-bullseye ((arg0 process-focusable) + (arg1 process-focusable) + (arg2 matrix) + (arg3 int) + (arg4 sparticle-launcher) + (arg5 sparticle-launcher) + (arg6 sparticle-launcher) + ) + (local-vars (sv-16 process) (sv-32 matrix) (sv-48 process-focusable)) + (set! sv-48 arg0) + (let ((s0-0 arg1)) + (set! sv-32 arg2) + (let ((gp-0 arg4) + (s2-0 arg5) + (s3-0 arg6) + (s4-0 (get-trans sv-48 3)) + (s5-0 (get-trans s0-0 3)) + ) + (set! sv-16 (get-process *default-dead-pool* lightning-tracker #x4000)) + (let ((s1-0 (when sv-16 + (let ((t9-3 (method-of-type lightning-tracker activate))) + (t9-3 + (the-as lightning-tracker sv-16) + s0-0 + (symbol->string (-> lightning-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-4 run-function-in-process) + (a0-5 sv-16) + (a1-7 lightning-tracker-init) + (a3-2 0) + (t0-1 lightning-probe-callback) + (t2-1 256) + (t3-0 256) + ) + ((the-as (function object object object object object object object object none) t9-4) + a0-5 + a1-7 + sv-32 + a3-2 + t0-1 + sv-48 + t2-1 + t3-0 + ) + ) + (-> sv-16 ppointer) + ) + ) + ) + (when s2-0 + (let ((t9-5 sp-launch-particles-var) + (a0-6 *sp-particle-system-2d*) + (a2-4 *launch-matrix*) + ) + (set! (-> a2-4 trans quad) (-> s4-0 quad)) + (t9-5 a0-6 s2-0 a2-4 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (when s3-0 + (let ((t9-6 sp-launch-particles-var) + (a0-7 *sp-particle-system-2d*) + (a2-5 *launch-matrix*) + ) + (set! (-> a2-5 trans quad) (-> s4-0 quad)) + (t9-6 a0-7 s3-0 a2-5 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (when (and gp-0 s1-0) + (let ((v1-15 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-15 + (set! (-> v1-15 initial-valuef) (the-as float (-> (the-as lightning-tracker (-> s1-0 0)) duration))) + ) + ) + (let ((t9-8 sp-launch-particles-var) + (a0-12 *sp-particle-system-2d*) + (a1-15 gp-0) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> s4-0 quad)) + (t9-8 a0-12 a1-15 a2-6 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-9 sp-launch-particles-var) + (a0-13 *sp-particle-system-2d*) + (a2-7 *launch-matrix*) + ) + (set! (-> a2-7 trans quad) (-> s5-0 quad)) + (t9-9 a0-13 gp-0 a2-7 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defstate fizzle (gun-dark-shot) + :virtual #t + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :trans (behavior () + (if (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 1)) + (deactivate self) + ) + (process-drawable-shock-effect + self + (-> *lightning-spec-id-table* 11) + lightning-probe-callback + (-> *part-id-table* 429) + 256 + 0 + 40960.0 + ) + (let ((t9-2 sp-launch-particles-var) + (a0-3 *sp-particle-system-2d*) + (a1-1 (-> *part-id-table* 215)) + (a2-1 *launch-matrix*) + ) + (set! (-> a2-1 trans quad) (-> self root-override trans quad)) + (t9-2 a0-3 a1-1 a2-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-3 sp-launch-particles-var) + (a0-4 *sp-particle-system-2d*) + (a1-2 (-> *part-id-table* 216)) + (a2-2 *launch-matrix*) + ) + (set! (-> a2-2 trans quad) (-> self root-override trans quad)) + (t9-3 a0-4 a1-2 a2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((gp-0 (-> *part-id-table* 430))) + (when gp-0 + (let ((v1-14 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-14 + (set! (-> v1-14 initial-valuef) (the-as float #xf)) + ) + ) + (let ((t9-5 sp-launch-particles-var) + (a0-8 *sp-particle-system-2d*) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> self root-override trans quad)) + (t9-5 a0-8 gp-0 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + (none) + ) + :code (the-as (function none :behavior gun-dark-shot) sleep-code) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior gun-dark-shot-init-fizzle gun-dark-shot ((arg0 vector)) + (let ((s5-0 (new 'process 'collide-shape-moving self (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-projectile) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (let ((v1-6 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-6 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-6 prim-core collide-with) + (collide-spec backgnd crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher) + ) + (set! (-> v1-6 prim-core action) (collide-action solid)) + (set-vector! (-> v1-6 local-sphere) 0.0 5324.8 0.0 5324.8) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-6) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-9 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-9 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-9 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> self root-override) s5-0) + ) + (set! (-> self root-override trans quad) (-> arg0 quad)) + (let ((v1-16 (-> self root-override root-prim))) + (set! (-> v1-16 prim-core collide-as) (collide-spec)) + (set! (-> v1-16 prim-core collide-with) (collide-spec)) + ) + 0 + (logclear! (-> self mask) (process-mask actor-pause)) + (go-virtual fizzle) + (none) + ) + +(defstate impact (gun-dark-shot) + :virtual #t + :code (behavior () + (local-vars + (sv-256 collide-shape) + (sv-272 process-drawable) + (sv-288 vector) + (sv-304 process-drawable) + (sv-320 process-drawable) + (sv-336 process-drawable) + ) + (if (< (- (-> self clock frame-counter) (-> self spawn-time)) (seconds 0.1)) + (send-event (ppointer->process (-> self parent)) 'release) + ) + (sound-stop (the-as sound-id (-> self trail-sound))) + (let ((v1-10 (gui-control-method-17 *gui-control* (the-as sound-id (-> self explode-sound))))) + (cond + ((= v1-10 (gui-action play)) + (gui-control-method-16 + *gui-control* + (gui-action play) + (the-as sound-id (-> self explode-sound)) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (else + (gui-control-method-16 + *gui-control* + (gui-action stop) + (the-as sound-id (-> self explode-sound)) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (the-as int (sound-play "explosion" :pitch 2.5)) + ) + ) + ) + (let ((v1-16 (-> self root-override root-prim))) + (set! (-> v1-16 prim-core collide-as) (collide-spec)) + (set! (-> v1-16 prim-core collide-with) (collide-spec)) + ) + 0 + (let ((gp-1 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-1 spawn-point quad) (-> self root-override trans quad)) + (quaternion-copy! (-> gp-1 spawn-quat) (-> self root-override quat)) + (set! (-> gp-1 radius) 36864.0) + (set! (-> gp-1 group) (-> *part-group-id-table* 71)) + (set! (-> gp-1 collide-with) + (collide-spec backgnd crate enemy obstacle vehicle-sphere hit-by-others-list player-list pusher) + ) + (set! (-> gp-1 penetrate-using) (penetrate explode)) + (explosion-spawn (the-as process-drawable *default-pool*) explosion gp-1) + ) + (let (;(s3-0 (the-as (array collide-shape) (new 'stack 'array collide-shape 16))) + (s3-0 (the-as (pointer collide-shape) (new 'stack-no-clear 'array 'collide-shape 16))) + (a1-8 (new 'stack-no-clear 'sphere)) + ) + (set! (-> a1-8 quad) (-> self root-override trans quad)) + (set! (-> a1-8 r) (-> self blast-radius)) + (let ((gp-2 (fill-actor-list-for-sphere *actor-hash* a1-8 s3-0 16))) + (let ((s1-0 (the-as process-drawable #f)) + (f30-0 4096000.0) + (s4-0 0) + (s5-1 #t) + ) + (countdown (s2-0 gp-2) + (set! sv-256 (-> s3-0 s2-0)) + (set! sv-272 (-> sv-256 process)) + (let ((s0-0 (if (type? sv-272 process-focusable) + sv-272 + ) + ) + ) + (cond + ((and (nonzero? (-> sv-256 root-prim prim-core collide-as)) + s0-0 + (logtest? (process-mask crate enemy collectable guard) (-> s0-0 mask)) + (not (logtest? (-> (the-as process-focusable s0-0) focus-status) (focus-status disable dead ignore))) + (zero? (logand (process-mask no-track) (-> s0-0 mask))) + ) + (set! sv-288 (get-trans (the-as process-focusable s0-0) 3)) + (let ((f28-0 (- (vector-vector-distance (-> self root-override trans) sv-288) (-> sv-288 w)))) + (set! sv-304 s0-0) + (if (and (not (if (type? sv-304 crate) + sv-304 + ) + ) + (begin (set! sv-320 s0-0) (not (if (type? sv-320 market-object) + sv-320 + ) + ) + ) + (begin (set! sv-336 s0-0) (not (if (type? sv-336 fruit-stand) + sv-336 + ) + ) + ) + ) + (set! s5-1 #f) + ) + (cond + ((not s1-0) + (+! gp-2 -1) + (set! f30-0 f28-0) + (set! s1-0 s0-0) + ) + ((< f28-0 f30-0) + (set! (-> self result-array s4-0) (process->handle s1-0)) + (+! s4-0 1) + (set! f30-0 f28-0) + (set! s1-0 s0-0) + ) + (else + (set! (-> self result-array s4-0) (process->handle s0-0)) + (+! s4-0 1) + ) + ) + ) + ) + (else + (+! gp-2 -1) + ) + ) + ) + ) + (when s1-0 + (set! (-> self result-array s4-0) (process->handle s1-0)) + (+! gp-2 1) + (+ s4-0 1) + ) + (if (zero? gp-2) + (go-virtual fizzle) + ) + (if s5-1 + (process-spawn gun-dark-shot :init gun-dark-shot-init-fizzle (-> self root-override trans)) + ) + ) + (countdown (s5-3 gp-2) + (let* ((s3-1 (handle->process (-> self result-array s5-3))) + (s4-1 (if (type? s3-1 process-focusable) + s3-1 + ) + ) + ) + (when s4-1 + (let ((a1-21 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-21 from) (process->ppointer self)) + (set! (-> a1-21 num-params) 2) + (set! (-> a1-21 message) 'attack) + (set! (-> a1-21 param 0) (the-as uint #f)) + (let ((v1-91 (new 'static 'attack-info :mask (attack-info-mask mode id damage)))) + (let* ((a0-49 *game-info*) + (a2-12 (+ (-> a0-49 attack-id) 1)) + ) + (set! (-> a0-49 attack-id) a2-12) + (set! (-> v1-91 id) a2-12) + ) + (set! (-> v1-91 mode) 'explode) + (set! (-> v1-91 damage) 16.0) + (set! (-> a1-21 param 1) (the-as uint v1-91)) + ) + (send-event-function s4-1 a1-21) + ) + (process-spawn-function + process + (lambda :behavior gun-dark-shot + ((arg0 handle)) + (let ((s5-0 (-> self parent)) + (s4-0 0) + (s3-0 (-> self clock frame-counter)) + ) + (set! (-> self clock) (-> s5-0 0 clock)) + (while (and (nonzero? (-> (the-as process-drawable (-> s5-0 0)) skel)) + (let ((v1-30 s5-0)) + (and (or (logtest? (-> (the-as process-focusable (if v1-30 + (the-as process-focusable (-> v1-30 0 self)) + ) + ) + focus-status + ) + (focus-status dead hit) + ) + (let ((v1-35 s5-0)) + (or (and (-> (the-as process (if v1-35 + (the-as process (-> v1-35 0 self)) + ) + ) + next-state + ) + (let ((v1-39 s5-0)) + (= (-> (the-as process (if v1-39 + (the-as process (-> v1-39 0 self)) + ) + ) + next-state + name + ) + 'knocked + ) + ) + ) + (< (- (-> self clock frame-counter) s3-0) (seconds 0.1)) + ) + ) + ) + (< (- (-> self clock frame-counter) s3-0) (seconds 5)) + (zero? (logand (-> (the-as process-drawable (-> s5-0 0)) draw status) (draw-control-status no-draw no-draw-temp)) + ) + ) + ) + ) + (when (>= (- (-> self clock frame-counter) (the-as time-frame s4-0)) (seconds 0.05)) + (set! s4-0 (the-as int (-> self clock frame-counter))) + (if (handle->process arg0) + (process-drawable-shock-effect-bullseye + (the-as process-focusable (handle->process arg0)) + (the-as process-focusable (ppointer->process s5-0)) + (the-as matrix (-> *lightning-spec-id-table* 12)) + (the-as int lightning-probe-callback) + (-> *part-id-table* 430) + (-> *part-id-table* 215) + (-> *part-id-table* 216) + ) + ) + (process-drawable-shock-effect + (the-as process-drawable (ppointer->process s5-0)) + (-> *lightning-spec-id-table* 11) + lightning-probe-callback + (-> *part-id-table* 429) + 0 + 0 + 40960.0 + ) + ) + (suspend) + ) + ) + (none) + ) + (-> self result-array (+ gp-2 -1)) + :to s4-1 + ) + (let ((s4-2 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s4-2) (seconds 0.1)) + (suspend) + ) + ) + ) + ) + ) + ) + ) + (let ((gp-3 (-> self clock frame-counter))) + (while (or (-> self child) + (and (nonzero? (gui-control-method-17 *gui-control* (the-as sound-id (-> self explode-sound)))) + (< (- (-> self clock frame-counter) gp-3) (seconds 10)) + ) + ) + (suspend) + ) + ) + (deactivate self) + (none) + ) + ) diff --git a/goal_src/jak2/engine/target/gun/gun-red-shot.gc b/goal_src/jak2/engine/target/gun/gun-red-shot.gc index ed9b666f4f..720988fe1d 100644 --- a/goal_src/jak2/engine/target/gun/gun-red-shot.gc +++ b/goal_src/jak2/engine/target/gun/gun-red-shot.gc @@ -9,3 +9,590 @@ (define-extern gun-red-shot-init-by-other (function vector vector gun-red-shot :behavior gun-red-shot)) ;; DECOMP BEGINS + +(deftype gun-red-shot (process-drawable) + ((root-override collide-shape-moving :offset 128) + (probe-count int32 :offset-assert 200) + (probe-mask uint32 :offset-assert 204) + (actor-count int32 :offset-assert 208) + (attack-id uint32 :offset-assert 212) + (start-pos vector :inline :offset-assert 224) + (start-dir vector :inline :offset-assert 240) + (start-rot vector :inline :offset-assert 256) + (probe-dir vector 19 :inline :offset-assert 272) + ) + :heap-base #x1c0 + :method-count-assert 30 + :size-assert #x240 + :flag-assert #x1e01c00240 + (:methods + (blocked () _type_ :state 20) + (debug-idle () _type_ :state 21) + (idle () _type_ :state 22) + (init-probes! (_type_ collide-shape) none 23) + (gun-red-shot-method-24 (_type_) symbol 24) + (noop (_type_) none 25) + (gun-red-shot-method-26 (_type_) none 26) + (gun-red-shot-method-27 (_type_) none 27) + (gun-red-shot-method-28 (_type_ vector) sound-id 28) + (fire! (_type_ process-drawable int) object :behavior gun-red-shot 29) + ) + ) + + +;; WARN: Return type mismatch (pointer process) vs (pointer gun-red-shot). +(defbehavior target-gun-fire-red target () + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (-> self gun))) + (let ((s5-0 (-> *part-id-table* 190))) + (get-field-spec-by-id s5-0 (sp-field-id spt-omega)) + (let ((s5-1 (get-field-spec-by-id s5-0 (sp-field-id spt-rotate-y)))) + (if s5-1 + (set! (-> s5-1 initial-valuef) (y-angle (-> self control))) + ) + ) + ) + (let ((t9-3 sp-launch-particles-var) + (a0-3 *sp-particle-system-2d*) + (a1-2 (-> *part-id-table* 190)) + (a2-0 *launch-matrix*) + ) + (set! (-> a2-0 trans quad) (-> gp-0 fire-point quad)) + (t9-3 a0-3 a1-2 a2-0 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((s5-2 (new 'stack-no-clear 'vector))) + (let ((v1-10 (-> gp-0 fire-point))) + (let ((a0-4 (-> gp-0 fire-dir-out))) + (let ((a1-4 24576.0)) + (.mov vf7 a1-4) + ) + (.lvf vf5 (&-> a0-4 quad)) + ) + (.lvf vf4 (&-> v1-10 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> s5-2 quad) vf6) + (set! (-> s5-2 w) 24576.0) + (when (and (sphere-in-view-frustum? (the-as sphere s5-2)) + (< 24576.0 (vector-vector-distance s5-2 (math-camera-pos))) + ) + (let ((s5-3 (process-spawn + manipy + :init manipy-init + (-> gp-0 fire-point) + (-> self entity) + (art-group-get-by-name *level* "skel-gun-red-cone" (the-as (pointer uint32) #f)) + #f + 0 + :to self + ) + ) + ) + (when s5-3 + (send-event (ppointer->process s5-3) 'anim-mode 'play1) + (send-event (ppointer->process s5-3) 'anim "idle") + (forward-up->quaternion + (-> (the-as process-drawable (-> s5-3 0)) root quat) + (-> gp-0 fire-dir-out) + *up-vector* + ) + (let ((f30-1 (vector-dot + (-> gp-0 fire-dir-out) + (vector-! (new 'stack-no-clear 'vector) (-> gp-0 fire-point) (math-camera-pos)) + ) + ) + (f0-5 (vector-vector-xz-distance (-> gp-0 fire-point) (math-camera-pos))) + ) + (when (and (< f30-1 0.0) (< f0-5 32768.0)) + (set! (-> (the-as process-drawable (-> s5-3 0)) root scale z) + (lerp-scale 0.2 1.0 (fabs f0-5) 20480.0 32768.0) + ) + (set! (-> (the-as process-drawable (-> s5-3 0)) root scale x) + (-> (the-as process-drawable (-> s5-3 0)) root scale z) + ) + ) + ) + ) + ) + ) + ) + (process-spawn gun-red-shot (-> gp-0 fire-point) (-> gp-0 fire-dir-out) :to (ppointer->process (-> gp-0 gun))) + ) + ) + ) + +(defbehavior gun-red-shot-event-handler gun-red-shot ((arg0 process-drawable) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('touched) + (fire! self arg0 (the-as int (-> arg3 param 0))) + ) + ) + ) + +(defmethod fire! gun-red-shot ((obj gun-red-shot) (arg0 process-drawable) (arg1 int)) + (let* ((s5-0 arg0) + (v1-0 (if (type? s5-0 process-drawable) + s5-0 + ) + ) + ) + (when v1-0 + (let* ((s5-2 (vector-! (new 'stack-no-clear 'vector) (-> v1-0 root trans) (-> obj start-pos))) + (f30-0 (* (if (< (vector-length s5-2) 24576.0) + 3.0 + 2.0 + ) + (if (logtest? (game-feature gun-upgrade-damage) (-> *game-info* features)) + 2.0 + 1.0 + ) + ) + ) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (rot-zxy-from-vector! s2-0 s5-2) + (let ((f28-0 (deg- (-> s2-0 x) (-> obj start-rot x))) + (f0-6 (deg- (-> s2-0 y) (-> obj start-rot y))) + ) + (when (or (< 2730.6667 (fabs f28-0)) (< 8192.0 (fabs f0-6))) + (let ((f1-5 (fmax -2730.6667 (fmin 2730.6667 f28-0))) + (f0-8 (fmax -8192.0 (fmin 8192.0 f0-6))) + ) + (set! (-> s2-0 x) (+ (-> obj start-rot x) f1-5)) + (set! (-> s2-0 y) (+ (-> obj start-rot y) f0-8)) + ) + (set-vector! s5-2 0.0 0.0 1.0 1.0) + (vector-rotate-around-x! s5-2 s5-2 (-> s2-0 x)) + (vector-rotate-around-y! s5-2 s5-2 (-> s2-0 y)) + ) + ) + ) + (let ((a1-7 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-7 from) (process->ppointer self)) + (set! (-> a1-7 num-params) 2) + (set! (-> a1-7 message) 'attack) + (set! (-> a1-7 param 0) (the-as uint arg1)) + (let ((v1-24 (new 'static 'attack-info :mask (attack-info-mask mode id attacker-velocity damage)))) + (set! (-> v1-24 id) (-> obj attack-id)) + (set! (-> v1-24 mode) 'eco-red) + (set! (-> v1-24 attacker-velocity quad) (-> s5-2 quad)) + (set! (-> v1-24 damage) f30-0) + (set! (-> a1-7 param 1) (the-as uint v1-24)) + ) + (send-event-function arg0 a1-7) + ) + ) + ) + ) + ) + +(defmethod noop gun-red-shot ((obj gun-red-shot)) + "Does nothing" + 0 + (none) + ) + +(defmethod init-probes! gun-red-shot ((obj gun-red-shot) (arg0 collide-shape)) + "Create all 19 probe vectors" + (let ((s5-0 (-> obj probe-count))) + (when (< s5-0 19) + (let* ((s4-0 (-> arg0 process)) + (a0-2 (if (type? s4-0 process-focusable) + (the-as process-focusable s4-0) + ) + ) + (s4-1 (new 'stack-no-clear 'vector)) + ) + (if a0-2 + (set! (-> s4-1 quad) (-> (get-trans a0-2 3) quad)) + (set! (-> s4-1 quad) (-> arg0 root-prim prim-core world-sphere quad)) + ) + (vector-! s4-1 s4-1 (-> obj start-pos)) + (vector-normalize! s4-1 1.0) + (let ((s3-2 (new 'stack-no-clear 'vector))) + (rot-zxy-from-vector! s3-2 s4-1) + (let ((f30-0 (deg- (-> s3-2 x) (-> obj start-rot x))) + (f0-4 (deg- (-> s3-2 y) (-> obj start-rot y))) + ) + (when (or (< 2730.6667 (fabs f30-0)) (< 8192.0 (fabs f0-4))) + (let ((f1-3 (fmax -2730.6667 (fmin 2730.6667 f30-0))) + (f0-6 (fmax -8192.0 (fmin 8192.0 f0-4))) + ) + (set! (-> s3-2 x) (+ (-> obj start-rot x) f1-3)) + (set! (-> s3-2 y) (+ (-> obj start-rot y) f0-6)) + ) + (set-vector! s4-1 0.0 0.0 1.0 1.0) + (vector-rotate-around-x! s4-1 s4-1 (-> s3-2 x)) + (vector-rotate-around-y! s4-1 s4-1 (-> s3-2 y)) + ) + ) + ) + (set! (-> obj probe-dir s5-0 quad) (-> s4-1 quad)) + ) + (set! (-> obj probe-count) (+ s5-0 1)) + ) + ) + (none) + ) + +(defmethod gun-red-shot-method-26 gun-red-shot ((obj gun-red-shot)) + (local-vars (a2-5 float) (a2-12 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + ) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> obj start-dir quad)) + (vector-float*! s5-0 s5-0 43417.6) + (vector+! s5-0 s5-0 (-> obj start-pos)) + (set! (-> s5-0 w) 43827.2) + (let ((s4-0 (-> obj root-override root-prim prim-core collide-with))) + (set! *actor-list-length* 0) + (if (logtest? s4-0 (collide-spec hit-by-others-list)) + (set! *actor-list-length* (fill-actor-list-for-sphere *actor-hash* (the-as sphere s5-0) *actor-list* 256)) + ) + (when (logtest? s4-0 (collide-spec player-list)) + (let ((a0-6 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((v1-18 (-> a0-6 next0))) + (while (!= a0-6 (-> *collide-player-list* alive-list-end)) + (let* ((a0-7 (-> (the-as connection a0-6) param1)) + (a1-4 (-> (the-as collide-shape a0-7) root-prim)) + ) + (when (logtest? s4-0 (-> a1-4 prim-core collide-as)) + (let ((a1-5 (-> a1-4 prim-core))) + (let ((a2-4 a1-5) + (a3-1 s5-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) (-> s5-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-7)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-6 v1-18) + *collide-player-list* + (set! v1-18 (-> v1-18 next0)) + ) + ) + ) + ) + (when (logtest? s4-0 (collide-spec hit-by-player-list)) + (let ((a0-9 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((v1-26 (-> a0-9 next0))) + (while (!= a0-9 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((a0-10 (-> (the-as connection a0-9) param1)) + (a1-16 (-> (the-as collide-shape a0-10) root-prim)) + ) + (when (logtest? s4-0 (-> a1-16 prim-core collide-as)) + (let ((a1-17 (-> a1-16 prim-core))) + (let ((a2-11 a1-17) + (a3-2 s5-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) (-> s5-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-10)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-9 v1-26) + *collide-hit-by-player-list* + (set! v1-26 (-> v1-26 next0)) + ) + ) + ) + ) + (dotimes (s5-1 *actor-list-length*) + (let ((a1-28 (-> *actor-list* s5-1))) + (if (logtest? s4-0 (-> a1-28 root-prim prim-core collide-as)) + (init-probes! obj a1-28) + ) + ) + ) + ) + ) + (set! (-> obj actor-count) (-> obj probe-count)) + 0 + (none) + ) + ) + +(defmethod gun-red-shot-method-27 gun-red-shot ((obj gun-red-shot)) + (gun-red-shot-method-26 obj) + (let ((s5-0 (-> obj probe-count))) + (while (< s5-0 19) + (let ((f28-0 (rand-vu-float-range -2730.6667 2730.6667)) + (f30-0 (rand-vu-float-range -8192.0 8192.0)) + (s4-0 (-> obj probe-dir s5-0)) + ) + (set-vector! s4-0 0.0 0.0 1.0 1.0) + (vector-rotate-around-x! s4-0 s4-0 (+ (-> obj start-rot x) f28-0)) + (vector-rotate-around-y! s4-0 s4-0 (+ (-> obj start-rot y) f30-0)) + ) + (+! s5-0 1) + ) + (set! (-> obj probe-count) s5-0) + ) + 0 + (none) + ) + +(defmethod gun-red-shot-method-28 gun-red-shot ((obj gun-red-shot) (arg0 vector)) + (local-vars (at-0 int)) + (with-pp + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (-> obj root-override))) + (let ((v1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> gp-0 trans quad) (-> obj start-pos quad)) + (vector-float*! (-> gp-0 transv) arg0 61440.0) + (let ((a1-1 v1-0)) + (set! (-> a1-1 radius) (-> gp-0 root-prim local-sphere w)) + (set! (-> a1-1 collide-with) (-> gp-0 root-prim prim-core collide-with)) + (set! (-> a1-1 ignore-process0) obj) + (set! (-> a1-1 ignore-process1) (ppointer->process (-> obj parent))) + (set! (-> a1-1 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> a1-1 action-mask) (collide-action solid)) + ) + (set! (-> v1-0 start-pos quad) (-> gp-0 trans quad)) + (set! (-> v1-0 move-dist quad) (-> gp-0 transv quad)) + (fill-using-line-sphere *collide-cache* v1-0) + ) + (let ((v1-2 (-> gp-0 transv))) + (.lvf vf1 (&-> (-> gp-0 transv) quad)) + (let ((f0-2 (-> pp clock frames-per-second))) + (.mov at-0 f0-2) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-2 quad) vf1) + ) + (integrate-and-collide! gp-0 (-> gp-0 transv)) + (if (logtest? (-> gp-0 status) (collide-status touch-surface touch-wall)) + (sound-play "red-shot-hit") + ) + ) + ) + ) + ) + +(defmethod gun-red-shot-method-24 gun-red-shot ((obj gun-red-shot)) + (let ((v1-0 (-> obj root-override)) + (t1-0 (new 'stack-no-clear 'collide-query)) + ) + (let ((a1-0 t1-0)) + (set! (-> a1-0 radius) (-> v1-0 root-prim prim-core world-sphere w)) + (set! (-> a1-0 collide-with) (-> v1-0 root-prim prim-core collide-with)) + (set! (-> a1-0 ignore-process0) obj) + (set! (-> a1-0 ignore-process1) (ppointer->process (-> obj parent))) + (set! (-> a1-0 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> a1-0 action-mask) (collide-action solid)) + ) + (if (fill-and-try-snap-to-surface v1-0 (-> v1-0 transv) -6144.0 0.0 -2048.0 t1-0) + #t + ) + ) + ) + +(defstate debug-idle (gun-red-shot) + :virtual #t + :code (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (until (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 3)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (dotimes (s5-0 (-> self probe-count)) + (vector-float*! gp-0 (-> self probe-dir s5-0) 61440.0) + (vector+! gp-0 gp-0 (-> self start-pos)) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + gp-0 + (meters 0.5) + (if (< s5-0 (-> self actor-count)) + (new 'static 'rgba :r #xff :a #x80) + (new 'static 'rgba :r #xff :g #xff :a #x60) + ) + ) + ) + ) + (add-debug-vector + #t + (bucket-id debug2) + (-> self start-pos) + (-> self start-dir) + (meters 6) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (suspend) + ) + (none) + ) + ) + +(defstate blocked (gun-red-shot) + :virtual #t + :event gun-red-shot-event-handler + :code (behavior () + (suspend) + 0 + (none) + ) + ) + +(defstate idle (gun-red-shot) + :virtual #t + :event gun-red-shot-event-handler + :code (behavior () + (let ((gp-0 0)) + (countdown (s5-0 3) + (countdown (s4-0 7) + (when (< gp-0 19) + (gun-red-shot-method-28 self (-> self probe-dir gp-0)) + (+! gp-0 1) + ) + ) + (suspend) + ) + ) + (none) + ) + ) + +;; WARN: Return type mismatch object vs gun-red-shot. +(defbehavior gun-red-shot-init-by-other gun-red-shot ((arg0 vector) (arg1 vector)) + (set! (-> self start-pos quad) (-> arg0 quad)) + (set! (-> self start-dir quad) (-> arg1 quad)) + (rot-zxy-from-vector! (-> self start-rot) arg1) + (let* ((v1-2 *game-info*) + (a0-7 (+ (-> v1-2 attack-id) 1)) + ) + (set! (-> v1-2 attack-id) a0-7) + (set! (-> self attack-id) a0-7) + ) + (let ((s5-0 (new 'process 'collide-shape-moving self (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) + (the-as (function control-info collide-query vector vector collide-status) cshape-reaction-just-move) + ) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate jak-red-shot)) + (let ((v1-10 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-10 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-10 prim-core collide-with) + (collide-spec backgnd bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher) + ) + (set! (-> v1-10 prim-core action) (collide-action solid)) + (set-vector! (-> v1-10 local-sphere) 0.0 0.0 0.0 819.2) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-10) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-13 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-13 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-13 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> self root-override) s5-0) + ) + (let ((s5-1 (-> self root-override))) + (set! (-> s5-1 trans quad) (-> arg0 quad)) + (quaternion-copy! (-> s5-1 quat) (-> (the-as process-drawable (-> self parent 0)) root quat)) + (vector-identity! (-> s5-1 scale)) + ) + (update-transforms (-> self root-override)) + (set! (-> self event-hook) gun-red-shot-event-handler) + (set! (-> self mask) (logior (process-mask projectile) (-> self mask))) + (logclear! (-> self mask) (process-mask enemy)) + (gun-red-shot-method-27 self) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (let ((gp-1 (get-process *default-dead-pool* part-tracker #x4000))) + (when gp-1 + (let ((t9-10 (method-of-type part-tracker activate))) + (t9-10 + (the-as part-tracker gp-1) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-11 run-function-in-process) + (a0-27 gp-1) + (a1-9 part-tracker-init) + (a2-7 (-> *part-group-id-table* 66)) + (a3-4 0) + (t0-0 #f) + (t1-0 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self start-pos quad)) + ((the-as (function object object object object object object object object none) t9-11) + a0-27 + a1-9 + a2-7 + a3-4 + t0-0 + t1-0 + t2-0 + t3-0 + ) + ) + (-> gp-1 ppointer) + ) + ) + (draw-beam (-> *part-id-table* 187) (-> self start-pos) (-> self start-dir) #f #t) + (sound-play "red-shot-fire") + (vector-float*! (-> self root-override transv) (-> self start-dir) 61440.0) + (the-as gun-red-shot (if (gun-red-shot-method-24 self) + (go-virtual blocked) + (go-virtual idle) + ) + ) + ) diff --git a/goal_src/jak2/engine/target/gun/gun-states.gc b/goal_src/jak2/engine/target/gun/gun-states.gc index faedb6f9b0..15dae66e60 100644 --- a/goal_src/jak2/engine/target/gun/gun-states.gc +++ b/goal_src/jak2/engine/target/gun/gun-states.gc @@ -7,3 +7,433 @@ ;; DECOMP BEGINS +(defstate target-gun-stance (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('gun) + (let ((gp-0 (-> event param 0)) + (v0-0 (target-standard-event-handler proc arg1 event-type event)) + ) + (when v0-0 + (cond + ((= gp-0 2) + (if (logtest? (-> self game features) (game-feature gun-upgrade-speed)) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 309))) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 256))) + ) + ) + ((= gp-0 4) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 259))) + ) + ((= gp-0 1) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 246))) + ) + ((= gp-0 3) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 258))) + ) + ) + ) + v0-0 + ) + ) + (('wade) + #f + ) + (else + (target-standard-event-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self state-flags) (logior (state-flags lleg-still rleg-still) (-> self state-flags))) + (set! (-> self control mod-surface) *gun-walk-mods*) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (behavior () + (set! (-> self control bend-target) 0.0) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (target-state-hook-exit) + (target-gun-exit) + (none) + ) + :trans (behavior () + ((-> self state-hook)) + (when (= (-> self control ground-pat material) (pat-material ice)) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (set! (-> self control bend-target) 0.0) + (remove-exit) + (go target-ice-stance) + ) + (when (or (move-legs?) (< 8192.0 (fabs (-> self gun gun-roty-rel)))) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (set! (-> self control bend-target) 0.0) + (remove-exit) + (go target-gun-walk) + ) + (if (want-to-darkjak?) + (go target-darkjak-get-on 2) + ) + (when (and (cpad-hold? (-> self control cpad number) l1) (can-duck?)) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (set! (-> self control bend-target) 0.0) + (remove-exit) + (go target-duck-stance #f) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (target-jump-go) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons circle) + ) + (can-feet? #t) + ) + (go target-attack) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons square) + ) + (can-hands? #t) + ) + (go target-running-attack) + ) + (slide-down-test) + (fall-test target-falling -4096000.0) + (none) + ) + :code (behavior () + (local-vars (v1-232 object)) + (let ((gp-0 (-> self skel top-anim frame-targ))) + (when (or (= gp-0 (-> self draw art-group data 263)) + (= gp-0 (-> self draw art-group data 265)) + (= gp-0 (-> self draw art-group data 266)) + (= gp-0 (-> self draw art-group data 264)) + ) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! gp-0 :num! (seek! (the float (+ (-> gp-0 frames num-frames) -1))) :frame-num 0.0) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + (while (using-gun? self) + (let* ((v1-33 (-> self gun gun-type)) + (gp-1 (cond + ((= v1-33 (pickup-type eco-blue)) + (-> self draw art-group data 255) + ) + ((= v1-33 (pickup-type eco-yellow)) + (-> self draw art-group data 254) + ) + ((= v1-33 (pickup-type eco-dark)) + (-> self draw art-group data 253) + ) + (else + (-> self draw art-group data 244) + ) + ) + ) + ) + (cond + ((ja-group? gp-1) + ) + (else + (let ((v1-50 (ja-group))) + (cond + ((and (and v1-50 (or (= v1-50 (-> self draw art-group data 244)) (= v1-50 (-> self draw art-group data 253)))) + (or (= gp-1 (-> self draw art-group data 244)) (= gp-1 (-> self draw art-group data 253))) + ) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 269) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 269)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (ja-channel-push! 1 (seconds 0.1)) + (set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim gp-1)) + ) + ((let ((v1-89 (ja-group))) + (and (and v1-89 (or (= v1-89 (-> self draw art-group data 244)) (= v1-89 (-> self draw art-group data 253)))) + (or (= gp-1 (-> self draw art-group data 254)) (= gp-1 (-> self draw art-group data 255))) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 270) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 270)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (ja-channel-push! 1 (seconds 0.1)) + (set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim gp-1)) + ) + ((let ((v1-129 (ja-group))) + (and (and v1-129 (or (= v1-129 (-> self draw art-group data 254)) (= v1-129 (-> self draw art-group data 255)))) + (or (= gp-1 (-> self draw art-group data 244)) (= gp-1 (-> self draw art-group data 253))) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 268) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 268)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (ja-channel-push! 1 (seconds 0.1)) + (set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim gp-1)) + ) + ((let ((v1-169 (ja-group))) + (and (and v1-169 (or (= v1-169 (-> self draw art-group data 254)) (= v1-169 (-> self draw art-group data 255)))) + (or (= gp-1 (-> self draw art-group data 255)) (= gp-1 (-> self draw art-group data 254))) + ) + ) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! (-> self draw art-group data 252) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 252)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (ja-channel-push! 1 (seconds 0.1)) + (set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim gp-1)) + ) + (else + (ja-channel-push! 1 (seconds 0.1)) + (set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim gp-1)) + ) + ) + ) + ) + ) + ) + (suspend) + (ja :num! (loop!)) + (when (can-play-stance-amibent?) + (set! (-> self ambient-time) (-> self clock frame-counter)) + (target-gun-end-mode #t) + ) + (cond + ((not (-> self control unknown-spool-anim00)) + ) + ((= (-> self control unknown-spool-anim00) (-> self draw art-group data 259)) + (ja-channel-push! 1 0) + (ja :group! (-> self control unknown-spool-anim00)) + (suspend) + ;(b! #t cfg-94) ; branch to the next instruction... + (until (not v1-232) + (let ((v1-231 (get-channel (-> self skel top-anim) 0))) + (b! (not v1-231) cfg-101 :likely-delay (set! v1-232 v1-231)) + (let ((a1-30 (= (-> v1-231 frame-group) (-> self draw art-group data 259)))) + (b! (not a1-30) cfg-101 :likely-delay (set! v1-232 a1-30)) + ) + (let ((a0-74 (-> self skel root-channel 0))) + (set! (-> a0-74 num-func) num-func-identity) + (let ((f0-36 (-> v1-231 frame-num))) + (set! (-> a0-74 frame-num) f0-36) + (let ((v1-233 f0-36)) + (b! (not (the int v1-233)) cfg-101 :likely-delay (set! v1-232 v1-233)) + ) + ) + ) + ) + (suspend) + (set! v1-232 0) + (label cfg-101) + ) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + (else + (ja-channel-push! 1 0) + (ja-no-eval :group! (-> self control unknown-spool-anim00) + :num! (seek! + (the float (+ (-> (the-as art-joint-anim (-> self control unknown-spool-anim00)) frames num-frames) -1)) + ) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ) + ) + (let ((gp-2 (-> self skel top-anim frame-targ))) + (cond + ((or (= gp-2 (-> self draw art-group data 263)) + (= gp-2 (-> self draw art-group data 265)) + (= gp-2 (-> self draw art-group data 264)) + ) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! gp-2 :num! (seek! 0.0) :frame-num (the float (+ (-> gp-2 frames num-frames) -1))) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! 0.0)) + ) + ) + ((= gp-2 (-> self draw art-group data 266)) + (ja-channel-push! 1 (seconds 0.1)) + (ja-no-eval :group! gp-2 :num! (seek! 0.0) :frame-num (ja-aframe -34.0 0)) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! 0.0)) + ) + ) + ) + ) + (go target-stance) + (none) + ) + :post target-gun-post + ) + +(defstate target-gun-walk (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *gun-walk-mods*) + (case (-> self gun gun-type) + (((pickup-type eco-yellow) (pickup-type eco-blue)) + (set! (-> self control unknown-word04) (the-as uint 0)) + 0 + ) + (else + (set! (-> self control unknown-word04) (the-as uint 1)) + ) + ) + (none) + ) + :exit (behavior () + (target-effect-exit) + (target-state-hook-exit) + (target-gun-exit) + (none) + ) + :trans (behavior () + (cond + ((zero? (-> self control unknown-spool-anim00)) + (case (-> self gun gun-type) + (((pickup-type eco-red) (pickup-type eco-dark)) + (remove-exit) + (go target-gun-walk) + ) + ) + ) + (else + (case (-> self gun gun-type) + (((pickup-type eco-yellow) (pickup-type eco-blue)) + (remove-exit) + (go target-gun-walk) + ) + ) + ) + ) + ((-> self state-hook)) + (if (not (using-gun? self)) + (go target-walk) + ) + (if (logtest? (water-flags wading) (-> self water flags)) + (go target-wade-walk) + ) + (when (= (-> self control ground-pat material) (pat-material ice)) + (target-effect-exit) + (remove-exit) + (go target-ice-walk) + ) + (when (not (or (move-legs?) (< 182.04445 (fabs (-> self gun gun-roty-rel))))) + (target-effect-exit) + (remove-exit) + (go target-gun-stance) + ) + (if (want-to-darkjak?) + (go target-darkjak-get-on 2) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons l1) + ) + (and (!= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) (can-roll?)) + ) + (go target-roll) + ) + (when (and (cpad-hold? (-> self control cpad number) l1) (can-duck?)) + (target-effect-exit) + (remove-exit) + (go target-duck-walk #f) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (target-jump-go) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons circle) + ) + (can-feet? #t) + ) + (go target-attack) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons square) + ) + (can-hands? #t) + ) + (go target-running-attack) + ) + (if (wall-hide?) + (go target-hide) + ) + (slide-down-test) + (fall-test target-falling -4096000.0) + (none) + ) + :code (behavior () + (target-walk-anim -300) + (none) + ) + :post target-gun-post + ) diff --git a/goal_src/jak2/engine/target/gun/gun-util.gc b/goal_src/jak2/engine/target/gun/gun-util.gc index ab9c7f0c6c..a58c2d2396 100644 --- a/goal_src/jak2/engine/target/gun/gun-util.gc +++ b/goal_src/jak2/engine/target/gun/gun-util.gc @@ -684,15 +684,15 @@ ) ) ) - (s5-0 '(("jakb-gun-yellow-fire" . #xf) - ("jakb-gun-yellow-fire-low" . #x13) - ("jakb-pilot-gun-yellow-fire" . #xf) - ("jakb-gun-red-fire" . #xc) - ("jakb-pilot-gun-red-fire" . #xc) - ("jakb-gun-blue-fire" . #xd) - ("jakb-pilot-gun-blue-fire" . #xd) - ("jakb-gun-dark-fire" . #xd) - ("jakb-pilot-gun-dark-fire" . #xd) + (s5-0 '(("jakb-gun-yellow-fire" . "gun-yellow-fire") + ("jakb-gun-yellow-fire-low" . "gun-yellow-fire-low") + ("jakb-pilot-gun-yellow-fire" . "gun-yellow-fire") + ("jakb-gun-red-fire" . "gun-red-fire") + ("jakb-pilot-gun-red-fire" . "gun-red-fire") + ("jakb-gun-blue-fire" . "gun-blue-fire") + ("jakb-pilot-gun-blue-fire" . "gun-blue-fire") + ("jakb-gun-dark-fire" . "gun-dark-fire") + ("jakb-pilot-gun-dark-fire" . "gun-dark-fire") ) ) (v1-277 (-> self parent)) @@ -735,14 +735,14 @@ ) ((and (= (-> s4-0 skel top-anim interp) 1.0) (begin - (set! s1-0 (nassoc s2-0 '(("jakb-gun-yellow-takeout" . #xe) - ("jakb-gun-blue-takeout" . #xc) - ("jakb-gun-dark-takeout" . #xc) - ("jakb-gun-red-takeout" . #xc) - ("jakb-pilot-gun-yellow-takeout" . #xe) - ("jakb-pilot-gun-blue-takeout" . #xc) - ("jakb-pilot-gun-dark-takeout" . #xc) - ("jakb-pilot-gun-red-takeout" . #xc) + (set! s1-0 (nassoc s2-0 '(("jakb-gun-yellow-takeout" . "gun-red-yellow") + ("jakb-gun-blue-takeout" . "gun-red-blue") + ("jakb-gun-dark-takeout" . "gun-red-dark") + ("jakb-gun-red-takeout" . "gun-idle-red") + ("jakb-pilot-gun-yellow-takeout" . "gun-red-yellow") + ("jakb-pilot-gun-blue-takeout" . "gun-red-blue") + ("jakb-pilot-gun-dark-takeout" . "gun-red-dark") + ("jakb-pilot-gun-red-takeout" . "gun-idle-red") ) ) ) diff --git a/goal_src/jak2/engine/target/gun/gun-yellow-shot.gc b/goal_src/jak2/engine/target/gun/gun-yellow-shot.gc index a8d6662508..20857b6259 100644 --- a/goal_src/jak2/engine/target/gun/gun-yellow-shot.gc +++ b/goal_src/jak2/engine/target/gun/gun-yellow-shot.gc @@ -6,3 +6,389 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS + +(defbehavior target-gun-fire-yellow target () + (let ((s5-0 (-> self gun)) + (gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)) + ) + (set! (-> gp-0 ent) (-> self entity)) + (set! (-> gp-0 charge) 1.0) + (set! (-> gp-0 options) (projectile-options account-for-target-velocity deal-damage proj-options-8000)) + (set! (-> gp-0 pos quad) (-> s5-0 fire-point quad)) + (set! (-> gp-0 notify-handle) (the-as handle #f)) + (set! (-> gp-0 owner-handle) (the-as handle #f)) + (set! (-> gp-0 ignore-handle) (process->handle (the-as process (send-event self 'get-vehicle)))) + (let* ((v1-9 *game-info*) + (a0-9 (+ (-> v1-9 attack-id) 1)) + ) + (set! (-> v1-9 attack-id) a0-9) + (set! (-> gp-0 attack-id) a0-9) + ) + (set! (-> gp-0 timeout) (new 'static 'handle :process #x4b0 :u64 #x4b0)) + (vector-float*! (-> gp-0 vel) (-> s5-0 fire-dir-out) 819200.0) + (spawn-projectile gun-yellow-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*) + ) + ) + +(defun someone-fire-yellow ((arg0 process-drawable) (arg1 vector) (arg2 vector)) + (let ((gp-0 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> gp-0 ent) (-> arg0 entity)) + (set! (-> gp-0 charge) 1.0) + (set! (-> gp-0 options) (projectile-options account-for-target-velocity proj-options-8000)) + (set! (-> gp-0 pos quad) (-> arg1 quad)) + (set! (-> gp-0 notify-handle) (the-as handle #f)) + (set! (-> gp-0 owner-handle) (the-as handle #f)) + (set! (-> gp-0 ignore-handle) (process->handle arg0)) + (let* ((v1-7 *game-info*) + (a0-8 (+ (-> v1-7 attack-id) 1)) + ) + (set! (-> v1-7 attack-id) a0-8) + (set! (-> gp-0 attack-id) a0-8) + ) + (set! (-> gp-0 timeout) (new 'static 'handle :process #x4b0 :u64 #x4b0)) + (vector-normalize-copy! (-> gp-0 vel) arg2 819200.0) + (spawn-projectile gun-yellow-shot gp-0 arg0 *default-dead-pool*) + ) + ) + +(deftype gun-yellow-shot (projectile) + ((hit-actor? symbol :offset-assert 472) + (tail-pos vector :inline :offset-assert 480) + (hit-pos vector :inline :offset-assert 496) + ) + :heap-base #x180 + :method-count-assert 40 + :size-assert #x200 + :flag-assert #x2801800200 + ) + + +(defmethod draw-laser-sight gun-yellow-shot ((obj gun-yellow-shot)) + "TODO - confirm If applicable, draw the laser sight particles + :virtual" + (draw-beam (-> *part-id-table* 227) (-> obj tail-pos) (-> obj starting-dir) #f #t) + 0 + (none) + ) + +(defmethod spawn-impact-particles gun-yellow-shot ((obj gun-yellow-shot)) + "Spawns associated particles with the projectile if applicable" + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let* ((s4-0 (-> obj root-override trans)) + (a1-0 (-> obj tail-pos)) + (s5-1 (vector-! (new 'stack-no-clear 'vector) s4-0 a1-0)) + (f30-0 (vector-length s5-1)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (let ((v1-4 a1-0)) + (let ((a0-2 s5-1)) + (let ((a2-1 0.8)) + (.mov vf7 a2-1) + ) + (.lvf vf5 (&-> a0-2 quad)) + ) + (.lvf vf4 (&-> v1-4 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> gp-0 quad) vf6) + (let ((f28-0 (-> *part-id-table* 223 init-specs 4 initial-valuef))) + (set! (-> *part-id-table* 223 init-specs 4 initial-valuef) (fmin f28-0 (vector-length s5-1))) + (draw-beam (-> *part-id-table* 223) a1-0 s5-1 #f #t) + (set! (-> *part-id-table* 223 init-specs 4 initial-valuef) f28-0) + ) + (vector-normalize! s5-1 1.0) + (let ((t9-2 sp-launch-particles-var) + (a0-5 *sp-particle-system-2d*) + (a1-2 (-> *part-id-table* 224)) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> gp-0 quad)) + (t9-2 a0-5 a1-2 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((s3-0 (new 'stack-no-clear 'matrix)) + (f28-1 (* 0.000015258789 f30-0)) + (f30-1 (-> *part-id-table* 226 init-specs 3 initial-valuef)) + ) + (forward-up->inv-matrix s3-0 s5-1 *up-vector*) + (set! (-> s3-0 trans quad) (-> s4-0 quad)) + (set! (-> *part-id-table* 226 init-specs 3 initial-valuef) (* f28-1 f30-1)) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 226) + s3-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + (set! (-> *part-id-table* 226 init-specs 3 initial-valuef) f30-1) + ) + (let ((f0-6 (vector-dot s5-1 (-> (camera-matrix) vector 2)))) + (when (< 0.0 f0-6) + (let ((f0-7 (* f0-6 f0-6)) + (f30-2 (-> *part-id-table* 225 init-specs 8 initial-valuef)) + (f28-2 (-> *part-id-table* 225 init-specs 8 random-rangef)) + ) + (set! (-> *part-id-table* 225 init-specs 8 initial-valuef) (* f30-2 f0-7)) + (set! (-> *part-id-table* 225 init-specs 8 random-rangef) (* f28-2 f0-7)) + (let ((t9-6 sp-launch-particles-var) + (a0-9 *sp-particle-system-2d*) + (a1-5 (-> *part-id-table* 225)) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> gp-0 quad)) + (t9-6 a0-9 a1-5 a2-6 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (set! (-> *part-id-table* 225 init-specs 8 initial-valuef) f30-2) + (set! (-> *part-id-table* 225 init-specs 8 random-rangef) f28-2) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod deal-damage! gun-yellow-shot ((obj gun-yellow-shot) (arg0 process) (arg1 event-message-block)) + "Constructs an [[attack-info]] according to the projectile's `options`" + (let ((t9-0 (method-of-type projectile deal-damage!))) + (when (t9-0 obj arg0 arg1) + (set! (-> obj hit-actor?) #t) + #t + ) + ) + ) + +(defmethod spawn-shell-particles gun-yellow-shot ((obj gun-yellow-shot)) + "TODO - confirm" + (cond + ((-> obj hit-actor?) + (let ((s5-0 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-0 + (let ((t9-1 (method-of-type part-tracker activate))) + (t9-1 + (the-as part-tracker s5-0) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-2 run-function-in-process) + (a0-3 s5-0) + (a1-2 part-tracker-init) + (a2-4 (-> *part-group-id-table* 74)) + (a3-1 0) + (t0-0 #f) + (t1-0 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> obj root-override trans quad)) + ((the-as (function object object object object object object object object none) t9-2) + a0-3 + a1-2 + a2-4 + a3-1 + t0-0 + t1-0 + t2-0 + t3-0 + ) + ) + (-> s5-0 ppointer) + ) + ) + ) + (else + (let ((s5-1 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-1 + (let ((t9-4 (method-of-type part-tracker activate))) + (t9-4 + (the-as part-tracker s5-1) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-5 run-function-in-process) + (a0-6 s5-1) + (a1-5 part-tracker-init) + (a2-9 (-> *part-group-id-table* 73)) + (a3-3 0) + (t0-1 #f) + (t1-1 #f) + (t2-1 #f) + (t3-1 *launch-matrix*) + ) + (set! (-> t3-1 trans quad) (-> obj root-override trans quad)) + ((the-as (function object object object object object object object object none) t9-5) + a0-6 + a1-5 + a2-9 + a3-3 + t0-1 + t1-1 + t2-1 + t3-1 + ) + ) + (-> s5-1 ppointer) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod play-impact-sound gun-yellow-shot ((obj gun-yellow-shot) (arg0 projectile-options)) + (let ((v1-0 arg0)) + (cond + ((zero? v1-0) + (sound-play "yellow-shot-fir") + ) + ((= v1-0 (projectile-options lose-altitude)) + (sound-play "yellow-gun-burn") + ) + ((= v1-0 (projectile-options proj-options-2)) + (sound-play "yellow-shot-fiz") + ) + (else + (sound-play "yellow-shot-std" :id (-> obj sound-id) :position (-> obj root-override trans)) + ) + ) + ) + ) + +(defmethod made-impact? gun-yellow-shot ((obj gun-yellow-shot)) + "TODO - queries the collision cache, return true/false" + (let ((v1-0 (-> obj root-override)) + (t1-0 (new 'stack-no-clear 'collide-query)) + ) + (let ((a0-1 t1-0)) + (set! (-> a0-1 radius) (-> v1-0 root-prim prim-core world-sphere w)) + (set! (-> a0-1 collide-with) (-> v1-0 root-prim prim-core collide-with)) + (set! (-> a0-1 ignore-process0) obj) + (set! (-> a0-1 ignore-process1) (ppointer->process (-> obj parent))) + (set! (-> a0-1 ignore-pat) (-> v1-0 pat-ignore-mask)) + (set! (-> a0-1 action-mask) (collide-action solid)) + ) + (when (fill-and-try-snap-to-surface v1-0 (-> v1-0 transv) -10240.0 12697.6 -4096.0 t1-0) + (if (logtest? (-> obj root-override status) (collide-status touch-actor)) + (set! (-> obj hit-actor?) #t) + ) + #t + ) + ) + ) + +(defun gun-yellow-shot-move ((arg0 gun-yellow-shot)) + (projectile-move-fill-line-sphere arg0) + (let ((s5-0 (-> arg0 root-override))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 (-> arg0 tail-pos) (-> s5-0 trans)) + (let ((f0-0 (vector-length s4-0))) + (when (< 65536.0 f0-0) + (vector-normalize! s4-0 65536.0) + (vector+! (-> arg0 tail-pos) (-> s5-0 trans) s4-0) + ) + ) + ) + (when (logtest? (-> s5-0 status) (collide-status touch-surface)) + (if (logtest? (-> arg0 root-override status) (collide-status touch-actor)) + (set! (-> arg0 hit-actor?) #t) + ) + (let ((v1-14 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> arg0 tail-pos) (-> s5-0 trans)) 2048.0)) + (a1-5 (-> arg0 hit-pos)) + ) + (set! (-> a1-5 quad) (-> s5-0 trans quad)) + (vector+! a1-5 a1-5 v1-14) + (move-to-point! (-> arg0 root-override) a1-5) + ) + (go (method-of-object arg0 impact)) + ) + ) + 0 + (none) + ) + +(defmethod init-collision! gun-yellow-shot ((obj gun-yellow-shot)) + "Init the [[projectile]]'s [[collide-shape]]" + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) + (the-as (function control-info collide-query vector vector collide-status) cshape-reaction-just-move) + ) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate jak-yellow-shot)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0))) + (set! (-> s5-0 total-prims) (the-as uint 3)) + (set! (-> s4-0 prim-core collide-as) (collide-spec projectile)) + (set! (-> s4-0 prim-core collide-with) + (collide-spec backgnd bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher) + ) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 4096.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-13 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-13 prim-core collide-with) + (collide-spec backgnd bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher) + ) + (set! (-> v1-13 prim-core action) (collide-action solid)) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 0.0 819.2) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-15 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-15 prim-core collide-with) + (collide-spec bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher) + ) + (set-vector! (-> v1-15 local-sphere) 0.0 0.0 0.0 4096.0) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-18 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-18 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-18 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> obj root-override) s5-0) + ) + (set! (-> obj root-override pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1) + ) + 0 + (none) + ) + +(defmethod init-proj-settings! gun-yellow-shot ((obj gun-yellow-shot)) + "Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc + :virtual" + (set! (-> obj hit-actor?) #f) + (set! (-> obj tail-pos quad) (-> obj root-override trans quad)) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (set! (-> obj attack-mode) 'eco-yellow) + (set! (-> obj max-speed) 819200.0) + (set! (-> obj move) gun-yellow-shot-move) + (set! (-> obj timeout) (seconds 0.5)) + (set! (-> obj sound-id) (new-sound-id)) + (set! (-> obj damage) (if (logtest? (game-feature gun-upgrade-damage) (-> *game-info* features)) + 4.0 + 2.0 + ) + ) + 0 + (none) + ) diff --git a/test/decompiler/reference/jak2/engine/target/gun/gun-dark-shot_REF.gc b/test/decompiler/reference/jak2/engine/target/gun/gun-dark-shot_REF.gc new file mode 100644 index 0000000000..a40e9c145f --- /dev/null +++ b/test/decompiler/reference/jak2/engine/target/gun/gun-dark-shot_REF.gc @@ -0,0 +1,661 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(set! (-> *lightning-spec-id-table* 11) (new 'static 'lightning-spec + :name "lightning-dark-shot-attack" + :flags (lightning-spec-flags lsf0) + :start-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :end-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :fade-to-color (new 'static 'rgba :r #xbf :b #x8f :a #x5) + :fade-start-factor 0.2 + :texture (new 'static 'texture-id :index #x83 :page #xc) + :reduction 0.42 + :num-points 16 + :box-size 8192.0 + :merge-factor 0.6 + :merge-count 2 + :radius 3276.8 + :duration 45.0 + :duration-rand 60.0 + :sound (static-sound-spec "stretched-zap") + ) + ) + +;; failed to figure out what this is: +(set! (-> *lightning-spec-id-table* 12) (new 'static 'lightning-spec + :name "lightning-dark-shot-attack-thick" + :flags (lightning-spec-flags lsf0) + :start-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :end-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + :fade-to-color (new 'static 'rgba :r #xbf :b #x8f :a #x5) + :fade-start-factor 0.2 + :texture (new 'static 'texture-id :index #x83 :page #xc) + :reduction 0.42 + :num-points 32 + :box-size 12288.0 + :merge-factor 0.6 + :merge-count 2 + :radius 12288.0 + :duration 60.0 + :sound (static-sound-spec "stretched-zap") + ) + ) + +;; failed to figure out what this is: +(defpart 429 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0) + (sp-flt spt-rot-x 2048.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 0.0 64.0 1.0) + (sp-rnd-flt spt-g 64.0 64.0 1.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 48.0) + (sp-int spt-timer 5) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-flt spt-userdata 4096.0) + ) + ) + +;; failed to figure out what this is: +(defpart 430 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbc :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 1) (meters 4) 1.0) + (sp-flt spt-rot-x 2048.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 0.0 64.0 1.0) + (sp-rnd-flt spt-g 64.0 64.0 1.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 128.0) + (sp-int spt-timer 5) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-flt spt-userdata 4096.0) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 3600.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-rnd-flt spt-conerot-z (degrees 0.0) (degrees 3600.0) 1.0) + (sp-rnd-flt spt-conerot-radius (meters -0.1) (meters 0.5) 1.0) + ) + ) + +;; definition of type gun-dark-shot +(deftype gun-dark-shot (projectile) + ((blast-radius float :offset-assert 472) + (core-position vector :inline :offset-assert 480) + (core-velocity vector :inline :offset-assert 496) + (spin-vector vector :inline :offset-assert 512) + (track-target handle :offset-assert 528) + (size-t float :offset-assert 536) + (result-array handle 16 :offset-assert 544) + (charge-sound uint32 :offset-assert 672) + (fire-sound uint32 :offset-assert 676) + (trail-sound uint32 :offset-assert 680) + (explode-sound uint32 :offset-assert 684) + (start-pilot? basic :offset-assert 688) + ) + :heap-base #x240 + :method-count-assert 42 + :size-assert #x2b4 + :flag-assert #x2a024002b4 + (:methods + (startup () _type_ :state 40) + (fizzle () _type_ :state 41) + ) + ) + +;; definition for method 3 of type gun-dark-shot +(defmethod inspect gun-dark-shot ((obj gun-dark-shot)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile inspect))) + (t9-0 obj) + ) + (format #t "~2Tblast-radius: ~f~%" (-> obj blast-radius)) + (format #t "~2Tcore-position: #~%" (-> obj core-position)) + (format #t "~2Tcore-velocity: #~%" (-> obj core-velocity)) + (format #t "~2Tspin-vector: #~%" (-> obj spin-vector)) + (format #t "~2Ttrack-target: ~D~%" (-> obj track-target)) + (format #t "~2Tsize-t: ~f~%" (-> obj size-t)) + (format #t "~2Tresult-array[16] @ #x~X~%" (-> obj result-array)) + (format #t "~2Tcharge-sound: ~D~%" (-> obj charge-sound)) + (format #t "~2Tfire-sound: ~D~%" (-> obj fire-sound)) + (format #t "~2Ttrail-sound: ~D~%" (-> obj trail-sound)) + (format #t "~2Texplode-sound: ~D~%" (-> obj explode-sound)) + (format #t "~2Tstart-pilot?: ~A~%" (-> obj start-pilot?)) + (label cfg-4) + obj + ) + +;; definition for function target-gun-fire-dark +;; INFO: Used lq/sq +(defbehavior target-gun-fire-dark target () + (let ((s5-0 (-> self gun)) + (gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)) + ) + (set! (-> gp-0 ent) (-> self entity)) + (set! (-> gp-0 charge) (-> s5-0 fire-charge)) + (set! (-> gp-0 options) (projectile-options)) + (set! (-> gp-0 pos quad) (-> s5-0 fire-point quad)) + (set! (-> gp-0 vel quad) (-> s5-0 fire-dir-out quad)) + (set! (-> gp-0 notify-handle) (the-as handle #f)) + (set! (-> gp-0 owner-handle) (the-as handle #f)) + (set! (-> gp-0 ignore-handle) (process->handle (the-as process (send-event self 'get-vehicle)))) + (let* ((v1-8 *game-info*) + (a0-11 (+ (-> v1-8 attack-id) 1)) + ) + (set! (-> v1-8 attack-id) a0-11) + (set! (-> gp-0 attack-id) a0-11) + ) + (set! (-> gp-0 timeout) (new 'static 'handle :process #x4b0 :u64 #x4b0)) + (let ((v0-1 (spawn-projectile gun-dark-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*))) + (when v0-1 + (set! (-> (the-as gun-dark-shot (-> v0-1 0)) track-target) (-> self gun track-target 0 handle)) + (set! (-> self gun charge-active?) (ppointer->handle v0-1)) + ) + v0-1 + ) + ) + ) + +;; definition for method 31 of type gun-dark-shot +;; WARN: Return type mismatch int vs none. +(defmethod init-proj-settings! gun-dark-shot ((obj gun-dark-shot)) + "Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc + :virtual" + (set! (-> obj attack-mode) 'eco-dark) + (vector-normalize! (-> obj root-override transv) (+ 225280.0 (* 225280.0 (-> obj charge-level)))) + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 72) obj)) + (set! (-> obj blast-radius) 40960.0) + (set! (-> obj size-t) 0.0) + (set! (-> obj charge-sound) (the-as uint (new-sound-id))) + (set! (-> obj fire-sound) (the-as uint (new-sound-id))) + (set! (-> obj trail-sound) (the-as uint (new-sound-id))) + (set! (-> obj explode-sound) + (the-as + uint + (gui-control-method-9 *gui-control* obj (gui-channel background) (gui-action queue) "pmkrxplo" -99.0 0) + ) + ) + (gui-control-method-20 *gui-control* (the-as sound-id (-> obj explode-sound)) #t 50 150 11) + (set! (-> obj start-pilot?) + (the-as basic (and *target* (logtest? (focus-status pilot) (-> *target* focus-status)))) + ) + ((method-of-type projectile init-proj-settings!) obj) + 0 + (none) + ) + +;; definition for method 25 of type gun-dark-shot +(defmethod spawn-impact-particles gun-dark-shot ((obj gun-dark-shot)) + "Spawns associated particles with the projectile if applicable" + (cond + ((and (and (-> obj next-state) (= (-> obj next-state name) 'startup)) + (and *target* (logtest? (-> *target* focus-status) (focus-status in-head))) + ) + (kill-and-free-particles (-> obj part)) + ) + (else + (set! (-> *part-id-table* 219 init-specs 2 initial-valuef) (lerp 409.6 9216.0 (-> obj size-t))) + (set! (-> *part-id-table* 219 init-specs 8 initial-valuef) (lerp 0.0 32.0 (-> obj size-t))) + (set! (-> *part-id-table* 220 init-specs 2 initial-valuef) (lerp 409.6 32768.0 (-> obj size-t))) + (set! (-> *part-id-table* 220 init-specs 8 initial-valuef) (lerp 0.0 16.0 (-> obj size-t))) + (set! (-> *part-id-table* 218 init-specs 2 initial-valuef) (lerp 409.6 8192.0 (-> obj size-t))) + (set! (-> *part-id-table* 217 init-specs 1 initial-valuef) (lerp 0.1 1.0 (-> obj size-t))) + (set! (-> *part-id-table* 217 init-specs 2 initial-valuef) (lerp 409.6 3686.4 (-> obj size-t))) + (spawn (-> obj part) (-> obj root-override trans)) + ) + ) + (ja-post) + (none) + ) + +;; definition for method 32 of type gun-dark-shot +;; WARN: Return type mismatch int vs none. +(defmethod go-moving! gun-dark-shot ((obj gun-dark-shot)) + (go (method-of-object obj startup)) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate startup (gun-dark-shot) + :virtual #t + :exit (behavior () + (send-event (ppointer->process (-> self parent)) 'release) + (set! (-> self size-t) 1.0) + (let ((v1-6 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-6 command) (sound-command set-param)) + (set! (-> v1-6 id) (the-as sound-id (-> self charge-sound))) + (set! (-> v1-6 params volume) -4) + (set! (-> v1-6 auto-time) 24) + (set! (-> v1-6 auto-from) 2) + (set! (-> v1-6 params mask) (the-as uint 17)) + (-> v1-6 id) + ) + (none) + ) + :code (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (until #f + (cond + ((or (and *target* + (logtest? (focus-status dead grabbed under-water pole flut board mech dark carry indax teleporting) + (-> *target* focus-status) + ) + ) + (and *target* (zero? (logand (focus-status in-head gun) (-> *target* focus-status)))) + (and *target* (not (-> self start-pilot?)) (logtest? (focus-status pilot) (-> *target* focus-status))) + ) + (go-virtual dissipate) + ) + ((or (< (- (-> self clock frame-counter) (-> self state-time)) (seconds 0.3)) (cpad-hold? 0 r1)) + (set! (-> self size-t) + (fmin 1.0 (* 0.016666668 (the float (- (-> self clock frame-counter) (-> self state-time))))) + ) + (let ((t9-1 vector<-cspace!) + (a0-13 (-> self root-override trans)) + (v1-26 (-> self parent)) + ) + (t9-1 a0-13 (-> (the-as process-drawable (if v1-26 + (the-as process-drawable (-> v1-26 0 self)) + ) + ) + node-list + data + 13 + ) + ) + ) + ) + ((and (logtest? (-> self options) (projectile-options proj-options-8000)) (made-impact? self)) + (go-virtual impact) + ) + (else + (go-virtual moving) + ) + ) + (suspend) + ) + #f + (none) + ) + :post (behavior () + (sound-play + "pmkr-charge" + :id (the-as sound-id (-> self charge-sound)) + :position (-> self root-override trans) + ) + (spawn-impact-particles self) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate moving (gun-dark-shot) + :virtual #t + :enter (behavior () + (let ((t9-0 (-> (method-of-type projectile moving) enter))) + (if t9-0 + (t9-0) + ) + ) + (set! (-> self core-position quad) (-> self root-override trans quad)) + (let ((v1-5 (-> self core-velocity)) + (a0-3 (-> self parent)) + ) + (set! (-> v1-5 quad) (-> (the-as process-drawable (if a0-3 + (the-as process-drawable (-> a0-3 0 self)) + ) + ) + node-list + data + 13 + bone + transform + vector + 2 + quad + ) + ) + ) + (when (and *target* (logtest? (-> *target* focus-status) (focus-status in-head))) + (set! (-> self core-position quad) (-> (camera-pos) quad)) + (set! (-> self core-velocity quad) (-> (camera-matrix) vector 2 quad)) + ) + (set-vector! (-> self spin-vector) (-> self core-velocity z) 0.0 (- (-> self core-velocity x)) 1.0) + (let ((f0-5 (vector-length (-> self spin-vector)))) + (if (< f0-5 1.0) + (set-vector! (-> self spin-vector) 1.0 0.0 0.0 1.0) + (vector-float*! (-> self spin-vector) (-> self spin-vector) (/ 1.0 f0-5)) + ) + ) + (set! (-> self state-time) (-> self clock frame-counter)) + (let ((gp-2 (get-process *default-dead-pool* part-tracker #x4000))) + (when gp-2 + (let ((t9-4 (method-of-type part-tracker activate))) + (t9-4 + (the-as part-tracker gp-2) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-5 run-function-in-process) + (a0-18 gp-2) + (a1-4 part-tracker-init) + (a2-4 (-> *part-group-id-table* 70)) + (a3-1 0) + (t0-0 #f) + (t1-0 #f) + (t2-0 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self root-override trans quad)) + ((the-as (function object object object object object object object object none) t9-5) + a0-18 + a1-4 + a2-4 + a3-1 + t0-0 + t1-0 + t2-0 + t3-0 + ) + ) + (-> gp-2 ppointer) + ) + ) + (draw-beam (-> *part-id-table* 210) (-> self root-override trans) (-> self core-velocity) #f #t) + (none) + ) + :trans (behavior () + (local-vars (at-0 int)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-normalize-copy! s4-0 (-> self core-velocity) 1.0) + (let* ((s3-0 (handle->process (-> self track-target))) + (v1-3 (if (type? s3-0 process-drawable) + (the-as process-drawable s3-0) + ) + ) + ) + (when v1-3 + (let* ((s3-2 (vector-! (new 'stack-no-clear 'vector) (-> v1-3 root trans) (-> self core-position))) + (f0-0 (vector-normalize-ret-len! s3-2 1.0)) + (f0-1 (lerp-scale 182.04445 8192.0 f0-0 61440.0 4096.0)) + (s2-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-from-two-vectors-max-angle! s2-0 s4-0 s3-2 f0-1) + (vector-matrix*! (-> self core-velocity) (-> self core-velocity) s2-0) + ) + ) + ) + (+! (-> self spin-vector x) (-> s4-0 z)) + (set! (-> self spin-vector z) (- (-> self spin-vector z) (-> s4-0 x))) + (vector-flatten! (-> self spin-vector) (-> self spin-vector) s4-0) + (matrix-axis-angle! s5-0 s4-0 (* 2002.4889 (-> self clock time-adjust-ratio))) + (vector-matrix*! (-> self spin-vector) (-> self spin-vector) s5-0) + (let ((f0-9 (the float (- (-> self clock frame-counter) (-> self state-time)))) + (f30-0 0.0) + ) + (cond + ((< 450.0 f0-9) + (go-virtual impact) + ) + ((< f0-9 90.0) + (set! f30-0 (lerp-scale 0.0 4096.0 f0-9 0.0 90.0)) + ) + (else + (set! f30-0 (lerp-scale 4096.0 1228.8 f0-9 30.0 300.0)) + ) + ) + (vector-normalize! (-> self spin-vector) f30-0) + (vector-normalize! (-> self core-velocity) 7372.8) + (set! (-> s5-0 vector 2 quad) (-> s4-0 quad)) + (set! (-> s5-0 vector 1 quad) (-> self spin-vector quad)) + (vector-float*! (-> s5-0 vector 1) (-> s5-0 vector 1) (/ 1.0 f30-0)) + ) + ) + (vector-cross! (the-as vector (-> s5-0 vector)) (-> s5-0 vector 1) (-> s5-0 vector 2)) + (matrix->quaternion (-> self root-override quat) s5-0) + ) + (vector+! (-> self core-position) (-> self core-position) (-> self core-velocity)) + (vector+! gp-0 (-> self core-position) (-> self spin-vector)) + (vector-! (-> self root-override transv) gp-0 (-> self root-override trans)) + ) + (let ((v1-31 (-> self root-override transv))) + (.lvf vf1 (&-> (-> self root-override transv) quad)) + (let ((f0-12 (-> self clock frames-per-second))) + (.mov at-0 f0-12) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-31 quad) vf1) + ) + (projectile-move-fill-line-sphere self) + (if (logtest? (-> self root-override status) (collide-status touch-surface)) + (go-virtual impact) + ) + (sound-play "pmkr-fire" :id (the-as sound-id (-> self fire-sound)) :position (-> self root-override trans)) + (sound-play "pmkr-trail" :id (the-as sound-id (-> self trail-sound)) :position (-> self root-override trans)) + (none) + ) + ) + ) + +;; definition for function process-drawable-shock-effect-bullseye +;; WARN: Check prologue - tricky store of a0 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun process-drawable-shock-effect-bullseye ((arg0 process-focusable) + (arg1 process-focusable) + (arg2 matrix) + (arg3 int) + (arg4 sparticle-launcher) + (arg5 sparticle-launcher) + (arg6 sparticle-launcher) + ) + (local-vars (sv-16 process) (sv-32 matrix) (sv-48 process-focusable)) + (set! sv-48 arg0) + (let ((s0-0 arg1)) + (set! sv-32 arg2) + (let ((gp-0 arg4) + (s2-0 arg5) + (s3-0 arg6) + (s4-0 (get-trans sv-48 3)) + (s5-0 (get-trans s0-0 3)) + ) + (set! sv-16 (get-process *default-dead-pool* lightning-tracker #x4000)) + (let ((s1-0 (when sv-16 + (let ((t9-3 (method-of-type lightning-tracker activate))) + (t9-3 + (the-as lightning-tracker sv-16) + s0-0 + (symbol->string (-> lightning-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-4 run-function-in-process) + (a0-5 sv-16) + (a1-7 lightning-tracker-init) + (a3-2 0) + (t0-1 lightning-probe-callback) + (t2-1 256) + (t3-0 256) + ) + ((the-as (function object object object object object object object object none) t9-4) + a0-5 + a1-7 + sv-32 + a3-2 + t0-1 + sv-48 + t2-1 + t3-0 + ) + ) + (-> sv-16 ppointer) + ) + ) + ) + (when s2-0 + (let ((t9-5 sp-launch-particles-var) + (a0-6 *sp-particle-system-2d*) + (a2-4 *launch-matrix*) + ) + (set! (-> a2-4 trans quad) (-> s4-0 quad)) + (t9-5 a0-6 s2-0 a2-4 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (when s3-0 + (let ((t9-6 sp-launch-particles-var) + (a0-7 *sp-particle-system-2d*) + (a2-5 *launch-matrix*) + ) + (set! (-> a2-5 trans quad) (-> s4-0 quad)) + (t9-6 a0-7 s3-0 a2-5 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + (when (and gp-0 s1-0) + (let ((v1-15 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-15 + (set! (-> v1-15 initial-valuef) (the-as float (-> (the-as lightning-tracker (-> s1-0 0)) duration))) + ) + ) + (let ((t9-8 sp-launch-particles-var) + (a0-12 *sp-particle-system-2d*) + (a1-15 gp-0) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> s4-0 quad)) + (t9-8 a0-12 a1-15 a2-6 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-9 sp-launch-particles-var) + (a0-13 *sp-particle-system-2d*) + (a2-7 *launch-matrix*) + ) + (set! (-> a2-7 trans quad) (-> s5-0 quad)) + (t9-9 a0-13 gp-0 a2-7 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate fizzle (gun-dark-shot) + :virtual #t + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :trans (behavior () + (if (>= (- (-> self clock frame-counter) (-> self state-time)) (seconds 1)) + (deactivate self) + ) + (process-drawable-shock-effect + self + (-> *lightning-spec-id-table* 11) + lightning-probe-callback + (-> *part-id-table* 429) + 256 + 0 + 40960.0 + ) + (let ((t9-2 sp-launch-particles-var) + (a0-3 *sp-particle-system-2d*) + (a1-1 (-> *part-id-table* 215)) + (a2-1 *launch-matrix*) + ) + (set! (-> a2-1 trans quad) (-> self root-override trans quad)) + (t9-2 a0-3 a1-1 a2-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-3 sp-launch-particles-var) + (a0-4 *sp-particle-system-2d*) + (a1-2 (-> *part-id-table* 216)) + (a2-2 *launch-matrix*) + ) + (set! (-> a2-2 trans quad) (-> self root-override trans quad)) + (t9-3 a0-4 a1-2 a2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((gp-0 (-> *part-id-table* 430))) + (when gp-0 + (let ((v1-14 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-14 + (set! (-> v1-14 initial-valuef) (the-as float #xf)) + ) + ) + (let ((t9-5 sp-launch-particles-var) + (a0-8 *sp-particle-system-2d*) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> self root-override trans quad)) + (t9-5 a0-8 gp-0 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + (none) + ) + :code (the-as (function none :behavior gun-dark-shot) sleep-code) + ) + +;; definition for function gun-dark-shot-init-fizzle +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior gun-dark-shot-init-fizzle gun-dark-shot ((arg0 vector)) + (let ((s5-0 (new 'process 'collide-shape-moving self (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-projectile) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (let ((v1-6 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-6 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-6 prim-core collide-with) + (collide-spec backgnd crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher) + ) + (set! (-> v1-6 prim-core action) (collide-action solid)) + (set-vector! (-> v1-6 local-sphere) 0.0 5324.8 0.0 5324.8) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-6) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-9 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-9 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-9 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> self root-override) s5-0) + ) + (set! (-> self root-override trans quad) (-> arg0 quad)) + (let ((v1-16 (-> self root-override root-prim))) + (set! (-> v1-16 prim-core collide-as) (collide-spec)) + (set! (-> v1-16 prim-core collide-with) (collide-spec)) + ) + 0 + (logclear! (-> self mask) (process-mask actor-pause)) + (go-virtual fizzle) + (none) + ) + +;; failed to figure out what this is: +(defstate impact (gun-dark-shot) + :virtual #t + ) diff --git a/test/decompiler/reference/jak2/engine/target/gun/gun-states_REF.gc b/test/decompiler/reference/jak2/engine/target/gun/gun-states_REF.gc new file mode 100644 index 0000000000..8745f4b1d7 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/target/gun/gun-states_REF.gc @@ -0,0 +1,242 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(defstate target-gun-stance (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('gun) + (let ((gp-0 (-> event param 0)) + (v0-0 (target-standard-event-handler proc arg1 event-type event)) + ) + (when v0-0 + (cond + ((= gp-0 2) + (if (logtest? (-> self game features) (game-feature gun-upgrade-speed)) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 309))) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 256))) + ) + ) + ((= gp-0 4) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 259))) + ) + ((= gp-0 1) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 246))) + ) + ((= gp-0 3) + (set! (-> self control unknown-word04) (the-as uint (-> self draw art-group data 258))) + ) + ) + ) + v0-0 + ) + ) + (('wade) + #f + ) + (else + (target-standard-event-handler proc arg1 event-type event) + ) + ) + ) + :enter (behavior () + (set! (-> self state-flags) (logior (state-flags lleg-still rleg-still) (-> self state-flags))) + (set! (-> self control mod-surface) *gun-walk-mods*) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self state-time) (-> self clock frame-counter)) + (none) + ) + :exit (behavior () + (set! (-> self control bend-target) 0.0) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (target-state-hook-exit) + (target-gun-exit) + (none) + ) + :trans (behavior () + ((-> self state-hook)) + (when (= (-> self control ground-pat material) (pat-material ice)) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (set! (-> self control bend-target) 0.0) + (remove-exit) + (go target-ice-stance) + ) + (when (or (move-legs?) (< 8192.0 (fabs (-> self gun gun-roty-rel)))) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (set! (-> self control bend-target) 0.0) + (remove-exit) + (go target-gun-walk) + ) + (if (want-to-darkjak?) + (go target-darkjak-get-on 2) + ) + (when (and (cpad-hold? (-> self control cpad number) l1) (can-duck?)) + (logclear! (-> self state-flags) (state-flags lleg-still rleg-still)) + (set! (-> self control bend-target) 0.0) + (remove-exit) + (go target-duck-stance #f) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (target-jump-go) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons circle) + ) + (can-feet? #t) + ) + (go target-attack) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons square) + ) + (can-hands? #t) + ) + (go target-running-attack) + ) + (slide-down-test) + (fall-test target-falling -4096000.0) + (none) + ) + :post target-gun-post + ) + +;; failed to figure out what this is: +(defstate target-gun-walk (target) + :event target-standard-event-handler + :enter (behavior () + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self control mod-surface) *gun-walk-mods*) + (case (-> self gun gun-type) + (((pickup-type eco-yellow) (pickup-type eco-blue)) + (set! (-> self control unknown-word04) (the-as uint 0)) + 0 + ) + (else + (set! (-> self control unknown-word04) (the-as uint 1)) + ) + ) + (none) + ) + :exit (behavior () + (target-effect-exit) + (target-state-hook-exit) + (target-gun-exit) + (none) + ) + :trans (behavior () + (cond + ((zero? (-> self control unknown-spool-anim00)) + (case (-> self gun gun-type) + (((pickup-type eco-red) (pickup-type eco-dark)) + (remove-exit) + (go target-gun-walk) + ) + ) + ) + (else + (case (-> self gun gun-type) + (((pickup-type eco-yellow) (pickup-type eco-blue)) + (remove-exit) + (go target-gun-walk) + ) + ) + ) + ) + ((-> self state-hook)) + (if (not (using-gun? self)) + (go target-walk) + ) + (if (logtest? (water-flags wading) (-> self water flags)) + (go target-wade-walk) + ) + (when (= (-> self control ground-pat material) (pat-material ice)) + (target-effect-exit) + (remove-exit) + (go target-ice-walk) + ) + (when (not (or (move-legs?) (< 182.04445 (fabs (-> self gun gun-roty-rel))))) + (target-effect-exit) + (remove-exit) + (go target-gun-stance) + ) + (if (want-to-darkjak?) + (go target-darkjak-get-on 2) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons l1) + ) + (and (!= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) (can-roll?)) + ) + (go target-roll) + ) + (when (and (cpad-hold? (-> self control cpad number) l1) (can-duck?)) + (target-effect-exit) + (remove-exit) + (go target-duck-walk #f) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (target-jump-go) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons circle) + ) + (can-feet? #t) + ) + (go target-attack) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control cpad number) button0-rel 0) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control cpad number) button0-rel 2) + ) + (pad-buttons square) + ) + (can-hands? #t) + ) + (go target-running-attack) + ) + (if (wall-hide?) + (go target-hide) + ) + (slide-down-test) + (fall-test target-falling -4096000.0) + (none) + ) + :code (behavior () + (target-walk-anim -300) + (none) + ) + :post target-gun-post + ) diff --git a/test/decompiler/reference/jak2/engine/target/gun/gun-util_REF.gc b/test/decompiler/reference/jak2/engine/target/gun/gun-util_REF.gc index d12b670a10..151b12145c 100644 --- a/test/decompiler/reference/jak2/engine/target/gun/gun-util_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/gun/gun-util_REF.gc @@ -780,15 +780,15 @@ ) ) ) - (s5-0 '(("jakb-gun-yellow-fire" . #xf) - ("jakb-gun-yellow-fire-low" . #x13) - ("jakb-pilot-gun-yellow-fire" . #xf) - ("jakb-gun-red-fire" . #xc) - ("jakb-pilot-gun-red-fire" . #xc) - ("jakb-gun-blue-fire" . #xd) - ("jakb-pilot-gun-blue-fire" . #xd) - ("jakb-gun-dark-fire" . #xd) - ("jakb-pilot-gun-dark-fire" . #xd) + (s5-0 '(("jakb-gun-yellow-fire" . "gun-yellow-fire") + ("jakb-gun-yellow-fire-low" . "gun-yellow-fire-low") + ("jakb-pilot-gun-yellow-fire" . "gun-yellow-fire") + ("jakb-gun-red-fire" . "gun-red-fire") + ("jakb-pilot-gun-red-fire" . "gun-red-fire") + ("jakb-gun-blue-fire" . "gun-blue-fire") + ("jakb-pilot-gun-blue-fire" . "gun-blue-fire") + ("jakb-gun-dark-fire" . "gun-dark-fire") + ("jakb-pilot-gun-dark-fire" . "gun-dark-fire") ) ) (v1-277 (-> self parent)) @@ -831,14 +831,14 @@ ) ((and (= (-> s4-0 skel top-anim interp) 1.0) (begin - (set! s1-0 (nassoc s2-0 '(("jakb-gun-yellow-takeout" . #xe) - ("jakb-gun-blue-takeout" . #xc) - ("jakb-gun-dark-takeout" . #xc) - ("jakb-gun-red-takeout" . #xc) - ("jakb-pilot-gun-yellow-takeout" . #xe) - ("jakb-pilot-gun-blue-takeout" . #xc) - ("jakb-pilot-gun-dark-takeout" . #xc) - ("jakb-pilot-gun-red-takeout" . #xc) + (set! s1-0 (nassoc s2-0 '(("jakb-gun-yellow-takeout" . "gun-red-yellow") + ("jakb-gun-blue-takeout" . "gun-red-blue") + ("jakb-gun-dark-takeout" . "gun-red-dark") + ("jakb-gun-red-takeout" . "gun-idle-red") + ("jakb-pilot-gun-yellow-takeout" . "gun-red-yellow") + ("jakb-pilot-gun-blue-takeout" . "gun-red-blue") + ("jakb-pilot-gun-dark-takeout" . "gun-red-dark") + ("jakb-pilot-gun-red-takeout" . "gun-idle-red") ) ) ) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index 827f5e392b..d5dd1a9662 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -257,6 +257,8 @@ ], "skip_compile_states": { - "(idle process-taskable)": ["event"] + "(idle process-taskable)": ["event"], + "(impact gun-dark-shot)": ["code"], + "(target-gun-stance target)": ["code"] } }