diff --git a/decompiler/analysis/find_defstates.cpp b/decompiler/analysis/find_defstates.cpp index a5bdd6fe0f..2f59fd0424 100644 --- a/decompiler/analysis/find_defstates.cpp +++ b/decompiler/analysis/find_defstates.cpp @@ -355,6 +355,21 @@ FormElement* rewrite_virtual_defstate( inherit_info = {{mot_mr.maps.strings.at(0), mot_mr.maps.strings.at(1)}}; } + // jak 3: some virtual states set their parent here and inherit from their own type's states... + std::string maybe_parent_state; + std::string maybe_state_type; + auto maybe_parent = elt->body()->at(body_idx); + auto maybe_parent_matcher = + Matcher::set(Matcher::deref(Matcher::any_reg(), false, {DerefTokenMatcher::string("parent")}), + Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::METHOD_OF_TYPE), + {Matcher::any_symbol(0), Matcher::any_constant_token(1)})); + auto maybe_parent_mr = match(maybe_parent_matcher, maybe_parent); + if (maybe_parent_mr.matched) { + maybe_state_type = maybe_parent_mr.maps.strings.at(0); + maybe_parent_state = maybe_parent_mr.maps.strings.at(1); + body_idx++; + } + // checks to check: method type is a state // if inherit matches expected. @@ -411,7 +426,14 @@ FormElement* rewrite_virtual_defstate( // expected_state_name, type_name); } } else { - if (inherit_info) { + // if we set our parent state, check that that state's type and this type are the same + if (inherit_info && maybe_parent_mr.matched && maybe_state_type == type_name) { + env.func->warnings.warning( + "Virtual defstate {} is inheriting from state {} which is one of its own type's " + "states.", + expected_state_name, maybe_parent_state); + } + if (inherit_info && !maybe_parent_mr.matched) { env.func->warnings.error_and_throw( "Virtual defstate for state {} in type {}: the state wasn't defined in the " "parent but was inherited.", @@ -421,7 +443,7 @@ FormElement* rewrite_virtual_defstate( } // checks: parent_type_name is the parent - if (inherit_info) { + if (inherit_info && !maybe_parent_mr.matched) { auto child_type_info = env.dts->ts.lookup_type(type_name); if (child_type_info->get_parent() != inherit_info->parent_type_name) { env.func->warnings.error_and_throw( @@ -451,8 +473,13 @@ FormElement* rewrite_virtual_defstate( elt->body(), body_idx + 1, env, expected_state_name, elt->entries().at(0).dest, method_info.type.substitute_for_method_call(type_name), pool, type_name, skip_states); - return pool.alloc_element(type_name, expected_state_name, "", entries, true, - state_override); + std::string parent_str; + if (!maybe_parent_state.empty()) { + parent_str = fmt::format("({} {})", type_name, maybe_parent_state); + } + + return pool.alloc_element(type_name, expected_state_name, parent_str, entries, + true, state_override); } FormElement* rewrite_virtual_defstate_with_nonvirtual_inherit( @@ -481,8 +508,6 @@ FormElement* rewrite_virtual_defstate_with_nonvirtual_inherit( // (set! (-> gp-6 exit) (the-as (function object) L251)) // (set! (-> gp-6 trans) (the-as (function object) L253)) // ) - - // ASSERT(elt->body()->size() > 1); env.func->warnings.warning("Encountered virtual defstate {} with non-virtual inherit.", expected_state_name); // variable at the top of let, contains the static state with name exptected_state_name diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index be56f86641..32829112be 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -2265,16 +2265,16 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern matrix-fur-compose (function matrix vector vector vector matrix)) -(define-extern matrix-fu-compose (function matrix vector vector vector matrix)) +(define-extern matrix-fu-compose (function matrix vector vector matrix)) (define-extern matrix-fr-compose (function matrix vector vector vector matrix)) (define-extern matrix-ur-compose (function matrix vector vector vector matrix)) -(define-extern matrix-f-u-compose (function matrix vector vector vector matrix)) +(define-extern matrix-f-u-compose (function matrix vector vector matrix)) (define-extern matrix-f-r-compose (function matrix vector vector vector matrix)) (define-extern matrix-u-f-compose (function matrix vector vector matrix)) (define-extern matrix-u-r-compose (function matrix vector vector vector matrix)) (define-extern matrix-r-f-compose (function matrix vector vector vector matrix)) (define-extern matrix-r-u-compose (function matrix vector vector vector matrix)) -(define-extern matrix-f-compose (function matrix vector vector vector matrix)) +(define-extern matrix-f-compose (function matrix vector float matrix)) (define-extern matrix-u-compose (function matrix vector vector vector matrix)) (define-extern matrix-r-compose (function matrix vector vector vector matrix)) @@ -7449,6 +7449,19 @@ (movie0 16) (movie1 17) (movie2 18) + (tm19 19) + (tm20 20) + (tm21 21) + (tm22 22) + (tm23 23) + (tm24 24) + (tm25 25) + (tm26 26) + (tm27 27) + (tm28 28) + (tm29 29) + (tm30 30) + (tm31 31) ) ;; ---level-h:task-mask @@ -7815,7 +7828,7 @@ it will kick out levels as needed to make a free slot, and set up a new level, and start the load. This should only be used when you might want to start a load." (_type_ symbol symbol) level) ;; 12 (activate-levels! "Make all levels 'active!" (_type_) int) ;; 13 - (level-group-method-14 () none) ;; 14 ;; (debug-print-entities (_type_ symbol type) none) + (debug-print-entities (_type_ symbol type string) none) ;; 14 (debug-draw-actors (_type_ symbol) none) ;; 15 (assign-draw-indices "Assign the order for levels to be drawn." (_type_) none) ;; 16 (actors-update (_type_) none) ;; 17 @@ -7824,11 +7837,11 @@ (level-get-target-inside "Get the level that the player is 'in'." (_type_) level) ;; 20 (init-level-system "If needed, initialize the level system by loading common/art packages and allocating level heaps." (_type_ symbol) none) ;; 21 (art-group-get-by-name "Check all levels for an art group with the given name." (_type_ string (pointer level)) art-group) ;; 22 ;; (load-commands-set! (_type_ pair) none) - (level-group-method-23 () none) ;; 23 ;; (art-group-get-by-name (_type_ string (pointer uint32)) art-group) - (level-group-method-24 () none) ;; 24 ;; (alt-load-command-get-index (_type_ symbol int) pair) - (level-group-method-25 () none) ;; 25 ;; (update-vis-volumes (_type_) none) + (update-vis-volumes (_type_) none) ;; 23 ;; (art-group-get-by-name (_type_ string (pointer uint32)) art-group) + (level-group-method-24 (_type_) none) ;; 24 ;; (alt-load-command-get-index (_type_ symbol int) pair) + (print-volume-sizes (_type_) none) ;; 25 (status-of-level-and-borrows "Get the combined status of a level and borrow levels." (_type_ symbol symbol) symbol) ;; 26 ;; (update-vis-volumes-from-nav-mesh (_type_) none) - (do-nothing "Empty method." (_type_) none) ;; 27 ;; (print-volume-sizes (_type_) none) + (do-nothing "Empty method." (_type_) none) ;; 27 (load-in-progress? "Is there a load happening now?" (_type_) symbol) ;; 28 ;; (level-status (_type_ symbol) symbol) (is-load-allowed? "Does the exclusive-load setting allow us to load this level?" (_type_ (pointer symbol)) symbol) ;; 29 (level-get-most-disposable "Get the level inside this level-group that should @@ -17943,7 +17956,7 @@ (radius float :offset-assert 56) (duration float :offset-assert 60) (duration-rand float :offset-assert 64) - (sound symbol :offset-assert 68) + (sound sound-spec :offset-assert 68) (delay float :offset-assert 72) (delay-rand float :offset-assert 76) ) @@ -20541,7 +20554,7 @@ (send-shoves (_type_ process touching-shapes-entry float float float) symbol) ;; 50 (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) ;; 51 (water-info-init! (_type_ water-info collide-action) water-info) ;; 52 - (collide-shape-method-53 () none) ;; 53 ;; (iterate-prims (_type_ (function collide-shape-prim none)) none) + (iterate-prims (_type_ (function collide-shape-prim none)) none) ;; 53 (collide-shape-method-54 () none) ;; 54 ;; (pusher-init (_type_) none) ) ) @@ -23187,6 +23200,7 @@ (declare-type entity-camera entity) (declare-type entity-nav-mesh structure) +(declare-type entity-race-mesh entity) (declare-type city-level-info structure) (deftype bsp-node (structure) @@ -23238,11 +23252,11 @@ ; (ambients symbol :offset-assert 156) ;; now just #t? (subdivide-close float :offset 160) (subdivide-far float :offset-assert 164) - ; (race-meshes (array entity-race-mesh) :offset-assert 168) + (race-meshes (array entity-race-mesh) :offset-assert 168) (actor-birth-order (pointer uint32) :offset 172) (light-hash light-hash :offset-assert 176) (nav-meshes (array entity-nav-mesh) :offset-assert 180) - ; (actor-groups (array actor-group) :offset-assert 184) + (actor-groups (array actor-group) :offset-assert 184) (region-trees (array drawable-tree-region-prim) :offset 188) ; (region-array region-array :offset-assert 192) (collide-hash collide-hash :offset 196) @@ -25078,7 +25092,7 @@ :size-assert #x40 :flag-assert #xa00000040 (:methods - (entity-links-method-9 () none) ;; 9 ;; (birth? (_type_ vector) symbol) + (birth? (_type_ vector) symbol) ;; 9 ) ) @@ -25232,7 +25246,7 @@ (sx float :offset 12) (sy float :offset 28) (rot float :offset 24) - (flag int32 :offset 16) + (flag int32 :offset 16 :score 1) (matrix int32 :offset 20) (warp-turns int32 :offset 16) (r float :offset 32) @@ -28079,9 +28093,9 @@ (nav-mesh-method-19 () none) ;; 19 ;; (clamp-vector-to-mesh-no-gaps (_type_ vector nav-poly vector clamp-travel-vector-to-mesh-return-info) none) (nav-mesh-method-20 () none) ;; 20 ;; (set-normals-from-adjacent-bounds (_type_ clamp-travel-vector-to-mesh-return-info) none) (nav-mesh-method-21 () none) ;; 21 ;; (find-adjacent-bounds-one (_type_ vector nav-poly int int) none) - (nav-mesh-method-22 () none) ;; 22 ;; (compute-bounding-box-from-vertices (_type_ vector vector) none) + (nav-mesh-method-22 () none) ;; 22 (nav-mesh-method-23 () none) ;; 23 ;; (init-from-entity (_type_ entity-nav-mesh) none) - (nav-mesh-method-24 () none) ;; 24 ;; (handle-birth (_type_) none) + (compute-bounding-box-from-vertices (_type_ vector vector) none) ;; 24 ;; (handle-birth (_type_) none) (nav-mesh-method-25 () none) ;; 25 ;; (handle-kill (_type_) none) (nav-mesh-method-26 () none) ;; 26 ;; (update-navigation (_type_) none) (nav-mesh-method-27 () none) ;; 27 ;; (new-nav-control (_type_ process-drawable) nav-control) @@ -28305,7 +28319,7 @@ :size-assert #x120 :flag-assert #x2f00000120 (:methods - (nav-control-method-9 () none) ;; 9 ;; (debug-draw (_type_) none) + (debug-draw (_type_) none) ;; 9 (nav-control-method-10 () none) ;; 10 ;; (point-in-bsphere? (_type_ vector) symbol) (find-poly-containing-point-1 (_type_ vector) nav-poly) ;; 11 (cloest-point-on-mesh (_type_ vector vector nav-poly) nav-poly) ;; 12 @@ -30928,10 +30942,10 @@ (define-extern *particle-vel* vector) ;; (define-extern birth-func-set-vel function) ;; (function object sparticle-cpuinfo sparticle-launchinfo none) ;; (define-extern birth-func-texture-group function) ;; (function int sparticle-cpuinfo sparticle-launchinfo none) -;; (define-extern rot-to-particle function) +(define-extern rot-to-particle (function degrees sprite-vec-data-2d matrix none)) ;; (define-extern birth-func-flip-based-on-scale function) ;; (define-extern sparticle-2d-spline-align function) -;; (define-extern sparticle-2d-spline-align-instant function) +(define-extern sparticle-2d-spline-align-instant (function object sparticle-cpuinfo sprite-vec-data-2d object none)) ;; (define-extern birth-func-inherit-size function) ;; (define-extern birth-func-texture-group-2d function) ;; (define-extern birth-func-set-vel-2d function) @@ -33185,7 +33199,7 @@ (define-extern slave-los-state->string (function slave-los-state string)) ;; (define-extern cam-line-dma function) ;; (function pointer) ;; (define-extern camera-line2d function) ;; (function vector4w vector4w pointer) -;; (define-extern camera-plot-float-func function) ;; (function float float float float (function float float) vector4w none) +(define-extern camera-plot-float-func (function float float float float (function float float) vector4w none)) (define-extern camera-line-setup (function vector4w none)) (define-extern camera-line-draw (function vector vector none)) (define-extern camera-line (function vector vector vector4w none)) @@ -33580,7 +33594,7 @@ :size-assert #x10 :flag-assert #xc00000010 (:methods - (curve2d-piecewise-method-10 (_type_ int symbol uint) none) ;; 10 + (curve2d-piecewise-method-10 (_type_ int symbol int) none) ;; 10 (curve2d-piecewise-method-11 (_type_) none) ;; 11 ) ) @@ -35357,7 +35371,7 @@ ;; (define-extern spt-birth-func-part-jump-droppings-for function) (define-extern process-drawable-burn-effect (function time-frame rgbaf :behavior target)) (define-extern lightning-probe-callback (function lightning-tracker none)) -;; (define-extern process-drawable-shock-effect-replace function) +(define-extern process-drawable-shock-effect-replace (function process-drawable lightning-spec (function lightning-tracker none) int int float none)) (define-extern process-drawable-shock-effect (function process-drawable lightning-spec (function lightning-tracker none) sparticle-launcher int int float object)) ;; (define-extern process-drawable-shock-wall-effect function) ;; (function process-drawable lightning-spec (function lightning-tracker none) sparticle-launcher symbol) (define-extern process-drawable2-shock-effect (function process-drawable process-drawable lightning-spec (function lightning-tracker none) sparticle-launcher none)) @@ -35369,28 +35383,28 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (define-extern sparticle-track-gun-joint function) -;; (define-extern *red-shot-colors* object) ;; (pointer rgba) -;; (define-extern *range-explo-dust-color* curve-color-fast) -;; (define-extern *range-explo-dust-alpha* curve2d-fast) -;; (define-extern *range-explo-dust-scale-x* curve2d-fast) -;; (define-extern *range-explo-dust-scale-y* curve2d-fast) -;; (define-extern *curve-explo-dust-alpha* curve2d-fast) -;; (define-extern *curve-explo-dust-scale-x* curve2d-fast) -;; (define-extern *curve-explo-dust-scale-y* curve2d-fast) -;; (define-extern *part-gun-red3-explosion-dust-in-curve-settings* object) -;; (define-extern *range-explo-color* curve-color-fast) -;; (define-extern *range-explo-alpha* curve2d-fast) -;; (define-extern *range-explo-scale-x* curve2d-fast) -;; (define-extern *range-explo-scale-y* curve2d-fast) -;; (define-extern *curve-explo-alpha* curve2d-fast) -;; (define-extern *curve-explo-scale-x* curve2d-fast) -;; (define-extern *curve-explo-scale-y* curve2d-fast) -;; (define-extern *part-gun-red3-explosion-texture-curve-settings* object) -;; (define-extern *curve-linear-up-red* object) +(define-extern *red-shot-colors* (pointer rgba)) +(define-extern *range-explo-dust-color* curve-color-fast) +(define-extern *range-explo-dust-alpha* curve2d-fast) +(define-extern *range-explo-dust-scale-x* curve2d-fast) +(define-extern *range-explo-dust-scale-y* curve2d-fast) +(define-extern *curve-explo-dust-alpha* curve2d-fast) +(define-extern *curve-explo-dust-scale-x* curve2d-fast) +(define-extern *curve-explo-dust-scale-y* curve2d-fast) +(define-extern *part-gun-red3-explosion-dust-in-curve-settings* particle-curve-settings) +(define-extern *range-explo-color* curve-color-fast) +(define-extern *range-explo-alpha* curve2d-fast) +(define-extern *range-explo-scale-x* curve2d-fast) +(define-extern *range-explo-scale-y* curve2d-fast) +(define-extern *curve-explo-alpha* curve2d-fast) +(define-extern *curve-explo-scale-x* curve2d-fast) +(define-extern *curve-explo-scale-y* curve2d-fast) +(define-extern *part-gun-red3-explosion-texture-curve-settings* particle-curve-settings) +(define-extern *curve-linear-up-red* curve2d-piecewise) (define-extern *red-shot-3-trail* light-trail-composition) -;; (define-extern *curve-yellow2-shot-alpha* object) -;; (define-extern *curve-yellow2-shot-color* curve-color-fast) -;; (define-extern *curve-linear-down-long* curve2d-fast) +(define-extern *curve-yellow2-shot-alpha* curve2d-piecewise) +(define-extern *curve-yellow2-shot-color* curve-color-fast) +(define-extern *curve-linear-down-long* curve2d-fast) (define-extern *yellow-shot-2-trail* light-trail-composition) ;; (define-extern check-shell-level1 function) ;; (function sparticle-system sparticle-cpuinfo vector none) ;; (define-extern check-shell-level2 function) ;; (function sparticle-system sparticle-cpuinfo vector none) @@ -35401,20 +35415,20 @@ ;; (define-extern birth-func-converge function) ;; (define-extern sparticle-red-2-converge function) ;; (define-extern sparticle-red-2-glow-trail-halt function) -;; (define-extern *gun-dark-3-nuke-fade-time* object) -;; (define-extern *gun-dark-3-nuke-fade-curve* object) -;; (define-extern *gun-dark-3-nuke-blur-segs* object) -;; (define-extern *gun-dark-3-nuke-blur-time* object) -;; (define-extern *gun-dark-3-nuke-blur-curve* object) -;; (define-extern *gun-dark-3-mushroom-speed* object) -;; (define-extern *gun-dark-3-mushroom-size-time* object) -;; (define-extern *gun-dark-3-nuke-mushroom-size-curve-x* object) -;; (define-extern *gun-dark-3-nuke-mushroom-size-curve-y* object) -;; (define-extern *gun-dark-3-nuke-fade-time-small* object) -;; (define-extern *gun-dark-3-nuke-fade-curve-small* object) -;; (define-extern *gun-dark-3-nuke-blur-segs-small* object) -;; (define-extern *gun-dark-3-nuke-blur-time-small* object) -;; (define-extern *gun-dark-3-nuke-blur-curve-small* object) +(define-extern *gun-dark-3-nuke-fade-time* time-frame) +(define-extern *gun-dark-3-nuke-fade-curve* curve-color-piecewise) +(define-extern *gun-dark-3-nuke-blur-segs* uint) +(define-extern *gun-dark-3-nuke-blur-time* time-frame) +(define-extern *gun-dark-3-nuke-blur-curve* curve2d-piecewise) +(define-extern *gun-dark-3-mushroom-speed* float) +(define-extern *gun-dark-3-mushroom-size-time* time-frame) +(define-extern *gun-dark-3-nuke-mushroom-size-curve-x* curve2d-piecewise) +(define-extern *gun-dark-3-nuke-mushroom-size-curve-y* curve2d-piecewise) +(define-extern *gun-dark-3-nuke-fade-time-small* time-frame) +(define-extern *gun-dark-3-nuke-fade-curve-small* curve-color-piecewise) +(define-extern *gun-dark-3-nuke-blur-segs-small* uint) +(define-extern *gun-dark-3-nuke-blur-time-small* time-frame) +(define-extern *gun-dark-3-nuke-blur-curve-small* curve2d-piecewise) ;; (define-extern spt-func-part-gun-dark-1-upgrade-shot-edges function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -36068,9 +36082,8 @@ ;; gun-blue-shot ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype gun-blue-shot-3 (projectile) - ((hit-actor? basic :offset-assert 512) + ((hit-actor? symbol :offset-assert 512) (start-pos vector :inline :offset-assert 528) (track-mode uint64 :offset-assert 544) (random-travel-distance float :offset-assert 552) @@ -36083,9 +36096,7 @@ dissipate ;; 21 ) ) -|# -#| (deftype dist-dot-val (structure) ((dot float :offset-assert 0) (dist float :offset-assert 4) @@ -36096,54 +36107,44 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype light-trail-tracker-blue-3 (light-trail-tracker-projectile) () :method-count-assert 22 :size-assert #xb8 :flag-assert #x16004000b8 ) -|# -#| (deftype target-quality-info (structure) - ((targ uint64 :offset-assert 0) + ((targ handle :offset-assert 0) (value float :offset-assert 8) ) :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype timeframe-wrapper (structure) - ((time uint64 :offset-assert 0) + ((time time-frame :offset-assert 0) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype gun-blue-2-lightning-info (structure) - ((pts UNKNOWN 32 :offset-assert 0) + ((pts vector 32 :inline :offset-assert 0) (num-pts int8 :offset-assert 512) - (should-draw-terminal-sparks? basic :offset-assert 516) + (should-draw-terminal-sparks? symbol :offset-assert 516) (terminal-spark-pos vector :inline :offset-assert 528) - (should-draw-extension? basic :offset-assert 544) + (should-draw-extension? symbol :offset-assert 544) (extension-end-point vector :inline :offset-assert 560) ) :method-count-assert 9 :size-assert #x240 :flag-assert #x900000240 ) -|# -#| (deftype gun-blue-lightning-command (structure) ((msg uint64 :offset-assert 0) (lightning-info gun-blue-2-lightning-info :inline :offset-assert 16) @@ -36152,20 +36153,18 @@ :size-assert #x250 :flag-assert #x900000250 ) -|# -#| (deftype gun-blue-2-lightning-tracker (process-drawable) - ((lt-array basic :offset-assert 200) - (should-draw-this-frame? basic :offset-assert 204) - (last-spark-time uint64 :offset-assert 216) - (spark-time-interval uint64 :offset-assert 224) - (last-deduct-ammo-time uint64 :offset-assert 232) - (snd-lightning uint32 :offset-assert 240) - (active-enter-time uint64 :offset-assert 248) + ((lt-array (array gun-blue-2-lightning-info) :offset-assert 200) + (should-draw-this-frame? symbol :offset-assert 204) + (last-spark-time time-frame :offset 216) + (spark-time-interval time-frame :offset-assert 224) + (last-deduct-ammo-time time-frame :offset-assert 232) + (snd-lightning sound-id :offset-assert 240) + (active-enter-time time-frame :offset-assert 248) (revolve-angle float :offset-assert 256) (sway-angle float :offset-assert 260) - (snd-spin uint32 :offset-assert 264) + (snd-spin sound-id :offset-assert 264) (spin-intensity float :offset-assert 268) (prev-targ-pos vector :inline :offset-assert 272) (last-probe-index int16 :offset-assert 288) @@ -36173,32 +36172,28 @@ :method-count-assert 27 :size-assert #x122 :flag-assert #x1b00b00122 - (:methods - (gun-blue-2-lightning-tracker-method-24 () none) ;; 24 - (gun-blue-2-lightning-tracker-method-25 () none) ;; 25 - (gun-blue-2-lightning-tracker-method-26 () none) ;; 26 - ) (:state-methods - test ;; 23 active ;; 20 inactive ;; 21 die ;; 22 + test ;; 23 + ) + (:methods + (gun-blue-2-lightning-tracker-method-24 () none) ;; 24 + (gun-blue-2-lightning-tracker-method-25 () none) ;; 25 + (gun-blue-2-lightning-tracker-method-26 () none) ;; 26 ) ) -|# -#| (deftype gun-blue-2-target-info (structure) - ((target uint64 :offset-assert 0) - (start-time uint64 :offset-assert 8) + ((target handle :offset-assert 0) + (start-time time-frame :offset-assert 8) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype constraint-knot (structure) ((pt vector :inline :offset-assert 0) (dir vector :inline :offset-assert 16) @@ -36208,11 +36203,9 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype rope-constraint (structure) - ((constraints UNKNOWN 12 :offset-assert 0) + ((constraints constraint-knot 12 :inline :offset-assert 0) (num-knots uint8 :offset-assert 576) ) :method-count-assert 10 @@ -36222,9 +36215,7 @@ (rope-constraint-method-9 () none) ;; 9 ) ) -|# -#| (deftype gun-blue-2-lightning-init-params (structure) ((num-beams int8 :offset-assert 0) ) @@ -36232,9 +36223,7 @@ :size-assert #x1 :flag-assert #x900000001 ) -|# -#| (deftype gun-blue-shot (projectile) ((init-pos vector :inline :offset-assert 512) (init-dir vector :inline :offset-assert 528) @@ -36244,23 +36233,20 @@ :size-assert #x230 :flag-assert #x2901b00230 ) -|# -#| (deftype gun-blue-shot-2 (gun-blue-shot) () :method-count-assert 41 :size-assert #x230 :flag-assert #x2901b00230 ) -|# ;; (define-extern sparticle-fade-alpha-dist function) ;; (define-extern gun-fire-blue-1 function) ;; (define-extern fmod-2 function) ;; (define-extern get-dist-and-dot function) ;; (define-extern gun-blue-shot-3-move function) -;; (define-extern *blue-shot-trail* object) +(define-extern *blue-shot-trail* light-trail-composition) ;; (define-extern gun-fire-blue-3 function) ;; (define-extern draw-beam-segment function) ;; (define-extern *found-objects* object) @@ -36269,7 +36255,7 @@ ;; (define-extern fire-projectile-if-necessary function) ;; (define-extern *gun-blue-2-targets* object) ;; (define-extern *blue-2-lightning-shape* object) -;; (define-extern *uv-loop-curve* object) +(define-extern *uv-loop-curve* curve2d-piecewise) ;; (define-extern *blue-light-test* object) ;; (define-extern *blue-light-test-end* object) ;; (define-extern *blue-light-test-big* object) @@ -36281,13 +36267,13 @@ ;; (define-extern find-gun-blue-2-target function) ;; (define-extern find-gun-blue-2-target-old function) ;; (define-extern *lightning-pts-cache* object) -;; (define-extern gun-fire-blue-2 function) -;; (define-extern gun-fire-blue-2-old function) +(define-extern gun-fire-blue-2 (function object :behavior target)) +(define-extern gun-fire-blue-2-old (function object :behavior target)) (define-extern target-gun-can-fire-blue? (function pickup-type symbol :behavior target)) -;; (define-extern *last-fire-blue-time* object) +(define-extern *last-fire-blue-time* time-frame) (define-extern target-gun-fire-blue (function pickup-type (pointer process) :behavior target)) -;; (define-extern gun-blue-shot-move function) ;; (function gun-blue-shot none) -;; (define-extern cshape-reaction-blue-shot function) ;; (function control-info collide-query vector vector collide-status) +(define-extern gun-blue-shot-move (function gun-blue-shot none)) +(define-extern cshape-reaction-blue-shot (function control-info collide-query vector vector collide-status)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gun-yellow-shot ;; @@ -36460,12 +36446,12 @@ ) (:methods (init-probes! (_type_ collide-shape) none) ;; 23 - (gun-red-shot-method-24 (_type_) none) ;; 24 ;; (gun-red-shot-method-24 (_type_) symbol) + (check-blocked? (_type_) symbol) ;; 24 (stub (_type_) none) ;; 25 - (do-collision (_type_) none) ;; 26 ;; (gun-red-shot-method-26 (_type_) none) - (gun-red-shot-method-27 (_type_) none) ;; 27 ;; (gun-red-shot-method-27 (_type_) none) - (gun-red-shot-method-28 (_type_ vector) none) ;; 28 ;; (gun-red-shot-method-28 (_type_ vector) sound-id) - (gun-red-shot-method-29 (_type_ process-drawable touching-shapes-entry) none) ;; 29 ;; (fire! (_type_ process-drawable int) object) + (find-targets (_type_) none) ;; 26 + (setup-probes (_type_) none) ;; 27 + (do-collision (_type_ vector) none) ;; 28 + (send-attack! (_type_ process-drawable touching-shapes-entry) none) ;; 29 ) ) @@ -36554,17 +36540,16 @@ die ;; 16 ) (:methods - (gun-red-2-shockwave-method-17 (_type_) none) ;; 17 + (find-targets-and-attack! (_type_) none) ;; 17 (send-attack! (_type_ process-focusable symbol) none) ;; 18 - ;; adding _type_ here causes decompiler hang - (gun-red-2-shockwave-method-19 () none) ;; 19 - (gun-red-2-shockwave-method-20 (_type_) none) ;; 20 - (gun-red-2-shockwave-method-21 (_type_) none) ;; 21 + (find-collision-point! (_type_) int) ;; 19 + (generate-collision-points! (_type_) none) ;; 20 + (adjust-height-and-radius (_type_) none) ;; 21 (gun-red-2-shockwave-method-22 (_type_ int int int int) none) ;; 22 (generate-shockwave-particles (_type_) none) ;; 23 (adjust-warp-radius-and-alpha (_type_) object) ;; 24 (adjust-ring-radius-and-alpha (_type_) none) ;; 25 - (generate-collision-points (_type_) none) ;; 26 + (generate-order-array (_type_) none) ;; 26 (spawn-ring (_type_) none) ;; 27 ) ) @@ -36648,7 +36633,7 @@ (define-extern gun-fire-red-2 (function object :behavior target)) (define-extern red-3-sphere-init-by-other (function red-3-sphere-init-params object :behavior red-3-sphere)) (define-extern gun-fire-red-3 (function gun-red-3-grenade :behavior target)) -(define-extern gun-fire-red-1 (function gun-red-shot :behavior target)) +(define-extern gun-fire-red-1 (function object :behavior target)) (define-extern target-gun-can-fire-red? (function pickup-type symbol :behavior target)) (define-extern target-gun-fire-red (function pickup-type (pointer process) :behavior target)) (define-extern gun-red-shot-event-handler (function process int symbol event-message-block object :behavior gun-red-shot)) @@ -36658,36 +36643,33 @@ ;; gun-dark-shot ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype gun-dark-shot (projectile) ((blast-radius float :offset-assert 512) (core-position vector :inline :offset-assert 528) (core-velocity vector :inline :offset-assert 544) (spin-vector vector :inline :offset-assert 560) - (track-target uint64 :offset-assert 576) ;; handle + (track-target handle :offset-assert 576) (size-t float :offset-assert 584) - (result-array handle 16 :offset-assert 592) ;; guessed by decompiler + (result-array handle 16 :offset-assert 592) (result-count int8 :offset-assert 720) - (charge-sound sound-id :offset-assert 724) ;; guessed by decompiler - (fire-sound sound-id :offset-assert 728) ;; guessed by decompiler - (trail-sound sound-id :offset-assert 732) ;; guessed by decompiler - (explode-sound sound-id :offset-assert 736) ;; guessed by decompiler - (start-pilot? basic :offset-assert 740) - (spread-timer uint64 :offset-assert 744) + (charge-sound sound-id :offset-assert 724) + (fire-sound sound-id :offset-assert 728) + (trail-sound sound-id :offset-assert 732) + (explode-sound sound-id :offset-assert 736) + (start-pilot? symbol :offset-assert 740) + (spread-timer time-frame :offset-assert 744) ) :method-count-assert 43 :size-assert #x2f0 :flag-assert #x2b027002f0 (:state-methods impact ;; 22 - fizzle ;; 42 moving ;; 23 - startup ;; 41, old: (fizzle () _type_ :state) + startup ;; 41 + fizzle ;; 42 ) ) -|# -#| (deftype gun-dark-3-sphere (process-drawable) ((alpha-val float :offset-assert 200) ) @@ -36698,9 +36680,7 @@ active ;; 20 ) ) -|# -#| (deftype gun-dark-3-sphere-init-params (structure) ((pos vector :inline :offset-assert 0) (size-x float :offset-assert 16) @@ -36711,122 +36691,114 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype last-active-nuke-info (structure) - ((last-active-nuke uint64 :offset-assert 0) + ((last-active-nuke handle :offset-assert 0) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype gun-dark-3-nuke (projectile) - ((flash-time uint64 :offset-assert 512) - (blur-time uint64 :offset-assert 520) - (spawned-mushroom-cloud? basic :offset-assert 528) - (strip basic :offset-assert 532) + ((flash-time time-frame :offset-assert 512) + (blur-time time-frame :offset-assert 520) + (spawned-mushroom-cloud? symbol :offset-assert 528) + (strip prim-strip :offset-assert 532) (mushroom-top-pos vector :inline :offset-assert 544) - (warp uint64 :offset-assert 560) + (warp handle :offset-assert 560) (initial-velocity vector :inline :offset-assert 576) (start-y float :offset-assert 592) (y-vel-adjust float :offset-assert 596) (launch-speed float :offset-assert 600) (launch-sin-region-start float :offset-assert 604) (launch-sin-region-end float :offset-assert 608) - (launch-stay-state-time uint64 :offset-assert 616) - (launch-next-state basic :offset-assert 624) - (launch-impact-state basic :offset-assert 628) + (launch-stay-state-time time-frame :offset-assert 616) + (launch-next-state (state gun-dark-3-nuke) :offset-assert 624) + (launch-impact-state (state gun-dark-3-nuke) :offset-assert 628) (launch-y-scale float :offset-assert 632) (launch-height-t float :offset-assert 636) (expected-height float :offset-assert 640) - (total-fly-time uint64 :offset-assert 648) + (total-fly-time time-frame :offset-assert 648) (num-dying-vehicles uint8 :offset-assert 656) (num-dying-guards uint8 :offset-assert 657) (num-dying-civilians uint8 :offset-assert 658) - (last-death-sound-play-time uint64 :offset-assert 664) - (blur-curve basic :offset-assert 672) - (fade-curve basic :offset-assert 676) + (last-death-sound-play-time time-frame :offset-assert 664) + (blur-curve curve2d-piecewise :offset-assert 672) + (fade-curve curve-color-piecewise :offset-assert 676) (num-blur-segments uint8 :offset-assert 680) - (shook-camera? basic :offset-assert 684) - (hit-wall? basic :offset-assert 688) - (killed-everything? basic :offset-assert 696) - (explode-sound uint32 :offset-assert 700) - (explode-wall-sound uint32 :offset-assert 704) - (played-trail? basic :offset-assert 708) - (smoke-trail basic :offset-assert 712) - (killed-objects UNKNOWN 64 :offset-assert 720) + (shook-camera? symbol :offset-assert 684) + (hit-wall? symbol :offset-assert 688) + (killed-everything? symbol :offset 696) + (explode-sound sound-id :offset-assert 700) + (explode-wall-sound sound-id :offset-assert 704) + (played-trail? symbol :offset-assert 708) + (smoke-trail sparticle-subsampler :offset-assert 712) + (killed-objects handle 64 :offset-assert 720) (num-killed-objects int32 :offset-assert 1232) - (last-kill-time uint64 :offset-assert 1240) + (last-kill-time time-frame :offset-assert 1240) ) :method-count-assert 60 :size-assert #x4e0 :flag-assert #x3c046004e0 - (:methods - (gun-dark-3-nuke-method-41 () none) ;; 41 - (gun-dark-3-nuke-method-51 () none) ;; 51 - (gun-dark-3-nuke-method-52 () none) ;; 52 - (gun-dark-3-nuke-method-53 () none) ;; 53 - (gun-dark-3-nuke-method-54 () none) ;; 54 - (gun-dark-3-nuke-method-55 () none) ;; 55 - (gun-dark-3-nuke-method-56 () none) ;; 56 - (gun-dark-3-nuke-method-57 () none) ;; 57 - (gun-dark-3-nuke-method-58 () none) ;; 58 - (gun-dark-3-nuke-method-59 () none) ;; 59 - ) (:state-methods - wait-for-alive ;; 50 - impact-small ;; 47 - impact-embedded ;; 49 impact ;; 22 - impact-dud ;; 48 - launch-3 ;; 46 - launch-2 ;; 45 - launch-1 ;; 44 - launch-0 ;; 43 + undefined ;; 41, not defined launching-base-state ;; 42 + launch-0 ;; 43 + launch-1 ;; 44 + launch-2 ;; 45 + launch-3 ;; 46 + impact-small ;; 47 + impact-dud ;; 48 + impact-embedded ;; 49 + wait-for-alive ;; 50 + ) + (:methods + (set-launch-height! (_type_) none) ;; 51 + (do-blur-effect (_type_) none) ;; 52 + (do-white-screen-effect (_type_) none) ;; 53 + (count-casualties (_type_) none) ;; 54 + (send-attack! (_type_ process-focusable) none) ;; 55 + (play-death-sounds (_type_) none) ;; 56 + (do-camera-shake (_type_) none) ;; 57 + (do-vibration (_type_) none) ;; 58 + (check-for-impact (_type_) none) ;; 59 ) ) -|# -#| (deftype gravity-spinner (process) ((cached-damage float :offset-assert 128) - (end-time uint64 :offset-assert 136) - (time-subtract uint64 :offset-assert 144) - (parent-hand uint64 :offset-assert 152) + (end-time time-frame :offset-assert 136) + (time-subtract time-frame :offset-assert 144) + (parent-hand handle :offset-assert 152) (rotation-accel vector :inline :offset-assert 160) (original-sphere-offset sphere :inline :offset-assert 176) (obj-radius float :offset-assert 192) - (was-hit-previously? basic :offset-assert 196) + (was-hit-previously? symbol :offset-assert 196) (ground-height float :offset-assert 200) - (next-ground-probe-time uint64 :offset-assert 208) + (next-ground-probe-time time-frame :offset-assert 208) ) :method-count-assert 25 :size-assert #xd8 :flag-assert #x19006000d8 - (:methods - (gravity-spinner-method-16 () none) ;; 16 - (gravity-spinner-method-17 () none) ;; 17 - (gravity-spinner-method-18 () none) ;; 18 - (gravity-spinner-method-19 () none) ;; 19 - (gravity-spinner-method-20 () none) ;; 20 - (gravity-spinner-method-21 () none) ;; 21 - (gravity-spinner-method-22 () none) ;; 22 - (gravity-spinner-method-23 () none) ;; 23 - (gravity-spinner-method-24 () none) ;; 24 - ) (:state-methods zero-g ;; 14 zero-g-vehicle ;; 15 ) + (:methods + (gravity-spinner-method-16 (_type_ vector vector) none) ;; 16 + (update-rotation (_type_ symbol) none) ;; 17 + (gravity-spinner-method-18 (_type_ process) float) ;; 18 + (handle-impact (_type_ symbol) vector) ;; 19 + (probe-ground (_type_) none) ;; 20 + (get-float-speed (_type_) float) ;; 21 + (gravity-spinner-method-22 (_type_) none) ;; 22 + (spawn-part (_type_) none) ;; 23 + (rotate! (_type_ quaternion) none) ;; 24 + ) ) -|# -#| (deftype gravity-ring (process-drawable) ((start-pos vector :inline :offset-assert 208) (jmod-outer joint-mod-add-local :inline :offset-assert 224) @@ -36834,67 +36806,68 @@ (ring-scale-t float :offset-assert 352) (current-radius float :offset-assert 356) (max-radius float :offset-assert 360) - (reverse? basic :offset-assert 364) + (reverse? symbol :offset-assert 364) (total-time float :offset-assert 368) (ring-width float :offset-assert 372) - (stop-time uint64 :offset-assert 376) + (stop-time time-frame :offset-assert 376) ) :method-count-assert 22 :size-assert #x180 :flag-assert #x1601000180 - (:methods - (gravity-ring-method-21 () none) ;; 21 - ) (:state-methods expand ;; 20 ) + (:methods + (gravity-ring-method-21 (_type_) none) ;; 21 + ) ) -|# -#| (deftype gun-gravity (process-drawable) ((current-radius float :offset-assert 200) (max-radius float :offset-assert 204) (lowest-y float :offset-assert 208) (start-pos vector :inline :offset-assert 224) (total-time float :offset-assert 240) - (ring-closest uint64 :offset-assert 248) - (ring-furthest uint64 :offset-assert 256) - (gravity-sound uint32 :offset-assert 264) + (ring-closest handle :offset-assert 248) + (ring-furthest handle :offset-assert 256) + (gravity-sound sound-id :offset-assert 264) ) :method-count-assert 25 :size-assert #x10c :flag-assert #x190090010c - (:methods - (gun-gravity-method-21 () none) ;; 21 - (gun-gravity-method-22 () none) ;; 22 - (gun-gravity-method-23 () none) ;; 23 - (gun-gravity-method-24 () none) ;; 24 - ) (:state-methods expand ;; 20 ) + (:methods + (gun-gravity-method-21 (_type_) none) ;; 21 + (gun-gravity-method-22 (_type_ symbol) none) ;; 22 + (spawn-gravity-spinner (_type_ process) (pointer gravity-spinner)) ;; 23 + (gun-gravity-method-24 (_type_) none) ;; 24 + ) ) -|# -;; (define-extern sparticle-lightning-2d-spline-align-plus-rotz function) -;; (define-extern gun-fire-dark-1 function) -;; (define-extern gun-dark-3-sphere-init-by-other function) -;; (define-extern *last-active-nuke* object) -;; (define-extern gun-dark-reaction function) -;; (define-extern nuke-move function) +(define-extern market-object type) +(define-extern fruit-stand type) +(define-extern missile-bot type) + +(define-extern sparticle-lightning-2d-spline-align-plus-rotz (function object sparticle-cpuinfo sprite-vec-data-2d object none)) +(define-extern gun-fire-dark-1 (function (pointer process) :behavior target)) +(define-extern gun-dark-3-sphere-init-by-other (function gun-dark-3-sphere-init-params object :behavior gun-dark-3-sphere)) +(define-extern *last-active-nuke* last-active-nuke-info) +(define-extern gun-dark-reaction (function control-info collide-query vector vector collide-status)) +(define-extern nuke-move (function object :behavior gun-dark-3-nuke)) (define-extern target-gun-can-fire-dark? (function pickup-type symbol :behavior target)) -;; (define-extern gun-fire-dark-3 function) -;; (define-extern process-drawable-shock-effect-bullseye function) ;; (function process-focusable process-focusable matrix int sparticle-launcher sparticle-launcher sparticle-launcher none) -;; (define-extern gun-dark-shot-init-fizzle function) ;; (function vector none :behavior gun-dark-shot) -;; (define-extern *gravity-origin-pos* object) -;; (define-extern gravity-spinner-init-by-other function) -;; (define-extern zero-g-wait-for-land function) -;; (define-extern *zero-g-fake-attack-vec* object) -;; (define-extern *gun-gravity-shadow-control* shadow-control) -;; (define-extern gravity-ring-init-by-other function) -;; (define-extern gun-gravity-init-by-other function) -;; (define-extern gun-fire-dark-2 function) +(define-extern gun-fire-dark-3 (function (pointer process) :behavior target)) +(define-extern process-drawable-shock-effect-bullseye (function process-focusable process-focusable lightning-spec (function lightning-tracker none) sparticle-launcher sparticle-launcher sparticle-launcher none)) +(define-extern gun-dark-shot-init-fizzle (function vector none :behavior gun-dark-shot)) +(define-extern *gravity-origin-pos* vector) +(define-extern gravity-spinner-init-by-other (function handle object time-frame object :behavior gravity-spinner)) +(define-extern zero-g-wait-for-land (function object :behavior gravity-spinner)) +(define-extern *zero-g-fake-attack-vec* vector) +(define-extern *gun-gravity-shadow-control* shadow-control) +(define-extern gravity-ring-init-by-other (function vector symbol float float float time-frame object :behavior gravity-ring)) +(define-extern gun-gravity-init-by-other (function vector vector object :behavior gun-gravity)) +(define-extern gun-fire-dark-2 (function (pointer process) :behavior target)) (define-extern target-gun-fire-dark (function pickup-type (pointer process) :behavior target)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -37443,45 +37416,45 @@ ) (define-extern *spawn-actors* symbol) -;; (define-extern *compact-actors* object) ;; symbol -;; (define-extern *vis-actors* object) ;; symbol +(define-extern *compact-actors* symbol) +(define-extern *vis-actors* symbol) (define-extern entity-by-name (function string entity)) (define-extern entity-by-type (function type entity-actor)) (define-extern entity-by-aid (function uint entity)) (define-extern entity-actor-from-level-name (function symbol entity-actor)) -;; (define-extern entity-nav-mesh-by-aid function) ;; (function actor-id entity-nav-mesh) -;; (define-extern nav-mesh-from-res-tag function) ;; (function entity symbol int nav-mesh) -;; (define-extern entity-by-meters function) ;; (function float float float entity-actor) -;; (define-extern process-by-ename function) ;; (function string process) -;; (define-extern entity-process-count function) ;; (function symbol int) -;; (define-extern entity-count function) ;; (function int) -;; (define-extern entity-remap-names function) ;; (function pair none) -;; (define-extern process-status-bits function) ;; (function process symbol none) +(define-extern entity-nav-mesh-by-aid (function actor-id entity-nav-mesh)) +(define-extern nav-mesh-from-res-tag (function entity symbol int nav-mesh)) +(define-extern entity-by-meters (function float float float entity-actor)) +(define-extern process-by-ename (function string process)) +(define-extern entity-process-count (function symbol int)) +(define-extern entity-count (function int)) +(define-extern entity-remap-names (function pair none)) +(define-extern process-status-bits (function process symbol none)) (define-extern process-entity-set! (function process entity entity)) (define-extern process-task-mask (function process task-mask)) -;; (define-extern update-actor-vis-box function) ;; (function process-drawable vector vector none) -;; (define-extern expand-bounding-box function) ;; (function vector vector vector vector none) -;; (define-extern expand-bounding-box-from-nav-meshes function) -;; (define-extern expand-vis-box-with-point function) ;; (function entity vector none) -;; (define-extern *debug-actor-info* debug-actor-info) ;; debug-actor-info -;; (define-extern *pid-string* object) ;; string -;; (define-extern debug-actor function) ;; (function string none) -;; (define-extern debug-actor-process function) -;; (define-extern draw-actor-marks function) ;; (function process none) +(define-extern update-actor-vis-box (function process-drawable vector vector none)) +(define-extern expand-bounding-box (function vector vector vector vector none)) +(define-extern expand-bounding-box-from-nav-meshes (function entity vector vector object)) +(define-extern expand-vis-box-with-point (function entity vector none)) +(define-extern *debug-actor-info* debug-actor-info) +(define-extern *pid-string* string) +(define-extern debug-actor (function string none)) +(define-extern debug-actor-process (function process none)) +(define-extern draw-actor-marks (function process none)) (define-extern init-entity (function process entity-actor type none)) -;; (define-extern entity-deactivate-handler function) ;; (function process entity-actor none) -;; (define-extern check-for-rougue-process function) ;; (function process int int level none) -;; (define-extern process-drawable-scale-from-entity! function) ;; (function process-drawable entity none) +(define-extern entity-deactivate-handler (function process entity-actor none)) +(define-extern check-for-rougue-process (function process int int level none)) +(define-extern process-drawable-scale-from-entity! (function process-drawable entity none)) (define-extern process-drawable-from-entity! (function process-drawable entity-actor none)) (define-extern reset-actors (function symbol none)) (define-extern reset-cameras (function none)) (define-extern entity-birth-no-kill (function entity process)) -;; (define-extern entity-task-complete-on function) ;; (function entity none) -;; (define-extern entity-task-complete-off function) ;; (function entity none) +(define-extern entity-task-complete-on (function entity none)) +(define-extern entity-task-complete-off (function entity none)) (define-extern process-entity-status! (function process entity-perm-status symbol entity-perm-status)) (define-extern find-nearest-entity (function vector type entity)) -;; (define-extern entity-speed-test function) ;; (function string entity) -;; (define-extern dump-entity-remap function) ;; (function object object none) +(define-extern entity-speed-test (function string entity)) +(define-extern dump-entity-remap (function object object none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; path ;; diff --git a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc index ae237c6fc6..439c1a70a9 100644 --- a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc @@ -166,5 +166,15 @@ [8, "(function string object :behavior process)"], [12, "(function object :behavior target)"] ], - "gun-yellow-shot": [[59, "(function handle object :behavior process)"]] + "gun-yellow-shot": [[59, "(function handle object :behavior process)"]], + "gun-dark-shot": [ + [25, "(function collide-shape-prim none :behavior gravity-spinner)"], + [34, "(function handle float object :behavior process)"] + ], + "entity": [ + [11, "(function process object)"], + [16, "(function process object)"], + [57, "(function process object)"], + [61, "(function process object)"] + ] } diff --git a/decompiler/config/jak3/ntsc_v1/art_info.jsonc b/decompiler/config/jak3/ntsc_v1/art_info.jsonc index fdf43f798c..32ea05d4f1 100644 --- a/decompiler/config/jak3/ntsc_v1/art_info.jsonc +++ b/decompiler/config/jak3/ntsc_v1/art_info.jsonc @@ -14,7 +14,8 @@ "wings": "jakb-ag", "lightjak-shield": "jakb-ag", "freeze-screen": "collectables-ag", - "red-3-sphere": "gun-ag" + "red-3-sphere": "gun-ag", + "gun-dark-3-sphere": "gun-ag" }, // remap names for types in an entire file (higher priority) diff --git a/decompiler/config/jak3/ntsc_v1/hacks.jsonc b/decompiler/config/jak3/ntsc_v1/hacks.jsonc index 08f475d883..3e1c230851 100644 --- a/decompiler/config/jak3/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak3/ntsc_v1/hacks.jsonc @@ -114,7 +114,6 @@ "(method 33 rub-tower)", "(method 261 crimson-guard)", "(anon-function 25 volcanox-obs)", - "find-nearest-entity", "foreground-draw-hud" ], @@ -354,7 +353,9 @@ "(method 11 rigid-body-queue)": [0, 6, 7, 9], "(method 10 rigid-body-queue)": [10, 34, 37], "(method 9 los-control)": [0, 43], - "load-game-text-info": [19, 20, 21] + "load-game-text-info": [19, 20, 21], + "draw-actor-marks": [8], + "find-nearest-entity": [7, 9] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak3/ntsc_v1/label_types.jsonc b/decompiler/config/jak3/ntsc_v1/label_types.jsonc index a8b03e710f..e4429118a4 100644 --- a/decompiler/config/jak3/ntsc_v1/label_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/label_types.jsonc @@ -457,5 +457,38 @@ ["L443", "uint64", true], ["L405", "attack-info"], ["L450", "uint64", true] - ] + ], + "gun-dark-shot": [ + ["L824", "uint64", true], + ["L827", "uint64", true], + ["L823", "uint64", true], + ["L826", "uint64", true], + ["L828", "uint64", true], + ["L829", "uint64", true], + ["L825", "uint64", true], + ["L830", "uint64", true], + ["L707", "uint64", true], + ["L704", "uint64", true], + ["L702", "uint64", true], + ["L701", "uint64", true], + ["L700", "uint64", true], + ["L710", "uint64", true], + ["L648", "attack-info"], + ["L647", "attack-info"], + ["L638", "attack-info"], + ["L637", "attack-info"], + ["L639", "attack-info"], + ["L708", "uint64", true], + ["L643", "attack-info"], + ["L644", "attack-info"], + ["L712", "uint64", true], + ["L711", "uint64", true], + ["L709", "uint64", true], + ["L664", "attack-info"], + ["L703", "uint64", true], + ["L699", "uint64", true], + ["L705", "uint64", true], + ["L706", "uint64", true] + ], + "gun-part": [["L537", "(pointer rgba)", 36]] } diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index 2a3e23d49f..0362dce58e 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -487,7 +487,12 @@ [16, "vector"], [1584, "collide-query"] ], - "(method 19 gun-red-2-shockwave)": [[16, "collide-query"]], + "(method 19 gun-red-2-shockwave)": [ + [16, "collide-query"], + [576, "vector"], + [624, "vector"], + [592, "vector"] + ], "(method 23 gun-red-2-shockwave)": [[32, "vector"]], "(method 24 gun-red-2-shockwave)": [[16, "vector"]], "gun-fire-red-2": [[16, "gun-red-2-shockwave-init-params"]], @@ -497,5 +502,48 @@ [128, "vector"], [1696, "vector"] ], - "(method 26 gun-red-shot)": [[16, "bounding-box"]] + "(method 26 gun-red-shot)": [[16, "bounding-box"]], + "gun-dark-reaction": [[112, "vector"]], + "gun-fire-red-1": [ + [16, "vector"], + [32, "event-message-block"], + [112, "vector"] + ], + "(trans expand gun-gravity)": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [80, "collide-query"], + [624, "matrix"] + ], + "gun-fire-dark-3": [[16, "projectile-init-by-other-params"]], + "(trans moving gun-dark-shot)": [[16, "vector"]], + "(enter impact gun-dark-shot)": [ + [192, ["array", "collide-shape", 384]], + [96, "vector"] + ], + "gravity-spinner-init-by-other": [[32, "vector"]], + "(code zero-g gravity-spinner)": [[112, "vector"]], + "(method 25 gun-dark-3-nuke)": [[16, "matrix"]], + "(code impact-dud gun-dark-3-nuke)": [[16, "explosion-init-params"]], + "(method 54 gun-dark-3-nuke)": [ + [32, ["array", "collide-shape", 384]], + [16, "vector"] + ], + "(trans impact gun-dark-3-nuke)": [ + [96, "gun-dark-3-sphere-init-params"], + [128, "gun-dark-3-sphere-init-params"] + ], + "(method 19 gravity-spinner)": [ + [176, ["array", "collide-shape", 384]], + [128, "vector"], + [112, "vector"], + [1712, "vector"], + [2288, "vector"] + ], + "(method 16 gravity-spinner)": [[32, "vector"]], + "(method 22 gun-gravity)": [ + [112, ["array", "collide-shape", 384]], + [16, "vector"] + ] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 5165d095ac..d360fc1a3b 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -3090,7 +3090,10 @@ [707, "v0", "sound-rpc-set-param"], [586, "v0", "sound-rpc-set-param"] ], - "(trans play-anim scene-player)": [[66, "a0", "process-drawable"]], + "(trans play-anim scene-player)": [ + [71, "v1", "process-drawable"], + [78, "v1", "process-drawable"] + ], "(event play-anim scene-player)": [ [11, "t9", "(function scene-player none)"] ], @@ -3379,8 +3382,8 @@ [20, "a0", "process-focusable"] ], "scene-player-init": [ - [44, "a0", "(array scene)"], - [37, "s5", "(array scene)"] + [[37, 44], "s5", "(array scene)"], + [83, "v0", "(array scene)"] ], "(method 34 process-taskable)": [ [58, "v0", "joint"], @@ -3486,12 +3489,15 @@ [52, "v1", "collide-shape-prim"], [62, "s2", "gun-yellow-shot-2"], [58, "v1", "gun-yellow-shot-2"], - [68, "s2", "gun-yellow-shot-2"] + [68, "s2", "gun-yellow-shot-2"], + [[9, 66], "s3", "handle"] ], "gun-yellow-shot-do-deflect": [ [134, "s1", "process-focusable"], [178, "s1", "process-focusable"], - ["_stack_", 136, "handle"] + ["_stack_", 136, "handle"], + ["_stack_", 1716, "float"], + ["_stack_", 1748, "float"] ], "gun-fire-yellow-1": [[33, "v0", "process"]], "gun-fire-yellow-2": [[33, "v0", "process"]], @@ -3523,7 +3529,11 @@ [59, "a0", "process-focusable"], [63, "a0", "process-focusable"], [82, "a0", "process-focusable"], - [85, "a0", "process-focusable"] + [85, "a0", "process-focusable"], + ["_stack_", 1688, "float"], + ["_stack_", 1692, "float"], + ["_stack_", 1752, "float"], + ["_stack_", 1756, "float"] ], "(method 47 gun-red-3-grenade)": [ [53, "s1", "process-focusable"], @@ -3541,18 +3551,15 @@ [246, "s1", "process-focusable"], [436, "gp", "process-focusable"], [440, "a0", "process-focusable"], - ["_stack_", 28, "float"] + ["_stack_", 28, "float"], + [168, "gp", "process-focusable"], + [314, "s1", "process-focusable"] ], "gun-fire-red-1": [ [147, "v1", "manipy"], [191, "v1", "manipy"], - [194, "v1", "manipy"] - // decompiler hang - // [ - // 197, - // "v1", - // "manipy" - // ] + [194, "v1", "manipy"], + [197, "v1", "manipy"] ], "(method 23 gun-red-shot)": [[10, "s4", "process-focusable"]], "(method 26 gun-red-shot)": [ @@ -3561,5 +3568,250 @@ [92, "a0", "connection"], [93, "a0", "collide-shape"] ], - "(trans charging gun-red-2-shockwave)": [[6, "a1", "process-drawable"]] + "(trans charging gun-red-2-shockwave)": [[6, "a1", "process-drawable"]], + "gun-fire-dark-1": [[38, "v0", "process"]], + "(event active gun-dark-3-sphere)": [ + [[3, 35], "v1", "gun-dark-3-sphere-init-params"] + ], + "gun-fire-dark-3": [[64, "v0", "process"]], + "(exit startup gun-dark-shot)": [[20, "v0", "sound-rpc-set-param"]], + "(code startup gun-dark-shot)": [[88, "a1", "process-focusable"]], + "(enter moving gun-dark-shot)": [[22, "a1", "process-focusable"]], + "(trans moving gun-dark-shot)": [ + [27, "s2", "process-focusable"], + [39, "a0", "process-focusable"], + [42, "a0", "process-focusable"] + ], + "(enter impact gun-dark-shot)": [ + [245, "s1", "process-focusable"], + [256, "s1", "process-focusable"], + [262, "s1", "process-focusable"], + [201, "v0", "(array float)"] + ], + "(method 20 gravity-spinner)": [ + [19, "s5", "process-focusable"], + [63, "s5", "process-focusable"] + ], + "(method 21 gravity-spinner)": [ + [19, "s5", "process-focusable"], + [26, "s5", "process-focusable"] + ], + "(anon-function 34 gun-dark-shot)": [ + [134, "s5", "process-focusable"], + [137, "s5", "process-focusable"], + [141, "s5", "process-focusable"], + [144, "s5", "process-focusable"], + [162, "s5", "process-focusable"], + [167, "s5", "process-focusable"], + [170, "s5", "process-focusable"] + ], + "gravity-spinner-init-by-other": [ + [33, "gp", "process-focusable"], + [39, "gp", "process-focusable"], + [47, "gp", "process-focusable"], + [54, "gp", "process-focusable"], + [69, "gp", "process-focusable"], + [73, "gp", "process-focusable"], + [77, "gp", "process-focusable"], + [94, "gp", "process-focusable"], + [100, "gp", "process-focusable"], + [113, "gp", "process-focusable"], + [144, "v1", "float"], + [182, "v1", "float"] + ], + "(code zero-g gravity-spinner)": [ + [71, "gp", "process-focusable"], + [100, "gp", "process-focusable"], + [104, "gp", "process-focusable"], + [137, "gp", "process-focusable"], + [144, "gp", "process-focusable"], + [165, "gp", "process-focusable"], + [174, "v1", "collide-shape-moving"], + [262, "gp", "process-focusable"], + [270, "gp", "process-focusable"], + [285, "gp", "process-focusable"], + [176, "v1", "collide-shape-moving"] + ], + "(enter zero-g gravity-spinner)": [[17, "v1", "float"]], + "(event zero-g gravity-spinner)": [ + [105, "a0", "attack-info"], + [109, "v1", "attack-info"], + [168, "s4", "process-drawable"], + [170, "s4", "process-drawable"], + [182, "s4", "process-drawable"], + [184, "s4", "process-drawable"], + [177, "s4", "process-drawable"], + ["_stack_", 36, "float"] + ], + "zero-g-wait-for-land": [ + [22, "s5", "process-focusable"], + [26, "s5", "process-focusable"], + [33, "s5", "process-focusable"], + [42, "s5", "process-focusable"], + [52, "s5", "process-focusable"], + [53, "a0", "collide-shape-moving"], + [61, "s5", "process-focusable"], + [72, "s5", "process-focusable"], + [84, "s5", "process-focusable"], + [99, "s5", "process-focusable"], + [108, "s5", "process-focusable"] + ], + "(enter zero-g-vehicle gravity-spinner)": [[17, "v1", "float"]], + "(enter launch-0 gun-dark-3-nuke)": [[15, "t9", "(function none)"]], + "(enter launch-1 gun-dark-3-nuke)": [[12, "t9", "(function none)"]], + "(enter launch-2 gun-dark-3-nuke)": [[18, "t9", "(function none)"]], + "(code impact-dud gun-dark-3-nuke)": [[39, "a0", "process"]], + "(method 54 gun-dark-3-nuke)": [[47, "s1", "process-focusable"]], + "(method 22 gravity-spinner)": [ + [18, "s3", "process-focusable"], + [24, "s3", "process-focusable"], + [29, "s3", "process-focusable"] + ], + "(method 23 gravity-spinner)": [ + [25, "gp", "process-focusable"], + [29, "gp", "process-focusable"], + [35, "gp", "process-focusable"], + [44, "gp", "process-focusable"] + ], + "(method 19 gravity-spinner)": [ + [40, "s5", "process-focusable"], + [68, "s5", "process-focusable"], + [377, "s5", "process-focusable"], + [435, "s5", "process-focusable"], + [113, "a0", "process-focusable"], + [124, "a0", "process-focusable"], + [131, "a0", "process-focusable"], + [134, "a0", "process-focusable"], + [200, "s5", "process-focusable"], + ["_stack_", 148, "process"], + ["_stack_", 156, "float"], + ["_stack_", 160, "float"], + ["_stack_", 172, "float"], + ["_stack_", 1736, "float"], + ["_stack_", 2312, "float"] + ], + "(method 16 gravity-spinner)": [ + [22, "s4", "process-focusable"], + [43, "s4", "process-focusable"] + ], + "(method 17 gravity-spinner)": [ + [101, "s4", "process-focusable"], + [127, "s4", "process-focusable"], + [149, "s4", "process-focusable"] + ], + "(method 24 gravity-spinner)": [ + [19, "s5", "process-focusable"], + [26, "s5", "process-focusable"], + [42, "s5", "process-focusable"], + [47, "s5", "process-focusable"], + [52, "s5", "process-focusable"], + [55, "s5", "process-focusable"], + [66, "s5", "process-focusable"], + [59, "s5", "process-focusable"], + [61, "s5", "process-focusable"] + ], + "(trans expand gun-gravity)": [ + [116, "v1", "float"], + [149, "v1", "float"] + ], + "(method 22 gun-gravity)": [ + [14, "v0", "process"], + [35, "v1", "gravity-ring"], + [36, "v1", "gravity-ring"], + [[51, 53], "v1", "gravity-ring"], + [101, "s1", "process-focusable"], + [113, "s1", "process-focusable"] + ], + "process-drawable-shock-effect-bullseye": [[85, "a0", "lightning-tracker"]], + "(method 14 level-group)": [ + [62, "a0", "entity-actor"], + [66, "a0", "entity-actor"] + ], + "(method 23 level-group)": [[28, "v0", "(inline-array vector)"]], + "expand-bounding-box-from-nav-meshes": [["_stack_", 16, "res-tag"]], + "expand-vis-box-with-point": [[10, "v0", "(inline-array vector)"]], + "(method 25 level-group)": [ + [24, "s3", "entity-actor"], + [112, "s3", "entity-actor"], + [120, "s3", "entity-actor"], + [143, "v0", "string"], + [56, "v0", "string"], + [99, "v0", "(inline-array vector)"] + ], + "process-drawable-scale-from-entity!": [[11, "v0", "vector"]], + "reset-actors": [ + [174, "t9", "(function level none)"], + [162, "v0", "(function level none)"] + ], + "process-status-bits": [[8, "s5", "process-drawable"]], + "(method 24 level-group)": [ + [127, "v0", "(pointer actor-group)"], + [28, "v0", "(inline-array vector)"], + ["_stack_", 28, "float"], + ["_stack_", 32, "float"] + ], + "(method 15 level-group)": [ + [262, "s0", "process-drawable"], + [268, "s0", "process-drawable"], + [275, "s0", "process-drawable"], + [277, "s0", "process-drawable"], + [308, "s4", "process-drawable"], + [663, "a0", "drawable-region-prim"], + [666, "a0", "drawable-region-prim"], + [726, "a0", "drawable-region-prim"], + [729, "a0", "drawable-region-prim"] + ], + "check-for-rougue-process": [ + [133, "gp", "part-tracker"], + [157, "gp", "part-spawner"], + [184, "v1", "process-drawable"], + [187, "v1", "process-drawable"], + [192, "v1", "process-drawable"], + [199, "v1", "process-drawable"], + [209, "v1", "process-drawable"], + [212, "v1", "process-drawable"], + [217, "v1", "process-drawable"], + [224, "v1", "process-drawable"] + ], + "draw-actor-marks": [ + [20, "gp", "process-drawable"], + [29, "gp", "process-drawable"], + [33, "gp", "process-drawable"], + [40, "gp", "process-drawable"], + [45, "gp", "process-drawable"], + [47, "gp", "process-drawable"], + [52, "gp", "process-drawable"], + [54, "gp", "process-drawable"], + [59, "gp", "process-drawable"], + [67, "gp", "process-drawable"], + [69, "gp", "process-drawable"], + [78, "gp", "process-drawable"], + [106, "gp", "process-drawable"], + [105, "v0", "string"], + [131, "v0", "(pointer int32)"], + [155, "gp", "process-drawable"], + [174, "v0", "string"], + [187, "gp", "process-drawable"], + [271, "gp", "process-drawable"], + [250, "gp", "process-drawable"], + [208, "v0", "(inline-array vector)"], + [120, "a2", "string"] + ], + "(anon-function 57 entity)": [ + [6, "gp", "process-drawable"], + [8, "gp", "process-drawable"], + [13, "gp", "process-drawable"], + [15, "gp", "process-drawable"] + ], + "draw-subtitle-image": [ + [[163, 194], "v1", "(pointer uint128)"], + [[195, 199], "t0", "vector4w"], + [[199, 206], "t0", "vector4w"], + [[206, 213], "a2", "vector4w"], + [[214, 220], "v1", "vector4w"], + [[223, 254], "v1", "(pointer uint128)"], + [[255, 266], "t0", "vector4w"], + [[266, 273], "a1", "vector4w"], + [[274, 280], "v1", "vector4w"] + ] } diff --git a/decompiler/config/jak3/ntsc_v1/var_names.jsonc b/decompiler/config/jak3/ntsc_v1/var_names.jsonc index 7a835aa40d..94d448f194 100644 --- a/decompiler/config/jak3/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jak3/ntsc_v1/var_names.jsonc @@ -1968,5 +1968,20 @@ "s4-0": "i", "v1-7": "debris" } + }, + "(enter burnt-husk gun-yellow-3-saucer)": { + "vars": { + "s5-0": ["name", "sound-name"] + } + }, + "reset-actors": { + "vars": { + "s5-0": ["perm", "entity-perm-status"] + } + }, + "(method 24 level-group)": { + "vars": { + "a0-9": ["enemy-option", "enemy-option"] + } } } diff --git a/goal_src/jak3/engine/camera/cam-debug.gc b/goal_src/jak3/engine/camera/cam-debug.gc index 3e51950026..d78bd4f336 100644 --- a/goal_src/jak3/engine/camera/cam-debug.gc +++ b/goal_src/jak3/engine/camera/cam-debug.gc @@ -5,5 +5,7 @@ ;; name in dgo: cam-debug ;; dgos: GAME +(define-extern camera-plot-float-func (function float float float float (function float float) vector4w none)) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/collide/collide-shape-h.gc b/goal_src/jak3/engine/collide/collide-shape-h.gc index 67e8ae9156..742b96a06a 100644 --- a/goal_src/jak3/engine/collide/collide-shape-h.gc +++ b/goal_src/jak3/engine/collide/collide-shape-h.gc @@ -341,7 +341,7 @@ Most [[process-drawable]]s have a [[collide-shape]] that represents their root t (send-shoves (_type_ process touching-shapes-entry float float float) symbol) (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) (water-info-init! (_type_ water-info collide-action) water-info) - (collide-shape-method-53 () none) + (iterate-prims (_type_ (function collide-shape-prim none)) none) (collide-shape-method-54 () none) ) ) diff --git a/goal_src/jak3/engine/common-obs/curves.gc b/goal_src/jak3/engine/common-obs/curves.gc index f1dd334b23..bf11617009 100644 --- a/goal_src/jak3/engine/common-obs/curves.gc +++ b/goal_src/jak3/engine/common-obs/curves.gc @@ -60,7 +60,7 @@ (default-loop-behavior uint64) ) (:methods - (curve2d-piecewise-method-10 (_type_ int symbol uint) none) + (curve2d-piecewise-method-10 (_type_ int symbol int) none) (curve2d-piecewise-method-11 (_type_) none) ) ) @@ -115,7 +115,7 @@ ) -(defmethod curve2d-piecewise-method-10 ((this curve2d-piecewise) (arg0 int) (arg1 symbol) (arg2 uint)) +(defmethod curve2d-piecewise-method-10 ((this curve2d-piecewise) (arg0 int) (arg1 symbol) (arg2 int)) (set! (-> this pts) ((method-of-type float-pair-array new) arg1 float-pair-array arg0)) (set! (-> this default-loop-behavior) (the-as uint (if arg2 0 @@ -456,7 +456,7 @@ (when (or (zero? *curve-linear-up-hold*) (!= loading-level global)) (set! *curve-linear-up-hold* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *curve-linear-up-hold* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *curve-linear-up-hold* 2 'loading-level (the-as int #f)) ) (set! (-> *curve-linear-up-hold* pts data 0 first) 0.0) diff --git a/goal_src/jak3/engine/common-obs/generic-obs.gc b/goal_src/jak3/engine/common-obs/generic-obs.gc index 470db43315..cbfdd7187e 100644 --- a/goal_src/jak3/engine/common-obs/generic-obs.gc +++ b/goal_src/jak3/engine/common-obs/generic-obs.gc @@ -1696,7 +1696,7 @@ ) ) ) - (set! (-> self sound) (sound-play-by-spec (the-as sound-spec gp-1) (new-sound-id) s5-1)) + (set! (-> self sound) (sound-play-by-spec gp-1 (new-sound-id) s5-1)) ) ) ) diff --git a/goal_src/jak3/engine/common-obs/water.gc b/goal_src/jak3/engine/common-obs/water.gc index 72178afb8b..18a8ef47eb 100644 --- a/goal_src/jak3/engine/common-obs/water.gc +++ b/goal_src/jak3/engine/common-obs/water.gc @@ -67,7 +67,7 @@ (when (or (zero? *water-simple-alpha-curve-in*) (!= loading-level global)) (set! *water-simple-alpha-curve-in* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *water-simple-alpha-curve-in* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *water-simple-alpha-curve-in* 2 'loading-level (the-as int #f)) ) (set! (-> *water-simple-alpha-curve-in* pts data 0 first) 0.0) @@ -80,7 +80,7 @@ (when (or (zero? *growing-curve*) (!= loading-level global)) (set! *growing-curve* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *growing-curve* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *growing-curve* 2 'loading-level (the-as int #f)) ) (set! (-> *growing-curve* pts data 0 first) 0.0) @@ -93,7 +93,7 @@ (when (or (zero? *water-simple-alpha-curve-fade-out*) (!= loading-level global)) (set! *water-simple-alpha-curve-fade-out* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *water-simple-alpha-curve-fade-out* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *water-simple-alpha-curve-fade-out* 2 'loading-level (the-as int #f)) ) (set! (-> *water-simple-alpha-curve-fade-out* pts data 0 first) 0.0) diff --git a/goal_src/jak3/engine/entity/entity-h.gc b/goal_src/jak3/engine/entity/entity-h.gc index 580d58a592..3a70056ca8 100644 --- a/goal_src/jak3/engine/entity/entity-h.gc +++ b/goal_src/jak3/engine/entity/entity-h.gc @@ -40,6 +40,7 @@ (define-extern init-entity (function process entity-actor type none)) (define-extern entity-by-type (function type entity-actor)) (define-extern entity-actor-from-level-name (function symbol entity-actor)) +(define-extern birth-viewer (function process entity-actor object)) (define-extern *spawn-actors* symbol) @@ -91,7 +92,7 @@ (task game-task :overlay-at (-> perm task)) ) (:methods - (entity-links-method-9 () none) + (birth? (_type_ vector) symbol) ) ) diff --git a/goal_src/jak3/engine/entity/entity-table.gc b/goal_src/jak3/engine/entity/entity-table.gc index ae31d78fb8..b20bf31d02 100644 --- a/goal_src/jak3/engine/entity/entity-table.gc +++ b/goal_src/jak3/engine/entity/entity-table.gc @@ -7,3 +7,308 @@ ;; DECOMP BEGINS +;; TODO stub +(define *entity-info* (new 'static 'boxed-array :type entity-info + (new 'static 'entity-info + :ptype (type-ref factory-boss :method-count 31) + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype (type-ref flitter-spawner :method-count 22) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref bubbles-path :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x8000 + ) + (new 'static 'entity-info + :ptype (type-ref desert-chase-ring :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref bt-grunt :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref bt-roboguard :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref w-parking-spot :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref min-elevator :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref tpl-bouncer :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref veger-npc :method-count 40) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref seem-npc :method-count 40) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref krimson-wall :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref kleever-catch-lizards :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref kleever-npc :method-count 40) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref damus-npc :method-count 40) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref nav-graph :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref tizard :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref ladder :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mh-centipede :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref dark-tower :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref curve-bubbles-Shape :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-tower-door :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-grunt-egg-d :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-grunt-egg-c :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref a :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-grunt-egg-b :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-grund-egg-a :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-de-tower-undervines :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-vine-wriggler-big :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-vine-wriggler :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-twitch-blade :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-claw-finger-small :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-vein-writhing-small :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-vein-writhing-large :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-dark-eco-nodule :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-dark-eco-door :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-puffer-large :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref mhcity-puffer :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref a :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref searchlight :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref ctyn-lamp :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref burning-bush :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref sail-boat-a :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref barge :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref boat-manager :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref propa :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref city-window-a :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref cty-window-a :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref parking-spot :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref security-wall :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref cty-guard-turret :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref cty-fruit-stand :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref fruit-stand :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref torn :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + (new 'static 'entity-info + :ptype (type-ref neon-baron :method-count 0) + :pool '*16k-dead-pool* + :heap-size #x4000 + ) + ) + ) + +(defun entity-info-lookup ((arg0 type)) + (the-as entity-info (cond + ((nonzero? (-> arg0 method-table 13)) + (-> arg0 method-table 13) + ) + (else + (let ((v1-1 *entity-info*)) + (dotimes (a1-0 (-> v1-1 length)) + (let ((a2-3 (-> v1-1 a1-0 ptype))) + (when (if (logtest? (the-as int a2-3) 1) + (= (-> arg0 symbol) a2-3) + (= arg0 a2-3) + ) + (set! (-> arg0 method-table 13) (the-as function (-> v1-1 a1-0))) + (return (the-as entity-info (-> v1-1 a1-0))) + ) + ) + ) + ) + (set! (-> arg0 method-table 13) #f) + (the-as basic #f) + ) + ) + ) + ) \ No newline at end of file diff --git a/goal_src/jak3/engine/entity/entity.gc b/goal_src/jak3/engine/entity/entity.gc index dfd3d69007..a8f963c3b7 100644 --- a/goal_src/jak3/engine/entity/entity.gc +++ b/goal_src/jak3/engine/entity/entity.gc @@ -7,3 +7,2551 @@ ;; DECOMP BEGINS +(define *spawn-actors* #t) + +(define *compact-actors* #t) + +(define *vis-actors* #t) + +;; WARN: Return type mismatch int vs drawable-actor. +(defmethod mem-usage ((this drawable-actor) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 45 (-> usage length))) + (set! (-> usage data 44 name) "entity") + (+! (-> usage data 44 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 44 used) v1-6) + (+! (-> usage data 44 total) (logand -16 (+ v1-6 15))) + ) + (mem-usage (-> this actor) usage (logior flags 64)) + (the-as drawable-actor 0) + ) + +;; WARN: Return type mismatch int vs drawable-inline-array-actor. +(defmethod mem-usage ((this drawable-inline-array-actor) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-5 32)) + (+! (-> usage data 0 used) v1-5) + (+! (-> usage data 0 total) (logand -16 (+ v1-5 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this data s3-0) usage flags) + ) + (the-as drawable-inline-array-actor 0) + ) + +(defmethod print ((this entity-links)) + (format #t "#" (-> this process) this) + this + ) + +(defmethod print ((this entity-perm)) + (format + #t + "#" + (-> this aid) + (-> this task) + (-> this status) + (-> this user-uint64) + this + ) + this + ) + +(defmethod print ((this actor-group)) + (format #t "# this length)) + (format #t " ~A" (-> this data s5-0 actor)) + ) + (format #t " @ #x~X>" this) + this + ) + + +(defmethod birth! ((this entity)) + (format #t "birth ~A~%" this) + this + ) + +(defmethod kill! ((this entity)) + (format #t "kill ~A~%" this) + this + ) + +(defmethod print ((this entity)) + (format #t "#<~A :name ~S @ #x~X>" (-> this type) (res-lump-struct this 'name structure) this) + this + ) + +(defmethod get-level ((this entity)) + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (if (and (>= (the-as int this) (the-as int (-> a1-3 heap base))) + (< (the-as int this) (the-as int (-> a1-3 heap top-base))) + ) + (return a1-3) + ) + ) + ) + ) + (-> *level* level-default) + ) + +(defun entity-by-name ((arg0 string)) + (if (not arg0) + (return (the-as entity #f)) + ) + (dotimes (s5-0 (-> *level* length)) + (let ((s4-0 (-> *level* level s5-0))) + (when (= (-> s4-0 status) 'active) + (let ((s3-0 (-> s4-0 bsp actors))) + (when (nonzero? s3-0) + (dotimes (s2-0 (-> s3-0 length)) + (let ((s1-0 (-> s3-0 data s2-0 actor))) + (if (string= (res-lump-struct s1-0 'name string) arg0) + (return s1-0) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s4-0 bsp nav-meshes))) + (when (nonzero? s3-1) + (dotimes (s2-1 (-> s3-1 length)) + (let ((s1-1 (-> s3-1 s2-1))) + (if (string= (res-lump-struct s1-1 'name string) arg0) + (return s1-1) + ) + ) + ) + ) + ) + (let ((s3-2 (-> s4-0 bsp race-meshes))) + (when (nonzero? s3-2) + (dotimes (s2-2 (-> s3-2 length)) + (let ((s1-2 (-> s3-2 s2-2))) + (if (string= (res-lump-struct s1-2 'name string) arg0) + (return s1-2) + ) + ) + ) + ) + ) + (let ((s4-1 (-> s4-0 bsp cameras))) + (when (nonzero? s4-1) + (dotimes (s3-3 (-> s4-1 length)) + (let ((s2-3 (-> s4-1 s3-3))) + (if (string= (res-lump-struct s2-3 'name string) arg0) + (return s2-3) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity #f) + ) + +(defun entity-by-type ((arg0 type)) + (dotimes (s5-0 (-> *level* length)) + (let ((v1-3 (-> *level* level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp actors))) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 actor))) + (if (and (type? s2-0 entity-actor) (= (-> s2-0 etype) arg0)) + (return s2-0) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-actor #f) + ) + +(defun entity-by-aid ((arg0 uint)) + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (let ((a1-4 (-> a1-3 entity))) + (when (nonzero? a1-4) + (let ((a2-4 0) + (a3-2 (+ (-> a1-4 length) -1)) + ) + 0 + (while (>= a3-2 a2-4) + (let* ((t0-3 (+ a2-4 (/ (- a3-2 a2-4) 2))) + (t1-2 (-> a1-4 data t0-3)) + (t2-0 (-> t1-2 perm aid)) + ) + (cond + ((= t2-0 arg0) + (return (-> t1-2 entity)) + ) + ((< (the-as uint t2-0) arg0) + (set! a2-4 (+ t0-3 1)) + ) + (else + (set! a3-2 (+ t0-3 -1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity #f) + ) + +;; WARN: Return type mismatch entity vs entity-actor. +(defun entity-actor-from-level-name ((arg0 symbol)) + (let ((v0-0 (the-as entity #f))) + (dotimes (s5-0 (-> *level* length)) + (let ((s4-0 (-> *level* level s5-0))) + (when (= (-> s4-0 status) 'active) + (when (= (-> s4-0 name) arg0) + (when (zero? (-> s4-0 entity length)) + (format 0 "ERROR: level ~s has no entities!!" (-> s4-0 name)) + (when *debug-segment* + (break!) + 0 + ) + ) + (set! v0-0 (-> s4-0 entity data 0 entity)) + ) + ) + ) + ) + (the-as entity-actor v0-0) + ) + ) + +(defmethod update-nav-meshes-method ((this level-group)) + (when (not (paused?)) + (dotimes (s5-0 (-> this length)) + (let ((v1-4 (-> this level s5-0))) + (when (= (-> v1-4 status) 'active) + (let ((s4-0 (-> v1-4 bsp nav-meshes))) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> s4-0 length)) + ((method-of-object (-> s4-0 s3-0 nav-mesh) nav-mesh-method-28)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun entity-nav-mesh-by-aid ((arg0 actor-id)) + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (let ((a1-5 (-> a1-3 bsp nav-meshes))) + (when (nonzero? a1-5) + (let ((a2-4 0) + (a3-2 (+ (-> a1-5 length) -1)) + ) + 0 + (while (>= a3-2 a2-4) + (let* ((t0-3 (+ a2-4 (/ (- a3-2 a2-4) 2))) + (t1-2 (-> a1-5 t0-3)) + (t2-0 (-> t1-2 aid)) + ) + (cond + ((= t2-0 arg0) + (return t1-2) + ) + ((< t2-0 (the-as uint arg0)) + (set! a2-4 (+ t0-3 1)) + ) + (else + (set! a3-2 (+ t0-3 -1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-nav-mesh #f) + ) + +(defun nav-mesh-from-res-tag ((arg0 entity) (arg1 symbol) (arg2 int)) + (let ((v1-1 (res-lump-data arg0 arg1 pointer)) + (gp-0 (the-as nav-mesh #f)) + ) + (when v1-1 + (let* ((s5-1 (entity-nav-mesh-by-aid (the-as actor-id (-> (the-as (pointer uint32) (&+ v1-1 (* arg2 4))))))) + (v1-3 (if (type? s5-1 entity-nav-mesh) + s5-1 + ) + ) + ) + (if v1-3 + (set! gp-0 (-> v1-3 nav-mesh)) + ) + ) + ) + gp-0 + ) + ) + +(defun entity-by-meters ((arg0 float) (arg1 float) (arg2 float)) + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-5 (-> a3-3 bsp actors))) + (when (nonzero? a3-5) + (dotimes (t0-4 (-> a3-5 length)) + (let* ((t1-3 (-> a3-5 data t0-4 actor)) + (t2-1 (-> t1-3 extra trans)) + ) + (if (and (= (the float (the int (-> t2-1 x))) arg0) + (= (the float (the int (-> t2-1 y))) arg1) + (= (the float (the int (-> t2-1 z))) arg2) + ) + (return t1-3) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-actor #f) + ) + +(defun process-by-ename ((arg0 string)) + (let ((v1-0 (entity-by-name arg0))) + (if v1-0 + (-> v1-0 extra process) + ) + ) + ) + +(defun entity-process-count ((arg0 symbol)) + (let ((gp-0 0)) + (dotimes (s4-0 (-> *level* length)) + (let ((s3-0 (-> *level* level s4-0))) + (when (= (-> s3-0 status) 'active) + (let ((s2-0 (-> s3-0 bsp level entity))) + (dotimes (s1-0 (-> s2-0 length)) + (let ((v1-9 (-> s2-0 data s1-0 entity))) + (case arg0 + (('vis) + (if (is-object-visible? s3-0 (-> v1-9 extra vis-id)) + (+! gp-0 1) + ) + ) + (else + (if (-> v1-9 extra process) + (+! gp-0 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +(defun entity-count () + (let ((v0-0 0)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-3 (-> *level* level v1-0))) + (when (= (-> a0-3 status) 'active) + (let ((a0-6 (-> a0-3 bsp level entity))) + (dotimes (a1-3 (-> a0-6 length)) + (-> a0-6 data a1-3 entity) + (+! v0-0 1) + ) + ) + ) + ) + ) + v0-0 + ) + ) + +(defun entity-remap-names ((arg0 pair)) + (let ((s5-0 (car arg0))) + (while (not (null? arg0)) + (let ((a0-2 (entity-by-meters + (the float (/ (the-as int (car (cdr s5-0))) 8)) + (the float (/ (the-as int (car (cdr (cdr s5-0)))) 8)) + (the float (/ (the-as int (car (cdr (cdr (cdr s5-0))))) 8)) + ) + ) + ) + (if a0-2 + (add-data! + a0-2 + (new 'static 'res-tag :name 'name :key-frame -1000000000.0 :elt-count #x1 :elt-type string) + (the-as pointer (car s5-0)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! s5-0 (car arg0)) + ) + ) + 0 + (none) + ) + +(defun-debug process-status-bits ((arg0 process) (arg1 symbol)) + (let* ((s5-0 arg0) + (s3-0 (if (type? s5-0 process-drawable) + (the-as process-drawable s5-0) + ) + ) + ) + (if (and s3-0 (zero? (-> s3-0 draw))) + (set! s3-0 (the-as process-drawable #f)) + ) + (let ((s5-1 format) + (s4-0 "~C~C~C") + (a2-0 (if (and arg0 (not (logtest? (-> *kernel-context* prevent-from-run) (-> arg0 mask))) (run-logic? arg0)) + 114 + 32 + ) + ) + (a3-0 (if (and s3-0 (logtest? (-> s3-0 draw status) (draw-control-status on-screen))) + 100 + 32 + ) + ) + (t0-0 (cond + ((and s3-0 (logtest? (-> s3-0 draw status) (draw-control-status on-screen))) + (let ((v1-14 (-> s3-0 draw cur-lod))) + (cond + ((zero? v1-14) + 48 + ) + ((= v1-14 1) + 49 + ) + ((= v1-14 2) + 50 + ) + ((= v1-14 3) + 51 + ) + ((= v1-14 4) + 52 + ) + ) + ) + ) + (else + 32 + ) + ) + ) + ) + (s5-1 arg1 s4-0 a2-0 a3-0 t0-0) + ) + ) + 0 + (none) + ) + +(defun process-entity-set! ((arg0 process) (arg1 entity)) + (set! (-> arg0 entity) (the-as entity-actor arg1)) + (if arg1 + (set! (-> arg0 level) (-> arg1 extra level)) + (set! (-> arg0 level) (-> *level* level-default)) + ) + arg1 + ) + +(defun process-task-mask ((arg0 process)) + (-> arg0 level task-mask) + ) + +(defmethod print ((this process)) + (cond + ((and (-> this top-thread) (!= (-> this status) 'dead)) + (format + #t + "#<~A ~S ~A :state ~S :flags " + (-> this type) + (-> this name) + (-> this status) + (if (-> this state) + (-> this state name) + ) + ) + (process-status-bits this #t) + (format + #t + " :stack ~D/~D :heap ~D/~D @ #x~X>" + (&- (-> this top-thread stack-top) (the-as uint (-> this top-thread sp))) + (-> this main-thread stack-size) + (- (-> this allocated-length) (&- (-> this heap-top) (the-as uint (-> this heap-cur)))) + (-> this allocated-length) + this + ) + ) + (else + (format + #t + "#<~A ~S ~A :state ~S @ #x~X" + (-> this type) + (-> this name) + (-> this status) + (if (-> this state) + (-> this state name) + ) + this + ) + ) + ) + this + ) + + + + +;; WARN: Return type mismatch entity-actor vs none. +(defmethod debug-print ((this entity-actor) (arg0 symbol) (arg1 type)) + (let ((s4-0 (-> this etype))) + (when (or (not arg1) (and s4-0 (valid? s4-0 type (the-as string #f) #f 0) (type-type? s4-0 arg1))) + (format #t "~5D #x~8X ~-26S" (-> this extra vis-id) this (res-lump-struct this 'name structure)) + (let ((t9-4 format) + (a0-5 #t) + (a1-5 "~8D ~3D ~-8S #x~4X") + (a2-4 (-> this extra perm aid)) + (a3-3 (-> this extra perm task)) + (t0-3 (-> this extra level nickname)) + ) + (set! t0-3 (cond + (t0-3 + (empty) + t0-3 + ) + (else + (-> this extra level name) + ) + ) + ) + (t9-4 a0-5 a1-5 a2-4 a3-3 t0-3 (-> this extra perm status)) + ) + (if (= arg0 'entity-meters) + (format #t " :trans ~14m ~14m ~14m " (-> this extra trans x) (-> this extra trans y) (-> this extra trans z)) + (format + #t + " :trans ~11,,1f ~11,,1f ~11,,1f " + (-> this extra trans x) + (-> this extra trans y) + (-> this extra trans z) + ) + ) + (let* ((s3-2 (-> this extra process)) + (s4-2 (if (type? s3-2 process-drawable) + s3-2 + ) + ) + ) + (format + #t + ":pr #x~8X ~-18S ~-5S/~-5S " + (if (-> this extra process) + (-> this extra process) + 0 + ) + (if (and (-> this extra process) (-> this extra process state)) + (-> this extra process state name) + "" + ) + (if (-> this extra process) + (* (- (-> this extra process allocated-length) + (&- (-> this extra process heap-top) (the-as uint (-> this extra process heap-cur))) + ) + 8 + ) + "" + ) + (if (-> this extra process) + (* (-> this extra process allocated-length) 8) + "" + ) + ) + (process-status-bits s4-2 #t) + ) + (format #t "~%") + (if (= arg0 'entity-perm) + (format #t " ~`entity-perm`P~%" (-> this extra perm)) + ) + ) + ) + (none) + ) + +(defmethod debug-print-entities ((this level-group) (arg0 symbol) (arg1 type) (arg2 string)) + (let ((t9-0 format) + (a0-1 #t) + (a1-1 + " id address name aid tsk lev status x y z address state heap flags~%" + ) + ) + 0 + 0 + 0 + (t9-0 a0-1 a1-1) + ) + (dotimes (s2-0 (-> this length)) + (let ((s1-0 (-> this level s2-0))) + (when (= (-> s1-0 status) 'active) + (when (or (not arg2) (= arg2 (-> s1-0 name))) + (case arg0 + (('art-group) + (format #t "level ~A~%" (-> s1-0 name)) + (dotimes (s0-0 (-> s1-0 art-group art-group-array length)) + (format #t "~T~2D ~S~%" s0-0 (-> s1-0 art-group art-group-array s0-0 name)) + ) + ) + (else + (let ((s1-1 (-> s1-0 bsp level entity))) + (dotimes (s0-1 (-> s1-1 length)) + (debug-print (the-as entity-actor (-> s1-1 data s0-1 entity)) arg0 arg1) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch entity-actor vs none. +(defmethod add-to-level! ((this entity-actor) (arg0 level-group) (arg1 level) (arg2 actor-id)) + (let ((v1-4 (-> arg1 entity data (-> arg1 entity length)))) + (+! (-> arg1 entity length) 1) + (set! (-> v1-4 process) #f) + (set! (-> v1-4 entity) this) + (set! (-> this extra) v1-4) + (cond + ((-> arg0 entity-link) + (let* ((a0-6 (-> arg0 entity-link)) + (t0-1 (-> a0-6 next-link)) + ) + (set! (-> a0-6 next-link) v1-4) + (set! (-> v1-4 prev-link) a0-6) + (set! (-> v1-4 next-link) t0-1) + (set! (-> t0-1 prev-link) v1-4) + ) + ) + (else + (set! (-> v1-4 prev-link) v1-4) + (set! (-> v1-4 next-link) v1-4) + ) + ) + (set! (-> arg0 entity-link) v1-4) + (set! (-> v1-4 trans quad) (-> this trans quad)) + ) + (set! (-> this extra perm aid) arg2) + (set! (-> this extra level) arg1) + (set! (-> this extra kill-mask) + (logior (logand (-> this kill-mask) + (task-mask + task0 + task1 + task2 + task3 + task4 + task5 + task6 + task7 + done + dummy0 + dummy1 + vehicle + special + primary0 + ctywide + never + ) + ) + (logclear + (task-mask movie0 movie1 movie2 tm19 tm20 tm21 tm22 tm23 tm24 tm25 tm26 tm27 tm28 tm29 tm30 tm31) + (-> this kill-mask) + ) + ) + ) + (if (not (-> arg1 vis-info 0)) + (set! (-> this extra vis-dist) (res-lump-float this 'vis-dist :default 40960000.0)) + ) + (cond + ((= (-> this type) entity-actor) + (set! (-> this extra perm task) (-> this task)) + (set! (-> this extra vis-id) (-> this vis-id)) + ) + (else + (set! (-> this extra perm task) (game-task none)) + (set! (-> this extra vis-id) 0) + 0 + ) + ) + (none) + ) + +(defmethod remove-from-level! ((this entity) (arg0 level-group)) + (let ((v1-0 (-> this extra))) + (cond + ((= (-> v1-0 next-link) v1-0) + (set! (-> arg0 entity-link) #f) + ) + (else + (set! (-> v1-0 next-link prev-link) (-> v1-0 prev-link)) + (set! (-> v1-0 prev-link next-link) (-> v1-0 next-link)) + (if (= (-> arg0 entity-link) v1-0) + (set! (-> arg0 entity-link) (-> v1-0 prev-link)) + ) + ) + ) + ) + this + ) + +(defun update-actor-vis-box ((arg0 process-drawable) (arg1 vector) (arg2 vector)) + (when (and arg0 (nonzero? (-> arg0 draw)) (not (logtest? (-> arg0 draw status) (draw-control-status no-draw)))) + (let ((v1-5 (-> arg0 draw origin)) + (f0-0 (-> arg0 draw bounds w)) + ) + (set! (-> arg1 x) (fmin (-> arg1 x) (- (-> v1-5 x) f0-0))) + (set! (-> arg1 y) (fmin (-> arg1 y) (- (-> v1-5 y) f0-0))) + (set! (-> arg1 z) (fmin (-> arg1 z) (- (-> v1-5 z) f0-0))) + (set! (-> arg2 x) (fmax (-> arg2 x) (+ (-> v1-5 x) f0-0))) + (set! (-> arg2 y) (fmax (-> arg2 y) (+ (-> v1-5 y) f0-0))) + (set! (-> arg2 z) (fmax (-> arg2 z) (+ (-> v1-5 z) f0-0))) + ) + ) + 0 + (none) + ) + +(defmethod update-vis-volumes ((this level-group)) + (local-vars (sv-16 (inline-array vector)) (sv-20 vector) (sv-24 vector) (sv-28 process)) + (dotimes (s5-0 (-> this length)) + (let ((v1-3 (-> this level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 entity))) + (set! sv-16 (res-lump-data s2-0 'visvol (inline-array vector))) + (set! sv-20 (-> sv-16 0)) + (set! sv-24 (-> sv-16 1)) + (let ((s2-1 (-> s2-0 extra process))) + (set! sv-28 (if (type? s2-1 process-drawable) + s2-1 + ) + ) + ) + ) + (when sv-28 + (update-actor-vis-box (the-as process-drawable sv-28) sv-20 sv-24) + (let ((s2-2 (-> sv-28 child))) + (while s2-2 + (let ((s1-0 update-actor-vis-box) + (s0-0 (-> s2-2 0)) + ) + (s1-0 + (the-as process-drawable (if (type? s0-0 process-drawable) + s0-0 + ) + ) + sv-20 + sv-24 + ) + ) + (set! s2-2 (-> s2-2 0 brother)) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun expand-bounding-box ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 x) (fmin (-> arg0 x) (-> arg2 x))) + (set! (-> arg0 y) (fmin (-> arg0 y) (-> arg2 y))) + (set! (-> arg0 z) (fmin (-> arg0 z) (-> arg2 z))) + (set! (-> arg1 x) (fmax (-> arg1 x) (-> arg3 x))) + (set! (-> arg1 y) (fmax (-> arg1 y) (-> arg3 y))) + (set! (-> arg1 z) (fmax (-> arg1 z) (-> arg3 z))) + 0 + (none) + ) + +;; WARN: Return type mismatch symbol vs object. +(defun expand-bounding-box-from-nav-meshes ((arg0 entity) (arg1 vector) (arg2 vector)) + (local-vars (sv-16 res-tag)) + (set! sv-16 (new 'static 'res-tag)) + (res-lump-data arg0 'nav-mesh-actor pointer :tag-ptr (& sv-16)) + (dotimes (s3-0 (the-as int (-> sv-16 elt-count))) + (let ((a0-3 (nav-mesh-from-res-tag arg0 'nav-mesh-actor s3-0))) + (when a0-3 + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (compute-bounding-box-from-vertices a0-3 s2-0 s1-0) + (expand-bounding-box arg1 arg2 s2-0 s1-0) + ) + ) + ) + ) + #f + ) + +(defmethod level-group-method-24 ((this level-group)) + (local-vars + (r0-0 uint128) + (a0-23 object) + (a1-10 uint128) + (sv-16 (inline-array vector)) + (sv-20 vector) + (sv-24 vector) + (sv-28 float) + (sv-32 float) + (sv-36 vector) + (sv-40 entity) + (sv-48 int) + ) + (dotimes (s5-0 (-> this length)) + (let ((v1-3 (-> this level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 entity))) + (set! sv-16 (res-lump-data s2-0 'visvol (inline-array vector))) + (set! sv-20 (-> sv-16 0)) + (set! sv-24 (-> sv-16 1)) + (set! sv-28 (the-as float -12288.0)) + (set! sv-32 (the-as float 12288.0)) + (set! sv-36 (-> s2-0 extra trans)) + (set! sv-40 s2-0) + (let ((v1-17 (entity-actor-lookup s2-0 'nav-mesh-actor 0))) + (if v1-17 + (set! sv-40 v1-17) + ) + ) + ) + (cond + ((type? sv-40 entity-actor) + (let ((enemy-option (res-lump-value sv-40 'enemy-options enemy-option :time -1000000000.0))) + (cond + ((logtest? (enemy-option spawner) (the-as uint128 enemy-option)) + (set! (-> sv-20 quad) (-> sv-36 quad)) + (set! (-> sv-24 quad) (-> sv-36 quad)) + (set! sv-28 (the-as float -409.6)) + (set! sv-32 (the-as float 409.6)) + ) + ((string-prefix= "battle" (res-lump-struct sv-40 'name string)) + (set! (-> sv-20 quad) (-> sv-36 quad)) + (set! (-> sv-24 quad) (-> sv-36 quad)) + (set! sv-48 0) + (let ((v1-29 + (res-lump-data sv-40 'actor-groups (pointer actor-group) :tag-ptr (the-as (pointer res-tag) (& sv-48))) + ) + ) + (when (and v1-29 (begin + (let ((a0-24 #t)) + (let ((a1-9 (the-as uint128 sv-48))) + (.pcpyud a1-10 a1-9 r0-0) + ) + (let ((a1-12 (the-as int (shr (* (the-as int a1-10) 2) 49)))) + (cmove-#f-zero a0-23 a1-12 a0-24) + ) + ) + a0-23 + ) + ) + (let* ((s2-2 (-> v1-29 0)) + (s1-1 (-> s2-2 length)) + ) + (dotimes (s0-0 s1-1) + (let ((a0-26 (-> s2-2 data s0-0 actor))) + (expand-bounding-box-from-nav-meshes a0-26 sv-20 sv-24) + ) + ) + ) + ) + ) + ) + (else + (expand-bounding-box-from-nav-meshes sv-40 sv-20 sv-24) + ) + ) + ) + ) + (else + (set! (-> sv-20 quad) (-> sv-36 quad)) + (set! (-> sv-24 quad) (-> sv-36 quad)) + ) + ) + (+! (-> sv-20 x) sv-28) + (+! (-> sv-20 y) sv-28) + (+! (-> sv-20 z) sv-28) + (+! (-> sv-24 x) sv-32) + (+! (-> sv-24 y) sv-32) + (+! (-> sv-24 z) sv-32) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod print-volume-sizes ((this level-group)) + (local-vars + (sv-16 (inline-array vector)) + (sv-20 float) + (sv-24 vector) + (sv-28 type) + (sv-32 vector) + (sv-36 vector) + (sv-48 int) + (sv-64 entity) + (sv-80 string) + ) + (let ((s5-0 0)) + (dotimes (v1-0 (-> this length)) + (let ((a0-4 (-> this level v1-0))) + (if (= (-> a0-4 status) 'active) + (+! s5-0 (-> a0-4 entity length)) + ) + ) + ) + (let ((s4-0 (the-as string #f))) + (while (nonzero? s5-0) + 0 + (let ((s2-0 (the-as string #f)) + (s3-0 (the-as entity #f)) + ) + (dotimes (s1-0 (-> this length)) + (let ((v1-7 (-> this level s1-0))) + (when (= (-> v1-7 status) 'active) + (let ((s0-0 (-> v1-7 entity))) + (set! sv-48 (-> s0-0 length)) + (while (nonzero? sv-48) + (set! sv-48 (+ sv-48 -1)) + (set! sv-64 (-> s0-0 data sv-48 entity)) + (set! sv-80 (res-lump-struct sv-64 'name string)) + (when (and (or (not s4-0) (string>? sv-80 s4-0)) (or (not s2-0) (string (the-as entity-actor s3-0) extra trans)) + (set! sv-28 (if (type? s3-0 entity-actor) + (-> (the-as entity-actor s3-0) etype) + (the-as type #f) + ) + ) + (set! sv-32 (-> sv-16 0)) + (set! sv-36 (-> sv-16 1)) + (format #t "actor-vis ~S ~6,,1M " (res-lump-struct s3-0 'name structure) sv-20) + (format + #t + "~6,,1M ~6,,1M ~6,,1M ~6,,1M ~6,,1M ~6,,1M~%" + (- (-> sv-32 x) (-> sv-24 x)) + (- (-> sv-32 y) (-> sv-24 y)) + (- (-> sv-32 z) (-> sv-24 z)) + (- (-> sv-36 x) (-> sv-24 x)) + (- (-> sv-36 y) (-> sv-24 y)) + (- (-> sv-36 z) (-> sv-24 z)) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun expand-vis-box-with-point ((arg0 entity) (arg1 vector)) + (let ((v1-1 (res-lump-data arg0 'visvol (inline-array vector)))) + (when v1-1 + (let ((a0-2 (-> v1-1 0)) + (v1-2 (-> v1-1 1)) + ) + (set! (-> a0-2 x) (fmin (-> a0-2 x) (-> arg1 x))) + (set! (-> a0-2 y) (fmin (-> a0-2 y) (-> arg1 y))) + (set! (-> a0-2 z) (fmin (-> a0-2 z) (-> arg1 z))) + (set! (-> v1-2 x) (fmax (-> v1-2 x) (-> arg1 x))) + (set! (-> v1-2 y) (fmax (-> v1-2 y) (-> arg1 y))) + (set! (-> v1-2 z) (fmax (-> v1-2 z) (-> arg1 z))) + ) + ) + ) + 0 + (none) + ) + +(deftype debug-actor-info (basic) + ((name string) + (handle handle) + (process process) + (pid int32) + ) + ) + + +(define *debug-actor-info* (new 'static 'debug-actor-info :name #f)) + +(define *pid-string* (new 'global 'string 128 (the-as string #f))) + +(defun-debug debug-actor ((arg0 string)) + (let ((gp-0 *debug-actor-info*)) + (set! (-> gp-0 name) #f) + (set! (-> gp-0 handle) (the-as handle #f)) + (cond + ((string-prefix= "pid " arg0) + (let ((s4-0 (length arg0))) + (when (< 4 s4-0) + (clear *pid-string*) + (catn-string<-charp *pid-string* (&-> arg0 data 4) (+ s4-0 -4)) + (set! (-> gp-0 pid) (string->int *pid-string*)) + ) + ) + (let ((gp-1 (lambda ((arg0 process)) (let ((v1-0 *debug-actor-info*)) + (when (= (-> arg0 pid) (-> v1-0 pid)) + (let ((v0-0 (process->handle arg0))) + (set! (-> v1-0 handle) (the-as handle v0-0)) + v0-0 + ) + ) + ) + ) + ) + ) + (iterate-process-tree *pusher-pool* gp-1 *null-kernel-context*) + (iterate-process-tree *entity-pool* gp-1 *null-kernel-context*) + ) + ) + (else + (set! (-> gp-0 name) arg0) + ) + ) + ) + 0 + (none) + ) + +(defun-debug debug-actor-process ((arg0 process)) + (let ((v1-0 *debug-actor-info*)) + (set! (-> v1-0 handle) (process->handle arg0)) + ) + (none) + ) + +(defun-debug draw-actor-marks ((arg0 process)) + (local-vars (sv-16 entity-actor) (sv-20 (pointer int32))) + (b! + (not (and (or (type? arg0 process-drawable) (= (-> arg0 type) part-tracker) (type? arg0 part-spawner)) + (nonzero? (-> (the-as process-drawable arg0) root)) + ) + ) + cfg-51 + :delay (nop!) + ) + (when (type? arg0 process-drawable) + (when (and (-> (the-as process-drawable arg0) nav) (nonzero? (-> (the-as process-drawable arg0) nav))) + (if (= arg0 *debug-actor*) + (debug-draw (-> (the-as process-drawable arg0) nav)) + ) + ) + (if (nonzero? (-> (the-as process-drawable arg0) path)) + (path-control-method-9 (-> (the-as process-drawable arg0) path)) + ) + (if (nonzero? (-> (the-as process-drawable arg0) vol)) + (debug-draw (-> (the-as process-drawable arg0) vol)) + ) + (if (and (nonzero? (-> (the-as process-drawable arg0) draw)) *display-actor-vis*) + (add-debug-sphere + #t + (bucket-id bucket583) + (-> (the-as process-drawable arg0) draw origin) + (-> (the-as process-drawable arg0) draw bounds w) + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + ) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> (the-as process-drawable arg0) root trans) + (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80) + ) + (set! sv-16 (-> arg0 entity)) + (cond + ((and sv-16 (= (-> sv-16 extra process) arg0)) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (res-lump-struct sv-16 'name string) + (-> (the-as process-drawable arg0) root trans) + (if (logtest? (-> sv-16 extra perm status) (entity-perm-status bit-0 error)) + (font-color red) + (font-color white) + ) + (new 'static 'vector2h :y 8) + ) + (set! sv-20 (res-lump-data sv-16 'eco-info (pointer int32) :time 0.0)) + (when sv-20 + (let ((s5-1 add-debug-text-3d) + (s4-1 #t) + (s3-1 577) + ) + (format (clear *temp-string*) "~S ~D~%" (pickup-type->string (the-as pickup-type (-> sv-20 0))) (-> sv-20 1)) + (s5-1 + s4-1 + (the-as bucket-id s3-1) + *temp-string* + (-> (the-as process-drawable arg0) root trans) + (font-color white) + (new 'static 'vector2h :y 24) + ) + ) + ) + (let ((a0-23 (res-lump-struct sv-16 'art-name string))) + (if (and a0-23 (logtest? (the-as int a0-23) 1)) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (symbol->string-debug (the-as symbol a0-23)) + (-> (the-as process-drawable arg0) root trans) + (font-color white) + (new 'static 'vector2h :y 24) + ) + ) + ) + (when *display-actor-vis* + (let ((v1-56 (res-lump-data sv-16 'visvol (inline-array vector))) + (a1-14 (-> sv-16 extra vis-id)) + ) + (if v1-56 + (add-debug-box + #t + (bucket-id debug-no-zbuf1) + (-> v1-56 0) + (-> v1-56 1) + (if (is-object-visible? (-> sv-16 extra level) a1-14) + (new 'static 'rgba :g #x80 :b #x80 :a #x80) + (new 'static 'rgba :r #x80 :b #x80 :a #x80) + ) + ) + ) + ) + ) + ) + (else + (let ((s5-4 add-debug-text-3d) + (s4-4 #t) + (s3-4 577) + ) + (format (clear *temp-string*) "pid ~d" (-> arg0 pid)) + (s5-4 + s4-4 + (the-as bucket-id s3-4) + *temp-string* + (-> (the-as process-drawable arg0) root trans) + (font-color green) + (new 'static 'vector2h :y 8) + ) + ) + ) + ) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (if (-> arg0 state) + (symbol->string-debug (-> arg0 state name)) + "#f" + ) + (-> (the-as process-drawable arg0) root trans) + (font-color white) + (new 'static 'vector2h :y 16) + ) + (label cfg-51) + 0 + (none) + ) + +(defmethod debug-draw-actors ((this level-group) (arg0 symbol)) + (local-vars + (sv-16 symbol) + (sv-20 vector) + (sv-32 int) + (sv-48 (function symbol bucket-id vector vector rgba symbol)) + (sv-64 symbol) + (sv-80 int) + (sv-96 pointer) + (sv-112 pointer) + (sv-128 int) + ) + (let ((s4-0 *debug-actor-info*)) + (set! (-> s4-0 process) #f) + (if (zero? (-> s4-0 handle pid)) + (set! (-> s4-0 handle) + (logior (logand (-> s4-0 handle) (shl (the-as uint #xffffffff) 32)) (shr (shl (the-as int #f) 32) 32)) + ) + ) + (let ((v1-7 (handle->process (-> s4-0 handle)))) + (when (not v1-7) + (when (-> s4-0 name) + (let ((s3-0 (process-by-name (-> s4-0 name) *active-pool*))) + (set! v1-7 (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (set! (-> s4-0 handle) (process->handle v1-7)) + ) + ) + (set! (-> s4-0 process) v1-7) + ) + (set! *debug-actor* (-> s4-0 process)) + ) + (set! sv-16 arg0) + (when (and sv-16 (not (or (= *master-mode* 'menu) (= *master-mode* 'progress)))) + (cond + ((= sv-16 'process) + (let ((s5-1 draw-actor-marks)) + (iterate-process-tree *pusher-pool* s5-1 *null-kernel-context*) + (iterate-process-tree *entity-pool* s5-1 *null-kernel-context*) + ) + ) + (else + (dotimes (s5-2 (-> this length)) + (let ((v1-21 (-> this level s5-2))) + (when (= (-> v1-21 status) 'active) + (let ((s4-1 (-> v1-21 bsp level entity))) + (dotimes (s3-1 (-> s4-1 length)) + (let ((s2-0 (-> s4-1 data s3-1 entity))) + (set! sv-20 (-> s2-0 extra trans)) + (when (or (= sv-16 'full) (-> s2-0 extra process)) + (add-debug-x #t (bucket-id debug-no-zbuf1) sv-20 (if (-> s2-0 extra process) + (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80) + (new 'static 'rgba :r #xff :a #x80) + ) + ) + (when (< (vector-vector-distance (math-camera-pos) sv-20) 491520.0) + (let ((s1-1 add-debug-text-3d) + (s0-0 #t) + ) + (set! sv-32 577) + (let ((a2-4 (res-lump-struct s2-0 'name structure)) + (a3-2 sv-20) + (t0-1 (if (logtest? (-> s2-0 extra perm status) (entity-perm-status bit-0 error)) + 1 + 5 + ) + ) + (t1-1 (new 'static 'vector2h :y 8)) + ) + (s1-1 s0-0 (the-as bucket-id sv-32) (the-as string a2-4) a3-2 (the-as font-color t0-1) t1-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (when (and *display-actor-vis* (not *debug-actor*)) + (let ((s5-3 *display-actor-vis*)) + (dotimes (s4-2 (-> this length)) + (let ((s3-2 (-> this level s4-2))) + (when (= (-> s3-2 status) 'active) + (let ((s2-1 (-> s3-2 bsp level entity))) + (dotimes (s1-2 (-> s2-1 length)) + (let ((s0-1 (-> s2-1 data s1-2 entity))) + (let ((v0-9 (res-lump-data s0-1 'visvol pointer)) + (a1-16 (-> s0-1 extra vis-id)) + ) + (when (and v0-9 (or (= s5-3 #t) (= s5-3 'box))) + (set! sv-48 add-debug-box) + (set! sv-64 #t) + (set! sv-80 577) + (set! sv-96 (&+ v0-9 0)) + (set! sv-112 (&+ v0-9 16)) + (let ((t0-3 (if (is-object-visible? s3-2 a1-16) + (the-as uint #x80808000) + (the-as uint #x80800080) + ) + ) + ) + (sv-48 sv-64 (the-as bucket-id sv-80) (the-as vector sv-96) (the-as vector sv-112) (the-as rgba t0-3)) + ) + ) + ) + (when (or (= s5-3 #t) (= s5-3 'sphere)) + (let ((s0-2 (-> s0-1 extra process))) + (when s0-2 + (when (and (type? s0-2 process-drawable) (nonzero? (-> (the-as process-drawable s0-2) draw))) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> (the-as process-drawable s0-2) root trans) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (add-debug-sphere + #t + (bucket-id bucket583) + (-> (the-as process-drawable s0-2) draw origin) + (-> (the-as process-drawable s0-2) draw bounds w) + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if *generate-actor-vis* + (update-vis-volumes this) + ) + (cond + (*debug-actor* + (let* ((s4-3 *debug-actor*) + (s5-4 (if (type? s4-3 process-drawable) + (the-as process-drawable s4-3) + ) + ) + ) + (when s5-4 + (if (nonzero? (-> s5-4 skel)) + (debug-print-channels (-> s5-4 skel) (the-as symbol *stdcon*)) + ) + (when (and (nonzero? (-> s5-4 nav)) (-> s5-4 nav) *display-nav-marks*) + (let ((s4-4 (-> s5-4 nav state flags))) + (if (= (logand s4-4 (nav-state-flag in-target-poly)) (nav-state-flag in-target-poly)) + (format *stdcon* "in-target-poly ") + ) + (if (= (logand s4-4 (nav-state-flag directional-mode)) (nav-state-flag directional-mode)) + (format *stdcon* "directional-mode ") + ) + (if (= (logand s4-4 (nav-state-flag initialized)) (nav-state-flag initialized)) + (format *stdcon* "initialized ") + ) + (if (= (logand s4-4 (nav-state-flag display-marks)) (nav-state-flag display-marks)) + (format *stdcon* "display-marks ") + ) + (if (= (logand s4-4 (nav-state-flag recovery-mode)) (nav-state-flag recovery-mode)) + (format *stdcon* "recovery-mode ") + ) + (if (= (logand s4-4 (nav-state-flag touching-sphere)) (nav-state-flag touching-sphere)) + (format *stdcon* "touching-sphere ") + ) + (if (= (logand s4-4 (nav-state-flag trapped-by-sphere)) (nav-state-flag trapped-by-sphere)) + (format *stdcon* "trapped-by-sphere ") + ) + (if (= (logand s4-4 (nav-state-flag blocked)) (nav-state-flag blocked)) + (format *stdcon* "blocked ") + ) + (if (= (logand s4-4 (nav-state-flag avoiding-sphere)) (nav-state-flag avoiding-sphere)) + (format *stdcon* "avoiding-sphere ") + ) + (if (= (logand s4-4 (nav-state-flag target-inside)) (nav-state-flag target-inside)) + (format *stdcon* "target-inside ") + ) + (if (= (logand s4-4 (nav-state-flag debug)) (nav-state-flag debug)) + (format *stdcon* "debug ") + ) + (if (= (logand s4-4 (nav-state-flag at-gap)) (nav-state-flag at-gap)) + (format *stdcon* "at-gap ") + ) + (if (= (logand s4-4 (nav-state-flag use-position)) (nav-state-flag use-position)) + (format *stdcon* "user-position ") + ) + (if (= (logand s4-4 (nav-state-flag in-mesh)) (nav-state-flag in-mesh)) + (format *stdcon* "in-mesh ") + ) + (if (= (logand s4-4 (nav-state-flag at-target)) (nav-state-flag at-target)) + (format *stdcon* "at-target ") + ) + (if (= (logand s4-4 (nav-state-flag target-poly-dirty)) (nav-state-flag target-poly-dirty)) + (format *stdcon* "target-poly-dirty ") + ) + ) + (format *stdcon* "~%") + ) + (when *display-joint-axes* + (if (and (type? s5-4 process-drawable) (nonzero? (-> s5-4 draw))) + (draw-joint-axes s5-4) + ) + ) + (draw-actor-marks s5-4) + ) + ) + ) + (*display-nav-mesh* + (dotimes (s5-5 (-> this length)) + (let ((v1-145 (-> this level s5-5))) + (when (= (-> v1-145 status) 'active) + (let ((s4-5 (-> v1-145 bsp nav-meshes))) + (when (nonzero? s4-5) + (dotimes (s3-3 (-> s4-5 length)) + (let ((s2-2 (-> s4-5 s3-3))) + (if (name= *display-nav-mesh* (res-lump-struct s2-2 'name structure)) + (debug-draw s2-2) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (else + (when *display-nav-marks* + (dotimes (s5-6 (-> this length)) + (let ((v1-163 (-> this level s5-6))) + (when (= (-> v1-163 status) 'active) + (let ((s4-6 (-> v1-163 bsp nav-meshes))) + (when (nonzero? s4-6) + (dotimes (s3-4 (-> s4-6 length)) + (debug-draw (-> s4-6 s3-4)) + ) + ) + ) + ) + ) + ) + ) + (if (or *display-path-marks* *display-vol-marks*) + (iterate-process-tree + *active-pool* + (lambda ((arg0 process)) (when (type? arg0 process-drawable) + (if (nonzero? (-> (the-as process-drawable arg0) path)) + (path-control-method-9 (-> (the-as process-drawable arg0) path)) + ) + (if (nonzero? (-> (the-as process-drawable arg0) vol)) + (debug-draw (-> (the-as process-drawable arg0) vol)) + ) + ) + ) + *null-kernel-context* + ) + ) + ) + ) + (when (and *display-actor-graph* (not (or (= *master-mode* 'menu) (= *master-mode* 'progress)))) + (if (not (paused?)) + (float-save-timeplot (if (< (the int (the float (mod (current-time) 600))) 300) + 1.0 + 0.0 + ) + ) + ) + (camera-plot-float-func + 0.0 + 399.0 + -81920.0 + 81920.0 + float-lookup-redline + (new 'static 'vector4w :x #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + -81920.0 + 81920.0 + float-lookup-blueline + (new 'static 'vector4w :z #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + -81920.0 + 81920.0 + float-lookup-greenline + (new 'static 'vector4w :y #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + 0.0 + 409600.0 + float-lookup-yellowline + (new 'static 'vector4w :x #xff :y #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + 0.0 + 1.0 + float-lookup-timeplot + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + ) + ) + (when *display-split-boxes* + (dotimes (s5-7 (-> this length)) + (let ((v1-193 (-> this level s5-7))) + (when (= (-> v1-193 status) 'active) + (let ((s4-7 (-> v1-193 bsp region-tree))) + (when (nonzero? s4-7) + (let* ((s3-5 (-> s4-7 data2 (+ (-> s4-7 length) -1) length)) + (s2-3 0) + (a0-113 (the-as object (+ (+ (* s2-3 32) 32) (the-as int (-> s4-7 data2 (+ (-> s4-7 length) -1)))))) + ) + (while (< s2-3 s3-5) + (debug-draw-region (the-as drawable-region-prim a0-113) 0) + (+! s2-3 1) + (set! a0-113 (+ (+ (* s2-3 32) 32) (the-as int (-> s4-7 data2 (+ (-> s4-7 length) -1))))) + ) + ) + ) + ) + ) + ) + ) + ) + (when *display-region-marks* + (dotimes (s5-8 (-> this length)) + (let ((s4-8 (-> this level s5-8))) + (when (= (-> s4-8 status) 'active) + (when (nonzero? (-> s4-8 bsp region-trees)) + (let* ((s3-6 (-> s4-8 bsp region-trees length)) + (s2-4 0) + (s1-4 (-> s4-8 bsp region-trees s2-4)) + ) + (while (< s2-4 s3-6) + (let ((s0-4 (-> s1-4 data2 (+ (-> s1-4 length) -1) length))) + (set! sv-128 0) + (let ((a0-128 (the-as object (+ (+ (* sv-128 32) 32) (the-as int (-> s1-4 data2 (+ (-> s1-4 length) -1))))))) + (while (< sv-128 s0-4) + (debug-draw-region (the-as drawable-region-prim a0-128) 0) + (set! sv-128 (+ sv-128 1)) + (set! a0-128 (+ (+ (* sv-128 32) 32) (the-as int (-> s1-4 data2 (+ (-> s1-4 length) -1))))) + ) + ) + ) + (+! s2-4 1) + (set! s1-4 (-> s4-8 bsp region-trees s2-4)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod birth! ((this entity-camera)) + (add-connection *camera-engine* *camera* nothing this #f #f) + this + ) + +(defmethod kill! ((this entity-camera)) + (remove-by-param1 *camera-engine* (the-as int this)) + this + ) + +;; WARN: Return type mismatch process vs none. +(defun init-entity ((arg0 process) (arg1 entity-actor) (arg2 type)) + (activate arg0 *entity-pool* (res-lump-struct arg1 'name string) (the-as pointer #x70004000)) + (set! (-> arg0 entity) arg1) + (set! (-> arg0 level) (-> arg1 extra level)) + (set! (-> arg1 extra process) arg0) + (run-now-in-process arg0 (method-of-object arg0 init-from-entity!) arg0 arg1) + (none) + ) + +(defmethod birth! ((this entity-actor)) + (let* ((s5-0 (-> this etype)) + (v1-0 (entity-info-lookup s5-0)) + (s4-0 (get-process + *default-dead-pool* + s5-0 + (if v1-0 + (-> v1-0 heap-size) + #x4000 + ) + 0 + ) + ) + ) + (cond + ((not s4-0) + ) + ((begin + (set! (-> s4-0 type) s5-0) + (and s5-0 + (valid? s5-0 type (the-as string #f) #f 0) + (valid? (method-of-object s4-0 init-from-entity!) function (the-as string #f) #f 0) + ) + ) + (init-entity s4-0 this s5-0) + ) + (else + (when (not (birth-viewer s4-0 this)) + (format 0 "ERROR: no proper process type named ~A exists in the code, could not start ~A~%" s5-0 this) + (logior! (-> this extra perm status) (entity-perm-status bit-0)) + ) + ) + ) + ) + this + ) + +;; WARN: Return type mismatch symbol vs none. +(defun entity-deactivate-handler ((arg0 process) (arg1 entity-actor)) + (when (= arg0 (-> arg1 extra process)) + (logclear! (-> arg1 extra perm status) (entity-perm-status error no-kill)) + (set! (-> arg1 extra process) #f) + ) + (none) + ) + +(defmethod kill! ((this entity-actor)) + (let ((a0-1 (-> this extra process))) + (if a0-1 + (deactivate a0-1) + (entity-deactivate-handler a0-1 this) + ) + ) + this + ) + +;; WARN: Return type mismatch bsp-header vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 s5, Count] +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defmethod birth ((this bsp-header)) + (local-vars (v1-75 int) (s5-0 int) (sv-16 int)) + (.mfc0 s5-0 Count) + (let ((a2-0 (if (nonzero? (-> this actors)) + (-> this actors length) + 0 + ) + ) + ) + (cond + ((not (-> this level entity)) + (set! (-> this level entity) (new 'loading-level 'entity-links-array a2-0)) + ) + ((< (-> this level entity allocated-length) a2-0) + (format + 0 + "ERROR: Attempting to rebirth level ~A with incorrect entity table size ~D/~D~%" + (-> this level) + a2-0 + (-> this level entity allocated-length) + ) + ) + ) + ) + (set! (-> this level entity length) 0) + 0 + (when (nonzero? (-> this actors)) + (dotimes (s4-0 (-> this actors length)) + (let* ((a0-4 (-> this actor-birth-order s4-0)) + (v1-23 (-> this actors data (logand a0-4 8191) actor)) + ) + (add-to-level! v1-23 *level* (-> this level) (the-as actor-id (-> v1-23 aid))) + ) + ) + ) + (let ((s4-1 (-> this cameras))) + (when (nonzero? s4-1) + (dotimes (s3-0 (-> s4-1 length)) + (birth! (-> s4-1 s3-0)) + ) + ) + ) + (let ((s4-2 (-> this level status))) + (set! (-> this level status) 'active) + (do-nothing *level*) + (dotimes (s3-1 (-> *level* length)) + (let ((s2-0 (-> *level* level s3-1))) + (when (= (-> s2-0 status) 'active) + (when (nonzero? (-> s2-0 bsp actor-groups)) + (countdown (s1-0 (-> s2-0 bsp actor-groups length)) + (let ((s0-0 (-> s2-0 bsp actor-groups s1-0))) + (set! sv-16 0) + (while (< sv-16 (-> s0-0 length)) + (if (not (-> s0-0 data sv-16 actor)) + (set! (-> s0-0 data sv-16 actor) (entity-by-aid (-> s0-0 data sv-16 id))) + ) + (set! sv-16 (+ sv-16 1)) + ) + ) + ) + ) + ) + ) + ) + (set! (-> this level status) s4-2) + ) + (.mfc0 v1-75 Count) + (let ((a3-2 (- v1-75 s5-0))) + (format 0 "Done ~S in ~D~%" "birth" a3-2) + ) + (none) + ) + +(defun check-for-rougue-process ((arg0 process) (arg1 int) (arg2 int) (arg3 level)) + (cond + ((-> arg0 entity) + (cond + ((or (= (-> arg0 level) arg3) (= (-> arg0 entity extra level) arg3)) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((let ((v1-9 (-> arg0 name))) + (and (>= (the-as int v1-9) arg1) (< (the-as int v1-9) arg2)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((and (logtest? (-> arg0 entity extra kill-mask) (task-mask ctywide)) + (or (= (-> arg3 name) 'ctywide) (= (-> arg3 name) 'waswide)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((and (logtest? (-> arg0 entity extra kill-mask) (task-mask vehicle)) + (or (= (-> arg3 name) 'ctywide) (= (-> arg3 name) 'wasall)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((and (logtest? (-> arg0 entity extra kill-mask) (task-mask primary0)) + (logtest? (-> arg3 info base-task-mask) (task-mask primary0)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ) + ) + ((= (-> arg0 level) arg3) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((= (-> arg0 type) part-tracker) + (let ((v1-45 (the-as part-tracker arg0))) + (if (and (nonzero? (-> v1-45 part)) + (>= (the-as int (-> v1-45 part group)) arg1) + (< (the-as int (-> v1-45 part group)) arg2) + ) + (deactivate arg0) + ) + ) + ) + ((type? arg0 part-spawner) + (let ((v1-50 (the-as part-spawner arg0))) + (if (and (nonzero? (-> v1-50 part)) + (>= (the-as int (-> v1-50 part group)) arg1) + (< (the-as int (-> v1-50 part group)) arg2) + ) + (deactivate arg0) + ) + ) + ) + (else + (let* ((s3-0 arg0) + (v1-55 (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (when v1-55 + (cond + ((and (nonzero? (-> (the-as process-drawable v1-55) part)) + (>= (the-as int (-> (the-as process-drawable v1-55) part group)) arg1) + (< (the-as int (-> (the-as process-drawable v1-55) part group)) arg2) + ) + (format + #t + "NOTICE: rogue null level entity (using part ~A) ~A still alive~%" + (-> (the-as process-drawable v1-55) part group) + arg0 + ) + (deactivate arg0) + ) + ((and (nonzero? (-> (the-as process-drawable v1-55) draw)) + (>= (the-as int (-> (the-as process-drawable v1-55) draw art-group)) arg1) + (< (the-as int (-> (the-as process-drawable v1-55) draw art-group)) arg2) + ) + (format + #t + "NOTICE: rogue null level entity (using art ~A) ~A still alive~%" + (-> (the-as process-drawable v1-55) draw art-group) + arg0 + ) + (deactivate arg0) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch bsp-header vs none. +(defmethod deactivate-entities ((this bsp-header)) + (let ((v1-1 (-> this level heap base)) + (a0-2 (-> this level heap top-base)) + ) + (when (nonzero? (-> this actor-groups)) + (dotimes (a1-2 (-> this actor-groups length)) + (let ((a2-2 (-> this actor-groups a1-2))) + (dotimes (a3-1 (-> a2-2 length)) + (let ((t0-2 (-> a2-2 data a3-1 actor))) + (if (and t0-2 (not (and (>= (the-as int t0-2) (the-as int v1-1)) (< (the-as int t0-2) (the-as int a0-2))))) + (set! (-> a2-2 data a3-1 actor) #f) + ) + ) + ) + ) + ) + ) + (dotimes (a1-5 (-> *level* length)) + (let ((a2-10 (-> *level* level a1-5))) + (when (= (-> a2-10 status) 'active) + (when (!= a2-10 (-> this level)) + (when (nonzero? (-> a2-10 bsp actor-groups)) + (dotimes (a3-10 (-> a2-10 bsp actor-groups length)) + (let ((t0-13 (-> a2-10 bsp actor-groups a3-10))) + (dotimes (t1-2 (-> t0-13 length)) + (let ((t2-3 (-> t0-13 data t1-2 actor))) + (if (and t2-3 (>= (the-as int t2-3) (the-as int v1-1)) (< (the-as int t2-3) (the-as int a0-2))) + (set! (-> t0-13 data t1-2 actor) #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s5-0 (-> this actors))) + (when (nonzero? s5-0) + (dotimes (s4-0 (-> s5-0 length)) + (let ((s3-0 (-> s5-0 data s4-0 actor))) + (kill! s3-0) + (remove-from-level! s3-0 *level*) + ) + ) + ) + ) + (let ((s5-1 (-> this cameras))) + (when (nonzero? s5-1) + (dotimes (s4-1 (-> s5-1 length)) + (kill! (-> s5-1 s4-1)) + ) + ) + ) + (let ((v1-23 (-> this level heap base)) + (a0-7 (-> this level heap top-base)) + (s5-2 (lambda ((arg0 process)) (check-for-rougue-process + arg0 + (-> *kernel-context* relocating-min) + (-> *kernel-context* relocating-max) + (-> *kernel-context* relocating-level) + ) + ) + ) + ) + (set! (-> *kernel-context* relocating-min) (the-as int v1-23)) + (set! (-> *kernel-context* relocating-max) (the-as int a0-7)) + (set! (-> *kernel-context* relocating-level) (-> this level)) + (iterate-process-tree *pusher-pool* s5-2 *null-kernel-context*) + (iterate-process-tree *entity-pool* s5-2 *null-kernel-context*) + (iterate-process-tree *default-pool* s5-2 *null-kernel-context*) + ) + (let ((s5-3 (-> this nav-meshes))) + (when (nonzero? s5-3) + (dotimes (s4-2 (-> s5-3 length)) + (kill! (-> s5-3 s4-2)) + ) + ) + ) + (none) + ) + +(defun process-drawable-scale-from-entity! ((arg0 process-drawable) (arg1 entity)) + (let ((v1-1 (res-lump-struct arg1 'scale vector))) + (if v1-1 + (set! (-> arg0 root scale quad) (-> v1-1 quad)) + (vector-identity! (-> arg0 root scale)) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch process-drawable vs none. +(defun process-drawable-from-entity! ((arg0 process-drawable) (arg1 entity-actor)) + (logior! (-> arg0 mask) (process-mask actor-pause)) + (set! (-> arg0 root trans quad) (-> arg1 extra trans quad)) + (quaternion-copy! (-> arg0 root quat) (-> arg1 quat)) + (vector-identity! (-> arg0 root scale)) + (none) + ) + +(defmethod update ((this entity-perm) (arg0 symbol) (arg1 entity-perm-status)) + (cond + ((= arg0 'game) + (logclear! (-> this status) arg1) + ) + ((task-complete? *game-info* (-> this task)) + (if (or (= arg0 'try) (= arg0 'life)) + (logclear! (-> this status) (logior (if (logtest? (-> this status) (entity-perm-status bit-4)) + 524 + 0 + ) + #x8203 + ) + ) + (logclear! (-> this status) (logior (if (logtest? (-> this status) (entity-perm-status bit-4)) + 524 + 0 + ) + 515 + ) + ) + ) + ) + (else + (logclear! (-> this status) (logclear + (logior arg1 (if (logtest? (-> this status) (entity-perm-status bit-4)) + 524 + 0 + ) + ) + (if (logtest? (-> this status) (entity-perm-status bit-14)) + 32 + 0 + ) + ) + ) + ) + ) + (when (not (logtest? (-> this status) (entity-perm-status bit-5))) + (set! (-> this user-uint64) (the-as uint 0)) + 0 + ) + this + ) + +(defun reset-actors ((arg0 symbol)) + (let* ((v1-0 arg0) + (perm + (cond + ((or (= v1-0 'life) (= v1-0 'debug)) + (the-as + entity-perm-status + (entity-perm-status bit-0 error dead no-kill bit-5 subtask-complete bit-9 bit-12 bit-15) + ) + ) + ((= v1-0 'try) + (the-as + entity-perm-status + (entity-perm-status bit-0 error dead no-kill bit-5 subtask-complete bit-9 bit-12 bit-15) + ) + ) + ((= v1-0 'game) + (the-as entity-perm-status (entity-perm-status + bit-0 + error + dead + no-kill + bit-4 + bit-5 + subtask-complete + complete + bit-9 + bit-10 + save + bit-12 + bit-13 + bit-15 + ) + ) + ) + (else + (the-as + entity-perm-status + (entity-perm-status bit-0 error dead no-kill bit-4 bit-5 subtask-complete bit-9 bit-10 bit-12 bit-15) + ) + ) + ) + ) + (s4-0 *game-info*) + ) + (dotimes (s3-0 (-> *level* length)) + (let ((v1-4 (-> *level* level s3-0))) + (when (or (= (-> v1-4 status) 'active) (= (-> v1-4 status) 'alive) (= (-> v1-4 status) 'loaded)) + (when (-> v1-4 part-engine) + (set! (-> v1-4 part-engine length) 0) + 0 + ) + (when (-> v1-4 entity) + (let ((s2-0 (-> v1-4 bsp level entity))) + (dotimes (s1-0 (-> s2-0 length)) + (let ((s0-0 (-> s2-0 data s1-0 entity))) + (if (not (and (-> s0-0 extra process) (logtest? (-> s0-0 extra process mask) (process-mask no-kill)))) + (kill! s0-0) + ) + (update (-> s0-0 extra perm) arg0 (the-as entity-perm-status perm)) + ) + ) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s4-0 task-perm-list))) + (dotimes (s2-1 (-> s3-1 length)) + (update (-> s3-1 data s2-1) arg0 (the-as entity-perm-status perm)) + ) + (logior! (-> s3-1 data 1 status) (entity-perm-status complete)) + ) + (let ((s4-1 (-> s4-0 perm-list))) + (dotimes (s3-2 (-> s4-1 length)) + (update (-> s4-1 data s3-2) arg0 (the-as entity-perm-status perm)) + ) + ) + ) + (let ((s5-1 (lambda ((arg0 process)) (if (not (logtest? (-> arg0 mask) (process-mask no-kill))) + (deactivate arg0) + ) + ) + ) + ) + (iterate-process-tree *pusher-pool* s5-1 *null-kernel-context*) + (iterate-process-tree *entity-pool* s5-1 *null-kernel-context*) + ) + (if #t + (task-node-reset arg0) + ) + (dotimes (s5-2 (-> *level* length)) + (let ((s4-2 (-> *level* level s5-2))) + (when (= (-> s4-2 status) 'active) + (let ((s3-3 (the-as (function level none) (get-callback-symbol-value-by-slot! (-> s4-2 info) 35)))) + (if (and s3-3 (type? s3-3 function)) + (s3-3 s4-2) + ) + ) + ) + ) + ) + (set! (-> *ACTOR-bank* birth-max) 1000) + (update-task-masks arg0) + 0 + (none) + ) + +(defun reset-cameras () + (remove-all *camera-engine*) + (dotimes (gp-0 (-> *level* length)) + (let ((v1-5 (-> *level* level gp-0))) + (when (= (-> v1-5 status) 'active) + (let ((s5-0 (-> v1-5 bsp cameras))) + (when (nonzero? s5-0) + (dotimes (s4-0 (-> s5-0 length)) + (birth! (-> s5-0 s4-0)) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod run-logic? ((this process-drawable)) + "Should this process be run? Checked by execute-process-tree." + (or (not (logtest? (-> this mask) (process-mask actor-pause))) + (or (>= (+ (-> *ACTOR-bank* pause-dist) (-> this root pause-adjust-distance)) + (vector-vector-distance (-> this root trans) (math-camera-pos)) + ) + (and (nonzero? (-> this skel)) (!= (-> this skel root-channel 0) (-> this skel channel))) + (and (nonzero? (-> this draw)) (logtest? (-> this draw status) (draw-control-status uninited))) + ) + ) + ) + +(defmethod birth? ((this entity-links) (arg0 vector)) + (and (not (logtest? (-> this perm status) (entity-perm-status bit-0 dead))) + (< (vector-vector-distance (-> this trans) arg0) (-> *ACTOR-bank* birth-dist)) + ) + ) + +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; WARN: Function (method 17 level-group) has a return type of none, but the expression builder found a return statement. +(defmethod actors-update ((this level-group)) + (local-vars + (sv-16 vector) + (sv-24 int) + (sv-32 task-mask) + (sv-48 entity-links) + (sv-64 string) + (sv-80 string) + (sv-96 float) + ) + (when *compact-actors* + (if (and (= *compact-actors* 'debug) (= (-> *nk-dead-pool* alive-list prev) (-> *nk-dead-pool* first-gap))) + (churn *nk-dead-pool* 1) + ) + (let ((s5-0 + (the int + (lerp-scale 8.0 1.0 (the float (-> *display* frames (-> *display* last-screen) run-time)) 2000.0 8000.0) + ) + ) + ) + (if (nonzero? *debug-dead-pool*) + (compact *debug-dead-pool* 10) + ) + (compact *nk-dead-pool* s5-0) + ) + ) + (update-actor-hash) + (when (not (paused?)) + (let ((s5-1 (-> *display* frames (-> *display* last-screen) run-time))) + (let ((f0-5 (fmax + 327680.0 + (fmin (+ 327680.0 (* 204.8 (the float (- 7000 (the-as int s5-1))))) (-> *ACTOR-bank* birth-dist)) + ) + ) + ) + (seek! (-> *ACTOR-bank* pause-dist) f0-5 (* 81920.0 (seconds-per-frame))) + ) + (seekl! (-> *ACTOR-bank* birth-max) (the int (lerp-scale 25.0 2.0 (the float s5-1) 2000.0 7000.0)) 10) + ) + (if (movie?) + (set! (-> *ACTOR-bank* birth-max) 1000) + ) + ) + (when *spawn-actors* + (set! sv-16 (if (movie?) + (math-camera-pos) + (camera-pos) + ) + ) + (set! sv-24 0) + (dotimes (s5-2 (-> this length)) + (let ((s4-1 (-> this level s5-2))) + (when (= (-> s4-1 status) 'active) + (set! sv-32 (-> s4-1 task-mask)) + (cond + ((= (-> s4-1 display?) 'special) + (let* ((s4-2 (-> s4-1 entity)) + (s3-1 (-> s4-2 length)) + ) + (dotimes (s2-0 s3-1) + (let ((v1-53 (-> s4-2 data s2-0))) + (cond + ((and (logtest? (-> v1-53 kill-mask) (task-mask special)) (not (logtest? (-> v1-53 kill-mask) sv-32))) + (when (not (or (-> v1-53 process) (logtest? (-> v1-53 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> v1-53 entity)) + (set! sv-24 (+ sv-24 1)) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + (else + (if (and (-> v1-53 process) + (not (logtest? (-> v1-53 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> v1-53 process mask) (process-mask no-kill))) + ) + (kill! (-> v1-53 entity)) + ) + ) + ) + ) + ) + ) + ) + ((= (-> s4-1 display?) 'actor) + (let* ((s4-3 (-> s4-1 entity)) + (s3-2 (-> s4-3 length)) + ) + (dotimes (s2-1 s3-2) + (let ((v1-66 (-> s4-3 data s2-1))) + (cond + ((not (logtest? (-> v1-66 kill-mask) sv-32)) + (when (not (or (-> v1-66 process) (logtest? (-> v1-66 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> v1-66 entity)) + (set! sv-24 (+ sv-24 1)) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + (else + (if (and (-> v1-66 process) + (not (logtest? (-> v1-66 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> v1-66 process mask) (process-mask no-kill))) + ) + (kill! (-> v1-66 entity)) + ) + ) + ) + ) + ) + ) + ) + ((not *vis-actors*) + (let* ((s4-4 (-> s4-1 entity)) + (s3-3 (-> s4-4 length)) + ) + (dotimes (s2-2 s3-3) + (let ((s1-0 (-> s4-4 data s2-2))) + (cond + ((and (< (vector-vector-distance (-> s1-0 trans) sv-16) (-> *ACTOR-bank* birth-dist)) + (not (logtest? (-> s1-0 perm status) (entity-perm-status bit-9 bit-10))) + (not (logtest? (-> s1-0 kill-mask) sv-32)) + ) + (when (not (or (-> s1-0 process) (logtest? (-> s1-0 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> s1-0 entity)) + (set! sv-24 (+ sv-24 1)) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + (else + (if (and (-> s1-0 process) + (not (logtest? (-> s1-0 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> s1-0 process mask) (process-mask no-kill))) + ) + (kill! (-> s1-0 entity)) + ) + ) + ) + ) + ) + ) + ) + (*vis-actors* + (when (not (and (-> s4-1 vis-info 0) (-> s4-1 all-visible?))) + (let* ((s3-4 (-> s4-1 entity)) + (s2-3 (-> s3-4 length)) + (s0-0 #f) + ) + (dotimes (s1-1 s2-3) + (set! sv-48 (-> s3-4 data s1-1)) + (cond + ((and (is-object-visible? s4-1 (-> sv-48 vis-id)) + (not (logtest? (-> sv-48 perm status) (entity-perm-status bit-9 bit-10))) + (not (logtest? (-> sv-48 kill-mask) sv-32)) + (or (-> s4-1 vis-info 0) (< (vector-vector-distance (-> sv-48 trans) sv-16) (-> sv-48 vis-dist))) + ) + (when (not (or (-> sv-48 process) (logtest? (-> sv-48 perm status) (entity-perm-status bit-0 dead)) s0-0)) + (birth! (-> sv-48 entity)) + (set! sv-24 (+ sv-24 1)) + (when (< (/ (the float (memory-free *nk-dead-pool*)) (the float (memory-total *nk-dead-pool*))) 0.1) + (when (and *debug-segment* (not *display-capture-mode*)) + (let ((s0-1 format)) + (set! sv-64 *stdcon*) + (set! sv-80 "low actor memory, no birth triggered!!! ~,,0fK/~,,0fK~%") + (set! sv-96 (* 0.0009765625 (the float (memory-free *nk-dead-pool*)))) + (let ((a3-2 (* 0.0009765625 (the float (memory-total *nk-dead-pool*))))) + (s0-1 sv-64 sv-80 sv-96 a3-2) + ) + ) + ) + (set! s0-0 #t) + ) + ) + ) + (else + (when (and (-> sv-48 process) + (not (logtest? (-> sv-48 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> sv-48 process mask) (process-mask no-kill))) + ) + (kill! (-> sv-48 entity)) + (set! sv-24 (+ sv-24 1)) + ) + ) + ) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun entity-birth-no-kill ((arg0 entity)) + (let ((gp-0 (-> arg0 extra))) + (logior! (-> gp-0 perm status) (entity-perm-status no-kill)) + (if (not (or (-> gp-0 process) (logtest? (-> gp-0 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> gp-0 entity)) + ) + (-> gp-0 process) + ) + ) + +(defun entity-task-complete-on ((arg0 entity)) + (let ((v1-0 (-> arg0 extra))) + (if (nonzero? (-> v1-0 perm task)) + (logior! (-> *game-info* task-perm-list data (-> v1-0 perm task) status) (entity-perm-status complete)) + ) + ) + 0 + (none) + ) + +(defun entity-task-complete-off ((arg0 entity)) + (let ((v1-0 (-> arg0 extra))) + (if (!= (-> v1-0 perm task) (game-task complete)) + (logclear! (-> *game-info* task-perm-list data (-> v1-0 perm task) status) (entity-perm-status complete)) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch entity-perm-status vs none. +(defmethod toggle-status ((this entity-actor) (arg0 entity-perm-status) (arg1 symbol)) + (let ((v1-0 (-> this extra))) + (if arg1 + (logior! (-> v1-0 perm status) arg0) + (logclear! (-> v1-0 perm status) arg0) + ) + (-> v1-0 perm status) + ) + (none) + ) + +;; WARN: Return type mismatch int vs entity-perm-status. +(defun process-entity-status! ((arg0 process) (arg1 entity-perm-status) (arg2 symbol)) + (the-as entity-perm-status (cond + ((and (-> arg0 entity) arg0 (= arg0 (-> arg0 entity extra process))) + (let ((v1-6 (-> arg0 entity extra))) + (if arg2 + (logior! (-> v1-6 perm status) arg1) + (logclear! (-> v1-6 perm status) arg1) + ) + (the-as int (-> v1-6 perm status)) + ) + ) + (else + 0 + ) + ) + ) + ) + +;; WARN: Return type mismatch entity-actor vs entity. +(defun find-nearest-entity ((arg0 vector) (arg1 type)) + (local-vars (v1-8 object)) + (let ((gp-0 (the-as entity-actor #f))) + (let ((f30-0 0.0) + (f28-0 0.0) + ) + (dotimes (s3-0 (-> *level* length)) + (let ((v1-3 (-> *level* level s3-0))) + (when (= (-> v1-3 status) 'active) + (let ((s2-0 (-> v1-3 bsp actors))) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 length)) + (let ((s0-0 (-> s2-0 data s1-0 actor))) + (let ((v1-7 (or (not arg1) (type-type? (-> s0-0 etype) arg1)))) + (b! (not v1-7) cfg-15 :likely-delay (set! v1-8 v1-7)) + ) + (set! f28-0 (vector-vector-distance arg0 (-> s0-0 extra trans))) + (set! v1-8 f28-0) + (b! (not (the int v1-8)) cfg-15 :likely-delay (nop!)) + (set! v1-8 (or (not gp-0) (< f28-0 f30-0))) + (label cfg-15) + (when v1-8 + (set! gp-0 s0-0) + (set! f30-0 f28-0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity gp-0) + ) + ) + +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 s4, Count] +(defun-debug entity-speed-test ((arg0 string)) + (local-vars (s4-0 int)) + (let ((gp-0 (entity-by-name arg0))) + (when gp-0 + (set! *spawn-actors* #f) + (reset-actors 'debug) + 0 + (disable-irq) + (.mtc0 Count 0) + (.sync.p) + (birth! gp-0) + (.mfc0 s4-0 Count) + (enable-irq) + (format #t "~D spawn ~A ~A ~%" s4-0 arg0 (-> gp-0 extra process)) + (kill! gp-0) + ) + ) + ) + +(defun-debug dump-entity-remap ((arg0 object) (arg1 object)) + (local-vars + (sv-16 symbol) + (sv-32 string) + (sv-48 symbol) + (sv-64 string) + (sv-80 symbol) + (sv-96 string) + (sv-112 string) + ) + (format #t "~%(:eval (remap-entity-list '(") + (dotimes (s4-0 (-> *level* length)) + (let ((s3-0 (-> *level* level s4-0))) + (when (= (-> s3-0 status) 'active) + (when (= (-> s3-0 name) arg0) + (let ((s2-0 (-> s3-0 bsp actors))) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 length)) + (let ((a0-4 (-> s2-0 data s1-0 actor)) + (s0-0 format) + ) + (set! sv-16 #t) + (set! sv-32 "~A ") + (let ((a2-1 (res-lump-struct a0-4 'name structure))) + (s0-0 sv-16 sv-32 a2-1) + ) + ) + ) + ) + ) + (let ((s2-1 (-> s3-0 bsp nav-meshes))) + (when (nonzero? s2-1) + (dotimes (s1-1 (-> s2-1 length)) + (let ((a0-6 (-> s2-1 s1-1)) + (s0-1 format) + ) + (set! sv-48 #t) + (set! sv-64 "~A ") + (let ((a2-3 (res-lump-struct a0-6 'name structure))) + (s0-1 sv-48 sv-64 a2-3) + ) + ) + ) + ) + ) + (let ((s2-2 (-> s3-0 bsp race-meshes))) + (when (nonzero? s2-2) + (dotimes (s1-2 (-> s2-2 length)) + (let ((a0-8 (-> s2-2 s1-2)) + (s0-2 format) + ) + (set! sv-80 #t) + (set! sv-96 "~A ") + (let ((a2-5 (res-lump-struct a0-8 'name structure))) + (s0-2 sv-80 sv-96 a2-5) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s3-0 bsp cameras))) + (when (nonzero? s3-1) + (dotimes (s2-3 (-> s3-1 length)) + (let ((a0-10 (-> s3-1 s2-3)) + (s1-3 format) + (s0-3 #t) + ) + (set! sv-112 "~A ") + (let ((a2-7 (res-lump-struct a0-10 'name structure))) + (s1-3 s0-3 sv-112 a2-7) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (format #t ") '~A '~A))~%~%" arg0 arg1) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc b/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc index f1b75a2255..40f024446e 100644 --- a/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc +++ b/goal_src/jak3/engine/gfx/generic/lightning/lightning-h.gc @@ -68,7 +68,7 @@ (radius float) (duration float) (duration-rand float) - (sound symbol) + (sound sound-spec) (delay float) (delay-rand float) ) diff --git a/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher.gc b/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher.gc index 44820a615d..1b9e04e11f 100644 --- a/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher.gc +++ b/goal_src/jak3/engine/gfx/sprite/particles/sparticle-launcher.gc @@ -33,6 +33,9 @@ ) ) +(define-extern sparticle-2d-spline-align-instant (function object sparticle-cpuinfo sprite-vec-data-2d object none)) +(define-extern rot-to-particle (function degrees sprite-vec-data-2d matrix none)) + ;; DECOMP BEGINS ;; TODO: stub diff --git a/goal_src/jak3/engine/level/bsp-h.gc b/goal_src/jak3/engine/level/bsp-h.gc index 10632e40ea..4a416f7569 100644 --- a/goal_src/jak3/engine/level/bsp-h.gc +++ b/goal_src/jak3/engine/level/bsp-h.gc @@ -9,6 +9,7 @@ (declare-type bsp-node structure) (declare-type entity-camera entity) (declare-type entity-nav-mesh structure) +(declare-type entity-race-mesh entity) (declare-type city-level-info structure) (define-extern inspect-bsp-tree (function bsp-header bsp-node none)) @@ -67,9 +68,11 @@ This probably started as a very simple structure, but now it is extremely compli (cam-box-idx uint16) (subdivide-close float :offset 160) (subdivide-far float) + (race-meshes (array entity-race-mesh)) (actor-birth-order (pointer uint32) :offset 172) (light-hash light-hash) (nav-meshes (array entity-nav-mesh)) + (actor-groups (array actor-group)) (region-trees (array drawable-tree-region-prim) :offset 188) (collide-hash collide-hash :offset 196) (wind-array uint32 :offset 200) diff --git a/goal_src/jak3/engine/level/level-h.gc b/goal_src/jak3/engine/level/level-h.gc index 54677f2b4d..d21f1ea594 100644 --- a/goal_src/jak3/engine/level/level-h.gc +++ b/goal_src/jak3/engine/level/level-h.gc @@ -114,6 +114,19 @@ (movie0 16) (movie1 17) (movie2 18) + (tm19 19) + (tm20 20) + (tm21 21) + (tm22 22) + (tm23 23) + (tm24 24) + (tm25 25) + (tm26 26) + (tm27 27) + (tm28 28) + (tm29 29) + (tm30 30) + (tm31 31) ) ;; ---task-mask @@ -475,7 +488,7 @@ (get-level-by-heap-ptr-and-status (_type_ pointer symbol) level) (level-get-for-use (_type_ symbol symbol) level) (activate-levels! (_type_) int) - (level-group-method-14 () none) + (debug-print-entities (_type_ symbol type string) none) (debug-draw-actors (_type_ symbol) none) (assign-draw-indices (_type_) none) (actors-update (_type_) none) @@ -484,9 +497,9 @@ (level-get-target-inside (_type_) level) (init-level-system (_type_ symbol) none) (art-group-get-by-name (_type_ string (pointer level)) art-group) - (level-group-method-23 () none) - (level-group-method-24 () none) - (level-group-method-25 () none) + (update-vis-volumes (_type_) none) + (level-group-method-24 (_type_) none) + (print-volume-sizes (_type_) none) (status-of-level-and-borrows (_type_ symbol symbol) symbol) (do-nothing (_type_) none) (load-in-progress? (_type_) symbol) diff --git a/goal_src/jak3/engine/math/matrix-compose.gc b/goal_src/jak3/engine/math/matrix-compose.gc index 33dd360d78..c04d1cfef9 100644 --- a/goal_src/jak3/engine/math/matrix-compose.gc +++ b/goal_src/jak3/engine/math/matrix-compose.gc @@ -14,7 +14,7 @@ arg0 ) -(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) +(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) (set! (-> arg0 fvec quad) (-> arg1 quad)) (set! (-> arg0 uvec quad) (-> arg2 quad)) (vector-cross! (-> arg0 rvec) arg2 arg1) @@ -35,7 +35,7 @@ arg0 ) -(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) +(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) (set! (-> arg0 fvec quad) (-> arg1 quad)) (vector-cross! (-> arg0 rvec) arg2 arg1) (vector-normalize! (-> arg0 rvec) 1.0) @@ -83,10 +83,10 @@ arg0 ) -(defun matrix-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) +(defun matrix-f-compose ((arg0 matrix) (arg1 vector) (arg2 float)) (set! (-> arg0 fvec quad) (-> arg1 quad)) (let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) - (matrix-f-u-compose arg0 arg1 a2-1 arg3) + (matrix-f-u-compose arg0 arg1 a2-1) ) arg0 ) diff --git a/goal_src/jak3/engine/nav/nav-control-h.gc b/goal_src/jak3/engine/nav/nav-control-h.gc index cd85091191..c680a25d5d 100644 --- a/goal_src/jak3/engine/nav/nav-control-h.gc +++ b/goal_src/jak3/engine/nav/nav-control-h.gc @@ -177,7 +177,7 @@ (mesh basic :overlay-at (-> state mesh)) ) (:methods - (nav-control-method-9 () none) + (debug-draw (_type_) none) (nav-control-method-10 () none) (find-poly-containing-point-1 (_type_ vector) nav-poly) (cloest-point-on-mesh (_type_ vector vector nav-poly) nav-poly) diff --git a/goal_src/jak3/engine/nav/nav-mesh-h.gc b/goal_src/jak3/engine/nav/nav-mesh-h.gc index 90d8479ebd..a1ed7d7529 100644 --- a/goal_src/jak3/engine/nav/nav-mesh-h.gc +++ b/goal_src/jak3/engine/nav/nav-mesh-h.gc @@ -210,7 +210,7 @@ Based on the implementation of point-poly-intersection?, these should likely be (nav-mesh-method-21 () none) (nav-mesh-method-22 () none) (nav-mesh-method-23 () none) - (nav-mesh-method-24 () none) + (compute-bounding-box-from-vertices (_type_ vector vector) none) (nav-mesh-method-25 () none) (nav-mesh-method-26 () none) (nav-mesh-method-27 () none) diff --git a/goal_src/jak3/engine/physics/rigid-body-h.gc b/goal_src/jak3/engine/physics/rigid-body-h.gc index b56e640226..eaaa4f2200 100644 --- a/goal_src/jak3/engine/physics/rigid-body-h.gc +++ b/goal_src/jak3/engine/physics/rigid-body-h.gc @@ -71,6 +71,8 @@ ;; ---rigid-body-h:rigid-body-object-flag (declare-type rigid-body-object basic) +(declare-type rigid-body-queue-manager process) +(define-extern *rigid-body-queue-manager* rigid-body-queue-manager) ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/scene/scene.gc b/goal_src/jak3/engine/scene/scene.gc index c05fd1ba28..e43b1987e3 100644 --- a/goal_src/jak3/engine/scene/scene.gc +++ b/goal_src/jak3/engine/scene/scene.gc @@ -7,3 +7,1992 @@ ;; DECOMP BEGINS +(deftype scene-stage (process-hidden) + () + ) + + +(defmethod print ((this scene)) + (format #t "#" (-> this art-group) (-> this anim) this) + this + ) + +(defmethod init-spool-by-scene! ((this scene) (arg0 spool-anim)) + (set! (-> arg0 name) (-> this anim)) + (set! (-> arg0 anim-name) (-> this anim)) + (set! (-> arg0 parts) (-> this parts)) + (set! (-> arg0 command-list) (-> this command-list)) + arg0 + ) + +;; WARN: Return type mismatch basic vs continue-point. +(defun scene-decode-continue ((arg0 basic)) + (the-as continue-point (cond + ((not arg0) + (the-as basic #f) + ) + ((= (-> arg0 type) continue-point) + arg0 + ) + ((= (-> arg0 type) string) + (get-continue-by-name *game-info* (the-as string arg0)) + ) + (else + (the-as basic #f) + ) + ) + ) + ) + +(defmethod setup-manipy-for-scene! ((this scene-actor) (arg0 scene-player)) + (local-vars (s4-0 (pointer process)) (sv-96 process)) + (let ((s2-0 (if (-> this level) + (level-get *level* (-> this level)) + (-> *level* level-default) + ) + ) + ) + (cond + ((not s2-0) + (-> *level* level-default) + (set! s4-0 (the-as (pointer process) #f)) + (goto cfg-260) + ) + ((= (-> s2-0 status) 'reserved) + ) + ((!= (-> s2-0 status) 'active) + (set! s4-0 (the-as (pointer process) #f)) + (goto cfg-260) + ) + ) + (let* ((s4-1 (art-group-get-by-name *level* (-> this art-group) (the-as (pointer level) #f))) + (s3-0 (if (type? s4-1 skeleton-group) + s4-1 + ) + ) + (s0-0 (-> arg0 level)) + (s1-0 + (cond + ((or (string= (-> this name) "jak-highres") + (string= (-> this name) "jak-highres-prison") + (string= (-> this name) "darkjak-highres") + ) + 'jakb + ) + ((string= (-> this name) "jakc-highres") + 'jakc + ) + ) + ) + ) + (set! (-> arg0 level) #f) + (set! s4-0 + (when s3-0 + (let ((s2-1 (if (and (nonzero? (-> s2-0 entity)) (> (-> s2-0 entity length) 0)) + (-> s2-0 entity data 0 entity) + (-> arg0 entity) + ) + ) + ) + (set! sv-96 (get-process *default-dead-pool* manipy #x20000 0)) + (set! s4-0 (when sv-96 + (let ((t9-8 (method-of-type manipy activate))) + (t9-8 (the-as manipy sv-96) arg0 (-> this name) (the-as pointer #x70004000)) + ) + (run-now-in-process + sv-96 + manipy-init + (-> arg0 root trans) + s2-1 + s3-0 + #f + (if (and s1-0 (logtest? (game-secrets big-head little-head) (-> *game-info* secrets))) + 1 + 0 + ) + ) + (-> sv-96 ppointer) + ) + ) + (set! (-> arg0 level) s0-0) + (send-event (ppointer->process s4-0) 'anim-mode 'clone-anim) + (send-event (ppointer->process s4-0) 'blend-shape #t) + (send-event (ppointer->process s4-0) 'prefix (-> this prefix)) + (cond + ((zero? (-> this light-index)) + (if (zero? (-> (the-as skeleton-group s3-0) light-index)) + (send-event (ppointer->process s4-0) 'light-index 80) + ) + ) + (else + (send-event (ppointer->process s4-0) 'light-index (* (-> this light-index) 8)) + ) + ) + (send-event (ppointer->process s4-0) 'shadow-disable-smooth #t) + (if (nonzero? (-> this shadow-mask)) + (send-event (ppointer->process s4-0) 'shadow-mask (* (-> this shadow-mask) 8)) + ) + (if (nonzero? (-> this shadow-values)) + (send-event (ppointer->process s4-0) 'shadow-values (* (-> this shadow-values) 8)) + ) + (if (and s4-0 (not (logtest? (-> this flags) 1)) (nonzero? (-> (the-as process-drawable (-> s4-0 0)) draw))) + (logior! (-> (the-as process-drawable (-> s4-0 0)) draw status) (draw-control-status no-draw-bounds)) + ) + (if (-> this shadow-volume-joint) + (send-event (ppointer->process s4-0) 'shadow-volume (-> this shadow-volume-joint) (-> this shadow-flags)) + ) + (when (or (nonzero? (-> this draw-seg)) (nonzero? (-> this no-draw-seg))) + (send-event (ppointer->process s4-0) 'segment 0 (* (-> this no-draw-seg) 8)) + (send-event (ppointer->process s4-0) 'segment (* (-> this draw-seg) 8) 0) + ) + (when (and s1-0 s4-0 (nonzero? (-> (the-as process-drawable (-> s4-0 0)) draw))) + (cond + ((= s1-0 'jakb) + (if (not (-> *setting-control* user-current beard)) + (send-event (ppointer->process s4-0) 'segment 0 16) + ) + ) + ((= s1-0 'jakc) + (if (not (-> *setting-control* user-current beard)) + (send-event (ppointer->process s4-0) 'segment 0 32) + ) + (if (not (logtest? (game-feature armor0) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 16) + ) + (if (not (logtest? (game-feature armor1) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 256) + ) + (if (not (logtest? (game-feature armor2) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 2048) + ) + (if (not (logtest? (game-feature armor3) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 4096) + ) + (let ((v0-28 (log2 (the-as int (-> (the-as process-drawable (-> s4-0 0)) draw mgeo seg-table (log2 16)))))) + (logior! (-> (the-as process-drawable (-> s4-0 0)) draw mgeo effect v0-28 effect-usage) 8) + ) + ) + ) + (when (nonzero? (-> (the-as manipy (-> s4-0 0)) joint 0)) + (cond + ((logtest? (game-secrets little-head) (-> *game-info* secrets)) + (mode-set! (-> (the-as manipy (-> s4-0 0)) joint 0) (joint-mod-mode joint-set*)) + (trs-set! + (-> (the-as manipy (-> s4-0 0)) joint 0) + (the-as vector #f) + (the-as quaternion #f) + (new 'static 'vector :x 0.4 :y 0.4 :z 0.4 :w 1.0) + ) + ) + ((logtest? (game-secrets big-head) (-> *game-info* secrets)) + (mode-set! (-> (the-as manipy (-> s4-0 0)) joint 0) (joint-mod-mode joint-set*)) + (trs-set! + (-> (the-as manipy (-> s4-0 0)) joint 0) + (the-as vector #f) + (the-as quaternion #f) + (new 'static 'vector :x 2.0 :y 2.0 :z 2.0 :w 1.0) + ) + ) + ) + ) + ) + (when (and s4-0 (logtest? (-> this flags) 2)) + (let ((s1-2 (process-spawn + manipy + :init manipy-init + (-> arg0 root trans) + s2-1 + s3-0 + #f + 0 + :name (-> this name) + :to (ppointer->process s4-0) + :stack-size #x20000 + :unk 0 + ) + ) + ) + (send-event (ppointer->process s1-2) 'mirror #t) + (send-event (ppointer->process s1-2) 'anim-mode 'mirror) + (if (nonzero? (-> this light-index)) + (send-event (ppointer->process s1-2) 'light-index (* (-> this light-index) 8)) + ) + (send-event (ppointer->process s4-0) 'shadow-disable-smooth #t) + (if (nonzero? (-> this shadow-mask)) + (send-event (ppointer->process s1-2) 'shadow-mask (* (-> this shadow-mask) 8)) + ) + (if (nonzero? (-> this shadow-values)) + (send-event (ppointer->process s1-2) 'shadow-values (* (-> this shadow-values) 8)) + ) + (if (and s1-2 (not (logtest? (-> this flags) 1)) (nonzero? (-> (the-as process-drawable (-> s1-2 0)) draw))) + (logior! (-> (the-as process-drawable (-> s1-2 0)) draw status) (draw-control-status no-draw-bounds)) + ) + (if (-> this shadow-volume-joint) + (send-event (ppointer->process s1-2) 'shadow-volume (-> this shadow-volume-joint) (-> this shadow-flags)) + ) + (if (or (nonzero? (-> this draw-seg)) (nonzero? (-> this no-draw-seg))) + (send-event (ppointer->process s1-2) 'segment (* (-> this draw-seg) 8) (* (-> this no-draw-seg) 8)) + ) + ) + ) + ) + (when (and s4-0 (nonzero? (-> this camera))) + (cond + ((handle->process (-> arg0 camera)) + (change-parent (handle->process (-> arg0 camera)) (ppointer->process s4-0)) + (send-event (handle->process (-> arg0 camera)) 'target (ppointer->process s4-0)) + (send-event (handle->process (-> arg0 camera)) 'joint (* (-> this camera) 8)) + ) + (else + (let ((v1-341 (process-spawn + othercam + (ppointer->process s4-0) + (-> this camera) + #t + 'scene-player + :name "othercam" + :to (ppointer->process s4-0) + ) + ) + ) + (if v1-341 + (set! (-> arg0 camera) (ppointer->handle v1-341)) + ) + ) + ) + ) + ) + s4-0 + ) + ) + ) + ) + (label cfg-260) + s4-0 + ) + +(defmethod deactivate ((this scene-player)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (set! *debug-menu-scene-play* (the-as object #f)) + (set! *scene-player* (the-as (pointer scene-player) #f)) + (kill-persister *setting-control* (the-as engine-pers 'blackout) 'bg-a-force) + (kill-persister *setting-control* (the-as engine-pers 'blur-a) 'blur-a) + ((method-of-type process-drawable deactivate) this) + (none) + ) + +;; WARN: Return type mismatch process-drawable vs scene-player. +(defmethod relocate ((this scene-player) (offset int)) + (let ((v1-0 *kernel-context*)) + (set! (-> v1-0 relocating-process) this) + (set! (-> v1-0 relocating-min) (the-as int (&-> this type))) + (set! (-> v1-0 relocating-max) + (the-as int (+ (+ (-> this allocated-length) -4 (-> process size)) (the-as int this))) + ) + (set! (-> v1-0 relocating-offset) offset) + ) + (let ((v1-2 (-> this scene-list))) + (if (and (>= (the-as int v1-2) (-> *kernel-context* relocating-min)) + (< (the-as int v1-2) (-> *kernel-context* relocating-max)) + ) + (&+! (-> this scene-list) offset) + ) + ) + (the-as scene-player ((method-of-type process-drawable relocate) this offset)) + ) + +;; WARN: disable def twice: 288. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: disable def twice: 365. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defmethod scene-player-method-25 ((this scene-player) (arg0 float) (arg1 float)) + (local-vars + (v1-12 symbol) + (v1-47 symbol) + (v1-73 symbol) + (v1-105 symbol) + (sv-96 object) + (sv-112 object) + (sv-128 object) + (sv-144 object) + (sv-160 object) + (sv-176 object) + (sv-192 object) + (sv-208 object) + (sv-224 object) + ) + (dotimes (s3-0 (-> this scene actor length)) + (let ((s2-0 (-> this scene actor s3-0))) + (let* ((s1-0 (-> s2-0 draw-frames)) + (s0-0 (car s1-0)) + ) + (while (not (null? s1-0)) + (when (and (pair? s0-0) + (let ((a0-4 (car s0-0))) + (set! sv-96 (car (cdr s0-0))) + (or (= a0-4 'min) (>= arg0 (command-get-float a0-4 0.0))) + ) + (or (= sv-96 'max) (< arg0 (command-get-float (car (cdr s0-0)) 0.0))) + ) + (set! v1-12 #t) + (goto cfg-20) + ) + (set! s1-0 (cdr s1-0)) + (set! s0-0 (car s1-0)) + ) + ) + (set! v1-12 #f) + (label cfg-20) + (cond + (v1-12 + (if (not (handle->process (-> s2-0 process))) + (set! (-> s2-0 process) (ppointer->handle (setup-manipy-for-scene! s2-0 this))) + ) + (let ((s1-1 (handle->process (-> s2-0 process)))) + (when (and s1-1 (nonzero? (-> (the-as process-drawable s1-1) draw))) + (let ((s0-1 (-> s2-0 scissor-frames))) + (set! sv-112 (car s0-1)) + (while (not (null? s0-1)) + (when (and (pair? sv-112) + (let ((a0-21 (car sv-112))) + (set! sv-128 (car (cdr sv-112))) + (or (= a0-21 'min) (>= arg0 (command-get-float a0-21 0.0))) + ) + (or (= sv-128 'max) (< arg0 (command-get-float (car (cdr sv-112)) 0.0))) + ) + (set! v1-47 #t) + (goto cfg-59) + ) + (set! s0-1 (cdr s0-1)) + (set! sv-112 (car s0-1)) + ) + ) + (set! v1-47 #f) + (label cfg-59) + (if v1-47 + (logclear! (-> (the-as process-drawable s1-1) draw status) (draw-control-status force-vu1)) + (logior! (-> (the-as process-drawable s1-1) draw status) (draw-control-status force-vu1)) + ) + (let ((s0-2 (-> s2-0 shadow-frames))) + (set! sv-144 (car s0-2)) + (while (not (null? s0-2)) + (when (and (pair? sv-144) + (let ((a0-30 (car sv-144))) + (set! sv-160 (car (cdr sv-144))) + (or (= a0-30 'min) (>= arg0 (command-get-float a0-30 0.0))) + ) + (or (= sv-160 'max) (< arg0 (command-get-float (car (cdr sv-144)) 0.0))) + ) + (set! v1-73 #t) + (goto cfg-81) + ) + (set! s0-2 (cdr s0-2)) + (set! sv-144 (car s0-2)) + ) + ) + (set! v1-73 #f) + (label cfg-81) + (if v1-73 + (send-event s1-1 'shadow #t) + (send-event s1-1 'shadow #f) + ) + (let ((s0-3 (-> s2-0 cloth-reset-frames))) + (set! sv-192 (car s0-3)) + (while (not (null? s0-3)) + (let ((v1-97 (cond + ((pair? sv-192) + (let ((a0-38 (car sv-192))) + (set! sv-176 (car (cdr sv-192))) + (and (or (= a0-38 'min) (>= arg0 (+ -1.0 (command-get-float a0-38 0.0)))) + (or (= sv-176 'max) (< arg0 (+ 1.0 (command-get-float (car (cdr sv-192)) 0.0)))) + ) + ) + ) + (else + (let* ((t9-11 command-get-float) + (a1-18 0.0) + (f0-10 (t9-11 sv-192 a1-18)) + ) + (and (< arg1 f0-10) (>= arg0 f0-10)) + ) + ) + ) + ) + ) + (when v1-97 + (set! v1-105 #t) + (goto cfg-113) + ) + ) + (set! s0-3 (cdr s0-3)) + (set! sv-192 (car s0-3)) + ) + ) + (set! v1-105 #f) + (label cfg-113) + (if v1-105 + (process-drawable-cloth-command (the-as process-drawable s1-1) '(scene-reset-frame)) + ) + (let* ((s2-1 (-> s2-0 cloth-commands)) + (s0-4 (car s2-1)) + ) + (while (not (null? s2-1)) + (when (pair? s0-4) + (set! sv-224 (car s0-4)) + (let ((v1-121 (cond + ((pair? sv-224) + (let ((a0-44 (car sv-224))) + (set! sv-208 (car (cdr sv-224))) + (and (or (= a0-44 'min) (>= arg0 (command-get-float a0-44 0.0))) + (or (= sv-208 'max) (< arg0 (command-get-float (car (cdr sv-224)) 0.0))) + ) + ) + ) + (else + (let* ((t9-15 command-get-float) + (a1-23 0.0) + (f0-13 (t9-15 sv-224 a1-23)) + ) + (and (< arg1 f0-13) (>= arg0 f0-13)) + ) + ) + ) + ) + ) + (if v1-121 + (process-drawable-cloth-command (the-as process-drawable s1-1) (cdr s0-4)) + ) + ) + ) + (set! s2-1 (cdr s2-1)) + (set! s0-4 (car s2-1)) + ) + ) + ) + ) + 0 + ) + ((handle->process (-> s2-0 process)) + (deactivate (handle->process (-> s2-0 process))) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch basic vs scene. +(defun scene-lookup ((arg0 basic)) + (the-as + scene + (case (-> arg0 type) + ((string) + (let ((s5-0 (art-group-get-by-name *level* (the-as string arg0) (the-as (pointer level) #f)))) + (when (type? s5-0 scene) + (let ((gp-0 (get-level-by-heap-ptr-and-status *level* (the-as pointer s5-0) 'active))) + (when (and s5-0 gp-0) + (let ((s4-0 (scene-decode-continue (-> s5-0 data 15)))) + (when s4-0 + (dotimes (s3-0 (-> s4-0 want-count)) + (if (= (-> gp-0 name) (-> s4-0 want s3-0 name)) + (goto cfg-25) + ) + (let ((v1-14 (lookup-level-info (-> s4-0 want s3-0 name)))) + (if (and v1-14 (-> v1-14 borrow) (-> v1-14 borrow alias) (member (-> gp-0 name) (-> v1-14 borrow alias))) + (goto cfg-25) + ) + ) + ) + (format + 0 + "WARNING: can not find scene level ~A in continue ~A, dropping scene until after load~%" + (-> gp-0 name) + (-> s4-0 name) + ) + (return (the-as scene #f)) + ) + ) + ) + ) + (label cfg-25) + s5-0 + ) + ) + ) + ((scene) + arg0 + ) + ) + ) + ) + +(defmethod scene-player-method-24 ((this scene-player) (arg0 scene) (arg1 symbol)) + (when (= (-> arg0 type) string) + (let ((v1-2 (scene-lookup arg0))) + (if v1-2 + (set! arg0 v1-2) + ) + ) + ) + (when (or (not arg0) (!= (-> arg0 type) scene)) + (format 0 "ERROR: SCENE: scene-player can not find scene ~A~%" arg0) + (go process-drawable-art-error "scene-list format") + ) + (when arg1 + (let ((s4-1 (get-level-by-heap-ptr-and-status *level* (the-as pointer arg0) 'active))) + (init-spool-by-scene! arg0 (-> this anim)) + (set! (-> this level) s4-1) + ) + (set! (-> this scene) arg0) + ) + arg0 + ) + +(defmethod scene-player-method-23 ((this scene-player) (arg0 string) (arg1 symbol)) + (let ((gp-0 (scene-player-method-24 this (the-as scene arg0) #t))) + (when (logtest? (-> gp-0 scene-flags) (scene-flags scf3)) + (let ((a0-2 *traffic-manager*)) + (send-event a0-2 'restore-default-settings) + ) + ) + (send-event *target* 'draw (logtest? (-> gp-0 scene-flags) (scene-flags scf0))) + (let ((s3-0 (entity-by-name (-> gp-0 entity)))) + (when (and (-> gp-0 entity) (not s3-0)) + (format 0 "ERROR: SCENE: scene ~A can not find entity ~A~%" (-> gp-0 name) (-> gp-0 entity)) + (go process-drawable-art-error (-> gp-0 entity)) + ) + (set! (-> this main-entity) (the-as entity-actor s3-0)) + (cond + (s3-0 + (process-drawable-from-entity! this (-> this main-entity)) + (logclear! (-> this mask) (process-mask actor-pause)) + ) + (else + (vector-reset! (-> this root trans)) + (quaternion-identity! (-> this root quat)) + ) + ) + ) + (let ((s3-1 (load-to-heap-by-name (-> *level* level-default art-group) (-> gp-0 art-group) 'load global 0))) + (when (not s3-1) + (format 0 "ERROR: SCENE: scene ~A can not find art-group ~A~%" (-> gp-0 name) (-> gp-0 art-group)) + (go process-drawable-art-error (-> gp-0 art-group)) + ) + (set! (-> this draw art-group) s3-1) + (countdown (v1-31 (-> s3-1 length)) + (when (-> s3-1 data v1-31) + (cond + ((= (-> s3-1 data v1-31 type) merc-ctrl) + (set! (-> this draw mgeo) (the-as merc-ctrl (-> s3-1 data v1-31))) + ) + ((= (-> s3-1 data v1-31 type) art-joint-geo) + (set! (-> this draw jgeo) (the-as art-joint-geo (-> s3-1 data v1-31))) + ) + ) + ) + ) + ) + (cond + ((< (+ (-> this scene-index) 1) (-> this scene-list length)) + (let ((a0-34 (scene-player-method-24 this (-> this scene-list (+ (-> this scene-index) 1)) #f))) + (cond + (a0-34 + (init-spool-by-scene! a0-34 (-> this next-anim)) + ) + (else + (set! (-> this next-anim anim-name) (the-as string 0)) + 0 + ) + ) + ) + ) + (else + (set! (-> this next-anim anim-name) (the-as string 0)) + 0 + ) + ) + (dotimes (s3-2 (-> gp-0 actor length)) + (let ((s2-0 (-> gp-0 actor s3-2))) + (set! (-> s2-0 process) (the-as handle #f)) + (let ((s1-0 (if (-> s2-0 level) + (level-get *level* (-> s2-0 level)) + (-> *level* level-default) + ) + ) + (v1-53 (when level + (let ((s0-0 (art-group-get-by-name *level* (-> s2-0 art-group) (the-as (pointer level) #f)))) + (if (type? s0-0 skeleton-group) + s0-0 + ) + ) + ) + ) + ) + (cond + ((or (not s1-0) (not (or (= (-> s1-0 status) 'active) (= (-> s1-0 status) 'reserved)))) + (format + 0 + "ERROR: SCENE: scene actor ~A can not find an active level ~A~%" + (-> s2-0 art-group) + (-> s2-0 level) + ) + ) + ((not v1-53) + (format + 0 + "ERROR: SCENE: scene actor ~A can not find skeleton-group ~A~%" + (-> s2-0 art-group) + (-> s2-0 art-group) + ) + ) + (else + (load-to-heap-by-name (-> s1-0 art-group) (the-as string (-> v1-53 data 0)) 'load global 0) + ) + ) + ) + ) + ) + (process-entity-status! this (entity-perm-status no-kill) #t) + (when arg1 + (kill-persister *setting-control* (the-as engine-pers 'fail-sfx-volume) 'sfx-volume) + (kill-persister *setting-control* (the-as engine-pers 'fail-dialog-volume) 'dialog-volume) + (kill-persister *setting-control* (the-as engine-pers 'fail-music-volume) 'music-volume) + (set-setting! 'region-mode #f 0.0 0) + (set-setting! 'process-mask 'set 0.0 (-> gp-0 mask-to-clear)) + (if (logtest? (-> gp-0 mask-to-clear) (process-mask movie)) + (set-setting! 'letterbox 'abs 1.0 0) + ) + (set-setting! 'sound-bank-load #f 0.0 0) + (set-setting! 'movie (process->ppointer this) 0.0 0) + (set-setting! 'movie-name (-> gp-0 name) 0.0 0) + (let ((f30-0 (if (>= (-> gp-0 music-volume) 0.0) + (-> gp-0 music-volume) + (-> *setting-control* user-current music-volume-movie) + ) + ) + ) + (set-setting! 'music-volume 'rel f30-0 0) + (set-setting! + 'sfx-volume + 'rel + (if (>= (-> gp-0 sfx-volume) 0.0) + (-> gp-0 sfx-volume) + (-> *setting-control* user-current sfx-volume-movie) + ) + 0 + ) + (set-setting! + 'ambient-volume + 'rel + (if (>= (-> gp-0 ambient-volume) 0.0) + (-> gp-0 ambient-volume) + (-> *setting-control* user-current ambient-volume-movie) + ) + 0 + ) + (when (nonzero? (the int (-> gp-0 music-delay))) + (set-setting! 'music-volume 'abs 0.0 0) + (set! f30-0 0.0) + ) + (remove-setting! 'music) + (if (= f30-0 0.0) + (set-setting! 'music #f 0.0 0) + ) + ) + (set-setting! 'gem #f 0.0 0) + (set-setting! 'citizen-fights #f 0.0 0) + (apply-settings *setting-control*) + ) + ) + 0 + (none) + ) + +(deftype subtitle-work (structure) + ((draw-tmpl dma-gif-packet :inline) + (color0 vector4w :inline) + (color1 vector4w :inline) + ) + ) + + +(define *subtitle-work* (new 'static 'subtitle-work + :draw-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x50ab400000008001 #x53531) + ) + :color0 (new 'static 'vector4w :w #x80) + :color1 (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + ) + ) + +;; WARN: Return type mismatch pointer vs none. +(defun draw-subtitle-image ((arg0 subtitle-image) (arg1 font-context)) + (local-vars (sv-16 pointer) (sv-32 int)) + (let ((gp-0 (-> arg0 width)) + (s5-0 (-> arg0 height)) + ) + (let ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (set! sv-16 (-> s4-0 base)) + (unpack-comp-rle (the-as (pointer int8) sv-16) (the-as (pointer int8) (-> arg0 data))) + (&+! (-> s4-0 base) (logand -16 (+ (shr (* gp-0 s5-0) 1) 15))) + ) + (with-dma-buffer-add-bucket ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hud-draw-pris2) + ) + (upload-vram-data s3-0 0 (-> arg0 palette) 2 8) + (let ((s0-0 20)) + (dma-buffer-add-gs-set s3-0 + (bitbltbuf (new 'static 'gs-bitbltbuf :dbp #x1 :dbw (shr gp-0 6) :dpsm s0-0)) + (trxpos (new 'static 'gs-trxpos)) + (trxreg (new 'static 'gs-trxreg :rrw gp-0 :rrh s5-0)) + (trxdir (new 'static 'gs-trxdir)) + ) + (let ((t9-2 dma-buffer-add-ref-texture) + (a0-13 s3-0) + (a2-8 gp-0) + (a3-1 s5-0) + (t0-1 s0-0) + ) + (t9-2 a0-13 sv-16 (the-as int a2-8) (the-as int a3-1) (the-as gs-psm t0-1)) + ) + (set! sv-32 (+ (log2 (the-as int (+ gp-0 -1))) 1)) + (let ((v1-17 (+ (log2 (the-as int (+ s5-0 -1))) 1))) + (dma-buffer-add-gs-set s3-0 + (test-1 (new 'static 'gs-test :ate #x1 :afail #x3 :zte #x1 :ztst (gs-ztest always))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (tex0-1 (new 'static 'gs-tex0 :tbp0 #x1 :tcc #x1 :cld #x1 :psm s0-0 :th v1-17 :tw sv-32 :tbw (shr gp-0 6))) + (tex1-1 (new 'static 'gs-tex1)) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (texflush 0) + ) + ) + ) + (let* ((v1-28 (-> s3-0 base)) + (a2-23 + (+ (- 1793 (the-as int (shr (-> arg0 width) 1))) (the int (+ (-> arg1 origin x) (* 0.5 (-> arg1 width))))) + ) + (a3-8 (+ (the int (-> arg1 origin y)) 1841)) + (a0-23 (+ a2-23 (-> arg0 width))) + (a1-33 (+ a3-8 (-> arg0 height))) + ) + (set! (-> (the-as (pointer uint128) v1-28) 0) (-> *subtitle-work* draw-tmpl dma-vif quad)) + (set! (-> (the-as (pointer uint128) v1-28) 1) (-> *subtitle-work* draw-tmpl quad 1)) + (set! (-> (the-as (pointer uint128) v1-28) 2) (-> *subtitle-work* color0 quad)) + (set-vector! (the-as vector4w (&+ v1-28 48)) 0 0 0 0) + (set-vector! (the-as vector4w (&+ v1-28 64)) (the-as int (* a2-23 16)) (* a3-8 16) 0 0) + (set-vector! (the-as vector4w (&+ v1-28 80)) (the-as int (* gp-0 16)) (the-as int (* s5-0 16)) 0 0) + (set-vector! (the-as vector4w (&+ v1-28 96)) (the-as int (* a0-23 16)) (* a1-33 16) 0 0) + ) + (&+! (-> s3-0 base) 112) + (let* ((v1-32 (-> s3-0 base)) + (a1-38 + (+ (- 1792 (the-as int (shr (-> arg0 width) 1))) (the int (+ (-> arg1 origin x) (* 0.5 (-> arg1 width))))) + ) + (a3-11 (+ (the int (-> arg1 origin y)) 1840)) + (a0-30 (+ a1-38 (-> arg0 width))) + (a2-28 (+ a3-11 (-> arg0 height))) + ) + (set! (-> (the-as (pointer uint128) v1-32) 0) (-> *subtitle-work* draw-tmpl dma-vif quad)) + (set! (-> (the-as (pointer uint128) v1-32) 1) (-> *subtitle-work* draw-tmpl quad 1)) + (set! (-> (the-as (pointer uint128) v1-32) 2) (-> *subtitle-work* color1 quad)) + (set-vector! (the-as vector4w (&+ v1-32 48)) 0 0 0 0) + (set-vector! (the-as vector4w (&+ v1-32 64)) (the-as int (* a1-38 16)) (* a3-11 16) 0 0) + (set-vector! (the-as vector4w (&+ v1-32 80)) (the-as int (* gp-0 16)) (the-as int (* s5-0 16)) 0 0) + (set-vector! (the-as vector4w (&+ v1-32 96)) (the-as int (* a0-30 16)) (* a2-28 16) 0 0) + ) + (&+! (-> s3-0 base) 112) + (set-dirty-mask! (-> *level* level-default) 8 (the-as int (* gp-0 s5-0)) 256) + ) + ) + (none) + ) + +(defbehavior process-drawable-draw-subtitles process-drawable () + (when (and (nonzero? (-> self skel)) + (> (-> self skel active-channels) 0) + (-> *setting-control* user-current subtitle) + ) + (let ((v1-9 (-> self skel root-channel 0 frame-group))) + (when v1-9 + (let ((gp-0 (res-lump-struct (-> v1-9 extra) 'subtitle-range (array subtitle-range)))) + (when gp-0 + (let ((f30-0 (ja-aframe-num 0)) + (s5-0 (the-as int (-> *setting-control* user-current subtitle-language))) + ) + (if (and (= (the-as language-enum s5-0) (language-enum english)) (= (scf-get-territory) 1)) + (set! s5-0 11) + ) + (dotimes (s4-0 (-> gp-0 length)) + (let ((v1-16 (-> gp-0 s4-0))) + (when (and (>= f30-0 (-> v1-16 start-frame)) (< f30-0 (-> v1-16 end-frame))) + (let ((s3-0 (-> v1-16 message s5-0))) + (when (and s3-0 (nonzero? s3-0)) + (let ((s2-0 + (new 'stack 'font-context *font-default-matrix* 20 290 0.0 (font-color default) (font-flags shadow kerning)) + ) + ) + (let ((v1-20 s2-0)) + (set! (-> v1-20 width) (the float 465)) + ) + (let ((v1-21 s2-0)) + (set! (-> v1-21 height) (the float 70)) + ) + (let ((v1-22 s2-0)) + (set! (-> v1-22 scale) 0.5) + ) + (set! (-> s2-0 flags) (font-flags shadow kerning middle large)) + (case (-> s3-0 type) + ((string) + (when (= (-> *setting-control* user-default subtitle-language) (language-enum korean)) + (set! s3-0 (convert-korean-text (the-as string s3-0))) + (let ((v1-27 s2-0)) + (set! (-> v1-27 scale) 0.6) + ) + ) + (when (= (-> *setting-control* user-default subtitle-language) (language-enum russian)) + (let ((v1-30 s2-0)) + (set! (-> v1-30 scale) 0.75) + ) + ) + (set! (-> s2-0 flags) (font-flags kerning middle middle-vert large)) + (+! (-> s2-0 origin x) -1.0) + (+! (-> s2-0 origin y) -1.0) + (set! (-> s2-0 color) (font-color font-color-39)) + (+! (-> s2-0 origin x) 1.0) + (+! (-> s2-0 origin y) 1.0) + (set! (-> s2-0 color) (font-color default)) + (set! (-> s2-0 flags) (font-flags shadow kerning middle middle-vert large)) + (print-game-text (the-as string s3-0) s2-0 #f 44 (bucket-id hud-draw-pris2)) + (gui-control-method-12 + *gui-control* + self + (gui-channel subtitle) + (gui-action play) + "scene" + 0 + 81920.0 + (new 'static 'sound-id) + ) + ) + ((subtitle-image) + (draw-subtitle-image (the-as subtitle-image s3-0) s2-0) + ) + (else + (if *debug-segment* + (format *stdcon* "unknown message ~A~%" s3-0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defstate wait (scene-player) + :virtual #t + :enter (behavior ((arg0 symbol)) + (set-time! (-> self state-time)) + (if (= (-> *game-info* demo-state) 101) + (set-setting! 'audio-language #f 0.0 5) + ) + (when (or (-> self scene) (-> self preload-continue)) + (let ((gp-0 (scene-decode-continue (if (-> self scene) + (-> self scene load-point) + (-> self preload-continue) + ) + ) + ) + ) + (when gp-0 + (when (-> self scene) + (set-setting! 'borrow (-> self scene borrow) 0.0 0) + (apply-settings *setting-control*) + ) + (cond + ((and *target* + (zero? (-> self scene-index)) + (or (not (-> self scene)) + (!= (status-of-level-and-borrows *level* (-> gp-0 vis-nick) #f) 'active) + (logtest? (-> self scene scene-flags) (scene-flags scf5)) + ) + ) + (send-event *target* 'continue gp-0) + ) + (else + (let ((a0-16 (lookup-level-info (-> gp-0 vis-nick)))) + (set! (-> *load-state* vis-nick) (if a0-16 + (-> a0-16 name) + ) + ) + ) + (dotimes (v1-28 10) + (cond + ((< v1-28 (-> gp-0 want-count)) + (set! (-> *load-state* want v1-28 name) (-> gp-0 want v1-28 name)) + (set! (-> *load-state* want v1-28 display?) (-> gp-0 want v1-28 display?)) + ) + (else + (set! (-> *load-state* want v1-28 name) #f) + (set! (-> *load-state* want v1-28 display?) #f) + ) + ) + (set! (-> *load-state* want v1-28 force-vis?) #f) + (set! (-> *load-state* want v1-28 force-inside?) #f) + ) + (update-task-masks 'event) + ) + ) + ) + ) + ) + ) + :trans (behavior () + (if (and (-> self scene) (nonzero? (-> self anim anim-name)) (not (load-in-progress? *level*))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> self anim name) + 0 + -1.0 + (new 'static 'sound-id) + ) + ) + (set! (-> *ACTOR-bank* birth-max) 1000) + ) + :code (behavior ((arg0 symbol)) + (local-vars (v1-18 symbol) (v1-124 symbol)) + (when (and (-> self scene) (zero? (-> self scene wait-max-time))) + (while *progress-process* + (suspend) + ) + (set-setting! 'allow-progress #f 0.0 0) + (set-setting! 'bg-a-force 'abs 1.0 0) + (apply-settings *setting-control*) + ) + (if (or (not *target*) + (or (focus-test? *target* grabbed) + (begin + (dotimes (v1-17 10) + (when (and (-> *target* current-level) (= (-> *load-state* target v1-17 name) (-> *target* current-level name))) + (set! v1-18 #f) + (goto cfg-22) + ) + ) + #t + (set! v1-18 #t) + (label cfg-22) + (or v1-18 (not (-> self scene))) + ) + ) + ) + (set! arg0 #f) + ) + (while (and arg0 + (or (focus-test? *target* in-air) + (and (-> *target* next-state) (= (-> *target* next-state name) 'target-flop-hit-ground)) + ) + (-> self scene) + (not (time-elapsed? (-> self state-time) (-> self scene wait-air-time))) + ) + (suspend) + ) + (suspend) + (let ((s5-0 (current-time))) + (when (and *target* (not (logtest? (-> *target* focus-status) (focus-status grabbed)))) + (label cfg-47) + (send-event *target* 'end-mode 'freeze 'force) + (when (not (process-grab? *target* #f)) + (suspend) + (goto cfg-47) + ) + ) + (process-entity-status! self (entity-perm-status no-kill) #t) + (until (not (or (-> *setting-control* user-current talking) + (-> *setting-control* user-current spooling) + (-> *setting-control* user-current hint) + (-> *setting-control* user-current ambient) + ) + ) + (set-setting! 'allow-progress #f 0.0 0) + (apply-settings *setting-control*) + (dotimes (s4-0 2) + (while (or (-> *setting-control* user-current talking) + (-> *setting-control* user-current spooling) + (-> *setting-control* user-current hint) + (-> *setting-control* user-current ambient) + (or (and (-> *setting-control* user-current movie) + (!= (-> *setting-control* user-current movie) (process->ppointer self)) + ) + *progress-process* + (!= (get-status *gui-control* (-> self gui-id)) 3) + ) + ) + (suspend) + ) + ) + (when arg0 + (while (and (-> self scene) (not (or (time-elapsed? s5-0 (-> self scene wait-ground-time)) + (time-elapsed? (-> self state-time) (-> self scene wait-max-time)) + ) + ) + ) + (suspend) + ) + ) + (remove-setting! 'movie) + (remove-setting! 'sound-bank-load) + (remove-setting! 'movie-name) + (remove-setting! 'bg-a-force) + (apply-settings *setting-control*) + (set-blackout-frames (seconds 0.1)) + (suspend) + (set-blackout-frames (seconds 0.1)) + (suspend) + ) + ) + (send-event *target* 'trans 'save (-> self old-target-pos)) + (let ((gp-1 *load-state*)) + (when gp-1 + (dotimes (s5-1 2) + (while (begin + (dotimes (s4-1 10) + (when (not (or (not (-> gp-1 want s4-1 name)) + (not (-> gp-1 want s4-1 display?)) + (= (status-of-level-and-borrows *level* (-> gp-1 want s4-1 name) 'all) 'active) + ) + ) + (set! v1-124 #t) + (goto cfg-114) + ) + ) + (set! v1-124 #f) + (label cfg-114) + v1-124 + ) + (set-blackout-frames (seconds 0.1)) + (suspend) + ) + (when (and (zero? s5-1) (< (-> self scene-index) (-> self scene-list length))) + (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t) + (when (-> self scene) + (set-setting! 'borrow (-> self scene borrow) 0.0 0) + (apply-settings *setting-control*) + ) + ) + ) + ) + ) + (when (and *target* (focus-test? *target* in-head flut light board pilot mech dark)) + (send-event *target* 'change-mode 'normal) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak-mode) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak-effect-1) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak-effect-2) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (when (< (-> self scene-index) (-> self scene-list length)) + (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t) + (while (and (-> self scene) + (nonzero? (-> self anim anim-name)) + (let ((v1-175 (file-status *art-control* (-> self anim name) 0))) + (or (not (or (= v1-175 'active) (= v1-175 'locked))) + (let* ((a1-32 + (lookup-gui-connection-id *gui-control* (-> self anim anim-name) (gui-channel art-load) (gui-action none)) + ) + (v1-181 (get-status *gui-control* a1-32)) + ) + (not (or (= v1-181 (gui-status ready)) (= v1-181 (gui-status active)))) + ) + ) + ) + ) + (set-blackout-frames (seconds 0.1)) + (suspend) + ) + ) + (go-virtual play-anim) + ) + ) + +(defstate release (scene-player) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('user-data-set!) + (let ((v0-0 (-> block param 0))) + (set! (-> self user-data) v0-0) + v0-0 + ) + ) + (('user-data) + (-> self user-data) + ) + ) + ) + :code (behavior () + (remove-setting! 'borrow) + (when (scene-select?) + (remove-setting! 'audio-language) + (logclear! (-> self mask) (process-mask pause progress)) + (set-blackout-frames (seconds 0.05)) + (set-setting! 'music-volume 'abs 0.0 0) + (set-setting! 'sfx-volume 'abs 0.0 0) + (set-setting! 'ambient-volume 'abs 0.0 0) + (set-setting! 'allow-pause #f 0.0 0) + (set-setting! 'allow-progress #f 0.0 0) + (setup + *screen-filter* + (new 'static 'vector) + (new 'static 'vector :w 128.0) + (* 30.0 (seconds-per-frame)) + (bucket-id tex-hud-pris2) + #x3fffff + #x33001 + #t + ) + (let ((gp-0 (current-time))) + (until (time-elapsed? gp-0 (seconds 0.05)) + (suspend) + ) + ) + (set! (-> *setting-control* user-current bg-a) 0.0) + (remove-setting! 'movie) + (remove-setting! 'movie-name) + (while (or (-> *setting-control* user-current movie) + (not *target*) + (or (!= (-> *setting-control* user-current bg-a) 0.0) (load-in-progress? *level*)) + ) + (suspend) + ) + (set! (-> *game-info* blackout-time) 0) + (set! (-> *game-info* demo-state) (the-as uint 1)) + (set! (-> *setting-control* user-current bg-a-force) 0.0) + (set-setting! 'allow-progress #t 0.0 0) + (remove-setting! 'process-mask) + (remove-setting! 'letterbox) + (apply-settings *setting-control*) + (send-event *target* 'draw #t) + (send-event *target* 'trans 'reset) + (send-event *target* 'change-mode 'normal) + (activate-progress *dproc* 'select-scene-special) + (dotimes (gp-1 5) + (suspend) + ) + (disable *screen-filter*) + (deactivate self) + ) + (when (< (-> self scene-index) (+ (-> self scene-list length) -1)) + (set! (-> self scene-index) (+ (-> self scene-list length) -1)) + (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t) + ) + (let ((gp-2 (or (not (-> self scene)) (if (= (-> self blackout-end) 'none) + (logtest? (-> self scene scene-flags) (scene-flags scf2)) + (-> self blackout-end) + ) + ) + ) + ) + (if gp-2 + (set-blackout-frames (seconds 0.1)) + ) + (send-event *target* 'draw #t) + (send-event *target* 'trans 'reset) + (suspend) + (while (not (process-release? *target*)) + (suspend) + (if gp-2 + (set-blackout-frames (seconds 0.1)) + ) + ) + (if gp-2 + (set-blackout-frames (seconds 0.1)) + ) + ) + (when (nonzero? (the int (-> self scene music-delay))) + (persist-with-delay + *setting-control* + 'music-volume-movie + (the-as time-frame (the int (-> self scene music-delay))) + 'music-volume + 'abs + 0.0 + 0 + ) + (persist-with-delay + *setting-control* + 'music-delay + (the-as time-frame (the int (-> self scene music-delay))) + 'music + #f + 0.0 + 0 + ) + ) + (cond + ((and *target* (-> self scene) (or (-> self end-point) (-> self scene end-point))) + (let ((t9-32 scene-decode-continue) + (a0-37 (-> self end-point)) + ) + (set! a0-37 (cond + (a0-37 + (empty) + a0-37 + ) + (else + (-> self scene end-point) + ) + ) + ) + (let ((gp-4 (t9-32 a0-37))) + (when gp-4 + (persist-with-delay + *setting-control* + 'fail-sfx-volume + (seconds 10) + 'sfx-volume + 'abs + (-> *setting-control* user-target sfx-volume) + 0 + ) + (persist-with-delay + *setting-control* + 'fail-music-volume + (seconds 10) + 'music-volume + 'abs + (-> *setting-control* user-target music-volume) + 0 + ) + (persist-with-delay + *setting-control* + 'fail-dialog-volume + (seconds 10) + 'dialog-volume + 'abs + (-> *setting-control* user-target dialog-volume) + 0 + ) + (set-continue! *game-info* gp-4 #f) + (send-event *target* 'continue gp-4) + ) + ) + ) + ) + (else + (send-event *target* 'trans 'restore (-> self old-target-pos)) + ) + ) + (if (and (-> self scene) (logtest? (-> self scene scene-flags) (scene-flags scf4))) + (auto-save-user) + ) + (when (and (-> self scene) (-> self scene on-complete)) + (while (and *target* (focus-test? *target* teleporting)) + (suspend) + ) + (script-eval (-> self scene on-complete)) + ) + ) + ) + +(defstate play-anim (scene-player) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object)) + (case message + (('trans-hook) + (set! v0-0 (-> block param 0)) + (set! (-> self new-trans-hook) (the-as (function none) v0-0)) + v0-0 + ) + (('eval) + ((the-as (function scene-player none) (-> block param 0)) self) + ) + (('abort) + (set! (-> self aborted?) #t) + (set-blackout-frames (seconds 0.2)) + (let ((a0-9 (-> self anim))) + (when (and a0-9 (= (-> *setting-control* user-current spooling) (process->ppointer self))) + (ja-abort-spooled-anim a0-9 (the-as art-joint-anim #f) -1) + (ja-channel-set! 0) + ) + ) + (go-virtual release) + ) + (('change-entity) + (let ((v1-9 (entity-by-name (the-as string (-> block param 0))))) + (set! (-> self main-entity) (the-as entity-actor v1-9)) + (cond + (v1-9 + (process-drawable-from-entity! self (-> self main-entity)) + (set! v0-0 (logclear (-> self mask) (process-mask actor-pause))) + (set! (-> self mask) (the-as process-mask v0-0)) + v0-0 + ) + (else + (format 0 "ERROR: SCENE: scene ~A can not find entity ~A~%" (-> self scene name) (-> block param 0)) + (vector-reset! (-> self root trans)) + (quaternion-identity! (-> self root quat)) + ) + ) + ) + ) + (('user-data-set!) + (set! v0-0 (-> block param 0)) + (set! (-> self user-data) (the-as uint v0-0)) + v0-0 + ) + (('user-data) + (-> self user-data) + ) + ) + ) + :enter (behavior () + (set-setting! 'ambient-wind-scalar #f 0.0 0) + (if (and (logtest? (-> self scene scene-flags) (scene-flags scf6)) *rigid-body-queue-manager*) + (change-parent self *rigid-body-queue-manager*) + ) + ) + :exit (behavior () + (while (-> self child) + (deactivate (-> self child 0)) + ) + (kill-current-talker '() '(daxter voicebox message) 'exit) + (set! (-> *setting-control* user-current bg-a) 0.0) + (kill-persister *setting-control* (the-as engine-pers 'bg-a) 'bg-a) + (kill-persister *setting-control* (the-as engine-pers 'bg-a-speed) 'bg-a-speed) + (if (not (and (-> self next-state) (= (-> self next-state name) 'wait))) + (remove-setting! 'borrow) + ) + (remove-setting! 'gem) + (apply-settings *setting-control*) + ) + :trans (behavior () + (if (!= (-> self cur-trans-hook) (-> self new-trans-hook)) + (set! (-> self cur-trans-hook) (-> self new-trans-hook)) + ) + (cond + ((not (-> *setting-control* user-current spooling)) + (if (and (-> self scene) (nonzero? (-> self anim anim-name))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> self anim name) + 0 + -1.0 + (new 'static 'sound-id) + ) + ) + ) + (else + (if (and (-> self scene) (nonzero? (-> self next-anim anim-name))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> self next-anim name) + 0 + -1.0 + (new 'static 'sound-id) + ) + ) + ) + ) + (when (logtest? (-> self scene scene-flags) (scene-flags scf6)) + (let ((v1-26 (handle->process (-> *target* pilot vehicle)))) + (when v1-26 + (set! (-> self root trans quad) (-> (the-as process-drawable v1-26) root trans quad)) + (quaternion-copy! (-> self root quat) (-> (the-as process-drawable v1-26) root quat)) + ) + ) + ) + (if (and (-> self scene) (-> self scene on-running)) + (script-eval (-> self scene on-running)) + ) + (when (and (logtest? (-> self scene scene-flags) (scene-flags scf8)) + (not (-> self preload-sound)) + (-> self scene) + (-> self scene end-point) + (< 10.0 (ja-aframe-num 0)) + ) + (let ((t9-6 scene-decode-continue) + (a0-20 (-> self end-point)) + ) + (set! a0-20 (cond + (a0-20 + (empty) + a0-20 + ) + (else + (-> self scene end-point) + ) + ) + ) + (let ((v1-49 (t9-6 a0-20))) + (when v1-49 + (dotimes (a0-22 3) + (set! (-> *load-state* want-sound a0-22 name) (-> v1-49 want-sound a0-22)) + (set! (-> *load-state* want-sound a0-22 mode) (sound-bank-mode unknown)) + (set! (-> *backup-load-state* want-sound a0-22 name) (-> v1-49 want-sound a0-22)) + (set! (-> *backup-load-state* want-sound a0-22 mode) (sound-bank-mode unknown)) + ) + (remove-setting! 'sound-bank-load) + (add-borrow-levels *load-state*) + ) + ) + ) + (set! (-> self preload-sound) (the-as basic #t)) + ) + ((-> self cur-trans-hook)) + ) + :code (behavior () + (local-vars (a0-29 symbol)) + (when (or *debug-menu-scene-play* (and (scene-select?) (-> self scene) (nonzero? (-> self scene scene-task)))) + (task-node-open! (the-as game-task-node (-> self scene scene-task)) 'event) + (logior! (-> self mask) (process-mask no-kill)) + (if (not (logtest? (-> self scene scene-flags) (scene-flags scf6))) + (reset-actors 'debug) + ) + (logclear! (-> self mask) (process-mask no-kill)) + ) + (dotimes (gp-0 2) + (let ((v1-17 (-> *art-control* buffer gp-0))) + (if (= (-> v1-17 status) 'active) + (link-art-to-master (-> v1-17 art-group)) + ) + ) + ) + (while (and (< (-> self scene-index) (-> self scene-list length)) (not (-> self aborted?))) + (scene-player-method-23 self (the-as string (-> self scene-list (-> self scene-index))) #t) + (kill-persister *setting-control* (the-as engine-pers 'title-control-scene) 'render) + (set-blackout-frames (seconds 0.1)) + (suspend) + (set-blackout-frames (seconds 0.1)) + (suspend) + (when (not (-> *setting-control* user-current border-mode)) + (set! (-> *setting-control* user-default border-mode) #t) + (set! (-> *level* play?) (-> *setting-control* user-default border-mode)) + (apply-settings *setting-control*) + ) + (scene-player-method-25 self 0.0 -1.0) + (set! (-> self cur-speed) 0.0) + (set-time! (-> self scene-start-time)) + (ja-play-spooled-anim + (-> self anim) + (the-as art-joint-anim #f) + (the-as art-joint-anim #f) + (the-as + (function process-drawable symbol) + (if (logtest? (-> self scene scene-flags) (scene-flags scf1)) + (lambda :behavior scene-player + () + (when (cpad-pressed? 0 triangle) + (set! (-> self aborted?) #t) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons triangle)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons triangle)) + #t + ) + (none) + ) + false-func + ) + ) + (if (logtest? (-> self scene scene-flags) (scene-flags scf7)) + (spooler-flags) + (spooler-flags blackout-on-stall) + ) + ) + (while (-> self child) + (deactivate (-> self child 0)) + ) + (+! (-> self scene-index) 1) + (when (and (< (-> self scene-index) (-> self scene-list length)) (not (-> self aborted?))) + (let ((v1-61 (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t))) + (when v1-61 + (let ((a0-26 (scene-decode-continue (-> v1-61 load-point)))) + (set! a0-29 (when (and a0-26 (logtest? (-> a0-26 flags) (continue-flags scene-wait))) + (go-virtual wait a0-29) + a0-29 + ) + ) + ) + ) + ) + ) + ) + (if (and (-> self wait) *target* (focus-test? *target* grabbed)) + (go-virtual release) + ) + ) + :post (behavior () + (when (-> self scene) + (let ((gp-0 (-> self scene cut-list)) + (s5-0 (-> self skel root-channel 0 frame-group)) + ) + (when (not (or (null? gp-0) (not s5-0) (zero? s5-0))) + (let ((v1-8 (the int (ja-frame-num 0))) + (a0-2 (car gp-0)) + ) + (while (not (null? gp-0)) + (let ((f0-5 (/ (- (the float (/ (the-as int a0-2) 8)) (-> s5-0 artist-base)) (-> s5-0 artist-step)))) + (when (= v1-8 (if (= f0-5 (the float (the int f0-5))) + (+ (the int f0-5) -1) + (the int f0-5) + ) + ) + (set! (-> self skel root-channel 0 frame-num) (the float (the int (-> self skel root-channel 0 frame-num)))) + (set! (-> self pre-cut-frame) (the-as basic #t)) + ) + ) + (set! gp-0 (cdr gp-0)) + (set! a0-2 (car gp-0)) + ) + ) + ) + ) + (if (-> self pre-cut-frame) + (set! (-> self pre-cut-frame) #f) + ) + ) + (when (and (-> self scene) (nonzero? (-> self skel active-channels))) + (when (and (< (ja-aframe-num 0) 2.0) + (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (logtest? (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (set-blackout-frames 0) + (set-blackout-frames (seconds 0.017)) + ) + (scene-player-method-25 self (ja-aframe-num 0) (-> self last-frame)) + (set! (-> self last-frame) (ja-aframe-num 0)) + (set! (-> self dma-max) + (the-as uint (max + (the-as int (-> self dma-max)) + (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16) + ) + ) + ) + (let ((gp-4 *display-scene-control*)) + (when (nonzero? gp-4) + (if (logtest? gp-4 (scene-controls bounds-spheres)) + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) + ) + (if (logtest? gp-4 (scene-controls actors)) + (format *stdcon* "anim ~-30S " (-> self scene anim)) + ) + (if (logtest? gp-4 (scene-controls actor-marks)) + (format + *stdcon* + "dma ~DK / ~DK" + (shr (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16) 10) + (shr (-> self dma-max) 10) + ) + ) + (if (logtest? gp-4 (scene-controls actors actor-marks)) + (format *stdcon* "~%") + ) + (when (logtest? gp-4 (scene-controls special-fma-spheres)) + (dotimes (s5-3 (-> self scene actor length)) + (let* ((s4-1 (handle->process (-> self scene actor s5-3 process))) + (v1-66 (if (type? s4-1 process-drawable) + (the-as process-drawable s4-1) + ) + ) + ) + (if (and v1-66 (nonzero? (-> v1-66 draw))) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + (-> v1-66 draw origin) + (-> v1-66 draw bounds w) + (new 'static 'rgba :b #xff :a #x80) + ) + ) + ) + ) + ) + (when (logtest? gp-4 (scene-controls scene-controls-7)) + (dotimes (s5-4 (-> self scene actor length)) + (let* ((s4-2 (handle->process (-> self scene actor s5-4 process))) + (v1-82 (if (type? s4-2 process-drawable) + (the-as process-drawable s4-2) + ) + ) + ) + (if (and v1-82 (nonzero? (-> v1-82 draw))) + (format + *stdcon* + "~0K ~-30S ~S d:~4,,0m r:~4,,0m~1K~%" + (-> self scene actor s5-4 art-group) + (if (logtest? (-> v1-82 draw status) (draw-control-status on-screen)) + "os" + " " + ) + (-> v1-82 draw distance) + (-> v1-82 draw bounds w) + ) + ) + ) + ) + ) + (when (logtest? gp-4 (scene-controls scene-controls-8)) + (dotimes (gp-5 (-> self scene actor length)) + (let* ((s5-5 (handle->process (-> self scene actor gp-5 process))) + (v1-97 (if (type? s5-5 process-drawable) + (the-as process-drawable s5-5) + ) + ) + ) + (if (and v1-97 (nonzero? (-> v1-97 draw))) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (-> v1-97 name) + (-> v1-97 draw origin) + (font-color yellow) + (new 'static 'vector2h :y 8) + ) + ) + ) + ) + ) + ) + ) + ) + (when (cpad-pressed? 0 square) + (set! (-> *setting-control* user-default subtitle) (not (-> *setting-control* user-default subtitle))) + (set-time! (-> self subtitle-change-time)) + ) + (when (and (not (time-elapsed? (-> self subtitle-change-time) (seconds 2))) + (< (mod (- (current-time) (-> self subtitle-change-time)) 300) 210) + ) + (let ((gp-6 + (new 'stack 'font-context *font-default-matrix* 36 60 0.0 (font-color default) (font-flags shadow kerning)) + ) + ) + (let ((v1-124 gp-6)) + (set! (-> v1-124 width) (the float 440)) + ) + (let ((v1-125 gp-6)) + (set! (-> v1-125 height) (the float 48)) + ) + (let ((v1-126 gp-6)) + (set! (-> v1-126 scale) 0.5) + ) + (set! (-> gp-6 flags) (font-flags shadow kerning middle large)) + (print-game-text + (lookup-text! + *common-text* + (if (-> *setting-control* user-default subtitle) + (text-id text-020b) + (text-id text-020c) + ) + #f + ) + gp-6 + #f + 44 + (bucket-id hud-draw-pris2) + ) + ) + ) + (process-drawable-draw-subtitles) + (when (-> self scene) + (let ((gp-7 + (lookup-gui-connection *gui-control* self (gui-channel art-load) (-> self scene anim) (new 'static 'sound-id)) + ) + ) + (when (and (= *cheat-mode* 'debug) (!= *external-cam-mode* 'pad-0)) + (cond + ((cpad-hold? 0 r1) + (if (cpad-pressed? 0 circle) + (set-time! (-> self speed-press-time)) + ) + (seek! + (-> self speed-change-speed) + 8.0 + (* (lerp-scale 0.01 0.3 (the float (- (current-time) (-> self speed-press-time))) 0.0 300.0) + (-> self clock time-adjust-ratio) + ) + ) + ) + ((cpad-hold? 0 l1) + (if (cpad-pressed? 0 square) + (set-time! (-> self speed-press-time)) + ) + (seek! + (-> self speed-change-speed) + -8.0 + (* (lerp-scale 0.01 0.3 (the float (- (current-time) (-> self speed-press-time))) 0.0 300.0) + (-> self clock time-adjust-ratio) + ) + ) + ) + ((cpad-hold? 0 x) + (when (cpad-pressed? 0 x) + (set-time! (-> self speed-press-time)) + (cond + ((= (-> self cur-speed) 0.0) + (set! (-> self speed-change-speed) -1000.0) + ) + (else + (set! (-> self targ-speed) 0.0) + (set! (-> self speed-change-speed) 0.0) + ) + ) + ) + ) + (else + (set! (-> self speed-change-speed) 0.0) + ) + ) + ) + (cond + ((not gp-7) + ) + ((= (-> self cur-speed) -1000.0) + (format *stdcon* "scene paused~%") + (when (!= (-> self targ-speed) -1000.0) + (sound-continue (-> gp-7 id)) + (when *sound-player-enable* + (let ((v1-190 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-190 command) (sound-command set-param)) + (set! (-> v1-190 id) (-> gp-7 id)) + (set! (-> v1-190 params pitch-mod) 0) + (set! (-> v1-190 params mask) (the-as uint 2)) + (-> v1-190 id) + ) + ) + (set! (-> self targ-speed) 0.0) + (set! (-> self cur-speed) 0.0) + (set-time! (-> self speed-change-time)) + ) + ) + ((= (-> self speed-change-speed) -1000.0) + (when (!= (-> self cur-speed) -1000.0) + (set-time! (-> self speed-change-time)) + (set! (-> self targ-speed) -1000.0) + (set! (-> self cur-speed) -1000.0) + (sound-pause (-> gp-7 id)) + ) + ) + (else + (set! (-> self targ-speed) + (fmax -10.0 (fmin 10.0 (+ (-> self targ-speed) (* (-> self speed-change-speed) (seconds-per-frame))))) + ) + (if (and (= *cheat-mode* 'debug) (not (time-elapsed? (-> self speed-change-time) (seconds 3)))) + (format + *stdcon* + "id ~d speed ~f~%" + (if gp-7 + (the-as int (-> gp-7 id)) + 0 + ) + (-> self targ-speed) + ) + ) + (cond + ((!= (-> self targ-speed) 0.0) + ) + ((logtest? (game-secrets fast-movie) (-> *game-info* secrets)) + (set! (-> self targ-speed) 0.2) + ) + ((logtest? (game-secrets slow-movie) (-> *game-info* secrets)) + (set! (-> self targ-speed) -0.2) + ) + ) + (when (and gp-7 (and (!= (-> self targ-speed) (-> self cur-speed)) + (< (-> self speed-change-time) (current-time)) + (time-elapsed? (-> self scene-start-time) (seconds 1)) + ) + ) + (when *sound-player-enable* + (let ((v1-229 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-229 command) (sound-command set-param)) + (set! (-> v1-229 id) (-> gp-7 id)) + (set! (-> v1-229 params pitch-mod) (the int (* 1524.0 (-> self targ-speed)))) + (set! (-> v1-229 params mask) (the-as uint 2)) + (-> v1-229 id) + ) + ) + (set! (-> self cur-speed) (-> self targ-speed)) + (set-time! (-> self speed-change-time)) + ) + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior scene-player-init scene-player ((arg0 object) (arg1 symbol) (arg2 string)) + (process-entity-set! self (the-as entity #f)) + (stack-size-set! (-> self main-thread) 512) + (set! (-> self root) (new 'process 'trsqv)) + (case (rtype-of arg0) + ((array) + (set! (-> self scene-list) (new 'process 'boxed-array scene (-> (the-as (array scene) arg0) length))) + (dotimes (v1-7 (-> self scene-list length)) + (set! (-> self scene-list v1-7) (-> (the-as (array scene) arg0) v1-7)) + ) + ) + ((pair) + (let ((s3-0 (method-of-type array new)) + (s2-0 'process) + (s1-0 array) + (s0-0 scene) + (a0-14 arg0) + ) + (set! (-> self scene-list) + (the-as (array scene) (s3-0 s2-0 s1-0 s0-0 ((method-of-type (rtype-of a0-14) length) a0-14))) + ) + ) + (dotimes (s3-1 (-> self scene-list length)) + (set! (-> self scene-list s3-1) (the-as scene (ref arg0 s3-1))) + ) + ) + (else + (set! (-> self scene-list) (new 'process 'boxed-array scene 1)) + (set! (-> self scene-list 0) (the-as scene arg0)) + ) + ) + (set! (-> self preload-continue) arg2) + (set! (-> self camera) (the-as handle #f)) + (set! (-> self wait) arg1) + (set! (-> self pre-cut-frame) #f) + (set! (-> self aborted?) #f) + (set! (-> self blackout-end) (the-as basic 'none)) + (set! (-> self end-point) #f) + (set! (-> self preload-sound) #f) + (set! (-> self draw) (new 'process 'draw-control self #f)) + (set! (-> self skel) (new 'process 'joint-control 48)) + (set! (-> self anim) (new 'static 'spool-anim)) + (set! (-> self next-anim) (new 'static 'spool-anim)) + (dotimes (s4-1 (-> self scene-list length)) + (let ((v1-30 (scene-lookup (-> self scene-list s4-1)))) + (if v1-30 + (set! (-> self scene-list s4-1) v1-30) + ) + ) + ) + (cond + ((= (-> self scene-list (-> self scene-index) type) scene) + (set! (-> self scene) (-> self scene-list (-> self scene-index))) + (if (-> self scene) + (init-spool-by-scene! (-> self scene) (-> self anim)) + ) + ) + (else + (set-blackout-frames (seconds 0.2)) + (set! (-> self scene) #f) + ) + ) + (set! (-> self gui-id) (add-process + *gui-control* + self + (gui-channel movie) + (gui-action play) + (the-as string (cond + ((= (rtype-of arg0) string) + (empty) + arg0 + ) + (else + "movie" + ) + ) + ) + -99.0 + 0 + ) + ) + (set! *scene-player* (the-as (pointer scene-player) (process->ppointer self))) + (set! *display-entity-errors* #f) + (set-setting! 'speech-control #f 0.0 0) + (set-setting! 'allow-progress #f 0.0 0) + (if (or (= (cond + ((-> self scene) + (if (>= (-> self scene music-volume) 0.0) + (-> self scene music-volume) + (-> *setting-control* user-current music-volume-movie) + ) + ) + (else + 0.0 + ) + ) + 0.0 + ) + (not (-> *setting-control* user-current music)) + (!= (-> *setting-control* user-target music) (-> *setting-control* user-current music)) + ) + (set-setting! 'music #f 0.0 0) + ) + (apply-settings *setting-control*) + (set! (-> self new-trans-hook) nothing) + (set! (-> self cur-trans-hook) nothing) + (go-virtual wait arg1) + (none) + ) + +(defmethod load-scene ((this scene)) + (let ((v1-1 (-> *level* loading-level))) + (if v1-1 + (set-loaded-art (-> v1-1 art-group) this) + ) + ) + this + ) diff --git a/goal_src/jak3/engine/target/gun/gun-dark-shot.gc b/goal_src/jak3/engine/target/gun/gun-dark-shot.gc index 5b681514fa..63d58d588a 100644 --- a/goal_src/jak3/engine/target/gun/gun-dark-shot.gc +++ b/goal_src/jak3/engine/target/gun/gun-dark-shot.gc @@ -5,5 +5,3799 @@ ;; name in dgo: gun-dark-shot ;; dgos: GAME +(define-extern sparticle-lightning-2d-spline-align-plus-rotz (function object sparticle-cpuinfo sprite-vec-data-2d object none)) +(define-extern missile-bot type) +(define-extern market-object type) +(define-extern fruit-stand type) + ;; DECOMP BEGINS +(format 0 "SKIP: gun-dark-shot removed lightning specs~%") +;; (set! (-> *lightning-spec-id-table* 15) (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 1.0 +;; :fade-time 30.0 +;; :texture (new 'static 'texture-id :index #x8f :page #x4) +;; :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" :group 1) +;; ) +;; ) + +;; (set! (-> *lightning-spec-id-table* 16) (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 1.0 +;; :fade-time 30.0 +;; :texture (new 'static 'texture-id :index #x3f :page #x4) +;; :reduction 0.42 +;; :num-points 16 +;; :box-size 8192.0 +;; :merge-factor 0.6 +;; :merge-count 2 +;; :radius 3276.8 +;; :duration 60.0 +;; :sound (static-sound-spec "stretched-zap" :group 1) +;; ) +;; ) + +(defpartgroup group-lightning-dark-shot-tip-hit + :id 183 + :flags (sp0 sp4) + :bounds (static-bspherem 0 0 0 10) + :parts ((sp-item 664)) + ) + +(defpart 664 + :init-specs ((:texture (lightning-anim-01 level-default-sprite)) + (:birth-func 'birth-func-texture-group) + (:num 2.0 3.0) + (:scale-x (meters 0.1) (meters 0.1)) + (:rot-z (degrees 90)) + (:scale-y :copy scale-x) + (:r 0.0 64.0) + (:g 64.0 64.0) + (:b 255.0) + (:a 255.0) + (:vel-z (meters 0.016666668) (meters 0.006666667)) + (:scalevel-x (meters 0.006666667) (meters 0.006666667)) + (:scalevel-y :copy scalevel-x) + (:fade-a -1.7) + (:friction 0.99) + (:timer (seconds 0.5)) + (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3)) + (:userdata :data (new 'static 'boxed-array :type int32 20 1 0 #x405700 #x405800 #x405900)) + (:func 'sparticle-lightning-2d-spline-align-plus-rotz) + (:rotate-y (degrees 0) (degrees 3600)) + ) + ) + +(defpart 665 + :init-specs ((:texture (glow-hotdot level-default-sprite)) + (:num 1.0) + (:scale-x (meters 1) (meters 4)) + (:rot-x (degrees 11.25)) + (:rot-z (degrees 0) (degrees 360)) + (:scale-y :copy scale-x) + (:r 0.0 64.0) + (:g 64.0 64.0) + (:b 255.0) + (:a 128.0) + (:timer (seconds 0.017)) + (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow)) + (:userdata 4096.0) + (:conerot-x (degrees 0) (degrees 3600)) + (:conerot-y (degrees 0) (degrees 3600)) + (:conerot-z (degrees 0) (degrees 3600)) + (:conerot-radius (meters -0.1) (meters 0.5)) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defun sparticle-lightning-2d-spline-align-plus-rotz ((arg0 object) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-2d) (arg3 object)) + (sparticle-2d-spline-align-instant arg0 arg1 arg2 arg3) + (+! (-> arg2 flag-rot-sy z) (-> *part-id-table* 664 init-specs 4 initial-valuef)) + (none) + ) + +(deftype gun-dark-shot (projectile) + ((blast-radius float) + (core-position vector :inline) + (core-velocity vector :inline) + (spin-vector vector :inline) + (track-target handle) + (size-t float) + (result-array handle 16) + (result-count int8) + (charge-sound sound-id) + (fire-sound sound-id) + (trail-sound sound-id) + (explode-sound sound-id) + (start-pilot? symbol) + (spread-timer time-frame) + ) + (:state-methods + startup + fizzle + ) + ) + + +(defbehavior gun-fire-dark-1 target () + (set-last-fire-time 35) + (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)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-11 *game-info*) + (a0-13 (+ (-> v1-11 attack-id) 1)) + ) + (set! (-> v1-11 attack-id) a0-13) + (set! (-> gp-0 attack-id) a0-13) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (let ((v0-2 (spawn-projectile gun-dark-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*))) + (if v0-2 + (set! (-> self gun charge-active?) (ppointer->handle v0-2)) + ) + v0-2 + ) + ) + ) + +(defskelgroup skel-gun-dark-3-sphere gun gun-nuke-sphere-lod0-jg gun-nuke-sphere-idle-ja + ((gun-nuke-sphere-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 30) + :texture-level 10 + :light-index 4 + ) + +(deftype gun-dark-3-sphere (process-drawable) + ((alpha-val float) + ) + (:state-methods + active + ) + ) + + +(deftype gun-dark-3-sphere-init-params (structure) + ((pos vector :inline) + (size-x float) + (size-y float) + (alpha-val float) + ) + ) + + +(defbehavior gun-dark-3-sphere-init-by-other gun-dark-3-sphere ((arg0 gun-dark-3-sphere-init-params)) + (set! (-> self root) (new 'process 'trsqv)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-dark-3-sphere" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self root trans quad) (-> arg0 pos quad)) + (quaternion-identity! (-> self root quat)) + (set-vector! + (-> self root scale) + (* 0.00024414062 (-> arg0 size-x)) + (* 0.00024414062 (-> arg0 size-y)) + 1.0 + 1.0 + ) + (go-virtual active) + ) + +(defstate active (gun-dark-3-sphere) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('set-pos-and-size) + (let ((v1-2 (the-as gun-dark-3-sphere-init-params (-> block param 0)))) + (set! (-> self root trans quad) (-> v1-2 pos quad)) + (set-vector! + (-> self root scale) + (* 0.00024414062 (-> v1-2 size-x)) + (* 0.00024414062 (-> v1-2 size-y)) + 1.0 + 1.0 + ) + (vector-float*! (-> self root scale) (-> self root scale) 1.7) + (set! (-> self alpha-val) (-> v1-2 alpha-val)) + ) + ) + ) + #t + ) + :enter (behavior () + (set-time! (-> self state-time)) + (ja-channel-push! 1 0) + (ja :group! gun-nuke-sphere-fade-ja :num! zero) + (set! (-> self alpha-val) 1.0) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (let ((s5-1 (vector-! (new 'stack-no-clear 'vector) (-> self root trans) (math-camera-pos)))) + (set! (-> s5-1 y) 0.0) + (vector-normalize! s5-1 1.0) + (vector-float*! s5-1 s5-1 -1.0) + (matrix-fu-compose gp-0 s5-1 *up-vector*) + ) + (matrix->quat gp-0 (-> self root quat)) + ) + (ja :group! gun-nuke-sphere-fade-ja :num! (identity (- 1.0 (-> self alpha-val)))) + ) + :code sleep-code + :post (behavior () + (ja-post) + ) + ) + +(defskelgroup skel-gun-dark-3-nuke gun gun-nuke-lod0-jg gun-nuke-idle-ja + ((gun-nuke-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3) + :texture-level 10 + ) + +(deftype last-active-nuke-info (structure) + ((last-active-nuke handle) + ) + ) + + +(define *last-active-nuke* (new 'static 'last-active-nuke-info)) + +(set! (-> *last-active-nuke* last-active-nuke) (the-as handle #f)) + +(deftype gun-dark-3-nuke (projectile) + ((flash-time time-frame) + (blur-time time-frame) + (spawned-mushroom-cloud? symbol) + (strip prim-strip) + (mushroom-top-pos vector :inline) + (warp handle) + (initial-velocity vector :inline) + (start-y float) + (y-vel-adjust float) + (launch-speed float) + (launch-sin-region-start float) + (launch-sin-region-end float) + (launch-stay-state-time time-frame) + (launch-next-state (state gun-dark-3-nuke)) + (launch-impact-state (state gun-dark-3-nuke)) + (launch-y-scale float) + (launch-height-t float) + (expected-height float) + (total-fly-time time-frame) + (num-dying-vehicles uint8) + (num-dying-guards uint8) + (num-dying-civilians uint8) + (last-death-sound-play-time time-frame) + (blur-curve curve2d-piecewise) + (fade-curve curve-color-piecewise) + (num-blur-segments uint8) + (shook-camera? symbol) + (hit-wall? symbol) + (killed-everything? symbol :offset 696) + (explode-sound sound-id) + (explode-wall-sound sound-id) + (played-trail? symbol) + (smoke-trail sparticle-subsampler) + (killed-objects handle 64) + (num-killed-objects int32) + (last-kill-time time-frame) + ) + (:state-methods + undefined + launching-base-state + launch-0 + launch-1 + launch-2 + launch-3 + impact-small + impact-dud + impact-embedded + wait-for-alive + ) + (:methods + (set-launch-height! (_type_) none) + (do-blur-effect (_type_) none) + (do-white-screen-effect (_type_) none) + (count-casualties (_type_) none) + (send-attack! (_type_ process-focusable) none) + (play-death-sounds (_type_) none) + (do-camera-shake (_type_) none) + (do-vibration (_type_) none) + (check-for-impact (_type_) none) + ) + ) + + +(defmethod projectile-method-25 ((this gun-dark-3-nuke)) + (when (not (logtest? (-> this draw status) (draw-control-status no-draw))) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (matrix-f-u-compose s5-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> this root quat)) *up-vector*) + (set! (-> s5-0 trans quad) (-> this root trans quad)) + (sparticle-launch-control-method-17 (-> this part) s5-0) + (sparticle-subsampler-method-10 (-> this smoke-trail) s5-0) + ) + ) + (none) + ) + +(defun gun-dark-reaction ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector)) + (cshape-reaction-update-state arg0 arg1 arg3) + (set! (-> arg2 quad) (-> arg3 quad)) + (cond + ((logtest? (-> arg0 status) (collide-status touch-wall)) + (send-event (-> arg0 process) 'impact-small) + ) + ((let ((f0-1 (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) arg3 1.0) (-> arg0 surface-normal)))) + (< -0.3 f0-1) + ) + (let ((v1-9 (new 'stack-no-clear 'vector))) + (set! (-> v1-9 quad) (-> arg0 trans quad)) + (+ 1228.8 (-> v1-9 y)) + ) + (vector-flatten! arg2 arg3 (-> arg0 surface-normal)) + (send-event (-> arg0 process) 'slide-now (-> arg0 surface-normal)) + ) + (else + (send-event (-> arg0 process) 'impact) + ) + ) + (-> arg0 status) + ) + +(defmethod setup-collision! ((this gun-dark-3-nuke)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) gun-dark-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate explode)) + (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-7 prim-core action) (collide-action solid)) + (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 40.96) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-7) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-10 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set-collide-with! (-> this root) (collide-spec backgnd obstacle pusher impenetrable-obj)) + (set-collide-as! (-> this root) (collide-spec projectile)) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + (none) + ) + +(defmethod init-proj-settings! ((this gun-dark-3-nuke)) + (with-pp + (set! (-> *last-active-nuke* last-active-nuke) (process->handle this)) + (set! (-> this attack-mode) 'eco-dark) + (initialize-skeleton + this + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-dark-3-nuke" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> this spawned-mushroom-cloud?) #f) + (set! (-> this strip) + (new 'process 'prim-strip 4 (new 'static 'texture-id :index #x1f :page #x5) (the-as string #f)) + ) + (set! (-> this played-trail?) #f) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 112) this)) + pp + (set! (-> this smoke-trail) + (new 'process 'sparticle-subsampler *sp-particle-system-2d* (-> *part-id-table* 388) 8.0) + ) + (set-setting! 'allow-progress #f 0.0 0) + (set! (-> this explode-sound) + (add-process *gui-control* this (gui-channel gun) (gui-action queue) "pg3nxplo" -99.0 0) + ) + (set! (-> this explode-wall-sound) + (add-process *gui-control* this (gui-channel gun) (gui-action queue) "pg3wxplo" -99.0 0) + ) + (let* ((v1-19 *game-info*) + (a0-15 (+ (-> v1-19 attack-id) 1)) + ) + (set! (-> v1-19 attack-id) a0-15) + (set! (-> this attack-id) a0-15) + ) + (set! (-> this initial-velocity quad) (-> this root transv quad)) + (set! (-> this start-y) (-> this root trans y)) + (set! (-> this launch-impact-state) (method-of-object this impact-dud)) + (set! (-> this y-vel-adjust) 0.0) + (set! (-> this warp) (the-as handle #f)) + (set! (-> this shook-camera?) #f) + (set-vector! (-> this root scale) 2.5 2.5 2.5 1.0) + (set! (-> this killed-everything?) #f) + (let ((t9-8 (method-of-type projectile init-proj-settings!))) + (t9-8 this) + ) + (logior! (-> this options) (projectile-options po4)) + (set! (-> this total-fly-time) 0) + 0 + (none) + ) + ) + +(defmethod relocate ((this gun-dark-3-nuke) (offset int)) + (if (nonzero? (-> this strip)) + (&+! (-> this strip) offset) + ) + (if (nonzero? (-> this smoke-trail)) + (&+! (-> this smoke-trail) offset) + ) + (call-parent-method this offset) + ) + +;; WARN: Return type mismatch symbol vs object. +(defbehavior nuke-move gun-dark-3-nuke () + (let ((gp-0 (-> self root))) + (set! (-> self pre-move-transv quad) (-> gp-0 transv quad)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> gp-0 trans quad)) + ((-> self move) self) + (projectile-method-39 self) + (set! (-> self old-dist (-> self old-dist-count)) (* 0.0625 (vector-vector-distance s5-0 (-> gp-0 trans)))) + ) + ) + (set! (-> self old-dist-count) (logand (+ (-> self old-dist-count) 1) 15)) + (let ((f0-2 0.0)) + (countdown (v1-12 16) + (+! f0-2 (-> self old-dist v1-12)) + ) + ) + #f + ) + +;; WARN: Return type mismatch float vs none. +(defmethod set-launch-height! ((this gun-dark-3-nuke)) + (set! (-> this launch-height-t) + (/ (the float (- (current-time) (-> this state-time))) (the float (-> this launch-stay-state-time))) + ) + (set! (-> this launch-height-t) (fmax 0.0 (fmin 1.0 (-> this launch-height-t)))) + (none) + ) + +(defmethod proj-event-handler ((this gun-dark-3-nuke) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('impact) + (go (-> this launch-impact-state)) + ) + (('impact-small) + (go (method-of-object this impact-embedded)) + ) + (('slide-now) + (let ((a2-1 (-> arg3 param 0)) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (vector-flatten! s5-1 (-> this initial-velocity) (the-as vector a2-1)) + (set! (-> this y-vel-adjust) (-> s5-1 y)) + ) + (set! (-> this start-y) (+ (-> this start-y) (* (-> this y-vel-adjust) (seconds-per-frame)))) + ) + (else + (call-parent-method this arg0 arg1 arg2 arg3) + ) + ) + ) + +(defstate launching-base-state (gun-dark-3-nuke) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (proj-event-handler self proc argc message block) + ) + :enter (behavior () + (set-time! (-> self state-time)) + (set! (-> self root transv y) 0.0) + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (when (and (not (-> self played-trail?)) (>= (+ (current-time) (seconds -0.3)) (-> self total-fly-time))) + (sound-play "purple-3-trail" :position (-> self root trans)) + (set! (-> self played-trail?) #t) + ) + (when (time-elapsed? (-> self state-time) (-> self launch-stay-state-time)) + (set! (-> self start-y) (-> self root trans y)) + (go (-> self launch-next-state)) + ) + (+! (-> self start-y) (* (-> self y-vel-adjust) (seconds-per-frame))) + (let ((f0-3 (-> self launch-height-t))) + 0.0 + 0.0 + (let ((f0-4 (lerp (-> self launch-sin-region-start) (-> self launch-sin-region-end) f0-3))) + 0.0 + (let ((f30-1 (+ (- (* (sin (* 182.04445 f0-4)) (-> self launch-y-scale)) + (* (sin (* 182.04445 (-> self launch-sin-region-start))) (-> self launch-y-scale)) + ) + (-> self start-y) + ) + ) + ) + (set! (-> self expected-height) f30-1) + (vector-normalize-copy! (-> self root transv) (-> self initial-velocity) (-> self launch-speed)) + (set! (-> self root transv y) (- f30-1 (-> self root trans y))) + ) + ) + ) + (set! (-> self root transv y) (/ (-> self root transv y) (seconds-per-frame))) + (let ((t9-8 nuke-move)) + (-> self launch-impact-state) + (t9-8) + ) + (vector-x-quaternion! (new 'stack-no-clear 'vector) (-> self root quat)) + (let ((gp-1 (new 'stack-no-clear 'matrix))) + (let* ((t9-10 vector-normalize-copy!) + (a0-12 (new 'stack-no-clear 'vector)) + (a1-4 (-> self root transv)) + (a2-3 1.0) + (a1-5 (t9-10 a0-12 a1-4 a2-3)) + ) + (matrix-f-compose gp-1 a1-5 a2-3) + ) + (matrix->quaternion (-> self root quat) gp-1) + ) + (+! (-> self total-fly-time) (- (current-time) (-> self clock old-frame-counter))) + ) + :code sleep-code + :post (behavior () + (ja-post) + (projectile-method-25 self) + ) + ) + +(defstate launch-0 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set! (-> self launch-impact-state) (method-of-object self impact-embedded)) + (set! (-> self launch-y-scale) 0.0) + (set! (-> self launch-stay-state-time) (seconds 0.2)) + (set! (-> self launch-next-state) (method-of-object self launch-1)) + (let ((v1-6 (-> self state parent))) + (when v1-6 + (let ((t9-0 (-> v1-6 enter))) + (if t9-0 + ((the-as (function none) t9-0)) + ) + ) + ) + ) + ) + :trans (behavior () + (set-launch-height! self) + (set! (-> self launch-speed) 32768.0) + (let ((v1-4 (-> self state parent))) + (when v1-4 + (let ((t9-1 (-> v1-4 trans))) + (if t9-1 + (t9-1) + ) + ) + ) + ) + ) + ) + +(defstate launch-1 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set! (-> self launch-y-scale) 0.0) + (set! (-> self launch-stay-state-time) (seconds 0.4)) + (set! (-> self launch-next-state) (method-of-object self launch-2)) + (let ((v1-4 (-> self state parent))) + (when v1-4 + (let ((t9-0 (-> v1-4 enter))) + (if t9-0 + ((the-as (function none) t9-0)) + ) + ) + ) + ) + ) + :trans (behavior () + (set-launch-height! self) + (let ((f0-1 (* 0.008333334 (the float (- (current-time) (-> self state-time)))))) + (set! (-> self launch-speed) (lerp 61440.0 204800.0 f0-1)) + ) + (let ((v1-8 (-> self state parent))) + (when v1-8 + (let ((t9-2 (-> v1-8 trans))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + ) + ) + +(defstate launch-2 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set! (-> self launch-sin-region-start) 0.0) + (set! (-> self launch-sin-region-end) 270.0) + (set! (-> self launch-stay-state-time) (seconds 0.5)) + (set! (-> self launch-next-state) (method-of-object self launch-3)) + (set! (-> self launch-y-scale) 34816.0) + (let ((v1-6 (-> self state parent))) + (when v1-6 + (let ((t9-0 (-> v1-6 enter))) + (if t9-0 + ((the-as (function none) t9-0)) + ) + ) + ) + ) + ) + :trans (behavior () + (let ((f30-0 (* 0.006666667 (the float (- (current-time) (-> self state-time)))))) + (if (< 0.7 f30-0) + (set! (-> self launch-impact-state) (method-of-object self impact)) + ) + (set! (-> self launch-speed) (lerp 204800.0 552960.0 f30-0)) + (set! (-> self launch-height-t) (* f30-0 f30-0)) + ) + (let ((v1-10 (-> self state parent))) + (when v1-10 + (let ((t9-1 (-> v1-10 trans))) + (if t9-1 + (t9-1) + ) + ) + ) + ) + ) + ) + +(defstate launch-3 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (let ((t9-0 nuke-move)) + (-> self launch-impact-state) + (t9-0) + ) + (if (time-elapsed? (-> self state-time) (seconds 4)) + (go-virtual die) + ) + ) + ) + +(defmethod send-attack! ((this gun-dark-3-nuke) (arg0 process-focusable)) + (let* ((s3-0 (get-trans arg0 3)) + (v1-2 (get-trans arg0 1)) + (s5-1 (vector-! (new 'stack-no-clear 'vector) s3-0 (-> this root trans))) + ) + (+! (-> v1-2 y) 409.6) + (let ((v1-5 (cond + ((logtest? (-> *part-group-id-table* 115 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> v1-2 quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 115)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> v1-2 quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 115)) + ) + ) + ) + ) + (send-event (ppointer->process v1-5) 'clock this) + ) + (send-event + arg0 + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage 32.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-dark) + (attacker-velocity s5-1) + (penetrate-using (penetrate explode jak-dark-nuke)) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod count-casualties ((this gun-dark-3-nuke)) + (local-vars (sv-1568 vector)) + (set! (-> this num-dying-vehicles) (the-as uint 0)) + (set! (-> this num-dying-guards) (the-as uint 0)) + (set! (-> this num-dying-civilians) (the-as uint 0)) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 64) + ) + (set! (-> s4-0 quad) (-> this root trans quad)) + (set! (-> s4-0 w) 1228800.0) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s4-0) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-5 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-5 + (let* ((s0-0 (-> v1-5 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= *target* s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive)) + (or (logtest? (process-mask enemy guard vehicle civilian) (-> s1-1 mask)) + (and (logtest? (process-mask crate) (-> s1-1 mask)) (let ((s0-1 vector-vector-xz-distance)) + (set! sv-1568 (-> s1-1 root trans)) + (let ((a1-3 (camera-pos))) + (< (s0-1 sv-1568 a1-3) 204800.0) + ) + ) + ) + ) + ) + (when (> s5-0 0) + (+! s5-0 -1) + (send-attack! this (the-as process-focusable s1-1)) + (cond + ((logtest? (process-mask civilian) (-> s1-1 mask)) + (+! (-> this num-dying-civilians) 1) + ) + ((logtest? (process-mask guard) (-> s1-1 mask)) + (+! (-> this num-dying-guards) 1) + ) + ((logtest? (process-mask vehicle) (-> s1-1 mask)) + (+! (-> this num-dying-vehicles) 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) s4-0) (-> s4-0 w))) + (when (and (!= *target* s3-1) + (not (focus-test? s3-1 disable dead inactive)) + (or (logtest? (process-mask enemy guard vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask crate) (-> s3-1 mask)) + (< (vector-vector-xz-distance (-> s3-1 control trans) (camera-pos)) 204800.0) + ) + ) + ) + (when (> s5-0 0) + (+ s5-0 -1) + (send-attack! this s3-1) + (cond + ((logtest? (process-mask civilian) (-> s3-1 mask)) + (+! (-> this num-dying-civilians) 1) + ) + ((logtest? (process-mask guard) (-> s3-1 mask)) + (+! (-> this num-dying-guards) 1) + ) + ((logtest? (process-mask vehicle) (-> s3-1 mask)) + (+! (-> this num-dying-vehicles) 1) + ) + ) + ) + ) + ) + ) + ) + (set! (-> this num-dying-vehicles) (the-as uint (min 4 (the-as int (-> this num-dying-vehicles))))) + (set! (-> this num-dying-guards) (the-as uint (min 6 (the-as int (-> this num-dying-vehicles))))) + (set! (-> this num-dying-civilians) (the-as uint (min 6 (the-as int (-> this num-dying-vehicles))))) + 0 + (none) + ) + +(defmethod do-blur-effect ((this gun-dark-3-nuke)) + (when (= (process->handle this) (-> *last-active-nuke* last-active-nuke)) + 0.0 + (let* ((f0-3 (/ (the float (- (current-time) (-> this state-time))) (the float (-> this blur-time)))) + (f0-4 (curve2d-method-9 (-> this blur-curve) f0-3 3)) + (f0-5 (- 1.0 f0-4)) + ) + (blit-displays-work-method-17 + *blit-displays-work* + (-> this root trans) + (the-as int (-> this num-blur-segments)) + (fmin 1.0 f0-5) + #f + ) + ) + (set! (-> *display* force-sync) (the-as uint 2)) + ) + (none) + ) + +(defmethod do-white-screen-effect ((this gun-dark-3-nuke)) + (when (= (process->handle this) (-> *last-active-nuke* last-active-nuke)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + 0.0 + 0.0 + (let ((f0-4 (/ (the float (- (current-time) (-> this state-time))) (the float (-> this flash-time))))) + (curve-color-method-9 (-> this fade-curve) f0-4 (the-as rgbaf gp-0) 3) + ) + (set! (-> gp-0 x) (* 255.0 (-> gp-0 x))) + (set! (-> gp-0 y) (* 255.0 (-> gp-0 y))) + (set! (-> gp-0 z) (* 255.0 (-> gp-0 z))) + (set! (-> gp-0 w) (* 128.0 (-> gp-0 w))) + (setup *screen-filter* gp-0 gp-0 0.0 (bucket-id tex-hud-pris2) #x3fffff #x33001 #t) + ) + ) + (none) + ) + +(defstate impact-dud (gun-dark-3-nuke) + :virtual #t + :code (behavior () + (if *scene-player* + (go empty-state) + ) + (let ((gp-0 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-0 spawn-point quad) (-> self root trans quad)) + (quaternion-identity! (-> gp-0 spawn-quat)) + (set! (-> gp-0 radius) 0.0) + (set! (-> gp-0 scale) 1.0) + (set! (-> gp-0 group) (-> *part-group-id-table* 104)) + (set! (-> gp-0 collide-with) (collide-spec)) + (set! (-> gp-0 damage) 2.0) + (set! (-> gp-0 damage-scale) 1.0) + (set! (-> gp-0 vehicle-damage-factor) 1.0) + (set! (-> gp-0 vehicle-impulse-factor) 1.0) + (set! (-> gp-0 ignore-proc) (process->handle #f)) + (explosion-spawn gp-0 self) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (let ((v1-20 (-> self root root-prim))) + (set! (-> v1-20 prim-core collide-as) (collide-spec)) + (set! (-> v1-20 prim-core collide-with) (collide-spec)) + ) + 0 + (ja-post) + (while (-> self child) + (suspend) + ) + ) + ) + +(defmethod projectile-method-40 ((this gun-dark-3-nuke)) + 256 + ) + +(defstate impact-embedded (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (let ((v1-3 (-> self root root-prim))) + (set! (-> v1-3 prim-core collide-as) (collide-spec)) + (set! (-> v1-3 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self root transv quad) (the-as uint128 0)) + ) + :exit (behavior () + '() + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (if (time-elapsed? (-> self state-time) (seconds 1.4)) + (go-virtual impact-small) + ) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 0.3)) + (suspend) + ) + (sound-play "beep") + (until (time-elapsed? (-> self state-time) (seconds 0.5)) + (suspend) + ) + (sound-play "beep") + (until #f + (suspend) + ) + #f + ) + :post (behavior () + (ja-post) + (projectile-method-25 self) + ) + ) + +;; WARN: Return type mismatch uint vs none. +(defmethod play-death-sounds ((this gun-dark-3-nuke)) + (when (and (not (time-elapsed? (-> this state-time) (seconds 1.5))) + (time-elapsed? (-> this last-death-sound-play-time) (seconds 0.1)) + ) + (set-time! (-> this last-death-sound-play-time)) + (let* ((v1-11 (+ (-> this num-dying-vehicles) (-> this num-dying-guards) (-> this num-dying-civilians))) + (v1-12 (rand-vu-int-range 0 (the-as int (+ v1-11 -1)))) + ) + (when (> v1-12 0) + (cond + ((< v1-12 (the-as int (-> this num-dying-vehicles))) + (sound-play-by-spec (static-sound-spec "vehicle-explode" :group 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "vehicle-explo-b" :group 1) (new-sound-id) (the-as vector #t)) + (+! (-> this num-dying-vehicles) -1) + ) + ((< v1-12 (the-as int (+ (-> this num-dying-guards) (-> this num-dying-vehicles)))) + (sound-play "guard-die") + (+! (-> this num-dying-guards) -1) + ) + (else + (sound-play "guard-hit") + (+! (-> this num-dying-civilians) -1) + ) + ) + ) + ) + ) + (none) + ) + +(defstate impact-small (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (logior! (-> self draw status) (draw-control-status no-draw)) + (case (get-status *gui-control* (-> self explode-wall-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action play) + (-> self explode-wall-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (else + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-wall-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (sound-play "explosion" :pitch 2.5) + ) + ) + (case (get-status *gui-control* (-> self explode-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + ) + (set-setting! 'music-volume 'abs 0.0 0) + (let ((v1-21 (-> self root root-prim))) + (set! (-> v1-21 prim-core collide-as) (collide-spec)) + (set! (-> v1-21 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self last-death-sound-play-time) 0) + (set! (-> self flash-time) *gun-dark-3-nuke-fade-time-small*) + (set! (-> self blur-time) *gun-dark-3-nuke-blur-time-small*) + (set! (-> self blur-curve) *gun-dark-3-nuke-blur-curve-small*) + (set! (-> self fade-curve) *gun-dark-3-nuke-fade-curve-small*) + (set! (-> self num-blur-segments) *gun-dark-3-nuke-blur-segs-small*) + ) + :exit (behavior () + (when (= (process->handle self) (-> *last-active-nuke* last-active-nuke)) + (disable *screen-filter*) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 0 1.0 #f) + ) + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (do-blur-effect self) + (do-white-screen-effect self) + (if (time-elapsed? (-> self state-time) (seconds 1)) + (do-camera-shake self) + ) + (when (not (-> self spawned-mushroom-cloud?)) + (let ((v1-23 + (cond + ((logtest? (-> *part-group-id-table* 114 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 114)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 114)) + ) + ) + ) + ) + (send-event (ppointer->process v1-23) 'clock self) + ) + (set! (-> self spawned-mushroom-cloud?) #t) + ) + (if (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (not (time-elapsed? (-> self state-time) (seconds 6))) + ) + (set-setting! 'nuke-active? #t 0.0 0) + (remove-setting! 'nuke-active?) + ) + (when (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (and (not (time-elapsed? (-> self state-time) (seconds 6))) + (time-elapsed? (-> self last-kill-time) (seconds 0.1)) + (not (-> self killed-everything?)) + ) + ) + (count-casualties self) + (set! (-> self killed-everything?) #t) + (set-time! (-> self last-kill-time)) + ) + (play-death-sounds self) + (ja-post) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 8)) + (suspend) + ) + ) + ) + +(defstate wait-for-alive (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (remove-setting! 'allow-progress) + ) + :exit (behavior () + '() + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (let ((f0-1 (* 0.00066666666 (the float (- (current-time) (-> self clock old-frame-counter)))))) + (set-setting! 'music-volume 'abs f0-1 0) + ) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 5)) + (suspend) + ) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defmethod check-for-impact ((this gun-dark-3-nuke)) + (let ((a1-0 (new 'stack-no-clear 'collide-query))) + (vector+float*! (-> a1-0 start-pos) (-> this root trans) *up-vector* 2048.0) + (set-vector! (-> a1-0 move-dist) 0.0 49152.0 0.0 1.0) + (let ((v1-3 a1-0)) + (set! (-> v1-3 radius) 40.96) + (set! (-> v1-3 collide-with) (collide-spec backgnd)) + (set! (-> v1-3 ignore-process0) #f) + (set! (-> v1-3 ignore-process1) #f) + (set! (-> v1-3 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-3 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* a1-0) 0.0) + (go (method-of-object this impact-small)) + ) + ) + (none) + ) + +(defmethod do-vibration ((this gun-dark-3-nuke)) + (buzz-stop! 0) + (let* ((f1-2 (* 0.00055555557 (the float (- (current-time) (-> this state-time))))) + (f0-2 (fmax 0.0 (fmin 1.0 f1-2))) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 (the int (* 255.0 (- 1.0 f0-2))) (seconds 1)) + ) + (none) + ) + +(defstate impact (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (check-for-impact self) + (set-setting! 'music-volume 'abs 0.0 0) + (case (get-status *gui-control* (-> self explode-wall-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-wall-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + ) + (case (get-status *gui-control* (-> self explode-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action play) + (-> 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 + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (sound-play "explosion" :pitch 2.5) + ) + ) + (set-time! (-> self state-time)) + (logior! (-> self draw status) (draw-control-status no-draw)) + (vector+float*! (-> self mushroom-top-pos) (-> self root trans) *up-vector* 20480.0) + (let ((v1-25 (-> self root root-prim))) + (set! (-> v1-25 prim-core collide-as) (collide-spec)) + (set! (-> v1-25 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self flash-time) *gun-dark-3-nuke-fade-time*) + (set! (-> self blur-time) *gun-dark-3-nuke-blur-time*) + (set! (-> self blur-curve) *gun-dark-3-nuke-blur-curve*) + (set! (-> self fade-curve) *gun-dark-3-nuke-fade-curve*) + (set! (-> self num-blur-segments) *gun-dark-3-nuke-blur-segs*) + ) + :exit (behavior () + (when (= (process->handle self) (-> *last-active-nuke* last-active-nuke)) + (disable *screen-filter*) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 0 1.0 #f) + ) + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (do-blur-effect self) + (do-white-screen-effect self) + (do-vibration self) + (if (time-elapsed? (-> self state-time) (seconds 1)) + (do-camera-shake self) + ) + (set! (-> self strip num-verts) (the-as uint 0)) + (when (time-elapsed? (-> self state-time) (seconds 0.035)) + (when (not (-> self spawned-mushroom-cloud?)) + (let ((v1-30 + (cond + ((logtest? (-> *part-group-id-table* 110 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 110)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 110)) + ) + ) + ) + ) + (send-event (ppointer->process v1-30) 'clock self) + ) + (let ((v1-61 + (cond + ((logtest? (-> *part-group-id-table* 111 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 111)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 111)) + ) + ) + ) + ) + (send-event (ppointer->process v1-61) 'clock self) + ) + (let ((gp-4 (new 'stack-no-clear 'gun-dark-3-sphere-init-params))) + (set! (-> gp-4 pos quad) (-> self root trans quad)) + (set! (-> gp-4 size-x) 1.0) + (set! (-> gp-4 size-y) 1.0) + (set! (-> self warp) + (ppointer->handle (process-spawn gun-dark-3-sphere gp-4 :name "gun-dark-3-sphere" :to self)) + ) + ) + (set! (-> self spawned-mushroom-cloud?) #t) + ) + (if (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (not (time-elapsed? (-> self state-time) (seconds 6))) + ) + (set-setting! 'nuke-active? #t 0.0 0) + (remove-setting! 'nuke-active?) + ) + (when (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (and (not (time-elapsed? (-> self state-time) (seconds 7))) + (time-elapsed? (-> self last-kill-time) (seconds 0.1)) + (not (-> self killed-everything?)) + ) + ) + (count-casualties self) + (set! (-> self killed-everything?) #t) + (set-time! (-> self last-kill-time)) + ) + (play-death-sounds self) + (+! (-> self mushroom-top-pos y) (* *gun-dark-3-mushroom-speed* (seconds-per-frame))) + (let ((f26-0 (/ (the float (- (current-time) (-> self state-time))) (the float *gun-dark-3-mushroom-size-time*)))) + 0.0 + 0.0 + (let ((f30-0 1.0) + (f28-0 (curve2d-method-9 *gun-dark-3-nuke-mushroom-size-curve-x* f26-0 3)) + (f26-1 (curve2d-method-9 *gun-dark-3-nuke-mushroom-size-curve-y* f26-0 3)) + ) + (when (time-elapsed? (-> self state-time) (seconds 5)) + (let ((f30-1 (* 0.00066666666 (the float (+ (- (seconds -5) (-> self state-time)) (current-time)))))) + 0.0 + (let ((f24-0 (* f30-1 f30-1))) + (set! f28-0 (* f28-0 (lerp 1.0 1.3 f24-0))) + (set! f26-1 (* f26-1 (lerp 1.0 1.3 f24-0))) + ) + (set! f30-0 (lerp 1.0 0.0 f30-1)) + ) + ) + (let ((v1-144 (new 'stack-no-clear 'gun-dark-3-sphere-init-params))) + (set! (-> v1-144 pos quad) (-> self mushroom-top-pos quad)) + (set! (-> v1-144 size-x) f28-0) + (set! (-> v1-144 size-y) f26-1) + (set! (-> v1-144 alpha-val) (* f30-0 f30-0)) + (send-event (handle->process (-> self warp)) 'set-pos-and-size v1-144) + ) + (let ((gp-6 (vector-float*! (new 'stack-no-clear 'vector) *up-vector* f26-1)) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (let ((s4-1 (vector-! (new 'stack-no-clear 'vector) (-> self mushroom-top-pos) (math-camera-pos)))) + (set! (-> s4-1 y) 0.0) + (vector-cross! s5-1 *up-vector* s4-1) + ) + (vector-normalize! s5-1 f28-0) + (dotimes (v1-152 4) + (if (> (logand v1-152 1) 0) + (vector-float*! gp-6 gp-6 -1.0) + ) + (when (= v1-152 2) + (vector-float*! gp-6 gp-6 -1.0) + (vector-float*! s5-1 s5-1 -1.0) + ) + (vector+! (the-as vector (+ (the-as uint (-> self strip data 0 pos)) (* v1-152 32))) s5-1 gp-6) + (vector+! + (the-as vector (+ (the-as uint (-> self strip data 0 pos)) (* v1-152 32))) + (the-as vector (+ (the-as uint (-> self strip data 0 pos)) (* v1-152 32))) + (-> self mushroom-top-pos) + ) + (set! (-> self strip data v1-152 stq z) 0.0) + (set! (-> self strip data v1-152 col) *color-gray*) + (set! (-> self strip data v1-152 col a) (the int (* 127.0 f30-0))) + (set! (-> self strip data v1-152 col g) (the int (* 127.0 f30-0))) + (set! (-> self strip data v1-152 col b) (the int (* 127.0 f30-0))) + ) + ) + ) + ) + (set! (-> self strip alpha) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> self strip adnops 0 cmds) (gs-reg64 test-1)) + (set! (-> self strip data0) (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x32 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (set! (-> self strip data 0 stq x) 1.0) + (set! (-> self strip data 0 stq y) 1.0) + (set! (-> self strip data 1 stq x) 1.0) + (set! (-> self strip data 1 stq y) 0.0) + (set! (-> self strip data 3 stq x) 0.0) + (set! (-> self strip data 3 stq y) 0.0) + (set! (-> self strip data 2 stq x) 0.0) + (set! (-> self strip data 2 stq y) 1.0) + (set! (-> self strip num-verts) (the-as uint 4)) + ) + (ja-post) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 10)) + (suspend) + ) + (go-virtual wait-for-alive) + ) + ) + +(defmethod projectile-method-32 ((this gun-dark-3-nuke)) + (if (not (do-fire-backcheck (-> this root trans) (-> this root transv))) + (go (method-of-object this impact-dud)) + (go (method-of-object this launch-0)) + ) + 0 + (none) + ) + +(defbehavior target-gun-can-fire-dark? target ((arg0 pickup-type)) + (case arg0 + (((pickup-type gun-dark-2)) + (time-elapsed? (get-last-fire-time 36) (seconds 2)) + ) + (((pickup-type gun-dark-3)) + (time-elapsed? (get-last-fire-time 37) (seconds 9)) + ) + (else + #t + ) + ) + ) + +;; WARN: Return type mismatch int vs (pointer process). +(defbehavior gun-fire-dark-3 target () + (let ((gp-0 (-> self gun)) + (s5-0 (new 'stack-no-clear 'projectile-init-by-other-params)) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> self gun fire-dir-out quad)) + (set-last-fire-time 37) + (sound-play "purple-3-shot" :position (-> gp-0 fire-point)) + (set! (-> s5-0 ent) (-> self entity)) + (set! (-> s5-0 charge) 1.0) + (set! (-> s5-0 options) (projectile-options)) + (logclear! (-> s5-0 options) (projectile-options po14 po15 po16)) + (set! (-> s5-0 pos quad) (-> gp-0 fire-point quad)) + (set! (-> s5-0 vel quad) (-> (vector-float*! (new 'stack-no-clear 'vector) s4-0 81920.0) quad)) + ) + (set! (-> s5-0 notify-handle) (the-as handle #f)) + (set! (-> s5-0 owner-handle) (the-as handle #f)) + (set! (-> s5-0 target-handle) (the-as handle #f)) + (set! (-> s5-0 target-pos quad) (the-as uint128 0)) + (set! (-> s5-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-17 *game-info*) + (a0-17 (+ (-> v1-17 attack-id) 1)) + ) + (set! (-> v1-17 attack-id) a0-17) + (set! (-> s5-0 attack-id) a0-17) + ) + (set! (-> s5-0 timeout) (seconds 4)) + (let ((v0-7 (ppointer->handle (process-spawn + gun-dark-3-nuke + :init projectile-init-by-other + s5-0 + :name "projectile" + :to (ppointer->process (-> gp-0 gun)) + :stack *kernel-dram-stack* + ) + ) + ) + ) + (set! (-> gp-0 gun 0 extra) (the-as handle v0-7)) + (the-as (pointer process) v0-7) + ) + ) + ) + +(defmethod init-proj-settings! ((this gun-dark-shot)) + (+! (-> *game-info* shots-fired 3) 1.0) + (set! (-> this attack-mode) 'eco-dark) + (vector-normalize! (-> this root transv) (+ 225280.0 (* 225280.0 (-> this charge-level)))) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 94) this)) + (set! (-> this blast-radius) 40960.0) + (if (logtest? (game-secrets gun-upgrade-dark-1) (-> *game-info* secrets)) + (set! (-> this blast-radius) 81920.0) + ) + (set! (-> this size-t) 0.0) + (set! (-> this notify-handle) (process->handle this)) + (set! (-> this charge-sound) (new-sound-id)) + (set! (-> this fire-sound) (new-sound-id)) + (set! (-> this trail-sound) (new-sound-id)) + (set! (-> this explode-sound) + (add-process *gui-control* this (gui-channel gun) (gui-action queue) "pmkrxplo" -99.0 0) + ) + (sound-params-set! *gui-control* (-> this explode-sound) #t 50 150 11 -1.0) + (set! (-> this start-pilot?) (the-as symbol (and *target* (focus-test? *target* pilot)))) + (set! (-> this damage) 16.0) + (set! (-> this vehicle-damage-factor) 1.0) + (set! (-> this vehicle-impulse-factor) 2.0) + (when (logtest? (game-secrets gun-upgrade-dark-1) (-> *game-info* secrets)) + (set! (-> this vehicle-damage-factor) 6.0) + (set! (-> this vehicle-impulse-factor) 6.0) + ) + ((method-of-type projectile init-proj-settings!) this) + 0 + (none) + ) + +(defmethod projectile-method-25 ((this gun-dark-shot)) + (cond + ((and (and (-> this next-state) (= (-> this next-state name) 'startup)) + (and *target* (focus-test? *target* in-head)) + ) + (kill-particles (-> this part)) + ) + (else + (set! (-> *part-id-table* 260 init-specs 2 initial-valuef) (lerp 409.6 9216.0 (-> this size-t))) + (set! (-> *part-id-table* 260 init-specs 8 initial-valuef) (lerp 0.0 32.0 (-> this size-t))) + (set! (-> *part-id-table* 261 init-specs 2 initial-valuef) (lerp 409.6 32768.0 (-> this size-t))) + (set! (-> *part-id-table* 261 init-specs 8 initial-valuef) (lerp 0.0 16.0 (-> this size-t))) + (set! (-> *part-id-table* 259 init-specs 2 initial-valuef) (lerp 409.6 8192.0 (-> this size-t))) + (set! (-> *part-id-table* 258 init-specs 1 initial-valuef) (lerp 0.1 1.0 (-> this size-t))) + (set! (-> *part-id-table* 258 init-specs 2 initial-valuef) (lerp 409.6 3686.4 (-> this size-t))) + (spawn (-> this part) (-> this root trans)) + ) + ) + (ja-post) + (none) + ) + +(defmethod projectile-method-32 ((this gun-dark-shot)) + (go (method-of-object this 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) (-> 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) + ) + ) + :code (behavior () + (set-time! (-> self state-time)) + (until #f + (cond + ((or (and *target* + (focus-test? *target* dead grabbed under-water pole flut board mech dark carry indax teleporting) + ) + (and *target* (not (logtest? (focus-status in-head gun) (-> *target* focus-status)))) + (and *target* (!= (-> self start-pilot?) (focus-test? *target* pilot))) + (not (-> *setting-control* user-current gun)) + ) + (adjust-player-ammo 1.0 (pickup-type ammo-dark)) + (go-virtual dissipate) + ) + ((or (not (time-elapsed? (-> self state-time) (seconds 0.3))) (cpad-hold? 0 r1)) + (set! (-> self size-t) (fmin 1.0 (* 0.016666668 (the float (- (current-time) (-> self state-time)))))) + (let ((t9-2 vector<-cspace!) + (a0-14 (-> self root trans)) + (v1-28 (-> self parent)) + ) + (t9-2 a0-14 (-> (the-as process-focusable (if v1-28 + (the-as process-focusable (-> v1-28 0 self)) + ) + ) + node-list + data + 13 + ) + ) + ) + ) + ((and (logtest? (projectile-options po17) (-> self options)) (made-impact? self)) + (go-virtual impact) + ) + (else + (go-virtual moving) + ) + ) + (suspend) + ) + #f + ) + :post (behavior () + (sound-play "pmkr-charge" :id (-> self charge-sound) :position (-> self root trans)) + (projectile-method-25 self) + ) + ) + +(defstate moving (gun-dark-shot) + :virtual #t + :enter (behavior () + (if *target* + (set! (-> self track-target) (-> *target* gun track-target 0 handle)) + ) + (let ((t9-0 (-> (method-of-type projectile moving) enter))) + (if t9-0 + (t9-0) + ) + ) + (set! (-> self core-position quad) (-> self root trans quad)) + (let ((v1-10 (-> self core-velocity)) + (a0-3 (-> self parent)) + ) + (set! (-> v1-10 quad) (-> (the-as process-focusable (if a0-3 + (the-as process-focusable (-> a0-3 0 self)) + ) + ) + node-list + data + 13 + bone + transform + fvec + quad + ) + ) + ) + (when (and *target* (focus-test? *target* in-head)) + (set! (-> self core-position quad) (-> (camera-pos) quad)) + (set! (-> self core-velocity quad) (-> (camera-matrix) fvec 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-time! (-> self state-time)) + (let ((v1-35 (cond + ((logtest? (-> *part-group-id-table* 92 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 92)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 92)) + ) + ) + ) + ) + (send-event (ppointer->process v1-35) 'clock self) + ) + (draw-beam (-> *part-id-table* 250) (-> self root trans) (-> self core-velocity) #f) + ) + :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))) + (s2-0 (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (when s2-0 + (let ((s3-1 (new 'stack-no-clear 'vector))) + (set! (-> s3-1 quad) (-> (the-as process-focusable s2-0) root trans quad)) + (let ((a0-6 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (if a0-6 + (set! (-> s3-1 quad) (-> (get-trans (the-as process-focusable a0-6) 3) quad)) + ) + ) + (let* ((s2-3 (vector-! (new 'stack-no-clear 'vector) s3-1 (-> self core-position))) + (f0-0 (vector-normalize-ret-len! s2-3 1.0)) + (f0-1 (lerp-scale 182.04445 8192.0 f0-0 61440.0 4096.0)) + (s3-2 (new 'stack-no-clear 'matrix)) + ) + (matrix-from-two-vectors-max-angle! s3-2 s4-0 s2-3 f0-1) + (vector-matrix*! (-> self core-velocity) (-> self core-velocity) s3-2) + ) + ) + ) + ) + (+! (-> 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 (- (current-time) (-> 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)) + ) + ) + (let ((f30-1 (* 0.5 f30-0))) + (vector-normalize! (-> self spin-vector) f30-1) + (vector-normalize! (-> self core-velocity) 7372.8) + (set! (-> s5-0 fvec quad) (-> s4-0 quad)) + (set! (-> s5-0 uvec quad) (-> self spin-vector quad)) + (vector-float*! (-> s5-0 uvec) (-> s5-0 uvec) (/ 1.0 f30-1)) + ) + ) + ) + (vector-cross! (-> s5-0 rvec) (-> s5-0 uvec) (-> s5-0 fvec)) + (matrix->quaternion (-> self root 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 transv) gp-0 (-> self root trans)) + ) + (let ((v1-39 (-> self root transv))) + (.lvf vf1 (&-> (-> self root transv) quad)) + (let ((f0-13 (-> self clock frames-per-second))) + (.mov at-0 f0-13) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-39 quad) vf1) + ) + (projectile-move-fill-line-sphere self) + (if (logtest? (-> self root status) (collide-status touch-surface)) + (go-virtual impact) + ) + (sound-play "pmkr-fire" :id (-> self fire-sound) :position (-> self root trans)) + (sound-play "pmkr-trail" :id (-> self trail-sound) :position (-> self root trans)) + ) + ) + ) + +;; WARN: Check prologue - tricky store of a0 +(defun process-drawable-shock-effect-bullseye ((arg0 process-focusable) + (arg1 process-focusable) + (arg2 lightning-spec) + (arg3 (function lightning-tracker none)) + (arg4 sparticle-launcher) + (arg5 sparticle-launcher) + (arg6 sparticle-launcher) + ) + (local-vars (sv-16 process) (sv-32 lightning-spec) (sv-48 process-focusable)) + (set! sv-48 arg0) + (let ((s0-0 arg1)) + (set! sv-32 arg2) + (let ((gp-0 arg4) + (s1-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 0)) + (let ((s2-0 (when sv-16 + (let ((t9-3 (method-of-type lightning-tracker activate))) + (t9-3 (the-as lightning-tracker sv-16) s0-0 "lightning-tracker" (the-as pointer #x70004000)) + ) + (let ((t9-4 run-function-in-process) + (a0-5 sv-16) + (a1-5 lightning-tracker-init) + (a3-3 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-5 + sv-32 + a3-3 + t0-1 + sv-48 + t2-1 + t3-0 + ) + ) + (-> sv-16 ppointer) + ) + ) + ) + (when s1-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 s1-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 s2-0) + (let ((v1-13 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-13 + (set! (-> v1-13 initial-valuef) (the-as float (-> (the-as lightning-tracker (-> s2-0 0)) duration))) + ) + ) + (let ((t9-8 sp-launch-particles-var) + (a0-12 *sp-particle-system-2d*) + (a1-13 gp-0) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> s4-0 quad)) + (t9-8 a0-12 a1-13 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-time! (-> self state-time)) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 1)) + (deactivate self) + ) + (process-drawable-shock-effect-replace + self + (-> *lightning-spec-id-table* 15) + lightning-probe-callback + 256 + 0 + 40960.0 + ) + (launch-particles (-> *part-id-table* 255) (-> self root trans)) + (launch-particles (-> *part-id-table* 257) (-> self root trans)) + (let ((gp-0 (-> *part-id-table* 665))) + (when gp-0 + (let ((v1-13 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-13 + (set! (-> v1-13 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 trans quad)) + (t9-5 a0-8 gp-0 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + :code 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 shield) + ) + (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) s5-0) + ) + (set! (-> self root trans quad) (-> arg0 quad)) + (let ((v1-16 (-> self root 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) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod do-camera-shake ((this gun-dark-3-nuke)) + (when (not (-> this shook-camera?)) + (activate! *camera-smush-control* 1228.8 45 1275 1.0 0.9 (-> *display* camera-clock)) + (set! (-> this shook-camera?) #t) + ) + (none) + ) + +(defmethod projectile-method-40 ((this gun-dark-shot)) + 512 + ) + +(defstate impact (gun-dark-shot) + :virtual #t + :enter (behavior () + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.2)) + (let ((t9-1 (-> (method-of-type projectile impact) enter))) + (if t9-1 + (t9-1) + ) + ) + (set! (-> self result-count) 0) + (set! (-> self spread-timer) 0) + (if (not (time-elapsed? (-> self spawn-time) (seconds 0.1))) + (send-event (ppointer->process (-> self parent)) 'release) + ) + (sound-stop (-> self trail-sound)) + (case (get-status *gui-control* (-> self explode-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action play) + (-> 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 + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (sound-play "explosion" :pitch 2.5) + ) + ) + (let ((v1-23 (-> self root root-prim))) + (set! (-> v1-23 prim-core collide-as) (collide-spec)) + (set! (-> v1-23 prim-core collide-with) (collide-spec)) + ) + 0 + (cond + ((logtest? (-> *part-group-id-table* 93 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 93)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 93)) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> self root trans quad)) + (let ((gp-3 (the-as (array float) (new 'stack 'boxed-array float 16))) + (a1-13 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-13 from) (process->ppointer self)) + (set! (-> a1-13 num-params) 0) + (set! (-> a1-13 message) 'get-vehicle) + (let ((s5-1 (send-event-function *target* a1-13))) + (set! (-> s4-0 w) (-> self blast-radius)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s4-0) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-66 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-66 + (let* ((s0-0 (-> v1-66 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (nonzero? (-> (the-as process-focusable s1-1) root root-prim prim-core collide-as)) + (logtest? (process-mask crate enemy guard vehicle civilian kg-robot metalhead) (-> s1-1 mask)) + (not (focus-test? (the-as process-focusable s1-1) disable dead ignore)) + (!= s1-1 s5-1) + ) + (let* ((s0-1 (get-trans (the-as process-focusable s1-1) 3)) + (f0-2 (vector-vector-distance-squared (-> self root trans) s0-1)) + (f1-0 (-> s0-1 w)) + (f0-3 (- f0-2 (* f1-0 f1-0))) + (v1-80 (+ (-> self result-count) -1)) + ) + (while (and (>= v1-80 0) (< f0-3 (-> gp-3 v1-80))) + (when (< v1-80 15) + (set! (-> gp-3 (+ v1-80 1)) (-> gp-3 v1-80)) + (set! (-> self result-array (+ v1-80 1)) (-> self result-array v1-80)) + ) + (+! v1-80 -1) + ) + (when (< v1-80 15) + (let ((v1-81 (+ v1-80 1))) + (if (< (-> self result-count) 16) + (+! (-> self result-count) 1) + ) + (set! (-> gp-3 v1-81) f0-3) + (set! (-> self result-array v1-81) (process->handle s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) s4-0) (-> s4-0 w))) + (when (and (nonzero? (-> s3-1 control root-prim prim-core collide-as)) + (logtest? (process-mask crate enemy guard vehicle civilian kg-robot metalhead) (-> s3-1 mask)) + (not (focus-test? s3-1 disable dead ignore)) + (!= s3-1 s5-1) + ) + (let* ((s5-2 (get-trans s3-1 3)) + (f0-5 (vector-vector-distance-squared (-> self root trans) s5-2)) + (f1-6 (-> s5-2 w)) + (f0-6 (- f0-5 (* f1-6 f1-6))) + (v1-101 (+ (-> self result-count) -1)) + ) + (while (and (>= v1-101 0) (< f0-6 (-> gp-3 v1-101))) + (when (< v1-101 15) + (set! (-> gp-3 (+ v1-101 1)) (-> gp-3 v1-101)) + (set! (-> self result-array (+ v1-101 1)) (-> self result-array v1-101)) + ) + (+! v1-101 -1) + ) + (when (< v1-101 15) + (let ((v1-102 (+ v1-101 1))) + (if (< (-> self result-count) 16) + (+! (-> self result-count) 1) + ) + (set! (-> gp-3 v1-102) f0-6) + (set! (-> self result-array v1-102) (process->handle s3-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if (zero? (-> self result-count)) + (go-virtual fizzle) + ) + (let ((gp-4 (handle->process (-> self result-array 0)))) + (deal-damage! self gp-4 (the-as event-message-block #f)) + (let ((s5-3 gp-4)) + (if (or (if (type? s5-3 crate) + s5-3 + ) + (let ((s5-4 gp-4)) + (if (type? s5-4 market-object) + s5-4 + ) + ) + (if (type? gp-4 fruit-stand) + gp-4 + ) + ) + (process-spawn gun-dark-shot :init gun-dark-shot-init-fizzle (-> self root trans) :name "gun-dark-shot") + ) + ) + ) + ) + :trans (behavior () + (let ((t9-0 (-> (method-of-type projectile impact) trans))) + (if t9-0 + (t9-0) + ) + ) + (when (and (> (-> self result-count) 0) (time-elapsed? (-> self spread-timer) (seconds 0.1))) + (set-time! (-> self spread-timer)) + (+! (-> self result-count) -1) + (while (and (>= (-> self result-count) 0) (not (handle->process (-> self result-array (-> self result-count))))) + (+! (-> self result-count) -1) + ) + (when (>= (-> self result-count) 0) + (let ((s5-0 (handle->process (-> self result-array (-> self result-count))))) + (if s5-0 + (process-spawn-function + process + (lambda :behavior process + ((arg0 handle) (arg1 float)) + (let* ((s3-0 (ppointer->process (-> self parent))) + (s5-0 (if (type? s3-0 process-focusable) + s3-0 + ) + ) + (s2-0 0) + (s1-0 (current-time)) + (s3-1 #f) + ) + (+! (-> self clock ref-count) -1) + (+! (-> s5-0 clock ref-count) 1) + (set! (-> self clock) (-> s5-0 clock)) + (while (and (nonzero? (-> (the-as process-focusable s5-0) skel)) + (or (focus-test? (the-as process-focusable s5-0) dead hit) + (and (-> (the-as process-focusable s5-0) next-state) + (= (-> (the-as process-focusable s5-0) next-state name) 'knocked) + ) + (not (time-elapsed? s1-0 (seconds 0.35))) + ) + (not (time-elapsed? s1-0 (seconds 5))) + (not (logtest? (-> (the-as process-focusable s5-0) draw status) (draw-control-status no-draw no-draw-temp))) + (or (not (and (-> (the-as process-focusable s5-0) next-state) + (= (-> (the-as process-focusable s5-0) next-state name) 'fizzle) + ) + ) + (not (type? s5-0 missile-bot)) + ) + ) + (when (time-elapsed? (the-as time-frame s2-0) (seconds 0.05)) + (set! s2-0 (the-as int (current-time))) + (let ((a0-5 (handle->process arg0))) + (if a0-5 + (process-drawable-shock-effect-bullseye + (the-as process-focusable a0-5) + (the-as process-focusable s5-0) + (-> *lightning-spec-id-table* 16) + lightning-probe-callback + (-> *part-id-table* 665) + (-> *part-id-table* 255) + (-> *part-id-table* 257) + ) + ) + ) + (process-drawable-shock-effect-replace + (the-as process-drawable s5-0) + (-> *lightning-spec-id-table* 15) + lightning-probe-callback + 0 + 0 + 40960.0 + ) + ) + (suspend) + (let ((s5-1 (ppointer->process (-> self parent)))) + (set! s5-0 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (when (and (not s3-1) (time-elapsed? s1-0 (seconds 0.1)) (!= s5-0 (handle->process arg0))) + (set! s3-1 #t) + (send-event + s5-0 + 'attack + #f + (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) (damage 16.0) (vehicle-damage-factor arg1) (vehicle-impulse-factor 1.0) (mode 'explode)) + ) + ) + ) + ) + (+! (-> *game-info* shots-hit 3) 1.0) + (when (and (not s3-1) (!= s5-0 (handle->process arg0))) + #t + (send-event + s5-0 + 'attack + #f + (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) (damage 16.0) (vehicle-damage-factor arg1) (vehicle-impulse-factor 1.0) (mode 'explode)) + ) + ) + ) + ) + ) + (-> self result-array 0) + (-> self vehicle-damage-factor) + :to s5-0 + ) + ) + ) + ) + ) + (if (or (time-elapsed? (-> self spread-timer) (seconds 10)) + (and (not (-> self child)) + (= (get-status *gui-control* (-> self explode-sound)) (gui-status unknown)) + (< (-> self result-count) 0) + ) + ) + (deactivate self) + ) + ) + :code sleep-code + ) + +(deftype gravity-spinner (process) + ((cached-damage float) + (end-time time-frame) + (time-subtract time-frame) + (parent-hand handle) + (rotation-accel vector :inline) + (original-sphere-offset sphere :inline) + (obj-radius float) + (was-hit-previously? symbol) + (ground-height float) + (next-ground-probe-time time-frame) + ) + (:state-methods + zero-g + zero-g-vehicle + ) + (:methods + (gravity-spinner-method-16 (_type_ vector vector) none) + (update-rotation (_type_ symbol) none) + (gravity-spinner-method-18 (_type_ process) float) + (handle-impact (_type_ symbol) vector) + (probe-ground (_type_) none) + (get-float-speed (_type_) float) + (gravity-spinner-method-22 (_type_) none) + (spawn-part (_type_) none) + (rotate! (_type_ quaternion) none) + ) + ) + + +(defmethod relocate ((this gravity-spinner) (offset int)) + (call-parent-method this offset) + ) + +(defmethod deactivate ((this gravity-spinner)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (call-parent-method this) + (none) + ) + +(defmethod gravity-spinner-method-18 ((this gravity-spinner) (arg0 process)) + 1.0 + ) + +(defmethod spawn-part ((this gravity-spinner)) + (when (zero? (mod (the-as int (rand-uint31-gen *random-generator*)) 5)) + (let* ((s5-0 (handle->process (-> this parent-hand))) + (gp-1 (if (type? s5-0 process-focusable) + s5-0 + ) + ) + ) + (when gp-1 + (when (and (-> (the-as process-focusable gp-1) node-list) (nonzero? (-> (the-as process-focusable gp-1) node-list))) + (let* ((v1-12 + (+ (mod + (the-as int (rand-uint31-gen *random-generator*)) + (+ (-> (the-as process-focusable gp-1) node-list length) -2) + ) + 2 + ) + ) + (v1-15 + (vector<-cspace! (new 'stack-no-clear 'vector) (-> (the-as process-focusable gp-1) node-list data v1-12)) + ) + (t9-4 sp-launch-particles-var) + (a0-9 *sp-particle-system-2d*) + (a1-5 (-> *part-id-table* 398)) + (a2-0 *launch-matrix*) + ) + (set! (-> a2-0 trans quad) (-> v1-15 quad)) + (t9-4 a0-9 a1-5 a2-0 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod gravity-spinner-method-22 ((this gravity-spinner)) + (local-vars (a1-11 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (let* ((gp-0 (handle->process (-> this parent-hand))) + (s3-0 (if (type? gp-0 process-focusable) + gp-0 + ) + ) + ) + (when s3-0 + (let* ((gp-1 (-> (the-as process-focusable s3-0) root)) + (s5-0 (-> gp-1 root-prim)) + (s4-0 (-> gp-1 process node-list)) + (v1-5 (quaternion->matrix (new 'stack-no-clear 'matrix) (-> (the-as process-focusable s3-0) root quat))) + ) + (set! (-> v1-5 trans quad) (-> (the-as process-focusable s3-0) root trans quad)) + (when (nonzero? s4-0) + (countdown (a0-7 (-> gp-1 total-prims)) + (when (and (= (-> s5-0 transform-index) -2) (!= s5-0 (-> gp-1 root-prim))) + (.lvf vf5 (&-> v1-5 trans quad)) + (.lvf vf1 (&-> s5-0 local-sphere quad)) + (.lvf vf2 (&-> v1-5 rvec quad)) + (.mul.w.vf acc vf5 vf0) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b11) + (.lvf vf3 (&-> v1-5 uvec quad)) + (.add.mul.x.vf acc vf2 vf1 acc) + (.lvf vf4 (&-> v1-5 fvec quad)) + (.add.mul.y.vf acc vf3 vf1 acc) + (.add.mul.z.vf vf1 vf4 vf1 acc :mask #b111) + (.mul.vf vf1 vf1 Q :mask #b111) + (.svf (&-> s5-0 prim-core world-sphere quad) vf1) + (.mov a1-11 vf1) + ) + (&+! s5-0 80) + ) + ) + ) + ) + ) + (none) + ) + ) + +(defmethod get-float-speed ((this gravity-spinner)) + (let* ((s4-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (when s5-0 + (let ((f0-2 (- (- (-> (get-trans (the-as process-focusable s5-0) 3) y) + (-> (the-as process-focusable s5-0) root root-prim local-sphere w) + ) + (-> this ground-height) + ) + ) + ) + (cond + ((< f0-2 4096.0) + (* 10.0 (seconds-per-frame) (- 4096.0 f0-2)) + ) + ((< 14336.0 f0-2) + (let* ((f0-5 (+ -14336.0 f0-2)) + (f0-7 (* f0-5 f0-5)) + (f0-9 (* 0.00008138021 (- f0-7))) + (f0-10 (fmax -61440.0 f0-9)) + ) + (* 10.0 (seconds-per-frame) f0-10) + ) + ) + (else + 0.0 + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod probe-ground ((this gravity-spinner)) + (let* ((s4-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (when s5-0 + (let ((s4-1 (get-trans (the-as process-focusable s5-0) 3)) + (s3-0 (new 'stack-no-clear 'collide-query)) + ) + 0.0 + (vector+float*! (-> s3-0 start-pos) s4-1 *up-vector* 24576.0) + (set! (-> s3-0 move-dist quad) (the-as uint128 0)) + (set! (-> s3-0 move-dist y) -81920.0) + (let ((v1-8 s3-0)) + (set! (-> v1-8 radius) 40.96) + (set! (-> v1-8 collide-with) (collide-spec backgnd)) + (set! (-> v1-8 ignore-process0) #f) + (set! (-> v1-8 ignore-process1) #f) + (set! (-> v1-8 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-8 action-mask) (collide-action solid)) + ) + (set! (-> this ground-height) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s3-0) 0.0) + (-> s3-0 best-other-tri intersect y) + (fmin + (- (-> s4-1 y) (-> (the-as process-focusable s5-0) root root-prim local-sphere w)) + (-> (target-pos 0) y) + ) + ) + ) + ) + ) + ) + (none) + ) + +(define *gravity-origin-pos* (new 'static 'vector)) + +(defbehavior gravity-spinner-init-by-other gravity-spinner ((arg0 handle) (arg1 object) (arg2 time-frame)) + (stack-size-set! (-> self main-thread) 512) + (set! (-> self parent-hand) arg0) + (set! (-> self time-subtract) arg2) + (set! (-> self cached-damage) 0.0) + (set! (-> self was-hit-previously?) #f) + (let* ((s5-1 (handle->process (-> self parent-hand))) + (gp-1 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (when gp-1 + (set! (-> self original-sphere-offset quad) + (-> (the-as process-focusable gp-1) root root-prim local-sphere quad) + ) + (set! (-> *gravity-origin-pos* quad) (-> (get-trans (the-as process-focusable gp-1) 3) quad)) + (iterate-prims + (-> (the-as process-focusable gp-1) root) + (lambda :behavior gravity-spinner + ((arg0 collide-shape-prim)) + (case (-> arg0 prim-core prim-type) + ((-1) + (set! (-> self obj-radius) + (fmax + (-> self obj-radius) + (+ (vector-vector-distance (the-as vector (-> arg0 prim-core)) *gravity-origin-pos*) + (-> arg0 prim-core world-sphere w) + ) + ) + ) + ) + ) + (none) + ) + ) + (set! (-> self obj-radius) + (fmin (-> self obj-radius) (-> (the-as process-focusable gp-1) root root-prim local-sphere w)) + ) + (when (not (logtest? (process-mask vehicle) (-> gp-1 mask))) + (set! (-> self obj-radius) (* 0.75 (-> self obj-radius))) + (set! (-> (the-as process-focusable gp-1) root root-prim local-sphere w) (-> self obj-radius)) + (set! (-> (the-as process-focusable gp-1) root root-prim prim-core world-sphere w) (-> self obj-radius)) + ) + (let* ((v1-23 (get-trans (the-as process-focusable gp-1) 3)) + (s5-4 (vector-! (new 'stack-no-clear 'vector) v1-23 (the-as vector arg1))) + (s4-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-1 quad) (-> v1-23 quad)) + (let* ((f0-8 (- (-> s5-4 y))) + (f0-9 (if (< f0-8 0.0) + (fmax f0-8 (-> (the-as process-focusable gp-1) root root-prim local-sphere w)) + (fmin f0-8 (-> (the-as process-focusable gp-1) root root-prim local-sphere w)) + ) + ) + ) + (+! (-> s4-1 y) f0-9) + ) + (vector+! + s5-4 + s5-4 + (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> (the-as process-focusable gp-1) root transv) 1.0) + ) + (let ((a0-17 s5-4)) + (set! (-> a0-17 quad) (-> s5-4 quad)) + (set! (-> a0-17 y) 0.0) + (vector-normalize! a0-17 1.0) + ) + (let* ((s3-1 vector-rotate-around-axis!) + (s2-2 s5-4) + (s1-0 s5-4) + (f30-0 -1820.4445) + (f28-0 3640.889) + (v1-39 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-40 (the-as number (logior #x3f800000 v1-39))) + ) + (s3-1 s2-2 (the-as quaternion s1-0) (+ f30-0 (* f28-0 (+ -1.0 (the-as float v1-40)))) *up-vector*) + ) + (let ((f0-18 (* 0.000061035156 (-> self obj-radius)))) + 0.0 + (let* ((f30-1 (lerp 1.0 0.2 f0-18)) + (s3-2 s5-4) + (s2-3 s5-4) + (f28-1 12288.0) + (f26-0 8192.0) + (v1-46 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-47 (the-as number (logior #x3f800000 v1-46))) + ) + (vector-float*! s3-2 s2-3 (* f30-1 (+ f28-1 (* f26-0 (+ -1.0 (the-as float v1-47)))))) + ) + ) + (gravity-spinner-method-16 self s4-1 s5-4) + ) + (if (logtest? (process-mask vehicle) (-> gp-1 mask)) + (go-virtual zero-g-vehicle) + (go-virtual zero-g) + ) + ) + ) + ) + +(defmethod handle-impact ((this gravity-spinner) (arg0 symbol)) + (local-vars + (sv-144 sphere) + (sv-148 process) + (sv-152 vector) + (sv-156 float) + (sv-160 float) + (sv-164 vector) + (sv-168 symbol) + (sv-172 float) + (sv-1728 vector) + (sv-1732 vector) + (sv-1736 float) + (sv-2304 vector) + (sv-2308 vector) + (sv-2312 float) + ) + (let* ((s3-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s3-0 process-focusable) + s3-0 + ) + ) + ) + (when s5-0 + (set! sv-144 (new 'stack 'sphere)) + (set! sv-148 (the-as process (send-event *target* 'get-vehicle))) + (let ((v1-7 (new 'stack-no-clear 'vector))) + (set! (-> v1-7 quad) (-> (the-as process-focusable s5-0) root transv quad)) + (set! sv-152 v1-7) + ) + (set! sv-156 (the-as float 0.0)) + (set! sv-160 (the-as float 102400.0)) + (set! sv-164 (new 'stack-no-clear 'vector)) + (set! sv-168 (the-as symbol #f)) + (set! sv-172 (the-as float 40960000.0)) + (if arg0 + (set! sv-160 (the-as float 163840.0)) + ) + (set! sv-156 (vector-normalize-ret-len! sv-152 1.0)) + (set! (-> sv-144 quad) (-> (get-trans (the-as process-focusable s5-0) 3) quad)) + (set! (-> sv-144 r) sv-160) + (let ((s3-2 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-144) s3-2 384)) + (let* ((s1-0 (-> s3-2 s2-0)) + (a0-15 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when a0-15 + (let* ((s1-1 (-> a0-15 process)) + (a0-17 (if (type? s1-1 process-focusable) + s1-1 + ) + ) + ) + (when a0-17 + (when (and (!= s5-0 a0-17) + (not (focus-test? (the-as process-focusable a0-17) disable dead inactive gun-no-target)) + (logtest? (process-mask enemy guard civilian) (-> a0-17 mask)) + (not (focus-test? (the-as process-focusable a0-17) no-gravity)) + (!= a0-17 sv-148) + ) + (set! sv-1728 (get-trans (the-as process-focusable a0-17) 3)) + (set! sv-1732 (new 'stack-no-clear 'vector)) + (set! sv-1736 (the-as float 0.0)) + (vector-! sv-1732 sv-1728 (the-as vector sv-144)) + (set! sv-1736 (vector-normalize-ret-len! sv-1732 1.0)) + (when (and (>= sv-160 sv-1736) (< sv-1736 sv-172) (< sv-1736 (* 4.5 sv-156))) + (let ((f30-0 (vector-dot sv-152 sv-1732)) + (f0-12 0.707) + ) + (if arg0 + (set! f0-12 0.5) + ) + (when (< f0-12 f30-0) + (let ((a1-19 (new 'stack 'collide-query))) + (set! (-> a1-19 start-pos quad) (-> sv-144 quad)) + (vector-! (-> a1-19 move-dist) sv-1728 (-> a1-19 start-pos)) + (let ((v1-53 a1-19)) + (set! (-> v1-53 radius) (* 0.8 (-> (the-as process-focusable s5-0) root root-prim prim-core world-sphere w))) + (set! (-> v1-53 collide-with) (collide-spec backgnd obstacle)) + (set! (-> v1-53 ignore-process0) #f) + (set! (-> v1-53 ignore-process1) #f) + (set! (-> v1-53 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-53 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* a1-19) 0.0) + (set! sv-172 (* sv-1736 (* f30-0 f30-0))) + (set! sv-168 #t) + (let ((f0-18 sv-156)) + (when arg0 + (set! f0-18 (fmin (fmax sv-156 (* 1.5 sv-1736)) (* 3.0 sv-156))) + (if (-> this was-hit-previously?) + (set! f0-18 (fmin f0-18 (* 2.0 sv-156))) + ) + ) + (vector-normalize-copy! sv-164 sv-1732 f0-18) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-3 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-3 (< (vector-vector-distance (get-trans s3-3 0) sv-144) (-> sv-144 r))) + (when (and (!= s5-0 s3-3) + (not (focus-test? s3-3 disable dead inactive gun-no-target)) + (logtest? (process-mask enemy guard civilian) (-> s3-3 mask)) + (not (focus-test? s3-3 no-gravity)) + (!= s3-3 sv-148) + ) + (set! sv-2304 (get-trans s3-3 3)) + (set! sv-2308 (new 'stack-no-clear 'vector)) + (set! sv-2312 (the-as float 0.0)) + (vector-! sv-2308 sv-2304 (the-as vector sv-144)) + (set! sv-2312 (vector-normalize-ret-len! sv-2308 1.0)) + (when (and (>= sv-160 sv-2312) (< sv-2312 sv-172) (< sv-2312 (* 4.5 sv-156))) + (let ((f30-1 (vector-dot sv-152 sv-2308)) + (f0-28 0.707) + ) + (if arg0 + (set! f0-28 0.5) + ) + (when (< f0-28 f30-1) + (let ((a1-29 (new 'stack 'collide-query))) + (set! (-> a1-29 start-pos quad) (-> sv-144 quad)) + (vector-! (-> a1-29 move-dist) sv-2304 (-> a1-29 start-pos)) + (let ((v1-103 a1-29)) + (set! (-> v1-103 radius) (* 0.8 (-> (the-as process-focusable s5-0) root root-prim prim-core world-sphere w))) + (set! (-> v1-103 collide-with) (collide-spec backgnd obstacle)) + (set! (-> v1-103 ignore-process0) #f) + (set! (-> v1-103 ignore-process1) #f) + (set! (-> v1-103 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-103 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* a1-29) 0.0) + (set! sv-172 (* sv-2312 (* f30-1 f30-1))) + (set! sv-168 #t) + (let ((f0-34 sv-156)) + (when arg0 + (set! f0-34 (fmin (fmax sv-156 (* 1.5 sv-2312)) (* 3.0 sv-156))) + (if (-> this was-hit-previously?) + (set! f0-34 (fmin f0-34 (* 2.0 sv-156))) + ) + ) + (vector-normalize-copy! sv-164 sv-2308 f0-34) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (when sv-168 + (let ((v0-1 (-> (the-as process-focusable s5-0) root transv))) + (set! (-> v0-1 quad) (-> sv-164 quad)) + v0-1 + ) + ) + ) + ) + ) + +(defmethod gravity-spinner-method-16 ((this gravity-spinner) (arg0 vector) (arg1 vector)) + (local-vars (sv-48 vector) (sv-52 vector) (sv-56 float)) + (let* ((s2-0 (handle->process (-> this parent-hand))) + (s4-0 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (when s4-0 + (set! sv-48 (vector-! (new 'stack-no-clear 'vector) arg0 (get-trans (the-as process-focusable s4-0) 3))) + (set! sv-52 (new 'stack-no-clear 'vector)) + (let ((f30-0 1.0) + (f0-0 (gravity-spinner-method-18 this s4-0)) + (f1-1 (fmin 12288.0 (-> (the-as process-focusable s4-0) root root-prim prim-core world-sphere w))) + ) + (set! sv-56 (/ f30-0 (* f0-0 (* f1-1 f1-1)))) + ) + (vector-cross! sv-52 sv-48 arg1) + (vector+float*! (-> this rotation-accel) (-> this rotation-accel) sv-52 sv-56) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch quaternion vs none. +(defmethod rotate! ((this gravity-spinner) (arg0 quaternion)) + (let* ((s4-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (when s5-0 + (let* ((s4-1 (get-trans (the-as process-focusable s5-0) 3)) + (s3-1 (vector-! (new 'stack-no-clear 'vector) (-> (the-as process-focusable s5-0) root trans) s4-1)) + ) + (let ((s2-0 (new 'stack-no-clear 'matrix))) + (quaternion->matrix s2-0 arg0) + (vector-matrix*! s3-1 s3-1 s2-0) + ) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere x) (- (-> s3-1 x))) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere y) (- (-> s3-1 y))) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere z) (- (-> s3-1 z))) + (vector+! (-> (the-as process-focusable s5-0) root trans) s4-1 s3-1) + ) + (quaternion*! + (-> (the-as process-focusable s5-0) root quat) + arg0 + (-> (the-as process-focusable s5-0) root quat) + ) + (quaternion-normalize! (-> (the-as process-focusable s5-0) root quat)) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defmethod update-rotation ((this gravity-spinner) (arg0 symbol)) + (cond + ((< (current-time) (+ (-> this end-time) (seconds -0.2))) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> this rotation-accel quad)) + 0.0 + (let* ((f0-1 (vector-normalize-ret-len! s5-1 1.0)) + (f0-2 (* 182.04445 f0-1)) + (f0-3 (* 360.0 f0-2)) + (f0-4 (* 0.2 f0-3)) + (f30-0 (fmin 116508.445 f0-4)) + (s4-0 (handle->process (-> this parent-hand))) + ) + (if (if (type? s4-0 process-focusable) + s4-0 + ) + (rotate! this (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) s5-1 (* f30-0 (seconds-per-frame)))) + ) + ) + ) + (if (< 0.2 (vector-length (-> this rotation-accel))) + (vector-float*! (-> this rotation-accel) (-> this rotation-accel) (- 1.0 (* 0.2 (seconds-per-frame)))) + ) + ) + (else + (let* ((s3-1 (handle->process (-> this parent-hand))) + (s4-2 (if (type? s3-1 process-focusable) + s3-1 + ) + ) + ) + (when s4-2 + (let ((s2-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> (the-as process-focusable s4-2) root quat))) + (s3-2 (new 'stack-no-clear 'quaternion)) + (f30-1 (* 4.0 (seconds-per-frame))) + ) + (let ((a0-18 s2-0)) + (set! (-> a0-18 quad) (-> s2-0 quad)) + (set! (-> a0-18 y) 0.0) + (vector-normalize! a0-18 1.0) + ) + (quaternion-look-at! s3-2 s2-0 *up-vector*) + (let ((s2-1 (quaternion-copy! (new 'stack-no-clear 'quaternion) (-> (the-as process-focusable s4-2) root quat)))) + (if arg0 + (quaternion-copy! s2-1 s3-2) + (quaternion-slerp! s2-1 s2-1 s3-2 f30-1) + ) + (let ((a1-16 + (quaternion*! + (new 'stack-no-clear 'quaternion) + s2-1 + (quaternion-inverse! (new 'stack-no-clear 'quaternion) (-> (the-as process-focusable s4-2) root quat)) + ) + ) + ) + (rotate! this a1-16) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defstate zero-g-vehicle (gravity-spinner) + :virtual #t + :enter (behavior () + (let* ((gp-0 (current-time)) + (f30-0 300.0) + (f28-0 6.0) + (f26-0 2.0) + (v1-5 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-6 (the-as number (logior #x3f800000 v1-5))) + ) + (set! (-> self end-time) + (+ gp-0 + (the int + (* f30-0 + (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-6)))) + (if (logtest? (game-secrets gun-upgrade-dark-2) (-> *game-info* secrets)) + 1.5 + 1.0 + ) + ) + ) + ) + ) + ) + (set! (-> self end-time) (- (-> self end-time) (-> self time-subtract))) + (set! (-> self end-time) (the-as time-frame (max (-> self end-time) (+ (current-time) (seconds 2))))) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage 0.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-dark) + (attacker-velocity *zero-vector*) + (penetrate-using (penetrate explode jak-dark-blackhole)) + ) + ) + ) + ) + :code (behavior () + (until (< (-> self end-time) (current-time)) + (suspend) + ) + (let* ((f0-1 (+ 0.5 (* 0.0625 (-> self cached-damage)))) + (f0-2 (fmin 0.9 f0-1)) + ) + (send-event (handle->process (-> self parent-hand)) 'gun-dark-2-off f0-2) + ) + (let ((gp-0 (handle->process (-> self parent-hand)))) + (if (if (type? gp-0 process-focusable) + gp-0 + ) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage 0.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (penetrate-using (penetrate vehicle)) + (vector *zero-vector*) + (attacker-velocity *zero-vector*) + (mode 'gravity-end) + ) + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch int vs object. +(defbehavior zero-g-wait-for-land gravity-spinner () + (let ((gp-0 (current-time))) + (until (time-elapsed? gp-0 (seconds 1.5)) + (let* ((s4-0 (handle->process (-> self parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (cond + ((and s5-0 + (not (logtest? (-> (the-as process-focusable s5-0) focus-status) (focus-status disable dead inactive))) + ) + (if (or (< (- (-> (get-trans (the-as process-focusable s5-0) 3) y) + (-> (the-as process-focusable s5-0) root root-prim local-sphere w) + ) + (-> self ground-height) + ) + (let ((s4-1 (-> (the-as process-focusable s5-0) root))) + (and (if (type? s4-1 collide-shape-moving) + s4-1 + ) + (logtest? (-> (the-as collide-shape-moving (-> (the-as process-focusable s5-0) root)) status) + (collide-status on-surface touch-surface) + ) + ) + ) + ) + (return (the-as object 0)) + ) + (when (not (logtest? (process-mask vehicle) (-> (the-as process-focusable s5-0) mask))) + (let ((s4-2 (new 'stack 'sphere))) + (vector-lerp! + s4-2 + (-> (the-as process-focusable s5-0) root root-prim local-sphere) + (-> self original-sphere-offset) + (* 3.0 (seconds-per-frame)) + ) + (set! (-> s4-2 r) (lerp + (-> (the-as process-focusable s5-0) root root-prim local-sphere w) + (-> self original-sphere-offset r) + (* 3.0 (seconds-per-frame)) + ) + ) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere quad) (-> s4-2 quad)) + ) + (if (>= (+ (current-time) (seconds -1)) gp-0) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere quad) + (-> self original-sphere-offset quad) + ) + ) + ) + ) + (else + (return (the-as object 0)) + ) + ) + ) + (suspend) + ) + ) + (the-as int #f) + ) + +(define *zero-g-fake-attack-vec* (new 'static 'vector :y -0.001 :w 1.0)) + +(defstate zero-g (gravity-spinner) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (sv-32 vector) (sv-36 float) (sv-40 uint) (sv-48 uint)) + (case message + (('get-float-speed) + (get-float-speed self) + ) + (('update-rotation) + (update-rotation self #f) + ) + (('impact) + (handle-impact self #f) + (let ((s5-1 (handle->process (-> self parent-hand)))) + (when (if (type? s5-1 process-focusable) + s5-1 + ) + (let ((f0-0 (vector-length (the-as vector (-> block param 1))))) + 0.0 + (when (< 40960.0 f0-0) + (let ((f30-0 (* 0.000024414063 f0-0))) + (format 0 "Receving impact damage ~f~%" f30-0) + (+! (-> self cached-damage) f30-0) + ) + ) + ) + ) + ) + (gravity-spinner-method-16 self (the-as vector (-> block param 0)) (the-as vector (-> block param 1))) + ) + (('is-gravity) + #t + ) + (('attack-forward) + (if (!= proc (handle->process (-> self parent-hand))) + (return 0) + ) + (set! sv-32 (vector-normalize-copy! (new 'stack-no-clear 'vector) (the-as vector (-> block param 0)) 1.0)) + (set! sv-36 (the-as float 0.0)) + (set! sv-40 (-> block param 2)) + (set! sv-48 (-> block param 3)) + (set! sv-36 (if (logtest? (attack-mask damage) (-> (the-as attack-info sv-40) mask)) + (-> (the-as attack-info sv-40) damage) + (penetrate-using->damage (the-as penetrate sv-48)) + ) + ) + (vector-float*! sv-32 sv-32 (fmin 184320.0 (vector-length (the-as vector (-> block param 4))))) + (if (!= sv-48 1024) + (vector-float*! sv-32 sv-32 (* 2.0 sv-36)) + ) + (set! (-> sv-32 y) (* 0.15 (-> sv-32 y))) + (+! (-> self cached-damage) sv-36) + (let ((s4-0 (if (type? proc process-focusable) + proc + ) + ) + ) + (when s4-0 + (vector-float*! sv-32 sv-32 (fmax 0.5 (gravity-spinner-method-18 self s4-0))) + (vector+float*! + (-> (the-as process-drawable s4-0) root transv) + (-> (the-as process-drawable s4-0) root transv) + sv-32 + 1.0 + ) + (let ((f0-17 (vector-normalize-ret-len! (-> (the-as process-drawable s4-0) root transv) 1.0))) + (vector-float*! + (-> (the-as process-drawable s4-0) root transv) + (-> (the-as process-drawable s4-0) root transv) + (fmin 143360.0 f0-17) + ) + ) + (handle-impact self #t) + (gravity-spinner-method-16 self (the-as vector (-> block param 5)) sv-32) + ) + ) + (when (< 0.0 sv-36) + (let ((v0-0 (the-as object #t))) + (set! (-> self was-hit-previously?) (the-as symbol v0-0)) + v0-0 + ) + ) + ) + ) + ) + :enter (behavior () + (let* ((gp-0 (current-time)) + (f30-0 300.0) + (f28-0 7.0) + (f26-0 2.0) + (v1-5 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-6 (the-as number (logior #x3f800000 v1-5))) + ) + (set! (-> self end-time) + (+ gp-0 + (the int + (* f30-0 + (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-6)))) + (if (logtest? (game-secrets gun-upgrade-dark-2) (-> *game-info* secrets)) + 1.5 + 1.0 + ) + ) + ) + ) + ) + ) + (set! (-> self end-time) (- (-> self end-time) (-> self time-subtract))) + (set! (-> self end-time) (the-as time-frame (max (-> self end-time) (+ (current-time) (seconds 2))))) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage 0.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-dark) + (attacker (process->handle *target*)) + (attacker-velocity *zero-vector*) + (penetrate-using (penetrate explode jak-dark-blackhole)) + ) + ) + ) + ) + :code (behavior () + (until (< (-> self end-time) (current-time)) + (when (< (-> self next-ground-probe-time) (current-time)) + (probe-ground self) + (set! (-> self next-ground-probe-time) + (the-as time-frame (+ (mod (the-as int (rand-uint31-gen *random-generator*)) 61) 60 (current-time))) + ) + ) + (suspend) + ) + (send-event (handle->process (-> self parent-hand)) 'gun-dark-2-off) + (let* ((s5-0 (handle->process (-> self parent-hand))) + (gp-0 (if (type? s5-0 process-focusable) + s5-0 + ) + ) + ) + (when gp-0 + (update-rotation self #t) + (quaternion-normalize! (-> (the-as process-focusable gp-0) root quat)) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) + (damage 0.2) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (penetrate-using (penetrate vehicle)) + (vector (-> (the-as process-focusable gp-0) root transv)) + (attacker-velocity (-> (the-as process-focusable gp-0) root transv)) + (mode 'gravity-end) + (attacker (process->handle *target*)) + ) + ) + ) + (let ((f0-5 + (- (- (-> (get-trans (the-as process-focusable gp-0) 3) y) + (-> (the-as process-focusable gp-0) root root-prim local-sphere w) + ) + (-> self ground-height) + ) + ) + ) + 0.0 + (set! (-> self cached-damage) (* 2.0 (-> self cached-damage))) + (let* ((f0-6 (* 0.00012207031 f0-5)) + (f0-7 (fmax 1.0 f0-6)) + ) + (+! (-> self cached-damage) f0-7) + ) + ) + (let* ((gp-1 (-> (the-as process-focusable gp-0) root)) + (v1-37 (if (type? gp-1 collide-shape-moving) + gp-1 + ) + ) + ) + (if v1-37 + (logclear! (-> (the-as collide-shape-moving v1-37) status) (collide-status on-surface touch-surface)) + ) + ) + ) + ) + (probe-ground self) + (zero-g-wait-for-land) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage (-> self cached-damage)) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (penetrate-using (penetrate vehicle)) + (vector *zero-g-fake-attack-vec*) + (attacker-velocity *zero-g-fake-attack-vec*) + (mode 'eco-dark) + (attacker (process->handle *target*)) + ) + ) + ) + (let* ((s5-1 (handle->process (-> self parent-hand))) + (gp-2 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (when gp-2 + (set! (-> (the-as process-focusable gp-2) root root-prim local-sphere quad) + (-> self original-sphere-offset quad) + ) + (let ((s5-2 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> (the-as process-focusable gp-2) root quat)))) + (new 'stack-no-clear 'vector) + (let ((a0-67 s5-2)) + (set! (-> a0-67 quad) (-> s5-2 quad)) + (set! (-> a0-67 y) 0.0) + (vector-normalize! a0-67 1.0) + ) + (quaternion-look-at! (-> (the-as process-focusable gp-2) root quat) s5-2 *up-vector*) + ) + ) + ) + ) + :post (behavior () + (spawn-part self) + (if (>= (-> self end-time) (current-time)) + (gravity-spinner-method-22 self) + ) + ) + ) + +(defskelgroup skel-gun-dark-2-ring gun gun-dark-2-ring-lod0-jg gun-dark-2-ring-idle-ja + ((gun-dark-2-ring-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0.5 84) + :longest-edge (meters 80) + :shadow gun-dark-2-ring-shadow-mg + ) + +(define *gun-gravity-shadow-control* + (new 'static 'shadow-control :settings (new 'static 'shadow-settings + :center (new 'static 'vector :w (the-as float #x9a)) + :shadow-dir (new 'static 'vector :y -1.0 :w 614400.0) + :bot-plane (new 'static 'plane :y 1.0 :w 163840.0) + :top-plane (new 'static 'plane :y 1.0 :w -163840.0) + :shadow-type 2 + ) + ) + ) + +(deftype gravity-ring (process-drawable) + ((start-pos vector :inline) + (jmod-outer joint-mod-add-local :inline) + (jmod-inner joint-mod-add-local :inline) + (ring-scale-t float) + (current-radius float) + (max-radius float) + (reverse? symbol) + (total-time float) + (ring-width float) + (stop-time time-frame) + ) + (:state-methods + expand + ) + (:methods + (gravity-ring-method-21 (_type_) none) + ) + ) + + +(defbehavior gravity-ring-init-by-other gravity-ring ((arg0 vector) (arg1 symbol) (arg2 float) (arg3 float) (arg4 float) (arg5 time-frame)) + (set! (-> self root) (new 'process 'trsqv)) + (set! (-> self root trans quad) (-> arg0 quad)) + (quaternion-identity! (-> self root quat)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-dark-2-ring" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self draw shadow-ctrl) *gun-gravity-shadow-control*) + (init (-> self jmod-inner) self (the-as uint 4) (joint-mod-base-flags attached scale)) + (init (-> self jmod-outer) self (the-as uint 3) (joint-mod-base-flags attached scale)) + (let ((v1-13 (-> self draw shadow-ctrl))) + (logclear! (-> v1-13 settings flags) (shadow-flags disable-draw)) + ) + 0 + (logclear! (-> self draw status) (draw-control-status no-draw)) + (set! (-> self total-time) arg3) + (set! (-> self reverse?) arg1) + (set! (-> self max-radius) arg2) + (set! (-> self ring-width) arg4) + (+! (-> self root trans y) (-> self max-radius)) + (ja-post) + (setup-masks (-> self draw) 0 1) + (set-time! (-> self state-time)) + (set! (-> self stop-time) arg5) + (go-virtual expand) + ) + +(defstate expand (gravity-ring) + :virtual #t + :trans (behavior () + (gravity-ring-method-21 self) + ) + :code sleep-code + :post (behavior () + (ja-post) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod gravity-ring-method-21 ((this gravity-ring)) + (let* ((a0-1 *time-of-day-context*) + (v1-0 (-> a0-1 light-group)) + (s4-0 (-> v1-0 0 ambi color)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (-> a0-1 current-prt-color) + (-> a0-1 current-env-color) + (vector4-lerp! s5-0 (-> v1-0 0 dir0 color) (-> v1-0 0 dir1 color) (-> v1-0 0 dir1 extra x)) + (fmax (fmax (-> s4-0 x) (-> s4-0 y)) (-> s4-0 z)) + (fmax (fmax (-> s5-0 x) (-> s5-0 y)) (-> s5-0 z)) + (let* ((f0-10 (+ (* 0.2 (-> s4-0 x)) (* 0.75 (-> s4-0 y)) (* 0.05 (-> s4-0 z)))) + (f1-12 (+ (* 0.2 (-> s5-0 x)) (* 0.75 (-> s5-0 y)) (* 0.05 (-> s5-0 z)))) + (f0-12 (* 0.5 (+ f0-10 f1-12))) + (f30-0 (lerp-scale-clamp 0.0 1.0 f0-12 0.0 1.0)) + (s5-1 (new 'stack 'rgbaf)) + (s3-0 (new 'stack 'rgbaf)) + (s4-1 0) + ) + (cond + ((or (= (status-of-level-and-borrows *level* 'desert #f) 'active) + (= (status-of-level-and-borrows *level* 'waswide #f) 'active) + (= (status-of-level-and-borrows *level* 'wasdoors #f) 'active) + ) + (set-vector! s5-1 0.85 1.1 1.1 0.25) + ) + (else + (set-vector! s5-1 0.4 2.0 2.0 0.25) + (set-vector! s3-0 0.7 1.15 1.15 0.25) + (vector-lerp! s5-1 s5-1 s3-0 f30-0) + ) + ) + (set! (-> s5-1 w) 0.25) + (let ((t1-0 + (logior (logand (logior (logand (logior (logand (logior (logand s4-1 -256) (shr (shl (the int (* 127.5 (-> s5-1 x))) 56) 56)) -65281) + (shr (shl (the int (* 127.5 (-> s5-1 y))) 56) 48) + ) + -16711681 + ) + (shr (shl (the int (* 127.5 (-> s5-1 z))) 56) 40) + ) + (the-as uint #xffffffff00ffffff) + ) + (shr (shl (the int (* 127.5 (-> s5-1 w))) 56) 32) + ) + ) + ) + (set-setting! 'highlight-color #f 0.0 t1-0) + ) + ) + ) + (let* ((f0-38 (-> this total-time)) + (f24-0 (/ (* 0.0033333334 (the float (- (current-time) (-> this state-time)))) f0-38)) + ) + 0.0 + (let ((f30-1 (-> this ring-width)) + (f22-0 1.0) + ) + 1.0 + (let ((f26-0 1.1) + (f28-0 0.5) + ) + (set! (-> this max-radius) 102400.0) + (if (-> this reverse?) + (set! f24-0 (- 1.0 f24-0)) + ) + (if (time-elapsed? (-> this state-time) (the int (* 1800.0 f0-38))) + (set! f28-0 + (lerp + f28-0 + 0.0 + (fmax 0.0 (fmin 1.0 (- (* 0.0033333334 (the float (- (current-time) (-> this state-time)))) (* 6.0 f0-38)))) + ) + ) + ) + (if (= f28-0 0.0) + (go empty-state) + ) + (let ((f26-1 + (+ (-> this ring-scale-t) + (* (cond + ((time-elapsed? (-> this stop-time) (the int (* 300.0 f26-0))) + (let ((f1-27 1.0)) + (lerp + 0.5 + 0.05 + (fmax 0.0 (fmin 1.0 (/ (- (* 0.0033333334 (the float (- (current-time) (-> this stop-time)))) f26-0) f1-27))) + ) + ) + ) + ((>= f22-0 f24-0) + (lerp 2.3 0.4 (/ f24-0 f22-0)) + ) + (else + 0.4 + ) + ) + (seconds-per-frame) + ) + ) + ) + ) + (let ((f24-1 (* 0.00024414062 (* (-> this max-radius) f26-1)))) + 0.0 + 0.0 + 0.0 + (let* ((f0-56 f26-1) + (f0-57 (* f0-56 f0-56)) + (f1-33 (fmax (lerp f30-1 0.0 f0-57) f28-0)) + (f0-60 (fmax 0.0 (- f24-1 f1-33))) + ) + (set-vector! (-> this jmod-outer transform scale) f24-1 1.0 f24-1 1.0) + (set-vector! (-> this jmod-inner transform scale) f0-60 1.0 f0-60 1.0) + ) + ) + (set! (-> this ring-scale-t) f26-1) + ) + ) + ) + ) + (none) + ) + +(deftype gun-gravity (process-drawable) + ((current-radius float) + (max-radius float) + (lowest-y float) + (start-pos vector :inline) + (total-time float) + (ring-closest handle) + (ring-furthest handle) + (gravity-sound sound-id) + ) + (:state-methods + expand + ) + (:methods + (gun-gravity-method-21 (_type_) none) + (gun-gravity-method-22 (_type_ symbol) none) + (spawn-gravity-spinner (_type_ process) (pointer gravity-spinner)) + (gun-gravity-method-24 (_type_) none) + ) + ) + + +(defbehavior gun-gravity-init-by-other gun-gravity ((arg0 vector) (arg1 vector)) + (set! (-> self root) (new 'process 'trsqv)) + (set! (-> self root trans quad) (-> arg0 quad)) + (let ((s4-0 (new 'stack-no-clear 'collide-query))) + 0.0 + (vector+float*! (-> s4-0 start-pos) (-> self root trans) *up-vector* 24576.0) + (set! (-> s4-0 move-dist quad) (the-as uint128 0)) + (set! (-> s4-0 move-dist y) -81920.0) + (let ((v1-7 s4-0)) + (set! (-> v1-7 radius) 40.96) + (set! (-> v1-7 collide-with) (collide-spec backgnd pusher)) + (set! (-> v1-7 ignore-process0) #f) + (set! (-> v1-7 ignore-process1) #f) + (set! (-> v1-7 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-7 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s4-0) 0.0) + (set! (-> self root trans y) (-> s4-0 best-other-tri intersect y)) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.2)) + (let ((s4-1 quaternion-look-at!) + (s3-0 (-> self root quat)) + (a0-12 (new 'stack-no-clear 'vector)) + ) + (set! (-> a0-12 quad) (-> arg1 quad)) + (set! (-> a0-12 y) 0.0) + (s4-1 s3-0 (vector-normalize! a0-12 1.0) *up-vector*) + ) + (set! (-> self max-radius) 122880.0) + (set! (-> self total-time) 1.0) + (if (logtest? (game-secrets gun-upgrade-dark-2) (-> *game-info* secrets)) + (set! (-> self total-time) (* 1.5 (-> self total-time))) + ) + (set! (-> self start-pos quad) (-> arg0 quad)) + (set! (-> self ring-closest) (the-as handle #f)) + (set! (-> self ring-furthest) (the-as handle #f)) + (set! (-> self part) (create-launch-control (-> *part-group-id-table* 118) self)) + (set! (-> self gravity-sound) (new-sound-id)) + (go-virtual expand) + ) + +(defmethod deactivate ((this gun-gravity)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (sound-stop (-> this gravity-sound)) + (call-parent-method this) + (none) + ) + +(defstate expand (gun-gravity) + :virtual #t + :enter (behavior () + (set! (-> self lowest-y) (-> self root trans y)) + (set-time! (-> self state-time)) + (sound-play "grav-gun" :id (-> self gravity-sound) :position (-> self root trans)) + ) + :trans (behavior () + (cond + ((not (time-elapsed? (-> self state-time) (the int (* 300.0 (-> self total-time))))) + (let* ((f0-4 (* 0.0033333334 (the float (- (current-time) (-> self state-time))))) + (f1-3 (-> self total-time)) + (f0-6 (/ (- f0-4 (* (the float (the int (/ f0-4 f1-3))) f1-3)) (-> self total-time))) + ) + (set! (-> self current-radius) (* (-> self max-radius) f0-6)) + ) + (gun-gravity-method-22 self #f) + ) + (else + (if (not (time-elapsed? (-> self state-time) (the int (* 2025.0 (-> self total-time))))) + (gun-gravity-method-22 self #t) + ) + ) + ) + (cond + ((not (time-elapsed? (-> self state-time) (the int (* 2025.0 (-> self total-time))))) + (let ((s5-1 (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (-> self root trans)))) + 0.0 + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((f0-16 (fmin (vector-normalize-ret-len! s5-1 1.0) (-> self current-radius)))) + (vector+float*! gp-0 (-> self root trans) s5-1 f0-16) + ) + (sound-play "grav-gun" :id (-> self gravity-sound) :position gp-0) + ) + ) + (dotimes (gp-1 6) + (let* ((s5-2 vector-rotate-around-y!) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 *x-vector*) + (f30-0 65536.0) + (v1-27 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-28 (the-as number (logior #x3f800000 v1-27))) + (s4-1 (s5-2 s4-0 s3-0 (* f30-0 (+ -1.0 (the-as float v1-28))))) + (s5-3 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (let* ((f30-1 (-> self current-radius)) + (f28-0 (fmax 0.0 (+ -40960.0 (-> self current-radius)))) + (s3-1 s5-3) + (s2-0 (-> self root trans)) + (v1-33 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-34 (the-as number (logior #x3f800000 v1-33))) + ) + (vector+float*! s3-1 s2-0 s4-1 (+ f28-0 (* (+ -1.0 (the-as float v1-34)) (- f30-1 f28-0)))) + ) + (let ((s4-2 (new 'stack-no-clear 'collide-query))) + 0.0 + (vector+float*! (-> s4-2 start-pos) s5-3 *up-vector* 24576.0) + (set! (-> s4-2 move-dist quad) (the-as uint128 0)) + (set! (-> s4-2 move-dist y) -81920.0) + (let ((v1-40 s4-2)) + (set! (-> v1-40 radius) 40.96) + (set! (-> v1-40 collide-with) (collide-spec backgnd pusher)) + (set! (-> v1-40 ignore-process0) #f) + (set! (-> v1-40 ignore-process1) #f) + (set! (-> v1-40 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-40 action-mask) (collide-action solid)) + ) + (when (>= (fill-and-probe-using-line-sphere *collide-cache* s4-2) 0.0) + (let ((f30-2 (-> s4-2 best-other-tri intersect y)) + (a1-7 (matrix-identity! (new 'stack-no-clear 'matrix))) + ) + (set! (-> a1-7 trans quad) (-> s4-2 start-pos quad)) + (set! (-> a1-7 trans y) f30-2) + (sparticle-launch-control-method-17 (-> self part) a1-7) + ) + ) + ) + ) + ) + ) + (else + (sound-stop (-> self gravity-sound)) + ) + ) + ) + :code (behavior () + (let ((f30-0 4.0) + (gp-0 (current-time)) + ) + (until #f + (dotimes (s5-0 5) + (let ((v1-7 (ppointer->handle (process-spawn + gravity-ring + (-> self root trans) + #f + (-> self max-radius) + (-> self total-time) + f30-0 + gp-0 + :name "gravity-ring" + :to self + ) + ) + ) + (a0-6 s5-0) + ) + (cond + ((zero? a0-6) + (set! (-> self ring-furthest) (the-as handle v1-7)) + ) + ((= a0-6 4) + (set! (-> self ring-closest) (the-as handle v1-7)) + ) + ) + ) + (set! f30-0 (+ -0.6 f30-0)) + (let ((s4-1 (current-time))) + (until (time-elapsed? s4-1 (seconds 0.15)) + (suspend) + ) + ) + ) + (let ((s5-1 (current-time))) + (until (time-elapsed? s5-1 (seconds 13.5)) + (suspend) + ) + ) + (go empty-state) + (set! f30-0 4.0) + ) + ) + #f + ) + ) + +;; WARN: Return type mismatch (pointer process) vs (pointer gravity-spinner). +(defmethod spawn-gravity-spinner ((this gun-gravity) (arg0 process)) + (process-spawn + gravity-spinner + (process->handle arg0) + (-> this root trans) + (- (current-time) (-> this state-time)) + :name "gravity-spinner" + :to arg0 + ) + ) + +;; WARN: Return type mismatch (pointer gravity-spinner) vs none. +(defmethod gun-gravity-method-22 ((this gun-gravity) (arg0 symbol)) + (local-vars (v1-29 symbol) (v1-49 symbol)) + (with-pp + (let ((s5-0 (new 'stack-no-clear 'vector)) + (a1-1 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-1 from) (process->ppointer pp)) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'get-vehicle) + (let ((s4-0 (the-as process (send-event-function *target* a1-1))) + (f30-0 0.0) + (f28-0 (-> this current-radius)) + ) + (set! (-> s5-0 quad) (-> this root trans quad)) + (when arg0 + (let ((v1-5 (handle->process (-> this ring-closest)))) + (if v1-5 + (set! f30-0 (* (-> (the-as gravity-ring v1-5) max-radius) (-> (the-as gravity-ring v1-5) ring-scale-t))) + ) + ) + (let ((v1-8 (handle->process (-> this ring-furthest)))) + (if v1-8 + (set! f28-0 (* (-> (the-as gravity-ring v1-8) max-radius) (-> (the-as gravity-ring v1-8) ring-scale-t))) + ) + ) + (set! f28-0 (* 0.85 f28-0)) + (set! f30-0 (* 0.85 f30-0)) + (set! (-> this current-radius) (* 0.5 (+ f30-0 f28-0))) + ) + (set! (-> s5-0 w) f28-0) + (let ((s3-1 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s5-0) s3-1 384)) + (let* ((s1-0 (-> s3-1 s2-0)) + (v1-17 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-17 + (let* ((s0-0 (-> v1-17 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= *target* s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s1-1 mask)) + (!= s4-0 s1-1) + ) + (let ((f0-6 (vector-vector-distance (get-trans (the-as process-focusable s1-1) 3) s5-0))) + (when (and (>= f28-0 f0-6) (>= f0-6 f30-0)) + (let ((v1-27 (-> s1-1 child))) + (while v1-27 + (when (= (-> v1-27 0 type) gravity-spinner) + (set! v1-29 #t) + (goto cfg-47) + ) + (set! v1-27 (-> v1-27 0 brother)) + ) + ) + (set! v1-29 #f) + (label cfg-47) + (if (not v1-29) + (spawn-gravity-spinner this s1-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-2 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-2 (< (vector-vector-distance (get-trans s3-2 0) s5-0) (-> s5-0 w))) + (when (and (!= *target* s3-2) + (not (focus-test? s3-2 disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s3-2 mask)) + (!= s4-0 s3-2) + ) + (let ((f0-8 (vector-vector-distance (get-trans s3-2 3) s5-0))) + (when (and (>= f28-0 f0-8) (>= f0-8 f30-0)) + (let ((v1-47 (-> s3-2 child))) + (while v1-47 + (when (= (-> v1-47 0 type) gravity-spinner) + (set! v1-49 #t) + (goto cfg-79) + ) + (set! v1-47 (-> v1-47 0 brother)) + ) + ) + (set! v1-49 #f) + (label cfg-79) + (if (not v1-49) + (spawn-gravity-spinner this s3-2) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + +(defbehavior gun-fire-dark-2 target () + (set-last-fire-time 36) + (cond + ((logtest? (-> *part-group-id-table* 120 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self gun fire-point quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 120)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self gun fire-point quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 120)) + ) + ) + (process-spawn + gun-gravity + (-> self gun fire-point) + (-> self gun fire-dir-out) + :name "gun-gravity" + :to (ppointer->process (-> self gun gun)) + ) + ) + +(defbehavior target-gun-fire-dark target ((arg0 pickup-type)) + (case arg0 + (((pickup-type gun-dark-1)) + (gun-fire-dark-1) + ) + (((pickup-type gun-dark-2)) + (gun-fire-dark-2) + ) + (((pickup-type gun-dark-3)) + (gun-fire-dark-3) + ) + ) + ) diff --git a/goal_src/jak3/engine/target/gun/gun-part.gc b/goal_src/jak3/engine/target/gun/gun-part.gc index 83515aeec1..acabf66290 100644 --- a/goal_src/jak3/engine/target/gun/gun-part.gc +++ b/goal_src/jak3/engine/target/gun/gun-part.gc @@ -5,5 +5,23 @@ ;; name in dgo: gun-part ;; dgos: GAME +(define-extern *yellow-shot-2-trail* light-trail-composition) +(define-extern *red-shot-3-trail* light-trail-composition) +(define-extern *last-player-pos* vector) +(define-extern *gun-dark-3-nuke-fade-time-small* time-frame) +(define-extern *gun-dark-3-nuke-blur-time-small* time-frame) +(define-extern *gun-dark-3-nuke-blur-curve-small* curve2d-piecewise) +(define-extern *gun-dark-3-nuke-fade-curve-small* curve-color-piecewise) +(define-extern *gun-dark-3-nuke-blur-segs-small* uint) +(define-extern *gun-dark-3-mushroom-speed* float) +(define-extern *gun-dark-3-mushroom-size-time* time-frame) +(define-extern *gun-dark-3-nuke-mushroom-size-curve-x* curve2d-piecewise) +(define-extern *gun-dark-3-nuke-mushroom-size-curve-y* curve2d-piecewise) +(define-extern *gun-dark-3-nuke-fade-time* time-frame) +(define-extern *gun-dark-3-nuke-blur-time* time-frame) +(define-extern *gun-dark-3-nuke-blur-curve* curve2d-piecewise) +(define-extern *gun-dark-3-nuke-fade-curve* curve-color-piecewise) +(define-extern *gun-dark-3-nuke-blur-segs* uint) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/target/gun/gun-red-shot.gc b/goal_src/jak3/engine/target/gun/gun-red-shot.gc index 00d7fcb465..962c1b30d8 100644 --- a/goal_src/jak3/engine/target/gun/gun-red-shot.gc +++ b/goal_src/jak3/engine/target/gun/gun-red-shot.gc @@ -5,5 +5,2640 @@ ;; name in dgo: gun-red-shot ;; dgos: GAME +(define-extern *impact-blur* curve2d-piecewise) +(define-extern *shockwave-blur-red-2* curve2d-piecewise) +(declare-type gun-red-shot process-drawable) +(define-extern gun-red-shot-init-by-other (function vector vector object :behavior gun-red-shot)) + ;; DECOMP BEGINS +(deftype gun-red-shot (process-drawable) + ((parent (pointer gun) :override) + (root collide-shape-moving :override) + (probe-count int32) + (probe-mask uint32) + (actor-count int32) + (attack-id uint32) + (start-pos vector :inline) + (start-dir vector :inline) + (start-rot vector :inline) + (probe-dir vector 19 :inline) + ) + (:state-methods + blocked + debug-idle + idle + ) + (:methods + (init-probes! (_type_ collide-shape) none) + (check-blocked? (_type_) symbol) + (stub (_type_) none) + (find-targets (_type_) none) + (setup-probes (_type_) none) + (do-collision (_type_ vector) none) + (send-attack! (_type_ process-drawable touching-shapes-entry) none) + ) + ) + + +(deftype gun-red-3-grenade (projectile-bounce) + ((blast-radius float) + (should-explode-soon? symbol) + (explode-tick-time time-frame) + (birth-time time-frame) + (immediate-detonation? symbol) + (explode-delay-time time-frame) + ) + (:state-methods + impact-tiny + ) + (:methods + (check-should-explode (_type_) int) + (go-impact (_type_) object) + (find-and-damage-targets (_type_) object) + ) + ) + + +(defskelgroup skel-gun-red-3-grenade gun gun-grenade-lod0-jg gun-grenade-idle-ja + ((gun-grenade-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 0.2) + :texture-level 10 + ) + +(defmethod setup-collision! ((this gun-red-3-grenade)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) projectile-bounce-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate explode)) + (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-7 prim-core action) (collide-action solid)) + (set-vector! (-> v1-7 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-7) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-10 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set-collide-with! + (-> this root) + (collide-spec backgnd crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher shield) + ) + (set-collide-as! (-> this root) (collide-spec projectile)) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs object. +(defmethod handle-proj-hit! ((this gun-red-3-grenade) (arg0 process) (arg1 event-message-block)) + (go (method-of-object this impact)) + #t + ) + +(defmethod projectile-method-40 ((this gun-red-3-grenade)) + 256 + ) + +(defmethod init-proj-settings! ((this gun-red-3-grenade)) + (set! (-> this attack-mode) #f) + (initialize-skeleton + this + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-red-3-grenade" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (let ((t9-2 (method-of-type projectile-bounce init-proj-settings!))) + (t9-2 this) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.2)) + (sound-play "red3-fire") + (let* ((v1-6 *game-info*) + (a0-9 (+ (-> v1-6 attack-id) 1)) + ) + (set! (-> v1-6 attack-id) a0-9) + (set! (-> this attack-id) a0-9) + ) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 87) this)) + (set! (-> this blast-radius) 81920.0) + (set! (-> this max-speed) 327680.0) + (set! (-> this timeout) (seconds 3)) + (set! (-> this should-explode-soon?) #f) + (set-time! (-> this birth-time)) + (let ((v1-15 (new 'stack-no-clear 'vector))) + (set! (-> v1-15 x) 2.5) + (set! (-> v1-15 y) 2.5) + (set! (-> v1-15 z) 2.5) + (set! (-> v1-15 w) 1.0) + (set! (-> this root scale quad) (-> v1-15 quad)) + ) + (set! (-> this immediate-detonation?) #f) + (let ((s5-2 (new 'stack-no-clear 'light-trail-tracker-spawn-params))) + (set! (-> s5-2 tracked-obj) (process->handle this)) + (set! (-> s5-2 appearance) *red-shot-3-trail*) + (set! (-> s5-2 max-num-crumbs) (the int (* 0.5 (the float (-> s5-2 appearance max-age))))) + (set! (-> s5-2 track-immediately?) #t) + (let* ((v1-28 (estimate-light-trail-mem-usage + (the-as uint (-> s5-2 max-num-crumbs)) + (the-as uint (= (-> s5-2 appearance lie-mode) 3)) + ) + ) + (s4-2 (get-process *default-dead-pool* light-trail-tracker-projectile (+ v1-28 8192) 1)) + ) + (when s4-2 + (let ((t9-9 (method-of-type process activate))) + (t9-9 s4-2 this "light-trail" (the-as pointer #x70004000)) + ) + (run-now-in-process s4-2 light-trail-tracker-init-by-other s5-2) + (-> s4-2 ppointer) + ) + ) + ) + 0 + (none) + ) + +(defmethod projectile-method-32 ((this gun-red-3-grenade)) + (cond + ((not (do-fire-backcheck (-> this root trans) (-> this root transv))) + (let ((v1-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this root transv) 1.0))) + (vector+float*! (-> this root trans) (-> this root trans) v1-3 -14336.0) + ) + (set! (-> this immediate-detonation?) #t) + (go (method-of-object this impact)) + ) + (else + (call-parent-method this) + ) + ) + 0 + (none) + ) + +(defmethod go-impact ((this gun-red-3-grenade)) + (cond + ((-> this should-explode-soon?) + (if (time-elapsed? (-> this explode-tick-time) (-> this explode-delay-time)) + (go (method-of-object this impact)) + ) + ) + (else + (case (check-should-explode this) + ((1) + (set! (-> this should-explode-soon?) #t) + (let ((v0-0 (the-as object (current-time)))) + (set! (-> this explode-tick-time) (the-as time-frame v0-0)) + v0-0 + ) + ) + ((2) + (go (method-of-object this impact)) + ) + ) + ) + ) + ) + +(defmethod find-and-damage-targets ((this gun-red-3-grenade)) + (local-vars (v1-21 float) (v1-45 float)) + (with-pp + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (a1-0 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-0 from) (process->ppointer pp)) + (set! (-> a1-0 num-params) 0) + (set! (-> a1-0 message) 'get-vehicle) + (let ((s4-0 (send-event-function *target* a1-0))) + (set! (-> s5-0 quad) (-> this root trans quad)) + (set! (-> s5-0 w) (-> this blast-radius)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s5-0) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (a0-8 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when a0-8 + (let* ((s0-0 (-> a0-8 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= s4-0 s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s1-1 mask)) + (nonzero? (-> (the-as process-focusable s1-1) root root-prim prim-core collide-with)) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (let ((s0-2 + (vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable s1-1) 3) (-> this root trans)) + ) + ) + 0.0 + (.lvf vf1 (&-> s0-2 quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-21 vf1) + (let ((f0-4 v1-21) + (f1-1 (-> this blast-radius)) + ) + (if (>= (* f1-1 f1-1) f0-4) + (send-event + s1-1 + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage 12.0) + (vehicle-damage-factor 3.0) + (vehicle-impulse-factor 1.0) + (mode 'explode) + (attacker-velocity s0-2) + (penetrate-using (penetrate explode)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) s5-0) (-> s5-0 w))) + (when (and (!= s4-0 s3-1) + (not (focus-test? s3-1 disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s3-1 mask)) + (nonzero? (-> s3-1 control root-prim prim-core collide-with)) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (let ((s5-2 (vector-! (new 'stack-no-clear 'vector) (get-trans s3-1 3) (-> this root trans)))) + 0.0 + (.lvf vf1 (&-> s5-2 quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-45 vf1) + (let ((f0-12 v1-45) + (f1-6 (-> this blast-radius)) + ) + (if (>= (* f1-6 f1-6) f0-12) + (send-event + s3-1 + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage 12.0) + (vehicle-damage-factor 3.0) + (vehicle-impulse-factor 1.0) + (mode 'explode) + (attacker-velocity s5-2) + (penetrate-using (penetrate explode)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + +(defmethod check-should-explode ((this gun-red-3-grenade)) + (local-vars + (sv-1680 vector) + (sv-1684 vector) + (sv-1688 float) + (sv-1692 float) + (sv-1696 symbol) + (sv-1744 vector) + (sv-1748 vector) + (sv-1752 float) + (sv-1756 float) + (sv-1760 symbol) + ) + (with-pp + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 #f) + ) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) (process->ppointer pp)) + (set! (-> a1-0 num-params) 0) + (set! (-> a1-0 message) 'get-vehicle) + (let ((s3-0 (send-event-function *target* a1-0))) + (set! (-> s4-0 quad) (-> this root trans quad)) + (set! (-> s4-0 w) (* 0.6666667 (-> this blast-radius))) + (let ((s2-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s1-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s4-0) s2-0 384)) + (let* ((s0-0 (-> s2-0 s1-0)) + (a0-8 (if (type? s0-0 collide-shape) + s0-0 + ) + ) + ) + (when a0-8 + (let* ((s0-1 (-> a0-8 process)) + (a0-10 (if (type? s0-1 process-focusable) + s0-1 + ) + ) + ) + (when a0-10 + (when (and (!= s3-0 a0-10) + (not (focus-test? (the-as process-focusable a0-10) disable dead inactive gun-no-target)) + (nonzero? (-> (the-as process-focusable a0-10) root root-prim prim-core collide-with)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> a0-10 mask)) + (and (logtest? (process-mask guard) (-> a0-10 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (set! sv-1680 + (vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable a0-10) 3) (-> this root trans)) + ) + (set! sv-1684 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this root transv) 1.0)) + (set! sv-1688 (the-as float 0.0)) + (set! sv-1692 (the-as float 0.0)) + (set! sv-1696 (time-elapsed? (-> this birth-time) (seconds 0.05))) + (set! sv-1688 (vector-normalize-ret-len! sv-1680 1.0)) + (set! sv-1692 (vector-dot sv-1680 sv-1684)) + (when (< sv-1688 (-> s4-0 w)) + (cond + ((and (< 0.0 sv-1692) sv-1696) + (set! gp-0 #t) + (set! (-> this explode-delay-time) + (the-as time-frame (min 150 (the int (* 300.0 (/ sv-1688 (vector-length (-> this root transv))) sv-1692)))) + ) + ) + ((< sv-1688 8192.0) + (return 2) + ) + ((and (not sv-1696) (< (seconds 0.05) (- (current-time) (-> this birth-time)))) + (return 2) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s1-1 *target*) + (s2-1 (if (type? s1-1 process-focusable) + s1-1 + ) + ) + ) + (when (and s2-1 (< (vector-vector-distance (get-trans s2-1 0) s4-0) (-> s4-0 w))) + (when (and (!= s3-0 s2-1) + (not (focus-test? s2-1 disable dead inactive gun-no-target)) + (nonzero? (-> s2-1 control root-prim prim-core collide-with)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s2-1 mask)) + (and (logtest? (process-mask guard) (-> s2-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (set! sv-1744 (vector-! (new 'stack-no-clear 'vector) (get-trans s2-1 3) (-> this root trans))) + (set! sv-1748 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this root transv) 1.0)) + (set! sv-1752 (the-as float 0.0)) + (set! sv-1756 (the-as float 0.0)) + (set! sv-1760 (time-elapsed? (-> this birth-time) (seconds 0.05))) + (set! sv-1752 (vector-normalize-ret-len! sv-1744 1.0)) + (set! sv-1756 (vector-dot sv-1744 sv-1748)) + (when (< sv-1752 (-> s4-0 w)) + (cond + ((and (< 0.0 sv-1756) sv-1760) + (set! gp-0 #t) + (set! (-> this explode-delay-time) + (the-as time-frame (min 150 (the int (* 300.0 (/ sv-1752 (vector-length (-> this root transv))) sv-1756)))) + ) + ) + ((< sv-1752 8192.0) + (return 2) + ) + ((and (not sv-1760) (< (seconds 0.05) (- (current-time) (-> this birth-time)))) + (return 2) + ) + ) + ) + ) + ) + ) + ) + ) + (if gp-0 + (return 1) + (return 0) + ) + ) + (the-as int 0) + ) + ) + +(defmethod projectile-method-25 ((this gun-red-3-grenade)) + (spawn (-> this part) (-> this root trans)) + (if (logtest? (-> this root status) (collide-status touch-surface)) + (sound-play "red3-bounce") + ) + (call-parent-method this) + (none) + ) + +(defmethod projectile-bounce-method-42 ((this gun-red-3-grenade)) + (spawn (-> this part) (-> this root trans)) + (call-parent-method this) + (none) + ) + +(deftype shockwave-collision-pt (structure) + ((collision-pt vector :inline) + (normal vector :inline) + (found? symbol) + (angle degrees) + ) + ) + + +(deftype gun-red-2-shockwave (process) + ((origin vector :inline) + (max-radius float) + (strength float) + (current-radius float) + (current-intensity float) + (state-time time-frame) + (alpha-scalar float) + (base-damage float) + (snd-charge sound-id) + (min-charge-radius float) + (max-charge-radius float) + (total-charge-time time-frame) + (total-explode-time time-frame) + (ring-expansion-time time-frame) + (burst-expansion-time time-frame) + (warp-expansion-time time-frame) + (previously-attacked-targets handle 64) + (num-previously-attacked-targets int8) + (start-pilot? symbol) + (explosion-0 handle) + (explosion-1 handle) + (generate-order-array uint8 127) + (current-stage-t float) + (ammo-drained float) + (eventual-collision-points shockwave-collision-pt 128 :inline) + (next-computed-collision-point int8) + (num-collision-pts-to-generate int8) + (show-scorch-marks? symbol) + (height-off-ground float) + (max-ground-radius float) + (current-ring-radius float) + (current-ring-alpha float) + (current-warp-radius float) + (current-warp-alpha float) + (current-burst-radius float) + (current-burst-alpha float) + (generating-marks? symbol) + (generated-particles? symbol) + (charge-part-tracker handle) + ) + (:state-methods + charging + explode + die + ) + (:methods + (find-targets-and-attack! (_type_) none) + (send-attack! (_type_ process-focusable symbol) none) + (find-collision-point! (_type_) int) + (generate-collision-points! (_type_) none) + (adjust-height-and-radius (_type_) none) + (gun-red-2-shockwave-method-22 (_type_ int int int int) none) + (generate-shockwave-particles (_type_) none) + (adjust-warp-radius-and-alpha (_type_) object) + (adjust-ring-radius-and-alpha (_type_) none) + (generate-order-array (_type_) none) + (spawn-ring (_type_) none) + ) + ) + + +(deftype gun-red-2-shockwave-init-params (structure) + ((pos vector :inline) + (max-radius float) + (strength float) + ) + ) + + +;; WARN: Return type mismatch float vs none. +(defun part-tracker-move-to-target-gun ((arg0 part-tracker)) + (when *target* + (set! (-> arg0 root trans quad) (-> *target* gun fire-point quad)) + (set! (-> arg0 root trans y) (+ 6553.6 (-> *target* control trans y))) + ) + (none) + ) + +(defbehavior gun-red-2-shockwave-init-by-other gun-red-2-shockwave ((arg0 gun-red-2-shockwave-init-params)) + (set! (-> self current-intensity) 0.0) + (set! (-> self current-radius) 0.0) + (set! (-> self current-warp-radius) 0.0) + (set! (-> self current-burst-radius) 0.0) + (set! (-> self height-off-ground) 0.0) + (set! (-> self current-ring-radius) 0.0) + (set! (-> self current-ring-alpha) 0.0) + (set! (-> self total-explode-time) (seconds 0.7)) + (set! (-> self min-charge-radius) 12288.0) + (set! (-> self max-charge-radius) 73728.0) + (set! (-> self total-charge-time) (seconds 1)) + (set! (-> self base-damage) 5.0) + (set! (-> self ring-expansion-time) (seconds 0.35)) + (set! (-> self burst-expansion-time) (seconds 0.3)) + (set! (-> self warp-expansion-time) (seconds 0.4)) + (set! (-> self explosion-0) (the-as handle #f)) + (set! (-> self explosion-1) (the-as handle #f)) + (set! (-> self ammo-drained) 0.0) + (set! (-> self snd-charge) (new-sound-id)) + (set! (-> self num-previously-attacked-targets) 0) + (set! (-> self start-pilot?) (the-as symbol (and *target* (focus-test? *target* pilot)))) + (set! (-> self charge-part-tracker) + (ppointer->handle (cond + ((logtest? (-> *part-group-id-table* 109 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self origin quad)) + (part-tracker-spawn + part-tracker-subsampler + :to *entity-pool* + :group (-> *part-group-id-table* 109) + :callback (the-as (function part-tracker vector) part-tracker-move-to-target-gun) + ) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self origin quad)) + (part-tracker-spawn + part-tracker + :to *entity-pool* + :group (-> *part-group-id-table* 109) + :callback (the-as (function part-tracker vector) part-tracker-move-to-target-gun) + ) + ) + ) + ) + ) + (send-event (handle->process (-> self charge-part-tracker)) 'clock self) + (dotimes (v1-49 64) + (set! (-> self eventual-collision-points v1-49 found?) #f) + ) + (set! (-> self next-computed-collision-point) 0) + (set! (-> self show-scorch-marks?) #f) + (set! (-> self generating-marks?) #f) + (set! (-> self generated-particles?) #f) + (go-virtual charging) + ) + +(defmethod find-targets-and-attack! ((this gun-red-2-shockwave)) + (local-vars + (sv-32 bounding-box) + (sv-2672 (function vector vector float)) + (sv-2688 vector) + (sv-2704 vector) + (sv-2720 collide-query) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! sv-32 (the-as bounding-box (new 'stack-no-clear 'vector))) + (set! (-> sv-32 min quad) (-> this origin quad)) + (set! (-> sv-32 min w) (-> this current-radius)) + (let ((s5-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s4-0 (fill-actor-list-for-box *actor-hash* sv-32 s5-0 384)) + (let* ((s3-0 (-> s5-0 s4-0)) + (v1-6 (if (type? s3-0 collide-shape) + s3-0 + ) + ) + ) + (when v1-6 + (let* ((s2-0 (-> v1-6 process)) + (s3-1 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (when s3-1 + (when (and (!= *target* s3-1) + (not (focus-test? (the-as process-focusable s3-1) disable dead inactive)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s2-1 #f)) + (let ((s1-0 (process->handle s3-1))) + (dotimes (v1-18 (-> this num-previously-attacked-targets)) + (when (= (-> this previously-attacked-targets v1-18) s1-0) + (set! s2-1 #t) + 0 + (goto cfg-29) + ) + ) + (label cfg-29) + (when (not s2-1) + (let ((s0-0 #f)) + (set! sv-2672 vector-vector-xz-distance-squared) + (set! sv-2688 (-> this origin)) + (let* ((a1-4 (get-trans (the-as process-focusable s3-1) 3)) + (f0-1 (sv-2672 sv-2688 a1-4)) + (f1-0 24576.0) + ) + (cond + ((< f0-1 (* f1-0 f1-0)) + (set! s0-0 #t) + ) + (else + (set! sv-2720 (new 'stack-no-clear 'collide-query)) + (set! (-> sv-2720 start-pos quad) (-> this origin quad)) + (set! sv-2704 (-> sv-2720 move-dist)) + (let ((v1-35 (get-trans (the-as process-focusable s3-1) 3)) + (a0-26 (-> this origin)) + ) + (.lvf vf4 (&-> v1-35 quad)) + (.lvf vf5 (&-> a0-26 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-2704 quad) vf6) + (let ((v1-37 sv-2720)) + (set! (-> v1-37 radius) 40.96) + (set! (-> v1-37 collide-with) (collide-spec backgnd)) + (set! (-> v1-37 ignore-process0) #f) + (set! (-> v1-37 ignore-process1) #f) + (set! (-> v1-37 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-37 action-mask) (collide-action solid)) + ) + (if (= (fill-and-probe-using-line-sphere *collide-cache* sv-2720) -100000000.0) + (set! s0-0 #t) + ) + ) + ) + ) + (when s0-0 + (send-attack! this (the-as process-focusable s3-1) #t) + (set! (-> this previously-attacked-targets (-> this num-previously-attacked-targets)) (the-as handle s1-0)) + (+! (-> this num-previously-attacked-targets) 1) + ) + ) + ) + ) + (if (and s2-1 (logtest? (process-mask vehicle) (-> s3-1 mask))) + (send-attack! this (the-as process-focusable s3-1) #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s4-1 *target*) + (s5-1 (if (type? s4-1 process-focusable) + s4-1 + ) + ) + ) + (when (and s5-1 (< (vector-vector-distance (get-trans s5-1 0) (the-as vector sv-32)) (-> sv-32 min w))) + (when (and (!= *target* s5-1) + (not (focus-test? s5-1 disable dead inactive)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s5-1 mask)) + (and (logtest? (process-mask guard) (-> s5-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s4-3 #f)) + (let ((s3-2 (process->handle s5-1))) + (dotimes (v1-68 (-> this num-previously-attacked-targets)) + (when (= (-> this previously-attacked-targets v1-68) s3-2) + (set! s4-3 #t) + 0 + (goto cfg-71) + ) + ) + (label cfg-71) + (when (not s4-3) + (let ((s2-2 #f)) + (let ((f0-5 (vector-vector-xz-distance-squared (-> this origin) (get-trans s5-1 3))) + (f1-5 24576.0) + ) + (cond + ((< f0-5 (* f1-5 f1-5)) + (set! s2-2 #t) + ) + (else + (let ((s1-2 (new 'stack-no-clear 'collide-query))) + (set! (-> s1-2 start-pos quad) (-> this origin quad)) + (vector-! (-> s1-2 move-dist) (get-trans s5-1 3) (-> this origin)) + (let ((v1-80 s1-2)) + (set! (-> v1-80 radius) 40.96) + (set! (-> v1-80 collide-with) (collide-spec backgnd)) + (set! (-> v1-80 ignore-process0) #f) + (set! (-> v1-80 ignore-process1) #f) + (set! (-> v1-80 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-80 action-mask) (collide-action solid)) + ) + (if (= (fill-and-probe-using-line-sphere *collide-cache* s1-2) -100000000.0) + (set! s2-2 #t) + ) + ) + ) + ) + ) + (when s2-2 + (send-attack! this s5-1 #t) + (set! (-> this previously-attacked-targets (-> this num-previously-attacked-targets)) (the-as handle s3-2)) + (+! (-> this num-previously-attacked-targets) 1) + ) + ) + ) + ) + (if (and s4-3 (logtest? (process-mask vehicle) (-> s5-1 mask))) + (send-attack! this s5-1 #f) + ) + ) + ) + ) + ) + (none) + ) + ) + +(defmethod send-attack! ((this gun-red-2-shockwave) (arg0 process-focusable) (arg1 symbol)) + (let* ((a0-2 (get-trans arg0 3)) + (v1-2 (vector-! (new 'stack-no-clear 'vector) a0-2 (-> this origin))) + ) + 0.0 + (set! (-> v1-2 y) 0.0) + (let* ((f0-3 (* (-> this base-damage) (-> this current-intensity))) + (f0-4 (fmax 1.0 f0-3)) + (a0-4 'eco-red) + ) + (if (not arg1) + (set! a0-4 'eco-red-shove) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (send-event arg0 'attack #f (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) + (damage f0-4) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode a0-4) + (attacker-velocity v1-2) + (control (-> this current-intensity)) + (penetrate-using (penetrate jak-red-shot jak-red-shockwave)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defstate charging (gun-red-2-shockwave) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 float)) + (case message + (('charge) + (return (the-as object (-> self strength))) + v0-0 + ) + ) + ) + :enter (behavior () + (set-time! (-> self state-time)) + (set! (-> self ammo-drained) 0.0) + ) + :exit (behavior () + (send-event (ppointer->process (-> self parent)) 'release) + (send-event (handle->process (-> self charge-part-tracker)) 'die) + (sound-stop (-> self snd-charge)) + ) + :trans (behavior () + (let ((t9-0 vector<-cspace!) + (a0-0 (-> self origin)) + (v1-0 (-> self parent)) + ) + (t9-0 a0-0 (-> (the-as process-drawable (if v1-0 + (the-as process-drawable (-> v1-0 0 self)) + ) + ) + node-list + data + 13 + ) + ) + ) + (sound-play "red2-charge" :id (-> self snd-charge) :position (-> self origin)) + (let ((f0-0 (get-remaining-player-ammo (pickup-type ammo-red)))) + (if (< 0.0 f0-0) + (set! (-> self strength) + (fmin 1.0 (/ (the float (- (current-time) (-> self state-time))) (the float (-> self total-charge-time)))) + ) + ) + ) + (let ((f30-0 (cond + ((time-elapsed? (-> self state-time) (seconds 1)) + 5.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.75)) + 4.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.5)) + 3.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.25)) + 2.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.1)) + 1.0 + ) + (else + 0.0 + ) + ) + ) + ) + (when (< (-> self ammo-drained) f30-0) + (let ((f0-5 (- f30-0 (-> self ammo-drained)))) + (adjust-player-ammo (- f0-5) (pickup-type ammo-red)) + ) + (set! (-> self ammo-drained) f30-0) + ) + ) + (set! (-> *part-id-table* 372 init-specs 2 initial-valuef) (lerp 3276.8 8192.0 (-> self strength))) + (set! (-> *part-id-table* 373 init-specs 2 initial-valuef) (lerp 8192.0 14336.0 (-> self strength))) + (if (and (time-elapsed? (-> self state-time) (seconds 0.1)) + (or (not (cpad-hold? 0 r1)) + (and *target* + (focus-test? *target* dead grabbed under-water pole flut board mech dark carry indax teleporting) + ) + (and *target* (not (logtest? (focus-status in-head gun) (-> *target* focus-status)))) + (and *target* (!= (-> self start-pilot?) (focus-test? *target* pilot))) + (not (-> *setting-control* user-current gun)) + ) + ) + (go-virtual explode) + ) + ) + :code sleep-code + :post (behavior () + (set! (-> *last-player-pos* x) (-> *target* gun fire-point x)) + (set! (-> *last-player-pos* y) (+ 6553.6 (-> *target* control trans y))) + (set! (-> *last-player-pos* z) (-> *target* gun fire-point z)) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior generate-shockwave-scorch-marks-3 gun-red-2-shockwave ((arg0 int)) + (let ((s4-0 (-> self eventual-collision-points arg0)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s5-0 x) 0.0) + (set! (-> s5-0 y) 409.6) + (set! (-> s5-0 z) 0.0) + (set! (-> s5-0 w) 1.0) + (when (-> s4-0 found?) + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (let ((s3-1 (vector-! (new 'stack-no-clear 'vector) (-> s4-0 collision-pt) (-> self origin)))) + (set! (-> s3-1 y) 0.0) + (vector-normalize! s3-1 1.0) + (matrix-u-f-compose gp-0 (-> s4-0 normal) s3-1) + ) + (vector+! (-> gp-0 trans) (-> s4-0 collision-pt) s5-0) + (let ((v1-14 + (if (logtest? (-> *part-group-id-table* 89 flags) (sp-group-flag sp13)) + (part-tracker-spawn + part-tracker-subsampler + :to *entity-pool* + :group (-> *part-group-id-table* 89) + :mat-joint gp-0 + ) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 89) :mat-joint gp-0) + ) + ) + ) + (send-event (ppointer->process v1-14) 'clock self) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defbehavior generate-shockwave-scorch-marks-2 gun-red-2-shockwave () + (set! (-> self show-scorch-marks?) #t) + (set! (-> self generating-marks?) #t) + (let ((gp-0 0)) + (dotimes (s5-0 (-> self num-collision-pts-to-generate)) + (when (< 30 gp-0) + (set! gp-0 0) + (suspend) + 0 + ) + (+! gp-0 1) + (generate-shockwave-scorch-marks-3 s5-0) + ) + ) + (set! (-> self generating-marks?) #f) + (none) + ) + +(defstate die (gun-red-2-shockwave) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :code (behavior () + (when (not (-> self show-scorch-marks?)) + (generate-collision-points! self) + (generate-shockwave-scorch-marks-2) + ) + ) + ) + +(deftype gun-red-2-explosion (process-drawable) + () + (:methods + (gun-red-2-explosion-method-20 (_type_) none) + ) + ) + + +(defmethod gun-red-2-shockwave-method-22 ((this gun-red-2-shockwave) (arg0 int) (arg1 int) (arg2 int) (arg3 int)) + (when (< 1 (- arg1 arg0)) + (let ((s2-0 (/ (+ arg0 arg1) 2))) + (let ((a0-4 (+ arg3 -1 (ash 1 arg2)))) + (set! (-> this generate-order-array a0-4) (the-as uint (+ s2-0 -1))) + ) + (gun-red-2-shockwave-method-22 this arg0 s2-0 (+ arg2 1) (* arg3 2)) + (gun-red-2-shockwave-method-22 this s2-0 arg1 (+ arg2 1) (+ (* arg3 2) 1)) + ) + ) + (none) + ) + +(defmethod find-collision-point! ((this gun-red-2-shockwave)) + (local-vars (sv-560 collide-query) (sv-564 int) (sv-608 vector) (sv-612 vector) (sv-616 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (if (>= (-> this next-computed-collision-point) (-> this num-collision-pts-to-generate)) + (return 0) + ) + (set! sv-560 (new 'stack-no-clear 'collide-query)) + (set! sv-564 (-> this num-collision-pts-to-generate)) + (set! sv-608 (new 'stack-no-clear 'vector)) + (set! sv-612 (new 'stack-no-clear 'vector)) + (set! sv-616 (/ 65536.0 (the float (+ sv-564 -1)))) + (let ((f30-1 + (+ (* sv-616 (the float (-> this generate-order-array (-> this next-computed-collision-point)))) + (rand-vu-float-range (* -0.43478262 sv-616) (* 0.43478262 sv-616)) + ) + ) + ) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) angle) f30-1) + (set-vector! + sv-608 + (* (rand-vu-float-range 0.7 0.9) (-> this max-ground-radius) (cos f30-1)) + 32768.0 + (* (rand-vu-float-range 0.7 0.9) (-> this max-ground-radius) (sin f30-1)) + 1.0 + ) + ) + (vector+! (-> sv-560 start-pos) (-> this origin) sv-608) + (set! (-> sv-560 start-pos y) (- (-> sv-560 start-pos y) (-> this height-off-ground))) + (+! (-> sv-560 start-pos y) 20480.0) + (set-vector! (-> sv-560 move-dist) 0.0 -65536.0 0.0 1.0) + (let ((v1-29 sv-560)) + (set! (-> v1-29 radius) 40.96) + (set! (-> v1-29 collide-with) (collide-spec backgnd hit-by-others-list pusher impenetrable-obj)) + (set! (-> v1-29 ignore-process0) #f) + (set! (-> v1-29 ignore-process1) #f) + (set! (-> v1-29 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-29 action-mask) (collide-action solid)) + ) + (let ((f0-25 (fill-and-probe-using-line-sphere *collide-cache* sv-560))) + (when (>= f0-25 0.0) + (let ((v1-33 sv-612)) + (let ((a0-17 (-> sv-560 start-pos))) + (let ((a1-7 (-> sv-560 move-dist))) + (let ((a2-0 f0-25)) + (.mov vf7 a2-0) + ) + (.lvf vf5 (&-> a1-7 quad)) + ) + (.lvf vf4 (&-> a0-17 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> v1-33 quad) vf6) + ) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) collision-pt quad) + (-> sv-612 quad) + ) + (+! (-> this eventual-collision-points (-> this next-computed-collision-point) collision-pt y) 204.8) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) found?) #t) + (set! (-> (the-as + (pointer uint128) + (+ (the-as uint (-> this eventual-collision-points 0 normal)) (* 48 (-> this next-computed-collision-point))) + ) + ) + (-> sv-560 best-other-tri normal quad) + ) + (let ((s5-1 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-1 (vector-float*! (new 'stack-no-clear 'vector) (-> sv-560 best-other-tri normal) 3072.0)) + ) + (let ((s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> sv-560 best-other-tri normal) 1.0)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (vector-get-unique! s1-0 s2-0) + (vector-cross! s5-1 s2-0 s1-0) + ) + (vector-normalize! s5-1 1.0) + (dotimes (s2-1 4) + (vector-rotate-around-axis! + s4-0 + (the-as quaternion s5-1) + (* 16384.0 (the float s2-1)) + (-> sv-560 best-other-tri normal) + ) + (vector-normalize! s4-0 10240.0) + (vector+! s4-0 s4-0 s3-1) + (vector+! (-> sv-560 start-pos) sv-612 s4-0) + (vector-float*! (-> sv-560 move-dist) (-> sv-560 best-other-tri normal) -6144.0) + (let ((v1-59 sv-560)) + (set! (-> v1-59 radius) 40.96) + (set! (-> v1-59 collide-with) (collide-spec backgnd hit-by-others-list pusher impenetrable-obj)) + (set! (-> v1-59 ignore-process0) #f) + (set! (-> v1-59 ignore-process1) #f) + (set! (-> v1-59 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-59 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* sv-560) 0.0) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) found?) #f) + 0 + (goto cfg-11) + ) + ) + ) + ) + ) + (label cfg-11) + (let ((v0-0 (+ (-> this next-computed-collision-point) 1))) + (set! (-> this next-computed-collision-point) v0-0) + v0-0 + ) + ) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod generate-collision-points! ((this gun-red-2-shockwave)) + (while (< (-> this next-computed-collision-point) (-> this num-collision-pts-to-generate)) + (find-collision-point! this) + ) + (none) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod adjust-height-and-radius ((this gun-red-2-shockwave)) + (let ((a1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> a1-0 start-pos quad) (-> this origin quad)) + (set-vector! (-> a1-0 move-dist) 0.0 (* -1.0 (-> this max-radius)) 0.0 1.0) + (let ((v1-2 a1-0)) + (set! (-> v1-2 radius) 40.96) + (set! (-> v1-2 collide-with) (collide-spec backgnd hit-by-others-list pusher impenetrable-obj)) + (set! (-> v1-2 ignore-process0) #f) + (set! (-> v1-2 ignore-process1) #f) + (set! (-> v1-2 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-2 action-mask) (collide-action solid)) + ) + (let ((f0-6 (fill-and-probe-using-line-sphere *collide-cache* a1-0))) + (if (>= f0-6 0.0) + (set! (-> this height-off-ground) (* f0-6 (-> this max-radius))) + (set! (-> this height-off-ground) (-> this max-radius)) + ) + ) + ) + (set! (-> this max-ground-radius) (-> this max-radius)) + (none) + ) + +(defskelgroup skel-gun-red-sphere gun gun-red-sphere-lod0-jg gun-red-sphere-idle-ja + ((gun-red-sphere-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 30) + :texture-level 10 + :light-index 4 + ) + +(deftype red-2-ring (process-drawable) + ((current-alpha float) + (pad uint8 12) + ) + (:state-methods + active + fading + ) + (:methods + (red-2-ring-method-22 () none) + ) + ) + + +(deftype red-2-ring-init-params (structure) + ((pos vector :inline) + ) + ) + + +(defbehavior red-2-ring-event-handler red-2-ring ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('scale) + (let ((v1-1 (the-as object (-> arg3 param 0))) + (v0-0 (the-as object (-> self root scale))) + ) + (set! (-> (the-as vector v0-0) quad) (-> (the-as vector v1-1) quad)) + v0-0 + ) + ) + (('alpha) + (set! (-> self current-alpha) (the-as float (-> arg3 param 0))) + ) + (('start-fade) + (if (not (and (-> self next-state) (= (-> self next-state name) 'fading))) + (go-virtual fading) + ) + ) + ) + ) + +(defbehavior red-2-ring-init-by-other red-2-ring ((arg0 red-2-ring-init-params)) + (set! (-> self root) (new 'process 'trsqv)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-generic-blast" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self root trans quad) (-> arg0 pos quad)) + (quaternion-identity! (-> self root quat)) + (go-virtual active) + ) + +(defstate active (red-2-ring) + :virtual #t + :event red-2-ring-event-handler + :enter (behavior () + (set-time! (-> self state-time)) + (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) + ) + :trans (behavior () + '() + ) + :code (behavior () + (ja-channel-push! 1 0) + (ja :group! (-> self draw art-group data 13) :num! zero) + (let ((gp-0 (ja-num-frames 0))) + (until #f + (ja :group! (-> self draw art-group data 13) + :num! (identity (lerp (the float gp-0) 0.0 (-> self current-alpha))) + ) + (suspend) + ) + ) + #f + ) + :post (behavior () + (ja-post) + ) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod generate-shockwave-particles ((this gun-red-2-shockwave)) + (local-vars (sv-160 int) (sv-176 shockwave-collision-pt)) + (when (and (not (-> this generated-particles?)) (time-elapsed? (-> this state-time) (seconds 0.067))) + (set! (-> this generated-particles?) #t) + (dotimes (s5-0 150) + (let ((f26-0 (* 436.90668 (the float s5-0))) + (s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-0 quad) (-> this origin quad)) + (set-vector! s3-0 (cos f26-0) 0.0 (sin f26-0) 1.0) + (vector-normalize! s3-0 (* 0.9 (-> this max-ground-radius))) + (let ((f30-0 (-> this origin y)) + (f24-0 -32768.0) + (f28-0 (-> this origin y)) + (f22-0 32768.0) + ) + 0.0 + (let ((s0-0 0) + (s2-1 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-160 0) + (while (< sv-160 (-> this next-computed-collision-point)) + (set! sv-176 (-> this eventual-collision-points sv-160)) + (when (-> sv-176 found?) + (let ((f0-9 (deg- (-> sv-176 angle) f26-0))) + (cond + ((and (< f0-9 0.0) (< f24-0 f0-9)) + (set! f24-0 f0-9) + (set! f30-0 (-> sv-176 collision-pt y)) + (set! s0-0 (logior s0-0 1)) + (set! (-> s2-1 quad) (-> sv-176 normal quad)) + ) + ((and (>= f0-9 0.0) (< f0-9 f22-0)) + (set! f22-0 f0-9) + (set! f28-0 (-> sv-176 collision-pt y)) + (set! s0-0 (logior s0-0 2)) + (set! (-> s1-0 quad) (-> sv-176 normal quad)) + ) + ) + ) + ) + (set! sv-160 (+ sv-160 1)) + ) + (let ((f26-1 0.0)) + (cond + ((= s0-0 3) + (set! f26-1 (/ (* -1.0 f24-0) (- f22-0 f24-0))) + ) + ((= s0-0 2) + (set! f26-1 1.0) + ) + ((= s0-0 1) + (set! f26-1 0.0) + ) + ) + (when #t + (let ((f0-12 (lerp f30-0 f28-0 f26-1))) + (set! (-> s4-0 y) (- (-> s4-0 y) (-> this height-off-ground))) + (set! (-> s3-0 y) (- f0-12 (-> s4-0 y))) + ) + (let ((s2-2 (vector-lerp! (new 'stack-no-clear 'vector) s2-1 s1-0 f26-1))) + (vector-normalize! s2-2 2048.0) + (vector+! s3-0 s3-0 s2-2) + ) + (vector-normalize! s3-0 1.0) + (let ((s2-3 (new 'stack-no-clear 'matrix))) + (matrix-f-u-compose s2-3 s3-0 *up-vector*) + (set! (-> s2-3 trans quad) (-> s4-0 quad)) + (launch-particles (-> *part-id-table* 353) s2-3 :origin-is-matrix #t) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defmethod adjust-warp-radius-and-alpha ((this gun-red-2-shockwave)) + (let* ((f0-1 (/ (-> this max-radius) (-> this max-charge-radius))) + (f0-3 + (/ (the float (- (current-time) (-> this state-time))) (* f0-1 (the float (-> this warp-expansion-time)))) + ) + (f0-4 (* f0-3 f0-3)) + ) + (set! (-> this current-warp-radius) (lerp (-> this min-charge-radius) (-> this max-radius) f0-4)) + ) + (let ((f0-7 (/ (-> this current-warp-radius) (-> this max-radius)))) + (if (< 1.0 f0-7) + (set! (-> this current-warp-alpha) (fmax 0.0 (- 2.0 f0-7))) + ) + ) + (let ((v1-8 (new 'stack-no-clear 'vector))) + (set! (-> v1-8 x) (* 0.00024414062 (-> this current-warp-radius))) + (set! (-> v1-8 y) 1.0) + (set! (-> v1-8 z) (* 0.00024414062 (-> this current-warp-radius))) + (set! (-> v1-8 w) 1.0) + (send-event (handle->process (-> this explosion-1)) 'scale v1-8) + ) + (send-event (handle->process (-> this explosion-1)) 'alpha (-> this current-warp-alpha)) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod adjust-ring-radius-and-alpha ((this gun-red-2-shockwave)) + (let ((f0-2 (/ (the float (- (current-time) (-> this state-time))) (the float (-> this ring-expansion-time))))) + (set! (-> this current-ring-radius) (lerp (-> this min-charge-radius) (-> this max-charge-radius) f0-2)) + ) + (let ((f0-5 (/ (-> this current-ring-radius) (-> this max-radius)))) + (if (< 1.0 f0-5) + (set! (-> this current-ring-alpha) (fmax 0.0 (- 1.7 f0-5))) + ) + ) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod generate-order-array ((this gun-red-2-shockwave)) + (gun-red-2-shockwave-method-22 this 0 (-> this num-collision-pts-to-generate) 0 0) + (let ((a0-3 (log2 (-> this num-collision-pts-to-generate)))) + (when (< (ash 1 a0-3) (-> this num-collision-pts-to-generate)) + (let ((v1-7 (+ (ash 1 (+ (log2 (-> this num-collision-pts-to-generate)) 1)) -1)) + (a0-7 0) + ) + (dotimes (a1-1 v1-7) + (set! (-> this generate-order-array a0-7) (-> this generate-order-array a1-1)) + (if (nonzero? (-> this generate-order-array a0-7)) + (+! a0-7 1) + ) + ) + ) + ) + ) + (none) + ) + +(when (or (zero? *impact-blur*) (!= loading-level global)) + (set! *impact-blur* (new 'loading-level 'curve2d-piecewise)) + (curve2d-piecewise-method-10 *impact-blur* 3 'loading-level (the-as int #f)) + ) + +(set! (-> *impact-blur* pts data 0 first) 0.0) + +(set! (-> *impact-blur* pts data 0 second) 0.0) + +(set! (-> *impact-blur* pts data 1 first) 0.2) + +(set! (-> *impact-blur* pts data 1 second) 1.0) + +(set! (-> *impact-blur* pts data 2 first) 1.0) + +(set! (-> *impact-blur* pts data 2 second) 0.0) + +(when (or (zero? *shockwave-blur-red-2*) (!= loading-level global)) + (set! *shockwave-blur-red-2* (new 'loading-level 'curve2d-piecewise)) + (curve2d-piecewise-method-10 *shockwave-blur-red-2* 5 'loading-level (the-as int #f)) + ) + +(set! (-> *shockwave-blur-red-2* pts data 0 first) 0.0) + +(set! (-> *shockwave-blur-red-2* pts data 0 second) 0.0) + +(set! (-> *shockwave-blur-red-2* pts data 1 first) 0.7) + +(set! (-> *shockwave-blur-red-2* pts data 1 second) 0.0) + +(set! (-> *shockwave-blur-red-2* pts data 2 first) 0.8) + +(set! (-> *shockwave-blur-red-2* pts data 2 second) 1.0) + +(set! (-> *shockwave-blur-red-2* pts data 3 first) 0.9) + +(set! (-> *shockwave-blur-red-2* pts data 3 second) 0.3) + +(set! (-> *shockwave-blur-red-2* pts data 4 first) 1.0) + +(set! (-> *shockwave-blur-red-2* pts data 4 second) 0.0) + +(defmethod spawn-ring ((this gun-red-2-shockwave)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (set! (-> v1-0 quad) (-> this origin quad)) + (set! (-> v1-0 y) (- (-> v1-0 y) (-> this height-off-ground))) + (+! (-> v1-0 y) 2048.0) + (+! (-> v1-0 y) -1433.6) + (let ((s5-0 (new 'stack-no-clear 'red-2-ring-init-params))) + (set! (-> s5-0 pos quad) (-> v1-0 quad)) + (let ((v1-3 (process-spawn red-2-ring s5-0 :name "red-2-ring" :to this))) + (if v1-3 + (set! (-> this explosion-1) (ppointer->handle v1-3)) + ) + ) + ) + ) + (none) + ) + +(defmethod deactivate ((this gun-red-2-shockwave)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (blit-displays-work-method-17 *blit-displays-work* (-> this origin) 0 1.0 #f) + (call-parent-method this) + (none) + ) + +(defstate explode (gun-red-2-shockwave) + :virtual #t + :enter (behavior () + (let ((f30-0 (lerp 0.3 0.8 (-> self strength))) + (a3-0 (the int (* 300.0 (lerp 0.1 0.4 (-> self strength))))) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 (the int (* 255.0 f30-0)) (the-as time-frame a3-0)) + ) + (sound-play "red2-shot") + (set-time! (-> self state-time)) + (set! (-> self max-radius) (lerp (-> self min-charge-radius) (-> self max-charge-radius) (-> self strength))) + (/ (-> self max-radius) (-> self max-charge-radius)) + (let ((f0-15 (* 0.000012207031 (-> self max-radius)))) + 0.0 + (let ((f1-5 (/ (* 2.0 (- (* 163840.0 f0-15) (-> self max-radius))) (* f0-15 f0-15)))) + (set! (-> *part-id-table* 353 init-specs 9 initial-valuef) (* 1.2 f1-5)) + ) + (let ((v1-15 (the int (* 150.0 f0-15)))) + (set! (-> *part-id-table* 354 init-specs 3 initial-valuef) (the-as float (+ v1-15 -25))) + (set! (-> *part-id-table* 354 init-specs 3 random-rangef) (the-as float (+ v1-15 -5))) + ) + ) + (adjust-height-and-radius self) + (set! (-> self current-intensity) (-> self strength)) + (spawn-ring self) + (set! (-> self num-collision-pts-to-generate) + (the int (fmax 6.0 (fmin 64.0 (* 64.0 (/ (-> self max-ground-radius) (-> self max-charge-radius)))))) + ) + (generate-order-array self) + (set! (-> self current-ring-alpha) 1.0) + (set! (-> self current-burst-alpha) 1.0) + (set! (-> self current-warp-alpha) 1.0) + ) + :exit (behavior () + (blit-displays-work-method-17 *blit-displays-work* (-> self origin) 0 1.0 #f) + ) + :trans (behavior () + (let ((f0-1 + (fmin 1.0 (/ (the float (- (current-time) (-> self state-time))) (the float (-> self total-explode-time)))) + ) + ) + (set! (-> self current-radius) + (fmin (lerp (-> self min-charge-radius) (-> self max-charge-radius) f0-1) (-> self max-radius)) + ) + ) + (set! (-> self current-stage-t) + (/ (- (-> self current-radius) (-> self min-charge-radius)) + (- (-> self max-radius) (-> self min-charge-radius)) + ) + ) + (set! (-> self current-intensity) + (cond + ((logtest? (game-secrets gun-upgrade-red-2) (-> *game-info* secrets)) + (let ((f0-8 (fmin (-> self current-stage-t) (* 1.5 (-> self current-stage-t) (-> self current-stage-t))))) + (fmax 0.3 (lerp (-> self strength) 0.0 f0-8)) + ) + ) + (else + (lerp (-> self strength) 0.0 (-> self current-stage-t)) + ) + ) + ) + (generate-shockwave-particles self) + (adjust-ring-radius-and-alpha self) + (adjust-warp-radius-and-alpha self) + (let ((f0-14 (-> self current-stage-t))) + 0.0 + (let* ((f0-16 (- 1.0 (curve2d-method-9 *impact-blur* f0-14 3))) + (f0-19 (lerp f0-16 1.0 (fmax 0.0 (- 0.5 (-> self strength))))) + ) + (blit-displays-work-method-17 *blit-displays-work* (-> self origin) 2 (fmin 1.0 f0-19) #f) + ) + ) + (if (< (-> self current-stage-t) 1.0) + (find-targets-and-attack! self) + ) + (cond + ((and (not (-> self generating-marks?)) (-> self show-scorch-marks?) (>= 0.0 (-> self current-warp-alpha))) + (go-virtual die) + ) + ((and (not (-> self show-scorch-marks?)) + (< (-> self next-computed-collision-point) (-> self num-collision-pts-to-generate)) + ) + (find-collision-point! self) + (find-collision-point! self) + (find-collision-point! self) + ) + ) + (if (and (not (-> self show-scorch-marks?)) + (time-elapsed? (-> self state-time) (the int (* 0.0036621094 (-> self max-radius)))) + ) + (set! (-> self show-scorch-marks?) #t) + ) + ) + :code (behavior () + (while (not (-> self show-scorch-marks?)) + (suspend) + ) + (generate-collision-points! self) + (generate-shockwave-scorch-marks-2) + (sleep-code) + ) + :post (behavior () + (set-vector! (new 'stack-no-clear 'vector) 1.9 0.0 0.0 (-> self alpha-scalar)) + (set! (-> *part-id-table* 229 init-specs 2 initial-valuef) (* 2.0 (-> self current-ring-radius))) + (set! (-> *part-id-table* 229 init-specs 7 initial-valuef) (* 128.0 (-> self current-ring-alpha))) + (set! (-> *part-id-table* 226 init-specs 3 initial-valuef) + (lerp 20480.0 24576.0 (/ (-> self max-radius) (-> self max-charge-radius))) + ) + (set! (-> *part-id-table* 226 init-specs 3 initial-valuef) + (* 0.5 (-> *part-id-table* 226 init-specs 3 initial-valuef)) + ) + (set! (-> *part-id-table* 226 init-specs 3 random-rangef) + (lerp 0.0 20480.0 (/ (-> self max-radius) (-> self max-charge-radius))) + ) + (launch-particles (-> *part-id-table* 229) (-> self origin)) + ) + ) + +;; WARN: Return type mismatch int vs object. +(defbehavior gun-fire-red-2 target () + (let ((gp-0 (-> self gun)) + (v1-1 (-> self gun fire-point)) + ) + (set! (-> *last-player-pos* x) (-> *target* gun fire-point x)) + (set! (-> *last-player-pos* y) (+ 6553.6 (-> *target* control trans y))) + (set! (-> *last-player-pos* z) (-> *target* gun fire-point z)) + (when #t + (let ((s5-0 (new 'stack-no-clear 'gun-red-2-shockwave-init-params))) + (set! (-> s5-0 pos quad) (-> v1-1 quad)) + (let ((v1-4 (process-spawn + gun-red-2-shockwave + s5-0 + :name "gun-red-2-shockwave" + :to (ppointer->process (-> gp-0 gun)) + :stack *kernel-dram-stack* + ) + ) + ) + (set! (-> gp-0 gun 0 extra) (ppointer->handle v1-4)) + (let ((v0-0 (ppointer->handle v1-4))) + (set! (-> self gun charge-active?) (the-as handle v0-0)) + v0-0 + ) + ) + ) + ) + ) + ) + +(deftype red-3-sphere (process-drawable) + ((current-alpha float) + (pad uint8 12) + ) + (:state-methods + active + ) + (:methods + (red-3-sphere-method-21 (_type_) none) + (red-3-sphere-method-22 (_type_) none) + ) + ) + + +(deftype red-3-sphere-init-params (structure) + ((pos vector :inline) + ) + ) + + +(defbehavior red-3-sphere-init-by-other red-3-sphere ((arg0 red-3-sphere-init-params)) + (set! (-> self root) (new 'process 'trsqv)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-red-sphere" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self root trans quad) (-> arg0 pos quad)) + (quaternion-identity! (-> self root quat)) + (go-virtual active) + ) + +(defstate active (red-3-sphere) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (let* ((a2-0 (math-camera-matrix)) + (v1-0 (-> a2-0 rvec quad)) + (a0-0 (-> a2-0 uvec quad)) + (a1-0 (-> a2-0 fvec quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> gp-0 rvec quad) v1-0) + (set! (-> gp-0 uvec quad) a0-0) + (set! (-> gp-0 fvec quad) a1-0) + (set! (-> gp-0 trans quad) a2-1) + ) + (-> gp-0 fvec) + (-> gp-0 rvec) + (matrix->quat gp-0 (-> self root quat)) + ) + (set! (-> self current-alpha) (* 0.008333334 (the float (- (current-time) (-> self state-time))))) + (let ((f0-3 (+ (-> self root scale x) (* 24.0 (seconds-per-frame))))) + (set-vector! (-> self root scale) f0-3 f0-3 f0-3 1.0) + ) + ) + :code (behavior () + (ja-channel-push! 1 0) + (ja-no-eval :group! gun-red-sphere-burst-ja :num! (seek!) :frame-num 0.0) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (ja-no-eval :group! gun-red-sphere-fade-ja :num! (seek! max 5.0) :frame-num 0.0) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! max 5.0)) + ) + (deactivate self) + ) + :post (behavior () + (ja-post) + ) + ) + +;; WARN: Return type mismatch (pointer process) vs gun-red-3-grenade. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f2, f5] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f1, f3, f6] +(defbehavior gun-fire-red-3 target () + (local-vars + (f1-2 float) + (sv-16 gun-info) + (sv-20 vector) + (sv-24 vector) + (sv-28 float) + (sv-144 vector) + (sv-148 vector) + (sv-1952 vector) + (sv-1968 vector) + ) + (set! sv-16 (-> self gun)) + (set! sv-20 (-> self gun fire-dir-out)) + (set! sv-24 (-> self gun fire-point)) + (set! sv-28 (the-as float 266240.0)) + (draw-beam (-> *part-id-table* 217) sv-24 sv-20 #f) + (set! (-> sv-20 y) (fmax 0.3 (-> sv-20 y))) + (vector-normalize! sv-20 1.0) + (let ((v1-17 (cond + ((logtest? (-> *part-group-id-table* 86 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> sv-16 fire-point quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 86)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> sv-16 fire-point quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 86)) + ) + ) + ) + ) + (send-event (ppointer->process v1-17) 'clock self) + ) + (set! sv-144 (new 'stack-no-clear 'vector)) + (let ((v1-42 (new 'stack-no-clear 'vector))) + (set! (-> v1-42 quad) (-> sv-20 quad)) + (set! sv-148 v1-42) + ) + (set! (-> sv-148 y) 0.0) + (vector-normalize! sv-148 1.0) + (vector+float*! sv-144 sv-24 sv-148 143360.0) + (set! (-> sv-144 w) 143360.0) + (let ((f30-0 4096000.0) + (s5-0 #f) + (gp-2 (the-as process-focusable #f)) + ) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) (process->ppointer self)) + (set! (-> a1-11 num-params) 0) + (set! (-> a1-11 message) 'get-vehicle) + (let ((s4-0 (send-event-function *target* a1-11))) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-144) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-54 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-54 + (let* ((s0-0 (-> v1-54 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= *target* s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive gun-no-target)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s1-1 mask)) + (and (logtest? (process-mask guard) (-> s1-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + (!= s4-0 s1-1) + ) + (when (or (not s5-0) (logtest? (process-mask enemy guard) (-> s1-1 mask))) + (set! sv-1952 (new 'stack-no-clear 'vector)) + (let ((v1-71 (-> (get-trans (the-as process-focusable s1-1) 0) quad))) + (set! (-> sv-1952 quad) v1-71) + ) + (set! sv-1968 (vector-normalize-copy! (new 'stack-no-clear 'vector) sv-148 1.0)) + (let ((s0-1 (new 'stack-no-clear 'vector))) + (let ((a1-18 s0-1) + (v1-72 sv-24) + ) + (vector-! a1-18 sv-1952 v1-72) + ) + (let ((f0-7 (vector-normalize-ret-len! s0-1 1.0))) + (let* ((v1-73 s0-1) + ; (f1-1 (-> sv-1968 x)) + ; (f2-0 (-> sv-1968 y)) + ; (f3-0 (-> sv-1968 z)) + ; (f4-0 (-> v1-73 x)) + ; (f5-0 (-> v1-73 y)) + ; (f6-0 (-> v1-73 z)) + ) + ;; og:preserve-this vector-dot + ; (.mula.s f1-1 f4-0) + ; (.madda.s f2-0 f5-0) + ; (.madd.s f1-2 f3-0 f6-0) + (set! f1-2 (vector-dot sv-1968 v1-73)) + ) + (let ((f1-3 f1-2) + (v1-75 (and (not s5-0) (logtest? (process-mask enemy guard) (-> s1-1 mask)))) + ) + (when (and (< 0.707 f1-3) (< (fabs (-> s0-1 y)) 28672.0) (or v1-75 (< f0-7 f30-0))) + (set! s5-0 v1-75) + (set! f30-0 f0-7) + (set! gp-2 (the-as process-focusable s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) sv-144) (-> sv-144 w))) + (when (and (!= *target* s3-1) + (not (focus-test? s3-1 disable dead inactive gun-no-target)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + (!= s4-0 s3-1) + ) + (when (or (not s5-0) (logtest? (process-mask enemy guard) (-> s3-1 mask))) + (let ((s1-2 (new 'stack-no-clear 'vector))) + (set! (-> s1-2 quad) (-> (get-trans s3-1 0) quad)) + (let ((s2-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) sv-148 1.0)) + (s4-1 (new 'stack-no-clear 'vector)) + ) + (vector-! s4-1 s1-2 sv-24) + (let ((f0-9 (vector-normalize-ret-len! s4-1 1.0)) + (f1-8 (vector-dot s2-3 s4-1)) + (v1-101 (and (not s5-0) (logtest? (process-mask enemy guard) (-> s3-1 mask)))) + ) + (if (and (< 0.707 f1-8) (< (fabs (-> s4-1 y)) 28672.0) (or v1-101 (< f0-9 f0-9))) + (set! gp-2 s3-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (when gp-2 + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> (get-trans gp-2 3) quad)) + (let ((f0-10 (vector-vector-xz-distance s5-1 (-> sv-16 fire-point))) + (f1-13 (fabs (- (-> s5-1 y) (-> sv-16 fire-point y)))) + ) + 0.0 + (when (< f1-13 24576.0) + (let ((f0-14 (* 0.5 (asin (/ (* 184320.0 f0-10) (* sv-28 sv-28)))))) + (set! (-> sv-20 y) (sin f0-14)) + ) + (vector-normalize! sv-20 1.0) + ) + ) + ) + ) + ) + (let ((a1-33 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> a1-33 ent) (-> self entity)) + (set! (-> a1-33 charge) 1.0) + (set! (-> a1-33 options) (projectile-options)) + (logclear! (-> a1-33 options) (projectile-options po14 po15 po16)) + (set! (-> a1-33 pos quad) (-> sv-24 quad)) + (set! (-> a1-33 vel quad) (-> (vector-float*! (new 'stack-no-clear 'vector) sv-20 sv-28) quad)) + (set! (-> a1-33 notify-handle) (the-as handle #f)) + (set! (-> a1-33 owner-handle) (process->handle self)) + (set! (-> a1-33 target-handle) (the-as handle #f)) + (set! (-> a1-33 target-pos quad) (the-as uint128 0)) + (set! (-> a1-33 ignore-handle) (process->handle self)) + (let* ((v1-127 *game-info*) + (a0-100 (+ (-> v1-127 attack-id) 1)) + ) + (set! (-> v1-127 attack-id) a0-100) + (set! (-> a1-33 attack-id) a0-100) + ) + (set! (-> a1-33 timeout) (seconds 4)) + (the-as gun-red-3-grenade (spawn-projectile gun-red-3-grenade a1-33 self *default-dead-pool*)) + ) + ) + +;; WARN: Return type mismatch sound-id vs none. +(defmethod projectile-method-39 ((this gun-red-3-grenade)) + (let* ((a2-0 (-> this root)) + (v1-0 (-> a2-0 status)) + ) + (if (logtest? v1-0 (collide-status touch-surface)) + (vector-float*! (-> a2-0 transv) (-> a2-0 transv) 0.6) + ) + (when (and (logtest? v1-0 (collide-status impact-surface)) + (time-elapsed? (-> this played-bounce-time) (seconds 0.3)) + ) + (set-time! (-> this played-bounce-time)) + (sound-play "grenade-bounce") + ) + ) + (none) + ) + +(defstate moving (gun-red-3-grenade) + :virtual #t + :trans (behavior () + (go-impact self) + (let ((t9-2 (-> (find-parent-state) trans))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + +(defstate sitting (gun-red-3-grenade) + :virtual #t + :trans (behavior () + (go-impact self) + (let ((t9-2 (-> (find-parent-state) trans))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + +(defstate impact-tiny (gun-red-3-grenade) + :virtual #t + :event projectile-event-handler + :enter (behavior () + '() + ) + :code (behavior () + (let ((gp-0 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-0 spawn-point quad) (-> self root trans quad)) + (quaternion-identity! (-> gp-0 spawn-quat)) + (set! (-> gp-0 radius) 0.0) + (set! (-> gp-0 scale) 1.0) + (set! (-> gp-0 group) (-> *part-group-id-table* 104)) + (set! (-> gp-0 collide-with) (collide-spec)) + (set! (-> gp-0 damage) 2.0) + (set! (-> gp-0 damage-scale) 1.0) + (set! (-> gp-0 vehicle-damage-factor) 1.0) + (set! (-> gp-0 vehicle-impulse-factor) 1.0) + (set! (-> gp-0 ignore-proc) (process->handle #f)) + (explosion-spawn gp-0 self) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (while (-> self child) + (suspend) + ) + (deactivate self) + ) + ) + +(defmethod deactivate ((this gun-red-3-grenade)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (blit-displays-work-method-17 *blit-displays-work* *zero-vector* 0 1.0 #f) + (call-parent-method this) + (none) + ) + +(defstate impact (gun-red-3-grenade) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('touched) + (when (send-event + proc + 'attack + (-> block param 0) + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> self attack-id)) + (damage 2.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'explode) + ) + ) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + #t + ) + ) + ) + ) + :code (behavior () + (sound-play "red3-blast") + (find-and-damage-targets self) + (set-time! (-> self state-time)) + (when (not (-> self immediate-detonation?)) + (let ((gp-1 (new 'stack-no-clear 'red-3-sphere-init-params))) + (set! (-> gp-1 pos quad) (-> self root trans quad)) + (process-spawn red-3-sphere gp-1 :name "red-3-sphere" :to self) + ) + ) + (cond + ((logtest? (-> *part-group-id-table* 88 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 88)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 88)) + ) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (let ((v1-49 (-> self root root-prim))) + (set! (-> v1-49 prim-core collide-as) (collide-spec)) + (set! (-> v1-49 prim-core collide-with) (collide-spec)) + ) + 0 + (let ((gp-4 (-> self child))) + (while gp-4 + (send-event (ppointer->process gp-4) 'notice 'die) + (set! gp-4 (-> gp-4 0 brother)) + ) + ) + (let ((gp-6 (vector-! (new 'stack-no-clear 'vector) (-> self root trans) (math-camera-pos)))) + 0.0 + (let* ((f0-2 (vector-length gp-6)) + (f30-0 (* 0.0000016276042 f0-2)) + ) + (cpad-set-buzz! + (-> *cpad-list* cpads 0) + 1 + (the int (* 255.0 (lerp-scale-clamp 1.0 0.3 f30-0 0.1 0.8))) + (the-as time-frame (the int (* 300.0 (lerp 0.3 0.1 f30-0)))) + ) + (let ((f30-1 (fmin 1.0 f30-0))) + (while (-> self child) + (let ((f0-11 (* 0.0044444446 (the float (- (current-time) (-> self state-time)))))) + 0.0 + (let* ((f0-13 (- 1.0 (curve2d-method-9 *impact-blur* f0-11 1))) + (f0-14 (lerp f0-13 1.0 f30-1)) + ) + (set! (-> *display* force-sync) (the-as uint 2)) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 2 (fmin 1.0 f0-14) #f) + ) + ) + (let ((gp-8 (-> self child))) + (while gp-8 + (send-event (ppointer->process gp-8) 'notice 'die) + (set! gp-8 (-> gp-8 0 brother)) + ) + ) + (suspend) + ) + ) + ) + ) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 15 1.0 #f) + (deactivate self) + ) + ) + +;; WARN: Return type mismatch (pointer process) vs object. +(defbehavior gun-fire-red-1 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* 216))) + (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))) + ) + ) + ) + (launch-particles (-> *part-id-table* 216) (-> gp-0 fire-point)) + (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 level) #f)) + #f + 0 + :name "manipy" + :to self + :stack-size #x20000 + ) + ) + ) + (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 manipy (-> 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 manipy (-> s5-3 0)) root scale z) (lerp-scale 0.2 1.0 (fabs f0-5) 20480.0 32768.0)) + (set! (-> (the-as manipy (-> s5-3 0)) root scale x) (-> (the-as manipy (-> s5-3 0)) root scale z)) + ) + ) + ) + ) + ) + ) + (process-spawn + gun-red-shot + (-> gp-0 fire-point) + (-> gp-0 fire-dir-out) + :name "gun-red-shot" + :to (ppointer->process (-> gp-0 gun)) + ) + ) + ) + ) + +(defbehavior target-gun-can-fire-red? target ((arg0 pickup-type)) + #t + ) + +;; WARN: Return type mismatch object vs (pointer process). +(defbehavior target-gun-fire-red target ((arg0 pickup-type)) + (+! (-> *game-info* shots-fired 1) 1.0) + (the-as (pointer process) (case arg0 + (((pickup-type gun-red-1)) + (gun-fire-red-1) + ) + (((pickup-type gun-red-2)) + (gun-fire-red-2) + ) + (((pickup-type gun-red-3)) + (gun-fire-red-3) + ) + ) + ) + ) + +;; WARN: Return type mismatch none vs object. +(defbehavior gun-red-shot-event-handler gun-red-shot ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('touched) + (send-attack! self (the-as process-drawable arg0) (the-as touching-shapes-entry (-> arg3 param 0))) + ) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defmethod send-attack! ((this gun-red-shot) (arg0 process-drawable) (arg1 touching-shapes-entry)) + (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) (-> this start-pos))) + (f30-0 (* (if (< (vector-length s5-2) 24576.0) + 3.0 + 2.0 + ) + (if (logtest? (game-feature feature22) (-> *game-info* features)) + 2.0 + 1.0 + ) + ) + ) + ) + (if (and (logtest? (process-mask guard) (-> arg0 mask)) + (not (-> *setting-control* user-current gun-target-guards?)) + ) + (set! f30-0 0.0) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (rot-zxy-from-vector! s2-0 s5-2) + (let ((f28-0 (deg- (-> s2-0 x) (-> this start-rot x))) + (f0-6 (deg- (-> s2-0 y) (-> this 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) (+ (-> this start-rot x) f1-5)) + (set! (-> s2-0 y) (+ (-> this 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)) + ) + ) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (send-event + arg0 + 'attack + arg1 + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage f30-0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-red) + (attacker-velocity s5-2) + (attacker (process->handle *target*)) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defmethod stub ((this gun-red-shot)) + 0 + (none) + ) + +(defmethod init-probes! ((this gun-red-shot) (arg0 collide-shape)) + (let ((s5-0 (-> this 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 (-> this 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) (-> this start-rot x))) + (f0-4 (deg- (-> s3-2 y) (-> this 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) (+ (-> this start-rot x) f1-3)) + (set! (-> s3-2 y) (+ (-> this 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! (-> this probe-dir s5-0 quad) (-> s4-1 quad)) + ) + (set! (-> this probe-count) (+ s5-0 1)) + ) + ) + (none) + ) + +(defmethod find-targets ((this 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 'bounding-box))) + (set! (-> s5-0 min quad) (-> this start-dir quad)) + (vector-float*! (the-as vector s5-0) (the-as vector s5-0) 43417.6) + (vector+! (the-as vector s5-0) (the-as vector s5-0) (-> this start-pos)) + (set! (-> s5-0 min w) 43827.2) + (let ((s4-0 (-> this root 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-box *actor-hash* 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 min 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 min 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 min 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 min 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! this a1-28) + ) + ) + ) + ) + ) + (set! (-> this actor-count) (-> this probe-count)) + 0 + (none) + ) + ) + +(defmethod setup-probes ((this gun-red-shot)) + (find-targets this) + (let ((s5-0 (-> this 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 (-> this probe-dir s5-0)) + ) + (set-vector! s4-0 0.0 0.0 1.0 1.0) + (vector-rotate-around-x! s4-0 s4-0 (+ (-> this start-rot x) f28-0)) + (vector-rotate-around-y! s4-0 s4-0 (+ (-> this start-rot y) f30-0)) + ) + (+! s5-0 1) + ) + (set! (-> this probe-count) s5-0) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch sound-id vs none. +(defmethod do-collision ((this 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 (-> this root))) + (let ((v1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> gp-0 trans quad) (-> this 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) this) + (set! (-> a1-1 ignore-process1) (ppointer->process (-> this parent))) + (set! (-> a1-1 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #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") + ) + ) + (none) + ) + ) + ) + +(defmethod check-blocked? ((this gun-red-shot)) + (let ((v1-0 (-> this root)) + (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) this) + (set! (-> a1-0 ignore-process1) (ppointer->process (-> this parent))) + (set! (-> a1-0 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #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-time! (-> self state-time)) + (until (time-elapsed? (-> 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 bucket583) + (-> self start-pos) + (-> self start-dir) + (meters 6) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (suspend) + ) + ) + ) + +(defstate blocked (gun-red-shot) + :virtual #t + :event gun-red-shot-event-handler + :code (behavior () + (suspend) + 0 + ) + ) + +(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) + (do-collision self (-> self probe-dir gp-0)) + (+! gp-0 1) + ) + ) + (suspend) + ) + ) + ) + ) + +(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 pusher shield) + ) + (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) s5-0) + ) + (let ((s5-1 (-> self root))) + (set! (-> s5-1 trans quad) (-> arg0 quad)) + (quaternion-copy! (-> s5-1 quat) (-> self parent 0 root quat)) + (vector-identity! (-> s5-1 scale)) + ) + (update-transforms (-> self root)) + (set! (-> self event-hook) gun-red-shot-event-handler) + (logior! (-> self mask) (process-mask projectile)) + (logclear! (-> self mask) (process-mask enemy)) + (setup-probes self) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (let ((v1-39 (cond + ((logtest? (-> *part-group-id-table* 84 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self start-pos quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 84)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self start-pos quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 84)) + ) + ) + ) + ) + (send-event (ppointer->process v1-39) 'clock self) + ) + (draw-beam (-> *part-id-table* 213) (-> self start-pos) (-> self start-dir) #f) + (sound-play "red-shot-fire") + (vector-float*! (-> self root transv) (-> self start-dir) 61440.0) + (if (check-blocked? self) + (go-virtual blocked) + (go-virtual idle) + ) + ) diff --git a/goal_src/jak3/engine/target/gun/gun-yellow-shot.gc b/goal_src/jak3/engine/target/gun/gun-yellow-shot.gc index f72e294910..6f3858845c 100644 --- a/goal_src/jak3/engine/target/gun/gun-yellow-shot.gc +++ b/goal_src/jak3/engine/target/gun/gun-yellow-shot.gc @@ -7,3 +7,2151 @@ ;; DECOMP BEGINS +(deftype gun-yellow-shot (projectile) + ((hit-actor? symbol) + (tail-pos vector :inline) + (hit-pos vector :inline) + (last-hit-time time-frame) + (snd-whoosh sound-id) + (muzzle-flash-part sparticle-launcher) + (main-shot-part sparticle-launcher) + (shot-aim-part sparticle-launcher) + (shot-ring-part sparticle-launcher) + ) + (:methods + (draw-main-shot (_type_ vector vector) none) + (gun-yellow-shot-method-42 (_type_ float float matrix) none) + (spawn-particles (_type_ vector) none) + ) + ) + + +(deftype gun-yellow-2-proc-ignore (structure) + ((hand handle) + (time time-frame) + ) + :pack-me + ) + + +(deftype gun-yellow-shot-2 (gun-yellow-shot) + ((last-collide-time time-frame) + (snd-trail sound-id) + (hit-yet? symbol) + (actor-deflect? symbol) + (max-actor-deflect-count int32) + (last-hit-enemy handle) + (delay-attack time-frame) + (delay-norm vector :inline) + (enemy-hit-count int32) + (ignore-list gun-yellow-2-proc-ignore 6 :inline) + (last-attack-time time-frame) + ) + (:methods + (on-impact (_type_ handle) object) + (handle-impact (_type_ handle) object) + (is-in-ignore-list? (_type_ handle) symbol) + (add-to-ignore-list! (_type_ handle) int) + ) + ) + + +(deftype gun-yellow-shot-3 (gun-yellow-shot) + () + ) + + +(deftype gun-yellow-3-saucer (projectile-bounce) + ((total-float-time time-frame) + (firing? symbol :offset 568) + (asleep? symbol) + (first-fire-time time-frame) + (activated? symbol) + (collided-with-surface? symbol) + (last-deflect-time time-frame) + (last-fire-time time-frame) + (spawn-part sparticle-launch-control) + (last-blink-time time-frame) + (finished? symbol) + (initial-fire-dir vector :inline) + (initial-fire-pos vector :inline) + (last-deduct-ammo-time time-frame) + (total-ammo-drained float) + (total-ammo-to-drain float) + (total-fire-time time-frame) + (snd-hum sound-id) + (snd-shoot sound-id) + ) + (:state-methods + undefined + navigating + spinning + impact-explode + falling-down + burnt-husk + ) + (:methods + (start-firing (_type_) none) + (init-antigrav (_type_) none) + (find-targets (_type_) int) + (spawn-shot (_type_ vector) (pointer gun-yellow-shot-3)) + ) + (:states + gun-yellow-3-saucer-base-state + ) + ) + + +(defmethod relocate ((this gun-yellow-3-saucer) (offset int)) + (call-parent-method this offset) + ) + +(deftype target-quality-info-saucer (structure) + ((targ handle) + (value float) + ) + ) + + +;; WARN: Return type mismatch (pointer process) vs (pointer gun-yellow-shot-3). +(defmethod spawn-shot ((this gun-yellow-3-saucer) (arg0 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 x) (rand-vu-float-range -1.0 1.0)) + (set! (-> s5-0 y) (rand-vu-float-range -1.0 1.0)) + (set! (-> s5-0 z) (rand-vu-float-range -1.0 1.0)) + (set! (-> s5-0 w) 1.0) + (vector+float*! arg0 arg0 s5-0 4096.0) + ) + (let ((s5-2 (vector-! (new 'stack-no-clear 'vector) arg0 (-> this root trans))) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (vector-normalize! s5-2 1.0) + (set! (-> s3-0 quad) (-> s5-2 quad)) + (set! (-> s3-0 y) 0.0) + (vector-normalize! s3-0 1228.8) + (vector+! s3-0 (-> this root trans) s3-0) + (+! (-> s3-0 y) -819.2) + (let ((s4-1 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> s4-1 ent) (-> this entity)) + (set! (-> s4-1 charge) 1.0) + (set! (-> s4-1 options) (projectile-options)) + (logclear! (-> s4-1 options) (projectile-options po14 po15 po16)) + (set! (-> s4-1 pos quad) (-> s3-0 quad)) + (set! (-> s4-1 notify-handle) (the-as handle #f)) + (set! (-> s4-1 owner-handle) (the-as handle #f)) + (set! (-> s4-1 target-handle) (the-as handle #f)) + (set! (-> s4-1 target-pos quad) (the-as uint128 0)) + (set! (-> s4-1 ignore-handle) (process->handle (send-event *target* 'get-vehicle))) + (let* ((v1-20 *game-info*) + (a0-20 (+ (-> v1-20 attack-id) 1)) + ) + (set! (-> v1-20 attack-id) a0-20) + (set! (-> s4-1 attack-id) a0-20) + ) + (set! (-> s4-1 timeout) (seconds 4)) + (vector-float*! (-> s4-1 vel) s5-2 819200.0) + (the-as (pointer gun-yellow-shot-3) (spawn-projectile gun-yellow-shot-3 s4-1 this *default-dead-pool*)) + ) + ) + ) + +(defmethod projectile-method-32 ((this gun-yellow-3-saucer)) + (if (not (do-fire-backcheck (-> this root trans) (-> this root transv))) + (go (method-of-object this impact-explode)) + (call-parent-method this) + ) + 0 + (none) + ) + +(defmethod find-targets ((this gun-yellow-3-saucer)) + (local-vars + (sv-16 int) + (sv-1072 vector) + (sv-1076 (inline-array target-quality-info-saucer)) + (sv-1080 int) + (sv-1088 float) + (sv-3792 (pointer int8)) + (sv-3800 int) + (sv-3808 float) + (sv-3812 symbol) + ) + (if (not (-> this firing?)) + (return 0) + ) + (sound-play "yellow3-shot" :id (-> this snd-shoot)) + (if (not (time-elapsed? (-> this last-fire-time) (seconds 0.05))) + (return 0) + ) + (set-time! (-> this last-fire-time)) + (when (and (time-elapsed? (-> this last-deduct-ammo-time) (seconds 0.1)) (< (-> this total-ammo-drained) 50.0)) + (+! (-> this total-ammo-drained) (adjust-player-ammo-over-time + (the-as int (- (current-time) (-> this last-deduct-ammo-time))) + (/ 50.0 (* 0.0033333334 (the float (-> this total-fire-time)))) + (pickup-type ammo-yellow) + (- 50.0 (-> this total-ammo-drained)) + ) + ) + (set-time! (-> this last-deduct-ammo-time)) + ) + (set! sv-16 2) + (set! sv-1072 (new 'stack-no-clear 'vector)) + (set! sv-1076 (new 'stack-no-clear 'inline-array 'target-quality-info-saucer 66)) + (set! sv-1080 0) + (set! sv-1088 (the-as float 0.0)) + (set! (-> sv-1072 quad) (-> this root trans quad)) + (set! (-> sv-1072 w) 143360.0) + (let ((s5-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s4-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-1072) s5-0 384)) + (let* ((s3-0 (-> s5-0 s4-0)) + (v1-34 (if (type? s3-0 collide-shape) + s3-0 + ) + ) + ) + (when v1-34 + (let* ((s2-0 (-> v1-34 process)) + (s3-1 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (when s3-1 + (when (and (!= *target* s3-1) + (not (focus-test? (the-as process-focusable s3-1) disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s2-1 (new 'stack-no-clear 'collide-query))) + (set! (-> s2-1 start-pos quad) (-> this root trans quad)) + (vector-! (-> s2-1 move-dist) (get-trans (the-as process-focusable s3-1) 3) (-> this root trans)) + (let ((v1-47 s2-1)) + (set! (-> v1-47 radius) 40.96) + (set! (-> v1-47 collide-with) (collide-spec backgnd)) + (set! (-> v1-47 ignore-process0) #f) + (set! (-> v1-47 ignore-process1) #f) + (set! (-> v1-47 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-47 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* s2-1) 0.0) + (set! (-> sv-1076 sv-1080 targ) (process->handle s3-1)) + (let ((f0-11 1.0)) + (if (and (nonzero? (-> s3-1 draw)) (logtest? (-> s3-1 draw status) (draw-control-status on-screen))) + (set! f0-11 (+ 2.0 f0-11)) + ) + (if (logtest? (process-mask enemy guard) (-> s3-1 mask)) + (set! f0-11 (+ 28.0 f0-11)) + ) + (if (logtest? (process-mask vehicle civilian) (-> s3-1 mask)) + (set! f0-11 (* 0.25 f0-11)) + ) + (set! (-> sv-1076 sv-1080 value) f0-11) + (set! sv-1088 (+ sv-1088 f0-11)) + ) + (set! sv-1080 (+ sv-1080 1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s4-1 *target*) + (s5-1 (if (type? s4-1 process-focusable) + s4-1 + ) + ) + ) + (when (and s5-1 (< (vector-vector-distance (get-trans s5-1 0) sv-1072) (-> sv-1072 w))) + (when (and (!= *target* s5-1) + (not (focus-test? s5-1 disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy vehicle civilian) (-> s5-1 mask)) + (and (logtest? (process-mask guard) (-> s5-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s4-3 (new 'stack-no-clear 'collide-query))) + (set! (-> s4-3 start-pos quad) (-> this root trans quad)) + (vector-! (-> s4-3 move-dist) (get-trans s5-1 3) (-> this root trans)) + (let ((v1-94 s4-3)) + (set! (-> v1-94 radius) 40.96) + (set! (-> v1-94 collide-with) (collide-spec backgnd)) + (set! (-> v1-94 ignore-process0) #f) + (set! (-> v1-94 ignore-process1) #f) + (set! (-> v1-94 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-94 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* s4-3) 0.0) + (set! (-> sv-1076 sv-1080 targ) (process->handle s5-1)) + (let ((f0-16 1.0)) + (if (and (nonzero? (-> s5-1 draw)) (logtest? (-> s5-1 draw status) (draw-control-status on-screen))) + (set! f0-16 (+ 2.0 f0-16)) + ) + (if (logtest? (process-mask enemy guard) (-> s5-1 mask)) + (set! f0-16 (+ 28.0 f0-16)) + ) + (if (logtest? (process-mask vehicle civilian) (-> s5-1 mask)) + (set! f0-16 (* 0.25 f0-16)) + ) + (set! (-> sv-1076 sv-1080 value) f0-16) + (set! sv-1088 (+ sv-1088 f0-16)) + ) + (set! sv-1080 (+ sv-1080 1)) + ) + ) + ) + ) + ) + (set! sv-3792 (new 'stack-no-clear 'array 'int8 100)) + (set! sv-3800 0) + (set! sv-3808 (the-as float 0.0)) + (set! sv-3812 (the-as symbol #f)) + (when (> sv-1080 0) + (dotimes (s5-2 sv-16) + (let ((f0-20 (rand-vu-float-range 0.0 sv-1088))) + (dotimes (v1-127 sv-1080) + (set! sv-3808 (+ sv-3808 (-> sv-1076 v1-127 value))) + (when (< f0-20 sv-3808) + (dotimes (a0-82 sv-3800) + (when (= (-> sv-3792 a0-82) v1-127) + 0 + (goto cfg-91) + ) + ) + (set! (-> sv-3792 sv-3800) v1-127) + (set! sv-3800 (+ sv-3800 1)) + 0 + (goto cfg-94) + ) + (label cfg-91) + ) + ) + (label cfg-94) + ) + ) + (dotimes (s5-3 sv-3800) + (let* ((s4-4 (handle->process (-> sv-1076 (-> sv-3792 s5-3) targ))) + (a0-95 (if (type? s4-4 process-focusable) + s4-4 + ) + ) + (s4-5 this) + (s3-4 (method-of-object s4-5 spawn-shot)) + (s2-2 (new 'stack-no-clear 'vector)) + ) + (set! (-> s2-2 quad) (-> (get-trans (the-as process-focusable a0-95) 0) quad)) + (s3-4 s4-5 s2-2) + ) + ) + (let ((s5-4 sv-3800) + (s4-6 (+ sv-16 -1)) + ) + (while (>= s4-6 s5-4) + (let ((s3-5 (new 'stack-no-clear 'vector))) + (set! (-> s3-5 x) (rand-vu-float-range -1.0 1.0)) + (set! (-> s3-5 y) (rand-vu-float-range -0.85 -0.3)) + (set! (-> s3-5 z) (rand-vu-float-range -1.0 1.0)) + (vector+float*! s3-5 (-> this root trans) s3-5 40960.0) + (spawn-shot this s3-5) + ) + (+! s5-4 1) + ) + ) + (the-as int #f) + ) + +(defskelgroup skel-gun-yellow-3-saucer gun gun-saucer-lod0-jg gun-saucer-idle-ja + ((gun-saucer-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 4096) + :texture-level 10 + :light-index 1 + ) + +(defmethod setup-collision! ((this gun-yellow-3-saucer)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) projectile-bounce-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate explode)) + (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-7 prim-core action) (collide-action solid)) + (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 1638.4) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-7) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-10 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set-collide-with! + (-> this root) + (collide-spec backgnd crate vehicle-sphere hit-by-others-list pusher impenetrable-obj shield) + ) + (set-collide-as! (-> this root) (collide-spec projectile)) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + (none) + ) + +;; WARN: Return type mismatch vector vs none. +(defmethod init-proj-settings! ((this gun-yellow-3-saucer)) + (initialize-skeleton + this + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-yellow-3-saucer" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (let ((t9-2 (method-of-type projectile-bounce init-proj-settings!))) + (t9-2 this) + ) + (set! (-> this move) projectile-move-fill-line-sphere) + (set! (-> this total-float-time) (seconds 0.05)) + (quaternion-identity! (-> this root quat)) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 95) this)) + (set! (-> this asleep?) #t) + (set! (-> this firing?) #f) + (set! (-> this first-fire-time) 0) + (set! (-> this timeout) (seconds 30)) + (set! (-> this activated?) #f) + (set! (-> this collided-with-surface?) #f) + (set! (-> this last-blink-time) 0) + (set! (-> this finished?) #f) + (set! (-> this snd-hum) (new-sound-id)) + (set! (-> this snd-shoot) (new-sound-id)) + (set! (-> this total-ammo-to-drain) 50.0) + (set! (-> this total-fire-time) (seconds 4)) + (when (logtest? (game-secrets gun-upgrade-yellow-3) (-> *game-info* secrets)) + (set! (-> this total-ammo-to-drain) 50.0) + (set! (-> this total-fire-time) (seconds 6)) + ) + (set-vector! (-> this root scale) 3.5 3.5 3.5 1.0) + (none) + ) + +(defmethod deactivate ((this gun-yellow-3-saucer)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (sound-stop (-> this snd-hum)) + (sound-stop (-> this snd-shoot)) + (if (nonzero? (-> this spawn-part)) + (kill-particles (-> this spawn-part)) + ) + (call-parent-method this) + (none) + ) + +(deftype gun-yellow-3-event-msg (structure) + ((activated? symbol) + (finished? symbol) + ) + ) + + +;; WARN: Return type mismatch time-frame vs none. +(defmethod start-firing ((this gun-yellow-3-saucer)) + (set-time! (-> this first-fire-time)) + (set! (-> this firing?) #t) + (set! (-> this last-fire-time) 0) + (set-time! (-> this last-deduct-ammo-time)) + (none) + ) + +;; WARN: Return type mismatch time-frame vs none. +(defmethod init-antigrav ((this gun-yellow-3-saucer)) + (set! (-> this asleep?) #f) + (set! (-> this root dynam gravity y) 0.0) + (set! (-> this root dynam gravity-length) 0.0) + (set! (-> this root dynam gravity-max) 0.0) + (set-time! (-> this last-blink-time)) + (none) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod projectile-method-25 ((this gun-yellow-3-saucer)) + (if (nonzero? (-> this part)) + (spawn (-> this part) (-> this root trans)) + ) + (when (and (nonzero? (-> this part)) (not (-> this finished?))) + ) + (let ((v1-14 (if (< (mod (- (current-time) (-> this last-blink-time)) 300) 150) + 60 + 128 + ) + ) + ) + (set! (-> *part-id-table* 279 init-specs 4 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 280 init-specs 5 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 281 init-specs 5 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 279 init-specs 5 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 280 init-specs 6 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 281 init-specs 6 initial-valuef) (the float v1-14)) + ) + (none) + ) + +(defmethod projectile-bounce-method-42 ((this gun-yellow-3-saucer)) + (projectile-method-25 this) + (none) + ) + +(defstate gun-yellow-3-saucer-base-state (gun-yellow-3-saucer) + :event projectile-event-handler + :trans (behavior () + (if (and (-> self firing?) + (not (and (-> self next-state) (let ((v1-5 (-> self next-state name))) + (or (= v1-5 'falling-down) (= v1-5 'impact-explode)) + ) + ) + ) + (or (< (get-remaining-player-ammo (pickup-type ammo-yellow)) 1.0) + (time-elapsed? (-> self first-fire-time) (-> self total-fire-time)) + ) + ) + (go-virtual falling-down) + ) + ) + :code sleep-code + :post (behavior () + (projectile-method-25 self) + (ja-post) + ) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod projectile-bounce-method-43 ((this gun-yellow-3-saucer)) + (set! (-> this collided-with-surface?) #t) + (none) + ) + +(defun saucer-land-move ((arg0 gun-yellow-3-saucer)) + (seek-toward-heading-vec! (-> arg0 root) (-> arg0 root transv) 131072.0 (seconds 0.1)) + (new 'stack-no-clear 'vector) + (let ((a2-1 (quaternion-identity! (new 'stack-no-clear 'quaternion)))) + (fmin 1.0 (* 0.006666667 (the float (- (current-time) (-> arg0 state-time))))) + (quaternion-smooth-seek! (-> arg0 root quat) (-> arg0 root quat) a2-1 (* 3.5 (seconds-per-frame))) + ) + (projectile-move-fill-all-dirs arg0) + (none) + ) + +(defstate sitting (gun-yellow-3-saucer) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 1)) + (suspend) + ) + (go-virtual burnt-husk) + ) + ) + +(defstate burnt-husk (gun-yellow-3-saucer) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (cond + ((logtest? (-> *part-group-id-table* 97 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 97)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 97)) + ) + ) + (let ((gp-2 sound-play-by-name) + (name (static-sound-name "yellow3-zap")) + (a1-6 (new-sound-id)) + (a2-10 1024) + (a3-4 0) + ) + (gp-2 (the-as sound-name name) a1-6 a2-10 a3-4 0 (sound-group) #t) + (set! (-> self draw color-mult quad) (the-as uint128 0)) + (set! (-> self draw color-mult x) 0.15) + (set! (-> self draw color-mult y) 0.15) + (set! (-> self draw color-mult z) 0.15) + (set! (-> self draw color-emissive quad) (the-as uint128 0)) + (let ((gp-3 (new 'stack-no-clear 'matrix))) + (matrix-u-compose + gp-3 + (vector-y-quaternion! (new 'stack-no-clear 'vector) (-> self root quat)) + (the-as vector a2-10) + (the-as vector a3-4) + ) + (set! (-> gp-3 trans quad) (-> self root trans quad)) + (let ((gp-4 + (ppointer->handle + (if (logtest? (-> *part-group-id-table* 96 flags) (sp-group-flag sp13)) + (part-tracker-spawn + part-tracker-subsampler + :to (-> self parent 0) + :group (-> *part-group-id-table* 96) + :mat-joint gp-3 + ) + (part-tracker-spawn part-tracker :to (-> self parent 0) :group (-> *part-group-id-table* 96) :mat-joint gp-3) + ) + ) + ) + ) + (process-spawn-function + process + (lambda :behavior process + ((arg0 handle)) + (let ((s5-0 (current-time))) + (until (time-elapsed? s5-0 (seconds 0.2)) + (suspend) + ) + ) + (send-event (handle->process arg0) 'die) + ) + gp-4 + :to self + ) + ) + ) + ) + ) + :trans (behavior () + (let* ((f1-2 (* 0.016666668 (the float (- (current-time) (-> self state-time))))) + (f0-2 (fmax 0.0 (fmin 1.0 f1-2))) + ) + (set-vector! (-> self root scale) 3.5 (lerp 3.5 0.0 f0-2) 3.5 1.0) + ) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 0.2)) + (suspend) + ) + (when (type? (-> self root) collide-shape) + (let ((v1-6 (-> self root root-prim))) + (set! (-> v1-6 prim-core collide-as) (collide-spec)) + (set! (-> v1-6 prim-core collide-with) (collide-spec)) + ) + 0 + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (transform-post) + (let ((gp-0 (current-time))) + (until (time-elapsed? gp-0 (seconds 1)) + (suspend) + ) + ) + (deactivate self) + ) + :post ja-post + ) + +(defstate falling-down (gun-yellow-3-saucer) + :virtual #t + :parent gun-yellow-3-saucer-base-state + :enter (behavior () + (set-time! (-> self state-time)) + (set! (-> self finished?) #t) + (set! (-> self move) projectile-bounce-move) + (set! (-> self root dynam gravity y) 184320.0) + (set! (-> self root dynam gravity-length) 184320.0) + (set! (-> self root dynam gravity-max) 184320.0) + (set! (-> self root transv quad) (the-as uint128 0)) + (set-time! (-> self state-time)) + (set! (-> self activated?) #t) + (sound-stop (-> self snd-shoot)) + ) + :exit (behavior () + (set! (-> self move) saucer-land-move) + (sound-stop (-> self snd-hum)) + ) + :trans (behavior () + (if (not (time-elapsed? (-> self state-time) (seconds 0.4))) + (sound-play-by-name + (static-sound-name "yellow3-fire") + (-> self snd-hum) + 1024 + (the int (* 1524.0 (lerp 0.0 -0.5 (* 0.008333334 (the float (- (current-time) (-> self state-time))))))) + 0 + (sound-group) + #t + ) + (sound-stop (-> self snd-hum)) + ) + ((-> (method-of-type projectile moving) trans)) + (when (logtest? (-> self root status) (collide-status touch-surface)) + (sound-play "yellow3-bounce") + (set! (-> self move) saucer-land-move) + ) + (let ((v1-19 gun-yellow-3-saucer-base-state)) + (when v1-19 + (let ((t9-6 (-> v1-19 trans))) + (if t9-6 + (t9-6) + ) + ) + ) + ) + ) + ) + +(defstate impact-explode (gun-yellow-3-saucer) + :virtual #t + :event projectile-event-handler + :enter (behavior () + (set! (-> self activated?) #t) + (sound-stop (-> self snd-hum)) + ) + :code (behavior () + (set! (-> self firing?) #t) + (let ((gp-0 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-0 spawn-point quad) (-> self root trans quad)) + (quaternion-identity! (-> gp-0 spawn-quat)) + (set! (-> gp-0 radius) 0.0) + (set! (-> gp-0 scale) 1.0) + (set! (-> gp-0 group) (-> *part-group-id-table* 104)) + (set! (-> gp-0 collide-with) (collide-spec)) + (set! (-> gp-0 damage) 2.0) + (set! (-> gp-0 damage-scale) 1.0) + (set! (-> gp-0 vehicle-damage-factor) 1.0) + (set! (-> gp-0 vehicle-impulse-factor) 1.0) + (set! (-> gp-0 ignore-proc) (process->handle #f)) + (explosion-spawn gp-0 self) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (while (-> self child) + (suspend) + ) + (deactivate self) + ) + ) + +;; WARN: Return type mismatch symbol vs object. +(defmethod proj-event-handler ((this gun-yellow-3-saucer) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('activate) + (go (method-of-object this spinning)) + ) + (('query) + (let ((v1-3 (the-as gun-yellow-3-event-msg (-> arg3 param 0)))) + (set! (-> v1-3 activated?) (-> this activated?)) + (set! (-> v1-3 finished?) (-> this finished?)) + ) + ) + (else + (call-parent-method this arg0 arg1 arg2 arg3) + ) + ) + #t + ) + +;; WARN: Return type mismatch object vs none. +(defmethod projectile-method-39 ((this gun-yellow-3-saucer)) + (when (logtest? (-> this root status) (collide-status touch-surface)) + (if (-> this asleep?) + (go (method-of-object this impact-explode)) + (call-parent-method this) + ) + ) + (none) + ) + +(defstate moving (gun-yellow-3-saucer) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (if (and (time-elapsed? (-> self state-time) (-> self total-float-time)) + (not (and (-> self next-state) (= (-> self next-state name) 'navigating))) + ) + (go-virtual navigating) + ) + (sound-play "yellow3-fire" :id (-> self snd-hum)) + (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) (* 131072.0 (seconds-per-frame))) + (let ((a0-7 gun-yellow-3-saucer-base-state)) + (when a0-7 + (let ((t9-3 (-> a0-7 trans))) + (if t9-3 + (t9-3) + ) + ) + ) + ) + (let ((t9-5 (-> (find-parent-state) trans))) + (if t9-5 + (t9-5) + ) + ) + (ja-post) + ) + ) + +(defstate navigating (gun-yellow-3-saucer) + :virtual #t + :parent gun-yellow-3-saucer-base-state + :enter (behavior () + (init-antigrav self) + (set-time! (-> self state-time)) + (set! (-> self last-deflect-time) 0) + 0 + ) + :trans (behavior () + (sound-play "yellow3-fire" :id (-> self snd-hum)) + (let ((f0-1 (fmin 1.0 (* 0.033333335 (the float (- (current-time) (-> self state-time))))))) + 0.0 + (let ((f0-2 (lerp 409600.0 40960.0 f0-1))) + (vector-normalize! (-> self root transv) f0-2) + ) + ) + (let ((f0-4 (fmin 1.0 (* 0.004761905 (the float (- (current-time) (-> self state-time))))))) + (set! (-> self root transv y) (lerp (-> self root transv y) 0.0 f0-4)) + ) + (when (time-elapsed? (-> self last-deflect-time) (seconds 0.5)) + (let ((v1-19 (-> self root)) + (gp-0 (new 'stack-no-clear 'collide-query)) + ) + (-> v1-19 root-prim) + (set! (-> gp-0 start-pos quad) (-> v1-19 trans quad)) + (vector-normalize-copy! (-> gp-0 move-dist) (-> v1-19 transv) 40960.0) + (let ((v1-20 gp-0)) + (set! (-> v1-20 radius) 0.01) + (set! (-> v1-20 collide-with) (collide-spec backgnd)) + (set! (-> v1-20 ignore-process0) #f) + (set! (-> v1-20 ignore-process1) #f) + (set! (-> v1-20 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-20 action-mask) (collide-action solid)) + ) + (let ((f0-7 (fill-and-probe-using-line-sphere *collide-cache* gp-0))) + (when (and (>= f0-7 0.0) (< f0-7 1.0)) + (let ((s5-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> gp-0 best-other-tri normal) 1.0)) + (gp-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> self root transv) 1.0)) + ) + 0.0 + (set! (-> s5-0 y) 0.0) + (vector-normalize! s5-0 1.0) + (vector-dot s5-0 gp-1) + (cond + (#f + (vector-float*! (-> self root transv) (-> self root transv) -1.0) + ) + (else + (vector-reflect! gp-1 gp-1 s5-0) + (set! (-> gp-1 y) 0.0) + (vector-normalize-copy! (-> self root transv) gp-1 32768.0) + (set-time! (-> self last-deflect-time)) + ) + ) + ) + ) + ) + ) + ) + (when (not (-> self firing?)) + (cond + ((time-elapsed? (-> self state-time) (seconds 1)) + (start-firing self) + ) + (else + ) + ) + ) + (find-targets self) + ((-> self move) self) + (projectile-method-39 self) + (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) (* 131072.0 (seconds-per-frame))) + (let ((v1-52 gun-yellow-3-saucer-base-state)) + (when v1-52 + (let ((t9-16 (-> v1-52 trans))) + (if t9-16 + (t9-16) + ) + ) + ) + ) + ) + ) + +(defstate spinning (gun-yellow-3-saucer) + :virtual #t + :parent gun-yellow-3-saucer-base-state + :enter (behavior () + (set! (-> self activated?) #t) + (if (-> self asleep?) + (init-antigrav self) + ) + (if (not (-> self firing?)) + (start-firing self) + ) + (quaternion-identity! (-> self root quat)) + ) + :exit (behavior () + (let ((f0-0 (get-remaining-player-ammo (pickup-type ammo-yellow)))) + 0.0 + (when (< 1.0 f0-0) + (let* ((f0-1 (fmin f0-0 (- 50.0 (-> self total-ammo-drained)))) + (f0-2 (fmax 0.0 f0-1)) + ) + (adjust-player-ammo (- f0-2) (pickup-type ammo-yellow)) + ) + (truncate-player-ammo (pickup-type ammo-yellow)) + ) + ) + ) + :trans (behavior () + (sound-play "yellow3-fire" :id (-> self snd-hum)) + (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) (* 131072.0 (seconds-per-frame))) + (find-targets self) + (let ((v1-7 gun-yellow-3-saucer-base-state)) + (when v1-7 + (let ((t9-3 (-> v1-7 trans))) + (if t9-3 + (t9-3) + ) + ) + ) + ) + ) + ) + +(defbehavior gun-fire-yellow-3 target () + (let ((gp-0 (-> self gun))) + (let ((s5-0 (-> self gun fire-dir-out)) + (s4-0 (-> self gun fire-point)) + (f30-0 409600.0) + ) + (talker-spawn-func (-> *talker-speech* 364) *entity-pool* (target-pos 0) (the-as region #f)) + (set! (-> s5-0 y) 0.6) + (vector-normalize! s5-0 1.0) + (when (handle->process (-> gp-0 gun 0 extra)) + (let ((s3-1 (new 'stack-no-clear 'gun-yellow-3-event-msg))) + (send-event (handle->process (-> gp-0 gun 0 extra)) 'query s3-1) + (when (not (-> s3-1 activated?)) + (send-event (handle->process (-> gp-0 gun 0 extra)) 'activate) + (return 0) + ) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 229 (seconds 0.2)) + (let ((s3-2 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> s3-2 ent) (-> self entity)) + (set! (-> s3-2 charge) 1.0) + (set! (-> s3-2 options) (projectile-options po13)) + (logclear! (-> s3-2 options) (projectile-options po14 po15 po16)) + (set! (-> s3-2 pos quad) (-> s4-0 quad)) + (set! (-> s3-2 vel quad) (-> (vector-float*! (new 'stack-no-clear 'vector) s5-0 f30-0) quad)) + (set! (-> s3-2 notify-handle) (the-as handle #f)) + (set! (-> s3-2 owner-handle) (the-as handle #f)) + (set! (-> s3-2 target-handle) (the-as handle #f)) + (set! (-> s3-2 target-pos quad) (the-as uint128 0)) + (set! (-> s3-2 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-45 *game-info*) + (a0-30 (+ (-> v1-45 attack-id) 1)) + ) + (set! (-> v1-45 attack-id) a0-30) + (set! (-> s3-2 attack-id) a0-30) + ) + (set! (-> s3-2 timeout) (seconds 4)) + (set! (-> gp-0 gun 0 extra) + (ppointer->handle + (spawn-projectile gun-yellow-3-saucer s3-2 (ppointer->process (-> gp-0 gun)) *default-dead-pool*) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> self gun fire-dir-out quad)) + (set! (-> s4-1 y) 0.0) + (vector-normalize! s4-1 1.0) + (let ((t9-9 draw-beam) + (a0-38 (-> *part-id-table* 297)) + (a1-9 (-> gp-0 fire-point)) + (a2-5 s4-1) + ) + (t9-9 a0-38 a1-9 a2-5 #f) + (let ((s5-1 (new 'stack-no-clear 'matrix))) + (matrix-f-compose s5-1 s4-1 (the-as float a2-5)) + (set! (-> s5-1 trans quad) (-> gp-0 fire-point quad)) + (let ((v1-62 + (if (logtest? (-> *part-group-id-table* 100 flags) (sp-group-flag sp13)) + (part-tracker-spawn + part-tracker-subsampler + :to *entity-pool* + :group (-> *part-group-id-table* 100) + :mat-joint s5-1 + ) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 100) :mat-joint s5-1) + ) + ) + ) + (send-event (ppointer->process v1-62) 'clock self) + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch (pointer process) vs (pointer gun-yellow-shot-2). +(defbehavior gun-fire-yellow-2 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 po17)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-12 *game-info*) + (a0-10 (+ (-> v1-12 attack-id) 1)) + ) + (set! (-> v1-12 attack-id) a0-10) + (set! (-> gp-0 attack-id) a0-10) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (vector-float*! (-> gp-0 vel) (-> s5-0 fire-dir-out) 819200.0) + (the-as + (pointer gun-yellow-shot-2) + (spawn-projectile gun-yellow-shot-2 gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*) + ) + ) + ) + +;; WARN: Return type mismatch (pointer process) vs (pointer gun-yellow-shot). +(defbehavior gun-fire-yellow-1 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 po17)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-12 *game-info*) + (a0-10 (+ (-> v1-12 attack-id) 1)) + ) + (set! (-> v1-12 attack-id) a0-10) + (set! (-> gp-0 attack-id) a0-10) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (vector-float*! (-> gp-0 vel) (-> s5-0 fire-dir-out) 819200.0) + (the-as + (pointer gun-yellow-shot) + (spawn-projectile gun-yellow-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*) + ) + ) + ) + +;; WARN: disable def twice: 51. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defbehavior target-gun-can-fire-yellow? target ((arg0 pickup-type)) + (case arg0 + (((pickup-type gun-yellow-3)) + (cond + ((handle->process (-> self gun gun 0 extra)) + (let ((gp-0 (new 'stack-no-clear 'gun-yellow-3-event-msg))) + (set! (-> gp-0 finished?) #t) + (set! (-> gp-0 activated?) #f) + (send-event (handle->process (-> self gun gun 0 extra)) 'query gp-0) + (or (-> gp-0 finished?) (not (-> gp-0 activated?))) + ) + ) + (else + #t + ) + ) + ) + (else + #t + ) + ) + ) + +;; WARN: Return type mismatch object vs (pointer process). +(defbehavior target-gun-fire-yellow target ((arg0 pickup-type)) + (the-as (pointer process) (case arg0 + (((pickup-type gun-yellow-1)) + (gun-fire-yellow-1) + ) + (((pickup-type gun-yellow-2)) + (gun-fire-yellow-2) + ) + (((pickup-type gun-yellow-3)) + (gun-fire-yellow-3) + ) + ) + ) + ) + +(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 po13 po17)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle arg0)) + (let* ((v1-10 *game-info*) + (a0-9 (+ (-> v1-10 attack-id) 1)) + ) + (set! (-> v1-10 attack-id) a0-9) + (set! (-> gp-0 attack-id) a0-9) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (vector-normalize-copy! (-> gp-0 vel) arg2 819200.0) + (spawn-projectile gun-yellow-shot-2 gp-0 arg0 *default-dead-pool*) + ) + ) + +(defmethod projectile-method-24 ((this gun-yellow-shot)) + (draw-beam (-> this muzzle-flash-part) (-> this tail-pos) (-> this starting-dir) #f) + 0 + (none) + ) + +(defmethod projectile-method-25 ((this gun-yellow-shot)) + (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 (-> this root trans)) + (a1-0 (-> this tail-pos)) + (gp-1 (vector-! (new 'stack-no-clear 'vector) s4-0 a1-0)) + ) + (let ((f30-0 (vector-length gp-1))) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (let ((v1-4 a1-0)) + (let ((a0-2 gp-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 (&-> s3-0 quad) vf6) + (draw-main-shot this a1-0 gp-1) + (vector-normalize! gp-1 1.0) + (spawn-particles this s3-0) + ) + (let ((s3-1 (new 'stack-no-clear 'matrix)) + (f30-1 (fmin 1.0 (* 0.000015258789 f30-0))) + (f28-0 (-> *part-id-table* 267 init-specs 3 initial-valuef)) + ) + (forward-up->inv-matrix s3-1 gp-1 *up-vector*) + (set! (-> s3-1 trans quad) (-> s4-0 quad)) + (gun-yellow-shot-method-42 this f30-1 f28-0 s3-1) + ) + ) + (let ((f0-3 (vector-dot gp-1 (-> (camera-matrix) fvec)))) + (when (< 0.0 f0-3) + (let ((f2-0 (* f0-3 f0-3)) + (f0-4 (-> *part-id-table* 266 init-specs 8 initial-valuef)) + (f1-3 (-> *part-id-table* 266 init-specs 8 random-rangef)) + ) + (set! (-> *part-id-table* 266 init-specs 8 initial-valuef) (* f0-4 f2-0)) + (set! (-> *part-id-table* 266 init-specs 8 random-rangef) (* f1-3 f2-0)) + (set! (-> *part-id-table* 266 init-specs 8 initial-valuef) f0-4) + (set! (-> *part-id-table* 266 init-specs 8 random-rangef) f1-3) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod deal-damage! ((this gun-yellow-shot) (arg0 process) (arg1 event-message-block)) + (if (and (logtest? (process-mask guard) (-> arg0 mask)) + (not (-> *setting-control* user-current gun-target-guards?)) + ) + (set! (-> this damage) 0.0) + ) + (let ((t9-0 (method-of-type projectile deal-damage!))) + (when (t9-0 this arg0 arg1) + (+! (-> *game-info* shots-hit 0) 1.0) + (set! (-> this hit-actor?) #t) + #t + ) + ) + ) + +(defmethod projectile-method-26 ((this gun-yellow-shot)) + (let ((v1-8 + (cond + ((-> this hit-actor?) + (cond + ((logtest? (-> *part-group-id-table* 102 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + ) + ) + ((logtest? (-> *part-group-id-table* 101 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 101)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 101)) + ) + ) + ) + ) + (send-event (ppointer->process v1-8) 'clock this) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch sound-id vs none. +(defmethod play-impact-sound ((this gun-yellow-shot) (arg0 projectile-options)) + (let ((v1-0 arg0)) + (cond + ((zero? v1-0) + (sound-play "yellow-shot-fir") + ) + ((= v1-0 (projectile-options po0)) + (sound-play "yellow-gun-burn") + ) + ((= v1-0 (projectile-options po1)) + (sound-play "yellow-shot-fiz") + ) + (else + (sound-play "yellow-shot-std" :id (-> this sound-id) :position (-> this root trans)) + ) + ) + ) + (none) + ) + +(defmethod play-impact-sound ((this gun-yellow-shot-3) (arg0 projectile-options)) + 0 + (none) + ) + +(defmethod play-impact-sound ((this gun-yellow-shot-2) (arg0 projectile-options)) + (let ((v1-0 arg0)) + (cond + ((zero? v1-0) + (sound-play "yellow2-fire") + ) + ((= v1-0 (projectile-options po0)) + (sound-play "yellow2-burn") + ) + ((= v1-0 (projectile-options po1)) + ) + ((not (-> this hit-yet?)) + (sound-play-by-name + (static-sound-name "yellow2-trail") + (-> this snd-trail) + 1024 + (the int + (* 1524.0 + (lerp 1.0 0.1 (fmax 0.0 (fmin 1.0 (* 0.011111111 (the float (- (current-time) (-> this last-hit-time))))))) + ) + ) + 0 + (sound-group) + #t + ) + ) + (else + (sound-play-by-name + (static-sound-name "yellow2-trail") + (-> this snd-trail) + 1024 + (the int (* 1524.0 (doppler-pitch-shift (-> this root trans) (-> this root transv)))) + 0 + (sound-group) + #t + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod made-impact? ((this gun-yellow-shot)) + (let ((v1-0 (-> this root)) + (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) this) + (set! (-> a0-1 ignore-process1) (handle->process (-> this ignore-handle))) + (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? (-> this root status) (collide-status touch-actor)) + (set! (-> this hit-actor?) #t) + ) + #t + ) + ) + ) + +(defun gun-yellow-shot-move ((arg0 gun-yellow-shot)) + (projectile-move-fill-line-sphere arg0) + (let ((s5-0 (-> arg0 root))) + (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 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) a1-5) + ) + (go (method-of-object arg0 impact)) + ) + ) + 0 + (none) + ) + +(define *last-hit-deflect-target-handle* (the-as (pointer process) #f)) + +;; WARN: Return type mismatch symbol vs none. +(defbehavior gun-yellow-shot-do-deflect gun-yellow-shot-2 ((arg0 gun-yellow-shot-2) (arg1 vector) (arg2 vector) (arg3 vector)) + (local-vars + (sv-32 vector) + (sv-36 gun-yellow-shot-2) + (sv-40 process) + (sv-80 vector) + (sv-84 vector) + (sv-112 vector) + (sv-116 number) + (sv-120 int) + (sv-128 symbol) + (sv-136 handle) + (sv-1680 vector) + (sv-1712 vector) + (sv-1716 float) + (sv-1720 float) + (sv-1724 vector) + (sv-1744 vector) + (sv-1748 float) + (sv-1752 float) + ) + (let ((f0-1 (vector-dot arg2 arg3))) + (set! sv-32 (vector-float*! (new 'stack-no-clear 'vector) arg3 (* -2.0 f0-1))) + ) + (vector+! arg1 arg2 sv-32) + (if (< 0.2 (-> arg1 y)) + (set! (-> arg1 y) (fmax 0.2 (-> arg2 y))) + ) + (let ((s4-0 arg0)) + (set! sv-36 s4-0) + (set! sv-40 (handle->process (-> sv-36 last-hit-enemy))) + (when (and (time-elapsed? (-> sv-36 last-collide-time) (seconds 0.05)) (rand-vu-percent? 0.75)) + (set! sv-80 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg1 204800.0)) + (set! sv-84 (new 'stack-no-clear 'vector)) + (set! (-> sv-84 quad) (-> s4-0 root trans quad)) + (vector+! sv-84 sv-84 sv-80) + (set! (-> sv-84 w) 409600.0) + (set! (-> sv-80 y) 0.0) + (vector-normalize! sv-80 1.0) + (set! sv-112 (vector+! (new 'stack-no-clear 'vector) (-> s4-0 root trans) arg1)) + (set! sv-116 409600000000000000000000.0) + (set! sv-120 -55041728) + (set! sv-128 (the-as symbol #f)) + (set! sv-136 (the-as handle #f)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-84) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-31 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-31 + (let* ((s0-0 (-> v1-31 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= s4-0 s1-1) + (!= s1-1 sv-40) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy civilian) (-> s1-1 mask)) + (and (logtest? (process-mask guard) (-> s1-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (when (or (not sv-128) + (logtest? (process-mask enemy guard) (-> s1-1 mask)) + (not (is-in-ignore-list? sv-36 (process->handle s1-1))) + ) + (set! sv-1680 (get-trans (the-as process-focusable s1-1) 3)) + (set! sv-1712 (vector-! (new 'stack-no-clear 'vector) sv-1680 (-> s4-0 root trans))) + (set! sv-1716 (the-as float 0.0)) + (set! (-> sv-1712 y) 0.0) + (set! sv-1720 (vector-normalize-ret-len! sv-1712 1.0)) + (set! sv-1716 (vector-dot sv-1712 sv-80)) + (when (or (< (the float sv-120) sv-1716) (and (< 0.707 sv-1716) (= sv-136 *last-hit-deflect-target-handle*))) + (set! sv-116 sv-1720) + (set! sv-120 (the int sv-1716)) + (set! (-> sv-112 quad) (-> sv-1680 quad)) + (set! sv-128 (logtest? (process-mask enemy) (-> s1-1 mask))) + (set! sv-136 (process->handle s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) sv-84) (-> sv-84 w))) + (when (and (!= s4-0 s3-1) + (!= s3-1 sv-40) + (not (focus-test? s3-1 disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (when (or (not sv-128) + (logtest? (process-mask enemy guard) (-> s3-1 mask)) + (not (is-in-ignore-list? sv-36 (process->handle s3-1))) + ) + (set! sv-1724 (get-trans s3-1 3)) + (set! sv-1744 (vector-! (new 'stack-no-clear 'vector) sv-1724 (-> s4-0 root trans))) + (set! sv-1748 (the-as float 0.0)) + (set! (-> sv-1744 y) 0.0) + (set! sv-1752 (vector-normalize-ret-len! sv-1744 1.0)) + (set! sv-1748 (vector-dot sv-1744 sv-80)) + (when (or (< (the float sv-120) sv-1748) (and (< 0.707 sv-1748) (= sv-136 *last-hit-deflect-target-handle*))) + (set! sv-116 sv-1752) + (set! sv-120 (the int sv-1748)) + (set! (-> sv-112 quad) (-> sv-1724 quad)) + (set! sv-128 (logtest? (process-mask enemy) (-> s3-1 mask))) + (set! sv-136 (process->handle s3-1)) + ) + ) + ) + ) + ) + (vector-! arg1 sv-112 (-> s4-0 root trans)) + (set! *last-hit-deflect-target-handle* (the-as (pointer process) sv-136)) + ) + ) + (vector-normalize! arg1 546133.3) + (cond + ((time-elapsed? (-> arg0 last-hit-time) (seconds 0.3)) + ) + ((time-elapsed? (-> arg0 last-hit-time) (seconds 0.05)) + ) + ) + (sound-play "yellow2-ricco") + (set-time! (-> arg0 last-hit-time)) + (set! (-> arg0 hit-yet?) #t) + (none) + ) + +(defun gun-yellow-deflect-reaction ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector)) + (cshape-reaction-update-state arg0 arg1 arg3) + (let ((s3-0 (the-as handle #f))) + (when (and (nonzero? (-> arg1 best-other-tri collide-ptr)) + (-> arg1 best-other-tri collide-ptr) + (let ((s1-0 (-> arg1 best-other-tri collide-ptr))) + (if (type? s1-0 collide-shape-prim) + s1-0 + ) + ) + ) + (let* ((s2-1 (-> arg1 best-other-tri collide-ptr)) + (a0-4 (if (type? s2-1 collide-shape-prim) + s2-1 + ) + ) + (v1-4 a0-4) + ) + (when v1-4 + (set! s3-0 (process->handle (-> (the-as collide-shape-prim a0-4) cshape process))) + (when (and (logtest? (collide-spec obstacle pusher) (-> (the-as collide-shape-prim v1-4) prim-core collide-as)) + (not (logtest? (collide-spec civilian enemy vehicle-sphere vehicle-mesh-probeable) + (-> (the-as collide-shape-prim v1-4) prim-core collide-as) + ) + ) + ) + (let ((v1-7 (-> arg0 process))) + (set! (-> (the-as gun-yellow-shot-2 v1-7) actor-deflect?) #t) + ) + (set! s3-0 (the-as handle #f)) + ) + ) + ) + ) + (let ((s2-2 (the-as gun-yellow-shot-2 (-> arg0 process)))) + (on-impact s2-2 s3-0) + (set! (-> s2-2 delay-attack) 0) + ) + ) + 0 + (gun-yellow-shot-do-deflect (the-as gun-yellow-shot-2 (-> arg0 process)) arg2 arg3 (-> arg0 surface-normal)) + (-> arg0 status) + ) + +(defmethod setup-collision! ((this gun-yellow-shot)) + (let ((s5-0 (new 'process 'collide-shape-moving this (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 pusher shield) + ) + (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 pusher shield) + ) + (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 pusher shield) + ) + (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! (-> this root) s5-0) + ) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + 0 + (none) + ) + +(defmethod deal-damage! ((this gun-yellow-shot-2) (arg0 process) (arg1 event-message-block)) + (if (> (-> this max-actor-deflect-count) 0) + ((method-of-type projectile deal-damage!) this arg0 arg1) + ) + ) + +(defun gun-yellow-shot-2-move ((arg0 gun-yellow-shot-2)) + (with-pp + (projectile-move-fill-line-sphere arg0) + (let ((s5-0 (-> arg0 root))) + (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 (not (handle->process (-> arg0 last-hit-enemy))) + (set! (-> arg0 delay-attack) 0) + 0 + ) + (if (and (> (-> arg0 delay-attack) 0) (time-elapsed? (-> arg0 delay-attack) (seconds 0.1))) + (logior! (-> s5-0 status) (collide-status touch-actor)) + ) + (when (or (logtest? (-> s5-0 status) (collide-status touch-surface)) + (logtest? (-> s5-0 status) (collide-status touch-actor)) + ) + (let ((s2-0 #f) + (s3-0 #f) + (s4-1 (the-as object #f)) + ) + (when (logtest? (-> s5-0 status) (collide-status touch-actor)) + (cond + ((-> arg0 actor-deflect?) + (set! (-> arg0 actor-deflect?) #f) + ) + ((> (-> arg0 max-actor-deflect-count) 0) + (let ((a0-16 (handle->process (-> arg0 last-hit-enemy)))) + (when a0-16 + (set! s2-0 #t) + (let ((a1-5 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-5 from) (process->ppointer pp)) + (set! (-> a1-5 num-params) 0) + (set! (-> a1-5 message) 'prevent-bounce?) + (set! s4-1 (send-event-function a0-16 a1-5)) + ) + ) + ) + ) + (else + (set! s4-1 #t) + ) + ) + ) + (when s2-0 + (when (> (-> arg0 delay-attack) 0) + ) + (handle-impact arg0 (-> arg0 last-hit-enemy)) + ) + (if (and (> (-> arg0 delay-attack) 0) (and (time-elapsed? (-> arg0 delay-attack) (seconds 0.1)) s2-0 (not s4-1))) + (set! s3-0 #t) + ) + (when s3-0 + (let ((t9-4 gun-yellow-shot-do-deflect) + (a0-23 arg0) + (a1-7 (-> arg0 root transv)) + (a2-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a2-1 quad) (-> arg0 root transv quad)) + (t9-4 a0-23 a1-7 a2-1 (-> arg0 delay-norm)) + ) + ) + (set! (-> arg0 hit-actor?) (the-as symbol s4-1)) + ) + (set! (-> arg0 delay-attack) 0) + (let ((v1-57 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> arg0 tail-pos) (-> s5-0 trans)) 2048.0)) + (a1-10 (-> arg0 hit-pos)) + ) + (set! (-> a1-10 quad) (-> s5-0 trans quad)) + (vector+! a1-10 a1-10 v1-57) + (move-to-point! (-> arg0 root) a1-10) + ) + (cond + ((-> arg0 hit-actor?) + (go (method-of-object arg0 impact)) + ) + (else + (set-time! (-> arg0 last-collide-time)) + (launch-particles (-> *part-id-table* 272) (-> arg0 hit-pos)) + (launch-particles (-> *part-id-table* 273) (-> arg0 hit-pos)) + (let ((a0-32 (new 'stack-no-clear 'vector))) + (set! (-> a0-32 quad) (-> arg0 root transv quad)) + (vector-normalize! a0-32 65536.0) + ) + (vector+! (-> arg0 tail-pos) (-> arg0 root trans) (-> arg0 root transv)) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod init-proj-settings! ((this gun-yellow-shot)) + (+! (-> *game-info* shots-fired 0) 1.0) + (set! (-> this hit-actor?) #f) + (set! (-> this tail-pos quad) (-> this root trans quad)) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (set! (-> this attack-mode) 'eco-yellow) + (set! (-> this max-speed) 819200.0) + (set! (-> this move) gun-yellow-shot-move) + (set! (-> this timeout) (seconds 3)) + (set! (-> this sound-id) (new-sound-id)) + (set! (-> this damage) 2.0) + (if (logtest? (game-secrets gun-upgrade-yellow-1) (-> *game-info* secrets)) + (set! (-> this damage) 3.0) + ) + (logior! (-> this options) (projectile-options po13)) + (set! (-> this muzzle-flash-part) (-> *part-id-table* 268)) + (set! (-> this main-shot-part) (-> *part-id-table* 264)) + (set! (-> this shot-aim-part) (-> *part-id-table* 267)) + (set! (-> this shot-ring-part) (-> *part-id-table* 266)) + 0 + (none) + ) + +;; WARN: Return type mismatch (pointer process) vs none. +(defmethod init-proj-settings! ((this gun-yellow-shot-2)) + (call-parent-method this) + (set! (-> this actor-deflect?) #f) + (set! (-> this last-hit-enemy) (the-as handle #f)) + (set! (-> this damage) 1.5) + (if (logtest? (game-secrets gun-upgrade-yellow-2) (-> *game-info* secrets)) + (set! (-> this damage) 2.0) + ) + (set! (-> this snd-trail) (new-sound-id)) + (set! (-> this hit-yet?) #f) + (sound-play "yellow2-trail" :id (-> this snd-trail) :pitch 1) + (set! (-> this last-collide-time) 0) + (set! (-> this move) gun-yellow-shot-2-move) + (set! (-> this snd-whoosh) (new-sound-id)) + (dotimes (v1-9 6) + (set! (-> this ignore-list v1-9 hand) (the-as handle #f)) + ) + (set! (-> this max-actor-deflect-count) 4) + (set! (-> this timeout) (seconds 3)) + (when (logtest? (game-secrets gun-upgrade-yellow-2) (-> *game-info* secrets)) + (set! (-> this max-actor-deflect-count) 7) + (set! (-> this timeout) (seconds 5)) + ) + (set! (-> this muzzle-flash-part) (-> *part-id-table* 274)) + (sound-play "yellow2-shot" :pitch 1) + (let ((s5-1 (new 'stack-no-clear 'light-trail-tracker-spawn-params))) + (set! (-> s5-1 tracked-obj) (process->handle this)) + (set! (-> s5-1 appearance) *yellow-shot-2-trail*) + (set! (-> s5-1 max-num-crumbs) (the int (* 0.25 (the float (-> s5-1 appearance max-age))))) + (set! (-> s5-1 track-immediately?) #t) + (let* ((v1-34 (estimate-light-trail-mem-usage + (the-as uint (-> s5-1 max-num-crumbs)) + (the-as uint (= (-> s5-1 appearance lie-mode) 3)) + ) + ) + (gp-1 (get-process *default-dead-pool* light-trail-tracker-projectile (+ v1-34 8192) 1)) + ) + (when gp-1 + (let ((t9-9 (method-of-type process activate))) + (t9-9 gp-1 *target* "light-trail" (the-as pointer #x70004000)) + ) + (run-now-in-process gp-1 light-trail-tracker-init-by-other s5-1) + (-> gp-1 ppointer) + ) + ) + ) + (none) + ) + +(defmethod add-to-ignore-list! ((this gun-yellow-shot-2) (arg0 handle)) + (when (and arg0 (not (is-in-ignore-list? this arg0))) + (dotimes (v1-3 6) + (when (not (handle->process (-> this ignore-list v1-3 hand))) + (set! (-> this ignore-list v1-3 hand) arg0) + (set-time! (-> this ignore-list v1-3 time)) + (return 0) + ) + ) + (the-as int #f) + ) + ) + +(defmethod is-in-ignore-list? ((this gun-yellow-shot-2) (arg0 handle)) + (if (not arg0) + (return #f) + ) + (dotimes (v1-2 6) + (if (and (-> this ignore-list v1-2 hand) (time-elapsed? (-> this ignore-list v1-2 time) (seconds 0.15))) + (set! (-> this ignore-list v1-2 hand) (the-as handle #f)) + ) + ) + (dotimes (v1-5 6) + (if (= arg0 (-> this ignore-list v1-5 hand)) + (return #t) + ) + ) + #f + ) + +;; WARN: Return type mismatch int vs object. +(defmethod handle-impact ((this gun-yellow-shot-2) (arg0 handle)) + (when (> (-> this max-actor-deflect-count) 0) + (let ((s5-0 (handle->process arg0))) + (when s5-0 + (if (and (logtest? (process-mask guard) (-> s5-0 mask)) + (not (-> *setting-control* user-current gun-target-guards?)) + ) + (set! (-> this damage) 0.0) + ) + (when (time-elapsed? (-> this last-attack-time) (seconds 0.25)) + (let* ((v1-15 *game-info*) + (a0-7 (+ (-> v1-15 attack-id) 1)) + ) + (set! (-> v1-15 attack-id) a0-7) + (set! (-> this attack-id) a0-7) + ) + ) + (when (deal-damage! this s5-0 (the-as event-message-block #f)) + (set-time! (-> this last-attack-time)) + (+! (-> this enemy-hit-count) 1) + (when (and (< 1 (-> this enemy-hit-count)) (< (-> this enemy-hit-count) 4)) + (adjust-player-ammo -1.0 (pickup-type ammo-yellow)) + (when (>= 0.0 (get-remaining-player-ammo (pickup-type ammo-yellow))) + (set! (-> this timeout) 0) + 0 + ) + ) + (let ((v1-28 (-> this notify-handle))) + (send-event (handle->process v1-28) 'notify 'attack s5-0) + ) + (if (>= (-> this enemy-hit-count) 1) + (set! (-> this damage) 1.0) + ) + (cond + ((logtest? (-> *part-group-id-table* 102 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + ) + (let ((v0-0 (+ (-> this max-actor-deflect-count) -1))) + (set! (-> this max-actor-deflect-count) v0-0) + v0-0 + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch int vs object. +(defmethod on-impact ((this gun-yellow-shot-2) (arg0 handle)) + (let ((a1-1 (-> this last-hit-enemy))) + (set! (-> this last-hit-enemy) arg0) + (if (and (!= a1-1 arg0) (> (-> this delay-attack) 0)) + (handle-impact this a1-1) + ) + ) + (set! (-> this delay-attack) 0) + (add-to-ignore-list! this arg0) + ) + +(defmethod handle-proj-hit! ((this gun-yellow-shot-2) (arg0 process) (arg1 event-message-block)) + (cond + ((-> this hit-actor?) + (call-parent-method this arg0 arg1) + ) + (else + (let ((s4-1 (the-as object (-> arg1 param 0)))) + (when (and (!= arg0 (handle->process (-> this last-hit-enemy))) + (!= arg0 (send-event *target* 'get-vehicle)) + (not (is-in-ignore-list? this (process->handle arg0))) + ) + (new 'stack-no-clear 'vector) + (let ((s3-0 (-> this delay-norm)) + (s1-0 (-> (the-as touching-shapes-entry s4-1) head)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (get-intersect-point s2-0 s1-0 (-> this root) (the-as touching-shapes-entry s4-1)) + (let ((v1-16 + (get-touched-prim + s1-0 + ((method-of-type touching-shapes-entry get-touched-shape) (the-as touching-shapes-entry s4-1) (-> this root)) + (the-as touching-shapes-entry s4-1) + ) + ) + ) + (when v1-16 + (vector-! s3-0 s2-0 (the-as vector (-> v1-16 prim-core))) + (vector-normalize! s3-0 1.0) + (on-impact this (process->handle arg0)) + (set-time! (-> this delay-attack)) + ) + ) + ) + ) + ) + #t + ) + ) + ) + +(defstate impact (gun-yellow-shot-2) + :virtual #t + :enter (behavior () + (sound-stop (-> self snd-trail)) + (let ((t9-2 (-> (find-parent-state) enter))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + +;; WARN: Return type mismatch sparticle-launcher vs none. +(defmethod init-proj-settings! ((this gun-yellow-shot-3)) + (+! (-> *game-info* shots-fired 0) 1.0) + (set! (-> this hit-actor?) #f) + (set! (-> this tail-pos quad) (-> this root trans quad)) + (let ((f0-2 (vector-vector-xz-distance (target-pos 0) (-> this root trans)))) + (cpad-set-buzz! + (-> *cpad-list* cpads 0) + 1 + (the int (* 255.0 (lerp-scale-clamp 0.5 0.0 f0-2 40960.0 245760.0))) + (seconds 0.1) + ) + ) + (set! (-> this attack-mode) 'eco-yellow) + (set! (-> this max-speed) 819200.0) + (set! (-> this move) gun-yellow-shot-move) + (set! (-> this timeout) (seconds 3)) + (set! (-> this sound-id) (new-sound-id)) + (set! (-> this damage) 2.0) + (when (logtest? (game-feature feature22) (-> *game-info* features)) + (set! (-> this damage) (* 2.0 (-> this damage))) + (set! (-> this vehicle-impulse-factor) (* 0.5 (-> this vehicle-impulse-factor))) + ) + (logior! (-> this options) (projectile-options po13)) + (set! (-> this muzzle-flash-part) (-> *part-id-table* 275)) + (set! (-> this main-shot-part) (-> *part-id-table* 276)) + (set! (-> this shot-aim-part) (-> *part-id-table* 278)) + (set! (-> this shot-ring-part) (-> *part-id-table* 266)) + (none) + ) + +(defmethod setup-collision! ((this gun-yellow-shot-2)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) gun-yellow-deflect-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate)) + (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 pusher shield) + ) + (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-12 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-12 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-12 prim-core collide-with) + (collide-spec backgnd bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher shield) + ) + (set! (-> v1-12 prim-core action) (collide-action solid)) + (set-vector! (-> v1-12 local-sphere) 0.0 0.0 0.0 819.2) + ) + (let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-14 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-14 prim-core collide-with) + (collide-spec bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher shield) + ) + (set-vector! (-> v1-14 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-17 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-17 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-17 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + 0 + (none) + ) + +(defmethod draw-main-shot ((this gun-yellow-shot) (arg0 vector) (arg1 vector)) + (let ((f30-0 (-> *part-id-table* 264 init-specs 4 initial-valuef))) + (set! (-> *part-id-table* 264 init-specs 4 initial-valuef) (fmin f30-0 (vector-length arg1))) + (draw-beam (-> this main-shot-part) arg0 arg1 #f) + (set! (-> *part-id-table* 264 init-specs 4 initial-valuef) f30-0) + ) + 0 + (none) + ) + +(defmethod draw-main-shot ((this gun-yellow-shot-2) (arg0 vector) (arg1 vector)) + 0 + (none) + ) + +(defmethod deactivate ((this gun-yellow-shot-2)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (sound-stop (-> this snd-trail)) + (call-parent-method this) + (none) + ) + +(defmethod draw-main-shot ((this gun-yellow-shot-3) (arg0 vector) (arg1 vector)) + (let ((f30-0 (-> *part-id-table* 276 init-specs 4 initial-valuef))) + (set! (-> *part-id-table* 276 init-specs 4 initial-valuef) (fmin f30-0 (vector-length arg1))) + (draw-beam (-> this main-shot-part) arg0 arg1 #f) + (set! (-> *part-id-table* 276 init-specs 4 initial-valuef) f30-0) + ) + 0 + (none) + ) + +(defmethod gun-yellow-shot-method-42 ((this gun-yellow-shot) (arg0 float) (arg1 float) (arg2 matrix)) + (set! (-> *part-id-table* 267 init-specs 3 initial-valuef) (* arg0 arg1)) + (launch-particles (-> *part-id-table* 267) arg2 :origin-is-matrix #t) + (set! (-> *part-id-table* 267 init-specs 3 initial-valuef) arg1) + 0 + (none) + ) + +(defmethod gun-yellow-shot-method-42 ((this gun-yellow-shot-2) (arg0 float) (arg1 float) (arg2 matrix)) + 0 + (none) + ) + +(defmethod gun-yellow-shot-method-42 ((this gun-yellow-shot-3) (arg0 float) (arg1 float) (arg2 matrix)) + (set! (-> *part-id-table* 278 init-specs 3 initial-valuef) (* arg0 arg1)) + (set! (-> *part-id-table* 278 init-specs 3 initial-valuef) arg1) + 0 + (none) + ) + +(defmethod projectile-method-25 ((this gun-yellow-shot-2)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let* ((s5-0 (-> this root trans)) + (a1-0 (-> this tail-pos)) + (s4-1 (vector-! (new 'stack-no-clear 'vector) s5-0 a1-0)) + (f30-0 (vector-length s4-1)) + ) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (let ((v1-4 a1-0)) + (let ((a0-2 s4-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 (&-> s3-0 quad) vf6) + (draw-main-shot this a1-0 s4-1) + (vector-normalize! s4-1 1.0) + (launch-particles (-> *part-id-table* 270) s3-0) + ) + (let ((s3-1 (new 'stack-no-clear 'matrix)) + (f30-1 (fmin 1.0 (* 0.000015258789 f30-0))) + (f28-0 (-> *part-id-table* 267 init-specs 3 initial-valuef)) + ) + (forward-up->inv-matrix s3-1 s4-1 *up-vector*) + (set! (-> s3-1 trans quad) (-> s5-0 quad)) + (gun-yellow-shot-method-42 this f30-1 f28-0 s3-1) + ) + ) + 0 + (none) + ) + ) + +(defmethod spawn-particles ((this gun-yellow-shot) (arg0 vector)) + (launch-particles (-> *part-id-table* 265) arg0) + 0 + (none) + ) + +(defmethod spawn-particles ((this gun-yellow-shot-2) (arg0 vector)) + (launch-particles (-> *part-id-table* 270) arg0) + 0 + (none) + ) + +(defmethod spawn-particles ((this gun-yellow-shot-3) (arg0 vector)) + 0 + (none) + ) + +(defmethod projectile-method-26 ((this gun-yellow-shot-3)) + (let ((v1-8 + (cond + ((-> this hit-actor?) + (cond + ((logtest? (-> *part-group-id-table* 99 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 99)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 99)) + ) + ) + ) + ((logtest? (-> *part-group-id-table* 98 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 98)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 98)) + ) + ) + ) + ) + (send-event (ppointer->process v1-8) 'clock this) + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/target/target-part.gc b/goal_src/jak3/engine/target/target-part.gc index 801dfdac08..ba6defe34b 100644 --- a/goal_src/jak3/engine/target/target-part.gc +++ b/goal_src/jak3/engine/target/target-part.gc @@ -6,6 +6,7 @@ ;; dgos: GAME (define-extern process-drawable2-shock-effect (function process-drawable process-drawable lightning-spec (function lightning-tracker none) sparticle-launcher none)) +(define-extern process-drawable-shock-effect-replace (function process-drawable lightning-spec (function lightning-tracker none) int int float none)) ;; DECOMP BEGINS diff --git a/goal_src/jak3/kernel/gstate.gc b/goal_src/jak3/kernel/gstate.gc index eb1c203f1a..f0f8404a23 100644 --- a/goal_src/jak3/kernel/gstate.gc +++ b/goal_src/jak3/kernel/gstate.gc @@ -187,9 +187,9 @@ ,(cond ((and virtual parent) `(begin - (inherit-state ,new-state (the state ,parent)) - (set! (-> ,new-state parent) (the state ,parent)) - `(define-virtual-state-hook ,state-name ,defstate-type ,new-state ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + (inherit-state ,new-state ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (set! (-> ,new-state parent) ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (define-virtual-state-hook ,state-name ,defstate-type ,new-state ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) ) ) (virtual diff --git a/test/decompiler/reference/jak3/decompiler-macros.gc b/test/decompiler/reference/jak3/decompiler-macros.gc index 015a1d1777..5765211c53 100644 --- a/test/decompiler/reference/jak3/decompiler-macros.gc +++ b/test/decompiler/reference/jak3/decompiler-macros.gc @@ -215,9 +215,9 @@ ,(cond ((and virtual parent) `(begin - (inherit-state ,new-state (the state ,parent)) - (set! (-> ,new-state parent) (the state ,parent)) - `(define-virtual-state-hook ,state-name ,defstate-type ,new-state ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) + (inherit-state ,new-state ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (set! (-> ,new-state parent) ,(if (pair? parent) `(method-of-type ,(car parent) ,(cadr parent)) `(the state ,parent))) + (define-virtual-state-hook ,state-name ,defstate-type ,new-state ,(eq? virtual 'override) :event ,event :enter ,enter :trans ,trans :exit ,exit :code ,code :post ,post) ) ) (virtual diff --git a/test/decompiler/reference/jak3/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/jak3/engine/collide/collide-shape-h_REF.gc index 9dc30c46c8..d47b1d794f 100644 --- a/test/decompiler/reference/jak3/engine/collide/collide-shape-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/collide/collide-shape-h_REF.gc @@ -1427,7 +1427,7 @@ Most [[process-drawable]]s have a [[collide-shape]] that represents their root t (send-shoves (_type_ process touching-shapes-entry float float float) symbol) (above-ground? (_type_ collide-query vector collide-spec float float float) symbol) (water-info-init! (_type_ water-info collide-action) water-info) - (collide-shape-method-53 () none) + (iterate-prims (_type_ (function collide-shape-prim none)) none) (collide-shape-method-54 () none) ) ) diff --git a/test/decompiler/reference/jak3/engine/common-obs/curves_REF.gc b/test/decompiler/reference/jak3/engine/common-obs/curves_REF.gc index 604de322c4..be28d83c04 100644 --- a/test/decompiler/reference/jak3/engine/common-obs/curves_REF.gc +++ b/test/decompiler/reference/jak3/engine/common-obs/curves_REF.gc @@ -92,7 +92,7 @@ (default-loop-behavior uint64) ) (:methods - (curve2d-piecewise-method-10 (_type_ int symbol uint) none) + (curve2d-piecewise-method-10 (_type_ int symbol int) none) (curve2d-piecewise-method-11 (_type_) none) ) ) @@ -233,7 +233,7 @@ ;; definition for method 10 of type curve2d-piecewise ;; WARN: Return type mismatch int vs none. -(defmethod curve2d-piecewise-method-10 ((this curve2d-piecewise) (arg0 int) (arg1 symbol) (arg2 uint)) +(defmethod curve2d-piecewise-method-10 ((this curve2d-piecewise) (arg0 int) (arg1 symbol) (arg2 int)) (set! (-> this pts) ((method-of-type float-pair-array new) arg1 float-pair-array arg0)) (set! (-> this default-loop-behavior) (the-as uint (if arg2 0 @@ -588,7 +588,7 @@ ;; failed to figure out what this is: (when (or (zero? *curve-linear-up-hold*) (!= loading-level global)) (set! *curve-linear-up-hold* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *curve-linear-up-hold* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *curve-linear-up-hold* 2 'loading-level (the-as int #f)) ) ;; failed to figure out what this is: @@ -657,7 +657,3 @@ ) ) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc b/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc index b648255f1b..5c680d61f5 100644 --- a/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc +++ b/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc @@ -2096,7 +2096,7 @@ ) ) ) - (set! (-> self sound) (sound-play-by-spec (the-as sound-spec gp-1) (new-sound-id) s5-1)) + (set! (-> self sound) (sound-play-by-spec gp-1 (new-sound-id) s5-1)) ) ) ) diff --git a/test/decompiler/reference/jak3/engine/common-obs/water_REF.gc b/test/decompiler/reference/jak3/engine/common-obs/water_REF.gc index 3e39793214..8ff76ed73f 100644 --- a/test/decompiler/reference/jak3/engine/common-obs/water_REF.gc +++ b/test/decompiler/reference/jak3/engine/common-obs/water_REF.gc @@ -64,7 +64,7 @@ ;; failed to figure out what this is: (when (or (zero? *water-simple-alpha-curve-in*) (!= loading-level global)) (set! *water-simple-alpha-curve-in* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *water-simple-alpha-curve-in* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *water-simple-alpha-curve-in* 2 'loading-level (the-as int #f)) ) ;; failed to figure out what this is: @@ -82,7 +82,7 @@ ;; failed to figure out what this is: (when (or (zero? *growing-curve*) (!= loading-level global)) (set! *growing-curve* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *growing-curve* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *growing-curve* 2 'loading-level (the-as int #f)) ) ;; failed to figure out what this is: @@ -100,7 +100,7 @@ ;; failed to figure out what this is: (when (or (zero? *water-simple-alpha-curve-fade-out*) (!= loading-level global)) (set! *water-simple-alpha-curve-fade-out* (new 'loading-level 'curve2d-piecewise)) - (curve2d-piecewise-method-10 *water-simple-alpha-curve-fade-out* 2 'loading-level (the-as uint #f)) + (curve2d-piecewise-method-10 *water-simple-alpha-curve-fade-out* 2 'loading-level (the-as int #f)) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak3/engine/entity/entity-h_REF.gc b/test/decompiler/reference/jak3/engine/entity/entity-h_REF.gc index 434e4dc4a8..a43b17353b 100644 --- a/test/decompiler/reference/jak3/engine/entity/entity-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/entity/entity-h_REF.gc @@ -77,7 +77,7 @@ (task game-task :overlay-at (-> perm task)) ) (:methods - (entity-links-method-9 () none) + (birth? (_type_ vector) symbol) ) ) diff --git a/test/decompiler/reference/jak3/engine/entity/entity_REF.gc b/test/decompiler/reference/jak3/engine/entity/entity_REF.gc new file mode 100644 index 0000000000..d7b979ab56 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/entity/entity_REF.gc @@ -0,0 +1,2769 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *spawn-actors*, type symbol +(define *spawn-actors* #t) + +;; definition for symbol *compact-actors*, type symbol +(define *compact-actors* #t) + +;; definition for symbol *vis-actors*, type symbol +(define *vis-actors* #t) + +;; definition for method 8 of type drawable-actor +;; WARN: Return type mismatch int vs drawable-actor. +(defmethod mem-usage ((this drawable-actor) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 45 (-> usage length))) + (set! (-> usage data 44 name) "entity") + (+! (-> usage data 44 count) 1) + (let ((v1-6 (asize-of this))) + (+! (-> usage data 44 used) v1-6) + (+! (-> usage data 44 total) (logand -16 (+ v1-6 15))) + ) + (mem-usage (-> this actor) usage (logior flags 64)) + (the-as drawable-actor 0) + ) + +;; definition for method 8 of type drawable-inline-array-actor +;; WARN: Return type mismatch int vs drawable-inline-array-actor. +(defmethod mem-usage ((this drawable-inline-array-actor) (usage memory-usage-block) (flags int)) + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 1) + (let ((v1-5 32)) + (+! (-> usage data 0 used) v1-5) + (+! (-> usage data 0 total) (logand -16 (+ v1-5 15))) + ) + (dotimes (s3-0 (-> this length)) + (mem-usage (-> this data s3-0) usage flags) + ) + (the-as drawable-inline-array-actor 0) + ) + +;; definition for method 2 of type entity-links +(defmethod print ((this entity-links)) + (format #t "#" (-> this process) this) + this + ) + +;; definition for method 2 of type entity-perm +(defmethod print ((this entity-perm)) + (format + #t + "#" + (-> this aid) + (-> this task) + (-> this status) + (-> this user-uint64) + this + ) + this + ) + +;; definition for method 2 of type actor-group +(defmethod print ((this actor-group)) + (format #t "# this length)) + (format #t " ~A" (-> this data s5-0 actor)) + ) + (format #t " @ #x~X>" this) + this + ) + +;; definition for method 3 of type actor-group +(defmethod inspect ((this actor-group)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tlength: ~D~%" (-> this length)) + (format #t "~Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~Tdata[~D]: @ #x~X~%" (-> this length) (-> this data)) + (dotimes (s5-0 (-> this length)) + (format #t "~T [~D] ~A / ~D~%" s5-0 (-> this data s5-0 actor) (-> this data s5-0 id)) + ) + this + ) + +;; definition for method 22 of type entity +(defmethod birth! ((this entity)) + (format #t "birth ~A~%" this) + this + ) + +;; definition for method 23 of type entity +(defmethod kill! ((this entity)) + (format #t "kill ~A~%" this) + this + ) + +;; definition for method 2 of type entity +(defmethod print ((this entity)) + (format #t "#<~A :name ~S @ #x~X>" (-> this type) (res-lump-struct this 'name structure) this) + this + ) + +;; definition for method 26 of type entity +(defmethod get-level ((this entity)) + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (if (and (>= (the-as int this) (the-as int (-> a1-3 heap base))) + (< (the-as int this) (the-as int (-> a1-3 heap top-base))) + ) + (return a1-3) + ) + ) + ) + ) + (-> *level* level-default) + ) + +;; definition for function entity-by-name +(defun entity-by-name ((arg0 string)) + (if (not arg0) + (return (the-as entity #f)) + ) + (dotimes (s5-0 (-> *level* length)) + (let ((s4-0 (-> *level* level s5-0))) + (when (= (-> s4-0 status) 'active) + (let ((s3-0 (-> s4-0 bsp actors))) + (when (nonzero? s3-0) + (dotimes (s2-0 (-> s3-0 length)) + (let ((s1-0 (-> s3-0 data s2-0 actor))) + (if (string= (res-lump-struct s1-0 'name string) arg0) + (return s1-0) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s4-0 bsp nav-meshes))) + (when (nonzero? s3-1) + (dotimes (s2-1 (-> s3-1 length)) + (let ((s1-1 (-> s3-1 s2-1))) + (if (string= (res-lump-struct s1-1 'name string) arg0) + (return s1-1) + ) + ) + ) + ) + ) + (let ((s3-2 (-> s4-0 bsp race-meshes))) + (when (nonzero? s3-2) + (dotimes (s2-2 (-> s3-2 length)) + (let ((s1-2 (-> s3-2 s2-2))) + (if (string= (res-lump-struct s1-2 'name string) arg0) + (return s1-2) + ) + ) + ) + ) + ) + (let ((s4-1 (-> s4-0 bsp cameras))) + (when (nonzero? s4-1) + (dotimes (s3-3 (-> s4-1 length)) + (let ((s2-3 (-> s4-1 s3-3))) + (if (string= (res-lump-struct s2-3 'name string) arg0) + (return s2-3) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity #f) + ) + +;; definition for function entity-by-type +(defun entity-by-type ((arg0 type)) + (dotimes (s5-0 (-> *level* length)) + (let ((v1-3 (-> *level* level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp actors))) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 actor))) + (if (and (type? s2-0 entity-actor) (= (-> s2-0 etype) arg0)) + (return s2-0) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-actor #f) + ) + +;; definition for function entity-by-aid +(defun entity-by-aid ((arg0 uint)) + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (let ((a1-4 (-> a1-3 entity))) + (when (nonzero? a1-4) + (let ((a2-4 0) + (a3-2 (+ (-> a1-4 length) -1)) + ) + 0 + (while (>= a3-2 a2-4) + (let* ((t0-3 (+ a2-4 (/ (- a3-2 a2-4) 2))) + (t1-2 (-> a1-4 data t0-3)) + (t2-0 (-> t1-2 perm aid)) + ) + (cond + ((= t2-0 arg0) + (return (-> t1-2 entity)) + ) + ((< (the-as uint t2-0) arg0) + (set! a2-4 (+ t0-3 1)) + ) + (else + (set! a3-2 (+ t0-3 -1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity #f) + ) + +;; definition for function entity-actor-from-level-name +;; WARN: Return type mismatch entity vs entity-actor. +(defun entity-actor-from-level-name ((arg0 symbol)) + (let ((v0-0 (the-as entity #f))) + (dotimes (s5-0 (-> *level* length)) + (let ((s4-0 (-> *level* level s5-0))) + (when (= (-> s4-0 status) 'active) + (when (= (-> s4-0 name) arg0) + (when (zero? (-> s4-0 entity length)) + (format 0 "ERROR: level ~s has no entities!!" (-> s4-0 name)) + (when *debug-segment* + (break!) + 0 + ) + ) + (set! v0-0 (-> s4-0 entity data 0 entity)) + ) + ) + ) + ) + (the-as entity-actor v0-0) + ) + ) + +;; definition for method 18 of type level-group +;; WARN: Return type mismatch int vs none. +(defmethod update-nav-meshes-method ((this level-group)) + (when (not (paused?)) + (dotimes (s5-0 (-> this length)) + (let ((v1-4 (-> this level s5-0))) + (when (= (-> v1-4 status) 'active) + (let ((s4-0 (-> v1-4 bsp nav-meshes))) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> s4-0 length)) + ((method-of-object (-> s4-0 s3-0 nav-mesh) nav-mesh-method-28)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function entity-nav-mesh-by-aid +(defun entity-nav-mesh-by-aid ((arg0 actor-id)) + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (let ((a1-5 (-> a1-3 bsp nav-meshes))) + (when (nonzero? a1-5) + (let ((a2-4 0) + (a3-2 (+ (-> a1-5 length) -1)) + ) + 0 + (while (>= a3-2 a2-4) + (let* ((t0-3 (+ a2-4 (/ (- a3-2 a2-4) 2))) + (t1-2 (-> a1-5 t0-3)) + (t2-0 (-> t1-2 aid)) + ) + (cond + ((= t2-0 arg0) + (return t1-2) + ) + ((< t2-0 (the-as uint arg0)) + (set! a2-4 (+ t0-3 1)) + ) + (else + (set! a3-2 (+ t0-3 -1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-nav-mesh #f) + ) + +;; definition for function nav-mesh-from-res-tag +(defun nav-mesh-from-res-tag ((arg0 entity) (arg1 symbol) (arg2 int)) + (let ((v1-1 (res-lump-data arg0 arg1 pointer)) + (gp-0 (the-as nav-mesh #f)) + ) + (when v1-1 + (let* ((s5-1 (entity-nav-mesh-by-aid (the-as actor-id (-> (the-as (pointer uint32) (&+ v1-1 (* arg2 4))))))) + (v1-3 (if (type? s5-1 entity-nav-mesh) + s5-1 + ) + ) + ) + (if v1-3 + (set! gp-0 (-> v1-3 nav-mesh)) + ) + ) + ) + gp-0 + ) + ) + +;; definition for function entity-by-meters +(defun entity-by-meters ((arg0 float) (arg1 float) (arg2 float)) + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-5 (-> a3-3 bsp actors))) + (when (nonzero? a3-5) + (dotimes (t0-4 (-> a3-5 length)) + (let* ((t1-3 (-> a3-5 data t0-4 actor)) + (t2-1 (-> t1-3 extra trans)) + ) + (if (and (= (the float (the int (-> t2-1 x))) arg0) + (= (the float (the int (-> t2-1 y))) arg1) + (= (the float (the int (-> t2-1 z))) arg2) + ) + (return t1-3) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity-actor #f) + ) + +;; definition for function process-by-ename +(defun process-by-ename ((arg0 string)) + (let ((v1-0 (entity-by-name arg0))) + (if v1-0 + (-> v1-0 extra process) + ) + ) + ) + +;; definition for function entity-process-count +(defun entity-process-count ((arg0 symbol)) + (let ((gp-0 0)) + (dotimes (s4-0 (-> *level* length)) + (let ((s3-0 (-> *level* level s4-0))) + (when (= (-> s3-0 status) 'active) + (let ((s2-0 (-> s3-0 bsp level entity))) + (dotimes (s1-0 (-> s2-0 length)) + (let ((v1-9 (-> s2-0 data s1-0 entity))) + (case arg0 + (('vis) + (if (is-object-visible? s3-0 (-> v1-9 extra vis-id)) + (+! gp-0 1) + ) + ) + (else + (if (-> v1-9 extra process) + (+! gp-0 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +;; definition for function entity-count +(defun entity-count () + (let ((v0-0 0)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-3 (-> *level* level v1-0))) + (when (= (-> a0-3 status) 'active) + (let ((a0-6 (-> a0-3 bsp level entity))) + (dotimes (a1-3 (-> a0-6 length)) + (-> a0-6 data a1-3 entity) + (+! v0-0 1) + ) + ) + ) + ) + ) + v0-0 + ) + ) + +;; definition for function entity-remap-names +;; WARN: Return type mismatch int vs none. +(defun entity-remap-names ((arg0 pair)) + (let ((s5-0 (car arg0))) + (while (not (null? arg0)) + (let ((a0-2 (entity-by-meters + (the float (/ (the-as int (car (cdr s5-0))) 8)) + (the float (/ (the-as int (car (cdr (cdr s5-0)))) 8)) + (the float (/ (the-as int (car (cdr (cdr (cdr s5-0))))) 8)) + ) + ) + ) + (if a0-2 + (add-data! + a0-2 + (new 'static 'res-tag :name 'name :key-frame -1000000000.0 :elt-count #x1 :elt-type string) + (the-as pointer (car s5-0)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! s5-0 (car arg0)) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function process-status-bits +;; WARN: Return type mismatch int vs none. +(defun-debug process-status-bits ((arg0 process) (arg1 symbol)) + (let* ((s5-0 arg0) + (s3-0 (if (type? s5-0 process-drawable) + (the-as process-drawable s5-0) + ) + ) + ) + (if (and s3-0 (zero? (-> s3-0 draw))) + (set! s3-0 (the-as process-drawable #f)) + ) + (let ((s5-1 format) + (s4-0 "~C~C~C") + (a2-0 (if (and arg0 (not (logtest? (-> *kernel-context* prevent-from-run) (-> arg0 mask))) (run-logic? arg0)) + 114 + 32 + ) + ) + (a3-0 (if (and s3-0 (logtest? (-> s3-0 draw status) (draw-control-status on-screen))) + 100 + 32 + ) + ) + (t0-0 (cond + ((and s3-0 (logtest? (-> s3-0 draw status) (draw-control-status on-screen))) + (let ((v1-14 (-> s3-0 draw cur-lod))) + (cond + ((zero? v1-14) + 48 + ) + ((= v1-14 1) + 49 + ) + ((= v1-14 2) + 50 + ) + ((= v1-14 3) + 51 + ) + ((= v1-14 4) + 52 + ) + ) + ) + ) + (else + 32 + ) + ) + ) + ) + (s5-1 arg1 s4-0 a2-0 a3-0 t0-0) + ) + ) + 0 + (none) + ) + +;; definition for function process-entity-set! +(defun process-entity-set! ((arg0 process) (arg1 entity)) + (set! (-> arg0 entity) (the-as entity-actor arg1)) + (if arg1 + (set! (-> arg0 level) (-> arg1 extra level)) + (set! (-> arg0 level) (-> *level* level-default)) + ) + arg1 + ) + +;; definition for function process-task-mask +(defun process-task-mask ((arg0 process)) + (-> arg0 level task-mask) + ) + +;; definition for method 2 of type process +(defmethod print ((this process)) + (cond + ((and (-> this top-thread) (!= (-> this status) 'dead)) + (format + #t + "#<~A ~S ~A :state ~S :flags " + (-> this type) + (-> this name) + (-> this status) + (if (-> this state) + (-> this state name) + ) + ) + (process-status-bits this #t) + (format + #t + " :stack ~D/~D :heap ~D/~D @ #x~X>" + (&- (-> this top-thread stack-top) (the-as uint (-> this top-thread sp))) + (-> this main-thread stack-size) + (- (-> this allocated-length) (&- (-> this heap-top) (the-as uint (-> this heap-cur)))) + (-> this allocated-length) + this + ) + ) + (else + (format + #t + "#<~A ~S ~A :state ~S @ #x~X" + (-> this type) + (-> this name) + (-> this status) + (if (-> this state) + (-> this state name) + ) + this + ) + ) + ) + this + ) + +;; definition for method 3 of type entity +(defmethod inspect ((this entity)) + (call-parent-method this) + (format #t "~Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~Taid: ~D~%" (-> this aid)) + this + ) + +;; definition for method 3 of type entity-nav-mesh +(defmethod inspect ((this entity-nav-mesh)) + (call-parent-method this) + (format #t "~Tnav-mesh ~A~%" (-> this nav-mesh)) + (if (and (-> this nav-mesh) (nonzero? (-> this nav-mesh))) + (inspect (-> this nav-mesh)) + ) + this + ) + +;; definition for method 3 of type entity-actor +(defmethod inspect ((this entity-actor)) + (call-parent-method this) + (format #t "~Tetype: ~A~%" (-> this etype)) + (format #t "~Ttask: ~d~%" (-> this task)) + (format #t "~Tkill-mask: #x~X : (" (-> this kill-mask)) + (let ((s5-0 (-> this kill-mask))) + (if (= (logand s5-0 (task-mask task0)) (task-mask task0)) + (format #t "task0 ") + ) + (if (= (logand s5-0 (task-mask task2)) (task-mask task2)) + (format #t "task2 ") + ) + (if (= (logand s5-0 (task-mask task4)) (task-mask task4)) + (format #t "task4 ") + ) + (if (= (logand s5-0 (task-mask task6)) (task-mask task6)) + (format #t "task6 ") + ) + (if (= (logand s5-0 (task-mask ctywide)) (task-mask ctywide)) + (format #t "ctywide ") + ) + (if (= (logand s5-0 (task-mask never)) (task-mask never)) + (format #t "never ") + ) + (if (= (logand (task-mask movie1) s5-0) (task-mask movie1)) + (format #t "movie1 ") + ) + (if (= (logand s5-0 (task-mask vehicle)) (task-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand s5-0 (task-mask dummy1)) (task-mask dummy1)) + (format #t "dummy1 ") + ) + (if (= (logand s5-0 (task-mask primary0)) (task-mask primary0)) + (format #t "primary0 ") + ) + (if (= (logand s5-0 (task-mask task1)) (task-mask task1)) + (format #t "task1 ") + ) + (if (= (logand s5-0 (task-mask task3)) (task-mask task3)) + (format #t "task3 ") + ) + (if (= (logand s5-0 (task-mask task5)) (task-mask task5)) + (format #t "task5 ") + ) + (if (= (logand s5-0 (task-mask task7)) (task-mask task7)) + (format #t "task7 ") + ) + (if (= (logand (task-mask movie2) s5-0) (task-mask movie2)) + (format #t "movie2 ") + ) + (if (= (logand s5-0 (task-mask done)) (task-mask done)) + (format #t "done ") + ) + (if (= (logand s5-0 (task-mask special)) (task-mask special)) + (format #t "special ") + ) + (if (= (logand (task-mask movie0) s5-0) (task-mask movie0)) + (format #t "movie0 ") + ) + (if (= (logand s5-0 (task-mask dummy0)) (task-mask dummy0)) + (format #t "dummy0 ") + ) + ) + (format #t ")~%") + (format #t "~Tvis-id: ~d~%" (-> this vis-id)) + (format #t "~Tquat: ~`vector`P~%" (-> this quat)) + this + ) + +;; definition for method 29 of type entity-actor +;; WARN: Return type mismatch entity-actor vs none. +(defmethod debug-print ((this entity-actor) (arg0 symbol) (arg1 type)) + (let ((s4-0 (-> this etype))) + (when (or (not arg1) (and s4-0 (valid? s4-0 type (the-as string #f) #f 0) (type-type? s4-0 arg1))) + (format #t "~5D #x~8X ~-26S" (-> this extra vis-id) this (res-lump-struct this 'name structure)) + (let ((t9-4 format) + (a0-5 #t) + (a1-5 "~8D ~3D ~-8S #x~4X") + (a2-4 (-> this extra perm aid)) + (a3-3 (-> this extra perm task)) + (t0-3 (-> this extra level nickname)) + ) + (set! t0-3 (cond + (t0-3 + (empty) + t0-3 + ) + (else + (-> this extra level name) + ) + ) + ) + (t9-4 a0-5 a1-5 a2-4 a3-3 t0-3 (-> this extra perm status)) + ) + (if (= arg0 'entity-meters) + (format #t " :trans ~14m ~14m ~14m " (-> this extra trans x) (-> this extra trans y) (-> this extra trans z)) + (format + #t + " :trans ~11,,1f ~11,,1f ~11,,1f " + (-> this extra trans x) + (-> this extra trans y) + (-> this extra trans z) + ) + ) + (let* ((s3-2 (-> this extra process)) + (s4-2 (if (type? s3-2 process-drawable) + s3-2 + ) + ) + ) + (format + #t + ":pr #x~8X ~-18S ~-5S/~-5S " + (if (-> this extra process) + (-> this extra process) + 0 + ) + (if (and (-> this extra process) (-> this extra process state)) + (-> this extra process state name) + "" + ) + (if (-> this extra process) + (* (- (-> this extra process allocated-length) + (&- (-> this extra process heap-top) (the-as uint (-> this extra process heap-cur))) + ) + 8 + ) + "" + ) + (if (-> this extra process) + (* (-> this extra process allocated-length) 8) + "" + ) + ) + (process-status-bits s4-2 #t) + ) + (format #t "~%") + (if (= arg0 'entity-perm) + (format #t " ~`entity-perm`P~%" (-> this extra perm)) + ) + ) + ) + (none) + ) + +;; definition for method 14 of type level-group +;; WARN: Return type mismatch int vs none. +(defmethod debug-print-entities ((this level-group) (arg0 symbol) (arg1 type) (arg2 string)) + (let ((t9-0 format) + (a0-1 #t) + (a1-1 + " id address name aid tsk lev status x y z address state heap flags~%" + ) + ) + 0 + 0 + 0 + (t9-0 a0-1 a1-1) + ) + (dotimes (s2-0 (-> this length)) + (let ((s1-0 (-> this level s2-0))) + (when (= (-> s1-0 status) 'active) + (when (or (not arg2) (= arg2 (-> s1-0 name))) + (case arg0 + (('art-group) + (format #t "level ~A~%" (-> s1-0 name)) + (dotimes (s0-0 (-> s1-0 art-group art-group-array length)) + (format #t "~T~2D ~S~%" s0-0 (-> s1-0 art-group art-group-array s0-0 name)) + ) + ) + (else + (let ((s1-1 (-> s1-0 bsp level entity))) + (dotimes (s0-1 (-> s1-1 length)) + (debug-print (the-as entity-actor (-> s1-1 data s0-1 entity)) arg0 arg1) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 24 of type entity-actor +;; INFO: Used lq/sq +;; WARN: Return type mismatch entity-actor vs none. +(defmethod add-to-level! ((this entity-actor) (arg0 level-group) (arg1 level) (arg2 actor-id)) + (let ((v1-4 (-> arg1 entity data (-> arg1 entity length)))) + (+! (-> arg1 entity length) 1) + (set! (-> v1-4 process) #f) + (set! (-> v1-4 entity) this) + (set! (-> this extra) v1-4) + (cond + ((-> arg0 entity-link) + (let* ((a0-6 (-> arg0 entity-link)) + (t0-1 (-> a0-6 next-link)) + ) + (set! (-> a0-6 next-link) v1-4) + (set! (-> v1-4 prev-link) a0-6) + (set! (-> v1-4 next-link) t0-1) + (set! (-> t0-1 prev-link) v1-4) + ) + ) + (else + (set! (-> v1-4 prev-link) v1-4) + (set! (-> v1-4 next-link) v1-4) + ) + ) + (set! (-> arg0 entity-link) v1-4) + (set! (-> v1-4 trans quad) (-> this trans quad)) + ) + (set! (-> this extra perm aid) arg2) + (set! (-> this extra level) arg1) + (set! (-> this extra kill-mask) + (logior (logand (-> this kill-mask) + (task-mask + task0 + task1 + task2 + task3 + task4 + task5 + task6 + task7 + done + dummy0 + dummy1 + vehicle + special + primary0 + ctywide + never + ) + ) + (logclear + (task-mask movie0 movie1 movie2 tm19 tm20 tm21 tm22 tm23 tm24 tm25 tm26 tm27 tm28 tm29 tm30 tm31) + (-> this kill-mask) + ) + ) + ) + (if (not (-> arg1 vis-info 0)) + (set! (-> this extra vis-dist) (res-lump-float this 'vis-dist :default 40960000.0)) + ) + (cond + ((= (-> this type) entity-actor) + (set! (-> this extra perm task) (-> this task)) + (set! (-> this extra vis-id) (-> this vis-id)) + ) + (else + (set! (-> this extra perm task) (game-task none)) + (set! (-> this extra vis-id) 0) + 0 + ) + ) + (none) + ) + +;; definition for method 25 of type entity +(defmethod remove-from-level! ((this entity) (arg0 level-group)) + (let ((v1-0 (-> this extra))) + (cond + ((= (-> v1-0 next-link) v1-0) + (set! (-> arg0 entity-link) #f) + ) + (else + (set! (-> v1-0 next-link prev-link) (-> v1-0 prev-link)) + (set! (-> v1-0 prev-link next-link) (-> v1-0 next-link)) + (if (= (-> arg0 entity-link) v1-0) + (set! (-> arg0 entity-link) (-> v1-0 prev-link)) + ) + ) + ) + ) + this + ) + +;; definition for function update-actor-vis-box +;; WARN: Return type mismatch int vs none. +(defun update-actor-vis-box ((arg0 process-drawable) (arg1 vector) (arg2 vector)) + (when (and arg0 (nonzero? (-> arg0 draw)) (not (logtest? (-> arg0 draw status) (draw-control-status no-draw)))) + (let ((v1-5 (-> arg0 draw origin)) + (f0-0 (-> arg0 draw bounds w)) + ) + (set! (-> arg1 x) (fmin (-> arg1 x) (- (-> v1-5 x) f0-0))) + (set! (-> arg1 y) (fmin (-> arg1 y) (- (-> v1-5 y) f0-0))) + (set! (-> arg1 z) (fmin (-> arg1 z) (- (-> v1-5 z) f0-0))) + (set! (-> arg2 x) (fmax (-> arg2 x) (+ (-> v1-5 x) f0-0))) + (set! (-> arg2 y) (fmax (-> arg2 y) (+ (-> v1-5 y) f0-0))) + (set! (-> arg2 z) (fmax (-> arg2 z) (+ (-> v1-5 z) f0-0))) + ) + ) + 0 + (none) + ) + +;; definition for method 23 of type level-group +;; WARN: Return type mismatch int vs none. +(defmethod update-vis-volumes ((this level-group)) + (local-vars (sv-16 (inline-array vector)) (sv-20 vector) (sv-24 vector) (sv-28 process)) + (dotimes (s5-0 (-> this length)) + (let ((v1-3 (-> this level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 entity))) + (set! sv-16 (res-lump-data s2-0 'visvol (inline-array vector))) + (set! sv-20 (-> sv-16 0)) + (set! sv-24 (-> sv-16 1)) + (let ((s2-1 (-> s2-0 extra process))) + (set! sv-28 (if (type? s2-1 process-drawable) + s2-1 + ) + ) + ) + ) + (when sv-28 + (update-actor-vis-box (the-as process-drawable sv-28) sv-20 sv-24) + (let ((s2-2 (-> sv-28 child))) + (while s2-2 + (let ((s1-0 update-actor-vis-box) + (s0-0 (-> s2-2 0)) + ) + (s1-0 + (the-as process-drawable (if (type? s0-0 process-drawable) + s0-0 + ) + ) + sv-20 + sv-24 + ) + ) + (set! s2-2 (-> s2-2 0 brother)) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function expand-bounding-box +;; WARN: Return type mismatch int vs none. +(defun expand-bounding-box ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (set! (-> arg0 x) (fmin (-> arg0 x) (-> arg2 x))) + (set! (-> arg0 y) (fmin (-> arg0 y) (-> arg2 y))) + (set! (-> arg0 z) (fmin (-> arg0 z) (-> arg2 z))) + (set! (-> arg1 x) (fmax (-> arg1 x) (-> arg3 x))) + (set! (-> arg1 y) (fmax (-> arg1 y) (-> arg3 y))) + (set! (-> arg1 z) (fmax (-> arg1 z) (-> arg3 z))) + 0 + (none) + ) + +;; definition for function expand-bounding-box-from-nav-meshes +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs object. +(defun expand-bounding-box-from-nav-meshes ((arg0 entity) (arg1 vector) (arg2 vector)) + (local-vars (sv-16 res-tag)) + (set! sv-16 (new 'static 'res-tag)) + (res-lump-data arg0 'nav-mesh-actor pointer :tag-ptr (& sv-16)) + (dotimes (s3-0 (the-as int (-> sv-16 elt-count))) + (let ((a0-3 (nav-mesh-from-res-tag arg0 'nav-mesh-actor s3-0))) + (when a0-3 + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (compute-bounding-box-from-vertices a0-3 s2-0 s1-0) + (expand-bounding-box arg1 arg2 s2-0 s1-0) + ) + ) + ) + ) + #f + ) + +;; definition for method 24 of type level-group +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod level-group-method-24 ((this level-group)) + (local-vars + (r0-0 uint128) + (a0-23 object) + (a1-10 uint128) + (sv-16 (inline-array vector)) + (sv-20 vector) + (sv-24 vector) + (sv-28 float) + (sv-32 float) + (sv-36 vector) + (sv-40 entity) + (sv-48 int) + ) + (dotimes (s5-0 (-> this length)) + (let ((v1-3 (-> this level s5-0))) + (when (= (-> v1-3 status) 'active) + (let ((s4-0 (-> v1-3 bsp level entity))) + (dotimes (s3-0 (-> s4-0 length)) + (let ((s2-0 (-> s4-0 data s3-0 entity))) + (set! sv-16 (res-lump-data s2-0 'visvol (inline-array vector))) + (set! sv-20 (-> sv-16 0)) + (set! sv-24 (-> sv-16 1)) + (set! sv-28 (the-as float -12288.0)) + (set! sv-32 (the-as float 12288.0)) + (set! sv-36 (-> s2-0 extra trans)) + (set! sv-40 s2-0) + (let ((v1-17 (entity-actor-lookup s2-0 'nav-mesh-actor 0))) + (if v1-17 + (set! sv-40 v1-17) + ) + ) + ) + (cond + ((type? sv-40 entity-actor) + (let ((enemy-option (res-lump-value sv-40 'enemy-options enemy-option :time -1000000000.0))) + (cond + ((logtest? (enemy-option spawner) (the-as uint128 enemy-option)) + (set! (-> sv-20 quad) (-> sv-36 quad)) + (set! (-> sv-24 quad) (-> sv-36 quad)) + (set! sv-28 (the-as float -409.6)) + (set! sv-32 (the-as float 409.6)) + ) + ((string-prefix= "battle" (res-lump-struct sv-40 'name string)) + (set! (-> sv-20 quad) (-> sv-36 quad)) + (set! (-> sv-24 quad) (-> sv-36 quad)) + (set! sv-48 0) + (let ((v1-29 + (res-lump-data sv-40 'actor-groups (pointer actor-group) :tag-ptr (the-as (pointer res-tag) (& sv-48))) + ) + ) + (when (and v1-29 (begin + (let ((a0-24 #t)) + (let ((a1-9 (the-as uint128 sv-48))) + (.pcpyud a1-10 a1-9 r0-0) + ) + (let ((a1-12 (the-as int (shr (* (the-as int a1-10) 2) 49)))) + (cmove-#f-zero a0-23 a1-12 a0-24) + ) + ) + a0-23 + ) + ) + (let* ((s2-2 (-> v1-29 0)) + (s1-1 (-> s2-2 length)) + ) + (dotimes (s0-0 s1-1) + (let ((a0-26 (-> s2-2 data s0-0 actor))) + (expand-bounding-box-from-nav-meshes a0-26 sv-20 sv-24) + ) + ) + ) + ) + ) + ) + (else + (expand-bounding-box-from-nav-meshes sv-40 sv-20 sv-24) + ) + ) + ) + ) + (else + (set! (-> sv-20 quad) (-> sv-36 quad)) + (set! (-> sv-24 quad) (-> sv-36 quad)) + ) + ) + (+! (-> sv-20 x) sv-28) + (+! (-> sv-20 y) sv-28) + (+! (-> sv-20 z) sv-28) + (+! (-> sv-24 x) sv-32) + (+! (-> sv-24 y) sv-32) + (+! (-> sv-24 z) sv-32) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 25 of type level-group +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod print-volume-sizes ((this level-group)) + (local-vars + (sv-16 (inline-array vector)) + (sv-20 float) + (sv-24 vector) + (sv-28 type) + (sv-32 vector) + (sv-36 vector) + (sv-48 int) + (sv-64 entity) + (sv-80 string) + ) + (let ((s5-0 0)) + (dotimes (v1-0 (-> this length)) + (let ((a0-4 (-> this level v1-0))) + (if (= (-> a0-4 status) 'active) + (+! s5-0 (-> a0-4 entity length)) + ) + ) + ) + (let ((s4-0 (the-as string #f))) + (while (nonzero? s5-0) + 0 + (let ((s2-0 (the-as string #f)) + (s3-0 (the-as entity #f)) + ) + (dotimes (s1-0 (-> this length)) + (let ((v1-7 (-> this level s1-0))) + (when (= (-> v1-7 status) 'active) + (let ((s0-0 (-> v1-7 entity))) + (set! sv-48 (-> s0-0 length)) + (while (nonzero? sv-48) + (set! sv-48 (+ sv-48 -1)) + (set! sv-64 (-> s0-0 data sv-48 entity)) + (set! sv-80 (res-lump-struct sv-64 'name string)) + (when (and (or (not s4-0) (string>? sv-80 s4-0)) (or (not s2-0) (string (the-as entity-actor s3-0) extra trans)) + (set! sv-28 (if (type? s3-0 entity-actor) + (-> (the-as entity-actor s3-0) etype) + (the-as type #f) + ) + ) + (set! sv-32 (-> sv-16 0)) + (set! sv-36 (-> sv-16 1)) + (format #t "actor-vis ~S ~6,,1M " (res-lump-struct s3-0 'name structure) sv-20) + (format + #t + "~6,,1M ~6,,1M ~6,,1M ~6,,1M ~6,,1M ~6,,1M~%" + (- (-> sv-32 x) (-> sv-24 x)) + (- (-> sv-32 y) (-> sv-24 y)) + (- (-> sv-32 z) (-> sv-24 z)) + (- (-> sv-36 x) (-> sv-24 x)) + (- (-> sv-36 y) (-> sv-24 y)) + (- (-> sv-36 z) (-> sv-24 z)) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function expand-vis-box-with-point +;; WARN: Return type mismatch int vs none. +(defun expand-vis-box-with-point ((arg0 entity) (arg1 vector)) + (let ((v1-1 (res-lump-data arg0 'visvol (inline-array vector)))) + (when v1-1 + (let ((a0-2 (-> v1-1 0)) + (v1-2 (-> v1-1 1)) + ) + (set! (-> a0-2 x) (fmin (-> a0-2 x) (-> arg1 x))) + (set! (-> a0-2 y) (fmin (-> a0-2 y) (-> arg1 y))) + (set! (-> a0-2 z) (fmin (-> a0-2 z) (-> arg1 z))) + (set! (-> v1-2 x) (fmax (-> v1-2 x) (-> arg1 x))) + (set! (-> v1-2 y) (fmax (-> v1-2 y) (-> arg1 y))) + (set! (-> v1-2 z) (fmax (-> v1-2 z) (-> arg1 z))) + ) + ) + ) + 0 + (none) + ) + +;; definition of type debug-actor-info +(deftype debug-actor-info (basic) + ((name string) + (handle handle) + (process process) + (pid int32) + ) + ) + +;; definition for method 3 of type debug-actor-info +(defmethod inspect ((this debug-actor-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Thandle: ~D~%" (-> this handle)) + (format #t "~1Tprocess: ~A~%" (-> this process)) + (format #t "~1Tpid: ~D~%" (-> this pid)) + (label cfg-4) + this + ) + +;; definition for symbol *debug-actor-info*, type debug-actor-info +(define *debug-actor-info* (new 'static 'debug-actor-info :name #f)) + +;; definition for symbol *pid-string*, type string +(define *pid-string* (new 'global 'string 128 (the-as string #f))) + +;; definition (debug) for function debug-actor +;; WARN: Return type mismatch int vs none. +(defun-debug debug-actor ((arg0 string)) + (let ((gp-0 *debug-actor-info*)) + (set! (-> gp-0 name) #f) + (set! (-> gp-0 handle) (the-as handle #f)) + (cond + ((string-prefix= "pid " arg0) + (let ((s4-0 (length arg0))) + (when (< 4 s4-0) + (clear *pid-string*) + (catn-string<-charp *pid-string* (&-> arg0 data 4) (+ s4-0 -4)) + (set! (-> gp-0 pid) (string->int *pid-string*)) + ) + ) + (let ((gp-1 (lambda ((arg0 process)) (let ((v1-0 *debug-actor-info*)) + (when (= (-> arg0 pid) (-> v1-0 pid)) + (let ((v0-0 (process->handle arg0))) + (set! (-> v1-0 handle) (the-as handle v0-0)) + v0-0 + ) + ) + ) + ) + ) + ) + (iterate-process-tree *pusher-pool* gp-1 *null-kernel-context*) + (iterate-process-tree *entity-pool* gp-1 *null-kernel-context*) + ) + ) + (else + (set! (-> gp-0 name) arg0) + ) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function debug-actor-process +;; WARN: Return type mismatch int vs none. +(defun-debug debug-actor-process ((arg0 process)) + (let ((v1-0 *debug-actor-info*)) + (set! (-> v1-0 handle) (process->handle arg0)) + ) + (none) + ) + +;; definition (debug) for function draw-actor-marks +;; WARN: Return type mismatch int vs none. +(defun-debug draw-actor-marks ((arg0 process)) + (local-vars (sv-16 entity-actor) (sv-20 (pointer int32))) + (b! + (not (and (or (type? arg0 process-drawable) (= (-> arg0 type) part-tracker) (type? arg0 part-spawner)) + (nonzero? (-> (the-as process-drawable arg0) root)) + ) + ) + cfg-51 + :delay (nop!) + ) + (when (type? arg0 process-drawable) + (when (and (-> (the-as process-drawable arg0) nav) (nonzero? (-> (the-as process-drawable arg0) nav))) + (if (= arg0 *debug-actor*) + (debug-draw (-> (the-as process-drawable arg0) nav)) + ) + ) + (if (nonzero? (-> (the-as process-drawable arg0) path)) + (path-control-method-9 (-> (the-as process-drawable arg0) path)) + ) + (if (nonzero? (-> (the-as process-drawable arg0) vol)) + (debug-draw (-> (the-as process-drawable arg0) vol)) + ) + (if (and (nonzero? (-> (the-as process-drawable arg0) draw)) *display-actor-vis*) + (add-debug-sphere + #t + (bucket-id bucket583) + (-> (the-as process-drawable arg0) draw origin) + (-> (the-as process-drawable arg0) draw bounds w) + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + ) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> (the-as process-drawable arg0) root trans) + (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80) + ) + (set! sv-16 (-> arg0 entity)) + (cond + ((and sv-16 (= (-> sv-16 extra process) arg0)) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (res-lump-struct sv-16 'name string) + (-> (the-as process-drawable arg0) root trans) + (if (logtest? (-> sv-16 extra perm status) (entity-perm-status bit-0 error)) + (font-color red) + (font-color white) + ) + (new 'static 'vector2h :y 8) + ) + (set! sv-20 (res-lump-data sv-16 'eco-info (pointer int32) :time 0.0)) + (when sv-20 + (let ((s5-1 add-debug-text-3d) + (s4-1 #t) + (s3-1 577) + ) + (format (clear *temp-string*) "~S ~D~%" (pickup-type->string (the-as pickup-type (-> sv-20 0))) (-> sv-20 1)) + (s5-1 + s4-1 + (the-as bucket-id s3-1) + *temp-string* + (-> (the-as process-drawable arg0) root trans) + (font-color white) + (new 'static 'vector2h :y 24) + ) + ) + ) + (let ((a0-23 (res-lump-struct sv-16 'art-name string))) + (if (and a0-23 (logtest? (the-as int a0-23) 1)) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (symbol->string-debug (the-as symbol a0-23)) + (-> (the-as process-drawable arg0) root trans) + (font-color white) + (new 'static 'vector2h :y 24) + ) + ) + ) + (when *display-actor-vis* + (let ((v1-56 (res-lump-data sv-16 'visvol (inline-array vector))) + (a1-14 (-> sv-16 extra vis-id)) + ) + (if v1-56 + (add-debug-box + #t + (bucket-id debug-no-zbuf1) + (-> v1-56 0) + (-> v1-56 1) + (if (is-object-visible? (-> sv-16 extra level) a1-14) + (new 'static 'rgba :g #x80 :b #x80 :a #x80) + (new 'static 'rgba :r #x80 :b #x80 :a #x80) + ) + ) + ) + ) + ) + ) + (else + (let ((s5-4 add-debug-text-3d) + (s4-4 #t) + (s3-4 577) + ) + (format (clear *temp-string*) "pid ~d" (-> arg0 pid)) + (s5-4 + s4-4 + (the-as bucket-id s3-4) + *temp-string* + (-> (the-as process-drawable arg0) root trans) + (font-color green) + (new 'static 'vector2h :y 8) + ) + ) + ) + ) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (if (-> arg0 state) + (symbol->string-debug (-> arg0 state name)) + "#f" + ) + (-> (the-as process-drawable arg0) root trans) + (font-color white) + (new 'static 'vector2h :y 16) + ) + (label cfg-51) + 0 + (none) + ) + +;; definition for method 15 of type level-group +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-actors ((this level-group) (arg0 symbol)) + (local-vars + (sv-16 symbol) + (sv-20 vector) + (sv-32 int) + (sv-48 (function symbol bucket-id vector vector rgba symbol)) + (sv-64 symbol) + (sv-80 int) + (sv-96 pointer) + (sv-112 pointer) + (sv-128 int) + ) + (let ((s4-0 *debug-actor-info*)) + (set! (-> s4-0 process) #f) + (if (zero? (-> s4-0 handle pid)) + (set! (-> s4-0 handle) + (logior (logand (-> s4-0 handle) (shl (the-as uint #xffffffff) 32)) (shr (shl (the-as int #f) 32) 32)) + ) + ) + (let ((v1-7 (handle->process (-> s4-0 handle)))) + (when (not v1-7) + (when (-> s4-0 name) + (let ((s3-0 (process-by-name (-> s4-0 name) *active-pool*))) + (set! v1-7 (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (set! (-> s4-0 handle) (process->handle v1-7)) + ) + ) + (set! (-> s4-0 process) v1-7) + ) + (set! *debug-actor* (-> s4-0 process)) + ) + (set! sv-16 arg0) + (when (and sv-16 (not (or (= *master-mode* 'menu) (= *master-mode* 'progress)))) + (cond + ((= sv-16 'process) + (let ((s5-1 draw-actor-marks)) + (iterate-process-tree *pusher-pool* s5-1 *null-kernel-context*) + (iterate-process-tree *entity-pool* s5-1 *null-kernel-context*) + ) + ) + (else + (dotimes (s5-2 (-> this length)) + (let ((v1-21 (-> this level s5-2))) + (when (= (-> v1-21 status) 'active) + (let ((s4-1 (-> v1-21 bsp level entity))) + (dotimes (s3-1 (-> s4-1 length)) + (let ((s2-0 (-> s4-1 data s3-1 entity))) + (set! sv-20 (-> s2-0 extra trans)) + (when (or (= sv-16 'full) (-> s2-0 extra process)) + (add-debug-x #t (bucket-id debug-no-zbuf1) sv-20 (if (-> s2-0 extra process) + (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80) + (new 'static 'rgba :r #xff :a #x80) + ) + ) + (when (< (vector-vector-distance (math-camera-pos) sv-20) 491520.0) + (let ((s1-1 add-debug-text-3d) + (s0-0 #t) + ) + (set! sv-32 577) + (let ((a2-4 (res-lump-struct s2-0 'name structure)) + (a3-2 sv-20) + (t0-1 (if (logtest? (-> s2-0 extra perm status) (entity-perm-status bit-0 error)) + 1 + 5 + ) + ) + (t1-1 (new 'static 'vector2h :y 8)) + ) + (s1-1 s0-0 (the-as bucket-id sv-32) (the-as string a2-4) a3-2 (the-as font-color t0-1) t1-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (when (and *display-actor-vis* (not *debug-actor*)) + (let ((s5-3 *display-actor-vis*)) + (dotimes (s4-2 (-> this length)) + (let ((s3-2 (-> this level s4-2))) + (when (= (-> s3-2 status) 'active) + (let ((s2-1 (-> s3-2 bsp level entity))) + (dotimes (s1-2 (-> s2-1 length)) + (let ((s0-1 (-> s2-1 data s1-2 entity))) + (let ((v0-9 (res-lump-data s0-1 'visvol pointer)) + (a1-16 (-> s0-1 extra vis-id)) + ) + (when (and v0-9 (or (= s5-3 #t) (= s5-3 'box))) + (set! sv-48 add-debug-box) + (set! sv-64 #t) + (set! sv-80 577) + (set! sv-96 (&+ v0-9 0)) + (set! sv-112 (&+ v0-9 16)) + (let ((t0-3 (if (is-object-visible? s3-2 a1-16) + (the-as uint #x80808000) + (the-as uint #x80800080) + ) + ) + ) + (sv-48 sv-64 (the-as bucket-id sv-80) (the-as vector sv-96) (the-as vector sv-112) (the-as rgba t0-3)) + ) + ) + ) + (when (or (= s5-3 #t) (= s5-3 'sphere)) + (let ((s0-2 (-> s0-1 extra process))) + (when s0-2 + (when (and (type? s0-2 process-drawable) (nonzero? (-> (the-as process-drawable s0-2) draw))) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> (the-as process-drawable s0-2) root trans) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (add-debug-sphere + #t + (bucket-id bucket583) + (-> (the-as process-drawable s0-2) draw origin) + (-> (the-as process-drawable s0-2) draw bounds w) + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if *generate-actor-vis* + (update-vis-volumes this) + ) + (cond + (*debug-actor* + (let* ((s4-3 *debug-actor*) + (s5-4 (if (type? s4-3 process-drawable) + (the-as process-drawable s4-3) + ) + ) + ) + (when s5-4 + (if (nonzero? (-> s5-4 skel)) + (debug-print-channels (-> s5-4 skel) (the-as symbol *stdcon*)) + ) + (when (and (nonzero? (-> s5-4 nav)) (-> s5-4 nav) *display-nav-marks*) + (let ((s4-4 (-> s5-4 nav state flags))) + (if (= (logand s4-4 (nav-state-flag in-target-poly)) (nav-state-flag in-target-poly)) + (format *stdcon* "in-target-poly ") + ) + (if (= (logand s4-4 (nav-state-flag directional-mode)) (nav-state-flag directional-mode)) + (format *stdcon* "directional-mode ") + ) + (if (= (logand s4-4 (nav-state-flag initialized)) (nav-state-flag initialized)) + (format *stdcon* "initialized ") + ) + (if (= (logand s4-4 (nav-state-flag display-marks)) (nav-state-flag display-marks)) + (format *stdcon* "display-marks ") + ) + (if (= (logand s4-4 (nav-state-flag recovery-mode)) (nav-state-flag recovery-mode)) + (format *stdcon* "recovery-mode ") + ) + (if (= (logand s4-4 (nav-state-flag touching-sphere)) (nav-state-flag touching-sphere)) + (format *stdcon* "touching-sphere ") + ) + (if (= (logand s4-4 (nav-state-flag trapped-by-sphere)) (nav-state-flag trapped-by-sphere)) + (format *stdcon* "trapped-by-sphere ") + ) + (if (= (logand s4-4 (nav-state-flag blocked)) (nav-state-flag blocked)) + (format *stdcon* "blocked ") + ) + (if (= (logand s4-4 (nav-state-flag avoiding-sphere)) (nav-state-flag avoiding-sphere)) + (format *stdcon* "avoiding-sphere ") + ) + (if (= (logand s4-4 (nav-state-flag target-inside)) (nav-state-flag target-inside)) + (format *stdcon* "target-inside ") + ) + (if (= (logand s4-4 (nav-state-flag debug)) (nav-state-flag debug)) + (format *stdcon* "debug ") + ) + (if (= (logand s4-4 (nav-state-flag at-gap)) (nav-state-flag at-gap)) + (format *stdcon* "at-gap ") + ) + (if (= (logand s4-4 (nav-state-flag use-position)) (nav-state-flag use-position)) + (format *stdcon* "user-position ") + ) + (if (= (logand s4-4 (nav-state-flag in-mesh)) (nav-state-flag in-mesh)) + (format *stdcon* "in-mesh ") + ) + (if (= (logand s4-4 (nav-state-flag at-target)) (nav-state-flag at-target)) + (format *stdcon* "at-target ") + ) + (if (= (logand s4-4 (nav-state-flag target-poly-dirty)) (nav-state-flag target-poly-dirty)) + (format *stdcon* "target-poly-dirty ") + ) + ) + (format *stdcon* "~%") + ) + (when *display-joint-axes* + (if (and (type? s5-4 process-drawable) (nonzero? (-> s5-4 draw))) + (draw-joint-axes s5-4) + ) + ) + (draw-actor-marks s5-4) + ) + ) + ) + (*display-nav-mesh* + (dotimes (s5-5 (-> this length)) + (let ((v1-145 (-> this level s5-5))) + (when (= (-> v1-145 status) 'active) + (let ((s4-5 (-> v1-145 bsp nav-meshes))) + (when (nonzero? s4-5) + (dotimes (s3-3 (-> s4-5 length)) + (let ((s2-2 (-> s4-5 s3-3))) + (if (name= *display-nav-mesh* (res-lump-struct s2-2 'name structure)) + (debug-draw s2-2) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (else + (when *display-nav-marks* + (dotimes (s5-6 (-> this length)) + (let ((v1-163 (-> this level s5-6))) + (when (= (-> v1-163 status) 'active) + (let ((s4-6 (-> v1-163 bsp nav-meshes))) + (when (nonzero? s4-6) + (dotimes (s3-4 (-> s4-6 length)) + (debug-draw (-> s4-6 s3-4)) + ) + ) + ) + ) + ) + ) + ) + (if (or *display-path-marks* *display-vol-marks*) + (iterate-process-tree + *active-pool* + (lambda ((arg0 process)) (when (type? arg0 process-drawable) + (if (nonzero? (-> (the-as process-drawable arg0) path)) + (path-control-method-9 (-> (the-as process-drawable arg0) path)) + ) + (if (nonzero? (-> (the-as process-drawable arg0) vol)) + (debug-draw (-> (the-as process-drawable arg0) vol)) + ) + ) + ) + *null-kernel-context* + ) + ) + ) + ) + (when (and *display-actor-graph* (not (or (= *master-mode* 'menu) (= *master-mode* 'progress)))) + (if (not (paused?)) + (float-save-timeplot (if (< (the int (the float (mod (current-time) 600))) 300) + 1.0 + 0.0 + ) + ) + ) + (camera-plot-float-func + 0.0 + 399.0 + -81920.0 + 81920.0 + float-lookup-redline + (new 'static 'vector4w :x #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + -81920.0 + 81920.0 + float-lookup-blueline + (new 'static 'vector4w :z #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + -81920.0 + 81920.0 + float-lookup-greenline + (new 'static 'vector4w :y #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + 0.0 + 409600.0 + float-lookup-yellowline + (new 'static 'vector4w :x #xff :y #xff :w #x80) + ) + (camera-plot-float-func + 0.0 + 399.0 + 0.0 + 1.0 + float-lookup-timeplot + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + ) + ) + (when *display-split-boxes* + (dotimes (s5-7 (-> this length)) + (let ((v1-193 (-> this level s5-7))) + (when (= (-> v1-193 status) 'active) + (let ((s4-7 (-> v1-193 bsp region-tree))) + (when (nonzero? s4-7) + (let* ((s3-5 (-> s4-7 data2 (+ (-> s4-7 length) -1) length)) + (s2-3 0) + (a0-113 (the-as object (+ (+ (* s2-3 32) 32) (the-as int (-> s4-7 data2 (+ (-> s4-7 length) -1)))))) + ) + (while (< s2-3 s3-5) + (debug-draw-region (the-as drawable-region-prim a0-113) 0) + (+! s2-3 1) + (set! a0-113 (+ (+ (* s2-3 32) 32) (the-as int (-> s4-7 data2 (+ (-> s4-7 length) -1))))) + ) + ) + ) + ) + ) + ) + ) + ) + (when *display-region-marks* + (dotimes (s5-8 (-> this length)) + (let ((s4-8 (-> this level s5-8))) + (when (= (-> s4-8 status) 'active) + (when (nonzero? (-> s4-8 bsp region-trees)) + (let* ((s3-6 (-> s4-8 bsp region-trees length)) + (s2-4 0) + (s1-4 (-> s4-8 bsp region-trees s2-4)) + ) + (while (< s2-4 s3-6) + (let ((s0-4 (-> s1-4 data2 (+ (-> s1-4 length) -1) length))) + (set! sv-128 0) + (let ((a0-128 (the-as object (+ (+ (* sv-128 32) 32) (the-as int (-> s1-4 data2 (+ (-> s1-4 length) -1))))))) + (while (< sv-128 s0-4) + (debug-draw-region (the-as drawable-region-prim a0-128) 0) + (set! sv-128 (+ sv-128 1)) + (set! a0-128 (+ (+ (* sv-128 32) 32) (the-as int (-> s1-4 data2 (+ (-> s1-4 length) -1))))) + ) + ) + ) + (+! s2-4 1) + (set! s1-4 (-> s4-8 bsp region-trees s2-4)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 22 of type entity-camera +(defmethod birth! ((this entity-camera)) + (add-connection *camera-engine* *camera* nothing this #f #f) + this + ) + +;; definition for method 23 of type entity-camera +(defmethod kill! ((this entity-camera)) + (remove-by-param1 *camera-engine* (the-as int this)) + this + ) + +;; definition for function init-entity +;; WARN: Return type mismatch process vs none. +(defun init-entity ((arg0 process) (arg1 entity-actor) (arg2 type)) + (activate arg0 *entity-pool* (res-lump-struct arg1 'name string) (the-as pointer #x70004000)) + (set! (-> arg0 entity) arg1) + (set! (-> arg0 level) (-> arg1 extra level)) + (set! (-> arg1 extra process) arg0) + (run-now-in-process arg0 (method-of-object arg0 init-from-entity!) arg0 arg1) + (none) + ) + +;; definition for method 22 of type entity-actor +(defmethod birth! ((this entity-actor)) + (let* ((s5-0 (-> this etype)) + (v1-0 (entity-info-lookup s5-0)) + (s4-0 (get-process + *default-dead-pool* + s5-0 + (if v1-0 + (-> v1-0 heap-size) + #x4000 + ) + 0 + ) + ) + ) + (cond + ((not s4-0) + ) + ((begin + (set! (-> s4-0 type) s5-0) + (and s5-0 + (valid? s5-0 type (the-as string #f) #f 0) + (valid? (method-of-object s4-0 init-from-entity!) function (the-as string #f) #f 0) + ) + ) + (init-entity s4-0 this s5-0) + ) + (else + (when (not (birth-viewer s4-0 this)) + (format 0 "ERROR: no proper process type named ~A exists in the code, could not start ~A~%" s5-0 this) + (logior! (-> this extra perm status) (entity-perm-status bit-0)) + ) + ) + ) + ) + this + ) + +;; definition for function entity-deactivate-handler +;; WARN: Return type mismatch symbol vs none. +(defun entity-deactivate-handler ((arg0 process) (arg1 entity-actor)) + (when (= arg0 (-> arg1 extra process)) + (logclear! (-> arg1 extra perm status) (entity-perm-status error no-kill)) + (set! (-> arg1 extra process) #f) + ) + (none) + ) + +;; definition for method 23 of type entity-actor +(defmethod kill! ((this entity-actor)) + (let ((a0-1 (-> this extra process))) + (if a0-1 + (deactivate a0-1) + (entity-deactivate-handler a0-1 this) + ) + ) + this + ) + +;; definition for method 17 of type bsp-header +;; INFO: Used lq/sq +;; WARN: Return type mismatch bsp-header vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 s5, Count] +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count] +(defmethod birth ((this bsp-header)) + (local-vars (v1-75 int) (s5-0 int) (sv-16 int)) + (.mfc0 s5-0 Count) + (let ((a2-0 (if (nonzero? (-> this actors)) + (-> this actors length) + 0 + ) + ) + ) + (cond + ((not (-> this level entity)) + (set! (-> this level entity) (new 'loading-level 'entity-links-array a2-0)) + ) + ((< (-> this level entity allocated-length) a2-0) + (format + 0 + "ERROR: Attempting to rebirth level ~A with incorrect entity table size ~D/~D~%" + (-> this level) + a2-0 + (-> this level entity allocated-length) + ) + ) + ) + ) + (set! (-> this level entity length) 0) + 0 + (when (nonzero? (-> this actors)) + (dotimes (s4-0 (-> this actors length)) + (let* ((a0-4 (-> this actor-birth-order s4-0)) + (v1-23 (-> this actors data (logand a0-4 8191) actor)) + ) + (add-to-level! v1-23 *level* (-> this level) (the-as actor-id (-> v1-23 aid))) + ) + ) + ) + (let ((s4-1 (-> this cameras))) + (when (nonzero? s4-1) + (dotimes (s3-0 (-> s4-1 length)) + (birth! (-> s4-1 s3-0)) + ) + ) + ) + (let ((s4-2 (-> this level status))) + (set! (-> this level status) 'active) + (do-nothing *level*) + (dotimes (s3-1 (-> *level* length)) + (let ((s2-0 (-> *level* level s3-1))) + (when (= (-> s2-0 status) 'active) + (when (nonzero? (-> s2-0 bsp actor-groups)) + (countdown (s1-0 (-> s2-0 bsp actor-groups length)) + (let ((s0-0 (-> s2-0 bsp actor-groups s1-0))) + (set! sv-16 0) + (while (< sv-16 (-> s0-0 length)) + (if (not (-> s0-0 data sv-16 actor)) + (set! (-> s0-0 data sv-16 actor) (entity-by-aid (-> s0-0 data sv-16 id))) + ) + (set! sv-16 (+ sv-16 1)) + ) + ) + ) + ) + ) + ) + ) + (set! (-> this level status) s4-2) + ) + (.mfc0 v1-75 Count) + (let ((a3-2 (- v1-75 s5-0))) + (format 0 "Done ~S in ~D~%" "birth" a3-2) + ) + (none) + ) + +;; definition for function check-for-rougue-process +;; WARN: Return type mismatch int vs none. +(defun check-for-rougue-process ((arg0 process) (arg1 int) (arg2 int) (arg3 level)) + (cond + ((-> arg0 entity) + (cond + ((or (= (-> arg0 level) arg3) (= (-> arg0 entity extra level) arg3)) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((let ((v1-9 (-> arg0 name))) + (and (>= (the-as int v1-9) arg1) (< (the-as int v1-9) arg2)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((and (logtest? (-> arg0 entity extra kill-mask) (task-mask ctywide)) + (or (= (-> arg3 name) 'ctywide) (= (-> arg3 name) 'waswide)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((and (logtest? (-> arg0 entity extra kill-mask) (task-mask vehicle)) + (or (= (-> arg3 name) 'ctywide) (= (-> arg3 name) 'wasall)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((and (logtest? (-> arg0 entity extra kill-mask) (task-mask primary0)) + (logtest? (-> arg3 info base-task-mask) (task-mask primary0)) + ) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ) + ) + ((= (-> arg0 level) arg3) + (format #t "NOTICE: rogue level entity ~A still alive~%" arg0) + (deactivate arg0) + ) + ((= (-> arg0 type) part-tracker) + (let ((v1-45 (the-as part-tracker arg0))) + (if (and (nonzero? (-> v1-45 part)) + (>= (the-as int (-> v1-45 part group)) arg1) + (< (the-as int (-> v1-45 part group)) arg2) + ) + (deactivate arg0) + ) + ) + ) + ((type? arg0 part-spawner) + (let ((v1-50 (the-as part-spawner arg0))) + (if (and (nonzero? (-> v1-50 part)) + (>= (the-as int (-> v1-50 part group)) arg1) + (< (the-as int (-> v1-50 part group)) arg2) + ) + (deactivate arg0) + ) + ) + ) + (else + (let* ((s3-0 arg0) + (v1-55 (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (when v1-55 + (cond + ((and (nonzero? (-> (the-as process-drawable v1-55) part)) + (>= (the-as int (-> (the-as process-drawable v1-55) part group)) arg1) + (< (the-as int (-> (the-as process-drawable v1-55) part group)) arg2) + ) + (format + #t + "NOTICE: rogue null level entity (using part ~A) ~A still alive~%" + (-> (the-as process-drawable v1-55) part group) + arg0 + ) + (deactivate arg0) + ) + ((and (nonzero? (-> (the-as process-drawable v1-55) draw)) + (>= (the-as int (-> (the-as process-drawable v1-55) draw art-group)) arg1) + (< (the-as int (-> (the-as process-drawable v1-55) draw art-group)) arg2) + ) + (format + #t + "NOTICE: rogue null level entity (using art ~A) ~A still alive~%" + (-> (the-as process-drawable v1-55) draw art-group) + arg0 + ) + (deactivate arg0) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 18 of type bsp-header +;; WARN: Return type mismatch bsp-header vs none. +(defmethod deactivate-entities ((this bsp-header)) + (let ((v1-1 (-> this level heap base)) + (a0-2 (-> this level heap top-base)) + ) + (when (nonzero? (-> this actor-groups)) + (dotimes (a1-2 (-> this actor-groups length)) + (let ((a2-2 (-> this actor-groups a1-2))) + (dotimes (a3-1 (-> a2-2 length)) + (let ((t0-2 (-> a2-2 data a3-1 actor))) + (if (and t0-2 (not (and (>= (the-as int t0-2) (the-as int v1-1)) (< (the-as int t0-2) (the-as int a0-2))))) + (set! (-> a2-2 data a3-1 actor) #f) + ) + ) + ) + ) + ) + ) + (dotimes (a1-5 (-> *level* length)) + (let ((a2-10 (-> *level* level a1-5))) + (when (= (-> a2-10 status) 'active) + (when (!= a2-10 (-> this level)) + (when (nonzero? (-> a2-10 bsp actor-groups)) + (dotimes (a3-10 (-> a2-10 bsp actor-groups length)) + (let ((t0-13 (-> a2-10 bsp actor-groups a3-10))) + (dotimes (t1-2 (-> t0-13 length)) + (let ((t2-3 (-> t0-13 data t1-2 actor))) + (if (and t2-3 (>= (the-as int t2-3) (the-as int v1-1)) (< (the-as int t2-3) (the-as int a0-2))) + (set! (-> t0-13 data t1-2 actor) #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s5-0 (-> this actors))) + (when (nonzero? s5-0) + (dotimes (s4-0 (-> s5-0 length)) + (let ((s3-0 (-> s5-0 data s4-0 actor))) + (kill! s3-0) + (remove-from-level! s3-0 *level*) + ) + ) + ) + ) + (let ((s5-1 (-> this cameras))) + (when (nonzero? s5-1) + (dotimes (s4-1 (-> s5-1 length)) + (kill! (-> s5-1 s4-1)) + ) + ) + ) + (let ((v1-23 (-> this level heap base)) + (a0-7 (-> this level heap top-base)) + (s5-2 (lambda ((arg0 process)) (check-for-rougue-process + arg0 + (-> *kernel-context* relocating-min) + (-> *kernel-context* relocating-max) + (-> *kernel-context* relocating-level) + ) + ) + ) + ) + (set! (-> *kernel-context* relocating-min) (the-as int v1-23)) + (set! (-> *kernel-context* relocating-max) (the-as int a0-7)) + (set! (-> *kernel-context* relocating-level) (-> this level)) + (iterate-process-tree *pusher-pool* s5-2 *null-kernel-context*) + (iterate-process-tree *entity-pool* s5-2 *null-kernel-context*) + (iterate-process-tree *default-pool* s5-2 *null-kernel-context*) + ) + (let ((s5-3 (-> this nav-meshes))) + (when (nonzero? s5-3) + (dotimes (s4-2 (-> s5-3 length)) + (kill! (-> s5-3 s4-2)) + ) + ) + ) + (none) + ) + +;; definition for function process-drawable-scale-from-entity! +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun process-drawable-scale-from-entity! ((arg0 process-drawable) (arg1 entity)) + (let ((v1-1 (res-lump-struct arg1 'scale vector))) + (if v1-1 + (set! (-> arg0 root scale quad) (-> v1-1 quad)) + (vector-identity! (-> arg0 root scale)) + ) + ) + 0 + (none) + ) + +;; definition for function process-drawable-from-entity! +;; INFO: Used lq/sq +;; WARN: Return type mismatch process-drawable vs none. +(defun process-drawable-from-entity! ((arg0 process-drawable) (arg1 entity-actor)) + (logior! (-> arg0 mask) (process-mask actor-pause)) + (set! (-> arg0 root trans quad) (-> arg1 extra trans quad)) + (quaternion-copy! (-> arg0 root quat) (-> arg1 quat)) + (vector-identity! (-> arg0 root scale)) + (none) + ) + +;; definition for method 9 of type entity-perm +(defmethod update ((this entity-perm) (arg0 symbol) (arg1 entity-perm-status)) + (cond + ((= arg0 'game) + (logclear! (-> this status) arg1) + ) + ((task-complete? *game-info* (-> this task)) + (if (or (= arg0 'try) (= arg0 'life)) + (logclear! (-> this status) (logior (if (logtest? (-> this status) (entity-perm-status bit-4)) + 524 + 0 + ) + #x8203 + ) + ) + (logclear! (-> this status) (logior (if (logtest? (-> this status) (entity-perm-status bit-4)) + 524 + 0 + ) + 515 + ) + ) + ) + ) + (else + (logclear! (-> this status) (logclear + (logior arg1 (if (logtest? (-> this status) (entity-perm-status bit-4)) + 524 + 0 + ) + ) + (if (logtest? (-> this status) (entity-perm-status bit-14)) + 32 + 0 + ) + ) + ) + ) + ) + (when (not (logtest? (-> this status) (entity-perm-status bit-5))) + (set! (-> this user-uint64) (the-as uint 0)) + 0 + ) + this + ) + +;; definition for function reset-actors +;; WARN: Return type mismatch int vs none. +(defun reset-actors ((arg0 symbol)) + (let* ((v1-0 arg0) + (perm + (cond + ((or (= v1-0 'life) (= v1-0 'debug)) + (the-as + entity-perm-status + (entity-perm-status bit-0 error dead no-kill bit-5 subtask-complete bit-9 bit-12 bit-15) + ) + ) + ((= v1-0 'try) + (the-as + entity-perm-status + (entity-perm-status bit-0 error dead no-kill bit-5 subtask-complete bit-9 bit-12 bit-15) + ) + ) + ((= v1-0 'game) + (the-as entity-perm-status (entity-perm-status + bit-0 + error + dead + no-kill + bit-4 + bit-5 + subtask-complete + complete + bit-9 + bit-10 + save + bit-12 + bit-13 + bit-15 + ) + ) + ) + (else + (the-as + entity-perm-status + (entity-perm-status bit-0 error dead no-kill bit-4 bit-5 subtask-complete bit-9 bit-10 bit-12 bit-15) + ) + ) + ) + ) + (s4-0 *game-info*) + ) + (dotimes (s3-0 (-> *level* length)) + (let ((v1-4 (-> *level* level s3-0))) + (when (or (= (-> v1-4 status) 'active) (= (-> v1-4 status) 'alive) (= (-> v1-4 status) 'loaded)) + (when (-> v1-4 part-engine) + (set! (-> v1-4 part-engine length) 0) + 0 + ) + (when (-> v1-4 entity) + (let ((s2-0 (-> v1-4 bsp level entity))) + (dotimes (s1-0 (-> s2-0 length)) + (let ((s0-0 (-> s2-0 data s1-0 entity))) + (if (not (and (-> s0-0 extra process) (logtest? (-> s0-0 extra process mask) (process-mask no-kill)))) + (kill! s0-0) + ) + (update (-> s0-0 extra perm) arg0 (the-as entity-perm-status perm)) + ) + ) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s4-0 task-perm-list))) + (dotimes (s2-1 (-> s3-1 length)) + (update (-> s3-1 data s2-1) arg0 (the-as entity-perm-status perm)) + ) + (logior! (-> s3-1 data 1 status) (entity-perm-status complete)) + ) + (let ((s4-1 (-> s4-0 perm-list))) + (dotimes (s3-2 (-> s4-1 length)) + (update (-> s4-1 data s3-2) arg0 (the-as entity-perm-status perm)) + ) + ) + ) + (let ((s5-1 (lambda ((arg0 process)) (if (not (logtest? (-> arg0 mask) (process-mask no-kill))) + (deactivate arg0) + ) + ) + ) + ) + (iterate-process-tree *pusher-pool* s5-1 *null-kernel-context*) + (iterate-process-tree *entity-pool* s5-1 *null-kernel-context*) + ) + (if #t + (task-node-reset arg0) + ) + (dotimes (s5-2 (-> *level* length)) + (let ((s4-2 (-> *level* level s5-2))) + (when (= (-> s4-2 status) 'active) + (let ((s3-3 (the-as (function level none) (get-callback-symbol-value-by-slot! (-> s4-2 info) 35)))) + (if (and s3-3 (type? s3-3 function)) + (s3-3 s4-2) + ) + ) + ) + ) + ) + (set! (-> *ACTOR-bank* birth-max) 1000) + (update-task-masks arg0) + 0 + (none) + ) + +;; definition for function reset-cameras +;; WARN: Return type mismatch int vs none. +(defun reset-cameras () + (remove-all *camera-engine*) + (dotimes (gp-0 (-> *level* length)) + (let ((v1-5 (-> *level* level gp-0))) + (when (= (-> v1-5 status) 'active) + (let ((s5-0 (-> v1-5 bsp cameras))) + (when (nonzero? s5-0) + (dotimes (s4-0 (-> s5-0 length)) + (birth! (-> s5-0 s4-0)) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type process-drawable +(defmethod run-logic? ((this process-drawable)) + "Should this process be run? Checked by execute-process-tree." + (or (not (logtest? (-> this mask) (process-mask actor-pause))) + (or (>= (+ (-> *ACTOR-bank* pause-dist) (-> this root pause-adjust-distance)) + (vector-vector-distance (-> this root trans) (math-camera-pos)) + ) + (and (nonzero? (-> this skel)) (!= (-> this skel root-channel 0) (-> this skel channel))) + (and (nonzero? (-> this draw)) (logtest? (-> this draw status) (draw-control-status uninited))) + ) + ) + ) + +;; definition for method 9 of type entity-links +(defmethod birth? ((this entity-links) (arg0 vector)) + (and (not (logtest? (-> this perm status) (entity-perm-status bit-0 dead))) + (< (vector-vector-distance (-> this trans) arg0) (-> *ACTOR-bank* birth-dist)) + ) + ) + +;; definition for method 17 of type level-group +;; INFO: Used lq/sq +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 96 mismatch: defined as size 4, got size 16 +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 17 level-group) has a return type of none, but the expression builder found a return statement. +(defmethod actors-update ((this level-group)) + (local-vars + (sv-16 vector) + (sv-24 int) + (sv-32 task-mask) + (sv-48 entity-links) + (sv-64 string) + (sv-80 string) + (sv-96 float) + ) + (when *compact-actors* + (if (and (= *compact-actors* 'debug) (= (-> *nk-dead-pool* alive-list prev) (-> *nk-dead-pool* first-gap))) + (churn *nk-dead-pool* 1) + ) + (let ((s5-0 + (the int + (lerp-scale 8.0 1.0 (the float (-> *display* frames (-> *display* last-screen) run-time)) 2000.0 8000.0) + ) + ) + ) + (if (nonzero? *debug-dead-pool*) + (compact *debug-dead-pool* 10) + ) + (compact *nk-dead-pool* s5-0) + ) + ) + (update-actor-hash) + (when (not (paused?)) + (let ((s5-1 (-> *display* frames (-> *display* last-screen) run-time))) + (let ((f0-5 (fmax + 327680.0 + (fmin (+ 327680.0 (* 204.8 (the float (- 7000 (the-as int s5-1))))) (-> *ACTOR-bank* birth-dist)) + ) + ) + ) + (seek! (-> *ACTOR-bank* pause-dist) f0-5 (* 81920.0 (seconds-per-frame))) + ) + (seekl! (-> *ACTOR-bank* birth-max) (the int (lerp-scale 25.0 2.0 (the float s5-1) 2000.0 7000.0)) 10) + ) + (if (movie?) + (set! (-> *ACTOR-bank* birth-max) 1000) + ) + ) + (when *spawn-actors* + (set! sv-16 (if (movie?) + (math-camera-pos) + (camera-pos) + ) + ) + (set! sv-24 0) + (dotimes (s5-2 (-> this length)) + (let ((s4-1 (-> this level s5-2))) + (when (= (-> s4-1 status) 'active) + (set! sv-32 (-> s4-1 task-mask)) + (cond + ((= (-> s4-1 display?) 'special) + (let* ((s4-2 (-> s4-1 entity)) + (s3-1 (-> s4-2 length)) + ) + (dotimes (s2-0 s3-1) + (let ((v1-53 (-> s4-2 data s2-0))) + (cond + ((and (logtest? (-> v1-53 kill-mask) (task-mask special)) (not (logtest? (-> v1-53 kill-mask) sv-32))) + (when (not (or (-> v1-53 process) (logtest? (-> v1-53 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> v1-53 entity)) + (set! sv-24 (+ sv-24 1)) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + (else + (if (and (-> v1-53 process) + (not (logtest? (-> v1-53 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> v1-53 process mask) (process-mask no-kill))) + ) + (kill! (-> v1-53 entity)) + ) + ) + ) + ) + ) + ) + ) + ((= (-> s4-1 display?) 'actor) + (let* ((s4-3 (-> s4-1 entity)) + (s3-2 (-> s4-3 length)) + ) + (dotimes (s2-1 s3-2) + (let ((v1-66 (-> s4-3 data s2-1))) + (cond + ((not (logtest? (-> v1-66 kill-mask) sv-32)) + (when (not (or (-> v1-66 process) (logtest? (-> v1-66 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> v1-66 entity)) + (set! sv-24 (+ sv-24 1)) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + (else + (if (and (-> v1-66 process) + (not (logtest? (-> v1-66 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> v1-66 process mask) (process-mask no-kill))) + ) + (kill! (-> v1-66 entity)) + ) + ) + ) + ) + ) + ) + ) + ((not *vis-actors*) + (let* ((s4-4 (-> s4-1 entity)) + (s3-3 (-> s4-4 length)) + ) + (dotimes (s2-2 s3-3) + (let ((s1-0 (-> s4-4 data s2-2))) + (cond + ((and (< (vector-vector-distance (-> s1-0 trans) sv-16) (-> *ACTOR-bank* birth-dist)) + (not (logtest? (-> s1-0 perm status) (entity-perm-status bit-9 bit-10))) + (not (logtest? (-> s1-0 kill-mask) sv-32)) + ) + (when (not (or (-> s1-0 process) (logtest? (-> s1-0 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> s1-0 entity)) + (set! sv-24 (+ sv-24 1)) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + (else + (if (and (-> s1-0 process) + (not (logtest? (-> s1-0 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> s1-0 process mask) (process-mask no-kill))) + ) + (kill! (-> s1-0 entity)) + ) + ) + ) + ) + ) + ) + ) + (*vis-actors* + (when (not (and (-> s4-1 vis-info 0) (-> s4-1 all-visible?))) + (let* ((s3-4 (-> s4-1 entity)) + (s2-3 (-> s3-4 length)) + (s0-0 #f) + ) + (dotimes (s1-1 s2-3) + (set! sv-48 (-> s3-4 data s1-1)) + (cond + ((and (is-object-visible? s4-1 (-> sv-48 vis-id)) + (not (logtest? (-> sv-48 perm status) (entity-perm-status bit-9 bit-10))) + (not (logtest? (-> sv-48 kill-mask) sv-32)) + (or (-> s4-1 vis-info 0) (< (vector-vector-distance (-> sv-48 trans) sv-16) (-> sv-48 vis-dist))) + ) + (when (not (or (-> sv-48 process) (logtest? (-> sv-48 perm status) (entity-perm-status bit-0 dead)) s0-0)) + (birth! (-> sv-48 entity)) + (set! sv-24 (+ sv-24 1)) + (when (< (/ (the float (memory-free *nk-dead-pool*)) (the float (memory-total *nk-dead-pool*))) 0.1) + (when (and *debug-segment* (not *display-capture-mode*)) + (let ((s0-1 format)) + (set! sv-64 *stdcon*) + (set! sv-80 "low actor memory, no birth triggered!!! ~,,0fK/~,,0fK~%") + (set! sv-96 (* 0.0009765625 (the float (memory-free *nk-dead-pool*)))) + (let ((a3-2 (* 0.0009765625 (the float (memory-total *nk-dead-pool*))))) + (s0-1 sv-64 sv-80 sv-96 a3-2) + ) + ) + ) + (set! s0-0 #t) + ) + ) + ) + (else + (when (and (-> sv-48 process) + (not (logtest? (-> sv-48 perm status) (entity-perm-status no-kill))) + (not (logtest? (-> sv-48 process mask) (process-mask no-kill))) + ) + (kill! (-> sv-48 entity)) + (set! sv-24 (+ sv-24 1)) + ) + ) + ) + (if (>= sv-24 (-> *ACTOR-bank* birth-max)) + (return #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function entity-birth-no-kill +(defun entity-birth-no-kill ((arg0 entity)) + (let ((gp-0 (-> arg0 extra))) + (logior! (-> gp-0 perm status) (entity-perm-status no-kill)) + (if (not (or (-> gp-0 process) (logtest? (-> gp-0 perm status) (entity-perm-status bit-0 dead)))) + (birth! (-> gp-0 entity)) + ) + (-> gp-0 process) + ) + ) + +;; definition for function entity-task-complete-on +;; WARN: Return type mismatch int vs none. +(defun entity-task-complete-on ((arg0 entity)) + (let ((v1-0 (-> arg0 extra))) + (if (nonzero? (-> v1-0 perm task)) + (logior! (-> *game-info* task-perm-list data (-> v1-0 perm task) status) (entity-perm-status complete)) + ) + ) + 0 + (none) + ) + +;; definition for function entity-task-complete-off +;; WARN: Return type mismatch int vs none. +(defun entity-task-complete-off ((arg0 entity)) + (let ((v1-0 (-> arg0 extra))) + (if (!= (-> v1-0 perm task) (game-task complete)) + (logclear! (-> *game-info* task-perm-list data (-> v1-0 perm task) status) (entity-perm-status complete)) + ) + ) + 0 + (none) + ) + +;; definition for method 30 of type entity-actor +;; WARN: Return type mismatch entity-perm-status vs none. +(defmethod toggle-status ((this entity-actor) (arg0 entity-perm-status) (arg1 symbol)) + (let ((v1-0 (-> this extra))) + (if arg1 + (logior! (-> v1-0 perm status) arg0) + (logclear! (-> v1-0 perm status) arg0) + ) + (-> v1-0 perm status) + ) + (none) + ) + +;; definition for function process-entity-status! +;; WARN: Return type mismatch int vs entity-perm-status. +(defun process-entity-status! ((arg0 process) (arg1 entity-perm-status) (arg2 symbol)) + (the-as entity-perm-status (cond + ((and (-> arg0 entity) arg0 (= arg0 (-> arg0 entity extra process))) + (let ((v1-6 (-> arg0 entity extra))) + (if arg2 + (logior! (-> v1-6 perm status) arg1) + (logclear! (-> v1-6 perm status) arg1) + ) + (the-as int (-> v1-6 perm status)) + ) + ) + (else + 0 + ) + ) + ) + ) + +;; definition for function find-nearest-entity +;; WARN: Return type mismatch entity-actor vs entity. +(defun find-nearest-entity ((arg0 vector) (arg1 type)) + (local-vars (v1-8 object)) + (let ((gp-0 (the-as entity-actor #f))) + (let ((f30-0 0.0) + (f28-0 0.0) + ) + (dotimes (s3-0 (-> *level* length)) + (let ((v1-3 (-> *level* level s3-0))) + (when (= (-> v1-3 status) 'active) + (let ((s2-0 (-> v1-3 bsp actors))) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 length)) + (let ((s0-0 (-> s2-0 data s1-0 actor))) + (let ((v1-7 (or (not arg1) (type-type? (-> s0-0 etype) arg1)))) + (b! (not v1-7) cfg-15 :likely-delay (set! v1-8 v1-7)) + ) + (set! f28-0 (vector-vector-distance arg0 (-> s0-0 extra trans))) + (set! v1-8 f28-0) + (b! (not (the int v1-8)) cfg-15 :likely-delay (nop!)) + (set! v1-8 (or (not gp-0) (< f28-0 f30-0))) + (label cfg-15) + (when v1-8 + (set! gp-0 s0-0) + (set! f30-0 f28-0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as entity gp-0) + ) + ) + +;; definition (debug) for function entity-speed-test +;; ERROR: Unsupported inline assembly instruction kind - [mfc0 s4, Count] +(defun-debug entity-speed-test ((arg0 string)) + (local-vars (s4-0 int)) + (let ((gp-0 (entity-by-name arg0))) + (when gp-0 + (set! *spawn-actors* #f) + (reset-actors 'debug) + 0 + (disable-irq) + (.mtc0 Count 0) + (.sync.p) + (birth! gp-0) + (.mfc0 s4-0 Count) + (enable-irq) + (format #t "~D spawn ~A ~A ~%" s4-0 arg0 (-> gp-0 extra process)) + (kill! gp-0) + ) + ) + ) + +;; definition (debug) for function dump-entity-remap +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun-debug dump-entity-remap ((arg0 object) (arg1 object)) + (local-vars + (sv-16 symbol) + (sv-32 string) + (sv-48 symbol) + (sv-64 string) + (sv-80 symbol) + (sv-96 string) + (sv-112 string) + ) + (format #t "~%(:eval (remap-entity-list '(") + (dotimes (s4-0 (-> *level* length)) + (let ((s3-0 (-> *level* level s4-0))) + (when (= (-> s3-0 status) 'active) + (when (= (-> s3-0 name) arg0) + (let ((s2-0 (-> s3-0 bsp actors))) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 length)) + (let ((a0-4 (-> s2-0 data s1-0 actor)) + (s0-0 format) + ) + (set! sv-16 #t) + (set! sv-32 "~A ") + (let ((a2-1 (res-lump-struct a0-4 'name structure))) + (s0-0 sv-16 sv-32 a2-1) + ) + ) + ) + ) + ) + (let ((s2-1 (-> s3-0 bsp nav-meshes))) + (when (nonzero? s2-1) + (dotimes (s1-1 (-> s2-1 length)) + (let ((a0-6 (-> s2-1 s1-1)) + (s0-1 format) + ) + (set! sv-48 #t) + (set! sv-64 "~A ") + (let ((a2-3 (res-lump-struct a0-6 'name structure))) + (s0-1 sv-48 sv-64 a2-3) + ) + ) + ) + ) + ) + (let ((s2-2 (-> s3-0 bsp race-meshes))) + (when (nonzero? s2-2) + (dotimes (s1-2 (-> s2-2 length)) + (let ((a0-8 (-> s2-2 s1-2)) + (s0-2 format) + ) + (set! sv-80 #t) + (set! sv-96 "~A ") + (let ((a2-5 (res-lump-struct a0-8 'name structure))) + (s0-2 sv-80 sv-96 a2-5) + ) + ) + ) + ) + ) + (let ((s3-1 (-> s3-0 bsp cameras))) + (when (nonzero? s3-1) + (dotimes (s2-3 (-> s3-1 length)) + (let ((a0-10 (-> s3-1 s2-3)) + (s1-3 format) + (s0-3 #t) + ) + (set! sv-112 "~A ") + (let ((a2-7 (res-lump-struct a0-10 'name structure))) + (s1-3 s0-3 sv-112 a2-7) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (format #t ") '~A '~A))~%~%" arg0 arg1) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/generic/lightning/lightning-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/generic/lightning/lightning-h_REF.gc index 3a07f20187..782ddd2273 100644 --- a/test/decompiler/reference/jak3/engine/gfx/generic/lightning/lightning-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/generic/lightning/lightning-h_REF.gc @@ -21,7 +21,7 @@ (radius float) (duration float) (duration-rand float) - (sound symbol) + (sound sound-spec) (delay float) (delay-rand float) ) @@ -315,7 +315,3 @@ ) ) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-distort_REF.gc b/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-distort_REF.gc index a14dd1505c..3f20424db1 100644 --- a/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-distort_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-distort_REF.gc @@ -221,7 +221,7 @@ (.mul.vf vf10 vf1 vf8) (.div.vf Q vf0 vf10 :fsf #b11 :ftf #b11) (TODO.VCLIP vf10 vf10) - (b! (zero? (-> sv-16 flag-rot-sy x)) cfg-22 :delay (nop!)) + (b! (zero? (-> sv-16 flag)) cfg-22 :delay (nop!)) (.wait.vf) (.mul.vf vf1 vf1 Q :mask #b111) (.mul.vf vf2 vf2 Q :mask #b111) @@ -235,11 +235,11 @@ (set! (-> sv-32 y) (+ 0.0009765625 (* 0.001953125 (+ -1840.0 (-> (the-as vector a0-3) y))))) ) (set! (-> sv-32 z) 1.0) - (when (or (< (the-as int (-> sv-16 flag-rot-sy x)) 3) (< 11 (the-as int (-> sv-16 flag-rot-sy x)))) - (format 0 "Turns = ~D!!!~%" (-> sv-16 flag-rot-sy x)) - (set! (-> sv-16 flag-rot-sy x) (the-as float #xb)) + (when (or (< (-> sv-16 flag) 3) (< 11 (-> sv-16 flag))) + (format 0 "Turns = ~D!!!~%" (-> sv-16 flag)) + (set! (-> sv-16 flag) 11) ) - (set! (-> sv-32 w) (-> sv-16 flag-rot-sy x)) + (set! (-> sv-32 w) (the-as float (-> sv-16 flag))) (let* ((f1-4 (- (-> *math-camera* perspective uvec y))) (f2-4 (-> sv-32 y)) (f4-0 (+ f2-4 (* (-> sv-48 x) f1-4))) @@ -372,7 +372,3 @@ (none) ) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-h_REF.gc index b649486079..058aacf7b6 100644 --- a/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/sprite/sprite-h_REF.gc @@ -35,7 +35,7 @@ ) (format #t "[~8x] ~A~%" this 'sprite-vec-data-2d) (format #t "~1Tx-y-z-sx: #~%" (-> this x-y-z-sx)) - (format #t "~1Tflag-rot-sy: #~%" (-> this flag-rot-sy)) + (format #t "~1Tflag-rot-sy: #~%" (&-> this flag)) (format #t "~1Tr-g-b-a: #~%" (-> this r-g-b-a)) (format #t "~1Tx: ~f~%" (-> this x-y-z-sx x)) (format #t "~1Ty: ~f~%" (-> this x-y-z-sx y)) @@ -43,9 +43,9 @@ (format #t "~1Tsx: ~f~%" (-> this x-y-z-sx w)) (format #t "~1Tsy: ~f~%" (-> this flag-rot-sy w)) (format #t "~1Trot: ~f~%" (-> this flag-rot-sy z)) - (format #t "~1Tflag: ~D~%" (-> this flag-rot-sy x)) + (format #t "~1Tflag: ~D~%" (-> this flag)) (format #t "~1Tmatrix: ~D~%" (-> this flag-rot-sy y)) - (format #t "~1Twarp-turns: ~D~%" (-> this flag-rot-sy x)) + (format #t "~1Twarp-turns: ~D~%" (-> this flag)) (format #t "~1Tr: ~f~%" (-> this r-g-b-a x)) (format #t "~1Tg: ~f~%" (-> this r-g-b-a y)) (format #t "~1Tb: ~f~%" (-> this r-g-b-a z)) diff --git a/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc b/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc index c6da4a4c66..83bbdd4e87 100644 --- a/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc @@ -62,9 +62,11 @@ This probably started as a very simple structure, but now it is extremely compli (cam-box-idx uint16) (subdivide-close float :offset 160) (subdivide-far float) + (race-meshes (array entity-race-mesh)) (actor-birth-order (pointer uint32) :offset 172) (light-hash light-hash) (nav-meshes (array entity-nav-mesh)) + (actor-groups (array actor-group)) (region-trees (array drawable-tree-region-prim) :offset 188) (collide-hash collide-hash :offset 196) (wind-array uint32 :offset 200) diff --git a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc index 759daf17dd..05daf3a92a 100644 --- a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc @@ -666,7 +666,7 @@ (get-level-by-heap-ptr-and-status (_type_ pointer symbol) level) (level-get-for-use (_type_ symbol symbol) level) (activate-levels! (_type_) int) - (level-group-method-14 () none) + (debug-print-entities (_type_ symbol type string) none) (debug-draw-actors (_type_ symbol) none) (assign-draw-indices (_type_) none) (actors-update (_type_) none) @@ -675,9 +675,9 @@ (level-get-target-inside (_type_) level) (init-level-system (_type_ symbol) none) (art-group-get-by-name (_type_ string (pointer level)) art-group) - (level-group-method-23 () none) - (level-group-method-24 () none) - (level-group-method-25 () none) + (update-vis-volumes (_type_) none) + (level-group-method-24 (_type_) none) + (print-volume-sizes (_type_) none) (status-of-level-and-borrows (_type_ symbol symbol) symbol) (do-nothing (_type_) none) (load-in-progress? (_type_) symbol) diff --git a/test/decompiler/reference/jak3/engine/math/matrix-compose_REF.gc b/test/decompiler/reference/jak3/engine/math/matrix-compose_REF.gc index e87e1ccbe3..9adad7d0ce 100644 --- a/test/decompiler/reference/jak3/engine/math/matrix-compose_REF.gc +++ b/test/decompiler/reference/jak3/engine/math/matrix-compose_REF.gc @@ -12,7 +12,7 @@ ;; definition for function matrix-fu-compose ;; INFO: Used lq/sq -(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) +(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) (set! (-> arg0 fvec quad) (-> arg1 quad)) (set! (-> arg0 uvec quad) (-> arg2 quad)) (vector-cross! (-> arg0 rvec) arg2 arg1) @@ -39,7 +39,7 @@ ;; definition for function matrix-f-u-compose ;; INFO: Used lq/sq -(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) +(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector)) (set! (-> arg0 fvec quad) (-> arg1 quad)) (vector-cross! (-> arg0 rvec) arg2 arg1) (vector-normalize! (-> arg0 rvec) 1.0) @@ -99,10 +99,10 @@ ;; definition for function matrix-f-compose ;; INFO: Used lq/sq -(defun matrix-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector)) +(defun matrix-f-compose ((arg0 matrix) (arg1 vector) (arg2 float)) (set! (-> arg0 fvec quad) (-> arg1 quad)) (let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1))) - (matrix-f-u-compose arg0 arg1 a2-1 arg3) + (matrix-f-u-compose arg0 arg1 a2-1) ) arg0 ) diff --git a/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc b/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc index d370f24130..4eade75679 100644 --- a/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc @@ -278,7 +278,7 @@ (mesh basic :overlay-at (-> state mesh)) ) (:methods - (nav-control-method-9 () none) + (debug-draw (_type_) none) (nav-control-method-10 () none) (find-poly-containing-point-1 (_type_ vector) nav-poly) (cloest-point-on-mesh (_type_ vector vector nav-poly) nav-poly) diff --git a/test/decompiler/reference/jak3/engine/nav/nav-mesh-h_REF.gc b/test/decompiler/reference/jak3/engine/nav/nav-mesh-h_REF.gc index 9086f90398..3a0f8627e1 100644 --- a/test/decompiler/reference/jak3/engine/nav/nav-mesh-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/nav/nav-mesh-h_REF.gc @@ -397,7 +397,7 @@ Based on the implementation of point-poly-intersection?, these should likely be (nav-mesh-method-21 () none) (nav-mesh-method-22 () none) (nav-mesh-method-23 () none) - (nav-mesh-method-24 () none) + (compute-bounding-box-from-vertices (_type_ vector vector) none) (nav-mesh-method-25 () none) (nav-mesh-method-26 () none) (nav-mesh-method-27 () none) @@ -799,7 +799,3 @@ Based on the implementation of point-poly-intersection?, these should likely be 0 (none) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/scene/scene_REF.gc b/test/decompiler/reference/jak3/engine/scene/scene_REF.gc new file mode 100644 index 0000000000..5ef1fcb458 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/scene/scene_REF.gc @@ -0,0 +1,2174 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type scene-stage +(deftype scene-stage (process-hidden) + () + ) + +;; definition for method 3 of type scene-stage +(defmethod inspect ((this scene-stage)) + (when (not this) + (set! this this) + (goto cfg-68) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tmask: #x~X : (process-mask " (-> this mask)) + (let ((s5-0 (-> this mask))) + (if (= (logand s5-0 (process-mask process-tree)) (process-mask process-tree)) + (format #t "process-tree ") + ) + (if (= (logand s5-0 (process-mask target)) (process-mask target)) + (format #t "target ") + ) + (if (= (logand (process-mask collectable) s5-0) (process-mask collectable)) + (format #t "collectable ") + ) + (if (= (logand (process-mask projectile) s5-0) (process-mask projectile)) + (format #t "projectile ") + ) + (if (= (logand s5-0 (process-mask sleep-code)) (process-mask sleep-code)) + (format #t "sleep-code ") + ) + (if (= (logand s5-0 (process-mask actor-pause)) (process-mask actor-pause)) + (format #t "actor-pause ") + ) + (if (= (logand (process-mask metalhead) s5-0) (shl #x8000 16)) + (format #t "metalhead ") + ) + (if (= (logand (process-mask bot) s5-0) (process-mask bot)) + (format #t "bot ") + ) + (if (= (logand (process-mask vehicle) s5-0) (process-mask vehicle)) + (format #t "vehicle ") + ) + (if (= (logand (process-mask enemy) s5-0) (process-mask enemy)) + (format #t "enemy ") + ) + (if (= (logand (process-mask entity) s5-0) (process-mask entity)) + (format #t "entity ") + ) + (if (= (logand s5-0 (process-mask heap-shrunk)) (process-mask heap-shrunk)) + (format #t "heap-shrunk ") + ) + (if (= (logand (process-mask sidekick) s5-0) (process-mask sidekick)) + (format #t "sidekick ") + ) + (if (= (logand s5-0 (process-mask going)) (process-mask going)) + (format #t "going ") + ) + (if (= (logand s5-0 (process-mask execute)) (process-mask execute)) + (format #t "execute ") + ) + (if (= (logand (process-mask civilian) s5-0) (process-mask civilian)) + (format #t "civilian ") + ) + (if (= (logand (process-mask death) s5-0) (process-mask death)) + (format #t "death ") + ) + (if (= (logand (process-mask guard) s5-0) (process-mask guard)) + (format #t "guard ") + ) + (if (= (logand s5-0 (process-mask no-kill)) (process-mask no-kill)) + (format #t "no-kill ") + ) + (if (= (logand (process-mask kg-robot) s5-0) (process-mask kg-robot)) + (format #t "kg-robot ") + ) + (if (= (logand (process-mask platform) s5-0) (process-mask platform)) + (format #t "platform ") + ) + (if (= (logand s5-0 (process-mask freeze)) (process-mask freeze)) + (format #t "freeze ") + ) + (if (= (logand s5-0 (process-mask sleep)) (process-mask sleep)) + (format #t "sleep ") + ) + (if (= (logand s5-0 (process-mask progress)) (process-mask progress)) + (format #t "progress ") + ) + (if (= (logand s5-0 (process-mask menu)) (process-mask menu)) + (format #t "menu ") + ) + (if (= (logand (process-mask camera) s5-0) (process-mask camera)) + (format #t "camera ") + ) + (if (= (logand (process-mask ambient) s5-0) (process-mask ambient)) + (format #t "ambient ") + ) + (if (= (logand s5-0 (process-mask dark-effect)) (process-mask dark-effect)) + (format #t "dark-effect ") + ) + (if (= (logand (process-mask crate) s5-0) (process-mask crate)) + (format #t "crate ") + ) + (if (= (logand s5-0 (process-mask kernel-run)) (process-mask kernel-run)) + (format #t "kernel-run ") + ) + (if (= (logand s5-0 (process-mask movie)) (process-mask movie)) + (format #t "movie ") + ) + (if (= (logand s5-0 (process-mask pause)) (process-mask pause)) + (format #t "pause ") + ) + ) + (format #t ")~%") + (format #t "~1Tclock: ~A~%" (-> this clock)) + (format #t "~1Tparent: #x~X~%" (-> this parent)) + (format #t "~1Tbrother: #x~X~%" (-> this brother)) + (format #t "~1Tchild: #x~X~%" (-> this child)) + (format #t "~1Tppointer: #x~X~%" (-> this ppointer)) + (format #t "~1Tself: ~A~%" (-> this self)) + (format #t "~1Tpool: ~A~%" (-> this pool)) + (format #t "~1Tstatus: ~A~%" (-> this status)) + (format #t "~1Tpid: ~D~%" (-> this pid)) + (format #t "~1Tmain-thread: ~A~%" (-> this main-thread)) + (format #t "~1Ttop-thread: ~A~%" (-> this top-thread)) + (format #t "~1Tentity: ~A~%" (-> this entity)) + (format #t "~1Tlevel: ~A~%" (-> this level)) + (format #t "~1Tstate: ~A~%" (-> this state)) + (format #t "~1Tprev-state: ~A~%" (-> this prev-state)) + (format #t "~1Tnext-state: ~A~%" (-> this next-state)) + (format #t "~1Tstate-stack: ~A~%" (-> this state-stack)) + (format #t "~1Ttrans-hook: ~A~%" (-> this trans-hook)) + (format #t "~1Tpost-hook: ~A~%" (-> this post-hook)) + (format #t "~1Tevent-hook: ~A~%" (-> this event-hook)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Theap-base: #x~X~%" (-> this heap-base)) + (format #t "~1Theap-top: #x~X~%" (-> this heap-top)) + (format #t "~1Theap-cur: #x~X~%" (-> this heap-cur)) + (format #t "~1Tstack-frame-top: ~A~%" (-> this stack-frame-top)) + (format #t "~1Theap: #~%" (&-> this heap-base)) + (format #t "~1Tconnection-list: ~`connectable`P~%" (-> this connection-list)) + (format #t "~1Tstack[0] @ #x~X~%" (-> this stack)) + (label cfg-68) + this + ) + +;; definition for method 2 of type scene +(defmethod print ((this scene)) + (format #t "#" (-> this art-group) (-> this anim) this) + this + ) + +;; definition for method 16 of type scene +(defmethod init-spool-by-scene! ((this scene) (arg0 spool-anim)) + (set! (-> arg0 name) (-> this anim)) + (set! (-> arg0 anim-name) (-> this anim)) + (set! (-> arg0 parts) (-> this parts)) + (set! (-> arg0 command-list) (-> this command-list)) + arg0 + ) + +;; definition for function scene-decode-continue +;; WARN: Return type mismatch basic vs continue-point. +(defun scene-decode-continue ((arg0 basic)) + (the-as continue-point (cond + ((not arg0) + (the-as basic #f) + ) + ((= (-> arg0 type) continue-point) + arg0 + ) + ((= (-> arg0 type) string) + (get-continue-by-name *game-info* (the-as string arg0)) + ) + (else + (the-as basic #f) + ) + ) + ) + ) + +;; definition for method 9 of type scene-actor +;; INFO: Used lq/sq +(defmethod setup-manipy-for-scene! ((this scene-actor) (arg0 scene-player)) + (local-vars (s4-0 (pointer process)) (sv-96 process)) + (let ((s2-0 (if (-> this level) + (level-get *level* (-> this level)) + (-> *level* level-default) + ) + ) + ) + (cond + ((not s2-0) + (-> *level* level-default) + (set! s4-0 (the-as (pointer process) #f)) + (goto cfg-260) + ) + ((= (-> s2-0 status) 'reserved) + ) + ((!= (-> s2-0 status) 'active) + (set! s4-0 (the-as (pointer process) #f)) + (goto cfg-260) + ) + ) + (let* ((s4-1 (art-group-get-by-name *level* (-> this art-group) (the-as (pointer level) #f))) + (s3-0 (if (type? s4-1 skeleton-group) + s4-1 + ) + ) + (s0-0 (-> arg0 level)) + (s1-0 + (cond + ((or (string= (-> this name) "jak-highres") + (string= (-> this name) "jak-highres-prison") + (string= (-> this name) "darkjak-highres") + ) + 'jakb + ) + ((string= (-> this name) "jakc-highres") + 'jakc + ) + ) + ) + ) + (set! (-> arg0 level) #f) + (set! s4-0 + (when s3-0 + (let ((s2-1 (if (and (nonzero? (-> s2-0 entity)) (> (-> s2-0 entity length) 0)) + (-> s2-0 entity data 0 entity) + (-> arg0 entity) + ) + ) + ) + (set! sv-96 (get-process *default-dead-pool* manipy #x20000 0)) + (set! s4-0 (when sv-96 + (let ((t9-8 (method-of-type manipy activate))) + (t9-8 (the-as manipy sv-96) arg0 (-> this name) (the-as pointer #x70004000)) + ) + (run-now-in-process + sv-96 + manipy-init + (-> arg0 root trans) + s2-1 + s3-0 + #f + (if (and s1-0 (logtest? (game-secrets big-head little-head) (-> *game-info* secrets))) + 1 + 0 + ) + ) + (-> sv-96 ppointer) + ) + ) + (set! (-> arg0 level) s0-0) + (send-event (ppointer->process s4-0) 'anim-mode 'clone-anim) + (send-event (ppointer->process s4-0) 'blend-shape #t) + (send-event (ppointer->process s4-0) 'prefix (-> this prefix)) + (cond + ((zero? (-> this light-index)) + (if (zero? (-> (the-as skeleton-group s3-0) light-index)) + (send-event (ppointer->process s4-0) 'light-index 80) + ) + ) + (else + (send-event (ppointer->process s4-0) 'light-index (* (-> this light-index) 8)) + ) + ) + (send-event (ppointer->process s4-0) 'shadow-disable-smooth #t) + (if (nonzero? (-> this shadow-mask)) + (send-event (ppointer->process s4-0) 'shadow-mask (* (-> this shadow-mask) 8)) + ) + (if (nonzero? (-> this shadow-values)) + (send-event (ppointer->process s4-0) 'shadow-values (* (-> this shadow-values) 8)) + ) + (if (and s4-0 (not (logtest? (-> this flags) 1)) (nonzero? (-> (the-as process-drawable (-> s4-0 0)) draw))) + (logior! (-> (the-as process-drawable (-> s4-0 0)) draw status) (draw-control-status no-draw-bounds)) + ) + (if (-> this shadow-volume-joint) + (send-event (ppointer->process s4-0) 'shadow-volume (-> this shadow-volume-joint) (-> this shadow-flags)) + ) + (when (or (nonzero? (-> this draw-seg)) (nonzero? (-> this no-draw-seg))) + (send-event (ppointer->process s4-0) 'segment 0 (* (-> this no-draw-seg) 8)) + (send-event (ppointer->process s4-0) 'segment (* (-> this draw-seg) 8) 0) + ) + (when (and s1-0 s4-0 (nonzero? (-> (the-as process-drawable (-> s4-0 0)) draw))) + (cond + ((= s1-0 'jakb) + (if (not (-> *setting-control* user-current beard)) + (send-event (ppointer->process s4-0) 'segment 0 16) + ) + ) + ((= s1-0 'jakc) + (if (not (-> *setting-control* user-current beard)) + (send-event (ppointer->process s4-0) 'segment 0 32) + ) + (if (not (logtest? (game-feature armor0) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 16) + ) + (if (not (logtest? (game-feature armor1) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 256) + ) + (if (not (logtest? (game-feature armor2) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 2048) + ) + (if (not (logtest? (game-feature armor3) (-> *game-info* features))) + (send-event (ppointer->process s4-0) 'segment 0 4096) + ) + (let ((v0-28 (log2 (the-as int (-> (the-as process-drawable (-> s4-0 0)) draw mgeo seg-table (log2 16)))))) + (logior! (-> (the-as process-drawable (-> s4-0 0)) draw mgeo effect v0-28 effect-usage) 8) + ) + ) + ) + (when (nonzero? (-> (the-as manipy (-> s4-0 0)) joint 0)) + (cond + ((logtest? (game-secrets little-head) (-> *game-info* secrets)) + (mode-set! (-> (the-as manipy (-> s4-0 0)) joint 0) (joint-mod-mode joint-set*)) + (trs-set! + (-> (the-as manipy (-> s4-0 0)) joint 0) + (the-as vector #f) + (the-as quaternion #f) + (new 'static 'vector :x 0.4 :y 0.4 :z 0.4 :w 1.0) + ) + ) + ((logtest? (game-secrets big-head) (-> *game-info* secrets)) + (mode-set! (-> (the-as manipy (-> s4-0 0)) joint 0) (joint-mod-mode joint-set*)) + (trs-set! + (-> (the-as manipy (-> s4-0 0)) joint 0) + (the-as vector #f) + (the-as quaternion #f) + (new 'static 'vector :x 2.0 :y 2.0 :z 2.0 :w 1.0) + ) + ) + ) + ) + ) + (when (and s4-0 (logtest? (-> this flags) 2)) + (let ((s1-2 (process-spawn + manipy + :init manipy-init + (-> arg0 root trans) + s2-1 + s3-0 + #f + 0 + :name (-> this name) + :to (ppointer->process s4-0) + :stack-size #x20000 + :unk 0 + ) + ) + ) + (send-event (ppointer->process s1-2) 'mirror #t) + (send-event (ppointer->process s1-2) 'anim-mode 'mirror) + (if (nonzero? (-> this light-index)) + (send-event (ppointer->process s1-2) 'light-index (* (-> this light-index) 8)) + ) + (send-event (ppointer->process s4-0) 'shadow-disable-smooth #t) + (if (nonzero? (-> this shadow-mask)) + (send-event (ppointer->process s1-2) 'shadow-mask (* (-> this shadow-mask) 8)) + ) + (if (nonzero? (-> this shadow-values)) + (send-event (ppointer->process s1-2) 'shadow-values (* (-> this shadow-values) 8)) + ) + (if (and s1-2 (not (logtest? (-> this flags) 1)) (nonzero? (-> (the-as process-drawable (-> s1-2 0)) draw))) + (logior! (-> (the-as process-drawable (-> s1-2 0)) draw status) (draw-control-status no-draw-bounds)) + ) + (if (-> this shadow-volume-joint) + (send-event (ppointer->process s1-2) 'shadow-volume (-> this shadow-volume-joint) (-> this shadow-flags)) + ) + (if (or (nonzero? (-> this draw-seg)) (nonzero? (-> this no-draw-seg))) + (send-event (ppointer->process s1-2) 'segment (* (-> this draw-seg) 8) (* (-> this no-draw-seg) 8)) + ) + ) + ) + ) + (when (and s4-0 (nonzero? (-> this camera))) + (cond + ((handle->process (-> arg0 camera)) + (change-parent (handle->process (-> arg0 camera)) (ppointer->process s4-0)) + (send-event (handle->process (-> arg0 camera)) 'target (ppointer->process s4-0)) + (send-event (handle->process (-> arg0 camera)) 'joint (* (-> this camera) 8)) + ) + (else + (let ((v1-341 (process-spawn + othercam + (ppointer->process s4-0) + (-> this camera) + #t + 'scene-player + :name "othercam" + :to (ppointer->process s4-0) + ) + ) + ) + (if v1-341 + (set! (-> arg0 camera) (ppointer->handle v1-341)) + ) + ) + ) + ) + ) + s4-0 + ) + ) + ) + ) + (label cfg-260) + s4-0 + ) + +;; definition for method 10 of type scene-player +(defmethod deactivate ((this scene-player)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (set! *debug-menu-scene-play* (the-as object #f)) + (set! *scene-player* (the-as (pointer scene-player) #f)) + (kill-persister *setting-control* (the-as engine-pers 'blackout) 'bg-a-force) + (kill-persister *setting-control* (the-as engine-pers 'blur-a) 'blur-a) + ((method-of-type process-drawable deactivate) this) + (none) + ) + +;; definition for method 7 of type scene-player +;; WARN: Return type mismatch process-drawable vs scene-player. +(defmethod relocate ((this scene-player) (offset int)) + (let ((v1-0 *kernel-context*)) + (set! (-> v1-0 relocating-process) this) + (set! (-> v1-0 relocating-min) (the-as int (&-> this type))) + (set! (-> v1-0 relocating-max) + (the-as int (+ (+ (-> this allocated-length) -4 (-> process size)) (the-as int this))) + ) + (set! (-> v1-0 relocating-offset) offset) + ) + (let ((v1-2 (-> this scene-list))) + (if (and (>= (the-as int v1-2) (-> *kernel-context* relocating-min)) + (< (the-as int v1-2) (-> *kernel-context* relocating-max)) + ) + (&+! (-> this scene-list) offset) + ) + ) + (the-as scene-player ((method-of-type process-drawable relocate) this offset)) + ) + +;; definition for method 25 of type scene-player +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: disable def twice: 288. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: disable def twice: 365. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defmethod scene-player-method-25 ((this scene-player) (arg0 float) (arg1 float)) + (local-vars + (v1-12 symbol) + (v1-47 symbol) + (v1-73 symbol) + (v1-105 symbol) + (sv-96 object) + (sv-112 object) + (sv-128 object) + (sv-144 object) + (sv-160 object) + (sv-176 object) + (sv-192 object) + (sv-208 object) + (sv-224 object) + ) + (dotimes (s3-0 (-> this scene actor length)) + (let ((s2-0 (-> this scene actor s3-0))) + (let* ((s1-0 (-> s2-0 draw-frames)) + (s0-0 (car s1-0)) + ) + (while (not (null? s1-0)) + (when (and (pair? s0-0) + (let ((a0-4 (car s0-0))) + (set! sv-96 (car (cdr s0-0))) + (or (= a0-4 'min) (>= arg0 (command-get-float a0-4 0.0))) + ) + (or (= sv-96 'max) (< arg0 (command-get-float (car (cdr s0-0)) 0.0))) + ) + (set! v1-12 #t) + (goto cfg-20) + ) + (set! s1-0 (cdr s1-0)) + (set! s0-0 (car s1-0)) + ) + ) + (set! v1-12 #f) + (label cfg-20) + (cond + (v1-12 + (if (not (handle->process (-> s2-0 process))) + (set! (-> s2-0 process) (ppointer->handle (setup-manipy-for-scene! s2-0 this))) + ) + (let ((s1-1 (handle->process (-> s2-0 process)))) + (when (and s1-1 (nonzero? (-> (the-as process-drawable s1-1) draw))) + (let ((s0-1 (-> s2-0 scissor-frames))) + (set! sv-112 (car s0-1)) + (while (not (null? s0-1)) + (when (and (pair? sv-112) + (let ((a0-21 (car sv-112))) + (set! sv-128 (car (cdr sv-112))) + (or (= a0-21 'min) (>= arg0 (command-get-float a0-21 0.0))) + ) + (or (= sv-128 'max) (< arg0 (command-get-float (car (cdr sv-112)) 0.0))) + ) + (set! v1-47 #t) + (goto cfg-59) + ) + (set! s0-1 (cdr s0-1)) + (set! sv-112 (car s0-1)) + ) + ) + (set! v1-47 #f) + (label cfg-59) + (if v1-47 + (logclear! (-> (the-as process-drawable s1-1) draw status) (draw-control-status force-vu1)) + (logior! (-> (the-as process-drawable s1-1) draw status) (draw-control-status force-vu1)) + ) + (let ((s0-2 (-> s2-0 shadow-frames))) + (set! sv-144 (car s0-2)) + (while (not (null? s0-2)) + (when (and (pair? sv-144) + (let ((a0-30 (car sv-144))) + (set! sv-160 (car (cdr sv-144))) + (or (= a0-30 'min) (>= arg0 (command-get-float a0-30 0.0))) + ) + (or (= sv-160 'max) (< arg0 (command-get-float (car (cdr sv-144)) 0.0))) + ) + (set! v1-73 #t) + (goto cfg-81) + ) + (set! s0-2 (cdr s0-2)) + (set! sv-144 (car s0-2)) + ) + ) + (set! v1-73 #f) + (label cfg-81) + (if v1-73 + (send-event s1-1 'shadow #t) + (send-event s1-1 'shadow #f) + ) + (let ((s0-3 (-> s2-0 cloth-reset-frames))) + (set! sv-192 (car s0-3)) + (while (not (null? s0-3)) + (let ((v1-97 (cond + ((pair? sv-192) + (let ((a0-38 (car sv-192))) + (set! sv-176 (car (cdr sv-192))) + (and (or (= a0-38 'min) (>= arg0 (+ -1.0 (command-get-float a0-38 0.0)))) + (or (= sv-176 'max) (< arg0 (+ 1.0 (command-get-float (car (cdr sv-192)) 0.0)))) + ) + ) + ) + (else + (let* ((t9-11 command-get-float) + (a1-18 0.0) + (f0-10 (t9-11 sv-192 a1-18)) + ) + (and (< arg1 f0-10) (>= arg0 f0-10)) + ) + ) + ) + ) + ) + (when v1-97 + (set! v1-105 #t) + (goto cfg-113) + ) + ) + (set! s0-3 (cdr s0-3)) + (set! sv-192 (car s0-3)) + ) + ) + (set! v1-105 #f) + (label cfg-113) + (if v1-105 + (process-drawable-cloth-command (the-as process-drawable s1-1) '(scene-reset-frame)) + ) + (let* ((s2-1 (-> s2-0 cloth-commands)) + (s0-4 (car s2-1)) + ) + (while (not (null? s2-1)) + (when (pair? s0-4) + (set! sv-224 (car s0-4)) + (let ((v1-121 (cond + ((pair? sv-224) + (let ((a0-44 (car sv-224))) + (set! sv-208 (car (cdr sv-224))) + (and (or (= a0-44 'min) (>= arg0 (command-get-float a0-44 0.0))) + (or (= sv-208 'max) (< arg0 (command-get-float (car (cdr sv-224)) 0.0))) + ) + ) + ) + (else + (let* ((t9-15 command-get-float) + (a1-23 0.0) + (f0-13 (t9-15 sv-224 a1-23)) + ) + (and (< arg1 f0-13) (>= arg0 f0-13)) + ) + ) + ) + ) + ) + (if v1-121 + (process-drawable-cloth-command (the-as process-drawable s1-1) (cdr s0-4)) + ) + ) + ) + (set! s2-1 (cdr s2-1)) + (set! s0-4 (car s2-1)) + ) + ) + ) + ) + 0 + ) + ((handle->process (-> s2-0 process)) + (deactivate (handle->process (-> s2-0 process))) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function scene-lookup +;; WARN: Return type mismatch basic vs scene. +(defun scene-lookup ((arg0 basic)) + (the-as + scene + (case (-> arg0 type) + ((string) + (let ((s5-0 (art-group-get-by-name *level* (the-as string arg0) (the-as (pointer level) #f)))) + (when (type? s5-0 scene) + (let ((gp-0 (get-level-by-heap-ptr-and-status *level* (the-as pointer s5-0) 'active))) + (when (and s5-0 gp-0) + (let ((s4-0 (scene-decode-continue (-> s5-0 data 15)))) + (when s4-0 + (dotimes (s3-0 (-> s4-0 want-count)) + (if (= (-> gp-0 name) (-> s4-0 want s3-0 name)) + (goto cfg-25) + ) + (let ((v1-14 (lookup-level-info (-> s4-0 want s3-0 name)))) + (if (and v1-14 (-> v1-14 borrow) (-> v1-14 borrow alias) (member (-> gp-0 name) (-> v1-14 borrow alias))) + (goto cfg-25) + ) + ) + ) + (format + 0 + "WARNING: can not find scene level ~A in continue ~A, dropping scene until after load~%" + (-> gp-0 name) + (-> s4-0 name) + ) + (return (the-as scene #f)) + ) + ) + ) + ) + (label cfg-25) + s5-0 + ) + ) + ) + ((scene) + arg0 + ) + ) + ) + ) + +;; definition for method 24 of type scene-player +(defmethod scene-player-method-24 ((this scene-player) (arg0 scene) (arg1 symbol)) + (when (= (-> arg0 type) string) + (let ((v1-2 (scene-lookup arg0))) + (if v1-2 + (set! arg0 v1-2) + ) + ) + ) + (when (or (not arg0) (!= (-> arg0 type) scene)) + (format 0 "ERROR: SCENE: scene-player can not find scene ~A~%" arg0) + (go process-drawable-art-error "scene-list format") + ) + (when arg1 + (let ((s4-1 (get-level-by-heap-ptr-and-status *level* (the-as pointer arg0) 'active))) + (init-spool-by-scene! arg0 (-> this anim)) + (set! (-> this level) s4-1) + ) + (set! (-> this scene) arg0) + ) + arg0 + ) + +;; definition for method 23 of type scene-player +;; WARN: Return type mismatch int vs none. +(defmethod scene-player-method-23 ((this scene-player) (arg0 string) (arg1 symbol)) + (let ((gp-0 (scene-player-method-24 this (the-as scene arg0) #t))) + (when (logtest? (-> gp-0 scene-flags) (scene-flags scf3)) + (let ((a0-2 *traffic-manager*)) + (send-event a0-2 'restore-default-settings) + ) + ) + (send-event *target* 'draw (logtest? (-> gp-0 scene-flags) (scene-flags scf0))) + (let ((s3-0 (entity-by-name (-> gp-0 entity)))) + (when (and (-> gp-0 entity) (not s3-0)) + (format 0 "ERROR: SCENE: scene ~A can not find entity ~A~%" (-> gp-0 name) (-> gp-0 entity)) + (go process-drawable-art-error (-> gp-0 entity)) + ) + (set! (-> this main-entity) (the-as entity-actor s3-0)) + (cond + (s3-0 + (process-drawable-from-entity! this (-> this main-entity)) + (logclear! (-> this mask) (process-mask actor-pause)) + ) + (else + (vector-reset! (-> this root trans)) + (quaternion-identity! (-> this root quat)) + ) + ) + ) + (let ((s3-1 (load-to-heap-by-name (-> *level* level-default art-group) (-> gp-0 art-group) 'load global 0))) + (when (not s3-1) + (format 0 "ERROR: SCENE: scene ~A can not find art-group ~A~%" (-> gp-0 name) (-> gp-0 art-group)) + (go process-drawable-art-error (-> gp-0 art-group)) + ) + (set! (-> this draw art-group) s3-1) + (countdown (v1-31 (-> s3-1 length)) + (when (-> s3-1 data v1-31) + (cond + ((= (-> s3-1 data v1-31 type) merc-ctrl) + (set! (-> this draw mgeo) (the-as merc-ctrl (-> s3-1 data v1-31))) + ) + ((= (-> s3-1 data v1-31 type) art-joint-geo) + (set! (-> this draw jgeo) (the-as art-joint-geo (-> s3-1 data v1-31))) + ) + ) + ) + ) + ) + (cond + ((< (+ (-> this scene-index) 1) (-> this scene-list length)) + (let ((a0-34 (scene-player-method-24 this (-> this scene-list (+ (-> this scene-index) 1)) #f))) + (cond + (a0-34 + (init-spool-by-scene! a0-34 (-> this next-anim)) + ) + (else + (set! (-> this next-anim anim-name) (the-as string 0)) + 0 + ) + ) + ) + ) + (else + (set! (-> this next-anim anim-name) (the-as string 0)) + 0 + ) + ) + (dotimes (s3-2 (-> gp-0 actor length)) + (let ((s2-0 (-> gp-0 actor s3-2))) + (set! (-> s2-0 process) (the-as handle #f)) + (let ((s1-0 (if (-> s2-0 level) + (level-get *level* (-> s2-0 level)) + (-> *level* level-default) + ) + ) + (v1-53 (when level + (let ((s0-0 (art-group-get-by-name *level* (-> s2-0 art-group) (the-as (pointer level) #f)))) + (if (type? s0-0 skeleton-group) + s0-0 + ) + ) + ) + ) + ) + (cond + ((or (not s1-0) (not (or (= (-> s1-0 status) 'active) (= (-> s1-0 status) 'reserved)))) + (format + 0 + "ERROR: SCENE: scene actor ~A can not find an active level ~A~%" + (-> s2-0 art-group) + (-> s2-0 level) + ) + ) + ((not v1-53) + (format + 0 + "ERROR: SCENE: scene actor ~A can not find skeleton-group ~A~%" + (-> s2-0 art-group) + (-> s2-0 art-group) + ) + ) + (else + (load-to-heap-by-name (-> s1-0 art-group) (the-as string (-> v1-53 data 0)) 'load global 0) + ) + ) + ) + ) + ) + (process-entity-status! this (entity-perm-status no-kill) #t) + (when arg1 + (kill-persister *setting-control* (the-as engine-pers 'fail-sfx-volume) 'sfx-volume) + (kill-persister *setting-control* (the-as engine-pers 'fail-dialog-volume) 'dialog-volume) + (kill-persister *setting-control* (the-as engine-pers 'fail-music-volume) 'music-volume) + (set-setting! 'region-mode #f 0.0 0) + (set-setting! 'process-mask 'set 0.0 (-> gp-0 mask-to-clear)) + (if (logtest? (-> gp-0 mask-to-clear) (process-mask movie)) + (set-setting! 'letterbox 'abs 1.0 0) + ) + (set-setting! 'sound-bank-load #f 0.0 0) + (set-setting! 'movie (process->ppointer this) 0.0 0) + (set-setting! 'movie-name (-> gp-0 name) 0.0 0) + (let ((f30-0 (if (>= (-> gp-0 music-volume) 0.0) + (-> gp-0 music-volume) + (-> *setting-control* user-current music-volume-movie) + ) + ) + ) + (set-setting! 'music-volume 'rel f30-0 0) + (set-setting! + 'sfx-volume + 'rel + (if (>= (-> gp-0 sfx-volume) 0.0) + (-> gp-0 sfx-volume) + (-> *setting-control* user-current sfx-volume-movie) + ) + 0 + ) + (set-setting! + 'ambient-volume + 'rel + (if (>= (-> gp-0 ambient-volume) 0.0) + (-> gp-0 ambient-volume) + (-> *setting-control* user-current ambient-volume-movie) + ) + 0 + ) + (when (nonzero? (the int (-> gp-0 music-delay))) + (set-setting! 'music-volume 'abs 0.0 0) + (set! f30-0 0.0) + ) + (remove-setting! 'music) + (if (= f30-0 0.0) + (set-setting! 'music #f 0.0 0) + ) + ) + (set-setting! 'gem #f 0.0 0) + (set-setting! 'citizen-fights #f 0.0 0) + (apply-settings *setting-control*) + ) + ) + 0 + (none) + ) + +;; definition of type subtitle-work +(deftype subtitle-work (structure) + ((draw-tmpl dma-gif-packet :inline) + (color0 vector4w :inline) + (color1 vector4w :inline) + ) + ) + +;; definition for method 3 of type subtitle-work +(defmethod inspect ((this subtitle-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'subtitle-work) + (format #t "~1Tdraw-tmpl: #~%" (-> this draw-tmpl)) + (format #t "~1Tcolor0: #~%" (-> this color0)) + (format #t "~1Tcolor1: #~%" (-> this color1)) + (label cfg-4) + this + ) + +;; definition for symbol *subtitle-work*, type subtitle-work +(define *subtitle-work* (new 'static 'subtitle-work + :draw-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x50ab400000008001 #x53531) + ) + :color0 (new 'static 'vector4w :w #x80) + :color1 (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + ) + ) + +;; definition for function draw-subtitle-image +;; INFO: Used lq/sq +;; WARN: Return type mismatch pointer vs none. +(defun draw-subtitle-image ((arg0 subtitle-image) (arg1 font-context)) + (local-vars (sv-16 pointer) (sv-32 int)) + (let ((gp-0 (-> arg0 width)) + (s5-0 (-> arg0 height)) + ) + (let ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (set! sv-16 (-> s4-0 base)) + (unpack-comp-rle (the-as (pointer int8) sv-16) (the-as (pointer int8) (-> arg0 data))) + (&+! (-> s4-0 base) (logand -16 (+ (shr (* gp-0 s5-0) 1) 15))) + ) + (with-dma-buffer-add-bucket ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hud-draw-pris2) + ) + (upload-vram-data s3-0 0 (-> arg0 palette) 2 8) + (let ((s0-0 20)) + (dma-buffer-add-gs-set s3-0 + (bitbltbuf (new 'static 'gs-bitbltbuf :dbp #x1 :dbw (shr gp-0 6) :dpsm s0-0)) + (trxpos (new 'static 'gs-trxpos)) + (trxreg (new 'static 'gs-trxreg :rrw gp-0 :rrh s5-0)) + (trxdir (new 'static 'gs-trxdir)) + ) + (let ((t9-2 dma-buffer-add-ref-texture) + (a0-13 s3-0) + (a2-8 gp-0) + (a3-1 s5-0) + (t0-1 s0-0) + ) + (t9-2 a0-13 sv-16 (the-as int a2-8) (the-as int a3-1) (the-as gs-psm t0-1)) + ) + (set! sv-32 (+ (log2 (the-as int (+ gp-0 -1))) 1)) + (let ((v1-17 (+ (log2 (the-as int (+ s5-0 -1))) 1))) + (dma-buffer-add-gs-set s3-0 + (test-1 (new 'static 'gs-test :ate #x1 :afail #x3 :zte #x1 :ztst (gs-ztest always))) + (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) + (tex0-1 (new 'static 'gs-tex0 :tbp0 #x1 :tcc #x1 :cld #x1 :psm s0-0 :th v1-17 :tw sv-32 :tbw (shr gp-0 6))) + (tex1-1 (new 'static 'gs-tex1)) + (clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (texflush 0) + ) + ) + ) + (let* ((v1-28 (-> s3-0 base)) + (a2-23 + (+ (- 1793 (the-as int (shr (-> arg0 width) 1))) (the int (+ (-> arg1 origin x) (* 0.5 (-> arg1 width))))) + ) + (a3-8 (+ (the int (-> arg1 origin y)) 1841)) + (a0-23 (+ a2-23 (-> arg0 width))) + (a1-33 (+ a3-8 (-> arg0 height))) + ) + (set! (-> (the-as (pointer uint128) v1-28) 0) (-> *subtitle-work* draw-tmpl dma-vif quad)) + (set! (-> (the-as (pointer uint128) v1-28) 1) (-> *subtitle-work* draw-tmpl quad 1)) + (set! (-> (the-as (pointer uint128) v1-28) 2) (-> *subtitle-work* color0 quad)) + (set-vector! (the-as vector4w (&+ v1-28 48)) 0 0 0 0) + (set-vector! (the-as vector4w (&+ v1-28 64)) (the-as int (* a2-23 16)) (* a3-8 16) 0 0) + (set-vector! (the-as vector4w (&+ v1-28 80)) (the-as int (* gp-0 16)) (the-as int (* s5-0 16)) 0 0) + (set-vector! (the-as vector4w (&+ v1-28 96)) (the-as int (* a0-23 16)) (* a1-33 16) 0 0) + ) + (&+! (-> s3-0 base) 112) + (let* ((v1-32 (-> s3-0 base)) + (a1-38 + (+ (- 1792 (the-as int (shr (-> arg0 width) 1))) (the int (+ (-> arg1 origin x) (* 0.5 (-> arg1 width))))) + ) + (a3-11 (+ (the int (-> arg1 origin y)) 1840)) + (a0-30 (+ a1-38 (-> arg0 width))) + (a2-28 (+ a3-11 (-> arg0 height))) + ) + (set! (-> (the-as (pointer uint128) v1-32) 0) (-> *subtitle-work* draw-tmpl dma-vif quad)) + (set! (-> (the-as (pointer uint128) v1-32) 1) (-> *subtitle-work* draw-tmpl quad 1)) + (set! (-> (the-as (pointer uint128) v1-32) 2) (-> *subtitle-work* color1 quad)) + (set-vector! (the-as vector4w (&+ v1-32 48)) 0 0 0 0) + (set-vector! (the-as vector4w (&+ v1-32 64)) (the-as int (* a1-38 16)) (* a3-11 16) 0 0) + (set-vector! (the-as vector4w (&+ v1-32 80)) (the-as int (* gp-0 16)) (the-as int (* s5-0 16)) 0 0) + (set-vector! (the-as vector4w (&+ v1-32 96)) (the-as int (* a0-30 16)) (* a2-28 16) 0 0) + ) + (&+! (-> s3-0 base) 112) + (set-dirty-mask! (-> *level* level-default) 8 (the-as int (* gp-0 s5-0)) 256) + ) + ) + (none) + ) + +;; definition for function process-drawable-draw-subtitles +;; WARN: Return type mismatch int vs none. +(defbehavior process-drawable-draw-subtitles process-drawable () + (when (and (nonzero? (-> self skel)) + (> (-> self skel active-channels) 0) + (-> *setting-control* user-current subtitle) + ) + (let ((v1-9 (-> self skel root-channel 0 frame-group))) + (when v1-9 + (let ((gp-0 (res-lump-struct (-> v1-9 extra) 'subtitle-range (array subtitle-range)))) + (when gp-0 + (let ((f30-0 (ja-aframe-num 0)) + (s5-0 (the-as int (-> *setting-control* user-current subtitle-language))) + ) + (if (and (= (the-as language-enum s5-0) (language-enum english)) (= (scf-get-territory) 1)) + (set! s5-0 11) + ) + (dotimes (s4-0 (-> gp-0 length)) + (let ((v1-16 (-> gp-0 s4-0))) + (when (and (>= f30-0 (-> v1-16 start-frame)) (< f30-0 (-> v1-16 end-frame))) + (let ((s3-0 (-> v1-16 message s5-0))) + (when (and s3-0 (nonzero? s3-0)) + (let ((s2-0 + (new 'stack 'font-context *font-default-matrix* 20 290 0.0 (font-color default) (font-flags shadow kerning)) + ) + ) + (let ((v1-20 s2-0)) + (set! (-> v1-20 width) (the float 465)) + ) + (let ((v1-21 s2-0)) + (set! (-> v1-21 height) (the float 70)) + ) + (let ((v1-22 s2-0)) + (set! (-> v1-22 scale) 0.5) + ) + (set! (-> s2-0 flags) (font-flags shadow kerning middle large)) + (case (-> s3-0 type) + ((string) + (when (= (-> *setting-control* user-default subtitle-language) (language-enum korean)) + (set! s3-0 (convert-korean-text (the-as string s3-0))) + (let ((v1-27 s2-0)) + (set! (-> v1-27 scale) 0.6) + ) + ) + (when (= (-> *setting-control* user-default subtitle-language) (language-enum russian)) + (let ((v1-30 s2-0)) + (set! (-> v1-30 scale) 0.75) + ) + ) + (set! (-> s2-0 flags) (font-flags kerning middle middle-vert large)) + (+! (-> s2-0 origin x) -1.0) + (+! (-> s2-0 origin y) -1.0) + (set! (-> s2-0 color) (font-color font-color-39)) + (+! (-> s2-0 origin x) 1.0) + (+! (-> s2-0 origin y) 1.0) + (set! (-> s2-0 color) (font-color default)) + (set! (-> s2-0 flags) (font-flags shadow kerning middle middle-vert large)) + (print-game-text (the-as string s3-0) s2-0 #f 44 (bucket-id hud-draw-pris2)) + (gui-control-method-12 + *gui-control* + self + (gui-channel subtitle) + (gui-action play) + "scene" + 0 + 81920.0 + (new 'static 'sound-id) + ) + ) + ((subtitle-image) + (draw-subtitle-image (the-as subtitle-image s3-0) s2-0) + ) + (else + (if *debug-segment* + (format *stdcon* "unknown message ~A~%" s3-0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate wait (scene-player) + :virtual #t + :enter (behavior ((arg0 symbol)) + (set-time! (-> self state-time)) + (if (= (-> *game-info* demo-state) 101) + (set-setting! 'audio-language #f 0.0 5) + ) + (when (or (-> self scene) (-> self preload-continue)) + (let ((gp-0 (scene-decode-continue (if (-> self scene) + (-> self scene load-point) + (-> self preload-continue) + ) + ) + ) + ) + (when gp-0 + (when (-> self scene) + (set-setting! 'borrow (-> self scene borrow) 0.0 0) + (apply-settings *setting-control*) + ) + (cond + ((and *target* + (zero? (-> self scene-index)) + (or (not (-> self scene)) + (!= (status-of-level-and-borrows *level* (-> gp-0 vis-nick) #f) 'active) + (logtest? (-> self scene scene-flags) (scene-flags scf5)) + ) + ) + (send-event *target* 'continue gp-0) + ) + (else + (let ((a0-16 (lookup-level-info (-> gp-0 vis-nick)))) + (set! (-> *load-state* vis-nick) (if a0-16 + (-> a0-16 name) + ) + ) + ) + (dotimes (v1-28 10) + (cond + ((< v1-28 (-> gp-0 want-count)) + (set! (-> *load-state* want v1-28 name) (-> gp-0 want v1-28 name)) + (set! (-> *load-state* want v1-28 display?) (-> gp-0 want v1-28 display?)) + ) + (else + (set! (-> *load-state* want v1-28 name) #f) + (set! (-> *load-state* want v1-28 display?) #f) + ) + ) + (set! (-> *load-state* want v1-28 force-vis?) #f) + (set! (-> *load-state* want v1-28 force-inside?) #f) + ) + (update-task-masks 'event) + ) + ) + ) + ) + ) + ) + :trans (behavior () + (if (and (-> self scene) (nonzero? (-> self anim anim-name)) (not (load-in-progress? *level*))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> self anim name) + 0 + -1.0 + (new 'static 'sound-id) + ) + ) + (set! (-> *ACTOR-bank* birth-max) 1000) + ) + :code (behavior ((arg0 symbol)) + (local-vars (v1-18 symbol) (v1-124 symbol)) + (when (and (-> self scene) (zero? (-> self scene wait-max-time))) + (while *progress-process* + (suspend) + ) + (set-setting! 'allow-progress #f 0.0 0) + (set-setting! 'bg-a-force 'abs 1.0 0) + (apply-settings *setting-control*) + ) + (if (or (not *target*) + (or (focus-test? *target* grabbed) + (begin + (dotimes (v1-17 10) + (when (and (-> *target* current-level) (= (-> *load-state* target v1-17 name) (-> *target* current-level name))) + (set! v1-18 #f) + (goto cfg-22) + ) + ) + #t + (set! v1-18 #t) + (label cfg-22) + (or v1-18 (not (-> self scene))) + ) + ) + ) + (set! arg0 #f) + ) + (while (and arg0 + (or (focus-test? *target* in-air) + (and (-> *target* next-state) (= (-> *target* next-state name) 'target-flop-hit-ground)) + ) + (-> self scene) + (not (time-elapsed? (-> self state-time) (-> self scene wait-air-time))) + ) + (suspend) + ) + (suspend) + (let ((s5-0 (current-time))) + (when (and *target* (not (logtest? (-> *target* focus-status) (focus-status grabbed)))) + (label cfg-47) + (send-event *target* 'end-mode 'freeze 'force) + (when (not (process-grab? *target* #f)) + (suspend) + (goto cfg-47) + ) + ) + (process-entity-status! self (entity-perm-status no-kill) #t) + (until (not (or (-> *setting-control* user-current talking) + (-> *setting-control* user-current spooling) + (-> *setting-control* user-current hint) + (-> *setting-control* user-current ambient) + ) + ) + (set-setting! 'allow-progress #f 0.0 0) + (apply-settings *setting-control*) + (dotimes (s4-0 2) + (while (or (-> *setting-control* user-current talking) + (-> *setting-control* user-current spooling) + (-> *setting-control* user-current hint) + (-> *setting-control* user-current ambient) + (or (and (-> *setting-control* user-current movie) + (!= (-> *setting-control* user-current movie) (process->ppointer self)) + ) + *progress-process* + (!= (get-status *gui-control* (-> self gui-id)) 3) + ) + ) + (suspend) + ) + ) + (when arg0 + (while (and (-> self scene) (not (or (time-elapsed? s5-0 (-> self scene wait-ground-time)) + (time-elapsed? (-> self state-time) (-> self scene wait-max-time)) + ) + ) + ) + (suspend) + ) + ) + (remove-setting! 'movie) + (remove-setting! 'sound-bank-load) + (remove-setting! 'movie-name) + (remove-setting! 'bg-a-force) + (apply-settings *setting-control*) + (set-blackout-frames (seconds 0.1)) + (suspend) + (set-blackout-frames (seconds 0.1)) + (suspend) + ) + ) + (send-event *target* 'trans 'save (-> self old-target-pos)) + (let ((gp-1 *load-state*)) + (when gp-1 + (dotimes (s5-1 2) + (while (begin + (dotimes (s4-1 10) + (when (not (or (not (-> gp-1 want s4-1 name)) + (not (-> gp-1 want s4-1 display?)) + (= (status-of-level-and-borrows *level* (-> gp-1 want s4-1 name) 'all) 'active) + ) + ) + (set! v1-124 #t) + (goto cfg-114) + ) + ) + (set! v1-124 #f) + (label cfg-114) + v1-124 + ) + (set-blackout-frames (seconds 0.1)) + (suspend) + ) + (when (and (zero? s5-1) (< (-> self scene-index) (-> self scene-list length))) + (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t) + (when (-> self scene) + (set-setting! 'borrow (-> self scene borrow) 0.0 0) + (apply-settings *setting-control*) + ) + ) + ) + ) + ) + (when (and *target* (focus-test? *target* in-head flut light board pilot mech dark)) + (send-event *target* 'change-mode 'normal) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak-mode) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak-effect-1) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set-action! + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel jak-effect-2) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (when (< (-> self scene-index) (-> self scene-list length)) + (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t) + (while (and (-> self scene) + (nonzero? (-> self anim anim-name)) + (let ((v1-175 (file-status *art-control* (-> self anim name) 0))) + (or (not (or (= v1-175 'active) (= v1-175 'locked))) + (let* ((a1-32 + (lookup-gui-connection-id *gui-control* (-> self anim anim-name) (gui-channel art-load) (gui-action none)) + ) + (v1-181 (get-status *gui-control* a1-32)) + ) + (not (or (= v1-181 (gui-status ready)) (= v1-181 (gui-status active)))) + ) + ) + ) + ) + (set-blackout-frames (seconds 0.1)) + (suspend) + ) + ) + (go-virtual play-anim) + ) + ) + +;; failed to figure out what this is: +(defstate release (scene-player) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('user-data-set!) + (let ((v0-0 (-> block param 0))) + (set! (-> self user-data) v0-0) + v0-0 + ) + ) + (('user-data) + (-> self user-data) + ) + ) + ) + :code (behavior () + (remove-setting! 'borrow) + (when (scene-select?) + (remove-setting! 'audio-language) + (logclear! (-> self mask) (process-mask pause progress)) + (set-blackout-frames (seconds 0.05)) + (set-setting! 'music-volume 'abs 0.0 0) + (set-setting! 'sfx-volume 'abs 0.0 0) + (set-setting! 'ambient-volume 'abs 0.0 0) + (set-setting! 'allow-pause #f 0.0 0) + (set-setting! 'allow-progress #f 0.0 0) + (setup + *screen-filter* + (new 'static 'vector) + (new 'static 'vector :w 128.0) + (* 30.0 (seconds-per-frame)) + (bucket-id tex-hud-pris2) + #x3fffff + #x33001 + #t + ) + (let ((gp-0 (current-time))) + (until (time-elapsed? gp-0 (seconds 0.05)) + (suspend) + ) + ) + (set! (-> *setting-control* user-current bg-a) 0.0) + (remove-setting! 'movie) + (remove-setting! 'movie-name) + (while (or (-> *setting-control* user-current movie) + (not *target*) + (or (!= (-> *setting-control* user-current bg-a) 0.0) (load-in-progress? *level*)) + ) + (suspend) + ) + (set! (-> *game-info* blackout-time) 0) + (set! (-> *game-info* demo-state) (the-as uint 1)) + (set! (-> *setting-control* user-current bg-a-force) 0.0) + (set-setting! 'allow-progress #t 0.0 0) + (remove-setting! 'process-mask) + (remove-setting! 'letterbox) + (apply-settings *setting-control*) + (send-event *target* 'draw #t) + (send-event *target* 'trans 'reset) + (send-event *target* 'change-mode 'normal) + (activate-progress *dproc* 'select-scene-special) + (dotimes (gp-1 5) + (suspend) + ) + (disable *screen-filter*) + (deactivate self) + ) + (when (< (-> self scene-index) (+ (-> self scene-list length) -1)) + (set! (-> self scene-index) (+ (-> self scene-list length) -1)) + (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t) + ) + (let ((gp-2 (or (not (-> self scene)) (if (= (-> self blackout-end) 'none) + (logtest? (-> self scene scene-flags) (scene-flags scf2)) + (-> self blackout-end) + ) + ) + ) + ) + (if gp-2 + (set-blackout-frames (seconds 0.1)) + ) + (send-event *target* 'draw #t) + (send-event *target* 'trans 'reset) + (suspend) + (while (not (process-release? *target*)) + (suspend) + (if gp-2 + (set-blackout-frames (seconds 0.1)) + ) + ) + (if gp-2 + (set-blackout-frames (seconds 0.1)) + ) + ) + (when (nonzero? (the int (-> self scene music-delay))) + (persist-with-delay + *setting-control* + 'music-volume-movie + (the-as time-frame (the int (-> self scene music-delay))) + 'music-volume + 'abs + 0.0 + 0 + ) + (persist-with-delay + *setting-control* + 'music-delay + (the-as time-frame (the int (-> self scene music-delay))) + 'music + #f + 0.0 + 0 + ) + ) + (cond + ((and *target* (-> self scene) (or (-> self end-point) (-> self scene end-point))) + (let ((t9-32 scene-decode-continue) + (a0-37 (-> self end-point)) + ) + (set! a0-37 (cond + (a0-37 + (empty) + a0-37 + ) + (else + (-> self scene end-point) + ) + ) + ) + (let ((gp-4 (t9-32 a0-37))) + (when gp-4 + (persist-with-delay + *setting-control* + 'fail-sfx-volume + (seconds 10) + 'sfx-volume + 'abs + (-> *setting-control* user-target sfx-volume) + 0 + ) + (persist-with-delay + *setting-control* + 'fail-music-volume + (seconds 10) + 'music-volume + 'abs + (-> *setting-control* user-target music-volume) + 0 + ) + (persist-with-delay + *setting-control* + 'fail-dialog-volume + (seconds 10) + 'dialog-volume + 'abs + (-> *setting-control* user-target dialog-volume) + 0 + ) + (set-continue! *game-info* gp-4 #f) + (send-event *target* 'continue gp-4) + ) + ) + ) + ) + (else + (send-event *target* 'trans 'restore (-> self old-target-pos)) + ) + ) + (if (and (-> self scene) (logtest? (-> self scene scene-flags) (scene-flags scf4))) + (auto-save-user) + ) + (when (and (-> self scene) (-> self scene on-complete)) + (while (and *target* (focus-test? *target* teleporting)) + (suspend) + ) + (script-eval (-> self scene on-complete)) + ) + ) + ) + +;; failed to figure out what this is: +(defstate play-anim (scene-player) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object)) + (case message + (('trans-hook) + (set! v0-0 (-> block param 0)) + (set! (-> self new-trans-hook) (the-as (function none) v0-0)) + v0-0 + ) + (('eval) + ((the-as (function scene-player none) (-> block param 0)) self) + ) + (('abort) + (set! (-> self aborted?) #t) + (set-blackout-frames (seconds 0.2)) + (let ((a0-9 (-> self anim))) + (when (and a0-9 (= (-> *setting-control* user-current spooling) (process->ppointer self))) + (ja-abort-spooled-anim a0-9 (the-as art-joint-anim #f) -1) + (ja-channel-set! 0) + ) + ) + (go-virtual release) + ) + (('change-entity) + (let ((v1-9 (entity-by-name (the-as string (-> block param 0))))) + (set! (-> self main-entity) (the-as entity-actor v1-9)) + (cond + (v1-9 + (process-drawable-from-entity! self (-> self main-entity)) + (set! v0-0 (logclear (-> self mask) (process-mask actor-pause))) + (set! (-> self mask) (the-as process-mask v0-0)) + v0-0 + ) + (else + (format 0 "ERROR: SCENE: scene ~A can not find entity ~A~%" (-> self scene name) (-> block param 0)) + (vector-reset! (-> self root trans)) + (quaternion-identity! (-> self root quat)) + ) + ) + ) + ) + (('user-data-set!) + (set! v0-0 (-> block param 0)) + (set! (-> self user-data) (the-as uint v0-0)) + v0-0 + ) + (('user-data) + (-> self user-data) + ) + ) + ) + :enter (behavior () + (set-setting! 'ambient-wind-scalar #f 0.0 0) + (if (and (logtest? (-> self scene scene-flags) (scene-flags scf6)) *rigid-body-queue-manager*) + (change-parent self *rigid-body-queue-manager*) + ) + ) + :exit (behavior () + (while (-> self child) + (deactivate (-> self child 0)) + ) + (kill-current-talker '() '(daxter voicebox message) 'exit) + (set! (-> *setting-control* user-current bg-a) 0.0) + (kill-persister *setting-control* (the-as engine-pers 'bg-a) 'bg-a) + (kill-persister *setting-control* (the-as engine-pers 'bg-a-speed) 'bg-a-speed) + (if (not (and (-> self next-state) (= (-> self next-state name) 'wait))) + (remove-setting! 'borrow) + ) + (remove-setting! 'gem) + (apply-settings *setting-control*) + ) + :trans (behavior () + (if (!= (-> self cur-trans-hook) (-> self new-trans-hook)) + (set! (-> self cur-trans-hook) (-> self new-trans-hook)) + ) + (cond + ((not (-> *setting-control* user-current spooling)) + (if (and (-> self scene) (nonzero? (-> self anim anim-name))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> self anim name) + 0 + -1.0 + (new 'static 'sound-id) + ) + ) + ) + (else + (if (and (-> self scene) (nonzero? (-> self next-anim anim-name))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> self next-anim name) + 0 + -1.0 + (new 'static 'sound-id) + ) + ) + ) + ) + (when (logtest? (-> self scene scene-flags) (scene-flags scf6)) + (let ((v1-26 (handle->process (-> *target* pilot vehicle)))) + (when v1-26 + (set! (-> self root trans quad) (-> (the-as process-drawable v1-26) root trans quad)) + (quaternion-copy! (-> self root quat) (-> (the-as process-drawable v1-26) root quat)) + ) + ) + ) + (if (and (-> self scene) (-> self scene on-running)) + (script-eval (-> self scene on-running)) + ) + (when (and (logtest? (-> self scene scene-flags) (scene-flags scf8)) + (not (-> self preload-sound)) + (-> self scene) + (-> self scene end-point) + (< 10.0 (ja-aframe-num 0)) + ) + (let ((t9-6 scene-decode-continue) + (a0-20 (-> self end-point)) + ) + (set! a0-20 (cond + (a0-20 + (empty) + a0-20 + ) + (else + (-> self scene end-point) + ) + ) + ) + (let ((v1-49 (t9-6 a0-20))) + (when v1-49 + (dotimes (a0-22 3) + (set! (-> *load-state* want-sound a0-22 name) (-> v1-49 want-sound a0-22)) + (set! (-> *load-state* want-sound a0-22 mode) (sound-bank-mode unknown)) + (set! (-> *backup-load-state* want-sound a0-22 name) (-> v1-49 want-sound a0-22)) + (set! (-> *backup-load-state* want-sound a0-22 mode) (sound-bank-mode unknown)) + ) + (remove-setting! 'sound-bank-load) + (add-borrow-levels *load-state*) + ) + ) + ) + (set! (-> self preload-sound) (the-as basic #t)) + ) + ((-> self cur-trans-hook)) + ) + :code (behavior () + (local-vars (a0-29 symbol)) + (when (or *debug-menu-scene-play* (and (scene-select?) (-> self scene) (nonzero? (-> self scene scene-task)))) + (task-node-open! (the-as game-task-node (-> self scene scene-task)) 'event) + (logior! (-> self mask) (process-mask no-kill)) + (if (not (logtest? (-> self scene scene-flags) (scene-flags scf6))) + (reset-actors 'debug) + ) + (logclear! (-> self mask) (process-mask no-kill)) + ) + (dotimes (gp-0 2) + (let ((v1-17 (-> *art-control* buffer gp-0))) + (if (= (-> v1-17 status) 'active) + (link-art-to-master (-> v1-17 art-group)) + ) + ) + ) + (while (and (< (-> self scene-index) (-> self scene-list length)) (not (-> self aborted?))) + (scene-player-method-23 self (the-as string (-> self scene-list (-> self scene-index))) #t) + (kill-persister *setting-control* (the-as engine-pers 'title-control-scene) 'render) + (set-blackout-frames (seconds 0.1)) + (suspend) + (set-blackout-frames (seconds 0.1)) + (suspend) + (when (not (-> *setting-control* user-current border-mode)) + (set! (-> *setting-control* user-default border-mode) #t) + (set! (-> *level* play?) (-> *setting-control* user-default border-mode)) + (apply-settings *setting-control*) + ) + (scene-player-method-25 self 0.0 -1.0) + (set! (-> self cur-speed) 0.0) + (set-time! (-> self scene-start-time)) + (ja-play-spooled-anim + (-> self anim) + (the-as art-joint-anim #f) + (the-as art-joint-anim #f) + (the-as + (function process-drawable symbol) + (if (logtest? (-> self scene scene-flags) (scene-flags scf1)) + (lambda :behavior scene-player + () + (when (cpad-pressed? 0 triangle) + (set! (-> self aborted?) #t) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons triangle)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons triangle)) + #t + ) + (none) + ) + false-func + ) + ) + (if (logtest? (-> self scene scene-flags) (scene-flags scf7)) + (spooler-flags) + (spooler-flags blackout-on-stall) + ) + ) + (while (-> self child) + (deactivate (-> self child 0)) + ) + (+! (-> self scene-index) 1) + (when (and (< (-> self scene-index) (-> self scene-list length)) (not (-> self aborted?))) + (let ((v1-61 (scene-player-method-24 self (-> self scene-list (-> self scene-index)) #t))) + (when v1-61 + (let ((a0-26 (scene-decode-continue (-> v1-61 load-point)))) + (set! a0-29 (when (and a0-26 (logtest? (-> a0-26 flags) (continue-flags scene-wait))) + (go-virtual wait a0-29) + a0-29 + ) + ) + ) + ) + ) + ) + ) + (if (and (-> self wait) *target* (focus-test? *target* grabbed)) + (go-virtual release) + ) + ) + :post (behavior () + (when (-> self scene) + (let ((gp-0 (-> self scene cut-list)) + (s5-0 (-> self skel root-channel 0 frame-group)) + ) + (when (not (or (null? gp-0) (not s5-0) (zero? s5-0))) + (let ((v1-8 (the int (ja-frame-num 0))) + (a0-2 (car gp-0)) + ) + (while (not (null? gp-0)) + (let ((f0-5 (/ (- (the float (/ (the-as int a0-2) 8)) (-> s5-0 artist-base)) (-> s5-0 artist-step)))) + (when (= v1-8 (if (= f0-5 (the float (the int f0-5))) + (+ (the int f0-5) -1) + (the int f0-5) + ) + ) + (set! (-> self skel root-channel 0 frame-num) (the float (the int (-> self skel root-channel 0 frame-num)))) + (set! (-> self pre-cut-frame) (the-as basic #t)) + ) + ) + (set! gp-0 (cdr gp-0)) + (set! a0-2 (car gp-0)) + ) + ) + ) + ) + (if (-> self pre-cut-frame) + (set! (-> self pre-cut-frame) #f) + ) + ) + (when (and (-> self scene) (nonzero? (-> self skel active-channels))) + (when (and (< (ja-aframe-num 0) 2.0) + (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (logtest? (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (set-blackout-frames 0) + (set-blackout-frames (seconds 0.017)) + ) + (scene-player-method-25 self (ja-aframe-num 0) (-> self last-frame)) + (set! (-> self last-frame) (ja-aframe-num 0)) + (set! (-> self dma-max) + (the-as uint (max + (the-as int (-> self dma-max)) + (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16) + ) + ) + ) + (let ((gp-4 *display-scene-control*)) + (when (nonzero? gp-4) + (if (logtest? gp-4 (scene-controls bounds-spheres)) + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) + ) + (if (logtest? gp-4 (scene-controls actors)) + (format *stdcon* "anim ~-30S " (-> self scene anim)) + ) + (if (logtest? gp-4 (scene-controls actor-marks)) + (format + *stdcon* + "dma ~DK / ~DK" + (shr (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16) 10) + (shr (-> self dma-max) 10) + ) + ) + (if (logtest? gp-4 (scene-controls actors actor-marks)) + (format *stdcon* "~%") + ) + (when (logtest? gp-4 (scene-controls special-fma-spheres)) + (dotimes (s5-3 (-> self scene actor length)) + (let* ((s4-1 (handle->process (-> self scene actor s5-3 process))) + (v1-66 (if (type? s4-1 process-drawable) + (the-as process-drawable s4-1) + ) + ) + ) + (if (and v1-66 (nonzero? (-> v1-66 draw))) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + (-> v1-66 draw origin) + (-> v1-66 draw bounds w) + (new 'static 'rgba :b #xff :a #x80) + ) + ) + ) + ) + ) + (when (logtest? gp-4 (scene-controls scene-controls-7)) + (dotimes (s5-4 (-> self scene actor length)) + (let* ((s4-2 (handle->process (-> self scene actor s5-4 process))) + (v1-82 (if (type? s4-2 process-drawable) + (the-as process-drawable s4-2) + ) + ) + ) + (if (and v1-82 (nonzero? (-> v1-82 draw))) + (format + *stdcon* + "~0K ~-30S ~S d:~4,,0m r:~4,,0m~1K~%" + (-> self scene actor s5-4 art-group) + (if (logtest? (-> v1-82 draw status) (draw-control-status on-screen)) + "os" + " " + ) + (-> v1-82 draw distance) + (-> v1-82 draw bounds w) + ) + ) + ) + ) + ) + (when (logtest? gp-4 (scene-controls scene-controls-8)) + (dotimes (gp-5 (-> self scene actor length)) + (let* ((s5-5 (handle->process (-> self scene actor gp-5 process))) + (v1-97 (if (type? s5-5 process-drawable) + (the-as process-drawable s5-5) + ) + ) + ) + (if (and v1-97 (nonzero? (-> v1-97 draw))) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + (-> v1-97 name) + (-> v1-97 draw origin) + (font-color yellow) + (new 'static 'vector2h :y 8) + ) + ) + ) + ) + ) + ) + ) + ) + (when (cpad-pressed? 0 square) + (set! (-> *setting-control* user-default subtitle) (not (-> *setting-control* user-default subtitle))) + (set-time! (-> self subtitle-change-time)) + ) + (when (and (not (time-elapsed? (-> self subtitle-change-time) (seconds 2))) + (< (mod (- (current-time) (-> self subtitle-change-time)) 300) 210) + ) + (let ((gp-6 + (new 'stack 'font-context *font-default-matrix* 36 60 0.0 (font-color default) (font-flags shadow kerning)) + ) + ) + (let ((v1-124 gp-6)) + (set! (-> v1-124 width) (the float 440)) + ) + (let ((v1-125 gp-6)) + (set! (-> v1-125 height) (the float 48)) + ) + (let ((v1-126 gp-6)) + (set! (-> v1-126 scale) 0.5) + ) + (set! (-> gp-6 flags) (font-flags shadow kerning middle large)) + (print-game-text + (lookup-text! + *common-text* + (if (-> *setting-control* user-default subtitle) + (text-id text-020b) + (text-id text-020c) + ) + #f + ) + gp-6 + #f + 44 + (bucket-id hud-draw-pris2) + ) + ) + ) + (process-drawable-draw-subtitles) + (when (-> self scene) + (let ((gp-7 + (lookup-gui-connection *gui-control* self (gui-channel art-load) (-> self scene anim) (new 'static 'sound-id)) + ) + ) + (when (and (= *cheat-mode* 'debug) (!= *external-cam-mode* 'pad-0)) + (cond + ((cpad-hold? 0 r1) + (if (cpad-pressed? 0 circle) + (set-time! (-> self speed-press-time)) + ) + (seek! + (-> self speed-change-speed) + 8.0 + (* (lerp-scale 0.01 0.3 (the float (- (current-time) (-> self speed-press-time))) 0.0 300.0) + (-> self clock time-adjust-ratio) + ) + ) + ) + ((cpad-hold? 0 l1) + (if (cpad-pressed? 0 square) + (set-time! (-> self speed-press-time)) + ) + (seek! + (-> self speed-change-speed) + -8.0 + (* (lerp-scale 0.01 0.3 (the float (- (current-time) (-> self speed-press-time))) 0.0 300.0) + (-> self clock time-adjust-ratio) + ) + ) + ) + ((cpad-hold? 0 x) + (when (cpad-pressed? 0 x) + (set-time! (-> self speed-press-time)) + (cond + ((= (-> self cur-speed) 0.0) + (set! (-> self speed-change-speed) -1000.0) + ) + (else + (set! (-> self targ-speed) 0.0) + (set! (-> self speed-change-speed) 0.0) + ) + ) + ) + ) + (else + (set! (-> self speed-change-speed) 0.0) + ) + ) + ) + (cond + ((not gp-7) + ) + ((= (-> self cur-speed) -1000.0) + (format *stdcon* "scene paused~%") + (when (!= (-> self targ-speed) -1000.0) + (sound-continue (-> gp-7 id)) + (when *sound-player-enable* + (let ((v1-190 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-190 command) (sound-command set-param)) + (set! (-> v1-190 id) (-> gp-7 id)) + (set! (-> v1-190 params pitch-mod) 0) + (set! (-> v1-190 params mask) (the-as uint 2)) + (-> v1-190 id) + ) + ) + (set! (-> self targ-speed) 0.0) + (set! (-> self cur-speed) 0.0) + (set-time! (-> self speed-change-time)) + ) + ) + ((= (-> self speed-change-speed) -1000.0) + (when (!= (-> self cur-speed) -1000.0) + (set-time! (-> self speed-change-time)) + (set! (-> self targ-speed) -1000.0) + (set! (-> self cur-speed) -1000.0) + (sound-pause (-> gp-7 id)) + ) + ) + (else + (set! (-> self targ-speed) + (fmax -10.0 (fmin 10.0 (+ (-> self targ-speed) (* (-> self speed-change-speed) (seconds-per-frame))))) + ) + (if (and (= *cheat-mode* 'debug) (not (time-elapsed? (-> self speed-change-time) (seconds 3)))) + (format + *stdcon* + "id ~d speed ~f~%" + (if gp-7 + (the-as int (-> gp-7 id)) + 0 + ) + (-> self targ-speed) + ) + ) + (cond + ((!= (-> self targ-speed) 0.0) + ) + ((logtest? (game-secrets fast-movie) (-> *game-info* secrets)) + (set! (-> self targ-speed) 0.2) + ) + ((logtest? (game-secrets slow-movie) (-> *game-info* secrets)) + (set! (-> self targ-speed) -0.2) + ) + ) + (when (and gp-7 (and (!= (-> self targ-speed) (-> self cur-speed)) + (< (-> self speed-change-time) (current-time)) + (time-elapsed? (-> self scene-start-time) (seconds 1)) + ) + ) + (when *sound-player-enable* + (let ((v1-229 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> v1-229 command) (sound-command set-param)) + (set! (-> v1-229 id) (-> gp-7 id)) + (set! (-> v1-229 params pitch-mod) (the int (* 1524.0 (-> self targ-speed)))) + (set! (-> v1-229 params mask) (the-as uint 2)) + (-> v1-229 id) + ) + ) + (set! (-> self cur-speed) (-> self targ-speed)) + (set-time! (-> self speed-change-time)) + ) + ) + ) + ) + ) + ) + ) + +;; definition for function scene-player-init +;; WARN: Return type mismatch object vs none. +(defbehavior scene-player-init scene-player ((arg0 object) (arg1 symbol) (arg2 string)) + (process-entity-set! self (the-as entity #f)) + (stack-size-set! (-> self main-thread) 512) + (set! (-> self root) (new 'process 'trsqv)) + (case (rtype-of arg0) + ((array) + (set! (-> self scene-list) (new 'process 'boxed-array scene (-> (the-as (array scene) arg0) length))) + (dotimes (v1-7 (-> self scene-list length)) + (set! (-> self scene-list v1-7) (-> (the-as (array scene) arg0) v1-7)) + ) + ) + ((pair) + (let ((s3-0 (method-of-type array new)) + (s2-0 'process) + (s1-0 array) + (s0-0 scene) + (a0-14 arg0) + ) + (set! (-> self scene-list) + (the-as (array scene) (s3-0 s2-0 s1-0 s0-0 ((method-of-type (rtype-of a0-14) length) a0-14))) + ) + ) + (dotimes (s3-1 (-> self scene-list length)) + (set! (-> self scene-list s3-1) (the-as scene (ref arg0 s3-1))) + ) + ) + (else + (set! (-> self scene-list) (new 'process 'boxed-array scene 1)) + (set! (-> self scene-list 0) (the-as scene arg0)) + ) + ) + (set! (-> self preload-continue) arg2) + (set! (-> self camera) (the-as handle #f)) + (set! (-> self wait) arg1) + (set! (-> self pre-cut-frame) #f) + (set! (-> self aborted?) #f) + (set! (-> self blackout-end) (the-as basic 'none)) + (set! (-> self end-point) #f) + (set! (-> self preload-sound) #f) + (set! (-> self draw) (new 'process 'draw-control self #f)) + (set! (-> self skel) (new 'process 'joint-control 48)) + (set! (-> self anim) (new 'static 'spool-anim)) + (set! (-> self next-anim) (new 'static 'spool-anim)) + (dotimes (s4-1 (-> self scene-list length)) + (let ((v1-30 (scene-lookup (-> self scene-list s4-1)))) + (if v1-30 + (set! (-> self scene-list s4-1) v1-30) + ) + ) + ) + (cond + ((= (-> self scene-list (-> self scene-index) type) scene) + (set! (-> self scene) (-> self scene-list (-> self scene-index))) + (if (-> self scene) + (init-spool-by-scene! (-> self scene) (-> self anim)) + ) + ) + (else + (set-blackout-frames (seconds 0.2)) + (set! (-> self scene) #f) + ) + ) + (set! (-> self gui-id) (add-process + *gui-control* + self + (gui-channel movie) + (gui-action play) + (the-as string (cond + ((= (rtype-of arg0) string) + (empty) + arg0 + ) + (else + "movie" + ) + ) + ) + -99.0 + 0 + ) + ) + (set! *scene-player* (the-as (pointer scene-player) (process->ppointer self))) + (set! *display-entity-errors* #f) + (set-setting! 'speech-control #f 0.0 0) + (set-setting! 'allow-progress #f 0.0 0) + (if (or (= (cond + ((-> self scene) + (if (>= (-> self scene music-volume) 0.0) + (-> self scene music-volume) + (-> *setting-control* user-current music-volume-movie) + ) + ) + (else + 0.0 + ) + ) + 0.0 + ) + (not (-> *setting-control* user-current music)) + (!= (-> *setting-control* user-target music) (-> *setting-control* user-current music)) + ) + (set-setting! 'music #f 0.0 0) + ) + (apply-settings *setting-control*) + (set! (-> self new-trans-hook) nothing) + (set! (-> self cur-trans-hook) nothing) + (go-virtual wait arg1) + (none) + ) + +;; definition for method 17 of type scene +(defmethod load-scene ((this scene)) + (let ((v1-1 (-> *level* loading-level))) + (if v1-1 + (set-loaded-art (-> v1-1 art-group) this) + ) + ) + this + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/target/gun/gun-dark-shot_REF.gc b/test/decompiler/reference/jak3/engine/target/gun/gun-dark-shot_REF.gc new file mode 100644 index 0000000000..7920e2172a --- /dev/null +++ b/test/decompiler/reference/jak3/engine/target/gun/gun-dark-shot_REF.gc @@ -0,0 +1,4103 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(set! (-> *lightning-spec-id-table* 15) (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 1.0 + :fade-time 30.0 + :texture (new 'static 'texture-id :index #x8f :page #x4) + :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" :group 1) + ) + ) + +;; failed to figure out what this is: +(set! (-> *lightning-spec-id-table* 16) (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 1.0 + :fade-time 30.0 + :texture (new 'static 'texture-id :index #x3f :page #x4) + :reduction 0.42 + :num-points 16 + :box-size 8192.0 + :merge-factor 0.6 + :merge-count 2 + :radius 3276.8 + :duration 60.0 + :sound (static-sound-spec "stretched-zap" :group 1) + ) + ) + +;; failed to figure out what this is: +(defpartgroup group-lightning-dark-shot-tip-hit + :id 183 + :flags (sp0 sp4) + :bounds (static-bspherem 0 0 0 10) + :parts ((sp-item 664)) + ) + +;; failed to figure out what this is: +(defpart 664 + :init-specs ((:texture (lightning-anim-01 level-default-sprite)) + (:birth-func 'birth-func-texture-group) + (:num 2.0 3.0) + (:scale-x (meters 0.1) (meters 0.1)) + (:rot-z (degrees 90)) + (:scale-y :copy scale-x) + (:r 0.0 64.0) + (:g 64.0 64.0) + (:b 255.0) + (:a 255.0) + (:vel-z (meters 0.016666668) (meters 0.006666667)) + (:scalevel-x (meters 0.006666667) (meters 0.006666667)) + (:scalevel-y :copy scalevel-x) + (:fade-a -1.7) + (:friction 0.99) + (:timer (seconds 0.5)) + (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3)) + (:userdata :data (new 'static 'boxed-array :type int32 20 1 0 #x405700 #x405800 #x405900)) + (:func 'sparticle-lightning-2d-spline-align-plus-rotz) + (:rotate-y (degrees 0) (degrees 3600)) + ) + ) + +;; failed to figure out what this is: +(defpart 665 + :init-specs ((:texture (glow-hotdot level-default-sprite)) + (:num 1.0) + (:scale-x (meters 1) (meters 4)) + (:rot-x (degrees 11.25)) + (:rot-z (degrees 0) (degrees 360)) + (:scale-y :copy scale-x) + (:r 0.0 64.0) + (:g 64.0 64.0) + (:b 255.0) + (:a 128.0) + (:timer (seconds 0.017)) + (:flags (sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow)) + (:userdata 4096.0) + (:conerot-x (degrees 0) (degrees 3600)) + (:conerot-y (degrees 0) (degrees 3600)) + (:conerot-z (degrees 0) (degrees 3600)) + (:conerot-radius (meters -0.1) (meters 0.5)) + ) + ) + +;; definition for function sparticle-lightning-2d-spline-align-plus-rotz +;; WARN: Return type mismatch float vs none. +(defun sparticle-lightning-2d-spline-align-plus-rotz ((arg0 object) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-2d) (arg3 object)) + (sparticle-2d-spline-align-instant arg0 arg1 arg2 arg3) + (+! (-> arg2 flag-rot-sy z) (-> *part-id-table* 664 init-specs 4 initial-valuef)) + (none) + ) + +;; definition of type gun-dark-shot +(deftype gun-dark-shot (projectile) + ((blast-radius float) + (core-position vector :inline) + (core-velocity vector :inline) + (spin-vector vector :inline) + (track-target handle) + (size-t float) + (result-array handle 16) + (result-count int8) + (charge-sound sound-id) + (fire-sound sound-id) + (trail-sound sound-id) + (explode-sound sound-id) + (start-pilot? symbol) + (spread-timer time-frame) + ) + (:state-methods + startup + fizzle + ) + ) + +;; definition for method 3 of type gun-dark-shot +(defmethod inspect ((this gun-dark-shot)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile inspect))) + (t9-0 this) + ) + (format #t "~2Tblast-radius: ~f~%" (-> this blast-radius)) + (format #t "~2Tcore-position: #~%" (-> this core-position)) + (format #t "~2Tcore-velocity: #~%" (-> this core-velocity)) + (format #t "~2Tspin-vector: #~%" (-> this spin-vector)) + (format #t "~2Ttrack-target: ~D~%" (-> this track-target)) + (format #t "~2Tsize-t: ~f~%" (-> this size-t)) + (format #t "~2Tresult-array[16] @ #x~X~%" (-> this result-array)) + (format #t "~2Tresult-count: ~D~%" (-> this result-count)) + (format #t "~2Tcharge-sound: ~D~%" (-> this charge-sound)) + (format #t "~2Tfire-sound: ~D~%" (-> this fire-sound)) + (format #t "~2Ttrail-sound: ~D~%" (-> this trail-sound)) + (format #t "~2Texplode-sound: ~D~%" (-> this explode-sound)) + (format #t "~2Tstart-pilot?: ~A~%" (-> this start-pilot?)) + (format #t "~2Tspread-timer: ~D~%" (-> this spread-timer)) + (label cfg-4) + this + ) + +;; definition for function gun-fire-dark-1 +;; INFO: Used lq/sq +(defbehavior gun-fire-dark-1 target () + (set-last-fire-time 35) + (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)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-11 *game-info*) + (a0-13 (+ (-> v1-11 attack-id) 1)) + ) + (set! (-> v1-11 attack-id) a0-13) + (set! (-> gp-0 attack-id) a0-13) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (let ((v0-2 (spawn-projectile gun-dark-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*))) + (if v0-2 + (set! (-> self gun charge-active?) (ppointer->handle v0-2)) + ) + v0-2 + ) + ) + ) + +;; failed to figure out what this is: +(defskelgroup skel-gun-dark-3-sphere gun gun-nuke-sphere-lod0-jg gun-nuke-sphere-idle-ja + ((gun-nuke-sphere-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 30) + :texture-level 10 + :light-index 4 + ) + +;; definition of type gun-dark-3-sphere +(deftype gun-dark-3-sphere (process-drawable) + ((alpha-val float) + ) + (:state-methods + active + ) + ) + +;; definition for method 3 of type gun-dark-3-sphere +(defmethod inspect ((this gun-dark-3-sphere)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Talpha-val: ~f~%" (-> this alpha-val)) + (label cfg-4) + this + ) + +;; definition of type gun-dark-3-sphere-init-params +(deftype gun-dark-3-sphere-init-params (structure) + ((pos vector :inline) + (size-x float) + (size-y float) + (alpha-val float) + ) + ) + +;; definition for method 3 of type gun-dark-3-sphere-init-params +(defmethod inspect ((this gun-dark-3-sphere-init-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gun-dark-3-sphere-init-params) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tsize-x: ~f~%" (-> this size-x)) + (format #t "~1Tsize-y: ~f~%" (-> this size-y)) + (format #t "~1Talpha-val: ~f~%" (-> this alpha-val)) + (label cfg-4) + this + ) + +;; definition for function gun-dark-3-sphere-init-by-other +;; INFO: Used lq/sq +(defbehavior gun-dark-3-sphere-init-by-other gun-dark-3-sphere ((arg0 gun-dark-3-sphere-init-params)) + (set! (-> self root) (new 'process 'trsqv)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-dark-3-sphere" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self root trans quad) (-> arg0 pos quad)) + (quaternion-identity! (-> self root quat)) + (set-vector! + (-> self root scale) + (* 0.00024414062 (-> arg0 size-x)) + (* 0.00024414062 (-> arg0 size-y)) + 1.0 + 1.0 + ) + (go-virtual active) + ) + +;; failed to figure out what this is: +(defstate active (gun-dark-3-sphere) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('set-pos-and-size) + (let ((v1-2 (the-as gun-dark-3-sphere-init-params (-> block param 0)))) + (set! (-> self root trans quad) (-> v1-2 pos quad)) + (set-vector! + (-> self root scale) + (* 0.00024414062 (-> v1-2 size-x)) + (* 0.00024414062 (-> v1-2 size-y)) + 1.0 + 1.0 + ) + (vector-float*! (-> self root scale) (-> self root scale) 1.7) + (set! (-> self alpha-val) (-> v1-2 alpha-val)) + ) + ) + ) + #t + ) + :enter (behavior () + (set-time! (-> self state-time)) + (ja-channel-push! 1 0) + (ja :group! gun-nuke-sphere-fade-ja :num! zero) + (set! (-> self alpha-val) 1.0) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (let ((s5-1 (vector-! (new 'stack-no-clear 'vector) (-> self root trans) (math-camera-pos)))) + (set! (-> s5-1 y) 0.0) + (vector-normalize! s5-1 1.0) + (vector-float*! s5-1 s5-1 -1.0) + (matrix-fu-compose gp-0 s5-1 *up-vector*) + ) + (matrix->quat gp-0 (-> self root quat)) + ) + (ja :group! gun-nuke-sphere-fade-ja :num! (identity (- 1.0 (-> self alpha-val)))) + ) + :code sleep-code + :post (behavior () + (ja-post) + ) + ) + +;; failed to figure out what this is: +(defskelgroup skel-gun-dark-3-nuke gun gun-nuke-lod0-jg gun-nuke-idle-ja + ((gun-nuke-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3) + :texture-level 10 + ) + +;; definition of type last-active-nuke-info +(deftype last-active-nuke-info (structure) + ((last-active-nuke handle) + ) + ) + +;; definition for method 3 of type last-active-nuke-info +(defmethod inspect ((this last-active-nuke-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'last-active-nuke-info) + (format #t "~1Tlast-active-nuke: ~D~%" (-> this last-active-nuke)) + (label cfg-4) + this + ) + +;; definition for symbol *last-active-nuke*, type last-active-nuke-info +(define *last-active-nuke* (new 'static 'last-active-nuke-info)) + +;; failed to figure out what this is: +(set! (-> *last-active-nuke* last-active-nuke) (the-as handle #f)) + +;; definition of type gun-dark-3-nuke +(deftype gun-dark-3-nuke (projectile) + ((flash-time time-frame) + (blur-time time-frame) + (spawned-mushroom-cloud? symbol) + (strip prim-strip) + (mushroom-top-pos vector :inline) + (warp handle) + (initial-velocity vector :inline) + (start-y float) + (y-vel-adjust float) + (launch-speed float) + (launch-sin-region-start float) + (launch-sin-region-end float) + (launch-stay-state-time time-frame) + (launch-next-state (state gun-dark-3-nuke)) + (launch-impact-state (state gun-dark-3-nuke)) + (launch-y-scale float) + (launch-height-t float) + (expected-height float) + (total-fly-time time-frame) + (num-dying-vehicles uint8) + (num-dying-guards uint8) + (num-dying-civilians uint8) + (last-death-sound-play-time time-frame) + (blur-curve curve2d-piecewise) + (fade-curve curve-color-piecewise) + (num-blur-segments uint8) + (shook-camera? symbol) + (hit-wall? symbol) + (killed-everything? symbol :offset 696) + (explode-sound sound-id) + (explode-wall-sound sound-id) + (played-trail? symbol) + (smoke-trail sparticle-subsampler) + (killed-objects handle 64) + (num-killed-objects int32) + (last-kill-time time-frame) + ) + (:state-methods + undefined + launching-base-state + launch-0 + launch-1 + launch-2 + launch-3 + impact-small + impact-dud + impact-embedded + wait-for-alive + ) + (:methods + (set-launch-height! (_type_) none) + (do-blur-effect (_type_) none) + (do-white-screen-effect (_type_) none) + (count-casualties (_type_) none) + (send-attack! (_type_ process-focusable) none) + (play-death-sounds (_type_) none) + (do-camera-shake (_type_) none) + (do-vibration (_type_) none) + (check-for-impact (_type_) none) + ) + ) + +;; definition for method 3 of type gun-dark-3-nuke +(defmethod inspect ((this gun-dark-3-nuke)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile inspect))) + (t9-0 this) + ) + (format #t "~2Tflash-time: ~D~%" (-> this flash-time)) + (format #t "~2Tblur-time: ~D~%" (-> this blur-time)) + (format #t "~2Tspawned-mushroom-cloud?: ~A~%" (-> this spawned-mushroom-cloud?)) + (format #t "~2Tstrip: ~A~%" (-> this strip)) + (format #t "~2Tmushroom-top-pos: #~%" (-> this mushroom-top-pos)) + (format #t "~2Twarp: ~D~%" (-> this warp)) + (format #t "~2Tinitial-velocity: #~%" (-> this initial-velocity)) + (format #t "~2Tstart-y: ~f~%" (-> this start-y)) + (format #t "~2Ty-vel-adjust: ~f~%" (-> this y-vel-adjust)) + (format #t "~2Tlaunch-speed: ~f~%" (-> this launch-speed)) + (format #t "~2Tlaunch-sin-region-start: ~f~%" (-> this launch-sin-region-start)) + (format #t "~2Tlaunch-sin-region-end: ~f~%" (-> this launch-sin-region-end)) + (format #t "~2Tlaunch-stay-state-time: ~D~%" (-> this launch-stay-state-time)) + (format #t "~2Tlaunch-next-state: ~A~%" (-> this launch-next-state)) + (format #t "~2Tlaunch-impact-state: ~A~%" (-> this launch-impact-state)) + (format #t "~2Tlaunch-y-scale: ~f~%" (-> this launch-y-scale)) + (format #t "~2Tlaunch-height-t: ~f~%" (-> this launch-height-t)) + (format #t "~2Texpected-height: ~f~%" (-> this expected-height)) + (format #t "~2Ttotal-fly-time: ~D~%" (-> this total-fly-time)) + (format #t "~2Tnum-dying-vehicles: ~D~%" (-> this num-dying-vehicles)) + (format #t "~2Tnum-dying-guards: ~D~%" (-> this num-dying-guards)) + (format #t "~2Tnum-dying-civilians: ~D~%" (-> this num-dying-civilians)) + (format #t "~2Tlast-death-sound-play-time: ~D~%" (-> this last-death-sound-play-time)) + (format #t "~2Tblur-curve: ~A~%" (-> this blur-curve)) + (format #t "~2Tfade-curve: ~A~%" (-> this fade-curve)) + (format #t "~2Tnum-blur-segments: ~D~%" (-> this num-blur-segments)) + (format #t "~2Tshook-camera?: ~A~%" (-> this shook-camera?)) + (format #t "~2Thit-wall?: ~A~%" (-> this hit-wall?)) + (format #t "~2Tattack-id: ~D~%" (-> this attack-id)) + (format #t "~2Tkilled-everything?: ~A~%" (-> this killed-everything?)) + (format #t "~2Texplode-sound: ~D~%" (-> this explode-sound)) + (format #t "~2Texplode-wall-sound: ~D~%" (-> this explode-wall-sound)) + (format #t "~2Tplayed-trail?: ~A~%" (-> this played-trail?)) + (format #t "~2Tsmoke-trail: ~A~%" (-> this smoke-trail)) + (format #t "~2Tkilled-objects[64] @ #x~X~%" (-> this killed-objects)) + (format #t "~2Tnum-killed-objects: ~D~%" (-> this num-killed-objects)) + (format #t "~2Tlast-kill-time: ~D~%" (-> this last-kill-time)) + (label cfg-4) + this + ) + +;; definition for method 25 of type gun-dark-3-nuke +;; INFO: Used lq/sq +(defmethod projectile-method-25 ((this gun-dark-3-nuke)) + (when (not (logtest? (-> this draw status) (draw-control-status no-draw))) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (matrix-f-u-compose s5-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> this root quat)) *up-vector*) + (set! (-> s5-0 trans quad) (-> this root trans quad)) + (sparticle-launch-control-method-17 (-> this part) s5-0) + (sparticle-subsampler-method-10 (-> this smoke-trail) s5-0) + ) + ) + (none) + ) + +;; definition for function gun-dark-reaction +;; INFO: Used lq/sq +(defun gun-dark-reaction ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector)) + (cshape-reaction-update-state arg0 arg1 arg3) + (set! (-> arg2 quad) (-> arg3 quad)) + (cond + ((logtest? (-> arg0 status) (collide-status touch-wall)) + (send-event (-> arg0 process) 'impact-small) + ) + ((let ((f0-1 (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) arg3 1.0) (-> arg0 surface-normal)))) + (< -0.3 f0-1) + ) + (let ((v1-9 (new 'stack-no-clear 'vector))) + (set! (-> v1-9 quad) (-> arg0 trans quad)) + (+ 1228.8 (-> v1-9 y)) + ) + (vector-flatten! arg2 arg3 (-> arg0 surface-normal)) + (send-event (-> arg0 process) 'slide-now (-> arg0 surface-normal)) + ) + (else + (send-event (-> arg0 process) 'impact) + ) + ) + (-> arg0 status) + ) + +;; definition for method 30 of type gun-dark-3-nuke +;; WARN: Return type mismatch int vs none. +(defmethod setup-collision! ((this gun-dark-3-nuke)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) gun-dark-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate explode)) + (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-7 prim-core action) (collide-action solid)) + (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 40.96) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-7) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-10 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set-collide-with! (-> this root) (collide-spec backgnd obstacle pusher impenetrable-obj)) + (set-collide-as! (-> this root) (collide-spec projectile)) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + (none) + ) + +;; definition for method 31 of type gun-dark-3-nuke +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod init-proj-settings! ((this gun-dark-3-nuke)) + (with-pp + (set! (-> *last-active-nuke* last-active-nuke) (process->handle this)) + (set! (-> this attack-mode) 'eco-dark) + (initialize-skeleton + this + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-dark-3-nuke" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> this spawned-mushroom-cloud?) #f) + (set! (-> this strip) + (new 'process 'prim-strip 4 (new 'static 'texture-id :index #x1f :page #x5) (the-as string #f)) + ) + (set! (-> this played-trail?) #f) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 112) this)) + pp + (set! (-> this smoke-trail) + (new 'process 'sparticle-subsampler *sp-particle-system-2d* (-> *part-id-table* 388) 8.0) + ) + (set-setting! 'allow-progress #f 0.0 0) + (set! (-> this explode-sound) + (add-process *gui-control* this (gui-channel gun) (gui-action queue) "pg3nxplo" -99.0 0) + ) + (set! (-> this explode-wall-sound) + (add-process *gui-control* this (gui-channel gun) (gui-action queue) "pg3wxplo" -99.0 0) + ) + (let* ((v1-19 *game-info*) + (a0-15 (+ (-> v1-19 attack-id) 1)) + ) + (set! (-> v1-19 attack-id) a0-15) + (set! (-> this attack-id) a0-15) + ) + (set! (-> this initial-velocity quad) (-> this root transv quad)) + (set! (-> this start-y) (-> this root trans y)) + (set! (-> this launch-impact-state) (method-of-object this impact-dud)) + (set! (-> this y-vel-adjust) 0.0) + (set! (-> this warp) (the-as handle #f)) + (set! (-> this shook-camera?) #f) + (set-vector! (-> this root scale) 2.5 2.5 2.5 1.0) + (set! (-> this killed-everything?) #f) + (let ((t9-8 (method-of-type projectile init-proj-settings!))) + (t9-8 this) + ) + (logior! (-> this options) (projectile-options po4)) + (set! (-> this total-fly-time) 0) + 0 + (none) + ) + ) + +;; definition for method 7 of type gun-dark-3-nuke +(defmethod relocate ((this gun-dark-3-nuke) (offset int)) + (if (nonzero? (-> this strip)) + (&+! (-> this strip) offset) + ) + (if (nonzero? (-> this smoke-trail)) + (&+! (-> this smoke-trail) offset) + ) + (call-parent-method this offset) + ) + +;; definition for function nuke-move +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs object. +(defbehavior nuke-move gun-dark-3-nuke () + (let ((gp-0 (-> self root))) + (set! (-> self pre-move-transv quad) (-> gp-0 transv quad)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> gp-0 trans quad)) + ((-> self move) self) + (projectile-method-39 self) + (set! (-> self old-dist (-> self old-dist-count)) (* 0.0625 (vector-vector-distance s5-0 (-> gp-0 trans)))) + ) + ) + (set! (-> self old-dist-count) (logand (+ (-> self old-dist-count) 1) 15)) + (let ((f0-2 0.0)) + (countdown (v1-12 16) + (+! f0-2 (-> self old-dist v1-12)) + ) + ) + #f + ) + +;; definition for method 51 of type gun-dark-3-nuke +;; WARN: Return type mismatch float vs none. +(defmethod set-launch-height! ((this gun-dark-3-nuke)) + (set! (-> this launch-height-t) + (/ (the float (- (current-time) (-> this state-time))) (the float (-> this launch-stay-state-time))) + ) + (set! (-> this launch-height-t) (fmax 0.0 (fmin 1.0 (-> this launch-height-t)))) + (none) + ) + +;; definition for method 35 of type gun-dark-3-nuke +(defmethod proj-event-handler ((this gun-dark-3-nuke) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('impact) + (go (-> this launch-impact-state)) + ) + (('impact-small) + (go (method-of-object this impact-embedded)) + ) + (('slide-now) + (let ((a2-1 (-> arg3 param 0)) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (vector-flatten! s5-1 (-> this initial-velocity) (the-as vector a2-1)) + (set! (-> this y-vel-adjust) (-> s5-1 y)) + ) + (set! (-> this start-y) (+ (-> this start-y) (* (-> this y-vel-adjust) (seconds-per-frame)))) + ) + (else + (call-parent-method this arg0 arg1 arg2 arg3) + ) + ) + ) + +;; failed to figure out what this is: +(defstate launching-base-state (gun-dark-3-nuke) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (proj-event-handler self proc argc message block) + ) + :enter (behavior () + (set-time! (-> self state-time)) + (set! (-> self root transv y) 0.0) + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (when (and (not (-> self played-trail?)) (>= (+ (current-time) (seconds -0.3)) (-> self total-fly-time))) + (sound-play "purple-3-trail" :position (-> self root trans)) + (set! (-> self played-trail?) #t) + ) + (when (time-elapsed? (-> self state-time) (-> self launch-stay-state-time)) + (set! (-> self start-y) (-> self root trans y)) + (go (-> self launch-next-state)) + ) + (+! (-> self start-y) (* (-> self y-vel-adjust) (seconds-per-frame))) + (let ((f0-3 (-> self launch-height-t))) + 0.0 + 0.0 + (let ((f0-4 (lerp (-> self launch-sin-region-start) (-> self launch-sin-region-end) f0-3))) + 0.0 + (let ((f30-1 (+ (- (* (sin (* 182.04445 f0-4)) (-> self launch-y-scale)) + (* (sin (* 182.04445 (-> self launch-sin-region-start))) (-> self launch-y-scale)) + ) + (-> self start-y) + ) + ) + ) + (set! (-> self expected-height) f30-1) + (vector-normalize-copy! (-> self root transv) (-> self initial-velocity) (-> self launch-speed)) + (set! (-> self root transv y) (- f30-1 (-> self root trans y))) + ) + ) + ) + (set! (-> self root transv y) (/ (-> self root transv y) (seconds-per-frame))) + (let ((t9-8 nuke-move)) + (-> self launch-impact-state) + (t9-8) + ) + (vector-x-quaternion! (new 'stack-no-clear 'vector) (-> self root quat)) + (let ((gp-1 (new 'stack-no-clear 'matrix))) + (let* ((t9-10 vector-normalize-copy!) + (a0-12 (new 'stack-no-clear 'vector)) + (a1-4 (-> self root transv)) + (a2-3 1.0) + (a1-5 (t9-10 a0-12 a1-4 a2-3)) + ) + (matrix-f-compose gp-1 a1-5 a2-3) + ) + (matrix->quaternion (-> self root quat) gp-1) + ) + (+! (-> self total-fly-time) (- (current-time) (-> self clock old-frame-counter))) + ) + :code sleep-code + :post (behavior () + (ja-post) + (projectile-method-25 self) + ) + ) + +;; failed to figure out what this is: +(defstate launch-0 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set! (-> self launch-impact-state) (method-of-object self impact-embedded)) + (set! (-> self launch-y-scale) 0.0) + (set! (-> self launch-stay-state-time) (seconds 0.2)) + (set! (-> self launch-next-state) (method-of-object self launch-1)) + (let ((v1-6 (-> self state parent))) + (when v1-6 + (let ((t9-0 (-> v1-6 enter))) + (if t9-0 + ((the-as (function none) t9-0)) + ) + ) + ) + ) + ) + :trans (behavior () + (set-launch-height! self) + (set! (-> self launch-speed) 32768.0) + (let ((v1-4 (-> self state parent))) + (when v1-4 + (let ((t9-1 (-> v1-4 trans))) + (if t9-1 + (t9-1) + ) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate launch-1 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set! (-> self launch-y-scale) 0.0) + (set! (-> self launch-stay-state-time) (seconds 0.4)) + (set! (-> self launch-next-state) (method-of-object self launch-2)) + (let ((v1-4 (-> self state parent))) + (when v1-4 + (let ((t9-0 (-> v1-4 enter))) + (if t9-0 + ((the-as (function none) t9-0)) + ) + ) + ) + ) + ) + :trans (behavior () + (set-launch-height! self) + (let ((f0-1 (* 0.008333334 (the float (- (current-time) (-> self state-time)))))) + (set! (-> self launch-speed) (lerp 61440.0 204800.0 f0-1)) + ) + (let ((v1-8 (-> self state parent))) + (when v1-8 + (let ((t9-2 (-> v1-8 trans))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate launch-2 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set! (-> self launch-sin-region-start) 0.0) + (set! (-> self launch-sin-region-end) 270.0) + (set! (-> self launch-stay-state-time) (seconds 0.5)) + (set! (-> self launch-next-state) (method-of-object self launch-3)) + (set! (-> self launch-y-scale) 34816.0) + (let ((v1-6 (-> self state parent))) + (when v1-6 + (let ((t9-0 (-> v1-6 enter))) + (if t9-0 + ((the-as (function none) t9-0)) + ) + ) + ) + ) + ) + :trans (behavior () + (let ((f30-0 (* 0.006666667 (the float (- (current-time) (-> self state-time)))))) + (if (< 0.7 f30-0) + (set! (-> self launch-impact-state) (method-of-object self impact)) + ) + (set! (-> self launch-speed) (lerp 204800.0 552960.0 f30-0)) + (set! (-> self launch-height-t) (* f30-0 f30-0)) + ) + (let ((v1-10 (-> self state parent))) + (when v1-10 + (let ((t9-1 (-> v1-10 trans))) + (if t9-1 + (t9-1) + ) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate launch-3 (gun-dark-3-nuke) + :virtual #t + :parent (gun-dark-3-nuke launching-base-state) + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (let ((t9-0 nuke-move)) + (-> self launch-impact-state) + (t9-0) + ) + (if (time-elapsed? (-> self state-time) (seconds 4)) + (go-virtual die) + ) + ) + ) + +;; definition for method 55 of type gun-dark-3-nuke +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod send-attack! ((this gun-dark-3-nuke) (arg0 process-focusable)) + (let* ((s3-0 (get-trans arg0 3)) + (v1-2 (get-trans arg0 1)) + (s5-1 (vector-! (new 'stack-no-clear 'vector) s3-0 (-> this root trans))) + ) + (+! (-> v1-2 y) 409.6) + (let ((v1-5 (cond + ((logtest? (-> *part-group-id-table* 115 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> v1-2 quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 115)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> v1-2 quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 115)) + ) + ) + ) + ) + (send-event (ppointer->process v1-5) 'clock this) + ) + (send-event + arg0 + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage 32.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-dark) + (attacker-velocity s5-1) + (penetrate-using (penetrate explode jak-dark-nuke)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 54 of type gun-dark-3-nuke +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod count-casualties ((this gun-dark-3-nuke)) + (local-vars (sv-1568 vector)) + (set! (-> this num-dying-vehicles) (the-as uint 0)) + (set! (-> this num-dying-guards) (the-as uint 0)) + (set! (-> this num-dying-civilians) (the-as uint 0)) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 64) + ) + (set! (-> s4-0 quad) (-> this root trans quad)) + (set! (-> s4-0 w) 1228800.0) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s4-0) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-5 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-5 + (let* ((s0-0 (-> v1-5 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= *target* s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive)) + (or (logtest? (process-mask enemy guard vehicle civilian) (-> s1-1 mask)) + (and (logtest? (process-mask crate) (-> s1-1 mask)) (let ((s0-1 vector-vector-xz-distance)) + (set! sv-1568 (-> s1-1 root trans)) + (let ((a1-3 (camera-pos))) + (< (s0-1 sv-1568 a1-3) 204800.0) + ) + ) + ) + ) + ) + (when (> s5-0 0) + (+! s5-0 -1) + (send-attack! this (the-as process-focusable s1-1)) + (cond + ((logtest? (process-mask civilian) (-> s1-1 mask)) + (+! (-> this num-dying-civilians) 1) + ) + ((logtest? (process-mask guard) (-> s1-1 mask)) + (+! (-> this num-dying-guards) 1) + ) + ((logtest? (process-mask vehicle) (-> s1-1 mask)) + (+! (-> this num-dying-vehicles) 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) s4-0) (-> s4-0 w))) + (when (and (!= *target* s3-1) + (not (focus-test? s3-1 disable dead inactive)) + (or (logtest? (process-mask enemy guard vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask crate) (-> s3-1 mask)) + (< (vector-vector-xz-distance (-> s3-1 control trans) (camera-pos)) 204800.0) + ) + ) + ) + (when (> s5-0 0) + (+ s5-0 -1) + (send-attack! this s3-1) + (cond + ((logtest? (process-mask civilian) (-> s3-1 mask)) + (+! (-> this num-dying-civilians) 1) + ) + ((logtest? (process-mask guard) (-> s3-1 mask)) + (+! (-> this num-dying-guards) 1) + ) + ((logtest? (process-mask vehicle) (-> s3-1 mask)) + (+! (-> this num-dying-vehicles) 1) + ) + ) + ) + ) + ) + ) + ) + (set! (-> this num-dying-vehicles) (the-as uint (min 4 (the-as int (-> this num-dying-vehicles))))) + (set! (-> this num-dying-guards) (the-as uint (min 6 (the-as int (-> this num-dying-vehicles))))) + (set! (-> this num-dying-civilians) (the-as uint (min 6 (the-as int (-> this num-dying-vehicles))))) + 0 + (none) + ) + +;; definition for method 52 of type gun-dark-3-nuke +;; WARN: Return type mismatch int vs none. +(defmethod do-blur-effect ((this gun-dark-3-nuke)) + (when (= (process->handle this) (-> *last-active-nuke* last-active-nuke)) + 0.0 + (let* ((f0-3 (/ (the float (- (current-time) (-> this state-time))) (the float (-> this blur-time)))) + (f0-4 (curve2d-method-9 (-> this blur-curve) f0-3 3)) + (f0-5 (- 1.0 f0-4)) + ) + (blit-displays-work-method-17 + *blit-displays-work* + (-> this root trans) + (the-as int (-> this num-blur-segments)) + (fmin 1.0 f0-5) + #f + ) + ) + (set! (-> *display* force-sync) (the-as uint 2)) + ) + (none) + ) + +;; definition for method 53 of type gun-dark-3-nuke +(defmethod do-white-screen-effect ((this gun-dark-3-nuke)) + (when (= (process->handle this) (-> *last-active-nuke* last-active-nuke)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + 0.0 + 0.0 + (let ((f0-4 (/ (the float (- (current-time) (-> this state-time))) (the float (-> this flash-time))))) + (curve-color-method-9 (-> this fade-curve) f0-4 (the-as rgbaf gp-0) 3) + ) + (set! (-> gp-0 x) (* 255.0 (-> gp-0 x))) + (set! (-> gp-0 y) (* 255.0 (-> gp-0 y))) + (set! (-> gp-0 z) (* 255.0 (-> gp-0 z))) + (set! (-> gp-0 w) (* 128.0 (-> gp-0 w))) + (setup *screen-filter* gp-0 gp-0 0.0 (bucket-id tex-hud-pris2) #x3fffff #x33001 #t) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate impact-dud (gun-dark-3-nuke) + :virtual #t + :code (behavior () + (if *scene-player* + (go empty-state) + ) + (let ((gp-0 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-0 spawn-point quad) (-> self root trans quad)) + (quaternion-identity! (-> gp-0 spawn-quat)) + (set! (-> gp-0 radius) 0.0) + (set! (-> gp-0 scale) 1.0) + (set! (-> gp-0 group) (-> *part-group-id-table* 104)) + (set! (-> gp-0 collide-with) (collide-spec)) + (set! (-> gp-0 damage) 2.0) + (set! (-> gp-0 damage-scale) 1.0) + (set! (-> gp-0 vehicle-damage-factor) 1.0) + (set! (-> gp-0 vehicle-impulse-factor) 1.0) + (set! (-> gp-0 ignore-proc) (process->handle #f)) + (explosion-spawn gp-0 self) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (let ((v1-20 (-> self root root-prim))) + (set! (-> v1-20 prim-core collide-as) (collide-spec)) + (set! (-> v1-20 prim-core collide-with) (collide-spec)) + ) + 0 + (ja-post) + (while (-> self child) + (suspend) + ) + ) + ) + +;; definition for method 40 of type gun-dark-3-nuke +(defmethod projectile-method-40 ((this gun-dark-3-nuke)) + 256 + ) + +;; failed to figure out what this is: +(defstate impact-embedded (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (let ((v1-3 (-> self root root-prim))) + (set! (-> v1-3 prim-core collide-as) (collide-spec)) + (set! (-> v1-3 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self root transv quad) (the-as uint128 0)) + ) + :exit (behavior () + '() + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (if (time-elapsed? (-> self state-time) (seconds 1.4)) + (go-virtual impact-small) + ) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 0.3)) + (suspend) + ) + (sound-play "beep") + (until (time-elapsed? (-> self state-time) (seconds 0.5)) + (suspend) + ) + (sound-play "beep") + (until #f + (suspend) + ) + #f + ) + :post (behavior () + (ja-post) + (projectile-method-25 self) + ) + ) + +;; definition for method 56 of type gun-dark-3-nuke +;; WARN: Return type mismatch uint vs none. +(defmethod play-death-sounds ((this gun-dark-3-nuke)) + (when (and (not (time-elapsed? (-> this state-time) (seconds 1.5))) + (time-elapsed? (-> this last-death-sound-play-time) (seconds 0.1)) + ) + (set-time! (-> this last-death-sound-play-time)) + (let* ((v1-11 (+ (-> this num-dying-vehicles) (-> this num-dying-guards) (-> this num-dying-civilians))) + (v1-12 (rand-vu-int-range 0 (the-as int (+ v1-11 -1)))) + ) + (when (> v1-12 0) + (cond + ((< v1-12 (the-as int (-> this num-dying-vehicles))) + (sound-play-by-spec (static-sound-spec "vehicle-explode" :group 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "vehicle-explo-b" :group 1) (new-sound-id) (the-as vector #t)) + (+! (-> this num-dying-vehicles) -1) + ) + ((< v1-12 (the-as int (+ (-> this num-dying-guards) (-> this num-dying-vehicles)))) + (sound-play "guard-die") + (+! (-> this num-dying-guards) -1) + ) + (else + (sound-play "guard-hit") + (+! (-> this num-dying-civilians) -1) + ) + ) + ) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate impact-small (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (logior! (-> self draw status) (draw-control-status no-draw)) + (case (get-status *gui-control* (-> self explode-wall-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action play) + (-> self explode-wall-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (else + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-wall-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (sound-play "explosion" :pitch 2.5) + ) + ) + (case (get-status *gui-control* (-> self explode-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + ) + (set-setting! 'music-volume 'abs 0.0 0) + (let ((v1-21 (-> self root root-prim))) + (set! (-> v1-21 prim-core collide-as) (collide-spec)) + (set! (-> v1-21 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self last-death-sound-play-time) 0) + (set! (-> self flash-time) *gun-dark-3-nuke-fade-time-small*) + (set! (-> self blur-time) *gun-dark-3-nuke-blur-time-small*) + (set! (-> self blur-curve) *gun-dark-3-nuke-blur-curve-small*) + (set! (-> self fade-curve) *gun-dark-3-nuke-fade-curve-small*) + (set! (-> self num-blur-segments) *gun-dark-3-nuke-blur-segs-small*) + ) + :exit (behavior () + (when (= (process->handle self) (-> *last-active-nuke* last-active-nuke)) + (disable *screen-filter*) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 0 1.0 #f) + ) + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (do-blur-effect self) + (do-white-screen-effect self) + (if (time-elapsed? (-> self state-time) (seconds 1)) + (do-camera-shake self) + ) + (when (not (-> self spawned-mushroom-cloud?)) + (let ((v1-23 + (cond + ((logtest? (-> *part-group-id-table* 114 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 114)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 114)) + ) + ) + ) + ) + (send-event (ppointer->process v1-23) 'clock self) + ) + (set! (-> self spawned-mushroom-cloud?) #t) + ) + (if (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (not (time-elapsed? (-> self state-time) (seconds 6))) + ) + (set-setting! 'nuke-active? #t 0.0 0) + (remove-setting! 'nuke-active?) + ) + (when (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (and (not (time-elapsed? (-> self state-time) (seconds 6))) + (time-elapsed? (-> self last-kill-time) (seconds 0.1)) + (not (-> self killed-everything?)) + ) + ) + (count-casualties self) + (set! (-> self killed-everything?) #t) + (set-time! (-> self last-kill-time)) + ) + (play-death-sounds self) + (ja-post) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 8)) + (suspend) + ) + ) + ) + +;; failed to figure out what this is: +(defstate wait-for-alive (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (remove-setting! 'allow-progress) + ) + :exit (behavior () + '() + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (let ((f0-1 (* 0.00066666666 (the float (- (current-time) (-> self clock old-frame-counter)))))) + (set-setting! 'music-volume 'abs f0-1 0) + ) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 5)) + (suspend) + ) + ) + ) + +;; definition for method 59 of type gun-dark-3-nuke +;; WARN: Return type mismatch object vs none. +(defmethod check-for-impact ((this gun-dark-3-nuke)) + (let ((a1-0 (new 'stack-no-clear 'collide-query))) + (vector+float*! (-> a1-0 start-pos) (-> this root trans) *up-vector* 2048.0) + (set-vector! (-> a1-0 move-dist) 0.0 49152.0 0.0 1.0) + (let ((v1-3 a1-0)) + (set! (-> v1-3 radius) 40.96) + (set! (-> v1-3 collide-with) (collide-spec backgnd)) + (set! (-> v1-3 ignore-process0) #f) + (set! (-> v1-3 ignore-process1) #f) + (set! (-> v1-3 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-3 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* a1-0) 0.0) + (go (method-of-object this impact-small)) + ) + ) + (none) + ) + +;; definition for method 58 of type gun-dark-3-nuke +(defmethod do-vibration ((this gun-dark-3-nuke)) + (buzz-stop! 0) + (let* ((f1-2 (* 0.00055555557 (the float (- (current-time) (-> this state-time))))) + (f0-2 (fmax 0.0 (fmin 1.0 f1-2))) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 (the int (* 255.0 (- 1.0 f0-2))) (seconds 1)) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate impact (gun-dark-3-nuke) + :virtual #t + :enter (behavior () + (check-for-impact self) + (set-setting! 'music-volume 'abs 0.0 0) + (case (get-status *gui-control* (-> self explode-wall-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-wall-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + ) + (case (get-status *gui-control* (-> self explode-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action play) + (-> 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 + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (sound-play "explosion" :pitch 2.5) + ) + ) + (set-time! (-> self state-time)) + (logior! (-> self draw status) (draw-control-status no-draw)) + (vector+float*! (-> self mushroom-top-pos) (-> self root trans) *up-vector* 20480.0) + (let ((v1-25 (-> self root root-prim))) + (set! (-> v1-25 prim-core collide-as) (collide-spec)) + (set! (-> v1-25 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self flash-time) *gun-dark-3-nuke-fade-time*) + (set! (-> self blur-time) *gun-dark-3-nuke-blur-time*) + (set! (-> self blur-curve) *gun-dark-3-nuke-blur-curve*) + (set! (-> self fade-curve) *gun-dark-3-nuke-fade-curve*) + (set! (-> self num-blur-segments) *gun-dark-3-nuke-blur-segs*) + ) + :exit (behavior () + (when (= (process->handle self) (-> *last-active-nuke* last-active-nuke)) + (disable *screen-filter*) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 0 1.0 #f) + ) + ) + :trans (behavior () + (if *scene-player* + (go empty-state) + ) + (do-blur-effect self) + (do-white-screen-effect self) + (do-vibration self) + (if (time-elapsed? (-> self state-time) (seconds 1)) + (do-camera-shake self) + ) + (set! (-> self strip num-verts) (the-as uint 0)) + (when (time-elapsed? (-> self state-time) (seconds 0.035)) + (when (not (-> self spawned-mushroom-cloud?)) + (let ((v1-30 + (cond + ((logtest? (-> *part-group-id-table* 110 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 110)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 110)) + ) + ) + ) + ) + (send-event (ppointer->process v1-30) 'clock self) + ) + (let ((v1-61 + (cond + ((logtest? (-> *part-group-id-table* 111 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 111)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 111)) + ) + ) + ) + ) + (send-event (ppointer->process v1-61) 'clock self) + ) + (let ((gp-4 (new 'stack-no-clear 'gun-dark-3-sphere-init-params))) + (set! (-> gp-4 pos quad) (-> self root trans quad)) + (set! (-> gp-4 size-x) 1.0) + (set! (-> gp-4 size-y) 1.0) + (set! (-> self warp) + (ppointer->handle (process-spawn gun-dark-3-sphere gp-4 :name "gun-dark-3-sphere" :to self)) + ) + ) + (set! (-> self spawned-mushroom-cloud?) #t) + ) + (if (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (not (time-elapsed? (-> self state-time) (seconds 6))) + ) + (set-setting! 'nuke-active? #t 0.0 0) + (remove-setting! 'nuke-active?) + ) + (when (and (time-elapsed? (-> self state-time) (seconds 0.3)) + (and (not (time-elapsed? (-> self state-time) (seconds 7))) + (time-elapsed? (-> self last-kill-time) (seconds 0.1)) + (not (-> self killed-everything?)) + ) + ) + (count-casualties self) + (set! (-> self killed-everything?) #t) + (set-time! (-> self last-kill-time)) + ) + (play-death-sounds self) + (+! (-> self mushroom-top-pos y) (* *gun-dark-3-mushroom-speed* (seconds-per-frame))) + (let ((f26-0 (/ (the float (- (current-time) (-> self state-time))) (the float *gun-dark-3-mushroom-size-time*)))) + 0.0 + 0.0 + (let ((f30-0 1.0) + (f28-0 (curve2d-method-9 *gun-dark-3-nuke-mushroom-size-curve-x* f26-0 3)) + (f26-1 (curve2d-method-9 *gun-dark-3-nuke-mushroom-size-curve-y* f26-0 3)) + ) + (when (time-elapsed? (-> self state-time) (seconds 5)) + (let ((f30-1 (* 0.00066666666 (the float (+ (- (seconds -5) (-> self state-time)) (current-time)))))) + 0.0 + (let ((f24-0 (* f30-1 f30-1))) + (set! f28-0 (* f28-0 (lerp 1.0 1.3 f24-0))) + (set! f26-1 (* f26-1 (lerp 1.0 1.3 f24-0))) + ) + (set! f30-0 (lerp 1.0 0.0 f30-1)) + ) + ) + (let ((v1-144 (new 'stack-no-clear 'gun-dark-3-sphere-init-params))) + (set! (-> v1-144 pos quad) (-> self mushroom-top-pos quad)) + (set! (-> v1-144 size-x) f28-0) + (set! (-> v1-144 size-y) f26-1) + (set! (-> v1-144 alpha-val) (* f30-0 f30-0)) + (send-event (handle->process (-> self warp)) 'set-pos-and-size v1-144) + ) + (let ((gp-6 (vector-float*! (new 'stack-no-clear 'vector) *up-vector* f26-1)) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (let ((s4-1 (vector-! (new 'stack-no-clear 'vector) (-> self mushroom-top-pos) (math-camera-pos)))) + (set! (-> s4-1 y) 0.0) + (vector-cross! s5-1 *up-vector* s4-1) + ) + (vector-normalize! s5-1 f28-0) + (dotimes (v1-152 4) + (if (> (logand v1-152 1) 0) + (vector-float*! gp-6 gp-6 -1.0) + ) + (when (= v1-152 2) + (vector-float*! gp-6 gp-6 -1.0) + (vector-float*! s5-1 s5-1 -1.0) + ) + (vector+! (the-as vector (+ (the-as uint (-> self strip data 0 pos)) (* v1-152 32))) s5-1 gp-6) + (vector+! + (the-as vector (+ (the-as uint (-> self strip data 0 pos)) (* v1-152 32))) + (the-as vector (+ (the-as uint (-> self strip data 0 pos)) (* v1-152 32))) + (-> self mushroom-top-pos) + ) + (set! (-> self strip data v1-152 stq z) 0.0) + (set! (-> self strip data v1-152 col) *color-gray*) + (set! (-> self strip data v1-152 col a) (the int (* 127.0 f30-0))) + (set! (-> self strip data v1-152 col g) (the int (* 127.0 f30-0))) + (set! (-> self strip data v1-152 col b) (the int (* 127.0 f30-0))) + ) + ) + ) + ) + (set! (-> self strip alpha) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> self strip adnops 0 cmds) (gs-reg64 test-1)) + (set! (-> self strip data0) (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x32 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (set! (-> self strip data 0 stq x) 1.0) + (set! (-> self strip data 0 stq y) 1.0) + (set! (-> self strip data 1 stq x) 1.0) + (set! (-> self strip data 1 stq y) 0.0) + (set! (-> self strip data 3 stq x) 0.0) + (set! (-> self strip data 3 stq y) 0.0) + (set! (-> self strip data 2 stq x) 0.0) + (set! (-> self strip data 2 stq y) 1.0) + (set! (-> self strip num-verts) (the-as uint 4)) + ) + (ja-post) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 10)) + (suspend) + ) + (go-virtual wait-for-alive) + ) + ) + +;; definition for method 32 of type gun-dark-3-nuke +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-32 ((this gun-dark-3-nuke)) + (if (not (do-fire-backcheck (-> this root trans) (-> this root transv))) + (go (method-of-object this impact-dud)) + (go (method-of-object this launch-0)) + ) + 0 + (none) + ) + +;; definition for function target-gun-can-fire-dark? +(defbehavior target-gun-can-fire-dark? target ((arg0 pickup-type)) + (case arg0 + (((pickup-type gun-dark-2)) + (time-elapsed? (get-last-fire-time 36) (seconds 2)) + ) + (((pickup-type gun-dark-3)) + (time-elapsed? (get-last-fire-time 37) (seconds 9)) + ) + (else + #t + ) + ) + ) + +;; definition for function gun-fire-dark-3 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs (pointer process). +(defbehavior gun-fire-dark-3 target () + (let ((gp-0 (-> self gun)) + (s5-0 (new 'stack-no-clear 'projectile-init-by-other-params)) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> self gun fire-dir-out quad)) + (set-last-fire-time 37) + (sound-play "purple-3-shot" :position (-> gp-0 fire-point)) + (set! (-> s5-0 ent) (-> self entity)) + (set! (-> s5-0 charge) 1.0) + (set! (-> s5-0 options) (projectile-options)) + (logclear! (-> s5-0 options) (projectile-options po14 po15 po16)) + (set! (-> s5-0 pos quad) (-> gp-0 fire-point quad)) + (set! (-> s5-0 vel quad) (-> (vector-float*! (new 'stack-no-clear 'vector) s4-0 81920.0) quad)) + ) + (set! (-> s5-0 notify-handle) (the-as handle #f)) + (set! (-> s5-0 owner-handle) (the-as handle #f)) + (set! (-> s5-0 target-handle) (the-as handle #f)) + (set! (-> s5-0 target-pos quad) (the-as uint128 0)) + (set! (-> s5-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-17 *game-info*) + (a0-17 (+ (-> v1-17 attack-id) 1)) + ) + (set! (-> v1-17 attack-id) a0-17) + (set! (-> s5-0 attack-id) a0-17) + ) + (set! (-> s5-0 timeout) (seconds 4)) + (let ((v0-7 (ppointer->handle (process-spawn + gun-dark-3-nuke + :init projectile-init-by-other + s5-0 + :name "projectile" + :to (ppointer->process (-> gp-0 gun)) + :stack *kernel-dram-stack* + ) + ) + ) + ) + (set! (-> gp-0 gun 0 extra) (the-as handle v0-7)) + (the-as (pointer process) v0-7) + ) + ) + ) + +;; definition for method 31 of type gun-dark-shot +;; WARN: Return type mismatch int vs none. +(defmethod init-proj-settings! ((this gun-dark-shot)) + (+! (-> *game-info* shots-fired 3) 1.0) + (set! (-> this attack-mode) 'eco-dark) + (vector-normalize! (-> this root transv) (+ 225280.0 (* 225280.0 (-> this charge-level)))) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 94) this)) + (set! (-> this blast-radius) 40960.0) + (if (logtest? (game-secrets gun-upgrade-dark-1) (-> *game-info* secrets)) + (set! (-> this blast-radius) 81920.0) + ) + (set! (-> this size-t) 0.0) + (set! (-> this notify-handle) (process->handle this)) + (set! (-> this charge-sound) (new-sound-id)) + (set! (-> this fire-sound) (new-sound-id)) + (set! (-> this trail-sound) (new-sound-id)) + (set! (-> this explode-sound) + (add-process *gui-control* this (gui-channel gun) (gui-action queue) "pmkrxplo" -99.0 0) + ) + (sound-params-set! *gui-control* (-> this explode-sound) #t 50 150 11 -1.0) + (set! (-> this start-pilot?) (the-as symbol (and *target* (focus-test? *target* pilot)))) + (set! (-> this damage) 16.0) + (set! (-> this vehicle-damage-factor) 1.0) + (set! (-> this vehicle-impulse-factor) 2.0) + (when (logtest? (game-secrets gun-upgrade-dark-1) (-> *game-info* secrets)) + (set! (-> this vehicle-damage-factor) 6.0) + (set! (-> this vehicle-impulse-factor) 6.0) + ) + ((method-of-type projectile init-proj-settings!) this) + 0 + (none) + ) + +;; definition for method 25 of type gun-dark-shot +(defmethod projectile-method-25 ((this gun-dark-shot)) + (cond + ((and (and (-> this next-state) (= (-> this next-state name) 'startup)) + (and *target* (focus-test? *target* in-head)) + ) + (kill-particles (-> this part)) + ) + (else + (set! (-> *part-id-table* 260 init-specs 2 initial-valuef) (lerp 409.6 9216.0 (-> this size-t))) + (set! (-> *part-id-table* 260 init-specs 8 initial-valuef) (lerp 0.0 32.0 (-> this size-t))) + (set! (-> *part-id-table* 261 init-specs 2 initial-valuef) (lerp 409.6 32768.0 (-> this size-t))) + (set! (-> *part-id-table* 261 init-specs 8 initial-valuef) (lerp 0.0 16.0 (-> this size-t))) + (set! (-> *part-id-table* 259 init-specs 2 initial-valuef) (lerp 409.6 8192.0 (-> this size-t))) + (set! (-> *part-id-table* 258 init-specs 1 initial-valuef) (lerp 0.1 1.0 (-> this size-t))) + (set! (-> *part-id-table* 258 init-specs 2 initial-valuef) (lerp 409.6 3686.4 (-> this size-t))) + (spawn (-> this part) (-> this root trans)) + ) + ) + (ja-post) + (none) + ) + +;; definition for method 32 of type gun-dark-shot +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-32 ((this gun-dark-shot)) + (go (method-of-object this 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) (-> 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) + ) + ) + :code (behavior () + (set-time! (-> self state-time)) + (until #f + (cond + ((or (and *target* + (focus-test? *target* dead grabbed under-water pole flut board mech dark carry indax teleporting) + ) + (and *target* (not (logtest? (focus-status in-head gun) (-> *target* focus-status)))) + (and *target* (!= (-> self start-pilot?) (focus-test? *target* pilot))) + (not (-> *setting-control* user-current gun)) + ) + (adjust-player-ammo 1.0 (pickup-type ammo-dark)) + (go-virtual dissipate) + ) + ((or (not (time-elapsed? (-> self state-time) (seconds 0.3))) (cpad-hold? 0 r1)) + (set! (-> self size-t) (fmin 1.0 (* 0.016666668 (the float (- (current-time) (-> self state-time)))))) + (let ((t9-2 vector<-cspace!) + (a0-14 (-> self root trans)) + (v1-28 (-> self parent)) + ) + (t9-2 a0-14 (-> (the-as process-focusable (if v1-28 + (the-as process-focusable (-> v1-28 0 self)) + ) + ) + node-list + data + 13 + ) + ) + ) + ) + ((and (logtest? (projectile-options po17) (-> self options)) (made-impact? self)) + (go-virtual impact) + ) + (else + (go-virtual moving) + ) + ) + (suspend) + ) + #f + ) + :post (behavior () + (sound-play "pmkr-charge" :id (-> self charge-sound) :position (-> self root trans)) + (projectile-method-25 self) + ) + ) + +;; failed to figure out what this is: +(defstate moving (gun-dark-shot) + :virtual #t + :enter (behavior () + (if *target* + (set! (-> self track-target) (-> *target* gun track-target 0 handle)) + ) + (let ((t9-0 (-> (method-of-type projectile moving) enter))) + (if t9-0 + (t9-0) + ) + ) + (set! (-> self core-position quad) (-> self root trans quad)) + (let ((v1-10 (-> self core-velocity)) + (a0-3 (-> self parent)) + ) + (set! (-> v1-10 quad) (-> (the-as process-focusable (if a0-3 + (the-as process-focusable (-> a0-3 0 self)) + ) + ) + node-list + data + 13 + bone + transform + fvec + quad + ) + ) + ) + (when (and *target* (focus-test? *target* in-head)) + (set! (-> self core-position quad) (-> (camera-pos) quad)) + (set! (-> self core-velocity quad) (-> (camera-matrix) fvec 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-time! (-> self state-time)) + (let ((v1-35 (cond + ((logtest? (-> *part-group-id-table* 92 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 92)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 92)) + ) + ) + ) + ) + (send-event (ppointer->process v1-35) 'clock self) + ) + (draw-beam (-> *part-id-table* 250) (-> self root trans) (-> self core-velocity) #f) + ) + :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))) + (s2-0 (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (when s2-0 + (let ((s3-1 (new 'stack-no-clear 'vector))) + (set! (-> s3-1 quad) (-> (the-as process-focusable s2-0) root trans quad)) + (let ((a0-6 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (if a0-6 + (set! (-> s3-1 quad) (-> (get-trans (the-as process-focusable a0-6) 3) quad)) + ) + ) + (let* ((s2-3 (vector-! (new 'stack-no-clear 'vector) s3-1 (-> self core-position))) + (f0-0 (vector-normalize-ret-len! s2-3 1.0)) + (f0-1 (lerp-scale 182.04445 8192.0 f0-0 61440.0 4096.0)) + (s3-2 (new 'stack-no-clear 'matrix)) + ) + (matrix-from-two-vectors-max-angle! s3-2 s4-0 s2-3 f0-1) + (vector-matrix*! (-> self core-velocity) (-> self core-velocity) s3-2) + ) + ) + ) + ) + (+! (-> 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 (- (current-time) (-> 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)) + ) + ) + (let ((f30-1 (* 0.5 f30-0))) + (vector-normalize! (-> self spin-vector) f30-1) + (vector-normalize! (-> self core-velocity) 7372.8) + (set! (-> s5-0 fvec quad) (-> s4-0 quad)) + (set! (-> s5-0 uvec quad) (-> self spin-vector quad)) + (vector-float*! (-> s5-0 uvec) (-> s5-0 uvec) (/ 1.0 f30-1)) + ) + ) + ) + (vector-cross! (-> s5-0 rvec) (-> s5-0 uvec) (-> s5-0 fvec)) + (matrix->quaternion (-> self root 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 transv) gp-0 (-> self root trans)) + ) + (let ((v1-39 (-> self root transv))) + (.lvf vf1 (&-> (-> self root transv) quad)) + (let ((f0-13 (-> self clock frames-per-second))) + (.mov at-0 f0-13) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-39 quad) vf1) + ) + (projectile-move-fill-line-sphere self) + (if (logtest? (-> self root status) (collide-status touch-surface)) + (go-virtual impact) + ) + (sound-play "pmkr-fire" :id (-> self fire-sound) :position (-> self root trans)) + (sound-play "pmkr-trail" :id (-> self trail-sound) :position (-> self root trans)) + ) + ) + ) + +;; 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 lightning-spec) + (arg3 (function lightning-tracker none)) + (arg4 sparticle-launcher) + (arg5 sparticle-launcher) + (arg6 sparticle-launcher) + ) + (local-vars (sv-16 process) (sv-32 lightning-spec) (sv-48 process-focusable)) + (set! sv-48 arg0) + (let ((s0-0 arg1)) + (set! sv-32 arg2) + (let ((gp-0 arg4) + (s1-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 0)) + (let ((s2-0 (when sv-16 + (let ((t9-3 (method-of-type lightning-tracker activate))) + (t9-3 (the-as lightning-tracker sv-16) s0-0 "lightning-tracker" (the-as pointer #x70004000)) + ) + (let ((t9-4 run-function-in-process) + (a0-5 sv-16) + (a1-5 lightning-tracker-init) + (a3-3 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-5 + sv-32 + a3-3 + t0-1 + sv-48 + t2-1 + t3-0 + ) + ) + (-> sv-16 ppointer) + ) + ) + ) + (when s1-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 s1-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 s2-0) + (let ((v1-13 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-13 + (set! (-> v1-13 initial-valuef) (the-as float (-> (the-as lightning-tracker (-> s2-0 0)) duration))) + ) + ) + (let ((t9-8 sp-launch-particles-var) + (a0-12 *sp-particle-system-2d*) + (a1-13 gp-0) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> s4-0 quad)) + (t9-8 a0-12 a1-13 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-time! (-> self state-time)) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 1)) + (deactivate self) + ) + (process-drawable-shock-effect-replace + self + (-> *lightning-spec-id-table* 15) + lightning-probe-callback + 256 + 0 + 40960.0 + ) + (launch-particles (-> *part-id-table* 255) (-> self root trans)) + (launch-particles (-> *part-id-table* 257) (-> self root trans)) + (let ((gp-0 (-> *part-id-table* 665))) + (when gp-0 + (let ((v1-13 (get-field-spec-by-id gp-0 (sp-field-id spt-timer)))) + (if v1-13 + (set! (-> v1-13 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 trans quad)) + (t9-5 a0-8 gp-0 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + :code 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 shield) + ) + (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) s5-0) + ) + (set! (-> self root trans quad) (-> arg0 quad)) + (let ((v1-16 (-> self root 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) + ) + +;; definition for method 57 of type gun-dark-3-nuke +;; WARN: Return type mismatch symbol vs none. +(defmethod do-camera-shake ((this gun-dark-3-nuke)) + (when (not (-> this shook-camera?)) + (activate! *camera-smush-control* 1228.8 45 1275 1.0 0.9 (-> *display* camera-clock)) + (set! (-> this shook-camera?) #t) + ) + (none) + ) + +;; definition for method 40 of type gun-dark-shot +(defmethod projectile-method-40 ((this gun-dark-shot)) + 512 + ) + +;; failed to figure out what this is: +(defstate impact (gun-dark-shot) + :virtual #t + :enter (behavior () + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.2)) + (let ((t9-1 (-> (method-of-type projectile impact) enter))) + (if t9-1 + (t9-1) + ) + ) + (set! (-> self result-count) 0) + (set! (-> self spread-timer) 0) + (if (not (time-elapsed? (-> self spawn-time) (seconds 0.1))) + (send-event (ppointer->process (-> self parent)) 'release) + ) + (sound-stop (-> self trail-sound)) + (case (get-status *gui-control* (-> self explode-sound)) + (((gui-status ready)) + (set-action! + *gui-control* + (gui-action play) + (-> 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 + (set-action! + *gui-control* + (gui-action stop) + (-> self explode-sound) + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (sound-play "explosion" :pitch 2.5) + ) + ) + (let ((v1-23 (-> self root root-prim))) + (set! (-> v1-23 prim-core collide-as) (collide-spec)) + (set! (-> v1-23 prim-core collide-with) (collide-spec)) + ) + 0 + (cond + ((logtest? (-> *part-group-id-table* 93 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 93)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 93)) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> self root trans quad)) + (let ((gp-3 (the-as (array float) (new 'stack 'boxed-array float 16))) + (a1-13 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-13 from) (process->ppointer self)) + (set! (-> a1-13 num-params) 0) + (set! (-> a1-13 message) 'get-vehicle) + (let ((s5-1 (send-event-function *target* a1-13))) + (set! (-> s4-0 w) (-> self blast-radius)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s4-0) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-66 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-66 + (let* ((s0-0 (-> v1-66 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (nonzero? (-> (the-as process-focusable s1-1) root root-prim prim-core collide-as)) + (logtest? (process-mask crate enemy guard vehicle civilian kg-robot metalhead) (-> s1-1 mask)) + (not (focus-test? (the-as process-focusable s1-1) disable dead ignore)) + (!= s1-1 s5-1) + ) + (let* ((s0-1 (get-trans (the-as process-focusable s1-1) 3)) + (f0-2 (vector-vector-distance-squared (-> self root trans) s0-1)) + (f1-0 (-> s0-1 w)) + (f0-3 (- f0-2 (* f1-0 f1-0))) + (v1-80 (+ (-> self result-count) -1)) + ) + (while (and (>= v1-80 0) (< f0-3 (-> gp-3 v1-80))) + (when (< v1-80 15) + (set! (-> gp-3 (+ v1-80 1)) (-> gp-3 v1-80)) + (set! (-> self result-array (+ v1-80 1)) (-> self result-array v1-80)) + ) + (+! v1-80 -1) + ) + (when (< v1-80 15) + (let ((v1-81 (+ v1-80 1))) + (if (< (-> self result-count) 16) + (+! (-> self result-count) 1) + ) + (set! (-> gp-3 v1-81) f0-3) + (set! (-> self result-array v1-81) (process->handle s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) s4-0) (-> s4-0 w))) + (when (and (nonzero? (-> s3-1 control root-prim prim-core collide-as)) + (logtest? (process-mask crate enemy guard vehicle civilian kg-robot metalhead) (-> s3-1 mask)) + (not (focus-test? s3-1 disable dead ignore)) + (!= s3-1 s5-1) + ) + (let* ((s5-2 (get-trans s3-1 3)) + (f0-5 (vector-vector-distance-squared (-> self root trans) s5-2)) + (f1-6 (-> s5-2 w)) + (f0-6 (- f0-5 (* f1-6 f1-6))) + (v1-101 (+ (-> self result-count) -1)) + ) + (while (and (>= v1-101 0) (< f0-6 (-> gp-3 v1-101))) + (when (< v1-101 15) + (set! (-> gp-3 (+ v1-101 1)) (-> gp-3 v1-101)) + (set! (-> self result-array (+ v1-101 1)) (-> self result-array v1-101)) + ) + (+! v1-101 -1) + ) + (when (< v1-101 15) + (let ((v1-102 (+ v1-101 1))) + (if (< (-> self result-count) 16) + (+! (-> self result-count) 1) + ) + (set! (-> gp-3 v1-102) f0-6) + (set! (-> self result-array v1-102) (process->handle s3-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if (zero? (-> self result-count)) + (go-virtual fizzle) + ) + (let ((gp-4 (handle->process (-> self result-array 0)))) + (deal-damage! self gp-4 (the-as event-message-block #f)) + (let ((s5-3 gp-4)) + (if (or (if (type? s5-3 crate) + s5-3 + ) + (let ((s5-4 gp-4)) + (if (type? s5-4 market-object) + s5-4 + ) + ) + (if (type? gp-4 fruit-stand) + gp-4 + ) + ) + (process-spawn gun-dark-shot :init gun-dark-shot-init-fizzle (-> self root trans) :name "gun-dark-shot") + ) + ) + ) + ) + :trans (behavior () + (let ((t9-0 (-> (method-of-type projectile impact) trans))) + (if t9-0 + (t9-0) + ) + ) + (when (and (> (-> self result-count) 0) (time-elapsed? (-> self spread-timer) (seconds 0.1))) + (set-time! (-> self spread-timer)) + (+! (-> self result-count) -1) + (while (and (>= (-> self result-count) 0) (not (handle->process (-> self result-array (-> self result-count))))) + (+! (-> self result-count) -1) + ) + (when (>= (-> self result-count) 0) + (let ((s5-0 (handle->process (-> self result-array (-> self result-count))))) + (if s5-0 + (process-spawn-function + process + (lambda :behavior process + ((arg0 handle) (arg1 float)) + (let* ((s3-0 (ppointer->process (-> self parent))) + (s5-0 (if (type? s3-0 process-focusable) + s3-0 + ) + ) + (s2-0 0) + (s1-0 (current-time)) + (s3-1 #f) + ) + (+! (-> self clock ref-count) -1) + (+! (-> s5-0 clock ref-count) 1) + (set! (-> self clock) (-> s5-0 clock)) + (while (and (nonzero? (-> (the-as process-focusable s5-0) skel)) + (or (focus-test? (the-as process-focusable s5-0) dead hit) + (and (-> (the-as process-focusable s5-0) next-state) + (= (-> (the-as process-focusable s5-0) next-state name) 'knocked) + ) + (not (time-elapsed? s1-0 (seconds 0.35))) + ) + (not (time-elapsed? s1-0 (seconds 5))) + (not (logtest? (-> (the-as process-focusable s5-0) draw status) (draw-control-status no-draw no-draw-temp))) + (or (not (and (-> (the-as process-focusable s5-0) next-state) + (= (-> (the-as process-focusable s5-0) next-state name) 'fizzle) + ) + ) + (not (type? s5-0 missile-bot)) + ) + ) + (when (time-elapsed? (the-as time-frame s2-0) (seconds 0.05)) + (set! s2-0 (the-as int (current-time))) + (let ((a0-5 (handle->process arg0))) + (if a0-5 + (process-drawable-shock-effect-bullseye + (the-as process-focusable a0-5) + (the-as process-focusable s5-0) + (-> *lightning-spec-id-table* 16) + lightning-probe-callback + (-> *part-id-table* 665) + (-> *part-id-table* 255) + (-> *part-id-table* 257) + ) + ) + ) + (process-drawable-shock-effect-replace + (the-as process-drawable s5-0) + (-> *lightning-spec-id-table* 15) + lightning-probe-callback + 0 + 0 + 40960.0 + ) + ) + (suspend) + (let ((s5-1 (ppointer->process (-> self parent)))) + (set! s5-0 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (when (and (not s3-1) (time-elapsed? s1-0 (seconds 0.1)) (!= s5-0 (handle->process arg0))) + (set! s3-1 #t) + (send-event + s5-0 + 'attack + #f + (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) (damage 16.0) (vehicle-damage-factor arg1) (vehicle-impulse-factor 1.0) (mode 'explode)) + ) + ) + ) + ) + (+! (-> *game-info* shots-hit 3) 1.0) + (when (and (not s3-1) (!= s5-0 (handle->process arg0))) + #t + (send-event + s5-0 + 'attack + #f + (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) (damage 16.0) (vehicle-damage-factor arg1) (vehicle-impulse-factor 1.0) (mode 'explode)) + ) + ) + ) + ) + ) + (-> self result-array 0) + (-> self vehicle-damage-factor) + :to s5-0 + ) + ) + ) + ) + ) + (if (or (time-elapsed? (-> self spread-timer) (seconds 10)) + (and (not (-> self child)) + (= (get-status *gui-control* (-> self explode-sound)) (gui-status unknown)) + (< (-> self result-count) 0) + ) + ) + (deactivate self) + ) + ) + :code sleep-code + ) + +;; definition of type gravity-spinner +(deftype gravity-spinner (process) + ((cached-damage float) + (end-time time-frame) + (time-subtract time-frame) + (parent-hand handle) + (rotation-accel vector :inline) + (original-sphere-offset sphere :inline) + (obj-radius float) + (was-hit-previously? symbol) + (ground-height float) + (next-ground-probe-time time-frame) + ) + (:state-methods + zero-g + zero-g-vehicle + ) + (:methods + (gravity-spinner-method-16 (_type_ vector vector) none) + (update-rotation (_type_ symbol) none) + (gravity-spinner-method-18 (_type_ process) float) + (handle-impact (_type_ symbol) vector) + (probe-ground (_type_) none) + (get-float-speed (_type_) float) + (gravity-spinner-method-22 (_type_) none) + (spawn-part (_type_) none) + (rotate! (_type_ quaternion) none) + ) + ) + +;; definition for method 3 of type gravity-spinner +(defmethod inspect ((this gravity-spinner)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Tcached-damage: ~f~%" (-> this cached-damage)) + (format #t "~2Tend-time: ~D~%" (-> this end-time)) + (format #t "~2Ttime-subtract: ~D~%" (-> this time-subtract)) + (format #t "~2Tparent-hand: ~D~%" (-> this parent-hand)) + (format #t "~2Trotation-accel: #~%" (-> this rotation-accel)) + (format #t "~2Toriginal-sphere-offset: #~%" (-> this original-sphere-offset)) + (format #t "~2Tobj-radius: ~f~%" (-> this obj-radius)) + (format #t "~2Twas-hit-previously?: ~A~%" (-> this was-hit-previously?)) + (format #t "~2Tground-height: ~f~%" (-> this ground-height)) + (format #t "~2Tnext-ground-probe-time: ~D~%" (-> this next-ground-probe-time)) + (label cfg-4) + this + ) + +;; definition for method 7 of type gravity-spinner +(defmethod relocate ((this gravity-spinner) (offset int)) + (call-parent-method this offset) + ) + +;; definition for method 10 of type gravity-spinner +(defmethod deactivate ((this gravity-spinner)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (call-parent-method this) + (none) + ) + +;; definition for method 18 of type gravity-spinner +(defmethod gravity-spinner-method-18 ((this gravity-spinner) (arg0 process)) + 1.0 + ) + +;; definition for method 23 of type gravity-spinner +;; INFO: Used lq/sq +(defmethod spawn-part ((this gravity-spinner)) + (when (zero? (mod (the-as int (rand-uint31-gen *random-generator*)) 5)) + (let* ((s5-0 (handle->process (-> this parent-hand))) + (gp-1 (if (type? s5-0 process-focusable) + s5-0 + ) + ) + ) + (when gp-1 + (when (and (-> (the-as process-focusable gp-1) node-list) (nonzero? (-> (the-as process-focusable gp-1) node-list))) + (let* ((v1-12 + (+ (mod + (the-as int (rand-uint31-gen *random-generator*)) + (+ (-> (the-as process-focusable gp-1) node-list length) -2) + ) + 2 + ) + ) + (v1-15 + (vector<-cspace! (new 'stack-no-clear 'vector) (-> (the-as process-focusable gp-1) node-list data v1-12)) + ) + (t9-4 sp-launch-particles-var) + (a0-9 *sp-particle-system-2d*) + (a1-5 (-> *part-id-table* 398)) + (a2-0 *launch-matrix*) + ) + (set! (-> a2-0 trans quad) (-> v1-15 quad)) + (t9-4 a0-9 a1-5 a2-0 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 22 of type gravity-spinner +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defmethod gravity-spinner-method-22 ((this gravity-spinner)) + (local-vars (a1-11 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (let* ((gp-0 (handle->process (-> this parent-hand))) + (s3-0 (if (type? gp-0 process-focusable) + gp-0 + ) + ) + ) + (when s3-0 + (let* ((gp-1 (-> (the-as process-focusable s3-0) root)) + (s5-0 (-> gp-1 root-prim)) + (s4-0 (-> gp-1 process node-list)) + (v1-5 (quaternion->matrix (new 'stack-no-clear 'matrix) (-> (the-as process-focusable s3-0) root quat))) + ) + (set! (-> v1-5 trans quad) (-> (the-as process-focusable s3-0) root trans quad)) + (when (nonzero? s4-0) + (countdown (a0-7 (-> gp-1 total-prims)) + (when (and (= (-> s5-0 transform-index) -2) (!= s5-0 (-> gp-1 root-prim))) + (.lvf vf5 (&-> v1-5 trans quad)) + (.lvf vf1 (&-> s5-0 local-sphere quad)) + (.lvf vf2 (&-> v1-5 rvec quad)) + (.mul.w.vf acc vf5 vf0) + (.div.vf Q vf0 vf5 :fsf #b11 :ftf #b11) + (.lvf vf3 (&-> v1-5 uvec quad)) + (.add.mul.x.vf acc vf2 vf1 acc) + (.lvf vf4 (&-> v1-5 fvec quad)) + (.add.mul.y.vf acc vf3 vf1 acc) + (.add.mul.z.vf vf1 vf4 vf1 acc :mask #b111) + (.mul.vf vf1 vf1 Q :mask #b111) + (.svf (&-> s5-0 prim-core world-sphere quad) vf1) + (.mov a1-11 vf1) + ) + (&+! s5-0 80) + ) + ) + ) + ) + ) + (none) + ) + ) + +;; definition for method 21 of type gravity-spinner +(defmethod get-float-speed ((this gravity-spinner)) + (let* ((s4-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (when s5-0 + (let ((f0-2 (- (- (-> (get-trans (the-as process-focusable s5-0) 3) y) + (-> (the-as process-focusable s5-0) root root-prim local-sphere w) + ) + (-> this ground-height) + ) + ) + ) + (cond + ((< f0-2 4096.0) + (* 10.0 (seconds-per-frame) (- 4096.0 f0-2)) + ) + ((< 14336.0 f0-2) + (let* ((f0-5 (+ -14336.0 f0-2)) + (f0-7 (* f0-5 f0-5)) + (f0-9 (* 0.00008138021 (- f0-7))) + (f0-10 (fmax -61440.0 f0-9)) + ) + (* 10.0 (seconds-per-frame) f0-10) + ) + ) + (else + 0.0 + ) + ) + ) + ) + ) + ) + +;; definition for method 20 of type gravity-spinner +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defmethod probe-ground ((this gravity-spinner)) + (let* ((s4-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (when s5-0 + (let ((s4-1 (get-trans (the-as process-focusable s5-0) 3)) + (s3-0 (new 'stack-no-clear 'collide-query)) + ) + 0.0 + (vector+float*! (-> s3-0 start-pos) s4-1 *up-vector* 24576.0) + (set! (-> s3-0 move-dist quad) (the-as uint128 0)) + (set! (-> s3-0 move-dist y) -81920.0) + (let ((v1-8 s3-0)) + (set! (-> v1-8 radius) 40.96) + (set! (-> v1-8 collide-with) (collide-spec backgnd)) + (set! (-> v1-8 ignore-process0) #f) + (set! (-> v1-8 ignore-process1) #f) + (set! (-> v1-8 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-8 action-mask) (collide-action solid)) + ) + (set! (-> this ground-height) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s3-0) 0.0) + (-> s3-0 best-other-tri intersect y) + (fmin + (- (-> s4-1 y) (-> (the-as process-focusable s5-0) root root-prim local-sphere w)) + (-> (target-pos 0) y) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for symbol *gravity-origin-pos*, type vector +(define *gravity-origin-pos* (new 'static 'vector)) + +;; definition for function gravity-spinner-init-by-other +;; INFO: Used lq/sq +(defbehavior gravity-spinner-init-by-other gravity-spinner ((arg0 handle) (arg1 object) (arg2 time-frame)) + (stack-size-set! (-> self main-thread) 512) + (set! (-> self parent-hand) arg0) + (set! (-> self time-subtract) arg2) + (set! (-> self cached-damage) 0.0) + (set! (-> self was-hit-previously?) #f) + (let* ((s5-1 (handle->process (-> self parent-hand))) + (gp-1 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (when gp-1 + (set! (-> self original-sphere-offset quad) + (-> (the-as process-focusable gp-1) root root-prim local-sphere quad) + ) + (set! (-> *gravity-origin-pos* quad) (-> (get-trans (the-as process-focusable gp-1) 3) quad)) + (iterate-prims + (-> (the-as process-focusable gp-1) root) + (lambda :behavior gravity-spinner + ((arg0 collide-shape-prim)) + (case (-> arg0 prim-core prim-type) + ((-1) + (set! (-> self obj-radius) + (fmax + (-> self obj-radius) + (+ (vector-vector-distance (the-as vector (-> arg0 prim-core)) *gravity-origin-pos*) + (-> arg0 prim-core world-sphere w) + ) + ) + ) + ) + ) + (none) + ) + ) + (set! (-> self obj-radius) + (fmin (-> self obj-radius) (-> (the-as process-focusable gp-1) root root-prim local-sphere w)) + ) + (when (not (logtest? (process-mask vehicle) (-> gp-1 mask))) + (set! (-> self obj-radius) (* 0.75 (-> self obj-radius))) + (set! (-> (the-as process-focusable gp-1) root root-prim local-sphere w) (-> self obj-radius)) + (set! (-> (the-as process-focusable gp-1) root root-prim prim-core world-sphere w) (-> self obj-radius)) + ) + (let* ((v1-23 (get-trans (the-as process-focusable gp-1) 3)) + (s5-4 (vector-! (new 'stack-no-clear 'vector) v1-23 (the-as vector arg1))) + (s4-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-1 quad) (-> v1-23 quad)) + (let* ((f0-8 (- (-> s5-4 y))) + (f0-9 (if (< f0-8 0.0) + (fmax f0-8 (-> (the-as process-focusable gp-1) root root-prim local-sphere w)) + (fmin f0-8 (-> (the-as process-focusable gp-1) root root-prim local-sphere w)) + ) + ) + ) + (+! (-> s4-1 y) f0-9) + ) + (vector+! + s5-4 + s5-4 + (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> (the-as process-focusable gp-1) root transv) 1.0) + ) + (let ((a0-17 s5-4)) + (set! (-> a0-17 quad) (-> s5-4 quad)) + (set! (-> a0-17 y) 0.0) + (vector-normalize! a0-17 1.0) + ) + (let* ((s3-1 vector-rotate-around-axis!) + (s2-2 s5-4) + (s1-0 s5-4) + (f30-0 -1820.4445) + (f28-0 3640.889) + (v1-39 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-40 (the-as number (logior #x3f800000 v1-39))) + ) + (s3-1 s2-2 (the-as quaternion s1-0) (+ f30-0 (* f28-0 (+ -1.0 (the-as float v1-40)))) *up-vector*) + ) + (let ((f0-18 (* 0.000061035156 (-> self obj-radius)))) + 0.0 + (let* ((f30-1 (lerp 1.0 0.2 f0-18)) + (s3-2 s5-4) + (s2-3 s5-4) + (f28-1 12288.0) + (f26-0 8192.0) + (v1-46 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-47 (the-as number (logior #x3f800000 v1-46))) + ) + (vector-float*! s3-2 s2-3 (* f30-1 (+ f28-1 (* f26-0 (+ -1.0 (the-as float v1-47)))))) + ) + ) + (gravity-spinner-method-16 self s4-1 s5-4) + ) + (if (logtest? (process-mask vehicle) (-> gp-1 mask)) + (go-virtual zero-g-vehicle) + (go-virtual zero-g) + ) + ) + ) + ) + +;; definition for method 19 of type gravity-spinner +;; INFO: Used lq/sq +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +;; WARN: Stack slot offset 148 signed mismatch +(defmethod handle-impact ((this gravity-spinner) (arg0 symbol)) + (local-vars + (sv-144 sphere) + (sv-148 process) + (sv-152 vector) + (sv-156 float) + (sv-160 float) + (sv-164 vector) + (sv-168 symbol) + (sv-172 float) + (sv-1728 vector) + (sv-1732 vector) + (sv-1736 float) + (sv-2304 vector) + (sv-2308 vector) + (sv-2312 float) + ) + (let* ((s3-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s3-0 process-focusable) + s3-0 + ) + ) + ) + (when s5-0 + (set! sv-144 (new 'stack 'sphere)) + (set! sv-148 (the-as process (send-event *target* 'get-vehicle))) + (let ((v1-7 (new 'stack-no-clear 'vector))) + (set! (-> v1-7 quad) (-> (the-as process-focusable s5-0) root transv quad)) + (set! sv-152 v1-7) + ) + (set! sv-156 (the-as float 0.0)) + (set! sv-160 (the-as float 102400.0)) + (set! sv-164 (new 'stack-no-clear 'vector)) + (set! sv-168 (the-as symbol #f)) + (set! sv-172 (the-as float 40960000.0)) + (if arg0 + (set! sv-160 (the-as float 163840.0)) + ) + (set! sv-156 (vector-normalize-ret-len! sv-152 1.0)) + (set! (-> sv-144 quad) (-> (get-trans (the-as process-focusable s5-0) 3) quad)) + (set! (-> sv-144 r) sv-160) + (let ((s3-2 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-144) s3-2 384)) + (let* ((s1-0 (-> s3-2 s2-0)) + (a0-15 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when a0-15 + (let* ((s1-1 (-> a0-15 process)) + (a0-17 (if (type? s1-1 process-focusable) + s1-1 + ) + ) + ) + (when a0-17 + (when (and (!= s5-0 a0-17) + (not (focus-test? (the-as process-focusable a0-17) disable dead inactive gun-no-target)) + (logtest? (process-mask enemy guard civilian) (-> a0-17 mask)) + (not (focus-test? (the-as process-focusable a0-17) no-gravity)) + (!= a0-17 sv-148) + ) + (set! sv-1728 (get-trans (the-as process-focusable a0-17) 3)) + (set! sv-1732 (new 'stack-no-clear 'vector)) + (set! sv-1736 (the-as float 0.0)) + (vector-! sv-1732 sv-1728 (the-as vector sv-144)) + (set! sv-1736 (vector-normalize-ret-len! sv-1732 1.0)) + (when (and (>= sv-160 sv-1736) (< sv-1736 sv-172) (< sv-1736 (* 4.5 sv-156))) + (let ((f30-0 (vector-dot sv-152 sv-1732)) + (f0-12 0.707) + ) + (if arg0 + (set! f0-12 0.5) + ) + (when (< f0-12 f30-0) + (let ((a1-19 (new 'stack 'collide-query))) + (set! (-> a1-19 start-pos quad) (-> sv-144 quad)) + (vector-! (-> a1-19 move-dist) sv-1728 (-> a1-19 start-pos)) + (let ((v1-53 a1-19)) + (set! (-> v1-53 radius) (* 0.8 (-> (the-as process-focusable s5-0) root root-prim prim-core world-sphere w))) + (set! (-> v1-53 collide-with) (collide-spec backgnd obstacle)) + (set! (-> v1-53 ignore-process0) #f) + (set! (-> v1-53 ignore-process1) #f) + (set! (-> v1-53 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-53 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* a1-19) 0.0) + (set! sv-172 (* sv-1736 (* f30-0 f30-0))) + (set! sv-168 #t) + (let ((f0-18 sv-156)) + (when arg0 + (set! f0-18 (fmin (fmax sv-156 (* 1.5 sv-1736)) (* 3.0 sv-156))) + (if (-> this was-hit-previously?) + (set! f0-18 (fmin f0-18 (* 2.0 sv-156))) + ) + ) + (vector-normalize-copy! sv-164 sv-1732 f0-18) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-3 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-3 (< (vector-vector-distance (get-trans s3-3 0) sv-144) (-> sv-144 r))) + (when (and (!= s5-0 s3-3) + (not (focus-test? s3-3 disable dead inactive gun-no-target)) + (logtest? (process-mask enemy guard civilian) (-> s3-3 mask)) + (not (focus-test? s3-3 no-gravity)) + (!= s3-3 sv-148) + ) + (set! sv-2304 (get-trans s3-3 3)) + (set! sv-2308 (new 'stack-no-clear 'vector)) + (set! sv-2312 (the-as float 0.0)) + (vector-! sv-2308 sv-2304 (the-as vector sv-144)) + (set! sv-2312 (vector-normalize-ret-len! sv-2308 1.0)) + (when (and (>= sv-160 sv-2312) (< sv-2312 sv-172) (< sv-2312 (* 4.5 sv-156))) + (let ((f30-1 (vector-dot sv-152 sv-2308)) + (f0-28 0.707) + ) + (if arg0 + (set! f0-28 0.5) + ) + (when (< f0-28 f30-1) + (let ((a1-29 (new 'stack 'collide-query))) + (set! (-> a1-29 start-pos quad) (-> sv-144 quad)) + (vector-! (-> a1-29 move-dist) sv-2304 (-> a1-29 start-pos)) + (let ((v1-103 a1-29)) + (set! (-> v1-103 radius) (* 0.8 (-> (the-as process-focusable s5-0) root root-prim prim-core world-sphere w))) + (set! (-> v1-103 collide-with) (collide-spec backgnd obstacle)) + (set! (-> v1-103 ignore-process0) #f) + (set! (-> v1-103 ignore-process1) #f) + (set! (-> v1-103 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-103 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* a1-29) 0.0) + (set! sv-172 (* sv-2312 (* f30-1 f30-1))) + (set! sv-168 #t) + (let ((f0-34 sv-156)) + (when arg0 + (set! f0-34 (fmin (fmax sv-156 (* 1.5 sv-2312)) (* 3.0 sv-156))) + (if (-> this was-hit-previously?) + (set! f0-34 (fmin f0-34 (* 2.0 sv-156))) + ) + ) + (vector-normalize-copy! sv-164 sv-2308 f0-34) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (when sv-168 + (let ((v0-1 (-> (the-as process-focusable s5-0) root transv))) + (set! (-> v0-1 quad) (-> sv-164 quad)) + v0-1 + ) + ) + ) + ) + ) + +;; definition for method 16 of type gravity-spinner +;; WARN: Return type mismatch int vs none. +(defmethod gravity-spinner-method-16 ((this gravity-spinner) (arg0 vector) (arg1 vector)) + (local-vars (sv-48 vector) (sv-52 vector) (sv-56 float)) + (let* ((s2-0 (handle->process (-> this parent-hand))) + (s4-0 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (when s4-0 + (set! sv-48 (vector-! (new 'stack-no-clear 'vector) arg0 (get-trans (the-as process-focusable s4-0) 3))) + (set! sv-52 (new 'stack-no-clear 'vector)) + (let ((f30-0 1.0) + (f0-0 (gravity-spinner-method-18 this s4-0)) + (f1-1 (fmin 12288.0 (-> (the-as process-focusable s4-0) root root-prim prim-core world-sphere w))) + ) + (set! sv-56 (/ f30-0 (* f0-0 (* f1-1 f1-1)))) + ) + (vector-cross! sv-52 sv-48 arg1) + (vector+float*! (-> this rotation-accel) (-> this rotation-accel) sv-52 sv-56) + ) + ) + 0 + (none) + ) + +;; definition for method 24 of type gravity-spinner +;; WARN: Return type mismatch quaternion vs none. +(defmethod rotate! ((this gravity-spinner) (arg0 quaternion)) + (let* ((s4-0 (handle->process (-> this parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (when s5-0 + (let* ((s4-1 (get-trans (the-as process-focusable s5-0) 3)) + (s3-1 (vector-! (new 'stack-no-clear 'vector) (-> (the-as process-focusable s5-0) root trans) s4-1)) + ) + (let ((s2-0 (new 'stack-no-clear 'matrix))) + (quaternion->matrix s2-0 arg0) + (vector-matrix*! s3-1 s3-1 s2-0) + ) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere x) (- (-> s3-1 x))) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere y) (- (-> s3-1 y))) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere z) (- (-> s3-1 z))) + (vector+! (-> (the-as process-focusable s5-0) root trans) s4-1 s3-1) + ) + (quaternion*! + (-> (the-as process-focusable s5-0) root quat) + arg0 + (-> (the-as process-focusable s5-0) root quat) + ) + (quaternion-normalize! (-> (the-as process-focusable s5-0) root quat)) + ) + ) + (none) + ) + +;; definition for method 17 of type gravity-spinner +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defmethod update-rotation ((this gravity-spinner) (arg0 symbol)) + (cond + ((< (current-time) (+ (-> this end-time) (seconds -0.2))) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> this rotation-accel quad)) + 0.0 + (let* ((f0-1 (vector-normalize-ret-len! s5-1 1.0)) + (f0-2 (* 182.04445 f0-1)) + (f0-3 (* 360.0 f0-2)) + (f0-4 (* 0.2 f0-3)) + (f30-0 (fmin 116508.445 f0-4)) + (s4-0 (handle->process (-> this parent-hand))) + ) + (if (if (type? s4-0 process-focusable) + s4-0 + ) + (rotate! this (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) s5-1 (* f30-0 (seconds-per-frame)))) + ) + ) + ) + (if (< 0.2 (vector-length (-> this rotation-accel))) + (vector-float*! (-> this rotation-accel) (-> this rotation-accel) (- 1.0 (* 0.2 (seconds-per-frame)))) + ) + ) + (else + (let* ((s3-1 (handle->process (-> this parent-hand))) + (s4-2 (if (type? s3-1 process-focusable) + s3-1 + ) + ) + ) + (when s4-2 + (let ((s2-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> (the-as process-focusable s4-2) root quat))) + (s3-2 (new 'stack-no-clear 'quaternion)) + (f30-1 (* 4.0 (seconds-per-frame))) + ) + (let ((a0-18 s2-0)) + (set! (-> a0-18 quad) (-> s2-0 quad)) + (set! (-> a0-18 y) 0.0) + (vector-normalize! a0-18 1.0) + ) + (quaternion-look-at! s3-2 s2-0 *up-vector*) + (let ((s2-1 (quaternion-copy! (new 'stack-no-clear 'quaternion) (-> (the-as process-focusable s4-2) root quat)))) + (if arg0 + (quaternion-copy! s2-1 s3-2) + (quaternion-slerp! s2-1 s2-1 s3-2 f30-1) + ) + (let ((a1-16 + (quaternion*! + (new 'stack-no-clear 'quaternion) + s2-1 + (quaternion-inverse! (new 'stack-no-clear 'quaternion) (-> (the-as process-focusable s4-2) root quat)) + ) + ) + ) + (rotate! this a1-16) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate zero-g-vehicle (gravity-spinner) + :virtual #t + :enter (behavior () + (let* ((gp-0 (current-time)) + (f30-0 300.0) + (f28-0 6.0) + (f26-0 2.0) + (v1-5 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-6 (the-as number (logior #x3f800000 v1-5))) + ) + (set! (-> self end-time) + (+ gp-0 + (the int + (* f30-0 + (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-6)))) + (if (logtest? (game-secrets gun-upgrade-dark-2) (-> *game-info* secrets)) + 1.5 + 1.0 + ) + ) + ) + ) + ) + ) + (set! (-> self end-time) (- (-> self end-time) (-> self time-subtract))) + (set! (-> self end-time) (the-as time-frame (max (-> self end-time) (+ (current-time) (seconds 2))))) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage 0.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-dark) + (attacker-velocity *zero-vector*) + (penetrate-using (penetrate explode jak-dark-blackhole)) + ) + ) + ) + ) + :code (behavior () + (until (< (-> self end-time) (current-time)) + (suspend) + ) + (let* ((f0-1 (+ 0.5 (* 0.0625 (-> self cached-damage)))) + (f0-2 (fmin 0.9 f0-1)) + ) + (send-event (handle->process (-> self parent-hand)) 'gun-dark-2-off f0-2) + ) + (let ((gp-0 (handle->process (-> self parent-hand)))) + (if (if (type? gp-0 process-focusable) + gp-0 + ) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage 0.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (penetrate-using (penetrate vehicle)) + (vector *zero-vector*) + (attacker-velocity *zero-vector*) + (mode 'gravity-end) + ) + ) + ) + ) + ) + ) + ) + +;; definition for function zero-g-wait-for-land +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs object. +(defbehavior zero-g-wait-for-land gravity-spinner () + (let ((gp-0 (current-time))) + (until (time-elapsed? gp-0 (seconds 1.5)) + (let* ((s4-0 (handle->process (-> self parent-hand))) + (s5-0 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (cond + ((and s5-0 + (not (logtest? (-> (the-as process-focusable s5-0) focus-status) (focus-status disable dead inactive))) + ) + (if (or (< (- (-> (get-trans (the-as process-focusable s5-0) 3) y) + (-> (the-as process-focusable s5-0) root root-prim local-sphere w) + ) + (-> self ground-height) + ) + (let ((s4-1 (-> (the-as process-focusable s5-0) root))) + (and (if (type? s4-1 collide-shape-moving) + s4-1 + ) + (logtest? (-> (the-as collide-shape-moving (-> (the-as process-focusable s5-0) root)) status) + (collide-status on-surface touch-surface) + ) + ) + ) + ) + (return (the-as object 0)) + ) + (when (not (logtest? (process-mask vehicle) (-> (the-as process-focusable s5-0) mask))) + (let ((s4-2 (new 'stack 'sphere))) + (vector-lerp! + s4-2 + (-> (the-as process-focusable s5-0) root root-prim local-sphere) + (-> self original-sphere-offset) + (* 3.0 (seconds-per-frame)) + ) + (set! (-> s4-2 r) (lerp + (-> (the-as process-focusable s5-0) root root-prim local-sphere w) + (-> self original-sphere-offset r) + (* 3.0 (seconds-per-frame)) + ) + ) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere quad) (-> s4-2 quad)) + ) + (if (>= (+ (current-time) (seconds -1)) gp-0) + (set! (-> (the-as process-focusable s5-0) root root-prim local-sphere quad) + (-> self original-sphere-offset quad) + ) + ) + ) + ) + (else + (return (the-as object 0)) + ) + ) + ) + (suspend) + ) + ) + (the-as int #f) + ) + +;; definition for symbol *zero-g-fake-attack-vec*, type vector +(define *zero-g-fake-attack-vec* (new 'static 'vector :y -0.001 :w 1.0)) + +;; failed to figure out what this is: +(defstate zero-g (gravity-spinner) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (sv-32 vector) (sv-36 float) (sv-40 uint) (sv-48 uint)) + (case message + (('get-float-speed) + (get-float-speed self) + ) + (('update-rotation) + (update-rotation self #f) + ) + (('impact) + (handle-impact self #f) + (let ((s5-1 (handle->process (-> self parent-hand)))) + (when (if (type? s5-1 process-focusable) + s5-1 + ) + (let ((f0-0 (vector-length (the-as vector (-> block param 1))))) + 0.0 + (when (< 40960.0 f0-0) + (let ((f30-0 (* 0.000024414063 f0-0))) + (format 0 "Receving impact damage ~f~%" f30-0) + (+! (-> self cached-damage) f30-0) + ) + ) + ) + ) + ) + (gravity-spinner-method-16 self (the-as vector (-> block param 0)) (the-as vector (-> block param 1))) + ) + (('is-gravity) + #t + ) + (('attack-forward) + (if (!= proc (handle->process (-> self parent-hand))) + (return 0) + ) + (set! sv-32 (vector-normalize-copy! (new 'stack-no-clear 'vector) (the-as vector (-> block param 0)) 1.0)) + (set! sv-36 (the-as float 0.0)) + (set! sv-40 (-> block param 2)) + (set! sv-48 (-> block param 3)) + (set! sv-36 (if (logtest? (attack-mask damage) (-> (the-as attack-info sv-40) mask)) + (-> (the-as attack-info sv-40) damage) + (penetrate-using->damage (the-as penetrate sv-48)) + ) + ) + (vector-float*! sv-32 sv-32 (fmin 184320.0 (vector-length (the-as vector (-> block param 4))))) + (if (!= sv-48 1024) + (vector-float*! sv-32 sv-32 (* 2.0 sv-36)) + ) + (set! (-> sv-32 y) (* 0.15 (-> sv-32 y))) + (+! (-> self cached-damage) sv-36) + (let ((s4-0 (if (type? proc process-focusable) + proc + ) + ) + ) + (when s4-0 + (vector-float*! sv-32 sv-32 (fmax 0.5 (gravity-spinner-method-18 self s4-0))) + (vector+float*! + (-> (the-as process-drawable s4-0) root transv) + (-> (the-as process-drawable s4-0) root transv) + sv-32 + 1.0 + ) + (let ((f0-17 (vector-normalize-ret-len! (-> (the-as process-drawable s4-0) root transv) 1.0))) + (vector-float*! + (-> (the-as process-drawable s4-0) root transv) + (-> (the-as process-drawable s4-0) root transv) + (fmin 143360.0 f0-17) + ) + ) + (handle-impact self #t) + (gravity-spinner-method-16 self (the-as vector (-> block param 5)) sv-32) + ) + ) + (when (< 0.0 sv-36) + (let ((v0-0 (the-as object #t))) + (set! (-> self was-hit-previously?) (the-as symbol v0-0)) + v0-0 + ) + ) + ) + ) + ) + :enter (behavior () + (let* ((gp-0 (current-time)) + (f30-0 300.0) + (f28-0 7.0) + (f26-0 2.0) + (v1-5 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-6 (the-as number (logior #x3f800000 v1-5))) + ) + (set! (-> self end-time) + (+ gp-0 + (the int + (* f30-0 + (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-6)))) + (if (logtest? (game-secrets gun-upgrade-dark-2) (-> *game-info* secrets)) + 1.5 + 1.0 + ) + ) + ) + ) + ) + ) + (set! (-> self end-time) (- (-> self end-time) (-> self time-subtract))) + (set! (-> self end-time) (the-as time-frame (max (-> self end-time) (+ (current-time) (seconds 2))))) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage 0.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-dark) + (attacker (process->handle *target*)) + (attacker-velocity *zero-vector*) + (penetrate-using (penetrate explode jak-dark-blackhole)) + ) + ) + ) + ) + :code (behavior () + (until (< (-> self end-time) (current-time)) + (when (< (-> self next-ground-probe-time) (current-time)) + (probe-ground self) + (set! (-> self next-ground-probe-time) + (the-as time-frame (+ (mod (the-as int (rand-uint31-gen *random-generator*)) 61) 60 (current-time))) + ) + ) + (suspend) + ) + (send-event (handle->process (-> self parent-hand)) 'gun-dark-2-off) + (let* ((s5-0 (handle->process (-> self parent-hand))) + (gp-0 (if (type? s5-0 process-focusable) + s5-0 + ) + ) + ) + (when gp-0 + (update-rotation self #t) + (quaternion-normalize! (-> (the-as process-focusable gp-0) root quat)) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) + (damage 0.2) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (penetrate-using (penetrate vehicle)) + (vector (-> (the-as process-focusable gp-0) root transv)) + (attacker-velocity (-> (the-as process-focusable gp-0) root transv)) + (mode 'gravity-end) + (attacker (process->handle *target*)) + ) + ) + ) + (let ((f0-5 + (- (- (-> (get-trans (the-as process-focusable gp-0) 3) y) + (-> (the-as process-focusable gp-0) root root-prim local-sphere w) + ) + (-> self ground-height) + ) + ) + ) + 0.0 + (set! (-> self cached-damage) (* 2.0 (-> self cached-damage))) + (let* ((f0-6 (* 0.00012207031 f0-5)) + (f0-7 (fmax 1.0 f0-6)) + ) + (+! (-> self cached-damage) f0-7) + ) + ) + (let* ((gp-1 (-> (the-as process-focusable gp-0) root)) + (v1-37 (if (type? gp-1 collide-shape-moving) + gp-1 + ) + ) + ) + (if v1-37 + (logclear! (-> (the-as collide-shape-moving v1-37) status) (collide-status on-surface touch-surface)) + ) + ) + ) + ) + (probe-ground self) + (zero-g-wait-for-land) + (send-event + (handle->process (-> self parent-hand)) + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (new-attack-id)) + (damage (-> self cached-damage)) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (penetrate-using (penetrate vehicle)) + (vector *zero-g-fake-attack-vec*) + (attacker-velocity *zero-g-fake-attack-vec*) + (mode 'eco-dark) + (attacker (process->handle *target*)) + ) + ) + ) + (let* ((s5-1 (handle->process (-> self parent-hand))) + (gp-2 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (when gp-2 + (set! (-> (the-as process-focusable gp-2) root root-prim local-sphere quad) + (-> self original-sphere-offset quad) + ) + (let ((s5-2 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> (the-as process-focusable gp-2) root quat)))) + (new 'stack-no-clear 'vector) + (let ((a0-67 s5-2)) + (set! (-> a0-67 quad) (-> s5-2 quad)) + (set! (-> a0-67 y) 0.0) + (vector-normalize! a0-67 1.0) + ) + (quaternion-look-at! (-> (the-as process-focusable gp-2) root quat) s5-2 *up-vector*) + ) + ) + ) + ) + :post (behavior () + (spawn-part self) + (if (>= (-> self end-time) (current-time)) + (gravity-spinner-method-22 self) + ) + ) + ) + +;; failed to figure out what this is: +(defskelgroup skel-gun-dark-2-ring gun gun-dark-2-ring-lod0-jg gun-dark-2-ring-idle-ja + ((gun-dark-2-ring-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0.5 84) + :longest-edge (meters 80) + :shadow gun-dark-2-ring-shadow-mg + ) + +;; definition for symbol *gun-gravity-shadow-control*, type shadow-control +(define *gun-gravity-shadow-control* + (new 'static 'shadow-control :settings (new 'static 'shadow-settings + :center (new 'static 'vector :w (the-as float #x9a)) + :shadow-dir (new 'static 'vector :y -1.0 :w 614400.0) + :bot-plane (new 'static 'plane :y 1.0 :w 163840.0) + :top-plane (new 'static 'plane :y 1.0 :w -163840.0) + :shadow-type 2 + ) + ) + ) + +;; definition of type gravity-ring +(deftype gravity-ring (process-drawable) + ((start-pos vector :inline) + (jmod-outer joint-mod-add-local :inline) + (jmod-inner joint-mod-add-local :inline) + (ring-scale-t float) + (current-radius float) + (max-radius float) + (reverse? symbol) + (total-time float) + (ring-width float) + (stop-time time-frame) + ) + (:state-methods + expand + ) + (:methods + (gravity-ring-method-21 (_type_) none) + ) + ) + +;; definition for method 3 of type gravity-ring +(defmethod inspect ((this gravity-ring)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tstart-pos: #~%" (-> this start-pos)) + (format #t "~2Tjmod-outer: #~%" (-> this jmod-outer)) + (format #t "~2Tjmod-inner: #~%" (-> this jmod-inner)) + (format #t "~2Tring-scale-t: ~f~%" (-> this ring-scale-t)) + (format #t "~2Tcurrent-radius: ~f~%" (-> this current-radius)) + (format #t "~2Tmax-radius: ~f~%" (-> this max-radius)) + (format #t "~2Treverse?: ~A~%" (-> this reverse?)) + (format #t "~2Ttotal-time: ~f~%" (-> this total-time)) + (format #t "~2Tring-width: ~f~%" (-> this ring-width)) + (format #t "~2Tstop-time: ~D~%" (-> this stop-time)) + (label cfg-4) + this + ) + +;; definition for function gravity-ring-init-by-other +;; INFO: Used lq/sq +(defbehavior gravity-ring-init-by-other gravity-ring ((arg0 vector) (arg1 symbol) (arg2 float) (arg3 float) (arg4 float) (arg5 time-frame)) + (set! (-> self root) (new 'process 'trsqv)) + (set! (-> self root trans quad) (-> arg0 quad)) + (quaternion-identity! (-> self root quat)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-dark-2-ring" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self draw shadow-ctrl) *gun-gravity-shadow-control*) + (init (-> self jmod-inner) self (the-as uint 4) (joint-mod-base-flags attached scale)) + (init (-> self jmod-outer) self (the-as uint 3) (joint-mod-base-flags attached scale)) + (let ((v1-13 (-> self draw shadow-ctrl))) + (logclear! (-> v1-13 settings flags) (shadow-flags disable-draw)) + ) + 0 + (logclear! (-> self draw status) (draw-control-status no-draw)) + (set! (-> self total-time) arg3) + (set! (-> self reverse?) arg1) + (set! (-> self max-radius) arg2) + (set! (-> self ring-width) arg4) + (+! (-> self root trans y) (-> self max-radius)) + (ja-post) + (setup-masks (-> self draw) 0 1) + (set-time! (-> self state-time)) + (set! (-> self stop-time) arg5) + (go-virtual expand) + ) + +;; failed to figure out what this is: +(defstate expand (gravity-ring) + :virtual #t + :trans (behavior () + (gravity-ring-method-21 self) + ) + :code sleep-code + :post (behavior () + (ja-post) + ) + ) + +;; definition for method 21 of type gravity-ring +;; WARN: Return type mismatch float vs none. +(defmethod gravity-ring-method-21 ((this gravity-ring)) + (let* ((a0-1 *time-of-day-context*) + (v1-0 (-> a0-1 light-group)) + (s4-0 (-> v1-0 0 ambi color)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (-> a0-1 current-prt-color) + (-> a0-1 current-env-color) + (vector4-lerp! s5-0 (-> v1-0 0 dir0 color) (-> v1-0 0 dir1 color) (-> v1-0 0 dir1 extra x)) + (fmax (fmax (-> s4-0 x) (-> s4-0 y)) (-> s4-0 z)) + (fmax (fmax (-> s5-0 x) (-> s5-0 y)) (-> s5-0 z)) + (let* ((f0-10 (+ (* 0.2 (-> s4-0 x)) (* 0.75 (-> s4-0 y)) (* 0.05 (-> s4-0 z)))) + (f1-12 (+ (* 0.2 (-> s5-0 x)) (* 0.75 (-> s5-0 y)) (* 0.05 (-> s5-0 z)))) + (f0-12 (* 0.5 (+ f0-10 f1-12))) + (f30-0 (lerp-scale-clamp 0.0 1.0 f0-12 0.0 1.0)) + (s5-1 (new 'stack 'rgbaf)) + (s3-0 (new 'stack 'rgbaf)) + (s4-1 0) + ) + (cond + ((or (= (status-of-level-and-borrows *level* 'desert #f) 'active) + (= (status-of-level-and-borrows *level* 'waswide #f) 'active) + (= (status-of-level-and-borrows *level* 'wasdoors #f) 'active) + ) + (set-vector! s5-1 0.85 1.1 1.1 0.25) + ) + (else + (set-vector! s5-1 0.4 2.0 2.0 0.25) + (set-vector! s3-0 0.7 1.15 1.15 0.25) + (vector-lerp! s5-1 s5-1 s3-0 f30-0) + ) + ) + (set! (-> s5-1 w) 0.25) + (let ((t1-0 + (logior (logand (logior (logand (logior (logand (logior (logand s4-1 -256) (shr (shl (the int (* 127.5 (-> s5-1 x))) 56) 56)) -65281) + (shr (shl (the int (* 127.5 (-> s5-1 y))) 56) 48) + ) + -16711681 + ) + (shr (shl (the int (* 127.5 (-> s5-1 z))) 56) 40) + ) + (the-as uint #xffffffff00ffffff) + ) + (shr (shl (the int (* 127.5 (-> s5-1 w))) 56) 32) + ) + ) + ) + (set-setting! 'highlight-color #f 0.0 t1-0) + ) + ) + ) + (let* ((f0-38 (-> this total-time)) + (f24-0 (/ (* 0.0033333334 (the float (- (current-time) (-> this state-time)))) f0-38)) + ) + 0.0 + (let ((f30-1 (-> this ring-width)) + (f22-0 1.0) + ) + 1.0 + (let ((f26-0 1.1) + (f28-0 0.5) + ) + (set! (-> this max-radius) 102400.0) + (if (-> this reverse?) + (set! f24-0 (- 1.0 f24-0)) + ) + (if (time-elapsed? (-> this state-time) (the int (* 1800.0 f0-38))) + (set! f28-0 + (lerp + f28-0 + 0.0 + (fmax 0.0 (fmin 1.0 (- (* 0.0033333334 (the float (- (current-time) (-> this state-time)))) (* 6.0 f0-38)))) + ) + ) + ) + (if (= f28-0 0.0) + (go empty-state) + ) + (let ((f26-1 + (+ (-> this ring-scale-t) + (* (cond + ((time-elapsed? (-> this stop-time) (the int (* 300.0 f26-0))) + (let ((f1-27 1.0)) + (lerp + 0.5 + 0.05 + (fmax 0.0 (fmin 1.0 (/ (- (* 0.0033333334 (the float (- (current-time) (-> this stop-time)))) f26-0) f1-27))) + ) + ) + ) + ((>= f22-0 f24-0) + (lerp 2.3 0.4 (/ f24-0 f22-0)) + ) + (else + 0.4 + ) + ) + (seconds-per-frame) + ) + ) + ) + ) + (let ((f24-1 (* 0.00024414062 (* (-> this max-radius) f26-1)))) + 0.0 + 0.0 + 0.0 + (let* ((f0-56 f26-1) + (f0-57 (* f0-56 f0-56)) + (f1-33 (fmax (lerp f30-1 0.0 f0-57) f28-0)) + (f0-60 (fmax 0.0 (- f24-1 f1-33))) + ) + (set-vector! (-> this jmod-outer transform scale) f24-1 1.0 f24-1 1.0) + (set-vector! (-> this jmod-inner transform scale) f0-60 1.0 f0-60 1.0) + ) + ) + (set! (-> this ring-scale-t) f26-1) + ) + ) + ) + ) + (none) + ) + +;; definition of type gun-gravity +(deftype gun-gravity (process-drawable) + ((current-radius float) + (max-radius float) + (lowest-y float) + (start-pos vector :inline) + (total-time float) + (ring-closest handle) + (ring-furthest handle) + (gravity-sound sound-id) + ) + (:state-methods + expand + ) + (:methods + (gun-gravity-method-21 (_type_) none) + (gun-gravity-method-22 (_type_ symbol) none) + (spawn-gravity-spinner (_type_ process) (pointer gravity-spinner)) + (gun-gravity-method-24 (_type_) none) + ) + ) + +;; definition for method 3 of type gun-gravity +(defmethod inspect ((this gun-gravity)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tcurrent-radius: ~f~%" (-> this current-radius)) + (format #t "~2Tmax-radius: ~f~%" (-> this max-radius)) + (format #t "~2Tlowest-y: ~f~%" (-> this lowest-y)) + (format #t "~2Tstart-pos: #~%" (-> this start-pos)) + (format #t "~2Ttotal-time: ~f~%" (-> this total-time)) + (format #t "~2Tring-closest: ~D~%" (-> this ring-closest)) + (format #t "~2Tring-furthest: ~D~%" (-> this ring-furthest)) + (format #t "~2Tgravity-sound: ~D~%" (-> this gravity-sound)) + (label cfg-4) + this + ) + +;; definition for function gun-gravity-init-by-other +;; INFO: Used lq/sq +(defbehavior gun-gravity-init-by-other gun-gravity ((arg0 vector) (arg1 vector)) + (set! (-> self root) (new 'process 'trsqv)) + (set! (-> self root trans quad) (-> arg0 quad)) + (let ((s4-0 (new 'stack-no-clear 'collide-query))) + 0.0 + (vector+float*! (-> s4-0 start-pos) (-> self root trans) *up-vector* 24576.0) + (set! (-> s4-0 move-dist quad) (the-as uint128 0)) + (set! (-> s4-0 move-dist y) -81920.0) + (let ((v1-7 s4-0)) + (set! (-> v1-7 radius) 40.96) + (set! (-> v1-7 collide-with) (collide-spec backgnd pusher)) + (set! (-> v1-7 ignore-process0) #f) + (set! (-> v1-7 ignore-process1) #f) + (set! (-> v1-7 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-7 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s4-0) 0.0) + (set! (-> self root trans y) (-> s4-0 best-other-tri intersect y)) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 (seconds 0.2)) + (let ((s4-1 quaternion-look-at!) + (s3-0 (-> self root quat)) + (a0-12 (new 'stack-no-clear 'vector)) + ) + (set! (-> a0-12 quad) (-> arg1 quad)) + (set! (-> a0-12 y) 0.0) + (s4-1 s3-0 (vector-normalize! a0-12 1.0) *up-vector*) + ) + (set! (-> self max-radius) 122880.0) + (set! (-> self total-time) 1.0) + (if (logtest? (game-secrets gun-upgrade-dark-2) (-> *game-info* secrets)) + (set! (-> self total-time) (* 1.5 (-> self total-time))) + ) + (set! (-> self start-pos quad) (-> arg0 quad)) + (set! (-> self ring-closest) (the-as handle #f)) + (set! (-> self ring-furthest) (the-as handle #f)) + (set! (-> self part) (create-launch-control (-> *part-group-id-table* 118) self)) + (set! (-> self gravity-sound) (new-sound-id)) + (go-virtual expand) + ) + +;; definition for method 10 of type gun-gravity +(defmethod deactivate ((this gun-gravity)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (sound-stop (-> this gravity-sound)) + (call-parent-method this) + (none) + ) + +;; failed to figure out what this is: +(defstate expand (gun-gravity) + :virtual #t + :enter (behavior () + (set! (-> self lowest-y) (-> self root trans y)) + (set-time! (-> self state-time)) + (sound-play "grav-gun" :id (-> self gravity-sound) :position (-> self root trans)) + ) + :trans (behavior () + (cond + ((not (time-elapsed? (-> self state-time) (the int (* 300.0 (-> self total-time))))) + (let* ((f0-4 (* 0.0033333334 (the float (- (current-time) (-> self state-time))))) + (f1-3 (-> self total-time)) + (f0-6 (/ (- f0-4 (* (the float (the int (/ f0-4 f1-3))) f1-3)) (-> self total-time))) + ) + (set! (-> self current-radius) (* (-> self max-radius) f0-6)) + ) + (gun-gravity-method-22 self #f) + ) + (else + (if (not (time-elapsed? (-> self state-time) (the int (* 2025.0 (-> self total-time))))) + (gun-gravity-method-22 self #t) + ) + ) + ) + (cond + ((not (time-elapsed? (-> self state-time) (the int (* 2025.0 (-> self total-time))))) + (let ((s5-1 (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (-> self root trans)))) + 0.0 + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((f0-16 (fmin (vector-normalize-ret-len! s5-1 1.0) (-> self current-radius)))) + (vector+float*! gp-0 (-> self root trans) s5-1 f0-16) + ) + (sound-play "grav-gun" :id (-> self gravity-sound) :position gp-0) + ) + ) + (dotimes (gp-1 6) + (let* ((s5-2 vector-rotate-around-y!) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 *x-vector*) + (f30-0 65536.0) + (v1-27 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-28 (the-as number (logior #x3f800000 v1-27))) + (s4-1 (s5-2 s4-0 s3-0 (* f30-0 (+ -1.0 (the-as float v1-28))))) + (s5-3 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (let* ((f30-1 (-> self current-radius)) + (f28-0 (fmax 0.0 (+ -40960.0 (-> self current-radius)))) + (s3-1 s5-3) + (s2-0 (-> self root trans)) + (v1-33 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-34 (the-as number (logior #x3f800000 v1-33))) + ) + (vector+float*! s3-1 s2-0 s4-1 (+ f28-0 (* (+ -1.0 (the-as float v1-34)) (- f30-1 f28-0)))) + ) + (let ((s4-2 (new 'stack-no-clear 'collide-query))) + 0.0 + (vector+float*! (-> s4-2 start-pos) s5-3 *up-vector* 24576.0) + (set! (-> s4-2 move-dist quad) (the-as uint128 0)) + (set! (-> s4-2 move-dist y) -81920.0) + (let ((v1-40 s4-2)) + (set! (-> v1-40 radius) 40.96) + (set! (-> v1-40 collide-with) (collide-spec backgnd pusher)) + (set! (-> v1-40 ignore-process0) #f) + (set! (-> v1-40 ignore-process1) #f) + (set! (-> v1-40 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-40 action-mask) (collide-action solid)) + ) + (when (>= (fill-and-probe-using-line-sphere *collide-cache* s4-2) 0.0) + (let ((f30-2 (-> s4-2 best-other-tri intersect y)) + (a1-7 (matrix-identity! (new 'stack-no-clear 'matrix))) + ) + (set! (-> a1-7 trans quad) (-> s4-2 start-pos quad)) + (set! (-> a1-7 trans y) f30-2) + (sparticle-launch-control-method-17 (-> self part) a1-7) + ) + ) + ) + ) + ) + ) + (else + (sound-stop (-> self gravity-sound)) + ) + ) + ) + :code (behavior () + (let ((f30-0 4.0) + (gp-0 (current-time)) + ) + (until #f + (dotimes (s5-0 5) + (let ((v1-7 (ppointer->handle (process-spawn + gravity-ring + (-> self root trans) + #f + (-> self max-radius) + (-> self total-time) + f30-0 + gp-0 + :name "gravity-ring" + :to self + ) + ) + ) + (a0-6 s5-0) + ) + (cond + ((zero? a0-6) + (set! (-> self ring-furthest) (the-as handle v1-7)) + ) + ((= a0-6 4) + (set! (-> self ring-closest) (the-as handle v1-7)) + ) + ) + ) + (set! f30-0 (+ -0.6 f30-0)) + (let ((s4-1 (current-time))) + (until (time-elapsed? s4-1 (seconds 0.15)) + (suspend) + ) + ) + ) + (let ((s5-1 (current-time))) + (until (time-elapsed? s5-1 (seconds 13.5)) + (suspend) + ) + ) + (go empty-state) + (set! f30-0 4.0) + ) + ) + #f + ) + ) + +;; definition for method 23 of type gun-gravity +;; WARN: Return type mismatch (pointer process) vs (pointer gravity-spinner). +(defmethod spawn-gravity-spinner ((this gun-gravity) (arg0 process)) + (process-spawn + gravity-spinner + (process->handle arg0) + (-> this root trans) + (- (current-time) (-> this state-time)) + :name "gravity-spinner" + :to arg0 + ) + ) + +;; definition for method 22 of type gun-gravity +;; INFO: Used lq/sq +;; WARN: Return type mismatch (pointer gravity-spinner) vs none. +(defmethod gun-gravity-method-22 ((this gun-gravity) (arg0 symbol)) + (local-vars (v1-29 symbol) (v1-49 symbol)) + (with-pp + (let ((s5-0 (new 'stack-no-clear 'vector)) + (a1-1 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-1 from) (process->ppointer pp)) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'get-vehicle) + (let ((s4-0 (the-as process (send-event-function *target* a1-1))) + (f30-0 0.0) + (f28-0 (-> this current-radius)) + ) + (set! (-> s5-0 quad) (-> this root trans quad)) + (when arg0 + (let ((v1-5 (handle->process (-> this ring-closest)))) + (if v1-5 + (set! f30-0 (* (-> (the-as gravity-ring v1-5) max-radius) (-> (the-as gravity-ring v1-5) ring-scale-t))) + ) + ) + (let ((v1-8 (handle->process (-> this ring-furthest)))) + (if v1-8 + (set! f28-0 (* (-> (the-as gravity-ring v1-8) max-radius) (-> (the-as gravity-ring v1-8) ring-scale-t))) + ) + ) + (set! f28-0 (* 0.85 f28-0)) + (set! f30-0 (* 0.85 f30-0)) + (set! (-> this current-radius) (* 0.5 (+ f30-0 f28-0))) + ) + (set! (-> s5-0 w) f28-0) + (let ((s3-1 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s5-0) s3-1 384)) + (let* ((s1-0 (-> s3-1 s2-0)) + (v1-17 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-17 + (let* ((s0-0 (-> v1-17 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= *target* s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s1-1 mask)) + (!= s4-0 s1-1) + ) + (let ((f0-6 (vector-vector-distance (get-trans (the-as process-focusable s1-1) 3) s5-0))) + (when (and (>= f28-0 f0-6) (>= f0-6 f30-0)) + (let ((v1-27 (-> s1-1 child))) + (while v1-27 + (when (= (-> v1-27 0 type) gravity-spinner) + (set! v1-29 #t) + (goto cfg-47) + ) + (set! v1-27 (-> v1-27 0 brother)) + ) + ) + (set! v1-29 #f) + (label cfg-47) + (if (not v1-29) + (spawn-gravity-spinner this s1-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-2 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-2 (< (vector-vector-distance (get-trans s3-2 0) s5-0) (-> s5-0 w))) + (when (and (!= *target* s3-2) + (not (focus-test? s3-2 disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s3-2 mask)) + (!= s4-0 s3-2) + ) + (let ((f0-8 (vector-vector-distance (get-trans s3-2 3) s5-0))) + (when (and (>= f28-0 f0-8) (>= f0-8 f30-0)) + (let ((v1-47 (-> s3-2 child))) + (while v1-47 + (when (= (-> v1-47 0 type) gravity-spinner) + (set! v1-49 #t) + (goto cfg-79) + ) + (set! v1-47 (-> v1-47 0 brother)) + ) + ) + (set! v1-49 #f) + (label cfg-79) + (if (not v1-49) + (spawn-gravity-spinner this s3-2) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + +;; definition for function gun-fire-dark-2 +;; INFO: Used lq/sq +(defbehavior gun-fire-dark-2 target () + (set-last-fire-time 36) + (cond + ((logtest? (-> *part-group-id-table* 120 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self gun fire-point quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 120)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self gun fire-point quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 120)) + ) + ) + (process-spawn + gun-gravity + (-> self gun fire-point) + (-> self gun fire-dir-out) + :name "gun-gravity" + :to (ppointer->process (-> self gun gun)) + ) + ) + +;; definition for function target-gun-fire-dark +(defbehavior target-gun-fire-dark target ((arg0 pickup-type)) + (case arg0 + (((pickup-type gun-dark-1)) + (gun-fire-dark-1) + ) + (((pickup-type gun-dark-2)) + (gun-fire-dark-2) + ) + (((pickup-type gun-dark-3)) + (gun-fire-dark-3) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/target/gun/gun-red-shot_REF.gc b/test/decompiler/reference/jak3/engine/target/gun/gun-red-shot_REF.gc new file mode 100644 index 0000000000..c4ce41c03e --- /dev/null +++ b/test/decompiler/reference/jak3/engine/target/gun/gun-red-shot_REF.gc @@ -0,0 +1,2935 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type gun-red-shot +(deftype gun-red-shot (process-drawable) + ((parent (pointer gun) :override) + (root collide-shape-moving :override) + (probe-count int32) + (probe-mask uint32) + (actor-count int32) + (attack-id uint32) + (start-pos vector :inline) + (start-dir vector :inline) + (start-rot vector :inline) + (probe-dir vector 19 :inline) + ) + (:state-methods + blocked + debug-idle + idle + ) + (:methods + (init-probes! (_type_ collide-shape) none) + (check-blocked? (_type_) symbol) + (stub (_type_) none) + (find-targets (_type_) none) + (setup-probes (_type_) none) + (do-collision (_type_ vector) none) + (send-attack! (_type_ process-drawable touching-shapes-entry) none) + ) + ) + +;; definition for method 3 of type gun-red-shot +(defmethod inspect ((this gun-red-shot)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tprobe-count: ~D~%" (-> this probe-count)) + (format #t "~2Tprobe-mask: ~D~%" (-> this probe-mask)) + (format #t "~2Tactor-count: ~D~%" (-> this actor-count)) + (format #t "~2Tattack-id: ~D~%" (-> this attack-id)) + (format #t "~2Tstart-pos: #~%" (-> this start-pos)) + (format #t "~2Tstart-dir: #~%" (-> this start-dir)) + (format #t "~2Tstart-rot: #~%" (-> this start-rot)) + (format #t "~2Tprobe-dir[19] @ #x~X~%" (-> this probe-dir)) + (label cfg-4) + this + ) + +;; definition of type gun-red-3-grenade +(deftype gun-red-3-grenade (projectile-bounce) + ((blast-radius float) + (should-explode-soon? symbol) + (explode-tick-time time-frame) + (birth-time time-frame) + (immediate-detonation? symbol) + (explode-delay-time time-frame) + ) + (:state-methods + impact-tiny + ) + (:methods + (check-should-explode (_type_) int) + (go-impact (_type_) object) + (find-and-damage-targets (_type_) object) + ) + ) + +;; definition for method 3 of type gun-red-3-grenade +(defmethod inspect ((this gun-red-3-grenade)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile-bounce inspect))) + (t9-0 this) + ) + (format #t "~2Tblast-radius: ~f~%" (-> this blast-radius)) + (format #t "~2Tshould-explode-soon?: ~A~%" (-> this should-explode-soon?)) + (format #t "~2Texplode-tick-time: ~D~%" (-> this explode-tick-time)) + (format #t "~2Tbirth-time: ~D~%" (-> this birth-time)) + (format #t "~2Timmediate-detonation?: ~A~%" (-> this immediate-detonation?)) + (format #t "~2Tattack-id: ~D~%" (-> this attack-id)) + (format #t "~2Texplode-delay-time: ~D~%" (-> this explode-delay-time)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(defskelgroup skel-gun-red-3-grenade gun gun-grenade-lod0-jg gun-grenade-idle-ja + ((gun-grenade-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 0.2) + :texture-level 10 + ) + +;; definition for method 30 of type gun-red-3-grenade +;; WARN: Return type mismatch int vs none. +(defmethod setup-collision! ((this gun-red-3-grenade)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) projectile-bounce-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate explode)) + (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-7 prim-core action) (collide-action solid)) + (set-vector! (-> v1-7 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-7) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-10 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set-collide-with! + (-> this root) + (collide-spec backgnd crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher shield) + ) + (set-collide-as! (-> this root) (collide-spec projectile)) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + (none) + ) + +;; definition for method 36 of type gun-red-3-grenade +;; WARN: Return type mismatch symbol vs object. +(defmethod handle-proj-hit! ((this gun-red-3-grenade) (arg0 process) (arg1 event-message-block)) + (go (method-of-object this impact)) + #t + ) + +;; definition for method 40 of type gun-red-3-grenade +(defmethod projectile-method-40 ((this gun-red-3-grenade)) + 256 + ) + +;; definition for method 31 of type gun-red-3-grenade +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod init-proj-settings! ((this gun-red-3-grenade)) + (set! (-> this attack-mode) #f) + (initialize-skeleton + this + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-red-3-grenade" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (let ((t9-2 (method-of-type projectile-bounce init-proj-settings!))) + (t9-2 this) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.2)) + (sound-play "red3-fire") + (let* ((v1-6 *game-info*) + (a0-9 (+ (-> v1-6 attack-id) 1)) + ) + (set! (-> v1-6 attack-id) a0-9) + (set! (-> this attack-id) a0-9) + ) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 87) this)) + (set! (-> this blast-radius) 81920.0) + (set! (-> this max-speed) 327680.0) + (set! (-> this timeout) (seconds 3)) + (set! (-> this should-explode-soon?) #f) + (set-time! (-> this birth-time)) + (let ((v1-15 (new 'stack-no-clear 'vector))) + (set! (-> v1-15 x) 2.5) + (set! (-> v1-15 y) 2.5) + (set! (-> v1-15 z) 2.5) + (set! (-> v1-15 w) 1.0) + (set! (-> this root scale quad) (-> v1-15 quad)) + ) + (set! (-> this immediate-detonation?) #f) + (let ((s5-2 (new 'stack-no-clear 'light-trail-tracker-spawn-params))) + (set! (-> s5-2 tracked-obj) (process->handle this)) + (set! (-> s5-2 appearance) *red-shot-3-trail*) + (set! (-> s5-2 max-num-crumbs) (the int (* 0.5 (the float (-> s5-2 appearance max-age))))) + (set! (-> s5-2 track-immediately?) #t) + (let* ((v1-28 (estimate-light-trail-mem-usage + (the-as uint (-> s5-2 max-num-crumbs)) + (the-as uint (= (-> s5-2 appearance lie-mode) 3)) + ) + ) + (s4-2 (get-process *default-dead-pool* light-trail-tracker-projectile (+ v1-28 8192) 1)) + ) + (when s4-2 + (let ((t9-9 (method-of-type process activate))) + (t9-9 s4-2 this "light-trail" (the-as pointer #x70004000)) + ) + (run-now-in-process s4-2 light-trail-tracker-init-by-other s5-2) + (-> s4-2 ppointer) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 32 of type gun-red-3-grenade +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-32 ((this gun-red-3-grenade)) + (cond + ((not (do-fire-backcheck (-> this root trans) (-> this root transv))) + (let ((v1-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this root transv) 1.0))) + (vector+float*! (-> this root trans) (-> this root trans) v1-3 -14336.0) + ) + (set! (-> this immediate-detonation?) #t) + (go (method-of-object this impact)) + ) + (else + (call-parent-method this) + ) + ) + 0 + (none) + ) + +;; definition for method 46 of type gun-red-3-grenade +(defmethod go-impact ((this gun-red-3-grenade)) + (cond + ((-> this should-explode-soon?) + (if (time-elapsed? (-> this explode-tick-time) (-> this explode-delay-time)) + (go (method-of-object this impact)) + ) + ) + (else + (case (check-should-explode this) + ((1) + (set! (-> this should-explode-soon?) #t) + (let ((v0-0 (the-as object (current-time)))) + (set! (-> this explode-tick-time) (the-as time-frame v0-0)) + v0-0 + ) + ) + ((2) + (go (method-of-object this impact)) + ) + ) + ) + ) + ) + +;; definition for method 47 of type gun-red-3-grenade +;; INFO: Used lq/sq +(defmethod find-and-damage-targets ((this gun-red-3-grenade)) + (local-vars (v1-21 float) (v1-45 float)) + (with-pp + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (a1-0 (new 'stack-no-clear 'event-message-block)) + ) + (set! (-> a1-0 from) (process->ppointer pp)) + (set! (-> a1-0 num-params) 0) + (set! (-> a1-0 message) 'get-vehicle) + (let ((s4-0 (send-event-function *target* a1-0))) + (set! (-> s5-0 quad) (-> this root trans quad)) + (set! (-> s5-0 w) (-> this blast-radius)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s5-0) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (a0-8 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when a0-8 + (let* ((s0-0 (-> a0-8 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= s4-0 s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s1-1 mask)) + (nonzero? (-> (the-as process-focusable s1-1) root root-prim prim-core collide-with)) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (let ((s0-2 + (vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable s1-1) 3) (-> this root trans)) + ) + ) + 0.0 + (.lvf vf1 (&-> s0-2 quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-21 vf1) + (let ((f0-4 v1-21) + (f1-1 (-> this blast-radius)) + ) + (if (>= (* f1-1 f1-1) f0-4) + (send-event + s1-1 + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage 12.0) + (vehicle-damage-factor 3.0) + (vehicle-impulse-factor 1.0) + (mode 'explode) + (attacker-velocity s0-2) + (penetrate-using (penetrate explode)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) s5-0) (-> s5-0 w))) + (when (and (!= s4-0 s3-1) + (not (focus-test? s3-1 disable dead inactive)) + (logtest? (process-mask crate enemy guard vehicle civilian) (-> s3-1 mask)) + (nonzero? (-> s3-1 control root-prim prim-core collide-with)) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (let ((s5-2 (vector-! (new 'stack-no-clear 'vector) (get-trans s3-1 3) (-> this root trans)))) + 0.0 + (.lvf vf1 (&-> s5-2 quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-45 vf1) + (let ((f0-12 v1-45) + (f1-6 (-> this blast-radius)) + ) + (if (>= (* f1-6 f1-6) f0-12) + (send-event + s3-1 + 'attack + #f + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage 12.0) + (vehicle-damage-factor 3.0) + (vehicle-impulse-factor 1.0) + (mode 'explode) + (attacker-velocity s5-2) + (penetrate-using (penetrate explode)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for method 45 of type gun-red-3-grenade +;; INFO: Used lq/sq +(defmethod check-should-explode ((this gun-red-3-grenade)) + (local-vars + (sv-1680 vector) + (sv-1684 vector) + (sv-1688 float) + (sv-1692 float) + (sv-1696 symbol) + (sv-1744 vector) + (sv-1748 vector) + (sv-1752 float) + (sv-1756 float) + (sv-1760 symbol) + ) + (with-pp + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 #f) + ) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) (process->ppointer pp)) + (set! (-> a1-0 num-params) 0) + (set! (-> a1-0 message) 'get-vehicle) + (let ((s3-0 (send-event-function *target* a1-0))) + (set! (-> s4-0 quad) (-> this root trans quad)) + (set! (-> s4-0 w) (* 0.6666667 (-> this blast-radius))) + (let ((s2-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s1-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box s4-0) s2-0 384)) + (let* ((s0-0 (-> s2-0 s1-0)) + (a0-8 (if (type? s0-0 collide-shape) + s0-0 + ) + ) + ) + (when a0-8 + (let* ((s0-1 (-> a0-8 process)) + (a0-10 (if (type? s0-1 process-focusable) + s0-1 + ) + ) + ) + (when a0-10 + (when (and (!= s3-0 a0-10) + (not (focus-test? (the-as process-focusable a0-10) disable dead inactive gun-no-target)) + (nonzero? (-> (the-as process-focusable a0-10) root root-prim prim-core collide-with)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> a0-10 mask)) + (and (logtest? (process-mask guard) (-> a0-10 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (set! sv-1680 + (vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable a0-10) 3) (-> this root trans)) + ) + (set! sv-1684 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this root transv) 1.0)) + (set! sv-1688 (the-as float 0.0)) + (set! sv-1692 (the-as float 0.0)) + (set! sv-1696 (time-elapsed? (-> this birth-time) (seconds 0.05))) + (set! sv-1688 (vector-normalize-ret-len! sv-1680 1.0)) + (set! sv-1692 (vector-dot sv-1680 sv-1684)) + (when (< sv-1688 (-> s4-0 w)) + (cond + ((and (< 0.0 sv-1692) sv-1696) + (set! gp-0 #t) + (set! (-> this explode-delay-time) + (the-as time-frame (min 150 (the int (* 300.0 (/ sv-1688 (vector-length (-> this root transv))) sv-1692)))) + ) + ) + ((< sv-1688 8192.0) + (return 2) + ) + ((and (not sv-1696) (< (seconds 0.05) (- (current-time) (-> this birth-time)))) + (return 2) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s1-1 *target*) + (s2-1 (if (type? s1-1 process-focusable) + s1-1 + ) + ) + ) + (when (and s2-1 (< (vector-vector-distance (get-trans s2-1 0) s4-0) (-> s4-0 w))) + (when (and (!= s3-0 s2-1) + (not (focus-test? s2-1 disable dead inactive gun-no-target)) + (nonzero? (-> s2-1 control root-prim prim-core collide-with)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s2-1 mask)) + (and (logtest? (process-mask guard) (-> s2-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (set! sv-1744 (vector-! (new 'stack-no-clear 'vector) (get-trans s2-1 3) (-> this root trans))) + (set! sv-1748 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this root transv) 1.0)) + (set! sv-1752 (the-as float 0.0)) + (set! sv-1756 (the-as float 0.0)) + (set! sv-1760 (time-elapsed? (-> this birth-time) (seconds 0.05))) + (set! sv-1752 (vector-normalize-ret-len! sv-1744 1.0)) + (set! sv-1756 (vector-dot sv-1744 sv-1748)) + (when (< sv-1752 (-> s4-0 w)) + (cond + ((and (< 0.0 sv-1756) sv-1760) + (set! gp-0 #t) + (set! (-> this explode-delay-time) + (the-as time-frame (min 150 (the int (* 300.0 (/ sv-1752 (vector-length (-> this root transv))) sv-1756)))) + ) + ) + ((< sv-1752 8192.0) + (return 2) + ) + ((and (not sv-1760) (< (seconds 0.05) (- (current-time) (-> this birth-time)))) + (return 2) + ) + ) + ) + ) + ) + ) + ) + ) + (if gp-0 + (return 1) + (return 0) + ) + ) + (the-as int 0) + ) + ) + +;; definition for method 25 of type gun-red-3-grenade +(defmethod projectile-method-25 ((this gun-red-3-grenade)) + (spawn (-> this part) (-> this root trans)) + (if (logtest? (-> this root status) (collide-status touch-surface)) + (sound-play "red3-bounce") + ) + (call-parent-method this) + (none) + ) + +;; definition for method 42 of type gun-red-3-grenade +(defmethod projectile-bounce-method-42 ((this gun-red-3-grenade)) + (spawn (-> this part) (-> this root trans)) + (call-parent-method this) + (none) + ) + +;; definition of type shockwave-collision-pt +(deftype shockwave-collision-pt (structure) + ((collision-pt vector :inline) + (normal vector :inline) + (found? symbol) + (angle degrees) + ) + ) + +;; definition for method 3 of type shockwave-collision-pt +(defmethod inspect ((this shockwave-collision-pt)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'shockwave-collision-pt) + (format #t "~1Tcollision-pt: #~%" (-> this collision-pt)) + (format #t "~1Tnormal: #~%" (-> this normal)) + (format #t "~1Tfound?: ~A~%" (-> this found?)) + (format #t "~1Tangle: ~f~%" (-> this angle)) + (label cfg-4) + this + ) + +;; definition of type gun-red-2-shockwave +(deftype gun-red-2-shockwave (process) + ((origin vector :inline) + (max-radius float) + (strength float) + (current-radius float) + (current-intensity float) + (state-time time-frame) + (alpha-scalar float) + (base-damage float) + (snd-charge sound-id) + (min-charge-radius float) + (max-charge-radius float) + (total-charge-time time-frame) + (total-explode-time time-frame) + (ring-expansion-time time-frame) + (burst-expansion-time time-frame) + (warp-expansion-time time-frame) + (previously-attacked-targets handle 64) + (num-previously-attacked-targets int8) + (start-pilot? symbol) + (explosion-0 handle) + (explosion-1 handle) + (generate-order-array uint8 127) + (current-stage-t float) + (ammo-drained float) + (eventual-collision-points shockwave-collision-pt 128 :inline) + (next-computed-collision-point int8) + (num-collision-pts-to-generate int8) + (show-scorch-marks? symbol) + (height-off-ground float) + (max-ground-radius float) + (current-ring-radius float) + (current-ring-alpha float) + (current-warp-radius float) + (current-warp-alpha float) + (current-burst-radius float) + (current-burst-alpha float) + (generating-marks? symbol) + (generated-particles? symbol) + (charge-part-tracker handle) + ) + (:state-methods + charging + explode + die + ) + (:methods + (find-targets-and-attack! (_type_) none) + (send-attack! (_type_ process-focusable symbol) none) + (find-collision-point! (_type_) int) + (generate-collision-points! (_type_) none) + (adjust-height-and-radius (_type_) none) + (gun-red-2-shockwave-method-22 (_type_ int int int int) none) + (generate-shockwave-particles (_type_) none) + (adjust-warp-radius-and-alpha (_type_) object) + (adjust-ring-radius-and-alpha (_type_) none) + (generate-order-array (_type_) none) + (spawn-ring (_type_) none) + ) + ) + +;; definition for method 3 of type gun-red-2-shockwave +(defmethod inspect ((this gun-red-2-shockwave)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Torigin: #~%" (-> this origin)) + (format #t "~2Tmax-radius: ~f~%" (-> this max-radius)) + (format #t "~2Tstrength: ~f~%" (-> this strength)) + (format #t "~2Tcurrent-radius: ~f~%" (-> this current-radius)) + (format #t "~2Tcurrent-intensity: ~f~%" (-> this current-intensity)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (format #t "~2Talpha-scalar: ~f~%" (-> this alpha-scalar)) + (format #t "~2Tbase-damage: ~f~%" (-> this base-damage)) + (format #t "~2Tsnd-charge: ~D~%" (-> this snd-charge)) + (format #t "~2Tmin-charge-radius: ~f~%" (-> this min-charge-radius)) + (format #t "~2Tmax-charge-radius: ~f~%" (-> this max-charge-radius)) + (format #t "~2Ttotal-charge-time: ~D~%" (-> this total-charge-time)) + (format #t "~2Ttotal-explode-time: ~D~%" (-> this total-explode-time)) + (format #t "~2Tring-expansion-time: ~D~%" (-> this ring-expansion-time)) + (format #t "~2Tburst-expansion-time: ~D~%" (-> this burst-expansion-time)) + (format #t "~2Twarp-expansion-time: ~D~%" (-> this warp-expansion-time)) + (format #t "~2Tpreviously-attacked-targets[64] @ #x~X~%" (-> this previously-attacked-targets)) + (format #t "~2Tnum-previously-attacked-targets: ~D~%" (-> this num-previously-attacked-targets)) + (format #t "~2Tstart-pilot?: ~A~%" (-> this start-pilot?)) + (format #t "~2Texplosion-0: ~D~%" (-> this explosion-0)) + (format #t "~2Texplosion-1: ~D~%" (-> this explosion-1)) + (format #t "~2Tgenerate-order-array[127] @ #x~X~%" (-> this generate-order-array)) + (format #t "~2Tcurrent-stage-t: ~f~%" (-> this current-stage-t)) + (format #t "~2Tammo-drained: ~f~%" (-> this ammo-drained)) + (format #t "~2Teventual-collision-points[128] @ #x~X~%" (-> this eventual-collision-points)) + (format #t "~2Tnext-computed-collision-point: ~D~%" (-> this next-computed-collision-point)) + (format #t "~2Tnum-collision-pts-to-generate: ~D~%" (-> this num-collision-pts-to-generate)) + (format #t "~2Tshow-scorch-marks?: ~A~%" (-> this show-scorch-marks?)) + (format #t "~2Theight-off-ground: ~f~%" (-> this height-off-ground)) + (format #t "~2Tmax-ground-radius: ~f~%" (-> this max-ground-radius)) + (format #t "~2Tcurrent-ring-radius: ~f~%" (-> this current-ring-radius)) + (format #t "~2Tcurrent-ring-alpha: ~f~%" (-> this current-ring-alpha)) + (format #t "~2Tcurrent-warp-radius: ~f~%" (-> this current-warp-radius)) + (format #t "~2Tcurrent-warp-alpha: ~f~%" (-> this current-warp-alpha)) + (format #t "~2Tcurrent-burst-radius: ~f~%" (-> this current-burst-radius)) + (format #t "~2Tcurrent-burst-alpha: ~f~%" (-> this current-burst-alpha)) + (format #t "~2Tgenerating-marks?: ~A~%" (-> this generating-marks?)) + (format #t "~2Tgenerated-particles?: ~A~%" (-> this generated-particles?)) + (format #t "~2Tcharge-part-tracker: ~D~%" (-> this charge-part-tracker)) + (label cfg-4) + this + ) + +;; definition of type gun-red-2-shockwave-init-params +(deftype gun-red-2-shockwave-init-params (structure) + ((pos vector :inline) + (max-radius float) + (strength float) + ) + ) + +;; definition for method 3 of type gun-red-2-shockwave-init-params +(defmethod inspect ((this gun-red-2-shockwave-init-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gun-red-2-shockwave-init-params) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tmax-radius: ~f~%" (-> this max-radius)) + (format #t "~1Tstrength: ~f~%" (-> this strength)) + (label cfg-4) + this + ) + +;; definition for function part-tracker-move-to-target-gun +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defun part-tracker-move-to-target-gun ((arg0 part-tracker)) + (when *target* + (set! (-> arg0 root trans quad) (-> *target* gun fire-point quad)) + (set! (-> arg0 root trans y) (+ 6553.6 (-> *target* control trans y))) + ) + (none) + ) + +;; definition for function gun-red-2-shockwave-init-by-other +;; INFO: Used lq/sq +(defbehavior gun-red-2-shockwave-init-by-other gun-red-2-shockwave ((arg0 gun-red-2-shockwave-init-params)) + (set! (-> self current-intensity) 0.0) + (set! (-> self current-radius) 0.0) + (set! (-> self current-warp-radius) 0.0) + (set! (-> self current-burst-radius) 0.0) + (set! (-> self height-off-ground) 0.0) + (set! (-> self current-ring-radius) 0.0) + (set! (-> self current-ring-alpha) 0.0) + (set! (-> self total-explode-time) (seconds 0.7)) + (set! (-> self min-charge-radius) 12288.0) + (set! (-> self max-charge-radius) 73728.0) + (set! (-> self total-charge-time) (seconds 1)) + (set! (-> self base-damage) 5.0) + (set! (-> self ring-expansion-time) (seconds 0.35)) + (set! (-> self burst-expansion-time) (seconds 0.3)) + (set! (-> self warp-expansion-time) (seconds 0.4)) + (set! (-> self explosion-0) (the-as handle #f)) + (set! (-> self explosion-1) (the-as handle #f)) + (set! (-> self ammo-drained) 0.0) + (set! (-> self snd-charge) (new-sound-id)) + (set! (-> self num-previously-attacked-targets) 0) + (set! (-> self start-pilot?) (the-as symbol (and *target* (focus-test? *target* pilot)))) + (set! (-> self charge-part-tracker) + (ppointer->handle (cond + ((logtest? (-> *part-group-id-table* 109 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self origin quad)) + (part-tracker-spawn + part-tracker-subsampler + :to *entity-pool* + :group (-> *part-group-id-table* 109) + :callback (the-as (function part-tracker vector) part-tracker-move-to-target-gun) + ) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self origin quad)) + (part-tracker-spawn + part-tracker + :to *entity-pool* + :group (-> *part-group-id-table* 109) + :callback (the-as (function part-tracker vector) part-tracker-move-to-target-gun) + ) + ) + ) + ) + ) + (send-event (handle->process (-> self charge-part-tracker)) 'clock self) + (dotimes (v1-49 64) + (set! (-> self eventual-collision-points v1-49 found?) #f) + ) + (set! (-> self next-computed-collision-point) 0) + (set! (-> self show-scorch-marks?) #f) + (set! (-> self generating-marks?) #f) + (set! (-> self generated-particles?) #f) + (go-virtual charging) + ) + +;; definition for method 17 of type gun-red-2-shockwave +;; INFO: Used lq/sq +(defmethod find-targets-and-attack! ((this gun-red-2-shockwave)) + (local-vars + (sv-32 bounding-box) + (sv-2672 (function vector vector float)) + (sv-2688 vector) + (sv-2704 vector) + (sv-2720 collide-query) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! sv-32 (the-as bounding-box (new 'stack-no-clear 'vector))) + (set! (-> sv-32 min quad) (-> this origin quad)) + (set! (-> sv-32 min w) (-> this current-radius)) + (let ((s5-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s4-0 (fill-actor-list-for-box *actor-hash* sv-32 s5-0 384)) + (let* ((s3-0 (-> s5-0 s4-0)) + (v1-6 (if (type? s3-0 collide-shape) + s3-0 + ) + ) + ) + (when v1-6 + (let* ((s2-0 (-> v1-6 process)) + (s3-1 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (when s3-1 + (when (and (!= *target* s3-1) + (not (focus-test? (the-as process-focusable s3-1) disable dead inactive)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s2-1 #f)) + (let ((s1-0 (process->handle s3-1))) + (dotimes (v1-18 (-> this num-previously-attacked-targets)) + (when (= (-> this previously-attacked-targets v1-18) s1-0) + (set! s2-1 #t) + 0 + (goto cfg-29) + ) + ) + (label cfg-29) + (when (not s2-1) + (let ((s0-0 #f)) + (set! sv-2672 vector-vector-xz-distance-squared) + (set! sv-2688 (-> this origin)) + (let* ((a1-4 (get-trans (the-as process-focusable s3-1) 3)) + (f0-1 (sv-2672 sv-2688 a1-4)) + (f1-0 24576.0) + ) + (cond + ((< f0-1 (* f1-0 f1-0)) + (set! s0-0 #t) + ) + (else + (set! sv-2720 (new 'stack-no-clear 'collide-query)) + (set! (-> sv-2720 start-pos quad) (-> this origin quad)) + (set! sv-2704 (-> sv-2720 move-dist)) + (let ((v1-35 (get-trans (the-as process-focusable s3-1) 3)) + (a0-26 (-> this origin)) + ) + (.lvf vf4 (&-> v1-35 quad)) + (.lvf vf5 (&-> a0-26 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-2704 quad) vf6) + (let ((v1-37 sv-2720)) + (set! (-> v1-37 radius) 40.96) + (set! (-> v1-37 collide-with) (collide-spec backgnd)) + (set! (-> v1-37 ignore-process0) #f) + (set! (-> v1-37 ignore-process1) #f) + (set! (-> v1-37 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-37 action-mask) (collide-action solid)) + ) + (if (= (fill-and-probe-using-line-sphere *collide-cache* sv-2720) -100000000.0) + (set! s0-0 #t) + ) + ) + ) + ) + (when s0-0 + (send-attack! this (the-as process-focusable s3-1) #t) + (set! (-> this previously-attacked-targets (-> this num-previously-attacked-targets)) (the-as handle s1-0)) + (+! (-> this num-previously-attacked-targets) 1) + ) + ) + ) + ) + (if (and s2-1 (logtest? (process-mask vehicle) (-> s3-1 mask))) + (send-attack! this (the-as process-focusable s3-1) #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s4-1 *target*) + (s5-1 (if (type? s4-1 process-focusable) + s4-1 + ) + ) + ) + (when (and s5-1 (< (vector-vector-distance (get-trans s5-1 0) (the-as vector sv-32)) (-> sv-32 min w))) + (when (and (!= *target* s5-1) + (not (focus-test? s5-1 disable dead inactive)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s5-1 mask)) + (and (logtest? (process-mask guard) (-> s5-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s4-3 #f)) + (let ((s3-2 (process->handle s5-1))) + (dotimes (v1-68 (-> this num-previously-attacked-targets)) + (when (= (-> this previously-attacked-targets v1-68) s3-2) + (set! s4-3 #t) + 0 + (goto cfg-71) + ) + ) + (label cfg-71) + (when (not s4-3) + (let ((s2-2 #f)) + (let ((f0-5 (vector-vector-xz-distance-squared (-> this origin) (get-trans s5-1 3))) + (f1-5 24576.0) + ) + (cond + ((< f0-5 (* f1-5 f1-5)) + (set! s2-2 #t) + ) + (else + (let ((s1-2 (new 'stack-no-clear 'collide-query))) + (set! (-> s1-2 start-pos quad) (-> this origin quad)) + (vector-! (-> s1-2 move-dist) (get-trans s5-1 3) (-> this origin)) + (let ((v1-80 s1-2)) + (set! (-> v1-80 radius) 40.96) + (set! (-> v1-80 collide-with) (collide-spec backgnd)) + (set! (-> v1-80 ignore-process0) #f) + (set! (-> v1-80 ignore-process1) #f) + (set! (-> v1-80 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-80 action-mask) (collide-action solid)) + ) + (if (= (fill-and-probe-using-line-sphere *collide-cache* s1-2) -100000000.0) + (set! s2-2 #t) + ) + ) + ) + ) + ) + (when s2-2 + (send-attack! this s5-1 #t) + (set! (-> this previously-attacked-targets (-> this num-previously-attacked-targets)) (the-as handle s3-2)) + (+! (-> this num-previously-attacked-targets) 1) + ) + ) + ) + ) + (if (and s4-3 (logtest? (process-mask vehicle) (-> s5-1 mask))) + (send-attack! this s5-1 #f) + ) + ) + ) + ) + ) + (none) + ) + ) + +;; definition for method 18 of type gun-red-2-shockwave +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod send-attack! ((this gun-red-2-shockwave) (arg0 process-focusable) (arg1 symbol)) + (let* ((a0-2 (get-trans arg0 3)) + (v1-2 (vector-! (new 'stack-no-clear 'vector) a0-2 (-> this origin))) + ) + 0.0 + (set! (-> v1-2 y) 0.0) + (let* ((f0-3 (* (-> this base-damage) (-> this current-intensity))) + (f0-4 (fmax 1.0 f0-3)) + (a0-4 'eco-red) + ) + (if (not arg1) + (set! a0-4 'eco-red-shove) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (send-event arg0 'attack #f (static-attack-info + :mask (vehicle-impulse-factor) + ((id (new-attack-id)) + (damage f0-4) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode a0-4) + (attacker-velocity v1-2) + (control (-> this current-intensity)) + (penetrate-using (penetrate jak-red-shot jak-red-shockwave)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate charging (gun-red-2-shockwave) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 float)) + (case message + (('charge) + (return (the-as object (-> self strength))) + v0-0 + ) + ) + ) + :enter (behavior () + (set-time! (-> self state-time)) + (set! (-> self ammo-drained) 0.0) + ) + :exit (behavior () + (send-event (ppointer->process (-> self parent)) 'release) + (send-event (handle->process (-> self charge-part-tracker)) 'die) + (sound-stop (-> self snd-charge)) + ) + :trans (behavior () + (let ((t9-0 vector<-cspace!) + (a0-0 (-> self origin)) + (v1-0 (-> self parent)) + ) + (t9-0 a0-0 (-> (the-as process-drawable (if v1-0 + (the-as process-drawable (-> v1-0 0 self)) + ) + ) + node-list + data + 13 + ) + ) + ) + (sound-play "red2-charge" :id (-> self snd-charge) :position (-> self origin)) + (let ((f0-0 (get-remaining-player-ammo (pickup-type ammo-red)))) + (if (< 0.0 f0-0) + (set! (-> self strength) + (fmin 1.0 (/ (the float (- (current-time) (-> self state-time))) (the float (-> self total-charge-time)))) + ) + ) + ) + (let ((f30-0 (cond + ((time-elapsed? (-> self state-time) (seconds 1)) + 5.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.75)) + 4.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.5)) + 3.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.25)) + 2.0 + ) + ((time-elapsed? (-> self state-time) (seconds 0.1)) + 1.0 + ) + (else + 0.0 + ) + ) + ) + ) + (when (< (-> self ammo-drained) f30-0) + (let ((f0-5 (- f30-0 (-> self ammo-drained)))) + (adjust-player-ammo (- f0-5) (pickup-type ammo-red)) + ) + (set! (-> self ammo-drained) f30-0) + ) + ) + (set! (-> *part-id-table* 372 init-specs 2 initial-valuef) (lerp 3276.8 8192.0 (-> self strength))) + (set! (-> *part-id-table* 373 init-specs 2 initial-valuef) (lerp 8192.0 14336.0 (-> self strength))) + (if (and (time-elapsed? (-> self state-time) (seconds 0.1)) + (or (not (cpad-hold? 0 r1)) + (and *target* + (focus-test? *target* dead grabbed under-water pole flut board mech dark carry indax teleporting) + ) + (and *target* (not (logtest? (focus-status in-head gun) (-> *target* focus-status)))) + (and *target* (!= (-> self start-pilot?) (focus-test? *target* pilot))) + (not (-> *setting-control* user-current gun)) + ) + ) + (go-virtual explode) + ) + ) + :code sleep-code + :post (behavior () + (set! (-> *last-player-pos* x) (-> *target* gun fire-point x)) + (set! (-> *last-player-pos* y) (+ 6553.6 (-> *target* control trans y))) + (set! (-> *last-player-pos* z) (-> *target* gun fire-point z)) + ) + ) + +;; definition for function generate-shockwave-scorch-marks-3 +;; WARN: Return type mismatch object vs none. +(defbehavior generate-shockwave-scorch-marks-3 gun-red-2-shockwave ((arg0 int)) + (let ((s4-0 (-> self eventual-collision-points arg0)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s5-0 x) 0.0) + (set! (-> s5-0 y) 409.6) + (set! (-> s5-0 z) 0.0) + (set! (-> s5-0 w) 1.0) + (when (-> s4-0 found?) + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (let ((s3-1 (vector-! (new 'stack-no-clear 'vector) (-> s4-0 collision-pt) (-> self origin)))) + (set! (-> s3-1 y) 0.0) + (vector-normalize! s3-1 1.0) + (matrix-u-f-compose gp-0 (-> s4-0 normal) s3-1) + ) + (vector+! (-> gp-0 trans) (-> s4-0 collision-pt) s5-0) + (let ((v1-14 + (if (logtest? (-> *part-group-id-table* 89 flags) (sp-group-flag sp13)) + (part-tracker-spawn + part-tracker-subsampler + :to *entity-pool* + :group (-> *part-group-id-table* 89) + :mat-joint gp-0 + ) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 89) :mat-joint gp-0) + ) + ) + ) + (send-event (ppointer->process v1-14) 'clock self) + ) + ) + ) + ) + (none) + ) + +;; definition for function generate-shockwave-scorch-marks-2 +;; WARN: Return type mismatch symbol vs none. +(defbehavior generate-shockwave-scorch-marks-2 gun-red-2-shockwave () + (set! (-> self show-scorch-marks?) #t) + (set! (-> self generating-marks?) #t) + (let ((gp-0 0)) + (dotimes (s5-0 (-> self num-collision-pts-to-generate)) + (when (< 30 gp-0) + (set! gp-0 0) + (suspend) + 0 + ) + (+! gp-0 1) + (generate-shockwave-scorch-marks-3 s5-0) + ) + ) + (set! (-> self generating-marks?) #f) + (none) + ) + +;; failed to figure out what this is: +(defstate die (gun-red-2-shockwave) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :code (behavior () + (when (not (-> self show-scorch-marks?)) + (generate-collision-points! self) + (generate-shockwave-scorch-marks-2) + ) + ) + ) + +;; definition of type gun-red-2-explosion +(deftype gun-red-2-explosion (process-drawable) + () + (:methods + (gun-red-2-explosion-method-20 (_type_) none) + ) + ) + +;; definition for method 3 of type gun-red-2-explosion +(defmethod inspect ((this gun-red-2-explosion)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (label cfg-4) + this + ) + +;; definition for method 22 of type gun-red-2-shockwave +(defmethod gun-red-2-shockwave-method-22 ((this gun-red-2-shockwave) (arg0 int) (arg1 int) (arg2 int) (arg3 int)) + (when (< 1 (- arg1 arg0)) + (let ((s2-0 (/ (+ arg0 arg1) 2))) + (let ((a0-4 (+ arg3 -1 (ash 1 arg2)))) + (set! (-> this generate-order-array a0-4) (the-as uint (+ s2-0 -1))) + ) + (gun-red-2-shockwave-method-22 this arg0 s2-0 (+ arg2 1) (* arg3 2)) + (gun-red-2-shockwave-method-22 this s2-0 arg1 (+ arg2 1) (+ (* arg3 2) 1)) + ) + ) + (none) + ) + +;; definition for method 19 of type gun-red-2-shockwave +;; INFO: Used lq/sq +;; WARN: Stack slot offset 564 signed mismatch +;; WARN: Stack slot offset 564 signed mismatch +;; WARN: Stack slot offset 564 signed mismatch +(defmethod find-collision-point! ((this gun-red-2-shockwave)) + (local-vars (sv-560 collide-query) (sv-564 int) (sv-608 vector) (sv-612 vector) (sv-616 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (if (>= (-> this next-computed-collision-point) (-> this num-collision-pts-to-generate)) + (return 0) + ) + (set! sv-560 (new 'stack-no-clear 'collide-query)) + (set! sv-564 (-> this num-collision-pts-to-generate)) + (set! sv-608 (new 'stack-no-clear 'vector)) + (set! sv-612 (new 'stack-no-clear 'vector)) + (set! sv-616 (/ 65536.0 (the float (+ sv-564 -1)))) + (let ((f30-1 + (+ (* sv-616 (the float (-> this generate-order-array (-> this next-computed-collision-point)))) + (rand-vu-float-range (* -0.43478262 sv-616) (* 0.43478262 sv-616)) + ) + ) + ) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) angle) f30-1) + (set-vector! + sv-608 + (* (rand-vu-float-range 0.7 0.9) (-> this max-ground-radius) (cos f30-1)) + 32768.0 + (* (rand-vu-float-range 0.7 0.9) (-> this max-ground-radius) (sin f30-1)) + 1.0 + ) + ) + (vector+! (-> sv-560 start-pos) (-> this origin) sv-608) + (set! (-> sv-560 start-pos y) (- (-> sv-560 start-pos y) (-> this height-off-ground))) + (+! (-> sv-560 start-pos y) 20480.0) + (set-vector! (-> sv-560 move-dist) 0.0 -65536.0 0.0 1.0) + (let ((v1-29 sv-560)) + (set! (-> v1-29 radius) 40.96) + (set! (-> v1-29 collide-with) (collide-spec backgnd hit-by-others-list pusher impenetrable-obj)) + (set! (-> v1-29 ignore-process0) #f) + (set! (-> v1-29 ignore-process1) #f) + (set! (-> v1-29 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-29 action-mask) (collide-action solid)) + ) + (let ((f0-25 (fill-and-probe-using-line-sphere *collide-cache* sv-560))) + (when (>= f0-25 0.0) + (let ((v1-33 sv-612)) + (let ((a0-17 (-> sv-560 start-pos))) + (let ((a1-7 (-> sv-560 move-dist))) + (let ((a2-0 f0-25)) + (.mov vf7 a2-0) + ) + (.lvf vf5 (&-> a1-7 quad)) + ) + (.lvf vf4 (&-> a0-17 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> v1-33 quad) vf6) + ) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) collision-pt quad) + (-> sv-612 quad) + ) + (+! (-> this eventual-collision-points (-> this next-computed-collision-point) collision-pt y) 204.8) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) found?) #t) + (set! (-> (the-as + (pointer uint128) + (+ (the-as uint (-> this eventual-collision-points 0 normal)) (* 48 (-> this next-computed-collision-point))) + ) + ) + (-> sv-560 best-other-tri normal quad) + ) + (let ((s5-1 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-1 (vector-float*! (new 'stack-no-clear 'vector) (-> sv-560 best-other-tri normal) 3072.0)) + ) + (let ((s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> sv-560 best-other-tri normal) 1.0)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (vector-get-unique! s1-0 s2-0) + (vector-cross! s5-1 s2-0 s1-0) + ) + (vector-normalize! s5-1 1.0) + (dotimes (s2-1 4) + (vector-rotate-around-axis! + s4-0 + (the-as quaternion s5-1) + (* 16384.0 (the float s2-1)) + (-> sv-560 best-other-tri normal) + ) + (vector-normalize! s4-0 10240.0) + (vector+! s4-0 s4-0 s3-1) + (vector+! (-> sv-560 start-pos) sv-612 s4-0) + (vector-float*! (-> sv-560 move-dist) (-> sv-560 best-other-tri normal) -6144.0) + (let ((v1-59 sv-560)) + (set! (-> v1-59 radius) 40.96) + (set! (-> v1-59 collide-with) (collide-spec backgnd hit-by-others-list pusher impenetrable-obj)) + (set! (-> v1-59 ignore-process0) #f) + (set! (-> v1-59 ignore-process1) #f) + (set! (-> v1-59 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-59 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* sv-560) 0.0) + (set! (-> this eventual-collision-points (-> this next-computed-collision-point) found?) #f) + 0 + (goto cfg-11) + ) + ) + ) + ) + ) + (label cfg-11) + (let ((v0-0 (+ (-> this next-computed-collision-point) 1))) + (set! (-> this next-computed-collision-point) v0-0) + v0-0 + ) + ) + ) + +;; definition for method 20 of type gun-red-2-shockwave +;; WARN: Return type mismatch symbol vs none. +(defmethod generate-collision-points! ((this gun-red-2-shockwave)) + (while (< (-> this next-computed-collision-point) (-> this num-collision-pts-to-generate)) + (find-collision-point! this) + ) + (none) + ) + +;; definition for method 21 of type gun-red-2-shockwave +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defmethod adjust-height-and-radius ((this gun-red-2-shockwave)) + (let ((a1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> a1-0 start-pos quad) (-> this origin quad)) + (set-vector! (-> a1-0 move-dist) 0.0 (* -1.0 (-> this max-radius)) 0.0 1.0) + (let ((v1-2 a1-0)) + (set! (-> v1-2 radius) 40.96) + (set! (-> v1-2 collide-with) (collide-spec backgnd hit-by-others-list pusher impenetrable-obj)) + (set! (-> v1-2 ignore-process0) #f) + (set! (-> v1-2 ignore-process1) #f) + (set! (-> v1-2 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-2 action-mask) (collide-action solid)) + ) + (let ((f0-6 (fill-and-probe-using-line-sphere *collide-cache* a1-0))) + (if (>= f0-6 0.0) + (set! (-> this height-off-ground) (* f0-6 (-> this max-radius))) + (set! (-> this height-off-ground) (-> this max-radius)) + ) + ) + ) + (set! (-> this max-ground-radius) (-> this max-radius)) + (none) + ) + +;; failed to figure out what this is: +(defskelgroup skel-gun-red-sphere gun gun-red-sphere-lod0-jg gun-red-sphere-idle-ja + ((gun-red-sphere-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 30) + :texture-level 10 + :light-index 4 + ) + +;; definition of type red-2-ring +(deftype red-2-ring (process-drawable) + ((current-alpha float) + (pad uint8 12) + ) + (:state-methods + active + fading + ) + (:methods + (red-2-ring-method-22 () none) + ) + ) + +;; definition for method 3 of type red-2-ring +(defmethod inspect ((this red-2-ring)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tcurrent-alpha: ~f~%" (-> this current-alpha)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (label cfg-4) + this + ) + +;; definition of type red-2-ring-init-params +(deftype red-2-ring-init-params (structure) + ((pos vector :inline) + ) + ) + +;; definition for method 3 of type red-2-ring-init-params +(defmethod inspect ((this red-2-ring-init-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'red-2-ring-init-params) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition for function red-2-ring-event-handler +;; INFO: Used lq/sq +(defbehavior red-2-ring-event-handler red-2-ring ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('scale) + (let ((v1-1 (the-as object (-> arg3 param 0))) + (v0-0 (the-as object (-> self root scale))) + ) + (set! (-> (the-as vector v0-0) quad) (-> (the-as vector v1-1) quad)) + v0-0 + ) + ) + (('alpha) + (set! (-> self current-alpha) (the-as float (-> arg3 param 0))) + ) + (('start-fade) + (if (not (and (-> self next-state) (= (-> self next-state name) 'fading))) + (go-virtual fading) + ) + ) + ) + ) + +;; definition for function red-2-ring-init-by-other +;; INFO: Used lq/sq +(defbehavior red-2-ring-init-by-other red-2-ring ((arg0 red-2-ring-init-params)) + (set! (-> self root) (new 'process 'trsqv)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-generic-blast" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self root trans quad) (-> arg0 pos quad)) + (quaternion-identity! (-> self root quat)) + (go-virtual active) + ) + +;; failed to figure out what this is: +(defstate active (red-2-ring) + :virtual #t + :event red-2-ring-event-handler + :enter (behavior () + (set-time! (-> self state-time)) + (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) + ) + :trans (behavior () + '() + ) + :code (behavior () + (ja-channel-push! 1 0) + (ja :group! (-> self draw art-group data 13) :num! zero) + (let ((gp-0 (ja-num-frames 0))) + (until #f + (ja :group! (-> self draw art-group data 13) + :num! (identity (lerp (the float gp-0) 0.0 (-> self current-alpha))) + ) + (suspend) + ) + ) + #f + ) + :post (behavior () + (ja-post) + ) + ) + +;; definition for method 23 of type gun-red-2-shockwave +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defmethod generate-shockwave-particles ((this gun-red-2-shockwave)) + (local-vars (sv-160 int) (sv-176 shockwave-collision-pt)) + (when (and (not (-> this generated-particles?)) (time-elapsed? (-> this state-time) (seconds 0.067))) + (set! (-> this generated-particles?) #t) + (dotimes (s5-0 150) + (let ((f26-0 (* 436.90668 (the float s5-0))) + (s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s4-0 quad) (-> this origin quad)) + (set-vector! s3-0 (cos f26-0) 0.0 (sin f26-0) 1.0) + (vector-normalize! s3-0 (* 0.9 (-> this max-ground-radius))) + (let ((f30-0 (-> this origin y)) + (f24-0 -32768.0) + (f28-0 (-> this origin y)) + (f22-0 32768.0) + ) + 0.0 + (let ((s0-0 0) + (s2-1 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-160 0) + (while (< sv-160 (-> this next-computed-collision-point)) + (set! sv-176 (-> this eventual-collision-points sv-160)) + (when (-> sv-176 found?) + (let ((f0-9 (deg- (-> sv-176 angle) f26-0))) + (cond + ((and (< f0-9 0.0) (< f24-0 f0-9)) + (set! f24-0 f0-9) + (set! f30-0 (-> sv-176 collision-pt y)) + (set! s0-0 (logior s0-0 1)) + (set! (-> s2-1 quad) (-> sv-176 normal quad)) + ) + ((and (>= f0-9 0.0) (< f0-9 f22-0)) + (set! f22-0 f0-9) + (set! f28-0 (-> sv-176 collision-pt y)) + (set! s0-0 (logior s0-0 2)) + (set! (-> s1-0 quad) (-> sv-176 normal quad)) + ) + ) + ) + ) + (set! sv-160 (+ sv-160 1)) + ) + (let ((f26-1 0.0)) + (cond + ((= s0-0 3) + (set! f26-1 (/ (* -1.0 f24-0) (- f22-0 f24-0))) + ) + ((= s0-0 2) + (set! f26-1 1.0) + ) + ((= s0-0 1) + (set! f26-1 0.0) + ) + ) + (when #t + (let ((f0-12 (lerp f30-0 f28-0 f26-1))) + (set! (-> s4-0 y) (- (-> s4-0 y) (-> this height-off-ground))) + (set! (-> s3-0 y) (- f0-12 (-> s4-0 y))) + ) + (let ((s2-2 (vector-lerp! (new 'stack-no-clear 'vector) s2-1 s1-0 f26-1))) + (vector-normalize! s2-2 2048.0) + (vector+! s3-0 s3-0 s2-2) + ) + (vector-normalize! s3-0 1.0) + (let ((s2-3 (new 'stack-no-clear 'matrix))) + (matrix-f-u-compose s2-3 s3-0 *up-vector*) + (set! (-> s2-3 trans quad) (-> s4-0 quad)) + (launch-particles (-> *part-id-table* 353) s2-3 :origin-is-matrix #t) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 24 of type gun-red-2-shockwave +(defmethod adjust-warp-radius-and-alpha ((this gun-red-2-shockwave)) + (let* ((f0-1 (/ (-> this max-radius) (-> this max-charge-radius))) + (f0-3 + (/ (the float (- (current-time) (-> this state-time))) (* f0-1 (the float (-> this warp-expansion-time)))) + ) + (f0-4 (* f0-3 f0-3)) + ) + (set! (-> this current-warp-radius) (lerp (-> this min-charge-radius) (-> this max-radius) f0-4)) + ) + (let ((f0-7 (/ (-> this current-warp-radius) (-> this max-radius)))) + (if (< 1.0 f0-7) + (set! (-> this current-warp-alpha) (fmax 0.0 (- 2.0 f0-7))) + ) + ) + (let ((v1-8 (new 'stack-no-clear 'vector))) + (set! (-> v1-8 x) (* 0.00024414062 (-> this current-warp-radius))) + (set! (-> v1-8 y) 1.0) + (set! (-> v1-8 z) (* 0.00024414062 (-> this current-warp-radius))) + (set! (-> v1-8 w) 1.0) + (send-event (handle->process (-> this explosion-1)) 'scale v1-8) + ) + (send-event (handle->process (-> this explosion-1)) 'alpha (-> this current-warp-alpha)) + ) + +;; definition for method 25 of type gun-red-2-shockwave +;; WARN: Return type mismatch float vs none. +(defmethod adjust-ring-radius-and-alpha ((this gun-red-2-shockwave)) + (let ((f0-2 (/ (the float (- (current-time) (-> this state-time))) (the float (-> this ring-expansion-time))))) + (set! (-> this current-ring-radius) (lerp (-> this min-charge-radius) (-> this max-charge-radius) f0-2)) + ) + (let ((f0-5 (/ (-> this current-ring-radius) (-> this max-radius)))) + (if (< 1.0 f0-5) + (set! (-> this current-ring-alpha) (fmax 0.0 (- 1.7 f0-5))) + ) + ) + (none) + ) + +;; definition for method 26 of type gun-red-2-shockwave +;; WARN: Return type mismatch symbol vs none. +(defmethod generate-order-array ((this gun-red-2-shockwave)) + (gun-red-2-shockwave-method-22 this 0 (-> this num-collision-pts-to-generate) 0 0) + (let ((a0-3 (log2 (-> this num-collision-pts-to-generate)))) + (when (< (ash 1 a0-3) (-> this num-collision-pts-to-generate)) + (let ((v1-7 (+ (ash 1 (+ (log2 (-> this num-collision-pts-to-generate)) 1)) -1)) + (a0-7 0) + ) + (dotimes (a1-1 v1-7) + (set! (-> this generate-order-array a0-7) (-> this generate-order-array a1-1)) + (if (nonzero? (-> this generate-order-array a0-7)) + (+! a0-7 1) + ) + ) + ) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(when (or (zero? *impact-blur*) (!= loading-level global)) + (set! *impact-blur* (new 'loading-level 'curve2d-piecewise)) + (curve2d-piecewise-method-10 *impact-blur* 3 'loading-level (the-as int #f)) + ) + +;; failed to figure out what this is: +(set! (-> *impact-blur* pts data 0 first) 0.0) + +;; failed to figure out what this is: +(set! (-> *impact-blur* pts data 0 second) 0.0) + +;; failed to figure out what this is: +(set! (-> *impact-blur* pts data 1 first) 0.2) + +;; failed to figure out what this is: +(set! (-> *impact-blur* pts data 1 second) 1.0) + +;; failed to figure out what this is: +(set! (-> *impact-blur* pts data 2 first) 1.0) + +;; failed to figure out what this is: +(set! (-> *impact-blur* pts data 2 second) 0.0) + +;; failed to figure out what this is: +(when (or (zero? *shockwave-blur-red-2*) (!= loading-level global)) + (set! *shockwave-blur-red-2* (new 'loading-level 'curve2d-piecewise)) + (curve2d-piecewise-method-10 *shockwave-blur-red-2* 5 'loading-level (the-as int #f)) + ) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 0 first) 0.0) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 0 second) 0.0) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 1 first) 0.7) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 1 second) 0.0) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 2 first) 0.8) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 2 second) 1.0) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 3 first) 0.9) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 3 second) 0.3) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 4 first) 1.0) + +;; failed to figure out what this is: +(set! (-> *shockwave-blur-red-2* pts data 4 second) 0.0) + +;; definition for method 27 of type gun-red-2-shockwave +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod spawn-ring ((this gun-red-2-shockwave)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (set! (-> v1-0 quad) (-> this origin quad)) + (set! (-> v1-0 y) (- (-> v1-0 y) (-> this height-off-ground))) + (+! (-> v1-0 y) 2048.0) + (+! (-> v1-0 y) -1433.6) + (let ((s5-0 (new 'stack-no-clear 'red-2-ring-init-params))) + (set! (-> s5-0 pos quad) (-> v1-0 quad)) + (let ((v1-3 (process-spawn red-2-ring s5-0 :name "red-2-ring" :to this))) + (if v1-3 + (set! (-> this explosion-1) (ppointer->handle v1-3)) + ) + ) + ) + ) + (none) + ) + +;; definition for method 10 of type gun-red-2-shockwave +(defmethod deactivate ((this gun-red-2-shockwave)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (blit-displays-work-method-17 *blit-displays-work* (-> this origin) 0 1.0 #f) + (call-parent-method this) + (none) + ) + +;; failed to figure out what this is: +(defstate explode (gun-red-2-shockwave) + :virtual #t + :enter (behavior () + (let ((f30-0 (lerp 0.3 0.8 (-> self strength))) + (a3-0 (the int (* 300.0 (lerp 0.1 0.4 (-> self strength))))) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 (the int (* 255.0 f30-0)) (the-as time-frame a3-0)) + ) + (sound-play "red2-shot") + (set-time! (-> self state-time)) + (set! (-> self max-radius) (lerp (-> self min-charge-radius) (-> self max-charge-radius) (-> self strength))) + (/ (-> self max-radius) (-> self max-charge-radius)) + (let ((f0-15 (* 0.000012207031 (-> self max-radius)))) + 0.0 + (let ((f1-5 (/ (* 2.0 (- (* 163840.0 f0-15) (-> self max-radius))) (* f0-15 f0-15)))) + (set! (-> *part-id-table* 353 init-specs 9 initial-valuef) (* 1.2 f1-5)) + ) + (let ((v1-15 (the int (* 150.0 f0-15)))) + (set! (-> *part-id-table* 354 init-specs 3 initial-valuef) (the-as float (+ v1-15 -25))) + (set! (-> *part-id-table* 354 init-specs 3 random-rangef) (the-as float (+ v1-15 -5))) + ) + ) + (adjust-height-and-radius self) + (set! (-> self current-intensity) (-> self strength)) + (spawn-ring self) + (set! (-> self num-collision-pts-to-generate) + (the int (fmax 6.0 (fmin 64.0 (* 64.0 (/ (-> self max-ground-radius) (-> self max-charge-radius)))))) + ) + (generate-order-array self) + (set! (-> self current-ring-alpha) 1.0) + (set! (-> self current-burst-alpha) 1.0) + (set! (-> self current-warp-alpha) 1.0) + ) + :exit (behavior () + (blit-displays-work-method-17 *blit-displays-work* (-> self origin) 0 1.0 #f) + ) + :trans (behavior () + (let ((f0-1 + (fmin 1.0 (/ (the float (- (current-time) (-> self state-time))) (the float (-> self total-explode-time)))) + ) + ) + (set! (-> self current-radius) + (fmin (lerp (-> self min-charge-radius) (-> self max-charge-radius) f0-1) (-> self max-radius)) + ) + ) + (set! (-> self current-stage-t) + (/ (- (-> self current-radius) (-> self min-charge-radius)) + (- (-> self max-radius) (-> self min-charge-radius)) + ) + ) + (set! (-> self current-intensity) + (cond + ((logtest? (game-secrets gun-upgrade-red-2) (-> *game-info* secrets)) + (let ((f0-8 (fmin (-> self current-stage-t) (* 1.5 (-> self current-stage-t) (-> self current-stage-t))))) + (fmax 0.3 (lerp (-> self strength) 0.0 f0-8)) + ) + ) + (else + (lerp (-> self strength) 0.0 (-> self current-stage-t)) + ) + ) + ) + (generate-shockwave-particles self) + (adjust-ring-radius-and-alpha self) + (adjust-warp-radius-and-alpha self) + (let ((f0-14 (-> self current-stage-t))) + 0.0 + (let* ((f0-16 (- 1.0 (curve2d-method-9 *impact-blur* f0-14 3))) + (f0-19 (lerp f0-16 1.0 (fmax 0.0 (- 0.5 (-> self strength))))) + ) + (blit-displays-work-method-17 *blit-displays-work* (-> self origin) 2 (fmin 1.0 f0-19) #f) + ) + ) + (if (< (-> self current-stage-t) 1.0) + (find-targets-and-attack! self) + ) + (cond + ((and (not (-> self generating-marks?)) (-> self show-scorch-marks?) (>= 0.0 (-> self current-warp-alpha))) + (go-virtual die) + ) + ((and (not (-> self show-scorch-marks?)) + (< (-> self next-computed-collision-point) (-> self num-collision-pts-to-generate)) + ) + (find-collision-point! self) + (find-collision-point! self) + (find-collision-point! self) + ) + ) + (if (and (not (-> self show-scorch-marks?)) + (time-elapsed? (-> self state-time) (the int (* 0.0036621094 (-> self max-radius)))) + ) + (set! (-> self show-scorch-marks?) #t) + ) + ) + :code (behavior () + (while (not (-> self show-scorch-marks?)) + (suspend) + ) + (generate-collision-points! self) + (generate-shockwave-scorch-marks-2) + (sleep-code) + ) + :post (behavior () + (set-vector! (new 'stack-no-clear 'vector) 1.9 0.0 0.0 (-> self alpha-scalar)) + (set! (-> *part-id-table* 229 init-specs 2 initial-valuef) (* 2.0 (-> self current-ring-radius))) + (set! (-> *part-id-table* 229 init-specs 7 initial-valuef) (* 128.0 (-> self current-ring-alpha))) + (set! (-> *part-id-table* 226 init-specs 3 initial-valuef) + (lerp 20480.0 24576.0 (/ (-> self max-radius) (-> self max-charge-radius))) + ) + (set! (-> *part-id-table* 226 init-specs 3 initial-valuef) + (* 0.5 (-> *part-id-table* 226 init-specs 3 initial-valuef)) + ) + (set! (-> *part-id-table* 226 init-specs 3 random-rangef) + (lerp 0.0 20480.0 (/ (-> self max-radius) (-> self max-charge-radius))) + ) + (launch-particles (-> *part-id-table* 229) (-> self origin)) + ) + ) + +;; definition for function gun-fire-red-2 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs object. +(defbehavior gun-fire-red-2 target () + (let ((gp-0 (-> self gun)) + (v1-1 (-> self gun fire-point)) + ) + (set! (-> *last-player-pos* x) (-> *target* gun fire-point x)) + (set! (-> *last-player-pos* y) (+ 6553.6 (-> *target* control trans y))) + (set! (-> *last-player-pos* z) (-> *target* gun fire-point z)) + (when #t + (let ((s5-0 (new 'stack-no-clear 'gun-red-2-shockwave-init-params))) + (set! (-> s5-0 pos quad) (-> v1-1 quad)) + (let ((v1-4 (process-spawn + gun-red-2-shockwave + s5-0 + :name "gun-red-2-shockwave" + :to (ppointer->process (-> gp-0 gun)) + :stack *kernel-dram-stack* + ) + ) + ) + (set! (-> gp-0 gun 0 extra) (ppointer->handle v1-4)) + (let ((v0-0 (ppointer->handle v1-4))) + (set! (-> self gun charge-active?) (the-as handle v0-0)) + v0-0 + ) + ) + ) + ) + ) + ) + +;; definition of type red-3-sphere +(deftype red-3-sphere (process-drawable) + ((current-alpha float) + (pad uint8 12) + ) + (:state-methods + active + ) + (:methods + (red-3-sphere-method-21 (_type_) none) + (red-3-sphere-method-22 (_type_) none) + ) + ) + +;; definition for method 3 of type red-3-sphere +(defmethod inspect ((this red-3-sphere)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 this) + ) + (format #t "~2Tcurrent-alpha: ~f~%" (-> this current-alpha)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (label cfg-4) + this + ) + +;; definition of type red-3-sphere-init-params +(deftype red-3-sphere-init-params (structure) + ((pos vector :inline) + ) + ) + +;; definition for method 3 of type red-3-sphere-init-params +(defmethod inspect ((this red-3-sphere-init-params)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'red-3-sphere-init-params) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition for function red-3-sphere-init-by-other +;; INFO: Used lq/sq +(defbehavior red-3-sphere-init-by-other red-3-sphere ((arg0 red-3-sphere-init-params)) + (set! (-> self root) (new 'process 'trsqv)) + (initialize-skeleton + self + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-red-sphere" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (set! (-> self root trans quad) (-> arg0 pos quad)) + (quaternion-identity! (-> self root quat)) + (go-virtual active) + ) + +;; failed to figure out what this is: +(defstate active (red-3-sphere) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (let* ((a2-0 (math-camera-matrix)) + (v1-0 (-> a2-0 rvec quad)) + (a0-0 (-> a2-0 uvec quad)) + (a1-0 (-> a2-0 fvec quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> gp-0 rvec quad) v1-0) + (set! (-> gp-0 uvec quad) a0-0) + (set! (-> gp-0 fvec quad) a1-0) + (set! (-> gp-0 trans quad) a2-1) + ) + (-> gp-0 fvec) + (-> gp-0 rvec) + (matrix->quat gp-0 (-> self root quat)) + ) + (set! (-> self current-alpha) (* 0.008333334 (the float (- (current-time) (-> self state-time))))) + (let ((f0-3 (+ (-> self root scale x) (* 24.0 (seconds-per-frame))))) + (set-vector! (-> self root scale) f0-3 f0-3 f0-3 1.0) + ) + ) + :code (behavior () + (ja-channel-push! 1 0) + (ja-no-eval :group! gun-red-sphere-burst-ja :num! (seek!) :frame-num 0.0) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + (ja-no-eval :group! gun-red-sphere-fade-ja :num! (seek! max 5.0) :frame-num 0.0) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! max 5.0)) + ) + (deactivate self) + ) + :post (behavior () + (ja-post) + ) + ) + +;; definition for function gun-fire-red-3 +;; INFO: Used lq/sq +;; WARN: Return type mismatch (pointer process) vs gun-red-3-grenade. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f2, f5] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f1, f3, f6] +(defbehavior gun-fire-red-3 target () + (local-vars + (f1-2 float) + (sv-16 gun-info) + (sv-20 vector) + (sv-24 vector) + (sv-28 float) + (sv-144 vector) + (sv-148 vector) + (sv-1952 vector) + (sv-1968 vector) + ) + (set! sv-16 (-> self gun)) + (set! sv-20 (-> self gun fire-dir-out)) + (set! sv-24 (-> self gun fire-point)) + (set! sv-28 (the-as float 266240.0)) + (draw-beam (-> *part-id-table* 217) sv-24 sv-20 #f) + (set! (-> sv-20 y) (fmax 0.3 (-> sv-20 y))) + (vector-normalize! sv-20 1.0) + (let ((v1-17 (cond + ((logtest? (-> *part-group-id-table* 86 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> sv-16 fire-point quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 86)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> sv-16 fire-point quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 86)) + ) + ) + ) + ) + (send-event (ppointer->process v1-17) 'clock self) + ) + (set! sv-144 (new 'stack-no-clear 'vector)) + (let ((v1-42 (new 'stack-no-clear 'vector))) + (set! (-> v1-42 quad) (-> sv-20 quad)) + (set! sv-148 v1-42) + ) + (set! (-> sv-148 y) 0.0) + (vector-normalize! sv-148 1.0) + (vector+float*! sv-144 sv-24 sv-148 143360.0) + (set! (-> sv-144 w) 143360.0) + (let ((f30-0 4096000.0) + (s5-0 #f) + (gp-2 (the-as process-focusable #f)) + ) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) (process->ppointer self)) + (set! (-> a1-11 num-params) 0) + (set! (-> a1-11 message) 'get-vehicle) + (let ((s4-0 (send-event-function *target* a1-11))) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-144) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-54 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-54 + (let* ((s0-0 (-> v1-54 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= *target* s1-1) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive gun-no-target)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s1-1 mask)) + (and (logtest? (process-mask guard) (-> s1-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + (!= s4-0 s1-1) + ) + (when (or (not s5-0) (logtest? (process-mask enemy guard) (-> s1-1 mask))) + (set! sv-1952 (new 'stack-no-clear 'vector)) + (let ((v1-71 (-> (get-trans (the-as process-focusable s1-1) 0) quad))) + (set! (-> sv-1952 quad) v1-71) + ) + (set! sv-1968 (vector-normalize-copy! (new 'stack-no-clear 'vector) sv-148 1.0)) + (let ((s0-1 (new 'stack-no-clear 'vector))) + (let ((a1-18 s0-1) + (v1-72 sv-24) + ) + (vector-! a1-18 sv-1952 v1-72) + ) + (let ((f0-7 (vector-normalize-ret-len! s0-1 1.0))) + (let* ((v1-73 s0-1) + (f1-1 (-> sv-1968 x)) + (f2-0 (-> sv-1968 y)) + (f3-0 (-> sv-1968 z)) + (f4-0 (-> v1-73 x)) + (f5-0 (-> v1-73 y)) + (f6-0 (-> v1-73 z)) + ) + (.mula.s f1-1 f4-0) + (.madda.s f2-0 f5-0) + (.madd.s f1-2 f3-0 f6-0) + ) + (let ((f1-3 f1-2) + (v1-75 (and (not s5-0) (logtest? (process-mask enemy guard) (-> s1-1 mask)))) + ) + (when (and (< 0.707 f1-3) (< (fabs (-> s0-1 y)) 28672.0) (or v1-75 (< f0-7 f30-0))) + (set! s5-0 v1-75) + (set! f30-0 f0-7) + (set! gp-2 (the-as process-focusable s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) sv-144) (-> sv-144 w))) + (when (and (!= *target* s3-1) + (not (focus-test? s3-1 disable dead inactive gun-no-target)) + (or (logtest? (process-mask crate enemy vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + (!= s4-0 s3-1) + ) + (when (or (not s5-0) (logtest? (process-mask enemy guard) (-> s3-1 mask))) + (let ((s1-2 (new 'stack-no-clear 'vector))) + (set! (-> s1-2 quad) (-> (get-trans s3-1 0) quad)) + (let ((s2-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) sv-148 1.0)) + (s4-1 (new 'stack-no-clear 'vector)) + ) + (vector-! s4-1 s1-2 sv-24) + (let ((f0-9 (vector-normalize-ret-len! s4-1 1.0)) + (f1-8 (vector-dot s2-3 s4-1)) + (v1-101 (and (not s5-0) (logtest? (process-mask enemy guard) (-> s3-1 mask)))) + ) + (if (and (< 0.707 f1-8) (< (fabs (-> s4-1 y)) 28672.0) (or v1-101 (< f0-9 f0-9))) + (set! gp-2 s3-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (when gp-2 + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> (get-trans gp-2 3) quad)) + (let ((f0-10 (vector-vector-xz-distance s5-1 (-> sv-16 fire-point))) + (f1-13 (fabs (- (-> s5-1 y) (-> sv-16 fire-point y)))) + ) + 0.0 + (when (< f1-13 24576.0) + (let ((f0-14 (* 0.5 (asin (/ (* 184320.0 f0-10) (* sv-28 sv-28)))))) + (set! (-> sv-20 y) (sin f0-14)) + ) + (vector-normalize! sv-20 1.0) + ) + ) + ) + ) + ) + (let ((a1-33 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> a1-33 ent) (-> self entity)) + (set! (-> a1-33 charge) 1.0) + (set! (-> a1-33 options) (projectile-options)) + (logclear! (-> a1-33 options) (projectile-options po14 po15 po16)) + (set! (-> a1-33 pos quad) (-> sv-24 quad)) + (set! (-> a1-33 vel quad) (-> (vector-float*! (new 'stack-no-clear 'vector) sv-20 sv-28) quad)) + (set! (-> a1-33 notify-handle) (the-as handle #f)) + (set! (-> a1-33 owner-handle) (process->handle self)) + (set! (-> a1-33 target-handle) (the-as handle #f)) + (set! (-> a1-33 target-pos quad) (the-as uint128 0)) + (set! (-> a1-33 ignore-handle) (process->handle self)) + (let* ((v1-127 *game-info*) + (a0-100 (+ (-> v1-127 attack-id) 1)) + ) + (set! (-> v1-127 attack-id) a0-100) + (set! (-> a1-33 attack-id) a0-100) + ) + (set! (-> a1-33 timeout) (seconds 4)) + (the-as gun-red-3-grenade (spawn-projectile gun-red-3-grenade a1-33 self *default-dead-pool*)) + ) + ) + +;; definition for method 39 of type gun-red-3-grenade +;; WARN: Return type mismatch sound-id vs none. +(defmethod projectile-method-39 ((this gun-red-3-grenade)) + (let* ((a2-0 (-> this root)) + (v1-0 (-> a2-0 status)) + ) + (if (logtest? v1-0 (collide-status touch-surface)) + (vector-float*! (-> a2-0 transv) (-> a2-0 transv) 0.6) + ) + (when (and (logtest? v1-0 (collide-status impact-surface)) + (time-elapsed? (-> this played-bounce-time) (seconds 0.3)) + ) + (set-time! (-> this played-bounce-time)) + (sound-play "grenade-bounce") + ) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate moving (gun-red-3-grenade) + :virtual #t + :trans (behavior () + (go-impact self) + (let ((t9-2 (-> (find-parent-state) trans))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate sitting (gun-red-3-grenade) + :virtual #t + :trans (behavior () + (go-impact self) + (let ((t9-2 (-> (find-parent-state) trans))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate impact-tiny (gun-red-3-grenade) + :virtual #t + :event projectile-event-handler + :enter (behavior () + '() + ) + :code (behavior () + (let ((gp-0 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-0 spawn-point quad) (-> self root trans quad)) + (quaternion-identity! (-> gp-0 spawn-quat)) + (set! (-> gp-0 radius) 0.0) + (set! (-> gp-0 scale) 1.0) + (set! (-> gp-0 group) (-> *part-group-id-table* 104)) + (set! (-> gp-0 collide-with) (collide-spec)) + (set! (-> gp-0 damage) 2.0) + (set! (-> gp-0 damage-scale) 1.0) + (set! (-> gp-0 vehicle-damage-factor) 1.0) + (set! (-> gp-0 vehicle-impulse-factor) 1.0) + (set! (-> gp-0 ignore-proc) (process->handle #f)) + (explosion-spawn gp-0 self) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (while (-> self child) + (suspend) + ) + (deactivate self) + ) + ) + +;; definition for method 10 of type gun-red-3-grenade +(defmethod deactivate ((this gun-red-3-grenade)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (blit-displays-work-method-17 *blit-displays-work* *zero-vector* 0 1.0 #f) + (call-parent-method this) + (none) + ) + +;; failed to figure out what this is: +(defstate impact (gun-red-3-grenade) + :virtual #t + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('touched) + (when (send-event + proc + 'attack + (-> block param 0) + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> self attack-id)) + (damage 2.0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'explode) + ) + ) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + #t + ) + ) + ) + ) + :code (behavior () + (sound-play "red3-blast") + (find-and-damage-targets self) + (set-time! (-> self state-time)) + (when (not (-> self immediate-detonation?)) + (let ((gp-1 (new 'stack-no-clear 'red-3-sphere-init-params))) + (set! (-> gp-1 pos quad) (-> self root trans quad)) + (process-spawn red-3-sphere gp-1 :name "red-3-sphere" :to self) + ) + ) + (cond + ((logtest? (-> *part-group-id-table* 88 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 88)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 88)) + ) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (let ((v1-49 (-> self root root-prim))) + (set! (-> v1-49 prim-core collide-as) (collide-spec)) + (set! (-> v1-49 prim-core collide-with) (collide-spec)) + ) + 0 + (let ((gp-4 (-> self child))) + (while gp-4 + (send-event (ppointer->process gp-4) 'notice 'die) + (set! gp-4 (-> gp-4 0 brother)) + ) + ) + (let ((gp-6 (vector-! (new 'stack-no-clear 'vector) (-> self root trans) (math-camera-pos)))) + 0.0 + (let* ((f0-2 (vector-length gp-6)) + (f30-0 (* 0.0000016276042 f0-2)) + ) + (cpad-set-buzz! + (-> *cpad-list* cpads 0) + 1 + (the int (* 255.0 (lerp-scale-clamp 1.0 0.3 f30-0 0.1 0.8))) + (the-as time-frame (the int (* 300.0 (lerp 0.3 0.1 f30-0)))) + ) + (let ((f30-1 (fmin 1.0 f30-0))) + (while (-> self child) + (let ((f0-11 (* 0.0044444446 (the float (- (current-time) (-> self state-time)))))) + 0.0 + (let* ((f0-13 (- 1.0 (curve2d-method-9 *impact-blur* f0-11 1))) + (f0-14 (lerp f0-13 1.0 f30-1)) + ) + (set! (-> *display* force-sync) (the-as uint 2)) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 2 (fmin 1.0 f0-14) #f) + ) + ) + (let ((gp-8 (-> self child))) + (while gp-8 + (send-event (ppointer->process gp-8) 'notice 'die) + (set! gp-8 (-> gp-8 0 brother)) + ) + ) + (suspend) + ) + ) + ) + ) + (blit-displays-work-method-17 *blit-displays-work* (-> self root trans) 15 1.0 #f) + (deactivate self) + ) + ) + +;; definition for function gun-fire-red-1 +;; INFO: Used lq/sq +;; WARN: Return type mismatch (pointer process) vs object. +(defbehavior gun-fire-red-1 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* 216))) + (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))) + ) + ) + ) + (launch-particles (-> *part-id-table* 216) (-> gp-0 fire-point)) + (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 level) #f)) + #f + 0 + :name "manipy" + :to self + :stack-size #x20000 + ) + ) + ) + (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 manipy (-> 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 manipy (-> s5-3 0)) root scale z) (lerp-scale 0.2 1.0 (fabs f0-5) 20480.0 32768.0)) + (set! (-> (the-as manipy (-> s5-3 0)) root scale x) (-> (the-as manipy (-> s5-3 0)) root scale z)) + ) + ) + ) + ) + ) + ) + (process-spawn + gun-red-shot + (-> gp-0 fire-point) + (-> gp-0 fire-dir-out) + :name "gun-red-shot" + :to (ppointer->process (-> gp-0 gun)) + ) + ) + ) + ) + +;; definition for function target-gun-can-fire-red? +(defbehavior target-gun-can-fire-red? target ((arg0 pickup-type)) + #t + ) + +;; definition for function target-gun-fire-red +;; WARN: Return type mismatch object vs (pointer process). +(defbehavior target-gun-fire-red target ((arg0 pickup-type)) + (+! (-> *game-info* shots-fired 1) 1.0) + (the-as (pointer process) (case arg0 + (((pickup-type gun-red-1)) + (gun-fire-red-1) + ) + (((pickup-type gun-red-2)) + (gun-fire-red-2) + ) + (((pickup-type gun-red-3)) + (gun-fire-red-3) + ) + ) + ) + ) + +;; definition for function gun-red-shot-event-handler +;; WARN: Return type mismatch none vs object. +(defbehavior gun-red-shot-event-handler gun-red-shot ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('touched) + (send-attack! self (the-as process-drawable arg0) (the-as touching-shapes-entry (-> arg3 param 0))) + ) + ) + ) + +;; definition for method 29 of type gun-red-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defmethod send-attack! ((this gun-red-shot) (arg0 process-drawable) (arg1 touching-shapes-entry)) + (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) (-> this start-pos))) + (f30-0 (* (if (< (vector-length s5-2) 24576.0) + 3.0 + 2.0 + ) + (if (logtest? (game-feature feature22) (-> *game-info* features)) + 2.0 + 1.0 + ) + ) + ) + ) + (if (and (logtest? (process-mask guard) (-> arg0 mask)) + (not (-> *setting-control* user-current gun-target-guards?)) + ) + (set! f30-0 0.0) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (rot-zxy-from-vector! s2-0 s5-2) + (let ((f28-0 (deg- (-> s2-0 x) (-> this start-rot x))) + (f0-6 (deg- (-> s2-0 y) (-> this 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) (+ (-> this start-rot x) f1-5)) + (set! (-> s2-0 y) (+ (-> this 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)) + ) + ) + ) + (+! (-> *game-info* shots-hit 1) 1.0) + (send-event + arg0 + 'attack + arg1 + (static-attack-info :mask (vehicle-impulse-factor) ((id (-> this attack-id)) + (damage f30-0) + (vehicle-damage-factor 1.0) + (vehicle-impulse-factor 1.0) + (mode 'eco-red) + (attacker-velocity s5-2) + (attacker (process->handle *target*)) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 25 of type gun-red-shot +;; WARN: Return type mismatch int vs none. +(defmethod stub ((this gun-red-shot)) + 0 + (none) + ) + +;; definition for method 23 of type gun-red-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod init-probes! ((this gun-red-shot) (arg0 collide-shape)) + (let ((s5-0 (-> this 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 (-> this 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) (-> this start-rot x))) + (f0-4 (deg- (-> s3-2 y) (-> this 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) (+ (-> this start-rot x) f1-3)) + (set! (-> s3-2 y) (+ (-> this 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! (-> this probe-dir s5-0 quad) (-> s4-1 quad)) + ) + (set! (-> this probe-count) (+ s5-0 1)) + ) + ) + (none) + ) + +;; definition for method 26 of type gun-red-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod find-targets ((this 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 'bounding-box))) + (set! (-> s5-0 min quad) (-> this start-dir quad)) + (vector-float*! (the-as vector s5-0) (the-as vector s5-0) 43417.6) + (vector+! (the-as vector s5-0) (the-as vector s5-0) (-> this start-pos)) + (set! (-> s5-0 min w) 43827.2) + (let ((s4-0 (-> this root 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-box *actor-hash* 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 min 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 min 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 min 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 min 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! this a1-28) + ) + ) + ) + ) + ) + (set! (-> this actor-count) (-> this probe-count)) + 0 + (none) + ) + ) + +;; definition for method 27 of type gun-red-shot +;; WARN: Return type mismatch int vs none. +(defmethod setup-probes ((this gun-red-shot)) + (find-targets this) + (let ((s5-0 (-> this 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 (-> this probe-dir s5-0)) + ) + (set-vector! s4-0 0.0 0.0 1.0 1.0) + (vector-rotate-around-x! s4-0 s4-0 (+ (-> this start-rot x) f28-0)) + (vector-rotate-around-y! s4-0 s4-0 (+ (-> this start-rot y) f30-0)) + ) + (+! s5-0 1) + ) + (set! (-> this probe-count) s5-0) + ) + 0 + (none) + ) + +;; definition for method 28 of type gun-red-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch sound-id vs none. +(defmethod do-collision ((this 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 (-> this root))) + (let ((v1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> gp-0 trans quad) (-> this 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) this) + (set! (-> a1-1 ignore-process1) (ppointer->process (-> this parent))) + (set! (-> a1-1 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #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") + ) + ) + (none) + ) + ) + ) + +;; definition for method 24 of type gun-red-shot +(defmethod check-blocked? ((this gun-red-shot)) + (let ((v1-0 (-> this root)) + (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) this) + (set! (-> a1-0 ignore-process1) (ppointer->process (-> this parent))) + (set! (-> a1-0 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #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 + ) + ) + ) + +;; failed to figure out what this is: +(defstate debug-idle (gun-red-shot) + :virtual #t + :code (behavior () + (set-time! (-> self state-time)) + (until (time-elapsed? (-> 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 bucket583) + (-> self start-pos) + (-> self start-dir) + (meters 6) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (suspend) + ) + ) + ) + +;; failed to figure out what this is: +(defstate blocked (gun-red-shot) + :virtual #t + :event gun-red-shot-event-handler + :code (behavior () + (suspend) + 0 + ) + ) + +;; failed to figure out what this is: +(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) + (do-collision self (-> self probe-dir gp-0)) + (+! gp-0 1) + ) + ) + (suspend) + ) + ) + ) + ) + +;; definition for function gun-red-shot-init-by-other +;; INFO: Used lq/sq +(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 pusher shield) + ) + (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) s5-0) + ) + (let ((s5-1 (-> self root))) + (set! (-> s5-1 trans quad) (-> arg0 quad)) + (quaternion-copy! (-> s5-1 quat) (-> self parent 0 root quat)) + (vector-identity! (-> s5-1 scale)) + ) + (update-transforms (-> self root)) + (set! (-> self event-hook) gun-red-shot-event-handler) + (logior! (-> self mask) (process-mask projectile)) + (logclear! (-> self mask) (process-mask enemy)) + (setup-probes self) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (let ((v1-39 (cond + ((logtest? (-> *part-group-id-table* 84 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self start-pos quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 84)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self start-pos quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 84)) + ) + ) + ) + ) + (send-event (ppointer->process v1-39) 'clock self) + ) + (draw-beam (-> *part-id-table* 213) (-> self start-pos) (-> self start-dir) #f) + (sound-play "red-shot-fire") + (vector-float*! (-> self root transv) (-> self start-dir) 61440.0) + (if (check-blocked? self) + (go-virtual blocked) + (go-virtual idle) + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/target/gun/gun-yellow-shot_REF.gc b/test/decompiler/reference/jak3/engine/target/gun/gun-yellow-shot_REF.gc new file mode 100644 index 0000000000..139bb5c66a --- /dev/null +++ b/test/decompiler/reference/jak3/engine/target/gun/gun-yellow-shot_REF.gc @@ -0,0 +1,2394 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type gun-yellow-shot +(deftype gun-yellow-shot (projectile) + ((hit-actor? symbol) + (tail-pos vector :inline) + (hit-pos vector :inline) + (last-hit-time time-frame) + (snd-whoosh sound-id) + (muzzle-flash-part sparticle-launcher) + (main-shot-part sparticle-launcher) + (shot-aim-part sparticle-launcher) + (shot-ring-part sparticle-launcher) + ) + (:methods + (draw-main-shot (_type_ vector vector) none) + (gun-yellow-shot-method-42 (_type_ float float matrix) none) + (spawn-particles (_type_ vector) none) + ) + ) + +;; definition for method 3 of type gun-yellow-shot +(defmethod inspect ((this gun-yellow-shot)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile inspect))) + (t9-0 this) + ) + (format #t "~2Thit-actor?: ~A~%" (-> this hit-actor?)) + (format #t "~2Ttail-pos: #~%" (-> this tail-pos)) + (format #t "~2Thit-pos: #~%" (-> this hit-pos)) + (format #t "~2Tlast-hit-time: ~D~%" (-> this last-hit-time)) + (format #t "~2Tsnd-whoosh: ~D~%" (-> this snd-whoosh)) + (format #t "~2Tmuzzle-flash-part: ~A~%" (-> this muzzle-flash-part)) + (format #t "~2Tmain-shot-part: ~A~%" (-> this main-shot-part)) + (format #t "~2Tshot-aim-part: ~A~%" (-> this shot-aim-part)) + (format #t "~2Tshot-ring-part: ~A~%" (-> this shot-ring-part)) + (label cfg-4) + this + ) + +;; definition of type gun-yellow-2-proc-ignore +(deftype gun-yellow-2-proc-ignore (structure) + ((hand handle) + (time time-frame) + ) + :pack-me + ) + +;; definition for method 3 of type gun-yellow-2-proc-ignore +(defmethod inspect ((this gun-yellow-2-proc-ignore)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gun-yellow-2-proc-ignore) + (format #t "~1Thand: ~D~%" (-> this hand)) + (format #t "~1Ttime: ~D~%" (-> this time)) + (label cfg-4) + this + ) + +;; definition of type gun-yellow-shot-2 +(deftype gun-yellow-shot-2 (gun-yellow-shot) + ((last-collide-time time-frame) + (snd-trail sound-id) + (hit-yet? symbol) + (actor-deflect? symbol) + (max-actor-deflect-count int32) + (last-hit-enemy handle) + (delay-attack time-frame) + (delay-norm vector :inline) + (enemy-hit-count int32) + (ignore-list gun-yellow-2-proc-ignore 6 :inline) + (last-attack-time time-frame) + ) + (:methods + (on-impact (_type_ handle) object) + (handle-impact (_type_ handle) object) + (is-in-ignore-list? (_type_ handle) symbol) + (add-to-ignore-list! (_type_ handle) int) + ) + ) + +;; definition for method 3 of type gun-yellow-shot-2 +(defmethod inspect ((this gun-yellow-shot-2)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type gun-yellow-shot inspect))) + (t9-0 this) + ) + (format #t "~2Tlast-collide-time: ~D~%" (-> this last-collide-time)) + (format #t "~2Tsnd-trail: ~D~%" (-> this snd-trail)) + (format #t "~2Thit-yet?: ~A~%" (-> this hit-yet?)) + (format #t "~2Tactor-deflect?: ~A~%" (-> this actor-deflect?)) + (format #t "~2Tmax-actor-deflect-count: ~D~%" (-> this max-actor-deflect-count)) + (format #t "~2Tlast-hit-enemy: ~D~%" (-> this last-hit-enemy)) + (format #t "~2Tdelay-attack: ~D~%" (-> this delay-attack)) + (format #t "~2Tdelay-norm: #~%" (-> this delay-norm)) + (format #t "~2Tenemy-hit-count: ~D~%" (-> this enemy-hit-count)) + (format #t "~2Tignore-list[6] @ #x~X~%" (-> this ignore-list)) + (format #t "~2Tlast-attack-time: ~D~%" (-> this last-attack-time)) + (label cfg-4) + this + ) + +;; definition of type gun-yellow-shot-3 +(deftype gun-yellow-shot-3 (gun-yellow-shot) + () + ) + +;; definition for method 3 of type gun-yellow-shot-3 +(defmethod inspect ((this gun-yellow-shot-3)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type gun-yellow-shot inspect))) + (t9-0 this) + ) + (label cfg-4) + this + ) + +;; definition of type gun-yellow-3-saucer +(deftype gun-yellow-3-saucer (projectile-bounce) + ((total-float-time time-frame) + (firing? symbol :offset 568) + (asleep? symbol) + (first-fire-time time-frame) + (activated? symbol) + (collided-with-surface? symbol) + (last-deflect-time time-frame) + (last-fire-time time-frame) + (spawn-part sparticle-launch-control) + (last-blink-time time-frame) + (finished? symbol) + (initial-fire-dir vector :inline) + (initial-fire-pos vector :inline) + (last-deduct-ammo-time time-frame) + (total-ammo-drained float) + (total-ammo-to-drain float) + (total-fire-time time-frame) + (snd-hum sound-id) + (snd-shoot sound-id) + ) + (:state-methods + undefined + navigating + spinning + impact-explode + falling-down + burnt-husk + ) + (:methods + (start-firing (_type_) none) + (init-antigrav (_type_) none) + (find-targets (_type_) int) + (spawn-shot (_type_ vector) (pointer gun-yellow-shot-3)) + ) + (:states + gun-yellow-3-saucer-base-state + ) + ) + +;; definition for method 3 of type gun-yellow-3-saucer +(defmethod inspect ((this gun-yellow-3-saucer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type projectile-bounce inspect))) + (t9-0 this) + ) + (format #t "~2Ttotal-float-time: ~D~%" (-> this total-float-time)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (format #t "~2Tfiring?: ~A~%" (-> this firing?)) + (format #t "~2Tasleep?: ~A~%" (-> this asleep?)) + (format #t "~2Tfirst-fire-time: ~D~%" (-> this first-fire-time)) + (format #t "~2Tactivated?: ~A~%" (-> this activated?)) + (format #t "~2Tcollided-with-surface?: ~A~%" (-> this collided-with-surface?)) + (format #t "~2Tlast-deflect-time: ~D~%" (-> this last-deflect-time)) + (format #t "~2Tlast-fire-time: ~D~%" (-> this last-fire-time)) + (format #t "~2Tspawn-part: ~A~%" (-> this spawn-part)) + (format #t "~2Tlast-blink-time: ~D~%" (-> this last-blink-time)) + (format #t "~2Tfinished?: ~A~%" (-> this finished?)) + (format #t "~2Tinitial-fire-dir: #~%" (-> this initial-fire-dir)) + (format #t "~2Tinitial-fire-pos: #~%" (-> this initial-fire-pos)) + (format #t "~2Tlast-deduct-ammo-time: ~D~%" (-> this last-deduct-ammo-time)) + (format #t "~2Ttotal-ammo-drained: ~f~%" (-> this total-ammo-drained)) + (format #t "~2Ttotal-ammo-to-drain: ~f~%" (-> this total-ammo-to-drain)) + (format #t "~2Ttotal-fire-time: ~D~%" (-> this total-fire-time)) + (format #t "~2Tsnd-hum: ~D~%" (-> this snd-hum)) + (format #t "~2Tsnd-shoot: ~D~%" (-> this snd-shoot)) + (label cfg-4) + this + ) + +;; definition for method 7 of type gun-yellow-3-saucer +(defmethod relocate ((this gun-yellow-3-saucer) (offset int)) + (call-parent-method this offset) + ) + +;; definition of type target-quality-info-saucer +(deftype target-quality-info-saucer (structure) + ((targ handle) + (value float) + ) + ) + +;; definition for method 3 of type target-quality-info-saucer +(defmethod inspect ((this target-quality-info-saucer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'target-quality-info-saucer) + (format #t "~1Ttarg: ~D~%" (-> this targ)) + (format #t "~1Tvalue: ~f~%" (-> this value)) + (label cfg-4) + this + ) + +;; definition for method 53 of type gun-yellow-3-saucer +;; INFO: Used lq/sq +;; WARN: Return type mismatch (pointer process) vs (pointer gun-yellow-shot-3). +(defmethod spawn-shot ((this gun-yellow-3-saucer) (arg0 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 x) (rand-vu-float-range -1.0 1.0)) + (set! (-> s5-0 y) (rand-vu-float-range -1.0 1.0)) + (set! (-> s5-0 z) (rand-vu-float-range -1.0 1.0)) + (set! (-> s5-0 w) 1.0) + (vector+float*! arg0 arg0 s5-0 4096.0) + ) + (let ((s5-2 (vector-! (new 'stack-no-clear 'vector) arg0 (-> this root trans))) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (vector-normalize! s5-2 1.0) + (set! (-> s3-0 quad) (-> s5-2 quad)) + (set! (-> s3-0 y) 0.0) + (vector-normalize! s3-0 1228.8) + (vector+! s3-0 (-> this root trans) s3-0) + (+! (-> s3-0 y) -819.2) + (let ((s4-1 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> s4-1 ent) (-> this entity)) + (set! (-> s4-1 charge) 1.0) + (set! (-> s4-1 options) (projectile-options)) + (logclear! (-> s4-1 options) (projectile-options po14 po15 po16)) + (set! (-> s4-1 pos quad) (-> s3-0 quad)) + (set! (-> s4-1 notify-handle) (the-as handle #f)) + (set! (-> s4-1 owner-handle) (the-as handle #f)) + (set! (-> s4-1 target-handle) (the-as handle #f)) + (set! (-> s4-1 target-pos quad) (the-as uint128 0)) + (set! (-> s4-1 ignore-handle) (process->handle (send-event *target* 'get-vehicle))) + (let* ((v1-20 *game-info*) + (a0-20 (+ (-> v1-20 attack-id) 1)) + ) + (set! (-> v1-20 attack-id) a0-20) + (set! (-> s4-1 attack-id) a0-20) + ) + (set! (-> s4-1 timeout) (seconds 4)) + (vector-float*! (-> s4-1 vel) s5-2 819200.0) + (the-as (pointer gun-yellow-shot-3) (spawn-projectile gun-yellow-shot-3 s4-1 this *default-dead-pool*)) + ) + ) + ) + +;; definition for method 32 of type gun-yellow-3-saucer +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-32 ((this gun-yellow-3-saucer)) + (if (not (do-fire-backcheck (-> this root trans) (-> this root transv))) + (go (method-of-object this impact-explode)) + (call-parent-method this) + ) + 0 + (none) + ) + +;; definition for method 52 of type gun-yellow-3-saucer +;; INFO: Used lq/sq +(defmethod find-targets ((this gun-yellow-3-saucer)) + (local-vars + (sv-16 int) + (sv-1072 vector) + (sv-1076 (inline-array target-quality-info-saucer)) + (sv-1080 int) + (sv-1088 float) + (sv-3792 (pointer int8)) + (sv-3800 int) + (sv-3808 float) + (sv-3812 symbol) + ) + (if (not (-> this firing?)) + (return 0) + ) + (sound-play "yellow3-shot" :id (-> this snd-shoot)) + (if (not (time-elapsed? (-> this last-fire-time) (seconds 0.05))) + (return 0) + ) + (set-time! (-> this last-fire-time)) + (when (and (time-elapsed? (-> this last-deduct-ammo-time) (seconds 0.1)) (< (-> this total-ammo-drained) 50.0)) + (+! (-> this total-ammo-drained) (adjust-player-ammo-over-time + (the-as int (- (current-time) (-> this last-deduct-ammo-time))) + (/ 50.0 (* 0.0033333334 (the float (-> this total-fire-time)))) + (pickup-type ammo-yellow) + (- 50.0 (-> this total-ammo-drained)) + ) + ) + (set-time! (-> this last-deduct-ammo-time)) + ) + (set! sv-16 2) + (set! sv-1072 (new 'stack-no-clear 'vector)) + (set! sv-1076 (new 'stack-no-clear 'inline-array 'target-quality-info-saucer 66)) + (set! sv-1080 0) + (set! sv-1088 (the-as float 0.0)) + (set! (-> sv-1072 quad) (-> this root trans quad)) + (set! (-> sv-1072 w) 143360.0) + (let ((s5-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s4-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-1072) s5-0 384)) + (let* ((s3-0 (-> s5-0 s4-0)) + (v1-34 (if (type? s3-0 collide-shape) + s3-0 + ) + ) + ) + (when v1-34 + (let* ((s2-0 (-> v1-34 process)) + (s3-1 (if (type? s2-0 process-focusable) + s2-0 + ) + ) + ) + (when s3-1 + (when (and (!= *target* s3-1) + (not (focus-test? (the-as process-focusable s3-1) disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy vehicle civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s2-1 (new 'stack-no-clear 'collide-query))) + (set! (-> s2-1 start-pos quad) (-> this root trans quad)) + (vector-! (-> s2-1 move-dist) (get-trans (the-as process-focusable s3-1) 3) (-> this root trans)) + (let ((v1-47 s2-1)) + (set! (-> v1-47 radius) 40.96) + (set! (-> v1-47 collide-with) (collide-spec backgnd)) + (set! (-> v1-47 ignore-process0) #f) + (set! (-> v1-47 ignore-process1) #f) + (set! (-> v1-47 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-47 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* s2-1) 0.0) + (set! (-> sv-1076 sv-1080 targ) (process->handle s3-1)) + (let ((f0-11 1.0)) + (if (and (nonzero? (-> s3-1 draw)) (logtest? (-> s3-1 draw status) (draw-control-status on-screen))) + (set! f0-11 (+ 2.0 f0-11)) + ) + (if (logtest? (process-mask enemy guard) (-> s3-1 mask)) + (set! f0-11 (+ 28.0 f0-11)) + ) + (if (logtest? (process-mask vehicle civilian) (-> s3-1 mask)) + (set! f0-11 (* 0.25 f0-11)) + ) + (set! (-> sv-1076 sv-1080 value) f0-11) + (set! sv-1088 (+ sv-1088 f0-11)) + ) + (set! sv-1080 (+ sv-1080 1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s4-1 *target*) + (s5-1 (if (type? s4-1 process-focusable) + s4-1 + ) + ) + ) + (when (and s5-1 (< (vector-vector-distance (get-trans s5-1 0) sv-1072) (-> sv-1072 w))) + (when (and (!= *target* s5-1) + (not (focus-test? s5-1 disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy vehicle civilian) (-> s5-1 mask)) + (and (logtest? (process-mask guard) (-> s5-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (let ((s4-3 (new 'stack-no-clear 'collide-query))) + (set! (-> s4-3 start-pos quad) (-> this root trans quad)) + (vector-! (-> s4-3 move-dist) (get-trans s5-1 3) (-> this root trans)) + (let ((v1-94 s4-3)) + (set! (-> v1-94 radius) 40.96) + (set! (-> v1-94 collide-with) (collide-spec backgnd)) + (set! (-> v1-94 ignore-process0) #f) + (set! (-> v1-94 ignore-process1) #f) + (set! (-> v1-94 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-94 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* s4-3) 0.0) + (set! (-> sv-1076 sv-1080 targ) (process->handle s5-1)) + (let ((f0-16 1.0)) + (if (and (nonzero? (-> s5-1 draw)) (logtest? (-> s5-1 draw status) (draw-control-status on-screen))) + (set! f0-16 (+ 2.0 f0-16)) + ) + (if (logtest? (process-mask enemy guard) (-> s5-1 mask)) + (set! f0-16 (+ 28.0 f0-16)) + ) + (if (logtest? (process-mask vehicle civilian) (-> s5-1 mask)) + (set! f0-16 (* 0.25 f0-16)) + ) + (set! (-> sv-1076 sv-1080 value) f0-16) + (set! sv-1088 (+ sv-1088 f0-16)) + ) + (set! sv-1080 (+ sv-1080 1)) + ) + ) + ) + ) + ) + (set! sv-3792 (new 'stack-no-clear 'array 'int8 100)) + (set! sv-3800 0) + (set! sv-3808 (the-as float 0.0)) + (set! sv-3812 (the-as symbol #f)) + (when (> sv-1080 0) + (dotimes (s5-2 sv-16) + (let ((f0-20 (rand-vu-float-range 0.0 sv-1088))) + (dotimes (v1-127 sv-1080) + (set! sv-3808 (+ sv-3808 (-> sv-1076 v1-127 value))) + (when (< f0-20 sv-3808) + (dotimes (a0-82 sv-3800) + (when (= (-> sv-3792 a0-82) v1-127) + 0 + (goto cfg-91) + ) + ) + (set! (-> sv-3792 sv-3800) v1-127) + (set! sv-3800 (+ sv-3800 1)) + 0 + (goto cfg-94) + ) + (label cfg-91) + ) + ) + (label cfg-94) + ) + ) + (dotimes (s5-3 sv-3800) + (let* ((s4-4 (handle->process (-> sv-1076 (-> sv-3792 s5-3) targ))) + (a0-95 (if (type? s4-4 process-focusable) + s4-4 + ) + ) + (s4-5 this) + (s3-4 (method-of-object s4-5 spawn-shot)) + (s2-2 (new 'stack-no-clear 'vector)) + ) + (set! (-> s2-2 quad) (-> (get-trans (the-as process-focusable a0-95) 0) quad)) + (s3-4 s4-5 s2-2) + ) + ) + (let ((s5-4 sv-3800) + (s4-6 (+ sv-16 -1)) + ) + (while (>= s4-6 s5-4) + (let ((s3-5 (new 'stack-no-clear 'vector))) + (set! (-> s3-5 x) (rand-vu-float-range -1.0 1.0)) + (set! (-> s3-5 y) (rand-vu-float-range -0.85 -0.3)) + (set! (-> s3-5 z) (rand-vu-float-range -1.0 1.0)) + (vector+float*! s3-5 (-> this root trans) s3-5 40960.0) + (spawn-shot this s3-5) + ) + (+! s5-4 1) + ) + ) + (the-as int #f) + ) + +;; failed to figure out what this is: +(defskelgroup skel-gun-yellow-3-saucer gun gun-saucer-lod0-jg gun-saucer-idle-ja + ((gun-saucer-lod0-mg (meters 999999))) + :bounds (static-spherem 0 0 0 4096) + :texture-level 10 + :light-index 1 + ) + +;; definition for method 30 of type gun-yellow-3-saucer +;; WARN: Return type mismatch int vs none. +(defmethod setup-collision! ((this gun-yellow-3-saucer)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) projectile-bounce-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate explode)) + (let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-7 prim-core action) (collide-action solid)) + (set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 1638.4) + (set! (-> s5-0 total-prims) (the-as uint 1)) + (set! (-> s5-0 root-prim) v1-7) + ) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + (let ((v1-10 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 2)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set-collide-with! + (-> this root) + (collide-spec backgnd crate vehicle-sphere hit-by-others-list pusher impenetrable-obj shield) + ) + (set-collide-as! (-> this root) (collide-spec projectile)) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + (none) + ) + +;; definition for method 31 of type gun-yellow-3-saucer +;; WARN: Return type mismatch vector vs none. +(defmethod init-proj-settings! ((this gun-yellow-3-saucer)) + (initialize-skeleton + this + (the-as skeleton-group (art-group-get-by-name *level* "skel-gun-yellow-3-saucer" (the-as (pointer level) #f))) + (the-as pair 0) + ) + (let ((t9-2 (method-of-type projectile-bounce init-proj-settings!))) + (t9-2 this) + ) + (set! (-> this move) projectile-move-fill-line-sphere) + (set! (-> this total-float-time) (seconds 0.05)) + (quaternion-identity! (-> this root quat)) + (set! (-> this part) (create-launch-control (-> *part-group-id-table* 95) this)) + (set! (-> this asleep?) #t) + (set! (-> this firing?) #f) + (set! (-> this first-fire-time) 0) + (set! (-> this timeout) (seconds 30)) + (set! (-> this activated?) #f) + (set! (-> this collided-with-surface?) #f) + (set! (-> this last-blink-time) 0) + (set! (-> this finished?) #f) + (set! (-> this snd-hum) (new-sound-id)) + (set! (-> this snd-shoot) (new-sound-id)) + (set! (-> this total-ammo-to-drain) 50.0) + (set! (-> this total-fire-time) (seconds 4)) + (when (logtest? (game-secrets gun-upgrade-yellow-3) (-> *game-info* secrets)) + (set! (-> this total-ammo-to-drain) 50.0) + (set! (-> this total-fire-time) (seconds 6)) + ) + (set-vector! (-> this root scale) 3.5 3.5 3.5 1.0) + (none) + ) + +;; definition for method 10 of type gun-yellow-3-saucer +(defmethod deactivate ((this gun-yellow-3-saucer)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (sound-stop (-> this snd-hum)) + (sound-stop (-> this snd-shoot)) + (if (nonzero? (-> this spawn-part)) + (kill-particles (-> this spawn-part)) + ) + (call-parent-method this) + (none) + ) + +;; definition of type gun-yellow-3-event-msg +(deftype gun-yellow-3-event-msg (structure) + ((activated? symbol) + (finished? symbol) + ) + ) + +;; definition for method 3 of type gun-yellow-3-event-msg +(defmethod inspect ((this gun-yellow-3-event-msg)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gun-yellow-3-event-msg) + (format #t "~1Tactivated?: ~A~%" (-> this activated?)) + (format #t "~1Tfinished?: ~A~%" (-> this finished?)) + (label cfg-4) + this + ) + +;; definition for method 50 of type gun-yellow-3-saucer +;; WARN: Return type mismatch time-frame vs none. +(defmethod start-firing ((this gun-yellow-3-saucer)) + (set-time! (-> this first-fire-time)) + (set! (-> this firing?) #t) + (set! (-> this last-fire-time) 0) + (set-time! (-> this last-deduct-ammo-time)) + (none) + ) + +;; definition for method 51 of type gun-yellow-3-saucer +;; WARN: Return type mismatch time-frame vs none. +(defmethod init-antigrav ((this gun-yellow-3-saucer)) + (set! (-> this asleep?) #f) + (set! (-> this root dynam gravity y) 0.0) + (set! (-> this root dynam gravity-length) 0.0) + (set! (-> this root dynam gravity-max) 0.0) + (set-time! (-> this last-blink-time)) + (none) + ) + +;; definition for method 25 of type gun-yellow-3-saucer +;; WARN: Return type mismatch float vs none. +(defmethod projectile-method-25 ((this gun-yellow-3-saucer)) + (if (nonzero? (-> this part)) + (spawn (-> this part) (-> this root trans)) + ) + (when (and (nonzero? (-> this part)) (not (-> this finished?))) + ) + (let ((v1-14 (if (< (mod (- (current-time) (-> this last-blink-time)) 300) 150) + 60 + 128 + ) + ) + ) + (set! (-> *part-id-table* 279 init-specs 4 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 280 init-specs 5 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 281 init-specs 5 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 279 init-specs 5 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 280 init-specs 6 initial-valuef) (the float v1-14)) + (set! (-> *part-id-table* 281 init-specs 6 initial-valuef) (the float v1-14)) + ) + (none) + ) + +;; definition for method 42 of type gun-yellow-3-saucer +(defmethod projectile-bounce-method-42 ((this gun-yellow-3-saucer)) + (projectile-method-25 this) + (none) + ) + +;; failed to figure out what this is: +(defstate gun-yellow-3-saucer-base-state (gun-yellow-3-saucer) + :event projectile-event-handler + :trans (behavior () + (if (and (-> self firing?) + (not (and (-> self next-state) (let ((v1-5 (-> self next-state name))) + (or (= v1-5 'falling-down) (= v1-5 'impact-explode)) + ) + ) + ) + (or (< (get-remaining-player-ammo (pickup-type ammo-yellow)) 1.0) + (time-elapsed? (-> self first-fire-time) (-> self total-fire-time)) + ) + ) + (go-virtual falling-down) + ) + ) + :code sleep-code + :post (behavior () + (projectile-method-25 self) + (ja-post) + ) + ) + +;; definition for method 43 of type gun-yellow-3-saucer +;; WARN: Return type mismatch symbol vs none. +(defmethod projectile-bounce-method-43 ((this gun-yellow-3-saucer)) + (set! (-> this collided-with-surface?) #t) + (none) + ) + +;; definition for function saucer-land-move +(defun saucer-land-move ((arg0 gun-yellow-3-saucer)) + (seek-toward-heading-vec! (-> arg0 root) (-> arg0 root transv) 131072.0 (seconds 0.1)) + (new 'stack-no-clear 'vector) + (let ((a2-1 (quaternion-identity! (new 'stack-no-clear 'quaternion)))) + (fmin 1.0 (* 0.006666667 (the float (- (current-time) (-> arg0 state-time))))) + (quaternion-smooth-seek! (-> arg0 root quat) (-> arg0 root quat) a2-1 (* 3.5 (seconds-per-frame))) + ) + (projectile-move-fill-all-dirs arg0) + (none) + ) + +;; failed to figure out what this is: +(defstate sitting (gun-yellow-3-saucer) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 1)) + (suspend) + ) + (go-virtual burnt-husk) + ) + ) + +;; failed to figure out what this is: +(defstate burnt-husk (gun-yellow-3-saucer) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (cond + ((logtest? (-> *part-group-id-table* 97 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 97)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> self root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 97)) + ) + ) + (let ((gp-2 sound-play-by-name) + (name (static-sound-name "yellow3-zap")) + (a1-6 (new-sound-id)) + (a2-10 1024) + (a3-4 0) + ) + (gp-2 (the-as sound-name name) a1-6 a2-10 a3-4 0 (sound-group) #t) + (set! (-> self draw color-mult quad) (the-as uint128 0)) + (set! (-> self draw color-mult x) 0.15) + (set! (-> self draw color-mult y) 0.15) + (set! (-> self draw color-mult z) 0.15) + (set! (-> self draw color-emissive quad) (the-as uint128 0)) + (let ((gp-3 (new 'stack-no-clear 'matrix))) + (matrix-u-compose + gp-3 + (vector-y-quaternion! (new 'stack-no-clear 'vector) (-> self root quat)) + (the-as vector a2-10) + (the-as vector a3-4) + ) + (set! (-> gp-3 trans quad) (-> self root trans quad)) + (let ((gp-4 + (ppointer->handle + (if (logtest? (-> *part-group-id-table* 96 flags) (sp-group-flag sp13)) + (part-tracker-spawn + part-tracker-subsampler + :to (-> self parent 0) + :group (-> *part-group-id-table* 96) + :mat-joint gp-3 + ) + (part-tracker-spawn part-tracker :to (-> self parent 0) :group (-> *part-group-id-table* 96) :mat-joint gp-3) + ) + ) + ) + ) + (process-spawn-function + process + (lambda :behavior process + ((arg0 handle)) + (let ((s5-0 (current-time))) + (until (time-elapsed? s5-0 (seconds 0.2)) + (suspend) + ) + ) + (send-event (handle->process arg0) 'die) + ) + gp-4 + :to self + ) + ) + ) + ) + ) + :trans (behavior () + (let* ((f1-2 (* 0.016666668 (the float (- (current-time) (-> self state-time))))) + (f0-2 (fmax 0.0 (fmin 1.0 f1-2))) + ) + (set-vector! (-> self root scale) 3.5 (lerp 3.5 0.0 f0-2) 3.5 1.0) + ) + ) + :code (behavior () + (until (time-elapsed? (-> self state-time) (seconds 0.2)) + (suspend) + ) + (when (type? (-> self root) collide-shape) + (let ((v1-6 (-> self root root-prim))) + (set! (-> v1-6 prim-core collide-as) (collide-spec)) + (set! (-> v1-6 prim-core collide-with) (collide-spec)) + ) + 0 + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (transform-post) + (let ((gp-0 (current-time))) + (until (time-elapsed? gp-0 (seconds 1)) + (suspend) + ) + ) + (deactivate self) + ) + :post ja-post + ) + +;; failed to figure out what this is: +(defstate falling-down (gun-yellow-3-saucer) + :virtual #t + :parent gun-yellow-3-saucer-base-state + :enter (behavior () + (set-time! (-> self state-time)) + (set! (-> self finished?) #t) + (set! (-> self move) projectile-bounce-move) + (set! (-> self root dynam gravity y) 184320.0) + (set! (-> self root dynam gravity-length) 184320.0) + (set! (-> self root dynam gravity-max) 184320.0) + (set! (-> self root transv quad) (the-as uint128 0)) + (set-time! (-> self state-time)) + (set! (-> self activated?) #t) + (sound-stop (-> self snd-shoot)) + ) + :exit (behavior () + (set! (-> self move) saucer-land-move) + (sound-stop (-> self snd-hum)) + ) + :trans (behavior () + (if (not (time-elapsed? (-> self state-time) (seconds 0.4))) + (sound-play-by-name + (static-sound-name "yellow3-fire") + (-> self snd-hum) + 1024 + (the int (* 1524.0 (lerp 0.0 -0.5 (* 0.008333334 (the float (- (current-time) (-> self state-time))))))) + 0 + (sound-group) + #t + ) + (sound-stop (-> self snd-hum)) + ) + ((-> (method-of-type projectile moving) trans)) + (when (logtest? (-> self root status) (collide-status touch-surface)) + (sound-play "yellow3-bounce") + (set! (-> self move) saucer-land-move) + ) + (let ((v1-19 gun-yellow-3-saucer-base-state)) + (when v1-19 + (let ((t9-6 (-> v1-19 trans))) + (if t9-6 + (t9-6) + ) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate impact-explode (gun-yellow-3-saucer) + :virtual #t + :event projectile-event-handler + :enter (behavior () + (set! (-> self activated?) #t) + (sound-stop (-> self snd-hum)) + ) + :code (behavior () + (set! (-> self firing?) #t) + (let ((gp-0 (new 'stack-no-clear 'explosion-init-params))) + (set! (-> gp-0 spawn-point quad) (-> self root trans quad)) + (quaternion-identity! (-> gp-0 spawn-quat)) + (set! (-> gp-0 radius) 0.0) + (set! (-> gp-0 scale) 1.0) + (set! (-> gp-0 group) (-> *part-group-id-table* 104)) + (set! (-> gp-0 collide-with) (collide-spec)) + (set! (-> gp-0 damage) 2.0) + (set! (-> gp-0 damage-scale) 1.0) + (set! (-> gp-0 vehicle-damage-factor) 1.0) + (set! (-> gp-0 vehicle-impulse-factor) 1.0) + (set! (-> gp-0 ignore-proc) (process->handle #f)) + (explosion-spawn gp-0 self) + ) + (logior! (-> self draw status) (draw-control-status no-draw)) + (while (-> self child) + (suspend) + ) + (deactivate self) + ) + ) + +;; definition for method 35 of type gun-yellow-3-saucer +;; WARN: Return type mismatch symbol vs object. +(defmethod proj-event-handler ((this gun-yellow-3-saucer) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('activate) + (go (method-of-object this spinning)) + ) + (('query) + (let ((v1-3 (the-as gun-yellow-3-event-msg (-> arg3 param 0)))) + (set! (-> v1-3 activated?) (-> this activated?)) + (set! (-> v1-3 finished?) (-> this finished?)) + ) + ) + (else + (call-parent-method this arg0 arg1 arg2 arg3) + ) + ) + #t + ) + +;; definition for method 39 of type gun-yellow-3-saucer +;; WARN: Return type mismatch object vs none. +(defmethod projectile-method-39 ((this gun-yellow-3-saucer)) + (when (logtest? (-> this root status) (collide-status touch-surface)) + (if (-> this asleep?) + (go (method-of-object this impact-explode)) + (call-parent-method this) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate moving (gun-yellow-3-saucer) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (if (and (time-elapsed? (-> self state-time) (-> self total-float-time)) + (not (and (-> self next-state) (= (-> self next-state name) 'navigating))) + ) + (go-virtual navigating) + ) + (sound-play "yellow3-fire" :id (-> self snd-hum)) + (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) (* 131072.0 (seconds-per-frame))) + (let ((a0-7 gun-yellow-3-saucer-base-state)) + (when a0-7 + (let ((t9-3 (-> a0-7 trans))) + (if t9-3 + (t9-3) + ) + ) + ) + ) + (let ((t9-5 (-> (find-parent-state) trans))) + (if t9-5 + (t9-5) + ) + ) + (ja-post) + ) + ) + +;; failed to figure out what this is: +(defstate navigating (gun-yellow-3-saucer) + :virtual #t + :parent gun-yellow-3-saucer-base-state + :enter (behavior () + (init-antigrav self) + (set-time! (-> self state-time)) + (set! (-> self last-deflect-time) 0) + 0 + ) + :trans (behavior () + (sound-play "yellow3-fire" :id (-> self snd-hum)) + (let ((f0-1 (fmin 1.0 (* 0.033333335 (the float (- (current-time) (-> self state-time))))))) + 0.0 + (let ((f0-2 (lerp 409600.0 40960.0 f0-1))) + (vector-normalize! (-> self root transv) f0-2) + ) + ) + (let ((f0-4 (fmin 1.0 (* 0.004761905 (the float (- (current-time) (-> self state-time))))))) + (set! (-> self root transv y) (lerp (-> self root transv y) 0.0 f0-4)) + ) + (when (time-elapsed? (-> self last-deflect-time) (seconds 0.5)) + (let ((v1-19 (-> self root)) + (gp-0 (new 'stack-no-clear 'collide-query)) + ) + (-> v1-19 root-prim) + (set! (-> gp-0 start-pos quad) (-> v1-19 trans quad)) + (vector-normalize-copy! (-> gp-0 move-dist) (-> v1-19 transv) 40960.0) + (let ((v1-20 gp-0)) + (set! (-> v1-20 radius) 0.01) + (set! (-> v1-20 collide-with) (collide-spec backgnd)) + (set! (-> v1-20 ignore-process0) #f) + (set! (-> v1-20 ignore-process1) #f) + (set! (-> v1-20 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-20 action-mask) (collide-action solid)) + ) + (let ((f0-7 (fill-and-probe-using-line-sphere *collide-cache* gp-0))) + (when (and (>= f0-7 0.0) (< f0-7 1.0)) + (let ((s5-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> gp-0 best-other-tri normal) 1.0)) + (gp-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> self root transv) 1.0)) + ) + 0.0 + (set! (-> s5-0 y) 0.0) + (vector-normalize! s5-0 1.0) + (vector-dot s5-0 gp-1) + (cond + (#f + (vector-float*! (-> self root transv) (-> self root transv) -1.0) + ) + (else + (vector-reflect! gp-1 gp-1 s5-0) + (set! (-> gp-1 y) 0.0) + (vector-normalize-copy! (-> self root transv) gp-1 32768.0) + (set-time! (-> self last-deflect-time)) + ) + ) + ) + ) + ) + ) + ) + (when (not (-> self firing?)) + (cond + ((time-elapsed? (-> self state-time) (seconds 1)) + (start-firing self) + ) + (else + ) + ) + ) + (find-targets self) + ((-> self move) self) + (projectile-method-39 self) + (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) (* 131072.0 (seconds-per-frame))) + (let ((v1-52 gun-yellow-3-saucer-base-state)) + (when v1-52 + (let ((t9-16 (-> v1-52 trans))) + (if t9-16 + (t9-16) + ) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate spinning (gun-yellow-3-saucer) + :virtual #t + :parent gun-yellow-3-saucer-base-state + :enter (behavior () + (set! (-> self activated?) #t) + (if (-> self asleep?) + (init-antigrav self) + ) + (if (not (-> self firing?)) + (start-firing self) + ) + (quaternion-identity! (-> self root quat)) + ) + :exit (behavior () + (let ((f0-0 (get-remaining-player-ammo (pickup-type ammo-yellow)))) + 0.0 + (when (< 1.0 f0-0) + (let* ((f0-1 (fmin f0-0 (- 50.0 (-> self total-ammo-drained)))) + (f0-2 (fmax 0.0 f0-1)) + ) + (adjust-player-ammo (- f0-2) (pickup-type ammo-yellow)) + ) + (truncate-player-ammo (pickup-type ammo-yellow)) + ) + ) + ) + :trans (behavior () + (sound-play "yellow3-fire" :id (-> self snd-hum)) + (quaternion-rotate-local-y! (-> self root quat) (-> self root quat) (* 131072.0 (seconds-per-frame))) + (find-targets self) + (let ((v1-7 gun-yellow-3-saucer-base-state)) + (when v1-7 + (let ((t9-3 (-> v1-7 trans))) + (if t9-3 + (t9-3) + ) + ) + ) + ) + ) + ) + +;; definition for function gun-fire-yellow-3 +;; INFO: Used lq/sq +(defbehavior gun-fire-yellow-3 target () + (let ((gp-0 (-> self gun))) + (let ((s5-0 (-> self gun fire-dir-out)) + (s4-0 (-> self gun fire-point)) + (f30-0 409600.0) + ) + (talker-spawn-func (-> *talker-speech* 364) *entity-pool* (target-pos 0) (the-as region #f)) + (set! (-> s5-0 y) 0.6) + (vector-normalize! s5-0 1.0) + (when (handle->process (-> gp-0 gun 0 extra)) + (let ((s3-1 (new 'stack-no-clear 'gun-yellow-3-event-msg))) + (send-event (handle->process (-> gp-0 gun 0 extra)) 'query s3-1) + (when (not (-> s3-1 activated?)) + (send-event (handle->process (-> gp-0 gun 0 extra)) 'activate) + (return 0) + ) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 229 (seconds 0.2)) + (let ((s3-2 (new 'stack-no-clear 'projectile-init-by-other-params))) + (set! (-> s3-2 ent) (-> self entity)) + (set! (-> s3-2 charge) 1.0) + (set! (-> s3-2 options) (projectile-options po13)) + (logclear! (-> s3-2 options) (projectile-options po14 po15 po16)) + (set! (-> s3-2 pos quad) (-> s4-0 quad)) + (set! (-> s3-2 vel quad) (-> (vector-float*! (new 'stack-no-clear 'vector) s5-0 f30-0) quad)) + (set! (-> s3-2 notify-handle) (the-as handle #f)) + (set! (-> s3-2 owner-handle) (the-as handle #f)) + (set! (-> s3-2 target-handle) (the-as handle #f)) + (set! (-> s3-2 target-pos quad) (the-as uint128 0)) + (set! (-> s3-2 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-45 *game-info*) + (a0-30 (+ (-> v1-45 attack-id) 1)) + ) + (set! (-> v1-45 attack-id) a0-30) + (set! (-> s3-2 attack-id) a0-30) + ) + (set! (-> s3-2 timeout) (seconds 4)) + (set! (-> gp-0 gun 0 extra) + (ppointer->handle + (spawn-projectile gun-yellow-3-saucer s3-2 (ppointer->process (-> gp-0 gun)) *default-dead-pool*) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> self gun fire-dir-out quad)) + (set! (-> s4-1 y) 0.0) + (vector-normalize! s4-1 1.0) + (let ((t9-9 draw-beam) + (a0-38 (-> *part-id-table* 297)) + (a1-9 (-> gp-0 fire-point)) + (a2-5 s4-1) + ) + (t9-9 a0-38 a1-9 a2-5 #f) + (let ((s5-1 (new 'stack-no-clear 'matrix))) + (matrix-f-compose s5-1 s4-1 (the-as float a2-5)) + (set! (-> s5-1 trans quad) (-> gp-0 fire-point quad)) + (let ((v1-62 + (if (logtest? (-> *part-group-id-table* 100 flags) (sp-group-flag sp13)) + (part-tracker-spawn + part-tracker-subsampler + :to *entity-pool* + :group (-> *part-group-id-table* 100) + :mat-joint s5-1 + ) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 100) :mat-joint s5-1) + ) + ) + ) + (send-event (ppointer->process v1-62) 'clock self) + ) + ) + ) + ) + ) + ) + +;; definition for function gun-fire-yellow-2 +;; INFO: Used lq/sq +;; WARN: Return type mismatch (pointer process) vs (pointer gun-yellow-shot-2). +(defbehavior gun-fire-yellow-2 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 po17)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-12 *game-info*) + (a0-10 (+ (-> v1-12 attack-id) 1)) + ) + (set! (-> v1-12 attack-id) a0-10) + (set! (-> gp-0 attack-id) a0-10) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (vector-float*! (-> gp-0 vel) (-> s5-0 fire-dir-out) 819200.0) + (the-as + (pointer gun-yellow-shot-2) + (spawn-projectile gun-yellow-shot-2 gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*) + ) + ) + ) + +;; definition for function gun-fire-yellow-1 +;; INFO: Used lq/sq +;; WARN: Return type mismatch (pointer process) vs (pointer gun-yellow-shot). +(defbehavior gun-fire-yellow-1 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 po17)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle (send-event self 'get-vehicle))) + (let* ((v1-12 *game-info*) + (a0-10 (+ (-> v1-12 attack-id) 1)) + ) + (set! (-> v1-12 attack-id) a0-10) + (set! (-> gp-0 attack-id) a0-10) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (vector-float*! (-> gp-0 vel) (-> s5-0 fire-dir-out) 819200.0) + (the-as + (pointer gun-yellow-shot) + (spawn-projectile gun-yellow-shot gp-0 (ppointer->process (-> s5-0 gun)) *default-dead-pool*) + ) + ) + ) + +;; definition for function target-gun-can-fire-yellow? +;; WARN: disable def twice: 51. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defbehavior target-gun-can-fire-yellow? target ((arg0 pickup-type)) + (case arg0 + (((pickup-type gun-yellow-3)) + (cond + ((handle->process (-> self gun gun 0 extra)) + (let ((gp-0 (new 'stack-no-clear 'gun-yellow-3-event-msg))) + (set! (-> gp-0 finished?) #t) + (set! (-> gp-0 activated?) #f) + (send-event (handle->process (-> self gun gun 0 extra)) 'query gp-0) + (or (-> gp-0 finished?) (not (-> gp-0 activated?))) + ) + ) + (else + #t + ) + ) + ) + (else + #t + ) + ) + ) + +;; definition for function target-gun-fire-yellow +;; WARN: Return type mismatch object vs (pointer process). +(defbehavior target-gun-fire-yellow target ((arg0 pickup-type)) + (the-as (pointer process) (case arg0 + (((pickup-type gun-yellow-1)) + (gun-fire-yellow-1) + ) + (((pickup-type gun-yellow-2)) + (gun-fire-yellow-2) + ) + (((pickup-type gun-yellow-3)) + (gun-fire-yellow-3) + ) + ) + ) + ) + +;; definition for function someone-fire-yellow +;; INFO: Used lq/sq +(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 po13 po17)) + (logclear! (-> gp-0 options) (projectile-options po14 po15 po16)) + (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 target-handle) (the-as handle #f)) + (set! (-> gp-0 target-pos quad) (the-as uint128 0)) + (set! (-> gp-0 ignore-handle) (process->handle arg0)) + (let* ((v1-10 *game-info*) + (a0-9 (+ (-> v1-10 attack-id) 1)) + ) + (set! (-> v1-10 attack-id) a0-9) + (set! (-> gp-0 attack-id) a0-9) + ) + (set! (-> gp-0 timeout) (seconds 4)) + (vector-normalize-copy! (-> gp-0 vel) arg2 819200.0) + (spawn-projectile gun-yellow-shot-2 gp-0 arg0 *default-dead-pool*) + ) + ) + +;; definition for method 24 of type gun-yellow-shot +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-24 ((this gun-yellow-shot)) + (draw-beam (-> this muzzle-flash-part) (-> this tail-pos) (-> this starting-dir) #f) + 0 + (none) + ) + +;; definition for method 25 of type gun-yellow-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-25 ((this gun-yellow-shot)) + (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 (-> this root trans)) + (a1-0 (-> this tail-pos)) + (gp-1 (vector-! (new 'stack-no-clear 'vector) s4-0 a1-0)) + ) + (let ((f30-0 (vector-length gp-1))) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (let ((v1-4 a1-0)) + (let ((a0-2 gp-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 (&-> s3-0 quad) vf6) + (draw-main-shot this a1-0 gp-1) + (vector-normalize! gp-1 1.0) + (spawn-particles this s3-0) + ) + (let ((s3-1 (new 'stack-no-clear 'matrix)) + (f30-1 (fmin 1.0 (* 0.000015258789 f30-0))) + (f28-0 (-> *part-id-table* 267 init-specs 3 initial-valuef)) + ) + (forward-up->inv-matrix s3-1 gp-1 *up-vector*) + (set! (-> s3-1 trans quad) (-> s4-0 quad)) + (gun-yellow-shot-method-42 this f30-1 f28-0 s3-1) + ) + ) + (let ((f0-3 (vector-dot gp-1 (-> (camera-matrix) fvec)))) + (when (< 0.0 f0-3) + (let ((f2-0 (* f0-3 f0-3)) + (f0-4 (-> *part-id-table* 266 init-specs 8 initial-valuef)) + (f1-3 (-> *part-id-table* 266 init-specs 8 random-rangef)) + ) + (set! (-> *part-id-table* 266 init-specs 8 initial-valuef) (* f0-4 f2-0)) + (set! (-> *part-id-table* 266 init-specs 8 random-rangef) (* f1-3 f2-0)) + (set! (-> *part-id-table* 266 init-specs 8 initial-valuef) f0-4) + (set! (-> *part-id-table* 266 init-specs 8 random-rangef) f1-3) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 37 of type gun-yellow-shot +(defmethod deal-damage! ((this gun-yellow-shot) (arg0 process) (arg1 event-message-block)) + (if (and (logtest? (process-mask guard) (-> arg0 mask)) + (not (-> *setting-control* user-current gun-target-guards?)) + ) + (set! (-> this damage) 0.0) + ) + (let ((t9-0 (method-of-type projectile deal-damage!))) + (when (t9-0 this arg0 arg1) + (+! (-> *game-info* shots-hit 0) 1.0) + (set! (-> this hit-actor?) #t) + #t + ) + ) + ) + +;; definition for method 26 of type gun-yellow-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-26 ((this gun-yellow-shot)) + (let ((v1-8 + (cond + ((-> this hit-actor?) + (cond + ((logtest? (-> *part-group-id-table* 102 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + ) + ) + ((logtest? (-> *part-group-id-table* 101 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 101)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 101)) + ) + ) + ) + ) + (send-event (ppointer->process v1-8) 'clock this) + ) + 0 + (none) + ) + +;; definition for method 28 of type gun-yellow-shot +;; WARN: Return type mismatch sound-id vs none. +(defmethod play-impact-sound ((this gun-yellow-shot) (arg0 projectile-options)) + (let ((v1-0 arg0)) + (cond + ((zero? v1-0) + (sound-play "yellow-shot-fir") + ) + ((= v1-0 (projectile-options po0)) + (sound-play "yellow-gun-burn") + ) + ((= v1-0 (projectile-options po1)) + (sound-play "yellow-shot-fiz") + ) + (else + (sound-play "yellow-shot-std" :id (-> this sound-id) :position (-> this root trans)) + ) + ) + ) + (none) + ) + +;; definition for method 28 of type gun-yellow-shot-3 +;; WARN: Return type mismatch int vs none. +(defmethod play-impact-sound ((this gun-yellow-shot-3) (arg0 projectile-options)) + 0 + (none) + ) + +;; definition for method 28 of type gun-yellow-shot-2 +;; WARN: Return type mismatch int vs none. +(defmethod play-impact-sound ((this gun-yellow-shot-2) (arg0 projectile-options)) + (let ((v1-0 arg0)) + (cond + ((zero? v1-0) + (sound-play "yellow2-fire") + ) + ((= v1-0 (projectile-options po0)) + (sound-play "yellow2-burn") + ) + ((= v1-0 (projectile-options po1)) + ) + ((not (-> this hit-yet?)) + (sound-play-by-name + (static-sound-name "yellow2-trail") + (-> this snd-trail) + 1024 + (the int + (* 1524.0 + (lerp 1.0 0.1 (fmax 0.0 (fmin 1.0 (* 0.011111111 (the float (- (current-time) (-> this last-hit-time))))))) + ) + ) + 0 + (sound-group) + #t + ) + ) + (else + (sound-play-by-name + (static-sound-name "yellow2-trail") + (-> this snd-trail) + 1024 + (the int (* 1524.0 (doppler-pitch-shift (-> this root trans) (-> this root transv)))) + 0 + (sound-group) + #t + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 38 of type gun-yellow-shot +(defmethod made-impact? ((this gun-yellow-shot)) + (let ((v1-0 (-> this root)) + (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) this) + (set! (-> a0-1 ignore-process1) (handle->process (-> this ignore-handle))) + (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? (-> this root status) (collide-status touch-actor)) + (set! (-> this hit-actor?) #t) + ) + #t + ) + ) + ) + +;; definition for function gun-yellow-shot-move +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun gun-yellow-shot-move ((arg0 gun-yellow-shot)) + (projectile-move-fill-line-sphere arg0) + (let ((s5-0 (-> arg0 root))) + (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 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) a1-5) + ) + (go (method-of-object arg0 impact)) + ) + ) + 0 + (none) + ) + +;; definition for symbol *last-hit-deflect-target-handle*, type (pointer process) +(define *last-hit-deflect-target-handle* (the-as (pointer process) #f)) + +;; definition for function gun-yellow-shot-do-deflect +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defbehavior gun-yellow-shot-do-deflect gun-yellow-shot-2 ((arg0 gun-yellow-shot-2) (arg1 vector) (arg2 vector) (arg3 vector)) + (local-vars + (sv-32 vector) + (sv-36 gun-yellow-shot-2) + (sv-40 process) + (sv-80 vector) + (sv-84 vector) + (sv-112 vector) + (sv-116 number) + (sv-120 int) + (sv-128 symbol) + (sv-136 handle) + (sv-1680 vector) + (sv-1712 vector) + (sv-1716 float) + (sv-1720 float) + (sv-1724 vector) + (sv-1744 vector) + (sv-1748 float) + (sv-1752 float) + ) + (let ((f0-1 (vector-dot arg2 arg3))) + (set! sv-32 (vector-float*! (new 'stack-no-clear 'vector) arg3 (* -2.0 f0-1))) + ) + (vector+! arg1 arg2 sv-32) + (if (< 0.2 (-> arg1 y)) + (set! (-> arg1 y) (fmax 0.2 (-> arg2 y))) + ) + (let ((s4-0 arg0)) + (set! sv-36 s4-0) + (set! sv-40 (handle->process (-> sv-36 last-hit-enemy))) + (when (and (time-elapsed? (-> sv-36 last-collide-time) (seconds 0.05)) (rand-vu-percent? 0.75)) + (set! sv-80 (vector-normalize-copy! (new 'stack-no-clear 'vector) arg1 204800.0)) + (set! sv-84 (new 'stack-no-clear 'vector)) + (set! (-> sv-84 quad) (-> s4-0 root trans quad)) + (vector+! sv-84 sv-84 sv-80) + (set! (-> sv-84 w) 409600.0) + (set! (-> sv-80 y) 0.0) + (vector-normalize! sv-80 1.0) + (set! sv-112 (vector+! (new 'stack-no-clear 'vector) (-> s4-0 root trans) arg1)) + (set! sv-116 409600000000000000000000.0) + (set! sv-120 -55041728) + (set! sv-128 (the-as symbol #f)) + (set! sv-136 (the-as handle #f)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 384))) + (countdown (s2-0 (fill-actor-list-for-box *actor-hash* (the-as bounding-box sv-84) s3-0 384)) + (let* ((s1-0 (-> s3-0 s2-0)) + (v1-31 (if (type? s1-0 collide-shape) + s1-0 + ) + ) + ) + (when v1-31 + (let* ((s0-0 (-> v1-31 process)) + (s1-1 (if (type? s0-0 process-focusable) + s0-0 + ) + ) + ) + (when s1-1 + (when (and (!= s4-0 s1-1) + (!= s1-1 sv-40) + (not (focus-test? (the-as process-focusable s1-1) disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy civilian) (-> s1-1 mask)) + (and (logtest? (process-mask guard) (-> s1-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (when (or (not sv-128) + (logtest? (process-mask enemy guard) (-> s1-1 mask)) + (not (is-in-ignore-list? sv-36 (process->handle s1-1))) + ) + (set! sv-1680 (get-trans (the-as process-focusable s1-1) 3)) + (set! sv-1712 (vector-! (new 'stack-no-clear 'vector) sv-1680 (-> s4-0 root trans))) + (set! sv-1716 (the-as float 0.0)) + (set! (-> sv-1712 y) 0.0) + (set! sv-1720 (vector-normalize-ret-len! sv-1712 1.0)) + (set! sv-1716 (vector-dot sv-1712 sv-80)) + (when (or (< (the float sv-120) sv-1716) (and (< 0.707 sv-1716) (= sv-136 *last-hit-deflect-target-handle*))) + (set! sv-116 sv-1720) + (set! sv-120 (the int sv-1716)) + (set! (-> sv-112 quad) (-> sv-1680 quad)) + (set! sv-128 (logtest? (process-mask enemy) (-> s1-1 mask))) + (set! sv-136 (process->handle s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let* ((s2-1 *target*) + (s3-1 (if (type? s2-1 process-focusable) + s2-1 + ) + ) + ) + (when (and s3-1 (< (vector-vector-distance (get-trans s3-1 0) sv-84) (-> sv-84 w))) + (when (and (!= s4-0 s3-1) + (!= s3-1 sv-40) + (not (focus-test? s3-1 disable dead inactive gun-no-target)) + (or (logtest? (process-mask enemy civilian) (-> s3-1 mask)) + (and (logtest? (process-mask guard) (-> s3-1 mask)) (-> *setting-control* user-current gun-target-guards?)) + ) + ) + (when (or (not sv-128) + (logtest? (process-mask enemy guard) (-> s3-1 mask)) + (not (is-in-ignore-list? sv-36 (process->handle s3-1))) + ) + (set! sv-1724 (get-trans s3-1 3)) + (set! sv-1744 (vector-! (new 'stack-no-clear 'vector) sv-1724 (-> s4-0 root trans))) + (set! sv-1748 (the-as float 0.0)) + (set! (-> sv-1744 y) 0.0) + (set! sv-1752 (vector-normalize-ret-len! sv-1744 1.0)) + (set! sv-1748 (vector-dot sv-1744 sv-80)) + (when (or (< (the float sv-120) sv-1748) (and (< 0.707 sv-1748) (= sv-136 *last-hit-deflect-target-handle*))) + (set! sv-116 sv-1752) + (set! sv-120 (the int sv-1748)) + (set! (-> sv-112 quad) (-> sv-1724 quad)) + (set! sv-128 (logtest? (process-mask enemy) (-> s3-1 mask))) + (set! sv-136 (process->handle s3-1)) + ) + ) + ) + ) + ) + (vector-! arg1 sv-112 (-> s4-0 root trans)) + (set! *last-hit-deflect-target-handle* (the-as (pointer process) sv-136)) + ) + ) + (vector-normalize! arg1 546133.3) + (cond + ((time-elapsed? (-> arg0 last-hit-time) (seconds 0.3)) + ) + ((time-elapsed? (-> arg0 last-hit-time) (seconds 0.05)) + ) + ) + (sound-play "yellow2-ricco") + (set-time! (-> arg0 last-hit-time)) + (set! (-> arg0 hit-yet?) #t) + (none) + ) + +;; definition for function gun-yellow-deflect-reaction +(defun gun-yellow-deflect-reaction ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector)) + (cshape-reaction-update-state arg0 arg1 arg3) + (let ((s3-0 (the-as handle #f))) + (when (and (nonzero? (-> arg1 best-other-tri collide-ptr)) + (-> arg1 best-other-tri collide-ptr) + (let ((s1-0 (-> arg1 best-other-tri collide-ptr))) + (if (type? s1-0 collide-shape-prim) + s1-0 + ) + ) + ) + (let* ((s2-1 (-> arg1 best-other-tri collide-ptr)) + (a0-4 (if (type? s2-1 collide-shape-prim) + s2-1 + ) + ) + (v1-4 a0-4) + ) + (when v1-4 + (set! s3-0 (process->handle (-> (the-as collide-shape-prim a0-4) cshape process))) + (when (and (logtest? (collide-spec obstacle pusher) (-> (the-as collide-shape-prim v1-4) prim-core collide-as)) + (not (logtest? (collide-spec civilian enemy vehicle-sphere vehicle-mesh-probeable) + (-> (the-as collide-shape-prim v1-4) prim-core collide-as) + ) + ) + ) + (let ((v1-7 (-> arg0 process))) + (set! (-> (the-as gun-yellow-shot-2 v1-7) actor-deflect?) #t) + ) + (set! s3-0 (the-as handle #f)) + ) + ) + ) + ) + (let ((s2-2 (the-as gun-yellow-shot-2 (-> arg0 process)))) + (on-impact s2-2 s3-0) + (set! (-> s2-2 delay-attack) 0) + ) + ) + 0 + (gun-yellow-shot-do-deflect (the-as gun-yellow-shot-2 (-> arg0 process)) arg2 arg3 (-> arg0 surface-normal)) + (-> arg0 status) + ) + +;; definition for method 30 of type gun-yellow-shot +;; WARN: Return type mismatch int vs none. +(defmethod setup-collision! ((this gun-yellow-shot)) + (let ((s5-0 (new 'process 'collide-shape-moving this (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 pusher shield) + ) + (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 pusher shield) + ) + (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 pusher shield) + ) + (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! (-> this root) s5-0) + ) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + 0 + (none) + ) + +;; definition for method 37 of type gun-yellow-shot-2 +(defmethod deal-damage! ((this gun-yellow-shot-2) (arg0 process) (arg1 event-message-block)) + (if (> (-> this max-actor-deflect-count) 0) + ((method-of-type projectile deal-damage!) this arg0 arg1) + ) + ) + +;; definition for function gun-yellow-shot-2-move +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun gun-yellow-shot-2-move ((arg0 gun-yellow-shot-2)) + (with-pp + (projectile-move-fill-line-sphere arg0) + (let ((s5-0 (-> arg0 root))) + (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 (not (handle->process (-> arg0 last-hit-enemy))) + (set! (-> arg0 delay-attack) 0) + 0 + ) + (if (and (> (-> arg0 delay-attack) 0) (time-elapsed? (-> arg0 delay-attack) (seconds 0.1))) + (logior! (-> s5-0 status) (collide-status touch-actor)) + ) + (when (or (logtest? (-> s5-0 status) (collide-status touch-surface)) + (logtest? (-> s5-0 status) (collide-status touch-actor)) + ) + (let ((s2-0 #f) + (s3-0 #f) + (s4-1 (the-as object #f)) + ) + (when (logtest? (-> s5-0 status) (collide-status touch-actor)) + (cond + ((-> arg0 actor-deflect?) + (set! (-> arg0 actor-deflect?) #f) + ) + ((> (-> arg0 max-actor-deflect-count) 0) + (let ((a0-16 (handle->process (-> arg0 last-hit-enemy)))) + (when a0-16 + (set! s2-0 #t) + (let ((a1-5 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-5 from) (process->ppointer pp)) + (set! (-> a1-5 num-params) 0) + (set! (-> a1-5 message) 'prevent-bounce?) + (set! s4-1 (send-event-function a0-16 a1-5)) + ) + ) + ) + ) + (else + (set! s4-1 #t) + ) + ) + ) + (when s2-0 + (when (> (-> arg0 delay-attack) 0) + ) + (handle-impact arg0 (-> arg0 last-hit-enemy)) + ) + (if (and (> (-> arg0 delay-attack) 0) (and (time-elapsed? (-> arg0 delay-attack) (seconds 0.1)) s2-0 (not s4-1))) + (set! s3-0 #t) + ) + (when s3-0 + (let ((t9-4 gun-yellow-shot-do-deflect) + (a0-23 arg0) + (a1-7 (-> arg0 root transv)) + (a2-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a2-1 quad) (-> arg0 root transv quad)) + (t9-4 a0-23 a1-7 a2-1 (-> arg0 delay-norm)) + ) + ) + (set! (-> arg0 hit-actor?) (the-as symbol s4-1)) + ) + (set! (-> arg0 delay-attack) 0) + (let ((v1-57 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> arg0 tail-pos) (-> s5-0 trans)) 2048.0)) + (a1-10 (-> arg0 hit-pos)) + ) + (set! (-> a1-10 quad) (-> s5-0 trans quad)) + (vector+! a1-10 a1-10 v1-57) + (move-to-point! (-> arg0 root) a1-10) + ) + (cond + ((-> arg0 hit-actor?) + (go (method-of-object arg0 impact)) + ) + (else + (set-time! (-> arg0 last-collide-time)) + (launch-particles (-> *part-id-table* 272) (-> arg0 hit-pos)) + (launch-particles (-> *part-id-table* 273) (-> arg0 hit-pos)) + (let ((a0-32 (new 'stack-no-clear 'vector))) + (set! (-> a0-32 quad) (-> arg0 root transv quad)) + (vector-normalize! a0-32 65536.0) + ) + (vector+! (-> arg0 tail-pos) (-> arg0 root trans) (-> arg0 root transv)) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 31 of type gun-yellow-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod init-proj-settings! ((this gun-yellow-shot)) + (+! (-> *game-info* shots-fired 0) 1.0) + (set! (-> this hit-actor?) #f) + (set! (-> this tail-pos quad) (-> this root trans quad)) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1)) + (set! (-> this attack-mode) 'eco-yellow) + (set! (-> this max-speed) 819200.0) + (set! (-> this move) gun-yellow-shot-move) + (set! (-> this timeout) (seconds 3)) + (set! (-> this sound-id) (new-sound-id)) + (set! (-> this damage) 2.0) + (if (logtest? (game-secrets gun-upgrade-yellow-1) (-> *game-info* secrets)) + (set! (-> this damage) 3.0) + ) + (logior! (-> this options) (projectile-options po13)) + (set! (-> this muzzle-flash-part) (-> *part-id-table* 268)) + (set! (-> this main-shot-part) (-> *part-id-table* 264)) + (set! (-> this shot-aim-part) (-> *part-id-table* 267)) + (set! (-> this shot-ring-part) (-> *part-id-table* 266)) + 0 + (none) + ) + +;; definition for method 31 of type gun-yellow-shot-2 +;; WARN: Return type mismatch (pointer process) vs none. +(defmethod init-proj-settings! ((this gun-yellow-shot-2)) + (call-parent-method this) + (set! (-> this actor-deflect?) #f) + (set! (-> this last-hit-enemy) (the-as handle #f)) + (set! (-> this damage) 1.5) + (if (logtest? (game-secrets gun-upgrade-yellow-2) (-> *game-info* secrets)) + (set! (-> this damage) 2.0) + ) + (set! (-> this snd-trail) (new-sound-id)) + (set! (-> this hit-yet?) #f) + (sound-play "yellow2-trail" :id (-> this snd-trail) :pitch 1) + (set! (-> this last-collide-time) 0) + (set! (-> this move) gun-yellow-shot-2-move) + (set! (-> this snd-whoosh) (new-sound-id)) + (dotimes (v1-9 6) + (set! (-> this ignore-list v1-9 hand) (the-as handle #f)) + ) + (set! (-> this max-actor-deflect-count) 4) + (set! (-> this timeout) (seconds 3)) + (when (logtest? (game-secrets gun-upgrade-yellow-2) (-> *game-info* secrets)) + (set! (-> this max-actor-deflect-count) 7) + (set! (-> this timeout) (seconds 5)) + ) + (set! (-> this muzzle-flash-part) (-> *part-id-table* 274)) + (sound-play "yellow2-shot" :pitch 1) + (let ((s5-1 (new 'stack-no-clear 'light-trail-tracker-spawn-params))) + (set! (-> s5-1 tracked-obj) (process->handle this)) + (set! (-> s5-1 appearance) *yellow-shot-2-trail*) + (set! (-> s5-1 max-num-crumbs) (the int (* 0.25 (the float (-> s5-1 appearance max-age))))) + (set! (-> s5-1 track-immediately?) #t) + (let* ((v1-34 (estimate-light-trail-mem-usage + (the-as uint (-> s5-1 max-num-crumbs)) + (the-as uint (= (-> s5-1 appearance lie-mode) 3)) + ) + ) + (gp-1 (get-process *default-dead-pool* light-trail-tracker-projectile (+ v1-34 8192) 1)) + ) + (when gp-1 + (let ((t9-9 (method-of-type process activate))) + (t9-9 gp-1 *target* "light-trail" (the-as pointer #x70004000)) + ) + (run-now-in-process gp-1 light-trail-tracker-init-by-other s5-1) + (-> gp-1 ppointer) + ) + ) + ) + (none) + ) + +;; definition for method 47 of type gun-yellow-shot-2 +(defmethod add-to-ignore-list! ((this gun-yellow-shot-2) (arg0 handle)) + (when (and arg0 (not (is-in-ignore-list? this arg0))) + (dotimes (v1-3 6) + (when (not (handle->process (-> this ignore-list v1-3 hand))) + (set! (-> this ignore-list v1-3 hand) arg0) + (set-time! (-> this ignore-list v1-3 time)) + (return 0) + ) + ) + (the-as int #f) + ) + ) + +;; definition for method 46 of type gun-yellow-shot-2 +(defmethod is-in-ignore-list? ((this gun-yellow-shot-2) (arg0 handle)) + (if (not arg0) + (return #f) + ) + (dotimes (v1-2 6) + (if (and (-> this ignore-list v1-2 hand) (time-elapsed? (-> this ignore-list v1-2 time) (seconds 0.15))) + (set! (-> this ignore-list v1-2 hand) (the-as handle #f)) + ) + ) + (dotimes (v1-5 6) + (if (= arg0 (-> this ignore-list v1-5 hand)) + (return #t) + ) + ) + #f + ) + +;; definition for method 45 of type gun-yellow-shot-2 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs object. +(defmethod handle-impact ((this gun-yellow-shot-2) (arg0 handle)) + (when (> (-> this max-actor-deflect-count) 0) + (let ((s5-0 (handle->process arg0))) + (when s5-0 + (if (and (logtest? (process-mask guard) (-> s5-0 mask)) + (not (-> *setting-control* user-current gun-target-guards?)) + ) + (set! (-> this damage) 0.0) + ) + (when (time-elapsed? (-> this last-attack-time) (seconds 0.25)) + (let* ((v1-15 *game-info*) + (a0-7 (+ (-> v1-15 attack-id) 1)) + ) + (set! (-> v1-15 attack-id) a0-7) + (set! (-> this attack-id) a0-7) + ) + ) + (when (deal-damage! this s5-0 (the-as event-message-block #f)) + (set-time! (-> this last-attack-time)) + (+! (-> this enemy-hit-count) 1) + (when (and (< 1 (-> this enemy-hit-count)) (< (-> this enemy-hit-count) 4)) + (adjust-player-ammo -1.0 (pickup-type ammo-yellow)) + (when (>= 0.0 (get-remaining-player-ammo (pickup-type ammo-yellow))) + (set! (-> this timeout) 0) + 0 + ) + ) + (let ((v1-28 (-> this notify-handle))) + (send-event (handle->process v1-28) 'notify 'attack s5-0) + ) + (if (>= (-> this enemy-hit-count) 1) + (set! (-> this damage) 1.0) + ) + (cond + ((logtest? (-> *part-group-id-table* 102 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 102)) + ) + ) + (let ((v0-0 (+ (-> this max-actor-deflect-count) -1))) + (set! (-> this max-actor-deflect-count) v0-0) + v0-0 + ) + ) + ) + ) + ) + ) + +;; definition for method 44 of type gun-yellow-shot-2 +;; WARN: Return type mismatch int vs object. +(defmethod on-impact ((this gun-yellow-shot-2) (arg0 handle)) + (let ((a1-1 (-> this last-hit-enemy))) + (set! (-> this last-hit-enemy) arg0) + (if (and (!= a1-1 arg0) (> (-> this delay-attack) 0)) + (handle-impact this a1-1) + ) + ) + (set! (-> this delay-attack) 0) + (add-to-ignore-list! this arg0) + ) + +;; definition for method 36 of type gun-yellow-shot-2 +(defmethod handle-proj-hit! ((this gun-yellow-shot-2) (arg0 process) (arg1 event-message-block)) + (cond + ((-> this hit-actor?) + (call-parent-method this arg0 arg1) + ) + (else + (let ((s4-1 (the-as object (-> arg1 param 0)))) + (when (and (!= arg0 (handle->process (-> this last-hit-enemy))) + (!= arg0 (send-event *target* 'get-vehicle)) + (not (is-in-ignore-list? this (process->handle arg0))) + ) + (new 'stack-no-clear 'vector) + (let ((s3-0 (-> this delay-norm)) + (s1-0 (-> (the-as touching-shapes-entry s4-1) head)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (get-intersect-point s2-0 s1-0 (-> this root) (the-as touching-shapes-entry s4-1)) + (let ((v1-16 + (get-touched-prim + s1-0 + ((method-of-type touching-shapes-entry get-touched-shape) (the-as touching-shapes-entry s4-1) (-> this root)) + (the-as touching-shapes-entry s4-1) + ) + ) + ) + (when v1-16 + (vector-! s3-0 s2-0 (the-as vector (-> v1-16 prim-core))) + (vector-normalize! s3-0 1.0) + (on-impact this (process->handle arg0)) + (set-time! (-> this delay-attack)) + ) + ) + ) + ) + ) + #t + ) + ) + ) + +;; failed to figure out what this is: +(defstate impact (gun-yellow-shot-2) + :virtual #t + :enter (behavior () + (sound-stop (-> self snd-trail)) + (let ((t9-2 (-> (find-parent-state) enter))) + (if t9-2 + (t9-2) + ) + ) + ) + ) + +;; definition for method 31 of type gun-yellow-shot-3 +;; INFO: Used lq/sq +;; WARN: Return type mismatch sparticle-launcher vs none. +(defmethod init-proj-settings! ((this gun-yellow-shot-3)) + (+! (-> *game-info* shots-fired 0) 1.0) + (set! (-> this hit-actor?) #f) + (set! (-> this tail-pos quad) (-> this root trans quad)) + (let ((f0-2 (vector-vector-xz-distance (target-pos 0) (-> this root trans)))) + (cpad-set-buzz! + (-> *cpad-list* cpads 0) + 1 + (the int (* 255.0 (lerp-scale-clamp 0.5 0.0 f0-2 40960.0 245760.0))) + (seconds 0.1) + ) + ) + (set! (-> this attack-mode) 'eco-yellow) + (set! (-> this max-speed) 819200.0) + (set! (-> this move) gun-yellow-shot-move) + (set! (-> this timeout) (seconds 3)) + (set! (-> this sound-id) (new-sound-id)) + (set! (-> this damage) 2.0) + (when (logtest? (game-feature feature22) (-> *game-info* features)) + (set! (-> this damage) (* 2.0 (-> this damage))) + (set! (-> this vehicle-impulse-factor) (* 0.5 (-> this vehicle-impulse-factor))) + ) + (logior! (-> this options) (projectile-options po13)) + (set! (-> this muzzle-flash-part) (-> *part-id-table* 275)) + (set! (-> this main-shot-part) (-> *part-id-table* 276)) + (set! (-> this shot-aim-part) (-> *part-id-table* 278)) + (set! (-> this shot-ring-part) (-> *part-id-table* 266)) + (none) + ) + +;; definition for method 30 of type gun-yellow-shot-2 +;; WARN: Return type mismatch int vs none. +(defmethod setup-collision! ((this gun-yellow-shot-2)) + (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) gun-yellow-deflect-reaction) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate)) + (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 pusher shield) + ) + (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-12 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-12 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-12 prim-core collide-with) + (collide-spec backgnd bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher shield) + ) + (set! (-> v1-12 prim-core action) (collide-action solid)) + (set-vector! (-> v1-12 local-sphere) 0.0 0.0 0.0 819.2) + ) + (let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-14 prim-core collide-as) (collide-spec projectile)) + (set! (-> v1-14 prim-core collide-with) + (collide-spec bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list pusher shield) + ) + (set-vector! (-> v1-14 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-17 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-17 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-17 prim-core collide-with)) + ) + (set! (-> s5-0 max-iteration-count) (the-as uint 1)) + (set! (-> s5-0 event-self) 'touched) + (set! (-> this root) s5-0) + ) + (set! (-> this root pat-ignore-mask) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1 :board #x1) + ) + 0 + (none) + ) + +;; definition for method 41 of type gun-yellow-shot +;; WARN: Return type mismatch int vs none. +(defmethod draw-main-shot ((this gun-yellow-shot) (arg0 vector) (arg1 vector)) + (let ((f30-0 (-> *part-id-table* 264 init-specs 4 initial-valuef))) + (set! (-> *part-id-table* 264 init-specs 4 initial-valuef) (fmin f30-0 (vector-length arg1))) + (draw-beam (-> this main-shot-part) arg0 arg1 #f) + (set! (-> *part-id-table* 264 init-specs 4 initial-valuef) f30-0) + ) + 0 + (none) + ) + +;; definition for method 41 of type gun-yellow-shot-2 +;; WARN: Return type mismatch int vs none. +(defmethod draw-main-shot ((this gun-yellow-shot-2) (arg0 vector) (arg1 vector)) + 0 + (none) + ) + +;; definition for method 10 of type gun-yellow-shot-2 +(defmethod deactivate ((this gun-yellow-shot-2)) + "Make a process dead, clean it up, remove it from the active pool, and return to dead pool." + (sound-stop (-> this snd-trail)) + (call-parent-method this) + (none) + ) + +;; definition for method 41 of type gun-yellow-shot-3 +;; WARN: Return type mismatch int vs none. +(defmethod draw-main-shot ((this gun-yellow-shot-3) (arg0 vector) (arg1 vector)) + (let ((f30-0 (-> *part-id-table* 276 init-specs 4 initial-valuef))) + (set! (-> *part-id-table* 276 init-specs 4 initial-valuef) (fmin f30-0 (vector-length arg1))) + (draw-beam (-> this main-shot-part) arg0 arg1 #f) + (set! (-> *part-id-table* 276 init-specs 4 initial-valuef) f30-0) + ) + 0 + (none) + ) + +;; definition for method 42 of type gun-yellow-shot +;; WARN: Return type mismatch int vs none. +(defmethod gun-yellow-shot-method-42 ((this gun-yellow-shot) (arg0 float) (arg1 float) (arg2 matrix)) + (set! (-> *part-id-table* 267 init-specs 3 initial-valuef) (* arg0 arg1)) + (launch-particles (-> *part-id-table* 267) arg2 :origin-is-matrix #t) + (set! (-> *part-id-table* 267 init-specs 3 initial-valuef) arg1) + 0 + (none) + ) + +;; definition for method 42 of type gun-yellow-shot-2 +;; WARN: Return type mismatch int vs none. +(defmethod gun-yellow-shot-method-42 ((this gun-yellow-shot-2) (arg0 float) (arg1 float) (arg2 matrix)) + 0 + (none) + ) + +;; definition for method 42 of type gun-yellow-shot-3 +;; WARN: Return type mismatch int vs none. +(defmethod gun-yellow-shot-method-42 ((this gun-yellow-shot-3) (arg0 float) (arg1 float) (arg2 matrix)) + (set! (-> *part-id-table* 278 init-specs 3 initial-valuef) (* arg0 arg1)) + (set! (-> *part-id-table* 278 init-specs 3 initial-valuef) arg1) + 0 + (none) + ) + +;; definition for method 25 of type gun-yellow-shot-2 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-25 ((this gun-yellow-shot-2)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let* ((s5-0 (-> this root trans)) + (a1-0 (-> this tail-pos)) + (s4-1 (vector-! (new 'stack-no-clear 'vector) s5-0 a1-0)) + (f30-0 (vector-length s4-1)) + ) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (let ((v1-4 a1-0)) + (let ((a0-2 s4-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 (&-> s3-0 quad) vf6) + (draw-main-shot this a1-0 s4-1) + (vector-normalize! s4-1 1.0) + (launch-particles (-> *part-id-table* 270) s3-0) + ) + (let ((s3-1 (new 'stack-no-clear 'matrix)) + (f30-1 (fmin 1.0 (* 0.000015258789 f30-0))) + (f28-0 (-> *part-id-table* 267 init-specs 3 initial-valuef)) + ) + (forward-up->inv-matrix s3-1 s4-1 *up-vector*) + (set! (-> s3-1 trans quad) (-> s5-0 quad)) + (gun-yellow-shot-method-42 this f30-1 f28-0 s3-1) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 43 of type gun-yellow-shot +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod spawn-particles ((this gun-yellow-shot) (arg0 vector)) + (launch-particles (-> *part-id-table* 265) arg0) + 0 + (none) + ) + +;; definition for method 43 of type gun-yellow-shot-2 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod spawn-particles ((this gun-yellow-shot-2) (arg0 vector)) + (launch-particles (-> *part-id-table* 270) arg0) + 0 + (none) + ) + +;; definition for method 43 of type gun-yellow-shot-3 +;; WARN: Return type mismatch int vs none. +(defmethod spawn-particles ((this gun-yellow-shot-3) (arg0 vector)) + 0 + (none) + ) + +;; definition for method 26 of type gun-yellow-shot-3 +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod projectile-method-26 ((this gun-yellow-shot-3)) + (let ((v1-8 + (cond + ((-> this hit-actor?) + (cond + ((logtest? (-> *part-group-id-table* 99 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 99)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 99)) + ) + ) + ) + ((logtest? (-> *part-group-id-table* 98 flags) (sp-group-flag sp13)) + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 98)) + ) + (else + (set! (-> *launch-matrix* trans quad) (-> this root trans quad)) + (part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 98)) + ) + ) + ) + ) + (send-event (ppointer->process v1-8) 'clock this) + ) + 0 + (none) + ) + + + + diff --git a/test/offline/config/jak3/config.jsonc b/test/offline/config/jak3/config.jsonc index 1ac9022a47..d29c79cc56 100644 --- a/test/offline/config/jak3/config.jsonc +++ b/test/offline/config/jak3/config.jsonc @@ -136,7 +136,9 @@ // idle-control "(method 10 idle-control)", // changes pp // aligner - "(method 9 align-control)" + "(method 9 align-control)", + // gun-red-shot + "gun-fire-red-3" ], "skip_compile_states": {}